/* Anatoscope. One system: every size, colour, space, radius and timing below comes from these tokens, and the canvas
   labels in hud.js read the same ones. Text size (--ts) scales every type token; High contrast (html.hc) swaps a few. */
:root {
  /* type scale: size / line height. No weight under 400 below 24 px */
  --ts: 1;
  --text-hero: calc(40px * var(--ts));    --lh-hero: calc(44px * var(--ts));
  --text-display: calc(28px * var(--ts)); --lh-display: calc(32px * var(--ts));
  --text-title: calc(20px * var(--ts));   --lh-title: calc(28px * var(--ts));
  --text-lead: calc(17px * var(--ts));    --lh-lead: calc(24px * var(--ts));
  --text-body: calc(15px * var(--ts));    --lh-body: calc(22px * var(--ts));
  --text-small: calc(14px * var(--ts));   --lh-small: calc(20px * var(--ts));
  --text-caption: calc(12px * var(--ts)); --lh-caption: calc(16px * var(--ts));
  --font: "Segoe UI Variable Text", "Segoe UI", ui-sans-serif, system-ui, -apple-system, Roboto, sans-serif;
  --font-display: "Segoe UI Variable Display", "Segoe UI", ui-sans-serif, system-ui, -apple-system, Roboto, sans-serif;

  /* contrast tiers, against the panel (#0c0e12): primary 16:1, secondary 11.7:1, tertiary 7.1:1; decoration is never text */
  --fg: #e6eaf0; --fg2: #c4cad4; --fg3: #959daa; --deco: #4c535e;
  --bg: #000; --panel: #07080b; --panel2: #0c0e12; --panel3: #14171d; --line: #191c22; --line2: #2a2f38;
  --rim: #5b636e;      /* outlines drawn in the diagrams */
  --accent: #a9c4e6; --accent-ink: #05080d; --switch: #4f6a8f; --warm: #e4a0a7; --act: #d8424f; --ok: #7fcf9f; --bad: #f08c97;

  /* the plate behind every word on the stage */
  --plate: rgba(8, 10, 14, .82); --plate-line: rgba(255, 255, 255, .12); --plate-blur: 12px;

  /* spacing on a 4 px grid, radii, control heights */
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 20px; --s6: 24px; --s8: 32px; --s10: 40px;
  --r-s: 6px; --r: 8px; --r-l: 12px;
  --ctl: 32px; --ctl-big: 44px; --journey: 40px;
  --top: 64px; --side: 368px; --gap: 16px;
  --col-h: max(440px, calc(100vh - var(--top) - 2 * var(--gap)));      /* the stage column and the panel share one height */

  /* motion: one curve, three durations */
  --ease: cubic-bezier(.2, .7, .2, 1); --t-fast: 120ms; --t: 200ms; --t-slow: 320ms;

  font: 400 var(--text-body) / var(--lh-body) var(--font);
  color-scheme: dark;
}
html.hc { --plate: rgba(4, 5, 8, .97); --plate-line: rgba(255, 255, 255, .28); --fg3: #c4cad4; --fg2: #dfe4ea; --line2: #454b56; --deco: #6b737f; }
html.rm *, html.rm *::before, html.rm *::after { animation: none !important; transition: none !important; }
@media (pointer: coarse) { :root { --ctl: 44px; --journey: 44px; } }

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--fg); }
body { min-height: 100vh; -webkit-font-smoothing: antialiased; }
button { font: inherit; color: inherit; cursor: pointer; transition: color var(--t-fast) var(--ease), background var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease), opacity var(--t-fast) var(--ease); }
button:disabled { cursor: default; }
:is(button, select, summary, a, input[type=range]):focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
a { color: var(--accent); }
svg use { pointer-events: none; }
[hidden] { display: none !important; }
kbd { font: 500 var(--text-caption) / 1 var(--font); color: var(--fg3); border: 1px solid var(--line2); border-radius: 4px; padding: 2px 5px; margin-left: auto; }

/* icons: drawn with strokes, in the text colour */
button svg, .ico, svg:has(> use) { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
symbol .fill { fill: currentColor; stroke: none; }

/* ---------- shared text styles ---------- */
.overline, .label { font-size: var(--text-caption); line-height: var(--lh-caption); font-weight: 500; letter-spacing: .08em; text-transform: uppercase; color: var(--fg3); margin: 0; }
.label { display: block; margin-bottom: var(--s2); }
.note { margin: var(--s2) 0 0; font-size: var(--text-small); line-height: var(--lh-small); color: var(--fg3); }
.note:empty { display: none; }
.callout { margin: 0 0 var(--s4); padding: var(--s3) var(--s4); border-radius: var(--r); background: var(--panel3); border: 1px solid var(--line2); font-size: var(--text-small); line-height: var(--lh-small); color: var(--fg2); }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: var(--s2); min-height: var(--ctl); padding: 0 var(--s4); border-radius: var(--r);
       border: 1px solid var(--line2); background: var(--panel3); color: var(--fg); font-size: var(--text-small); font-weight: 500; white-space: nowrap; }
