:root {
  --bg: #0E0E10;
  --bg-2: #121214;
  --surface: #17171A;
  --surface-2: #1F1F23;
  --raised: #26262B;
  --line: #232327;
  --line-2: #2A2A2F;
  --text: #F2F2F3;
  --text-2: #C9C9CE;
  --muted: #A1A1AA;
  --subtle: #8A8A93;
  --accent: #F2672A;
  --accent-ink: #111113;
  --danger: #FF8A80;
  --ok: #8FD3A8;
  --radius: 6px;
  --pad: 4%;
  font-family: Inter, "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { font-size: 15px; line-height: 1.45; -webkit-font-smoothing: antialiased; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
img { display: block; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
h1, h2, h3 { margin: 0; letter-spacing: -0.01em; }

/* ---------- buttons and fields ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 44px; padding: 0 18px; border-radius: var(--radius); border: 0; background: var(--raised); color: var(--text); font-size: 15px; font-weight: 600; text-decoration: none; white-space: nowrap; }
.btn:hover { background: #303036; }
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { background: #FF7A40; }
.btn.ghost { background: transparent; border: 1px solid var(--line-2); }
.btn.ghost:hover { background: var(--surface-2); }
.btn.danger { background: transparent; border: 1px solid #5A2A2A; color: var(--danger); }
.btn.small { height: 36px; padding: 0 12px; font-size: 13px; font-weight: 500; }
.btn.icon { width: 44px; padding: 0; }
.btn[disabled] { opacity: .5; cursor: default; }
.btn svg { flex: none; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > label, .label { font-size: 13px; color: var(--muted); }
.input, select.input, textarea.input { height: 42px; padding: 0 12px; background: var(--bg); border: 1px solid var(--line-2); border-radius: var(--radius); font-size: 14px; width: 100%; min-width: 0; }
textarea.input { height: auto; padding: 10px 12px; resize: vertical; }
.input:focus { border-color: #4A4A52; outline: none; }
.input.num { width: 64px; padding: 0 8px; height: 34px; text-align: center; }
.hint { font-size: 13px; color: var(--subtle); }
.error { color: var(--danger); font-size: 14px; }
.check { display: flex; gap: 10px; align-items: center; font-size: 14px; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); margin: 0; flex: none; }
.row { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
.grow { flex: 1 1 auto; min-width: 0; }

/* ---------- header ---------- */
.topbar { position: sticky; top: 0; z-index: 20; display: flex; flex-wrap: wrap; align-items: center; gap: 12px 32px; padding: 12px var(--pad); padding-top: max(12px, env(safe-area-inset-top)); background: rgba(14,14,16,.94); border-bottom: 1px solid var(--surface-2); backdrop-filter: blur(8px); }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; font-weight: 700; font-size: 20px; letter-spacing: -0.01em; }
.brand small { font-weight: 500; font-size: 14px; color: var(--subtle); }
.nav { display: flex; flex-wrap: wrap; gap: 4px 22px; font-size: 14px; }
.nav a { color: var(--muted); text-decoration: none; padding: 8px 0; }
.nav a:hover { color: var(--text); }
.nav a.on { color: var(--text); font-weight: 600; }
.top-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.search-box { position: relative; display: flex; align-items: center; }
.search-box svg { position: absolute; left: 10px; color: var(--muted); pointer-events: none; }
.search-box input { height: 38px; width: 220px; padding: 0 12px 0 34px; background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--radius); font-size: 14px; }
.pill-link { font-size: 13px; color: var(--muted); text-decoration: none; padding: 8px 12px; border: 1px solid var(--line-2); border-radius: var(--radius); }
.pill-link:hover { color: var(--text); }
.avatar { width: 36px; height: 36px; border-radius: var(--radius); display: grid; place-items: center; font-weight: 600; font-size: 14px; border: 0; color: var(--text); flex: none; }
.menu-wrap { position: relative; }
.menu { position: absolute; right: 0; top: calc(100% + 8px); min-width: 220px; background: var(--surface); border: 1px solid var(--line-2); border-radius: 8px; padding: 6px; z-index: 40; box-shadow: 0 12px 32px rgba(0,0,0,.5); }
.menu button, .menu a { display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px 12px; background: none; border: 0; border-radius: 6px; text-align: left; text-decoration: none; font-size: 14px; color: var(--text-2); }
.menu button:hover, .menu a:hover { background: var(--surface-2); color: var(--text); }
.menu hr { border: 0; border-top: 1px solid var(--line); margin: 6px 0; }
@media (max-width: 720px) {
  .search-box input { width: 150px; }
  .nav { order: 3; width: 100%; }
}

