:root {
  --bg: #101216; --panel: #181b21; --panel-2: #20242c; --line: #2b3039;
  --text: #e9ecf1; --muted: #9aa3b2; --accent: #4fb3ff; --accent-ink: #06243a; --bad: #ff7b72; --ok: #7ee787;
  --radius: 10px; --gutter: clamp(16px, 3vw, 40px);
  color-scheme: dark;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 system-ui, "Segoe UI", Roboto, sans-serif; }
body.no-scroll { overflow: hidden; }
body.has-music main { padding-bottom: 110px; }
a { color: inherit; text-decoration: none; }
h1 { font-size: clamp(22px, 3vw, 32px); margin: 0 0 6px; line-height: 1.2; }
h2 { font-size: 18px; margin: 0 0 10px; }
h3 { font-size: 14px; margin: 18px 0 8px; color: var(--muted); font-weight: 600; }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* top bar */
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 16px; padding: 10px var(--gutter);
  background: rgba(16, 18, 22, .92); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.logo { font-weight: 700; font-size: 18px; color: var(--accent); white-space: nowrap; }
.logo.big { font-size: 28px; text-align: center; margin-bottom: 8px; }
.topbar nav { display: flex; gap: 4px; flex: 1; overflow-x: auto; scrollbar-width: none; }
.topbar nav a { padding: 6px 12px; border-radius: 999px; color: var(--muted); white-space: nowrap; }
.topbar nav a:hover { color: var(--text); background: var(--panel-2); }
.topbar nav a.on { color: var(--text); background: var(--panel-2); }
.search { background: var(--panel); border: 1px solid var(--line); border-radius: 999px; padding: 7px 14px; width: min(260px, 40vw); }
.user { display: flex; align-items: center; gap: 10px; color: var(--muted); white-space: nowrap; }

main { padding: 22px var(--gutter) 60px; transition: opacity .15s; min-height: 60vh; }
main.loading { opacity: .55; }

