/* Theme tokens arrive from GET /v1/tenant/config and are set as custom properties on <html> (see js/theme.js). */
:root {
  --bg: #0a0a0a; --surface: #151515; --text: #f5f5f5; --muted: #a0a0a0; --border: #2a2a2a;
  --accent: #d4af37; --on-accent: #000; --accent2: #c41e3a; --ok: #2e9e6b; --warn: #e0a030;
  --r-sm: 4px; --r-md: 8px; --r-lg: 16px; --scale: 1; --t-micro: 200ms; --t-std: 400ms;
  --f-display: 'Inter', system-ui, sans-serif; --f-body: 'Inter', system-ui, sans-serif;
  --gap: 16px; --pad: 20px; --card-w: 150px; --nav-h: 60px;
}
html[data-density="compact"] { --gap: 10px; --pad: 14px; --card-w: 130px; }
html[data-density="spacious"] { --gap: 24px; --pad: 32px; --card-w: 180px; }
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { font-size: calc(16px * var(--scale)); -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--f-body); line-height: 1.5; min-height: 100vh; }
h1, h2, h3 { font-family: var(--f-display); line-height: 1.2; margin: 0 0 .4em; }
a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
.boot { padding: 40px; text-align: center; color: var(--muted); }
.muted { color: var(--muted); } .small { font-size: .85rem; } .bad { color: var(--accent2); } .ok { color: var(--ok); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ── Buttons, fields, chips ── */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 10px 18px; border-radius: var(--r-md); border: 1px solid var(--border); background: var(--surface); cursor: pointer; transition: filter var(--t-micro), transform var(--t-micro); }
.btn:hover { filter: brightness(1.15); } .btn:active { transform: scale(.98); }
.btn.primary { background: var(--accent); color: var(--on-accent); border-color: var(--accent); font-weight: 600; }
.btn.ghost { background: transparent; } .btn.danger { border-color: var(--accent2); color: var(--accent2); }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn.sm { padding: 5px 10px; font-size: .85rem; }
.field { display: grid; gap: 4px; margin-bottom: 12px; } .field > span { font-size: .85rem; color: var(--muted); }
input, select, textarea { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md); padding: 10px 12px; width: 100%; }
textarea { resize: vertical; min-height: 70px; }
.chip { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: .78rem; border: 1px solid var(--border); background: var(--surface); }
.chip.vip { background: var(--accent); color: var(--on-accent); border-color: var(--accent); font-weight: 600; }
.chip.free { color: var(--ok); border-color: var(--ok); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
a.chip:hover, button.chip:hover { border-color: var(--accent); } button.chip { cursor: pointer; color: inherit; }
.chip.on { border-color: var(--accent); color: var(--accent); }
.err { color: var(--accent2); min-height: 1.2em; margin: 6px 0; }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: var(--pad); }
.toast { position: fixed; left: 50%; bottom: 80px; transform: translateX(-50%); background: var(--surface); border: 1px solid var(--border); padding: 10px 18px; border-radius: var(--r-md); z-index: 100; max-width: 90vw; }
.toast.bad { border-color: var(--accent2); }

/* ── Shell and navigation (data-nav: top | side | bottom_tabs) ── */
.shell { min-height: 100vh; }
.nav { display: flex; align-items: center; gap: 18px; padding: 0 var(--pad); height: var(--nav-h); background: color-mix(in srgb, var(--bg) 92%, transparent); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 20; backdrop-filter: blur(8px); }
.brand { font-family: var(--f-display); font-weight: 700; font-size: 1.3rem; color: var(--accent); display: flex; align-items: center; gap: 8px; }
.brand img { height: 32px; width: auto; }
.nav .links { display: flex; gap: 4px; flex: 1; }
.nav a.l { padding: 8px 12px; border-radius: var(--r-md); color: var(--muted); } .nav a.l:hover, .nav a.l.on { color: var(--text); background: var(--surface); }
.nav .l .ic { display: none; }
main { padding: var(--pad); max-width: 1400px; width: 100%; margin: 0 auto; min-width: 0; }
main.flush { padding-top: 0; }
html[data-nav="side"] .shell { display: grid; grid-template-columns: 220px 1fr; }
html[data-nav="side"] .nav { position: sticky; top: 0; height: 100vh; flex-direction: column; align-items: stretch; padding: 20px 12px; border-right: 1px solid var(--border); border-bottom: 0; }
html[data-nav="side"] .nav .links { flex-direction: column; flex: 1; }
/* a backdrop filter would make the nav the containing block of the fixed tab bar, pinning it to the top */
html[data-nav="bottom_tabs"] .nav { position: static; backdrop-filter: none; }
html[data-nav="bottom_tabs"] .nav .links { position: fixed; left: 0; right: 0; bottom: 0; height: 58px; padding-bottom: env(safe-area-inset-bottom); background: var(--bg); border-top: 1px solid var(--border); justify-content: space-around; align-items: center; z-index: 30; }
html[data-nav="bottom_tabs"] .nav a.l { display: flex; flex-direction: column; align-items: center; font-size: .72rem; padding: 4px 10px; background: none; }
html[data-nav="bottom_tabs"] .nav .l .ic { display: block; font-size: 1.15rem; line-height: 1; }
html[data-nav="bottom_tabs"] body, html[data-nav="bottom_tabs"] .shell { padding-bottom: 66px; }
html[data-nav="bottom_tabs"] .nav .spacer { flex: 1; }
.nav .spacer { flex: 1; }
@media (max-width: 760px) {
  html[data-nav="side"] .shell { display: block; }
  html[data-nav="side"] .nav { position: sticky; height: var(--nav-h); flex-direction: row; align-items: center; padding: 0 var(--pad); border-right: 0; border-bottom: 1px solid var(--border); }
  html[data-nav="side"] .nav .links { flex-direction: row; overflow-x: auto; }
  html[data-nav="top"] .nav .links { overflow-x: auto; }
  .nav { gap: 8px; }
}

