/* ============ OPTtv — dark cinematic theme ============ */

:root {
  color-scheme: dark;
  /* Optimistic Media brand sherbet palette on a deep pine-green base */
  --bg: #0e1b14;
  --bg-raised: #16281e;
  --bg-card: #1b3024;
  --border: #2e4a38;
  --text: #f1f7f3;
  --text-muted: #a2bcab;
  --accent: #ffd96b;   /* brand lemon */
  --accent-strong: #ffe38c;
  --mint: #9fe7b8;     /* brand mint */
  --sky: #8fd3f4;      /* brand sky */
  --pink: #ff9aa2;     /* brand pink */
  --danger: #ff8a8a;
  --shadow: 0 18px 40px rgba(0, 0, 0, 0.55);
  --radius: 12px;
  --topbar-h: 64px;
  /* Horizontal page inset. Bumped on TV for overscan-safe margins. */
  --edge: clamp(1rem, 4vw, 2.5rem);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  line-height: 1.5;
  display: flex;
  flex-direction: column;
}

img { max-width: 100%; display: block; }

a { color: inherit; }

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

.skip-link {
  position: absolute;
  left: 1rem; top: -3rem;
  z-index: 100;
  padding: 0.5rem 1rem;
  background: var(--accent);
  color: #1c1608;
  border-radius: 8px;
  font-weight: 600;
  text-decoration: none;
  transition: top 0.15s ease;
}
.skip-link:focus { top: 0.75rem; }

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

/* Fallback for TV browsers / older engines that don't support :focus-visible.
   D-pad navigation relies entirely on a visible focus ring. */
@supports not selector(:focus-visible) {
  a:focus, button:focus, input:focus, select:focus, textarea:focus,
  [tabindex]:focus, video:focus {
    outline: 3px solid var(--accent);
    outline-offset: 2px;
  }
}

/* Solid top bar when backdrop blur isn't available (common on TV browsers),
   so nav content never bleeds through. */
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .topbar { background: #0c1711; }
}

/* ============ Top bar ============ */

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 1rem;
  height: var(--topbar-h);
  padding: 0 var(--edge);
  background: rgba(14, 27, 20, 0.82);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid rgba(46, 74, 56, 0.6);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  text-decoration: none;
  flex-shrink: 0;
}
.brand-mark { width: 30px; height: 30px; color: var(--text); }
.brand-name {
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: 0.06em;
}
.brand-tv { color: var(--accent); }

.search {
  position: relative;
  flex: 1;
  max-width: 26rem;
  margin-left: auto;
}
.search-icon {
  position: absolute;
  left: 0.7rem; top: 50%;
  translate: 0 -50%;
  width: 17px; height: 17px;
  color: var(--text-muted);
  pointer-events: none;
}
.search input {
  width: 100%;
  padding: 0.5rem 0.9rem 0.5rem 2.3rem;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text);
  font: inherit;
  font-size: 0.92rem;
}
.search input::placeholder { color: var(--text-muted); }
.search input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(255, 217, 107, 0.18);
}

.auth-area { display: flex; align-items: center; gap: 0.6rem; flex-shrink: 0; }

