:root {
  --bg: #0b0d10;
  --bg-2: #14181d;
  --bg-3: #1d232a;
  --line: #262e37;
  --text: #e8edf2;
  --muted: #8b97a5;
  --accent: #6cc4ff;
  --accent-ink: #04202f;
  --radius: 10px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  padding-bottom: calc(90px + var(--safe-b));
}
a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }

/* ---------- header ---------- */
.top {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 20px;
  padding: 12px clamp(16px, 4vw, 48px);
  padding-top: max(12px, env(safe-area-inset-top));
  background: rgba(11, 13, 16, 0.85);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--line);
  transition: background 0.3s, border-color 0.3s;
}
.top.over-hero {
  background: transparent; border-bottom-color: transparent;
  backdrop-filter: none; -webkit-backdrop-filter: none;
}
.top.over-hero nav a:not(.active), .top.over-hero .icon-btn { text-shadow: 0 1px 8px rgba(0, 0, 0, 0.6); }
.top.over-hero #search { background: rgba(29, 35, 42, 0.6); }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 650; letter-spacing: -0.01em; white-space: nowrap; flex-shrink: 0; }
.top nav { display: flex; gap: 4px; }
.top nav a { padding: 6px 12px; border-radius: 999px; color: var(--muted); font-weight: 500; }
.top nav a:hover { color: var(--text); }
.top nav a.active { color: var(--text); background: var(--bg-3); }
#search {
  margin-left: auto; width: min(260px, 30vw);
  background: var(--bg-3); border: 1px solid transparent; border-radius: 999px; padding: 7px 14px;
}
#search:focus { border-color: var(--line); outline: none; }
.icon-btn {
  background: none; border: 0; padding: 6px 10px; border-radius: 8px; font-size: 17px; line-height: 1; color: var(--text);
}
.icon-btn:hover { background: rgba(255, 255, 255, 0.08); }
.icon-btn.big { font-size: 22px; width: 46px; height: 46px; border-radius: 50%; background: var(--text); color: var(--bg); }
.icon-btn.big:hover { background: #fff; }
.menu {
  position: absolute; right: clamp(16px, 4vw, 48px); top: 100%; margin-top: 4px;
  background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 6px; min-width: 170px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
}
.menu button, .menu a { display: block; width: 100%; text-align: left; background: none; border: 0; padding: 8px 10px; border-radius: 6px; font-size: 15px; }
.menu button:hover, .menu a:hover { background: var(--bg-3); }

@media (max-width: 680px) {
  .top { flex-wrap: wrap; gap: 10px; }
  .brand span { display: none; }
  .top nav { gap: 0; }
  .top nav a { padding: 6px 9px; }
  #menu-btn { margin-left: auto; }
  #search { order: 3; width: 100%; }
}

/* ---------- views ---------- */
main { padding: 24px clamp(16px, 4vw, 48px); outline: none; }
h1.page { font-size: 28px; letter-spacing: -0.02em; margin: 4px 0 20px; }
h2.row-title { font-size: 18px; margin: 28px 0 12px; letter-spacing: -0.01em; }
.muted { color: var(--muted); }
.empty { color: var(--muted); padding: 40px 0; max-width: 560px; }
.empty code { background: var(--bg-3); padding: 1px 6px; border-radius: 4px; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 22px 16px; }
.grid.wide { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.row { display: grid; grid-auto-flow: column; grid-auto-columns: 150px; gap: 16px; overflow-x: auto; padding-bottom: 8px; scrollbar-width: thin; }
.row.wide { grid-auto-columns: 260px; }

.card { display: block; background: none; border: 0; padding: 0; text-align: left; min-width: 0; }
.card .art {
  position: relative; aspect-ratio: 2 / 3; border-radius: var(--radius); overflow: hidden;
  background: linear-gradient(145deg, #1f262e, #14181d); box-shadow: 0 4px 18px rgba(0, 0, 0, 0.35);
  transition: transform 0.15s ease;
}
.card.square .art { aspect-ratio: 1; }
.card.landscape .art { aspect-ratio: 16 / 9; }
.card:hover .art { transform: translateY(-3px); }
.card .art img { position: relative; z-index: 1; width: 100%; height: 100%; object-fit: cover; display: block; }
.card .art .ph {
  position: absolute; inset: 0; display: flex; align-items: flex-end; padding: 12px;
  font-weight: 650; font-size: 15px; line-height: 1.2; color: #d5dde6;
}
.card .art .bar { z-index: 2; position: absolute; left: 0; bottom: 0; height: 4px; background: var(--accent); }
.card .art .badge {
  z-index: 2; position: absolute; top: 8px; right: 8px; background: rgba(0,0,0,0.65); font-size: 11px; padding: 2px 7px; border-radius: 999px;
}
.card .t { margin-top: 8px; font-weight: 550; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card .s { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* detail pages */
.detail { display: grid; grid-template-columns: minmax(160px, 260px) 1fr; gap: 32px; align-items: start; }
.detail .poster { border-radius: var(--radius); overflow: hidden; aspect-ratio: 2/3; background: var(--bg-3); }
.detail .poster.square { aspect-ratio: 1; }
.detail .poster img { width: 100%; height: 100%; object-fit: cover; display: block; }
.detail h1 { font-size: clamp(26px, 4vw, 40px); margin: 0 0 6px; letter-spacing: -0.02em; line-height: 1.1; }
.meta { color: var(--muted); display: flex; flex-wrap: wrap; gap: 6px 14px; }
.detail .meta { margin-bottom: 20px; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 18px; }
.btn {
  border: 0; border-radius: 999px; padding: 10px 20px; font-weight: 600; background: var(--bg-3);
}
.btn:hover { background: #252c34; }
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { background: #8fd3ff; }
.tech { font-size: 13px; color: var(--muted); }
@media (max-width: 680px) { .detail { grid-template-columns: 1fr; } .detail .poster { max-width: 160px; } }

.seasons { display: flex; gap: 6px; flex-wrap: wrap; margin: 8px 0 16px; }
.seasons button { border: 1px solid var(--line); background: none; border-radius: 999px; padding: 6px 14px; }
.seasons button.active { background: var(--text); color: var(--bg); border-color: var(--text); }
.episodes { display: flex; flex-direction: column; gap: 4px; }
.episode {
  display: grid; grid-template-columns: 180px 1fr auto; gap: 16px; align-items: center;
  background: none; border: 0; padding: 8px; border-radius: var(--radius); text-align: left; width: 100%;
}
.episode:hover { background: var(--bg-2); }
.episode .art { aspect-ratio: 16/9; border-radius: 8px; overflow: hidden; background: var(--bg-3); position: relative; }
.episode .art img { width: 100%; height: 100%; object-fit: cover; display: block; }
.episode .art .bar { position: absolute; left: 0; bottom: 0; height: 3px; background: var(--accent); }
.episode .n { color: var(--muted); font-size: 13px; }
.episode .t { font-weight: 550; }
@media (max-width: 680px) { .episode { grid-template-columns: 120px 1fr; } .episode .d { display: none; } }

.tracks { width: 100%; border-collapse: collapse; }
.tracks tr { cursor: pointer; }
.tracks td { padding: 9px 10px; border-bottom: 1px solid var(--line); }
.tracks tr:hover td { background: var(--bg-2); }
.tracks tr.playing td { color: var(--accent); }
.tracks td.num, .tracks td.dur { color: var(--muted); width: 1%; white-space: nowrap; font-variant-numeric: tabular-nums; }
.tracks td.dur { text-align: right; }

/* ---------- video player ---------- */
.player { position: fixed; inset: 0; z-index: 50; background: #000; }
.player video { width: 100%; height: 100%; object-fit: contain; display: block; }
.player video::cue { background: rgba(0,0,0,0.6); font-size: clamp(16px, 2.6vw, 30px); }
.p-top, .p-controls { position: absolute; left: 0; right: 0; transition: opacity 0.25s; }
.p-top {
  top: 0; display: flex; align-items: center; gap: 12px; padding: max(14px, env(safe-area-inset-top)) 18px 40px;
  background: linear-gradient(rgba(0,0,0,0.7), transparent);
}
.p-title { font-weight: 600; font-size: 17px; }
.p-controls {
  bottom: 0; padding: 40px 20px calc(16px + var(--safe-b));
  background: linear-gradient(transparent, rgba(0,0,0,0.8));
}
.player.idle .p-top, .player.idle .p-controls { opacity: 0; pointer-events: none; }
.player.idle { cursor: none; }
.p-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.p-row .spacer { flex: 1; }
.p-time { font-variant-numeric: tabular-nums; font-size: 14px; }
.p-mode { font-size: 11px; color: var(--muted); border: 1px solid var(--line); border-radius: 4px; padding: 1px 6px; }
.p-mode:empty { display: none; }
.p-row select { background: rgba(255,255,255,0.1); border: 0; border-radius: 6px; padding: 5px 8px; max-width: 170px; }
.p-vol { width: 90px; }
@media (max-width: 680px) { .p-vol { display: none; } }
input[type=range] { accent-color: var(--accent); }
.p-seek { width: 100%; margin: 0 0 10px; }
.p-spinner {
  position: absolute; left: 50%; top: 50%; width: 48px; height: 48px; margin: -24px;
  border: 4px solid rgba(255,255,255,0.2); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.p-error {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); max-width: 520px;
  background: var(--bg-2); padding: 20px 24px; border-radius: var(--radius); border: 1px solid var(--line);
}

/* ---------- music bar ---------- */
.musicbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto minmax(0, 1.4fr); align-items: center; gap: 16px;
  padding: 10px clamp(16px, 4vw, 48px) calc(10px + var(--safe-b));
  background: rgba(20, 24, 29, 0.92); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--line);
}
.mb-art { width: 52px; height: 52px; border-radius: 6px; object-fit: cover; background: var(--bg-3); }
.mb-title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mb-artist { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mb-ctrls { display: flex; align-items: center; gap: 6px; }
.mb-ctrls .big { width: 40px; height: 40px; font-size: 18px; }
.mb-progress { display: flex; align-items: center; gap: 10px; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.mb-seek { flex: 1; }
@media (max-width: 680px) {
  .musicbar { grid-template-columns: auto minmax(0, 1fr) auto; }
  .mb-progress { grid-column: 1 / -1; }
}

.toast {
  position: fixed; left: 50%; bottom: calc(100px + var(--safe-b)); transform: translateX(-50%); z-index: 60;
  background: var(--text); color: var(--bg); padding: 10px 18px; border-radius: 999px; font-weight: 550;
}

/* ---------- login ---------- */
.login-page { display: grid; place-items: center; min-height: 100vh; padding: 20px; }
.login-card {
  width: min(360px, 100%); background: var(--bg-2); border: 1px solid var(--line); border-radius: 16px;
  padding: 32px; display: flex; flex-direction: column; gap: 10px;
}
.login-card h1 { margin: 6px 0 14px; font-size: 22px; }
.login-card label { font-size: 13px; color: var(--muted); }
.login-card input { background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; }
.login-card button { margin-top: 8px; border: 0; border-radius: 8px; padding: 11px; font-weight: 650; background: var(--accent); color: var(--accent-ink); }
.err { color: #ff7a7a; min-height: 1.4em; margin: 0; font-size: 14px; }

/* ---------- setup ---------- */
.setup-page { padding: 32px 16px; }
.setup-card {
  max-width: 640px; margin: 0 auto; background: var(--bg-2); border: 1px solid var(--line); border-radius: 16px;
  padding: 28px clamp(20px, 4vw, 36px);
}
.setup-card header { display: flex; gap: 16px; align-items: center; margin-bottom: 8px; }
.setup-card h1 { margin: 0 0 4px; font-size: 24px; letter-spacing: -0.02em; }
.setup-card header p { margin: 0; }
.setup-card h2 { font-size: 16px; margin: 28px 0 8px; }
.setup-card h3 { font-size: 14px; margin: 0 0 6px; color: var(--muted); font-weight: 600; }
.setup-card .hint { margin: -2px 0 6px; font-size: 13px; color: var(--muted); }
.setup-card code { background: var(--bg-3); padding: 1px 5px; border-radius: 4px; font-size: 12px; }
.lib { padding: 14px 0; border-top: 1px solid var(--line); }
.lib ul { list-style: none; margin: 0 0 10px; padding: 0; }
.lib li { display: flex; align-items: center; gap: 10px; padding: 6px 10px; background: var(--bg); border-radius: 8px; margin-bottom: 4px; font-size: 14px; }
.lib li span { flex: 1; overflow-wrap: anywhere; }
.lib li em { color: #ffb36b; font-style: normal; font-size: 12px; }
.lib li.none { color: var(--muted); background: none; padding-left: 0; }
.btn.small { padding: 6px 14px; font-size: 14px; }
.setup-card label { display: block; font-size: 13px; color: var(--muted); margin: 12px 0 4px; }
.setup-card input { width: 100%; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; }
.setup-card .small { font-size: 12px; }
.setup-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 8px; }
.key-row { display: flex; gap: 8px; align-items: center; }
.key-row input { flex: 1; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.setup-card a { color: var(--accent); }
.setup-card section > p { margin: 0 0 8px; }

/* ---------- TMDB details ---------- */
.overview { max-width: 680px; color: #c9d2dc; line-height: 1.6; margin: 0 0 18px; }
.rating { color: var(--accent); font-weight: 600; }
.backdrop {
  position: relative; margin: -24px calc(-1 * clamp(16px, 4vw, 48px)) 24px; height: clamp(180px, 34vw, 420px); overflow: hidden;
}
.backdrop img { width: 100%; height: 100%; object-fit: cover; display: block; opacity: 0.55; }
.backdrop::after { content: ''; position: absolute; inset: 0; background: linear-gradient(transparent 30%, var(--bg)); }
.has-backdrop .detail { margin-top: calc(-1 * clamp(110px, 18vw, 220px)); position: relative; }
.episode .o { color: var(--muted); font-size: 13px; margin-top: 2px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.credits { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; margin: -6px 0 18px; font-size: 14px; max-width: 680px; }
.credits dt { color: var(--muted); }
.credits dd { margin: 0; }

/* ---------- home hero ---------- */
.hero {
  position: relative; overflow: hidden; background: var(--bg-2);
  margin: calc(-24px - var(--header-h, 57px)) calc(-1 * clamp(16px, 4vw, 48px)) 12px;
  height: clamp(420px, 72vh, 720px);
}
.hero-slide { position: absolute; inset: 0; opacity: 0; visibility: hidden; transition: opacity 0.9s ease, visibility 0.9s; }
.hero-slide.active { opacity: 1; visibility: visible; }
.hero-slide > img {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: center 25%;
  transform: scale(1.04); transition: transform 9s ease-out;
}
.hero-slide.active > img { transform: scale(1); }
.hero-shade {
  position: absolute; inset: 0;
  background:
    linear-gradient(180deg, rgba(11, 13, 16, 0.6) 0%, rgba(11, 13, 16, 0) 22%),
    linear-gradient(90deg, rgba(11, 13, 16, 0.94) 0%, rgba(11, 13, 16, 0.7) 35%, rgba(11, 13, 16, 0) 68%),
    linear-gradient(0deg, var(--bg) 0%, rgba(11, 13, 16, 0) 38%);
}
.hero-body {
  position: absolute; left: clamp(16px, 4vw, 48px); bottom: clamp(56px, 10vh, 104px); width: min(580px, 88%);
}
.hero-label { color: var(--accent); font-size: 13px; font-weight: 600; letter-spacing: 0.02em; margin-bottom: 10px; }
.hero h2 { font-size: clamp(32px, 5.2vw, 60px); line-height: 1.02; letter-spacing: -0.03em; margin: 0 0 8px; font-weight: 700; }
.hero-sub { font-size: 17px; font-weight: 500; margin-bottom: 8px; }
.hero .meta { margin-bottom: 12px; color: #b9c3ce; }
.hero-overview {
  color: #c9d2dc; line-height: 1.55; margin: 0 0 18px; font-size: 15px;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.hero-progress { width: min(320px, 70%); height: 4px; background: rgba(232, 237, 242, 0.18); border-radius: 2px; overflow: hidden; margin: 0 0 20px; }
.hero-progress i { display: block; height: 100%; background: var(--accent); }
.btn.big { padding: 12px 26px; font-size: 16px; }
a.btn { display: inline-block; }
.hero .btn:not(.primary) { background: rgba(232, 237, 242, 0.14); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
.hero .btn:not(.primary):hover { background: rgba(232, 237, 242, 0.24); }
.hero-dots { position: absolute; right: clamp(16px, 4vw, 48px); bottom: clamp(60px, 10vh, 108px); display: flex; gap: 6px; }
.hero-dots button {
  width: 8px; height: 4px; padding: 0; border: 0; border-radius: 2px; background: rgba(232, 237, 242, 0.35);
  transition: width 0.3s, background 0.3s;
}
.hero-dots button::before { content: ''; position: absolute; } /* keep the hit area tidy */
.hero-dots button.active { width: 24px; background: var(--text); }
.hero + h2.row-title { margin-top: 0; }
@media (max-width: 680px) {
  .hero { height: min(78vh, 560px); }
  .hero-overview { display: none; }
  .hero-shade {
    background:
      linear-gradient(180deg, rgba(11, 13, 16, 0.6) 0%, rgba(11, 13, 16, 0) 25%),
      linear-gradient(0deg, var(--bg) 0%, rgba(11, 13, 16, 0.85) 38%, rgba(11, 13, 16, 0) 70%);
  }
  .hero-body { bottom: 48px; }
  .hero-dots { left: 0; right: 0; justify-content: center; bottom: 18px; }
  .btn.big { padding: 11px 20px; }
}
@media (prefers-reduced-motion: reduce) {
  .hero-slide, .hero-slide > img { transition: none; transform: none; }
}
.art-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.art-path { flex: 1; min-width: 200px; display: flex; flex-direction: column; gap: 2px; padding: 8px 12px; background: var(--bg); border-radius: 8px; font-size: 14px; overflow-wrap: anywhere; }
.setup-card label.check { display: flex; gap: 8px; align-items: center; color: var(--text); font-size: 14px; margin-top: 10px; }
.setup-card label.check input { width: auto; }
.warn { color: #ffb36b; }

/* ---------- scan progress ---------- */
.scanbar { position: absolute; left: 0; right: 0; bottom: -1px; pointer-events: none; }
.scanbar-track { height: 2px; background: rgba(108, 196, 255, 0.15); overflow: hidden; }
.scanbar-track i { display: block; height: 100%; width: 0; background: var(--accent); transition: width 0.5s ease; box-shadow: 0 0 10px var(--accent); }
.scanbar.indeterminate .scanbar-track i { width: 30% !important; animation: scan-slide 1.2s ease-in-out infinite; }
@keyframes scan-slide { from { transform: translateX(-100%); } to { transform: translateX(340%); } }
.scanbar-label {
  position: absolute; right: clamp(16px, 4vw, 48px); top: 10px; font-size: 12px; font-weight: 500; color: var(--text);
  background: rgba(20, 24, 29, 0.92); border: 1px solid var(--line); padding: 4px 12px; border-radius: 999px;
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); font-variant-numeric: tabular-nums;
}
.scanbar-label::before {
  content: ''; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--accent);
  margin-right: 8px; vertical-align: 1px; animation: scan-pulse 1.4s ease-in-out infinite;
}
@keyframes scan-pulse { 50% { opacity: 0.3; } }
@media (prefers-reduced-motion: reduce) { .scanbar.indeterminate .scanbar-track i, .scanbar-label::before { animation: none; } }

/* ---------- edit artwork panel ---------- */
.btn-icon { margin-right: 7px; display: inline-block; transform: translateY(-1px); }
.btn.ghost { background: none; color: var(--muted); }
.btn.ghost:hover { color: var(--text); background: var(--bg-3); }
.ae-scrim {
  position: fixed; inset: 0; z-index: 70; display: grid; place-items: center; padding: clamp(0px, 3vw, 32px);
  background: rgba(5, 7, 9, 0.72); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  animation: ae-fade 0.18s ease;
}
.ae-scrim.closing { animation: ae-fade 0.16s ease reverse forwards; }
@keyframes ae-fade { from { opacity: 0; } }
.ae {
  width: min(1180px, 100%); height: min(820px, 100%); display: flex; flex-direction: column; outline: none;
  background: linear-gradient(180deg, #161b21, #111519); border: 1px solid var(--line); border-radius: 20px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.55); overflow: hidden; animation: ae-rise 0.22s cubic-bezier(0.2, 0.8, 0.2, 1);
}
@keyframes ae-rise { from { transform: translateY(14px) scale(0.985); opacity: 0; } }
.ae.dropping { box-shadow: 0 0 0 2px var(--accent), 0 30px 80px rgba(0, 0, 0, 0.55); }
.ae-head { display: flex; align-items: center; gap: 16px; padding: 18px 22px; border-bottom: 1px solid var(--line); }
.ae-titles { flex: 1; min-width: 0; }
.ae-titles h2 { margin: 0; font-size: 19px; letter-spacing: -0.01em; }
.ae-titles .muted { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ae-seg { display: inline-flex; background: var(--bg); border: 1px solid var(--line); border-radius: 999px; padding: 3px; }
.ae-tab { border: 0; background: none; color: var(--muted); padding: 7px 18px; border-radius: 999px; font-weight: 600; font-size: 14px; }
.ae-tab[aria-selected="true"] { background: var(--bg-3); color: var(--text); box-shadow: 0 1px 0 rgba(255, 255, 255, 0.06) inset; }
.ae-close { font-size: 16px; }
.ae-body { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(240px, 34%) 1fr; }
.ae-preview {
  padding: 24px; border-right: 1px solid var(--line); display: flex; flex-direction: column; gap: 14px;
  align-items: center; justify-content: center; background: radial-gradient(circle at 50% 40%, rgba(108, 196, 255, 0.07), transparent 65%);
}
.ae-pv-poster { width: min(100%, 300px); aspect-ratio: 2 / 3; border-radius: 14px; overflow: hidden; background: var(--bg-3); box-shadow: 0 18px 50px rgba(0, 0, 0, 0.5); }
.ae-pv-wide { position: relative; width: 100%; aspect-ratio: 16 / 9; border-radius: 14px; overflow: hidden; background: var(--bg-3); box-shadow: 0 18px 50px rgba(0, 0, 0, 0.5); }
.ae-pv-poster img, .ae-pv-wide img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ae-pv-shade { position: absolute; inset: 0; background: linear-gradient(90deg, rgba(11, 13, 16, 0.85), rgba(11, 13, 16, 0) 65%); }
.ae-pv-title { position: absolute; left: 6%; bottom: 12%; right: 40%; font-size: clamp(16px, 2vw, 24px); font-weight: 700; letter-spacing: -0.02em; line-height: 1.1; }
.ae-pv-caption { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; justify-content: center; font-size: 13px; text-align: center; }
.ae-tag { font-size: 11px; padding: 2px 8px; border-radius: 999px; background: var(--bg-3); color: var(--muted); }
.ae-tag.new { background: rgba(108, 196, 255, 0.14); color: var(--accent); }
.ae.wide .ae-body { grid-template-columns: minmax(300px, 44%) 1fr; }
.ae-pick { min-height: 0; display: flex; flex-direction: column; }
.ae-filters { display: flex; gap: 6px; flex-wrap: wrap; padding: 16px 20px 12px; }
.ae-chip { border: 1px solid var(--line); background: none; color: var(--muted); border-radius: 999px; padding: 6px 12px; font-size: 13px; font-weight: 500; }
.ae-chip:hover { color: var(--text); }
.ae-chip.on { background: var(--text); color: var(--bg); border-color: var(--text); }
.ae-chip .n { margin-left: 6px; opacity: 0.6; font-variant-numeric: tabular-nums; }
.ae-grid {
  flex: 1; overflow-y: auto; padding: 4px 20px 20px; display: grid; gap: 14px; align-content: start;
  grid-template-columns: repeat(auto-fill, minmax(124px, 1fr)); scrollbar-width: thin;
}
.ae.wide .ae-grid { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
.ae-tile {
  position: relative; border: 0; padding: 0; background: none; text-align: left; border-radius: 12px;
  transition: transform 0.15s ease;
}
.ae-tile:hover { transform: translateY(-2px); }
.ae-tile .ae-img {
  position: relative; aspect-ratio: 2 / 3; border-radius: 12px; overflow: hidden; background: var(--bg-3);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.04); transition: box-shadow 0.15s ease;
}
.ae.wide .ae-tile .ae-img { aspect-ratio: 16 / 9; }
.ae-tile img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ae-tile.broken img { display: none; }
.ae-tile.on .ae-img { box-shadow: 0 0 0 2px var(--accent), 0 8px 24px rgba(108, 196, 255, 0.18); }
.ae-meta { display: flex; flex-direction: column; margin-top: 7px; font-size: 12px; line-height: 1.35; }
.ae-meta span:first-child { font-weight: 600; }
.ae-meta .muted { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ae-check {
  position: absolute; top: 8px; right: 8px; width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center;
  background: var(--accent); color: var(--accent-ink); font-size: 13px; font-weight: 800; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}
.ae-current {
  position: absolute; top: 8px; left: 8px; font-size: 10px; font-weight: 700; letter-spacing: 0.03em; text-transform: uppercase;
  padding: 3px 7px; border-radius: 6px; background: rgba(11, 13, 16, 0.75); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
}
.ae-auto {
  position: absolute; inset: auto 8px 8px 8px; text-align: center; font-size: 11px; font-weight: 700; padding: 4px; border-radius: 6px;
  background: rgba(11, 13, 16, 0.72); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
}
.ae-del {
  position: absolute; bottom: 52px; right: 8px; min-width: 24px; height: 24px; padding: 0 7px; border-radius: 999px; display: grid; place-items: center;
  background: rgba(11, 13, 16, 0.8); color: var(--text); font-size: 12px; font-weight: 600; opacity: 0; transition: opacity 0.15s;
}
.ae-tile:hover .ae-del, .ae-del:focus, .ae-del.confirm { opacity: 1; }
.ae-del.confirm { background: #e5484d; }
.ae-upload .ae-img { box-shadow: none; border: 1.5px dashed #33404d; background: rgba(108, 196, 255, 0.03); display: grid; place-items: center; }
.ae-upload:hover .ae-img, .ae.dropping .ae-upload .ae-img { border-color: var(--accent); background: rgba(108, 196, 255, 0.08); }
.ae-up-inner { display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 12px; text-align: center; padding: 8px; }
.ae-up-icon { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; font-size: 20px; background: var(--bg-3); color: var(--accent); margin-bottom: 4px; }
.ae-uploading .ae-img { display: grid; place-items: center; }
.ae-uploading .p-spinner { position: static; margin: 0; width: 32px; height: 32px; }
.ae-foot { display: flex; align-items: center; gap: 10px; padding: 14px 22px; border-top: 1px solid var(--line); }
.ae-foot .spacer { flex: 1; }
.ae-foot .btn { white-space: nowrap; }
@media (max-width: 760px) { .ae-foot { padding: 12px 14px; gap: 8px; } .ae-foot .btn { padding: 10px 16px; } }
@media (max-width: 760px) {
  .ae-scrim { padding: 0; }
  .ae { border-radius: 0; height: 100%; }
  .ae-head { flex-wrap: wrap; padding: 14px 16px; }
  .ae-seg { order: 3; width: 100%; }
  .ae-tab { flex: 1; }
  .ae-body, .ae.wide .ae-body { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .ae-preview { border-right: 0; border-bottom: 1px solid var(--line); padding: 14px; flex-direction: row; }
  .ae-pv-poster { width: 92px; }
  .ae-pv-wide { width: 52%; }
  .ae-pv-caption { flex-direction: column; align-items: flex-start; text-align: left; }
  .ae-grid { grid-template-columns: repeat(3, 1fr); gap: 10px; padding: 4px 14px 14px; }
  .ae.wide .ae-grid { grid-template-columns: repeat(2, 1fr); }
  .ae-filters { flex-wrap: nowrap; overflow-x: auto; padding: 12px 14px 10px; }
  .ae-chip { white-space: nowrap; }
}
@media (prefers-reduced-motion: reduce) { .ae, .ae-scrim, .ae-tile { animation: none; transition: none; } }
.setup-card .pin-input { max-width: 340px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.ae-skel { animation: ae-pulse 1.2s ease-in-out infinite; }
@keyframes ae-pulse { 50% { opacity: 0.55; } }
.ae-loading { grid-column: 1 / -1; display: flex; align-items: center; justify-content: center; gap: 12px; padding: 60px 0; color: var(--muted); }
.ae-loading .p-spinner { position: static; margin: 0; width: 26px; height: 26px; border-width: 3px; }
.ae-tile .ae-img::after { content: ''; position: absolute; inset: 0; background: linear-gradient(110deg, transparent 30%, rgba(255,255,255,0.04) 50%, transparent 70%); animation: ae-shimmer 1.4s linear infinite; pointer-events: none; }
.ae-tile .ae-img:has(img[data-loaded])::after, .ae-upload .ae-img::after, .ae-tile.broken .ae-img::after { display: none; }
@keyframes ae-shimmer { from { transform: translateX(-100%); } to { transform: translateX(100%); } }

/* ---------- settings tabs ---------- */
.setup-card.tabbed { max-width: 940px; display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: 0 32px; }
.setup-card.tabbed > header, .setup-card.tabbed > .err, .setup-card.tabbed > .setup-actions { grid-column: 1 / -1; }
.setup-card.tabbed > .st-tabs { grid-column: 1; grid-row: 2 / span 20; }
.setup-card.tabbed > section { grid-column: 2; }
.setup-card.tabbed > section h2:first-child { margin-top: 4px; }
.st-tabs { display: flex; flex-direction: column; gap: 2px; position: sticky; top: 16px; align-self: start; margin-top: 20px; }
.st-tabs [role=tab] {
  display: flex; align-items: center; gap: 10px; text-align: left; border: 0; background: none; color: var(--muted);
  padding: 9px 12px; border-radius: 9px; font-weight: 600; font-size: 14px;
}
.st-tabs [role=tab] span { width: 18px; text-align: center; opacity: 0.8; }
.st-tabs [role=tab]:hover { color: var(--text); background: rgba(255, 255, 255, 0.04); }
.st-tabs [role=tab][aria-selected="true"] { color: var(--text); background: var(--bg-3); box-shadow: inset 2px 0 0 var(--accent); }
.setup-card.tabbed .setup-actions { position: sticky; bottom: 0; margin: 24px -36px -28px; padding: 14px 36px; background: rgba(20, 24, 29, 0.96);
  border-top: 1px solid var(--line); border-radius: 0 0 16px 16px; backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
.about-list { display: grid; grid-template-columns: max-content 1fr; gap: 10px 20px; font-size: 14px; margin: 8px 0 16px; }
.about-list dt { color: var(--muted); }
.about-list dd { margin: 0; overflow-wrap: anywhere; }
@media (max-width: 760px) {
  .setup-card.tabbed { display: block; }
  .st-tabs { flex-direction: row; overflow-x: auto; position: static; margin: 16px -4px 8px; gap: 4px; scrollbar-width: none; }
  .st-tabs [role=tab] { white-space: nowrap; padding: 8px 12px; }
  .st-tabs [role=tab][aria-selected="true"] { box-shadow: inset 0 -2px 0 var(--accent); }
  .setup-card.tabbed .setup-actions { margin: 20px -20px -28px; padding: 12px 20px; }
}

/* ---------- movie versions ---------- */
.versions { display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0 16px; align-items: stretch; }
.versions-head { width: 100%; font-size: 12px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); }
.version {
  display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; gap: 2px 12px; align-items: center; text-align: left;
  background: rgba(29, 35, 42, 0.7); border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; min-width: 220px;
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); transition: border-color 0.15s, background 0.15s;
}
.version:hover { border-color: #3a4652; }
.version.on { border-color: var(--accent); background: rgba(108, 196, 255, 0.1); }
.v-res { grid-row: 1 / span 2; font-size: 20px; font-weight: 800; letter-spacing: -0.02em; display: flex; flex-direction: column; align-items: flex-start; line-height: 1.05; }
.v-hdr { font-size: 10px; font-weight: 800; color: #ffd36b; letter-spacing: 0.06em; margin-top: 2px; }
.v-label { font-size: 13px; font-weight: 500; }
.v-size { font-size: 12px; }
.v-best { grid-column: 1 / -1; justify-self: start; margin-top: 6px; font-size: 11px; font-weight: 700; color: var(--accent-ink); background: var(--accent); padding: 2px 8px; border-radius: 999px; }

/* ---------- movie page: Poster wall ---------- */
.pw, .ss { position: relative; margin: calc(-24px - var(--header-h, 57px)) calc(-1 * clamp(16px, 4vw, 48px)) 0; }
.pw {
  --gut: clamp(16px, 4vw, 72px);
  --ph: min(calc(100vh - var(--header-h, 57px) - 96px), 1150px);
  min-height: 100vh; overflow: hidden; display: grid; grid-template-columns: auto minmax(0, 1fr);
  gap: clamp(28px, 4vw, 88px); align-items: center;
  padding: calc(var(--header-h, 57px) + 40px) var(--gut) 56px;
}
.pw-bg, .ss-bg { position: absolute; inset: 0; z-index: 0; background: var(--bg); }
.pw-bg img, .ss-bg img { width: 100%; height: 100%; object-fit: cover; object-position: center 25%; display: block; }
.pw-bg img { filter: blur(1.5px) saturate(1.12); transform: scale(1.03); }
.pw-bg::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(0deg, var(--bg) 0%, rgba(11,13,16,0) 28%), linear-gradient(180deg, rgba(11,13,16,0.6) 0%, rgba(11,13,16,0) 18%),
    linear-gradient(90deg, rgba(11,13,16,0.3) 0%, rgba(11,13,16,0.62) 40%, rgba(11,13,16,0.74) 100%);
}
.pw-poster {
  position: relative; z-index: 1; width: min(42vw, calc(var(--ph) * 2 / 3)); aspect-ratio: 2 / 3;
  border-radius: 18px; overflow: hidden; background: var(--bg-3);
  box-shadow: 0 40px 100px rgba(0, 0, 0, 0.65), 0 0 0 1px rgba(255, 255, 255, 0.07);
}
.pw-poster img { width: 100%; height: 100%; object-fit: cover; display: block; }
.pw-info { position: relative; z-index: 1; max-width: 900px; }
.pw-label { color: var(--accent); font-weight: 650; font-size: clamp(13px, 1vw, 16px); letter-spacing: 0.02em; margin-bottom: 12px; }
.pw h1 { font-size: clamp(36px, 4.8vw, 88px); line-height: 1.02; letter-spacing: -0.035em; margin: 0 0 14px; font-weight: 750; }
.pw .meta { font-size: clamp(14px, 1.1vw, 19px); color: #b9c3ce; margin-bottom: 20px; }
.pw-overview { font-size: clamp(15px, 1.15vw, 20px); line-height: 1.6; color: #d3dbe4; max-width: 62ch; margin: 0 0 24px; }
.pw-progress { height: 5px; width: min(440px, 70%); background: rgba(232, 237, 242, 0.15); border-radius: 3px; overflow: hidden; margin: 0 0 24px; }
.pw-progress i, .ss .bar { display: block; height: 100%; background: var(--accent); }
.pw .actions, .ss .actions { margin-bottom: 26px; gap: 12px; }
.pw .btn:not(.primary), .ss-info .btn:not(.primary) { background: rgba(232, 237, 242, 0.12); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
.pw .btn:not(.primary):hover, .ss-info .btn:not(.primary):hover { background: rgba(232, 237, 242, 0.22); }
.pw .versions { margin-bottom: 22px; }
.pw .credits { margin: 0 0 18px; font-size: clamp(14px, 1vw, 17px); }
.pw .tech { font-size: 13px; color: #8b97a5; }
@media (min-width: 1900px) { .btn.big { padding: 15px 32px; font-size: 18px; } }
@media (max-width: 760px) {
  .pw { grid-template-columns: 1fr; min-height: 0; padding: calc(var(--header-h, 57px) + 18px) 18px 32px; gap: 22px; }
  .pw-poster { width: min(62vw, 300px); justify-self: center; }
  .pw-bg::after { background: linear-gradient(0deg, var(--bg) 0%, rgba(11,13,16,0.86) 45%, rgba(11,13,16,0.55) 100%); }
}

/* ---------- TV show page: Season shelf ---------- */
.ss { --gut: clamp(16px, 4vw, 72px); }
.ss-hero {
  position: relative; overflow: hidden; min-height: min(74vh, 860px);
  display: grid; grid-template-columns: auto minmax(0, 1fr) minmax(300px, 30vw); gap: clamp(20px, 3vw, 60px); align-items: end;
  padding: calc(var(--header-h, 57px) + 48px) var(--gut) clamp(28px, 4vh, 52px);
}
.ss-bg::after {
  content: ''; position: absolute; inset: 0;
  /* first layer paints on top: the fade into the page must come first, or a seam shows */
  background: linear-gradient(0deg, var(--bg) 0%, rgba(11,13,16,0.92) 8%, rgba(11,13,16,0.55) 26%, rgba(11,13,16,0) 58%),
    linear-gradient(180deg, rgba(11,13,16,0.6) 0%, rgba(11,13,16,0) 20%),
    linear-gradient(90deg, rgba(11,13,16,0.88) 0%, rgba(11,13,16,0.55) 45%, rgba(11,13,16,0.35) 100%);
}
.ss-poster, .ss-info, .ss-next { position: relative; z-index: 1; }
.ss-poster { width: clamp(150px, 15vw, 320px); aspect-ratio: 2 / 3; border-radius: 16px; overflow: hidden; background: var(--bg-3);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(255, 255, 255, 0.07); }
.ss-poster img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ss-info h1 { font-size: clamp(32px, 4.2vw, 76px); line-height: 1.02; letter-spacing: -0.035em; margin: 0 0 12px; font-weight: 750; }
.ss-info .meta { font-size: clamp(14px, 1.05vw, 18px); color: #c3ccd6; margin-bottom: 16px; }
.ss-overview { font-size: clamp(15px, 1.05vw, 18px); line-height: 1.55; color: #d3dbe4; max-width: 64ch; margin: 0 0 22px;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.ss-info .actions { margin-bottom: 0; }
.ss-next {
  text-align: left; border: 1px solid rgba(255, 255, 255, 0.08); border-radius: 16px; padding: 10px; color: var(--text);
  background: rgba(20, 24, 29, 0.78); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); transition: transform 0.15s, border-color 0.15s;
}
.ss-next:hover { transform: translateY(-3px); border-color: rgba(108, 196, 255, 0.45); }
.ss-next-art { position: relative; aspect-ratio: 16 / 9; border-radius: 10px; overflow: hidden; background: var(--bg-3); }
.ss-next-art img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ss .bar { position: absolute; left: 0; bottom: 0; height: 4px; }
.ss-play {
  position: absolute; left: 50%; top: 50%; width: 52px; height: 52px; margin: -26px; border-radius: 50%; display: grid; place-items: center;
  background: rgba(11, 13, 16, 0.6); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); font-size: 18px; padding-left: 3px;
  opacity: 0; transition: opacity 0.15s;
}
.ss-next:hover .ss-play { opacity: 1; }
.ss-next-text { padding: 10px 6px 4px; }
.ss-next-label { color: var(--accent); font-size: 12px; font-weight: 700; letter-spacing: 0.03em; text-transform: uppercase; }
.ss-next-title { font-weight: 650; font-size: clamp(15px, 1.1vw, 19px); margin: 4px 0; }
.ss-next-o { color: var(--muted); font-size: 13px; line-height: 1.45; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.ss-bar { display: flex; align-items: center; gap: 16px; padding: 6px var(--gut) 0; }
.ss-seasons { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; flex: 1; }
.ss-seasons button {
  border: 1px solid var(--line); background: none; color: var(--muted); border-radius: 999px; padding: 8px 16px;
  font-weight: 600; font-size: 14px; white-space: nowrap;
}
.ss-seasons button:hover { color: var(--text); }
.ss-seasons button.on { background: var(--text); color: var(--bg); border-color: var(--text); }
.ss-seasons .n { margin-left: 7px; opacity: 0.55; font-variant-numeric: tabular-nums; }
.ss-arrows { display: flex; gap: 4px; }
.ss-arrows .icon-btn { font-size: 26px; width: 40px; height: 40px; border-radius: 50%; background: rgba(232, 237, 242, 0.08); line-height: 1; }
.ss-shelf {
  display: grid; grid-auto-flow: column; grid-auto-columns: clamp(250px, 22vw, 440px); gap: clamp(14px, 1.4vw, 24px);
  overflow-x: auto; scroll-snap-type: x proximity; scroll-padding: 0 var(--gut); padding: 16px var(--gut) 36px; scrollbar-width: thin;
}
.ss-ep { text-align: left; border: 0; padding: 0; background: none; color: var(--text); scroll-snap-align: start; }
.ss-ep-art { position: relative; aspect-ratio: 16 / 9; border-radius: 12px; overflow: hidden; background: var(--bg-3);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35); transition: transform 0.15s, box-shadow 0.15s; }
.ss-ep:hover .ss-ep-art { transform: translateY(-3px); box-shadow: 0 14px 34px rgba(0, 0, 0, 0.5); }
.ss-ep.next .ss-ep-art { box-shadow: 0 0 0 2px var(--accent), 0 10px 30px rgba(108, 196, 255, 0.18); }
.ss-ep-art img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ss-check { position: absolute; top: 8px; right: 8px; width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center;
  background: rgba(11, 13, 16, 0.75); font-size: 12px; font-weight: 800; }
.ss-dur { position: absolute; right: 8px; bottom: 10px; font-size: 11px; font-weight: 600; padding: 2px 7px; border-radius: 6px; background: rgba(11, 13, 16, 0.75); }
.ss-ep-title { margin-top: 10px; font-size: clamp(14px, 1vw, 17px); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ss-ep-title b { color: var(--muted); font-weight: 700; margin-right: 2px; }
.ss-ep-o { margin-top: 4px; color: var(--muted); font-size: 13px; line-height: 1.45; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
@media (max-width: 1100px) { .ss-hero { grid-template-columns: auto minmax(0, 1fr); } .ss-next { grid-column: 1 / -1; display: grid; grid-template-columns: minmax(160px, 40%) 1fr; gap: 12px; align-items: center; } }
@media (max-width: 760px) {
  .ss-hero { grid-template-columns: 1fr; min-height: 0; padding: calc(var(--header-h, 57px) + 18px) 18px 24px; gap: 18px; }
  .ss-poster { width: min(42vw, 180px); }
  .ss-next { grid-template-columns: 1fr; }
  .ss-bg::after { background: linear-gradient(0deg, var(--bg) 0%, rgba(11,13,16,0.85) 50%, rgba(11,13,16,0.5) 100%); }
  .ss-arrows { display: none; }
  .ss-shelf { grid-auto-columns: 78vw; padding: 12px 18px 28px; }
  .ss-bar { padding: 4px 18px 0; }
}

/* the top menu never overflows: the search box gives way first */
#search { flex: 0 1 260px; min-width: 110px; width: auto; }
.top { min-width: 0; }
@media (max-width: 900px) { .top { gap: 12px; } .top nav a { padding: 6px 9px; } }

/* episode row: no scrollbar (the ‹ › arrows, swiping and trackpads still scroll it) */
.ss-shelf { scrollbar-width: none; }
.ss-shelf::-webkit-scrollbar { display: none; }

/* ---------- TV show page: Immersive ---------- */
.im {
  --gut: clamp(16px, 4vw, 72px);
  min-height: 100vh; display: flex; flex-direction: column; justify-content: flex-end; overflow: hidden; /* details sit just above the episodes */
}
.im-bg { position: absolute; inset: 0; z-index: 0; background: var(--bg); }
.im-bg img { width: 100%; height: 100%; object-fit: cover; object-position: center 22%; display: block; }
.im-bg::after {
  content: ''; position: absolute; inset: 0;
  /* darker toward the bottom-left, where the title now sits */
  background: linear-gradient(180deg, rgba(11,13,16,0.65) 0%, rgba(11,13,16,0) 18%),
    linear-gradient(0deg, rgba(11,13,16,0.55) 0%, rgba(11,13,16,0) 55%),
    linear-gradient(90deg, rgba(11,13,16,0.82) 0%, rgba(11,13,16,0.55) 34%, rgba(11,13,16,0.08) 70%, rgba(11,13,16,0) 100%);
}
.im-info { position: relative; z-index: 1; max-width: min(880px, 62vw); padding: calc(var(--header-h, 57px) + 24px) var(--gut) clamp(10px, 1.6vh, 20px); }
.im-info h1 { font-size: clamp(36px, 5vw, 96px); line-height: 1.0; letter-spacing: -0.035em; margin: 0 0 14px; font-weight: 750; text-shadow: 0 2px 30px rgba(0,0,0,0.35); }
.im-info .meta { font-size: clamp(14px, 1.1vw, 19px); color: #c9d2dc; margin-bottom: 18px; }
.im-overview { font-size: clamp(15px, 1.15vw, 20px); line-height: 1.55; color: #dde3ea; max-width: 60ch; margin: 0;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.im-info .actions { margin: 0; gap: 12px; }
.im-info .btn:not(.primary) { background: rgba(232, 237, 242, 0.14); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
.im-info .btn:not(.primary):hover { background: rgba(232, 237, 242, 0.24); }
.im-strip {
  position: relative; z-index: 1; padding-top: 14px;
  background: rgba(13, 16, 20, 0.72); backdrop-filter: blur(22px) saturate(1.2); -webkit-backdrop-filter: blur(22px) saturate(1.2);
  border-top: 1px solid rgba(255, 255, 255, 0.07);
}
.im .ss-bar { padding: 0 var(--gut); }
.im .ss-seasons button { background: rgba(232, 237, 242, 0.06); border-color: rgba(255, 255, 255, 0.1); }
.im .ss-seasons button.on { background: var(--text); color: var(--bg); border-color: var(--text); }
.im .ss-shelf { padding: 14px var(--gut) 26px; grid-auto-columns: clamp(240px, 19vw, 400px); }
.im .ss-ep-o { -webkit-line-clamp: 1; }
@media (max-height: 760px) and (min-width: 761px) { .im .ss-ep-o { display: none; } .im-info { padding-bottom: 20px; } }
@media (max-width: 760px) {
  .im { min-height: 0; }
  .im-bg { bottom: auto; height: 62vh; }
  .im-bg::after { background: linear-gradient(0deg, var(--bg) 0%, rgba(11,13,16,0.85) 40%, rgba(11,13,16,0.4) 100%); }
  .im-info { max-width: none; padding: calc(var(--header-h, 57px) + 34vh) 18px 22px; }
  .im-strip { background: none; backdrop-filter: none; -webkit-backdrop-filter: none; border: 0; }
  .im .ss-bar { padding: 0 18px; }
  .im .ss-shelf { grid-auto-columns: 78vw; padding: 12px 18px 28px; }
  .im .ss-ep-o { -webkit-line-clamp: 2; }
}
/* the Immersive page is exactly one screen tall (no spare room kept below it) */
@media (min-width: 761px) {
  body:has(.im) { padding-bottom: 0; }
  main:has(.im) { padding-bottom: 0; }
  body:has(.im):has(#musicbar:not([hidden])) .im-strip { padding-bottom: 76px; } /* clear the music bar when it's showing */
}

/* show title with its pencil, and the play button down in the season bar */
.im-info h1.im-title { margin: 0 0 14px; }
.im-edit {
  flex: none; width: clamp(36px, 2.4vw, 48px); height: clamp(36px, 2.4vw, 48px); border-radius: 50%; border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(232, 237, 242, 0.1); color: var(--text); font-size: clamp(16px, 1.1vw, 21px); display: inline-grid; place-items: center;
  vertical-align: middle; position: relative; top: -0.08em; letter-spacing: 0; font-weight: 400;
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); opacity: 0.75; transition: opacity 0.15s, background 0.15s, transform 0.15s;
}
.im-edit:hover, .im-edit:focus-visible { opacity: 1; background: rgba(232, 237, 242, 0.22); transform: scale(1.06); }
.im .ss-bar { gap: clamp(12px, 1.2vw, 20px); }
.im-play { flex: none; padding: 10px 22px; font-size: clamp(14px, 0.95vw, 17px); white-space: nowrap; }
.im-divider { flex: none; width: 1px; height: 30px; background: rgba(255, 255, 255, 0.28); }
.im .ss-seasons button { font-weight: 750; letter-spacing: -0.01em; color: #c9d2dc; }
@media (max-width: 760px) {
  .im .ss-bar { flex-wrap: wrap; }
  .im-play { width: 100%; }
  .im-divider { display: none; }
}

/* a pencil on each episode picture (shows on hover or keyboard focus) */
.ss-ep-wrap { position: relative; scroll-snap-align: start; }
.ss-ep-edit {
  position: absolute; top: 8px; left: 8px; width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.18); background: rgba(11, 13, 16, 0.7); color: var(--text); font-size: 15px;
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); opacity: 0; transform: translateY(-3px) scale(0.92);
  transition: opacity 0.15s, transform 0.15s, background 0.15s;
}
.ss-ep-wrap:hover .ss-ep-edit, .ss-ep-edit:focus-visible { opacity: 1; transform: translateY(-3px); }
.ss-ep-edit:hover { background: rgba(40, 46, 54, 0.9); }
@media (hover: none) { .ss-ep-edit { opacity: 0.85; transform: none; } }
.ae-seg.single { padding: 7px 16px; font-weight: 600; font-size: 14px; color: var(--muted); }

/* episode row: hold-to-glide arrows, fading ends, and a TV-style focus for keyboards and remotes */
.ss-shelf.gliding { scroll-snap-type: none; }
.ss-arrows .icon-btn { transition: opacity 0.2s, background 0.15s, transform 0.1s; touch-action: none; user-select: none; -webkit-user-select: none; }
.ss-arrows .icon-btn:hover { background: rgba(232, 237, 242, 0.18); }
.ss-arrows .icon-btn:active { transform: scale(0.92); }
.ss-arrows .icon-btn.dim { opacity: 0.28; pointer-events: none; }
.ss-arrows.fits { visibility: hidden; }
.ss-ep:focus-visible { outline: none; }
.ss-ep:focus-visible .ss-ep-art {
  transform: translateY(-4px) scale(1.03);
  box-shadow: 0 0 0 3px var(--text), 0 18px 44px rgba(0, 0, 0, 0.6);
}
.ss-ep:focus-visible .ss-ep-title { color: var(--text); }
.ss-ep-wrap:focus-within .ss-ep-edit { opacity: 1; transform: translateY(-3px); }
.im .ss-shelf { padding-top: 18px; } /* room for the focus lift */
@keyframes bump-l { 30% { transform: translateX(14px); } }
@keyframes bump-r { 30% { transform: translateX(-14px); } }
.ss-shelf.bump-l > * { animation: bump-l 0.32s ease-out; }
.ss-shelf.bump-r > * { animation: bump-r 0.32s ease-out; }
@media (prefers-reduced-motion: reduce) {
  .ss-shelf.bump-l > *, .ss-shelf.bump-r > * { animation: none; }
  .ss-ep:focus-visible .ss-ep-art { transform: none; }
}

/* ---------- player: quality menu ---------- */
.p-quality { max-width: 110px; }

/* ---------- header menu: who's signed in ---------- */
.menu-who { padding: 8px 14px 6px; font-size: 12px; color: var(--muted); border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.menu-who:empty { display: none; }
.login-hint { margin: -4px 0 6px; }

/* ---------- Settings: people ---------- */
.people { list-style: none; padding: 0; margin: 12px 0; display: grid; gap: 8px; }
.person { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; flex-wrap: wrap; }
.person.off { opacity: 0.6; }
.p-who { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 180px; }
.p-who input { max-width: 260px; }
.p-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.btn.danger { border-color: #e5484d; color: #ff8589; }
.people-add { margin-top: 16px; }
.invite { margin-top: 14px; padding: 14px; border-radius: 12px; background: rgba(108, 196, 255, 0.08); border: 1px solid rgba(108, 196, 255, 0.3); }
.invite pre { margin: 10px 0; padding: 10px 12px; background: var(--bg); border-radius: 8px; white-space: pre-wrap; user-select: all; font-size: 13px; }
.invite .btn { margin-right: 6px; }

/* ---------- Settings: remote access ---------- */
.remote-status { margin: 16px 0; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line); }
.rs-head { display: flex; align-items: center; gap: 10px; }
.rs-head .btn { margin-left: auto; }
.rs-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); flex: none; }
.remote-status[data-state="ok"] .rs-dot { background: #3dd68c; }
.remote-status[data-state="starting"] .rs-dot { background: #f5c451; animation: rs-pulse 1s infinite alternate; }
.remote-status[data-state="error"] .rs-dot { background: #e5484d; }
.remote-status p { margin: 8px 0 0; }
@keyframes rs-pulse { to { opacity: 0.3; } }
.steps { padding-left: 20px; display: grid; gap: 10px; line-height: 1.5; }
.rs-ok { color: #3dd68c; font-weight: 600; margin-left: 4px; }
.streams { list-style: none; padding: 0; margin: 8px 0; display: grid; gap: 6px; font-size: 14px; }
.setup-card select { width: 100%; background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; font: inherit; }
.setup-card input[type="checkbox"] { width: auto; }

/* ---------- Settings: transcoding monitor ---------- */
.tc-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(112px, 1fr)); gap: 10px; margin: 14px 0; }
.tc-tile { display: flex; flex-direction: column; gap: 2px; padding: 12px 14px; border-radius: 12px; background: rgba(232, 237, 242, 0.04); border: 1px solid var(--line); }
.tc-tile strong { font-size: 26px; font-weight: 700; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; line-height: 1.15; }
.tc-tile strong.tc-enc { font-size: 15px; line-height: 1.6; }
.tc-k { font-size: 12px; color: var(--muted); }
.tc-graph { margin: 4px 0 8px; padding: 10px 12px 8px; border-radius: 12px; border: 1px solid var(--line); background: rgba(232, 237, 242, 0.02); }
.tc-graph svg { width: 100%; height: 90px; display: block; overflow: visible; }
.tc-graph .grid { stroke: rgba(255, 255, 255, 0.06); stroke-width: 1; vector-effect: non-scaling-stroke; }
.tc-graph .gpu-area { fill: rgba(108, 196, 255, 0.14); }
.tc-graph .gpu-line { fill: none; stroke: #6cc4ff; stroke-width: 1.5; vector-effect: non-scaling-stroke; }
.tc-graph .conv-line { fill: none; stroke: #81d8d0; stroke-width: 2; vector-effect: non-scaling-stroke; }
.tc-graph figcaption { display: flex; gap: 14px; font-size: 12px; margin-top: 6px; }
.tc-graph figcaption span::before { content: ''; display: inline-block; width: 10px; height: 3px; border-radius: 2px; margin-right: 6px; vertical-align: middle; }
.tc-graph .lg-gpu::before { background: #6cc4ff; }
.tc-graph .lg-conv::before { background: #81d8d0; }
.tc-graph figcaption .muted { margin-left: auto; }
.tc-graph figcaption .muted::before { display: none; }
.tc-streams, .tc-history { list-style: none; padding: 0; margin: 8px 0 16px; display: grid; gap: 10px; }
.tc-stream { padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line); display: grid; gap: 6px; }
.tc-stream.st-converting { border-color: rgba(108, 196, 255, 0.35); }
.tc-stream.st-failed { border-color: rgba(229, 72, 77, 0.6); }
.tc-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.tc-head strong { font-size: 15px; margin-right: 4px; }
.tc-head .btn { margin-left: auto; }
.tc-chip { font-size: 12px; padding: 2px 8px; border-radius: 999px; background: rgba(232, 237, 242, 0.08); color: #c9d2dc; white-space: nowrap; }
.tc-chip.state.converting { background: rgba(108, 196, 255, 0.16); color: #9fd8ff; }
.tc-chip.state.ahead { background: rgba(129, 216, 208, 0.14); color: #a9e6df; }
.tc-chip.state.failed { background: rgba(229, 72, 77, 0.18); color: #ff9a9d; }
.tc-line { font-size: 14px; display: flex; flex-wrap: wrap; gap: 4px 6px; align-items: center; }
.tc-line.small { font-size: 12px; }
.tc-bar { position: relative; height: 6px; border-radius: 3px; background: rgba(232, 237, 242, 0.08); margin: 4px 0 2px; }
.tc-bar .tc-ready { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 3px; background: linear-gradient(90deg, rgba(108, 196, 255, 0.35), rgba(108, 196, 255, 0.6)); transition: width 0.6s; }
.tc-bar .tc-pos { position: absolute; top: -3px; width: 3px; height: 12px; border-radius: 2px; background: var(--text); transform: translateX(-1px); transition: left 0.6s; }
.tc-history li { font-size: 13px; padding: 8px 12px; border-radius: 10px; background: rgba(232, 237, 242, 0.03); }
.tc-history li.failed { background: rgba(229, 72, 77, 0.08); }
.tc-history .warn { margin-top: 4px; font-family: ui-monospace, Menlo, monospace; word-break: break-word; }
.tc-form { display: grid; gap: 2px; }

/* ---------- sign-in: cinematic, with "Who's watching?" ---------- */
body.lg { min-height: 100vh; margin: 0; overflow: hidden; background: #0b0d10; color: var(--text); }
.lg-bg { position: fixed; inset: 0; overflow: hidden; }
.lg-aurora {
  position: absolute; inset: -20%;
  background:
    radial-gradient(40% 50% at 20% 30%, rgba(108, 196, 255, 0.28), transparent 70%),
    radial-gradient(35% 45% at 80% 25%, rgba(129, 216, 208, 0.2), transparent 70%),
    radial-gradient(45% 55% at 60% 85%, rgba(150, 120, 255, 0.18), transparent 70%),
    #0b0d10;
  filter: blur(20px); animation: lg-drift 24s ease-in-out infinite alternate;
}
.lg-bg.has-art .lg-aurora { opacity: 0; transition: opacity 2s; }
@keyframes lg-drift { from { transform: translate(-3%, -2%) rotate(0deg) scale(1); } to { transform: translate(3%, 2%) rotate(8deg) scale(1.08); } }
.lg-art { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0; transition: opacity 2.4s ease;
  animation: lg-kenburns 20s ease-out forwards; }
.lg-art.alt { animation-name: lg-kenburns-alt; }
.lg-art.in { opacity: 1; }
@keyframes lg-kenburns { from { transform: scale(1.12) translate(1.5%, 1%); } to { transform: scale(1.02) translate(-1%, -0.5%); } }
@keyframes lg-kenburns-alt { from { transform: scale(1.02) translate(-1.5%, 0); } to { transform: scale(1.12) translate(1%, -1%); } }
.lg-shade { position: fixed; inset: 0; pointer-events: none;
  background: radial-gradient(120% 90% at 50% 45%, rgba(11, 13, 16, 0.35) 0%, rgba(11, 13, 16, 0.82) 70%, rgba(11, 13, 16, 0.95) 100%); }
.lg-main { position: relative; min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: clamp(20px, 4vh, 44px); padding: 24px; box-sizing: border-box; }
.lg-brand { position: absolute; top: clamp(18px, 4vh, 40px); left: clamp(18px, 4vw, 56px); display: flex; align-items: center; gap: 10px;
  font-weight: 700; font-size: 18px; letter-spacing: -0.01em; }
.lg-pick { text-align: center; animation: lg-rise 0.5s ease both; }
.lg-pick h1 { font-size: clamp(30px, 4.2vw, 60px); font-weight: 750; letter-spacing: -0.035em; margin: 0 0 clamp(24px, 4vh, 44px);
  text-shadow: 0 2px 30px rgba(0, 0, 0, 0.4); }
.lg-people { display: flex; flex-wrap: wrap; justify-content: center; gap: clamp(16px, 2.4vw, 36px); max-width: 1100px; }
.lg-person { display: flex; flex-direction: column; align-items: center; gap: 10px; background: none; border: 0; color: var(--text);
  padding: 6px; border-radius: 22px; cursor: pointer; width: clamp(110px, 11vw, 170px); }
.lg-avatar { --c: #6cc4ff; width: clamp(96px, 9.5vw, 150px); aspect-ratio: 1; border-radius: 28%; display: grid; place-items: center;
  font-size: clamp(40px, 4vw, 64px); font-weight: 750; color: #0b0d10;
  background: linear-gradient(145deg, color-mix(in srgb, var(--c) 88%, white), color-mix(in srgb, var(--c) 70%, #0b0d10));
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.35);
  transition: transform 0.18s ease, box-shadow 0.18s ease; }
.lg-avatar.plus { background: rgba(232, 237, 242, 0.08); color: var(--text); font-weight: 300; border: 2px dashed rgba(255, 255, 255, 0.25);
  box-shadow: none; backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); }
.lg-avatar.big { width: 84px; font-size: 38px; margin: 0 auto 6px; }
.lg-person:hover .lg-avatar, .lg-person:focus-visible .lg-avatar { transform: translateY(-4px) scale(1.06);
  box-shadow: 0 0 0 3px var(--text), 0 20px 50px rgba(0, 0, 0, 0.55); }
.lg-person:focus-visible { outline: none; }
.lg-person.current .lg-avatar { box-shadow: 0 0 0 3px #81d8d0, 0 14px 40px rgba(0, 0, 0, 0.45); }
.lg-name { font-weight: 650; font-size: clamp(15px, 1.15vw, 19px); color: #dde3ea; max-width: 100%; text-align: center; overflow-wrap: anywhere; line-height: 1.25; }
.lg-person:hover .lg-name, .lg-person:focus-visible .lg-name { color: var(--text); }
.lg-sub { font-size: 12px; color: var(--muted); min-height: 1em; }
.lg-card { position: relative; width: min(400px, 92vw); box-sizing: border-box; display: flex; flex-direction: column; gap: 6px;
  padding: 30px 28px 24px; border-radius: 22px; background: rgba(15, 18, 23, 0.62); border: 1px solid rgba(255, 255, 255, 0.09);
  backdrop-filter: blur(26px) saturate(1.2); -webkit-backdrop-filter: blur(26px) saturate(1.2);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.5); animation: lg-rise 0.45s ease both; text-align: left; }
.lg-card h1 { font-size: 26px; letter-spacing: -0.025em; margin: 0 0 12px; text-align: center; }
.lg-card label { font-size: 13px; color: var(--muted); margin-top: 6px; display: block; }
.lg-card input { width: 100%; box-sizing: border-box; background: rgba(11, 13, 16, 0.7); border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px; padding: 12px 14px; font-size: 16px; color: var(--text); margin-top: 4px; }
.lg-card input:focus { outline: none; border-color: #6cc4ff; box-shadow: 0 0 0 3px rgba(108, 196, 255, 0.22); }
.lg-submit { margin-top: 16px; border: 0; border-radius: 10px; padding: 13px; font-size: 16px; font-weight: 700; cursor: pointer;
  background: var(--accent); color: var(--accent-ink); transition: transform 0.12s, filter 0.12s; }
.lg-submit:hover { filter: brightness(1.08); }
.lg-submit:active { transform: scale(0.98); }
.lg-submit:disabled { opacity: 0.7; }
.lg-back { position: absolute; top: 12px; left: 12px; background: none; border: 0; color: var(--muted); font-size: 14px; cursor: pointer; padding: 6px 8px; border-radius: 8px; }
.lg-back:hover { color: var(--text); background: rgba(232, 237, 242, 0.08); }
.lg-who { text-align: center; }
.lg-card .err { min-height: 1.2em; margin: 8px 0 0; text-align: center; }
.lg-card.shake { animation: lg-shake 0.4s; }
@keyframes lg-rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes lg-shake { 20%, 60% { transform: translateX(-8px); } 40%, 80% { transform: translateX(8px); } }
@media (prefers-reduced-motion: reduce) {
  .lg-aurora, .lg-art, .lg-pick, .lg-card { animation: none !important; }
}
@media (max-width: 560px) {
  .lg-brand { position: static; }
  .lg-main { justify-content: flex-start; padding-top: 40px; }
}
