/* ------------------------------------------------------------------
   components.css — reusable pieces.

   The focus ring is the single most important rule in this file. Focus
   is applied by focus.js as a class; it is never :focus, never tab
   order, and never implied by hover.
   ------------------------------------------------------------------ */

/* ---- bidirectional text ------------------------------------------- */

/*
 * Provider text carries dir="auto" so Arabic, Hebrew and Farsi names are
 * shaped and ordered correctly. That is about the *glyphs*, not the layout:
 * an auto-detected RTL string also flips the element's direction, and since
 * text-align defaults to `start`, the whole line jumps to the right edge of
 * its box. In an interface whose panes, navigation and reading order all run
 * left to right, that reads as broken — an Arabic series title stranded on
 * the far right while its own subtitle sits on the left.
 *
 * So: keep dir="auto" for correct bidi rendering, and pin alignment to the
 * surrounding layout. A genuinely right-to-left *interface* is a different
 * job from rendering right-to-left *content*.
 */
[dir="auto"] { text-align: left; }

/* Centred contexts opt back in. */
.person [dir="auto"] { text-align: center; }

/* ---- focus ------------------------------------------------------- */

.focusable {
  position: relative;
  /* No box-shadow in the transition. A shadow cannot be composited: every
     frame of the fade is a fresh raster of the blurred area, on the old
     element and the new one, on every key press. It snaps; the scale still
     animates, and that is what the eye reads as movement. */
  transition: transform var(--t-fast) var(--ease),
              background-color var(--t-fast) var(--ease);
  /* No will-change here. It asked the GPU for a layer for every focusable
     thing on screen — every key of the keyboard, every chip and menu item —
     held for as long as the screen is up. Chrome promotes an element by
     itself for the moment its transform actually animates; a TV's GPU
     memory is better spent on the posters. */
}

/* Plain `.is-focused`, deliberately.
   A grid cell is `poster vgrid__cell` and a list row is `ch-row vlist__row`
   — the recycling containers mark the cursor with `is-focused` and never add
   `focusable`, which lives on the container itself. Qualifying this selector
   with `.focusable` therefore drops the ring from every poster and every row,
   i.e. from the two places the cursor spends all its time.
   Components that declare their own box-shadow later in this file (.btn,
   .sort-chip, .setting-row) used to beat this rule at equal specificity and
   showed no focus at all; each now has its own `.x.is-focused` rule below
   rather than this one being made stricter. */
.is-focused {
  z-index: 2;
  transform: scale(var(--focus-scale));
  /* The ring is INSET.
     An outer ring is clipped by every ancestor with overflow != visible,
     and this app has nine of them: the app root, each screen, the screen
     body, both scroll helpers, the list viewport, the debug log and the
     nav at narrow widths. Reserving bleed in all of them is whack-a-mole.
     A ring drawn inside the element's own box cannot be clipped by
     anything, ever. The outer glow is decorative and may clip harmlessly. */
  box-shadow: inset 0 0 0 var(--focus-width) var(--c-focus),
              var(--shadow-focus);
}

/* Full-width rows do not scale: there is nowhere for them to grow into,
   and a row that widens under the cursor reads as a wobble rather than a
   lift. The inset ring plus a background change is the whole affordance. */
.vlist__row.is-focused,
.row-item.is-focused,
.cat-row.is-focused,
.epg-row.is-focused,
.setting-row.is-focused,
.btn.is-focused,
.sort-chip.is-focused {
  transform: none;
}

/* ---- focused buttons, chips and settings rows --------------------------
   These three keep their own depth shadow AND get the ring, and add one
   more cue that costs no geometry: an accent bar seated inside the bottom
   edge. Inset, so like the ring it cannot be clipped by an ancestor, and
   unlike a scale it cannot wobble or overlap its neighbour. */

.btn.is-focused,
.sort-chip.is-focused,
.setting-row.is-focused {
  background: var(--c-surface-3);
  color: var(--c-text);
  box-shadow: inset 0 0 0 var(--focus-width) var(--c-focus),
              inset 0 calc(-1 * var(--focus-accent)) 0 0 var(--c-accent),
              var(--shadow-focus);
}

.btn.is-focused .icon,
.sort-chip.is-focused .icon { color: var(--c-text); }

/* The primary button is already a bright fill, so a white ring on it is
   invisible. It gets the same treatment in reverse. */
.btn--primary.is-focused {
  background: var(--c-action);
  color: var(--c-action-text);
  box-shadow: inset 0 0 0 var(--focus-width) var(--c-action-text),
              inset 0 calc(-1 * var(--focus-accent)) 0 0 var(--c-accent),
              var(--shadow-focus);
}
.btn--primary.is-focused .icon { color: var(--c-action-text); }

/* ---- buttons ----------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-3);
  min-height: 54px;
  padding: 0 var(--sp-5);
  background: var(--c-surface-2);
  color: var(--c-text);
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  letter-spacing: 0.02em;
  border-radius: var(--r-md);
  white-space: nowrap;
  box-shadow: var(--shadow-1);
}
.btn .icon { flex: 0 0 auto; opacity: 0.85; }

/* The primary action is the brightest neutral, not the loudest colour. */
.btn--primary {
  background: var(--c-action);
  color: var(--c-action-text);
  font-weight: var(--fw-bold);
}
.btn--primary .icon { opacity: 1; }

.btn--ghost {
  background: transparent;
  box-shadow: inset 0 0 0 1px var(--c-line);
}
.btn--danger { color: #FF8A8F; }
.btn--block  { display: flex; width: 100%; }
.btn--sm     { min-height: 44px; padding: 0 var(--sp-4); font-size: var(--fs-xs); }
.btn[disabled], .btn.is-disabled { opacity: 0.4; box-shadow: none; }

.icon {
  display: block;
  /* --icon-size is set per glyph by icons.js; the attribute size stands if
     either property is missing. */
  width:  calc(var(--icon-size, 22px) * var(--icon-scale, 1));
  height: calc(var(--icon-size, 22px) * var(--icon-scale, 1));
  flex-shrink: 0;
}

/* An icon inside a line of text — a rating's star, a favourite's heart.
   Sits on the text's baseline rather than on a line of its own. */
.icon--inline {
  display: inline-block;
  vertical-align: -0.15em;
  margin-right: 0.3em;
}
.icon-text { white-space: nowrap; }

/* A badge that is only an icon has nothing to space it from. */
.poster__fav .icon--inline,
.ch-row__fav .icon--inline,
.cat-row__icon .icon--inline { margin-right: 0; }

.pin__key .icon { margin: 0 auto; }

/* ---- nav items --------------------------------------------------- */

/* Icon only. The name is not printed under the glyph any more: eight labels
   stacked down the edge is eight pieces of text competing with the content
   they sit beside, and on a remote you are never hunting — you are stepping
   through a list you already know. The name appears when you land on it, as
   a pill beside the icon, and then gets out of the way. */
.nav-item {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  /* An explicit height rather than aspect-ratio: whether aspect-ratio holds
     on this panel's compositor is still an open question (see §0.4 of the
     testing checklist), and the navigation is the last thing that should be
     waiting on an answer. */
  height: var(--nav-item-h);
  padding: 0;
  border-radius: var(--r-md);
  color: var(--c-text-faint);
  transition: color var(--t-fast) var(--ease), background-color var(--t-fast) var(--ease);
}
.nav-item .icon { opacity: 0.7; }

/* The floating name.

   Positioned outside the rail, which is why .nav carries overflow:visible.
   pointer-events:none so it can never intercept a click meant for the icon,
   and it is not display:none between showings because an animation cannot
   start on an element that has no box. */
.nav-item__label {
  position: absolute;
  left: 100%;
  top: 50%;
  margin-left: var(--sp-2);
  padding: 6px var(--sp-3);
  border-radius: var(--r-pill);
  background: var(--c-surface-3);
  color: var(--c-text);
  box-shadow: var(--shadow-2);
  font-size: calc(var(--fs-xs) * 0.9);
  font-weight: var(--fw-medium);
  letter-spacing: 0.06em;
  line-height: 1;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transform: translateY(-50%) translateX(-8px);
  z-index: 3;
}

/* Shown on arrival, then it leaves. `forwards` holds the final frame, so a
   label that has had its moment stays gone until focus lands here again —
   at which point the class is re-applied and the animation restarts. */
.nav-item.is-focused .nav-item__label {
  animation: nav-label-visit 2400ms var(--ease) forwards;
}

@keyframes nav-label-visit {
  0%   { opacity: 0; transform: translateY(-50%) translateX(-8px); }
  8%   { opacity: 1; transform: translateY(-50%) translateX(0); }
  70%  { opacity: 1; transform: translateY(-50%) translateX(0); }
  100% { opacity: 0; transform: translateY(-50%) translateX(-8px); }
}

/* Someone who has turned motion down should not get a label that slides and
   fades; they get one that simply stays. */
@media (prefers-reduced-motion: reduce) {
  .nav-item.is-focused .nav-item__label {
    animation: none;
    opacity: 1;
    transform: translateY(-50%);
  }
}

.nav-item.is-current {
  color: var(--c-text);
  background: var(--c-surface-2);
  box-shadow: var(--shadow-1);
}
.nav-item.is-current .icon { opacity: 1; }
/* The current section gets the one spot of brand colour in the chrome. */
.nav-item.is-current .icon { color: var(--c-accent); }
/* The ring has to be repeated here, and the reason is the trap described at
   the top of this file rather than a style choice.

   `.nav-item.is-current` above declares `box-shadow: var(--shadow-1)` at
   (0,2,0). The ring lives in `.is-focused` at (0,1,0). So on every screen,
   the one nav item that matches the screen you are on — SERIES on series
   detail, MOVIES on movies — lost its ring completely and showed no focus
   at all. Everywhere else in the nav it worked, which is exactly why it
   survived: the broken item is the one you are least likely to press.

   Declared after `.is-current` so that an item which is both current and
   focused resolves to focused. */
.nav-item.is-focused {
  color: var(--c-text);
  background: var(--c-surface-3);
  box-shadow: inset 0 0 0 var(--focus-width) var(--c-focus),
              inset 0 calc(-1 * var(--focus-accent)) 0 0 var(--c-accent),
              var(--shadow-focus);
}

/* ---- tab chips ---------------------------------------------------
   A horizontal pill for tab strips: the favourites type tabs, the guide's
   category chips and the season picker.

   All three used to borrow `.nav-item`, which was harmless while the nav
   was a horizontal bar of pills and wrong the moment it became a rail of
   icon squares — they turned into 60px squares with their labels floating
   off to one side. They were never navigation; they are their own control,
   so they have their own class. */

.tab-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  min-height: 52px;
  padding: 0 var(--sp-5);
  border-radius: var(--r-pill);
  font-size: var(--fs-xs);
  font-weight: var(--fw-medium);
  letter-spacing: 0.08em;
  color: var(--c-text-faint);
  white-space: nowrap;
  transition: color var(--t-fast) var(--ease), background-color var(--t-fast) var(--ease);
}
.tab-chip .icon { opacity: 0.7; }

.tab-chip.is-current {
  color: var(--c-text);
  background: var(--c-surface-2);
  box-shadow: var(--shadow-1);
}
.tab-chip.is-current .icon { opacity: 1; color: var(--c-accent); }

/* After `.is-current`, and carrying the ring itself — the same trap as the
   rail: a component that declares its own box-shadow at (0,2,0) silently
   beats the (0,1,0) ring and shows no focus at all. */
.tab-chip.is-focused {
  transform: none;
  color: var(--c-text);
  background: var(--c-surface-3);
  box-shadow: inset 0 0 0 var(--focus-width) var(--c-focus),
              inset 0 calc(-1 * var(--focus-accent)) 0 0 var(--c-accent),
              var(--shadow-focus);
}

/* A strip of them. Chips need real air between them or they read as one
   long segmented bar rather than separate choices. */
.tab-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--sp-3);
  padding-bottom: var(--sp-4);
}

/* ---- cards ------------------------------------------------------- */

.card {
  background: var(--c-surface);
  border-radius: var(--r-lg);
  padding: var(--sp-4) var(--sp-5);
  box-shadow: var(--shadow-1);
}
.card--flat { background: var(--c-surface-2); box-shadow: none; }

/* A card heading: small, quiet, with a hairline under it. */
.card > h2 {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  font-size: var(--fs-sm) !important;
  letter-spacing: 0.08em;
  color: var(--c-text-dim);
  text-transform: uppercase;
  padding-bottom: var(--sp-3);
  border-bottom: 1px solid var(--c-line);
  margin-bottom: var(--sp-3) !important;
}
.card > h2 .icon { color: var(--c-text-faint); }

/* ---- list rows --------------------------------------------------- */

.row-item {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  min-height: 84px;
  padding: 0 var(--sp-4);
  border-radius: var(--r-md);
  background: transparent;
}
.row-item.is-focused { background: var(--c-surface-3); }
.row-item__title { font-size: var(--fs-base); }
.row-item__meta  { font-size: var(--fs-xs); color: var(--c-text-dim); }

/* ---- form fields ------------------------------------------------- */

.field { display: block; margin-bottom: var(--sp-5); }
.field__label {
  display: block;
  font-size: var(--fs-sm);
  color: var(--c-text-dim);
  margin-bottom: var(--sp-2);
  letter-spacing: 0.04em;
}
.field__input {
  display: flex;
  align-items: center;
  width: 100%;
  min-height: 76px;
  padding: 0 var(--sp-5);
  background: var(--c-surface-2);
  border-radius: var(--r-md);
  font-size: var(--fs-base);
  font-family: inherit;
  color: var(--c-text);
}
.field__input::placeholder { color: var(--c-text-faint); }