.user-chip {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  max-width: 16rem;
}
.user-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #9fe7b8, #8fd3f4);
  color: var(--text);
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  flex-shrink: 0;
}
.user-name {
  color: var(--text-muted);
  font-size: 0.9rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ============ Buttons ============ */

.btn {
  font: inherit;
  font-weight: 600;
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 0.5rem 1.2rem;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
}
.btn:active { transform: scale(0.97); }

.btn-primary {
  background: var(--accent);
  color: #1c1608;
}
.btn-primary:hover { background: var(--accent-strong); }

.btn-ghost {
  background: transparent;
  color: var(--text);
  border-color: var(--border);
}
.btn-ghost:hover { border-color: var(--text-muted); background: var(--bg-raised); }

.btn-lg { padding: 0.7rem 1.7rem; font-size: 1.02rem; }

.link-btn {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  color: var(--accent);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.link-btn:hover { color: var(--accent-strong); }

.icon-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  padding: 0.25rem 0.5rem;
  border-radius: 8px;
}
.icon-btn:hover { color: var(--text); background: var(--bg-raised); }

/* ============ Main layout ============ */

main {
  flex: 1;
  width: 100%;
  outline: none;
}

.page-loading,
.empty-note {
  padding: 4rem 1.5rem;
  text-align: center;
  color: var(--text-muted);
}

/* ============ Hero ============ */

.hero {
  position: relative;
  min-height: clamp(340px, 56vw, 560px);
  display: flex;
  align-items: flex-end;
  overflow: hidden;
  isolation: isolate;
}
.hero-backdrop {
  position: absolute;
  inset: 0;
  z-index: -1;
  background-size: cover;
  background-position: center 22%;
  filter: saturate(1.05);
}
.hero-backdrop::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(to top, var(--bg) 4%, rgba(14, 27, 20, 0.55) 45%, rgba(14, 27, 20, 0.25) 100%),
    linear-gradient(to right, rgba(14, 27, 20, 0.85) 0%, rgba(14, 27, 20, 0.1) 60%);
}
.hero-content {
  padding: clamp(1.25rem, 4vw, 3rem);
  padding-top: 6rem;
  max-width: 40rem;
}
.hero-eyebrow {
  color: var(--accent);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  margin: 0 0 0.5rem;
}
.hero-title {
  margin: 0 0 0.6rem;
  font-size: clamp(1.9rem, 5vw, 3.2rem);
  line-height: 1.1;
  letter-spacing: 0.01em;
  text-shadow: 0 2px 18px rgba(0, 0, 0, 0.6);
}
.hero-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  color: var(--text-muted);
  font-size: 0.9rem;
  margin: 0 0 0.75rem;
}
.hero-desc {
  color: var(--text);
  opacity: 0.92;
  margin: 0 0 1.4rem;
  max-width: 34rem;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.hero-actions { display: flex; gap: 0.8rem; flex-wrap: wrap; }

/* ============ Channel bar ============ */

.channel-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 0.9rem var(--edge) 0.2rem;
}
.channel-pill {
  --channel-color: var(--text-muted);
  padding: 0.32rem 1rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 600;
  transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}
.channel-pill:hover { color: var(--text); border-color: var(--channel-color); }
.channel-pill.active {
  color: #12100b;
  background: var(--channel-color);
  border-color: var(--channel-color);
}

.channel-empty {
  padding: 4rem var(--edge);
  text-align: center;
  display: grid;
  gap: 0.6rem;
  justify-items: center;
}
.channel-empty h1 { margin: 0; color: var(--channel-color, var(--accent)); }
.channel-empty p { margin: 0; color: var(--text-muted); }

/* ============ Rows ============ */

.rows { padding: 1.5rem 0 3rem; display: grid; gap: 2.2rem; }

