@font-face {
  font-family: 'Cutive Mono';
  src: url('/fonts/cutive-mono.woff2') format('woff2');
  font-display: swap;
}

* {
  box-sizing: border-box;
}

/* Several elements below set their own `display` (flex, for layout) which would otherwise
   silently outrank the `hidden` attribute's UA-stylesheet rule at equal/higher specificity -
   confirmed by rendering this in a real browser during this redesign (the clip modal and the
   offline/gate messages stayed visible despite `hidden` being set). This makes `el.hidden = true`
   always win, regardless of what else targets the same element. */
[hidden] {
  display: none !important;
}

html, body {
  margin: 0;
  min-height: 100%;
  background: #000;
  color: #ccc;
  font-family: 'Cutive Mono', monospace;
}

body {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 100vh;
}

a {
  color: inherit;
}

/* --- shared header/footer, used by every page --- */
header {
  width: 100%;
  max-width: 1600px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.6rem 1.25rem;
  padding: 1.1rem 1.25rem;
  font-size: 0.85rem;
}

header a {
  color: #888;
  text-decoration: none;
}

header a:hover {
  color: #ccc;
}

.spacer {
  flex: 1;
}

footer {
  width: 100%;
  max-width: 1600px;
  box-sizing: border-box;
  text-align: center;
  font-size: 0.7rem;
  color: #555;
  padding: 1.5rem 1.25rem 2.5rem;
}

footer a {
  color: #555;
  text-decoration: none;
}

footer a:hover {
  color: #888;
}

/* --- index (player) page --- */
main {
  width: 100%;
  max-width: 1600px;
  padding: 0 1.25rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}

#player {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #000;
  border-radius: 4px;
  overflow: hidden;
}

/* Toggled on <main> by the "compact" button - #player etc. keep width:100% (relative to
   <main>'s own box, already width-constrained below), so capping their max-width here just
   shrinks them within it; <main>'s existing align-items:center re-centers them automatically. */
main.narrow #player,
main.narrow #controls,
main.narrow #switcher,
main.narrow #multiview-controls,
main.narrow #split-view,
main.narrow #recent-clips {
  max-width: 820px;
}

#video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  background: #000;
}

#offline,
#gate {
  position: absolute;
  inset: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  color: #888;
  text-align: center;
  font-size: 0.9rem;
  padding: 1rem;
}

#gate a {
  color: #ccc;
}

#controls {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
  color: #888;
  font-size: 0.8rem;
}

.icon-btn {
  background: none;
  border: 1px solid #333;
  color: #aaa;
  border-radius: 3px;
  padding: 0.4rem 0.7rem;
  font-family: inherit;
  font-size: 0.85rem;
  line-height: 1;
  cursor: pointer;
}

.icon-btn:hover {
  color: #fff;
  border-color: #666;
}

.icon-btn:disabled {
  opacity: 0.5;
  cursor: default;
}

.icon-btn.active {
  color: #fff;
  border-color: #888;
}

#volume {
  width: 90px;
  accent-color: #888;
}

#viewers {
  font-size: 0.75rem;
  color: #777;
  white-space: nowrap;
}

#switcher {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  font-size: 0.75rem;
  justify-content: center;
}

#switcher a {
  color: #666;
  text-decoration: none;
  padding: 0.25rem 0.6rem;
  border: 1px solid #2a2a2a;
  border-radius: 3px;
}

#switcher a:hover {
  color: #ccc;
  border-color: #555;
}

#switcher a.active {
  color: #fff;
  border-color: #888;
}

#multiview-controls {
  display: flex;
  gap: 0.5rem;
  font-size: 0.75rem;
}

#split-view {
  width: 100%;
  display: flex;
  gap: 0.5rem;
}

#split-view.horizontal {
  flex-direction: row;
  flex-wrap: wrap;
}

#split-view.horizontal .split-tile {
  flex: 1 1 0;
  min-width: 220px;
}

#split-view.vertical {
  flex-direction: column;
}

#split-view.vertical .split-tile {
  flex: 0 0 auto;
  width: 100%;
}

.split-tile {
  position: relative;
  aspect-ratio: 16 / 9;
  background: #000;
  border-radius: 4px;
  overflow: hidden;
}

.split-tile video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  background: #000;
}

.split-tile .tile-label {
  position: absolute;
  left: 0.4rem;
  top: 0.4rem;
  background: rgba(0, 0, 0, 0.65);
  color: #ccc;
  font-size: 0.7rem;
  padding: 0.15rem 0.45rem;
  border-radius: 3px;
  max-width: calc(100% - 0.8rem);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.split-tile .tile-mute-btn {
  position: absolute;
  right: 0.4rem;
  bottom: 0.4rem;
  background: rgba(0, 0, 0, 0.65);
  border: 1px solid #444;
  color: #ccc;
  border-radius: 3px;
  padding: 0.3rem 0.5rem;
  font-family: inherit;
  font-size: 0.75rem;
  cursor: pointer;
}

.split-tile .tile-mute-btn:hover {
  color: #fff;
  border-color: #777;
}

#recent-clips {
  width: 100%;
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

#recent-clips a {
  color: #999;
  text-decoration: none;
  border: 1px solid #2a2a2a;
  border-radius: 3px;
  padding: 0.35rem 0.65rem;
  font-size: 0.75rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 260px;
}

#recent-clips a:hover {
  color: #fff;
  border-color: #555;
}

/* --- clip modal --- */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 10;
}

.modal-box {
  background: #111;
  border: 1px solid #333;
  border-radius: 6px;
  padding: 1.25rem;
  width: 100%;
  max-width: 360px;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.modal-box h2 {
  margin: 0;
  font-size: 1rem;
  color: #eee;
}

.modal-box label {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  font-size: 0.8rem;
  color: #999;
}

.modal-box input[type='text'] {
  background: #000;
  border: 1px solid #333;
  border-radius: 3px;
  color: #eee;
  padding: 0.55rem 0.6rem;
  font-family: inherit;
  font-size: 0.85rem;
}

.modal-box input[type='range'] {
  accent-color: #888;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.6rem;
}

.btn-primary,
.btn-secondary {
  font-family: inherit;
  font-size: 0.8rem;
  border-radius: 3px;
  padding: 0.5rem 1rem;
  cursor: pointer;
}

.btn-secondary {
  background: none;
  border: 1px solid #333;
  color: #999;
}

.btn-secondary:hover {
  color: #ccc;
  border-color: #666;
}

.btn-primary {
  background: #ccc;
  border: 1px solid #ccc;
  color: #000;
  font-weight: bold;
}

.btn-primary:hover {
  background: #fff;
  border-color: #fff;
}

.btn-primary:disabled {
  opacity: 0.5;
  cursor: default;
}

/* --- responsive --- */
@media (max-width: 640px) {
  header {
    padding: 0.85rem 1rem;
    font-size: 0.8rem;
    gap: 0.5rem 1rem;
  }

  main {
    padding: 0 0.85rem;
    gap: 0.75rem;
  }

  #controls {
    font-size: 0.75rem;
    gap: 0.45rem;
  }

  .icon-btn {
    padding: 0.5rem 0.65rem;
  }

  #volume {
    width: 64px;
  }

  #recent-clips a {
    max-width: 45vw;
  }

  footer {
    padding: 1.25rem 1rem 2rem;
  }
}