/* ---- badges & pills ---------------------------------------------- */

.badge {
  display: inline-flex;
  align-items: center;
  padding: var(--sp-1) var(--sp-3);
  border-radius: var(--r-sm);
  font-size: var(--fs-xs);
  letter-spacing: 0.04em;
  background: var(--c-surface-3);
  color: var(--c-text-dim);
}
.badge--ok   { background: rgba(34,197,94,0.18);  color: var(--c-ok); }
.badge--warn { background: rgba(245,158,11,0.18); color: var(--c-warn); }
.badge--bad  { background: rgba(239,68,68,0.18);  color: var(--c-bad); }
.badge--live { background: var(--c-primary); color: #fff; }

/* ---- spinner ----------------------------------------------------- */

.spinner {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-4);
  color: var(--c-text-dim);
  font-size: var(--fs-sm);
}
.spinner__ring {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 3px solid var(--c-surface-3);
  border-top-color: var(--c-primary);
  animation: spin 900ms linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.loading-block {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  min-height: 240px;
}

/* ---- empty & error states ---------------------------------------- */

.state-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--sp-4);
  height: 100%;
  min-height: 300px;
  text-align: center;
  padding: var(--sp-7);
}
.state-block__title { font-size: var(--fs-xl); font-weight: var(--fw-bold); }
.state-block__text  { font-size: var(--fs-sm); color: var(--c-text-dim); max-width: 760px; }
.state-block__actions { display: flex; gap: var(--sp-4); margin-top: var(--sp-4); }

/* ---- toast ------------------------------------------------------- */

.toast-stack {
  position: fixed;
  right: var(--safe-x);
  bottom: var(--safe-y);
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: var(--sp-2);
}
/* A compact pill: an icon that says what kind of message it is, and the
   message. The colour lives in the icon, not across the whole toast — a
   solid green slab is loud for "Added to favourites". */
