/* ==========================================================================
   QuantaLearn — layer 2.
   Loaded after styles.css. Everything here either adds the new interactive
   surfaces (lab, tasks) or raises the visual register of what already existed.

   Direction: Dark-OLED technical, per the design-system query. Deeper ground,
   a controlled glow on the accent only, sharper type scale, and depth from
   layered surfaces rather than heavy shadow. Light mode stays fully supported
   and is designed, not inverted.
   ========================================================================== */

:root {
  --glow: 0 0 0 rgba(0,0,0,0);
  --grid-line: rgba(47, 63, 191, .06);
  --hero-1: #2F3FBF;
  --hero-2: #6E4CC4;
  --hero-3: #BE4128;
  --elev-1: 0 1px 2px rgba(16,19,32,.06), 0 8px 20px -16px rgba(16,19,32,.35);
  --elev-2: 0 2px 6px rgba(16,19,32,.07), 0 22px 48px -28px rgba(16,19,32,.45);
  --radius: 4px;
  --tap: 44px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ground: #070910;
    --surface: #10141F;
    --surface-2: #161B29;
    --surface-3: #1F2637;
    --glow: 0 0 24px rgba(142, 153, 255, .22);
    --grid-line: rgba(142, 153, 255, .055);
    --hero-1: #8E99FF;
    --hero-2: #B18CFF;
    --hero-3: #FF8E71;
    --elev-1: 0 1px 2px rgba(0,0,0,.55), 0 10px 26px -18px rgba(0,0,0,.9);
    --elev-2: 0 2px 8px rgba(0,0,0,.6), 0 28px 60px -30px rgba(0,0,0,1);
  }
}
:root[data-theme="dark"] {
  --ground: #070910;
  --surface: #10141F;
  --surface-2: #161B29;
  --surface-3: #1F2637;
  --glow: 0 0 24px rgba(142, 153, 255, .22);
  --grid-line: rgba(142, 153, 255, .055);
  --hero-1: #8E99FF;
  --hero-2: #B18CFF;
  --hero-3: #FF8E71;
  --elev-1: 0 1px 2px rgba(0,0,0,.55), 0 10px 26px -18px rgba(0,0,0,.9);
  --elev-2: 0 2px 8px rgba(0,0,0,.6), 0 28px 60px -30px rgba(0,0,0,1);
}

/* A faint circuit grid behind everything — the subject's own graph paper.
   Fixed, cheap, and never animated. */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background-image:
    linear-gradient(to right, var(--grid-line) 1px, transparent 1px),
    linear-gradient(to bottom, var(--grid-line) 1px, transparent 1px);
  background-size: 56px 54px;
  mask-image: radial-gradient(ellipse 90% 60% at 50% 0%, #000 35%, transparent 100%);
  -webkit-mask-image: radial-gradient(ellipse 90% 60% at 50% 0%, #000 35%, transparent 100%);
}
.app { position: relative; z-index: 1; }

/* ------------------------------------------------------------------ chrome */
header.bar { padding-top: 22px; }
.brand .name {
  font-size: 21px;
  letter-spacing: -.02em;
  background: linear-gradient(96deg, var(--hero-1), var(--hero-2) 55%, var(--hero-3));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.brand .mark { text-shadow: var(--glow); }

nav button {
  position: relative;
  min-height: 34px;
  transition: color .18s ease, background .18s ease;
}
nav button::after {
  content: "";
  position: absolute;
  left: 12px; right: 12px; bottom: 2px;
  height: 2px; border-radius: 2px;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform .24s cubic-bezier(.22,.9,.28,1);
}
nav button[aria-current="true"]::after { transform: scaleX(1); }
nav button[aria-current="true"] { background: transparent; }

h2.vh {
  font-size: clamp(26px, 3.4vw, 34px);
  letter-spacing: -.022em;
  line-height: 1.08;
}
.panel { box-shadow: var(--elev-1); border-radius: var(--radius); }
.panel:has(.canvas-scroll) { box-shadow: var(--elev-2); }

/* Buttons: real tap targets and a visible press. */
.btn, nav button, .chip, .opt {
  min-height: 34px;
  cursor: pointer;
}
.btn.primary {
  box-shadow: var(--glow);
  transition: transform .12s ease, box-shadow .2s ease, background .18s ease;
}
.btn.primary:active { transform: translateY(1px); }
.btn:not(.tiny), select { min-height: 32px; }
@media (pointer: coarse) {
  .btn, nav button, .chip, .opt, select { min-height: var(--tap); }
  .btn.tiny { min-height: 34px; }
}

/* ------------------------------------------------------- circuit canvas */
.canvas-scroll {
  background:
    radial-gradient(1200px 220px at 20% -40%, color-mix(in srgb, var(--accent) 7%, transparent), transparent 70%),
    var(--surface);
}
.gbox {
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--surface) 92%, transparent);
  transition: transform .14s cubic-bezier(.22,.9,.28,1), box-shadow .18s ease;
}
.gbox:hover, .xor:hover, .dot:hover, .swapx:hover { transform: scale(1.08); }
.gbox.sel { box-shadow: 0 0 0 2px var(--accent), var(--glow); }
.chip { transition: transform .12s ease, border-color .16s ease, background .16s ease, box-shadow .2s ease; }
.chip:hover { transform: translateY(-1px); }
.chip.armed { box-shadow: var(--glow); }

/* The run pulse: a bright sweep down the wires when a circuit executes.
   One animation, on one event, showing the direction time runs. */
.wire { position: absolute; overflow: hidden; }
.run-pulse {
  position: absolute;
  top: 0; bottom: 0;
  width: 90px;
  pointer-events: none;
  background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--accent) 55%, transparent), transparent);
  animation: sweep 900ms cubic-bezier(.4,0,.2,1) forwards;
}
@keyframes sweep {
  from { transform: translateX(-100px); opacity: 0; }
  15%  { opacity: 1; }
  to   { transform: translateX(var(--sweep-to, 900px)); opacity: 0; }
}
@media (prefers-reduced-motion: reduce) { .run-pulse { display: none; } }

/* ---------------------------------------------------------------- pulse */
.pulsing { animation: pop .6s cubic-bezier(.22,.9,.28,1); }
@keyframes pop {
  0%   { transform: scale(1); }
  30%  { transform: scale(1.015); }
  100% { transform: scale(1); }
}

/* ------------------------------------------------------- histogram bars */
.hbar i {
  background: linear-gradient(90deg, var(--accent), color-mix(in srgb, var(--accent) 72%, var(--hero-2)));
  transition: width .42s cubic-bezier(.22,.9,.28,1);
}
.hbar u { transition: left .42s cubic-bezier(.22,.9,.28,1); }
.hrow .val { transition: color .2s ease; }

/* ================================================================== LAB */
.lab { display: grid; gap: 18px; }
.lab-stage {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 14px;
}
.lab-card {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  box-shadow: var(--elev-1);
  padding: 14px 16px 18px;
  display: flex; flex-direction: column; align-items: center;
}
.lab-card-h {
  width: 100%;
  display: flex; align-items: baseline; justify-content: space-between; gap: 10px;
  margin-bottom: 10px; flex-wrap: wrap;
}
.lab-card-h span:first-child {
  font-family: "IBM Plex Mono", monospace; font-size: 10.5px;
  letter-spacing: .12em; text-transform: uppercase; color: var(--ink-3); font-weight: 600;
}
.lab-hint { font-size: 12px; color: var(--ink-3); }
.lab-canvas { display: block; max-width: 100%; height: auto; }

.lab-controls {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  box-shadow: var(--elev-1);
  padding: 16px 18px 18px;
  display: grid; gap: 12px;
}
.lab-readout {
  display: flex; gap: 18px; flex-wrap: wrap; align-items: baseline;
  font-family: "IBM Plex Mono", monospace; font-size: 12.5px; color: var(--ink-2);
}
.lab-phi {
  font-size: 20px; font-weight: 600; color: var(--accent);
  text-shadow: var(--glow); font-variant-numeric: tabular-nums;
}
.lab-eq b { color: var(--ink); font-variant-numeric: tabular-nums; }

.lab-dial {
  width: 100%; margin: 0;
  accent-color: var(--accent);
  height: 26px;
}
.lab-presets { display: flex; gap: 6px; flex-wrap: wrap; }
.lab-preset { font-variant-numeric: tabular-nums; }
.lab-explain {
  font-family: "Source Serif 4", Georgia, serif;
  font-size: 15.5px; line-height: 1.55; color: var(--ink-2);
  border-top: 1px dashed var(--rule); padding-top: 11px;
  min-height: 3em;
}

/* ================================================================ TASKS */
.task {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  box-shadow: var(--elev-1);
  padding: 16px 18px 18px;
}
.task h3 {
  margin: 0 0 4px; font-size: 17.5px; font-weight: 700;
  display: flex; justify-content: space-between; gap: 8px; align-items: baseline;
}
.task .goal { font-size: 14.5px; color: var(--ink-2); margin: 0 0 12px; }
.task .status { margin-top: 12px; }

/* order the steps */
.order-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.order-item {
  display: grid; grid-template-columns: 26px 1fr auto; gap: 10px; align-items: center;
  background: var(--surface-2); border: 1px solid var(--rule);
  border-radius: 3px; padding: 8px 10px;
  transition: border-color .16s ease, transform .16s cubic-bezier(.22,.9,.28,1);
}
.order-item:hover { border-color: var(--rule-2); }
.order-num {
  font-family: "IBM Plex Mono", monospace; font-size: 11px; font-weight: 600;
  color: var(--accent); text-align: center;
}
.order-body b { display: block; font-size: 14px; font-weight: 600; }
.order-body i { display: block; font-size: 11.5px; color: var(--ink-3); font-style: normal; }
.order-moves { display: flex; gap: 4px; }
.order-moves .btn { padding: 2px 8px; line-height: 1.2; }

/* bloch target */
.bloch-body { display: flex; gap: 18px; flex-wrap: wrap; align-items: flex-start; }
.bloch-target { border-radius: 3px; flex: 0 0 auto; }
.bloch-side { flex: 1 1 220px; min-width: 0; display: grid; gap: 9px; align-content: start; }
.bloch-gates { display: flex; gap: 5px; flex-wrap: wrap; }
.bloch-gates .chip { width: 40px; height: 32px; }
.bloch-seq {
  font-size: 12.5px; color: var(--ink-2);
  background: var(--surface-2); border: 1px solid var(--rule);
  border-radius: 3px; padding: 7px 10px;
}

/* code completion */
.code-editor {
  background: var(--surface-2); border: 1px solid var(--rule);
  border-radius: 3px; padding: 10px 0; overflow-x: auto;
}
.code-line {
  display: flex; align-items: center; gap: 10px;
  padding: 3px 14px; font-size: 12.5px; line-height: 1.8;
  white-space: nowrap;
}
.code-line.fixed { color: var(--ink-3); }
.code-gutter {
  color: var(--ink-3); opacity: .55; font-size: 10.5px;
  min-width: 14px; text-align: right; user-select: none;
}
.code-input {
  flex: 1 1 auto; min-width: 140px;
  background: var(--surface); color: var(--accent);
  border: 1px solid var(--accent); border-radius: 3px;
  padding: 4px 9px; font-size: 12.5px;
  box-shadow: var(--glow);
}
.code-input::placeholder { color: var(--ink-3); opacity: .6; }
.code-input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

/* ------------------------------------------------------------ hero strip */
.hero {
  position: relative;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background:
    radial-gradient(720px 200px at 8% -30%, color-mix(in srgb, var(--hero-1) 15%, transparent), transparent 70%),
    radial-gradient(520px 200px at 92% 130%, color-mix(in srgb, var(--hero-3) 11%, transparent), transparent 70%),
    var(--surface);
  padding: 20px 24px;
  margin-bottom: 18px;
  overflow: hidden;
  box-shadow: var(--elev-1);
}
.hero h2 { margin: 0 0 6px; font-size: clamp(22px, 3vw, 30px); letter-spacing: -.02em; }
.hero p { margin: 0; max-width: 72ch; color: var(--ink-2); font-size: 15px; }
.hero .kicker {
  font-family: "IBM Plex Mono", monospace; font-size: 10px; letter-spacing: .14em;
  text-transform: uppercase; color: var(--accent); font-weight: 600; margin-bottom: 8px;
  display: block;
}

