/* Layout concept: a reading room. Dark graphite surround (images read best on dark),
   a single winding lesson path down the centre, amber "lightbox" accent for the one
   thing to do next. Committed single dark theme by design. */
:root {
  color-scheme: dark;
  --bg: #0b1014;
  --panel: #121a20;
  --panel-2: #18232b;
  --line: #26343e;
  --fg: #e9eff1;
  --muted: #8b9ca7;
  --faint: #5a6a75;
  --accent: #f2b14c;
  --accent-ink: #1d1405;
  --accent-soft: rgba(242, 177, 76, .14);
  --ok: #3fd08f;
  --ok-soft: rgba(63, 208, 143, .14);
  --bad: #ff6464;
  --bad-soft: rgba(255, 100, 100, .14);
  --info: #72c6ff;
  --f-display: "Bricolage Grotesque", "Avenir Next", "Segoe UI", system-ui, sans-serif;
  --f-body: "Atkinson Hyperlegible", "Segoe UI", system-ui, -apple-system, sans-serif;
  --f-mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --r: 14px;
  --maxw: 720px;
}
* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--fg);
  font: 16px/1.5 var(--f-body);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 50; background: var(--bg); }
button { font: inherit; color: inherit; }
a { color: var(--info); }
:focus-visible { outline: 3px solid var(--info); outline-offset: 2px; border-radius: 6px; }
h1, h2, h3 { font-family: var(--f-display); text-wrap: balance; margin: 0; letter-spacing: -.01em; }
.wrap { max-width: var(--maxw); margin: 0 auto; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
.eyebrow { font: 700 11px/1 var(--f-mono); letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.mono { font-family: var(--f-mono); font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }

/* ---------- top bar ---------- */
.topbar { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 20; background: rgba(11,16,20,.92); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.topbar .wrap { display: flex; align-items: center; gap: 12px; padding-block: 10px; }
.brand { display: flex; align-items: center; gap: 8px; font: 800 19px/1 var(--f-display); text-decoration: none; color: var(--fg); margin-right: auto; }
.brand svg { width: 26px; height: 26px; }
.stat { display: flex; align-items: center; gap: 5px; font: 700 14px/1 var(--f-mono); padding: 6px 9px; border-radius: 999px; background: var(--panel); border: 1px solid var(--line); }
.stat svg { width: 16px; height: 16px; }
.stat.streak { color: #ff9f43; } .stat.xp { color: var(--accent); } .stat.hearts { color: var(--bad); }
.tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; background: var(--panel); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom, 0px); }
.tabs .wrap { display: grid; grid-template-columns: repeat(5, 1fr); }
.tab { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 9px 0 8px; font-size: 11px; color: var(--muted); text-decoration: none; border: 0; background: none; cursor: pointer; }
.tab svg { width: 22px; height: 22px; }
.tab[aria-current="page"] { color: var(--accent); }
main.page { padding-block: 18px 110px; }

/* ---------- path ---------- */
.rankcard { display: grid; grid-template-columns: auto 1fr; gap: 14px; align-items: center; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px; margin-bottom: 22px; }
.rankcard .badge { width: 52px; height: 52px; border-radius: 14px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); font: 800 20px/1 var(--f-display); }
.rankcard h2 { font-size: 20px; }
.meter { height: 8px; border-radius: 99px; background: var(--panel-2); overflow: hidden; }
.meter > i { display: block; height: 100%; background: var(--accent); border-radius: 99px; transition: width .5s; }
.section { margin-bottom: 30px; }
.sechead { border-radius: var(--r); padding: 16px 18px; background: var(--sc-soft); border: 1px solid var(--sc-line); display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; align-items: center; }
.sechead h2 { font-size: 22px; color: var(--fg); }
.sechead p { margin: 0; color: var(--muted); font-size: 14px; grid-column: 1 / -1; }
.sechead .rank { font: 700 11px/1.2 var(--f-mono); letter-spacing: .08em; text-transform: uppercase; color: var(--sc); text-align: right; }
.sechead .row { grid-column: 1 / -1; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.sechead .meter { flex: 1; min-width: 120px; } .sechead .meter > i { background: var(--sc); }
.btn-ghost { border: 1px solid var(--line); background: var(--panel); border-radius: 10px; padding: 7px 11px; font-size: 13px; cursor: pointer; color: var(--fg); }
.btn-ghost:hover { border-color: var(--muted); }
.unit { margin: 20px 0 6px; }
.unit h3 { font-size: 15px; color: var(--muted); font-weight: 700; display: flex; align-items: center; gap: 10px; }
.unit h3::after { content: ""; height: 1px; flex: 1; background: var(--line); }
.nodes { display: flex; flex-direction: column; align-items: center; gap: 14px; padding: 12px 0 4px; }
.node { position: relative; display: flex; align-items: center; gap: 12px; transform: translateX(var(--dx, 0)); }
.node-btn { width: 70px; height: 64px; border-radius: 50%; border: 0; cursor: pointer; display: grid; place-items: center; background: var(--sc); color: #0b1014; box-shadow: 0 6px 0 var(--sc-dark); transition: transform .08s; position: relative; }
.node-btn:active { transform: translateY(4px); box-shadow: 0 2px 0 var(--sc-dark); }
.node-btn svg { width: 30px; height: 30px; }
.node.locked .node-btn { background: var(--panel-2); color: var(--faint); box-shadow: 0 6px 0 #0e151a; cursor: not-allowed; }
.node.current .node-btn { outline: 4px solid var(--sc-soft); outline-offset: 5px; animation: pulse 2s infinite; }
@keyframes pulse { 50% { outline-color: transparent; } }
.node .label { position: absolute; left: calc(100% + 12px); width: 150px; font-size: 13px; line-height: 1.25; color: var(--muted); }
.node.alt .label { left: auto; right: calc(100% + 12px); text-align: right; }
.node .crown { position: absolute; bottom: -6px; right: -6px; background: var(--bg); border: 2px solid var(--sc); color: var(--sc); border-radius: 99px; font: 700 11px/1 var(--f-mono); padding: 3px 6px; }
.node.mastered .node-btn { background: linear-gradient(140deg, var(--accent), #ffdd8f); box-shadow: 0 6px 0 #a06d1c; }
.pop { position: absolute; top: calc(100% + 14px); left: 50%; transform: translateX(-50%); z-index: 15; width: min(300px, 86vw); background: var(--panel); border: 1px solid var(--sc-line); border-radius: var(--r); padding: 14px; box-shadow: 0 16px 40px rgba(0,0,0,.5); }
.pop h4 { margin: 0 0 4px; font: 700 17px/1.2 var(--f-display); }
.pop p { margin: 0 0 10px; color: var(--muted); font-size: 13px; }
.pop .lvl { display: flex; gap: 4px; margin-bottom: 12px; }
.pop .lvl i { flex: 1; height: 6px; border-radius: 9px; background: var(--panel-2); }
.pop .lvl i.on { background: var(--sc); }

/* ---------- primary button ---------- */
.btn { display: inline-flex; justify-content: center; align-items: center; gap: 8px; width: 100%; border: 0; border-radius: 13px; padding: 14px 18px; font: 800 16px/1 var(--f-display); letter-spacing: .02em; cursor: pointer; background: var(--accent); color: var(--accent-ink); box-shadow: 0 4px 0 #a06d1c; text-transform: uppercase; }
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 #a06d1c; }
.btn[disabled] { background: var(--panel-2); color: var(--faint); box-shadow: 0 4px 0 #0e151a; cursor: default; }
.btn.ok { background: var(--ok); box-shadow: 0 4px 0 #1d8a59; color: #04130c; }
.btn.bad { background: var(--bad); box-shadow: 0 4px 0 #a83232; color: #1d0505; }
.btn.sec { background: var(--panel-2); color: var(--fg); box-shadow: 0 4px 0 #0e151a; }

/* ---------- lesson ---------- */
.lesson { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }
.lhead .wrap { display: flex; align-items: center; gap: 12px; padding-block: 14px; }
.x { width: 36px; height: 36px; border-radius: 10px; border: 0; background: none; color: var(--muted); cursor: pointer; display: grid; place-items: center; }
.x svg { width: 22px; height: 22px; }
.prog { flex: 1; height: 14px; background: var(--panel-2); border-radius: 99px; overflow: hidden; }
.prog > i { display: block; height: 100%; background: var(--ok); border-radius: 99px; transition: width .35s; box-shadow: inset 0 -4px 0 rgba(0,0,0,.15); }
.lbody { flex: 1; padding-bottom: 210px; }
.qtype { font: 700 11px/1 var(--f-mono); letter-spacing: .12em; text-transform: uppercase; color: var(--sc, var(--accent)); margin: 6px 0 8px; display: flex; align-items: center; gap: 8px; }
.q { font: 700 clamp(20px, 4.6vw, 25px)/1.25 var(--f-display); margin: 0 0 16px; text-wrap: balance; }
.lead { color: var(--fg); font-size: 17px; margin: 0 0 14px; max-width: 62ch; }
.terms { display: grid; gap: 8px; margin: 12px 0; }
.term { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.term b { color: var(--accent); font-family: var(--f-display); }
.choices { display: grid; gap: 10px; }
.choice { text-align: left; padding: 14px 16px; border-radius: 13px; border: 2px solid var(--line); background: var(--panel); cursor: pointer; font-size: 16px; box-shadow: 0 3px 0 var(--line); line-height: 1.3; display: flex; gap: 12px; align-items: center; }
.choice .k { flex: none; width: 26px; height: 26px; border-radius: 8px; border: 2px solid var(--line); display: grid; place-items: center; font: 700 12px/1 var(--f-mono); color: var(--muted); }
.choice:hover { border-color: var(--faint); }
.choice.sel { border-color: var(--info); background: rgba(114,198,255,.1); box-shadow: 0 3px 0 #2c6e98; }
.choice.sel .k { border-color: var(--info); color: var(--info); }
.choice.right { border-color: var(--ok); background: var(--ok-soft); box-shadow: 0 3px 0 #1d8a59; }
.choice.wrong { border-color: var(--bad); background: var(--bad-soft); box-shadow: 0 3px 0 #a83232; }
.choice[disabled] { cursor: default; }
.tfrow { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tfrow .choice { justify-content: center; font: 800 18px/1 var(--f-display); padding: 20px; }

/* chips */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { border: 2px solid var(--line); background: var(--panel); border-radius: 11px; padding: 9px 12px; cursor: pointer; font-size: 15px; box-shadow: 0 3px 0 var(--line); line-height: 1.2; }
.chip.sel { border-color: var(--info); background: rgba(114,198,255,.1); }
.chip.used { opacity: .25; pointer-events: none; }
.chip.right { border-color: var(--ok); background: var(--ok-soft); }
.chip.wrong { border-color: var(--bad); background: var(--bad-soft); animation: shake .3s; }
@keyframes shake { 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }
.answerline { min-height: 58px; border-bottom: 2px solid var(--line); padding: 8px 0; margin-bottom: 16px; display: flex; flex-direction: column; gap: 8px; }
.answerline .chip { align-self: flex-start; }
.answerline .chip .n { font: 700 12px/1 var(--f-mono); color: var(--muted); margin-right: 6px; }
.match { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.match .col { display: grid; gap: 10px; align-content: start; }
.match .chip { width: 100%; text-align: left; font-size: 14px; }
.buckets { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin-top: 14px; }
.bucket { border: 2px dashed var(--line); border-radius: 14px; padding: 10px; min-height: 110px; cursor: pointer; background: transparent; text-align: left; display: flex; flex-direction: column; gap: 8px; }
.bucket.hot { border-color: var(--info); background: rgba(114,198,255,.06); }
.bucket h5 { margin: 0; font: 700 12px/1.2 var(--f-mono); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.bucket .chips .chip { font-size: 13px; padding: 6px 9px; }
.dxin { display: flex; gap: 8px; }
.dxin input { flex: 1; min-width: 0; font: 17px var(--f-body); padding: 14px; border-radius: 13px; border: 2px solid var(--line); background: var(--panel); color: var(--fg); }
.dxin input:focus { border-color: var(--info); outline: none; }
.linkbtn { border: 0; background: none; color: var(--info); cursor: pointer; padding: 10px 0; font-size: 15px; text-decoration: underline; text-underline-offset: 3px; }

/* ---------- image viewer ---------- */
.viewer { position: relative; border-radius: var(--r); overflow: hidden; background: #000; border: 1px solid var(--line); margin: 0 auto 14px; max-width: 100%; user-select: none; -webkit-user-select: none; touch-action: manipulation; }
.viewer .stage { position: relative; transform-origin: 0 0; }
.viewer img { display: block; width: 100%; height: auto; max-width: 100%; pointer-events: none; }
.viewer svg.ov { position: absolute; inset: 0; width: 100%; height: 100%; }
.viewer.tappable { cursor: crosshair; }
.viewer .chipbar { position: absolute; top: 8px; left: 8px; right: 8px; display: flex; justify-content: space-between; gap: 6px; pointer-events: none; }
.viewer .mod { font: 700 11px/1 var(--f-mono); letter-spacing: .06em; padding: 5px 7px; border-radius: 7px; background: rgba(0,0,0,.65); color: #cfe3ee; }
.viewer .tools { display: flex; gap: 6px; pointer-events: auto; }
.viewer .tools button { width: 32px; height: 32px; border-radius: 9px; border: 0; background: rgba(0,0,0,.65); color: #e9eff1; cursor: pointer; display: grid; place-items: center; }
.viewer .tools button svg { width: 18px; height: 18px; }
.viewer .tools button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }
.viewer .wl { position: absolute; left: 8px; right: 8px; bottom: 8px; background: rgba(0,0,0,.75); border-radius: 10px; padding: 8px 10px; display: grid; grid-template-columns: auto 1fr; gap: 4px 10px; align-items: center; font: 700 11px/1 var(--f-mono); color: #cfe3ee; }
.viewer .wl input { width: 100%; accent-color: var(--accent); }
.viewer .counter { position: absolute; bottom: 8px; left: 50%; transform: translateX(-50%); font: 700 13px/1 var(--f-mono); padding: 7px 10px; border-radius: 99px; background: rgba(0,0,0,.75); color: #fff; pointer-events: none; }
.viewer .credit { position: absolute; right: 6px; bottom: 4px; font-size: 9px; color: rgba(255,255,255,.55); pointer-events: none; max-width: 70%; text-align: right; }
.viewer.big { position: fixed; inset: 0; z-index: 60; border-radius: 0; margin: 0; display: grid; place-items: center; border: 0; }
.viewer.big .stage { width: min(100vw, calc(100vh * var(--ar))); width: min(100vw, calc(100dvh * var(--ar))); }
.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.pair .pick { border: 3px solid transparent; border-radius: calc(var(--r) + 3px); padding: 0; background: none; cursor: pointer; display: block; }
.pair .pick .viewer { margin: 0; }
.pair .pick.sel { border-color: var(--info); }
.pair .pick.right { border-color: var(--ok); } .pair .pick.wrong { border-color: var(--bad); }
.pair .tag { display: block; text-align: center; font: 800 14px/1 var(--f-display); padding: 8px 0 2px; color: var(--muted); }
@media (min-width: 760px) { .viewer.fit { max-width: 560px; } }
.mk { fill: none; stroke-width: 3; vector-effect: non-scaling-stroke; }
.mk.show { stroke: var(--accent); fill: rgba(242,177,76,.12); stroke-dasharray: 7 5; }
.mk.found { stroke: var(--ok); fill: rgba(63,208,143,.16); }
.mk.target { stroke: var(--ok); fill: rgba(63,208,143,.18); animation: blink 1s 2; }
.mk.missed { stroke: var(--bad); fill: rgba(255,100,100,.14); stroke-dasharray: 6 4; }
@keyframes blink { 50% { opacity: .3; } }
.pin { pointer-events: none; }
.pin circle.o { fill: rgba(114,198,255,.25); stroke: var(--info); stroke-width: 3; vector-effect: non-scaling-stroke; }
.pin.miss circle.o { fill: rgba(255,100,100,.3); stroke: var(--bad); }
.pin.hit circle.o { fill: rgba(63,208,143,.3); stroke: var(--ok); }
.lpin { cursor: pointer; }
.lpin circle { fill: #0b1014; stroke: var(--info); stroke-width: 3; vector-effect: non-scaling-stroke; }
.lpin.sel circle { fill: var(--info); }
.lpin text { font: 700 var(--pinfs, 22px) var(--f-mono); fill: #fff; text-anchor: middle; dominant-baseline: central; pointer-events: none; }
.lpin.sel text { fill: #0b1014; }
.lpin.right circle { stroke: var(--ok); fill: var(--ok); } .lpin.right text { fill: #04130c; }
.lpin.wrong circle { stroke: var(--bad); fill: var(--bad); }
.labelrows { display: grid; gap: 8px; margin-top: 4px; }
.labelrow { display: grid; grid-template-columns: 34px 1fr; gap: 10px; align-items: center; }
.labelrow .num { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font: 700 14px/1 var(--f-mono); border: 3px solid var(--info); cursor: pointer; background: none; }
.labelrow .num.sel { background: var(--info); color: #0b1014; }
.labelrow .slot { min-height: 40px; border-radius: 11px; border: 2px dashed var(--line); display: flex; align-items: center; padding: 0 10px; color: var(--muted); font-size: 15px; cursor: pointer; background: none; text-align: left; }
.labelrow .slot.filled { border-style: solid; color: var(--fg); background: var(--panel); }
.labelrow .slot.right { border-color: var(--ok); background: var(--ok-soft); }
.labelrow .slot.wrong { border-color: var(--bad); background: var(--bad-soft); }

/* ---------- footer / feedback ---------- */
.lfoot { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; border-top: 2px solid var(--line); background: var(--bg); padding-bottom: env(safe-area-inset-bottom, 0px); transition: background .2s; }
.lfoot .wrap { padding-block: 16px; display: grid; gap: 12px; }
.lfoot.ok { background: #0f2a1f; border-color: #1d5a40; }
.lfoot.bad { background: #2d1416; border-color: #6b2a2d; }
.fb h3 { font-size: 21px; display: flex; align-items: center; gap: 8px; }
.lfoot.ok .fb h3 { color: var(--ok); } .lfoot.bad .fb h3 { color: var(--bad); }
.fb p { margin: 6px 0 0; font-size: 15px; max-width: 65ch; max-height: 30vh; overflow: auto; }
.fb .ans { font-weight: 700; }
.frow { display: flex; gap: 10px; }
.frow .btn { flex: 1; }
.frow .btn.skip { flex: 0 0 auto; width: auto; }

/* ---------- end screens ---------- */
.done { text-align: center; padding-block: 40px 120px; display: grid; gap: 18px; justify-items: center; }
.done h1 { font-size: clamp(30px, 7vw, 44px); color: var(--accent); }
.tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; width: 100%; max-width: 460px; }
.tile { border: 2px solid var(--line); border-radius: 14px; overflow: hidden; }
.tile .h { font: 700 11px/1 var(--f-mono); letter-spacing: .08em; text-transform: uppercase; padding: 7px 4px; background: var(--line); }
.tile .v { font: 800 24px/1 var(--f-display); padding: 14px 4px; }
.tile.a { border-color: var(--accent); } .tile.a .h { background: var(--accent); color: var(--accent-ink); } .tile.a .v { color: var(--accent); }
.tile.g { border-color: var(--ok); } .tile.g .h { background: var(--ok); color: #04130c; } .tile.g .v { color: var(--ok); }
.tile.b { border-color: var(--info); } .tile.b .h { background: var(--info); color: #04121c; } .tile.b .v { color: var(--info); }
.scope { width: 120px; height: 120px; }

/* ---------- profile / lists ---------- */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; margin-bottom: 14px; }
.card h2 { font-size: 19px; margin-bottom: 10px; }
.ladder { display: grid; gap: 0; }
.rung { display: grid; grid-template-columns: 26px 1fr auto; gap: 10px; align-items: center; padding: 9px 0; border-bottom: 1px solid var(--line); color: var(--faint); }
.rung:last-child { border-bottom: 0; }
.rung .dot { width: 14px; height: 14px; border-radius: 50%; border: 2px solid currentColor; justify-self: center; }
.rung.got { color: var(--fg); } .rung.got .dot { background: var(--ok); border-color: var(--ok); }
.rung.now { color: var(--accent); } .rung.now .dot { background: var(--accent); border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.rung small { font: 700 11px/1 var(--f-mono); color: var(--muted); }
.mrow { display: grid; grid-template-columns: minmax(0, 1fr) 110px 44px; gap: 10px; align-items: center; padding: 8px 0; font-size: 14px; }
.mrow .meter > i { background: var(--sc); }
.mrow .mono { text-align: right; color: var(--muted); font-size: 13px; }
.statgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; }
.sg { background: var(--panel-2); border-radius: 12px; padding: 12px; }
.sg b { display: block; font: 800 24px/1.1 var(--f-display); }
.sg span { font-size: 12px; color: var(--muted); }
.search { width: 100%; font: 16px var(--f-body); padding: 12px 14px; border-radius: 12px; border: 2px solid var(--line); background: var(--panel); color: var(--fg); margin-bottom: 14px; }
.gl { padding: 12px 0; border-bottom: 1px solid var(--line); }
.gl b { font-family: var(--f-display); color: var(--accent); font-size: 17px; }
.gl p { margin: 3px 0 0; }
.gl small { color: var(--faint); font-size: 12px; }
.credit-row { padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 13px; display: grid; grid-template-columns: 56px 1fr; gap: 12px; align-items: center; }
.credit-row img { width: 56px; height: 56px; object-fit: cover; border-radius: 8px; background: #000; }
.credit-row div { min-width: 0; overflow-wrap: anywhere; }
.toggle { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.toggle:last-child { border-bottom: 0; }
.empty { text-align: center; padding: 40px 10px; color: var(--muted); }
.empty svg { width: 64px; height: 64px; color: var(--faint); }
.disclaimer { font-size: 12px; color: var(--faint); text-align: center; margin-top: 18px; }
.toast { position: fixed; left: 50%; top: calc(env(safe-area-inset-top, 0px) + 70px); transform: translateX(-50%); z-index: 80; background: var(--panel); border: 1px solid var(--accent); color: var(--fg); padding: 10px 16px; border-radius: 12px; font-weight: 700; box-shadow: 0 10px 30px rgba(0,0,0,.5); }

@media (max-width: 520px) {
  .node .label { width: 105px; font-size: 12px; }
  .match .chip { font-size: 13px; padding: 8px; }
  .pair { gap: 6px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
.hook { text-align: left; background: var(--accent-soft); border: 1px solid rgba(242,177,76,.35); border-radius: var(--r); padding: 12px 14px; }
.hook p { margin: 6px 0 0; font-size: 16px; }
.hook .eyebrow { color: var(--accent); }
.node.open { z-index: 30; }
.viewer.fit { max-width: min(100%, 560px, calc(58vh * var(--ar))); max-width: min(100%, 560px, calc(58dvh * var(--ar))); }
[hidden] { display: none !important; }
.fb h3 svg { width: 26px; height: 26px; flex: none; }
.labelgrid { display: grid; gap: 12px; }
.labelgrid > * { min-width: 0; }
@media (min-width: 760px) { .labelgrid { grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); align-items: start; } .labelgrid .viewer { margin: 0; } }
@media (min-width: 900px) { :root { --maxw: 860px; } }
.nodes { --amp: 44px; }
@media (max-width: 520px) {
  .nodes { --amp: 26px; }
  .sechead { grid-template-columns: 1fr; }
  .sechead .rank { text-align: left; }
  .sechead .rank br { display: none; }
  .sechead .rank::before { content: ""; }
}

/* ---------- narrated teaching ---------- */
.prog { position: relative; }
.prog .dia { position: absolute; top: 1px; width: 12px; height: 12px; transform: rotate(45deg) scale(.78); background: var(--bg); border: 2px solid var(--muted); border-radius: 2px; }
.prog .dia.done { background: var(--ok); border-color: var(--ok); }
.prog .dia.now { border-color: var(--accent); background: var(--accent); }
.lhead .fbbtn svg { width: 20px; height: 20px; }
.stat.fbtop { color: var(--muted); cursor: pointer; padding: 6px 8px; }
.stat.fbtop svg { width: 17px; height: 17px; }
.player { display: grid; gap: 8px; }
.pbar { height: 4px; border-radius: 99px; background: var(--panel-2); overflow: hidden; }
.pbar > i { display: block; height: 100%; width: 0; background: var(--sc, var(--accent)); transition: width .25s linear; }
.prow { display: flex; align-items: center; gap: 6px; }
.prow .sp { flex: 1; }
.pbtn { width: 40px; height: 40px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel); color: var(--fg); display: grid; place-items: center; cursor: pointer; padding: 0; }
.pbtn svg { width: 20px; height: 20px; }
.pbtn.main { width: 52px; height: 44px; background: var(--panel-2); }
.pbtn.main svg { width: 24px; height: 24px; }
.pbtn.rate { width: auto; padding: 0 10px; font-size: 13px; font-weight: 700; }
.pbtn[aria-pressed="false"] { color: var(--faint); }
.sent { transition: background .2s, color .2s; border-radius: 4px; }
.sent.on { background: var(--accent-soft); color: #fff; box-shadow: 0 0 0 2px var(--accent-soft); }
.task { margin: -6px 0 10px; font-size: 14px; }
.viewer .vcap { position: absolute; left: 50%; top: 48px; transform: translateX(-50%); width: max-content; max-width: 92%; background: rgba(20,20,20,.82); color: #fff; font: 700 15px/1.35 var(--f-body); padding: 6px 10px; border-radius: 8px; text-align: center; pointer-events: none; }
.viewer .stage.kb { animation: kenburns 9s ease-out forwards; }
@keyframes kenburns { from { transform: scale(1); } to { transform: scale(1.14); } }
.mk.draw { stroke-dasharray: 1200; stroke-dashoffset: 1200; animation: drawmk 1.4s .3s ease-out forwards; }
@keyframes drawmk { to { stroke-dashoffset: 0; } }
.lbl { fill: #fff; stroke: rgba(0,0,0,.85); paint-order: stroke; font-family: var(--f-display); font-weight: 800; }
.lbl.draw { opacity: 0; animation: fadein .5s ease-out forwards; }
@keyframes fadein { to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .viewer .stage.kb, .mk.draw, .lbl.draw { animation: none; stroke-dashoffset: 0; opacity: 1; } }
.linkbtn.report { font-size: 13px; padding: 6px 0 0; color: var(--muted); }
.mrow:has(.btn-ghost) { grid-template-columns: minmax(0, 1fr) 90px auto; }

/* ---------- feedback sheet ---------- */
.modal { position: fixed; inset: 0; z-index: 90; background: rgba(0,0,0,.6); display: grid; place-items: end center; padding: 0; }
.sheet { width: min(100%, 560px); background: var(--panel); border: 1px solid var(--line); border-radius: 18px 18px 0 0; padding: 18px 16px calc(18px + env(safe-area-inset-bottom, 0px)); display: grid; gap: 10px; max-height: 92dvh; overflow: auto; }
@media (min-width: 640px) { .modal { place-items: center; } .sheet { border-radius: 18px; } }
.sheet textarea, .sheet input { width: 100%; font: 16px var(--f-body); padding: 12px 14px; border-radius: 12px; border: 2px solid var(--line); background: var(--bg); color: var(--fg); resize: vertical; }
.sheet textarea:focus, .sheet input:focus { border-color: var(--info); outline: none; }

/* six tabs */
.tabs .wrap { grid-template-columns: repeat(6, 1fr); }
@media (max-width: 380px) { .tab { font-size: 10px; } }

/* AI tutor */
.fbacts { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 16px; margin-top: 4px; }
.btn.tutorbtn { width: auto; min-height: 40px; padding: 0 14px; font-size: 15px; display: inline-flex; align-items: center; gap: 8px; box-shadow: 0 3px 0 var(--line); }
.btn.tutorbtn svg { width: 18px; height: 18px; }
.fbacts .linkbtn.report { padding: 6px 0; }
.sheet.tutor { gap: 12px; }
.tchat { display: grid; gap: 10px; max-height: 52dvh; overflow-y: auto; padding: 2px; }
.tmsg { border-radius: 14px; padding: 10px 14px; font-size: 15.5px; line-height: 1.5; max-width: 92%; }
.tmsg p { margin: 0 0 8px; } .tmsg p:last-of-type { margin-bottom: 0; }
.tmsg ul { margin: 4px 0 8px; padding-left: 20px; } .tmsg li { margin: 3px 0; }
.tmsg.ai { background: var(--bg); border: 1px solid var(--line); justify-self: start; }
.tmsg.user { background: rgba(114,198,255,.14); border: 1px solid rgba(114,198,255,.4); justify-self: end; }
.tmsg.err { color: var(--bad); }
.trate { display: flex; align-items: center; gap: 8px; margin-top: 8px; font-size: 13px; }
.trate .chip { padding: 4px 10px; font-size: 15px; box-shadow: none; }
.tnote { font-size: 12.5px; margin: 0; }
.dots { display: inline-flex; gap: 5px; padding: 4px 0; }
.dots i { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); animation: tdot 1s infinite ease-in-out; }
.dots i:nth-child(2) { animation-delay: .15s; } .dots i:nth-child(3) { animation-delay: .3s; }
@keyframes tdot { 0%, 80%, 100% { opacity: .25; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }
@media (prefers-reduced-motion: reduce) { .dots i { animation: none; opacity: .6; } }

/* Clinical case history, shown above every part of a case */
.vignette { border: 1px solid var(--line); border-left: 4px solid var(--info); background: var(--panel); border-radius: 12px; padding: 10px 14px; margin-bottom: 12px; }
.vignette p { margin: 4px 0 0; font-size: 15.5px; line-height: 1.5; }

/* =====================================================================
   v2: plain system font, flat controls, no divider lines, light theme.
   ===================================================================== */
:root {
  --f-display: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --f-body: var(--f-display);
  --f-mono: var(--f-display);
  --topbar-bg: rgba(11, 16, 20, .9);
  --ok-bg: #0f2a1f;
  --bad-bg: #2d1416;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3);
}
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f5f6f8;
  --panel: #ffffff;
  --panel-2: #eceff2;
  --line: #dfe4e8;
  --fg: #15202a;
  --muted: #5b6a74;
  --faint: #98a4ac;
  --accent: #e8a032;
  --accent-ink: #1d1405;
  --accent-soft: rgba(232, 160, 50, .16);
  --ok: #18915a;
  --ok-soft: rgba(24, 145, 90, .12);
  --bad: #d23f3f;
  --bad-soft: rgba(210, 63, 63, .1);
  --info: #1b74b8;
  --topbar-bg: rgba(245, 246, 248, .92);
  --ok-bg: #e5f5ec;
  --bad-bg: #fbe9e9;
  --shadow: 0 1px 3px rgba(20, 32, 42, .08);
}
body { font: 16px/1.55 var(--f-body); letter-spacing: 0; }
h1, h2, h3, .q { font-family: var(--f-body); letter-spacing: -.01em; }
.eyebrow, .qtype, .sechead .rank, .tile .h, .rung small, .bucket h5, .viewer .mod, .viewer .wl, .viewer .counter, .stat, .node .crown, .choice .k, .labelrow .num, .answerline .chip .n {
  font-family: var(--f-body); letter-spacing: 0; text-transform: none;
}
.eyebrow { font-size: 13px; font-weight: 600; color: var(--muted); }
.qtype { font-size: 13px; font-weight: 600; color: var(--muted); margin: 4px 0 6px; }
.q { font-size: clamp(19px, 4.2vw, 23px); font-weight: 700; line-height: 1.3; }
.mono { font-family: var(--f-body); font-variant-numeric: tabular-nums; }

/* no separators */
.topbar { background: var(--topbar-bg); border-bottom: 0; }
.tabs { border-top: 0; box-shadow: 0 -1px 8px rgba(0, 0, 0, .06); }
.lfoot { border-top: 0; }
.lfoot.ok { background: var(--ok-bg); } .lfoot.bad { background: var(--bad-bg); }
.unit h3::after { display: none; }
.rung, .gl, .credit-row, .toggle { border-bottom: 0; }
.answerline { border-bottom: 0; }
.card, .rankcard, .sechead, .term, .stat, .pbtn, .viewer, .sheet, .pop, .tmsg.ai, .hook, .btn-ghost { border: 0; }
.card, .rankcard, .term, .pop { box-shadow: var(--shadow); }
.sechead { background: var(--sc-soft); }

/* flat buttons and choices */
.btn { font: 700 16px/1 var(--f-body); letter-spacing: 0; text-transform: none; box-shadow: none; border-radius: 12px; }
.btn:active { transform: scale(.99); box-shadow: none; }
.btn[disabled], .btn.sec { box-shadow: none; }
.btn.ok, .btn.bad { box-shadow: none; }
.btn.tutorbtn { box-shadow: none; }
.choice, .chip { border-width: 1.5px; box-shadow: none; }
.choice.sel, .choice.right, .choice.wrong { box-shadow: none; }
.choice .k { border-width: 1.5px; font-size: 13px; }
.node-btn { box-shadow: 0 4px 0 var(--sc-dark); }
.node.locked .node-btn { box-shadow: none; }
.sent.on { color: var(--fg); }
.tfrow .choice { font: 700 18px/1 var(--f-body); }

/* clinical case header */
.vignette { border: 0; background: var(--panel); box-shadow: var(--shadow); border-radius: 14px; padding: 14px 16px; margin-bottom: 14px; }
.vhead { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 6px; }
.vtitle { font-weight: 700; font-size: 14px; color: var(--info); }
.vchip { font-size: 12.5px; font-weight: 600; color: var(--muted); background: var(--panel-2); border-radius: 99px; padding: 3px 9px; }
.vstep { margin-left: auto; font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.vignette p { margin: 0; font-size: 16px; line-height: 1.55; color: var(--fg); }

/* question row: label + read-aloud button */
.qtype .say { margin-left: auto; width: 34px; height: 34px; border: 0; border-radius: 10px; background: var(--panel-2); color: var(--fg); display: grid; place-items: center; cursor: pointer; padding: 0; }
.qtype .say svg { width: 18px; height: 18px; }
.qtype .say.on { background: var(--accent-soft); color: var(--accent); }
.learncard .viewer { margin-top: 6px; }
.themebtn { cursor: pointer; padding: 6px 8px; color: var(--muted); }
.lbrand { padding-top: 10px; }
.lbrand .brand { font-size: 15px; gap: 6px; color: var(--muted); }
.lbrand .brand svg { width: 20px; height: 20px; }
.lhead .wrap { padding-block: 8px 14px; }
.sheet.pro h2 { font-size: 22px; }
.perks { margin: 4px 0; padding-left: 20px; display: grid; gap: 6px; }
.perks li::marker { color: var(--accent); }
.lockbtn { margin-top: 6px; }
