/* ============================================================
   Blazing Design System
   Background: #0A0A0A  |  Accent: #FF3D47  (Blazing red)

   #FF3D47, not #E50914. Markus, 27 Aug: "the color scheme on the apple tv seems
   so different and it shouldnt be like that." Apple TV was not the odd one —
   Roku, Fire TV and Apple TV all carry #FF3D47, and Colors.kt says in as many
   words that "the Roku is the reference". The WEB and the Samsung app were the
   two left behind on the older Netflix-ish #E50914, so those are what moved.
   Transitions: 300ms ease throughout
   ============================================================ */

:root {
  --bg: #0A0A0A;
  --surface: #141416;
  --surface-focus: #1c1c1f;
  --surface-soft: #18181b;
  --text: #f7f7f8;
  --muted: #a3a3aa;
  --quiet: #6d6d75;
  --accent: #FF3D47;
  --accent-strong: #E11D2B;
  --accent-glow: rgba(255,61,71, 0.35);
  --radius: 16px;
  --transition: 300ms ease;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

button, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
body.no-scroll { overflow: hidden; }
[hidden] { display: none !important; }

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

button:focus-visible, a:focus-visible, input:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
}

/* ── Topbar ─────────────────────────────────────────────── */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  width: min(1280px, calc(100% - 24px));
  height: 58px;
  margin: calc(10px + var(--safe-top)) auto 0;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 7px;
  border: 1px solid rgba(255, 255, 255, .08);
  border-radius: 20px;
  background: rgba(10, 10, 10, .88);
  box-shadow: 0 14px 40px rgba(0, 0, 0, .5);
  backdrop-filter: blur(24px) saturate(160%);
  -webkit-backdrop-filter: blur(24px) saturate(160%);
  transition: background var(--transition);
}

.brand, .icon-button, .topnav button, .drawer-nav button {
  border: 0;
  color: var(--text);
  background: transparent;
  transition: color var(--transition), background var(--transition);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
  padding: 7px 9px;
  font-size: 17px;
  font-weight: 800;
  letter-spacing: -.03em;
}

.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 27px;
  height: 27px;
  border-radius: 9px;
  color: #fff;
  background: linear-gradient(145deg, var(--accent), var(--accent-strong));
  box-shadow: 0 4px 16px var(--accent-glow);
  font-size: 15px;
  font-weight: 900;
}

.icon-button {
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  border-radius: 13px;
  transition: background var(--transition);
}
.icon-button:hover { background: var(--surface-focus); }
.icon-button svg, .player-close svg { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }

