:root {
  --bg: #17171a; --surface: #1f1f23; --soft: #27272c; --line: #2e2e34;
  --text: #ededf0; --muted: #8e8e96; --accent: #ffb36b; --accent-text: #ffb36b; --ink: #2e1804;
  --good: #6fcf97; --bad: #ff7a70;
  color-scheme: dark;
}
html[data-theme="light"] {
  --bg: #fafafa; --surface: #ffffff; --soft: #f1f1f3; --line: #e5e5e8;
  --text: #18181b; --muted: #6b6b73; --accent-text: #b35a0b; --good: #1d9a5f; --bad: #c9352b;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font: 14.5px/1.55 Geist, system-ui, -apple-system, "Segoe UI", sans-serif; -webkit-font-smoothing: antialiased; min-height: 100vh; }
button, input, select { font: inherit; color: inherit; }
a { color: inherit; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
html[data-theme="light"] #theme .fa-moon, html:not([data-theme="light"]) #theme .fa-sun { display: none; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; animation: none !important; } }

/* ---------------------------------------------------------------- header */
.top { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 16px; padding: 12px 28px; border-bottom: 1px solid var(--line); background: color-mix(in srgb, var(--bg) 90%, transparent); backdrop-filter: blur(12px); }
.logo { font-weight: 700; font-size: 16px; text-decoration: none; display: flex; gap: 8px; align-items: center; flex: none; }
.logo i { color: var(--accent-text); }
.search { flex: 1; max-width: 560px; margin: 0 auto; display: flex; align-items: center; gap: 10px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 0 4px 0 12px; height: 40px; min-width: 0; }
.search:focus-within { border-color: var(--muted); }
.search i { color: var(--muted); font-size: 13px; }
.search input { flex: 1; min-width: 0; border: 0; background: none; outline: 0; }
.search button { border: 0; background: var(--soft); border-radius: 7px; height: 32px; padding: 0 12px; cursor: pointer; font-weight: 500; }
.search button:hover { background: var(--line); }
body[data-state="home"] .search { visibility: hidden; }
.tools { display: flex; gap: 4px; align-items: center; flex: none; margin-left: auto; }
.tools select { background: none; border: 0; color: var(--muted); font-size: 13px; font-weight: 500; cursor: pointer; padding: 6px; }
.tools select option { background: var(--surface); color: var(--text); }
.ib { width: 34px; height: 34px; border: 0; background: none; border-radius: 8px; color: var(--muted); cursor: pointer; display: grid; place-items: center; text-decoration: none; }
.ib:hover { background: var(--soft); color: var(--text); }

.wrap { max-width: 1200px; margin: 0 auto; padding: 28px 28px 140px; }

/* sections are shown by body[data-state] */
.home, .status, .split, .playlist { display: none; }
body[data-state="home"] .home { display: block; }
body[data-state="loading"] #loading, body[data-state="error"] #error { display: flex; }
body[data-state="video"] .split { display: grid; }
body[data-state="playlist"] .playlist { display: block; }
body[data-mode="video"] .only-audio, body[data-mode="audio"] .only-video { display: none !important; }

/* ---------------------------------------------------------------- ads */
.ad-slot { display: none; }
.ad-slot.on { display: block; margin-bottom: 24px; text-align: center; overflow: hidden; }
.panel .ad-slot.on { margin: 8px 0 0; }
.tbl .ad-slot.on { margin: 0; padding: 8px 14px; border-top: 1px solid var(--line); }

/* ---------------------------------------------------------------- home */
.home { max-width: 680px; margin: 10vh auto 0; text-align: center; }
.home h1 { font-size: clamp(28px, 4.2vw, 42px); line-height: 1.1; letter-spacing: -.03em; font-weight: 700; margin: 0 0 14px; }
.home > p { color: var(--muted); font-size: 16px; margin: 0 auto 32px; max-width: 520px; }
.hero-search { display: flex; align-items: center; gap: 12px; height: 60px; padding: 0 7px 0 20px; border-radius: 16px; background: var(--surface); border: 1px solid var(--line); box-shadow: 0 20px 50px -30px #000; }
.hero-search:focus-within { border-color: var(--accent); }
.hero-search > i { color: #f33; font-size: 20px; }
.hero-search input { flex: 1; min-width: 0; border: 0; background: none; outline: 0; font-size: 16px; }
.hero-search button { height: 46px; border: 0; border-radius: 11px; background: var(--accent); color: var(--ink); font-weight: 600; padding: 0 18px; display: flex; gap: 10px; align-items: center; cursor: pointer; }
.home .hint { margin-top: 14px; }
kbd { font: 500 11px Geist, sans-serif; color: var(--muted); border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 5px; padding: 1px 6px; }

/* ---------------------------------------------------------------- status */
.status { min-height: 40vh; flex-direction: column; align-items: center; justify-content: center; gap: 14px; color: var(--muted); text-align: center; }
.status.error i { font-size: 28px; color: var(--bad); }
.status.error p { color: var(--text); max-width: 460px; margin: 0; font-size: 15px; }
.spinner { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { rotate: 360deg; } }
.btn-soft { border: 1px solid var(--line); background: var(--surface); border-radius: 9px; padding: 8px 16px; cursor: pointer; font-weight: 500; }
.btn-soft:hover { background: var(--soft); }

/* ---------------------------------------------------------------- video view */
.split { grid-template-columns: minmax(0, 1fr) 380px; gap: 40px; align-items: start; }
.left { position: sticky; top: 92px; }
.embed { position: relative; aspect-ratio: 16/9; border-radius: 12px; overflow: hidden; background: #000 center/cover no-repeat; }
.embed.short { aspect-ratio: 16/9; background-size: contain; }
.embed iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.cover { position: absolute; inset: 0; border: 0; background: none; cursor: pointer; }
.cover .play { position: absolute; inset: 0; margin: auto; width: 60px; height: 60px; border-radius: 50%; background: #fffffff0; color: #111; display: grid; place-items: center; font-size: 18px; padding-left: 3px; transition: scale .15s; }
.cover:hover .play { scale: 1.08; }
.v-title { font-size: 22px; line-height: 1.3; font-weight: 600; letter-spacing: -.015em; margin: 18px 0 14px; overflow-wrap: anywhere; }
.facts { margin: 0; display: grid; grid-template-columns: auto 1fr; border-top: 1px solid var(--line); }
.facts dt, .facts dd { margin: 0; padding: 9px 0; border-bottom: 1px solid var(--line); }
.facts dt { color: var(--muted); padding-right: 24px; }
.facts dd { text-align: right; font-variant-numeric: tabular-nums; font-weight: 500; min-width: 0; overflow-wrap: anywhere; }
.facts dd a { text-decoration: none; display: inline-flex; gap: 6px; align-items: center; }
.facts dd a:hover { text-decoration: underline; }
.facts dd a i { font-size: 11px; color: var(--muted); }
.tag { font-size: 11px; font-weight: 600; border: 1px solid var(--line); border-radius: 5px; padding: 1px 6px; margin-left: 6px; color: var(--muted); }

.panel { display: grid; gap: 22px; min-width: 0; }
.lab { display: flex; justify-content: space-between; gap: 10px; font-size: 13px; color: var(--muted); margin-bottom: 8px; }
.seg { display: flex; background: var(--soft); border-radius: 9px; padding: 3px; gap: 2px; }
.seg.wrap { flex-wrap: wrap; }
.seg button { flex: 1; border: 0; background: none; border-radius: 7px; padding: 7px 6px; cursor: pointer; color: var(--muted); font-weight: 500; font-size: 13.5px; white-space: nowrap; }
.seg button:hover:not(:disabled) { color: var(--text); }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px #0000002e, 0 0 0 1px var(--line); }
.seg button:disabled { opacity: .35; cursor: not-allowed; }
.seg.q { display: grid; grid-template-columns: repeat(4, 1fr); }
.hint { font-size: 12.5px; color: var(--muted); margin: 8px 0 0; }
.checks { display: flex; flex-wrap: wrap; gap: 8px 18px; }
.checks button { border: 0; background: none; cursor: pointer; display: flex; gap: 8px; align-items: center; padding: 2px 0; text-align: left; }
.cb { width: 16px; height: 16px; flex: none; border-radius: 4px; border: 1.5px solid var(--muted); display: grid; place-items: center; font-size: 9px; color: transparent; }
.checks button[aria-checked="true"] .cb { background: var(--accent); border-color: var(--accent); color: var(--ink); }
.checks small { color: var(--muted); font-size: 12px; }
.checks .more { color: var(--accent-text); font-weight: 500; }
.checks .more:hover { text-decoration: underline; }
.out { border-top: 1px solid var(--line); padding-top: 20px; display: grid; gap: 12px; }
.fname { font-size: 12.5px; color: var(--muted); overflow-wrap: anywhere; }
.fname b { color: var(--text); font-weight: 500; }

.dl { position: relative; overflow: hidden; border: 0; background: var(--accent); color: var(--ink); border-radius: 10px; height: 46px; padding: 0 20px; font-weight: 600; font-size: 15px; cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 10px; white-space: nowrap; }
.dl:hover { filter: brightness(1.05); }
.dl > * { position: relative; }
.dl .bar { position: absolute; inset: 0 auto 0 0; width: 0; background: #0000001f; transition: width .3s; }
.dl.busy { cursor: progress; }
.dl.busy i { animation: bob 1s ease-in-out infinite; }
@keyframes bob { 50% { translate: 0 2px; } }
.msg { font-size: 13px; margin: 0; color: var(--muted); }
.msg.err { color: var(--bad); }
.msg:empty { display: none; }
.cached { font-size: 12.5px; color: var(--muted); display: flex; gap: 8px; align-items: baseline; margin: 0; }
.cached i { color: var(--good); }

/* ---------------------------------------------------------------- playlist */
.pl-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 24px; margin-bottom: 20px; }
.pl-head h1 { font-size: 26px; font-weight: 600; margin: 0 0 4px; letter-spacing: -.015em; overflow-wrap: anywhere; }
.pl-head p { margin: 0; color: var(--muted); }
.pl-embed { width: 340px; flex: none; }
.tbl { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.tr { display: grid; grid-template-columns: 36px minmax(0, 1fr) 70px 120px 120px 100px; gap: 12px; align-items: center; padding: 8px 14px; border-top: 1px solid var(--line); }
.tr:first-child { border-top: 0; }
.tr.head { font-size: 12.5px; color: var(--muted); padding: 10px 14px; }
.tr.all { background: var(--soft); }
.tr.all b { font-weight: 600; }
.tr.playing { box-shadow: inset 3px 0 0 var(--accent); }
.tr .n { color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; }
.tr .t { display: flex; align-items: center; gap: 12px; min-width: 0; }
.tr .th { position: relative; aspect-ratio: 16/9; width: 72px; border-radius: 5px; background: var(--soft) center/cover; flex: none; border: 0; padding: 0; cursor: pointer; }
.tr .th i { position: absolute; inset: 0; display: grid; place-items: center; color: #fff; background: #0006; border-radius: inherit; opacity: 0; transition: opacity .15s; font-size: 12px; }
.tr .th:hover i, .tr .th:focus-visible i, .tr.playing .th i { opacity: 1; }
.tr .t span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tr .d { color: var(--muted); font-variant-numeric: tabular-nums; }
.tr .st { font-size: 12px; color: var(--good); }
.tr .st.err { color: var(--bad); }
.sel { position: relative; min-width: 0; }
.sel select { appearance: none; width: 100%; height: 30px; border-radius: 7px; border: 1px solid var(--line); background: var(--bg); padding: 0 28px 0 10px; cursor: pointer; font-size: 13px; }
.sel::after { content: "\f107"; font: 900 11px "Font Awesome 6 Free"; position: absolute; right: 10px; top: 9px; color: var(--muted); pointer-events: none; }
.sel.inh select { color: var(--muted); border-style: dashed; }
.sel.ovr select { border-color: var(--accent); color: var(--accent-text); }
.sel .mlab { display: none; }
.pl-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 14px; gap: 16px; flex-wrap: wrap; }
.pl-foot > p { margin: 0; color: var(--muted); font-size: 13px; flex: 1 1 280px; }
.pl-go { display: flex; align-items: center; gap: 14px; margin-left: auto; }
.failures { margin-top: 16px; font-size: 13px; color: var(--muted); }
.failures ul { margin: 6px 0 0; padding-left: 18px; }

/* ---------------------------------------------------------------- player */
.player { position: fixed; inset: auto 0 0; z-index: 30; display: grid; grid-template-columns: 1fr minmax(0, 1.5fr) 1fr; gap: 24px; align-items: center; padding: 10px 24px; background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(12px); border-top: 1px solid var(--line); }
body[data-state="home"] .player, body[data-state="loading"] .player, body[data-state="error"] .player { display: none; }
.np { display: flex; align-items: center; gap: 12px; min-width: 0; }
.np .art { width: 44px; height: 44px; border-radius: 6px; background: var(--soft) center/cover; flex: none; }
.np-text { min-width: 0; }
.np b { display: block; font-weight: 500; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.np small { display: block; color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ctr { display: grid; gap: 4px; justify-items: center; }
.btns { display: flex; gap: 14px; align-items: center; }
.btns button, .rs button { border: 0; background: none; color: var(--muted); cursor: pointer; font-size: 14px; width: 30px; height: 30px; border-radius: 50%; }
.btns button:hover:not(:disabled), .rs button:hover { color: var(--text); }
.btns button:disabled { opacity: .3; cursor: default; }
.btns .pp { width: 34px; height: 34px; background: var(--text); color: var(--bg); font-size: 13px; }
.btns .pp:hover:not(:disabled) { color: var(--bg); scale: 1.05; }
.prog { display: flex; gap: 10px; align-items: center; width: 100%; font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.track { flex: 1; height: 4px; border-radius: 4px; background: var(--soft); cursor: pointer; position: relative; }
.track::before { content: ""; position: absolute; inset: -8px 0; }
.track span { display: block; height: 100%; width: 0; background: var(--text); border-radius: inherit; pointer-events: none; }
.player:hover .prog .track span { background: var(--accent); }
.rs { display: flex; justify-content: flex-end; gap: 10px; align-items: center; }
.rs .vol { flex: none; width: 90px; }
.rs .vol span { width: 80%; }

/* ---------------------------------------------------------------- responsive */
@media (max-width: 880px) {
  .top { flex-wrap: wrap; padding: 10px 16px; gap: 8px 10px; }
  .search { order: 3; flex-basis: 100%; max-width: none; }
  body[data-state="home"] .search { display: none; }
  .wrap { padding: 18px 16px 130px; }
  .home { margin-top: 6vh; }
  .hero-search { height: 54px; padding-left: 14px; }
  .hero-search button span { display: none; }
  .split { grid-template-columns: 1fr; gap: 28px; }
  .left { position: static; }
  .pl-head { flex-direction: column-reverse; align-items: stretch; }
  .pl-embed { width: 100%; }
  .tr.head { display: none; }
  .tr { grid-template-columns: 1fr 1fr 1fr; gap: 8px; padding: 12px 14px; }
  .tr .n, .tr .d { display: none; }
  .tr .t { grid-column: 1 / -1; }
  .tr.all .t { grid-column: 1 / -1; }
  .tr > span:empty { display: none; }
  .sel .mlab { display: block; font-size: 11px; color: var(--muted); margin-bottom: 3px; }
  .sel::after { top: auto; bottom: 10px; }
  .pl-go { width: 100%; flex-direction: column-reverse; align-items: stretch; }
  .player { grid-template-columns: minmax(0, 1fr) auto; padding: 8px 14px; gap: 12px; }
  .ctr { display: flex; }
  .ctr .prog, .rs, .btns > :not(.pp) { display: none; }
}
