:root {
  --bg: #070c17; --surface: #0e1628; --surface2: #15213a; --line: #23314f;
  --fg: #e9eef8; --muted: #8e9bb6; --accent: #3a6bd1; --accent2: #5d8df0;
  --ok: #52d19a; --warn: #f2b455; --bad: #ff6b72;
  --font: 'Roboto', system-ui, -apple-system, 'Segoe UI', sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--fg); font-family: var(--font); font-size: 15px; line-height: 1.45; }
a { color: var(--accent2); }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent2); outline-offset: 2px; }
.hidden { display: none !important; }

/* layout */
.top { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 18px; padding: 10px max(16px, env(safe-area-inset-right)) 10px max(16px, env(safe-area-inset-left)); background: rgba(7,12,23,.92); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.brand { font-weight: 700; letter-spacing: .28em; text-decoration: none; color: var(--fg); }
.brand b { color: var(--accent2); }
.nav { display: flex; gap: 4px; }
.nav a { padding: 7px 14px; border-radius: 999px; color: var(--muted); text-decoration: none; }
.nav a:hover { color: var(--fg); }
.nav a.on { background: var(--surface2); color: var(--fg); }
.search { flex: 1; max-width: 360px; margin-left: auto; }
.search input { width: 100%; height: 38px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); }
.avatar { width: 38px; height: 38px; border-radius: 50%; border: 1px solid var(--line); background: var(--surface); display: grid; place-items: center; text-decoration: none; color: var(--fg); font-weight: 500; flex: none; }
main { padding: 0 0 48px; min-height: 70vh; }
.wrap { padding-inline: max(16px, env(safe-area-inset-left)) max(16px, env(safe-area-inset-right)); max-width: 1500px; margin: 0 auto; }
@media (max-width: 760px) {
  .top { flex-wrap: wrap; gap: 10px; }
  .nav { order: 3; width: 100%; overflow-x: auto; }
  .search { order: 2; max-width: none; flex-basis: 100%; margin: 0; }
}