/* ---------------------------------------------------------- stat accents */
.stat { transition: transform .18s cubic-bezier(.22,.9,.28,1), border-color .18s ease; }
.stat:hover { transform: translateY(-2px); border-color: var(--rule-2); }
.stat .sv { font-family: "IBM Plex Sans Condensed", sans-serif; }

/* --------------------------------------------------------- concept map */
.mapwrap {
  background:
    radial-gradient(700px 260px at 50% -20%, color-mix(in srgb, var(--accent) 8%, transparent), transparent 70%),
    var(--surface);
}
.node rect { transition: stroke-width .2s ease, opacity .3s ease; }
.node:hover rect { stroke-width: 2.4; }
.node:focus-visible rect { stroke-width: 2.6; }

/* ------------------------------------------------------------- tutor */
.tnote { transition: border-color .2s ease, background .2s ease; }
.tnote.good { box-shadow: inset 3px 0 0 -1px var(--good); }

/* ------------------------------------------------------------ mastery */
.mrow .mbar i {
  background: linear-gradient(90deg, var(--accent), color-mix(in srgb, var(--accent) 65%, var(--hero-2)));
}

/* --------------------------------------------------------- responsive */
@media (max-width: 700px) {
  .lab-stage { grid-template-columns: 1fr; }
  .bloch-body { flex-direction: column; }
  .hero { padding: 16px 16px; }
}

/* ====================================================== THEME TOGGLE */
.theme-toggle{display:inline-flex;gap:2px;background:var(--surface-2);
  border:1px solid var(--rule);border-radius:3px;padding:2px}
.theme-btn{background:none;border:0;border-radius:2px;padding:5px 8px;cursor:pointer;
  color:var(--ink-3);display:flex;align-items:center;min-height:28px;
  transition:background .15s,color .15s}
.theme-btn:hover{color:var(--ink)}
.theme-btn[aria-pressed="true"]{background:var(--accent);color:var(--on-accent)}

/* ====================================================== ONBOARDING */
.onb{max-width:900px;margin:0 auto;padding:14px 0 30px}
.onb-prog{display:flex;gap:6px;margin-bottom:26px}
.onb-dot{flex:1;height:3px;border-radius:2px;background:var(--surface-3);
  transition:background .4s ease}
.onb-dot.on{background:linear-gradient(90deg,var(--hero-1),var(--hero-2))}
.onb-q{font-size:clamp(26px,3.6vw,38px);font-weight:700;letter-spacing:-.024em;
  line-height:1.06;margin:0 0 10px;text-wrap:balance}
.onb-sub{color:var(--ink-2);font-size:16px;max-width:66ch;margin:0 0 22px;line-height:1.6}
.onb-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(250px,1fr));gap:12px}
.onb-card{
  text-align:left;background:var(--surface);border:1px solid var(--rule);
  border-radius:4px;padding:16px 18px;cursor:pointer;display:grid;gap:5px;
  transition:border-color .16s,transform .16s cubic-bezier(.22,.9,.28,1),box-shadow .2s;
  box-shadow:var(--elev-1);min-height:var(--tap);
}
.onb-card:hover{border-color:var(--accent);transform:translateY(-2px)}
.onb-card.sel,.onb-card[aria-pressed="true"]{border-color:var(--accent);box-shadow:var(--glow),var(--elev-1)}
.onb-card b{font-size:17px;font-weight:700;letter-spacing:-.01em}
.onb-card span{font-size:14px;color:var(--ink-2);line-height:1.5}
.onb-card i{font-size:12.5px;color:var(--ink-3);font-style:normal;line-height:1.5;
  border-top:1px dashed var(--rule);padding-top:7px;margin-top:3px}
.onb-back{margin-top:20px}
.onb-actions{display:flex;gap:8px;justify-content:space-between;margin-top:22px;flex-wrap:wrap}
.onb-go{min-height:40px;padding:8px 18px;font-size:13px}

.onb-place{display:grid;gap:10px}
.onb-pq{background:var(--surface);border:1px solid var(--rule);border-radius:4px;padding:14px 16px}
.onb-pn{font-family:"IBM Plex Mono",monospace;font-size:10px;letter-spacing:.12em;
  color:var(--accent);font-weight:600;margin-bottom:5px}
.onb-pt{font-size:16px;font-weight:600;margin-bottom:9px;line-height:1.4}
.onb-popts{display:grid;gap:5px}
.onb-popts .opt{font-family:inherit;font-size:14px;padding:9px 12px}
.onb-popts .opt.dunno{font-style:italic;color:var(--ink-3)}
.onb-popts .opt[aria-pressed="true"]{background:var(--accent-soft);border-color:var(--accent);
  color:var(--accent);font-weight:600}

/* ====================================================== PATH VIEW */
.path-hero{
  border:1px solid var(--rule);border-radius:5px;padding:26px 28px;
  background:
    radial-gradient(760px 220px at 6% -40%,color-mix(in srgb,var(--hero-1) 16%,transparent),transparent 70%),
    radial-gradient(520px 200px at 96% 140%,color-mix(in srgb,var(--hero-3) 10%,transparent),transparent 70%),
    var(--surface);
  box-shadow:var(--elev-2);margin-bottom:16px;
}
.path-hero .kicker{font-family:"IBM Plex Mono",monospace;font-size:10px;letter-spacing:.15em;
  text-transform:uppercase;color:var(--accent);font-weight:600;display:block;margin-bottom:9px}
.path-hero h2{margin:0 0 10px;font-size:clamp(24px,3.2vw,34px);letter-spacing:-.024em;
  line-height:1.08;text-wrap:balance}
.path-why{font-family:"Source Serif 4",Georgia,serif;font-size:17px;color:var(--ink-2);
  line-height:1.55;max-width:66ch;margin:0 0 14px}
.path-meta{display:flex;gap:6px;flex-wrap:wrap;margin-bottom:16px}
.path-meta .pill{background:var(--surface-2);color:var(--ink-3)}
.path-go{min-height:42px;padding:9px 20px;font-size:13px}

.path-prog{background:var(--surface);border:1px solid var(--rule);border-radius:4px;
  padding:13px 16px;margin-bottom:8px}
.path-prog-h{display:flex;justify-content:space-between;gap:10px;flex-wrap:wrap;
  font-size:14px;color:var(--ink-2);margin-bottom:8px}
.path-prog-h .mono{font-size:11.5px;color:var(--ink-3)}
.path-bar{height:6px;background:var(--surface-3);border-radius:4px;overflow:hidden}
.path-bar i{display:block;height:100%;border-radius:4px;
  background:linear-gradient(90deg,var(--hero-1),var(--hero-2));
  transition:width .5s cubic-bezier(.22,.9,.28,1)}

.path-list{display:grid;gap:7px}
.path-step{
  display:grid;grid-template-columns:30px 1fr auto;gap:13px;align-items:center;
  text-align:left;background:var(--surface);border:1px solid var(--rule);
  border-radius:4px;padding:12px 15px;cursor:pointer;min-height:var(--tap);
  transition:border-color .16s,transform .16s cubic-bezier(.22,.9,.28,1);
}
.path-step:hover{border-color:var(--accent);transform:translateX(2px)}
.path-n{font-family:"IBM Plex Mono",monospace;font-size:12px;font-weight:600;
  color:var(--accent);text-align:center}
.path-b b{display:block;font-size:15px;font-weight:600;margin-bottom:2px}
.path-b i{display:block;font-size:12.5px;color:var(--ink-3);font-style:normal;line-height:1.45}

.path-cfg{display:grid;gap:7px}
.path-cfg-row{display:grid;grid-template-columns:150px 190px 1fr;gap:14px;align-items:baseline;
  background:var(--surface);border:1px solid var(--rule);border-radius:3px;padding:11px 15px;font-size:14px}
.path-cfg-row .k{font-family:"IBM Plex Mono",monospace;font-size:10.5px;letter-spacing:.1em;
  text-transform:uppercase;color:var(--ink-3)}
.path-cfg-row .v{font-weight:600;color:var(--ink)}
.path-cfg-row .w{color:var(--ink-2);font-size:13.5px}
@media (max-width:760px){.path-cfg-row{grid-template-columns:1fr;gap:3px}}

/* ============================================ TRACK-AWARE LESSON LEAD */
.lesson-lead{background:var(--surface-2);border:1px solid var(--rule);border-left:3px solid var(--accent);
  border-radius:0 3px 3px 0;padding:11px 14px;margin:0 0 12px}
.lesson-lead-h{font-family:"IBM Plex Mono",monospace;font-size:10px;letter-spacing:.12em;
  text-transform:uppercase;color:var(--accent);font-weight:600;margin-bottom:7px}
.lesson-lead pre{margin:0;padding:0;background:none;border:0;font-size:12px;
  color:var(--ink);white-space:pre-wrap;word-break:break-word;line-height:1.7}
.lesson-lead-n{font-size:12.5px;color:var(--ink-3);margin:7px 0 0;line-height:1.5}
.lesson-plain{font-weight:600;color:var(--ink);font-size:15.5px}
.lesson-more{margin:0 0 10px}
.lesson-more summary{cursor:pointer;font-family:"IBM Plex Mono",monospace;font-size:11px;
  letter-spacing:.08em;text-transform:uppercase;color:var(--ink-3);padding:5px 0;min-height:30px}
.lesson-more summary:hover{color:var(--accent)}
.lesson-more[open] summary{margin-bottom:6px}

/* ==================================================== FIGURES */
.fig{display:block;width:100%;max-width:340px;height:auto;margin:0 auto}

/* A real photograph — see figPhoto() in ui/figures.js. Framed the same as
   every drawn figure (the .mod-fig wrapper), so it doesn't read as a
   different kind of content dropped in. */
.fig-photo{margin:0;display:flex;flex-direction:column;align-items:center;gap:8px}
.fig-photo-imgwrap{position:relative;display:inline-block;max-width:100%}
.fig-photo img,.fig-photo video{display:block;max-width:100%;max-height:280px;width:auto;height:auto;
  border-radius:3px;box-shadow:var(--shadow, 0 2px 10px rgba(0,0,0,.25))}