.btn:enabled:hover { border-color: var(--fg3); }
.btn.primary { background: var(--fg); color: var(--accent-ink); border-color: var(--fg); }
.btn.primary:enabled:hover { background: #fff; border-color: #fff; }
.btn.quiet { background: transparent; border-color: transparent; color: var(--fg2); }
.btn.quiet:enabled:hover { color: var(--fg); border-color: var(--line2); }
.btn.big { min-height: var(--ctl-big); padding: 0 var(--s5); font-size: var(--text-body); border-radius: var(--r); }
.btn.small { min-height: 28px; padding: 0 var(--s3); font-size: var(--text-caption); }
@media (pointer: coarse) { .btn.small { min-height: 40px; } }
.btn:disabled { opacity: .5; }
.icon-btn { display: inline-grid; place-items: center; width: var(--ctl); height: var(--ctl); padding: 0; border: 1px solid transparent; border-radius: var(--r); background: none; color: var(--fg3); }
.icon-btn:enabled:hover { color: var(--fg); background: var(--panel3); }
.icon-btn.small { width: 28px; height: 28px; }
.icon-btn.small svg { width: 16px; height: 16px; }
.icon-btn:disabled { color: var(--deco); }
.link { display: inline-flex; align-items: center; gap: var(--s1); background: none; border: 0; color: var(--accent); font-size: var(--text-small); padding: 0; min-height: 28px; }
.link:hover { text-decoration: underline; text-underline-offset: 3px; }
.link svg { width: 16px; height: 16px; }

/* ---------- header: the brand, the journeys, settings ---------- */
.top { height: var(--top); display: flex; align-items: center; gap: var(--s6); padding: 0 var(--s6); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: var(--s3); color: var(--fg); text-decoration: none; flex: none; }
.brand span { font: 400 var(--text-title) / var(--lh-title) var(--font-display); letter-spacing: .01em; }
.logo { width: 26px; height: 26px; color: var(--fg3); flex: none; }
.journeys { display: flex; gap: var(--s1); margin-right: auto; }
.journey { position: relative; display: inline-flex; align-items: center; gap: var(--s2); height: var(--journey); padding: 0 var(--s4) 0 var(--s3); border-radius: var(--r);
           border: 1px solid transparent; background: none; color: var(--fg3); font-size: var(--text-small); font-weight: 500; }
.journey svg { width: 20px; height: 20px; }
.journey:hover { color: var(--fg); background: var(--panel2); }
.journey[aria-current="page"] { color: var(--fg); background: var(--panel3); border-color: var(--line2); }
.journey .tick { width: 16px; height: 16px; color: var(--ok); stroke-width: 2; margin-left: -2px; }
.journey .badge { font-style: normal; font-size: var(--text-caption); line-height: var(--lh-caption); font-weight: 500; color: var(--accent-ink); background: var(--accent); border-radius: 999px; padding: 1px var(--s2); }
.top .icon-btn { width: var(--journey); height: var(--journey); }

/* ---------- layout: the stage beside the context panel ---------- */
.wrap { display: grid; grid-template-columns: minmax(0, 1fr) var(--side); gap: var(--gap); padding: var(--gap) var(--s6); align-items: start; }
.stagecol { position: sticky; top: var(--gap); min-width: 0; height: var(--col-h); display: flex; align-items: center; justify-content: center;
            background: #000; border: 1px solid var(--line); border-radius: var(--r-l); overflow: hidden; }
.stage { container: stage / inline-size; position: relative; width: min(100%, calc((var(--col-h) - 2px) * var(--ar, 1.7778))); aspect-ratio: var(--ar, 1.7778);
         overflow: hidden; background: #000; }
.stage.can-orbit { cursor: grab; touch-action: none; user-select: none; -webkit-user-select: none; }
.stage.dragging { cursor: grabbing !important; }
.card, .viewpop, .intro-text { touch-action: pan-y; }
.stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
#gl { transform: scaleX(-1); }
#hud { pointer-events: none; }


/* ---------- plates on the stage: one look, one home each ---------- */
.plate { background: var(--plate); border: 1px solid var(--plate-line); border-radius: var(--r); backdrop-filter: blur(var(--plate-blur)); -webkit-backdrop-filter: blur(var(--plate-blur)); }
@keyframes arrive { from { opacity: 0; transform: translateY(4px); } }
@keyframes fade { from { opacity: 0; } }
.plate:not(.card) { animation: arrive var(--t) var(--ease); }
.zone { position: absolute; display: flex; flex-direction: column; gap: var(--s2); pointer-events: none; max-width: calc(100% - 2 * var(--s4)); }
.zone > * { pointer-events: auto; }
.zone-tl { left: var(--s4); top: var(--s4); align-items: flex-start; max-width: min(360px, 42%); }
.zone-tc { left: 50%; top: var(--s4); transform: translateX(-50%); align-items: center; width: max-content; max-width: 40%; }
.zone-tr { right: var(--s4); top: var(--s4); align-items: flex-end; }
.zone-bl { left: var(--s4); bottom: var(--s4); align-items: flex-start; max-width: min(400px, 40%); }
.zone-bc { --tb-w: 336px; --pw: min(436px, calc(100% - var(--tb-w) - var(--s4)));
           left: max(var(--s4), min(calc(50% - var(--pw) / 2), calc(100% - var(--tb-w) - var(--pw))));
           bottom: var(--s4); width: var(--pw); align-items: stretch; }
.zone-br { right: var(--s4); top: var(--s4); bottom: var(--s4); justify-content: flex-end; align-items: flex-end; }

/* objective: the mode, then one line of goal */
.objective { padding: var(--s3) var(--s4); min-width: 220px; }
.objective .overline { color: var(--accent); }
.obj-goal { margin-top: 2px; font-size: var(--text-small); line-height: var(--lh-small); font-weight: 500; color: var(--fg); }
.obj-goal.swap { animation: fade var(--t) var(--ease); }
.obj-progress { display: flex; align-items: center; gap: var(--s2); margin-top: var(--s2); }
.obj-progress i { flex: 1; height: 3px; border-radius: 2px; background: rgba(255, 255, 255, .12); overflow: hidden; }
.obj-progress b { display: block; height: 100%; width: 0; background: var(--accent); transition: width var(--t-slow) var(--ease); }
.obj-progress span { font-size: var(--text-caption); line-height: var(--lh-caption); color: var(--fg3); font-variant-numeric: tabular-nums; white-space: nowrap; }

/* the simulation line (Conditions) and the sight view's eyes */
.simnote { display: flex; align-items: center; gap: var(--s1); padding: 0 var(--s1) 0 var(--s3); min-height: 32px; font-size: var(--text-caption); line-height: var(--lh-caption); color: var(--fg2); }
.sighteyes { padding: var(--s1) var(--s3); color: var(--fg); }

/* notices: a lost face, with its likely fix */
.notice { display: flex; align-items: center; gap: var(--s3); padding: var(--s3) var(--s4); text-align: left; }
.notice .ico { color: var(--warm); }
.notice b { display: block; font-size: var(--text-small); line-height: var(--lh-small); font-weight: 600; }
.notice span { display: block; font-size: var(--text-small); line-height: var(--lh-small); color: var(--fg2); }

/* live readout: which muscles are working */
.activity { width: calc(240px * var(--ts)); padding: var(--s3) var(--s4); }
.activity h4 { margin-bottom: var(--s2); }
.activity ol { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s2); }
.activity li { font-size: var(--text-small); line-height: var(--lh-small); display: grid; grid-template-columns: 1fr 52px; gap: var(--s2); align-items: center; }
.activity li b { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.activity li i { height: 3px; border-radius: 2px; background: var(--act); transform-origin: left; transition: transform var(--t-fast) linear; }
.activity li.idle { color: var(--fg3); grid-template-columns: 1fr; }

/* the movement card (Conditions): how much each part of the face moves, left and right */
.signal { width: calc(248px * var(--ts)); padding: var(--s3) var(--s4); }
.signal h4 { margin: 0 0 var(--s2); display: flex; justify-content: space-between; align-items: baseline; }
.signal h4 em { font-style: normal; text-transform: none; letter-spacing: 0; color: var(--fg3); font-weight: 400; }
.sig-grid { display: grid; grid-template-columns: 72px 1fr 1fr; gap: var(--s2) var(--s3); align-items: center; }
.sig-h { font-size: var(--text-caption); color: var(--fg3); }
.sig-name { font-size: var(--text-small); color: var(--fg2); }
.sig-cell { height: 20px; display: flex; align-items: center; }
.sig-cell i { flex: 1; height: 4px; border-radius: 2px; background: rgba(255, 255, 255, .12); overflow: hidden; }
.sig-cell b { display: block; height: 100%; background: var(--fg); transform-origin: left; transform: scaleX(0); }
.sig-cell em { display: none; font-style: normal; font-size: var(--text-caption); font-weight: 500; color: var(--lost); white-space: nowrap; }
.sig-cell.none i { display: none; } .sig-cell.none em { display: block; }

/* the structure card: beside its part (placed by explore.js), joined to it by a leader on the overlay */
.card { position: absolute; left: 0; top: 0; width: min(320px, calc(100% - 2 * var(--s4))); padding: var(--s3) var(--s4) var(--s4);
        max-height: calc(100% - 2 * var(--s4)); overflow-y: auto; transition: opacity var(--t) var(--ease), border-color var(--t) var(--ease); animation: fade var(--t) var(--ease); }
.card header { display: flex; justify-content: space-between; align-items: center; margin: 0 calc(-1 * var(--s2)) 0 0; }
.card h2 { margin: var(--s1) 0 var(--s2); font-size: var(--text-title); line-height: var(--lh-title); font-weight: 600; }
.card p { margin: 0 0 var(--s2); font-size: var(--text-small); line-height: var(--lh-small); color: var(--fg2); }
.card .fact { color: var(--fg3); }
.card .try { color: var(--warm); font-weight: 500; }
.card .try:empty, .card .fact:empty { display: none; }
.card.pinned { border-color: rgba(169, 196, 230, .55); }
.card:not(.pinned) { pointer-events: none; }
.card:not(.pinned) .card-actions, .card:not(.pinned) #cclose { display: none; }
.card-depth { display: flex; align-items: center; gap: var(--s2); margin: 0 0 var(--s2); }
.card-depth span { color: var(--fg3); font-size: var(--text-caption); font-variant-numeric: tabular-nums; }
.card-depth .icon-btn { border-color: var(--line2); background: var(--panel3); color: var(--fg); }
.card-actions { display: flex; gap: var(--s2); margin-top: var(--s3); }
.chip-btn { display: inline-flex; align-items: center; gap: var(--s2); min-height: 28px; padding: 0 var(--s3); border-radius: 999px; border: 1px solid var(--line2); background: var(--panel3); font-size: var(--text-caption); font-weight: 500; color: var(--fg); }
.chip-btn svg { width: 16px; height: 16px; }
.chip-btn:hover, .chip-btn[aria-pressed="true"] { border-color: var(--accent); }
.chip { font-size: var(--text-caption); line-height: var(--lh-caption); font-weight: 500; letter-spacing: .08em; text-transform: uppercase; color: var(--fg3);
        display: inline-flex; align-items: center; gap: var(--s2); }
.chip::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--c, var(--accent)); }

/* the story caption (Conditions): the beat's words, bottom left */
.storycap { padding: var(--s3) var(--s4); width: 100%; }
.storycap .story-bar { margin-bottom: var(--s2); }
.storycap p { margin: 0; font-size: var(--text-lead); line-height: var(--lh-lead); color: var(--fg); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* the cue (Expressions, the quiz, a lesson's movement, the first win): bottom centre */
.prompt { width: 100%; min-width: 0; max-width: 100%; padding: var(--s3) var(--s4); }
.prompt-main { display: flex; align-items: center; gap: var(--s4); }
.prompt-text { flex: 1; min-width: 0; }
.prompt-say { font-size: var(--text-display); line-height: var(--lh-display); font-weight: 500; letter-spacing: -.005em; color: var(--fg); }
.prompt-say.swap { animation: fade var(--t) var(--ease); }
.prompt-sub { margin-top: var(--s2); font-size: var(--text-small); line-height: var(--lh-small); color: var(--fg2); }
.prompt-sub:empty { display: none; }
.prompt-sub b { color: var(--fg); font-weight: 600; }
.prompt .meter { margin-top: var(--s3); }
.meter { height: 4px; border-radius: 2px; background: rgba(255, 255, 255, .12); overflow: hidden; }
.meter i { display: block; height: 100%; width: 0; background: var(--accent); transition: width 90ms linear; }
.prompt.win { border-color: rgba(127, 207, 159, .6); }
.prompt.win .prompt-say { color: var(--ok); }
.prompt.win .meter i { background: var(--ok); }
.prompt.miss { border-color: rgba(240, 140, 151, .6); }
.prompt.pulse { animation: pulse var(--t-slow) var(--ease); }
@keyframes pulse { 40% { transform: scale(1.025); } }
.glyph { flex: none; width: 56px; height: 56px; border-radius: var(--r); background: rgba(255, 255, 255, .04); display: grid; place-items: center; }
.glyph:empty { display: none; }
.glyph svg { width: 48px; height: 48px; fill: none; stroke: var(--fg); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.glyph svg .face { stroke: var(--fg3); stroke-width: 1.5; }
/* in a lesson the cue is small (its words are in the panel) */
.prompt.aside { min-width: 300px; }
.prompt.aside .prompt-say { font-size: var(--text-title); line-height: var(--lh-title); }

/* toolbar: View, zoom, camera off */
.toolbar { display: flex; align-items: center; gap: 2px; padding: var(--s1); }
.tool { display: inline-flex; align-items: center; gap: var(--s2); height: var(--ctl); padding: 0 var(--s3); border: 0; border-radius: var(--r-s); background: none; color: var(--fg); font-size: var(--text-small); font-weight: 500; }
.tool.icon { width: var(--ctl); padding: 0; justify-content: center; }
.tool:enabled:hover, .tool[aria-expanded="true"] { background: rgba(255, 255, 255, .08); }
.tool[aria-pressed="true"] { background: color-mix(in srgb, var(--accent) 18%, transparent); color: var(--accent); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 55%, transparent); }
.tool[aria-pressed="true"]:enabled:hover { background: color-mix(in srgb, var(--accent) 26%, transparent); }
.tool:disabled { color: var(--deco); }
.tool.accent { background: var(--fg); color: var(--accent-ink); }
.tool.accent:hover { background: #fff !important; }
.tool-sep { width: 1px; height: 20px; background: var(--plate-line); margin: 0 2px; }
.tool-sep[hidden] { display: none; }
/* tooltips: the control's name and its key */
[data-tip] { position: relative; }
[data-tip]:hover::after, [data-tip]:focus-visible::after { content: attr(data-tip); position: absolute; bottom: calc(100% + 8px); right: 0; padding: var(--s1) var(--s2); border-radius: var(--r-s);
  background: var(--panel3); border: 1px solid var(--line2); color: var(--fg); font-size: var(--text-caption); line-height: var(--lh-caption); font-weight: 500; white-space: nowrap; pointer-events: none; animation: fade var(--t-fast) var(--ease); }

/* the View popover above the toolbar */
.viewpop { width: min(312px, calc(100cqw - 2 * var(--s3))); min-height: 0; flex: 0 1 auto; padding: var(--s3) var(--s4); display: grid; gap: var(--s2); overflow-y: auto; overscroll-behavior: contain; }
.viewpop > .link { justify-self: start; min-height: 22px; }
.viewpop-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s2); min-height: 18px; }
.viewpop-head .link { min-height: 18px; font-size: var(--text-caption); }
.view-section { display: grid; gap: 6px; }
.view-presets { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s1); }
.view-presets button { display: flex; align-items: center; min-height: 30px; padding: var(--s1) 10px; border-radius: var(--r-s); border: 1px solid var(--line2);
                       background: rgba(255, 255, 255, .02); color: var(--fg2); font-size: var(--text-caption); line-height: 1.25; text-align: left; }
.view-presets button:hover { color: var(--fg); border-color: rgba(255, 255, 255, .24); background: rgba(255, 255, 255, .05); }
.view-presets button.on { color: var(--fg); background: color-mix(in srgb, var(--accent) 16%, transparent); border-color: color-mix(in srgb, var(--accent) 62%, transparent); font-weight: 500; }
.viewpop .toggles label { min-height: 28px; padding: 0 10px; font-size: var(--text-caption); }
.viewpop .seg button { min-height: 26px; font-size: var(--text-caption); }
.viewpop .sw { min-height: 26px; font-size: var(--text-caption); }
@media (pointer: coarse) {
  .view-presets button, .viewpop .toggles label { min-height: 38px; font-size: var(--text-small); }
  .viewpop .seg button, .viewpop .sw { min-height: 36px; font-size: var(--text-small); }
}

/* the first screen: words on the left, the model face turning on the right */
.intro { position: absolute; inset: 0; display: flex; align-items: center; padding: var(--s10);
         background: linear-gradient(90deg, rgba(0, 0, 0, .92) 0%, rgba(0, 0, 0, .78) 34%, rgba(0, 0, 0, 0) 62%); transition: opacity var(--t-slow) var(--ease); }
.intro.leaving { opacity: 0; pointer-events: none; }
.intro-text { max-width: 440px; display: grid; gap: var(--s4); }
.intro h2 { margin: 0; font: 300 var(--text-hero) / var(--lh-hero) var(--font-display); letter-spacing: -.01em; }
.intro-line { margin: 0; font-size: var(--text-lead); line-height: var(--lh-lead); color: var(--fg2); }
.intro .actions { display: flex; flex-wrap: wrap; gap: var(--s3); margin-top: var(--s2); }
.primer { margin: 0; min-height: var(--lh-small); font-size: var(--text-small); line-height: var(--lh-small); color: var(--fg2); }
.primer:empty { display: none; }
.facts { list-style: none; margin: var(--s2) 0 0; padding: var(--s4) 0 0; border-top: 1px solid var(--line2); display: grid; gap: var(--s2); }
.facts li { display: flex; align-items: center; gap: var(--s3); font-size: var(--text-small); line-height: var(--lh-small); color: var(--fg2); }
.facts svg { width: 18px; height: 18px; color: var(--fg3); }
.intro-note { margin: 0; font-size: var(--text-caption); line-height: var(--lh-caption); color: var(--fg3); }
.demobadge { position: absolute; left: var(--s4); bottom: var(--s4); display: inline-flex; align-items: center; gap: var(--s2); padding: var(--s2) var(--s3); font-size: var(--text-caption); line-height: var(--lh-caption); font-weight: 500; color: var(--fg2); letter-spacing: .08em; text-transform: uppercase; white-space: nowrap; max-width: calc(100% - 2 * var(--s4)); }
.demobadge[hidden] { display: none; }
.demobadge.frozen { border-color: color-mix(in srgb, var(--accent) 45%, transparent); }
.demobadge .badge-act { border: 0; background: none; padding: 0 0 0 var(--s2); margin-left: var(--s1); border-left: 1px solid var(--line); color: var(--accent); font: inherit; font-weight: 600; letter-spacing: inherit; text-transform: inherit; cursor: pointer; }
.demobadge .badge-act:hover { color: var(--fg); }
.split-line { position: absolute; left: 50%; top: 0; bottom: 0; width: 1px; background: var(--line); pointer-events: none; z-index: 3; }
.split-bar { position: absolute; top: var(--s4); right: var(--s4); padding: 3px; z-index: 5; }
.split-bar .seg { gap: 2px; }
.split-bar .seg button { min-height: 28px; padding: 0 var(--s3); font-size: var(--text-caption); }

/* coaching: the face guide, its checks, then the lock-on */
.coach { position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none; }
.coach-oval { position: absolute; height: 74%; aspect-ratio: 200 / 260; }
.coach-oval ellipse { fill: none; stroke: rgba(255, 255, 255, .55); stroke-width: 1.5; stroke-dasharray: 6 7; transition: stroke var(--t) var(--ease); }
.coach.found .coach-oval ellipse { stroke: var(--accent); stroke-dasharray: none; }
.coach.locked .coach-oval { animation: lock var(--t-slow) var(--ease) forwards; }
.coach.locked .coach-oval ellipse { stroke: var(--ok); }
@keyframes lock { to { transform: scale(.94); opacity: 0; } }
.coach-plate { position: absolute; left: 50%; bottom: var(--s4); transform: translateX(-50%); width: max-content; max-width: calc(100% - 2 * var(--s4)); padding: var(--s3) var(--s4); }
.checks { list-style: none; margin: var(--s2) 0 0; padding: 0; display: flex; gap: var(--s4); flex-wrap: wrap; }
.checks li { display: flex; align-items: center; gap: var(--s2); font-size: var(--text-small); line-height: var(--lh-small); color: var(--fg3); transition: color var(--t) var(--ease); }
.checks li svg { width: 18px; height: 18px; stroke-width: 1.8; }
.checks li .dot { width: 18px; height: 18px; display: grid; place-items: center; }
.checks li .dot::before { content: ""; width: 8px; height: 8px; border-radius: 50%; border: 1.5px solid var(--fg3); }
.checks li.ok { color: var(--fg); } .checks li.ok svg { color: var(--ok); }
.coach-tip { margin: var(--s2) 0 0; font-size: var(--text-small); line-height: var(--lh-small); color: var(--warm); font-weight: 500; }
.coach-tip:empty { display: none; }

/* an error card: what happened, how to fix it, and the way forward */
.errcard { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(420px, calc(100% - 2 * var(--s4))); padding: var(--s6); display: grid; gap: var(--s3); }
.errcard .ico { width: 28px; height: 28px; color: var(--warm); }
.errcard h2 { margin: 0; font-size: var(--text-title); line-height: var(--lh-title); font-weight: 600; }
.errcard p { margin: 0; font-size: var(--text-body); line-height: var(--lh-body); color: var(--fg2); }
.errcard .actions { display: flex; flex-wrap: wrap; gap: var(--s2); margin-top: var(--s2); }
@keyframes arrive-c { from { opacity: 0; transform: translate(-50%, calc(-50% + 6px)); } }
.errcard.plate { animation: arrive-c var(--t) var(--ease); }

/* ---------- the context panel: a header, a body that scrolls, a footer that stays in view ---------- */
.side { position: sticky; top: var(--gap); height: var(--col-h); display: flex; flex-direction: column;
        background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-l); overflow: hidden; }
