* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background: #0b0b0f;
  color: #e5e7eb;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

button {
  font-family: inherit;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

[hidden] {
  display: none !important;
}

/* ------------------------------------------------------------------ login */

.login {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 36px;
}

.card {
  width: 100%;
  max-width: 620px;
  background: #15151c;
  border: 1px solid #2a2a33;
  border-radius: 20px;
  padding: 48px;
  text-align: center;
}

.brand {
  font-size: 22px;
  color: #8b8b9a;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

h1 {
  margin: 18px 0 12px;
  font-size: 34px;
  font-weight: 600;
}

.subtitle {
  margin: 0 0 40px;
  font-size: 22px;
  line-height: 1.5;
  color: #a0a0b0;
}

.code-input {
  width: 100%;
  padding: 26px;
  font-size: 50px;
  letter-spacing: 0.4em;
  text-align: center;
  border-radius: 16px;
  border: 1px solid #3a3a46;
  background: #0d0d12;
  color: #fff;
  outline: none;
}

.code-input:focus {
  border-color: #38bdf8;
}

/* Reserved space for the auto-verify spinner (avoids layout jump). */
.verify-row {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 40px;
  margin-top: 32px;
}

.error {
  margin-top: 24px;
  padding: 18px;
  border-radius: 12px;
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.4);
  color: #fca5a5;
  font-size: 20px;
  line-height: 1.4;
}

.submit {
  margin-top: 32px;
  width: 100%;
  padding: 22px;
  border: none;
  border-radius: 16px;
  background: #0284c7;
  color: #fff;
  font-size: 26px;
  font-weight: 600;
}

.submit:hover:not(:disabled) {
  background: #0284c7cc;
}

/* --------------------------------------------------------------- channels */

.shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  max-width: none;
  padding: 20px 24px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  gap: 20px;
  flex-wrap: wrap;
}

.topbar .brand {
  font-size: 26px;
  font-weight: 700;
}

.topbar-status {
  display: flex;
  align-items: center;
  gap: 20px;
}

.pill {
  font-size: 20px;
  font-weight: 600;
  padding: 10px 20px;
  border-radius: 999px;
  background: #2a2a33;
  color: #cbd5e1;
}

.pill.streaming {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
}

.pill.idle {
  background: rgba(148, 163, 184, 0.15);
  color: #94a3b8;
}

.status-card {
  background: #15151c;
  border: 1px solid #2a2a33;
  border-radius: 18px;
  padding: 24px;
  margin-bottom: 24px;
}

.label {
  font-size: 18px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #8b8b9a;
  margin-bottom: 12px;
}

.row {
  display: flex;
  align-items: center;
  gap: 16px;
}

.row.muted {
  color: #a0a0b0;
  font-size: 22px;
}

.name {
  font-size: 30px;
  font-weight: 600;
}

.programme {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid #2a2a33;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.prog-title {
  font-size: 26px;
  color: #e5e7eb;
  font-weight: 500;
}

.prog-time {
  font-size: 22px;
  color: #8b8b9a;
}

.error-banner {
  margin-top: 16px;
  padding: 16px 20px;
  border-radius: 12px;
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.4);
  color: #fca5a5;
  font-size: 20px;
}

.channel-list {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}

.channel-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 20px;
  background: #121218;
  border: 1px solid #24242e;
  border-radius: 16px;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.channel-row:hover {
  border-color: #4aa3ff;
  background: #1c3d5e;
  box-shadow: 0 0 0 2px rgba(74, 163, 255, 0.35) inset;
}

.channel-meta {
  display: flex;
  align-items: center;
  gap: 32px;
  min-width: 0;
}

.logo {
  width: 96px;
  height: 96px;
  border-radius: 16px;
  object-fit: contain;
  background: #000;
}

.logo.placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 40px;
  color: #cbd5e1;
  background: #2a2a33;
}

.info {
  min-width: 0;
}

