/* ============================================================
   Learning Path — styles
   Colors are tokens so light/dark both work; scene SVG classes
   (prefixed s-, fill-, stroke-) use the same tokens.
   ============================================================ */

:root {
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;

  --bg: #f5f4f0;
  --surface: #ffffff;
  --surface-2: #efede7;
  --text: #1c1c21;
  --muted: #6c6c75;
  --faint: #b9b6ad;
  --border: #e2dfd6;
  --dot: #e4e1d8;

  --accent: #5b50e6;
  --accent-deep: #4136c4;
  --accent-soft: rgba(91, 80, 230, 0.12);
  --accent2: #0e9488;
  --accent2-soft: rgba(14, 148, 136, 0.12);
  --warm: #e38a0b;
  --warm-soft: rgba(227, 138, 11, 0.14);
  --pos: #1c9a52;
  --pos-soft: rgba(28, 154, 82, 0.12);
  --neg: #de3259;
  --neg-soft: rgba(222, 50, 89, 0.11);

  --shadow: 0 1px 2px rgba(20, 20, 30, 0.05), 0 10px 30px rgba(20, 20, 30, 0.06);
  --radius: 18px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1014;
    --surface: #161920;
    --surface-2: #1f232c;
    --text: #eceef2;
    --muted: #9aa1ae;
    --faint: #4a505d;
    --border: #2a2f3a;
    --dot: #232833;
    --accent: #8d85ff;
    --accent-deep: #5d54d8;
    --accent-soft: rgba(141, 133, 255, 0.16);
    --accent2: #2cc6b6;
    --accent2-soft: rgba(44, 198, 182, 0.14);
    --warm: #f5b441;
    --warm-soft: rgba(245, 180, 65, 0.15);
    --pos: #45d083;
    --pos-soft: rgba(69, 208, 131, 0.14);
    --neg: #ff6d8c;
    --neg-soft: rgba(255, 109, 140, 0.14);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 10px 30px rgba(0, 0, 0, 0.25);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0e1014;
  --surface: #161920;
  --surface-2: #1f232c;
  --text: #eceef2;
  --muted: #9aa1ae;
  --faint: #4a505d;
  --border: #2a2f3a;
  --dot: #232833;
  --accent: #8d85ff;
  --accent-deep: #5d54d8;
  --accent-soft: rgba(141, 133, 255, 0.16);
  --accent2: #2cc6b6;
  --accent2-soft: rgba(44, 198, 182, 0.14);
  --warm: #f5b441;
  --warm-soft: rgba(245, 180, 65, 0.15);
  --pos: #45d083;
  --pos-soft: rgba(69, 208, 131, 0.14);
  --neg: #ff6d8c;
  --neg-soft: rgba(255, 109, 140, 0.14);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 10px 30px rgba(0, 0, 0, 0.25);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 8px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 44px; padding: 0 18px;
  border-radius: 12px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text);
  font-weight: 600; font-size: 15px; cursor: pointer; text-decoration: none;
  transition: transform .15s ease, background .15s ease, border-color .15s ease, opacity .15s;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .4; cursor: default; }
.btn-primary {
  background: var(--accent); border-color: var(--accent); color: #fff;
  box-shadow: 0 3px 0 var(--accent-deep);
}
.btn-primary:hover { background: var(--accent); filter: brightness(1.06); }
.icon-btn {
  width: 40px; height: 40px; padding: 0; display: inline-grid; place-items: center;
  border-radius: 12px; border: 1px solid var(--border); background: var(--surface);
  cursor: pointer; color: var(--text); text-decoration: none; flex: none;
}
.icon-btn:hover { background: var(--surface-2); }
.icon-btn svg { width: 18px; height: 18px; }
.chip-btn {
  height: 40px; min-width: 52px; padding: 0 12px; border-radius: 12px;
  border: 1px solid var(--border); background: var(--surface); cursor: pointer;
  font-family: var(--mono); font-size: 13px; font-weight: 600; flex: none;
}
.chip-btn:hover { background: var(--surface-2); }

/* ============================================================
   HOME — learning path
   ============================================================ */
.home { max-width: 780px; margin: 0 auto; padding: 0 16px 96px; }
.topbar { display: flex; align-items: center; justify-content: space-between; padding: 18px 0; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; letter-spacing: -.01em; }
.brand-mark { width: 28px; height: 28px; border-radius: 8px; background: var(--accent); display: grid; place-items: center; }
.brand-mark svg { width: 18px; height: 18px; }