.side-page { display: flex; flex-direction: column; min-height: 0; flex: 1; }
.side-page.enter { animation: page-in var(--t) var(--ease); }
.side-page.enter.from-left { --dx: -12px; }
@keyframes page-in { from { opacity: 0; transform: translateX(var(--dx, 12px)); } }
.ctx-head { padding: var(--s5) var(--s5) var(--s4); border-bottom: 1px solid var(--line); }
.ctx-head .overline:empty { display: none; }
.ctx-head h2 { margin: 2px 0 0; font-size: var(--text-title); line-height: var(--lh-title); font-weight: 600; }
.ctx-head p { margin: var(--s1) 0 0; font-size: var(--text-small); line-height: var(--lh-small); color: var(--fg2); }
.ctx-head p:empty { display: none; }
.ctx-body { flex: 1; min-height: 0; overflow-y: auto; padding: var(--s4) var(--s5) var(--s5); overscroll-behavior: contain; }
.ctx-foot { display: flex; gap: var(--s2); justify-content: flex-end; padding: var(--s3) var(--s5); border-top: 1px solid var(--line); background: var(--panel); }
.ctx-foot .btn { min-height: 40px; }
.ctx-foot .btn.primary { flex: 1; max-width: 100%; }
.ctx-foot:not(:has(.btn:not([hidden]))) { display: none; }
.page-head { display: flex; align-items: center; gap: var(--s3); padding: var(--s4) var(--s5); border-bottom: 1px solid var(--line); }
.page-head h2 { margin: 0; font-size: var(--text-title); line-height: var(--lh-title); font-weight: 600; }
.page-head .back { color: var(--fg2); }
.mode-panel.arrive, .lstep.arrive { animation: arrive var(--t) var(--ease); }

