/* cast-flow — "Tally" redesign.
   Deep neutral slate; signal yellow marks only what is on your screen/TV,
   red marks only LIVE. Content (titles, time, live picture) carries the page. */

:root {
  --bg: #0b0c10;
  --bg-2: #0f1117;
  --surface: #14161e;
  --surface-2: #1b1e28;
  --surface-3: #242835;
  --line: rgb(255 255 255 / 0.08);
  --line-2: rgb(255 255 255 / 0.14);
  --text: #f2f3f7;
  --text-2: #c3c7d4;
  --muted: #9298ad;
  --tally: #ffd23f;
  --tally-ink: #1c1600;
  --live: #ff4d4f;      /* lines and dots on dark surfaces */
  --live-fill: #d92b3a; /* fills behind white text: 4.8:1 */
  --danger: #ff6b6b;
  --ok: #4fd18b;

  --font: ui-sans-serif, -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI Variable Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-display: ui-sans-serif, -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI Variable Display", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

  --r-sm: 10px;
  --r: 14px;
  --r-lg: 20px;
  --rail: 88px;
  --top: 72px;
  --pad: clamp(16px, 2.6vw, 40px);
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --shadow-float: 0 18px 48px -12px rgb(0 0 0 / 0.65), 0 4px 12px rgb(0 0 0 / 0.35);

  color-scheme: dark;
  accent-color: var(--tally);
}

/* Channel / series colour families (rgb triples for alpha mixing). */
.hue-0 { --h: 124 138 255; }
.hue-1 { --h: 52 199 180; }
.hue-2 { --h: 255 168 72; }
.hue-3 { --h: 255 105 150; }
.hue-4 { --h: 120 205 112; }
.hue-5 { --h: 178 128 255; }
.hue-6 { --h: 80 172 255; }
.hue-7 { --h: 255 128 96; }

/* ---------- Contracts ---------- */
[hidden] { display: none !important; }
dialog:not([open]) { display: none !important; }

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; scrollbar-color: var(--surface-3) transparent; }

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font: 400 15px/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-variant-numeric: tabular-nums;
}

::selection { background: rgb(255 210 63 / 0.35); color: var(--text); }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 999px; border: 2px solid var(--bg); }
::-webkit-scrollbar-track { background: transparent; }

h1, h2, h3 { font-family: var(--font-display); margin: 0; text-wrap: balance; }
p { margin: 0; }
a { color: inherit; text-underline-offset: 3px; }
button, input, select, textarea { font: inherit; color: inherit; }
code { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 0.9em; }

:focus-visible {
  outline: 2px solid var(--tally);
  outline-offset: 2px;
  border-radius: 8px;
}

.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.icon {
  width: 20px; height: 20px; flex: none;
  fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round;
}
.icon .fill, .icon use { fill: inherit; }
symbol .fill { fill: currentColor; stroke: none; }

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

.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.empty { color: var(--muted); padding: 40px 0; text-align: center; }