.row { min-width: 0; }
.row-head {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  padding: 0 var(--edge);
  margin-bottom: 0.8rem;
}
.row-title {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.row-count { color: var(--text-muted); font-size: 0.85rem; }

.row-wrap { position: relative; }

.row-arrow {
  position: absolute;
  top: 50%;
  translate: 0 -70%;
  z-index: 5;
  width: 40px; height: 64px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: rgba(14, 27, 20, 0.85);
  color: var(--text);
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s ease, border-color 0.15s ease;
}
.row-arrow-prev { left: 0.4rem; }
.row-arrow-next { right: 0.4rem; }
.row-wrap:hover .row-arrow,
.row-wrap:focus-within .row-arrow,
.row-arrow:focus { opacity: 1; }
.row-arrow:hover { border-color: var(--accent); }
@media (hover: none) { .row-arrow { display: none; } }

.row-scroller {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: clamp(150px, 24vw, 250px);
  gap: 0.9rem;
  overflow-x: auto;
  padding: 0.25rem var(--edge) 0.75rem;
  scroll-snap-type: x proximity;
  /* Snap targets align to the edge inset, so the first card isn't scrolled
     under the (overscan-safe) left padding on load. */
  scroll-padding-inline: var(--edge);
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
.row-scroller::-webkit-scrollbar { height: 8px; }
.row-scroller::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

/* ============ Cards ============ */

.card {
  scroll-snap-align: start;
  text-decoration: none;
  display: block;
  border-radius: var(--radius);
  outline-offset: 3px;
}

.card-poster {
  position: relative;
  aspect-ratio: 16 / 9;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg-card);
  border: 1px solid var(--border);
  transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}
.card:hover .card-poster,
.card:focus .card-poster {
  transform: translateY(-4px) scale(1.03);
  border-color: rgba(255, 217, 107, 0.55);
  box-shadow: var(--shadow);
}
/* D-pad focus on a card gets a bold ring so it's obvious from across the room. */
.card:focus .card-poster { border-color: var(--accent); outline: 3px solid var(--accent); outline-offset: 2px; }
.card:focus { outline: none; }

.card-poster img {
  width: 100%; height: 100%;
  object-fit: cover;
}

.poster-fallback {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 0.75rem;
  text-align: center;
  font-weight: 700;
  font-size: 0.95rem;
  letter-spacing: 0.03em;
  color: rgba(230, 233, 239, 0.9);
}

.card-play {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(5, 7, 11, 0.45);
  opacity: 0;
  transition: opacity 0.18s ease;
}
.card:hover .card-play,
.card:focus .card-play { opacity: 1; }
.card-play span {
  width: 52px; height: 52px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: rgba(255, 217, 107, 0.95);
  color: #1c1608;
}
.card-play svg { width: 20px; height: 20px; margin-left: 3px; }

.card-progress {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 4px;
  background: rgba(255, 255, 255, 0.18);
}
.card-progress > span {
  display: block;
  height: 100%;
  background: var(--accent);
}

.card-label {
  margin: 0.55rem 0.15rem 0;
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.card-sub {
  margin: 0.1rem 0.15rem 0;
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* ============ Search results grid ============ */

.results-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 1rem;
  padding: 1.5rem var(--edge) 3rem;
}
.results-head {
  padding: 2rem var(--edge) 0;
  margin: 0;
  font-size: 1.3rem;
}

/* ============ Watch page ============ */

.watch { padding-bottom: 3rem; }

.player-shell {
  background: #000;
  display: grid;
  place-items: center;
}
.player-shell video {
  width: 100%;
  aspect-ratio: 16 / 9;
  max-height: min(74vh, 760px);
  background: #000;
  outline: none;
}

.watch-info {
  padding: 1.5rem var(--edge) 0.5rem;
  max-width: 56rem;
}
.watch-back {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.9rem;
  margin-bottom: 0.8rem;
}
.watch-back:hover { color: var(--text); }
.watch-title { margin: 0 0 0.4rem; font-size: clamp(1.5rem, 3.5vw, 2.2rem); line-height: 1.15; }
.watch-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  color: var(--text-muted);
  font-size: 0.9rem;
  margin: 0 0 1rem;
}
.watch-meta .genre-tag {
  color: var(--sky);
  border: 1px solid rgba(143, 211, 244, 0.45);
  border-radius: 999px;
  padding: 0.05rem 0.7rem;
  font-size: 0.8rem;
  text-transform: capitalize;
}
.watch-meta .channel-tag {
  --channel-color: var(--mint);
  color: var(--channel-color);
  border: 1px solid var(--channel-color);
  border-radius: 999px;
  padding: 0.05rem 0.7rem;
  font-size: 0.8rem;
  text-decoration: none;
}
.watch-desc { color: var(--text); opacity: 0.9; margin: 0; max-width: 46rem; }
.watch-resume {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin: 0.75rem 0 0;
}
.watch-attribution {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem;
  margin: 1.1rem 0 0;
  padding: 0.6rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-raised);
  color: var(--text-muted);
  font-size: 0.85rem;
  max-width: 46rem;
}
.watch-attribution a { color: var(--mint); text-decoration: none; }
.watch-attribution a:hover { text-decoration: underline; }
.license-badge {
  display: inline-block;
  padding: 0.05rem 0.55rem;
  border-radius: 999px;
  border: 1px solid rgba(159, 231, 184, 0.5);
  color: var(--mint);
  font-size: 0.78rem;
  font-weight: 600;
  white-space: nowrap;
}

.watch .rows { padding-top: 2.2rem; }

/* ============ Auth modal ============ */

.auth-modal {
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--bg-raised);
  color: var(--text);
  padding: 0;
  width: min(92vw, 24rem);
  box-shadow: var(--shadow);
}
.auth-modal::backdrop {
  background: rgba(5, 7, 11, 0.7);
  backdrop-filter: blur(3px);
}

.auth-form { padding: 1.5rem 1.5rem 1.75rem; display: grid; gap: 0.9rem; }
.auth-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.auth-head h2 { margin: 0; font-size: 1.25rem; }
.auth-sub { margin: -0.4rem 0 0; color: var(--text-muted); font-size: 0.9rem; }

.field { display: grid; gap: 0.35rem; }
.field span { font-size: 0.85rem; color: var(--text-muted); font-weight: 600; }
.field input {
  font: inherit;
  padding: 0.6rem 0.8rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
}
.field input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(255, 217, 107, 0.18);
}