.hero { padding: 40px 0 8px; animation: rise .6s both; }
.hero .eyebrow { margin-bottom: 12px; }
.hero h1 { font-size: clamp(34px, 6vw, 52px); line-height: 1.04; letter-spacing: -.03em; margin: 0 0 12px; }
.hero p { color: var(--muted); font-size: 18px; margin: 0; max-width: 560px; }
.eyebrow { font-size: 12px; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; color: var(--accent); }

.progress-card {
  margin-top: 28px; display: flex; align-items: center; gap: 18px; flex-wrap: wrap;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 18px; box-shadow: var(--shadow);
}
.progress-card .meta { flex: 1; min-width: 200px; }
.progress-card .meta b { font-size: 15px; }
.progress-card .meta span { color: var(--muted); font-size: 14px; }
.bar { height: 8px; border-radius: 4px; background: var(--surface-2); overflow: hidden; margin-top: 8px; }
.bar i { display: block; height: 100%; width: var(--p, 0%); background: var(--accent); border-radius: 4px; transition: width .8s cubic-bezier(.22,1,.36,1); }

.module { margin-top: 56px; }
.module-head { display: flex; gap: 16px; align-items: flex-start; animation: rise .6s both; }
.module-num {
  flex: none; width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent); font-weight: 800; font-size: 18px;
}
.module-head h2 { margin: 2px 0 4px; font-size: 24px; letter-spacing: -.02em; line-height: 1.2; }
.module-head p { margin: 0; color: var(--muted); }

.path { position: relative; display: flex; flex-direction: column; gap: 30px; padding: 36px 0 8px; --k: 1; }
.path-line { position: absolute; left: 0; top: 0; pointer-events: none; overflow: visible; }
.pl-base { fill: none; stroke: var(--faint); stroke-width: 4; stroke-dasharray: 1 11; stroke-linecap: round; opacity: .8; }
.pl-done { fill: none; stroke: var(--accent); stroke-width: 5; stroke-linecap: round; opacity: .55; }

.node {
  position: relative; left: calc(var(--o) * var(--k) * 1px);
  align-self: center; width: min(380px, 100%);
  display: flex; align-items: center; gap: 18px;
  text-decoration: none; color: inherit; z-index: 1;
  animation: rise .55s both; animation-delay: calc(var(--i) * 60ms + 120ms);
}
.node-dot {
  position: relative; flex: none; width: 70px; height: 70px; border-radius: 50%;
  display: grid; place-items: center; font-weight: 800; font-size: 22px;
  background: var(--surface); color: var(--muted);
  border: 3px solid var(--border); box-shadow: 0 5px 0 var(--border);
  transition: transform .18s ease, box-shadow .18s ease;
}
.node-dot svg { width: 28px; height: 28px; }
.node:hover .node-dot { transform: translateY(-3px); box-shadow: 0 8px 0 var(--border); }
.node.done .node-dot { background: var(--accent); border-color: var(--accent); color: #fff; box-shadow: 0 5px 0 var(--accent-deep); }
.node.done:hover .node-dot { box-shadow: 0 8px 0 var(--accent-deep); }
.node.next .node-dot { border-color: var(--accent); color: var(--accent); box-shadow: 0 5px 0 var(--accent-deep); }
.node.next .node-dot::before {
  content: ""; position: absolute; inset: -10px; border-radius: 50%;
  border: 3px solid var(--accent); opacity: 0; animation: ring 2s ease-out infinite;
}
.node.soon { cursor: default; }
.node.soon .node-dot { border-style: dashed; box-shadow: none; background: transparent; color: var(--faint); }
.node.soon:hover .node-dot { transform: none; box-shadow: none; }
.node.soon .node-label { opacity: .6; }
.node-label b { display: block; font-size: 17px; letter-spacing: -.01em; line-height: 1.25; }
.node-label small { display: block; color: var(--muted); font-size: 14px; margin-top: 2px; }
.node-tag {
  display: inline-block; margin-top: 6px; font-size: 11px; font-weight: 700; letter-spacing: .06em;
  text-transform: uppercase; padding: 3px 8px; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent);
}
.node.done .node-tag { background: var(--pos-soft); color: var(--pos); }

.home-foot { margin-top: 64px; color: var(--muted); font-size: 14px; text-align: center; }
.home-foot button { background: none; border: 0; color: var(--muted); text-decoration: underline; cursor: pointer; padding: 0; font-size: 14px; }