/* ---------- hero ---------- */
.hero { position: relative; height: min(560px, 70vh); min-height: 380px; background: #1A1D22; overflow: hidden; }
.hero.short { height: min(500px, 64vh); }
.hero img.bg { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: center 20%; }
.hero .scrim { position: absolute; inset: 0; background: linear-gradient(90deg, var(--bg) 0%, rgba(14,14,16,.86) 36%, rgba(14,14,16,0) 72%), linear-gradient(0deg, var(--bg) 0%, rgba(14,14,16,0) 32%); }
.hero .body { position: relative; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; gap: 14px; padding: 0 var(--pad) 56px; max-width: 780px; }
.hero h1 { font-size: clamp(34px, 5vw, 56px); line-height: 1.05; font-weight: 700; letter-spacing: -0.02em; }
.hero p { margin: 0; color: var(--text-2); max-width: 56ch; line-height: 1.55; display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; font-size: 14px; color: var(--muted); }
.meta .rating { border: 1px solid #3A3A40; border-radius: 4px; padding: 0 6px; color: var(--text-2); }
.meta strong { color: var(--text); font-weight: 600; }
@media (max-width: 720px) {
  .hero .scrim { background: linear-gradient(0deg, var(--bg) 8%, rgba(14,14,16,.7) 55%, rgba(14,14,16,.2) 100%); }
  .hero .body { padding-bottom: 32px; }
}

/* ---------- rows and cards ---------- */
.rows { display: flex; flex-direction: column; gap: 36px; padding: 28px var(--pad) 72px; }
.row-title { font-size: 18px; font-weight: 600; margin-bottom: 12px; }
.strip { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 6px; scroll-snap-type: x proximity; scrollbar-width: thin; scrollbar-color: #2A2A2F transparent; }
.strip > * { scroll-snap-align: start; }
.poster { flex: 0 0 172px; text-decoration: none; color: var(--text); min-width: 0; }
.poster .art { aspect-ratio: 2 / 3; border-radius: var(--radius); overflow: hidden; position: relative; background: #2B3440; display: flex; align-items: flex-end; padding: 12px; font-weight: 700; font-size: 15px; line-height: 1.2; }
.poster .art img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.poster:hover .art { outline: 2px solid #4A4A52; outline-offset: 0; }
.poster .sub { margin-top: 8px; font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wide { flex: 0 0 300px; text-decoration: none; color: var(--text); min-width: 0; }
.wide .art { aspect-ratio: 16 / 9; border-radius: var(--radius); position: relative; overflow: hidden; background: #2B3440; display: flex; align-items: flex-end; padding: 12px; font-weight: 700; }
.wide .art img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.wide:hover .art { outline: 2px solid #4A4A52; }
.wide .name { margin-top: 10px; font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wide .sub { margin-top: 2px; font-size: 13px; color: var(--muted); }
.bar { position: absolute; left: 0; right: 0; bottom: 0; height: 4px; background: rgba(255,255,255,.18); }
.bar > i { display: block; height: 100%; background: var(--accent); }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 24px 12px; }
.grid .poster { flex: none; }
@media (max-width: 520px) { .poster { flex-basis: 128px; } .wide { flex-basis: 240px; } .grid { grid-template-columns: repeat(auto-fill, minmax(108px, 1fr)); } }

.page { padding: 28px var(--pad) 72px; }
.page-head { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 16px; margin-bottom: 24px; }
.page-head h1 { font-size: 28px; font-weight: 700; margin-right: auto; }
.empty { padding: 64px 0; text-align: center; color: var(--muted); }
.empty h2 { color: var(--text); font-size: 20px; margin-bottom: 8px; }

/* ---------- title page ---------- */
.title-layout { display: flex; flex-wrap: wrap; gap: 32px 48px; padding: 28px var(--pad) 72px; }
.title-main { flex: 999 1 560px; min-width: 0; }
.title-side { flex: 1 1 240px; max-width: 340px; display: flex; flex-direction: column; gap: 18px; font-size: 14px; }
.title-side .k { color: var(--subtle); margin-bottom: 3px; }
.episode { display: flex; flex-wrap: wrap; align-items: center; gap: 16px 20px; padding: 16px; border-bottom: 1px solid var(--surface-2); border-radius: 8px; text-decoration: none; color: var(--text); }
.episode:hover { background: var(--surface); }
.episode.current { background: var(--surface); }
.episode .num { width: 28px; text-align: center; font-size: 20px; color: var(--subtle); }
.episode .thumb { flex: 0 0 192px; aspect-ratio: 16 / 9; border-radius: 4px; overflow: hidden; position: relative; background: #24262B; }
.episode .thumb img { width: 100%; height: 100%; object-fit: cover; }
.episode .info { flex: 1 1 240px; min-width: 0; }
.episode .top { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; }
.episode .top b { font-size: 16px; font-weight: 600; }
.episode .top span { color: var(--muted); font-size: 14px; white-space: nowrap; }
.episode p { margin: 6px 0 0; color: var(--muted); font-size: 14px; line-height: 1.5; }
@media (max-width: 520px) { .episode .thumb { flex-basis: 132px; } .episode .num { display: none; } }

/* ---------- player ---------- */
.player { position: fixed; inset: 0; background: #000; z-index: 50; overflow: hidden; color: var(--text); }
.player video { position: absolute; inset: 0; width: 100%; height: 100%; background: #000; }
.player video::cue { background: rgba(0,0,0,.6); font-size: clamp(18px, 2.6vw, 30px); }
.player .shade-top { position: absolute; left: 0; right: 0; top: 0; height: 140px; background: linear-gradient(180deg, rgba(0,0,0,.75), rgba(0,0,0,0)); pointer-events: none; }
.player .shade-bottom { position: absolute; left: 0; right: 0; bottom: 0; height: 220px; background: linear-gradient(0deg, rgba(0,0,0,.85), rgba(0,0,0,0)); pointer-events: none; }
.player .chrome { transition: opacity .25s; }
.player.idle .chrome { opacity: 0; pointer-events: none; }
.player.idle { cursor: none; }
.p-top { position: absolute; left: 0; right: 0; top: 0; display: flex; align-items: center; gap: 14px; padding: 16px 3%; padding-top: max(16px, env(safe-area-inset-top)); }
.p-top .t1 { font-weight: 600; }
.p-top .t2 { color: var(--text-2); font-size: 14px; }
.p-bottom { position: absolute; left: 0; right: 0; bottom: 0; padding: 0 3% max(16px, env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 6px; }
.p-time { display: flex; align-items: center; gap: 14px; font-size: 13px; color: var(--text-2); font-variant-numeric: tabular-nums; }
.seek { flex: 1; position: relative; height: 20px; display: flex; align-items: center; }
.seek .track { position: absolute; left: 0; right: 0; height: 4px; border-radius: 2px; background: rgba(255,255,255,.22); overflow: hidden; }
.seek .buf { position: absolute; left: 0; top: 0; bottom: 0; background: rgba(255,255,255,.35); }
.seek .fill { position: absolute; left: 0; top: 0; bottom: 0; background: var(--accent); }
.seek input { position: absolute; inset: 0; width: 100%; margin: 0; opacity: 0; cursor: pointer; }
.seek .knob { position: absolute; width: 14px; height: 14px; margin-left: -7px; border-radius: 50%; background: var(--accent); pointer-events: none; }
.seek .tip { position: absolute; bottom: 22px; transform: translateX(-50%); background: rgba(20,20,22,.9); padding: 2px 6px; border-radius: 4px; font-size: 12px; pointer-events: none; display: none; }
.seek:hover .tip { display: block; }
.p-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 2px; }
.pbtn { width: 48px; height: 48px; display: grid; place-items: center; background: transparent; border: 0; color: var(--text); border-radius: 8px; }
.pbtn:hover { background: rgba(255,255,255,.08); }
.pbtn.text { width: auto; padding: 0 10px; font-size: 14px; font-weight: 600; }
.p-name { flex: 1 1 auto; min-width: 80px; text-align: center; font-size: 14px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.vol { width: 90px; accent-color: var(--accent); }
.skip-btn { position: absolute; right: 3%; bottom: 150px; height: 44px; padding: 0 20px; background: rgba(20,20,22,.72); color: var(--text); border: 1px solid rgba(242,242,243,.6); border-radius: var(--radius); font-weight: 600; font-size: 15px; }
.skip-btn:hover { background: rgba(40,40,44,.9); }
.upnext { position: absolute; right: 3%; bottom: 150px; width: 340px; max-width: 94%; background: rgba(20,20,22,.94); border: 1px solid var(--line-2); border-radius: 10px; padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.upnext .lbl { font-size: 13px; color: var(--muted); }
.p-panel { position: absolute; right: 3%; bottom: 120px; width: 320px; max-width: 94%; max-height: 60vh; overflow: auto; background: rgba(20,20,22,.96); border: 1px solid var(--line-2); border-radius: 10px; padding: 8px; }
.p-panel h3 { font-size: 13px; font-weight: 500; color: var(--muted); padding: 10px 10px 6px; }
.p-panel button { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; padding: 10px; background: none; border: 0; border-radius: 6px; font-size: 14px; color: var(--text-2); }
.p-panel button:hover { background: var(--surface-2); color: var(--text); }
.p-panel button.on { color: var(--text); font-weight: 600; }
.p-panel button.on::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); flex: none; }
.p-panel button:not(.on)::before { content: ""; width: 6px; flex: none; }
.p-msg { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; padding: 24px; pointer-events: none; }
.p-msg > div { max-width: 520px; pointer-events: auto; }
.spinner { width: 44px; height: 44px; border: 3px solid rgba(255,255,255,.2); border-top-color: var(--text); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (max-width: 640px) { .vol, .p-name, .pbtn.hide-sm { display: none; } .pbtn { width: 44px; height: 44px; } }

/* ---------- profile picker and auth ---------- */
.center-page { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 48px 20px; gap: 32px; }
.center-page h1 { font-size: 32px; font-weight: 600; text-align: center; }
.profiles { display: flex; flex-wrap: wrap; justify-content: center; gap: 24px; }
.profile-tile { display: flex; flex-direction: column; align-items: center; gap: 10px; background: none; border: 0; color: var(--muted); font-size: 15px; width: 128px; }
.profile-tile .big { width: 112px; height: 112px; border-radius: 10px; display: grid; place-items: center; font-size: 40px; font-weight: 600; color: var(--text); border: 2px solid transparent; position: relative; }
.profile-tile:hover .big { border-color: var(--text); }
.profile-tile:hover { color: var(--text); }
.profile-tile .big.add { background: var(--surface); color: var(--muted); }
.profile-tile .kid { position: absolute; bottom: 6px; right: 6px; font-size: 11px; font-weight: 700; background: var(--bg); color: var(--text); padding: 1px 6px; border-radius: 4px; }
.auth-card { width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 28px; display: flex; flex-direction: column; gap: 16px; }
.auth-card h1 { font-size: 24px; text-align: left; }
.auth-card .switch { font-size: 14px; color: var(--muted); }

/* ---------- admin ---------- */
.admin { display: flex; flex-wrap: wrap; min-height: 100vh; }
.admin-side { flex: 1 1 220px; max-width: 260px; padding: 20px 16px; background: var(--bg-2); border-right: 1px solid var(--surface-2); display: flex; flex-direction: column; gap: 2px; font-size: 14px; }
.admin-side .brand { padding: 6px 10px 20px; font-size: 18px; }
.admin-side a.item { display: flex; justify-content: space-between; align-items: center; padding: 10px 12px; border-radius: var(--radius); color: var(--muted); text-decoration: none; }
.admin-side a.item:hover { color: var(--text); background: var(--surface); }
.admin-side a.item.on { color: var(--text); background: var(--surface-2); font-weight: 600; }
.badge { font-size: 12px; background: var(--line-2); color: var(--text); border-radius: 10px; padding: 1px 8px; font-weight: 500; }
.badge.hot { background: var(--accent); color: var(--accent-ink); }
.admin-main { flex: 999 1 560px; min-width: 0; padding: 32px 4% 64px; display: flex; flex-direction: column; gap: 24px; max-width: 1180px; }
.admin-main > header h1 { font-size: 28px; font-weight: 700; }
.admin-main > header p { margin: 4px 0 0; color: var(--muted); font-size: 14px; }
.crumb { font-size: 13px; color: var(--subtle); margin-bottom: 6px; }
.crumb a { color: var(--subtle); }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 24px; display: flex; flex-direction: column; gap: 18px; }
.card > h2, .card-head h2 { font-size: 16px; font-weight: 600; }
.card-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 12px; }
.fields { display: flex; flex-wrap: wrap; gap: 16px; }
.fields > .field { flex: 1 1 240px; }
.table-box { overflow-x: auto; border: 1px solid var(--line); border-radius: 8px; }
table.t { width: 100%; border-collapse: collapse; font-size: 14px; }
table.t th { background: var(--bg-2); color: var(--muted); text-align: left; font-weight: 500; padding: 10px 14px; white-space: nowrap; }
table.t td { padding: 10px 14px; border-top: 1px solid var(--line); vertical-align: middle; }
table.t tr.group td { color: var(--text); font-weight: 600; background: rgba(255,255,255,.015); }
table.t tr.review { background: rgba(242,103,42,.07); }
table.t a { text-decoration: none; }
table.t a:hover { text-decoration: underline; }
.mono { font-family: ui-monospace, Consolas, "Cascadia Mono", monospace; font-size: 13px; color: var(--text-2); word-break: break-all; }
.status-review { color: var(--accent); font-weight: 600; }
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 18px; }
.stat .n { font-size: 28px; font-weight: 700; }
.stat .l { color: var(--muted); font-size: 13px; }
.checklist { display: flex; flex-direction: column; gap: 10px; font-size: 14px; }
.checklist div { display: flex; gap: 10px; align-items: flex-start; }
.dot { width: 8px; height: 8px; border-radius: 50%; margin-top: 6px; flex: none; background: var(--ok); }
.dot.warn { background: var(--accent); }
.match { display: flex; flex-wrap: wrap; gap: 20px; }
.match .mposter { flex: 0 0 104px; aspect-ratio: 2 / 3; border-radius: var(--radius); overflow: hidden; background: #2B3440; }
.match .mposter img { width: 100%; height: 100%; object-fit: cover; }
.cands { display: flex; flex-direction: column; gap: 4px; }
.cand { display: flex; align-items: center; gap: 12px; padding: 8px 10px; border-radius: var(--radius); border: 1px solid transparent; cursor: pointer; font-size: 14px; }
.cand:hover { background: var(--surface-2); }
.cand.on { border-color: var(--line-2); background: var(--surface-2); }
.cand img, .cand .ph { width: 36px; height: 54px; object-fit: cover; border-radius: 3px; background: #2B3440; flex: none; }
.roles { display: flex; flex-wrap: wrap; gap: 16px; }
.roles .card { flex: 1 1 240px; padding: 20px; gap: 8px; }
.roles p { margin: 0; color: var(--muted); font-size: 14px; line-height: 1.5; }
code.inv { font-family: ui-monospace, Consolas, monospace; font-size: 15px; background: var(--bg); border: 1px solid var(--line-2); border-radius: var(--radius); padding: 7px 12px; }

/* ---------- modal and toast ---------- */
.modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,.6); z-index: 80; display: grid; place-items: center; padding: 16px; }
.modal { width: 100%; max-width: 560px; max-height: 86vh; overflow: auto; background: var(--surface); border: 1px solid var(--line-2); border-radius: 12px; padding: 24px; display: flex; flex-direction: column; gap: 16px; }
.modal h2 { font-size: 18px; }
.modal .actions { display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }
.dirlist { border: 1px solid var(--line); border-radius: 8px; max-height: 340px; overflow: auto; }
.dirlist button { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; padding: 10px 12px; background: none; border: 0; border-top: 1px solid var(--line); font-size: 14px; color: var(--text-2); }
.dirlist button:first-child { border-top: 0; }
.dirlist button:hover { background: var(--surface-2); color: var(--text); }
#toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 100; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
#toast div { background: #26262B; border: 1px solid var(--line-2); color: var(--text); padding: 10px 16px; border-radius: 8px; font-size: 14px; box-shadow: 0 8px 24px rgba(0,0,0,.5); }
#toast div.err { border-color: #5A2A2A; }
.loading { display: grid; place-items: center; min-height: 50vh; }