.toast {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  max-width: 640px;
  padding: var(--sp-2) var(--sp-5) var(--sp-2) var(--sp-2);
  border-radius: var(--r-pill);
  background: var(--pop-bg);
  box-shadow: var(--pop-shadow);
  color: var(--c-text);
  font-size: var(--fs-sm);
  animation: toast-in var(--t-base) var(--ease);
}
.toast__icon {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: rgba(255,255,255,0.12);
  color: #fff;
}
.toast__text { min-width: 0; line-height: 1.3; }
.toast--ok    .toast__icon { background: var(--c-ok);  color: #06210F; }
.toast--error .toast__icon { background: var(--c-bad); color: #fff; }
.toast.is-leaving { opacity: 0; transition: opacity var(--t-base) var(--ease); }
@keyframes toast-in {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: none; }
}
@media (min-width: 2560px) {
  .toast { max-width: 1100px; }
  .toast__icon { width: 58px; height: 58px; }
}

/* ---- trailer ------------------------------------------------------
   The one place this app shows something from another host. It is drawn
   as a popup on the shared surface — same scrim, panel, radius and entry
   as a dialog — with a header like a player menu's. */

.trailer {
  /* As large as the screen allows: the picture is the point. The width is
     the smaller of 86% of the screen and what a 16:9 frame plus the header
     can have at 90% of its height; the frame's height follows from it. */
  --trailer-w: min(86vw, calc((90vh - 110px) * 1.7778 + 2 * var(--sp-3)));
  width: var(--trailer-w);
  padding: var(--sp-3);
  border-radius: calc(var(--pop-radius) + 6px);
  background: var(--pop-bg);
  box-shadow: var(--pop-shadow), 0 30px 90px rgba(0,0,0,0.6);
  animation: dialog-in var(--t-base) var(--ease);
}

.trailer__head {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  padding: var(--sp-1) var(--sp-1) var(--sp-3) var(--sp-2);
}
.trailer__titles {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.trailer__kicker {
  font-size: var(--fs-xs);
  font-weight: var(--fw-bold);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--c-accent);
}
.trailer__name {
  font-size: var(--fs-md);
  font-weight: var(--fw-bold);
  line-height: 1.2;
  color: var(--c-text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.trailer__close { flex: 0 0 auto; }

/* The stage holds the spinner, the explanation, or the video — always at
   the video's size, so nothing jumps when the video arrives. */
.trailer__stage,
.trailer__frame {
  display: block;
  width: 100%;
  /* 16:9 by height rather than aspect-ratio: whether aspect-ratio holds on
     this panel's compositor is still an open question (checklist 0.4). */
  height: calc((var(--trailer-w) - 2 * var(--sp-3)) * 0.5625);
  border: 0;
  border-radius: calc(var(--pop-radius) - 4px);
  background: #000;
}
.trailer__stage {
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.trailer__stage > .trailer__frame { border-radius: 0; }

.trailer__note {
  max-width: 720px;
  padding: var(--sp-6);
  text-align: center;
}
.trailer__note-glyph {
  width: 84px;
  height: 84px;
  margin: 0 auto var(--sp-4);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: rgba(255,255,255,0.06);
  color: var(--c-text-dim);
}
.trailer__note-title { font-size: var(--fs-lg); font-weight: var(--fw-bold); margin-bottom: var(--sp-2); }
.trailer__note-text  { font-size: var(--fs-sm); color: var(--c-text-dim); line-height: 1.5; }
.trailer__note-actions { margin-top: var(--sp-5); display: flex; justify-content: center; }

.dialog-scrim {
  position: fixed;
  inset: 0;
  z-index: var(--z-dialog);
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at center, rgba(0,0,0,0.55) 0%, rgba(0,0,0,0.8) 75%);
}
.dialog {
  width: min(680px, 62vw);
  padding: var(--sp-6);
  border-radius: calc(var(--pop-radius) + 6px);
  background: var(--pop-bg);
  box-shadow: var(--pop-shadow);
  animation: dialog-in var(--t-base) var(--ease);
}
.dialog__title { font-size: var(--fs-lg); font-weight: var(--fw-bold); line-height: 1.15; margin-bottom: var(--sp-2); }
.dialog__text  { font-size: var(--fs-sm); line-height: 1.45; color: var(--c-text-dim); margin-bottom: var(--sp-5); }
.dialog__actions { display: flex; gap: var(--sp-3); }
@keyframes dialog-in {
  from { opacity: 0; transform: translateY(6px) scale(0.98); }
  to   { opacity: 1; transform: none; }
}

/* A dialog of choices is a list: narrow, one column, rows like a player
   menu's. The current choice carries a tick, not the primary fill, which
   in a list would look like a second cursor. */
.dialog--list { width: min(520px, 50vw); padding: var(--sp-5) var(--sp-3) var(--sp-3); }
.dialog--list .dialog__title,
.dialog--list .dialog__text { padding: 0 var(--sp-3); }
.dialog--list .dialog__text { margin-bottom: var(--sp-3); font-size: var(--fs-xs); }
.dialog--list .dialog__actions {
  flex-direction: column;
  flex-wrap: nowrap;
  gap: 2px;
  padding-top: var(--sp-2);
  border-top: 1px solid var(--pop-line);
}
.dialog--list .btn,
.dialog--list .btn--primary {
  justify-content: flex-start;
  width: 100%;
  min-height: var(--pop-row-h);
  padding: 0 var(--sp-3);
  border-radius: calc(var(--pop-radius) - 6px);
  background: transparent;
  color: rgba(255,255,255,0.84);
  box-shadow: none;
  font-weight: var(--fw-normal);
}
.dialog--list .btn--primary { color: #fff; font-weight: var(--fw-bold); }
.dialog--list .btn .icon { color: var(--c-accent); opacity: 1; }
/* A fixed slot, filled or empty, so every label starts at the same x. */
.dialog__tick { flex: 0 0 auto; display: inline-flex; align-items: center; width: 20px; }
.dialog--list .btn.is-focused,
.dialog--list .btn--primary.is-focused {
  background: var(--pop-focus-bg);
  color: var(--pop-focus-text);
  box-shadow: none;
  transform: none;
}
.dialog--list .btn.is-focused .icon { color: var(--c-accent); }

@media (min-width: 2560px) {
  .dialog { width: min(1180px, 62vw); }
  .dialog--list { width: min(900px, 50vw); }
  .dialog__tick { width: 35px; }
}

/* ---- debug console ----------------------------------------------- */

.debug {
  position: fixed;
  inset: auto 0 0 0;
  height: 52vh;
  z-index: var(--z-debug);
  display: flex;
  flex-direction: column;
  background: rgba(4, 7, 10, 0.96);
  border-top: 2px solid var(--c-primary);
  font-family: "SF Mono", Menlo, Consolas, monospace;
  font-size: 15px;
  line-height: 1.4;
}
.debug__bar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  padding: var(--sp-3) var(--sp-5);
  border-bottom: 1px solid var(--c-line);
  color: var(--c-text-dim);
  font-size: 14px;
}
.debug__log { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: var(--sp-3) var(--sp-5); }
.debug__line { display: flex; gap: var(--sp-3); padding: 2px 0; word-break: break-word; }
.debug__t   { color: var(--c-text-faint); flex: 0 0 auto; }
.debug__tag { flex: 0 0 96px; }
.debug__msg { flex: 1 1 auto; white-space: pre-wrap; }
.debug__line--error { color: #FCA5A5; }
.debug__line--warn  { color: #FCD34D; }
.debug__line--info  { color: #C9D4E0; }
.debug__line--debug { color: #7E8CA0; }

/* ---- on-screen keyboard ------------------------------------------
   Compact on purpose: it sits beside results that are the actual point of
   the screen. Keys are quiet tiles; the one under the cursor turns solid
   light, which reads from across a room without needing a thick ring. */

.kb {
  width: 600px;
  max-width: 100%;
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  background: var(--c-surface);
  border: 1px solid var(--c-line);
  border-radius: var(--r-lg);
  padding: var(--sp-3);
}

.kb__bar {
  display: flex;
  align-items: baseline;
  gap: var(--sp-3);
  padding: 0 var(--sp-1);
}
.kb__bar[hidden] { display: none; }
.kb__hint   { font-size: var(--fs-xs); color: var(--c-text-faint); letter-spacing: 0.08em; }
.kb__target { font-size: var(--fs-xs); color: var(--c-text-dim); }

.kb__helpers {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.kb__helpers[hidden] { display: none; }

.kb__helper {
  padding: 0 var(--sp-3);
  height: 40px;
  border-radius: var(--r-sm);
  background: var(--c-surface-3);
  color: var(--c-text);
  font-size: var(--fs-xs);
  font-family: "SF Mono", Menlo, Consolas, monospace;
  white-space: nowrap;
}

.kb__grid {
  display: grid;
  grid-template-columns: repeat(10, minmax(0, 1fr));   /* keyboard.js sets it per layout */
  gap: 6px;
}

.kb__key {
  height: 52px;
  min-width: 0;
  padding: 0;
  border-radius: var(--r-sm);
  background: var(--c-surface-2);
  color: var(--c-text);
  font-size: var(--fs-sm);
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  white-space: nowrap;
  overflow: hidden;
  transition: transform var(--t-fast) var(--ease), background-color var(--t-fast) var(--ease),
              color var(--t-fast) var(--ease);
}
/* Arabic letters sit low and small in most TV fonts at the Latin size. */
.kb__grid--ar .kb__key:not(.kb__key--action):not(.kb__key--primary) { font-size: var(--fs-base); }

.kb__key--action  { background: var(--c-surface-3); color: var(--c-text-dim); font-size: var(--fs-xs);
                    letter-spacing: 0.04em; }
.kb__key--space   { color: var(--c-text-faint); }
.kb__key--primary { background: var(--c-primary); color: #fff; font-weight: var(--fw-bold); }
.kb__key.is-on    { background: var(--c-primary); color: #fff; }
.kb__caption      { font-size: var(--fs-xs); font-weight: var(--fw-bold); }

/* The focused key fills light instead of wearing the generic ring, which
   on a 52px tile ate a third of the glyph. */
.kb__key.is-focused,
.kb__helper.is-focused {
  background: var(--c-action);
  color: var(--c-action-text);
  box-shadow: var(--shadow-focus);
}
.kb__key.is-focused .icon { color: var(--c-action-text); }
.kb__key--primary.is-focused {
  background: var(--c-primary);
  color: #fff;
  box-shadow: inset 0 0 0 var(--focus-width) var(--c-focus), var(--shadow-focus);
}

@media (min-width: 2560px) {
  .kb         { width: 1040px; }
  .kb__key    { height: 92px; }
  .kb__helper { height: 72px; }
  .kb__grid, .kb__helpers { gap: 10px; }
}
@media (max-width: 1400px) {
  .kb         { width: 460px; }
  .kb__key    { height: 40px; }
  .kb__helper { height: 34px; }
  .kb__grid, .kb__helpers { gap: 4px; }
}

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

.login {
  display: flex;
  gap: var(--sp-8);
  height: 100%;
  min-height: 0;
  align-items: flex-start;
}
/* max-height is what makes the column scrollable rather than clipped.
   `.login` is align-items: flex-start, so a child sizes to its own content
   and nothing bounds it: the fields, the two buttons, the status area and
   the storage note together run past the bottom of the screen — 95px over
   at normal size, 207px at large — and `.screen__body` is overflow:hidden,
   so the CONNECT button simply was not there. Bounding the column against
   `.login`'s own height gives `.scroll-y` (on the element in login.js)
   something to scroll. The keyboard column keeps its natural height, so it
   stays put while the fields move. */
.login__left  {
  flex: 0 0 640px; display: flex; flex-direction: column; min-width: 0;
  max-height: 100%;
}
.login__right { flex: 1 1 auto; min-width: 0; max-height: 100%; }

.login__brand {
  font-size: var(--fs-3xl);
  font-weight: var(--fw-bold);
  letter-spacing: -0.02em;
  line-height: 1;
  margin-bottom: var(--sp-2);
}
.login__brand b { color: var(--c-primary); }
.login__tag {
  font-size: var(--fs-sm);
  color: var(--c-text-dim);
  margin-bottom: var(--sp-7);
}

.field__row { display: flex; align-items: center; gap: var(--sp-3); }
/* The field is a real <input>, so a physical or Bluetooth keyboard can type
   into it and — the whole point — the clipboard can paste into it. The
   on-screen keyboard writes to the same element. */
.field__row .field__input {
  flex: 1 1 auto;
  min-width: 0;
  font-family: "SF Mono", Menlo, Consolas, monospace;
  text-overflow: ellipsis;
}
.field__input::placeholder { color: var(--c-text-faint); }
.field__input::selection { background: var(--c-primary); color: #fff; }

.field__toggle {
  flex: 0 0 auto;
  font-size: var(--fs-xs);
  color: var(--c-text-dim);
  letter-spacing: 0.06em;
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--r-sm);
  background: var(--c-surface-3);
}

.field__error {
  font-size: var(--fs-xs);
  color: var(--c-bad);
  margin-top: var(--sp-2);
  min-height: 1.4em;
}

.field.is-active .field__input { box-shadow: inset 0 0 0 2px var(--c-primary); }

.login__status {
  margin-top: var(--sp-4);
  min-height: 90px;
  font-size: var(--fs-sm);
}
.login__status--error { color: var(--c-bad); }
.login__note {
  margin-top: var(--sp-5);
  font-size: var(--fs-xs);
  color: var(--c-text-faint);
  line-height: 1.5;
}

@media (max-width: 1400px) {
  .login { gap: var(--sp-5); }
  .login__left { flex-basis: 420px; }
}

/* ---- programme guide --------------------------------------------- */

.epg-row {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-4);
  padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--c-line);
}
.epg-row.is-now { background: var(--c-surface-2); border-radius: var(--r-sm); }

.epg-row__time  { flex: 0 0 210px; color: var(--c-text-dim); font-size: var(--fs-sm); }
.epg-row__main  { flex: 1 1 auto; min-width: 0; }
.epg-row__title { font-size: var(--fs-base); }
.epg-row__desc  {
  font-size: var(--fs-xs);
  color: var(--c-text-dim);
  margin-top: 4px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.epg-row__bar {
  margin-top: var(--sp-2);
  height: 4px;
  border-radius: 2px;
  background: var(--c-surface-3);
  overflow: hidden;
}
.epg-row__bar i {
  display: block;
  height: 100%;
  background: var(--c-primary);
}

@media (max-width: 1400px) {
  .epg-row__time { flex-basis: 150px; }
}

/* ---- virtual list ------------------------------------------------ */

.vlist {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

/* The region itself never shows the focus ring — the ring goes on the
   row holding the cursor, which is what the user is actually pointing at. */
.vlist.is-focused {
  transform: none;
  box-shadow: none;
}

.vlist__viewport {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  position: relative;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.vlist__viewport::-webkit-scrollbar { width: 0; height: 0; display: none; }

.vlist__spacer { position: relative; width: 100%; }

/* No will-change on recycled rows or cells. It gave every one of them its
   own GPU layer, each holding its decoded artwork, for as long as the list
   was up — thirty to forty layers on a poster grid. Their transforms are
   set once per scroll step, not animated, so a layer buys nothing. */
.vlist__row {
  contain: layout style;
}

.vlist__empty {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  min-height: 200px;
  color: var(--c-text-faint);
  font-size: var(--fs-sm);
}

/* A list without focus shows NOTHING selected.
   It previously kept a muted cursor so you could see where you would land
   on returning — but on screen that reads as "this row is chosen", when the
   user has not chosen anything. Nothing is highlighted until the list
   actually holds focus. */
.vlist:not(.is-active) .vlist__row.is-focused,
.vlist:not(.is-active) .vlist__row.is-focused:hover {
  box-shadow: none;
  background: transparent;
  transform: none;
}

/* An element that still owns focus while a dialog is over it. */
.is-focused-muted {
  box-shadow: inset 0 0 0 2px var(--c-text-faint);
}

/* ---- channel row ------------------------------------------------- */

.ch-row {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  padding: 0 var(--sp-4);
  border-radius: var(--r-md);
  background: transparent;
}
.ch-row__num {
  flex: 0 0 90px;
  color: var(--c-text-faint);
  font-size: var(--fs-sm);
  font-variant-numeric: tabular-nums;
  text-align: right;
}
.ch-row__logo {
  flex: 0 0 auto;
  width: 96px;
  height: 54px;
  border-radius: var(--r-sm);
  object-fit: contain;
  background: var(--c-surface-2);
}

/* A film or a series in a row is a POSTER, and a poster is 2:3.

   Favourites rendered every type through the channel row, so a portrait
   poster was squeezed into a 96x54 landscape box: `object-fit: contain`
   kept it from distorting and shrank it to about a third of the height
   instead, which is what "small and shrinked" looks like. Posters get a
   portrait box and `cover`, so the art fills it. */
.ch-row__logo--poster {
  width: 76px;
  height: 114px;
  object-fit: cover;
  background: var(--c-surface-2);
}
.ch-row__body { flex: 1 1 auto; min-width: 0; }   /* min-width:0 as above */
.ch-row__name {
  font-size: var(--fs-base);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ch-row__meta {
  font-size: var(--fs-xs);
  color: var(--c-text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}
.ch-row__fav {
  flex: 0 0 auto;
  width: 44px;
  text-align: center;
  font-size: var(--fs-md);
  color: var(--c-primary);
}

.lazy-img { opacity: 1; transition: opacity var(--t-base) var(--ease); }

@media (min-width: 2560px) {
  .ch-row__logo { width: 168px; height: 94px; }
  .ch-row__num  { flex-basis: 150px; }
}
@media (max-width: 1400px) {
  .ch-row__logo { width: 72px; height: 40px; }
  .ch-row__num  { flex-basis: 64px; }
}

/* ---- live tv ------------------------------------------------------ */

.pane-title {
  flex: 0 0 auto;
  font-size: var(--fs-xs);
  letter-spacing: 0.1em;
  color: var(--c-text-faint);
  padding-bottom: var(--sp-2);
}

.cat-row {
  display: flex;
  align-items: center;
  padding: 0 var(--sp-4);
  border-radius: var(--r-md);
  font-size: var(--fs-sm);
  color: var(--c-text-dim);
}
.cat-row.is-current {
  color: var(--c-text);
  font-weight: var(--fw-bold);
  /* The category showing, now that the highlight can be elsewhere. */
  box-shadow: inset 4px 0 0 var(--c-accent);
}
.cat-row.is-focused { color: var(--c-text); background: var(--c-surface-3); }
.cat-row__name { width: 100%; overflow-wrap: anywhere; }
.cat-row__icon { flex: 0 0 auto; display: inline-flex; margin-right: var(--sp-3); }
.cat-row__icon:empty { display: none; }

/* ---- home rails ---------------------------------------------------- */

.rail { flex: 0 0 auto; margin-bottom: var(--sp-6); }

.rail__title {
  font-size: var(--fs-sm);
  letter-spacing: 0.1em;
  color: var(--c-text-faint);
  margin-bottom: var(--sp-3);
}
.rail__hint {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-left: var(--sp-4);
  font-size: var(--fs-xs);
  letter-spacing: 0.04em;
  color: var(--c-text-faint);
  opacity: 0.55;
  transition: opacity var(--t-fast) var(--ease);
}
.rail__hint-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #E5484D;
  box-shadow: 0 0 0 3px rgba(229,72,77,0.15);
}
/* Brighter while the cursor is in that rail, when it applies. */
.rail.has-focus .rail__hint { opacity: 1; }

.rail__items {
  display: flex;
  gap: var(--sp-4);
  align-items: flex-start;
}

.rail__empty, .rail__loading {
  color: var(--c-text-faint);
  font-size: var(--fs-sm);
  padding: var(--sp-4) 0;
}

/* A poster in a rail: the same component as a grid cell (see
   js/ui/poster-card.js), given a fixed size because a rail has no cell to
   size it. Channels are landscape, with the logo contained, not cropped. */
.poster--rail {
  position: relative;
  flex: 0 0 auto;
  width: 200px;
}
.poster--rail .poster__frame { flex: 0 0 auto; height: 280px; }
.poster--rail-wide { width: 240px; }
.poster--rail-wide .poster__frame { height: 135px; }
.poster--rail-wide .poster__art { object-fit: contain; padding: var(--sp-3); }
.poster--rail .poster__name { min-height: 2.5em; }
.poster--rail .poster__sub  { min-height: 1.3em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.cat-tile {
  flex: 0 0 auto;
  width: 300px;
  height: 132px;
  display: flex;
  align-items: flex-end;
  padding: var(--sp-4);
  border-radius: var(--r-md);
  background: var(--c-surface);
  text-align: left;
}
.cat-tile__name {
  /* min-width:0 is the load-bearing line. A flex child defaults to
     min-width:auto and so refuses to shrink below its content, which is
     why long provider names spilled straight past the tile and over the
     focus ring even with a width set. */
  flex: 1 1 auto;
  min-width: 0;
  font-size: var(--fs-base);
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow-wrap: anywhere;
  word-break: break-word;
}

/* Each breakpoint re-states the wide variant. A bare frame height here
   comes later than the base wide rule at equal specificity, so without it
   channel cards would inherit the poster height and render as tall empty
   boxes with the logo as a strip across the middle. */
@media (min-width: 2560px) {
  .poster--rail { width: 340px; }
  .poster--rail .poster__frame { height: 476px; }
  .poster--rail-wide { width: 408px; }
  .poster--rail-wide .poster__frame { height: 230px; }
  .cat-tile { width: 480px; height: 220px; }
}
@media (max-width: 1400px) {
  .poster--rail { width: 150px; }
  .poster--rail .poster__frame { height: 210px; }
  .poster--rail-wide { width: 180px; }
  .poster--rail-wide .poster__frame { height: 101px; }
  .cat-tile { width: 230px; height: 104px; }
}

/* ---- virtual grid -------------------------------------------------- */

.vgrid {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.vgrid.is-focused { transform: none; box-shadow: none; }

.vgrid__viewport {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  position: relative;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.vgrid__viewport::-webkit-scrollbar { width: 0; height: 0; display: none; }

.vgrid__spacer { position: relative; width: 100%; }
.vgrid__cell   { contain: layout style; }   /* no will-change: see .vlist__row */

.vgrid__empty {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  min-height: 220px;
  color: var(--c-text-faint);
  font-size: var(--fs-sm);
}
.vgrid:not(.is-active) .vgrid__cell.is-focused {
  box-shadow: none;
  transform: none;
}

/* ---- poster cell --------------------------------------------------- */

.poster {
  border-radius: var(--r-md);
  background: var(--c-surface);
  overflow: hidden;
  text-align: left;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-1);
  /* Not transitioned — see .focusable. */
}
.poster.is-focused { box-shadow: var(--shadow-2); }
/* The ring is an overlay, not the card's own inset shadow. An inset shadow
   paints beneath the card's children, and the frame is opaque and flush to
   the card's edges — so the artwork covered the ring on three sides and it
   only showed around the caption. A pseudo-element drawn last sits above
   the artwork and cannot be covered or clipped. */
.poster.is-focused::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 3;
  border-radius: inherit;
  box-shadow: inset 0 0 0 var(--focus-width) var(--c-focus);
  pointer-events: none;
}

/* The artwork and everything that sits on top of it. */
.poster__frame {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  border-radius: var(--r-md) var(--r-md) 0 0;
  background: var(--c-surface-2);
}

.poster__art {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* A scrim under the badges, so a star on a pale poster is still legible.
   Drawn on the frame rather than the image: an <img> cannot carry a
   pseudo-element, and putting it on the card would tint the caption too. */
.poster__frame::after {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 38%;
  background: linear-gradient(to bottom, rgba(0, 0, 0, 0.55), rgba(0, 0, 0, 0));
  pointer-events: none;
}

/* Badges, at opposite corners. Both are empty most of the time and an
   empty badge must not draw a plate, hence :empty. */
.poster__rating,
.poster__fav {
  position: absolute;
  top: var(--sp-2);
  z-index: 1;
  font-size: var(--fs-xs);
  font-weight: var(--fw-medium);
  line-height: 1;
  padding: 5px 8px;
  border-radius: var(--r-pill);
  background: rgba(0, 0, 0, 0.62);
  white-space: nowrap;
}
.poster__rating { right: var(--sp-2); color: #FFD35C; }
.poster__fav    { left:  var(--sp-2); color: var(--c-primary); }
.poster__rating:empty,
.poster__fav:empty { display: none; }

/* Progress sits on the artwork now, along its bottom edge, where it reads
   as "how far into this film" rather than as a divider between two blocks. */
.poster__bar {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 4px;
  background: rgba(0, 0, 0, 0.55);
  z-index: 1;
}
.poster__bar i { display: block; height: 100%; background: var(--c-primary); }

.poster__meta {
  flex: 0 0 auto;
  padding: var(--sp-2) var(--sp-3) var(--sp-3);
}
.poster__name {
  font-size: var(--fs-sm);
  line-height: 1.25;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow-wrap: anywhere;
}
/* Just the year now. The rating moved to the artwork, because the two sat
   close enough to read as one value. */
.poster__sub {
  font-size: var(--fs-xs);
  color: var(--c-text-dim);
  margin-top: 4px;
  letter-spacing: 0.04em;
}

/* ---- detail screen -------------------------------------------------- */

.detail {
  display: flex;
  gap: var(--sp-7);
  height: 100%;
  min-height: 0;
}
.detail__poster { flex: 0 0 340px; }
.detail__art {
  width: 100%;
  height: auto;
  aspect-ratio: 2 / 3;
  object-fit: cover;
  border-radius: var(--r-lg);
  background: var(--c-surface-2);
}
.detail__body {
  flex: 1 1 auto;
  min-width: 0;
  overflow-y: auto;
  scrollbar-width: none;

  /* The column had no padding of its own: the title, the plot and the
     season strip all started hard against the poster and ran to the right
     edge of the screen.

     The block padding is the focus bleed rather than a round number,
     because this is a scroll container and a focused season tile carries a
     ring and a scale — without reserved room at the top and bottom edges
     the ring is clipped flat against the container. The negative block
     margin cancels it again, so the column still lines up with the top of
     the poster instead of sitting 12px lower than it. */
  padding: var(--focus-bleed) var(--sp-5);
  margin-block: calc(var(--focus-bleed) * -1);
  scroll-padding: var(--focus-bleed);
}
.detail__body::-webkit-scrollbar { width: 0; display: none; }

.detail__title {
  font-size: var(--fs-2xl);
  font-weight: var(--fw-bold);
  line-height: var(--lh-tight);
  overflow-wrap: anywhere;
}
.detail__facts {
  font-size: var(--fs-sm);
  color: var(--c-text-dim);
  margin-top: var(--sp-3);
}
.detail__progress {
  height: 5px;
  border-radius: 3px;
  background: var(--c-surface-3);
  margin-top: var(--sp-4);
  max-width: 520px;
  overflow: hidden;
}
.detail__progress i { display: block; height: 100%; background: var(--c-primary); }

.detail__plot {
  font-size: var(--fs-sm);
  line-height: 1.55;
  color: var(--c-text);
  margin-top: var(--sp-5);
  max-width: 1000px;
}
.detail__fact {
  display: flex;
  gap: var(--sp-4);
  font-size: var(--fs-xs);
  color: var(--c-text-dim);
  margin-top: var(--sp-3);
}
.detail__factLabel { flex: 0 0 120px; color: var(--c-text-faint); letter-spacing: 0.06em; }

.detail__actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-3);
  margin-top: var(--sp-6);
}

@media (max-width: 1400px) {
  .detail { gap: var(--sp-5); }
  .detail__poster { flex-basis: 220px; }
}

/* ---- cast & crew ---------------------------------------------------- */

.cast { margin-top: var(--sp-6); }

.cast__title {
  font-size: var(--fs-xs);
  letter-spacing: 0.1em;
  color: var(--c-text-faint);
  margin-bottom: var(--sp-3);
}

.cast-row {
  display: flex;
  gap: var(--sp-4);
  align-items: flex-start;
  padding-bottom: var(--sp-2);
}

.person {
  flex: 0 0 auto;
  /* The tile is the avatar plus its own padding. Deriving it this way is
     what keeps the image square: setting the image to width:100% of a
     padded tile made it 114x130 — an ellipse, not a circle. */
  width: calc(var(--person-size) + var(--sp-2) * 2);
  text-align: center;
  border-radius: var(--r-md);
  padding: var(--sp-2);
}

.person__photo {
  /* Both axes from the same token. Never width:100%. */
  width: var(--person-size);
  height: var(--person-size);
  min-width: var(--person-size);
  border-radius: 50%;
  object-fit: cover;
  background: var(--c-surface-2);
  display: block;
  margin: 0 auto;
}

.person__name {
  font-size: var(--fs-xs);
  margin-top: var(--sp-2);
  line-height: 1.25;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow-wrap: anywhere;
}

.person__role {
  font-size: 13px;
  color: var(--c-text-faint);
  margin-top: 2px;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow-wrap: anywhere;
}

/* Size comes from --person-size; only type needs adjusting here. */
@media (min-width: 2560px) {
  .person__role { font-size: 22px; }
}
@media (max-width: 1400px) {
  .person__role { font-size: 11px; }
}

/* ---- marquee labels -------------------------------------------------- */

.marq {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.marq__t {
  display: inline-block;
  /* No will-change: only the focused label ever moves, and Chrome promotes
     it while it does. Declaring it gave every list row's label a layer. */
}

/* While scrolling, the ellipsis has to go — otherwise the revealed text
   still ends in "…" and the whole point is lost. */
.marq.is-marqueeing { text-overflow: clip; }

/* ---- focused-item title strip ---------------------------------------- */

/* For captions that are clamped to two lines and so cannot scroll, the
   full title of the focused item lives here — always complete, no motion. */
.focused-title {
  flex: 0 0 auto;
  /* A fixed height, not a minimum. The strip sits directly above the grid,
     so any change in its height moves every poster: with min-height, a
     title that wrapped to two lines pushed the grid down and the next
     one-line title pulled it back up — LEFT/RIGHT made the page bounce.
     Two clamped lines plus the padding, always. */
  height: calc(2.1em + var(--sp-3));
  font-size: var(--fs-md);
  line-height: 1.05;
  color: var(--c-text);
  padding-bottom: var(--sp-3);
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow-wrap: anywhere;
}

/* ---- seasons -------------------------------------------------------- */

.season-row { display: flex; gap: var(--sp-3); align-items: flex-start; }

/* The season tabs sit directly above the episode list, separated by a
   hairline. The gap has to be generous on BOTH sides of that line: the
   current tab is a filled pill, so a tight gap reads as the pill sitting
   on the line rather than above it.
   It also has to scale, because .nav-item doubles to 104px at 4K. --sp-5
   is itself redefined per breakpoint, so naming the token is enough — the
   earlier --sp-3 was simply too small a token, not a missing media query. */
.season-row--compact {
  padding-bottom: var(--sp-5);
  margin-bottom: var(--sp-5);
  border-bottom: 1px solid var(--c-line);
}

.season-tile {
  flex: 0 0 auto;
  width: 170px;
  min-height: 150px;
  padding: var(--sp-4);
  border-radius: var(--r-md);
  background: var(--c-surface);
  text-align: left;
  position: relative;
}
.season-tile__n {
  font-size: var(--fs-xl);
  font-weight: var(--fw-bold);
  line-height: 1;
  color: var(--c-text-dim);
}
.season-tile__label {
  font-size: var(--fs-sm);
  margin-top: var(--sp-2);
  overflow-wrap: anywhere;
}
.season-tile__meta { font-size: var(--fs-xs); color: var(--c-text-faint); margin-top: 2px; }
.season-tile__bar {
  position: absolute;
  left: var(--sp-4);
  right: var(--sp-4);
  bottom: var(--sp-3);
  height: 4px;
  border-radius: 2px;
  background: var(--c-surface-3);
  overflow: hidden;
}
.season-tile__bar i { display: block; height: 100%; background: var(--c-primary); }

/* ---- episodes -------------------------------------------------------- */

.season-head { flex: 0 0 auto; margin-bottom: var(--sp-3); }
.season-head__title {
  font-size: var(--fs-xl);
  font-weight: var(--fw-bold);
  line-height: var(--lh-tight);
  overflow-wrap: anywhere;
}
.season-head__sub { font-size: var(--fs-sm); color: var(--c-text-dim); margin-top: 4px; }

.episode {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  padding: 0 var(--sp-4);
  border-radius: var(--r-md);
  position: relative;
}
.episode__n {
  flex: 0 0 62px;
  text-align: right;
  font-size: var(--fs-md);
  color: var(--c-text-faint);
  font-variant-numeric: tabular-nums;
}
.episode__still {
  flex: 0 0 auto;
  width: 160px;
  height: 90px;
  border-radius: var(--r-sm);
  object-fit: cover;
  background: var(--c-surface-2);
}
.episode__body { flex: 1 1 auto; min-width: 0; }
.episode__title { font-size: var(--fs-base); }
.episode__meta {
  font-size: var(--fs-xs);
  color: var(--c-text-dim);
  margin-top: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.episode__bar {
  position: absolute;
  left: var(--sp-4);
  right: var(--sp-4);
  bottom: 6px;
  height: 3px;
  border-radius: 2px;
  background: var(--c-surface-3);
  overflow: hidden;
}
.episode__bar i { display: block; height: 100%; background: var(--c-primary); }

.episode-aside { padding-left: var(--sp-5); }
.episode-plot {
  font-size: var(--fs-sm);
  line-height: 1.5;
  color: var(--c-text-dim);
  overflow-wrap: anywhere;
}

@media (max-width: 1400px) {
  .season-tile { width: 130px; min-height: 120px; }
  .episode__still { width: 112px; height: 63px; }
  .episode__n { flex-basis: 44px; }
}

/* ---- search ---------------------------------------------------------- */

.search { display: flex; gap: var(--sp-6); height: 100%; min-height: 0; }
.search__left  { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }
.search__right { flex: 0 0 auto; }

/* Looks like a field so it reads as "what you typed", not as a heading. */
.search__field {
  flex: 0 0 auto;           /* a column flex child: the list must not squeeze it */
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  height: 64px;
  padding: 0 var(--sp-4);
  background: var(--c-surface);
  border: 1px solid var(--c-line);
  border-radius: var(--r-md);
  color: var(--c-text-faint);
}
.search__text {
  flex: 1 1 auto;
  min-width: 0;
  font-size: var(--fs-md);
  font-weight: var(--fw-medium);
  color: var(--c-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.search__text.is-empty { color: var(--c-text-faint); font-weight: var(--fw-normal); }

.search__summary {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin: var(--sp-3) 0 var(--sp-3);
  padding: 0 var(--sp-1);
}
.search__counts {
  display: flex;
  align-items: baseline;
  gap: var(--sp-3);
  min-height: 1.4em;
  font-size: var(--fs-sm);
}
.search__total { color: var(--c-text); font-weight: var(--fw-bold); margin-right: var(--sp-1); }
.search__count { font-size: var(--fs-xs); background: none; padding: 0; }
.search__coverage {
  font-size: var(--fs-xs);
  color: var(--c-text-faint);
  min-height: 1.4em;
}

@media (max-width: 1400px) {
  .search { gap: var(--sp-5); }
  .search__field { height: 52px; }
}
@media (min-width: 2560px) {
  .search__field { height: 112px; }
}

.cast__note {
  font-size: var(--fs-xs);
  color: var(--c-text-faint);
  margin-top: var(--sp-2);
  max-width: 900px;
}

/* ---- sort chip ------------------------------------------------------- */

.sort-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  height: 44px;
  padding: 0 var(--sp-4);
  border-radius: var(--r-pill);
  background: transparent;
  box-shadow: inset 0 0 0 1px var(--c-line);
  color: var(--c-text-dim);
  font-size: var(--fs-xs);
  letter-spacing: 0.04em;
  white-space: nowrap;
}
.sort-chip .icon { color: var(--c-text-faint); }
.sort-chip.is-focused { color: var(--c-text); background: var(--c-surface-3); }

.pane-head {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  flex: 0 0 auto;
}
.pane-head .pane-title { padding-bottom: 0; flex: 1 1 auto; min-width: 0; }

/* A sort menu has more choices than a confirmation, so let it stack. */
.dialog__actions { flex-wrap: wrap; }

/* The filter chip is a sort chip until a filter is on; then it carries the
   accent, so a narrowed grid never passes for the whole category. */
.sort-chip--filter.is-active {
  color: var(--c-text);
  background: rgba(229, 9, 20, 0.14);
  box-shadow: inset 0 0 0 1px var(--c-accent-soft);
}
.sort-chip--filter.is-active .icon { color: var(--c-accent); }
.sort-chip__badge {
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: var(--r-pill);
  background: var(--c-accent);
  color: #fff;
  font-size: 13px;
  font-weight: var(--fw-bold);
  line-height: 22px;
  text-align: center;
}
.sort-chip__badge[hidden] { display: none; }
.sort-chip__text { max-width: 340px; overflow: hidden; text-overflow: ellipsis; }

/* `hidden` loses to the explicit display above without this; the playlist
   chip is hidden whenever the open category is not a playlist. */
.sort-chip[hidden] { display: none; }

/* ---- playlists ------------------------------------------------------------
   The picker is a dialog list; each playlist row carries its size on the
   right, and "New playlist" and "Done" are set apart from the lists. */

.pl-pick .dialog__actions { max-height: 60vh; overflow-y: auto; }
.pl-pick .dialog__actions::-webkit-scrollbar { width: 0; height: 0; display: none; }
.pl-pick .btn__label { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis;
                       white-space: nowrap; text-align: start; }
.pl-pick__count {
  flex: 0 0 auto;
  font-size: var(--fs-xs);
  color: var(--c-text-faint);
  font-variant-numeric: tabular-nums;
}
.pl-pick .btn.is-on { color: #fff; font-weight: var(--fw-bold); }
.pl-pick .btn.is-focused .pl-pick__count { color: var(--pop-focus-text); }
.pl-pick .btn.is-on.is-focused { color: var(--pop-focus-text); }
.pl-pick .pl-pick__new { color: var(--c-text-dim); }
.pl-pick .pl-pick__new .icon { color: var(--c-text-dim); }
.pl-pick .pl-pick__done { margin-top: var(--sp-2); border-top: 1px solid var(--pop-line); border-radius: 0; }
.pl-pick .pl-pick__done.is-focused { border-radius: calc(var(--pop-radius) - 6px); border-top-color: transparent; }

/* The name prompt: a field that shows what is typed, the keyboard under it. */
.dialog--prompt { width: auto; max-width: 92vw; }
.dialog--prompt .kb { width: 600px; margin-bottom: var(--sp-5); }
.prompt__field {
  display: flex;
  align-items: center;
  height: 64px;
  margin: 0 0 var(--sp-4);
  padding: 0 var(--sp-4);
  border-radius: var(--r-md);
  background: var(--c-surface);
  border: 1px solid var(--c-line);
  font-size: var(--fs-md);
  font-weight: var(--fw-medium);
  white-space: nowrap;
  overflow: hidden;
}
/* The cursor in a field typed with the on-screen keyboard (search, prompt).
   Inline, between the text before and after it — see js/ui/text-edit.js.
   The parts keep their spaces: collapsed, a space typed just before the
   cursor would vanish until the next letter arrived. */
.text-edit__part { white-space: pre; }
.text-caret {
  display: inline-block;
  flex: 0 0 auto;
  width: 2px;
  height: 1.1em;
  margin: 0 1px;
  vertical-align: text-bottom;
  background: var(--c-accent);
  animation: caret-blink 1.1s steps(1) infinite;
}
@keyframes caret-blink { 50% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .text-caret { animation: none; } }

/* The keyboard's shortcut strip: what the colour keys do while typing. */
.kb__shortcuts {
  padding: var(--sp-1) var(--sp-1) 0;
  gap: var(--sp-1) var(--sp-4);
  font-size: var(--fs-xs);
  color: var(--c-text-dim);
}
.dialog--prompt .dialog__actions { justify-content: flex-end; }
.btn.is-disabled { opacity: 0.45; }

@media (min-width: 2560px) {
  .dialog--prompt .kb { width: 1040px; }
  .prompt__field { height: 112px; }
}
@media (max-width: 1400px) {
  .dialog--prompt .kb { width: 460px; }
  .prompt__field { height: 52px; }
}

/* ---- filter drawer ------------------------------------------------------
   Slides in over the right of the grid, which stays visible and updates
   behind it as choices are made. */

.flt-scrim {
  position: fixed;
  inset: 0;
  z-index: var(--z-dialog);
  display: flex;
  justify-content: flex-end;
  background: linear-gradient(90deg, rgba(0,0,0,0) 30%, rgba(0,0,0,0.72) 100%);
}
.flt {
  width: 560px;
  max-width: 46vw;
  height: 100%;
  display: flex;
  flex-direction: column;
  padding: var(--sp-7) var(--sp-5) var(--sp-5);
  background: var(--pop-bg);
  box-shadow: var(--pop-shadow), -24px 0 60px rgba(0,0,0,0.45);
  border-left: 1px solid var(--pop-line);
  animation: flt-in var(--t-base) var(--ease);
}
@keyframes flt-in {
  from { opacity: 0; transform: translateX(40px); }
  to   { opacity: 1; transform: none; }
}

.flt__head { padding: 0 var(--sp-3) var(--sp-4); border-bottom: 1px solid var(--pop-line); }
.flt__title {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  font-size: var(--fs-lg);
  font-weight: var(--fw-bold);
  line-height: 1.1;
}
.flt__title .icon { color: var(--c-accent); }
.flt__sub {
  margin-top: var(--sp-1);
  padding-left: 38px;
  font-size: var(--fs-xs);
  color: var(--c-text-faint);
  letter-spacing: 0.04em;
}

.flt__body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: var(--sp-3) 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.flt__body::-webkit-scrollbar { width: 0; height: 0; display: none; }
.flt__none { padding: var(--sp-5) var(--sp-3); color: var(--c-text-dim); font-size: var(--fs-sm); }

/* A field: its name on the left, the choice between two chevrons on the
   right — the chevrons say LEFT and RIGHT change it. */
.flt-row {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-4);
  height: 64px;
  padding: 0 var(--sp-3) 0 var(--sp-4);
  border-radius: var(--r-md);
  background: transparent;
  color: var(--c-text-dim);
  font-size: var(--fs-sm);
}
.flt-row__label { flex: 0 0 auto; }
.flt-row__value {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  min-width: 0;
  color: var(--c-text);
  font-weight: var(--fw-medium);
}
.flt-row__text { min-width: 0; max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.flt-row__arrow { display: inline-flex; color: var(--c-text-faint); opacity: 0; transition: opacity var(--t-fast) var(--ease); }
.flt-row.is-set .flt-row__text { color: var(--c-accent); }
.flt-row.is-focused {
  transform: none;
  background: var(--pop-focus-bg);
  color: var(--pop-focus-text);
  box-shadow: none;
}
.flt-row.is-focused .flt-row__value,
.flt-row.is-focused .flt-row__text { color: var(--pop-focus-text); }
.flt-row.is-focused .flt-row__arrow { opacity: 1; color: var(--pop-focus-text); }
/* Several choices ticked: LEFT/RIGHT do not step (filter-panel.js), so no arrows. */
.flt-row.is-multi .flt-row__arrow { visibility: hidden; }

/* The full list of one field's choices. */
.flt__choices { display: flex; flex-direction: column; gap: 2px; }
.flt-opt {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  min-height: var(--pop-row-h);
  padding: 0 var(--sp-4) 0 var(--sp-3);
  border-radius: calc(var(--pop-radius) - 6px);
  background: transparent;
  color: rgba(255,255,255,0.84);
  font-size: var(--fs-sm);
  text-align: start;
}
.flt-opt__tick  { flex: 0 0 20px; display: inline-flex; color: var(--c-accent); }
.flt-opt__label { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.flt-opt__hint  { flex: 0 0 auto; font-size: var(--fs-xs); color: var(--c-text-faint); margin-inline-end: var(--sp-2); }
.flt-opt.is-focused .flt-opt__hint { color: var(--pop-focus-text); opacity: 0.6; }
.flt-opt__count { flex: 0 0 auto; font-size: var(--fs-xs); color: var(--c-text-faint); font-variant-numeric: tabular-nums; }
.flt-opt.is-on  { color: #fff; font-weight: var(--fw-bold); }
.flt-opt.is-focused {
  transform: none;
  background: var(--pop-focus-bg);
  color: var(--pop-focus-text);
  box-shadow: none;
}
.flt-opt.is-focused .flt-opt__count,
.flt-opt.is-focused .flt-opt__tick { color: var(--pop-focus-text); }

.flt__foot {
  display: flex;
  gap: var(--sp-3);
  padding-top: var(--sp-4);
  border-top: 1px solid var(--pop-line);
}
.flt__foot .btn { flex: 0 0 auto; }
.flt__foot .flt__done { flex: 1 1 auto; justify-content: center; }
.flt__reset.is-disabled { opacity: 0.4; }

@media (min-width: 2560px) {
  .flt      { width: 980px; }
  .flt-row  { height: 112px; }
  .flt-row__text { max-width: 460px; }
}
@media (max-width: 1400px) {
  .flt      { width: 440px; padding-top: var(--sp-5); }
  .flt-row  { height: 52px; }
}

@media (min-width: 2560px) { .sort-chip { height: 88px; } }
@media (max-width: 1400px) { .sort-chip { height: 44px; } }

.episode-aside__title {
  font-size: var(--fs-md);
  line-height: 1.2;
  overflow-wrap: anywhere;
  margin-bottom: var(--sp-2);
}
.episode-aside__meta {
  font-size: var(--fs-xs);
  color: var(--c-text-faint);
  margin-bottom: var(--sp-4);
}

/* ---- pin pad --------------------------------------------------------- */

.pin__dots { display: flex; gap: var(--sp-4); margin: var(--sp-5) 0 var(--sp-2); }
.pin__dot {
  width: 22px; height: 22px;
  border-radius: 50%;
  box-shadow: inset 0 0 0 2px var(--c-text-faint);
}
.pin__dot.is-filled { background: var(--c-text); box-shadow: none; }
.pin__dots.is-wrong { animation: pin-shake 360ms ease; }
@keyframes pin-shake {
  0%,100% { transform: translateX(0); }
  25% { transform: translateX(-10px); }
  75% { transform: translateX(10px); }
}

.pin__error { min-height: 1.6em; color: var(--c-bad); font-size: var(--fs-sm); }

.pin__pad {
  display: grid;
  grid-template-columns: repeat(3, 120px);
  gap: var(--sp-3);
  margin-top: var(--sp-4);
}
.pin__key {
  height: 96px;
  border-radius: var(--r-md);
  background: var(--c-surface-2);
  font-size: var(--fs-lg);
}
.pin__key--action { font-size: var(--fs-sm); color: var(--c-text-dim); }

@media (min-width: 2560px) {
  .pin__pad { grid-template-columns: repeat(3, 200px); }
  .pin__key { height: 160px; }
  .pin__dot { width: 34px; height: 34px; }
}

/* ---- settings rows --------------------------------------------------- */

.setting-row {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  width: 100%;
  min-height: 56px;
  padding: 0 var(--sp-4);
  border-radius: var(--r-md);
  background: transparent;
  box-shadow: inset 0 0 0 1px var(--c-line);
  text-align: left;
  margin-top: var(--sp-2);
}
.setting-row .icon { flex: 0 0 auto; color: var(--c-text-faint); }
.setting-row__label { flex: 0 0 340px; font-size: var(--fs-sm); }
.setting-row .mono  { flex: 1 1 auto; min-width: 0; font-size: var(--fs-sm); }
.setting-row__hint  { flex: 0 0 auto; font-size: var(--fs-xs); color: var(--c-text-faint); }
.setting-row__note  {
  font-size: var(--fs-xs);
  color: var(--c-text-faint);
  padding: var(--sp-2) var(--sp-4) 0;
  max-width: 1100px;
}

@media (max-width: 1400px) {
  .setting-row__label { flex-basis: 220px; }
  .setting-row__hint  { display: none; }
}

/* ---- wide poster cells (1–2 column layouts) -------------------------- */

/* Artwork beside the text rather than above it. Only the direction changes;
   the cell's markup is identical, so the recycling pool is unaffected. */
.vgrid--wide .poster {
  flex-direction: row;
  align-items: stretch;
  gap: var(--sp-4);
  padding: var(--sp-2);
}
/* The FRAME is the flex item, not the image. The artwork moved inside
   .poster__frame for the badges, and this width stayed on the <img>: the
   frame kept its default `flex: 1 1 auto` and shrank to whatever the text
   left over — 64px at two columns, a sliver of a poster beside a paragraph.
   Fixed and unshrinkable here, so the art is always a real 2:3 poster. */
.vgrid--wide .poster__frame {
  flex: 0 0 auto;
  /* 2:3 against the 210px cell, less the cell's own padding (194px). */
  width: 130px;
  height: 100%;
  border-radius: var(--r-sm);
}
.vgrid--wide .poster__art {
  width: 100%;
  height: 100%;
}
.vgrid--wide .poster__bar {
  position: absolute;
  left: 0; right: 0; bottom: 0;
}
.vgrid--wide .poster__meta {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 0;
}
.vgrid--wide .poster__name {
  font-size: var(--fs-base);
  -webkit-line-clamp: 2;
}
.vgrid--wide .poster { position: relative; }

@media (max-width: 1400px) {
  .vgrid--wide .poster__frame { width: 110px; }
}

/* ---- remote key hints ------------------------------------------------ */

.hints {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--sp-2) var(--sp-5);
  flex: 0 0 auto;
  padding-top: var(--sp-3);
}

.hint {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  white-space: nowrap;
}

.hint__dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  flex: 0 0 auto;
}

.hint__cap {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 34px;
  height: 22px;
  padding: 0 6px;
  border-radius: 6px;
  box-shadow: inset 0 0 0 1px var(--c-line);
  color: var(--c-text-dim);
  font-size: 12px;
  letter-spacing: 0.06em;
}
.hint__cap--icon { min-width: 26px; padding: 0 4px; }
.hint__cap .icon { opacity: 0.85; }

.hint--note {
  color: var(--c-text-faint);
  opacity: 0.75;
  font-style: italic;
}
.hint--note .icon { opacity: 0.7; }
.hint--note .hint__label { font-style: italic; }

.hint__label {
  font-size: var(--fs-xs);
  color: var(--c-text-faint);
  letter-spacing: 0.03em;
}

@media (min-width: 2560px) {
  .hint__dot { width: 18px; height: 18px; }
  .hint__cap { min-width: 56px; height: 36px; font-size: 20px; border-radius: 9px; }
}

/* ---- wide poster cells ------------------------------------------------ */

.sort-chip__glyph { display: inline-flex; align-items: center; }

/* Only ever visible at one or two columns, where there is room for it. */
.poster__detail {
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
  min-width: 0;
  margin-top: var(--sp-2);
}

/* Not the accent colour: it is red, and red on a line that reads
   "1h 40m · MKV" looks like a warning about the file rather than a fact
   about the film. */
.poster__facts {
  font-size: var(--fs-xs);
  color: var(--c-text-dim);
  letter-spacing: 0.04em;
}

.poster__plot {
  font-size: var(--fs-sm);
  line-height: 1.45;
  color: var(--c-text-dim);
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
}

.poster__people {
  font-size: var(--fs-xs);
  color: var(--c-text-faint);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* The wide cell is tall enough for three lines of plot; the narrow one is
   never shown at all, so the clamp only needs to change with the breakpoint. */
@media (min-width: 1600px) {
  .vgrid--wide .poster__plot { -webkit-line-clamp: 3; }
}

/* In wide mode the sub-line under the name duplicates the facts line. */
.vgrid--wide .poster__sub .poster__year,
.vgrid--wide .poster__sub .poster__rating { display: none; }

.vgrid--wide .poster__meta { justify-content: flex-start; padding: var(--sp-3) 0; overflow: hidden; }
/* The meta is a fixed-height column, so something has to give when the plot
   runs long — and by default the title did, shrinking to half a line and
   cutting its own text through the middle. The title keeps its height; the
   plot below it is already clamped. */
.vgrid--wide .poster__name { -webkit-line-clamp: 1; flex: 0 0 auto; }

/* ---- single-row layout ------------------------------------------------ */

/* One strip of cards that slides sideways. The strip takes what the pane
   leaves after the details below it, and the cards take the strip's height. */
.vgrid--row .vgrid__viewport { overflow-x: auto; overflow-y: hidden; }

/* What the cursor is on, under the strip: facts, plot, credits. A fixed
   height for the same reason as .focused-title — a panel that grew and
   shrank with the plot would move the strip on every press. */
.row-detail {
  flex: 0 0 auto;
  height: 150px;
  padding-top: var(--sp-4);
  overflow: hidden;
}
.row-detail .poster__detail { margin-top: 0; gap: var(--sp-2); }
.row-detail .poster__facts  { font-size: var(--fs-sm); }
.row-detail .poster__plot   { font-size: var(--fs-base); -webkit-line-clamp: 3; max-width: 90ch; }
.row-detail .poster__plot.is-loading { color: var(--c-text-faint); font-style: italic; }
@media (min-width: 2560px) { .row-detail { height: 280px; } }

/* ---- action button internals ----------------------------------------- */

.btn__glyph { display: inline-flex; align-items: center; flex: 0 0 auto; }
.btn__glyph[hidden] { display: none; }
.btn__label { display: inline-block; }

/* ---- search result artwork -------------------------------------------
   A result row is type-agnostic, so the art box changes shape rather than
   forcing every result into the channel-logo aspect. `contain` for logos
   (which carry their own padding and must not be cropped) and `cover` for
   posters (which are already the right shape and should fill). The art
   sits in a fixed-width slot so titles line up whatever the shape. */

.srch-row__art {
  flex: 0 0 72px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.srch-art {
  flex: 0 0 auto;
  border-radius: 6px;
  background: var(--c-surface-2);
}
.srch-art--wide   { width: 72px; height: 40px; object-fit: contain; }
/* Exactly 2:3, the aspect posters are actually delivered in, so `cover`
   has nothing to crop. */
.srch-art--poster { width: 40px; height: 60px; object-fit: cover; }

@media (min-width: 2560px) {
  .srch-row__art    { flex-basis: 128px; }
  .srch-art--wide   { width: 128px; height: 72px; }
  .srch-art--poster { width: 72px; height: 108px; }
}

/* ---- search result rows -----------------------------------------------
   Its own layout rather than .ch-row: a film has no channel number and no
   favourite marker, and reserving columns for both left a dead 90px gutter
   down the left of every result while the title truncated for want of the
   same space. */

.srch-row {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  padding: 0 var(--sp-4) 0 var(--sp-2);
  border-radius: var(--r-md);
  background: transparent;
  border-bottom: 1px solid var(--c-line);
}
.srch-row.is-focused { background: var(--c-surface-2); border-bottom-color: transparent; }

.srch-row__body {
  flex: 1 1 auto;
  min-width: 0;          /* lets the marquee measure its own overflow */
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.srch-row__name {
  font-size: var(--fs-base);
  color: var(--c-text-dim);
  width: 100%;
}
/* What matched is the brightest thing on the row. */
.srch-hit { color: var(--c-text); font-weight: var(--fw-bold); }

.srch-row__meta {
  font-size: var(--fs-xs);
  color: var(--c-text-faint);
  letter-spacing: 0.03em;
}
.srch-row__meta[hidden] { display: none; }

/* One colour per library, used by the row tag and the summary counts. */
.srch-tag {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: var(--r-pill);
  font-size: var(--fs-xs);
  font-weight: var(--fw-medium);
  letter-spacing: 0.04em;
  background: var(--c-surface-2);
}
.srch-tag--live   { color: #5EC2FF; }
.srch-tag--movie  { color: #FFB84D; }
.srch-tag--series { color: #B49CFF; }
.srch-tag .icon   { color: inherit; }
.srch-row.is-focused .srch-tag { background: var(--c-surface-3); }


/* ---- the player control bar --------------------------------------------
   Sits above the <video> surface, which is a sibling fixed element at
   --z-player. The layer is pointer-transparent; only the things that take
   input turn pointer events back on, because on a TV nothing is clicked and
   a stray hover must not swallow a key.

   The chrome uses `visibility` as well as `opacity` when it is down, and
   that is load-bearing rather than tidy: focus.js excludes a candidate on
   `visibility: hidden` but not on `opacity: 0`, so without it every control
   would still be focusable behind a bar nobody can see, and the arrows
   would move an invisible cursor. */

.pl {
  position: fixed;
  inset: 0;
  z-index: calc(var(--z-player) + 1);
  pointer-events: none;
  color: #fff;
}

.pl__chrome {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: var(--safe-y) var(--safe-x);
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--t-base) var(--ease), visibility 0s linear var(--t-base);
  /* Legible over any frame without dimming the middle of the picture. */
  background:
    linear-gradient(to bottom, rgba(0,0,0,0.72) 0%, rgba(0,0,0,0) 22%),
    linear-gradient(to top,    rgba(0,0,0,0.88) 0%, rgba(0,0,0,0) 46%);
}
.pl__chrome.is-shown {
  opacity: 1;
  visibility: visible;
  transition: opacity var(--t-base) var(--ease), visibility 0s;
}

.pl__top { display: flex; align-items: flex-start; gap: var(--sp-4); }
.pl__spacer { flex: 1 1 auto; }

.pl__badge {
  display: inline-flex;
  align-items: center;
  height: 34px;
  padding: 0 var(--sp-4);
  border-radius: 999px;
  background: var(--c-accent);
  color: #fff;
  font-size: var(--fs-xs);
  font-weight: var(--fw-bold);
  letter-spacing: 0.14em;
}
.pl__badge[hidden] { display: none; }

/* A quiet reminder that the picture or the speed is not on its default. */
.pl__pill {
  display: inline-flex;
  align-items: center;
  height: 34px;
  padding: 0 var(--sp-4);
  border-radius: 999px;
  background: rgba(0,0,0,0.55);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.28);
  font-size: var(--fs-xs);
  letter-spacing: 0.08em;
}
.pl__pill[hidden] { display: none; }

.pl__bottom { display: flex; flex-direction: column; gap: var(--sp-2); }

.pl__title {
  font-size: var(--fs-xl);
  font-weight: var(--fw-bold);
  line-height: 1.1;
  text-shadow: 0 2px 12px rgba(0,0,0,0.6);
}

.pl__sub {
  font-size: var(--fs-sm);
  color: rgba(255,255,255,0.78);
}

/* ---- the scrub bar ------------------------------------------------------
   Focusable in its own right. While it holds focus it claims Left/Right,
   which is why it needs to look unmistakably different from a button that
   merely happens to be wide. */

.pl__scrub {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  margin-top: var(--sp-3);
  pointer-events: auto;
}
.pl__scrub[hidden] { display: none; }

.pl__time { font-size: var(--fs-sm); color: rgba(255,255,255,0.85); min-width: 6ch; }
.pl__time:last-child { text-align: right; }

.pl__bar {
  position: relative;
  flex: 1 1 auto;
  height: 6px;
  border-radius: 999px;
  background: rgba(255,255,255,0.22);
  cursor: default;
}

/* How far the network has got. Behind the fill, never in front of it. */
.pl__buffered {
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 0;
  border-radius: 999px;
  background: rgba(255,255,255,0.30);
}

.pl__fill {
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 0;
  border-radius: 999px;
  background: var(--c-accent);
  transition: width var(--t-fast) linear;
}

.pl__head {
  position: absolute;
  top: 50%;
  left: 0;
  width: 14px;
  height: 14px;
  margin: -7px 0 0 -7px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 8px rgba(0,0,0,0.65);
  opacity: 0;
  transition: opacity var(--t-fast) var(--ease);
}

/* The head only appears once the bar is the thing being used — a dot that
   sat there permanently would read as a control when it is a readout. */
.pl__bar.is-focused .pl__head,
.pl__bar.is-scrubbing .pl__head { opacity: 1; }

.pl__bar.is-focused,
.pl__bar.is-scrubbing {
  height: 10px;
  background: rgba(255,255,255,0.30);
}
.pl__bar.is-scrubbing .pl__fill {
  background: #fff;
  transition: none;             /* the target must track the key, not lag it */
}

/* The target time, and how far it is from where playback actually is. */
.pl__bubble {
  position: absolute;
  bottom: calc(100% + 14px);
  transform: translateX(-50%);
  white-space: nowrap;
  padding: var(--sp-2) var(--sp-4);
  border-radius: var(--r-sm);
  background: rgba(0,0,0,0.88);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.22);
  font-size: var(--fs-sm);
}
.pl__bubble[hidden] { display: none; }

/* ---- the control row ----------------------------------------------------- */

.pl__controls {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  flex-wrap: wrap;
  margin-top: var(--sp-4);
  pointer-events: auto;
}

.pl__divider {
  width: 1px;
  height: 26px;
  margin: 0 var(--sp-3);
  background: rgba(255,255,255,0.22);
}

/* Transport buttons are glyph-only and round: they are the controls a
   viewer reaches for without reading, so they get shape instead of a word.
   Kept small — the picture is what is being watched, and a row of big
   buttons over it reads as a toolbar rather than as a light touch. */
.btn--transport {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  position: relative;
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  /* .btn carries min-height: 54px, and a min-height beats a height — which
     is what stretched these into ovals when they were first drawn. */
  min-height: 0;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(255,255,255,0.13);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.16);
  color: #fff;
  cursor: default;
}

/* The labelled options beside them, quieter than an ordinary action button
   because the picture behind them is the thing being looked at. */
.btn--player {
  flex: 0 0 auto;
  height: 44px;
  min-height: 0;                /* see the note on .btn--transport */
  padding: 0 var(--sp-4);
  gap: var(--sp-2);
  border: 0;
  border-radius: 999px;
  background: rgba(255,255,255,0.13);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.16);
  color: #fff;
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
}
.btn--player .btn__label { letter-spacing: 0.02em; }
.btn--player .icon { opacity: 0.9; }
.btn--quiet { background: rgba(255,255,255,0.07); }

/* Focus over a moving picture cannot rely on a background change alone, so
   it gets a solid plate, a ring and a lift.

   The glyph rule below is not decoration. `.btn.is-focused .icon` up in the
   shared focus block pins every focused button's icon to --c-text, which is
   near-white — at specificity (0,3,0) it beat the (0,2,0) colour set on the
   button itself and painted a white glyph onto a white plate. The focused
   play button was a blank white disc. Matching that specificity is what
   makes the icon follow its button. */
.btn--transport.is-focused,
.btn--player.is-focused {
  background: #fff;
  color: #0a0d12;
  box-shadow: inset 0 0 0 var(--focus-width) var(--c-accent),
              0 4px 16px rgba(0,0,0,0.5);
}
.btn--transport.is-focused .icon,
.btn--player.is-focused .icon { color: #0a0d12; opacity: 1; }

/* Doubled class deliberately.
   responsive-tv.css re-sets `.btn { min-height }` per breakpoint and loads
   after this file, so a plain `.btn--transport { min-height: 0 }` loses to
   it at every tier and the round buttons come out as ovals. (0,2,0) beats
   `.btn` wherever it is written. */
.btn.btn--transport,
.btn.btn--player { min-height: 0; }

/* ---- the menus ----------------------------------------------------------
   One panel at a time, above the control row it covers. Its rows are
   ordinary focusables, so the same spatial navigation drives them; the row
   underneath is marked data-focus-disabled by controls.js while a panel is
   open so focus cannot slip behind it. */

.pl__menu { pointer-events: auto; }
.pl__menu[hidden] { display: none; }

.pl-menu {
  width: 440px;
  max-width: 44vw;
  margin-bottom: var(--sp-4);
  padding: var(--sp-2);
  border-radius: var(--pop-radius);
  background: var(--pop-bg);
  box-shadow: var(--pop-shadow);
  animation: pop-in var(--t-base) var(--ease);
}

@keyframes pop-in {
  from { opacity: 0; transform: translateY(8px) scale(0.985); }
  to   { opacity: 1; transform: none; }
}

.pl-menu__title {
  padding: var(--sp-2) var(--sp-3) var(--sp-3);
  margin-bottom: var(--sp-1);
  border-bottom: 1px solid var(--pop-line);
  font-size: var(--fs-xs);
  font-weight: var(--fw-bold);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.55);
}

.pl-menu__list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 44vh;
  overflow-y: auto;
  padding: 2px 0;
  scrollbar-width: none;
}
.pl-menu__list::-webkit-scrollbar { width: 0; height: 0; display: none; }

.pl-menu__row {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  width: 100%;
  min-height: var(--pop-row-h);
  padding: 0 var(--sp-3);
  border: 0;
  border-radius: calc(var(--pop-radius) - 6px);
  background: transparent;
  color: rgba(255,255,255,0.82);
  font-size: var(--fs-sm);
  text-align: left;
  cursor: default;
  transition: background-color var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}

.pl-menu__tick {
  flex: 0 0 auto;
  width: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--c-accent);
}

.pl-menu__label {
  flex: 1 1 auto;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* The current value of a row that cycles, and the aside on a row that
   explains itself. Both sit right, both stay quiet. */
.pl-menu__value {
  flex: 0 0 auto;
  color: #fff;
  font-weight: var(--fw-bold);
}
.pl-menu__note-inline {
  flex: 0 0 auto;
  font-size: var(--fs-xs);
  color: rgba(255,255,255,0.45);
  font-variant-numeric: tabular-nums;
}

.pl-menu__row.is-current { color: #fff; font-weight: var(--fw-medium); }

.pl-menu__row.is-focused {
  background: var(--pop-focus-bg);
  color: var(--pop-focus-text);
  box-shadow: none;
  /* A full-width row that grows under the cursor pokes out of its panel;
     the light fill is the whole affordance. */
  transform: none;
}
.pl-menu__row.is-focused .pl-menu__value { color: var(--pop-focus-text); }
.pl-menu__row.is-focused .pl-menu__note-inline { color: rgba(10,13,17,0.55); }

/* The explanation under a menu that has something to explain — why a
   stream carries no subtitles, why there is nothing to choose between. */
.pl-menu__note {
  margin: var(--sp-2) 0 0;
  padding: var(--sp-3) var(--sp-3) var(--sp-2);
  border-top: 1px solid var(--pop-line);
  font-size: var(--fs-xs);
  line-height: 1.5;
  color: rgba(255,255,255,0.52);
}

/* The episode menu of a series with more than one season: the seasons in a
   narrow column beside the episodes, so both are on screen at once. */
.pl-menu--split {
  display: flex;
  gap: var(--sp-2);
  width: 680px;
  max-width: 68vw;
}
.pl-menu__col { flex: 1 1 auto; min-width: 0; }
.pl-menu__col--seasons {
  flex: 0 0 34%;
  padding-right: var(--sp-2);
  border-right: 1px solid var(--pop-line);
}

@media (min-width: 2560px) {
  .pl-menu { width: 760px; }
  .pl-menu--split { width: 1180px; }
  .pl-menu__tick { width: 30px; }
}

/* ---- spinner and failure -------------------------------------------------- */

/* The spinner is centred over the picture and stays put while buffering. */
.pl > .spinner {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  flex-direction: column;
  gap: var(--sp-4);
  text-shadow: 0 2px 10px rgba(0,0,0,0.7);
}

/* The one thing that does take input unconditionally. */
.pl__error {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--safe-y) var(--safe-x);
  background: radial-gradient(ellipse at center, rgba(8,10,14,0.72) 0%, rgba(8,10,14,0.94) 70%);
  pointer-events: auto;
}
.pl__error[hidden] { display: none; }

/* The failure itself is a card, not a wall of text across the screen. */
.pl__error .state-block {
  height: auto;
  min-height: 0;
  max-width: 680px;
  gap: var(--sp-3);
  padding: var(--sp-6) var(--sp-7);
  border-radius: calc(var(--pop-radius) + 6px);
  background: var(--pop-bg);
  box-shadow: var(--pop-shadow);
  animation: pop-in var(--t-base) var(--ease);
}
.pl__error .state-block__title { font-size: var(--fs-lg); }
.pl__error .state-block__text  { font-size: var(--fs-sm); line-height: 1.45; }
.pl__error .state-block__actions { margin-top: var(--sp-3); }

@media (min-width: 2560px) {
  .pl__error .state-block { max-width: 1180px; }
}

/* ---- channel switching (Phase 9) ----------------------------------------
   Three affordances, all of which sit OUTSIDE .pl__chrome. The chrome is
   `visibility: hidden` when the bar is down, and every one of these is
   meant to work while it is down — that is the whole point of them. */

.pl__layer { position: absolute; inset: 0; }

/* The banner a channel change puts up. Deliberately small and top-left:
   it answers "what am I on now?" without taking the picture. */
.pl-banner {
  position: absolute;
  left: var(--safe-x);
  top: var(--safe-y);
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  max-width: 48%;
  padding: var(--sp-2) var(--sp-5) var(--sp-2) var(--sp-2);
  border-radius: var(--pop-radius);
  background: var(--pop-bg);
  box-shadow: var(--pop-shadow);
  animation: banner-in var(--t-base) var(--ease);
}
.pl-banner[hidden] { display: none; }

@keyframes banner-in {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: none; }
}

.pl-banner__num {
  flex: 0 0 auto;
  min-width: 56px;
  padding: var(--sp-2) var(--sp-3);
  border-radius: calc(var(--pop-radius) - 6px);
  background: var(--c-accent);
  color: #fff;
  font-size: var(--fs-md);
  font-weight: var(--fw-bold);
  line-height: 1;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.pl-banner__body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.pl-banner__name {
  font-size: var(--fs-md);
  font-weight: var(--fw-bold);
  line-height: 1.15;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pl-banner__sub {
  font-size: var(--fs-xs);
  color: rgba(255,255,255,0.62);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pl-banner__sub[hidden] { display: none; }

/* The number being typed. Centre-screen, because it is a thing in
   progress and the viewer needs to see it without hunting — but a compact
   chip rather than a slab over the picture. */
.pl-entry {
  position: absolute;
  left: 50%;
  top: 20%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-1);
  min-width: 160px;
  padding: var(--sp-4) var(--sp-6) var(--sp-3);
  border-radius: calc(var(--pop-radius) + 4px);
  background: var(--pop-bg);
  box-shadow: inset 0 calc(-1 * var(--focus-accent)) 0 0 var(--c-accent), var(--pop-shadow);
  color: #fff;
  animation: pop-in var(--t-fast) var(--ease);
}
.pl-entry[hidden] { display: none; }

.pl-entry__value {
  font-size: var(--fs-2xl);
  font-weight: var(--fw-bold);
  letter-spacing: 0.1em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.pl-entry__note {
  font-size: var(--fs-xs);
  color: rgba(255,255,255,0.55);
  min-height: 1.2em;
}

/* The channel list: a floating card over the picture rather than a
   curtain down the side of it. */
.pl-channels {
  position: absolute;
  right: var(--sp-6);
  top: var(--safe-y);
  bottom: var(--safe-y);
  width: 500px;
  max-width: 42vw;
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  padding: var(--sp-3) var(--sp-2) var(--sp-3);
  border-radius: calc(var(--pop-radius) + 4px);
  background: var(--pop-bg);
  box-shadow: var(--pop-shadow);
  pointer-events: auto;
  animation: channels-in var(--t-base) var(--ease);
}
.pl-channels[hidden] { display: none; }

@keyframes channels-in {
  from { opacity: 0; transform: translateX(24px); }
  to   { opacity: 1; transform: none; }
}

/* The list itself takes the remaining height; the title and hints do not. */
.pl-channels > .vlist { flex: 1 1 auto; min-height: 0; }

.pl-channels > .pane-title {
  padding: var(--sp-1) var(--sp-3) var(--sp-3);
  margin: 0;
  border-bottom: 1px solid var(--pop-line);
}
.pl-channels > .hints { padding: var(--sp-2) var(--sp-3) 0; border-top: 1px solid var(--pop-line); }

.pl-channels .ch-row {
  gap: var(--sp-3);
  padding: 0 var(--sp-3);
  border-radius: calc(var(--pop-radius) - 6px);
}
.pl-channels .ch-row__num  { flex-basis: 52px; font-size: var(--fs-xs); }
.pl-channels .ch-row__logo { width: 64px; height: 36px; }
.pl-channels .ch-row__name { font-size: var(--fs-sm); }

/* Rows slide under the header and the hints rather than being cut off by
   them. A prefixed mask is the one kind old TV engines honour; where it is
   not supported the list is simply clipped, as it was. */
.pl-channels .vlist__viewport {
  -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 14px, #000 calc(100% - 14px), transparent 100%);
          mask-image: linear-gradient(to bottom, transparent 0, #000 14px, #000 calc(100% - 14px), transparent 100%);
}
.pl-channels .ch-row.is-focused {
  background: rgba(255,255,255,0.13);
  box-shadow: inset 0 0 0 var(--focus-width) rgba(255,255,255,0.85);
}

@media (min-width: 2560px) {
  .pl-channels { width: 880px; }
  .pl-channels .ch-row__num  { flex-basis: 90px; }
  .pl-channels .ch-row__logo { width: 112px; height: 63px; }
  .pl-entry { min-width: 280px; }
}

/* The channel you are watching stays marked while you browse past it. */
.pl-channels .ch-row.is-current .ch-row__num { color: var(--c-accent); }
.pl-channels .ch-row.is-current:not(.is-focused) { background: rgba(255,255,255,0.05); }

/* ---- live preview ------------------------------------------------------ */

/* The channel list and, beside it, the preview of whatever it is on. */
.live-body {
  display: flex;
  gap: var(--sp-5);
  min-height: 0;
}
.live-body > .vlist { flex: 1 1 auto; min-width: 0; }

.live-preview {
  flex: 0 0 min(34vw, 520px);
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
  min-width: 0;
}

/* The box the video is laid over. What shows before the first frame —
   and instead of one, if there is none — is the channel's logo. */
.live-preview__screen {
  position: relative;
  width: 100%;
  /* 16:9 by padding, not aspect-ratio — see the note on .nav-item. */
  height: 0;
  padding-top: 56.25%;
  border-radius: var(--r-md);
  background: radial-gradient(ellipse at center, var(--c-surface-2) 0%, var(--c-surface) 80%);
  box-shadow: var(--pop-shadow);
  overflow: hidden;
}
.live-preview__logo {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 40%;
  height: 45%;
  object-fit: contain;
  opacity: 0.9;
}
.live-preview__status {
  position: absolute;
  left: 0;
  right: 0;
  bottom: var(--sp-3);
  text-align: center;
  font-size: var(--fs-xs);
  color: var(--c-text-dim);
}
.live-preview__screen[data-state="loading"] .live-preview__logo { animation: preview-pulse 1.4s var(--ease) infinite; }
@keyframes preview-pulse {
  0%, 100% { opacity: 0.9; }
  50%      { opacity: 0.45; }
}

.live-preview__info { display: flex; flex-direction: column; gap: var(--sp-1); min-width: 0; }
.live-preview__name {
  font-size: var(--fs-md);
  font-weight: var(--fw-bold);
  line-height: 1.2;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
}
.live-preview__meta { font-size: var(--fs-sm); color: var(--c-text-dim); }
.live-preview__now  { font-size: var(--fs-sm); color: var(--c-text); }
.live-preview__hint { margin-top: var(--sp-2); font-size: var(--fs-xs); color: var(--c-text-faint); }

@media (min-width: 2560px) {
  .live-preview { flex-basis: min(34vw, 900px); }
}
/* The preview used to vanish at 1400px, and on the E7N it did — the set
   reports a viewport at or under that width (the exact figure is still
   unmeasured; /tools/env-probe.html shows it). 1280 fits three panes with a
   narrower preview. Below 1000 it is too tight, and the list matters more
   than the picture. */
@media (max-width: 1400px) {
  .live-body { gap: var(--sp-4); }
  .live-preview { flex-basis: 30vw; gap: var(--sp-3); }
}
@media (max-width: 1000px) {
  .live-preview { display: none; }
}

/* ---- accounts ----------------------------------------------------------------
   "Who's watching": a centred row of avatars, the one under the cursor
   lifting forward, the one in use ringed in the accent. The panel beneath
   describes whichever avatar the cursor is on. */

.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  border-radius: 50%;
  color: #fff;
  font-weight: var(--fw-bold);
  letter-spacing: 0.02em;
  line-height: 1;
  text-shadow: 0 2px 8px rgba(0,0,0,0.35);
  box-shadow: inset 0 -10px 24px rgba(0,0,0,0.25), inset 0 1px 0 rgba(255,255,255,0.18);
  user-select: none;
}

.acc {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-top: var(--sp-7);
  overflow-y: auto;
  background: radial-gradient(ellipse 70% 50% at 50% 0%, rgba(229,9,20,0.10) 0%, rgba(229,9,20,0) 70%);
}
.acc::-webkit-scrollbar { width: 0; height: 0; display: none; }

.acc__hero { text-align: center; margin-bottom: var(--sp-7); }
.acc__title {
  font-size: var(--fs-2xl);
  font-weight: var(--fw-bold);
  letter-spacing: -0.02em;
  line-height: 1.05;
}
.acc__sub { margin-top: var(--sp-3); font-size: var(--fs-sm); color: var(--c-text-dim); }

.acc__tiles {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--sp-6);
  max-width: 1400px;
  padding: var(--sp-3) var(--sp-4) var(--sp-5);
}

.acc-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-2);
  width: 210px;
  padding: var(--sp-3) var(--sp-2);
  background: transparent;
  border-radius: var(--r-lg);
  color: var(--c-text-dim);
  transition: transform var(--t-base) var(--ease), color var(--t-fast) var(--ease);
}
.acc-tile__ring {
  position: relative;
  display: inline-flex;
  padding: 6px;
  border-radius: 50%;
  box-shadow: 0 0 0 2px transparent;
  transition: box-shadow var(--t-base) var(--ease), transform var(--t-base) var(--ease);
}
.acc-tile__avatar {
  width: 150px;
  height: 150px;
  font-size: 56px;
  opacity: 0.82;
  transition: opacity var(--t-base) var(--ease), box-shadow var(--t-base) var(--ease);
}
.acc-tile__plus {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: transparent;
  border: 2px dashed rgba(255,255,255,0.28);
  color: var(--c-text-dim);
  box-shadow: none;
}
.acc-tile__badge {
  position: absolute;
  right: 6px;
  bottom: 10px;
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--c-accent);
  color: #fff;
  box-shadow: 0 0 0 4px var(--c-bg, #0B0E12), 0 4px 12px rgba(0,0,0,0.5);
}
.acc-tile__name {
  max-width: 100%;
  font-size: var(--fs-base);
  font-weight: var(--fw-medium);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.acc-tile__meta {
  max-width: 100%;
  font-size: var(--fs-xs);
  color: var(--c-text-faint);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.acc-tile.is-active .acc-tile__ring { box-shadow: 0 0 0 3px var(--c-accent); }
.acc-tile.is-active .acc-tile__avatar { opacity: 1; }
.acc-tile.is-active .acc-tile__meta { color: var(--c-accent); }

/* Focus: the avatar comes forward and gets a white ring and a glow — no
   generic box ring around the whole tile, which would square off a circle. */
.acc-tile.is-focused {
  transform: translateY(-6px);
  box-shadow: none;
  color: var(--c-text);
}
.acc-tile.is-focused .acc-tile__ring {
  transform: scale(1.08);
  box-shadow: 0 0 0 4px #fff, 0 18px 50px rgba(0,0,0,0.6);
}
.acc-tile.is-focused .acc-tile__avatar { opacity: 1; }
.acc-tile.is-focused .acc-tile__plus { border-color: #fff; color: #fff; }
.acc-tile.is-focused .acc-tile__meta { color: var(--c-text-dim); }

/* The panel: one card, glassy, holding the selected account's facts. */
.acc-panel {
  width: min(980px, 90%);
  margin-top: var(--sp-5);
  padding: var(--sp-5) var(--sp-6);
  border-radius: calc(var(--pop-radius) + 6px);
  background: var(--pop-bg);
  box-shadow: var(--pop-shadow);
  border: 1px solid var(--pop-line);
  animation: dialog-in var(--t-base) var(--ease);
}
.acc-panel--quiet { text-align: center; }
.acc-panel__lead { font-size: var(--fs-sm); color: var(--c-text-dim); line-height: 1.5; margin-bottom: var(--sp-5); }
.acc-panel--quiet .acc-panel__actions { justify-content: center; }

.acc-panel__head { display: flex; align-items: center; gap: var(--sp-4); }
.acc-panel__who { flex: 1 1 auto; min-width: 0; }
.acc-panel__name { font-size: var(--fs-lg); font-weight: var(--fw-bold); line-height: 1.15;
                   white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.acc-panel__when { margin-top: 2px; font-size: var(--fs-xs); color: var(--c-text-faint); letter-spacing: 0.03em; }

.acc-pill {
  flex: 0 0 auto;
  padding: 6px 14px;
  border-radius: var(--r-pill);
  font-size: 13px;
  font-weight: var(--fw-bold);
  letter-spacing: 0.12em;
}
.acc-pill--ok   { background: rgba(16,185,129,0.16); color: #34D399; box-shadow: inset 0 0 0 1px rgba(52,211,153,0.35); }
.acc-pill--warn { background: rgba(245,158,11,0.16); color: #FBBF24; box-shadow: inset 0 0 0 1px rgba(251,191,36,0.35); }

.acc-panel__facts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--sp-3) var(--sp-6);
  margin: var(--sp-5) 0;
  padding: var(--sp-4) 0;
  border-top: 1px solid var(--pop-line);
  border-bottom: 1px solid var(--pop-line);
}
.acc-fact { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.acc-fact__label { font-size: 13px; color: var(--c-text-faint); letter-spacing: 0.1em; text-transform: uppercase; }
.acc-fact__value { font-size: var(--fs-sm); color: var(--c-text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.acc-fact__value--ok   { color: #34D399; }
.acc-fact__value--warn { color: #FBBF24; }

.acc-panel__actions { display: flex; flex-wrap: wrap; gap: var(--sp-3); }

/* Switching: the chosen avatar alone on a dark field, its halo breathing
   while the account signs in. */
.acc-switch {
  position: fixed;
  inset: 0;
  z-index: calc(var(--z-dialog) + 10);
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at center, rgba(14,17,22,0.96) 0%, rgba(5,6,8,0.99) 70%);
  animation: acc-fade var(--t-base) var(--ease);
}
@keyframes acc-fade { from { opacity: 0; } to { opacity: 1; } }
.acc-switch__inner { display: flex; flex-direction: column; align-items: center; gap: var(--sp-4); }
.acc-switch__halo {
  display: inline-flex;
  padding: 10px;
  border-radius: 50%;
  animation: acc-breathe 1.6s var(--ease) infinite;
}
@keyframes acc-breathe {
  0%, 100% { box-shadow: 0 0 0 3px rgba(255,255,255,0.85), 0 0 0 0 rgba(229,9,20,0.45); }
  50%      { box-shadow: 0 0 0 3px rgba(255,255,255,0.85), 0 0 0 26px rgba(229,9,20,0); }
}
.acc-switch.is-done .acc-switch__halo { animation: none; box-shadow: 0 0 0 4px #34D399; }
.acc-switch__name { font-size: var(--fs-xl); font-weight: var(--fw-bold); }
.acc-switch__line { font-size: var(--fs-sm); color: var(--c-text-dim); letter-spacing: 0.04em; }
@media (prefers-reduced-motion: reduce) { .acc-switch__halo { animation: none; } }

/* The account's avatar standing in for an icon in the menu. */
.nav-item__avatar { font-size: 12px; box-shadow: 0 0 0 2px rgba(255,255,255,0.15); }
.nav-item.is-current .nav-item__avatar { box-shadow: 0 0 0 2px var(--c-accent); }

@media (min-width: 2560px) {
  .acc-tile { width: 380px; }
  .acc-tile__avatar { width: 270px; height: 270px; font-size: 100px; }
  .acc-tile__badge { width: 64px; height: 64px; }
}
@media (max-width: 1400px) {
  .acc { padding-top: var(--sp-5); }
  .acc__hero { margin-bottom: var(--sp-5); }
  .acc-tile { width: 160px; }
  .acc-tile__avatar { width: 112px; height: 112px; font-size: 42px; }
}


/* ---- dialog badge, danger buttons, and the exit card ---------------------
   A badge is the dialog's icon, large, in a softly glowing disc above the
   title. A destructive button stays quiet until focused, then turns red:
   the colour arrives exactly when the choice is about to be made. */

.dialog__badge {
  width: 72px;
  height: 72px;
  margin: 0 auto var(--sp-4);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  color: #fff;
  background: radial-gradient(circle at 30% 25%, #FF4D57 0%, var(--c-accent) 45%, #7A0A12 100%);
  box-shadow: 0 0 0 6px rgba(229,9,20,0.14), 0 0 40px rgba(229,9,20,0.45), inset 0 1px 0 rgba(255,255,255,0.3);
}
.dialog__badge .icon { color: #fff; }

.btn--danger.is-focused {
  background: var(--c-accent);
  color: #fff;
  box-shadow: inset 0 0 0 var(--focus-width) rgba(255,255,255,0.9), 0 8px 28px rgba(229,9,20,0.45);
}
.btn--danger.is-focused .icon { color: #fff; }

.dialog--exit {
  width: 560px;
  max-width: 90vw;
  padding: var(--sp-6) var(--sp-5) var(--sp-5);
  text-align: center;
}
.dialog--exit .dialog__title { font-size: var(--fs-lg); margin-bottom: var(--sp-1); }
.dialog--exit .dialog__text  { font-size: var(--fs-xs); margin-bottom: var(--sp-5); color: var(--c-text-faint); }
.dialog--exit .dialog__actions { flex-wrap: nowrap; gap: var(--sp-3); }
.dialog--exit .dialog__actions .btn {
  flex: 1 1 0;
  justify-content: center;
  min-width: 0;
  height: 56px;
  padding: 0 var(--sp-3);
  font-size: var(--fs-sm);
  white-space: nowrap;
}
@media (min-width: 2560px) {
  .dialog--exit { width: 820px; }
  .dialog__badge { width: 128px; height: 128px; }
  .dialog--exit .dialog__actions .btn { height: 100px; }
}

/* ---- icon actions on a details page ------------------------------------------
   Round, icon-only. The focused one lifts and turns light, and its name
   appears beneath it as a small pill — the words are there exactly when
   OK is about to do what they say. Room for the pill is reserved under
   the row (it is the last thing in a scrolling column), so it is never
   clipped. */

.detail__actions--icons {
  gap: var(--sp-4);
  align-items: center;
  /* The column scrolls, so it clips: room below for the hint, and at the
     left for the first button's lift and ring. */
  padding: 8px 0 52px 12px;
}
/* The first button's hint starts at its left edge instead of centring,
   which would push it out of the column. */
.detail__actions--icons > .btn-icon:first-child .btn-icon__tip {
  left: 0;
  transform: translate(0, -4px) scale(0.92);
  transform-origin: left center;
}
.detail__actions--icons > .btn-icon:first-child.is-focused .btn-icon__tip {
  transform: translate(0, 0) scale(0.91);
}

.btn-icon {
  position: relative;
  flex: 0 0 auto;
  width: 64px;
  height: 64px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: rgba(255,255,255,0.08);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.12);
  color: var(--c-text);
  transition: transform var(--t-fast) var(--ease), background-color var(--t-fast) var(--ease),
              box-shadow var(--t-fast) var(--ease);
}
.btn-icon__glyph { display: inline-flex; }
.btn-icon .icon { color: currentColor; }

.btn-icon--primary {
  width: 84px;
  height: 84px;
  background: var(--c-accent);
  color: #fff;
  box-shadow: 0 8px 26px rgba(229,9,20,0.35);
}

.btn-icon.is-focused {
  transform: scale(1.1);
  background: var(--c-action);
  color: var(--c-action-text);
  box-shadow: 0 0 0 4px rgba(255,255,255,0.18), 0 14px 34px rgba(0,0,0,0.55);
}
.btn-icon--primary.is-focused {
  background: #fff;
  color: var(--c-accent);
  box-shadow: 0 0 0 5px rgba(229,9,20,0.55), 0 14px 40px rgba(229,9,20,0.45);
}

/* The hint: hidden until focus, then fades up into place. */
.btn-icon__tip {
  position: absolute;
  top: calc(100% + 12px);
  left: 50%;
  transform: translate(-50%, -4px) scale(0.92);
  padding: 6px 14px;
  border-radius: var(--r-pill);
  background: rgba(10,13,17,0.92);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.14), 0 6px 18px rgba(0,0,0,0.5);
  color: #fff;
  font-size: var(--fs-xs);
  font-weight: var(--fw-medium);
  letter-spacing: 0.02em;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--t-fast) var(--ease), transform var(--t-fast) var(--ease);
}
.btn-icon.is-focused .btn-icon__tip {
  opacity: 1;
  /* Undo the button's own scale so the text stays its real size. */
  transform: translate(-50%, 0) scale(0.91);
}

@media (min-width: 2560px) {
  .btn-icon { width: 112px; height: 112px; }
  .btn-icon--primary { width: 148px; height: 148px; }
  .detail__actions--icons { padding-bottom: 92px; }
}
@media (max-width: 1400px) {
  .btn-icon { width: 52px; height: 52px; }
  .btn-icon--primary { width: 68px; height: 68px; }
}

/* A watched episode keeps its full bar; its number steps back so the
   unwatched ones ahead read as what is next. */
.episode.is-watched .episode__n { color: var(--c-text-faint); }

/* ---- watched / watching ribbon ---------------------------------------------
   A band across the foot of the artwork's left side, with a notched tail,
   just above the progress bar. The corners belong to the heart and the
   rating. Shadow by drop-shadow, because clip-path cuts a box-shadow off. */

.poster__ribbon {
  position: absolute;
  left: 0;
  bottom: 14px;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 18px 5px 10px;
  font-size: 12px;
  font-weight: var(--fw-bold);
  letter-spacing: 0.12em;
  line-height: 1;
  color: #fff;
  clip-path: polygon(0 0, 100% 0, calc(100% - 9px) 50%, 100% 100%, 0 100%);
  /* No filter/drop-shadow: a filter on every ribbon in a grid is an
     offscreen pass per card per frame on a TV. The band's colour carries it. */
  pointer-events: none;
}
.poster__ribbon[hidden] { display: none; }
.poster__ribbon .icon { color: #fff; }

.poster__ribbon--watched  { background: linear-gradient(90deg, #059669 0%, #10B981 100%); }
.poster__ribbon--watching { background: linear-gradient(90deg, #B0242B 0%, var(--c-accent) 100%); }

.poster__ribbon-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #fff;
  /* Still, deliberately: a pulse on every "watching" card kept the whole
     grid repainting forever, even with nothing on screen changing. */
}

@media (min-width: 2560px) {
  .poster__ribbon { font-size: 22px; padding: 9px 30px 9px 18px; bottom: 26px; gap: 10px; }
  .poster__ribbon-dot { width: 12px; height: 12px; }
}

/* Showing AND under the cursor: keep both the accent bar and the ring. */
.cat-row.is-current.is-focused {
  box-shadow: inset 4px 0 0 var(--c-accent), inset 0 0 0 var(--focus-width) var(--c-focus);
}