.auth-error { margin: 0; color: var(--danger); font-size: 0.88rem; }
.auth-notice { margin: 0; color: var(--accent); font-size: 0.88rem; }
.auth-submit { width: 100%; }
.auth-switch {
  margin: 0.2rem 0 0;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* ============ Skeleton loading ============ */

@keyframes shimmer {
  0% { background-position: -400px 0; }
  100% { background-position: 400px 0; }
}
.skeleton { padding-bottom: 2rem; }
.skeleton-hero,
.skeleton-poster,
.skeleton-line {
  background: linear-gradient(90deg, var(--bg-raised) 25%, var(--bg-card) 50%, var(--bg-raised) 75%);
  background-size: 800px 100%;
  animation: shimmer 1.4s linear infinite;
}
.skeleton-hero { height: clamp(280px, 44vw, 460px); }
.skeleton-row {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: clamp(150px, 24vw, 250px);
  gap: 0.9rem;
  overflow: hidden;
  padding: 1.6rem var(--edge) 0;
}
.skeleton-poster { aspect-ratio: 16 / 9; border-radius: var(--radius); }
.skeleton-line { height: 0.9rem; border-radius: 4px; margin-top: 0.6rem; width: 70%; }
@media (prefers-reduced-motion: reduce) {
  .skeleton-hero, .skeleton-poster, .skeleton-line { animation: none; }
}

/* ============ Admin ============ */

.admin {
  max-width: 60rem;
  margin: 0 auto;
  padding: 2rem var(--edge) 4rem;
  display: grid;
  gap: 1.5rem;
}
.admin h1 { margin: 0; font-size: 1.7rem; }
.admin-gate { text-align: center; padding-top: 5rem; justify-items: center; }
.admin-gate p { color: var(--text-muted); max-width: 30rem; margin: 0; }

.admin-card {
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--bg-raised);
  padding: 1.4rem;
  display: grid;
  gap: 1rem;
}
.admin-card h2 { margin: 0; font-size: 1.2rem; }
.admin-help { margin: 0; color: var(--text-muted); font-size: 0.95rem; }

.admin-notice {
  margin: 0;
  padding: 0.7rem 1rem;
  border-radius: 10px;
  font-weight: 600;
}
.admin-notice.ok { background: rgba(159, 231, 184, 0.12); color: var(--mint); border: 1px solid rgba(159, 231, 184, 0.4); }
.admin-notice.err { background: rgba(255, 138, 138, 0.1); color: var(--danger); border: 1px solid rgba(255, 138, 138, 0.4); }

.admin-check-form { display: grid; gap: 0.9rem; max-width: 34rem; }

.rights-banner {
  padding: 0.8rem 1rem;
  border-radius: 10px;
  font-size: 0.95rem;
}
.rights-banner.ok { background: rgba(159, 231, 184, 0.12); border: 1px solid rgba(159, 231, 184, 0.45); color: var(--mint); }
.rights-banner.warn { background: rgba(255, 217, 107, 0.08); border: 1px solid rgba(255, 217, 107, 0.4); color: var(--accent); }

.admin-add-form { display: grid; gap: 1rem; }
.admin-add-grid {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 1.2rem;
  align-items: start;
}
.admin-poster-preview {
  aspect-ratio: 16 / 9;
  border-radius: 10px;
  overflow: hidden;
  background: var(--bg-card);
  border: 1px solid var(--border);
}
.admin-poster-preview img { width: 100%; height: 100%; object-fit: cover; }
.admin-add-fields { display: grid; gap: 0.8rem; }
.admin-add-fields textarea {
  font: inherit;
  padding: 0.6rem 0.8rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  resize: vertical;
}
.admin-add-fields select {
  font: inherit;
  padding: 0.55rem 0.8rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
}
.admin-two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 0.8rem; align-items: end; }
.checkbox-line { display: flex; align-items: center; gap: 0.5rem; color: var(--text); font-weight: 400; }

.channel-picker { border: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 0.5rem; }
.channel-picker legend { font-size: 0.85rem; color: var(--text-muted); font-weight: 600; padding: 0 0 0.35rem; }
.channel-choice { position: relative; }
.channel-choice input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.channel-choice span {
  display: inline-block;
  padding: 0.35rem 1rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.9rem;
  font-weight: 600;
}
.channel-choice input:checked + span {
  background: var(--channel-color);
  border-color: var(--channel-color);
  color: #12100b;
}
.channel-choice input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

.admin-actions { display: flex; flex-wrap: wrap; gap: 0.7rem; }

