/* Rabbit Ears - the lineup look: near-black, Rabbit Ears red and one colour
   per category (Option A dark / Option B light). Barlow Condensed carries the
   tall type, Barlow the body. */

:root {
  /* surfaces */
  --bg: #0f1014;
  --bg-2: #15161b;
  --bar: #15161b;
  --panel: #17181e;
  --panel-2: #1e2028;
  --panel-3: #24262f;
  --ink: #eeedf2;
  --ink-2: #c9cbd6;
  --muted: #9a9eae;
  --line: #262832;
  --line-soft: rgba(38, 40, 50, .62);
  /* Rabbit Ears red */
  --accent: #e2232e;
  --accent-ink: #fff;
  --live: #ff4a4f;
  --focus: #fff;
  --sage: #4ade80;
  --blue: #60a5fa;
  --shadow: 0 18px 48px rgba(0, 0, 0, .55);
  /* the printed lineup's category colours */
  --c-news: #c8141f;
  --c-sports: #1d4ed8;
  --c-events: #111827;
  --c-movies: #7c3aed;
  --c-entertainment: #db2777;
  --c-comedy: #d97706;
  --c-crime: #374151;
  --c-reality: #ea580c;
  --c-food: #16a34a;
  --c-documentary: #0f766e;
  --c-classic: #92400e;
  --c-kids: #0284c7;
  --c-music: #9333ea;
  --c-local: #475569;
  --c-other: #6b7280;
  /* layout */
  --rowh: 62px;
  --sech: 40px;
  --chanw: 216px;
  --headh: 44px;
  --topbar: 64px;
  --radius: 12px;
  --display: "Barlow Condensed", "Arial Narrow", "Helvetica Neue", Arial, sans-serif;
  --sans: "Barlow", "Helvetica Neue", Arial, system-ui, sans-serif;
  color-scheme: dark;
}

:root[data-theme="light"] {
  --bg: #f4f4f6;
  --bg-2: #fff;
  --bar: #fff;
  --panel: #fff;
  --panel-2: #f6f7f9;
  --panel-3: #eceef2;
  --ink: #17181c;
  --ink-2: #3a3d49;
  --muted: #61667a;
  --line: #e2e3e8;
  --line-soft: rgba(210, 212, 220, .82);
  --accent: #c8141f;
  --accent-ink: #fff;
  --live: #c8141f;
  --focus: #17181c;
  --sage: #15803d;
  --blue: #1d4ed8;
  --shadow: 0 16px 40px rgba(20, 22, 30, .14);
  color-scheme: light;
}

/* One --cat per category. app.js puts k-<key> on the section band, on each
   channel row (from the channel's own category) and on the On now cards. */