@keyframes rise { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
@keyframes ring { 0% { opacity: .6; transform: scale(.85); } 100% { opacity: 0; transform: scale(1.25); } }

/* ============================================================
   PLAYER
   ============================================================ */
body[data-view="player"] { overflow: hidden; }
.player { height: 100vh; height: 100dvh; display: grid; grid-template-rows: auto minmax(0, 1fr) auto; }
.ptop {
  display: flex; align-items: center; gap: 12px; padding: 12px 20px;
  border-bottom: 1px solid var(--border); background: var(--surface);
}
.ptitle { min-width: 0; flex: 0 1 280px; }
.ptitle b { display: block; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ptitle small { display: block; font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.segs { flex: 1; display: flex; gap: 5px; max-width: 560px; margin: 0 auto; }
.seg {
  flex: 1; height: 8px; border: 0; padding: 0; border-radius: 4px; cursor: pointer;
  background: var(--surface-2); position: relative; overflow: hidden;
}
.seg::after {
  content: ""; position: absolute; inset: 0; background: var(--accent); border-radius: 4px;
  transform: scaleX(0); transform-origin: left; transition: transform .45s cubic-bezier(.22,1,.36,1);
}
.seg.done::after { transform: scaleX(1); opacity: .45; }
.seg.current::after { transform: scaleX(1); }
.seg.quiz { background: var(--warm-soft); }
.ptools { display: flex; gap: 8px; }

.pbody {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(300px, 380px);
  gap: 20px; padding: 20px; min-height: 0;
}
.stage {
  position: relative; min-height: 0; min-width: 0;
  display: flex; flex-direction: column;
  background-color: var(--surface);
  background-image: radial-gradient(var(--dot) 1.2px, transparent 1.3px);
  background-size: 22px 22px;
  border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
  overflow: hidden;
}
.stage > .scene-svg { flex: 1 1 auto; min-height: 0; width: 100%; }
.stage.flash-correct { animation: flashOk .7s ease; }
@keyframes flashOk { 0% { box-shadow: 0 0 0 0 var(--pos); } 40% { box-shadow: 0 0 0 6px var(--pos-soft); } 100% { box-shadow: var(--shadow); } }
.stage-msg { margin: auto; color: var(--muted); padding: 24px; text-align: center; }

.stage-controls {
  flex: none; display: flex; flex-wrap: wrap; gap: 10px 22px; align-items: center; justify-content: center;
  padding: 12px 18px; border-top: 1px solid var(--border); background: var(--surface);
}
.ctl { display: flex; align-items: center; gap: 10px; font-size: 14px; }
.ctl label { font-weight: 600; font-family: var(--mono); }
.ctl output { font-family: var(--mono); min-width: 52px; font-variant-numeric: tabular-nums; color: var(--accent); font-weight: 600; }
.ctl input[type="range"] { width: 160px; accent-color: var(--accent); }
.ctl-btn {
  height: 34px; padding: 0 14px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface-2); cursor: pointer; font-size: 14px; font-weight: 600;
}
.ctl-btn.on { background: var(--accent); border-color: var(--accent); color: #fff; }

.caption { overflow-y: auto; padding: 6px 4px 12px; min-height: 0; }
.caption.enter > * { animation: capIn .5s both; }
.caption.enter > *:nth-child(2) { animation-delay: .05s; }
.caption.enter > *:nth-child(3) { animation-delay: .1s; }
.caption.enter > *:nth-child(4) { animation-delay: .15s; }
@keyframes capIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.cap-step { font-size: 12px; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; color: var(--muted); }
.cap-step.is-quiz { color: var(--warm); }
.cap-title { font-size: 26px; line-height: 1.15; letter-spacing: -.02em; margin: 8px 0 14px; }
.cap-body { font-size: 16.5px; line-height: 1.65; }
.cap-body p { margin: 0 0 12px; }
.cap-body ul, .cap-body ol { margin: 0 0 12px; padding-left: 22px; }
.cap-body li { margin-bottom: 6px; }
.cap-body .note {
  border-left: 3px solid var(--accent); background: var(--accent-soft);
  padding: 10px 14px; border-radius: 0 12px 12px 0; margin: 14px 0; font-size: 15px;
}
.cap-body .note.warm { border-color: var(--warm); background: var(--warm-soft); }
.cap-body .note b:first-child { display: block; margin-bottom: 2px; }
.cap-body .eq {
  font-family: var(--mono); font-size: 15px; background: var(--surface-2);
  padding: 10px 14px; border-radius: 12px; margin: 12px 0; overflow-x: auto; white-space: nowrap;
}
.cap-body code { font-family: var(--mono); font-size: .92em; background: var(--surface-2); padding: 1px 6px; border-radius: 6px; }
.hl { font-weight: 650; }
.hl-accent { color: var(--accent); }
.hl-accent2 { color: var(--accent2); }
.hl-warm { color: var(--warm); }
.hl-pos { color: var(--pos); }
.hl-neg { color: var(--neg); }
.hl-muted { color: var(--muted); }

.quiz-opts { display: grid; gap: 10px; margin-top: 6px; }
.opt {
  display: flex; align-items: center; gap: 12px; text-align: left; width: 100%;
  padding: 12px 14px; border-radius: 14px; border: 1.5px solid var(--border);
  background: var(--surface); cursor: pointer; font-size: 15.5px; line-height: 1.35;
  transition: border-color .15s, background .15s, transform .15s;
}
.opt:hover:not(:disabled) { border-color: var(--accent); }
.opt .key {
  flex: none; width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center;
  background: var(--surface-2); font-size: 13px; font-weight: 700; font-family: var(--mono);
}
.opt.correct { border-color: var(--pos); background: var(--pos-soft); }
.opt.correct .key { background: var(--pos); color: #fff; }
.opt.wrong { border-color: var(--neg); background: var(--neg-soft); animation: shake .4s; }
.opt.wrong .key { background: var(--neg); color: #fff; }
.opt:disabled { cursor: default; }
@keyframes shake { 0%,100% { transform: none; } 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }
.explain { margin-top: 14px; padding: 12px 14px; border-radius: 14px; font-size: 15px; line-height: 1.55; animation: capIn .4s both; }
.explain.ok { background: var(--pos-soft); }
.explain.try { background: var(--neg-soft); }
.explain b { display: block; margin-bottom: 2px; }

.done-actions { display: grid; gap: 10px; margin-top: 18px; }

.pfoot {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 20px; border-top: 1px solid var(--border); background: var(--surface);
}
.pfoot .hint { color: var(--muted); font-size: 13px; }
.pfoot .hint kbd {
  font-family: var(--mono); font-size: 11px; border: 1px solid var(--border); border-bottom-width: 2px;
  border-radius: 5px; padding: 1px 5px; background: var(--surface-2);
}
.pfoot .group { display: flex; gap: 10px; }
.btn-next { min-width: 130px; }

@media (max-width: 960px) {
  body[data-view="player"] { overflow: auto; }
  .player { height: auto; min-height: 100vh; min-height: 100dvh; }
  .pbody { grid-template-columns: 1fr; padding: 14px; gap: 14px; align-content: start; }
  .stage > .scene-svg { flex: none; aspect-ratio: 16 / 9; height: auto; }
  .caption { overflow: visible; padding-bottom: 8px; }
  .pfoot { position: sticky; bottom: 0; z-index: 5; }
  .pfoot .hint { display: none; }
  .ptitle { display: none; }
}
@media (max-width: 600px) {
  .path { --k: .45; }
  .ptop { padding: 10px 12px; gap: 8px; }
  .pfoot { padding: 10px 12px; }
  .pfoot .btn { padding: 0 14px; }
  .cap-title { font-size: 22px; }
  .ctl input[type="range"] { width: 120px; }
}

/* ============================================================
   SCENE (SVG) classes — used by lesson animations
   ============================================================ */
.scene-svg { display: block; overflow: visible; user-select: none; -webkit-user-select: none; }
.scene-svg * { transform-box: fill-box; transform-origin: center; }
.scene-svg text { font-family: var(--font); fill: var(--text); font-size: 18px; }

/* text */
.s-title { font-size: 26px !important; font-weight: 750; letter-spacing: -.01em; }
.s-big { font-size: 34px !important; font-weight: 750; }
.s-huge { font-size: 56px !important; font-weight: 800; }
.s-label { font-size: 17px !important; fill: var(--muted) !important; }
.s-small { font-size: 14px !important; }
.s-caption { font-size: 15px !important; fill: var(--muted) !important; letter-spacing: .02em; font-weight: 650; }
.s-mono, .s-value { font-family: var(--mono) !important; font-variant-numeric: tabular-nums; }
.s-value { font-weight: 650; }
.s-bold { font-weight: 700; }
.s-sym { font-style: italic; font-weight: 600; font-family: "Times New Roman", Georgia, serif !important; font-size: 22px !important; }
.s-math { font-family: "Cambria Math", "Times New Roman", Georgia, serif !important; }

/* shapes */
.s-node { fill: var(--surface); stroke: var(--text); stroke-width: 2.5; }
.s-box { fill: var(--surface); stroke: var(--border); stroke-width: 1.5; }
.s-box-strong { fill: var(--surface); stroke: var(--text); stroke-width: 2.2; }
.s-panel { fill: var(--surface-2); stroke: var(--border); stroke-width: 1; }
.s-edge { stroke: var(--muted); stroke-width: 2.5; fill: none; stroke-linecap: round; }
.s-thin { stroke: var(--muted); stroke-width: 1.5; fill: none; }
.s-axis { stroke: var(--muted); stroke-width: 1.6; fill: none; stroke-linecap: round; }
.s-grid { stroke: var(--border); stroke-width: 1; fill: none; }
.s-tick { font-size: 13px !important; fill: var(--muted) !important; font-family: var(--mono) !important; }
.s-curve { stroke: var(--accent); stroke-width: 3.5; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.s-dash { stroke-dasharray: 6 6; }
.s-dot { fill: var(--accent); }
.s-point { fill: var(--accent2); stroke: var(--surface); stroke-width: 2; }
.s-ball { fill: var(--warm); stroke: var(--surface); stroke-width: 3; }
.particle { fill: var(--warm); }
.s-check { stroke: #fff; stroke-width: 9; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.s-ring { stroke: var(--accent); stroke-width: 4; fill: none; }

.fill-accent { fill: var(--accent) !important; }
.fill-accent-soft { fill: var(--accent-soft) !important; }
.fill-accent2 { fill: var(--accent2) !important; }
.fill-accent2-soft { fill: var(--accent2-soft) !important; }
.fill-warm { fill: var(--warm) !important; }
.fill-warm-soft { fill: var(--warm-soft) !important; }
.fill-pos { fill: var(--pos) !important; }
.fill-pos-soft { fill: var(--pos-soft) !important; }
.fill-neg { fill: var(--neg) !important; }
.fill-neg-soft { fill: var(--neg-soft) !important; }
.fill-muted { fill: var(--muted) !important; }
.fill-text { fill: var(--text) !important; }
.fill-surface { fill: var(--surface) !important; }
.fill-surface2 { fill: var(--surface-2) !important; }
.fill-white { fill: #fff !important; }
.fill-none { fill: none !important; }

.stroke-accent { stroke: var(--accent) !important; }
.stroke-accent2 { stroke: var(--accent2) !important; }
.stroke-warm { stroke: var(--warm) !important; }
.stroke-pos { stroke: var(--pos) !important; }
.stroke-neg { stroke: var(--neg) !important; }
.stroke-muted { stroke: var(--muted) !important; }
.stroke-text { stroke: var(--text) !important; }
.stroke-faint { stroke: var(--faint) !important; }
.stroke-surface { stroke: var(--surface) !important; }

/* arrow-head markers */
.mk-muted { fill: var(--muted); }
.mk-accent { fill: var(--accent); }
.mk-accent2 { fill: var(--accent2); }
.mk-warm { fill: var(--warm); }
.mk-pos { fill: var(--pos); }
.mk-neg { fill: var(--neg); }
.mk-text { fill: var(--text); }

@media (prefers-reduced-motion: reduce) {
  .node, .hero, .module-head, .caption.enter > * { animation: none !important; }
}

/* math-looking equation text inside scenes */
.s-eq { font-family: "Cambria Math", "Times New Roman", Georgia, serif !important; font-style: italic; font-size: 34px !important; }
.s-eq-md { font-family: "Cambria Math", "Times New Roman", Georgia, serif !important; font-style: italic; font-size: 24px !important; }
.s-eq tspan.n, .s-eq-md tspan.n, .s-eq .n, .s-eq-md .n { font-style: normal; font-family: var(--mono); font-size: .8em; }
.s-upright { font-style: normal !important; }

/* ============================================================
   BEATS — "play next animation" bar under the canvas
   ============================================================ */
.stage > .scene-svg { order: 1; }
.stage-beats { order: 2; }
.stage-controls { order: 3; }
.stage-beats {
  flex: none; display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 12px 18px; border-top: 1px solid var(--border);
  background: linear-gradient(to bottom, var(--surface), var(--surface));
}
.beat-dots { display: flex; gap: 6px; flex: none; }
.beat-dots i {
  width: 10px; height: 10px; border-radius: 50%; background: var(--surface-2);
  border: 1.5px solid var(--faint); transition: background .3s, border-color .3s, transform .3s;
}
.beat-dots i.on { background: var(--accent); border-color: var(--accent); }
.beat-dots i.now { border-color: var(--accent); transform: scale(1.25); }
.beat-mid { display: flex; align-items: center; gap: 14px; flex: 1; min-width: 0; }
.beat-btn {
  display: inline-flex; align-items: center; gap: 8px; flex: none;
  height: 40px; padding: 0 16px; border-radius: 12px; border: 0; cursor: pointer;
  background: var(--accent); color: #fff; font-weight: 700; font-size: 14.5px;
  box-shadow: 0 3px 0 var(--accent-deep); position: relative;
  transition: transform .12s, opacity .2s, background .2s;
}
.beat-btn:active:not(:disabled) { transform: translateY(2px); box-shadow: 0 1px 0 var(--accent-deep); }
.beat-btn:disabled { cursor: default; background: var(--surface-2); color: var(--muted); box-shadow: none; }
.beat-btn.done { color: var(--pos); background: var(--pos-soft); }
.beat-btn .tri { font-size: 11px; }
.beat-btn .beat-count { font-family: var(--mono); font-size: 12px; opacity: .8; font-weight: 600; }
.beat-btn.attn::after {
  content: ""; position: absolute; inset: -5px; border-radius: 16px; border: 2px solid var(--accent);
  animation: ring 1.8s ease-out infinite; pointer-events: none;
}
.beat-btn .spin {
  width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--faint); border-top-color: var(--accent);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.beat-label { color: var(--muted); font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }

/* caption lines tied to beats */
.cap-body [data-beat] { transition: opacity .4s ease, background .4s ease, box-shadow .4s ease; border-radius: 8px; }
.cap-body [data-beat].beat-pending { opacity: .28; }
.cap-body [data-beat].beat-now { background: var(--accent-soft); box-shadow: 0 0 0 6px var(--accent-soft); }
.cap-body li[data-beat].beat-now, .cap-body p[data-beat].beat-now { }
@media (max-width: 600px) {
  .stage-beats { padding: 10px 12px; gap: 10px; }
  .beat-label { display: none; }
}

/* ============================================================
   TERMS page
   ============================================================ */
.top-actions { display: flex; gap: 8px; align-items: center; }
.btn-sm { height: 40px; padding: 0 14px; font-size: 14px; }
.term-search {
  margin-top: 22px; width: 100%; height: 48px; padding: 0 16px; border-radius: 14px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; font-size: 16px;
}
.term-search:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.terms { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; margin-top: 24px; align-items: start; }
.term {
  text-align: left; display: flex; flex-direction: column; gap: 4px; padding: 16px 16px 14px;
  border-radius: 16px; border: 1px solid var(--border); background: var(--surface); cursor: pointer;
  box-shadow: var(--shadow); animation: rise .5s both; animation-delay: calc(var(--i) * 25ms);
  transition: border-color .2s, transform .15s;
}
.term:hover { border-color: var(--accent); transform: translateY(-2px); }
.term-name { font-weight: 750; font-size: 16px; letter-spacing: -.01em; }
.term-short { color: var(--accent); font-weight: 600; font-size: 14px; }
.term-def { display: none; color: var(--text); font-size: 14.5px; line-height: 1.55; margin-top: 6px; }
.term.open { border-color: var(--accent); background: var(--accent-soft); }
.term.open .term-def { display: block; animation: capIn .35s both; }
.term-link { display: block; margin-top: 10px; font-weight: 650; color: var(--accent); text-decoration: none; font-size: 13.5px; }
.term-link:hover { text-decoration: underline; }
.terms-head { margin: 40px 0 0; font-size: 20px; letter-spacing: -.01em; }

/* ============================================================
   SITE SHELL — header, hero, sections, footer
   ============================================================ */
.page { min-height: 100vh; display: flex; flex-direction: column; }
.page > .home { flex: 1; }

.sitebar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; gap: 18px;
  padding: 12px max(16px, calc((100% - 1120px) / 2));
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
}
.sitebar .brand { text-decoration: none; font-size: 17px; }
.brand-text { letter-spacing: -.02em; }
.nav { display: flex; gap: 4px; margin-left: auto; }
.nav-link {
  padding: 8px 14px; border-radius: 10px; text-decoration: none; font-weight: 600; font-size: 15px;
  color: var(--muted); transition: color .15s, background .15s;
}
.nav-link:hover { color: var(--text); background: var(--surface-2); }
.nav-link.active { color: var(--accent); background: var(--accent-soft); }

.home { max-width: 1120px; margin: 0 auto; padding: 0 16px 80px; width: 100%; }

/* hero */
.hero {
  display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, .95fr);
  gap: 40px; align-items: center; padding: 56px 0 32px;
}
.hero-text h1 { font-size: clamp(34px, 5.2vw, 56px); line-height: 1.03; letter-spacing: -.035em; margin: 10px 0 14px; }
.hero-text p { color: var(--muted); font-size: 18px; max-width: 520px; margin: 0; }
.grad { background: linear-gradient(100deg, var(--accent), var(--accent2)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero-cta { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 26px; }
.btn-lg { height: 52px; padding: 0 24px; font-size: 16px; border-radius: 14px; }
.stats { display: flex; flex-wrap: wrap; gap: 28px; margin-top: 34px; }
.stat b { display: block; font-size: 26px; letter-spacing: -.02em; }
.stat span { font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .07em; font-weight: 650; }

.hero-visual { display: flex; justify-content: center; }
.hero-art { width: 100%; max-width: 460px; height: auto; }
.ha-grid line { stroke: var(--border); stroke-width: 1; }
.ha-curve { fill: none; stroke: url(#hg); stroke-width: 4; stroke-linecap: round; stroke-dasharray: 620; stroke-dashoffset: 620; animation: drawCurve 2.2s cubic-bezier(.65,0,.35,1) forwards; }
@keyframes drawCurve { to { stroke-dashoffset: 0; } }
.ha-ball { fill: var(--warm); filter: drop-shadow(0 4px 10px rgba(0,0,0,.25)); }
.ha-dots circle { fill: var(--accent2); opacity: 0; animation: dotIn .5s both, dotPulse 3.2s ease-in-out infinite; animation-delay: calc(1.4s + var(--d)), calc(2s + var(--d)); }
@keyframes dotIn { from { opacity: 0; transform: translateY(6px); } to { opacity: .9; transform: none; } }
@keyframes dotPulse { 0%, 100% { opacity: .55; } 50% { opacity: 1; } }

/* sections */
.sec-head { font-size: 13px; font-weight: 750; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); margin: 0 0 20px; }
.how { padding-top: 56px; }
.how-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; }
.how-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 22px; box-shadow: var(--shadow);
}
.how-ico {
  display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 12px;
  background: var(--accent-soft); color: var(--accent); font-size: 17px; margin-bottom: 12px;
}
.how-card b { display: block; font-size: 17px; letter-spacing: -.01em; margin-bottom: 6px; }
.how-card p { margin: 0; color: var(--muted); font-size: 15px; line-height: 1.6; }

.lectures { padding-top: 60px; }
.module { margin-top: 12px; }
.module + .module { margin-top: 56px; }
.module-meta h3 { margin: 0 0 4px; font-size: 22px; letter-spacing: -.02em; line-height: 1.25; }
.module-meta p { margin: 0; color: var(--muted); }
.module-stats { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.module-stats span {
  font-size: 12px; font-weight: 650; letter-spacing: .04em; padding: 4px 10px;
  border-radius: 999px; background: var(--surface-2); color: var(--muted);
}
.reset-line { margin-top: 64px; text-align: center; color: var(--muted); font-size: 14px; }
.reset-line button { background: none; border: 0; color: var(--muted); text-decoration: underline; cursor: pointer; font-size: 14px; padding: 0; }

.page-head { padding: 48px 0 8px; }
.page-head h1 { font-size: clamp(30px, 5vw, 44px); line-height: 1.05; letter-spacing: -.03em; margin: 10px 0 12px; }
.page-head p { color: var(--muted); font-size: 17px; margin: 0; max-width: 620px; }

/* about */
.about-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; margin-top: 32px; }
.about-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow); }
.about-card.accent { background: var(--accent-soft); border-color: var(--accent); }
.about-card h2 { margin: 0 0 10px; font-size: 19px; letter-spacing: -.01em; }
.about-card p, .about-card li { color: var(--muted); font-size: 15.5px; line-height: 1.65; }
.about-card p { margin: 0 0 10px; }
.about-card ul { margin: 0; padding-left: 20px; }
.about-card a { color: var(--accent); font-weight: 650; }
.about-card .btn { color: var(--text); text-decoration: none; margin-top: 4px; }
.kbd { font-family: var(--mono); font-size: 12px; border: 1px solid var(--border); border-bottom-width: 2px; border-radius: 5px; padding: 1px 6px; background: var(--surface-2); color: var(--text); }

@media (max-width: 860px) {
  .hero { grid-template-columns: 1fr; gap: 24px; padding-top: 36px; }
  .hero-visual { order: -1; }
  .hero-art { max-width: 340px; }
  .sitefoot-in { flex-direction: column; align-items: flex-start; }
  .foot-org { text-align: left; }
}
@media (max-width: 600px) {
  .sitebar { gap: 10px; padding: 10px 14px; }
  .nav-link { padding: 8px 10px; font-size: 14px; }
  .brand-text { display: none; }
  .stats { gap: 18px; }
  .stat b { font-size: 22px; }
}
@media (prefers-reduced-motion: reduce) {
  .ha-curve, .ha-dots circle { animation: none; stroke-dashoffset: 0; opacity: .9; }
}

/* ---------- Subjects dropdown ---------- */
.nav-drop { position: relative; }
.drop-btn { border: 0; background: none; cursor: pointer; font-family: inherit; display: inline-flex; align-items: center; gap: 6px; }
.drop-btn .caret { font-size: 10px; opacity: .7; }
.drop-menu {
  position: absolute; top: calc(100% + 10px); left: 0; min-width: 260px; z-index: 50;
  background: var(--surface); border: 1px solid var(--border); border-radius: 16px;
  box-shadow: var(--shadow); padding: 8px; animation: capIn .18s ease both;
}
.drop-item { display: block; padding: 12px 14px; border-radius: 12px; text-decoration: none; color: inherit; }
.drop-item:hover { background: var(--accent-soft); }
.drop-item b { display: block; font-size: 15.5px; letter-spacing: -.01em; }
.drop-item small { color: var(--muted); font-size: 13px; }

/* ---------- breadcrumbs ---------- */
.crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: 14px; color: var(--muted); margin-bottom: 18px; }
.crumbs a { color: var(--muted); text-decoration: none; font-weight: 600; }
.crumbs a:hover { color: var(--accent); }
.crumbs i { font-style: normal; opacity: .5; }

/* ---------- lecture cards (subject page) ---------- */
.lec-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; margin-top: 30px; }
.lec-card {
  display: flex; flex-direction: column; gap: 8px; padding: 24px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); text-decoration: none; color: inherit;
  transition: transform .16s ease, border-color .16s ease;
}
.lec-card:hover { transform: translateY(-3px); border-color: var(--accent); }
.lec-card.locked { opacity: .62; }
.lec-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.lec-num { font-size: 12px; font-weight: 750; letter-spacing: .09em; text-transform: uppercase; color: var(--accent); }
.lec-card h3 { margin: 0; font-size: 21px; letter-spacing: -.02em; line-height: 1.25; }
.lec-card p { margin: 0; color: var(--muted); font-size: 15px; line-height: 1.6; }
.lec-bar { height: 7px; border-radius: 4px; background: var(--surface-2); overflow: hidden; margin-top: 6px; }
.lec-bar i { display: block; height: 100%; width: var(--p, 0%); background: var(--accent); border-radius: 4px; }
.lec-go { margin-top: 6px; font-weight: 700; color: var(--accent); font-size: 14.5px; }
.lec-nav { display: flex; justify-content: space-between; gap: 12px; margin-top: 48px; }

/* ---------- call-to-action band ---------- */
.cta-band {
  margin-top: 64px; padding: 34px; border-radius: var(--radius);
  background: linear-gradient(120deg, var(--accent-soft), var(--accent2-soft));
  border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; gap: 24px; flex-wrap: wrap;
}
.cta-band h2 { margin: 0 0 6px; font-size: 24px; letter-spacing: -.02em; }
.cta-band p { margin: 0; color: var(--muted); max-width: 560px; }

/* ---------- footer ---------- */
.sitefoot { border-top: 1px solid var(--border); background: var(--surface); margin-top: 72px; }
.sitefoot-in {
  max-width: 1120px; margin: 0 auto; padding: 40px 16px 28px;
  display: grid; grid-template-columns: 1.6fr 1fr 1fr; gap: 32px;
}
.foot-col { display: flex; flex-direction: column; gap: 10px; align-items: flex-start; }
.foot-col h4 { margin: 0 0 2px; font-size: 12px; font-weight: 750; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.foot-col a { color: var(--muted); text-decoration: none; font-size: 15px; font-weight: 600; }
.foot-col a:hover { color: var(--accent); }
.foot-about .brand { text-decoration: none; font-size: 16px; }
.foot-about .brand-text { display: inline; }
.foot-about p { margin: 0; color: var(--muted); font-size: 14.5px; max-width: 300px; }
.foot-bar {
  border-top: 1px solid var(--border);
  max-width: 1120px; margin: 0 auto; padding: 16px;
  display: flex; flex-wrap: wrap; gap: 8px 24px; justify-content: space-between;
  color: var(--muted); font-size: 13.5px;
}
.foot-bar a { color: var(--accent); font-weight: 650; text-decoration: none; }
.foot-bar a:hover { text-decoration: underline; }

@media (max-width: 860px) {
  .sitefoot-in { grid-template-columns: 1fr 1fr; }
  .foot-about { grid-column: 1 / -1; }
  .cta-band { padding: 26px; }
}
@media (max-width: 600px) {
  .drop-menu { left: auto; right: 0; min-width: 230px; }
  .lec-nav { flex-direction: column; }
  .foot-bar { flex-direction: column; }
}