.info .name {
  font-size: 30px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.info .now {
  font-size: 22px;
  color: #d1d5db;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.info .time {
  font-size: 20px;
  color: #8b8b9a;
}

.watch-btn {
  flex-shrink: 0;
  padding: 16px 30px;
  border: none;
  border-radius: 14px;
  background: #0284c7;
  color: #fff;
  font-weight: 600;
  font-size: 24px;
}

.watch-btn:hover:not(:disabled) {
  background: #0284c7cc;
}

.watch-group {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-shrink: 0;
}

.spinner {
  width: 28px;
  height: 28px;
  border: 4px solid rgba(56, 189, 248, 0.25);
  border-top-color: #38bdf8;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  flex-shrink: 0;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.ghost {
  padding: 14px 26px;
  border: 1px solid #3a3a46;
  border-radius: 14px;
  background: transparent;
  color: #cbd5e1;
  font-size: 22px;
}

.ghost:hover:not(:disabled) {
  background: #24242e;
}

.empty {
  grid-column: 1 / -1;
  padding: 60px;
  text-align: center;
  color: #8b8b9a;
  font-size: 22px;
}

/* 2-column grid is designed for a wide TV screen; fall back to a single column
   on narrow/portrait windows. */
@media (max-width: 760px) {
  .channel-list {
    grid-template-columns: 1fr;
  }
}

/* ------------------------------------------------------------------ watch */

/* The watch page is a full-window app: a fixed header on top and the video.js
   player filling everything beneath it. */
.shell.watch {
  max-width: none;
  height: 100vh;
  padding: 0;
  background: #000;
}

/* Dynamic viewport height so the player actually fits between the iOS/Android
   browser toolbars instead of overflowing under them. */
@supports (height: 100dvh) {
  .shell.watch {
    height: 100dvh;
  }
}

.shell.watch .topbar {
  margin-bottom: 0;
  padding: 14px 24px;
  background: #0b0b0f;
  border-bottom: 1px solid #2a2a33;
  flex-shrink: 0;
}

.watch-title {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.watch-title .name {
  font-size: 30px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.watch-prog {
  display: flex;
  align-items: baseline;
  gap: 16px;
  min-width: 0;
}

.watch-prog .prog-title {
  font-size: 22px;
  color: #e5e7eb;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.watch-prog .prog-time {
  font-size: 20px;
  color: #8b8b9a;
  white-space: nowrap;
}

.topbar .spacer {
  flex: 1;
}

.track-select {
  padding: 12px 18px;
  border: 1px solid #3a3a46;
  border-radius: 14px;
  background: #121218;
  color: #e5e7eb;
  font-size: 22px;
  min-height: 56px;
}

.track-select:focus {
  outline: none;
  border-color: #38bdf8;
}

.subtitle-error {
  display: inline-block;
  padding: 8px 18px;
  border-radius: 999px;
  background: rgba(234, 179, 8, 0.12);
  border: 1px solid rgba(234, 179, 8, 0.4);
  color: #fde68a;
  font-size: 18px;
  white-space: nowrap;
}

/* Player fills all the space below the fixed header. */
.player-wrap {
  flex: 1;
  min-height: 0;
  width: 100%;
  background: #000;
  overflow: hidden;
}

.player-wrap .video-js {
  width: 100%;
  height: 100%;
}

/* danflix-style overlay: channel + programme name shown on mouse-over of the
   player, fading after a short pause in movement. */
.vjs-filename-overlay {
  position: absolute;
  top: 16px;
  left: 16px;
  padding: 10px 16px;
  background: rgba(0, 0, 0, 0.65);
  color: #fff;
  border-radius: 8px;
  display: none;
  z-index: 999;
  pointer-events: none;
}

.vjs-filename-overlay .name {
  font-size: 32px;
  font-weight: 600;
  line-height: 1.2;
}

.vjs-filename-overlay .prog {
  font-size: 26px;
  color: #d1d5db;
  line-height: 1.2;
}

.error-box .error {
  padding: 16px;
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.4);
  border-radius: 10px;
  color: #fca5a5;
  margin-bottom: 16px;
}

/* ---------------------------------------------------- video.js overrides
   Migrated from the danflix player's styling model: the control bar runs at
   font-size 3em, so every em-sized child inside it (buttons, icons, progress,
   menus) scales 3x against the 10px player root font — big, TV-friendly
   controls without per-element hacks. */
.video-js .vjs-control-bar {
  font-size: 3em !important;
}

.video-js .vjs-control-bar {
  background-color: rgba(0, 0, 0, 0.9) !important;
}

/* danflix highlight: buttons turn cornflowerblue on hover. */
.video-js .vjs-button:hover {
  background-color: cornflowerblue;
  cursor: pointer;
}

/* Raise the caption baseline above the enlarged control bar. With the 3em
   control-bar font the stock 3em bar becomes 9em (~90px) tall, so the default
   .vjs-text-track-display bottom: 3em would hide the lower line of 2-line cues
   behind the opaque bar. The cue is bottom-anchored (vtt.js) and grows UP from
   this baseline, so 10em (~100px) lifts the whole subtitle block clear of the
   bar and both lines stay visible. */
.video-js .vjs-text-track-display {
  bottom: 10em !important;
}

/* Cue color/background (font size is forced deterministically below). */
.vjs-text-track-display ::cue {
  color: #fff;
  background: rgba(0, 0, 0, 0.75);
}

/* Deterministic cue size for the JS-emulated text-track overlay (we set
   nativeTextTracks: false). video.js 8's TextTrackDisplay.updateDisplayState()
   MULTIPLIES the cue div's inline font-size by textTrackSettings.fontPercent on
   every subtitle refresh, and vtt.js REUSES the same cue DOM (cue.displayState)
   between refreshes. So any persistent fontPercent != 1 compounds → captions
   grow geometrically every time a new whisper cue is added. We never feed
   fontPercent (the old watch.js patch is gone), and this !important rule also
   beats video.js inline font-size (inline non-important loses to !important) so
   the size is fixed even if the CC Settings dialog is ever used. The em unit is
   relative to the player's root font-size, which video.js scales with player
   width, so captions size consistently on every screen. */
.video-js .vjs-text-track-display .vjs-text-track-cue {
  font-size: 3.75em !important;
}

.video-js .vjs-text-track-display .vjs-text-track-cue .vjs-text-track {
  font-size: 1em !important;
}

/* iOS native-fullscreen captions. */
video::cue {
  color: #fff;
  background: rgba(0, 0, 0, 0.75);
  font-size: 150%;
  text-shadow: 2px 2px 2px rgba(0, 0, 0, 0.8);
}

/* ---------------------------------------------------------- mobile portrait
   Narrow/portrait phones. Everything above 760px keeps the large TV layout. */

@media (max-width: 760px) {
  /* ---- login ---- */
  .login {
    padding: 20px 16px;
  }

  .card {
    padding: 28px 20px;
    border-radius: 16px;
  }

  h1 {
    font-size: 24px;
  }

  .subtitle {
    font-size: 16px;
    margin-bottom: 24px;
  }

  /* Shrink the digits so all 6 fit the phone width (50px + 0.4em spacing
     clipped to ~4 digits before). */
  .code-input {
    font-size: 32px;
    letter-spacing: 0.28em;
    padding: 18px;
    border-radius: 12px;
  }

  .submit {
    font-size: 19px;
    padding: 16px;
    border-radius: 12px;
  }

  .error {
    font-size: 15px;
    padding: 14px;
  }

  /* ---- channels ---- */
  .shell {
    padding: 12px 14px;
  }

  .topbar {
    margin-bottom: 14px;
    gap: 10px;
  }

  .topbar .brand {
    font-size: 20px;
  }

  .pill {
    font-size: 13px;
    padding: 7px 12px;
  }

  .ghost {
    font-size: 15px;
    padding: 9px 14px;
    border-radius: 10px;
  }

  .status-card {
    padding: 14px;
    border-radius: 14px;
    margin-bottom: 14px;
  }

  .row {
    gap: 10px;
    flex-wrap: wrap;
  }

  .name {
    font-size: 22px;
  }

  .row.muted {
    font-size: 15px;
  }

  .prog-title {
    font-size: 17px;
  }

  .prog-time {
    font-size: 14px;
  }

  .error-banner {
    font-size: 15px;
  }

  .channel-list {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .channel-row {
    padding: 10px 12px;
    gap: 10px;
    border-radius: 12px;
  }

  .channel-meta {
    gap: 12px;
  }

  .logo {
    width: 52px;
    height: 52px;
    border-radius: 10px;
  }

  .logo.placeholder {
    font-size: 22px;
  }

  .info .name {
    font-size: 19px;
  }

  .info .now {
    font-size: 14px;
  }

  .info .time {
    font-size: 13px;
  }

  .watch-group {
    gap: 8px;
  }

  .watch-btn {
    padding: 10px 14px;
    font-size: 15px;
    border-radius: 10px;
  }

  .spinner {
    width: 20px;
    height: 20px;
    border-width: 3px;
  }

  .empty {
    padding: 40px 16px;
    font-size: 16px;
  }

  /* ---- watch ---- */
  .shell.watch .topbar {
    padding: 10px 12px;
    gap: 8px;
  }

  .watch-title {
    gap: 0;
  }

  .watch-title .name {
    font-size: 17px;
  }

  .watch-prog .prog-title {
    font-size: 13px;
  }

  .watch-prog .prog-time {
    font-size: 12px;
  }

  .track-select {
    font-size: 13px;
    padding: 7px 8px;
    min-height: 34px;
    border-radius: 10px;
  }

  .subtitle-error {
    font-size: 11px;
    padding: 5px 8px;
  }

  /* Shrink the video.js control bar so every icon (incl. fullscreen, the
     rightmost button) fits the phone width instead of overflowing. */
  .video-js .vjs-control-bar {
    font-size: 1.25em !important;
  }

  /* Lower the subtitle baseline to sit just above the smaller bar. */
  .video-js .vjs-text-track-display {
    bottom: 4.5em !important;
  }
}

@media (max-width: 420px) {
  /* Very narrow phones: drop the live + remaining-time readouts and the
     programme end time to free up control-bar / topbar space. */
  .video-js .vjs-remaining-time-display {
    display: none !important;
  }

  .watch-prog .prog-time {
    display: none;
  }
}