/* Explore's panel: progress, searchable structure atlas, how to */
.ex-controls { display: grid; gap: var(--s3); margin-bottom: var(--s4); padding-bottom: var(--s4); border-bottom: 1px solid var(--line2); }
.ex-sec { display: grid; gap: var(--s2); }
.ex-sec-head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s2); }
.ex-sec-head .label { margin: 0; }
.ex-controls .toggles label { min-height: 30px; padding: 0 10px; font-size: var(--text-caption); }
.ex-controls .style-seg { margin-top: var(--s1); }
.progress-row { display: flex; align-items: center; gap: var(--s3); margin-bottom: var(--s3); }
.progress-row i { flex: 1; height: 4px; border-radius: 2px; background: var(--line2); overflow: hidden; }
.progress-row b { display: block; height: 100%; width: 0; background: var(--accent); transition: width var(--t-slow) var(--ease); }
.progress-row span { font-size: var(--text-small); color: var(--fg2); font-variant-numeric: tabular-nums; white-space: nowrap; }
.atlas-search { display: flex; align-items: center; gap: var(--s2); min-height: var(--ctl); padding: 0 var(--s1) 0 var(--s3); margin-bottom: var(--s4);
                border-radius: var(--r); background: var(--panel2); border: 1px solid var(--line2); transition: border-color var(--t-fast) var(--ease), background var(--t-fast) var(--ease); }
.atlas-search:focus-within { border-color: var(--accent); background: var(--panel3); }
.atlas-search .ico { width: 16px; height: 16px; color: var(--fg3); }
.atlas-search input { flex: 1; min-width: 0; height: var(--ctl); padding: 0; border: 0; background: none; color: var(--fg); font: inherit; font-size: var(--text-small); outline: none; }
.atlas-search input::placeholder { color: var(--fg3); }
.atlas-bar { display: flex; align-items: center; justify-content: space-between; gap: var(--s2); margin-bottom: var(--s2); }
.atlas-bar .label { margin: 0; }
.atlas-filter { min-height: 24px; padding: 0 var(--s2); border-radius: 999px; border: 1px solid var(--line2); color: var(--fg3); font-size: var(--text-caption); text-decoration: none !important; }
.atlas-filter:hover { color: var(--fg); border-color: var(--fg3); }
.atlas-filter.on { color: var(--accent-ink); background: var(--accent); border-color: var(--accent); font-weight: 500; }
.atlas { list-style: none; margin: 0 0 var(--s5); padding: 0; display: grid; gap: var(--s2); }
.atlas-group { border-radius: var(--r); background: var(--panel2); border: 1px solid var(--line); overflow: hidden; transition: border-color var(--t-fast) var(--ease); }
.atlas-group.open { border-color: var(--line2); }
.atlas-head { display: flex; align-items: center; gap: var(--s2); width: 100%; min-height: 38px; padding: var(--s1) var(--s3); border: 0; background: none;
              color: var(--fg2); font-size: var(--text-small); line-height: var(--lh-small); font-weight: 500; text-align: left; }
.atlas-head:hover { color: var(--fg); background: rgba(255, 255, 255, .03); }
.atlas-head:focus-visible { outline-offset: -2px; border-radius: var(--r); }
.atlas-head .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--c); border: 1.5px solid var(--c); flex: none; transition: background var(--t-fast) var(--ease); }
.atlas-group.layer-off .atlas-head .dot { background: transparent; }
.atlas-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.atlas-count { font-style: normal; font-size: var(--text-caption); color: var(--fg3); font-variant-numeric: tabular-nums; }
.atlas-group.full .atlas-count { color: var(--ok); }
.atlas-head .chev { width: 15px; height: 15px; color: var(--fg3); transition: transform var(--t) var(--ease), color var(--t-fast) var(--ease); }
.atlas-group.open .atlas-head .chev { transform: rotate(90deg); color: var(--fg2); }
.atlas-items { list-style: none; margin: 0; padding: var(--s1); border-top: 1px solid var(--line); display: grid; gap: 1px; }
.atlas-item { display: grid; grid-template-columns: 18px 1fr; gap: var(--s2); align-items: start; width: 100%; min-height: 32px; padding: var(--s1) var(--s2);
              border: 1px solid transparent; border-radius: var(--r-s); background: none; color: var(--fg2); font-size: var(--text-small); line-height: var(--lh-small); text-align: left; }
.atlas-item:hover { background: var(--panel3); color: var(--fg); }
.atlas-item.on { background: var(--panel3); border-color: color-mix(in srgb, var(--c) 55%, var(--line2)); color: var(--fg); }
.atlas-item .mk { width: 18px; height: var(--lh-small); display: grid; place-items: center; }
.atlas-item .mk i { width: 6px; height: 6px; border-radius: 50%; border: 1.5px solid var(--fg3); opacity: .65; transition: border-color var(--t-fast) var(--ease), opacity var(--t-fast) var(--ease); }
.atlas-item:hover .mk i { border-color: var(--fg2); opacity: 1; }
.atlas-item.found .mk { color: var(--ok); }
.atlas-item .mk svg { width: 14px; height: 14px; stroke-width: 2.2; }
.atlas-item .item-text { min-width: 0; display: grid; }
.atlas-item b { font-weight: 400; color: var(--fg2); }
.atlas-item.found b, .atlas-item:hover b { color: var(--fg); }
.atlas-item.on b { font-weight: 500; color: var(--fg); }
.atlas-item small { font-size: var(--text-caption); line-height: var(--lh-caption); color: var(--fg3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.atlas-empty { margin: 0 0 var(--s5); padding: var(--s4); border-radius: var(--r); background: var(--panel2); border: 1px solid var(--line); font-size: var(--text-small); line-height: var(--lh-small); color: var(--fg3); text-align: center; }
@media (pointer: coarse) { .atlas-head { min-height: 44px; } .atlas-item { min-height: 40px; padding: var(--s2); } }
.how { margin: 0; padding: 0; list-style: none; counter-reset: how; display: grid; gap: var(--s2); }
.how li { counter-increment: how; display: grid; grid-template-columns: 24px 1fr; gap: var(--s2); font-size: var(--text-small); line-height: var(--lh-small); color: var(--fg2); }
.how li::before { content: counter(how); width: 22px; height: 22px; border-radius: 50%; border: 1px solid var(--line2); display: grid; place-items: center; font-size: var(--text-caption); color: var(--fg3); }

/* steps (Expressions, a lesson's movements): done, now, still to come */
.steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.steps li { display: grid; grid-template-columns: 24px 1fr; gap: var(--s3); align-items: start; padding: var(--s2) var(--s3); border-radius: var(--r); font-size: var(--text-small); line-height: var(--lh-small); color: var(--fg3); }
.steps li b { display: block; font-weight: 500; color: var(--fg2); }
.steps li span { display: block; }
.steps li .mk { width: 22px; height: 22px; margin-top: -1px; border-radius: 50%; border: 1px solid var(--line2); display: grid; place-items: center; font-size: var(--text-caption); color: var(--fg3); }
.steps li .mk svg { width: 14px; height: 14px; stroke-width: 2.2; }
.steps li.done .mk { background: color-mix(in srgb, var(--ok) 18%, transparent); border-color: color-mix(in srgb, var(--ok) 55%, transparent); color: var(--ok); }
.steps li.now { background: var(--panel3); color: var(--fg2); }
.steps li.now b { color: var(--fg); }
.steps li.now .mk { border-color: var(--accent); color: var(--accent); }
.steps li[role="button"] { cursor: pointer; border: 1px solid transparent; transition: background var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease), color var(--t-fast) var(--ease); }
.steps li[role="button"]:hover:not(.now) { background: var(--panel2); color: var(--fg2); border-color: var(--line2); }
.steps li[role="button"]:hover b { color: var(--fg); }
.steps li[role="button"]:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
button.steps-item { all: unset; }
.found-list { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s2); }
.found-list li { display: flex; align-items: center; gap: var(--s2); font-size: var(--text-small); line-height: var(--lh-small); color: var(--fg2); }
.found-list li::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--c, var(--accent)); flex: none; }
.found-list .link { margin-left: auto; min-height: 24px; }
#labdone { margin-top: var(--s5); }