.admin-list-head { margin: 0.4rem 0 0; font-size: 0.95rem; color: var(--text-muted); }
.admin-row {
  display: grid;
  grid-template-columns: 96px 1fr auto;
  gap: 0.9rem;
  align-items: center;
  padding: 0.6rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
}
.admin-row-poster {
  position: relative;
  aspect-ratio: 16 / 9;
  border-radius: 6px;
  overflow: hidden;
  background: var(--bg-card);
}
.admin-row-poster img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.admin-row-poster .poster-fallback { position: absolute; inset: 0; }
.admin-row-main { min-width: 0; }
.admin-row-title { margin: 0; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.admin-row-sub { margin: 0.15rem 0 0; color: var(--text-muted); font-size: 0.82rem; display: flex; flex-wrap: wrap; gap: 0.35rem; align-items: center; }
.admin-row-actions { display: flex; gap: 0.5rem; }
.btn-sm { padding: 0.35rem 0.9rem; font-size: 0.85rem; }
.btn.danger { color: var(--danger); border-color: rgba(255, 138, 138, 0.4); }
.btn.danger:hover { background: rgba(255, 138, 138, 0.08); border-color: var(--danger); }
.status-badge {
  display: inline-block;
  padding: 0.02rem 0.55rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  font-size: 0.75rem;
  font-weight: 700;
}
.status-badge.on { color: var(--mint); border-color: rgba(159, 231, 184, 0.5); }

@media (max-width: 640px) {
  .admin-add-grid { grid-template-columns: 1fr; }
  .admin-row { grid-template-columns: 72px 1fr; }
  .admin-row-actions { grid-column: 1 / -1; justify-content: flex-end; }
}

/* ============ Footer ============ */

.site-footer {
  border-top: 1px solid var(--border);
  padding: 1.4rem var(--edge);
  color: var(--text-muted);
  font-size: 0.85rem;
}
.site-footer p { margin: 0; }
.site-footer .footer-note { margin-top: 0.3rem; font-size: 0.78rem; opacity: 0.8; }

/* ============ Toast ============ */

.toast {
  position: fixed;
  left: 50%;
  bottom: 1.5rem;
  translate: -50% 140%;
  z-index: 200;
  max-width: min(92vw, 30rem);
  padding: 0.85rem 1.3rem;
  border-radius: 12px;
  background: var(--accent);
  color: #1c1608;
  font-weight: 600;
  text-align: center;
  box-shadow: var(--shadow);
  opacity: 0;
  transition: translate 0.3s ease, opacity 0.3s ease;
}
.toast.show { translate: -50% 0; opacity: 1; }

/* ============ Small screens ============ */

@media (max-width: 640px) {
  .topbar { gap: 0.6rem; }
  .brand-name { font-size: 1.15rem; }
  .search { max-width: none; }
  .user-name { display: none; }
  .hero-content { padding-top: 4rem; }
  .row-scroller { grid-auto-columns: clamp(140px, 44vw, 210px); }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .card:hover .card-poster,
  .card:focus .card-poster { transform: none; }
  * { transition-duration: 0.01ms !important; }
}

/* ============ TV / 10-foot experience ============
   Large screen with no hover pointer = a TV navigated by remote (D-pad).
   Bigger type for couch viewing, overscan-safe margins, always-visible
   play affordances (hover never fires), and bold focus rings. */
@media (hover: none) and (min-width: 1000px) {
  html { font-size: 22px; }                 /* scales all rem-based sizing up */
  :root { --edge: max(5vw, 56px); }         /* keep UI inside the overscan safe area */
  body { line-height: 1.55; }

  .topbar { height: 76px; background: #0c1711; }   /* solid: TV browsers may skip blur */
  .brand-name { font-size: 1.5rem; }
  .search input { font-size: 1rem; padding-top: 0.6rem; padding-bottom: 0.6rem; }

  /* Play badge is always visible — there is no hover to reveal it. */
  .card-play { opacity: 0.9; background: rgba(5, 7, 11, 0.25); }
  .card:focus .card-play { opacity: 1; background: rgba(5, 7, 11, 0.5); }
  .card-label { font-size: 1rem; }
  .card-sub { font-size: 0.85rem; }

  /* Fatter, unmissable focus ring for the current D-pad selection. */
  .card:focus .card-poster { outline-width: 4px; outline-offset: 3px; }
  a:focus, button:focus, .channel-pill:focus, video:focus {
    outline: 4px solid var(--accent);
    outline-offset: 3px;
  }

  .channel-pill { font-size: 1rem; padding: 0.45rem 1.25rem; }
  .btn { padding: 0.6rem 1.4rem; }
  .row-title { font-size: 1.35rem; }
  .hero-desc { -webkit-line-clamp: 4; }

  /* Arrows are pointer-only; on a remote the cards scroll themselves. */
  .row-arrow { display: none; }

  /* Give the sticky player and info breathing room from cropped edges. */
  .watch-info { padding-left: var(--edge); padding-right: var(--edge); }
  .site-footer { padding-bottom: max(1.4rem, 4vh); }
}
