:root {
  --bg: #0b1422; --stage: #0f1a2b; --ink: #ece8df; --dim: #8a97ab; --faint: #22324a; --line: #1d2b40;
  --yellow: #f4d35e; --blue: #58c4dd; --teal: #4fd1b5; --red: #f0645a;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.55 Inter, system-ui, sans-serif; }
main { max-width: 1120px; margin: 0 auto; padding: 0 16px 48px; }
a { color: var(--blue); }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
.top h1 { font-size: 22px; margin: 22px 0 2px; font-weight: 700; }
.top p { margin: 0 0 14px; color: var(--dim); font-size: 15px; }

/* player */
.player { background: #070d17; border-radius: 10px; overflow: hidden; }
.stage { position: relative; width: 100%; aspect-ratio: 16 / 9; background: var(--stage); overflow: hidden; cursor: pointer; }
.stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.layer { position: absolute; left: 0; top: 0; width: 1280px; height: 720px; transform-origin: 0 0; pointer-events: none; }
.layer .obj { position: absolute; inset: 0; }
.lbl { position: absolute; white-space: nowrap; line-height: 1.25; text-align: center; }
.lbl.caps { text-transform: uppercase; letter-spacing: 0.12em; }
.lbl.left { text-align: left; }
.lbl .katex { font-size: 1.1em; }
.big { position: absolute; inset: 0; margin: auto; width: 96px; height: 96px; border-radius: 50%; background: rgba(244, 211, 94, 0.95); display: grid; place-items: center; box-shadow: 0 6px 30px rgba(0,0,0,.4); }
.big svg { width: 48px; height: 48px; fill: #0f1a2b; margin-left: 5px; }
.big[hidden] { display: none; }
.spin { position: absolute; right: 14px; top: 14px; width: 22px; height: 22px; border: 3px solid rgba(255,255,255,.25); border-top-color: var(--ink); border-radius: 50%; animation: sp 0.8s linear infinite; }
@keyframes sp { to { transform: rotate(360deg); } }
.cap { min-height: 3.4em; padding: 10px 16px 4px; text-align: center; font-size: 17px; line-height: 1.45; color: var(--ink); }
.cap.off { visibility: hidden; }
.bar { padding: 0 10px 8px; }
.scrub { position: relative; height: 22px; display: flex; align-items: center; cursor: pointer; touch-action: none; }
.track { position: relative; width: 100%; height: 5px; background: #2a3950; border-radius: 3px; }
.fill { position: absolute; left: 0; top: 0; bottom: 0; background: var(--yellow); border-radius: 3px; }
.ticks i { position: absolute; top: -2px; width: 2px; height: 9px; background: #0b1422; }
.thumb { position: absolute; top: 50%; width: 14px; height: 14px; margin: -7px 0 0 -7px; border-radius: 50%; background: var(--yellow); }
.tip { position: absolute; bottom: 24px; transform: translateX(-50%); background: #1a2840; color: var(--ink); font-size: 13px; padding: 4px 8px; border-radius: 6px; white-space: nowrap; pointer-events: none; max-width: 80vw; overflow: hidden; text-overflow: ellipsis; }
.row { display: flex; align-items: center; gap: 6px; min-height: 40px; }
.row button { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 6px; }
.row button:hover { background: rgba(255,255,255,.07); }
.row button svg { width: 24px; height: 24px; fill: currentColor; }
.row .txt { width: auto; padding: 0 8px; font-size: 14px; font-weight: 600; color: var(--dim); }
.row .txt.on { color: var(--ink); }
.time { font-variant-numeric: tabular-nums; font-size: 14px; color: var(--dim); white-space: nowrap; }
.chap { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; flex: 0 1 auto; margin-left: 8px; }
.grow { flex: 1; }
.player:fullscreen { display: flex; flex-direction: column; justify-content: center; background: #000; border-radius: 0; }
.player:fullscreen .stage { width: min(100vw, calc((100vh - 130px) * 16 / 9)); margin: 0 auto; }
.player:fullscreen .cap, .player:fullscreen .bar { width: 100%; max-width: 1400px; margin: 0 auto; }

/* current chapter */
.now { padding: 14px 2px 4px; }
.now .k { color: var(--yellow); font-weight: 700; margin-right: 8px; }
.now h2 { font-size: 20px; margin: 0; display: inline; }
.now .off { color: var(--dim); font-size: 15px; margin: 2px 0 0; }
.now details { margin-top: 6px; font-size: 15px; }
.now summary { cursor: pointer; color: var(--dim); }
.now ul { margin: 6px 0 0; padding-left: 20px; }

/* toc */
.toc h2, .about h2 { font-size: 18px; margin: 0; }
.tochead { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 22px 0 8px; }
.tochead h2 { flex: 1 0 auto; }
.tochead input, .tochead select { background: #121e31; color: var(--ink); border: 1px solid var(--faint); border-radius: 6px; padding: 6px 8px; font: inherit; font-size: 15px; min-width: 0; }
.tochead input { width: 180px; }
.plbar { display: flex; align-items: center; gap: 10px; margin: 0 0 10px; font-size: 15px; color: var(--dim); flex-wrap: wrap; }
.plbar span { color: var(--ink); font-weight: 600; flex: 1 1 auto; }
.pf { border: 1px solid var(--faint); border-radius: 999px; padding: 3px 12px; font-size: 14px; color: var(--ink); background: #121e31; white-space: nowrap; }
.pf:hover { border-color: var(--yellow); }
.pf.on { border-color: var(--yellow); color: var(--yellow); }
.endcard { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; background: rgba(11, 20, 34, 0.88); text-align: center; padding: 16px; }
.endcard[hidden] { display: none; }
.endcard p { margin: 0; font-size: clamp(17px, 3vw, 28px); font-weight: 600; }
.endcard button { border: 1px solid var(--yellow); color: var(--yellow); border-radius: 999px; padding: 6px 16px; font-size: 15px; }
.grp { margin-top: 22px; }
.grp[hidden] { display: none; }
.gh { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; padding-bottom: 6px; border-bottom: 1px solid var(--line); }
.gh h3 { margin: 0; font-size: 17px; }
.gh .gc { color: var(--dim); font-size: 13px; flex: 1 1 auto; }
#toc ol { list-style: none; margin: 0; padding: 0; }
#toc li { display: grid; grid-template-columns: 48px 1fr auto; gap: 2px 12px; padding: 10px 6px; border-bottom: 1px solid var(--line); align-items: baseline; }
#toc li.made { cursor: pointer; }
#toc li.made:hover { background: #111d30; }
#toc li.cur { background: #15233a; box-shadow: inset 3px 0 0 var(--yellow); }
#toc .r { color: var(--yellow); font-weight: 700; font-variant-numeric: tabular-nums; text-align: right; }
#toc li.text .r { color: var(--dim); font-weight: 600; }
#toc li.text .o { color: #c9cfd9; }
#toc .s { color: var(--dim); font-size: 13.5px; margin-top: 2px; }
#toc .s a { white-space: nowrap; }
#toc .novid { font-size: 12px; color: var(--dim); border: 1px dashed var(--faint); border-radius: 4px; padding: 0 6px; white-space: nowrap; }
#toc .h { font-weight: 600; }
#toc .o { color: var(--dim); font-size: 14px; }
#toc .m { font-size: 13px; color: var(--dim); display: flex; gap: 8px; align-items: baseline; justify-content: flex-end; }
#toc .ts { font-variant-numeric: tabular-nums; color: var(--ink); font-size: 14px; }
.lean { display: inline-block; font-size: 11px; font-weight: 700; letter-spacing: .05em; color: var(--teal); border: 1px solid var(--teal); border-radius: 4px; padding: 0 5px; line-height: 17px; }
.about { margin-top: 30px; color: #c9cfd9; max-width: 760px; }
.about p { margin: 10px 0; }
.credit { color: var(--dim); }

@media (max-width: 640px) {
  .top h1 { font-size: 19px; }
  .cap { font-size: 15px; min-height: 4.4em; padding: 8px 10px 2px; }
  .chap { display: none; }
  .big { width: 64px; height: 64px; } .big svg { width: 34px; height: 34px; }
  #toc li { grid-template-columns: 34px 1fr; }
  #toc .m { grid-column: 2; justify-content: flex-start; }
  .tochead input { flex: 1; width: auto; }
}