.fig-video video{background:#000}
.fig-photo figcaption{display:flex;flex-direction:column;gap:2px;text-align:center;max-width:44ch}
.fig-photo-cap{font-size:12px;color:var(--ink-2);line-height:1.5}
.fig-photo-credit{font-family:"IBM Plex Mono",monospace;font-size:9.5px;color:var(--ink-3)}

/* A pixel-measured pointer to one detail inside a photo — see figPhoto()'s
   `mark` option. A plain ring would still get lost against a busy circuit
   photo, so this pairs it with an always-visible text label instead of
   relying on the ring's position alone to carry the meaning. */
.fig-photo-mark{position:absolute;transform:translate(-50%,-50%);pointer-events:none}
.fig-photo-mark::before{content:'';position:absolute;top:0;left:0;width:22px;height:22px;
  transform:translate(-50%,-50%);border-radius:50%;border:2.5px solid #ff5050;
  box-shadow:0 0 0 3px rgba(255,80,80,.35);animation:fig-mark-pulse 1.8s ease-out infinite}
.fig-photo-mark-label{position:absolute;left:16px;top:-9px;white-space:nowrap;
  font-family:"IBM Plex Mono",monospace;font-size:10.5px;font-weight:600;color:#fff;
  background:#c81e1e;padding:2px 6px;border-radius:3px;line-height:1.4}
@keyframes fig-mark-pulse{
  0%{box-shadow:0 0 0 3px rgba(255,80,80,.35)}
  70%{box-shadow:0 0 0 9px rgba(255,80,80,0)}
  100%{box-shadow:0 0 0 3px rgba(255,80,80,0)}
}
@media (prefers-reduced-motion: reduce){
  .fig-photo-mark::before{animation:none}
}

/* A visible "this is not a real photo" flag — see figPhoto()'s `synthetic`
   check. Never subtle: the whole point is that it can't be mistaken for the
   same real-photo credit line every other .fig-photo carries. */
.fig-photo-synthetic-badge{position:absolute;bottom:6px;right:6px;
  font-family:"IBM Plex Mono",monospace;font-size:9.5px;font-weight:600;
  color:#fff;background:rgba(20,20,24,.78);border:1px solid rgba(255,255,255,.25);
  padding:2px 6px;border-radius:3px;letter-spacing:.02em;pointer-events:none}

/* The familiar-vs-new bridge — see figCompare() in ui/figures.js. */
.fig-compare{display:flex;align-items:center;justify-content:center;gap:14px;flex-wrap:wrap;width:100%}
.fig-compare-side{display:flex;flex-direction:column;align-items:center;gap:6px}
.fig-compare-icon{width:60px;height:60px;flex:none}
.fig-compare-label{text-align:center;max-width:110px}
.fig-compare-label b{display:block;font-size:12px;color:var(--ink)}
.fig-compare-label span{display:block;font-size:10.5px;color:var(--ink-3);line-height:1.3}
.fig-compare-arrow{font-family:"IBM Plex Mono",monospace;font-size:11px;color:var(--ink-3);
  text-align:center;max-width:60px;line-height:1.3}
.fig-compare .fig-photo{gap:6px}
.fig-compare .fig-photo img{max-height:150px}
.fig-compare .fig-photo-cap{font-size:10.5px}

/* A real third-party interactive — see figEmbed() in ui/figures.js. Not
   loaded until clicked, and always labelled as the one thing on this page
   that needs a network connection. */
.fig-embed{display:flex;flex-direction:column;align-items:center;gap:10px;width:100%}
.fig-embed-notice{font-size:11px;color:var(--warn);text-align:center}
.fig-embed-btn{width:100%}
.fig-embed-frame{width:100%;max-width:100%;border:1px solid var(--rule-2);border-radius:4px;
  background:#fff}
.fig-embed-credit{font-family:"IBM Plex Mono",monospace;font-size:9.5px;color:var(--ink-3);
  text-align:center}

/* ==================================================== LEARN INDEX */
.learn-rail{display:grid;grid-template-columns:auto minmax(120px,1fr) auto;gap:14px;align-items:center;
  background:var(--surface);border:1px solid var(--rule);border-radius:4px;padding:12px 16px;
  margin-bottom:14px;box-shadow:var(--elev-1)}
.learn-rail-l b{font-size:15px;font-weight:700;display:block;letter-spacing:-.01em}
.learn-rail-l span{font-family:"IBM Plex Mono",monospace;font-size:10.5px;color:var(--ink-3)}
.learn-rail-bar{height:6px;background:var(--surface-3);border-radius:4px;overflow:hidden}
.learn-rail-bar i{display:block;height:100%;border-radius:4px;
  background:linear-gradient(90deg,var(--hero-1),var(--hero-2));transition:width .5s cubic-bezier(.22,.9,.28,1)}
.learn-rail-r{font-family:"IBM Plex Mono",monospace;font-size:10.5px;color:var(--ink-3);white-space:nowrap;
  display:flex;align-items:center;gap:10px;justify-content:flex-end}
.learn-streak{display:inline-flex;align-items:center;gap:3px;font-size:12px;font-weight:600;color:var(--ink)}
.learn-streak b{font-style:normal;font-size:13px}
@media (max-width:640px){.learn-rail{grid-template-columns:1fr;gap:8px}}

.learn-start{
  border:1px solid var(--accent);border-radius:5px;padding:22px 24px;margin-bottom:18px;
  background:
    radial-gradient(660px 200px at 6% -40%,color-mix(in srgb,var(--hero-1) 18%,transparent),transparent 70%),
    var(--surface);
  box-shadow:var(--glow),var(--elev-2);position:relative;overflow:hidden;
}
.learn-start .kicker{font-family:"IBM Plex Mono",monospace;font-size:10px;letter-spacing:.15em;
  text-transform:uppercase;color:var(--accent);font-weight:600;display:block;margin-bottom:8px}
.learn-start h3{margin:0 0 8px;font-size:clamp(20px,2.6vw,26px);font-weight:700;letter-spacing:-.02em}
.learn-start p{margin:0 0 14px;font-size:15.5px;color:var(--ink-2);max-width:64ch;line-height:1.55}
.learn-start .btn{min-height:42px;padding:9px 20px;font-size:13px}
.learn-start-n{display:block;margin-top:10px;font-size:10.5px;color:var(--ink-3)}

.lesson.next{border-color:var(--accent)}
.lesson.next.done{border-color:var(--good)}
.lesson h3{font-size:21px}
.lesson .prose{font-size:16px}
.lesson-plain{font-size:16.5px}

/* Two-column curriculum layout — a compact sidebar (chapter list) beside a
   spacious lesson pane, replacing an earlier winding-SVG-path design that
   put 97 small nodes in a squeezed centre column. Same breakpoint values
   as .wb (styles.css) for consistency: collapses to one column (sidebar
   stacked above content, not hidden) under 840px. */
.lessons > .learn-layout{grid-column:1 / -1}
.lessons > .learn-rail,
.lessons > .learn-start{grid-column:1 / -1}
.learn-layout{display:grid;grid-template-columns:290px minmax(0,1fr);gap:18px;align-items:start}
@media (max-width:840px){.learn-layout{grid-template-columns:minmax(0,1fr)}}

.learn-sidebar{position:sticky;top:14px;max-height:calc(100vh - 28px);overflow-y:auto}
@media (max-width:840px){.learn-sidebar{position:static;max-height:none}}

.learn-chapters{display:flex;flex-direction:column;gap:8px}
.chapter{
  border:1px solid var(--rule-2);border-radius:8px;overflow:hidden;
  background:linear-gradient(180deg, color-mix(in srgb, var(--chapter-hue) 5%, var(--surface)), var(--surface));
}
.chapter.chapter-done{border-color:color-mix(in srgb, var(--good) 45%, var(--rule-2))}
.chapter-banner{
  display:flex;align-items:center;gap:9px;padding:11px 13px;cursor:pointer;
  list-style:none;user-select:none;
}
.chapter-banner::-webkit-details-marker{display:none}
.chapter-dot{width:8px;height:8px;border-radius:50%;background:var(--chapter-hue);flex:none}
.chapter-title{
  font-family:"IBM Plex Mono",monospace;font-size:11.5px;font-weight:700;letter-spacing:.05em;
  color:var(--ink);flex:1;
}
.chapter-count{
  display:flex;flex-direction:column;align-items:flex-end;gap:3px;flex:none;
}
.chapter-count-text{
  font-family:"IBM Plex Mono",monospace;font-size:10px;color:var(--ink-2);white-space:nowrap;
  padding:2px 8px;border-radius:20px;background:var(--surface-2);
}
.chapter.chapter-done .chapter-count-text{color:var(--good);background:color-mix(in srgb, var(--good) 14%, var(--surface-2))}
.chapter-count-bar{width:64px;height:3px;background:var(--surface-3);border-radius:3px;overflow:hidden}
.chapter-count-bar i{display:block;height:100%;background:var(--accent);border-radius:3px}
.chapter-chevron{
  width:7px;height:7px;flex:none;border-right:1.6px solid var(--ink-2);border-bottom:1.6px solid var(--ink-2);
  transform:rotate(45deg);transition:transform .18s ease;margin-top:-2px;
}
.chapter[open] .chapter-chevron{transform:rotate(-135deg);margin-top:2px}

.lesson-rows{display:flex;flex-direction:column;border-top:1px solid var(--rule-2)}
.lesson-row{
  display:flex;align-items:center;gap:10px;width:100%;text-align:left;
  background:none;border:0;border-bottom:1px solid var(--rule-2);padding:9px 13px;cursor:pointer;
  font-family:inherit;
}
.lesson-row:last-child{border-bottom:0}
.lesson-row:hover{background:var(--surface-2)}
.row-icon{
  flex:none;width:24px;height:24px;border-radius:50%;display:flex;align-items:center;justify-content:center;
  font-size:12px;font-weight:700;background:var(--surface-3);color:var(--ink-2);
}
.row-label{display:flex;flex-direction:column;gap:1px;min-width:0}
.row-title{font-size:14.5px;color:var(--ink);line-height:1.3;
  overflow:hidden;text-overflow:ellipsis;display:-webkit-box;-webkit-line-clamp:2;line-clamp:2;-webkit-box-orient:vertical}
.row-state{font-family:"IBM Plex Mono",monospace;font-size:10px;letter-spacing:.04em;color:var(--ink-2)}

.lesson-row.row-done .row-icon{background:var(--good);color:var(--on-accent)}
.lesson-row.row-done .row-state{color:var(--good)}
.lesson-row.row-next{background:color-mix(in srgb, var(--accent) 7%, transparent)}
.lesson-row.row-next .row-icon{background:var(--accent);color:var(--on-accent)}
.lesson-row.row-next .row-title{font-weight:700}
.lesson-row.row-next .row-state{color:var(--accent);font-weight:700}
.lesson-row.row-selected{box-shadow:inset 3px 0 0 var(--accent)}

.learn-main{min-width:0}
@media (max-width:640px){
  .chapter-banner{padding:10px 11px}
  .lesson-row{padding:8px 11px}
}

/* ==================================================== MODULE READER */
.mod{max-width:820px;margin:0 auto}
.mod-bar{display:flex;align-items:center;gap:14px;flex-wrap:wrap;margin-bottom:14px}
.mod-title{display:flex;flex-direction:column;line-height:1.25;margin-right:auto}
.mod-n{font-family:"IBM Plex Mono",monospace;font-size:10px;letter-spacing:.13em;
  text-transform:uppercase;color:var(--accent);font-weight:600}
.mod-title b{font-size:17px;font-weight:700;letter-spacing:-.01em}
.mod-count{font-size:12px;color:var(--ink-3);font-variant-numeric:tabular-nums}
.mod-mute{background:none;border:none;cursor:pointer;font-size:15px;line-height:1;padding:4px 6px;
  border-radius:4px;opacity:.85;transition:opacity .12s,background .12s}
.mod-mute:hover{opacity:1;background:var(--surface-2)}
.mod-mute.off{opacity:.4}

.mod-ladder{display:flex;gap:4px;margin-bottom:16px;overflow-x:auto;padding-bottom:2px}
.mod-rung{flex:1 1 0;min-width:74px;background:var(--surface-2);border:1px solid var(--rule);
  border-radius:3px;padding:7px 6px;cursor:pointer;font-family:"IBM Plex Mono",monospace;
  font-size:9.5px;letter-spacing:.07em;text-transform:uppercase;color:var(--ink-3);
  transition:border-color .16s,color .16s,background .16s;min-height:32px}
.mod-rung:disabled{opacity:.4;cursor:default}
.mod-rung.done{color:var(--good);border-color:color-mix(in srgb,var(--good) 40%,transparent)}
.mod-rung.now{background:var(--accent);border-color:var(--accent);color:var(--on-accent);font-weight:600}

.mod-stage{background:var(--surface);border:1px solid var(--rule);border-radius:5px;
  padding:22px 26px 26px;box-shadow:var(--elev-2);border-top:3px solid var(--accent)}
.mod-stage.tone-ground{border-top-color:var(--ink-3)}
.mod-stage.tone-bridge{border-top-color:var(--accent)}
.mod-stage.tone-name{border-top-color:var(--hero-2)}
.mod-stage.tone-rules{border-top-color:var(--warn)}
.mod-stage.tone-do{border-top-color:var(--good)}
.mod-stage.tone-deep{border-top-color:var(--signal)}
.mod-rung-label{display:flex;gap:9px;align-items:baseline;margin-bottom:6px}
.mod-rung-label b{font-family:"IBM Plex Mono",monospace;font-size:10px;letter-spacing:.14em;
  text-transform:uppercase;color:var(--accent);font-weight:600}
.mod-rung-label span{font-size:12px;color:var(--ink-3)}
.mod-h{margin:0 0 16px;font-size:clamp(21px,2.8vw,28px);font-weight:700;letter-spacing:-.02em;
  line-height:1.12;text-wrap:balance}
.mod-fig{background:var(--surface-2);border:1px solid var(--rule);border-radius:4px;
  padding:18px 14px;margin-bottom:16px;display:flex;justify-content:center}
/* A stage is several paragraphs now, not one caption, so they need space
   between them — run together at this length they read as a wall. */
.mod-say{font-family:"Source Serif 4",Georgia,serif;font-size:17px;line-height:1.65;
  color:var(--ink-2);margin:0 0 15px;max-width:62ch}
.mod-say:last-of-type{margin-bottom:0}
.mod-action{margin-top:14px}

/* ---- the real workbench, on loan inline (see ui/inlinewb.js) ---- */
.wb-inline-panel{margin-top:16px;border:1px solid var(--accent);border-radius:5px;
  background:var(--surface);box-shadow:var(--glow, none);overflow:hidden}
.wb-inline-head{display:flex;flex-wrap:wrap;align-items:baseline;gap:8px;
  padding:11px 16px;border-bottom:1px solid var(--rule);background:var(--accent-soft)}
.wb-inline-head b{font-size:14px;font-weight:700;color:var(--accent)}
.wb-inline-head span{font-size:12px;color:var(--ink-3)}
.wb-inline-slot{padding:16px}
/* Forced narrow layout regardless of actual viewport width — this lives in
   a ~820px module column now, not the full-width Build view the normal
   .wb breakpoints (styles.css) were written for. */
.wb-inline{grid-template-columns:90px minmax(0,1fr) !important;gap:12px !important}
.wb-inline > .tutor-panel{grid-column:1 / -1}
@media (max-width:640px){.wb-inline{grid-template-columns:minmax(0,1fr) !important}}

/* ---- tap-to-answer exercise (see buildExercise() in ui/module.js) ---- */
.mod-ex{margin-top:4px}
.mod-ex-kicker{font-family:"IBM Plex Mono",monospace;font-size:10px;letter-spacing:.14em;
  text-transform:uppercase;color:var(--accent);font-weight:600;margin-bottom:10px}
.mod-ex-sentence,.mod-ex-q{font-family:"Source Serif 4",Georgia,serif;font-size:19px;
  line-height:1.6;color:var(--ink);margin:0 0 18px;max-width:60ch}
.mod-ex-slot{display:inline-block;min-width:96px;text-align:center;padding:1px 10px;
  border-bottom:2px solid var(--accent);color:var(--ink-3);font-family:"IBM Plex Mono",monospace;
  font-size:15px}
.mod-ex-slot.filled{color:var(--accent);font-weight:600}
.mod-ex-opts{display:flex;flex-wrap:wrap;gap:9px}
.mod-ex-opt{font-family:"IBM Plex Mono",monospace;font-size:13.5px;
  background:var(--surface-2);color:var(--ink);border:1.5px solid var(--rule-2);
  border-radius:8px;padding:11px 18px;cursor:pointer;min-height:44px;
  transition:border-color .12s,background .12s,transform .12s}
.mod-ex-opt:hover:not(:disabled){border-color:var(--accent);transform:translateY(-1px)}
.mod-ex-opt:disabled{cursor:default}
.mod-ex-opt.right{background:var(--good-soft);border-color:var(--good);color:var(--good);font-weight:600;
  animation:optPop .32s cubic-bezier(.22,.9,.28,1) both}
.mod-ex-opt.wrong{border-color:var(--signal);color:var(--signal);opacity:.55;text-decoration:line-through;
  animation:optShake .32s ease both}
@media (prefers-reduced-motion:reduce){.mod-ex-opt.right,.mod-ex-opt.wrong,.opt.right,.opt.wrong{animation:none}}
@keyframes optPop{
  0%{transform:scale(1)}
  40%{transform:scale(1.06)}
  100%{transform:scale(1)}
}
@keyframes optShake{
  0%,100%{transform:translateX(0)}
  20%{transform:translateX(-5px)}
  40%{transform:translateX(4px)}
  60%{transform:translateX(-3px)}
  80%{transform:translateX(2px)}
}
.mod-ex-feedback{display:none;margin-top:14px;font-size:14.5px;line-height:1.6;
  border-left:3px solid var(--rule-2);padding-left:12px;color:var(--ink-2)}
.mod-ex-feedback.on{display:block}
.mod-ex-feedback.good{border-left-color:var(--good)}
.mod-ex-feedback.bad{border-left-color:var(--signal)}

.mod-ai{margin:14px 0}
.mod-ai-btn{
  background:none;border:1px dashed var(--rule-2);color:var(--ink-3);
  font-family:"IBM Plex Mono",monospace;font-size:11.5px;padding:8px 12px;
}
.mod-ai-btn:hover{border-color:var(--accent);color:var(--accent)}
.mod-ai-box:empty{display:none}
.mod-ai-box{
  margin-top:10px;background:var(--accent-soft);border:1px solid var(--accent);
  border-radius:4px;padding:12px 14px;
}
.mod-ai-text{margin:0;font-size:14px;color:var(--ink);line-height:1.6}
.mod-ai-text.mono{font-family:"IBM Plex Mono",monospace;font-size:11.5px;color:var(--ink-3)}

.mod-example{margin:14px 0;background:var(--good-soft);border:1px solid var(--good);border-radius:4px;padding:14px 16px}
.mod-example-kicker{font-family:"IBM Plex Mono",monospace;font-size:10px;letter-spacing:.13em;text-transform:uppercase;color:var(--good);font-weight:600;margin-bottom:6px}
.mod-example-title{font-size:15px;font-weight:700;margin-bottom:6px;color:var(--ink)}
.mod-example-body{font-size:14.5px;line-height:1.6;color:var(--ink-2);margin:0 0 8px}
.mod-example-body:last-child{margin-bottom:8px}
.mod-example .stat{margin-top:4px;background:var(--surface)}

/* A step-by-step derivation, laid out the way a professor works through it
   on a board: one labelled card per step, each step's own lines unfolding
   progressively (expression, substitution, simplified, result) instead of
   the whole calculation compressed into a single sentence. The numbered
   badge and left accent bar read as "step N of the board", and the last
   line of each card — the step's own result — is the one line that
   should catch your eye first if you skim. */
.mod-steps{margin:14px 0;display:grid;gap:10px}
.mod-step{background:var(--surface-2);border:1px solid var(--rule-2);border-left:3px solid var(--accent);
  border-radius:4px;padding:12px 16px;display:flex;gap:12px;align-items:flex-start}
.mod-step-num{flex:none;width:22px;height:22px;border-radius:50%;background:var(--accent-soft);
  border:1px solid var(--accent);color:var(--accent);font-family:"IBM Plex Mono",monospace;
  font-size:11.5px;font-weight:700;display:flex;align-items:center;justify-content:center;margin-top:1px}
.mod-step-body{flex:1;min-width:0}
.mod-step-label{font-family:"IBM Plex Mono",monospace;font-size:11px;letter-spacing:.06em;
  text-transform:uppercase;color:var(--accent);font-weight:600;margin-bottom:8px}
.mod-step-lines{display:grid;gap:4px}
.mod-step-line{font-family:"IBM Plex Mono",monospace;font-size:14px;line-height:1.55;color:var(--ink-2);
  white-space:pre-wrap;word-break:break-word}
.mod-step-line:last-child{color:var(--good);font-weight:700;font-size:15px;margin-top:2px}
.mod-steps-closing{font-family:"Source Serif 4",Georgia,serif;font-size:16px;line-height:1.6;
  color:var(--ink-2);margin:12px 0 0}

.mod-check{margin-top:20px;border-top:1px dashed var(--rule);padding-top:16px}
.mod-check-h{font-family:"IBM Plex Mono",monospace;font-size:10px;letter-spacing:.13em;
  text-transform:uppercase;color:var(--signal);font-weight:600;margin-bottom:7px}
.mod-check-q{font-size:16px;font-weight:600;margin-bottom:10px;line-height:1.4}
.mod-check .opts{display:grid;gap:5px}
.mod-check .opt{font-family:inherit;font-size:14.5px;padding:10px 13px}
.mod-why{display:none;margin-top:11px;font-size:14px;color:var(--ink-2);line-height:1.55;
  border-left:2px solid var(--accent);padding-left:12px}
.mod-why.on{display:block}

.mod-controls{display:grid;grid-template-columns:auto minmax(60px,1fr) auto;gap:14px;
  align-items:center;margin-top:16px}
.mod-progress-wrap{display:flex;align-items:center;gap:10px;min-width:0}
.mod-progress{flex:1;height:9px;background:var(--surface-3);border-radius:5px;overflow:hidden;min-width:0}
.mod-progress i{display:block;height:100%;border-radius:5px;
  background:linear-gradient(90deg,var(--hero-1),var(--hero-2));transition:width .4s cubic-bezier(.22,.9,.28,1)}
.mod-progress-pct{flex:none;font-size:11px;color:var(--ink-3);width:34px;text-align:right}
.mod-next{min-height:40px;padding:8px 18px}

.mod-done{background:var(--surface);border:1px solid var(--good);border-radius:5px;
  padding:26px 28px;box-shadow:var(--elev-2);text-align:left}
.mod-done-badge{display:inline-flex;gap:9px;align-items:baseline;background:var(--good-soft);
  color:var(--good);border-radius:3px;padding:5px 11px;margin-bottom:12px}
.mod-done-badge .mono{font-size:10px;letter-spacing:.13em}
.mod-done-badge b{font-size:13px;font-weight:700}
.mod-done-stats{display:grid;grid-template-columns:repeat(auto-fit,minmax(130px,1fr));gap:11px;margin:18px 0}
.mod-recap{margin:18px 0}
.mod-recap-grid{display:grid;grid-template-columns:minmax(0,1fr) auto;gap:7px 14px;margin-top:8px}
.mod-recap-plain{font-size:13.5px;color:var(--ink-2);align-self:center}
.mod-recap-term{font-size:13.5px;color:var(--accent);font-weight:600;align-self:center;white-space:nowrap}
.mod-badges{margin:16px 0}
.badge{display:grid;gap:2px;background:var(--surface-2);border:1px solid var(--rule);
  border-left:3px solid var(--good);border-radius:0 3px 3px 0;padding:10px 13px;margin-bottom:6px}
.badge b{font-size:14.5px;font-weight:700}
.badge span{font-size:12.5px;color:var(--ink-3)}
.mod-unlock{margin:20px 0;padding:20px;border-radius:8px;text-align:center;
  background:var(--surface-2);border:1px dashed var(--rule-2)}
.mod-unlock-icon{font-size:30px;line-height:1;margin-bottom:8px;display:inline-block;
  transition:transform .15s ease}
.mod-unlock-icon.pop{animation:unlockPop .5s cubic-bezier(.22,.9,.28,1) both}
@keyframes unlockPop{
  0%{transform:scale(1) rotate(0deg)}
  40%{transform:scale(1.35) rotate(-8deg)}
  70%{transform:scale(0.95) rotate(4deg)}
  100%{transform:scale(1) rotate(0deg)}
}
@media (prefers-reduced-motion:reduce){.mod-unlock-icon.pop{animation:none}}
.mod-unlock-label{font-size:10.5px;letter-spacing:.16em;color:var(--accent);font-weight:700;margin-bottom:6px}
.mod-unlock-title{font-size:16px;font-weight:700;margin-bottom:6px}
.mod-unlock-tease{font-size:13.5px;color:var(--ink-2);line-height:1.5;max-width:44ch;margin:0 auto}
.mod-challenge{
  margin:20px 0;padding:18px 20px;border-radius:8px;
  background:
    radial-gradient(560px 160px at 6% -20%, color-mix(in srgb, var(--hero-2) 20%, transparent), transparent 70%),
    var(--surface-2);
  border:1.5px solid transparent;
  border-image:linear-gradient(120deg,var(--hero-1),var(--hero-2),var(--good)) 1;
}
.mod-challenge-kicker{font-size:11px;letter-spacing:.1em;color:var(--accent);font-weight:700;margin-bottom:6px}
.mod-challenge-h{font-size:19px;font-weight:700;margin-bottom:6px}
.mod-challenge-sub{font-size:13.5px;color:var(--ink-2);line-height:1.55;margin-bottom:14px;max-width:60ch}
.mod-challenge-body .mod-ai-btn{background:linear-gradient(90deg,var(--hero-1),var(--hero-2));
  color:var(--on-accent);border:none;font-weight:600}
.mod-challenge-body .mod-ai-btn:hover{filter:brightness(1.08);color:var(--on-accent)}
.mod-share{margin:18px 0}
.mod-share-canvas{display:block;width:100%;max-width:520px;height:auto;border-radius:8px;
  border:1px solid var(--rule-2);margin:8px 0 12px;box-shadow:var(--elev-1)}

@media (max-width:640px){
  .mod-stage{padding:18px 16px 20px}
  .mod-controls{grid-template-columns:1fr 1fr;gap:10px}
  .mod-progress{grid-column:1 / -1;order:-1}
}

/* The hidden attribute must beat a display rule, or a hidden grid stays visible. */
[hidden]{display:none !important}

/* The rail, the start card and the compact row list live inside the lessons
   grid; span the full row. Only the one full "next" card stays a normal
   grid item, the same width every card used to be. */
.lessons > .learn-rail,
.lessons > .learn-start,
.lessons > .lesson-rows{grid-column:1 / -1}

/* ==================================================== RESUME BANNER */
.resume-banner{
  display:flex;align-items:center;gap:14px;flex-wrap:wrap;justify-content:space-between;
  background:var(--warn-soft);border:1px solid var(--warn);border-radius:4px;
  padding:11px 16px;margin-bottom:12px;
}
.resume-text{display:flex;flex-direction:column;gap:1px;min-width:0}
.resume-text b{font-size:13px;font-weight:700;color:var(--warn);letter-spacing:-.005em}
.resume-text span{font-size:13px;color:var(--ink-2)}
.resume-actions{display:flex;gap:8px;flex-shrink:0}

/* ==================================================== CELEBRATION OVERLAYS */
.celebrate-overlay{
  position:fixed;inset:0;z-index:500;display:flex;align-items:center;justify-content:center;
  background:color-mix(in srgb, var(--ground) 82%, transparent);
  opacity:0;transition:opacity .22s ease;padding:20px;
}
.celebrate-overlay.celebrate-in{opacity:1}
.celebrate-overlay.celebrate-out{opacity:0}
.celebrate-canvas{position:absolute;inset:0;width:100%;height:100%;pointer-events:none}
.celebrate-card{
  position:relative;max-width:460px;width:100%;text-align:center;
  background:var(--surface);border:1px solid var(--rule-2);border-radius:14px;
  padding:36px 30px;box-shadow:var(--elev-2),var(--glow);
  transform:scale(.92) translateY(8px);transition:transform .28s cubic-bezier(.22,.9,.28,1);
}
.celebrate-overlay.celebrate-in .celebrate-card{transform:scale(1) translateY(0)}
@media (prefers-reduced-motion:reduce){
  .celebrate-overlay{transition:none}
  .celebrate-card{transition:none;transform:none}
}

/* ==================================================== GUIDED TOUR */
/* pointer-events:none on the root is the real fix — a fixed full-viewport box
   intercepts hit-testing itself even when every child already says none. Only
   the card (and its Skip/Back/Next controls) opts back in to being clickable;
   the spotlighted real UI underneath receives every other click untouched. */
.tour-root{position:fixed;inset:0;z-index:200;pointer-events:none}
.tour-dim{
  position:absolute;inset:0;
  background:color-mix(in srgb, var(--ground) 72%, transparent);
  backdrop-filter:blur(1px);
  /* CRITICAL: a full-viewport layer with no pointer-events rule captures every
     click before it reaches the real UI beneath — the spotlighted control
     looks clickable and is not. The cutout is drawn by .tour-ring's box-shadow
     below; this layer only needs to be seen, never touched. */
  pointer-events:none;
}
.tour-ring{
  position:fixed;display:none;border-radius:8px;
  box-shadow:0 0 0 2000px color-mix(in srgb, var(--ground) 72%, transparent),
             0 0 0 2px var(--accent), var(--glow);
  pointer-events:none;transition:left .28s cubic-bezier(.22,.9,.28,1),top .28s cubic-bezier(.22,.9,.28,1),
    width .28s cubic-bezier(.22,.9,.28,1),height .28s cubic-bezier(.22,.9,.28,1);
}
.tour-card{
  position:fixed;width:320px;max-width:calc(100vw - 32px);
  background:var(--surface);border:1px solid var(--accent);border-radius:5px;
  box-shadow:var(--elev-2),var(--glow);padding:16px 18px;z-index:201;
  pointer-events:auto; /* opts back in — the root disables it for everything else */
}
.tour-progress{display:flex;gap:4px;margin-bottom:10px}
.tour-dot{width:16px;height:3px;border-radius:2px;background:var(--surface-3)}
.tour-dot.on{background:var(--accent)}
.tour-dot.done{background:color-mix(in srgb,var(--accent) 45%,var(--surface-3))}
.tour-h{margin:0 0 6px;font-size:16.5px;font-weight:700;letter-spacing:-.01em}
.tour-body{margin:0 0 12px;font-size:14px;color:var(--ink-2);line-height:1.55}
.tour-wait{
  display:flex;align-items:center;gap:8px;font-size:11px;color:var(--accent);
  background:var(--accent-soft);border-radius:3px;padding:7px 10px;margin-bottom:6px;
}
.tour-pulse{
  width:8px;height:8px;border-radius:50%;background:var(--accent);flex-shrink:0;
  animation:tourpulse 1.1s ease-in-out infinite;
}
@keyframes tourpulse{0%,100%{transform:scale(.7);opacity:.5}50%{transform:scale(1.15);opacity:1}}
@media (prefers-reduced-motion:reduce){.tour-pulse{animation:none}}
.tour-controls{display:flex;align-items:center;gap:8px}

/* ==================================================== GLOSSARY LOOKUP */
/* Double-click a word anywhere in a module — see ui/glossary.js. */
.gloss-pop{
  position:fixed;z-index:180;background:var(--surface);border:1px solid var(--accent);
  border-radius:6px;box-shadow:var(--elev-2, 0 8px 24px rgba(0,0,0,.35)),var(--glow, none);
  padding:13px 14px;font-family:"IBM Plex Sans Condensed",sans-serif;
  animation:gloss-in .14s ease-out;
}
@keyframes gloss-in{from{opacity:0;transform:translateY(4px)}to{opacity:1;transform:translateY(0)}}
@media (prefers-reduced-motion:reduce){.gloss-pop{animation:none}}
.gloss-head{display:flex;align-items:baseline;gap:8px;margin-bottom:7px}
.gloss-head b{font-size:15px;font-weight:700;text-transform:capitalize}
.gloss-tag{font-family:"IBM Plex Mono",monospace;font-size:9.5px;letter-spacing:.08em;
  text-transform:uppercase;color:var(--accent);background:var(--accent-soft);
  border-radius:3px;padding:2px 6px}
.gloss-close{margin-left:auto;background:none;border:none;color:var(--ink-3);
  font-size:18px;line-height:1;cursor:pointer;padding:0 2px}
.gloss-close:hover{color:var(--ink)}
.gloss-def{font-size:13.5px;color:var(--ink-2);line-height:1.55;margin:0}
.gloss-example{font-size:12px;color:var(--ink-3);line-height:1.5;margin:8px 0 0;font-style:italic}
.gloss-example-k{font-family:"IBM Plex Mono",monospace;font-size:9.5px;letter-spacing:.06em;
  text-transform:uppercase;font-style:normal;color:var(--ink-3)}
.gloss-loading,.gloss-empty{font-size:13px;color:var(--ink-3);margin:0}
.gloss-loading-note{margin-top:6px;font-size:11px;opacity:.75}
.gloss-empty-retry{color:var(--warn)}
.gloss-credit{font-size:10.5px;color:var(--ink-3);margin:9px 0 0;border-top:1px dashed var(--rule);padding-top:7px}

/* ==================================================== COPILOT */
.copilot-fab{
  position:fixed;right:20px;bottom:20px;z-index:150;
  width:52px;height:52px;border-radius:50%;
  background:var(--accent);color:var(--on-accent);border:1px solid var(--accent);
  display:flex;align-items:center;justify-content:center;cursor:pointer;
  box-shadow:var(--elev-2),var(--glow);transition:transform .16s cubic-bezier(.22,.9,.28,1);
}
.copilot-fab:hover{transform:scale(1.06)}
.copilot-badge{
  position:absolute;top:-3px;right:-3px;min-width:18px;height:18px;border-radius:9px;
  background:var(--signal);color:#fff;font-family:"IBM Plex Mono",monospace;font-size:10px;
  font-weight:700;display:flex;align-items:center;justify-content:center;padding:0 4px;
  border:2px solid var(--ground);
}
.copilot-panel{
  position:fixed;right:20px;bottom:82px;z-index:150;width:340px;max-width:calc(100vw - 32px);
  max-height:min(72vh,560px);overflow-y:auto;
  background:var(--surface);border:1px solid var(--rule);border-radius:5px;
  box-shadow:var(--elev-2);padding:14px 16px 16px;
  opacity:0;transform:translateY(8px) scale(.98);pointer-events:none;
  transition:opacity .18s ease,transform .18s cubic-bezier(.22,.9,.28,1);
}
.copilot-panel.on{opacity:1;transform:none;pointer-events:auto}
.copilot-head{display:flex;align-items:center;justify-content:space-between;gap:10px;margin-bottom:10px}
.copilot-who{display:flex;flex-direction:column;line-height:1.2}
.copilot-who b{font-size:14.5px;font-weight:700}
.copilot-who span{font-family:"IBM Plex Mono",monospace;font-size:10.5px;color:var(--ink-3)}
.copilot-ai-tag{
  display:inline-block;width:fit-content;margin-top:3px;padding:1px 6px;border-radius:2px;
  background:var(--accent-soft);color:var(--accent);font-size:9.5px!important;font-weight:700;
  letter-spacing:.06em;text-transform:uppercase;
}
.copilot-brief{
  background:var(--accent-soft);border:1px solid var(--accent);border-radius:4px;
  padding:11px 13px;margin-bottom:10px;
}
.copilot-brief p{margin:0 0 8px;font-size:13.5px;color:var(--ink);line-height:1.5}
.copilot-brief p:last-child{margin-bottom:0}
.copilot-chips{display:flex;flex-wrap:wrap;gap:6px;margin-bottom:10px}
.copilot-chip{height:auto;min-height:0;padding:5px 10px;font-size:11.5px;white-space:normal;text-align:left}
.copilot-answer:empty{display:none}
.copilot-a-badge{
  display:inline-block;font-family:"IBM Plex Mono",monospace;font-size:9.5px;letter-spacing:.06em;
  text-transform:uppercase;padding:2px 7px;border-radius:2px;font-weight:600;margin-bottom:6px;
}
.copilot-a-badge.ok{background:var(--good-soft);color:var(--good)}
.copilot-a-badge.bad{background:var(--signal-soft);color:var(--signal)}
.copilot-a-text{margin:0 0 10px;font-size:13.5px;color:var(--ink-2);line-height:1.55}
.copilot-ask{display:flex;gap:6px;margin-top:4px}
.copilot-input{flex:1;min-width:0;font-size:12.5px}
.copilot-note{font-size:11.5px;color:var(--ink-3);margin:8px 0 0;line-height:1.5}
.copilot-foot{margin-top:12px;padding-top:10px;border-top:1px dashed var(--rule)}

@media (max-width:520px){
  .copilot-panel{right:10px;left:10px;width:auto;bottom:78px}
  .copilot-fab{right:14px;bottom:14px}
}

/* ==================================================== ANIMATED FIGURES
   One animated element per figure — the rest of the drawing is still.
   Every element's un-animated resting style (set inline, per instance) is
   already the CORRECT final picture, so the global
   `prefers-reduced-motion: reduce { animation:none!important }` rule (see
   styles.css) can disable any of these with zero loss of information —
   the reader just sees the finished diagram immediately, accurately. */

/* settle-in rotation: from vertical (0deg) to the real angle, once */
.fig .fig-rot{ animation:figRotIn .65s cubic-bezier(.22,.9,.28,1) both; }
@keyframes figRotIn{ from{ transform:rotate(0deg); } to{ transform:rotate(var(--fig-rot-to,0deg)); } }

/* the same settle, with a brief uncertain wobble first — "before you look" */
.fig .fig-rot-wobble{ animation:figRotWobble .9s cubic-bezier(.22,.9,.28,1) both; }
@keyframes figRotWobble{
  0%   { transform:rotate(0deg); }
  35%  { transform:rotate(calc(var(--fig-rot-to,0deg) + 10deg)); }
  60%  { transform:rotate(calc(var(--fig-rot-to,0deg) - 6deg)); }
  100% { transform:rotate(var(--fig-rot-to,0deg)); }
}

/* a gate acting: swing from one real angle to another, resting at the "after" */
.fig .fig-rot-delta{ animation:figRotDelta .55s cubic-bezier(.22,.9,.28,1) both .3s; }
@keyframes figRotDelta{ from{ transform:rotate(var(--fig-rot-from,0deg)); } to{ transform:rotate(var(--fig-rot-to,0deg)); } }

/* a route drawing itself in, rather than appearing pre-drawn */
.fig .fig-draw{ animation:figDraw .5s ease-out both; }
@keyframes figDraw{ from{ stroke-dasharray:var(--fig-len); stroke-dashoffset:var(--fig-len); } to{ stroke-dasharray:var(--fig-len); stroke-dashoffset:0; } }

/* a bar growing from its baseline to its real height */
.fig .fig-grow{ animation:figGrow .45s cubic-bezier(.22,.9,.28,1) both; }
@keyframes figGrow{ from{ transform:scaleY(0); } to{ transform:scaleY(1); } }

/* a bar (or a link) growing outward left-to-right or from its centre */
.fig .fig-grow-x{ animation:figGrowX .45s cubic-bezier(.22,.9,.28,1) both; }
@keyframes figGrowX{ from{ transform:scaleX(0); } to{ transform:scaleX(1); } }

/* something appearing as a discrete event — a sampled outcome, a conclusion */
.fig .fig-pop{ animation:figPop .4s cubic-bezier(.22,.9,.28,1) both; }
@keyframes figPop{ from{ opacity:0; transform:scale(.72); } to{ opacity:1; transform:scale(1); } }

/* the small replay control on a figure that animates once on mount */
.fig .fig-replay{ cursor:pointer; }
.fig .fig-replay circle{ transition:stroke .15s ease, fill .15s ease; }
.fig .fig-replay:hover circle, .fig .fig-replay:focus-visible circle{ stroke:var(--accent); fill:var(--accent-soft); }
.fig .fig-replay text{ pointer-events:none; }

/* the gate box, marking the instant it acts */
.fig .fig-gate-pulse{ animation:figGatePulse .5s cubic-bezier(.22,.9,.28,1) both; }
@keyframes figGatePulse{
  0%   { transform:scale(1); }
  45%  { transform:scale(1.08); filter:drop-shadow(0 0 6px color-mix(in srgb, var(--accent) 55%, transparent)); }
  100% { transform:scale(1); filter:none; }
}

/* ==================================================== MATH WORKBOOK
   Real matrix/vector arithmetic, laid out the way a textbook lays it out.
   No external math-typesetting library — CSS borders draw the brackets. */
.mod-mathwork{ margin:14px 0 0; }

/* ---- real generated code, walked line by line (see stage.codeWalk) ---- */
.mod-codewalk{margin:16px 0 0;border:1px solid var(--rule);border-radius:4px;
  background:var(--surface-2);overflow:hidden}
.mod-codewalk-h{font-family:"IBM Plex Mono",monospace;font-size:10.5px;letter-spacing:.1em;
  text-transform:uppercase;color:var(--accent);font-weight:600;padding:9px 14px;
  border-bottom:1px solid var(--rule)}
.mod-codewalk-pre{margin:0;padding:12px 14px;font-family:"IBM Plex Mono",monospace;
  font-size:12.5px;line-height:1.7;overflow-x:auto}
.mod-codewalk-line{color:var(--ink-3);white-space:pre}
.mod-codewalk-line.hl{color:var(--ink);background:color-mix(in srgb,var(--accent) 10%,transparent);
  margin:0 -14px;padding:0 14px;border-left:2px solid var(--accent)}
.mod-codewalk-note{font-family:"Source Serif 4",Georgia,serif;font-size:13.5px;line-height:1.55;
  color:var(--ink-2);margin:2px 0 8px;padding-left:14px;border-left:2px solid var(--rule-2)}

/* ---- per-stage citations (see the stage.sources block in ui/module.js) ---- */
.mod-sources{margin:14px 0 0;font-size:11.5px}
.mod-sources summary{cursor:pointer;color:var(--ink-3);font-family:"IBM Plex Mono",monospace;
  letter-spacing:.04em;padding:4px 0}
.mod-sources summary:hover{color:var(--accent)}
.mod-sources ul{margin:6px 0 0;padding-left:18px;display:grid;gap:4px}
.mod-sources a{color:var(--ink-2);text-decoration:underline;text-decoration-color:var(--rule-2)}
.mod-sources a:hover{color:var(--accent);text-decoration-color:var(--accent)}
.mw-toggle{
  border:1px solid var(--rule); border-radius:4px; background:var(--surface-2);
  overflow:hidden;
}
.mw-toggle > summary{
  cursor:pointer; padding:9px 14px; list-style:none;
  font-family:"IBM Plex Mono",monospace; font-size:11.5px; letter-spacing:.05em;
  color:var(--accent); font-weight:600; display:flex; align-items:center; gap:7px;
  min-height:38px;
}
.mw-toggle > summary::-webkit-details-marker{ display:none; }
.mw-toggle > summary::before{
  content:"▸"; display:inline-block; transition:transform .18s cubic-bezier(.22,.9,.28,1);
  font-size:10px; color:var(--ink-3);
}
.mw-toggle[open] > summary::before{ transform:rotate(90deg); }
.mw-toggle[open] > summary{ border-bottom:1px solid var(--rule); }
.mw-body{ padding:14px 16px 16px; display:grid; gap:16px; }
.mw-title{ font-family:"IBM Plex Mono",monospace; font-size:10.5px; letter-spacing:.1em;
  text-transform:uppercase; color:var(--ink-3); }

.mw-step{ border-top:1px dashed var(--rule); padding-top:14px; }
.mw-step:first-child{ border-top:0; padding-top:0; }
.mw-parallel{ display:grid; gap:12px; }
.mw-parallel > .mw-h{ margin-bottom:2px; }
.mw-parallel > .mw-step{ border-top:1px solid var(--rule); padding-top:12px; margin-left:14px;
  padding-left:14px; border-left:2px solid var(--accent-dim, var(--rule)); }
.mw-h{ display:flex; align-items:baseline; gap:10px; flex-wrap:wrap; margin-bottom:10px; }
.mw-col{ font-family:"IBM Plex Mono",monospace; font-size:10px; letter-spacing:.09em;
  text-transform:uppercase; color:var(--accent); font-weight:600; }
.mw-h > span:last-child{ font-size:13.5px; font-weight:600; color:var(--ink); }

.mw-row{ display:flex; align-items:center; gap:12px; flex-wrap:wrap; }
.mw-block{ display:flex; flex-direction:column; align-items:center; gap:5px; }
.mw-cap{ font-family:"IBM Plex Mono",monospace; font-size:9.5px; letter-spacing:.08em;
  text-transform:uppercase; color:var(--ink-3); }
.mw-op{ font-size:16px; color:var(--ink-3); font-weight:600; }

.mtx{
  display:inline-grid; grid-template-columns:repeat(2,auto); gap:3px 16px;
  padding:8px 14px; position:relative; font-family:"IBM Plex Mono",monospace;
  font-size:12.5px; color:var(--ink); font-variant-numeric:tabular-nums;
}
.mtx.mtx-col{ grid-template-columns:1fr; text-align:left; }
.mtx span{ white-space:nowrap; }
.mtx span i{ color:var(--ink-3); font-style:normal; font-size:10px; }
.mtx::before, .mtx::after{
  content:""; position:absolute; top:1px; bottom:1px; width:6px;
  border:1.4px solid var(--rule-2);
}
.mtx::before{ left:0; border-right:0; }
.mtx::after{ right:0; border-left:0; }

.mw-expand{ margin-top:10px; font-size:11.5px; color:var(--ink-2); line-height:1.8;
  background:var(--surface); border:1px solid var(--rule); border-radius:3px; padding:9px 12px; }
.mw-expand div{ white-space:pre-wrap; word-break:break-word; }

.mw-rule{ font-size:13px; color:var(--ink-2); margin:0 0 10px; }
.mw-perm{ display:grid; gap:5px; }
.mw-perm-row{ display:flex; align-items:center; gap:9px; padding:6px 10px;
  background:var(--surface); border:1px solid var(--rule); border-radius:3px; font-size:12.5px; }
.mw-perm-row.moved{ border-color:var(--accent); background:var(--accent-soft); }
.mw-arrow{ color:var(--ink-3); }
.mw-perm-note{ margin-left:auto; font-size:11px; color:var(--ink-3); }
.mw-perm-row.moved .mw-perm-note{ color:var(--accent); font-weight:600; }

.mw-final{ border-top:1px solid var(--rule-2); padding-top:12px; }
.mw-preadout{ display:grid; gap:4px; margin-top:6px; }
.mw-p-row{ display:flex; gap:14px; font-size:12px; color:var(--ink-2); }
.mw-p-row span:first-child{ color:var(--ink); font-weight:600; min-width:44px; }

/* Steps are revealed one click at a time — see renderMathWork()'s comment
   for why: Khan Academy's hint pattern, one gate's arithmetic before the
   next appears, never the whole trace as a single wall of numbers. */
.mw-steps{ display:grid; gap:16px; }
.mw-next{ justify-self:start; }

/* ==================================================== INLINE LIVE DEMO */
.mod-live{ margin:14px 0; }
.inline-lab{
  border:1px solid var(--accent); border-radius:4px;
  background:
    radial-gradient(420px 140px at 8% -30%, color-mix(in srgb, var(--hero-1) 14%, transparent), transparent 70%),
    var(--surface);
  box-shadow:var(--glow), var(--elev-1); padding:14px 16px 16px;
}
.inline-lab-kicker{ font-family:"IBM Plex Mono",monospace; font-size:10px; letter-spacing:.12em;
  text-transform:uppercase; color:var(--accent); font-weight:600; margin-bottom:10px; }
.inline-lab-read{ font-size:15px; color:var(--ink); font-weight:600; margin-bottom:8px;
  font-variant-numeric:tabular-nums; }

/* the live tilt dial — same 0-at-top, clockwise-to-180-at-bottom convention
   as figDial's SVG rotArrow, so the static figure earlier on the same
   stage and this live one read as literally the same object. */
.inline-dial{ position:relative; width:132px; height:150px; margin:0 auto 14px; }
.inline-dial-circle{
  position:absolute; left:50%; top:9px; width:114px; height:114px;
  margin-left:-57px; border-radius:50%;
  background:var(--sphere); border:1.3px solid var(--rule-2);
}
.inline-dial-circle::after{
  content:''; position:absolute; left:50%; top:0; bottom:0; width:0;
  border-left:1px dashed var(--rule-2);
}
.inline-dial-pole{
  position:absolute; left:50%; transform:translateX(-50%);
  font-family:"IBM Plex Mono",monospace; font-size:10.5px; font-weight:600;
}
.inline-dial-pole.up{ top:0; color:var(--accent); }
.inline-dial-pole.down{ bottom:0; color:var(--signal); }
.inline-dial-arrow{
  position:absolute; left:50%; top:9px; width:2px; height:57px;
  margin-left:-1px; background:var(--accent); transform-origin:bottom center;
  transition:transform .1s linear;
}
.inline-dial-arrow::before{
  content:''; position:absolute; top:-6px; left:50%; margin-left:-4px;
  border:4px solid transparent; border-bottom-color:var(--accent);
}

.inline-lab-slider{ width:100%; margin:0 0 14px; accent-color:var(--accent); height:24px; }
.inline-lab-btn{ display:block; margin:0 auto 14px; }
.inline-lab-bars{ display:grid; gap:6px; margin-bottom:4px; }
.inline-lab-bar-row{ display:grid; grid-template-columns:32px minmax(0,1fr) 52px; gap:10px; align-items:center; }
.inline-lab-bar{ height:14px; background:var(--surface-3); border-radius:2px; overflow:hidden; }
.inline-lab-bar i{ display:block; height:100%; border-radius:2px; transition:width .12s linear; }
.inline-lab-bar-row .mono{ font-size:12px; color:var(--ink-2); font-variant-numeric:tabular-nums; }
.inline-lab .mw-toggle{ margin-top:12px; background:var(--surface-2); }

.inline-lab-bignum{ font-size:clamp(22px,5vw,34px); font-weight:700; text-align:center;
  color:var(--ink); margin:6px 0 10px; letter-spacing:-.01em; word-break:break-all; }
.inline-lab-status{ font-size:12.5px; line-height:1.5; text-align:center; padding:8px 10px;
  border-radius:3px; background:var(--surface-2); color:var(--ink-2); }
.inline-lab-status.good{ background:var(--good-soft); color:var(--good); }
.inline-lab-status.warn{ background:var(--signal-soft); color:var(--signal); }

/* ------------------------------------------------ complex-number playground */
.pg-readout{ text-align:center; }
.pg-ops{ display:flex; gap:8px; justify-content:center; margin-bottom:12px; }
.pg-op{ font-family:"IBM Plex Mono",monospace; }
.pg-op[aria-pressed="true"]{ background:var(--accent); color:var(--on-accent); border-color:var(--accent); }
.pg-steppers{ display:flex; gap:18px; justify-content:center; flex-wrap:wrap; margin-bottom:12px; }
.pg-stepper-grp{ display:flex; align-items:center; gap:8px 12px; flex-wrap:wrap; justify-content:center; }
.pg-stepper-grp .btn.active{ background:var(--accent); border-color:var(--accent); color:var(--surface); }
.pg-grp-label{ font-family:"IBM Plex Mono",monospace; font-size:11px; color:var(--ink-3); }
.pg-stepper{ display:flex; align-items:center; gap:4px; }
.pg-stepper-label{ font-family:"IBM Plex Mono",monospace; font-size:12px; font-weight:700; color:var(--pg-c,var(--ink)); width:12px; text-align:center; }
.pg-stepper-btn{ padding:2px 9px; min-height:26px; line-height:1; }
.pg-stepper-val{ min-width:22px; text-align:center; font-size:13.5px; color:var(--ink); font-variant-numeric:tabular-nums; }
.pg-plane{ display:flex; justify-content:center; margin-bottom:8px; }
.pg-plane svg{ max-width:280px; width:100%; height:auto; }
.pg-steps{ background:var(--surface-2); border:1px solid var(--rule-2); border-radius:4px;
  padding:10px 12px; margin-bottom:10px; }
.pg-step-line{ font-size:13px; color:var(--ink-2); line-height:1.7; white-space:pre-wrap; }
.pg-step-line:last-child{ color:var(--good); font-weight:700; }
.pg-challenge{ display:flex; align-items:center; gap:10px; justify-content:center; flex-wrap:wrap; }
.pg-daily-btn{ border-color:var(--warn); color:var(--warn); }
.pg-target-status{ font-family:"IBM Plex Mono",monospace; font-size:12.5px; color:var(--ink-2); }
.pg-target-status.hit{ color:var(--good); font-weight:700; }

/* f04's own discovery-and-collection mechanic (see inlinelab.js's
   renderInlineInnerOuterPlaygroundDemo) — a live readout instead of a
   hidden target, and a five-dot collection tracker instead of a date. */
.pg-ortho-readout{ font-family:"IBM Plex Mono",monospace; font-size:12.5px; color:var(--ink-2);
  text-align:center; margin-top:10px; }
.pg-ortho-readout.hit{ color:var(--good); font-weight:700; }
.pg-ortho-readout.golden{ color:var(--warn); }
.pg-ortho-progress{ display:flex; align-items:center; justify-content:center; gap:7px; margin-top:8px; }
.pg-ortho-progress-label{ font-family:"IBM Plex Mono",monospace; font-size:10.5px; color:var(--ink-3); margin-right:4px; }
.pg-ortho-dot{ width:9px; height:9px; border-radius:50%; background:var(--surface-2);
  border:1.5px solid var(--rule-2); transition:background .2s ease, border-color .2s ease; }
.pg-ortho-dot.filled{ background:var(--good); border-color:var(--good); }

/* ==================================================== PHASE C — COMBO FEVER METER */
.combo-bar{
  display:flex;align-items:center;gap:10px;
  height:0;overflow:hidden;opacity:0;
  transition:height .28s cubic-bezier(.22,.9,.28,1),opacity .22s ease;
  margin-bottom:0;
}
.combo-bar.combo-active{
  height:28px;opacity:1;margin-bottom:12px;
}
.combo-track{
  flex:1;height:6px;background:var(--surface-3);border-radius:3px;overflow:hidden;
}
.combo-fill{
  height:100%;width:0;border-radius:3px;
  background:linear-gradient(90deg,var(--hero-1),var(--hero-2));
  transition:width .25s cubic-bezier(.22,.9,.28,1),background .3s ease;
}
.combo-count{
  font-family:"IBM Plex Mono",monospace;font-size:11px;font-weight:700;
  color:var(--warn);white-space:nowrap;min-width:48px;text-align:right;
}
/* crack: a brief red flash + shake when wrong */
.combo-bar.combo-crack .combo-track{ animation:comboShake .4s ease; }
.combo-bar.combo-crack .combo-fill{ background:var(--signal)!important; }
@keyframes comboShake{
  0%,100%{transform:translateX(0)}
  20%{transform:translateX(-4px)}
  40%{transform:translateX(4px)}
  60%{transform:translateX(-3px)}
  80%{transform:translateX(2px)}
}
@media (prefers-reduced-motion:reduce){.combo-bar.combo-crack .combo-track{animation:none}}

/* ==================================================== THE MASCOT */
/* See ui/mascot.js. A real state, tied to a real event (a right/wrong answer,
   a combo milestone) — never an animation played for its own sake. */
.mod-mascot-row{display:flex;align-items:center;gap:10px;margin-bottom:2px}
.mascot-wrap{display:inline-flex;flex:none;width:44px;height:44px}
.qm-mascot,.lu-mascot{width:72px;height:72px;margin:0 auto}
.qm-mascot .mascot,.lu-mascot .mascot{width:100%;height:100%}
.mascot{width:100%;height:100%;display:block}
.mascot-happy,.mascot-celebrating{animation:mascotPop .32s cubic-bezier(.22,.9,.28,1)}
@keyframes mascotPop{
  0%{transform:scale(.85)}
  55%{transform:scale(1.12)}
  100%{transform:scale(1)}
}
@media (prefers-reduced-motion:reduce){.mascot-happy,.mascot-celebrating{animation:none}}

/* QUANTUM STREAK sweep banner */
.combo-streak-banner{
  position:fixed;top:50%;left:50%;transform:translate(-50%,-50%) scale(.8);
  z-index:600;pointer-events:none;
  background:linear-gradient(120deg,var(--hero-1),var(--hero-2));
  color:#fff;font-family:"IBM Plex Mono",monospace;
  font-size:clamp(18px,4vw,28px);font-weight:900;letter-spacing:.06em;
  padding:16px 40px;border-radius:12px;
  box-shadow:0 8px 40px rgba(0,0,0,.45);
  animation:streakSweep 2.2s cubic-bezier(.22,.9,.28,1) both;
}
@keyframes streakSweep{
  0%{opacity:0;transform:translate(-50%,-50%) scale(.7)}
  12%{opacity:1;transform:translate(-50%,-50%) scale(1.05)}
  20%,75%{opacity:1;transform:translate(-50%,-50%) scale(1)}
  100%{opacity:0;transform:translate(-50%,-58%) scale(.96)}
}
@media (prefers-reduced-motion:reduce){.combo-streak-banner{animation:none;opacity:0}}

/* ==================================================== PHASE A — QUANTUM MOMENT OVERLAY */
.qm-overlay{
  position:fixed;inset:0;z-index:700;
  display:flex;align-items:center;justify-content:center;
  background:color-mix(in srgb,var(--ground) 88%,transparent);
  backdrop-filter:blur(3px);
  opacity:0;transition:opacity .3s ease;
  padding:20px;
}
.qm-overlay.qm-in{opacity:1}
.qm-overlay.qm-out{opacity:0}
.qm-canvas{position:absolute;inset:0;width:100%;height:100%;pointer-events:none}
.qm-card{
  position:relative;max-width:480px;width:100%;text-align:center;
  background:var(--surface);border:1px solid var(--rule-2);border-radius:16px;
  padding:36px 28px 32px;
  box-shadow:var(--elev-2),0 0 60px rgba(142,153,255,.18);
  transform:scale(.88) translateY(16px);
  transition:transform .36s cubic-bezier(.22,.9,.28,1);
}
.qm-overlay.qm-in .qm-card{transform:scale(1) translateY(0)}
@media (prefers-reduced-motion:reduce){.qm-card{transition:none;transform:none}}

.qm-badge{
  font-family:"IBM Plex Mono",monospace;font-size:9.5px;letter-spacing:.18em;
  text-transform:uppercase;color:var(--accent);font-weight:700;
  background:var(--accent-soft);border-radius:20px;padding:4px 14px;
  display:inline-block;margin-bottom:14px;
}
.qm-emoji{font-size:52px;line-height:1;margin-bottom:10px;display:block;animation:qmSpin 2s ease-in-out infinite alternate}
@keyframes qmSpin{from{transform:rotate(-8deg) scale(1)}to{transform:rotate(8deg) scale(1.08)}}
@media (prefers-reduced-motion:reduce){.qm-emoji{animation:none}}

.qm-headline{
  margin:0 0 12px;
  font-size:clamp(20px,4vw,26px);font-weight:800;letter-spacing:-.02em;
  line-height:1.15;text-wrap:balance;
  background:linear-gradient(120deg,var(--hero-1),var(--hero-2) 55%,var(--hero-3));
  -webkit-background-clip:text;background-clip:text;color:transparent;
}
.qm-impact{
  font-family:"Source Serif 4",Georgia,serif;
  font-size:15px;line-height:1.65;color:var(--ink-2);
  margin:0 0 18px;max-width:46ch;margin-left:auto;margin-right:auto;
}
.qm-xp{
  display:flex;align-items:center;justify-content:center;gap:10px;
  background:var(--surface-2);border-radius:8px;padding:8px 16px;
  margin:0 0 18px;flex-wrap:wrap;
}
.qm-xp-gained{
  font-family:"IBM Plex Mono",monospace;font-size:22px;font-weight:800;
  color:var(--accent);letter-spacing:-.01em;
}
.qm-xp-total{font-size:12.5px;color:var(--ink-3)}

.qm-share{display:flex;gap:8px;justify-content:center;flex-wrap:wrap;margin-bottom:18px}
.qm-share-btn{
  font-size:12.5px!important;padding:7px 14px!important;min-height:0!important;
  border-radius:6px;font-weight:700;text-decoration:none;display:inline-flex;
  align-items:center;gap:5px;
}
.qm-share-x{background:#000;color:#fff;border-color:#000}
.qm-share-x:hover{background:#111;color:#fff}
.qm-share-wa{background:#25D366;color:#fff;border-color:#25D366}
.qm-share-wa:hover{background:#1ebe5e;color:#fff}
.qm-share-li{background:#0077B5;color:#fff;border-color:#0077B5}
.qm-share-li:hover{background:#006396;color:#fff}
.qm-continue{width:100%;min-height:46px;font-size:15px;font-weight:700}
.qm-levelup-badge{
  font-family:"IBM Plex Mono",monospace;font-size:10.5px;font-weight:800;letter-spacing:.08em;
  background:linear-gradient(90deg,var(--warn),#ff8e71);color:#111;
  padding:2px 10px;border-radius:12px;margin-left:8px;display:inline-block;
  animation:luBadgePulse 1.4s ease-in-out infinite alternate;
}
@keyframes luBadgePulse{from{transform:scale(1)}to{transform:scale(1.08)}}
.qm-view-ceremony{
  margin-top:10px;background:transparent;border:1px dashed var(--hero-2);color:var(--hero-2);
  font-size:12px!important;padding:5px 14px!important;border-radius:20px;cursor:pointer;
  transition:all .2s ease;display:inline-block;
}
.qm-view-ceremony:hover{background:color-mix(in srgb,var(--hero-2) 15%,transparent);color:#fff}

/* ==================================================== PHASE B — LEVEL-UP CEREMONY */
.lu-overlay{
  position:fixed;inset:0;z-index:800;
  display:flex;align-items:center;justify-content:center;
  background:rgba(8,6,18,.88);
  opacity:0;transition:opacity .28s ease;padding:20px;
  overflow:hidden;
}
.lu-overlay.lu-in{opacity:1}
.lu-overlay.lu-out{opacity:0}

.lu-spotlight{
  position:absolute;top:-30%;left:50%;transform:translateX(-50%);
  width:750px;height:750px;border-radius:50%;
  background:radial-gradient(circle,rgba(177,140,255,.45) 0%,rgba(142,153,255,.2) 40%,transparent 72%);
  pointer-events:none;
  animation:luPulse 2.4s ease-in-out infinite;
}
@keyframes luPulse{0%,100%{transform:translateX(-50%) scale(1)}50%{transform:translateX(-50%) scale(1.08)}}
@media (prefers-reduced-motion:reduce){.lu-spotlight{animation:none}}

.lu-card{
  position:relative;text-align:center;max-width:400px;width:100%;
  transform:scale(.8) translateY(20px);
  transition:transform .38s cubic-bezier(.22,.9,.28,1);
}
.lu-overlay.lu-in .lu-card{transform:scale(1) translateY(0)}
@media (prefers-reduced-motion:reduce){.lu-card{transition:none;transform:none}}

.lu-pre{
  font-family:"IBM Plex Mono",monospace;font-size:11px;letter-spacing:.28em;
  text-transform:uppercase;color:var(--hero-2);font-weight:700;margin-bottom:12px;
  animation:luFadeUp .5s ease both .1s;
}
.lu-rank{
  font-size:clamp(36px,8vw,58px);font-weight:900;letter-spacing:-.03em;
  background:linear-gradient(120deg,#fff 30%,var(--hero-2));
  -webkit-background-clip:text;background-clip:text;color:transparent;
  margin-bottom:14px;line-height:1;
  animation:luReveal .65s cubic-bezier(.22,.9,.28,1) both .2s;
}
@keyframes luReveal{
  from{opacity:0;transform:scale(.6) translateY(10px)}
  to{opacity:1;transform:scale(1) translateY(0)}
}
.lu-msg{
  font-size:16px;color:rgba(255,255,255,.8);line-height:1.6;
  margin:0 0 24px;max-width:38ch;margin-left:auto;margin-right:auto;
  animation:luFadeUp .5s ease both .5s;
}
@keyframes luFadeUp{from{opacity:0;transform:translateY(8px)}to{opacity:1;transform:translateY(0)}}
@media (prefers-reduced-motion:reduce){.lu-pre,.lu-rank,.lu-msg{animation:none}}

.lu-btn{min-height:46px;font-size:15px;font-weight:700;animation:luFadeUp .4s ease both .7s}
@media (prefers-reduced-motion:reduce){.lu-btn{animation:none}}

/* confetti dots that fall from top */
.lu-confetti{
  position:absolute;top:-10px;border-radius:50%;
  animation:confettiFall 1.4s cubic-bezier(.4,0,.2,1) both;
  pointer-events:none;
}
@keyframes confettiFall{
  0%{transform:translateY(0) rotate(0deg);opacity:1}
  100%{transform:translateY(100vh) rotate(720deg);opacity:0}
}
@media (prefers-reduced-motion:reduce){.lu-confetti{display:none}}

/* ==================================================== PHASE E — STORY HOOKS */
.lesson-hook-tag{
  display:inline-block;
  font-family:"IBM Plex Mono",monospace;font-size:10.5px;letter-spacing:.1em;
  text-transform:uppercase;font-weight:700;
  color:var(--hero-2);background:color-mix(in srgb,var(--hero-2) 12%,transparent);
  border-radius:20px;padding:3px 12px;margin-bottom:10px;
}
.lesson-story{
  font-family:"Source Serif 4",Georgia,serif;
  font-size:16.5px;line-height:1.7;
  color:var(--ink);font-style:italic;
  margin:0 0 16px;max-width:58ch;
  border-left:3px solid var(--hero-2);
  padding-left:14px;
}

/* Stage 0's "the promise" card — mod.goal, shown once at the door instead of
   only on the done screen at the far end of the module. */
.mod-promise{
  border:1px solid var(--accent);border-radius:6px;
  background:color-mix(in srgb,var(--accent) 8%,transparent);
  padding:12px 16px;margin:4px 0 18px;
}
.mod-promise-kicker{
  display:block;font-family:"IBM Plex Mono",monospace;font-size:10px;
  letter-spacing:.12em;text-transform:uppercase;font-weight:700;
  color:var(--accent);margin-bottom:5px;
}
.mod-promise-text{
  margin:0;font-size:15px;line-height:1.55;color:var(--ink);font-weight:500;
}

/* ==================================================== PHASE D — WORLD HEADERS in detail card */
.learn-world-badge{
  display:inline-flex;align-items:center;gap:6px;
  font-family:"IBM Plex Mono",monospace;font-size:10px;letter-spacing:.1em;
  text-transform:uppercase;font-weight:700;
  background:var(--surface-2);border:1px solid var(--rule);
  border-radius:20px;padding:3px 12px;margin-bottom:10px;color:var(--ink-3);
}

/* ==================================================== LANDING PAGE
   The first screen a judge sees — before the app itself. Reuses .hero,
   .stats/.stat, .sec-h from the existing system; only the pieces those
   don't cover (a bigger title treatment, a feature grid, a chapter list)
   get their own rules here. */
.landing-hero{
  text-align:center;padding:44px 32px;margin-bottom:8px;
  background:
    radial-gradient(900px 320px at 50% -20%,color-mix(in srgb, var(--hero-1) 16%, transparent),transparent 70%),
    var(--surface);
}
.landing-hero .kicker{display:block;margin-bottom:14px}
.landing-h1{
  margin:0 0 12px;font-size:clamp(34px,6vw,56px);font-weight:800;letter-spacing:-.03em;
  background:linear-gradient(90deg,var(--hero-1),var(--hero-2));
  -webkit-background-clip:text;background-clip:text;color:transparent;
}
.landing-sub{
  margin:0 auto 26px;max-width:62ch;font-size:17px;line-height:1.6;color:var(--ink-2);
}
.landing-cta-row{display:flex;gap:10px;justify-content:center;flex-wrap:wrap}
.landing-cta{min-height:46px;padding:11px 24px;font-size:14.5px}

.landing-feature-grid{
  display:grid;grid-template-columns:repeat(auto-fit,minmax(240px,1fr));gap:14px;margin-bottom:22px;
}
.landing-feature{
  background:var(--surface);border:1px solid var(--rule);border-radius:4px;
  padding:18px 20px;box-shadow:var(--shadow);
}
.landing-feature-icon{font-size:26px;margin-bottom:8px}
.landing-feature-title{margin:0 0 6px;font-size:15.5px;font-weight:700;letter-spacing:-.01em}
.landing-feature-body{margin:0;font-size:13.5px;line-height:1.55;color:var(--ink-2)}

.landing-chapters{
  display:grid;grid-template-columns:repeat(auto-fill,minmax(260px,1fr));gap:8px;margin-bottom:28px;
}
.landing-chapter-row{
  display:flex;align-items:center;gap:9px;padding:10px 13px;
  border:1px solid var(--rule-2);border-radius:6px;
  background:linear-gradient(180deg, color-mix(in srgb, var(--chapter-hue) 6%, var(--surface)), var(--surface));
}
.landing-chapter-dot{width:8px;height:8px;border-radius:50%;background:var(--chapter-hue);flex:none}
.landing-chapter-title{flex:1;font-size:13.5px;font-weight:600;color:var(--ink)}
.landing-chapter-count{
  font-family:"IBM Plex Mono",monospace;font-size:10px;color:var(--ink-3);white-space:nowrap;
}

.landing-footer-cta{text-align:center;padding:24px 0 8px}

@media (max-width:640px){
  .landing-hero{padding:30px 18px}
  .landing-cta-row{flex-direction:column;align-items:stretch}
}

/* ==================================================== REVIEW QUEUE
   "Due for review" in Progress — concepts whose score has drifted down
   from time passing, not a wrong answer. Same visual family as .rec
   (the existing recommendation box) but a list of rows, not one message. */
.review-queue{display:flex;flex-direction:column;gap:8px;margin:12px 0 20px;max-width:780px}
.review-row{
  display:flex;align-items:center;justify-content:space-between;gap:14px;
  border:1px solid var(--rule);border-left:3px solid var(--warn);background:var(--surface);
  border-radius:0 4px 4px 0;padding:11px 15px;
}
.review-row-main{display:flex;flex-direction:column;gap:3px;min-width:0}
.review-row-label{font-size:14px;font-weight:600;color:var(--ink)}
.review-row-meta{font-size:10.5px;color:var(--ink-3)}

/* -------------------------------------------------- REVIEW SESSION overlay
   Same fixed-full-viewport-dialog pattern as .celebrate-overlay — a focused
   one-question-at-a-time flow through everything due, reusing each
   lesson's own predict-then-run question (ui/learn.js's buildPredictor). */
.review-overlay{
  position:fixed;inset:0;z-index:500;display:flex;align-items:center;justify-content:center;
  background:color-mix(in srgb, var(--ground) 82%, transparent);
  opacity:0;transition:opacity .2s ease;padding:20px;
}
.review-overlay.review-in{opacity:1}
.review-overlay.review-out{opacity:0}
.review-session-card{
  position:relative;max-width:560px;width:100%;
  background:var(--surface);border:1px solid var(--rule-2);border-radius:10px;
  padding:22px 26px 26px;box-shadow:var(--elev-2);
  max-height:calc(100vh - 40px);overflow-y:auto;
}
.review-session-head{display:flex;align-items:center;gap:12px;margin-bottom:10px}
.review-session-count{font-size:11px;color:var(--ink-3);font-weight:700}
.review-session-days{font-size:11.5px;color:var(--warn);flex:1}
.review-session-progress{height:4px;background:var(--surface-3);border-radius:3px;overflow:hidden;margin-bottom:16px}
.review-session-progress i{display:block;height:100%;background:var(--accent);border-radius:3px;transition:width .3s ease}
.review-session-next{margin-top:12px}
.review-session-summary-h{margin:8px 0 8px;font-size:20px;font-weight:700}
.review-session-summary-p{margin:0 0 16px;font-size:14.5px;color:var(--ink-2);line-height:1.55}
@media (prefers-reduced-motion:reduce){.review-overlay{transition:none}}

/* ==================================================== GLOBAL SEARCH
   Command-palette overlay (header button or "/" shortcut) over every
   module, concept, and glossary term — see ui/search.js. Same fixed
   full-viewport-dialog pattern as .review-overlay/.celebrate-overlay. */
.search-trigger{font-size:15px;line-height:1}
.search-overlay{
  position:fixed;inset:0;z-index:500;display:flex;align-items:flex-start;justify-content:center;
  background:color-mix(in srgb, var(--ground) 82%, transparent);
  opacity:0;transition:opacity .15s ease;padding:80px 20px 20px;
}
.search-overlay.search-in{opacity:1}
.search-overlay.search-out{opacity:0}
.search-card{
  position:relative;max-width:600px;width:100%;
  background:var(--surface);border:1px solid var(--rule-2);border-radius:10px;
  box-shadow:var(--elev-2);overflow:hidden;
  max-height:calc(100vh - 120px);display:flex;flex-direction:column;
}
.search-input{
  width:100%;border:none;border-bottom:1px solid var(--rule);background:transparent;color:var(--ink);
  font-size:16px;padding:16px 18px;outline:none;
}
.search-input::placeholder{color:var(--ink-3)}
.search-results{overflow-y:auto;padding:6px}
.search-empty{padding:20px 16px;font-size:13.5px;color:var(--ink-3);text-align:center}
.search-row{
  display:flex;align-items:baseline;gap:10px;flex-wrap:wrap;
  padding:10px 12px;border-radius:6px;cursor:pointer;
}
.search-row-selected{background:var(--surface-3)}
.search-row-kind{
  font-family:"IBM Plex Mono",monospace;font-size:9.5px;font-weight:700;letter-spacing:.04em;
  text-transform:uppercase;padding:2px 6px;border-radius:3px;flex:none;
}
.search-row-kind-lesson{color:var(--accent);background:color-mix(in srgb, var(--accent) 16%, transparent)}
.search-row-kind-concept{color:var(--good);background:color-mix(in srgb, var(--good) 16%, transparent)}
.search-row-kind-glossary{color:var(--warn);background:color-mix(in srgb, var(--warn) 16%, transparent)}
.search-row-title{font-size:14px;font-weight:600;color:var(--ink)}
.search-row-def{
  flex-basis:100%;font-size:12px;color:var(--ink-3);line-height:1.4;
  overflow:hidden;text-overflow:ellipsis;white-space:nowrap;
}
@media (prefers-reduced-motion:reduce){.search-overlay{transition:none}}