/* buttons */
.btn { background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 9px 16px; cursor: pointer; min-height: 40px; }
.btn:hover { border-color: #46505f; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 650; }
.btn.ghost { background: transparent; }
.btn.ghost.on { color: var(--accent); border-color: var(--accent); }
.btn.small { padding: 4px 10px; min-height: 30px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: wait; }
select { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; min-height: 40px; }

/* rows + cards */
.row { margin-bottom: 30px; }
.row h2 a:hover { color: var(--accent); }
.scroller { display: flex; gap: 14px; overflow-x: auto; padding-bottom: 8px; scroll-snap-type: x proximity; }
.scroller .card { flex: 0 0 auto; scroll-snap-align: start; }
.grid { display: grid; gap: 18px 14px; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
.card { display: block; width: 150px; }
.grid .card { width: auto; }
.card.wide { width: 250px; } .grid .card.wide { width: auto; }
.grid:has(.card.wide) { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.thumb { position: relative; border-radius: var(--radius); overflow: hidden; background: var(--panel-2); aspect-ratio: 2 / 3; }
.card.wide .thumb, .episode .thumb { aspect-ratio: 16 / 9; }
.card.square .thumb { aspect-ratio: 1; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.card:hover .thumb { outline: 2px solid var(--accent); }
.ph { width: 100%; height: 100%; display: grid; place-items: center; padding: 10px; text-align: center; color: var(--muted);
  font-size: 13px; background: linear-gradient(145deg, #232833, #171a20); overflow: hidden; }
.progress { position: absolute; left: 0; right: 0; bottom: 0; height: 4px; background: rgba(0, 0, 0, .6); }
.progress i { display: block; height: 100%; background: var(--accent); }
.badge { position: absolute; top: 6px; right: 6px; background: var(--accent); color: var(--accent-ink); border-radius: 999px;
  width: 22px; height: 22px; display: grid; place-items: center; font-size: 13px; font-weight: 700; }
.badge.inline { position: static; display: inline-grid; margin-left: 8px; width: 18px; height: 18px; font-size: 11px; }
.card-title { margin-top: 7px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-sub { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-height: 1.4em; }

.toolbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.toolbar h1 { margin: 0; }
.spacer { flex: 1; }
.tabs { display: flex; gap: 4px; flex-wrap: wrap; }
.tabs > * { padding: 6px 14px; border-radius: 999px; border: 1px solid var(--line); background: transparent; cursor: pointer; color: var(--muted); }
.tabs > .on { background: var(--panel-2); color: var(--text); border-color: #46505f; }
.pager { display: flex; align-items: center; gap: 14px; justify-content: center; margin-top: 24px; }
.count, .empty { color: var(--muted); }
.empty { padding: 30px 0; }

/* detail */
.detail { position: relative; }
.backdrop { position: absolute; inset: -22px calc(var(--gutter) * -1) auto; height: 420px; background-size: cover; background-position: center 20%;
  opacity: .28; mask-image: linear-gradient(#000 30%, transparent); -webkit-mask-image: linear-gradient(#000 30%, transparent); pointer-events: none; }
.detail-head { position: relative; display: flex; gap: 28px; align-items: flex-start; margin-bottom: 30px; }
.poster { width: min(240px, 34vw); border-radius: var(--radius); box-shadow: 0 10px 40px rgba(0, 0, 0, .5); aspect-ratio: 2 / 3; object-fit: cover; }
.poster.square { aspect-ratio: 1; }
.detail-text { flex: 1; min-width: 0; }
.crumb { color: var(--accent); font-weight: 600; }
.meta { color: var(--muted); margin-bottom: 10px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.chip { border: 1px solid var(--line); background: var(--panel); border-radius: 999px; padding: 3px 11px; font-size: 13px; }
.chip.person small { color: var(--muted); margin-left: 6px; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; margin: 16px 0; }
.overview { max-width: 70ch; color: #cfd5df; }

.episodes { display: grid; gap: 10px; margin-top: 14px; }
.episode { display: flex; gap: 14px; text-align: left; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 10px; cursor: pointer; width: 100%; }
.episode:hover { border-color: var(--accent); }
.episode .thumb { flex: 0 0 180px; }
.ep-title { font-weight: 600; } .ep-sub { color: var(--muted); font-size: 13px; }
.ep-text p { margin: 6px 0 0; color: #c3cad6; font-size: 14px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

.tracks { display: grid; }
.track { display: flex; align-items: center; gap: 14px; padding: 10px 12px; background: transparent; border: 0; border-bottom: 1px solid var(--line);
  text-align: left; cursor: pointer; width: 100%; min-height: 48px; }
.track:hover { background: var(--panel); }
.track-no { width: 26px; color: var(--muted); text-align: right; }
.track-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.track-name small { display: block; color: var(--muted); overflow: hidden; text-overflow: ellipsis; }
.track-plays, .track-len { color: var(--muted); font-variant-numeric: tabular-nums; font-size: 13px; }

/* login */
.login { max-width: 340px; margin: 14vh auto 0; padding: 0 16px; display: grid; gap: 12px; }
.login input { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; }
.form-error { color: var(--bad); min-height: 1.5em; margin: 0; }

/* video player */
.player { position: fixed; inset: 0; z-index: 100; background: #000; display: flex; flex-direction: column; }
.player-bar { display: flex; align-items: center; gap: 14px; padding: 8px 14px; background: #0b0c0f; }
.player-title { flex: 1; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.player-note { color: var(--muted); font-size: 13px; }
.player video { flex: 1; min-height: 0; width: 100%; background: #000; }

/* music bar */
.musicbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 50; display: flex; align-items: center; gap: 14px;
  padding: 10px var(--gutter); padding-bottom: max(10px, env(safe-area-inset-bottom)); background: #0d0f13; border-top: 1px solid var(--line); }
.mb-art { width: 52px; height: 52px; border-radius: 6px; object-fit: cover; flex: 0 0 auto; }
.mb-art.ph { font-size: 22px; padding: 0; }
.mb-meta { min-width: 0; flex: 0 1 240px; }
.mb-title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mb-sub, .mb-time, .mb-count { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-variant-numeric: tabular-nums; }
.mb-controls { display: flex; align-items: center; gap: 4px; }
.icon { background: transparent; border: 0; border-radius: 999px; width: 44px; height: 44px; font-size: 18px; cursor: pointer; display: grid; place-items: center; }
.icon:hover { background: var(--panel-2); }
.icon.big { background: var(--accent); color: var(--accent-ink); width: 48px; height: 48px; }
.icon.on { color: var(--accent); }
.mb-seek { flex: 1; min-width: 60px; accent-color: var(--accent); }

.toast { position: fixed; left: 50%; bottom: 120px; transform: translateX(-50%); z-index: 200; background: var(--panel-2); border: 1px solid var(--line);
  padding: 10px 16px; border-radius: 8px; max-width: min(90vw, 520px); box-shadow: 0 8px 30px rgba(0, 0, 0, .5); }
.toast.bad { border-color: var(--bad); }

@media (max-width: 700px) {
  .topbar { gap: 10px; }
  .topbar nav { order: 3; flex-basis: 100%; }
  .search { flex: 1; width: auto; min-width: 0; }
  .topbar { flex-wrap: wrap; }
  .user { flex: 0 0 auto; }
  .user span { display: none; }
  .detail-head { flex-direction: column; gap: 16px; }
  .poster { width: 46vw; }
  .episode .thumb { flex-basis: 120px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 14px 10px; }
  .card { width: 118px; } .card.wide { width: 200px; }
  .musicbar { flex-wrap: wrap; gap: 8px 10px; }
  .mb-meta { flex: 1 1 0; }
  .mb-seek { order: 5; flex-basis: 100%; }
  .mb-count, .mb-time { display: none; }
}
@media (prefers-reduced-motion: reduce) { main { transition: none; } }

/* accounts: sign-in, my account, admin */
.signin-wrap { max-width: 720px; margin: 9vh auto 0; padding: 0 16px; text-align: center; }
.signin h1 { margin: 6px 0 22px; }
.profiles { display: flex; flex-wrap: wrap; gap: 18px; justify-content: center; margin-bottom: 26px; }
.profile { display: grid; gap: 10px; justify-items: center; background: transparent; border: 0; cursor: pointer; padding: 10px; border-radius: var(--radius); width: 128px; }
.profile:hover { background: var(--panel); }
.profile span:last-child { font-weight: 600; overflow: hidden; text-overflow: ellipsis; max-width: 100%; white-space: nowrap; }
.avatar { display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 12px; background: linear-gradient(145deg, #2b6ea3, #1b3f63);
  font-weight: 700; font-size: 15px; flex: 0 0 auto; color: #fff; }
.avatar.big { width: 84px; height: 84px; font-size: 30px; border-radius: 20px; }
.login { margin-top: 0; text-align: left; }
.login h1 { text-align: center; }
.login-who { display: grid; justify-items: center; gap: 8px; margin-bottom: 6px; }
.link { background: none; border: 0; color: var(--accent); cursor: pointer; padding: 8px; min-height: 40px; }
.link:hover { text-decoration: underline; }
.user-name { color: var(--text); font-weight: 600; padding: 4px 6px; border-radius: 6px; }
.user-name:hover { background: var(--panel-2); }

.settings { max-width: 900px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 18px; }
.panel.who { display: flex; align-items: center; gap: 16px; }
.muted { color: var(--muted); font-size: 13px; }
.form { display: grid; gap: 14px; max-width: 460px; }
.field { display: grid; gap: 5px; }
.field > span { font-weight: 600; font-size: 14px; }
.field small { color: var(--muted); }
.field input:not([type=checkbox]), .field select, .modal input:not([type=checkbox]) { background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; min-height: 42px; width: 100%; }
.mono { font-family: ui-monospace, Consolas, monospace; letter-spacing: .5px; }
.check { display: flex; align-items: center; gap: 9px; min-height: 34px; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); }
.checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); padding-left: 27px; }
.users { padding: 0; }
.user-row { display: flex; align-items: center; gap: 14px; padding: 14px 18px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.user-row:last-child { border-bottom: 0; }
.user-main { flex: 1 1 260px; min-width: 0; display: grid; gap: 2px; }
.user-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.tag { display: inline-block; margin-left: 8px; padding: 1px 8px; border-radius: 999px; font-size: 12px; border: 1px solid var(--line); color: var(--muted); }
.tag.admin { color: #ffd479; border-color: #6b5520; } .tag.kid { color: var(--ok); border-color: #2f5e36; }
.status { font-size: 13px; } .status.ok { color: var(--ok); } .status.bad { color: var(--bad); }
.btn.danger { color: var(--bad); border-color: #6b2f2b; }
.btn.danger:hover { background: #3a1c1a; }
.modal { position: fixed; inset: 0; margin: auto; height: fit-content; background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 14px; padding: 22px; width: min(520px, calc(100vw - 32px)); max-height: calc(100vh - 40px); overflow: auto; }
.modal::backdrop { background: rgba(0, 0, 0, .65); }
.modal h2 { margin-bottom: 12px; }
.modal .form { max-width: none; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; margin-top: 16px; }
[hidden] { display: none !important; }
.secret { font-size: 20px; background: var(--bg); border: 1px dashed var(--line); border-radius: 8px; padding: 12px; text-align: center; user-select: all; }
.center { text-align: center; margin: 0; }
.btn.sso { display: block; margin: 0 auto 10px; border-color: var(--accent); color: var(--accent); background: transparent; }