.k-news { --cat: var(--c-news); --num: #e17e84; --now-edge: #771e28; --now-bg: #fbeced; }
.k-sports { --cat: var(--c-sports); --num: #839eea; --now-edge: #223b85; --now-bg: #edf1fc; }
.k-events { --cat: var(--c-events); --num: #7c8088; --now-edge: #1c202c; --now-bg: #ecedee; }
.k-movies { --cat: var(--c-movies); --num: #b793f5; --now-edge: #513190; --now-bg: #f5effe; }
.k-entertainment { --cat: var(--c-entertainment); --num: #eb88b4; --now-edge: #802854; --now-bg: #fceef4; }
.k-comedy { --cat: var(--c-comedy); --num: #eab476; --now-edge: #80501c; --now-bg: #fcf4eb; }
.k-crime { --cat: var(--c-crime); --num: #91969f; --now-edge: #2e3442; --now-bg: #eff0f1; }
.k-reality { --cat: var(--c-reality); --num: #f3a379; --now-edge: #88401f; --now-bg: #fdf2ec; }
.k-food { --cat: var(--c-food); --num: #7fcc9b; --now-edge: #1e663e; --now-bg: #ecf8f1; }
.k-documentary { --cat: var(--c-documentary); --num: #7bb4af; --now-edge: #1a4f50; --now-bg: #ecf4f3; }
.k-classic { --cat: var(--c-classic); --num: #c3967a; --now-edge: #5c3420; --now-bg: #f6f0ec; }
.k-kids { --cat: var(--c-kids); --num: #74bbe0; --now-edge: #14567c; --now-bg: #ebf5fb; }
.k-music { --cat: var(--c-music); --num: #c48ff3; --now-edge: #5c2e8e; --now-bg: #f6effd; }
.k-local { --cat: var(--c-local); --num: #9aa2ac; --now-edge: #363e4e; --now-bg: #f0f1f3; }
.k-other { --cat: var(--c-other); --num: #aeb1b9; --now-edge: #484d59; --now-bg: #f3f4f5; }
.k-__fav { --cat: var(--accent); --num: #ef868c; --now-edge: #842630; --now-bg: #fdedee; }
.k-__nonstop { --cat: var(--c-movies); --num: #b793f5; --now-edge: #513190; --now-bg: #f5effe; }
/* events / crime are almost black: lift the text on a dark band instead. */
:root .sec-head.k-events h2, :root .sec-head.k-crime h2 { color: #c9cbd6; }

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  -webkit-text-size-adjust: 100%;
}

body { overflow: hidden; }
button { font: inherit; color: inherit; }
a { color: var(--accent); }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.app {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  min-height: 100%;
}

/* ------------------------------------------------------------------ topbar */
.topbar {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 10px clamp(12px, 2.2vw, 26px);
  min-height: var(--topbar);
  background: var(--bar);
  border-bottom: 1px solid var(--line);
  z-index: 30;
  flex: 0 0 auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--ink);
  white-space: nowrap;
}
.brand-mark { width: 34px; height: 34px; color: var(--accent); display: block; }
.brand-mark svg { width: 100%; height: 100%; display: block; }
.brand-text {
  font-family: var(--display);
  font-weight: 800;
  font-size: 25px;
  letter-spacing: .01em;
  line-height: 1;
}
.brand-text em { font-style: normal; color: var(--accent); }

.tabs { display: flex; gap: 4px; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 3px; }
.tab {
  border: 0; background: none; padding: 6px 13px; border-radius: 6px;
  color: var(--muted); font-family: var(--display); font-weight: 700;
  font-size: 16px; letter-spacing: .02em; cursor: pointer;
  white-space: nowrap;
}
.tab:hover { color: var(--ink); }
.tab.active { background: var(--accent); color: var(--accent-ink); box-shadow: none; }

.searchbox { position: relative; flex: 1 1 220px; max-width: 440px; min-width: 130px; }
.search-glyph {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  width: 18px; height: 18px; color: var(--muted); pointer-events: none;
}
#search {
  width: 100%; padding: 10px 14px 10px 38px;
  background: var(--panel); color: var(--ink);
  border: 1px solid var(--line); border-radius: 999px;
  font-size: 15px; outline: none;
}
#search::placeholder { color: var(--muted); }
#search:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
#search::-webkit-search-cancel-button { filter: grayscale(1); }

.search-results {
  position: absolute; top: calc(100% + 8px); left: 0; right: 0;
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
  box-shadow: var(--shadow); overflow: auto; max-height: min(58vh, 460px);
  padding: 6px; z-index: 60;
}
.sr-item {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 9px 10px; border: 0; border-radius: 10px; background: none;
  text-align: left; cursor: pointer;
}
.sr-item.active, .sr-item:hover { background: var(--panel-3); }
/* Remote focus inside the suggestion list (only when the D-pad owns it). */
.search-results.kbd .sr-item.active { outline: 3px solid var(--focus); outline-offset: -3px; }
.sr-num { color: var(--accent); font-variant-numeric: tabular-nums; font-weight: 700; min-width: 46px; }
.sr-name { flex: 1; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sr-group { color: var(--muted); font-size: 12px; white-space: nowrap; }
.sr-empty { padding: 14px; color: var(--muted); font-size: 14px; }

.userbox { display: flex; align-items: center; gap: 4px; margin-left: auto; }
.logout-form { display: contents; }
.who { color: var(--muted); font-size: 13px; margin-right: 6px; max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.icon-btn {
  display: inline-grid; place-items: center;
  width: 38px; height: 38px; border-radius: 999px;
  border: 1px solid transparent; background: none; color: var(--ink-2);
  cursor: pointer; text-decoration: none;
}
.icon-btn:hover { background: var(--panel-2); color: var(--ink); }
.icon-btn svg { width: 20px; height: 20px; }
.i-sun { display: none; }
:root[data-theme="light"] .i-sun { display: block; }
:root[data-theme="light"] .i-moon { display: none; }

/* -------------------------------------------------------------------- rail */
.stage { position: relative; flex: 1 1 auto; min-height: 0; display: flex; }
.rail {
  flex: 0 0 208px;
  display: flex; flex-direction: column; gap: 4px;
  overflow-y: auto; overflow-x: hidden;
  padding: 14px 10px 30px;
  background: var(--bar);
  border-right: 1px solid var(--line);
  scrollbar-width: thin;
}
.rail .label {
  margin: 2px 8px 8px;
  color: var(--muted); font-size: 13px; letter-spacing: .1em; text-transform: uppercase;
  font-family: var(--display); font-weight: 700;
}
.rail-item {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 10px 12px; border-radius: 10px;
  border: 1px solid transparent; background: none;
  color: var(--ink-2); font-size: 14px; font-weight: 600;
  text-align: left; cursor: pointer; white-space: nowrap;
}
.rail-item .glyph { color: var(--accent); width: 8px; opacity: .0; flex: 0 0 8px; }
.rail-item .rail-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.rail-item .count { flex: 0 0 auto; margin-left: auto; color: var(--muted); font-size: 12px; font-weight: 500; }
.rail-item:hover { background: var(--panel); color: var(--ink); }
.rail-item.active { background: var(--panel-3); color: var(--ink); border-color: var(--line); }
.rail-item.active .glyph { opacity: 1; }
.rail.focus .rail-item.active { outline: 3px solid var(--focus); outline-offset: 1px; }
.rail-item.star { color: var(--accent); }
.rail-item.star.active { color: var(--ink); }

/* ------------------------------------------------------------------- stage */
.guide-pane { position: relative; flex: 1 1 auto; min-width: 0; }
.gscroll {
  position: absolute; inset: 0;
  overflow: auto;
  scrollbar-color: var(--panel-3) transparent;
  outline: none;
  overscroll-behavior: contain;
}
.gcanvas { position: relative; min-width: 100%; }

.thead {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: stretch;
  height: var(--headh);
  background: var(--bg-2);
  border-bottom: 1px solid var(--line);
}
.thead .cn {
  position: sticky; left: 0; z-index: 22;
  display: flex; align-items: center;
  width: var(--chanw); min-width: var(--chanw);
  padding: 0 14px;
  background: var(--bg-2);
  border-right: 1px solid var(--line);
  color: var(--muted); font-size: 12px; letter-spacing: .09em; text-transform: uppercase;
}
.ticks { position: relative; height: 100%; flex: 0 0 auto; }
.tick {
  position: absolute; top: 0; bottom: 0;
  border-left: 1px solid var(--line);
  padding: 0 0 0 9px;
  color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums;
  display: flex; align-items: center; white-space: nowrap;
}
.tick.hour { color: var(--ink-2); font-weight: 600; }
.tick.now-tick { color: var(--live); border-left-color: var(--live); }

.rows { position: relative; }

.sec-head {
  position: absolute; left: 0; right: 0;
  height: var(--sech);
  display: flex; align-items: center;
  padding: 0 14px;
  background: var(--panel-2); /* fallback for a WebView without color-mix */
  background: color-mix(in srgb, var(--cat, var(--accent)) 24%, var(--bar));
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  border-left: 6px solid var(--cat, var(--accent));
  z-index: 10;
}
.sec-head .inner {
  position: sticky; left: 12px;
  display: flex; align-items: baseline; gap: 10px;
  white-space: nowrap;
}
.sec-head h2 {
  margin: 0;
  font-family: var(--display);
  font-weight: 800;
  font-size: 17px;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: #fff;
}
.sec-head .n {
  color: rgba(255, 255, 255, .7);
  font-size: 12px; font-weight: 600;
  font-variant-numeric: tabular-nums;
}
/* Option B: a solid category bar with white text. */
:root[data-theme="light"] .sec-head {
  background: var(--cat, var(--accent));
  border-color: transparent;
  border-left-width: 0;
  padding-left: 20px;
}
:root[data-theme="light"] .sec-head .n { color: rgba(255, 255, 255, .8); }

.row {
  position: absolute; left: 0; right: 0;
  height: var(--rowh);
  border-bottom: 1px solid var(--line-soft);
}
.row .cn {
  position: sticky; left: 0; z-index: 12;
  display: flex; align-items: center; gap: 9px;
  width: var(--chanw); height: 100%;
  padding: 0 10px 0 12px;
  background: var(--panel);
  border-right: 1px solid var(--line);
  cursor: pointer;
}
.row:hover .cn { background: var(--panel-2); }
/* The selected row is the remote's focus: a solid 3px ring, white on dark.
   An outline does not repaint the row's background or its shadow. */
.row.sel .cn {
  background: var(--panel-2);
  outline: 3px solid var(--focus);
  outline-offset: -3px;
}

.ch-logo, .ch-badge {
  width: 40px; height: 30px; flex: 0 0 40px;
  border-radius: 6px; background: var(--panel-2);
  object-fit: contain; padding: 2px;
}
.ch-badge {
  display: grid; place-items: center;
  color: var(--muted); font-size: 12px; font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.ch-text { min-width: 0; }
.ch-num {
  display: block;
  font-family: var(--display);
  color: var(--num, #e17e84);
  font-size: 15px;
  line-height: 1.05;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: .03em;
}
:root[data-theme="light"] .ch-num { color: var(--cat, var(--accent)); }
.ch-name {
  display: block; font-size: 13.5px; font-weight: 600; line-height: 1.15;
  overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
}
.ch-fav { position: absolute; right: 6px; top: 6px; color: var(--accent); font-size: 11px; }

.progs { position: absolute; left: var(--chanw); top: 0; right: 0; bottom: 0; }
.prog {
  position: absolute; top: 5px; bottom: 5px;
  padding: 6px 9px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--panel);
  overflow: hidden;
  cursor: pointer;
  min-width: 2px;
}
.prog .t {
  display: block; font-size: 12.5px; font-weight: 600; line-height: 1.2;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.prog .s {
  display: block; margin-top: 2px;
  color: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.prog:hover { border-color: var(--accent); }
/* The cell that is on now: a lighter panel and a category edge. */
.prog.now {
  border-color: var(--now-edge, var(--line));
  background: var(--panel-2);
}
.prog.now::after {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  background: var(--cat, var(--live));
}
.prog.now.roomy .t::before {
  content: "LIVE";
  font-family: var(--display);
  font-weight: 800;
  font-size: 9.5px;
  letter-spacing: .08em;
  line-height: 1;
  background: var(--live);
  color: #fff;
  border-radius: 3px;
  padding: 2px 4px 1px;
  margin-right: 5px;
  vertical-align: 1px;
}
:root[data-theme="light"] .prog.now {
  background: var(--now-bg, var(--panel-2));
}
.prog.past { opacity: .58; }
.prog.selprog { outline: 3px solid var(--focus); outline-offset: -3px; }

.nowline {
  position: absolute; top: var(--headh); bottom: 0; width: 2px;
  background: var(--live); opacity: .9; z-index: 8; pointer-events: none;
}

.status {
  position: absolute; inset: 0; display: grid; place-items: center;
  background: var(--bg); color: var(--muted); text-align: center; padding: 24px;
  font-size: 15px; line-height: 1.5;
}

/* --------------------------------------------------------------- on now */
.nowpage { position: absolute; inset: 0; z-index: 6; background: var(--bg); overflow: auto; }
.nowinner { max-width: 1240px; margin: 0 auto; padding: 20px clamp(14px, 3vw, 36px) 48px; }

.now-section { margin: 0 0 30px; }
.now-sec-head { display: flex; align-items: baseline; gap: 12px; margin: 0 0 12px; }
.now-sec-head h2 {
  font-family: var(--display); font-size: 24px; margin: 0; font-weight: 800;
  letter-spacing: .05em; text-transform: uppercase;
}
.now-sec-head p { margin: 0; color: var(--muted); font-size: 13px; }

.now-cards { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.now-card {
  display: flex; align-items: center; gap: 12px;
  text-align: left; width: 100%;
  padding: 12px; border-radius: 14px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--cat, var(--line));
  background: var(--panel);
  cursor: pointer;
}
.now-card:hover, .now-card:focus-visible { border-color: var(--accent); background: var(--panel-2); outline: none; }
/* Remote focus: browsers can drop :focus-visible for a programmatic focus. */
.now-card.now-focus, .btn.now-focus {
  border-color: var(--accent); background: var(--panel-2);
  outline: 3px solid var(--focus); outline-offset: -3px;
}
.now-card .ch-logo, .now-card .ch-badge { width: 52px; height: 38px; flex-basis: 52px; }
.now-card-text { min-width: 0; flex: 1; }
.now-card-num {
  font-family: var(--display);
  color: var(--num, #e17e84);
  font-size: 13px; font-weight: 700; letter-spacing: .03em;
}
:root[data-theme="light"] .now-card-num { color: var(--cat, var(--accent)); }
.now-card-name { display: block; font-weight: 600; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.now-card-sub { display: block; color: var(--muted); font-size: 12.5px; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.now-card .badge {
  flex: 0 0 auto; align-self: flex-start; font-size: 10px; letter-spacing: .08em;
  text-transform: uppercase; color: var(--live); border: 1px solid var(--live);
  border-radius: 999px; padding: 2px 7px;
}
.now-card.wide { grid-column: span 2; min-height: 92px; }
.now-card.wide .now-card-name { font-size: 19px; }
.now-card.wide .now-card-sub { font-size: 13.5px; }
.now-empty { color: var(--muted); font-size: 14px; }
.now-hero {
  display: flex; flex-wrap: wrap; gap: 18px; align-items: center;
  padding: 18px 20px; border: 1px solid var(--line); border-radius: 18px;
  background: linear-gradient(120deg, var(--panel-2), var(--panel));
  margin-bottom: 26px;
}
.now-hero .hello { flex: 1 1 280px; }
.now-hero h1 {
  font-family: var(--display); font-size: clamp(28px, 4.2vw, 40px);
  margin: 2px 0 4px; font-weight: 800; letter-spacing: .01em;
}
.now-hero p { margin: 0; color: var(--muted); font-size: 14px; }
.kicker {
  margin: 0; color: var(--accent); letter-spacing: .12em; text-transform: uppercase;
  font-family: var(--display); font-size: 13px; font-weight: 700;
}

/* ---------------------------------------------------------------- player */
/* The player is always a dark room, even with the light guide. */
.player {
  --bg: #0f1014; --panel: #17181e; --panel-2: #1e2028; --panel-3: #24262f;
  --ink: #eeedf2; --ink-2: #c9cbd6; --muted: #9a9eae; --line: #262832;
  --accent: #e2232e; --accent-ink: #fff; --live: #ff4a4f; --focus: #fff;
  position: fixed; inset: 0; z-index: 100;
  background: #000; color: #f2f2f4;
  display: flex; flex-direction: column;
  overflow: hidden;
}
.player[hidden] { display: none; }
#video { position: absolute; inset: 0; width: 100%; height: 100%; background: #000; object-fit: contain; }
.p-shade { position: absolute; left: 0; right: 0; height: 28vh; pointer-events: none; transition: opacity .35s; }
.p-shade.top { top: 0; background: linear-gradient(180deg, rgba(0,0,0,.78), transparent); }
.p-shade.bottom { bottom: 0; background: linear-gradient(0deg, rgba(0,0,0,.86), transparent); }

.p-top {
  position: relative; z-index: 3;
  display: flex; align-items: center; gap: 14px;
  padding: 14px clamp(12px, 2.4vw, 30px) 0;
  transition: opacity .3s;
}
.p-title { min-width: 0; flex: 1; }
.p-num {
  font-family: var(--display); color: var(--accent); font-weight: 800;
  font-variant-numeric: tabular-nums; margin-right: 10px; font-size: 19px;
  letter-spacing: .02em;
}
.p-name { font-size: clamp(16px, 2vw, 22px); font-weight: 600; }
.p-actions { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }

.pbtn {
  border: 1px solid rgba(255,255,255,.22); background: rgba(15,16,20,.55);
  backdrop-filter: blur(6px);
  border-radius: 999px; padding: 8px 14px; font-size: 13px; font-weight: 600;
  cursor: pointer; color: #f2f2f4; white-space: nowrap;
}
.pbtn:hover { background: rgba(30,32,40,.85); border-color: var(--accent); }
.pbtn:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.pbtn.back { display: inline-flex; align-items: center; gap: 6px; }
.pbtn.back svg { width: 18px; height: 18px; }
.pbtn.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.pbtn.big { padding: 11px 22px; font-size: 15px; }
.pbtn.solid { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }

.p-bottom {
  position: relative; z-index: 3; margin-top: auto;
  padding: 0 clamp(12px, 2.4vw, 30px) calc(16px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: 10px;
  transition: opacity .3s;
}
.p-now { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.p-nowlabel {
  font-family: var(--display); color: var(--accent); font-size: 13px;
  letter-spacing: .12em; text-transform: uppercase; font-weight: 700;
}
.p-nowtitle { font-weight: 600; font-size: clamp(14px, 1.6vw, 18px); }
.p-progress { flex: 1 1 120px; min-width: 90px; height: 3px; border-radius: 3px; background: rgba(255,255,255,.2); overflow: hidden; }
.p-progress i { display: block; height: 100%; width: 0; background: var(--accent); }
.p-next { color: rgba(242,242,244,.72); font-size: 13px; }
.p-controls { display: flex; gap: 10px; flex-wrap: wrap; }

.p-loading {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  color: rgba(242,242,244,.8); font-size: 15px; letter-spacing: .06em;
  animation: pulse 1.4s ease-in-out infinite; z-index: 2;
}
@keyframes pulse { 0%, 100% { opacity: .45; } 50% { opacity: 1; } }

.p-msg {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  z-index: 4; max-width: min(90vw, 520px); text-align: center;
  background: rgba(15,16,20,.94); border: 1px solid rgba(255,255,255,.18);
  border-radius: 16px; padding: 22px;
}
.p-msg p { margin: 0 0 14px; font-size: 15px; line-height: 1.4; }
.p-msg-actions { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }

.player.idle .p-top, .player.idle .p-bottom, .player.idle .p-shade { opacity: 0; }
.player.idle { cursor: none; }

/* ------------------------------------------------------------- number entry */
.numentry {
  position: fixed; top: 16%; left: 50%; transform: translateX(-50%);
  z-index: 90; background: rgba(15,16,20,.94); color: #f2f2f4;
  border: 1px solid rgba(255,255,255,.18); border-radius: 18px;
  padding: 18px 30px; box-shadow: var(--shadow);
}
.numentry[hidden] { display: none; }
.digits {
  font-family: var(--display);
  font-size: clamp(40px, 9vw, 72px); font-weight: 800; letter-spacing: .1em;
  font-variant-numeric: tabular-nums; color: var(--accent); min-width: 2ch;
  text-align: center;
}

/* ------------------------------------------------------------------ toast */
.toast {
  position: fixed; left: 50%; bottom: calc(28px + env(safe-area-inset-bottom));
  transform: translateX(-50%); z-index: 95;
  background: var(--panel-3); color: var(--ink); border: 1px solid var(--line);
  border-radius: 999px; padding: 10px 18px; font-size: 14px; box-shadow: var(--shadow);
}
.toast[hidden] { display: none; }

/* ------------------------------------------------------------------- hint */
.hintbar {
  flex: 0 0 auto; padding: 6px clamp(12px, 2.2vw, 26px) calc(6px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line); background: var(--bg-2);
  color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.hintbar b { color: var(--ink-2); font-weight: 700; }
.hint-tv { display: none; }

/* -------------------------------------------------------------- sign-in */
body.simple {
  display: grid; place-items: center; min-height: 100dvh;
  background:
    radial-gradient(1100px 600px at 15% -10%, color-mix(in srgb, var(--accent) 13%, transparent), transparent 60%),
    var(--bg);
  padding: 24px;
  overflow: auto;
}
.simple-card {
  width: min(440px, 100%);
  background: var(--panel); border: 1px solid var(--line); border-radius: 22px;
  padding: 28px; box-shadow: var(--shadow);
}
.simple-card h1 {
  font-family: var(--display); font-size: 34px; margin: 4px 0 8px;
  font-weight: 800; letter-spacing: .01em;
}
.simple-card .lede { margin: 0 0 18px; color: var(--muted); font-size: 14.5px; line-height: 1.5; }
.login-form { display: flex; flex-direction: column; gap: 14px; }
.login-form label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 600; color: var(--ink-2); }
.login-form input {
  padding: 11px 13px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--bg-2); color: var(--ink); font-size: 16px;
}
.login-form input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
.btn {
  border: 1px solid var(--line); background: var(--panel-2); color: var(--ink);
  border-radius: 10px; padding: 11px 16px; font-weight: 600; font-size: 15px; cursor: pointer;
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.06); }
.small { color: var(--muted); font-size: 12.5px; margin: 14px 0 0; }
.flash { border-radius: 10px; padding: 10px 12px; font-size: 14px; margin: 0 0 14px; }
.flash.bad { background: color-mix(in srgb, var(--live) 16%, transparent); border: 1px solid color-mix(in srgb, var(--live) 50%, transparent); color: var(--ink); }
.flash.ok { background: color-mix(in srgb, var(--sage) 16%, transparent); border: 1px solid color-mix(in srgb, var(--sage) 50%, transparent); }

/* --------------------------------------------------------------- TV sizes */
@media (min-width: 1500px) and (min-height: 780px) {
  :root { --rowh: 80px; --sech: 50px; --chanw: 268px; --headh: 50px; --topbar: 76px; }
  .rail { flex-basis: 262px; padding: 18px 14px 34px; gap: 6px; }
  .rail .label { font-size: 13px; }
  .rail-item { font-size: 18px; padding: 14px 16px; }
  .rail-item .count { font-size: 14px; }
  .sec-head h2 { font-size: 23px; }
  .sec-head .n { font-size: 14px; }
  .brand-text { font-size: 32px; }
  .brand-mark { width: 44px; height: 44px; }
  .tab { font-size: 19px; padding: 9px 18px; }
  .now-sec-head h2 { font-size: 28px; }
  #search { font-size: 17px; padding: 12px 16px 12px 42px; }
  .chip { font-size: 15px; padding: 9px 16px; }
  .row .cn { padding-left: 16px; gap: 12px; }
  .ch-logo, .ch-badge { width: 54px; height: 40px; flex-basis: 54px; }
  .ch-num { font-size: 19px; }
  .ch-name { font-size: 16.5px; }
  .prog .t { font-size: 15px; }
  .prog .s { font-size: 12.5px; }
  .tick { font-size: 14px; }
  .hintbar { font-size: 14px; }
  .pbtn { font-size: 15px; padding: 10px 18px; }
  .pbtn.big { font-size: 18px; padding: 14px 28px; }
  .p-name { font-size: 26px; }
  .p-num { font-size: 21px; }
  .p-nowtitle { font-size: 21px; }
  .p-next { font-size: 16px; }
  .hint-desktop { display: none; }
  .hint-tv { display: inline; }
}

@media (hover: none) and (pointer: coarse) {
  .prog { padding: 5px 7px; }
  .pbtn.big { padding: 13px 20px; }
}

/* -------------------------------------------------------------- phone */
@media (max-width: 820px) {
  :root { --rowh: 58px; --sech: 34px; --chanw: 148px; --headh: 38px; }
  .topbar {
    display: grid;
    grid-template-columns: auto 1fr auto;
    grid-template-areas: "brand . user" "tabs search search";
    gap: 8px 10px; padding: 8px 12px 9px;
    min-height: 0;
  }
  .brand { grid-area: brand; }
  .brand-text { font-size: 20px; }
  .brand-mark { width: 28px; height: 28px; }
  .userbox { grid-area: user; }
  .who { display: none; }
  .tabs { grid-area: tabs; justify-self: start; }
  .tab { padding: 6px 12px; font-size: 13px; }
  .searchbox { grid-area: search; max-width: none; min-width: 0; }
  #search { font-size: 14px; padding: 8px 12px 8px 34px; }
  .search-glyph { width: 16px; height: 16px; left: 11px; }
  .icon-btn { width: 34px; height: 34px; }
  .stage { flex-direction: column; }
  .rail {
    flex: 0 0 auto; flex-direction: row; gap: 6px;
    overflow-x: auto; overflow-y: hidden;
    padding: 8px 10px; border-right: 0; border-bottom: 1px solid var(--line);
    scrollbar-width: none;
  }
  .rail::-webkit-scrollbar { display: none; }
  .rail .label { display: none; }
  .rail-item { width: auto; padding: 7px 11px; font-size: 12.5px; }
  .rail-item .glyph { display: none; }
  .rail-item .count { display: none; }
  .sec-head { padding: 0 10px; border-left-width: 4px; }
  :root[data-theme="light"] .sec-head { padding-left: 14px; }
  .sec-head h2 { font-size: 14px; letter-spacing: .05em; }
  .sec-head .n { font-size: 11px; }
  .row .cn { padding: 0 6px 0 9px; gap: 6px; }
  .ch-logo, .ch-badge { width: 32px; height: 24px; flex-basis: 32px; }
  .ch-name { font-size: 11.5px; }
  .ch-num { font-size: 12.5px; }
  .prog { top: 4px; bottom: 4px; padding: 5px 7px; border-radius: 7px; }
  .prog .t { font-size: 11px; }
  .prog .s { display: none; }
  .tick { font-size: 10.5px; }
  .now-cards { grid-template-columns: 1fr; }
  .now-card.wide { grid-column: span 1; }
  .hintbar { font-size: 10.5px; padding-bottom: calc(5px + env(safe-area-inset-bottom)); }
  .p-name { font-size: 16px; }
  .p-top { gap: 8px; padding: 10px 10px 0; }
  .p-actions { gap: 4px; }
  .p-actions .pbtn { padding: 6px 9px; font-size: 11px; }
  .pbtn.back span { display: none; }
  .p-bottom { padding: 0 10px calc(12px + env(safe-area-inset-bottom)); }
  .p-controls { gap: 6px; }
  .pbtn.big { padding: 10px 12px; font-size: 13px; flex: 1; }
  .p-next { display: none; }
  .login-card { padding: 22px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}

/* ------------------------------------------------------- sign-in choices */
.re-signin {
  display: block; width: 100%; text-align: center; text-decoration: none;
  padding: 13px 16px; border-radius: 12px; font-weight: 700; font-size: 16px;
  background: var(--accent); color: var(--accent-ink); border: 1px solid var(--accent);
}
.re-signin:hover { filter: brightness(1.06); }
.login-alt { margin: 16px 0 0; text-align: center; font-size: 13px; }
.login-alt a { color: var(--muted); text-decoration: underline; }
.login-alt a:hover { color: var(--accent); }

.tv-login { width: min(900px, 94vw); text-align: center; padding: 22px 24px; }
.tv-login h1 {
  font-family: var(--display); font-weight: 800; letter-spacing: .01em;
  font-size: clamp(28px, 3.6vw, 42px); margin: 2px 0 8px;
}
.tv-login .tv-wrap { display: flex; gap: 26px; align-items: center; text-align: left; }
.tv-login .tv-info { flex: 1 1 auto; min-width: 0; }
.tv-login .lede { font-size: clamp(14px, 1.5vw, 18px); margin: 0 0 10px; }
.tv-qr { flex: 0 0 auto; background: #fff; padding: 10px; border-radius: 16px; width: fit-content; }
.tv-qr img { display: block; width: min(40vh, 300px); height: auto; image-rendering: pixelated; }
.tv-code {
  font-family: ui-monospace, "DejaVu Sans Mono", monospace;
  font-size: clamp(26px, 3.6vw, 40px); letter-spacing: .16em;
  color: var(--accent); margin: 4px 0 4px; font-weight: 700; text-align: left;
}
.tv-status { color: var(--muted); font-size: clamp(13px, 1.4vw, 17px); margin: 0 0 8px; }
.tv-login .small { font-size: clamp(11px, 1.1vw, 14px); margin: 6px 0 0; line-height: 1.35; }
.tv-login .login-alt { margin: 10px 0 0; text-align: left; }
@media (max-width: 820px) {
  .tv-login .tv-wrap { flex-direction: column; text-align: center; gap: 12px; }
  .tv-qr img { width: min(52vw, 300px); }
  .tv-code { text-align: center; font-size: 26px; }
  .tv-login .login-alt { text-align: center; }
}

/* ---------------------------------------------------- remote / top bar focus */
.top-focus {
  box-shadow: 0 0 0 3px var(--focus) !important;
  border-radius: 999px;
}
.searchbox.top-focus { border-radius: 999px; }
.searchbox.top-focus #search { border-color: var(--accent); }

/* ----------------------------------------------------------- app download */
.app-card { width: min(760px, 94vw); text-align: left; }
.app-card h1 {
  font-family: var(--display); font-weight: 800; letter-spacing: .01em;
  font-size: clamp(28px, 3.6vw, 42px);
}
.download-btn {
  display: inline-block; margin: 6px 0 10px; padding: 14px 22px;
  border-radius: 12px; background: var(--accent); color: var(--accent-ink);
  border: 1px solid var(--accent); font-weight: 700; font-size: 17px;
  text-decoration: none;
}
.download-btn:hover { filter: brightness(1.06); }
.app-meta { margin: 0 0 18px; color: var(--muted); font-size: 13px; }
.app-steps { margin: 18px 0 14px; padding-left: 22px; line-height: 1.55; font-size: 15px; }
.app-steps li { margin: 12px 0; }
.app-steps code {
  font-family: ui-monospace, "DejaVu Sans Mono", monospace;
  background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 6px; padding: 1px 6px; font-size: 13.5px;
}
.app-note { color: var(--muted); font-size: 13.5px; line-height: 1.5; margin: 14px 0 0; }

/* ------------------------------------------------------------ mini player */
/* The corner window you get when Back leaves the full-screen player
   (player.js). The box is moved and sized from JS; one shape per device:
   phone = option A, computer = D2, TV/D-pad = T3 in the owner's mockups. */
.player.mini {
  inset: auto;
  left: var(--mini-left, 16px);
  top: var(--mini-top, 16px);
  width: var(--mini-w, 360px);
  height: var(--mini-h, 203px);
  z-index: 90;
  background: #000;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: visible;
  box-shadow: 0 14px 36px rgba(0, 0, 0, .55);
}
.player.mini.snapping {
  transition: left .18s ease, top .18s ease, width .18s ease, height .18s ease;
}
.player.mini #video {
  position: relative;
  inset: auto;
  width: 100%;
  height: auto;
  min-height: 0;
  flex: 1 1 auto;
  border-radius: 0 0 11px 11px;
}
.player.mini-phone #video,
.player.mini-tv #video { border-radius: 11px; }
/* The full-screen chrome has no business over the guide. */
.player.mini .p-shade,
.player.mini .p-top,
.player.mini .p-bottom,
.player.mini .p-loading,
.player.mini .p-msg,
.player.mini .p-castmenu { display: none; }
.player.mini.casting #video { visibility: hidden; }

.p-mini-bar { display: none; }
.player.mini .p-mini-bar {
  position: relative;
  z-index: 3;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 7px;
  height: 34px;
  padding: 0 6px 0 8px;
  background: var(--panel-3);
  border-radius: 11px 11px 0 0;
  color: var(--ink);
  cursor: grab;
  touch-action: none;
  user-select: none;
}
.player.mini.dragging .p-mini-bar { cursor: grabbing; }
/* Phone and TV: the same buttons float over the picture's top-right corner. */
.player.mini-phone .p-mini-bar,
.player.mini-tv .p-mini-bar {
  position: absolute;
  top: 7px;
  right: 7px;
  left: auto;
  height: auto;
  padding: 0;
  gap: 6px;
  background: none;
  border-radius: 0;
  cursor: pointer;
}
.player.mini-phone .p-mini-bar .p-mini-grip,
.player.mini-phone .p-mini-bar .p-mini-logo,
.player.mini-phone .p-mini-bar .p-mini-title,
.player.mini-tv .p-mini-bar .p-mini-grip,
.player.mini-tv .p-mini-bar .p-mini-logo,
.player.mini-tv .p-mini-bar .p-mini-title { display: none; }

.p-mini-grip { color: var(--muted); font-size: 13px; line-height: 1; }
.p-mini-logo {
  flex: 0 0 26px;
  width: 26px;
  height: 20px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border-radius: 4px;
  background: var(--panel-2);
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
}
.p-mini-logo img { width: 100%; height: 100%; object-fit: contain; display: block; }
.p-mini-title {
  display: flex;
  align-items: baseline;
  gap: 7px;
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
}
.p-mini-title b {
  font-size: 12.5px; font-weight: 600;
  overflow: hidden; text-overflow: ellipsis;
}
.p-mini-title span {
  font-size: 12px; color: var(--muted);
  overflow: hidden; text-overflow: ellipsis;
}

.p-mini-btn {
  flex: 0 0 26px;
  width: 26px;
  height: 26px;
  padding: 0;
  display: inline-grid;
  place-items: center;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, .2);
  background: rgba(0, 0, 0, .5);
  color: var(--ink);
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
}
.p-mini-btn:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}
.p-mini-btn.p-mini-on, .p-mini-btn:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 1px;
}
/* Computer: the buttons appear when the pointer (or the D-pad) is on it. */
.player.mini-desktop .p-mini-btn { opacity: 0; transition: opacity .15s ease; }
.player.mini-desktop .p-mini-bar:hover .p-mini-btn,
.player.mini-desktop .p-mini-bar:focus-within .p-mini-btn,
.player.mini-desktop.mini-focus .p-mini-btn,
.player.mini-desktop .p-mini-btn:focus-visible { opacity: 1; }

.p-mini-cap {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 30px 10px 8px;
  background: linear-gradient(transparent, rgba(0, 0, 0, .86));
  border-radius: 0 0 11px 11px;
  color: #f2f2f4;
  pointer-events: none;
}
.p-mini-captext { min-width: 0; display: block; }
.p-mini-cap b {
  display: block; font-size: 12.5px; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.p-mini-cap .p-mini-prog {
  display: block; font-size: 11.5px; color: rgba(242, 242, 244, .75);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.player.mini-tv .p-mini-cap b { font-size: clamp(14px, 1vw, 19px); }
.player.mini-tv .p-mini-cap .p-mini-prog { font-size: clamp(12px, .85vw, 16px); }

.p-mini-cast {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 16px;
  text-align: center;
  background: var(--panel);
  border-radius: 11px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 600;
}
.player.mini-desktop .p-mini-cast { top: 34px; border-radius: 0 0 11px 11px; }
.player.mini-tv .p-mini-cast { font-size: clamp(14px, 1vw, 20px); }

.p-mini-ring {
  position: absolute;
  inset: 0;
  z-index: 4;
  border: 3px solid var(--focus);
  border-radius: 12px;
  pointer-events: none;
}

.p-mini-hint {
  position: absolute;
  right: 0;
  bottom: calc(100% + 8px);
  z-index: 5;
  padding: 5px 12px;
  background: rgba(0, 0, 0, .78);
  border: 1px solid rgba(255, 255, 255, .16);
  border-radius: 999px;
  color: var(--ink);
  font-size: 13px;
  white-space: nowrap;
}
.p-mini-hint b { color: var(--focus); }
.player.mini-tv .p-mini-hint { font-size: clamp(13px, .9vw, 17px); }

.p-mini-gripcorner { display: none; position: absolute; width: 14px; height: 14px; z-index: 6; }
.player.mini-desktop .p-mini-gripcorner { display: block; cursor: nwse-resize; }
.player.mini-corner-br .p-mini-gripcorner {
  left: 3px; top: 38px;
  border-left: 2px solid var(--focus); border-top: 2px solid var(--focus);
}
.player.mini-corner-bl .p-mini-gripcorner {
  right: 3px; top: 38px;
  border-right: 2px solid var(--focus); border-top: 2px solid var(--focus);
  cursor: nesw-resize;
}
.player.mini-corner-tr .p-mini-gripcorner {
  left: 3px; bottom: 3px;
  border-left: 2px solid var(--focus); border-bottom: 2px solid var(--focus);
  cursor: nesw-resize;
}
.player.mini-corner-tl .p-mini-gripcorner {
  right: 3px; bottom: 3px;
  border-right: 2px solid var(--focus); border-bottom: 2px solid var(--focus);
}
.p-mini-gripcorner { touch-action: none; }