.topnav {
  display: flex;
  align-items: center;
  gap: 2px;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
}
.topnav::-webkit-scrollbar { display: none; }
.topnav button, .drawer-nav button {
  flex: 0 0 auto;
  border-radius: 12px;
  padding: 9px 10px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  transition: color var(--transition), background var(--transition);
}
.topnav button:hover, .topnav button.active { color: #fff; background: var(--surface-focus); }
.search-button { margin-left: auto; }

/* ── Drawer ──────────────────────────────────────────────── */
.drawer-layer { position: fixed; inset: 0; z-index: 40; }
.drawer-backdrop { position: absolute; inset: 0; width: 100%; border: 0; background: rgba(0, 0, 0, .65); }
.drawer {
  position: relative;
  z-index: 1;
  width: min(340px, calc(100% - 32px));
  max-height: calc(100vh - 32px);
  margin: 16px;
  padding: 24px;
  overflow-y: auto;
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 24px;
  background: rgba(14, 14, 16, 0.94);
  box-shadow: 0 25px 80px rgba(0,0,0,.75);
  backdrop-filter: blur(24px) saturate(160%);
  -webkit-backdrop-filter: blur(24px) saturate(160%);
}
.drawer-heading { display: flex; align-items: center; gap: 10px; font-size: 21px; font-weight: 850; letter-spacing: -.03em; }
.drawer-copy { margin: 13px 0 24px; color: var(--muted); font-size: 14px; }
.drawer-nav { display: grid; gap: 6px; }
.drawer-nav button { padding: 13px 14px; text-align: left; font-size: 15px; }
.drawer-nav button.active, .drawer-nav button:hover { background: var(--surface-focus); color: #fff; }
.drawer-section { margin: 26px 0 8px; color: var(--quiet); font-size: 11px; font-weight: 900; letter-spacing: .13em; text-transform: uppercase; }

/* ── Main layout ─────────────────────────────────────────── */
#app-main { width: min(1440px, 100%); margin: 0 auto; padding-bottom: calc(42px + var(--safe-bottom)); }
.view { padding-top: 18px; }
.hero {
  position: relative;
  min-height: min(52vw, 520px);
  margin: 0 12px 32px;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,.07);
  border-radius: 24px;
  background: linear-gradient(145deg, #18181b, #0a0a0a);
  isolation: isolate;
}
.hero-art, .detail-art { position: absolute; inset: 0; background-position: center right; background-size: cover; background-repeat: no-repeat; opacity: .9; z-index: -1; }
.hero::after { content: ""; position: absolute; inset: 0; z-index: -1; background: linear-gradient(0deg, rgba(10,10,10,.90), transparent 58%); }
.hero-loading .hero-art { animation: pulse 1.4s ease-in-out infinite alternate; background: linear-gradient(110deg, #151518, #202024, #151518); background-size: 180% 100%; }
.hero-content { display: flex; flex-direction: column; justify-content: end; min-height: inherit; width: min(560px, 100%); padding: 48px 24px 28px; }
.eyebrow { margin: 0 0 8px; color: #d0d0d4; font-size: 12px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.hero h1, .page-heading h1 { margin: 0; font-size: clamp(28px, 5vw, 52px); line-height: 1.02; letter-spacing: -.05em; }
.hero-content > p:not(.eyebrow), .page-heading > p:not(.eyebrow) { max-width: 520px; margin: 12px 0 0; color: var(--muted); font-size: 15px; line-height: 1.5; }
.hero-actions, .detail-actions { display: flex; flex-wrap: wrap; gap: 9px; margin-top: 22px; align-items: center; }

/* ── Buttons ─────────────────────────────────────────────── */
.primary-button, .secondary-button, .text-link {
  min-height: 42px;
  border-radius: 999px;
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 800;
  line-height: 1.2;
  text-decoration: none;
  transition: filter var(--transition), background var(--transition), box-shadow var(--transition);
}
.primary-button { border: 1px solid var(--accent); color: #fff; background: linear-gradient(140deg, var(--accent), var(--accent-strong)); box-shadow: 0 8px 22px var(--accent-glow); }
.primary-button:hover { filter: brightness(1.1); box-shadow: 0 12px 28px rgba(255,61,71,.45); }
.primary-button:disabled { cursor: wait; opacity: .55; }
.secondary-button { border: 1px solid rgba(255,255,255,.12); color: #fff; background: rgba(28,28,31,.9); }
.secondary-button:hover { background: var(--surface-focus); }
.text-link { display: inline-flex; align-items: center; color: #fff; background: transparent; }
.text-link:hover { color: var(--accent); }
/* "Already done" treatment */
.secondary-button.is-spent { border-color: rgba(255,61,71,.5); background: rgba(255,61,71,.16); }
.secondary-button.is-spent:hover { background: rgba(255,61,71,.16); }

/* ── Rows / Cards ────────────────────────────────────────── */
.rows { display: flex; flex-direction: column; gap: 29px; }
.row[hidden] { display: none; }
.row-title { margin: 0 0 11px 18px; font-size: 19px; font-weight: 800; letter-spacing: -.03em; }
.row-track, .result-grid {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  padding: 3px 18px 9px;
  scroll-snap-type: x proximity;
  scrollbar-width: none;
}
.row-track::-webkit-scrollbar, .result-grid::-webkit-scrollbar { display: none; }

/* ── Poster card ─────────────────────────────────────────── */
.card {
  position: relative;
  flex: 0 0 auto;
  width: 132px;
  aspect-ratio: 2 / 3;
  overflow: hidden;
  padding: 0;
  border: 1px solid rgba(255,255,255,.07);
  border-radius: var(--radius);
  color: #fff;
  background: var(--surface);
  box-shadow: 0 8px 22px rgba(0,0,0,.3);
  scroll-snap-align: start;
  text-align: left;
  transition: transform var(--transition), border-color var(--transition), box-shadow var(--transition);
}
.card:hover, .card:focus-visible {
  transform: translateY(-5px) scale(1.03);
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent), 0 20px 40px rgba(255,61,71,.28), 0 8px 22px rgba(0,0,0,.4);
  z-index: 2;
}
.card:active { transform: scale(.97); }
.card-image { display: block; width: 100%; height: 100%; object-fit: cover; background: linear-gradient(135deg, #252529, #111113); transition: opacity var(--transition); }
.card.no-image::before { content: "B"; position: absolute; inset: 0; display: grid; place-items: center; color: rgba(255,255,255,.34); font-size: 42px; font-weight: 900; }
.card.no-image .card-image { visibility: hidden; }
.card-label { position: absolute; right: 0; bottom: 0; left: 0; padding: 32px 10px 9px; background: linear-gradient(0deg, rgba(0,0,0,.93), rgba(0,0,0,0)); font-size: 12px; font-weight: 750; line-height: 1.25; text-shadow: 0 1px 4px #000; display: -webkit-box; overflow: hidden; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
.card-source { position: absolute; top: 8px; left: 8px; border-radius: 999px; padding: 4px 7px; color: #fff; background: rgba(255,61,71,.92); font-size: 10px; font-weight: 900; letter-spacing: .04em; }
.skeleton { background: linear-gradient(100deg, #151518 30%, #242429 50%, #151518 70%); background-size: 200% 100%; animation: shimmer 1.3s infinite linear; box-shadow: none; pointer-events: none; }

/* ── Card-hover trailer embed ────────────────────────────── */
/* The trailer preview replaces the poster image on hover.    */
.card-trailer-wrap {
  position: absolute;
  inset: 0;
  z-index: 1;
  opacity: 0;
  transition: opacity 400ms ease;
  pointer-events: none;
  background: #000;
}
.card-trailer-wrap.visible { opacity: 1; }
.card-trailer-wrap video,
.card-trailer-wrap iframe {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border: 0;
}
/* Mute toggle that appears on the hovered card */
.card-mute-btn {
  position: absolute;
  bottom: 36px;
  right: 6px;
  z-index: 3;
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 50%;
  background: rgba(0,0,0,.7);
  color: #fff;
  font-size: 13px;
  line-height: 1;
  display: grid;
  place-items: center;
  opacity: 0;
  transition: opacity var(--transition);
  cursor: pointer;
}
.card:hover .card-mute-btn { opacity: 1; }

/* ── Inner pages ─────────────────────────────────────────── */
.page-heading { max-width: 760px; margin: 44px auto 24px; padding: 0 20px; }
.page-heading h1 { font-size: clamp(30px, 6vw, 48px); }
.search-form { display: flex; gap: 10px; max-width: 760px; margin: 0 auto; padding: 0 20px; }
.search-form input { width: 100%; min-height: 46px; border: 1px solid rgba(255,255,255,.12); border-radius: 14px; padding: 0 15px; outline: none; color: var(--text); background: var(--surface); transition: border-color var(--transition), box-shadow var(--transition); }
.search-form input::placeholder { color: var(--quiet); }
.search-form input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(255,61,71,.18); }
.search-status { min-height: 24px; max-width: 760px; margin: 16px auto 0; padding: 0 20px; color: var(--muted); font-size: 14px; }
.search-results, .library-results { margin-top: 24px; }
.result-row { margin-bottom: 29px; }
.result-grid { flex-wrap: wrap; overflow: visible; padding-bottom: 0; }
.empty-copy { margin: 20px; color: var(--muted); }
.roadmap-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; max-width: 920px; margin: 0 auto; padding: 0 20px; }
.roadmap-grid article { min-height: 190px; padding: 22px; border: 1px solid rgba(255,255,255,.08); border-radius: var(--radius); background: var(--surface); transition: border-color var(--transition), box-shadow var(--transition); }
.roadmap-grid article:hover { border-color: rgba(255,61,71,.3); box-shadow: 0 8px 24px rgba(255,61,71,.1); }
.roadmap-grid span { color: var(--accent); font-size: 13px; font-weight: 900; letter-spacing: .12em; }
.roadmap-grid h2 { margin: 25px 0 8px; font-size: 20px; letter-spacing: -.03em; }
.roadmap-grid p { margin: 0; color: var(--muted); font-size: 14px; line-height: 1.5; }

/* ── Education tabs ──────────────────────────────────────── */
.edu-tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  max-width: 760px;
  margin: 0 auto 8px;
  padding: 0 20px;
}
.edu-tab {
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 999px;
  padding: 9px 16px;
  font-size: 14px;
  font-weight: 700;
  color: var(--muted);
  background: rgba(28,28,31,.8);
  transition: color var(--transition), background var(--transition), border-color var(--transition), box-shadow var(--transition);
}
.edu-tab:hover { color: #fff; background: var(--surface-focus); }
.edu-tab.active {
  color: #fff;
  background: linear-gradient(140deg, var(--accent), var(--accent-strong));
  border-color: var(--accent);
  box-shadow: 0 6px 18px var(--accent-glow);
}
/* Education card variant — slightly lighter background, subtle green border */
.card.edu-card {
  background: var(--surface-soft);
  border-color: rgba(40, 200, 100, .18);
}
.card.edu-card:hover, .card.edu-card:focus-visible {
  border-color: rgba(40, 200, 100, .55);
  box-shadow: 0 0 0 2px rgba(40,200,100,.4), 0 20px 40px rgba(0,0,0,.4);
}
/* EDU badge */
.edu-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  border-radius: 6px;
  padding: 3px 7px;
  color: #fff;
  background: rgba(30, 160, 80, .92);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: .04em;
}

/* ── Details overlay ─────────────────────────────────────── */
.detail-dialog {
  width: min(900px, calc(100% - 24px));
  max-height: min(760px, calc(100vh - 24px));
  overflow: hidden;
  padding: 0;
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 24px;
  color: var(--text);
  background: rgba(10,10,10,0.45);
  backdrop-filter: blur(28px) saturate(170%);
  -webkit-backdrop-filter: blur(28px) saturate(170%);
  box-shadow: 0 30px 100px rgba(0,0,0,.85);
}
.detail-dialog::backdrop { background: rgba(0,0,0,.75); backdrop-filter: blur(6px); }
.detail-card { position: relative; min-height: min(560px, calc(100vh - 24px)); overflow: hidden; }
.detail-art { opacity: .72; background-position: right center; }
.detail-card::after { content: ""; position: absolute; inset: 0; z-index: -1; background: linear-gradient(90deg, rgba(0,0,0,.88) 0%, rgba(0,0,0,.68) 45%, rgba(0,0,0,.3) 100%); }
.detail-close { position: absolute; top: 14px; right: 14px; z-index: 3; color: #fff; background: rgba(10,10,10,.78); transition: background var(--transition); }
.detail-close:hover { background: rgba(255,61,71,.3); }
.detail-body { position: relative; z-index: 0; width: min(550px, 100%); padding: 60px 28px 30px; }
.detail-body h2 { margin: 0; font-size: clamp(27px, 5vw, 43px); line-height: 1.04; letter-spacing: -.05em; }
.detail-copy { margin: 14px 0 0; color: #dddde0; font-size: 15px; line-height: 1.55; }
.source-pill { display: inline-flex; margin: 0 0 12px; border: 1px solid rgba(255,61,71,.5); border-radius: 999px; padding: 5px 9px; color: #fff; background: rgba(255,61,71,.16); font-size: 11px; font-weight: 800; }
.detail-status { min-height: 22px; margin: 16px 0 0; color: var(--muted); font-size: 14px; line-height: 1.4; }

/* ── Trailer embed in detail art ─────────────────────────── */
.detail-trailer {
  position: absolute;
  inset: 0;
  z-index: 0;
  opacity: 0;
  transition: opacity 600ms ease;
  pointer-events: none;
  background: #000;
}
.detail-trailer.loaded { opacity: 1; }
.detail-trailer iframe,
.detail-trailer video {
  width: 100%;
  height: 100%;
  border: 0;
  object-fit: cover;
}
/* Mute toggle button in detail overlay */
.detail-mute-btn {
  position: absolute;
  bottom: 16px;
  right: 16px;
  z-index: 4;
  width: 36px;
  height: 36px;
  border: 1px solid rgba(255,255,255,.2);
  border-radius: 50%;
  background: rgba(0,0,0,.7);
  color: #fff;
  font-size: 16px;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition);
  backdrop-filter: blur(8px);
}
.detail-mute-btn:hover { background: rgba(255,61,71,.4); border-color: var(--accent); }

/* ── Quality selector ────────────────────────────────────── */
.quality-select {
  height: 42px;
  min-width: 130px;
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 999px;
  padding: 0 14px;
  color: #fff;
  background: rgba(28,28,31,.9);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23fff' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.quality-select:hover, .quality-select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(255,61,71,.18); outline: none; }
.quality-select option { background: #1c1c1f; color: #fff; }

/* ── Player ──────────────────────────────────────────────── */
.player { position: fixed; inset: 0; z-index: 60; display: flex; flex-direction: column; background: #000; }
.player-bar { position: absolute; top: 0; right: 0; left: 0; z-index: 2; display: flex; align-items: center; gap: 12px; padding: calc(10px + var(--safe-top)) 16px 26px; pointer-events: none; background: linear-gradient(180deg, rgba(0,0,0,.8), transparent); }
.player-close { pointer-events: auto; display: inline-flex; align-items: center; gap: 4px; border: 0; border-radius: 999px; padding: 8px 12px 8px 6px; color: #fff; background: rgba(28,28,31,.78); font-size: 14px; font-weight: 800; transition: background var(--transition); }
.player-close:hover { background: rgba(255,61,71,.3); }
.player-title { overflow: hidden; color: #fff; font-size: 14px; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; text-shadow: 0 1px 4px #000; }
.player-stage { position: relative; display: grid; flex: 1; place-items: center; }
.video { width: 100%; height: 100%; background: #000; opacity: 0; transition: opacity .2s; }
.video.ready { opacity: 1; }
.player-msg { position: absolute; width: min(430px, calc(100% - 40px)); margin: 0; color: var(--muted); text-align: center; line-height: 1.45; }
.spinner { width: 34px; height: 34px; border: 3px solid rgba(255,255,255,.15); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
.spinner.big { position: absolute; width: 48px; height: 48px; border-width: 4px; }

/* ── Toast ───────────────────────────────────────────────── */
/* app.js moves this single host into the open <dialog> when
   there is one, because showModal() puts that dialog in the
   top layer and a body-level element cannot draw above it. */
.toast-host {
  position: fixed;
  z-index: 80;
  bottom: calc(18px + var(--safe-bottom));
  left: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: min(430px, calc(100% - 28px));
  transform: translateX(-50%);
  pointer-events: none;
}
.toast-host-inline { position: absolute; bottom: 18px; }
.toast {
  max-width: 100%;
  margin: 0;
  border: 1px solid rgba(255,255,255,.08);
  border-radius: var(--radius);
  padding: 12px 16px;
  color: var(--text);
  background: rgba(14,14,16,.92);
  box-shadow: 0 14px 40px rgba(0,0,0,.4);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  backdrop-filter: blur(18px) saturate(140%);
  font-size: 14px;
  font-weight: 700;
  line-height: 1.4;
  text-align: center;
  animation: toast-in .18s ease-out;
}
.toast-error { border-color: rgba(255,61,71,.5); background: rgba(255,61,71,.18); }
.toast-out { opacity: 0; transform: translateY(8px); transition: opacity .2s ease-in, transform .2s ease-in; }

/* ── Streams list ────────────────────────────────────────── */
.detail-streams {
  margin-top: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-height: 250px;
  overflow-y: auto;
}
.stream-row {
  background: rgba(20,20,22,.6);
  padding: 0.5rem 0.75rem;
  border-radius: 10px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border: 1px solid transparent;
  user-select: none;
  transition: border-color var(--transition), background var(--transition), box-shadow var(--transition);
}
.stream-row:hover {
  border-color: var(--accent);
  background: rgba(255,61,71,.08);
  box-shadow: 0 4px 16px rgba(255,61,71,.15);
}
.stream-row.dead { opacity: 0.4; }
.stream-info { display: flex; flex-direction: column; gap: 0.25rem; }
.stream-title { font-size: 0.85rem; color: var(--text); }
.stream-tags { font-size: 0.75rem; color: var(--muted); }
.stream-q { font-weight: 600; color: var(--accent); font-size: 0.85rem; }
.badge { display: inline-block; padding: 2px 6px; border-radius: 4px; font-weight: 800; font-size: 11px; margin-right: 6px; }
.badge-4k { background: #8a2be2; color: #fff; }
.badge-1080 { background: #0066ee; color: #fff; }
.badge-720 { background: #1a9e4a; color: #fff; }
.badge-sd { background: #555; color: #fff; }
.stream-meta { font-size: 11px; color: var(--muted); margin-top: 4px; display: flex; gap: 8px; }

/* ── Progress bar ────────────────────────────────────────── */
.progress-bar { position: absolute; bottom: 0; left: 0; right: 0; height: 4px; background: rgba(255,255,255,0.2); }
.progress-fill { height: 100%; background: var(--accent); }

/* ── Keyframes ───────────────────────────────────────────── */
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
@keyframes pulse { from { background-position: 0 0; } to { background-position: 100% 0; } }

/* ── Responsive ──────────────────────────────────────────── */
@media (min-width: 760px) {
  .hero { margin-right: 18px; margin-left: 18px; }
  .hero-content { padding: 70px 54px 45px; }
  .row-title { margin-left: 26px; }
  .row-track { padding-right: 26px; padding-left: 26px; }
  .card { width: 158px; }
  .detail-body { padding: 74px 48px 46px; }
}

@media (max-width: 700px) {
  .topnav { display: none; }
  .hero { min-height: 440px; }
  .hero-art { opacity: .58; background-position: 64% top; }
  .hero-content { padding-top: 170px; }
  .roadmap-grid { grid-template-columns: 1fr; }
}

@media (max-width: 420px) {
  .topbar { width: calc(100% - 16px); }
  .brand { padding-right: 3px; }
  .brand > span:last-child { display: none; }
  .card { width: 118px; }
  .search-form { align-items: stretch; flex-direction: column; }
  .search-form .primary-button { width: 100%; }
  .detail-dialog { width: calc(100% - 16px); }
  .detail-body { padding: 55px 20px 26px; }
  .edu-tabs { gap: 6px; }
  .edu-tab { padding: 7px 12px; font-size: 13px; }
}

/* ── Card hover trailer preview ───────────────────────────────
   The poster stays in the DOM underneath: the video fades in over it, so a
   trailer that fails to load leaves the card looking exactly as before rather
   than as a black hole. */
.card-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  object-fit: cover;
  border-radius: inherit;
  opacity: 0;
  animation: card-preview-in 420ms ease forwards;
  pointer-events: none;
}
@keyframes card-preview-in { to { opacity: 1; } }
.card-previewing { transform: scale(1.04); z-index: 3; }
.card-previewing .card-label { opacity: 0; }
@media (prefers-reduced-motion: reduce) {
  .card-video { animation: none; opacity: 1; }
  .card-previewing { transform: none; }
}

/* ── Detail rating chips ─────────────────────────────────────── */
.detail-chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 6px 0 10px; }
.detail-chip {
  border-radius: 6px; padding: 3px 9px;
  background: rgba(255,255,255,.1); color: #cfcfd4;
  font-size: 12px; font-weight: 700; letter-spacing: .02em;
}
.detail-chip-cert { border: 1px solid rgba(255,255,255,.45); background: transparent; color: #fff; }
.detail-chip-star { background: rgba(255,61,71,.22); color: #fff; }

/* ── Seerr request desk ────────────────────────────────────────────────────
   A request card is deliberately NOT a catalog card: it is not something you
   can watch, and dressing it up like a poster row invites a click that leads
   nowhere. It states what the server has, and offers a button only when there
   is something the button can actually do. */
.search-results { display: flex; flex-wrap: wrap; gap: 16px; }
.seerr-card {
  width: 200px; display: flex; flex-direction: column; gap: 10px;
  background: rgba(255, 255, 255, 0.04); border-radius: 12px; padding: 10px;
}
.seerr-art {
  aspect-ratio: 2 / 3; border-radius: 8px; background-size: cover;
  background-position: center; background-color: rgba(255, 255, 255, 0.06);
}
.seerr-body { display: flex; flex-direction: column; gap: 8px; }
.seerr-title { font-size: 14px; line-height: 1.3; margin: 0; }
.seerr-status {
  align-self: flex-start; font-size: 12px; padding: 3px 8px; border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
}
/* The status colours carry meaning, so they are keyed off Seerr's own enum
   rather than off the label text — a re-worded label must not silently change
   what a card looks like. */
.seerr-status[data-status="2"] { background: #a16207; color: #fff; }
.seerr-status[data-status="3"] { background: #1d4ed8; color: #fff; }
.seerr-status[data-status="4"] { background: #0369a1; color: #fff; }
.seerr-status[data-status="5"] { background: #15803d; color: #fff; }
.seerr-card .primary-button { font-size: 13px; padding: 6px 10px; }

/* ── Comic reader ──────────────────────────────────────────────────────────
   Full-bleed, because a comic page is the content. `object-fit: contain` keeps
   a tall page whole instead of cropping the top and bottom off it on a 16:9 TV. */
.comic-reader {
  position: fixed; inset: 0; z-index: 60; background: #000;
  display: flex; flex-direction: column;
}
.comic-reader[hidden] { display: none; }
.comic-bar {
  display: flex; align-items: center; gap: 16px; padding: 10px 18px;
  background: rgba(0, 0, 0, 0.85); color: #fff; font-size: 14px;
}
.comic-label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.comic-counter { opacity: 0.7; font-variant-numeric: tabular-nums; }
.comic-close {
  background: rgba(255, 255, 255, 0.14); color: #fff; border: 0;
  border-radius: 999px; padding: 6px 14px; cursor: pointer;
}
.comic-close:focus-visible { outline: 3px solid var(--accent, #f43f5e); }
.comic-page { flex: 1; min-height: 0; width: 100%; object-fit: contain; }

/* 10-foot UI D-pad magnetic focus engine */
@media (pointer: coarse), (hover: none) {
  .card:focus-visible, .primary-button:focus-visible, .secondary-button:focus-visible, button:focus-visible {
    transform: scale(1.08);
    box-shadow: 0 0 15px var(--accent-glow);
    outline: 3px solid var(--accent);
    outline-offset: 4px;
    z-index: 10;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
  }
}

[data-theme="kids_warm"] {
  --bg: #1a1510;
  --surface: #261f1a;
  --text: #fffdfa;
  --accent: #FFD700;
  --accent-glow: rgba(255, 215, 0, 0.4);
}

/* ── BrightMinds Feature UIs ──────────────────────────────── */
.bm-stories-layout, .bm-podcast-layout, .bm-family-layout {
  display: flex;
  gap: 24px;
  padding: 40px;
  max-width: 1400px;
  margin: 0 auto;
}

.bm-panel {
  background: var(--surface-soft);
  border: 1px solid rgba(255,255,255,0.05);
  border-radius: 24px;
  padding: 32px;
  flex: 1;
}

.bm-form { display: flex; flex-direction: column; gap: 16px; margin: 24px 0; }
.bm-form-row { display: flex; flex-direction: column; gap: 8px; }
.bm-form-row label { font-weight: 600; color: var(--muted); font-size: 14px; }
.bm-form-row input, .bm-form-row select, .bm-form-row textarea {
  background: var(--surface);
  border: 1px solid rgba(255,255,255,0.1);
  padding: 12px 16px;
  border-radius: 12px;
  color: #fff;
  font-size: 16px;
}
.bm-form-row input:focus, .bm-form-row select:focus, .bm-form-row textarea:focus {
  border-color: var(--accent);
  outline: none;
}

.bm-library-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 16px;
  margin-top: 16px;
}

.bm-story-card {
  background: var(--surface);
  border: 1px solid rgba(255,255,255,0.05);
  border-radius: 16px;
  padding: 16px;
  text-align: left;
  transition: transform 0.2s, box-shadow 0.2s;
  cursor: pointer;
}
.bm-story-card:hover, .bm-story-card:focus {
  transform: translateY(-4px);
  box-shadow: 0 10px 20px rgba(0,0,0,0.4);
  border-color: var(--accent);
}
.bm-story-card-emoji { font-size: 32px; margin-bottom: 8px; }
.bm-story-card-title { font-weight: 700; margin-bottom: 4px; }
.bm-story-card-meta { font-size: 12px; color: var(--muted); }

.bm-reader { flex: 1.5; display: flex; flex-direction: column; }
.bm-reader-bar { display: flex; align-items: center; gap: 16px; margin-bottom: 24px; }
.bm-reader-title { font-size: 20px; font-weight: 700; flex: 1; }

.bm-book {
  flex: 1;
  background: #111;
  border-radius: 20px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  position: relative;
  border: 1px solid rgba(255,255,255,0.1);
}
.bm-page-art {
  height: 45vh;
  display: grid;
  place-items: center;
  font-size: 120px;
  background: linear-gradient(135deg, #2a0845 0%, #6441A5 100%);
  transition: background 1s ease;
}
.bm-page-text {
  padding: 32px;
  font-size: 22px;
  line-height: 1.6;
  flex: 1;
}
.bm-page-number { font-size: 14px; color: var(--muted); margin-bottom: 16px; font-weight: 600; text-transform: uppercase; letter-spacing: 1px;}
.bm-page-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 32px;
  background: rgba(255,255,255,0.02);
  border-top: 1px solid rgba(255,255,255,0.05);
}

.bm-page-turning .bm-page-art { transform: rotateY(-15deg); opacity: 0.5; }
.bm-page-turning .bm-page-text { opacity: 0; transform: translateX(20px); }
.bm-page-art, .bm-page-text { transition: all 0.4s ease; }

/* Podcast Studio */
.bm-hosts { display: flex; gap: 40px; justify-content: center; margin: 40px 0; }
.bm-host { text-align: center; }
.bm-host-avatar { font-size: 80px; margin-bottom: 16px; }
.bm-host-name { font-weight: 700; font-size: 20px; margin-bottom: 16px; }
.bm-sound-bars { display: flex; gap: 4px; justify-content: center; height: 40px; align-items: flex-end;}
.bm-sound-bars span { width: 8px; height: 4px; background: var(--muted); border-radius: 4px; transition: height 0.1s ease; }
.bm-bars-active span { background: var(--accent); }

.bm-transcript {
  margin-top: 32px;
  flex: 1;
  background: var(--surface);
  border-radius: 16px;
  padding: 24px;
  overflow-y: auto;
  max-height: 400px;
}
.transcript-line { margin-bottom: 16px; opacity: 0.5; transition: opacity 0.3s; display: flex; gap: 16px; }
.transcript-line.active { opacity: 1; }
.tl-host { font-weight: 700; color: var(--accent); min-width: 80px; }
.tl-text { flex: 1; line-height: 1.5; }

/* Family Tree */
.bm-family-sidebar { flex: 1; overflow-y: auto; max-height: 85vh; }
.bm-member-detail { flex: 1; position: sticky; top: 40px; }
.bm-generation { margin-bottom: 32px; }
.bm-gen-label { color: var(--muted); font-size: 14px; text-transform: uppercase; letter-spacing: 1px; margin-bottom: 16px; border-bottom: 1px solid rgba(255,255,255,0.1); padding-bottom: 8px;}
.bm-gen-row { display: flex; flex-wrap: wrap; gap: 16px; }
.bm-member-card { display: flex; flex-direction: column; align-items: center; text-align: center; background: none; border: none; cursor: pointer; opacity: 0.8; transition: opacity 0.2s, transform 0.2s; width: 100px;}
.bm-member-card:hover, .bm-member-card:focus { opacity: 1; transform: scale(1.05); }
.bm-member-avatar { width: 64px; height: 64px; border-radius: 32px; background: var(--surface); display: grid; place-items: center; font-size: 24px; font-weight: 700; margin-bottom: 8px; border: 2px solid transparent;}
.bm-member-card:focus .bm-member-avatar { border-color: var(--accent); }
.bm-member-name { font-weight: 600; font-size: 14px; line-height: 1.2; }
.bm-member-years { font-size: 12px; color: var(--muted); margin-top: 4px; }

.bm-profile-header { display: flex; gap: 24px; align-items: center; margin-bottom: 32px; }
.bm-profile-avatar-large { width: 96px; height: 96px; border-radius: 48px; background: var(--surface); display: grid; place-items: center; font-size: 40px; font-weight: 700; }
.bm-transmute-wrap { margin-top: 32px; padding: 24px; background: rgba(255,61,71, 0.05); border: 1px solid var(--accent-glow); border-radius: 16px; }
.bm-transmute-result { margin-top: 16px; line-height: 1.6; font-style: italic; }


/* ── Phase 4 Delight CSS ──────────────────────────────────── */

/* Circadian Engine */
html.circadian-night {
  --bg: #120e0a;
  --surface: #1f1812;
  --surface-soft: #17110d;
}
html.circadian-night body {
  /* Very subtle warm amber filter over the whole UI after 8PM */
  filter: sepia(0.2) hue-rotate(-5deg) saturate(1.1);
}

/* Voice Button */
#voice-btn {
  font-size: 20px;
  transition: transform 0.2s, text-shadow 0.2s;
}
#voice-btn.recording {
  color: var(--accent);
  text-shadow: 0 0 15px var(--accent);
  animation: pulse-mic 1s infinite alternate;
}
@keyframes pulse-mic {
  0% { transform: scale(1); }
  100% { transform: scale(1.2); }
}

/* Modal Dialog Base */
.bm-dialog {
  background: var(--surface);
  color: var(--text);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 24px;
  padding: 40px;
  max-width: 400px;
  margin: auto;
  box-shadow: 0 20px 40px rgba(0,0,0,0.5);
  backdrop-filter: blur(20px);
}
.bm-dialog::backdrop {
  background: rgba(0,0,0,0.8);
  backdrop-filter: blur(4px);
}

/* Volumetric Fog Hero */
.hero::after {
  content: '';
  position: absolute;
  bottom: 0; left: 0; right: 0; height: 50%;
  background: linear-gradient(to top, var(--bg) 0%, transparent 100%);
  pointer-events: none;
}
.hero-art {
  transition: transform 0.3s ease-out; /* Parallax smooth trailing */
}