/* the quiz panel */
.score { font: 300 var(--text-display) / var(--lh-display) var(--font-display); font-variant-numeric: tabular-nums; margin-bottom: var(--s1); }
.score em { font-style: normal; font-size: var(--text-small); color: var(--fg3); margin-left: var(--s2); }
.qlist { list-style: none; margin: var(--s4) 0 0; padding: 0; display: grid; gap: 2px; }
.qlist li { display: flex; align-items: center; gap: var(--s3); padding: var(--s2) var(--s3); border-radius: var(--r); font-size: var(--text-small); line-height: var(--lh-small); color: var(--fg2); }
.qlist li .mk { width: 20px; height: 20px; display: grid; place-items: center; flex: none; }
.qlist li .mk svg { width: 16px; height: 16px; stroke-width: 2.2; }
.qlist li.right .mk { color: var(--ok); } .qlist li.missed .mk { color: var(--bad); }
.qlist li.now { background: var(--panel3); color: var(--fg); font-weight: 500; }
.qlist li.later { color: var(--deco); }
.qlist li .link { margin-left: auto; min-height: 24px; }

/* ---------- Conditions: the lesson list, then one lesson as four steps ---------- */
.lesson-list { display: grid; gap: var(--s2); }
.lesson-item { display: grid; gap: 2px; text-align: left; padding: var(--s3) var(--s4); border-radius: var(--r); border: 1px solid var(--line2); background: var(--panel2); }
.lesson-item b { font-size: var(--text-body); line-height: var(--lh-body); font-weight: 600; }
.lesson-item span { font-size: var(--text-small); line-height: var(--lh-small); color: var(--fg3); }
.lesson-item:enabled:hover, .lesson-item:focus-visible { border-color: var(--accent); }
.lesson-item:disabled { background: none; border-color: var(--line); }
.lesson-item:disabled b { color: var(--fg3); }
.lesson-item:disabled span { font-size: var(--text-caption); font-weight: 500; letter-spacing: .08em; text-transform: uppercase; }
.lesson-controls { display: grid; gap: var(--s3); margin-bottom: var(--s4); }
.field { transition: opacity var(--t) var(--ease); }
.field.off { opacity: .4; pointer-events: none; }
.lsteps { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--s1); margin: 0 0 var(--s4); }
.lsteps button { display: grid; gap: var(--s2); padding: 0 0 var(--s1); border: 0; background: none; text-align: left; font-size: var(--text-caption); line-height: var(--lh-caption); font-weight: 500; color: var(--fg3); }
.lsteps button i { height: 3px; border-radius: 2px; background: var(--line2); transition: background var(--t) var(--ease); }
.lsteps button.done i { background: color-mix(in srgb, var(--accent) 55%, transparent); }
.lsteps button[aria-current="step"] { color: var(--fg); }
.lsteps button[aria-current="step"] i { background: var(--accent); }
.lsteps button:hover { color: var(--fg); }
.lstep:not(.on) { display: none; }
.picks { display: grid; gap: var(--s1); }
.pick { display: grid; grid-template-columns: 12px 1fr; column-gap: var(--s3); align-items: center; text-align: left; padding: var(--s2) var(--s3); min-height: var(--ctl);
        border-radius: var(--r); border: 1px solid var(--line); background: none; }
