:root {
  --bg: #0b0b0f;
  --surface: #16161d;
  --surface-hover: #1f1f29;
  --border: #2a2a36;
  --text: #f4f4f7;
  --muted: #9a9aab;
  --accent: #ff7a1a;
  --accent-2: #ffc400;
  --gradient: linear-gradient(135deg, #ffd000 0%, #ff7a1a 35%, #ff2d6f 65%, #7b1fff 100%);
  --radius: 10px;
  color-scheme: dark;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

a { color: inherit; text-decoration: none; }

button {
  font: inherit;
  color: #111;
  background: var(--gradient);
  border: 0;
  border-radius: 999px;
  padding: 7px 16px;
  font-weight: 600;
  cursor: pointer;
}
button:disabled { opacity: .5; cursor: default; }

.muted { color: var(--muted); }

/* Menu down the left side; on phones it slides in from the menu button. */
:root { --sidebar: 216px; }
body { padding-left: var(--sidebar); }
.sidebar {
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 30;
  width: var(--sidebar);
  display: flex;
  flex-direction: column;
  gap: 22px;
  padding: 14px 12px;
  background: var(--bg);
  border-right: 1px solid var(--border);
  overflow-y: auto;
}
.sidebar .brand { padding: 2px 8px; }
.sidebar nav { flex-direction: column; gap: 2px; }
.sidebar nav a { display: flex; align-items: center; gap: 12px; padding: 9px 12px; border-radius: 8px; font-weight: 500; }
.sidebar nav a[hidden] { display: none; }
.sidebar nav a.active .nav-icon { color: var(--accent); }
.nav-icon { flex: none; width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.sidebar-backdrop { position: fixed; inset: 0; z-index: 25; background: rgba(0, 0, 0, .55); }

/* Top bar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 24px;
  background: rgba(11, 11, 15, .92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 20px; }
.brand img { border-radius: 8px; }
nav { display: flex; gap: 4px; }
nav a { padding: 6px 12px; border-radius: 999px; color: var(--muted); }
nav a:hover { color: var(--text); }
nav a.active { color: var(--text); background: var(--surface-hover); }
.menu-button {
  display: none;
  place-items: center;
  flex: none;
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: 8px;
  background: none;
  color: var(--text);
  font-size: 20px;
}
.menu-button:hover { background: var(--surface-hover); }
.global-search { position: relative; flex: 1 1 auto; max-width: 560px; margin: 0; }
.global-search input {
  width: 100%;
  padding: 9px 14px 9px 40px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
}
.global-search input:focus { outline: none; border-color: var(--accent); }
.search-icon {
  position: absolute;
  top: 50%;
  left: 14px;
  width: 18px;
  height: 18px;
  transform: translateY(-50%);
  fill: none;
  stroke: var(--muted);
  stroke-width: 2;
  stroke-linecap: round;
  pointer-events: none;
}
.scan { margin-left: auto; display: flex; align-items: center; gap: 12px; font-size: 13px; }

@media (max-width: 760px) {
  :root { --sidebar: 0px; }
  .sidebar { width: 248px; transform: translateX(-100%); transition: transform .2s ease; }
  body.menu-open .sidebar { transform: none; box-shadow: 8px 0 32px rgba(0, 0, 0, .6); }
  .menu-button { display: grid; }
  .topbar { padding-left: 12px; }
}

main { padding: 24px; max-width: 1600px; margin: 0 auto; }

.toolbar { display: flex; align-items: center; gap: 16px; margin-bottom: 20px; }
.toolbar h1 { margin: 0; font-size: 24px; }
.toolbar input {
  margin-left: auto;
  width: min(320px, 100%);
  padding: 8px 14px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  font: inherit;
}

/* Poster grid */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 20px;
}
.card { display: block; border-radius: var(--radius); }
.card:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.poster {
  position: relative;
  aspect-ratio: 2 / 3;
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  align-items: flex-end;
  padding: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  transition: transform .15s ease, border-color .15s ease;
}
.card:hover .poster { transform: translateY(-3px); border-color: var(--accent); }
.poster::before {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--gradient);
  opacity: var(--tint, .25);
}
.poster .initials {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 44px;
  font-weight: 800;
  color: rgba(255, 255, 255, .85);
}
.poster .badge {
  position: relative;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(0, 0, 0, .6);
}
.poster img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.poster img + .badge, .poster .badge { z-index: 1; }

/* Movie and show header */
.hero {
  position: relative;
  margin: 0 -24px 8px;
  padding: 32px 24px;
  overflow: hidden;
  min-height: 300px;
}
.hero-backdrop {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center 20%;
  opacity: .35;
  mask-image: linear-gradient(to bottom, #000 40%, transparent);
}
.hero-body { position: relative; display: flex; gap: 28px; align-items: flex-start; }
.hero-poster { flex: 0 0 200px; }
.hero-poster .poster { cursor: default; }
.hero-text { max-width: 760px; }
.hero h1 { margin: 4px 0 6px; font-size: 32px; line-height: 1.15; }
.hero-meta { color: var(--text); font-weight: 600; }
.hero-genres { color: var(--muted); font-size: 14px; margin-top: 2px; }
.overview { color: #d6d6de; margin: 14px 0 0; max-width: 760px; }
.hero-actions { margin-top: 20px; }
.play-button {
  display: inline-block;
  color: #111;
  background: var(--gradient);
  border-radius: 999px;
  padding: 10px 28px;
  font-weight: 700;
  font-size: 16px;
}
.play-button:hover { filter: brightness(1.1); }
.play-button:focus-visible { outline: 2px solid var(--text); outline-offset: 3px; }

.card-title { margin-top: 8px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-sub { font-size: 13px; color: var(--muted); }

/* Episode list */
.season h2 { font-size: 18px; margin: 28px 0 10px; }
.episodes { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.episodes a {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  padding: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.episodes a:hover { background: var(--surface-hover); border-color: var(--accent); }
.episodes .still {
  flex: 0 0 160px;
  aspect-ratio: 16 / 9;
  border-radius: 6px;
  overflow: hidden;
  background: var(--gradient);
  opacity: .9;
}
.episodes .still:has(img) { background: #000; opacity: 1; }
.episodes .still img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ep-text { flex: 1; min-width: 0; padding-top: 2px; }
.ep-head { display: flex; gap: 12px; align-items: baseline; }
.ep-title { font-weight: 600; }
.ep-overview {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.episodes .num { color: var(--accent); font-weight: 700; min-width: 3ch; }
.episodes .dur { margin-left: auto; color: var(--muted); font-size: 13px; white-space: nowrap; }

/* Player */
.player video {
  width: 100%;
  max-height: 75vh;
  background: #000;
  border-radius: var(--radius);
}
.player h1 { margin: 16px 0 4px; font-size: 24px; }

/* Player for remuxed and transcoded streams */
.video-player {
  position: relative;
  background: #000;
  border-radius: var(--radius);
  overflow: hidden;
  outline: none;
}
.video-player video { display: block; border-radius: 0; cursor: pointer; }
.video-player:fullscreen { display: flex; flex-direction: column; justify-content: center; }
.video-player:fullscreen video { max-height: none; flex: 1; min-height: 0; }
.controls {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: var(--surface);
  border-top: 1px solid var(--border);
}
.controls .ctl {
  background: transparent;
  color: var(--text);
  padding: 4px 8px;
  min-width: 36px;
  font-size: 16px;
  font-weight: 400;
  line-height: 1;
}
.controls .ctl:hover { color: var(--accent); }
.clock { font-variant-numeric: tabular-nums; font-size: 13px; color: var(--muted); }
.seek { flex: 1; min-width: 0; accent-color: var(--accent); cursor: pointer; }
.video-player:focus-visible { box-shadow: 0 0 0 2px var(--accent); }
.spinner {
  position: absolute;
  top: calc(50% - 40px);
  left: calc(50% - 24px);
  width: 48px;
  height: 48px;
  border: 4px solid rgba(255, 255, 255, .2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .8s linear infinite;
  pointer-events: none;
}
.spinner[hidden] { display: none; }
@keyframes spin { to { transform: rotate(360deg); } }
.back { color: var(--muted); display: inline-block; margin-bottom: 12px; }
.back:hover { color: var(--text); }
.facts { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.facts span {
  font-size: 12px;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--muted);
}
.notice {
  padding: 40px 24px;
  text-align: center;
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}

.empty { padding: 60px 0; text-align: center; color: var(--muted); }

@media (max-width: 640px) {
  .topbar { flex-wrap: wrap; gap: 12px; padding: 10px 16px; }
  .scan { margin-left: 0; width: 100%; justify-content: space-between; }
  main { padding: 16px; }
  .toolbar { flex-wrap: wrap; }
  .toolbar input { margin-left: 0; width: 100%; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 14px; }
  .hero { margin: 0 -16px 8px; padding: 20px 16px; }
  .hero-body { flex-direction: column; gap: 16px; }
  .hero-poster { flex-basis: auto; width: 130px; }
  .hero h1 { font-size: 24px; }
  .episodes .still { flex-basis: 110px; }
}

/* Watch state */
.progress {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 4px;
  background: rgba(0, 0, 0, .6);
  z-index: 1;
}
.progress span { display: block; height: 100%; background: var(--accent); }
.watched-mark, .count {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 1;
  min-width: 24px;
  height: 24px;
  padding: 0 7px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  color: #111;
  background: var(--accent-2);
  box-shadow: 0 1px 4px rgba(0, 0, 0, .5);
}
.count { background: var(--accent); }

/* Secondary actions */
.secondary {
  display: inline-block;
  color: var(--text);
  background: var(--surface-hover);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 9px 20px;
  font-weight: 600;
  font-size: 14px;
}
.secondary:hover { border-color: var(--accent); }
.hero-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.resume-info { flex-basis: 100%; display: flex; align-items: center; gap: 12px; font-size: 13px; }
.resume-info .progress { position: relative; flex: 0 0 200px; border-radius: 2px; overflow: hidden; background: var(--border); }
.link-button {
  background: none;
  color: var(--muted);
  padding: 2px 6px;
  font-weight: 500;
  font-size: 13px;
  border-radius: 6px;
}
.link-button:hover { color: var(--text); }
.link-button:focus-visible, .ep-toggle:focus-visible, .secondary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Episode rows with a watched toggle */
.season-head { display: flex; align-items: baseline; gap: 12px; }
.episodes li { display: flex; align-items: stretch; gap: 8px; }
.episodes li > a { flex: 1; min-width: 0; }
.episodes .still { position: relative; }
.episodes .still .watched-mark { top: 6px; right: 6px; min-width: 20px; height: 20px; font-size: 11px; }
.episodes li.watched .ep-title { color: var(--muted); }
.ep-toggle {
  flex: 0 0 44px;
  align-self: center;
  height: 44px;
  padding: 0;
  font-size: 16px;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--border);
}
.ep-toggle:hover { color: var(--text); border-color: var(--accent); }
.ep-toggle[aria-pressed="true"] { color: #111; background: var(--accent-2); border-color: var(--accent-2); }

/* Home shelves */
.shelf { margin-bottom: 32px; }
.shelf h2 { font-size: 20px; margin: 0 0 12px; }
.row {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 160px;
  gap: 16px;
  overflow-x: auto;
  padding: 4px 2px 12px;
  scroll-snap-type: x proximity;
}
.row > * { scroll-snap-align: start; }
.poster .up-next-badge { color: #111; background: var(--accent-2); }

/* Player extras */

.player-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 12px 16px; }
.player-head .secondary { padding: 5px 14px; font-size: 13px; }
.up-next {
  position: absolute;
  right: 16px;
  bottom: 72px;
  z-index: 2;
  width: min(320px, calc(100% - 32px));
  display: grid;
  gap: 4px;
  padding: 16px;
  background: rgba(11, 11, 15, .92);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 8px 30px rgba(0, 0, 0, .6);
}
.up-next-actions { display: flex; gap: 8px; margin-top: 8px; }

@media (max-width: 640px) {
  .row { grid-auto-columns: 120px; gap: 12px; }
  .ep-toggle { flex-basis: 36px; height: 36px; }
  .resume-info .progress { flex-basis: 120px; }
}

/* Live TV: guide grid */
.live-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; margin-bottom: 14px; }
.live-head h1 { margin: 0; font-size: 26px; }
.live-clock { color: var(--muted); font-variant-numeric: tabular-nums; font-size: 18px; }
.guide {
  --chan: 200px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
}
.guide-times { display: flex; height: 34px; border-bottom: 1px solid var(--border); }
.guide-corner { flex: 0 0 var(--chan); border-right: 1px solid var(--border); background: var(--bg); }
.guide-ruler { position: relative; flex: 1; overflow: hidden; }
.guide-ruler span {
  position: absolute;
  top: 0;
  bottom: 0;
  padding: 7px 8px 0;
  border-left: 1px solid var(--border);
  font-size: 13px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.guide-row { display: flex; height: 64px; border-bottom: 1px solid var(--border); }
.guide-row:last-child { border-bottom: 0; }
.guide-channel {
  flex: 0 0 var(--chan);
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  padding: 0 12px;
  border-right: 1px solid var(--border);
  background: var(--bg);
}
.channel-logo {
  position: relative;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 56px;
  height: 40px;
  overflow: hidden;
  border-radius: 6px;
  background: var(--surface-hover);
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}
.channel-logo img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: var(--surface-hover); }
.channel-name {
  min-width: 0;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.25;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.guide-track { position: relative; flex: 1; min-width: 0; overflow: hidden; }
.guide-prog {
  position: absolute;
  top: 5px;
  bottom: 5px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 0;
  padding: 0 10px;
  overflow: hidden;
  border: 1px solid transparent;
  border-radius: 6px;
  background: var(--surface-hover);
}
.guide-prog.now { background: rgba(255, 122, 26, .16); }
.guide-prog.cont .prog-title::before { content: "‹ "; color: var(--muted); }
.guide-prog:hover, .guide-channel:hover { border-color: var(--accent); }
.guide-prog:focus-visible, .guide-channel:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.prog-title, .prog-sub { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.prog-title { font-size: 14px; font-weight: 600; }
.prog-sub { font-size: 12px; color: var(--muted); }
.guide-now { position: absolute; top: 0; bottom: 0; z-index: 1; width: 2px; background: var(--accent-2); pointer-events: none; }
.guide-detail { display: flex; gap: 20px; min-height: 150px; margin-top: 20px; }
.guide-detail img { flex: 0 0 auto; width: 240px; aspect-ratio: 16 / 9; object-fit: cover; border-radius: var(--radius); background: var(--surface); }
.guide-detail-text { min-width: 0; }
.guide-detail h2 { margin: 2px 0 4px; font-size: 22px; }
.guide-meta { font-size: 14px; font-weight: 600; }
.guide-detail .progress { position: static; width: 240px; margin-top: 8px; }
.guide-detail .overview {
  max-width: 80ch;
  margin: 8px 0 0;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Live TV: playlists along the top, categories down the side */
.live-lists { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.live-body { display: flex; gap: 16px; align-items: flex-start; }
.live-main { flex: 1; min-width: 0; }
.live-categories { flex: 0 0 180px; display: flex; flex-direction: column; gap: 2px; position: sticky; top: 76px; }
.live-choice {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 7px 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
}
.live-categories .live-choice { border-color: transparent; border-radius: 8px; background: none; font-weight: 500; }
.live-choice .live-count { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.live-choice:hover { border-color: var(--accent); }
.live-choice.active { background: rgba(255, 122, 26, .16); border-color: var(--accent); }
.live-categories .live-choice.active { font-weight: 700; }
.live-choice:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

@media (max-width: 760px) {
  .live-body { flex-direction: column; align-items: stretch; }
  .live-categories { position: static; flex: none; flex-direction: row; overflow-x: auto; gap: 6px; padding-bottom: 4px; }
  .live-categories .live-choice { flex: 0 0 auto; border-color: var(--border); border-radius: 999px; background: var(--surface); }
}

@media (max-width: 640px) {
  .guide { --chan: 76px; }
  .channel-name { display: none; }
  .guide-detail img { display: none; }
}

/* Live TV: player */
.video-player.live video { aspect-ratio: 16 / 9; }
.live-badge {
  padding: 2px 8px;
  border-radius: 4px;
  background: #e5243b;
  color: #fff;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .06em;
}
.live-progress { flex: 1; min-width: 40px; height: 6px; overflow: hidden; border-radius: 999px; background: rgba(255, 255, 255, .18); }
.live-progress span { display: block; height: 100%; background: var(--accent); }
.live-error {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: grid;
  place-content: center;
  gap: 10px;
  text-align: center;
  background: rgba(0, 0, 0, .78);
}
.osd-next { display: none; }

/* On-screen title and resume notice: TV mode only */
.osd-title, .osd-toast { display: none; }
.video-player .controls { transition: opacity .3s ease; }

/* ==========================================================================
   TV mode: html.tv. Layouts are drawn for a 1536 px wide screen and scaled to fit
   (body zoom, set by tv.js), so they look the same on any TV.
   ========================================================================== */

html.tv { scrollbar-width: none; }
html.tv ::-webkit-scrollbar { display: none; }
html.tv body { font-size: 16px; }

/* Keep clear of the edges: many TVs crop them (overscan). */
html.tv { --sidebar: 272px; }
html.tv .sidebar { padding: 36px 20px 36px 48px; gap: 32px; }
html.tv .sidebar nav a { padding: 11px 16px; font-size: 18px; gap: 14px; }
html.tv .sidebar nav a:focus { background: var(--accent-2); color: #111; box-shadow: none; }
html.tv .sidebar nav a:focus .nav-icon { color: #111; }
html.tv .nav-icon { width: 24px; height: 24px; }
html.tv .topbar { padding: 18px 64px 18px 40px; gap: 32px; }
html.tv .global-search input { padding: 11px 18px 11px 44px; font-size: 17px; }
html.tv .global-search input:focus { box-shadow: 0 0 0 3px var(--bg), 0 0 0 6px var(--accent-2); }
html.tv main { max-width: none; padding: 28px 64px 80px 40px; }
html.tv .hero { margin: 0 -64px 8px -40px; padding: 40px 64px 40px 40px; }
html.tv nav a { padding: 8px 18px; font-size: 17px; }
html.tv .scan { font-size: 14px; }

/* Focus is the cursor on a TV, so it has to be obvious from across the room. */
html.tv :focus { outline: none; }
html.tv nav a:focus,
html.tv button:focus,
html.tv .secondary:focus,
html.tv .play-button:focus,
html.tv .back:focus,
html.tv .toolbar input:focus {
  box-shadow: 0 0 0 3px var(--bg), 0 0 0 6px var(--accent-2);
}
html.tv .back:focus { color: var(--text); border-radius: 6px; }
html.tv .card:focus .poster {
  border-color: transparent;
  box-shadow: 0 0 0 4px var(--accent-2), 0 14px 36px rgba(0, 0, 0, .7);
}
html.tv .card:focus .card-title { color: var(--accent-2); }
html.tv .card .poster { transition: box-shadow .15s ease; }
html.tv .card:hover .poster { transform: none; }
html.tv .episodes a:focus {
  background: var(--surface-hover);
  border-color: var(--accent-2);
  box-shadow: 0 0 0 2px var(--accent-2);
}
html.tv .ep-toggle:focus { border-color: var(--accent-2); color: var(--text); }
html.tv .link-button:focus { color: var(--text); }

/* Bigger posters, with room around rows so the focus ring is not clipped. */
html.tv .grid { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 32px 24px; }
html.tv .row { grid-auto-columns: 180px; gap: 24px; padding: 16px 16px 26px; margin: -16px -16px 0; scroll-padding: 0 16px; }
html.tv .shelf { margin-bottom: 28px; }
html.tv .shelf h2 { font-size: 24px; }
html.tv .card-title { font-size: 16px; }
html.tv .hero-poster { flex-basis: 240px; }
html.tv .hero h1 { font-size: 40px; }
html.tv .overview { font-size: 17px; }
html.tv .play-button { padding: 12px 32px; font-size: 18px; }
html.tv .episodes .still { flex-basis: 200px; }
html.tv .ep-title { font-size: 17px; }

/* Full-screen player with controls over the picture that fade out while watching. */
html.tv .player { position: fixed; inset: 0; z-index: 100; background: #000; }
html.tv .player > :not(.video-player) { display: none; }
html.tv .video-player { position: absolute; inset: 0; border-radius: 0; box-shadow: none; }
html.tv .video-player video { width: 100%; height: 100%; max-height: none; object-fit: contain; cursor: default; }
html.tv .video-player .controls {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  gap: 18px;
  padding: 60px 64px 44px;
  background: linear-gradient(transparent, rgba(0, 0, 0, .85));
  border: 0;
}
html.tv .video-player .ctl { font-size: 22px; pointer-events: none; }
html.tv .video-player .ctl.mute, html.tv .video-player .ctl.full { display: none; }
html.tv .video-player .seek { height: 8px; }
html.tv .video-player .clock { font-size: 18px; color: var(--text); }
html.tv .osd-title {
  display: block;
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  padding: 44px 64px 80px;
  background: linear-gradient(rgba(0, 0, 0, .8), transparent);
  transition: opacity .3s ease;
  pointer-events: none;
}
html.tv .osd-name { font-size: 30px; font-weight: 800; }
html.tv .osd-sub { font-size: 18px; color: #d6d6de; margin-top: 4px; }
html.tv .osd-toast {
  display: block;
  position: absolute;
  top: 150px;
  left: 64px;
  padding: 10px 18px;
  border-radius: 999px;
  background: rgba(11, 11, 15, .85);
  border: 1px solid var(--border);
  font-size: 16px;
}
html.tv .video-player.idle .controls,
html.tv .video-player.idle .osd-title { opacity: 0; }
html.tv .video-player.idle { cursor: none; }
html.tv .video-player:focus-visible { box-shadow: none; }
html.tv .spinner { width: 72px; height: 72px; top: calc(50% - 36px); left: calc(50% - 36px); }
html.tv .up-next { right: 64px; bottom: 150px; width: 380px; padding: 22px; font-size: 17px; }
html.tv .up-next strong { font-size: 22px; }

/* Live TV on a TV: a roomier guide; the focused programme lights up. */
html.tv .guide { --chan: 240px; }
html.tv .guide-times { height: 40px; }
html.tv .guide-ruler span { font-size: 15px; padding-top: 9px; }
html.tv .guide-row { height: 78px; }
html.tv .channel-logo { width: 64px; height: 46px; }
html.tv .channel-name { font-size: 16px; }
html.tv .prog-title { font-size: 17px; }
html.tv .prog-sub { font-size: 14px; }
html.tv .guide-prog:focus, html.tv .guide-channel:focus { background: var(--accent-2); color: #111; }
html.tv .guide-prog:focus .prog-sub, html.tv .guide-prog:focus .prog-title::before { color: #3a3a3a; }
html.tv .guide-channel:focus .channel-logo { background: #fff; }
html.tv .guide-detail { min-height: 200px; }
html.tv .guide-detail img { width: 320px; }
html.tv .guide-detail h2 { font-size: 28px; }
html.tv .guide-meta { font-size: 17px; }
html.tv .live-clock { font-size: 22px; }
html.tv .live-categories { flex-basis: 220px; }
html.tv .live-choice { font-size: 17px; padding: 9px 18px; }
html.tv .live-choice .live-count { font-size: 14px; }
html.tv .live-choice:focus { background: var(--accent-2); border-color: var(--accent-2); color: #111; }
html.tv .live-choice:focus .live-count { color: #3a3a3a; }
html.tv .video-player .ctl.chan { display: none; }
html.tv .video-player .live-badge { font-size: 15px; }
html.tv .video-player .live-progress { height: 8px; }
html.tv .osd-next { display: block; font-size: 16px; color: #b9b9c6; margin-top: 6px; }
html.tv .live-error { font-size: 20px; }

/* Profiles and devices */
[hidden] { display: none !important; }
.small { font-size: 13px; }
.avatar {
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--avatar, var(--accent));
  color: #fff;
  font-weight: 800;
  font-size: 14px;
  text-shadow: 0 1px 2px rgba(0, 0, 0, .35);
}
.avatar.large { width: 96px; height: 96px; font-size: 44px; border-radius: 22px; }
.profile-chip { display: flex; padding: 2px; border-radius: 50%; border: 1px solid var(--border); }
.profile-chip .avatar { width: 32px; height: 32px; font-size: 15px; }
.profile-chip:hover { border-color: var(--accent); }
.profile-name { font-weight: 600; max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Full-screen steps: link, setup, name, picker. The app's navigation is hidden until they're done. */
html.gated .sidebar, html.gated .sidebar-backdrop, html.gated .menu-button, html.gated .global-search,
html.gated .scan > :not(#tv-toggle) { display: none !important; }
html.gated body { padding-left: 0; }
.gate { max-width: 560px; margin: 8vh auto 0; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 14px; }
.gate.wide { max-width: 1000px; }
.gate h1 { margin: 0; font-size: 30px; }
.gate p { margin: 0; }
.gate-logo { border-radius: 14px; }
.gate input:not(.code-input) {
  width: min(360px, 100%);
  padding: 12px 16px;
  font: inherit;
  font-size: 18px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-align: center;
}
.code-input {
  width: 8ch;
  padding: 10px 14px;
  font: 700 28px/1 ui-monospace, "Cascadia Mono", Consolas, monospace;
  letter-spacing: .25em;
  text-align: center;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.gate .code-input { width: 10ch; }
.gate input:focus, .code-input:focus { outline: none; border-color: var(--accent-2); }
.gate button[type="submit"] { padding: 10px 32px; font-size: 16px; }
.link-code { display: flex; gap: 12px; margin: 10px 0; }
.link-code span {
  display: grid;
  place-items: center;
  width: 72px;
  height: 92px;
  font: 800 56px/1 ui-monospace, "Cascadia Mono", Consolas, monospace;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
}
.form-error { color: #ff7b72; min-height: 1.5em; }
.form-error:empty { min-height: 0; }
.avatar-preview { min-height: 96px; }
.swatches { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }
.swatch { width: 36px; height: 36px; padding: 0; border-radius: 50%; background: var(--avatar); border: 3px solid transparent; }
.swatch[aria-pressed="true"] { border-color: var(--text); }
.picker { display: flex; flex-wrap: wrap; justify-content: center; gap: 28px; margin: 24px 0; }
.pick { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 8px; background: none; color: var(--muted); border-radius: 26px; }
.pick:hover, .pick:focus-visible { color: var(--text); }
.pick .avatar.large { width: 132px; height: 132px; font-size: 60px; border-radius: 28px; transition: box-shadow .15s ease; }
.pick:hover .avatar, .pick:focus-visible .avatar { box-shadow: 0 0 0 4px var(--accent-2); }
.pick:focus-visible { outline: none; }
.pick-name { font-size: 18px; font-weight: 600; }

/* Profile and admin pages */
.account-head { display: flex; align-items: center; gap: 20px; margin: 8px 0 8px; }
.account-head h1 { margin: 0; font-size: 30px; }
.danger:hover { border-color: #ff7b72; color: #ff7b72; }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; margin-bottom: 20px; }
.panel h2 { margin: 0 0 8px; font-size: 18px; }
.panel > p { margin: 0 0 12px; }
.link-form { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.link-result:not(:empty) { margin-top: 14px; }
.link-result p { margin: 0 0 6px; }
.link-result .hero-actions { margin-top: 8px; }
.ok { color: #7ee787; }
.with-avatar { display: inline-flex; align-items: center; gap: 8px; padding-left: 6px; }
.tag { margin-left: 8px; padding: 1px 8px; font-size: 11px; font-weight: 700; border-radius: 999px; background: var(--surface-hover); border: 1px solid var(--border); color: var(--muted); vertical-align: 2px; }
.admin-list { list-style: none; margin: 0; padding: 0; }
.admin-list li { display: flex; align-items: center; gap: 14px; padding: 12px 0; border-top: 1px solid var(--border); }
.admin-list li:first-child { border-top: 0; }
.admin-list .avatar { width: 36px; height: 36px; font-size: 17px; }
.row-main { flex: 1; min-width: 0; }
.row-title { font-weight: 600; }
.row-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.row-actions .secondary { padding: 6px 14px; font-size: 13px; }
@media (max-width: 640px) {
  .admin-list li { flex-wrap: wrap; }
  .row-actions { flex-basis: 100%; justify-content: flex-start; }
  .link-code span { width: 56px; height: 72px; font-size: 42px; }
}

/* TV: focus on the new controls */
html.tv .pick:focus .avatar { box-shadow: 0 0 0 3px var(--bg), 0 0 0 7px var(--accent-2); }
html.tv .pick:focus { color: var(--text); box-shadow: none; }
html.tv .swatch:focus { box-shadow: 0 0 0 3px var(--bg), 0 0 0 6px var(--accent-2); }
html.tv .profile-chip:focus { border-color: var(--accent-2); box-shadow: 0 0 0 2px var(--accent-2); }
html.tv .gate input:focus, html.tv .code-input:focus { box-shadow: 0 0 0 2px var(--accent-2); }

/* Fix match */
.mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; overflow-wrap: anywhere; }
.match-form { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.match-form input {
  padding: 10px 14px;
  font: inherit;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.match-form input:focus { outline: none; border-color: var(--accent-2); }
.match-query { flex: 1 1 280px; min-width: 0; }
.match-year { width: 7ch; }
.match-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 12px; }
.match-card {
  display: flex; gap: 14px; align-items: flex-start; width: 100%; padding: 10px;
  font: inherit; color: inherit; text-align: left;
  background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius);
}
button.match-card { cursor: pointer; }
button.match-card:hover { background: var(--surface-hover); border-color: var(--accent-2); }
button.match-card:focus-visible { outline: 2px solid var(--accent-2); outline-offset: 2px; }
.match-card.current { max-width: 640px; margin-bottom: 12px; }
.match-poster { flex: 0 0 72px; }
.match-poster .poster { border-radius: 6px; }
.match-poster .initials { font-size: 20px; }
.match-text { min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.match-title { font-weight: 600; }
.match-overview {
  margin: 0; font-size: 13px; color: var(--muted);
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
html.tv button.match-card:focus { outline: none; border-color: transparent; box-shadow: 0 0 0 4px var(--accent-2); }
html.tv .match-form input:focus { box-shadow: 0 0 0 2px var(--accent-2); }
@media (max-width: 640px) {
  .match-list { grid-template-columns: 1fr; }
}

/* Settings: categories on the left, the chosen one on the right */
.settings { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 32px; align-items: start; }
.settings-nav { position: sticky; top: 80px; display: flex; flex-direction: column; gap: 2px; }
.settings-nav h1 { margin: 4px 12px 14px; font-size: 24px; }
.settings-link { padding: 10px 12px; border-radius: 8px; color: var(--muted); text-decoration: none; font-weight: 600; }
.settings-link:hover { background: var(--surface-hover); color: var(--text); }
.settings-link[aria-current="page"] { background: var(--surface); color: var(--text); box-shadow: inset 3px 0 0 var(--accent); }
.settings-title { margin: 6px 0 18px; font-size: 22px; }
.panel h3 { margin: 0 0 10px; font-size: 18px; }
.panel h4 { margin: 18px 0 4px; font-size: 14px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.fact-list { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 8px 24px; margin: 0; }
.fact-list dt { color: var(--muted); }
.fact-list dd { margin: 0; overflow-wrap: anywhere; }
.admin-list.compact li { padding: 8px 0; }
.row-actions.start { justify-content: flex-start; margin-top: 14px; }
.danger-text { color: #ff7b72; }
.meter { height: 8px; margin-top: 12px; border-radius: 999px; background: var(--surface-hover); overflow: hidden; }
.meter span { display: block; height: 100%; background: var(--gradient); }
@media (max-width: 760px) {
  .settings { grid-template-columns: minmax(0, 1fr); gap: 16px; }
  .settings-nav { position: static; flex-direction: row; flex-wrap: wrap; gap: 6px; }
  .settings-nav h1 { flex-basis: 100%; margin: 0 0 6px; }
  .settings-link { padding: 8px 12px; background: var(--surface); }
  .settings-link[aria-current="page"] { box-shadow: inset 0 -3px 0 var(--accent); }
  .fact-list { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .fact-list dd { margin-bottom: 8px; }
}
html.tv .settings { grid-template-columns: 280px minmax(0, 1fr); gap: 48px; }
html.tv .settings-link { font-size: 18px; padding: 12px 16px; }
html.tv .settings-link:focus { color: var(--text); box-shadow: 0 0 0 2px var(--accent-2); }

/* Settings: libraries */
.row-actions.top { margin: 0 0 14px; }
.scan-line:empty { display: none; }
.scan-line { margin: 0 0 14px; color: var(--accent-2); }
.library-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 10px; }
.library-head h3 { margin-bottom: 2px; }
.folder-list { list-style: none; margin: 0 0 14px; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.folder-list li { display: flex; align-items: center; gap: 12px; }
.folder-list.editable li { justify-content: space-between; padding: 8px 12px; background: var(--bg); border: 1px solid var(--border); border-radius: 8px; }
.small-button { padding: 4px 12px; font-size: 13px; }
.folder-browser { border: 1px solid var(--border); border-radius: 8px; padding: 12px; background: var(--bg); }
.browser-path { margin-bottom: 8px; color: var(--muted); }
.browser-list { display: flex; flex-wrap: wrap; gap: 6px; max-height: 260px; overflow-y: auto; }
.browser-item { padding: 6px 12px; font: inherit; font-size: 14px; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 8px; cursor: pointer; }
.browser-item:hover, .browser-item:focus-visible { border-color: var(--accent); }
.browser-item.up { color: var(--muted); }
.typed-path { display: flex; gap: 8px; margin-top: 10px; }
.typed-path input { flex: 1; min-width: 0; }
.field-row { display: flex; flex-wrap: wrap; gap: 14px; align-items: flex-end; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.field[hidden] { display: none; }
.field > span { font-size: 13px; color: var(--muted); }
.library-form input[type="text"], .library-form input[type="url"], .library-form input[type="time"], .library-form input[type="password"], .library-form input[type="number"], .library-form select {
  padding: 9px 12px; font: inherit; color: var(--text); background: var(--bg);
  border: 1px solid var(--border); border-radius: 8px; color-scheme: dark;
}
.library-form input[type="text"]:focus, .library-form input[type="url"]:focus, .library-form input[type="time"]:focus, .library-form input[type="password"]:focus, .library-form input[type="number"]:focus, .library-form select:focus { outline: none; border-color: var(--accent-2); }
.field input[type="text"] { min-width: 260px; }
.check { display: flex; gap: 12px; align-items: flex-start; margin-top: 12px; cursor: pointer; }
.check input { margin-top: 4px; width: 18px; height: 18px; accent-color: var(--accent); flex: none; }
.check > span { display: flex; flex-direction: column; gap: 2px; }
.form-error:empty { display: none; }
@media (max-width: 640px) {
  .field input[type="text"] { min-width: 0; width: 100%; }
  .field-row .field { flex: 1 1 140px; }
}
html.tv .browser-item:focus, html.tv .library-form select:focus, html.tv .library-form input:focus { box-shadow: 0 0 0 2px var(--accent-2); }

/* Settings → Metadata */
.source-list li { justify-content: space-between; }
.source-list .check { margin-top: 0; }
.source-check strong .tag, .source-check .tag { align-self: flex-start; margin-left: 0; }
.key-field input { width: min(460px, 100%); }
.short-input { width: 110px; }
.match-guess { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 4px; }
.source-list .row-actions { flex: none; }
.source-list .row-actions button { white-space: nowrap; }

/* Settings → Live TV */
.live-sources { display: flex; flex-direction: column; gap: 12px; margin-bottom: 12px; }
.live-source .field-row > .field:has(input[type="url"]) { flex: 1 1 340px; }
.live-source .field input[type="url"] { width: 100%; box-sizing: border-box; }
.live-source .field input[type="text"] { min-width: 200px; }
.library-form > h3 { margin: 24px 0 6px; }

/* Settings: a playlist's channels */
.live-editor input[type="search"] { min-width: 240px; }
.live-channels-scroll { max-height: 65vh; overflow: auto; border: 1px solid var(--border); border-radius: var(--radius); }
.live-channels { width: 100%; border-collapse: collapse; }
.live-channels th { position: sticky; top: 0; z-index: 1; background: var(--surface); text-align: left; font-size: 13px; color: var(--muted); }
.live-channels th, .live-channels td { padding: 6px 10px; border-bottom: 1px solid var(--border); }
.live-channels td:first-child, .live-channels th:first-child { width: 48px; text-align: center; }
.live-channels input[type="text"] { width: 100%; box-sizing: border-box; }
.live-channels input.chno { width: 72px; }
.live-channels td:nth-child(2) { width: 90px; }

/* Music: square covers, round artists, song rows */
.square .poster { aspect-ratio: 1; }
.square.round .poster { border-radius: 50%; }
.square .poster .initials { font-size: 36px; }
.music-toolbar { flex-wrap: wrap; }
.music-tabs { display: flex; gap: 6px; }
.music-tab { padding: 6px 14px; border-radius: 999px; border: 1px solid var(--border); color: var(--muted); font-weight: 600; font-size: 14px; }
.music-tab:hover { color: var(--text); border-color: var(--accent); }
.music-tab.active { color: var(--text); background: rgba(255, 122, 26, .16); border-color: var(--accent); }
.music-tab:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.music-toolbar input[type="search"] { margin-left: auto; }
.music-grid { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); }
.album-head { display: flex; gap: 28px; align-items: flex-end; margin-bottom: 24px; }
.album-cover { flex: 0 0 220px; }
.album-head h1 { margin: 2px 0 4px; font-size: 32px; line-height: 1.15; }
.album-artist { display: inline-block; font-weight: 700; margin-bottom: 4px; }
.album-artist:hover { color: var(--accent); }
.album-head .hero-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.track-list { display: flex; flex-direction: column; border-top: 1px solid var(--border); }
.track-row {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 9px 12px;
  border: 0;
  border-bottom: 1px solid var(--border);
  background: none;
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.track-row:hover { background: var(--surface-hover); }
.track-row:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.track-row.playing .track-title { color: var(--accent); }
.track-row.playing .track-no::before { content: "♪ "; color: var(--accent); }
.track-no { flex: 0 0 44px; color: var(--muted); font-variant-numeric: tabular-nums; text-align: right; }
.track-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.track-title, .track-sub { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.track-sub { font-size: 13px; color: var(--muted); }
.track-time { color: var(--muted); font-size: 14px; font-variant-numeric: tabular-nums; }

/* Music player bar: fixed along the bottom while something is queued */
body.has-player main { padding-bottom: 110px; }
.music-player {
  position: fixed;
  left: var(--sidebar);
  right: 0;
  bottom: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 20px;
  background: rgba(22, 22, 29, .97);
  border-top: 1px solid var(--border);
  backdrop-filter: blur(8px);
}
.mp-cover { flex: 0 0 auto; width: 56px; height: 56px; border-radius: 6px; object-fit: cover; background: var(--surface-hover); }
.mp-text { flex: 0 1 260px; min-width: 0; }
.mp-title { display: block; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mp-title:hover { color: var(--accent); }
.mp-artist { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mp-controls { display: flex; align-items: center; gap: 6px; }
.mp-btn {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 50%;
  background: none;
  color: var(--text);
  font-size: 18px;
  cursor: pointer;
}
.mp-btn:hover:not(:disabled) { background: var(--surface-hover); }
.mp-btn:disabled { opacity: .35; cursor: default; }
.mp-btn:focus-visible { outline: 2px solid var(--accent); }
.mp-play { width: 46px; height: 46px; background: var(--text); color: #111; }
.mp-play:hover:not(:disabled) { background: var(--accent-2); }
.mp-progress { flex: 1; display: flex; align-items: center; gap: 10px; min-width: 0; }
.mp-seek { flex: 1; min-width: 60px; accent-color: var(--accent); }
.mp-time { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; min-width: 38px; text-align: center; }
.mp-close { font-size: 15px; color: var(--muted); }

@media (max-width: 760px) {
  .album-head { flex-direction: column; align-items: flex-start; }
  .album-cover { flex-basis: auto; width: min(260px, 70vw); }
  .music-grid { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); }
  .music-player { flex-wrap: wrap; gap: 8px 12px; padding: 8px 12px; }
  .mp-cover { width: 44px; height: 44px; }
  .mp-text { flex: 1 1 0; }
  .mp-progress { order: 5; flex-basis: 100%; }
  body.has-player main { padding-bottom: 140px; }
}

html.tv .track-row { padding: 12px 16px; font-size: 18px; }
html.tv .track-row:focus { background: var(--accent-2); color: #111; }
html.tv .track-row:focus .track-sub, html.tv .track-row:focus .track-time, html.tv .track-row:focus .track-no { color: #3a3a3a; }
html.tv .music-tab { font-size: 17px; padding: 8px 18px; }
html.tv .music-tab:focus { background: var(--accent-2); color: #111; }
html.tv .music-player { padding: 14px 64px; }
html.tv .mp-btn:focus { background: var(--accent-2); color: #111; }

/* Search results */
.wide-shelf .row { grid-auto-columns: 240px; }
.episode-card .still {
  position: relative;
  aspect-ratio: 16 / 9;
  border-radius: 8px;
  overflow: hidden;
  background: var(--surface-hover);
  border: 1px solid var(--border);
}
.episode-card .still img { width: 100%; height: 100%; object-fit: cover; display: block; }
.episode-card .still .watched-mark { top: 6px; right: 6px; }
.search-live { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 8px; }
.search-live-row { display: flex; align-items: center; gap: 12px; padding: 8px 10px; border-radius: 8px; background: var(--surface); }
.search-live-row:hover { background: var(--surface-hover); }
.search-live-text { min-width: 0; display: flex; flex-direction: column; }
.search-live-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search-live-text .muted { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 640px) {
  .wide-shelf .row { grid-auto-columns: 200px; }
}
html.tv .wide-shelf .row { grid-auto-columns: 300px; }
html.tv .episode-card:focus .still { box-shadow: 0 0 0 4px var(--accent-2); }
html.tv .search-live-row:focus { background: var(--accent-2); color: #111; }
html.tv .search-live-row:focus .muted { color: #3a3a3a; }

/* Home: "Show all" / "Full guide" tiles and What's on */
.more-tile {
  aspect-ratio: 2 / 3;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border-radius: var(--radius);
  border: 1px dashed var(--border);
  background: var(--surface);
  color: var(--muted);
  font-weight: 600;
  transition: transform .15s ease, border-color .15s ease, color .15s ease;
}
.more-arrow {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--surface-hover);
  color: var(--text);
  font-size: 22px;
}
.more-card:hover .more-tile { transform: translateY(-3px); border-color: var(--accent); color: var(--text); }
html.tv .more-card:focus .more-tile { border: 1px solid transparent; color: var(--text); box-shadow: 0 0 0 4px var(--accent-2), 0 14px 36px rgba(0, 0, 0, .7); }
.live-now-card .channel-logo { position: absolute; top: 8px; left: 8px; z-index: 1; width: 52px; height: 36px; box-shadow: 0 2px 8px rgba(0, 0, 0, .5); }

/* Browse pages: sort, genre and decade filters */
.browse-controls { display: flex; flex: 1; flex-wrap: wrap; align-items: center; gap: 10px; }
.browse-controls input[type="search"] { margin-left: auto; }
.browse-select {
  padding: 6px 30px 6px 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%239a9aab' stroke-width='1.6'/%3E%3C/svg%3E") no-repeat right 12px center / 11px;
  color: var(--text);
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  appearance: none;
  cursor: pointer;
}
.browse-select:hover { border-color: var(--accent); }
.browse-select:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
button.music-tab { background: none; font: inherit; font-size: 14px; font-weight: 600; cursor: pointer; }

/* The # A–Z bar down the right side */
.alpha-rail {
  position: fixed;
  top: calc(var(--topbar-h, 64px) + 10px);
  right: 6px;
  bottom: 14px;
  z-index: 15;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
  width: 28px;
  touch-action: none;
  user-select: none;
}
.alpha-rail[hidden] { display: none; }
.alpha-rail button {
  flex: 1 1 0;
  max-height: 26px;
  width: 28px;
  padding: 0;
  border-radius: 6px;
  background: none;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
}
.alpha-rail button:hover:not(:disabled) { color: var(--text); background: var(--surface-hover); }
.alpha-rail button:disabled { opacity: .28; }
.alpha-rail button.current { color: var(--accent); }
main:has(.alpha-rail:not([hidden])) { padding-right: 44px; }
[data-letter] { scroll-margin-top: calc(var(--topbar-h, 64px) + 16px); }
body.has-player .alpha-rail { bottom: 96px; }
@media (max-width: 640px) {
  .alpha-rail { right: 2px; width: 22px; }
  .alpha-rail button { width: 22px; font-size: 10px; }
  main:has(.alpha-rail:not([hidden])) { padding-right: 30px; }
  .browse-controls input[type="search"] { margin-left: 0; width: 100%; }
}
html.tv .alpha-rail { right: 22px; width: 38px; }
html.tv .alpha-rail button { width: 38px; max-height: 30px; font-size: 14px; }
html.tv .alpha-rail button:focus { background: var(--accent-2); color: #111; }
html.tv main:has(.alpha-rail:not([hidden])) { padding-right: 84px; }
html.tv .browse-select { padding: 8px 34px 8px 18px; font-size: 17px; }
html.tv .browse-select:focus { box-shadow: 0 0 0 3px var(--bg), 0 0 0 6px var(--accent-2); outline: none; }
html.tv button.music-tab { font-size: 17px; padding: 8px 18px; }
html.tv button.music-tab:focus { background: var(--accent-2); color: #111; }
.music-tabs + .browse-controls { padding-left: 12px; border-left: 1px solid var(--border); }
@media (max-width: 640px) { .music-tabs + .browse-controls { padding-left: 0; border-left: 0; } }
.music-tab { white-space: nowrap; }
@media (max-width: 640px) {
  .music-toolbar { flex-direction: column; align-items: stretch; gap: 12px; }
  .music-toolbar .music-tabs { flex-wrap: wrap; }
}

/* Settings at the bottom of the menu (admins) */
.sidebar-settings { display: flex; align-items: center; gap: 12px; margin-top: auto; padding: 9px 12px; border-radius: 8px; color: var(--muted); font-weight: 500; }
.sidebar-settings[hidden] { display: none; }
.sidebar-settings:hover { color: var(--text); }
.sidebar-settings.active { color: var(--text); background: var(--surface-hover); }
.sidebar-settings.active .nav-icon { color: var(--accent); }
html.tv .sidebar-settings { padding: 11px 16px; font-size: 18px; gap: 14px; }
html.tv .sidebar-settings:focus { background: var(--accent-2); color: #111; box-shadow: none; }
html.tv .sidebar-settings:focus .nav-icon { color: #111; }