/* hero */
.hero { position: relative; margin: 16px auto 0; max-width: 1500px; min-height: 340px; border-radius: 18px; overflow: hidden; background: var(--surface) center/cover no-repeat; display: flex; align-items: flex-end; }
.hero::after { content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, rgba(7,12,23,.92), rgba(7,12,23,.1) 70%), linear-gradient(0deg, rgba(7,12,23,.85), transparent 55%); }
.hero .txt { position: relative; z-index: 1; padding: 24px; max-width: 640px; }
.hero small { color: var(--muted); }
.hero h1 { margin: 2px 0 6px; font-size: clamp(26px, 5vw, 44px); font-weight: 500; line-height: 1.1; text-wrap: balance; }
.hero .meta { color: #c8d2e6; margin-bottom: 14px; font-size: 13px; letter-spacing: .04em; }
.dots { position: absolute; z-index: 1; right: 18px; bottom: 16px; display: flex; gap: 6px; }
.dots button { width: 8px; height: 8px; padding: 0; border-radius: 50%; border: 0; background: rgba(255,255,255,.35); }
.dots button.on { background: #fff; }

/* buttons */
.btn { display: inline-flex; align-items: center; gap: 8px; height: 40px; padding: 0 18px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface2); color: var(--fg); text-decoration: none; font-weight: 500; }
.btn.pri { background: linear-gradient(180deg, #3563bf, #264a95); border-color: #2c58ad; }
.btn:disabled { opacity: .5; cursor: default; }
.btn.small { height: 32px; padding: 0 14px; font-size: 13px; }
.btn.danger { border-color: #6b2b30; color: var(--bad); }

/* rows and cards */
.sec { margin-top: 26px; }
.sec h2 { margin: 0 0 10px; font-size: 19px; font-weight: 500; }
.row { display: flex; gap: 14px; overflow-x: auto; padding-bottom: 8px; scrollbar-width: thin; scrollbar-color: var(--line) transparent; }
.card { flex: none; width: 150px; background: none; border: 0; padding: 0; text-align: left; text-decoration: none; color: inherit; }
.poster { width: 100%; aspect-ratio: 2 / 3; border-radius: 12px; overflow: hidden; background: linear-gradient(160deg, var(--surface2), var(--surface)); position: relative; border: 1px solid transparent; transition: transform .12s, border-color .12s; }
.poster img { width: 100%; height: 100%; object-fit: cover; display: block; }
.poster .ph { position: absolute; inset: 0; display: grid; place-items: center; padding: 10px; text-align: center; color: var(--muted); font-weight: 500; }
.card:hover .poster, .card:focus-visible .poster { transform: translateY(-3px); border-color: var(--accent2); }
.card .t { display: block; margin-top: 6px; font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card .s { display: block; font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 18px 14px; }
.grid .card { width: auto; }
.pagehead { padding: 22px 0 0; }
.pagehead h1 { margin: 0; font-size: 26px; font-weight: 500; }
.muted { color: var(--muted); }
.empty { color: var(--muted); padding: 24px 0; }

/* details */
.detail { position: relative; }
.detail .back { height: 360px; background: var(--surface) center/cover no-repeat; position: relative; }
.detail .back::after { content: ""; position: absolute; inset: 0; background: linear-gradient(0deg, var(--bg), rgba(7,12,23,.4) 70%); }
.detail .body { position: relative; z-index: 1; margin-top: -170px; display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: 24px; }
.detail .poster { width: 200px; }
.detail h1 { margin: 0 0 6px; font-size: clamp(26px, 4vw, 40px); font-weight: 500; text-wrap: balance; }
.detail .meta { color: var(--muted); margin-bottom: 12px; }
.detail p { max-width: 70ch; color: #cfd8ea; }
.acts { display: flex; gap: 10px; flex-wrap: wrap; margin: 14px 0; }
@media (max-width: 700px) { .detail .body { grid-template-columns: 1fr; margin-top: -120px; } .detail .poster { width: 130px; } .detail .back { height: 260px; } }
.seasons { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0 12px; }
.chip { padding: 6px 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--muted); }
.chip.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.eps { display: grid; gap: 8px; }
.ep { display: grid; grid-template-columns: 120px minmax(0, 1fr) auto; gap: 14px; align-items: center; padding: 8px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line); }
.ep .still { width: 120px; aspect-ratio: 16 / 9; border-radius: 8px; background: var(--surface2) center/cover no-repeat; }
.ep h4 { margin: 0; font-size: 14px; font-weight: 500; }
.ep p { margin: 2px 0 0; font-size: 12px; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
@media (max-width: 600px) { .ep { grid-template-columns: 90px minmax(0, 1fr); } .ep .still { width: 90px; } .ep .btn { grid-column: 1 / -1; justify-content: center; } }

/* player */
.player { max-width: 1200px; margin: 0 auto; padding-top: 16px; }
.player video { width: 100%; max-height: 74vh; background: #000; border-radius: 12px; display: block; }
.status { margin: 14px 0; padding: 14px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; }
.status .bar { height: 6px; border-radius: 3px; background: var(--surface2); overflow: hidden; margin-top: 10px; }
.status .bar i { display: block; height: 100%; background: var(--accent2); width: 0; transition: width .4s; }
.status.err { border-color: #6b2b30; }
.log { margin: 8px 0 0; padding: 0; list-style: none; font-size: 12px; color: var(--muted); max-height: 160px; overflow: auto; }

/* profile */
.cards { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); margin-top: 18px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 18px; }
.panel h2 { margin: 0 0 4px; font-size: 17px; font-weight: 500; }
.kv { display: flex; justify-content: space-between; gap: 12px; padding: 7px 0; border-top: 1px solid var(--line); }
.kv:first-of-type { border-top: 0; }
.pill { font-size: 12px; padding: 3px 10px; border-radius: 999px; background: var(--surface2); color: var(--muted); }
.pill.ok { background: #12352a; color: var(--ok); }
.pill.bad { background: #3a1a1d; color: var(--bad); }
.pill.warn { background: #3a2c12; color: var(--warn); }
.code { font-size: 34px; letter-spacing: .24em; font-weight: 700; text-align: center; padding: 14px; margin: 12px 0; border-radius: 12px; background: var(--surface2); border: 1px dashed var(--accent2); user-select: all; }
.msg { margin: 10px 0 0; font-size: 13px; }
.msg.err { color: var(--bad); }
.msg.ok { color: var(--ok); }
label.f { display: block; margin: 10px 0 4px; font-size: 13px; color: var(--muted); }
input.t { width: 100%; height: 40px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); }

/* login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login .box { width: min(400px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 26px; }
.login h1 { margin: 0 0 4px; letter-spacing: .28em; font-size: 22px; }
.login h1 b { color: var(--accent2); }

#toast { position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 50; background: var(--surface2); border: 1px solid var(--line); padding: 10px 18px; border-radius: 999px; max-width: 90vw; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