.pick i { width: 8px; height: 8px; border-radius: 50%; background: var(--c); opacity: .6; grid-row: span 2; justify-self: center; transition: opacity var(--t) var(--ease); }
.pick b { font-size: var(--text-small); line-height: var(--lh-small); font-weight: 500; color: var(--fg2); }
.pick span { font-size: var(--text-caption); line-height: var(--lh-caption); color: var(--fg3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pick:hover { border-color: var(--line2); }
.pick[aria-pressed="true"] { background: var(--panel2); border-color: var(--c); }
.pick[aria-pressed="true"] i { opacity: 1; } .pick[aria-pressed="true"] b { color: var(--fg); } .pick[aria-pressed="true"] span { color: var(--fg2); white-space: normal; }
.pick em { display: none; grid-column: 2; margin-top: var(--s1); font-style: normal; font-size: var(--text-small); line-height: var(--lh-small); color: var(--fg2); }
.pick[aria-pressed="true"] em { display: block; }
.pattern { margin-top: var(--s4); }
.pattern p { margin: 0 0 var(--s3); font-size: var(--text-body); line-height: var(--lh-body); color: var(--fg2); }
.pattern .why { color: var(--fg); }
.pattern .why:empty { display: none; }
.look { margin-top: var(--s4); padding: var(--s3) var(--s4); border-radius: var(--r); background: var(--panel2); border: 1px solid var(--line2); }
.look .label { margin-bottom: var(--s1); }
.look p { margin: 0; font-size: var(--text-body); line-height: var(--lh-body); color: var(--fg); }
.look p:empty { display: none; }
#ltrysteps { margin-top: var(--s4); }
.legend { display: flex; flex-wrap: wrap; gap: var(--s1) var(--s4); margin-top: var(--s2); font-size: var(--text-caption); line-height: var(--lh-caption); color: var(--fg2); }
.legend span { display: flex; align-items: center; gap: var(--s2); }
.legend span::before { content: ""; width: 18px; border-top: 1.5px solid var(--kept); flex: none; }
.legend .lost::before { border-top: 1.5px dashed var(--lost); }
.legend .problem::before { width: 9px; height: 9px; border: 1.5px solid var(--site); border-radius: 50%; }
.legend .unseen::before { width: 11px; height: 9px; border: 0; border-radius: 2px; background: color-mix(in srgb, var(--lost) 42%, transparent); }
.legend em { flex-basis: 100%; font-style: normal; color: var(--fg3); }
.block + .block { margin-top: var(--s5); }
.block > .label { margin: 0 0 var(--s2); }
.path { padding: var(--s3) var(--s2) var(--s2); border-radius: var(--r); background: #000; border: 1px solid var(--line); }

/* the lesson diagrams (diagrams.js). --svgk turns stage pixels into the diagram's own units, so its smallest words
   render at the caption size whatever the diagram's width (set by lessons.js) */
.pathway { --svgk: 1; display: block; width: 100%; height: auto; overflow: visible; }
.pathway text { text-anchor: middle; font-family: var(--font); }
.pw-cap { font-size: calc(var(--text-caption) * var(--svgk)); font-weight: 600; letter-spacing: .04em; text-transform: uppercase; fill: var(--fg3); }
.pathway .pw-cap.start { text-anchor: start; } .pathway .pw-cap.end { text-anchor: end; }
.pw-half, .pw-stem { fill: var(--panel2); stroke: var(--line2); }
.pw-half.hurt { fill: color-mix(in srgb, var(--site) 13%, var(--panel2)); stroke: var(--site); }
.pw-nuc { fill: #000; stroke: var(--line2); }
.pw-dot { fill: var(--kept); }
.pw-dot.off { fill: #000; stroke: var(--lost); stroke-width: 1.2; }
.pw-line { fill: none; stroke-width: 1.4; }
.pw-line.kept { stroke: var(--kept); opacity: .5; }
.pw-line.lost { stroke: var(--lost); stroke-dasharray: 4 3.5; }
.pw-flow { fill: none; stroke: var(--kept); stroke-width: 2.6; stroke-linecap: round; stroke-dasharray: 0.01 22; animation: pwflow 1.6s linear infinite; }
@keyframes pwflow { to { stroke-dashoffset: -22.01; } }
.pw-chip rect { fill: var(--panel2); stroke: var(--line2); }
.pw-chip.lost rect { fill: color-mix(in srgb, var(--lost) 9%, var(--panel2)); stroke: var(--lost); stroke-dasharray: 3 2.5; }
.pw-name { font-size: calc(var(--text-caption) * var(--svgk)); font-weight: 500; fill: var(--fg); }
.pw-state { font-size: calc(var(--text-caption) * var(--svgk)); fill: var(--fg3); }
.pw-chip.lost .pw-state { fill: var(--lost); }
.pw-lens { fill: none; stroke: var(--fg3); stroke-width: 1.2; stroke-linecap: round; }
.pw-bone { fill: var(--panel2); stroke: var(--rim); stroke-width: 1; }
.pw-bone.lost { fill: color-mix(in srgb, var(--lost) 9%, var(--panel2)); stroke: var(--lost); stroke-dasharray: 3 2.5; }
.pw-ghost { fill: none; stroke: var(--line2); stroke-width: 1; stroke-dasharray: 3 2.5; }
.pw-artery { fill: none; stroke: var(--kept); stroke-width: 1.4; opacity: .5; }
.pw-rule { stroke: var(--line); stroke-width: 1; }
.fd-bg { fill: rgba(255, 255, 255, .05); }
.fd-lost rect { fill: color-mix(in srgb, var(--lost) 42%, transparent); }
.fd-rim { fill: none; stroke: var(--rim); stroke-width: 1; }
.fd-dot { fill: var(--fg3); }
.fglyph { display: block; margin: 0 auto; }
.legend .hatch::before { width: 11px; height: 9px; border: 1px solid var(--lost); border-radius: 2px;
                         background: repeating-linear-gradient(-45deg, color-mix(in srgb, var(--lost) 55%, transparent) 0 1.2px, transparent 1.2px 3.5px); }
.sd-zone:not(.lost) { fill: color-mix(in srgb, var(--c) 38%, var(--panel2)); }
.sd-hatch-bg { fill: color-mix(in srgb, var(--lost) 10%, var(--panel2)); }
.sd-hatch { stroke: var(--lost); stroke-width: 1.3; opacity: .6; }
.sd-groove { fill: none; stroke: rgba(0, 0, 0, .5); stroke-width: 1.3; stroke-linecap: round; }
.sd-callosum { fill: var(--panel); stroke: rgba(0, 0, 0, .5); }
.sd-rim { fill: none; stroke: var(--rim); stroke-width: 1; }
.sd-label { font-size: calc(var(--text-caption) * var(--svgk)); font-weight: 500; fill: var(--fg); paint-order: stroke; stroke: rgba(0, 0, 0, .7); stroke-width: 2.5px; stroke-linejoin: round; }
.sd-label.lost { fill: var(--lost); }
.sd-key:not(.lost) rect { fill: color-mix(in srgb, var(--c) 45%, var(--panel2)); stroke: var(--c); }
.sd-key.lost rect { stroke: var(--lost); }
.pathway .sd-key text { text-anchor: start; font-size: calc(var(--text-caption) * var(--svgk)); fill: var(--fg2); }
.pathway .sd-key.lost text { fill: var(--lost); }
.pw-x circle { fill: #000; stroke: var(--site); stroke-width: 1.6; }
.pw-x path { stroke: var(--site); stroke-width: 1.6; stroke-linecap: round; }
/* a pattern's story: a bar per beat that fills as it plays, the beat's words, and Replay */
.story { margin: 0 0 var(--s3); }
.story-bar { display: flex; gap: var(--s1); margin-bottom: var(--s2); }
.story-bar i { flex: 1; height: 3px; border-radius: 2px; background: rgba(255, 255, 255, .14); overflow: hidden; }
.story-bar b { display: block; height: 100%; background: var(--fg2); transform-origin: left; transform: scaleX(0); }
.story-bar i.done b { transform: none; }
.story-bar i.now b { animation: beat var(--beat, 3s) linear forwards; }
@keyframes beat { to { transform: none; } }
.story p { margin: 0; min-height: calc(2 * var(--lh-body)); font-size: var(--text-body); line-height: var(--lh-body); color: var(--fg); }
.story .replay { margin-top: var(--s1); }
.arrive { animation: arrive var(--t) var(--ease); }
#lpath.reveal .pw-x { transform-box: fill-box; transform-origin: center; animation: pop .5s cubic-bezier(.2, .7, .2, 1.3) both; }
#lpath.reveal :is(.pw-line.lost, .pw-chip.lost, .pw-dot.off, .pw-half.hurt) { animation: fade .6s .25s both; }
@keyframes pop { from { opacity: 0; transform: scale(0); } }
.more { padding: var(--s3) var(--s4) var(--s4); border-radius: var(--r); border: 1px solid var(--line2); background: var(--panel2); margin-top: var(--s5); }
.more dl { margin: 0; display: grid; grid-template-columns: max-content 1fr; gap: var(--s2) var(--s3); }
.more dt { font-size: var(--text-small); line-height: var(--lh-small); font-weight: 600; color: var(--fg); }
.more dd { margin: 0; font-size: var(--text-small); line-height: var(--lh-small); color: var(--fg2); }
.cmp { width: 100%; border-collapse: collapse; table-layout: fixed; font-size: var(--text-small); line-height: var(--lh-small); }
.cmp th, .cmp td { padding: var(--s2); text-align: left; vertical-align: top; border-top: 1px solid var(--line); }
.cmp thead th { border-top: 0; padding-top: 0; font-size: var(--text-caption); line-height: var(--lh-caption); font-weight: 600; color: var(--fg3); }
.cmp thead th.on { color: var(--fg); }
.cmp tbody th { width: 31%; padding-left: 0; font-weight: 400; color: var(--fg3); }
.cmp td { color: var(--fg2); }
.cmp td.on { background: var(--panel3); color: var(--fg); }
.cmp td.lost { color: var(--lost); }
.cmp.by-pattern col.name { width: 32%; } .cmp.by-pattern col.fig1 { width: 22%; }
.cmp.by-pattern th, .cmp.by-pattern td { vertical-align: middle; }
.cmp.by-pattern thead th:not(:first-child) { text-align: center; white-space: nowrap; padding-left: 2px; padding-right: 2px; }
.cmp.by-pattern tbody th { padding-left: var(--s2); }
.cmp.by-pattern td.fig { padding: var(--s2) var(--s1); }
.cmp tbody th.on { background: var(--panel3); color: var(--fg); }
.sim { margin-top: var(--s5); padding: var(--s3) var(--s4); border-radius: var(--r); border: 1px solid var(--line2); background: #000; }
.sim p { margin: 0; font-size: var(--text-small); line-height: var(--lh-small); color: var(--fg2); }
.sim p + p { margin-top: var(--s2); color: var(--fg3); }

/* ---------- controls ---------- */
.panel { padding: 0 0 var(--s5); margin: 0 0 var(--s5); border-bottom: 1px solid var(--line); }
.panel:last-of-type { border-bottom: 0; }
.panel > .label { margin-bottom: var(--s3); }
.label.spaced { margin-top: var(--s5); }
details.panel summary { cursor: pointer; list-style: none; display: flex; justify-content: space-between; align-items: center; min-height: var(--ctl);
                        font-size: var(--text-caption); font-weight: 500; letter-spacing: .08em; text-transform: uppercase; color: var(--fg3); }
details.panel summary::-webkit-details-marker { display: none; }
details.panel summary::after { content: "+"; font-size: var(--text-title); font-weight: 300; line-height: 1; }
details[open].panel summary::after { content: "–"; }
details[open].panel summary { margin-bottom: var(--s3); }
.preset-row { display: flex; flex-wrap: wrap; gap: var(--s2); }
.row-block { display: grid; gap: var(--s2); margin-bottom: var(--s4); }
.row-name { font-size: var(--text-small); color: var(--fg2); }
.toggles { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s1); }
.toggles label { display: flex; align-items: center; gap: var(--s2); min-height: var(--ctl); padding: 0 var(--s3); border-radius: var(--r-s); border: 1px solid var(--line2);
                 font-size: var(--text-small); cursor: pointer; user-select: none; color: var(--fg3); transition: color var(--t-fast) var(--ease), background var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease); }
.toggles label:hover { color: var(--fg2); }
.toggles input { position: absolute; opacity: 0; pointer-events: none; }
.toggles i { width: 8px; height: 8px; border-radius: 50%; border: 1.5px solid var(--c); flex: none; transition: background var(--t-fast) var(--ease); }
.toggles label:has(input:checked) { color: var(--fg); background: rgba(255, 255, 255, .06); border-color: rgba(255, 255, 255, .2); }
.toggles label:has(input:checked) i { background: var(--c); }
.toggles label:has(input:focus-visible) { outline: 2px solid var(--accent); }
.switches { display: grid; gap: var(--s1); }
.sw { display: flex; align-items: center; gap: var(--s3); min-height: var(--ctl); font-size: var(--text-small); color: var(--fg2); cursor: pointer; user-select: none; }
.sw b { font-weight: 400; }
.sw input { position: absolute; opacity: 0; }
.sw span { width: 32px; height: 18px; border-radius: 9px; background: var(--line2); position: relative; flex: none; transition: background var(--t-fast) var(--ease); }
.sw span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 12px; height: 12px; border-radius: 50%; background: var(--fg3); transition: transform var(--t-fast) var(--ease), background var(--t-fast) var(--ease); }
.sw input:checked + span { background: var(--switch); }
.sw input:checked + span::after { transform: translateX(14px); background: var(--fg); }
.sw input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.sw + .note { margin: 0 0 var(--s3) 44px; }
.seg { display: flex; gap: 2px; padding: 2px; border-radius: var(--r); background: #000; border: 1px solid var(--line2); }
.seg button { flex: 1; min-height: calc(var(--ctl) - 4px); border: 0; background: none; padding: 0 var(--s2); border-radius: var(--r-s); font-size: var(--text-small); font-weight: 500; color: var(--fg3); }
.seg button.on { background: var(--panel3); color: var(--fg); box-shadow: inset 0 0 0 1px var(--line2); }
.seg button:not(.on):hover { color: var(--fg2); }
.row { display: grid; grid-template-columns: 1fr 48%; align-items: center; gap: var(--s3); min-height: var(--ctl); font-size: var(--text-small); color: var(--fg2); margin-top: var(--s2); }
.row b { font-weight: 500; color: var(--fg3); font-size: var(--text-caption); font-variant-numeric: tabular-nums; }
.row:has(> b) { grid-template-columns: 1fr auto 44%; }
.row:has(> b) b { text-align: right; min-width: 44px; }
input[type=range] { width: 100%; accent-color: var(--switch); }
select { font: inherit; font-size: var(--text-small); color: var(--fg); background: #000; border: 1px solid var(--line2); border-radius: var(--r-s); min-height: var(--ctl); padding: 0 var(--s2); width: 100%; }
.menu-row { display: flex; align-items: center; justify-content: space-between; width: 100%; min-height: 44px; padding: 0 var(--s3); border: 1px solid var(--line2); border-radius: var(--r);
            background: var(--panel2); text-align: left; font-size: var(--text-small); color: var(--fg); }
.menu-row svg { width: 16px; height: 16px; color: var(--fg3); transition: transform var(--t-fast) var(--ease); }
.menu-row:hover svg { transform: translateX(2px); color: var(--fg); }
pre#data { margin: 0; padding: var(--s3); background: #000; border: 1px solid var(--line); border-radius: var(--r); color: var(--fg2);
           font: var(--text-caption) / 1.5 ui-monospace, Menlo, Consolas, monospace; white-space: pre-wrap; font-variant-numeric: tabular-nums; }
.about p { margin: 0 0 var(--s3); font-size: var(--text-small); line-height: var(--lh-small); color: var(--fg2); }
.credits a { color: var(--fg); text-decoration-color: var(--line2); text-underline-offset: 2px; }

/* ---------- smaller stages: fewer, smaller plates, so the face stays in view ---------- */
@container stage (max-width: 760px) {
  .signal, .activity { display: none; }
  .zone-tl { max-width: 56%; }
  .objective { min-width: 0; padding: var(--s2) var(--s3); }
  .prompt, .prompt.aside { min-width: 0; padding: var(--s2) var(--s3); }
  .zone-bc { --tb-w: 216px; }
  .prompt-say, .prompt.aside .prompt-say { font-size: var(--text-lead); line-height: var(--lh-lead); }
  .glyph { width: 40px; height: 40px; } .glyph svg { width: 34px; height: 34px; }
  .tool:not(.icon) span { display: none; }
  .tool:not(.icon) { width: var(--ctl); padding: 0; justify-content: center; }
  .storycap p { font-size: var(--text-small); line-height: var(--lh-small); }
  .intro { padding: var(--s6); background: linear-gradient(90deg, rgba(0, 0, 0, .94) 0%, rgba(0, 0, 0, .8) 46%, rgba(0, 0, 0, .1) 80%); }
  .intro h2 { font-size: var(--text-display); line-height: var(--lh-display); }
  .intro-line { font-size: var(--text-body); line-height: var(--lh-body); }
  .facts, .intro-note { display: none; }
  .card { width: min(260px, calc(100% - 2 * var(--s3))); }
  .card p { font-size: var(--text-caption); line-height: var(--lh-caption); }
  .card h2 { font-size: var(--text-lead); line-height: var(--lh-lead); }
}
@container stage (max-width: 520px) {
  .zone-tl, .zone-tr, .zone-bl, .zone-br { --edge: var(--s2); }
  .zone-tl { left: var(--s2); top: var(--s2); max-width: calc(100% - 2 * var(--s2)); }
  .zone-br { right: var(--s2); top: var(--s2); bottom: var(--s2); }
  .zone-bc { left: var(--s2); right: var(--s2); bottom: calc(var(--s2) + var(--ctl) + var(--s5)); width: auto; align-items: stretch; }
  .zone-bl { left: var(--s2); right: var(--s2); bottom: calc(var(--s2) + var(--ctl) + var(--s5)); max-width: none; }
  .zone-tc { top: auto; bottom: calc(var(--s2) + var(--ctl) + var(--s5)); max-width: calc(100% - 2 * var(--s2)); }
  .obj-goal { font-size: var(--text-caption); line-height: var(--lh-caption); }
  .prompt-say, .prompt.aside .prompt-say { font-size: var(--text-body); line-height: var(--lh-body); }
  .prompt .meter { margin-top: var(--s2); }
  .glyph { display: none; }
  .toolbar .tool-sep, #zoomin, #zoomout, #resetview { display: none; }
  .split-bar { top: var(--s2); right: var(--s2); }
  .intro { align-items: flex-end; padding: var(--s4); background: linear-gradient(0deg, rgba(0, 0, 0, .95) 0%, rgba(0, 0, 0, .75) 50%, rgba(0, 0, 0, 0) 85%); }
  .intro-text { gap: var(--s3); }
  .intro h2 { font-size: var(--text-title); line-height: var(--lh-title); font-weight: 600; }
  .intro-line { display: none; }
  .intro .actions { margin: 0; }
  .intro .btn.big { min-height: 40px; font-size: var(--text-small); padding: 0 var(--s4); }
  .coach-oval { height: 64%; }
  .checks { gap: var(--s2) var(--s3); }
  .errcard { padding: var(--s4); }
  .simnote { font-size: var(--text-caption); }
  .obj-progress, .demobadge:not(.frozen) { display: none; }
  .demobadge.frozen { left: var(--s2); bottom: calc(var(--s2) + var(--ctl) + var(--s4)); max-width: calc(100% - 2 * var(--s2)); }
}

/* ---------- narrower windows: the panel below the stage ---------- */
@media (max-width: 1100px) { :root { --side: 332px; } .journey { padding: 0 var(--s3) 0 var(--s2); } .top { gap: var(--s4); } }
@media (max-width: 960px) {
  .wrap { grid-template-columns: 1fr; padding: var(--s3); gap: var(--s3); }
  .stagecol { position: relative; top: 0; height: auto; }
  .stage { width: 100%; }
  .side { position: relative; top: 0; height: auto; min-height: 0; overflow: visible; }
  .ctx-body { overflow: visible; }
  .ctx-foot { position: sticky; bottom: 0; border-radius: 0 0 var(--r-l) var(--r-l); }
  .top { padding: 0 var(--s3); }
  .brand span { display: none; }
}
/* phones: the stage at the top, the panel as a sheet under it, the journeys as a bar along the bottom */
@media (max-width: 640px) {
  :root { --ctl: 44px; --journey: 52px; }
  .top { height: 52px; gap: var(--s2); justify-content: space-between; }
  .brand span { display: inline; font-size: var(--text-lead); }
  .top .icon-btn { width: 40px; height: 40px; flex: none; }
  .journeys { position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; margin: 0; padding: var(--s1) var(--s2) calc(var(--s1) + env(safe-area-inset-bottom));
              background: rgba(5, 6, 8, .94); border-top: 1px solid var(--line); backdrop-filter: blur(12px); display: grid; grid-template-columns: repeat(4, 1fr); gap: 0; }
  .journey { flex-direction: column; justify-content: center; gap: 2px; height: var(--journey); padding: 0; font-size: var(--text-caption); }
  .journey .badge { position: absolute; top: 7px; left: calc(50% + 9px); width: 8px; height: 8px; padding: 0; font-size: 0; }      /* Start here, as a dot */
  .journey .tick { position: absolute; top: 3px; left: calc(50% + 10px); width: 14px; height: 14px; margin: 0; }
  .wrap { padding: 0 0 calc(64px + env(safe-area-inset-bottom)); gap: 0; }
  .stagecol { position: sticky; top: 0; z-index: 5; border: 0; border-radius: 0; }
  .stage { border-bottom: 1px solid var(--line); max-height: 62vh; width: min(100%, calc(62vh * var(--ar, 1.7778))); }
  .side { border-radius: var(--r-l) var(--r-l) 0 0; border-bottom: 0; margin-top: calc(-1 * var(--s2)); position: relative; z-index: 6; box-shadow: 0 -8px 24px rgba(0, 0, 0, .5); }
  .side::before { content: ""; display: block; width: 36px; height: 4px; border-radius: 2px; background: var(--line2); margin: var(--s2) auto 0; }
  .ctx-head { padding: var(--s3) var(--s4); }
  .ctx-body { padding: var(--s4); }
  .ctx-foot { position: sticky; bottom: calc(60px + env(safe-area-inset-bottom)); padding: var(--s3) var(--s4); border-radius: 0; }
  .pro-btn { height: 34px; margin-left: auto; }
  .pro-dialog { padding: var(--s4); }
  .pro-input-row { grid-template-columns: 1fr; }
}

/* ---------- Pro access: header pill, locked previews, Unlock Pro modal ---------- */
.pro-btn { display: inline-flex; align-items: center; gap: var(--s2); height: var(--ctl); padding: 0 var(--s3); border-radius: 999px;
           border: 1px solid var(--line2); background: var(--panel2); color: var(--fg2); font-size: var(--text-caption); font-weight: 500; white-space: nowrap; flex: none; }
.pro-btn svg { width: 14px; height: 14px; color: var(--accent); }
.pro-btn:hover { color: var(--fg); border-color: var(--accent); background: var(--panel3); }
.pro-btn.active { border-color: color-mix(in srgb, var(--ok) 45%, var(--line2)); color: var(--ok); background: color-mix(in srgb, var(--ok) 10%, var(--panel2)); }
.pro-btn.active svg { color: var(--ok); }

.pro-pill { display: inline-flex; align-items: center; gap: 5px; padding: 2px var(--s2); border-radius: 999px; border: 1px solid var(--line2);
            background: var(--panel3); color: var(--fg2); font-size: var(--text-caption); line-height: var(--lh-caption); font-weight: 500; letter-spacing: .04em; text-transform: uppercase; white-space: nowrap; }
.pro-pill svg { width: 12px; height: 12px; color: var(--accent); stroke-width: 1.9; }
.pro-pill.free { border-color: color-mix(in srgb, var(--ok) 40%, var(--line2)); color: var(--ok); background: color-mix(in srgb, var(--ok) 10%, transparent); }
.pro-pill.active { border-color: color-mix(in srgb, var(--ok) 45%, var(--line2)); color: var(--ok); background: color-mix(in srgb, var(--ok) 12%, transparent); }
.pro-pill.active svg { color: var(--ok); }

.lesson-item-top { display: flex; align-items: center; justify-content: space-between; gap: var(--s2); }
.lesson-item.locked { background: var(--panel); border-color: var(--line); }
.lesson-item.locked b { color: var(--fg2); }
.lesson-item.locked:hover, .lesson-item.locked:focus-visible { border-color: var(--line2); background: var(--panel2); }
.lesson-item.locked:hover b { color: var(--fg); }

.steps li.locked { color: var(--fg3); opacity: .82; }
.steps li.locked b { color: var(--fg3); }
.steps li.locked .mk { border-color: var(--line); color: var(--fg3); }
.steps li.locked .mk svg { width: 12px; height: 12px; }
.steps li.locked:hover { opacity: 1; }
.steps li.locked .step-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s2); }

.pro-callout { margin-top: var(--s4); padding: var(--s4); border-radius: var(--r); border: 1px solid var(--line2); background: var(--panel2); display: grid; gap: var(--s2); }
.pro-callout-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s2); }
.pro-callout b { font-size: var(--text-body); line-height: var(--lh-body); font-weight: 600; color: var(--fg); }
.pro-callout p { margin: 0; font-size: var(--text-small); line-height: var(--lh-small); color: var(--fg3); }
.pro-callout .btn { justify-self: start; margin-top: var(--s1); }

.pro-modal { position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; padding: var(--s4);
             background: rgba(0, 0, 0, .74); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); animation: fade var(--t-fast) var(--ease); }