/* ---------- Buttons ---------- */
.btn {
  --btn-bg: var(--surface-2);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 16px;
  border: 1px solid transparent; border-radius: 12px;
  background: var(--btn-bg); color: var(--text);
  font-weight: 600; font-size: 0.94rem; line-height: 1; white-space: nowrap;
  text-decoration: none; cursor: pointer;
  transition: background-color 160ms var(--ease), color 160ms var(--ease), transform 160ms var(--ease), opacity 160ms;
}
.btn:hover { --btn-bg: var(--surface-3); }
.btn:active { transform: scale(0.97); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.4; cursor: not-allowed; transform: none; }
.btn.primary { --btn-bg: var(--text); color: var(--bg); }
.btn.primary:hover { --btn-bg: #ffffff; }
.btn.pill { border-radius: 999px; padding: 0 24px; min-height: 48px; font-size: 1rem; }
.btn.glass {
  --btn-bg: rgb(255 255 255 / 0.1);
  backdrop-filter: blur(14px) saturate(140%);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
  border-color: rgb(255 255 255 / 0.08);
  border-radius: 999px;
}
.btn.glass:hover { --btn-bg: rgb(255 255 255 / 0.18); }
.btn.ghost { --btn-bg: transparent; color: var(--text-2); }
.btn.ghost:hover { --btn-bg: rgb(255 255 255 / 0.07); color: var(--text); }
.btn.danger { --btn-bg: rgb(255 107 107 / 0.12); color: var(--danger); }
.btn.danger:hover { --btn-bg: rgb(255 107 107 / 0.22); }
.btn.icon { width: 44px; padding: 0; }
.btn.round { border-radius: 999px; }
.btn.wide { width: 100%; }
.btn.small, .btn.btn-sm { min-height: 40px; padding: 0 14px; font-size: 0.86rem; border-radius: 10px; }
.btn.btn-xs { min-height: 32px; padding: 0 10px; font-size: 0.8rem; }
.btn.primary.btn-sm, .btn.primary.small { --btn-bg: var(--text); }
.btn.active { --btn-bg: rgb(255 210 63 / 0.16); color: var(--tally); }

.live-badge {
  display: inline-flex; align-items: center; gap: 6px;
  height: 24px; padding: 0 9px; border-radius: 6px;
  background: var(--live-fill); color: #fff;
  font-size: 0.72rem; font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase;
}
.live-badge::before {
  content: ""; width: 6px; height: 6px; border-radius: 50%; background: #fff;
  animation: blink 1.6s steps(1) infinite;
}
.live-badge.is-vod { background: var(--surface-3); color: var(--text-2); }
.live-badge.is-vod::before { display: none; }
@keyframes blink { 50% { opacity: 0.25; } }

.chip, .badge-subtle {
  display: inline-flex; align-items: center; height: 26px; padding: 0 10px;
  border-radius: 999px; border: 1px solid var(--line-2);
  color: var(--text-2); font-size: 0.78rem; font-weight: 600; white-space: nowrap;
}

.channel-bug {
  display: inline-grid; place-items: center; flex: none;
  min-width: 40px; height: 40px; padding: 0 8px; border-radius: 10px;
  background: var(--surface-3); color: var(--text);
  font-family: var(--font-display); font-weight: 800; font-size: 1.05rem; letter-spacing: -0.02em;
}

.tally-dot {
  display: inline-block; width: 14px; height: 14px; border-radius: 50%;
  background: var(--tally); border: 0; padding: 0;
  box-shadow: 0 0 0 4px rgb(255 210 63 / 0.18);
}

/* Native progress, themed: our only meter for program time. */
.meter {
  -webkit-appearance: none; appearance: none;
  display: block; width: 100%; height: 3px; border: 0; border-radius: 999px;
  background: rgb(255 255 255 / 0.14); overflow: hidden; color: var(--text);
}
.meter::-webkit-progress-bar { background: rgb(255 255 255 / 0.14); border-radius: 999px; }
.meter::-webkit-progress-value { background: var(--text); border-radius: 999px; }
.meter::-moz-progress-bar { background: var(--text); border-radius: 999px; }

/* ---------- Login ---------- */
.login-screen {
  min-height: 100dvh; display: grid; place-items: center; padding: 24px;
  background:
    radial-gradient(60% 50% at 50% 0%, rgb(255 210 63 / 0.07), transparent 70%),
    var(--bg);
}
.login-card { width: min(360px, 100%); }
.login-brand { display: grid; justify-items: center; text-align: center; margin-bottom: 36px; user-select: none; }
.login-logo {
  display: block; width: 104px; height: 104px; margin: 0 0 14px; padding: 0;
  border: 0; background: none; color: inherit; cursor: default;
  -webkit-tap-highlight-color: transparent;
}
.tv-logo { display: block; width: 100%; height: 100%; overflow: visible; }
.tv-stroke, .tv-knob, .tv-smile { fill: none; stroke-linecap: round; stroke-width: 4; }
.tv-stroke { stroke: var(--text-2); }
.tv-knob { stroke: var(--muted); }
.tv-smile { stroke: var(--tally); transition: d 260ms var(--ease); }
.tv-body { fill: var(--surface-3); stroke: var(--line-2); stroke-width: 2; }
.tv-screen { fill: var(--bg); }
.tv-tally { fill: var(--tally); }
.tv-power { fill: var(--tally); filter: drop-shadow(0 0 5px rgb(255 210 63 / 0.7)); }
.tv-antennas { transform-origin: 60px 34px; animation: tvWiggle 4.8s var(--ease) infinite; }
.tv-face { transition: transform 260ms var(--ease); }
.tv-eye {
  fill: var(--text); transform-box: fill-box; transform-origin: center;
  animation: tvBlink 5.2s infinite; transition: transform 200ms var(--ease);
}
@keyframes tvBlink { 0%, 94%, 100% { transform: scaleY(1); } 96% { transform: scaleY(0.1); } }
@keyframes tvWiggle { 0%, 82%, 100% { transform: rotate(0); } 86% { transform: rotate(-7deg); } 90% { transform: rotate(5deg); } 94% { transform: rotate(-2deg); } }
/* The TV looks down at the username field, and politely shuts its eyes for the password. */
.login-screen:has(#login-username:focus) .tv-face { transform: translateY(4px); }
.login-screen:has(#login-password:focus) .tv-eye { animation: none; transform: scaleY(0.12); }
.login-screen:has(#login-password:focus) .tv-smile { d: path("M45 79h18"); }
.login-logo:hover .tv-antennas { animation-duration: 1.2s; }
.login-logo.unlocked .tv-power { fill: var(--live); filter: drop-shadow(0 0 6px rgb(255 77 79 / 0.8)); }
@media (prefers-reduced-motion: reduce) {
  .tv-antennas, .tv-eye { animation: none; }
}
.login-wordmark { font-size: 1.75rem; line-height: 1.1; margin: 0; }
.login-desc { color: var(--muted); margin: 6px 0 0; }
.login-form { display: grid; gap: 14px; }
.login-password-wrap { animation: passwordSlideIn 260ms var(--ease); }
@keyframes passwordSlideIn { from { opacity: 0; transform: translateY(-6px); } }
.form-warning { color: var(--tally); font-size: 0.85rem; }
.form-error { color: var(--danger); font-size: 0.88rem; min-height: 1.2em; }
.form-error:empty { min-height: 0; }

/* ---------- Fields ---------- */
.field { display: grid; gap: 6px; }
.field > span, .field > label, .field-label {
  font-size: 0.8rem; font-weight: 600; color: var(--text-2); margin: 0;
}
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
/* :where() keeps base fields at zero specificity so components can restyle them. */
:where(input:not([type="checkbox"]):not([type="hidden"]), select, textarea) {
  width: 100%; min-height: 48px; padding: 12px 14px;
  border-radius: 12px; border: 1px solid var(--line-2);
  background: var(--bg-2); color: var(--text);
  transition: border-color 160ms, background-color 160ms;
}
:where(textarea) { min-height: 80px; resize: vertical; }
input::placeholder, textarea::placeholder { color: var(--muted); }
:where(input, select, textarea):focus-visible {
  outline: none; border-color: var(--tally); background: var(--surface);
  box-shadow: 0 0 0 3px rgb(255 210 63 / 0.18);
  border-radius: 12px;
}
select { cursor: pointer; }

/* ---------- App shell ---------- */
.app-view {
  display: grid;
  grid-template-columns: var(--rail) minmax(0, 1fr);
  grid-template-rows: var(--top) 1fr;
  min-height: 100dvh;
}

.rail {
  grid-row: 1 / -1; position: sticky; top: 0; height: 100dvh;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 20px 10px; background: var(--bg); border-right: 1px solid var(--line);
  z-index: 20;
}
.rail-brand { display: grid; place-items: center; width: 48px; height: 48px; margin-bottom: 20px; border-radius: 14px; }
.rail-link {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px;
  width: 68px; min-height: 64px; padding: 8px 4px; border-radius: 14px;
  color: var(--muted); text-decoration: none; font-size: 0.7rem; font-weight: 600;
  border: 0; background: transparent; cursor: pointer;
  transition: color 160ms, background-color 160ms;
}
.rail-link .icon { width: 24px; height: 24px; }
.rail-link:hover { color: var(--text); background: rgb(255 255 255 / 0.05); }
.rail-link.active { color: var(--text); background: var(--surface-2); }
.rail-link.active .icon { color: var(--tally); }
.rail-foot { margin-top: auto; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.rail-user {
  display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%;
  background: var(--surface-3); color: var(--text-2);
  font-weight: 800; font-size: 1rem;
}

.topbar {
  position: sticky; top: 0; z-index: 15;
  display: flex; align-items: center; gap: 12px;
  padding: 0 var(--pad);
  background: rgb(11 12 16 / 0.82);
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  border-bottom: 1px solid var(--line);
}
.search {
  position: relative; display: flex; align-items: center;
  flex: 1 1 auto; max-width: 520px;
}
.search .icon { position: absolute; left: 16px; color: var(--muted); pointer-events: none; }
.search input {
  min-height: 46px; padding-left: 46px; border-radius: 999px;
  background: var(--surface); border-color: transparent;
}
.search input:focus-visible { border-radius: 999px; }
.search input::-webkit-search-cancel-button { filter: invert(0.7); cursor: pointer; }

.cast-control {
  display: flex; align-items: center; gap: 2px;
  margin-left: auto; padding: 1px 3px 1px 14px; border-radius: 999px;
  background: var(--surface); color: var(--text-2);
}
.cast-target select {
  min-height: 44px; width: auto; max-width: 220px; padding: 0 8px;
  border: 0; background: transparent; font-weight: 600; text-overflow: ellipsis;
}
.cast-target select:focus-visible { box-shadow: none; outline: 2px solid var(--tally); }
.cast-control .btn.stop:hover { color: var(--danger); }
.clock { margin-left: auto; color: var(--text-2); font-weight: 700; font-size: 1rem; letter-spacing: -0.01em; }
.cast-control:not([hidden]) + .clock { margin-left: 8px; }

.page { padding: 28px var(--pad) 120px; min-width: 0; }

.view-head { margin: 8px 0 24px; }
.view-head h1 { font-size: clamp(1.75rem, 1.3rem + 1.6vw, 2.5rem); font-weight: 800; letter-spacing: -0.03em; line-height: 1.1; }
.view-lede { color: var(--muted); margin-top: 8px; max-width: 62ch; }
.view-head-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; }

/* ---------- Pills (category filter) ---------- */
.pills {
  display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none;
  margin: 0 calc(var(--pad) * -1) 20px; padding: 2px var(--pad);
  scroll-padding-inline: var(--pad);
  mask-image: linear-gradient(to right, transparent, #000 var(--pad), #000 calc(100% - var(--pad)), transparent);
}
.pills::-webkit-scrollbar { display: none; }
.pill-btn {
  flex: none; min-height: 40px; padding: 0 16px; border-radius: 999px;
  border: 1px solid var(--line-2); background: transparent; color: var(--text-2);
  font-weight: 600; font-size: 0.9rem; cursor: pointer;
  transition: background-color 160ms, color 160ms, border-color 160ms;
}
.pill-btn:hover { color: var(--text); border-color: rgb(255 255 255 / 0.28); }
.pill-btn[aria-pressed="true"], .pill-btn[aria-selected="true"] {
  background: var(--text); color: var(--bg); border-color: var(--text);
}

/* ---------- Stage ---------- */
.stage {
  position: relative; isolation: isolate;
  display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(300px, 1fr); gap: clamp(20px, 3vw, 44px);
  align-items: center;
  margin: 0 calc(var(--pad) * -1) 28px; padding: 8px var(--pad) 32px;
}
.stage::before {
  content: ""; position: absolute; inset: -28px 0 0; z-index: -1;
  background:
    radial-gradient(55% 80% at 22% 30%, rgb(var(--h, 255 255 255) / 0.16), transparent 70%),
    linear-gradient(to bottom, transparent 60%, var(--bg));
  transition: background 600ms var(--ease);
}
.stage-screen {
  position: relative; aspect-ratio: 16 / 9; border-radius: var(--r-lg); overflow: hidden;
  background: #000; box-shadow: var(--shadow-float);
}
.stage.on-tv .stage-screen, .stage-screen:has(.stage-screen-play:focus-visible) { outline: 2px solid var(--tally); outline-offset: 3px; }
.stage-video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0; transition: opacity 500ms var(--ease); }
.stage.is-live .stage-video { opacity: 1; }
.stage-slate {
  position: absolute; inset: 0; display: block;
  background:
    radial-gradient(70% 90% at 50% 40%, rgb(var(--h, 255 255 255) / 0.22), transparent 75%),
    #07080b;
  text-align: center; padding: 24px;
}
.stage-slate-num {
  position: absolute; left: clamp(16px, 3%, 32px); bottom: clamp(8px, 2%, 20px);
  font-family: var(--font-display); font-weight: 800; letter-spacing: -0.04em; line-height: 0.9;
  font-size: clamp(4.5rem, 3rem + 6vw, 8.5rem); color: rgb(var(--h, 255 255 255) / 0.55);
}
.stage-slate-text {
  position: absolute; left: 50%; top: calc(50% + 54px); transform: translateX(-50%);
  width: max-content; max-width: min(36ch, 90%); color: var(--text-2); font-size: 0.9rem;
}
.stage-slate-text:empty { display: none; }
.stage-screen-play {
  position: absolute; inset: 0; display: grid; place-items: center;
  border: 0; padding: 0; background: transparent; cursor: pointer; color: #fff;
}
.stage-screen-play:focus-visible { outline: none; }
.play-disc {
  display: grid; place-items: center; width: 76px; height: 76px; border-radius: 50%;
  background: rgb(255 255 255 / 0.16); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgb(255 255 255 / 0.2);
  opacity: 0; transform: scale(0.9);
  transition: opacity 220ms var(--ease), transform 220ms var(--ease), background-color 160ms;
}
.play-disc .icon { width: 30px; height: 30px; margin-left: 4px; }
.stage-screen-play:hover .play-disc, .stage-screen-play:focus-visible .play-disc,
.stage:not(.is-live) .play-disc { opacity: 1; transform: scale(1); }
.stage-screen-play:hover .play-disc { background: rgb(255 255 255 / 0.26); }
.stage-preview-tag {
  position: absolute; left: 14px; top: 14px;
  padding: 6px 10px; border-radius: 8px; background: rgb(0 0 0 / 0.55);
  color: var(--text-2); font-size: 0.75rem; font-weight: 600;
}

.stage-info { min-width: 0; display: grid; gap: 14px; align-content: center; }
.stage-channel { display: flex; align-items: center; gap: 12px; min-width: 0; }
.stage .channel-bug { background: rgb(var(--h) / 0.2); color: rgb(var(--h)); }
.stage-channel-text { display: grid; min-width: 0; flex: 1; }
.stage-channel-name { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stage-group { color: var(--muted); font-size: 0.82rem; }
.stage-title {
  font-size: clamp(1.75rem, 1.1rem + 2.2vw, 3rem); font-weight: 800;
  letter-spacing: -0.03em; line-height: 1.05; overflow-wrap: anywhere;
}
.stage-time { display: grid; gap: 8px; max-width: 460px; }
.stage-time .meter { height: 4px; }
.stage-left { color: var(--text-2); font-size: 0.9rem; font-weight: 600; }
.stage-next { color: var(--muted); font-size: 0.9rem; }
.stage-next:empty, .stage-desc:empty { display: none; }
.stage-desc {
  color: var(--muted); font-size: 0.9rem; max-width: 52ch;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.stage-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 6px; }
#stage-preview-toggle { margin-left: auto; color: var(--muted); }

/* ---------- Channel rows ---------- */
.group { margin-top: 32px; }
.group:first-child { margin-top: 0; }
.group-title {
  display: flex; align-items: center; gap: 10px; margin: 0 0 12px;
  font-size: 1.05rem; font-weight: 700; letter-spacing: -0.01em;
}
.group-title .count {
  display: inline-grid; place-items: center; min-width: 26px; height: 22px; padding: 0 7px;
  border-radius: 999px; background: var(--surface-2); color: var(--muted);
  font-size: 0.75rem; font-weight: 700;
}
details.group > summary { cursor: pointer; list-style: none; min-height: 44px; border-radius: 10px; }
details.group > summary::-webkit-details-marker { display: none; }
details.group > summary::after {
  content: ""; width: 8px; height: 8px; margin-left: 2px;
  border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted);
  transform: rotate(-45deg); transition: transform 200ms var(--ease);
}
details.group[open] > summary::after { transform: rotate(45deg) translateY(-2px); }
details.group.private > summary > span:first-child::before {
  content: "Privat · "; color: var(--muted); font-weight: 600;
}

.rows { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.row {
  position: relative;
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center;
  border-radius: var(--r); background: var(--surface);
  transition: background-color 160ms var(--ease), box-shadow 200ms var(--ease);
}
.row:hover { background: var(--surface-2); }
.row.is-stage { background: var(--surface-2); box-shadow: inset 0 0 0 2px var(--tally); }
.row.is-selected { background: rgb(255 210 63 / 0.06); }

.row-select { display: grid; place-items: center; width: 52px; align-self: stretch; cursor: pointer; }
.row-select[hidden] + .row-main { padding-left: 18px; }
.channel-checkbox {
  -webkit-appearance: none; appearance: none; margin: 0;
  width: 22px; height: 22px; border-radius: 7px; border: 2px solid var(--line-2);
  background: transparent; cursor: pointer; display: grid; place-items: center;
  transition: background-color 140ms, border-color 140ms;
}
.channel-checkbox::after {
  content: ""; width: 6px; height: 11px; margin-top: -2px;
  border-right: 2.5px solid var(--tally-ink); border-bottom: 2.5px solid var(--tally-ink);
  transform: rotate(45deg) scale(0); transition: transform 140ms var(--ease);
}
.channel-checkbox:checked { background: var(--tally); border-color: var(--tally); }
.channel-checkbox:checked::after { transform: rotate(45deg) scale(1); }
.channel-checkbox:focus-visible { outline: 2px solid var(--tally); outline-offset: 3px; }

.row-main {
  display: grid; grid-template-columns: minmax(150px, 210px) minmax(0, 1fr) minmax(170px, 26%);
  align-items: center; gap: 20px; min-height: 76px; padding: 12px 8px 12px 0;
  border: 0; background: transparent; text-align: left; cursor: pointer; min-width: 0;
  border-radius: var(--r);
}
.row-main:focus-visible { outline-offset: -2px; }
.row-channel { display: flex; align-items: baseline; gap: 12px; min-width: 0; }
.row-num {
  flex: none; min-width: 2.2ch; text-align: right;
  font-family: var(--font-display); font-weight: 800; font-size: 1.5rem; letter-spacing: -0.03em;
  color: rgb(var(--h) / 0.95);
}
.row-name { font-weight: 650; font-size: 0.95rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-2); }
.row-now { display: grid; gap: 8px; min-width: 0; position: relative; }
.row-title { display: flex; align-items: center; gap: 10px; min-width: 0; font-weight: 650; font-size: 1rem; }
.row-title-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-time { display: grid; grid-template-columns: auto minmax(60px, 1fr); align-items: center; gap: 12px; }
.row-left { color: var(--muted); font-size: 0.82rem; white-space: nowrap; }
.row-next {
  display: grid; gap: 2px; min-width: 0; padding-left: 20px; border-left: 1px solid var(--line);
  color: var(--muted); font-size: 0.85rem;
}
.row-next-time { font-weight: 700; color: var(--text-2); }
.row-next-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-next:has(.row-next-title:empty) { visibility: hidden; }

.row-actions { display: flex; align-items: center; gap: 2px; padding-right: 10px; }
.row-actions .btn { color: var(--muted); }
.row-actions .btn:hover { color: var(--text); }
.row-actions .action-watch:hover { color: var(--bg); --btn-bg: var(--text); }

/* Equalizer: "this is what you're watching" (Pluto) */
.eq { display: none; align-items: flex-end; gap: 2px; height: 14px; flex: none; }
.eq i { width: 3px; border-radius: 2px; background: var(--tally); height: 40%; }
.row.is-stage .eq, .row.on-tv .eq { display: inline-flex; }
.row.on-tv .eq i { background: var(--tally); }
@media (prefers-reduced-motion: no-preference) {
  .eq i { animation: eq 900ms ease-in-out infinite alternate; }
  .eq i:nth-child(2) { animation-delay: -300ms; animation-duration: 700ms; }
  .eq i:nth-child(3) { animation-delay: -600ms; animation-duration: 1100ms; }
}
@keyframes eq { from { height: 25%; } to { height: 100%; } }

.tally-badge {
  display: none; position: absolute; right: 0; top: -2px;
  padding: 3px 8px; border-radius: 6px; background: var(--tally); color: var(--tally-ink);
  font-size: 0.7rem; font-weight: 800; letter-spacing: 0.03em;
}
.row.on-tv .tally-badge { display: inline-block; }

/* ---------- Dock & toast ---------- */
.dock {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 30;
  display: flex; align-items: center; gap: 8px; padding: 8px 8px 8px 20px;
  border-radius: 999px; background: var(--surface-3); box-shadow: var(--shadow-float);
  animation: dockIn 320ms var(--ease);
}
.dock-count { color: var(--text-2); font-size: 0.9rem; margin-right: 6px; white-space: nowrap; }
.dock-count strong { color: var(--tally); font-size: 1.05rem; }
@keyframes dockIn { from { opacity: 0; transform: translate(-50%, 16px); } }

.toast {
  position: fixed; left: calc(var(--rail) + 24px); bottom: 24px; z-index: 40;
  max-width: min(440px, calc(100vw - var(--rail) - 48px));
  padding: 14px 18px; border-radius: 14px; background: var(--surface-3); color: var(--text);
  box-shadow: var(--shadow-float); font-size: 0.9rem; font-weight: 500;
  animation: toastIn 260ms var(--ease);
}
.toast:empty { display: none; }
.toast[data-kind="error"] { background: #3a1a1d; color: #ffd6d6; }
.toast[data-kind="ok"] { box-shadow: var(--shadow-float), inset 3px 0 0 var(--ok); }
@keyframes toastIn { from { opacity: 0; transform: translateY(10px); } }
body.has-dock .toast { bottom: 96px; }

/* ---------- TV-Guide timeline ---------- */
.timeline { min-width: 0; }
.tl-scroll {
  --min: 6px; --chcol: 220px;
  overflow: auto; max-height: calc(100dvh - var(--top) - 230px); min-height: 320px;
  margin: 0 calc(var(--pad) * -1); padding: 0 var(--pad) 12px;
  overscroll-behavior-x: contain; border-radius: 0;
}
.tl-scroll:focus-visible { outline-offset: -2px; }
.tl { display: grid; gap: 6px; width: max-content; }
.tl-row {
  display: grid; grid-template-columns: var(--chcol) repeat(240, var(--min));
  grid-template-rows: 72px; position: relative;
}
.tl-row > * { grid-row: 1; }
.tl-axis { grid-template-rows: 40px; position: sticky; top: 0; z-index: 4; background: var(--bg); }
.tl-corner {
  position: sticky; left: 0; z-index: 2; grid-column: 1;
  display: flex; align-items: center; padding-left: 4px;
  background: var(--bg); color: var(--muted); font-size: 0.8rem; font-weight: 700;
}
.tl-tick {
  display: flex; align-items: center; padding-left: 8px; border-left: 1px solid var(--line-2);
  color: var(--text-2); font-size: 0.82rem; font-weight: 700;
}
.tl-now-flag {
  z-index: 3; align-self: center; justify-self: start; transform: translateX(-50%);
  padding: 3px 7px; border-radius: 6px; background: var(--live-fill); color: #fff;
  font-size: 0.75rem; font-weight: 800;
}
.tl-channel {
  position: sticky; left: 0; z-index: 2; grid-column: 1;
  display: flex; align-items: stretch; padding-right: 8px; background: var(--bg);
}
.tl-channel-btn {
  display: flex; align-items: center; gap: 12px; width: 100%; min-width: 0; padding: 0 12px;
  border: 0; border-radius: var(--r-sm); background: var(--surface); text-align: left; cursor: pointer;
  transition: background-color 160ms;
}
.tl-channel-btn:hover { background: var(--surface-2); }
.tl-channel .channel-bug { background: rgb(var(--h) / 0.18); color: rgb(var(--h)); min-width: 38px; height: 38px; }
.tl-channel-name { font-weight: 650; font-size: 0.9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tl-prog {
  position: relative; display: flex; align-items: center; min-width: 0;
  margin: 0 2px; padding: 8px 12px; overflow: clip;
  border: 0; border-radius: var(--r-sm); background: var(--surface); text-align: left; cursor: pointer;
  transition: background-color 160ms;
}
.tl-prog:hover { background: var(--surface-3); }
.tl-prog-text {
  /* Sticks beside the channel column, so a program that began before the scroll position stays readable. */
  position: sticky; left: calc(var(--chcol) + 12px);
  display: grid; gap: 3px; min-width: 0; max-width: 100%;
}
.tl-prog-title { font-weight: 650; font-size: 0.88rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tl-prog-time { color: var(--muted); font-size: 0.76rem; white-space: nowrap; overflow: hidden; }
.tl-prog.is-past { background: var(--bg-2); }
.tl-prog.is-past .tl-prog-title { color: var(--muted); }
.tl-prog.is-current { background: var(--surface-3); }
.tl-prog.is-current .tl-prog-time { color: var(--text-2); }
.tl-prog.is-current .meter { position: absolute; left: 12px; right: 12px; bottom: 8px; width: auto; height: 3px; }
.tl-prog.clipped { border-top-left-radius: 2px; border-bottom-left-radius: 2px; }
.tl-prog.is-short { padding: 8px 6px; }
.tl-prog.is-short .tl-prog-text { left: calc(var(--chcol) + 6px); }
.tl-prog.is-short .tl-prog-time { display: none; }
.tl-empty { display: flex; align-items: center; padding: 0 16px; color: var(--muted); font-size: 0.85rem; }
.tl-now {
  z-index: 1; width: 2px; height: 100%; justify-self: start; transform: translateX(-1px);
  background: var(--live); pointer-events: none;
}

/* ---------- Series ---------- */
.cover-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(228px, 1fr));
  gap: 32px 20px;
}
.cover-grid > .empty { grid-column: 1 / -1; }
.cover-card { display: grid; gap: 10px; align-content: start; min-width: 0; }
.cover-link { display: grid; gap: 12px; text-decoration: none; border-radius: var(--r); }
.cover {
  position: relative; display: flex; align-items: flex-end;
  aspect-ratio: 2 / 3; padding: 16px; border-radius: var(--r); overflow: hidden;
  background:
    radial-gradient(120% 70% at 85% 10%, rgb(var(--h) / 0.55), transparent 60%),
    linear-gradient(160deg, rgb(var(--h) / 0.32), rgb(var(--h) / 0.08) 55%, #0d0e13);
  box-shadow: inset 0 0 0 1px rgb(255 255 255 / 0.06);
  transition: transform 260ms var(--ease), box-shadow 260ms var(--ease);
}
.cover-img {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: cover; object-position: center; border-radius: inherit;
  transition: transform 260ms var(--ease);
  z-index: 1;
}
.cover-link:hover .cover-img, .cover-link:focus-visible .cover-img {
  transform: scale(1.04);
}
.cover.has-poster .cover-title {
  display: none;
}
.cover-title {
  position: relative; z-index: 1;
  font-family: var(--font-display); font-weight: 800; letter-spacing: -0.03em; line-height: 1;
  font-size: clamp(1.3rem, 1rem + 0.9vw, 1.75rem); color: #fff; overflow-wrap: break-word;
  display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden;
}
.cover-badge {
  position: absolute; top: 10px; left: 10px; z-index: 2;
  padding: 4px 9px; border-radius: 7px; background: rgb(0 0 0 / 0.65);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  color: var(--text); font-size: 0.72rem; font-weight: 700;
}
.cover-link:hover .cover, .cover-link:focus-visible .cover { transform: translateY(-4px); box-shadow: inset 0 0 0 1px rgb(255 255 255 / 0.12), var(--shadow-float); }
.cover-link:focus-visible { outline-offset: 4px; }
.cover-meta { display: grid; gap: 2px; }
.cover-name { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cover-sub { color: var(--muted); font-size: 0.82rem; }

.series-view:has(> .series-detail:not([hidden])) > .view-head,
.series-view:has(> .series-detail:not([hidden])) > .series-toolbar { display: none; }
.series-toolbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  flex-wrap: wrap; margin-bottom: 20px;
}
.series-toolbar .pills { margin-bottom: 0; }
.series-search-wrap { flex: 1 1 260px; max-width: 380px; }
.series-search { width: 100%; max-width: 100%; }
.series-detail .back { margin: -4px 0 16px -12px; }
.series-hero { display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: 32px; align-items: end; margin-bottom: 32px; }
.series-hero .cover { width: 200px; }
.series-hero-info { display: grid; gap: 12px; }
.series-hero h2 { font-size: clamp(2rem, 1.3rem + 2.6vw, 3.25rem); font-weight: 800; letter-spacing: -0.035em; line-height: 1; }
.series-hero-meta { color: var(--text-2); font-weight: 600; }
.series-hero-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 8px; }
.series-hero-actions .hint { flex-basis: 100%; }
.episodes { list-style: none; margin: 0; padding: 0; max-width: 980px; }
.episodes li + li { border-top: 1px solid var(--line); }
.episode {
  display: grid; grid-template-columns: 56px minmax(0, 1fr) auto 44px; align-items: center; gap: 16px;
  width: 100%; min-height: 64px; padding: 10px 8px; border: 0; border-radius: 12px;
  background: transparent; text-align: left; cursor: pointer; transition: background-color 160ms;
}
.episode:hover { background: var(--surface); }
.ep-num { font-family: var(--font-display); font-weight: 800; font-size: 1.4rem; color: var(--muted); letter-spacing: -0.02em; }
.ep-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ep-dur { color: var(--muted); font-size: 0.85rem; }
.ep-play {
  display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%;
  background: var(--surface-2); color: var(--text); transition: background-color 160ms, color 160ms;
}
.ep-play .icon { width: 18px; height: 18px; margin-left: 2px; }
.episode:hover .ep-play, .episode:focus-visible .ep-play { background: var(--text); color: var(--bg); }

/* ---------- Dialogs: shared ---------- */
dialog { color: var(--text); padding: 0; border: 0; }
dialog::backdrop { background: rgb(4 5 8 / 0.72); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
dialog[open] { animation: dialogIn 280ms var(--ease); }
@keyframes dialogIn { from { opacity: 0; transform: translateY(14px) scale(0.985); } }

.sheet {
  width: min(640px, calc(100vw - 32px)); max-height: min(86dvh, 860px);
  border-radius: var(--r-lg); background: var(--surface); box-shadow: var(--shadow-float);
  overflow: hidden;
}
.sheet[open] { display: flex; flex-direction: column; }
.sheet-head {
  display: flex; align-items: flex-start; gap: 14px;
  padding: 20px 16px 16px 22px; border-bottom: 1px solid var(--line);
}
.sheet-head-text { flex: 1; min-width: 0; display: grid; gap: 4px; }
.sheet-head h2 { font-size: 1.3rem; font-weight: 800; letter-spacing: -0.02em; }
.sheet-head .muted { font-size: 0.88rem; }
.sheet-foot {
  display: flex; gap: 10px; padding: 14px 22px 20px; border-top: 1px solid var(--line);
  background: var(--surface);
}
.sheet-foot.split { justify-content: space-between; }
.sheet-form { display: grid; gap: 16px; padding: 20px 22px 0; overflow-y: auto; }
.sheet-form .sheet-foot { margin: 4px -22px 0; position: sticky; bottom: 0; }

.schedule { list-style: none; margin: 0; padding: 8px 10px; overflow-y: auto; flex: 1; }
.slot {
  display: grid; grid-template-columns: 56px minmax(0, 1fr) auto; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: 12px;
}
.slot + .slot { margin-top: 2px; }
.slot.past { opacity: 0.72; }
.slot.past .slot-title { color: var(--text-2); }
.slot.current { background: var(--surface-2); box-shadow: inset 0 0 0 2px var(--tally); }
.slot-time { font-weight: 800; color: var(--text-2); }
.slot-body { display: grid; gap: 4px; min-width: 0; }
.slot-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.slot-meta { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 0.82rem; }
.slot-meta .live-badge { height: 20px; font-size: 0.66rem; }
.slot-actions { display: flex; align-items: center; gap: 2px; }
.slot.error { color: var(--danger); grid-template-columns: 1fr; }

/* ---------- Theater player ---------- */
.theater {
  width: 100vw; height: 100dvh; max-width: none; max-height: none; margin: 0;
  background: #000; overflow: hidden;
}
.theater[open] { display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr) auto; }
.theater::backdrop { background: #000; }
.theater-head {
  display: flex; align-items: center; gap: 14px; padding: 18px 22px;
  background: linear-gradient(to bottom, rgb(0 0 0 / 0.9), transparent);
  position: relative; z-index: 2;
}
.theater-head-text { flex: 1; min-width: 0; display: grid; gap: 2px; }
.theater-head h2 { font-size: clamp(1.1rem, 0.9rem + 0.8vw, 1.5rem); font-weight: 800; letter-spacing: -0.02em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.theater-head p { color: var(--muted); font-size: 0.9rem; }
.theater-head p:empty { display: none; }
.theater .channel-bug { background: rgb(255 255 255 / 0.12); }
#player-mode-badge:not(:empty) { flex: none; }
.screen { position: relative; min-width: 0; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr); background: #000; }
.screen video { width: 100%; max-width: 100%; height: 100%; min-width: 0; min-height: 0; object-fit: contain; background: #000; }
.slate {
  position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 16px;
  padding: 24px; text-align: center; color: var(--text-2);
  background: radial-gradient(60% 60% at 50% 45%, rgb(255 255 255 / 0.06), transparent 70%), #000;
}
.slate p { max-width: 44ch; font-size: 1rem; }
.player-audio-warning {
  position: absolute; top: 16px; left: 50%; transform: translateX(-50%); z-index: 5;
  width: min(560px, calc(100vw - 32px));
  background: rgb(28 20 12 / 0.94); border: 1px solid rgb(255 170 0 / 0.4);
  border-radius: 14px; box-shadow: var(--shadow-float); backdrop-filter: blur(12px);
  animation: toastIn 260ms var(--ease);
}
.player-audio-warning-content {
  display: flex; align-items: flex-start; gap: 12px; padding: 12px 14px;
}
.player-audio-warning-content .icon {
  width: 20px; height: 20px; color: #ffaa00; flex: none; margin-top: 2px;
}
.player-audio-warning-text {
  flex: 1; display: grid; gap: 3px; font-size: 0.85rem; line-height: 1.35;
}
.player-audio-warning-text strong {
  color: #ffcc66; font-weight: 700;
}
.player-audio-warning-text span {
  color: var(--text-2);
}
.player-audio-warning-content .btn {
  color: var(--muted); padding: 4px; flex: none; min-height: 32px;
}
.player-audio-warning-content .btn:hover {
  color: var(--text);
}
.theater-foot {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 20px;
  padding: 14px 22px 20px; background: linear-gradient(to top, rgb(0 0 0 / 0.95), rgb(0 0 0 / 0.6));
}
.transport { display: flex; flex-wrap: wrap; gap: 4px; }
.transport .btn { min-height: 44px; }
.live-btn .live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--live); }
.up-next { display: grid; gap: 2px; min-width: 0; justify-self: end; text-align: right; padding: 0 4px; }
.up-next:has(#player-next:empty) { visibility: hidden; }
.up-next-label { font-size: 0.72rem; font-weight: 700; color: var(--muted); letter-spacing: 0.04em; text-transform: uppercase; }
#player-next { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-actions { display: flex; align-items: center; gap: 4px; }

/* "⋯" overflow menu: destructive actions live one deliberate step away. */
.menu { position: relative; }
.menu > summary { list-style: none; }
.menu > summary::-webkit-details-marker { display: none; }
.menu-list {
  position: absolute; right: 0; bottom: calc(100% + 8px); z-index: 10;
  display: grid; gap: 2px; width: max-content; max-width: calc(100vw - 24px); padding: 6px;
  border-radius: 14px; background: var(--surface-2); box-shadow: var(--shadow-float);
}
.menu-item {
  display: flex; align-items: center; gap: 10px; width: 100%; min-height: 44px; padding: 0 12px;
  border: 0; border-radius: 10px; background: transparent; color: var(--text);
  font-weight: 600; font-size: 0.9rem; text-align: left; cursor: pointer;
}
.menu-item:hover { background: var(--surface-3); }
.menu-item:disabled { opacity: 0.45; cursor: not-allowed; }
.menu-item.danger { color: var(--danger); }
.menu-item.danger:hover { background: rgb(255 107 107 / 0.14); }
.menu-note { padding: 6px 12px 8px; color: var(--muted); font-size: 0.78rem; }
/* Nothing to offer, no ⋯ button. */
.more-menu:not(:has(.menu-item:not([hidden]))) { display: none; }

/* Account menu (phones): keeps "Log ud" out of the thumb-zone nav. */
.account-menu { display: none; }
.account-menu .menu-list { top: calc(100% + 8px); bottom: auto; }
.account-menu > summary { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%; cursor: pointer; }
.account-menu .rail-user { display: grid; }

/* ---------- Multiview ---------- */
.matrix-dialog {
  width: 100vw; height: 100dvh; max-width: none; max-height: none; margin: 0;
  background: #000; overflow: hidden;
}
.matrix-dialog[open] { display: flex; flex-direction: column; }
.matrix-dialog::backdrop { background: #000; }
.matrix-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 4px 14px; min-height: 40px; background: var(--bg); border-bottom: 1px solid var(--line);
}
.matrix-head-left { display: flex; align-items: center; gap: 10px; min-width: 0; }
.matrix-head h2 { font-size: 0.95rem; font-weight: 800; letter-spacing: -0.01em; }
.matrix-hint { color: var(--muted); font-size: 0.76rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.matrix-head-actions { display: flex; gap: 6px; align-items: center; }
.matrix-head-actions .btn {
  min-height: 28px; padding: 0 10px; font-size: 0.78rem; border-radius: 6px; gap: 5px;
}
.matrix-head-actions .btn .icon { width: 14px; height: 14px; }
.matrix-head-actions .btn.icon { width: 28px; height: 28px; min-height: 28px; padding: 0; }
.matrix-grid { flex: 1; display: grid; gap: 4px; padding: 4px; background: #000; min-height: 0; }
.matrix-grid[data-count="1"] { grid-template-columns: 1fr; grid-template-rows: 1fr; }
.matrix-grid[data-count="2"] { grid-template-columns: 1fr 1fr; grid-template-rows: 1fr; }
.matrix-grid[data-count="3"] { grid-template-columns: 2fr 1fr; grid-template-rows: 1fr 1fr; }
.matrix-grid[data-count="3"] .matrix-cell:first-child { grid-row: span 2; }
.matrix-grid[data-count="4"] { grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr; }
.matrix-grid.has-solo { grid-template-columns: 1fr; grid-template-rows: 1fr; }
.matrix-grid.has-solo .matrix-cell:not(.solo) { display: none; }
.matrix-grid.has-solo .matrix-cell.solo { grid-column: 1 / -1; grid-row: 1 / -1; }
.matrix-cell {
  position: relative; min-width: 0; min-height: 0; overflow: hidden; border-radius: 8px;
  background: #07080b; cursor: pointer; outline: none;
}
.matrix-cell::after {
  content: ""; position: absolute; inset: 0; border-radius: 8px; pointer-events: none;
  box-shadow: inset 0 0 0 2px transparent; transition: box-shadow 200ms var(--ease);
}
.matrix-cell.focused::after { box-shadow: inset 0 0 0 3px var(--tally); }
.matrix-cell:focus-visible::after { box-shadow: inset 0 0 0 3px var(--text); }
.matrix-cell video { width: 100%; height: 100%; object-fit: contain; background: #000; display: block; }
.matrix-overlay {
  position: absolute; inset: 0 0 auto; z-index: 2;
  display: flex; align-items: flex-start; justify-content: space-between; gap: 10px;
  padding: 10px 12px 28px; pointer-events: none;
  background: linear-gradient(to bottom, rgb(0 0 0 / 0.78), transparent);
  opacity: 0.85; transition: opacity 200ms;
}
.matrix-cell:hover .matrix-overlay, .matrix-cell.focused .matrix-overlay { opacity: 1; }
.matrix-overlay-info { display: flex; gap: 10px; align-items: center; min-width: 0; }
.matrix-overlay-num {
  flex: none; padding: 3px 8px; border-radius: 6px; background: rgb(255 255 255 / 0.14);
  font-weight: 800; font-size: 0.78rem;
}
.matrix-cell.focused .matrix-overlay-num { background: var(--tally); color: var(--tally-ink); }
.matrix-overlay-text { display: grid; min-width: 0; }
.matrix-overlay-name { font-weight: 700; font-size: 0.88rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.matrix-overlay-title { color: var(--text-2); font-size: 0.78rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.matrix-cell-controls { display: flex; gap: 6px; align-items: center; pointer-events: auto; }
.matrix-cell-audio-btn {
  display: inline-flex; align-items: center; gap: 6px; min-height: 36px; min-width: 36px; padding: 0 10px;
  border: 0; border-radius: 8px; background: rgb(0 0 0 / 0.55); color: var(--text-2);
  font-size: 0.78rem; font-weight: 700; cursor: pointer; transition: background 160ms, color 160ms;
}
.matrix-cell-audio-btn .icon { width: 15px; height: 15px; }
.matrix-cell-audio-btn:hover { background: rgb(255 255 255 / 0.2); color: var(--text); }
.matrix-cell-audio-btn.active, .matrix-cell.has-audio .matrix-cell-audio-btn {
  color: var(--tally-ink); background: var(--tally);
}
.matrix-cell-audio-indicator {
  display: inline-flex; align-items: center; gap: 5px; padding: 4px 8px; border-radius: 6px;
  background: rgb(0 0 0 / 0.5); color: var(--muted); font-size: 0.74rem; font-weight: 700;
}
.matrix-cell-audio-indicator .icon { width: 14px; height: 14px; }
.matrix-cell.has-audio .matrix-cell-audio-indicator { color: var(--tally-ink); background: var(--tally); }
.matrix-cell-btn {
  display: inline-flex; align-items: center; gap: 6px; min-height: 36px; min-width: 36px; padding: 0 10px;
  border: 0; border-radius: 8px; background: rgb(0 0 0 / 0.55); color: var(--text);
  font-size: 0.78rem; font-weight: 700; cursor: pointer;
}
.matrix-cell-btn .icon { width: 16px; height: 16px; }
.matrix-cell-btn:hover, .matrix-cell-btn.active { background: rgb(255 255 255 / 0.2); }
.matrix-cell-btn-close { padding: 0; justify-content: center; }
.matrix-cell-slate {
  position: absolute; inset: 0; z-index: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px;
  padding: 16px; text-align: center; color: var(--text-2); font-size: 0.88rem; background: #07080b;
}
.spinner {
  width: 28px; height: 28px; border-radius: 50%;
  border: 3px solid rgb(255 255 255 / 0.15); border-top-color: var(--text);
  animation: spin 800ms linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.matrix-foot {
  display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  padding: 10px 14px 10px 20px; background: var(--bg);
}
.matrix-foot-info { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1 1 320px; }
.matrix-foot-title { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.matrix-foot-next { color: var(--muted); font-size: 0.82rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.matrix-foot-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.matrix-add-group { position: relative; }
.matrix-dropdown-menu {
  position: absolute; right: 0; bottom: calc(100% + 8px); z-index: 10; width: 300px; max-height: 360px; overflow: auto;
  padding: 6px; border-radius: 14px; background: var(--surface-2); box-shadow: var(--shadow-float);
}
.matrix-dropdown-head { padding: 8px 10px; color: var(--muted); font-size: 0.78rem; font-weight: 700; }
.matrix-dropdown-item {
  display: grid; grid-template-columns: 36px minmax(0, 1fr) auto; align-items: center; gap: 8px;
  width: 100%; min-height: 44px; padding: 0 10px; border: 0; border-radius: 10px;
  background: transparent; text-align: left; cursor: pointer;
}
.matrix-dropdown-item:hover:not(:disabled) { background: var(--surface-3); }
.matrix-dropdown-item:disabled { opacity: 0.45; cursor: default; }
.matrix-dropdown-item-num { font-weight: 800; color: var(--text-2); }
.matrix-dropdown-item-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.matrix-dropdown-item-status { color: var(--tally); font-size: 0.75rem; font-weight: 700; }

/* ---------- Admin (DRTV kanalbygger) ---------- */
.admin-search-box { display: grid; gap: 10px; margin-bottom: 24px; max-width: 760px; }
.admin-search-input-wrap { display: flex; gap: 10px; }
.search-lg { max-width: none; }
.search-lg input { min-height: 52px; }
.hint { color: var(--muted); font-size: 0.85rem; }
.admin-selection-bar {
  position: sticky; top: calc(var(--top) + 8px); z-index: 5;
  display: flex; align-items: center; flex-wrap: wrap; gap: 12px;
  margin-bottom: 20px; padding: 12px 14px; border-radius: var(--r);
  background: var(--surface-2); box-shadow: var(--shadow-float);
}
.admin-selection-text strong { color: var(--tally); }
.admin-selected-chips { display: flex; flex-wrap: wrap; gap: 6px; flex: 1; min-width: 0; }
.admin-selection-chip {
  display: inline-flex; align-items: center; gap: 6px; min-height: 32px; padding: 0 4px 0 12px;
  border-radius: 999px; background: var(--surface-3); font-size: 0.82rem; font-weight: 600;
}
.chip-remove {
  display: grid; place-items: center; width: 28px; height: 28px; border: 0; border-radius: 50%;
  background: transparent; color: var(--muted); cursor: pointer; font-size: 1.1rem; line-height: 1;
}
.chip-remove:hover { background: rgb(255 255 255 / 0.1); color: var(--text); }
.admin-selection-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.admin-card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 16px; }
.admin-item-card {
  display: grid; grid-template-rows: auto 1fr; border-radius: var(--r); overflow: hidden;
  background: var(--surface); transition: box-shadow 200ms var(--ease);
}
.admin-item-card.selected { box-shadow: inset 0 0 0 2px var(--tally); }
.admin-item-media { position: relative; aspect-ratio: 16 / 9; background: var(--surface-2); }
.admin-item-thumb-wrap { position: relative; aspect-ratio: 16 / 9; background: var(--surface-2); overflow: hidden; }
.admin-item-thumb { width: 100%; height: 100%; object-fit: cover; display: block; }
.admin-item-thumb.placeholder {
  display: grid; place-items: center; color: var(--muted); font-weight: 800; letter-spacing: 0.08em;
  background: linear-gradient(135deg, var(--surface-2), var(--surface-3));
  width: 100%; height: 100%;
}
.badge-source-stremio { background: rgba(147, 51, 234, 0.15); color: #c084fc; border-color: rgba(147, 51, 234, 0.3); }
.badge-source-drtv { background: rgba(239, 68, 68, 0.15); color: #f87171; border-color: rgba(239, 68, 68, 0.3); }
.badge-source-archive { background: rgba(59, 130, 246, 0.15); color: #60a5fa; border-color: rgba(59, 130, 246, 0.3); }
.admin-select-badge { position: absolute; top: 10px; right: 10px; }
.admin-item-media .admin-select-badge.ghost { --btn-bg: rgb(0 0 0 / 0.55); color: var(--text); }
.admin-item-body { display: grid; gap: 8px; padding: 14px 16px 16px; align-content: start; }
.admin-item-top { display: flex; align-items: center; gap: 8px; }
.admin-item-title { font-size: 1.05rem; font-weight: 750; letter-spacing: -0.01em; }
.admin-item-desc {
  color: var(--muted); font-size: 0.85rem;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.admin-item-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.admin-shows-summary, .admin-episodes-preview { display: grid; gap: 8px; }
.admin-shows-list, .admin-episodes-list {
  list-style: none; margin: 0; padding: 8px 12px; max-height: 200px; overflow: auto;
  border-radius: 12px; background: var(--bg-2); font-size: 0.85rem; color: var(--text-2);
}
.admin-shows-list li, .admin-episodes-list li { padding: 5px 0; }
.admin-shows-list li + li, .admin-episodes-list li + li { border-top: 1px solid var(--line); }
.add-show-row { display: flex; gap: 8px; margin-top: 8px; }
.add-show-row select { flex: 1; }

/* Stremio / Multi-source discovery modal styles */
.discover-source-tabs {
  display: flex; gap: 8px; margin-bottom: 12px; border-bottom: 1px solid var(--line); padding-bottom: 8px;
}
.discover-tab-btn {
  padding: 8px 16px; border-radius: 999px; background: transparent; border: 1px solid var(--line);
  color: var(--muted); font-size: 0.9rem; font-weight: 600; cursor: pointer; transition: all 160ms;
}
.discover-tab-btn:hover {
  color: var(--text); background: rgb(255 255 255 / 0.05); border-color: var(--line-2);
}
.discover-tab-btn.active {
  color: #fff; background: var(--surface-3); border-color: var(--accent, #e5a50a);
}

.stremio-search-wrap { position: relative; }
.stremio-suggest-dropdown {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0; z-index: 50;
  background: var(--surface-2); border: 1px solid var(--line-2); border-radius: 12px;
  box-shadow: 0 12px 32px rgb(0 0 0 / 0.5); max-height: 320px; overflow-y: auto;
  display: grid; padding: 6px;
}
.stremio-suggest-item {
  display: flex; align-items: center; gap: 12px; padding: 8px 12px;
  border-radius: 8px; cursor: pointer; color: var(--text); background: transparent;
  border: 0; text-align: left; width: 100%; transition: background-color 140ms;
}
.stremio-suggest-item:hover, .stremio-suggest-item:focus-visible, .stremio-suggest-item.is-selected {
  background: rgb(255 255 255 / 0.08); outline: none;
}
.stremio-suggest-thumb {
  width: 32px; height: 46px; border-radius: 4px; object-fit: cover; background: var(--surface-3); flex: none;
}
.stremio-suggest-thumb-ph {
  width: 32px; height: 46px; border-radius: 4px; background: var(--surface-3);
  display: grid; place-items: center; font-size: 0.65rem; color: var(--muted); flex: none;
}
.stremio-suggest-text { display: grid; gap: 2px; min-width: 0; flex: 1; }
.stremio-suggest-title { font-weight: 700; font-size: 0.92rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stremio-suggest-meta { font-size: 0.78rem; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.stremio-provision-panel { display: grid; gap: 16px; margin-top: 16px; }
.stremio-seasons-selection {
  display: grid; gap: 8px; max-height: 220px; overflow-y: auto; padding: 10px 14px;
  background: var(--bg-2); border-radius: 12px; border: 1px solid var(--line);
}
.stremio-seasons-actions {
  display: flex; gap: 8px; padding-bottom: 6px; border-bottom: 1px solid var(--line);
}
.stremio-season-row {
  display: flex; align-items: center; gap: 12px; padding: 6px 0; cursor: pointer;
  font-size: 0.9rem;
}
.stremio-season-row + .stremio-season-row { border-top: 1px solid var(--line); }
.stremio-season-row input[type="checkbox"] { width: 18px; height: 18px; cursor: pointer; }
.stremio-season-row .season-label { flex: 1; font-weight: 600; }
.badge-subtle.cached-tag { background: rgb(46 204 113 / 0.15); color: #2ecc71; border: 1px solid rgb(46 204 113 / 0.3); }
.badge-subtle.uncached-tag { background: rgb(241 196 15 / 0.15); color: #f1c40f; border: 1px solid rgb(241 196 15 / 0.3); }
.badge-subtle.in-catalog { background: rgb(52 152 219 / 0.15); color: #3498db; }
.stremio-channel-options { display: grid; gap: 12px; padding: 12px; background: var(--bg-2); border-radius: 12px; }
.check-label { display: flex; align-items: center; gap: 10px; cursor: pointer; font-size: 0.92rem; font-weight: 600; }
.check-label input[type="checkbox"] { width: 18px; height: 18px; cursor: pointer; }

/* ---------- Tablet & mobile ---------- */

/* ---------- Source links (DRTV, Bunkr, Pixeldrain, OneDrive, …) ---------- */
.source-link { gap: 6px; padding: 0 12px; font-size: 0.86rem; }
.source-link.icon { padding: 0; }
.source-link .link-label { white-space: nowrap; }
.slot-actions .source-link:not(.icon) { min-height: 40px; padding: 0 10px; }

/* On-demand marker for programs that already aired. */
.vod-tag {
  display: inline-flex; align-items: center; gap: 4px; height: 20px; padding: 0 7px; border-radius: 6px;
  background: rgb(255 210 63 / 0.14); color: var(--tally);
  font-size: 0.68rem; font-weight: 800; letter-spacing: 0.04em; text-transform: uppercase; white-space: nowrap;
}
.vod-tag .icon { width: 9px; height: 9px; }

/* Timeline cell = one full-size hit button under the text, plus optional source links. */
.tl-prog-hit {
  position: absolute; inset: 0; z-index: 0; width: 100%; height: 100%;
  border: 0; border-radius: inherit; background: transparent; cursor: pointer;
}
.tl-prog-hit:focus-visible { outline-offset: -2px; }
.tl-prog-text, .tl-prog .meter { z-index: 1; pointer-events: none; }
.tl-prog-time { display: flex; align-items: center; gap: 6px; }
.tl-prog-time .vod-tag { height: 18px; padding: 0 6px; font-size: 0.62rem; }
.tl-prog.is-past .tl-prog-time { color: var(--text-2); }
.tl-prog.is-past:hover .tl-prog-title { color: var(--text); }
.tl-prog-links {
  /* Bottom-right, beside the time line: the title row stays readable on hover. */
  position: absolute; right: 4px; bottom: 4px; z-index: 2;
  display: flex; gap: 4px; opacity: 0; transition: opacity 160ms;
}
.tl-prog:hover .tl-prog-links, .tl-prog:focus-within .tl-prog-links { opacity: 1; }
.tl-prog-links .btn.icon { width: 32px; min-height: 32px; height: 32px; border-radius: 8px; --btn-bg: var(--surface-2); box-shadow: 0 0 0 1px var(--line-2); }
.tl-prog-links .btn.icon .icon { width: 15px; height: 15px; }
/* 32 px visual, 40 px hit area (links sit 4 px apart, so areas never overlap). */
.tl-prog-links .btn.icon::after { content: ""; position: absolute; inset: -4px; }
.tl-prog-links .btn.icon { position: relative; }
@media (hover: none) { .tl-prog-links { opacity: 1; } }

/* Series cards: order badge + quick start. */
.cover-badge { display: inline-flex; align-items: center; gap: 5px; }
.cover-badge .icon { width: 12px; height: 12px; }
.cover-actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 108px), 1fr)); gap: 6px; }
.cover-actions .btn { min-height: 40px; padding: 0 8px; gap: 6px; font-size: 0.8rem; border-radius: 10px; }
.cover-actions .btn .icon { width: 15px; height: 15px; flex: none; }
.cover-actions .btn span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cover-actions .btn.is-running { --btn-bg: rgb(255 210 63 / 0.16); color: var(--tally); }

/* Chromecast picker with nothing to pick: explain instead of a dead select. */
.cast-control.is-empty .cast-target select { color: var(--muted); cursor: default; opacity: 1; }
.cast-help .menu-list {
  top: calc(100% + 10px); bottom: auto; right: -52px;
  width: min(340px, calc(100vw - 24px)); gap: 8px; padding: 14px 16px 16px;
  color: var(--text-2); font-size: 0.88rem; line-height: 1.45;
}
.cast-help .menu-list strong { color: var(--text); }
.cast-help .menu-list .btn { justify-self: start; margin-top: 4px; }
.cast-help > summary { color: var(--tally); }

/* Admin + channel editor selection chips. */
.admin-selection-chip .chip-title {
  max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  color: var(--text);
}

/* Multiview: muted reads as muted. */
#matrix-unmute-all.is-muted { color: var(--muted); }
.matrix-cell-audio-btn[aria-pressed="false"]:not(:hover) { color: var(--muted); }

@media (max-width: 1180px) {
  .row-main { grid-template-columns: minmax(130px, 170px) minmax(0, 1fr); }
  .row-next { display: none; }
  .matrix-hint { display: none; }
}

@media (max-width: 899px) {
  :root { --rail: 0px; --top: 64px; --nav: 64px; }
  .app-view { grid-template-columns: minmax(0, 1fr); grid-template-rows: var(--top) 1fr; }

  .rail {
    position: fixed; inset: auto 0 0 0; top: auto; height: auto; z-index: 25;
    flex-direction: row; justify-content: space-around; gap: 0;
    padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
    border-right: 0; border-top: 1px solid var(--line);
    background: rgb(11 12 16 / 0.92); backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
  }
  .rail-brand { display: none; }
  .rail-foot { display: none; }
  .account-menu { display: block; flex: none; }
  .rail-link { flex: 1; width: auto; min-width: 0; min-height: 52px; max-width: 96px; }
  .rail-link.active { background: transparent; }

  .topbar { padding: 0 16px; gap: 8px; padding-top: env(safe-area-inset-top); }
  .search { max-width: none; }
  .search input { min-height: 44px; }
  .cast-control { padding-left: 10px; margin-left: 0; flex: none; }
  .cast-control > svg.icon { display: none; }
  /* Phones: stop only while something is on the TV; refresh always reachable. */
  .cast-control:not(.is-casting) .btn.stop { display: none; }
  .cast-target select { max-width: 96px; padding: 0 4px; font-size: 0.85rem; }
  .cast-control.is-empty .cast-target { display: none; }
  .cast-help .menu-list { position: fixed; top: calc(var(--top) + env(safe-area-inset-top) + 4px); left: 12px; right: 12px; width: auto; }
  .source-link .link-label { display: none; }
  .slot { grid-template-columns: 48px minmax(0, 1fr); row-gap: 6px; }
  .slot-actions { grid-column: 2; justify-content: flex-start; margin-left: -10px; }
  .slot-actions .btn.icon:last-child { margin-left: auto; }
  .source-link:not(.icon) { width: 44px; padding: 0; }
  .slot-actions .source-link .link-label { display: inline; }
  .slot-actions .source-link:not(.icon) { width: auto; padding: 0 10px; }
  .clock { display: none; }

  .page { padding: 20px 16px calc(var(--nav) + 96px + env(safe-area-inset-bottom)); }
  .pills { margin-inline: -16px; padding-inline: 16px; }

  .stage { grid-template-columns: minmax(0, 1fr); gap: 18px; margin: 0 -16px 20px; padding: 0 16px 20px; }
  .stage-screen { border-radius: var(--r); }
  .stage-title { font-size: 1.6rem; }
  .stage-desc { display: none; }
  .stage.no-preview .stage-screen { display: none; }
  .stage.no-preview { padding-top: 4px; }
  #stage-preview-toggle { margin-left: 0; }

  .row-select { width: 44px; }
  .row-main { grid-template-columns: minmax(0, 1fr); gap: 8px; min-height: 72px; padding: 12px 4px 12px 0; }
  .row-select[hidden] + .row-main { padding-left: 14px; }
  .row-channel { gap: 8px; }
  .row-num { font-size: 1.05rem; min-width: 0; text-align: left; }
  .row-name { font-size: 0.82rem; }
  .row-title { font-size: 0.95rem; }
  .row-actions { padding-right: 4px; }
  .row-actions .action-watch, .row-actions .action-edit-channel { display: none; }
  .tally-badge { top: auto; bottom: 100%; }

  .dock { bottom: calc(var(--nav) + 12px + env(safe-area-inset-bottom)); max-width: calc(100vw - 24px); padding-left: 14px; }
  .dock .btn span { white-space: nowrap; }
  .dock #cast-selected > span { display: none; }
  .dock #cast-selected { width: 44px; padding: 0; }
  .toast { left: 12px; right: 12px; max-width: none; bottom: calc(var(--nav) + 12px + env(safe-area-inset-bottom)); }
  body.has-dock .toast { bottom: calc(var(--nav) + 80px + env(safe-area-inset-bottom)); }

  .view-head-row { align-items: flex-start; }
  .tl-scroll { --min: 4.5px; --chcol: 120px; max-height: calc(100dvh - var(--top) - var(--nav) - 230px); margin-inline: -16px; padding-inline: 16px; }
  .tl-row { grid-template-rows: 64px; }
  .tl-channel-btn { padding: 0 8px; gap: 8px; }
  .tl-channel .channel-bug { min-width: 32px; height: 32px; font-size: 0.9rem; }
  .tl-channel-name { font-size: 0.78rem; white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }

  .cover-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 24px 12px; }
  .series-hero { grid-template-columns: 112px minmax(0, 1fr); gap: 18px; align-items: center; }
  .series-hero .cover { width: 112px; padding: 10px; }
  .series-hero .cover-title { font-size: 1rem; }
  .series-hero-actions { grid-column: 1 / -1; }
  .episode { grid-template-columns: 36px minmax(0, 1fr) 44px; }
  .ep-num { font-size: 1.1rem; }
  .ep-dur { display: none; }

  /* Bottom sheets on phones (player included) */
  .sheet, .theater {
    width: 100vw; max-width: none; margin: auto 0 0; border-radius: var(--r-lg) var(--r-lg) 0 0;
    max-height: 92dvh;
  }
  /* fit-content: a fixed-position dialog with height:auto stretches to max-height. */
  .theater { height: fit-content; background: var(--bg); }
  .theater::backdrop { background: rgb(4 5 8 / 0.8); }
  .theater[open] { grid-template-rows: auto auto auto; }
  .screen { aspect-ratio: 16 / 9; }
  .theater-head { padding: 14px 14px 12px 16px; background: var(--bg); }
  .theater-head #player-cast span { display: none; }
  .theater-head #player-cast { width: 44px; padding: 0; }
  .theater-foot {
    grid-template-columns: minmax(0, 1fr) auto; gap: 12px;
    padding: 12px 12px calc(16px + env(safe-area-inset-bottom)); background: var(--bg);
  }
  .transport { grid-column: 1 / -1; justify-content: space-between; }
  .transport .btn { flex: 1; padding: 0 6px; font-size: 0.82rem; gap: 4px; }
  .up-next { justify-self: start; text-align: left; }
  dialog[open].sheet, dialog[open].theater { animation: sheetUp 320ms var(--ease); }
  @keyframes sheetUp { from { transform: translateY(40px); opacity: 0; } }
  .sheet-foot { padding-bottom: calc(16px + env(safe-area-inset-bottom)); }
  .field-row { grid-template-columns: 1fr; }

  .matrix-grid[data-count="2"], .matrix-grid[data-count="3"], .matrix-grid[data-count="4"] {
    grid-template-columns: 1fr; grid-template-rows: none; grid-auto-rows: auto; overflow-y: auto;
  }
  .matrix-grid[data-count="3"] .matrix-cell:first-child { grid-row: auto; }
  .matrix-grid:not(.has-solo) .matrix-cell { aspect-ratio: 16 / 9; }
  .matrix-head { padding: 4px 10px; gap: 8px; }
  .matrix-head-actions .btn span { display: none; }
  .matrix-head-actions .btn,
  .matrix-head-actions .btn.icon { width: 44px; height: 44px; min-height: 44px; padding: 0; border-radius: 10px; }
  .matrix-head-actions .btn .icon { width: 20px; height: 20px; }
  .matrix-cell-audio-btn, .matrix-cell-btn { min-height: 44px; min-width: 44px; }
  .admin-search-input-wrap { flex-direction: column; }
  .series-toolbar { flex-direction: column; align-items: stretch; gap: 12px; }
  .series-search-wrap { max-width: none; }
}

/* ---------- User Favorites & Continue Watching ---------- */
.action-fav { color: var(--muted); }
.action-fav:hover { color: var(--accent, #e5a50a); }
.action-fav.is-fav, .btn.is-fav { color: #e5a50a !important; }
.action-fav.is-fav svg, .btn.is-fav svg { fill: currentColor; }

.cover-fav-btn {
  position: absolute; top: 10px; right: 10px; z-index: 2;
  width: 36px; height: 36px; border-radius: 50%;
  border: 0; background: rgb(0 0 0 / 0.55); backdrop-filter: blur(8px);
  color: var(--muted); cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: transform 160ms, color 160ms, background-color 160ms;
}
.cover-fav-btn:hover { color: #fff; transform: scale(1.1); background: rgb(0 0 0 / 0.75); }
.cover-fav-btn.is-fav { color: #e5a50a; }
.cover-fav-btn.is-fav svg { fill: currentColor; }

.cover-progress {
  position: absolute; bottom: 0; left: 0; right: 0; height: 4px; z-index: 2;
  background: rgb(255 255 255 / 0.2); border-radius: 0;
}
.cover-progress::-webkit-progress-bar { background: transparent; }
.cover-progress::-webkit-progress-value { background: var(--accent, #e5a50a); }
.cover-progress::-moz-progress-bar { background: var(--accent, #e5a50a); }

.continue-watching-section { margin-bottom: 32px; }
.section-title { font-size: 1.25rem; font-weight: 700; margin: 0 0 16px; color: var(--text); }
.continue-watching-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}
.continue-card {
  position: relative; display: grid; grid-template-columns: 110px minmax(0, 1fr);
  gap: 14px; padding: 12px; border-radius: var(--r);
  background: var(--surface); border: 1px solid var(--line);
  transition: background-color 160ms, border-color 160ms;
}
.continue-card:hover { background: var(--surface-2, rgb(255 255 255 / 0.07)); border-color: rgb(255 255 255 / 0.15); }
.continue-thumb {
  position: relative; aspect-ratio: 16 / 10; border-radius: 8px; overflow: hidden;
  background: var(--card-bg, #1a1c23); display: flex; align-items: flex-end; padding: 8px;
}
.continue-thumb .cover-title { font-size: 0.75rem; font-weight: 700; color: #fff; line-height: 1.2; }
.continue-thumb-progress {
  position: absolute; bottom: 0; left: 0; right: 0; height: 4px; z-index: 2;
  background: rgb(255 255 255 / 0.2); border-radius: 0;
}
.continue-thumb-progress::-webkit-progress-bar { background: transparent; }
.continue-thumb-progress::-webkit-progress-value { background: var(--accent, #e5a50a); }
.continue-thumb-progress::-moz-progress-bar { background: var(--accent, #e5a50a); }
.continue-info { display: flex; flex-direction: column; justify-content: center; min-width: 0; gap: 4px; }
.continue-series { font-weight: 700; font-size: 0.95rem; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.continue-ep { font-size: 0.82rem; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.continue-meta { font-size: 0.75rem; color: var(--muted); margin-top: 2px; }
.continue-actions { display: flex; align-items: center; gap: 8px; margin-top: 6px; }
.continue-play { font-size: 0.8rem; padding: 4px 12px; height: 30px; }
.continue-dismiss {
  width: 28px; height: 28px; padding: 0; border: 0; background: transparent;
  color: var(--muted); border-radius: 50%; cursor: pointer; display: flex; align-items: center; justify-content: center;
}
.continue-dismiss:hover { color: var(--text); background: rgb(255 255 255 / 0.1); }

.episode.is-completed .ep-num { color: #22c55e; }
.ep-progress-bar {
  grid-column: 2 / -1; height: 3px; border-radius: 2px;
  background: rgb(255 255 255 / 0.1); width: 100%; margin-top: 4px;
}
.ep-progress-bar::-webkit-progress-bar { background: transparent; }
.ep-progress-bar::-webkit-progress-value { background: var(--accent, #e5a50a); }
.ep-progress-bar::-moz-progress-bar { background: var(--accent, #e5a50a); }

@media (max-width: 380px) {
  .row-select { width: 40px; }
  .cast-target select { max-width: 84px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; animation-iteration-count: 1 !important; transition-duration: 1ms !important; }
}

/* ==========================================================================
   USER-SPECIFIC CUSTOM STYLES & THEME ENGINE
   ========================================================================== */

/* Anna's Universe: Pink Brushed Aluminum & Y2K Candy Aqua
   Matched to https://anna.46.225.14.12.sslip.io/
   Palette:
     --bg: #1c0a18 (Deep plum metal canvas for video comfort)
     --bg-2: #240d1f
     --surface: #2d1027
     --surface-2: #3a1632
     --surface-3: #4e1d43
     --line: rgba(255, 133, 192, 0.22)
     --line-2: rgba(255, 133, 192, 0.38)
     --text: #fff5fa
     --text-2: #ffd6eb
     --muted: #d498ba
     --tally: #ff227d (Candy pink & ruby gel)
     --tally-ink: #ffffff
     --live: #ff1a75
     --live-fill: #e00b65
     --mint-aqua: #34ebb6 (High-contrast cyan/mint accent)
     --focus-ring: #ff227d
*/
html[data-theme="anna-pink-metal"],
body[data-theme="anna-pink-metal"],
html[data-user="anna"],
body[data-user="anna"] {
  --bg: #1b0a17;
  --bg-2: #230d1f;
  --surface: #2c1127;
  --surface-2: #391733;
  --surface-3: #4c1f44;
  --line: rgba(255, 153, 204, 0.22);
  --line-2: rgba(255, 153, 204, 0.38);
  --text: #fff2f8;
  --text-2: #ffd3ea;
  --muted: #cf96b6;
  --tally: #ff2a85;
  --tally-ink: #ffffff;
  --live: #ff1a75;
  --live-fill: #e00b65;
  --danger: #ff4d6d;
  --ok: #34ebb6;
  --accent: #ff2a85;
  --accent-ink: #ffffff;

  color-scheme: dark;
  accent-color: #ff2a85;
}

[data-theme="anna-pink-metal"] ::selection,
[data-user="anna"] ::selection {
  background: #ff5da6;
  color: #ffffff;
}

[data-theme="anna-pink-metal"] ::-webkit-scrollbar-track,
[data-user="anna"] ::-webkit-scrollbar-track {
  background: #230d1f;
}

[data-theme="anna-pink-metal"] ::-webkit-scrollbar-thumb,
[data-user="anna"] ::-webkit-scrollbar-thumb {
  background: linear-gradient(to bottom, #7d335c, #ba568c);
  border: 2px solid #1b0a17;
}

[data-theme="anna-pink-metal"] :focus-visible,
[data-user="anna"] :focus-visible {
  outline: 2px solid #ff227d;
  outline-offset: 2px;
}

/* Tactile Pink Gel Buttons & Badges for Anna's Theme */
[data-theme="anna-pink-metal"] .btn.primary,
[data-user="anna"] .btn.primary {
  --btn-bg: linear-gradient(180deg, #ff82b8 0%, #f72585 50%, #c70b5f 100%);
  color: #ffffff;
  text-shadow: 0 -1px 0 rgba(70, 0, 30, 0.6);
  border: 1px solid #940a44;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.65), 0 2px 6px rgba(180, 20, 80, 0.35);
}

[data-theme="anna-pink-metal"] .btn.primary:hover,
[data-user="anna"] .btn.primary:hover {
  --btn-bg: linear-gradient(180deg, #ffa3cb 0%, #ff3b94 50%, #d8146e 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8), 0 3px 10px rgba(255, 34, 125, 0.5);
}

[data-theme="anna-pink-metal"] .btn.active,
[data-user="anna"] .btn.active {
  --btn-bg: rgba(255, 42, 133, 0.22);
  color: #ff69b4;
  border-color: rgba(255, 42, 133, 0.45);
}

/* Stremio rail active states & tabs */
[data-theme="anna-pink-metal"] .tab-btn.active,
[data-user="anna"] .tab-btn.active {
  color: #ff85c0;
  border-color: #ff2a85;
}

[data-theme="anna-pink-metal"] .season-chip.active,
[data-user="anna"] .season-chip.active {
  background: linear-gradient(180deg, #ff82b8 0%, #f72585 50%, #c70b5f 100%);
  color: #ffffff;
  border-color: #ff2a85;
  box-shadow: 0 0 10px rgba(247, 37, 133, 0.5);
}

/* User avatar initial badge */
[data-theme="anna-pink-metal"] .user-btn,
[data-user="anna"] .user-btn {
  background: linear-gradient(180deg, #ff82b8 0%, #e00b65 100%);
  color: #ffffff;
  box-shadow: 0 0 10px rgba(255, 42, 133, 0.4);
}

/* Favorites heart badge styling in Anna's theme */
[data-theme="anna-pink-metal"] .cover-fav-btn.is-fav,
[data-user="anna"] .cover-fav-btn.is-fav {
  color: #ff2a85;
}

[data-theme="anna-pink-metal"] .cover-progress::-webkit-progress-value,
[data-user="anna"] .cover-progress::-webkit-progress-value {
  background: #ff2a85;
}

[data-theme="anna-pink-metal"] .cover-progress::-moz-progress-bar,
[data-user="anna"] .cover-progress::-moz-progress-bar {
  background: #ff2a85;
}

/* Aqua / Mint high-contrast accent for completion & time */
[data-theme="anna-pink-metal"] .episode.is-completed .ep-num,
[data-user="anna"] .episode.is-completed .ep-num {
  color: #34ebb6;
}

[data-theme="anna-pink-metal"] .live-badge,
[data-user="anna"] .live-badge {
  background: linear-gradient(180deg, #ff4d8d 0%, #e00b65 100%);
  color: #ffffff;
  box-shadow: 0 0 8px rgba(224, 11, 101, 0.6);
}

/* ---------- Tekst-TV (Teletext) ---------- */
.teletext-dialog {
  max-width: 540px;
  width: 95vw;
  max-height: 94vh;
  margin: auto;
  border-radius: 16px;
  background: #090a0f;
  border: 1px solid var(--line);
  color: #fff;
  overflow: hidden;
}
.teletext-dialog[open] {
  display: flex;
  flex-direction: column;
}
.teletext-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  background: #10121a;
  border-bottom: 1px solid var(--line);
}
.teletext-head-left {
  display: flex;
  align-items: center;
  gap: 12px;
}
.teletext-ch-tabs {
  display: flex;
  gap: 4px;
  background: #181b24;
  padding: 3px;
  border-radius: 8px;
}
.ttv-tab {
  min-height: 32px;
  padding: 0 12px;
  font-size: 0.8rem;
  font-weight: 700;
  border-radius: 6px;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: all 150ms ease;
}
.ttv-tab:hover {
  color: #fff;
}
.ttv-tab.active {
  background: var(--tally, #00e640);
  color: #000;
}
.teletext-page-display {
  display: flex;
  align-items: baseline;
  gap: 6px;
  font-family: 'Courier New', monospace;
  font-weight: 800;
  font-size: 1.1rem;
}
.teletext-prompt {
  font-size: 0.75rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.teletext-num {
  color: #ffff00;
  letter-spacing: 0.08em;
  font-size: 1.25rem;
}
.teletext-num.dialing {
  color: #ff2a2a;
  animation: blink 600ms infinite;
}
@keyframes blink {
  50% { opacity: 0.3; }
}
.teletext-sub-badge {
  font-size: 0.75rem;
  background: #252836;
  color: #00e640;
  padding: 2px 6px;
  border-radius: 4px;
}
.teletext-head-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
.teletext-body {
  padding: 12px 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow-y: auto;
  flex: 1;
}
.teletext-screen {
  background: #000;
  border: 2px solid #1a1d26;
  border-radius: 8px;
  min-height: 380px;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  box-shadow: inset 0 0 16px rgba(0, 0, 0, 0.8);
  outline: none;
}
.teletext-screen:focus-visible {
  border-color: #00e640;
  box-shadow: 0 0 0 2px #00e640;
}
.teletext-loading {
  position: absolute;
  top: 8px;
  right: 12px;
  background: rgba(0, 0, 0, 0.85);
  padding: 4px 10px;
  border-radius: 4px;
  border: 1px solid #ffff00;
  color: #ffff00;
  font-family: 'Courier New', monospace;
  font-size: 0.8rem;
  font-weight: 700;
  animation: blink 700ms infinite;
  z-index: 5;
}
.teletext-img-wrap {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
}
.teletext-img {
  max-width: 100%;
  max-height: 440px;
  width: auto;
  height: auto;
  object-fit: contain;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}
.teletext-text-wrap {
  width: 100%;
  overflow-x: auto;
  background: #000;
}
.teletext-pre {
  margin: 0;
  padding: 12px;
  font-family: 'Courier New', 'Lucida Console', monospace;
  font-size: clamp(0.7rem, 2vw, 0.92rem);
  line-height: 1.25;
  color: #ffffff;
  white-space: pre;
  user-select: text;
}
.ttv-link {
  color: #00ffff;
  background: transparent;
  border: none;
  font: inherit;
  cursor: pointer;
  padding: 0 1px;
  text-decoration: underline;
}
.ttv-link:hover, .ttv-link:focus-visible {
  color: #ffff00;
  background: #252836;
  outline: none;
}
.teletext-fastext {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}
.ttv-color-btn {
  min-height: 44px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #141721;
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  transition: transform 100ms ease, background 150ms ease;
}
.ttv-color-btn:hover {
  background: #1d2130;
}
.ttv-color-btn:active {
  transform: scale(0.97);
}
.ttv-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.ttv-dot.red { background: #ff2a2a; box-shadow: 0 0 6px #ff2a2a; }
.ttv-dot.green { background: #00e640; box-shadow: 0 0 6px #00e640; }
.ttv-dot.yellow { background: #ffd600; box-shadow: 0 0 6px #ffd600; }
.ttv-dot.blue { background: #00a8ff; box-shadow: 0 0 6px #00a8ff; }

.teletext-keypad {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.ttv-nav-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}
.ttv-nav-row .btn {
  min-height: 44px;
  font-size: 0.75rem;
  font-weight: 700;
  border-radius: 8px;
}
.ttv-numpad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}
.ttv-num-btn {
  min-height: 44px;
  min-width: 44px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #181b26;
  color: #fff;
  font-size: 1.05rem;
  font-weight: 800;
  cursor: pointer;
  transition: all 120ms ease;
  display: flex;
  align-items: center;
  justify-content: center;
}
.ttv-num-btn:hover {
  background: #232738;
}
.ttv-num-btn:active {
  transform: scale(0.96);
  background: #2d3348;
}
.ttv-num-btn.ttv-clear {
  color: #ff6b6b;
}
.ttv-num-btn.ttv-home {
  color: #00e640;
}

@media (max-width: 600px) {
  .teletext-dialog {
    width: 100vw;
    height: 100dvh;
    max-width: none;
    max-height: none;
    border-radius: 0;
  }
  .teletext-screen {
    min-height: 300px;
  }
  .ttv-color-btn {
    font-size: 0.65rem;
    padding: 0 4px;
  }
}


