:root {
  --bg: #0b0d12;
  --bg-2: #12151c;
  --surface: #181c25;
  --surface-2: #222733;
  --line: #2b3140;
  --text: #f2f3f5;
  --muted: #9aa1b0;
  --accent: #f6b93b;
  --accent-ink: #1b1300;
  --danger: #ff6b5e;
  --ok: #4cd19a;
  --radius: 10px;
  --card-w: clamp(118px, 15.5vw, 188px);
  --pad: clamp(16px, 4vw, 56px);
  --top-h: 64px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 400 16px/1.5 "Heebo", "Assistant", "Segoe UI", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
body.locked { overflow: hidden; }
a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3 { margin: 0; line-height: 1.2; text-wrap: balance; }
[hidden] { display: none !important; }
svg { width: 1.25em; height: 1.25em; fill: currentColor; flex: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

/* ------------------------------------------------------------ top bar */
#topbar {
  position: fixed; inset: 0 0 auto 0; z-index: 30;
  height: var(--top-h);
  display: flex; align-items: center; gap: 28px;
  padding: 0 var(--pad);
  background: linear-gradient(#0b0d12e6, #0b0d1200);
  transition: background .25s;
}
#topbar.solid { background: #0b0d12f2; backdrop-filter: blur(10px); box-shadow: 0 1px 0 #ffffff0d; }
.brand { font-weight: 900; font-size: 1.35rem; color: var(--accent); letter-spacing: -.01em; white-space: nowrap; }
#nav { display: flex; align-items: center; gap: 22px; }
#nav a, .menu-btn {
  background: none; border: 0; padding: 6px 0; color: #d5d8df; font-weight: 500; font-size: .98rem;
  white-space: nowrap;
}
#nav a:hover, .menu-btn:hover, #nav a.on { color: #fff; }
#nav a.on { font-weight: 700; }
.menu { position: relative; }
.menu-btn::after { content: "▾"; margin-inline-start: 4px; font-size: .8em; }
.menu-pop {
  position: absolute; top: calc(100% + 6px); inset-inline-start: -12px; z-index: 5;
  display: none; grid-template-columns: repeat(3, max-content); gap: 2px 20px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 18px; box-shadow: 0 16px 40px #000a;
}
.menu.open .menu-pop { display: grid; }
.menu-pop a { padding: 5px 0 !important; font-weight: 400 !important; }
.menu-pop small { color: var(--muted); margin-inline-start: 6px; font-size: .78em; }
.top-actions { margin-inline-start: auto; display: flex; align-items: center; gap: 10px; }
#searchInput {
  width: clamp(150px, 24vw, 300px); height: 38px;
  background: #0006; border: 1px solid #ffffff2e; border-radius: 999px;
  padding: 0 16px; outline: none;
}
#searchInput:focus { border-color: var(--accent); background: #000a; }
#searchInput::placeholder { color: #a9afbc; }
.icon-btn {
  display: inline-grid; place-items: center; width: 38px; height: 38px;
  border-radius: 50%; background: none; border: 0; color: #d5d8df;
}
.icon-btn:hover { background: #ffffff1a; color: #fff; }
#tabbar { display: none; }

/* ------------------------------------------------------------ hero */
.hero {
  position: relative; min-height: min(78vh, 720px);
  display: flex; align-items: flex-end;
  padding: calc(var(--top-h) + 40px) var(--pad) 72px;
  isolation: isolate; overflow: hidden;
}
.hero-bg { position: absolute; inset: 0; z-index: -2; background: var(--bg-2) center 22% / cover no-repeat; transition: opacity .6s; }
.hero-bg.ph { background: radial-gradient(120% 90% at 20% 10%, hsl(var(--h) 55% 30%), transparent 60%), radial-gradient(90% 80% at 85% 30%, hsl(calc(var(--h) + 50) 50% 22%), transparent 65%), var(--bg-2); }
.hero::after {
  content: ""; position: absolute; inset: 0; z-index: -1;
  background:
    linear-gradient(to top, var(--bg) 0%, #0b0d12cc 22%, #0b0d1200 55%),
    linear-gradient(to left, #0b0d12e6 0%, #0b0d1299 38%, #0b0d1200 70%);
}
.hero-body { max-width: 640px; }
.hero h1 { font-size: clamp(2rem, 5.2vw, 4rem); font-weight: 900; letter-spacing: -.02em; text-shadow: 0 2px 24px #000a; }
.hero .sub { color: #d0d4dc; margin-top: 4px; font-size: 1.05rem; direction: ltr; text-align: right; unicode-bidi: plaintext; }
.meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; color: #d0d4dc; font-size: .95rem; margin: 14px 0; }
.meta .star { color: var(--accent); font-weight: 700; }
.meta .tag { border: 1px solid #ffffff55; border-radius: 4px; padding: 0 6px; font-size: .78rem; font-weight: 700; line-height: 1.55; }
.hero p { margin: 0 0 22px; color: #e3e6eb; font-size: 1.05rem; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; text-shadow: 0 1px 12px #000c; }
.hero-dots { position: absolute; bottom: 58px; inset-inline-end: var(--pad); display: flex; gap: 8px; z-index: 2; }
.hero-dots button { width: 26px; height: 20px; border: 0; padding: 8px 0; background: #ffffff40 content-box; border-radius: 2px; }
.hero-dots button.on { background-color: var(--accent); }

.btns { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  height: 46px; padding: 0 22px; border-radius: 8px; border: 0;
  background: #ffffff26; color: #fff; font-weight: 700; white-space: nowrap;
  transition: background .15s, transform .1s;
}
.btn:hover { background: #ffffff3d; }
.btn:active { transform: scale(.97); }
.btn.primary { background: #fff; color: #111; }
.btn.primary:hover { background: #e4e4e4; }
.btn.accent { background: var(--accent); color: var(--accent-ink); }
.btn.accent:hover { background: #ffc955; }
.btn.small { height: 36px; padding: 0 14px; font-size: .9rem; font-weight: 500; }
.btn small { font-weight: 400; opacity: .75; font-size: .82em; }
.btn.ghost { background: none; border: 1px solid var(--line); }
.btn.ghost:hover { background: #ffffff14; }
.btn.danger { color: var(--danger); }
.btn[disabled] { opacity: .5; cursor: default; }
.round {
  display: inline-grid; place-items: center; width: 46px; height: 46px; border-radius: 50%;
  background: #0006; border: 2px solid #ffffff66; color: #fff; padding: 0;
}
.round:hover { border-color: #fff; background: #ffffff1f; }
.round.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }

/* ------------------------------------------------------------ rows + cards */
.rows { position: relative; margin-top: -36px; padding-bottom: 60px; }
.row { margin-bottom: 30px; position: relative; }
.row-head { display: flex; align-items: baseline; gap: 14px; padding: 0 var(--pad); margin-bottom: 10px; }
.row-head h2 { font-size: clamp(1.1rem, 2vw, 1.4rem); font-weight: 700; }
.row-head a { color: var(--muted); font-size: .85rem; }
.row-head a:hover { color: var(--accent); }
.strip {
  display: flex; gap: 12px; overflow-x: auto; overscroll-behavior-x: contain;
  padding: 6px var(--pad) 10px; scroll-padding: 0 var(--pad);
  scroll-snap-type: x proximity; scrollbar-width: none;
}
.strip::-webkit-scrollbar { display: none; }
.strip > .card { flex: 0 0 var(--card-w); scroll-snap-align: start; }
.row-nav {
  position: absolute; top: 44px; bottom: 58px; width: calc(var(--pad) - 4px); min-width: 34px; z-index: 3;
  border: 0; color: #fff; font-size: 2rem; opacity: 0; transition: opacity .2s;
  background: linear-gradient(to var(--dir), #0b0d12f2, #0b0d1200);
}
.row-nav.prev { inset-inline-start: 0; --dir: left; }
.row-nav.next { inset-inline-end: 0; --dir: right; }
.row:hover .row-nav { opacity: 1; }
@media (hover: none) { .row-nav { display: none; } }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(var(--card-w), 1fr)); gap: 22px 12px; }
.card { display: block; min-width: 0; }
.poster {
  position: relative; aspect-ratio: 2 / 3; border-radius: var(--radius); overflow: hidden;
  background: var(--surface); box-shadow: 0 6px 18px #0008;
  transition: transform .18s, box-shadow .18s;
}
.card:hover .poster, .card:focus-visible .poster { transform: translateY(-4px) scale(1.03); box-shadow: 0 14px 30px #000c, 0 0 0 2px #ffffff55; }
.poster img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ph {
  position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: flex-end;
  padding: 12px;
  background:
    radial-gradient(130% 80% at 80% 0%, hsl(var(--h) 60% 38%), transparent 62%),
    linear-gradient(160deg, hsl(calc(var(--h) + 40) 42% 20%), hsl(calc(var(--h) - 20) 46% 11%));
}
.ph::before { content: ""; position: absolute; inset: 0; background: linear-gradient(to top, #000a, #0000 60%); }
.ph b { position: relative; font-weight: 900; font-size: clamp(.9rem, 1.5vw, 1.15rem); line-height: 1.2; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.ph small { position: relative; color: #ffffffb3; font-size: .78rem; margin-top: 4px; }
.chip {
  position: absolute; top: 7px; font-size: .7rem; font-weight: 700; line-height: 1;
  padding: 4px 6px; border-radius: 5px; background: #000c; color: #fff;
}
.chip.q { inset-inline-start: 7px; }
.chip.r { inset-inline-end: 7px; color: var(--accent); }
.chip.w { top: auto; bottom: 9px; inset-inline-end: 7px; background: var(--ok); color: #03130c; }
.prog { position: absolute; inset: auto 0 0 0; height: 4px; background: #ffffff33; }
.prog i { display: block; height: 100%; background: var(--accent); }
.cap { padding: 8px 2px 0; }
.cap b { display: block; font-weight: 500; font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cap small { color: var(--muted); font-size: .78rem; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ------------------------------------------------------------ pages */
.page { padding: calc(var(--top-h) + 24px) var(--pad) 80px; min-height: 100vh; }
.page > h1 { font-size: clamp(1.5rem, 3vw, 2.1rem); font-weight: 900; margin-bottom: 18px; }
.page h2.sec { font-size: 1.2rem; margin: 34px 0 14px; }
.count { color: var(--muted); font-weight: 400; font-size: 1rem; margin-inline-start: 8px; }
.filters { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 24px; align-items: center; }
.filters select, .field input, .field select {
  height: 40px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 0 12px;
}
.filters select:focus, .field input:focus { border-color: var(--accent); outline: none; }
.toggle { display: inline-flex; align-items: center; gap: 8px; height: 40px; padding: 0 14px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); cursor: pointer; user-select: none; }
.toggle input { accent-color: var(--accent); width: 16px; height: 16px; }
.empty { color: var(--muted); padding: 60px 0; text-align: center; }
.empty b { display: block; color: var(--text); font-size: 1.2rem; margin-bottom: 6px; }
.spinner { width: 34px; height: 34px; border: 3px solid #ffffff22; border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; margin: 80px auto; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { * { animation-duration: .01ms !important; transition-duration: .01ms !important; scroll-behavior: auto !important; } }

/* ------------------------------------------------------------ movie modal */
.modal { position: fixed; inset: 0; z-index: 50; overflow-y: auto; background: #000000b8; padding: 4vh 16px 8vh; overscroll-behavior: contain; }
.sheet { position: relative; max-width: 940px; margin: 0 auto; background: var(--bg-2); border-radius: 14px; overflow: hidden; box-shadow: 0 30px 80px #000; animation: rise .22s ease-out; }
@keyframes rise { from { transform: translateY(18px); opacity: 0; } }
.sheet-close { position: absolute; top: 14px; inset-inline-end: 14px; z-index: 4; width: 40px; height: 40px; border-radius: 50%; border: 0; background: #000b; color: #fff; display: grid; place-items: center; }
.sheet-close:hover { background: #000; }
.sheet-top { position: relative; min-height: 380px; display: flex; align-items: flex-end; padding: 28px clamp(18px, 4vw, 40px); isolation: isolate; }
.sheet-top .hero-bg { background-position: center 20%; }
.sheet-top::after { content: ""; position: absolute; inset: 0; z-index: -1; background: linear-gradient(to top, var(--bg-2) 2%, #12151cd9 30%, #12151c33 70%, #12151c00); }
.sheet-top.trailer { min-height: 0; padding: 0; aspect-ratio: 16 / 9; }
.sheet-top.trailer::after { display: none; }
.sheet-top iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.sheet-head { display: flex; gap: 22px; align-items: flex-end; width: 100%; }
.sheet-head .mini { flex: none; width: 150px; border-radius: 8px; overflow: hidden; box-shadow: 0 10px 30px #000c; }
.sheet-head .mini img { display: block; width: 100%; }
.sheet-head h1 { font-size: clamp(1.6rem, 4vw, 2.6rem); font-weight: 900; }
.sheet-head .sub { color: #c9cdd6; direction: ltr; text-align: right; unicode-bidi: plaintext; }
.sheet-body { padding: 6px clamp(18px, 4vw, 40px) 36px; }
.sheet-body .overview { font-size: 1.04rem; color: #e3e6eb; margin: 18px 0; max-width: 70ch; white-space: pre-line; }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 18px 0; font-size: .95rem; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }
.facts a:hover { color: var(--accent); text-decoration: underline; }
.pill { display: inline-block; padding: 2px 10px; border-radius: 999px; border: 1px solid var(--line); font-size: .82rem; margin: 0 0 4px 4px; }
a.pill:hover { border-color: var(--accent); color: var(--accent); }
.pill.warn { border-color: #ff6b5e66; color: #ffb3ab; }
.note { background: var(--surface); border-inline-start: 3px solid var(--accent); border-radius: 6px; padding: 10px 14px; color: #dfe2e8; font-size: .95rem; margin: 14px 0; }
.note.bad { border-color: var(--danger); }
.note a { color: var(--accent); text-decoration: underline; }

.files { display: grid; gap: 8px; }
.file { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; background: var(--surface); border: 1px solid transparent; border-radius: 10px; padding: 10px 14px; }
.file.best { border-color: #f6b93b80; }
.file .ql { font-weight: 900; font-size: 1.05rem; min-width: 64px; }
.file .info { flex: 1 1 220px; min-width: 0; color: var(--muted); font-size: .86rem; }
.file .info b { color: var(--text); font-weight: 500; }
.file .fname { direction: ltr; text-align: right; unicode-bidi: plaintext; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; opacity: .75; font-size: .78rem; }
.file .acts { display: flex; gap: 6px; flex-wrap: wrap; }

/* ------------------------------------------------------------ player */
.player { position: fixed; inset: 0; z-index: 80; background: #000; display: flex; flex-direction: column; }
.player video { flex: 1; min-height: 0; width: 100%; background: #000; }
.player-bar { display: flex; align-items: center; gap: 12px; padding: 10px 16px; background: #0b0d12; flex-wrap: wrap; }
.player-bar h2 { font-size: 1rem; font-weight: 500; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.player-bar select { height: 36px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 0 10px; }
.player-msg { position: absolute; inset: 60px 0 0; display: grid; place-items: center; padding: 20px; text-align: center; pointer-events: none; }
.player-msg > div { pointer-events: auto; max-width: 560px; background: #12151cf2; border: 1px solid var(--line); border-radius: 14px; padding: 26px; }
.player-msg h3 { margin-bottom: 8px; }
.player-msg p { color: var(--muted); margin: 0 0 18px; }
.player-msg .btns { justify-content: center; }

/* ------------------------------------------------------------ settings */
.panel { background: var(--bg-2); border: 1px solid var(--line); border-radius: 14px; padding: 24px; margin-bottom: 20px; max-width: 820px; }
.panel h2 { font-size: 1.2rem; margin-bottom: 4px; display: flex; align-items: center; gap: 10px; }
.panel > p { color: var(--muted); margin: 0 0 16px; }
.panel ol { color: #cfd3db; padding-inline-start: 20px; margin: 0 0 16px; }
.panel ol a, .panel p a { color: var(--accent); text-decoration: underline; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); }
.dot.ok { background: var(--ok); }
.dot.busy { background: var(--accent); animation: pulse 1s infinite alternate; }
@keyframes pulse { to { opacity: .35; } }
.field { display: grid; gap: 6px; margin-bottom: 12px; max-width: 460px; }
.field label { font-size: .88rem; color: var(--muted); }
.field input { width: 100%; }
.field input[dir="ltr"] { text-align: left; }
.bar { height: 10px; border-radius: 5px; background: var(--surface-2); overflow: hidden; margin: 14px 0 8px; }
.bar i { display: block; height: 100%; background: var(--accent); transition: width .5s; }
.kv { display: flex; flex-wrap: wrap; gap: 8px 28px; color: var(--muted); font-size: .92rem; }
.kv b { color: var(--text); font-size: 1.25rem; display: block; }
.err { color: var(--danger); margin: 8px 0; }

/* ------------------------------------------------------------ login + toasts */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login form { width: min(380px, 100%); background: var(--bg-2); border: 1px solid var(--line); border-radius: 16px; padding: 32px; display: grid; gap: 14px; }
.login h1 { color: var(--accent); font-weight: 900; }
#toasts { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); z-index: 100; display: grid; gap: 8px; width: min(92vw, 460px); pointer-events: none; }
.toast { background: #fff; color: #111; border-radius: 10px; padding: 12px 16px; font-weight: 500; box-shadow: 0 10px 30px #000a; animation: rise .2s ease-out; pointer-events: auto; }
.toast a { color: #8a5a00; text-decoration: underline; font-weight: 700; }

/* ------------------------------------------------------------ small screens */
@media (max-width: 760px) {
  :root { --top-h: 56px; --card-w: clamp(104px, 29vw, 150px); }
  #nav { display: none; }
  #topbar { gap: 12px; }
  #searchInput { width: 100%; }
  .top-actions { flex: 1; }
  #searchForm { flex: 1; }
  #settingsLink { display: none; }
  #tabbar {
    position: fixed; inset: auto 0 0 0; z-index: 40; display: grid; grid-template-columns: repeat(5, 1fr);
    background: #0b0d12f5; border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom);
  }
  #tabbar a { text-align: center; padding: 12px 0; font-size: .82rem; color: var(--muted); }
  #tabbar a.on { color: var(--accent); font-weight: 700; }
  .page, .rows { padding-bottom: 110px; }
  .hero { min-height: 68vh; padding-bottom: 60px; }
  .hero::after { background: linear-gradient(to top, var(--bg) 4%, #0b0d12d9 38%, #0b0d1233 75%); }
  .modal { padding: 0; }
  .sheet { border-radius: 0; min-height: 100%; }
  .sheet-head .mini { display: none; }
  .sheet-top { min-height: 300px; }
  .menu-pop { grid-template-columns: repeat(2, max-content); }
  #toasts { bottom: 84px; }
}