.pro-dialog { width: min(460px, 100%); max-height: min(90vh, 720px); overflow: auto; padding: var(--s5); border-radius: var(--r-l);
              background: var(--panel2); border: 1px solid var(--line2); box-shadow: 0 24px 64px rgba(0, 0, 0, .75); display: grid; gap: var(--s4); }
.pro-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); }
.pro-head h2 { margin: 0; font: 500 var(--text-title) / var(--lh-title) var(--font-display); color: var(--fg); }
.pro-lead { margin: calc(-1 * var(--s2)) 0 0; font-size: var(--text-small); line-height: var(--lh-small); color: var(--fg2); }

.pro-preview { padding: var(--s4); border-radius: var(--r); background: var(--panel3); border: 1px solid var(--line2); display: grid; gap: var(--s2); }
.pro-preview h3 { margin: 0; font-size: var(--text-lead); line-height: var(--lh-lead); font-weight: 600; color: var(--fg); }
.pro-preview-sub { margin: 0; font-size: var(--text-small); line-height: var(--lh-small); color: var(--fg3); }
.pro-preview-lead { margin: 0; font-size: var(--text-small); line-height: var(--lh-small); color: var(--fg2); }
.pro-meta { margin-top: var(--s1); display: grid; gap: var(--s2); }
.pro-meta ul { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: var(--s1); }
.pro-meta li { padding: 2px var(--s2); border-radius: var(--r-s); background: var(--panel2); border: 1px solid var(--line2); font-size: var(--text-caption); color: var(--fg2); }