/* ── Hero (data-hero: billboard | carousel | split | spotlight | none) ── */
.hero { position: relative; margin: 0 calc(var(--pad) * -1) var(--gap); min-height: 56vh; display: flex; align-items: flex-end; overflow: hidden; background: var(--surface); }
.hero .bg { position: absolute; inset: 0; background-size: cover; background-position: center; opacity: .55; }
.hero::after { content: ''; position: absolute; inset: 0; background: linear-gradient(to top, var(--bg) 2%, transparent 70%), linear-gradient(to right, var(--bg) 0%, transparent 60%); }
.hero .body { position: relative; z-index: 1; padding: var(--pad) var(--pad) 36px; max-width: 640px; }
.hero h1 { font-size: clamp(1.8rem, 5vw, 3rem); }
.hero p { color: var(--text); opacity: .85; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.hero .acts { display: flex; gap: 10px; margin-top: 14px; flex-wrap: wrap; }
.hero .slide { display: none; position: absolute; inset: 0; } .hero .slide.on { display: flex; align-items: flex-end; }
.hero .dots { position: absolute; z-index: 2; right: var(--pad); bottom: 14px; display: flex; gap: 6px; }
.hero .dots button { width: 10px; height: 10px; border-radius: 50%; border: 0; background: var(--muted); cursor: pointer; padding: 0; } .hero .dots button.on { background: var(--accent); }
html[data-hero="split"] .hero { min-height: 0; padding: var(--pad); gap: 28px; align-items: center; flex-wrap: wrap; border-radius: var(--r-lg); margin: 0 0 var(--gap); }
html[data-hero="split"] .hero::after, html[data-hero="split"] .hero .bg { display: none; }
html[data-hero="split"] .hero .body { padding: 0; flex: 1 1 280px; }
.hero .poster { position: relative; z-index: 1; width: 200px; border-radius: var(--r-md); box-shadow: 0 10px 30px #0008; display: none; }
html[data-hero="split"] .hero .poster, html[data-hero="spotlight"] .hero .poster { display: block; }
html[data-hero="spotlight"] .hero { justify-content: center; align-items: center; text-align: center; min-height: 44vh; border-radius: var(--r-lg); margin: 0 0 var(--gap); flex-direction: column; padding: var(--pad); gap: 14px; }
html[data-hero="spotlight"] .hero .bg { filter: blur(18px); transform: scale(1.1); opacity: .4; }
html[data-hero="spotlight"] .hero .body { padding: 0; }
html[data-hero="spotlight"] .hero .acts, html[data-hero="spotlight"] .hero .chips { justify-content: center; }
html[data-hero="spotlight"] .hero p { -webkit-line-clamp: 2; }
html[data-hero="none"] .hero { display: none; }

/* ── Cards (data-card: poster | landscape | square | tile_overlay) and shelves (data-browse: rows | grid | masonry | list) ── */
.shelf-h { display: flex; align-items: baseline; justify-content: space-between; margin: calc(var(--gap) * 1.4) 0 8px; }
.shelf-h h2 { font-size: 1.25rem; margin: 0; }
.shelf { display: flex; gap: var(--gap); overflow-x: auto; padding-bottom: 8px; scroll-snap-type: x proximity; }
.card { position: relative; flex: 0 0 var(--card-w); scroll-snap-align: start; display: block; min-width: 0; }
.card .art { position: relative; aspect-ratio: 2 / 3; border-radius: var(--r-md); overflow: hidden; background: var(--surface); border: 1px solid var(--border); transition: transform var(--t-micro); }
.card:hover .art { transform: translateY(-3px); border-color: var(--accent); }
.card .art img { position: relative; z-index: 1; width: 100%; height: 100%; object-fit: cover; }
.card .ph { position: absolute; inset: 0; display: grid; place-items: center; font-family: var(--f-display); font-size: 2.2rem; color: var(--muted); }
.card .t { margin-top: 6px; font-size: .92rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card .m { font-size: .78rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card .rank, .card .badge, .card .prog { z-index: 2; }
.card .rank { position: absolute; left: 6px; bottom: 4px; font-family: var(--f-display); font-size: 2.4rem; font-weight: 800; color: var(--text); text-shadow: 0 2px 8px #000; }
.card .badge { position: absolute; top: 6px; right: 6px; font-size: .68rem; padding: 2px 7px; border-radius: 999px; background: var(--accent); color: var(--on-accent); font-weight: 600; }
.card .prog { position: absolute; left: 0; right: 0; bottom: 0; height: 4px; background: #0008; } .card .prog i { display: block; height: 100%; background: var(--accent); }
html[data-card="landscape"] .card { flex-basis: calc(var(--card-w) * 1.7); } html[data-card="landscape"] .card .art { aspect-ratio: 16 / 9; }
html[data-card="square"] .card .art { aspect-ratio: 1 / 1; }
html[data-card="tile_overlay"] .card .art::after { content: ''; position: absolute; inset: 0; background: linear-gradient(to top, #000c 0%, transparent 55%); }
html[data-card="tile_overlay"] .card .t, html[data-card="tile_overlay"] .card .m { position: absolute; left: 8px; right: 8px; z-index: 2; margin: 0; color: #fff; text-shadow: 0 1px 4px #000; }
html[data-card="tile_overlay"] .card .rank { bottom: auto; top: 2px; font-size: 1.8rem; }
html[data-card="tile_overlay"] .card .t { bottom: 22px; } html[data-card="tile_overlay"] .card .m { bottom: 6px; color: #ddd; }
html[data-browse="grid"] .shelf { display: grid; grid-template-columns: repeat(auto-fill, minmax(var(--card-w), 1fr)); overflow: visible; }
html[data-browse="grid"][data-card="landscape"] .shelf { grid-template-columns: repeat(auto-fill, minmax(calc(var(--card-w) * 1.7), 1fr)); }
html[data-browse="masonry"] .shelf { display: block; column-width: var(--card-w); column-gap: var(--gap); overflow: visible; }
html[data-browse="masonry"] .card { break-inside: avoid; margin-bottom: var(--gap); }
html[data-browse="masonry"] .card:nth-child(3n+1) .art { aspect-ratio: 2 / 3; } html[data-browse="masonry"] .card:nth-child(3n+2) .art { aspect-ratio: 1 / 1; } html[data-browse="masonry"] .card:nth-child(3n) .art { aspect-ratio: 3 / 4; }
html[data-browse="list"] .shelf { display: flex; flex-direction: column; overflow: visible; }
html[data-browse="list"] .card { flex: none; display: grid; grid-template-columns: 72px 1fr; gap: 12px; align-items: center; padding: 8px; border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface); }
html[data-browse="list"] .card .art { aspect-ratio: 2 / 3; } html[data-browse="list"] .card .t, html[data-browse="list"] .card .m { white-space: normal; }
html[data-browse="list"][data-card="tile_overlay"] .card .t, html[data-browse="list"][data-card="tile_overlay"] .card .m { position: static; color: inherit; text-shadow: none; }
html[data-browse="list"] .card .rank { font-size: 1.4rem; left: 4px; }
.txt { display: contents; }
html[data-browse="list"] .txt { display: block; min-width: 0; }

/* ── Series page ── */
.sh { position: relative; display: flex; gap: 24px; padding: var(--pad); border-radius: var(--r-lg); overflow: hidden; background: var(--surface); flex-wrap: wrap; }
.sh .bg { position: absolute; inset: 0; background-size: cover; background-position: center; opacity: .25; }
.sh > * { position: relative; }
.sh .poster { width: 180px; border-radius: var(--r-md); }
.sh .info { flex: 1 1 280px; min-width: 0; }
.sh .acts { display: flex; gap: 10px; flex-wrap: wrap; margin: 14px 0; }
.note { padding: 10px 14px; border-radius: var(--r-md); border: 1px dashed var(--accent); color: var(--accent); margin: 10px 0; font-size: .92rem; }
.eps { display: grid; gap: 10px; margin-top: 12px; }
.ep { display: grid; grid-template-columns: 140px 1fr; gap: 14px; padding: 10px; border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface); cursor: pointer; position: relative; }
.ep:hover { border-color: var(--accent); } .ep .th { aspect-ratio: 16 / 9; background: var(--bg); border-radius: var(--r-sm); overflow: hidden; position: relative; }
.ep .th img { width: 100%; height: 100%; object-fit: cover; } .ep .lock { position: absolute; inset: 0; display: grid; place-items: center; background: #000a; font-size: 1.4rem; }
.ep h3 { font-size: 1rem; margin: 0 0 4px; } .ep p { margin: 0; color: var(--muted); font-size: .88rem; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.ep .prog { position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: var(--border); } .ep .prog i { display: block; height: 100%; background: var(--accent); }
@media (max-width: 520px) { .ep { grid-template-columns: 100px 1fr; } .sh .poster { width: 110px; } }

/* ── Watch ── */
.player { position: relative; background: #000; border-radius: var(--r-lg); overflow: hidden; aspect-ratio: 16 / 9; max-height: 78vh; }
.player video { width: 100%; height: 100%; background: #000; }
.player .over { position: absolute; inset: 0; display: grid; place-items: center; background: #000b; text-align: center; padding: 20px; }
.player .skip { position: absolute; right: 16px; bottom: 64px; }
.player .next { position: absolute; right: 16px; bottom: 64px; background: #000d; border: 1px solid var(--border); padding: 12px 16px; border-radius: var(--r-md); display: grid; gap: 8px; }
.bar { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin: 12px 0; }
.bar select { width: auto; }
.cm { display: grid; gap: 14px; margin-top: 12px; }
.cmt { display: grid; grid-template-columns: 36px 1fr; gap: 10px; }
.av { width: 36px; height: 36px; border-radius: 50%; background: var(--accent); color: var(--on-accent); display: grid; place-items: center; font-weight: 700; overflow: hidden; } .av img { width: 100%; height: 100%; object-fit: cover; }
.cmt .who { font-size: .85rem; color: var(--muted); } .cmt .who b { color: var(--text); }
.cmt .body { white-space: pre-wrap; word-break: break-word; } .cmt .acts { display: flex; gap: 12px; font-size: .82rem; color: var(--muted); margin-top: 4px; }
.cmt .acts button { background: none; border: 0; padding: 0; cursor: pointer; color: var(--muted); } .cmt .acts button:hover { color: var(--text); }
.replies { margin-left: 46px; display: grid; gap: 12px; }

/* ── Account, forms, promo ── */
.tabs { display: flex; gap: 6px; overflow-x: auto; border-bottom: 1px solid var(--border); margin-bottom: 16px; }
.tabs a { padding: 10px 14px; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; } .tabs a.on { color: var(--text); border-color: var(--accent); }
.narrow { max-width: 440px; margin: 0 auto; } .auth { min-height: 100vh; display: grid; place-items: center; padding: var(--pad); }
.auth .panel { width: 100%; max-width: 420px; } .auth .brand { justify-content: center; margin-bottom: 12px; font-size: 1.6rem; }
.plans { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: var(--gap); margin: 14px 0; }
.plan { border: 1px solid var(--border); border-radius: var(--r-lg); padding: var(--pad); background: var(--surface); } .plan.cur { border-color: var(--accent); }
.plan .pr { font-family: var(--f-display); font-size: 1.5rem; color: var(--accent); }
.row { display: flex; gap: 12px; align-items: center; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid var(--border); }
.row:last-child { border-bottom: 0; } .row > .grow { flex: 1; min-width: 0; }
.promo { position: fixed; left: 50%; transform: translateX(-50%); bottom: 76px; width: min(520px, 92vw); z-index: 60; background: var(--surface); border: 1px solid var(--accent); border-radius: var(--r-lg); padding: 16px; box-shadow: 0 10px 40px #000a; }
.promo .x { position: absolute; top: 6px; right: 8px; background: none; border: 0; cursor: pointer; font-size: 1.2rem; color: var(--muted); }
.empty { text-align: center; color: var(--muted); padding: 40px 10px; }
.sugg { position: absolute; left: 0; right: 0; top: 100%; z-index: 10; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md); margin-top: 4px; overflow: hidden; }
.sugg a { display: block; padding: 8px 12px; } .sugg a:hover { background: var(--bg); }
.searchbar { position: relative; max-width: 640px; margin-bottom: 14px; }
.filters { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; } .filters select { width: auto; }
.install { position: fixed; top: 10px; right: 10px; z-index: 50; }