.pro-includes { display: grid; gap: var(--s2); }
.pro-includes ul { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s2); }
.pro-includes li { display: flex; align-items: start; gap: var(--s2); font-size: var(--text-small); line-height: var(--lh-small); color: var(--fg2); }
.pro-includes li svg { width: 16px; height: 16px; color: var(--ok); margin-top: 2px; flex: none; stroke-width: 2.2; }

.pro-form { display: grid; gap: var(--s2); padding-top: var(--s4); border-top: 1px solid var(--line); }
.pro-form .label { margin-bottom: 0; }
.pro-input-row { display: grid; grid-template-columns: 1fr auto; gap: var(--s2); }
.pro-input-row input { min-height: var(--ctl); padding: 0 var(--s3); border-radius: var(--r); border: 1px solid var(--line2); background: #000;
                       color: var(--fg); font: 500 var(--text-body) / 1 ui-monospace, Menlo, Consolas, monospace; letter-spacing: .04em; text-transform: uppercase; }
.pro-input-row input::placeholder { font-family: var(--font); font-weight: 400; letter-spacing: 0; text-transform: none; color: var(--fg3); }
.pro-input-row input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-color: var(--accent); }
.pro-status { margin: 0; font-size: var(--text-small); line-height: var(--lh-small); color: var(--fg2); }
.pro-status.bad { color: var(--bad); }
.pro-status.ok { color: var(--ok); }

.pro-pilot { padding: var(--s4); border-radius: var(--r); background: var(--panel); border: 1px solid var(--line); display: grid; gap: var(--s2); }
.pro-pilot b { font-size: var(--text-small); line-height: var(--lh-small); font-weight: 600; color: var(--fg); }
.pro-pilot p { margin: 0; font-size: var(--text-small); line-height: var(--lh-small); color: var(--fg3); }
.pro-pilot .btn { justify-self: start; margin-top: var(--s1); text-decoration: none; }

.pro-active { display: grid; gap: var(--s4); }
.pro-active-card { padding: var(--s4); border-radius: var(--r); background: var(--panel3); border: 1px solid var(--line2); display: grid; gap: var(--s2); justify-items: start; }
.pro-active-card b { font-size: var(--text-lead); line-height: var(--lh-lead); font-weight: 600; color: var(--fg); }
.pro-active-card code { padding: 2px var(--s2); border-radius: var(--r-s); background: #000; border: 1px solid var(--line); font-size: var(--text-caption); color: var(--fg2); }
#proremove { justify-self: start; }

@media (prefers-reduced-motion: reduce) { html:not(.rm-off) *, html:not(.rm-off) *::before, html:not(.rm-off) *::after { animation: none !important; transition: none !important; } }
@media (prefers-reduced-motion: reduce) { .story-bar i.now b { transform: scaleX(.5); } }
html.rm .story-bar i.now b { transform: scaleX(.5); }
