/* RootCause. One idea, repeated: the root line. */

:root {
  --primary: #0B5D3B;
  --primary-hover: #094D31;
  --primary-soft: #E3F1EA;
  --on-primary: #FFFFFF;
  --accent: #F5B700;
  --accent-glow: rgba(245, 183, 0, .32);
  --bg: #FAF8F3;
  --surface: #FFFFFF;
  --surface-2: #F3F0E8;
  --text: #1A1A1A;
  --muted: #5B5B55;
  --border: #E7E3DA;

  --weak: #B42318;   --weak-soft: #FEF0EE;
  --okay: #B54708;   --okay-soft: #FFF5E0;
  --strong: #067647; --strong-soft: #E6F6EC;
  --untried: #6B6B64; --untried-soft: #F1EFEA;

  --line-weak: #E9A39C;
  --line-okay: #EBC48A;
  --line-strong: #6FC39A;
  --line-untried: #D7D2C6;

  --ink: #1A1A1A;
  --shadow-color: #1A1A1A;
  --on-accent: #1A1A1A;
  --accent-soft: #FFF3C4;
  --bw: 2.5px;
  --shadow-1: 3px 3px 0 var(--shadow-color);
  --shadow-2: 6px 6px 0 var(--shadow-color);

  /* 3D sphere fills: highlight colour, then base colour */
  --sph-weak: #FFC9C2, #E5484D;
  --sph-okay: #FFE3A6, #F59E0B;
  --sph-strong: #B9F2D2, #12A15E;
  --sph-untried: #FFFFFF, #BDB7AA;
  --sph-root: #FFF1B8, #F5B700;

  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px; --s7: 48px;
  --r-input: 12px; --r-card: 18px; --r-pill: 999px;

  --font: ui-rounded, "SF Pro Rounded", system-ui, "Segoe UI", Roboto, sans-serif;
  --fs-body: 16px; --fs-lead: 18px; --fs-sub: 22px; --fs-title: 30px; --fs-hero: 40px; --fs-small: 14px;

  --nav-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --ease: cubic-bezier(.2, .7, .2, 1);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --primary: #4CC38A; --primary-hover: #6BD3A1; --primary-soft: #183326; --on-primary: #08130D;
    --accent-glow: rgba(245, 183, 0, .26);
    --bg: #0F1512; --surface: #17201B; --surface-2: #1E2924;
    --text: #F2F0EA; --muted: #B4B8B0; --border: #2B3832;
    --weak: #FF8A80;   --weak-soft: #3A1D1A;
    --okay: #FFB547;   --okay-soft: #36280F;
    --strong: #5BD69A; --strong-soft: #15301F;
    --untried: #A9AEA6; --untried-soft: #222C27;
    --line-weak: #7A3530; --line-okay: #6E5122; --line-strong: #2F7A55; --line-untried: #34413A;
    --ink: #E6EFEA; --shadow-color: #3E8E66; --accent-soft: #3A3010;
    --shadow-1: 3px 3px 0 var(--shadow-color);
    --shadow-2: 6px 6px 0 var(--shadow-color);
    --sph-untried: #F2F0EA, #7C8580;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --primary: #4CC38A; --primary-hover: #6BD3A1; --primary-soft: #183326; --on-primary: #08130D;
  --accent-glow: rgba(245, 183, 0, .26);
  --bg: #0F1512; --surface: #17201B; --surface-2: #1E2924;
  --text: #F2F0EA; --muted: #B4B8B0; --border: #2B3832;
  --weak: #FF8A80;   --weak-soft: #3A1D1A;
  --okay: #FFB547;   --okay-soft: #36280F;
  --strong: #5BD69A; --strong-soft: #15301F;
  --untried: #A9AEA6; --untried-soft: #222C27;
  --line-weak: #7A3530; --line-okay: #6E5122; --line-strong: #2F7A55; --line-untried: #34413A;
  --ink: #E6EFEA; --shadow-color: #3E8E66; --accent-soft: #3A3010;
    --shadow-1: 3px 3px 0 var(--shadow-color);
    --shadow-2: 6px 6px 0 var(--shadow-color);
    --sph-untried: #F2F0EA, #7C8580;
    color-scheme: dark;
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 400 var(--fs-body)/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
  padding-bottom: calc(var(--nav-h) + var(--safe-b) + var(--s5));
  overflow-x: hidden;
}
h1, h2, h3 { line-height: 1.2; margin: 0; }
p { margin: 0; }
button, input { font: inherit; color: inherit; }
svg { width: 24px; height: 24px; flex: none; }
a { color: var(--primary); }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); }
.title { font-size: var(--fs-title); font-weight: 850; letter-spacing: -.02em; }
.subtitle { font-size: var(--fs-sub); font-weight: 700; }
.lead { font-size: var(--fs-lead); }
.num { font-variant-numeric: tabular-nums; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 6px; }
main:focus { outline: none; }

.skip {
  position: absolute; left: var(--s4); top: -64px; z-index: 50;
  background: var(--primary); color: var(--on-primary); padding: var(--s3) var(--s4);
  border-radius: var(--r-pill); font-weight: 650; text-decoration: none;
}
.skip:focus { top: var(--s3); }

/* ---------- splash ---------- */
.splash {
  position: fixed; inset: 0; z-index: 100; display: grid; place-items: center;
  background: var(--bg); transition: opacity .3s var(--ease), visibility .3s;
}
.splash.done { opacity: 0; visibility: hidden; }
.splash-mark { display: flex; align-items: center; gap: var(--s4); }
.splash-mark svg { width: 40px; height: 120px; }
.splash-name { font-size: var(--fs-title); font-weight: 800; color: var(--primary); letter-spacing: -.02em; }
.splash-line { stroke: var(--primary); stroke-width: 3; stroke-linecap: round; stroke-dasharray: 100; stroke-dashoffset: 100; animation: draw .6s var(--ease) forwards; }
.splash-dot { fill: var(--primary); opacity: 0; animation: pop .25s var(--ease) forwards; }
.splash-dot.d1 { animation-delay: .05s; } .splash-dot.d2 { animation-delay: .3s; }
.splash-dot.d3 { fill: var(--accent); animation-delay: .55s; }
.splash-glow { fill: var(--accent-glow); opacity: 0; animation: pop .3s var(--ease) .6s forwards; }

@keyframes draw { to { stroke-dashoffset: 0; } }
@keyframes pop { from { opacity: 0; transform: scale(.6); } to { opacity: 1; transform: none; } }
.splash-dot, .splash-glow { transform-box: fill-box; transform-origin: center; }

/* ---------- app bar ---------- */
.appbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: var(--s3);
  padding: var(--s2) var(--s4); padding-top: max(var(--s2), env(safe-area-inset-top));
  background: var(--bg);
  border-bottom: var(--bw) solid transparent;
}
.appbar.scrolled { border-bottom: var(--bw) solid var(--ink); }
.brand { display: inline-flex; align-items: center; gap: var(--s2); min-height: 48px; text-decoration: none; color: var(--text); font-weight: 800; font-size: var(--fs-lead); letter-spacing: -.01em; }
.brand-mark { width: 28px; height: 28px; color: var(--primary); }
.appbar-actions { display: flex; align-items: center; gap: var(--s2); min-width: 0; }
.student-switch {
  display: inline-flex; align-items: center; gap: var(--s2); min-height: 48px; max-width: 46vw;
  padding: 0 var(--s3) 0 var(--s1); border: var(--bw) solid var(--ink); border-radius: var(--r-pill);
  background: var(--surface); cursor: pointer; font-weight: 700; font-size: var(--fs-small); box-shadow: var(--shadow-1);
}
.student-switch-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.avatar {
  width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; flex: none;
  background: var(--accent); color: var(--on-accent); font-weight: 850; font-size: var(--fs-small);
  border: 2px solid var(--ink);
}
.icon-btn {
  width: 48px; height: 48px; display: grid; place-items: center; border-radius: 50%;
  border: var(--bw) solid var(--ink); background: var(--surface); cursor: pointer; color: var(--text);
  box-shadow: var(--shadow-1); transition: transform .1s var(--ease), box-shadow .1s var(--ease);
}
.icon-btn:active, .student-switch:active { transform: translate(3px, 3px); box-shadow: none; }

/* ---------- offline ---------- */
.offline {
  display: flex; align-items: center; gap: var(--s2); justify-content: center;
  margin: 0 auto; padding: var(--s2) var(--s4); background: var(--okay-soft); color: var(--okay);
  font-weight: 600; font-size: var(--fs-small); text-align: center;
}
.offline svg { width: 20px; height: 20px; }

/* ---------- layout ---------- */
main { max-width: 640px; margin: 0 auto; padding: var(--s4) var(--s4) 0; }
.view { animation: fadeIn .2s var(--ease); }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.view-head { margin: var(--s3) 0 var(--s5); display: grid; gap: var(--s2); }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s2);
  min-height: 48px; padding: 0 var(--s5); border-radius: var(--r-pill); border: var(--bw) solid var(--ink);
  font-weight: 750; font-size: var(--fs-body); line-height: 1.25; text-align: center; text-decoration: none; cursor: pointer;
  padding-block: var(--s2);
  box-shadow: var(--shadow-1);
  transition: transform .1s var(--ease), box-shadow .1s var(--ease), background-color .15s, color .15s;
  -webkit-tap-highlight-color: transparent;
}
.btn:hover { transform: translate(-1px, -1px); box-shadow: 4px 4px 0 var(--shadow-color); }
.btn:active { transform: translate(3px, 3px) scale(.98); box-shadow: 0 0 0 var(--shadow-color); }
.btn svg { width: 20px; height: 20px; }
.btn-primary { background: var(--primary); color: var(--on-primary); }
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary { background: var(--accent); color: var(--on-accent); }
.btn-ghost { background: var(--surface); color: var(--text); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .5; cursor: not-allowed; transform: none; box-shadow: none; }
.btn-back { padding: 0 var(--s4) 0 var(--s3); justify-self: start; }
.btn-row { display: flex; flex-wrap: wrap; gap: var(--s2); }

/* ---------- mic ---------- */
.mic {
  position: relative; width: 56px; height: 56px; flex: none; border-radius: 50%;
  display: grid; place-items: center; cursor: pointer;
  background: var(--accent); color: var(--on-accent); border: var(--bw) solid var(--ink); box-shadow: var(--shadow-1);
  transition: transform .1s var(--ease), box-shadow .1s var(--ease), background-color .15s, color .15s;
}
.mic:active { transform: translate(3px, 3px); box-shadow: none; }
.mic svg { width: 26px; height: 26px; position: relative; }
.mic-ring { position: absolute; inset: 0; border-radius: 50%; }
.mic.listening { background: var(--primary); color: var(--on-primary); }
.mic.listening .mic-ring { animation: ring 1.2s ease-out infinite; }
.mic.error { background: var(--weak-soft); color: var(--weak); border-color: var(--weak); }
@keyframes ring { from { box-shadow: 0 0 0 0 var(--accent-glow); } to { box-shadow: 0 0 0 16px transparent; } }
.voice-status { min-height: 0; font-size: var(--fs-small); color: var(--muted); }
.voice-status:not(:empty) { margin-top: var(--s2); }
.voice-status.err { color: var(--weak); }
.voice-heard { color: var(--text); font-weight: 600; }

/* ---------- ask form ---------- */
.ask { display: grid; gap: var(--s3); margin: var(--s3) 0 var(--s5); }
.ask .title label { cursor: text; }
.ask-row { display: flex; gap: var(--s3); align-items: center; margin-top: var(--s2); }
.field { flex: 1; min-width: 0; }
.field input {
  width: 100%; min-height: 56px; padding: 0 var(--s4); border-radius: var(--r-input);
  border: var(--bw) solid var(--ink); background: var(--surface); font-size: var(--fs-lead); font-weight: 600;
  box-shadow: var(--shadow-1); transition: box-shadow .15s, transform .15s;
}
.field input::placeholder { color: var(--muted); opacity: .8; }
.field input:focus { outline: none; box-shadow: 5px 5px 0 var(--accent); transform: translate(-1px, -1px); }
.quick { display: grid; gap: var(--s2); margin-top: var(--s2); }
.quick-label { font-size: var(--fs-small); }

/* ---------- chips ---------- */
.chips { display: flex; flex-wrap: wrap; gap: var(--s2); }
.chip {
  display: inline-flex; align-items: center; gap: var(--s2); min-height: 48px; max-width: 100%;
  padding: 0 var(--s4); border-radius: var(--r-pill); border: 2px solid var(--ink);
  background: var(--surface); cursor: pointer; font-weight: 700; font-size: var(--fs-small);
  box-shadow: 2px 2px 0 var(--shadow-color);
  transition: transform .1s var(--ease), box-shadow .1s var(--ease), background-color .15s;
}
.chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip:active { transform: translate(2px, 2px); box-shadow: none; }
.chip:hover { background: var(--accent-soft); }
.chip[aria-pressed="true"] { background: var(--primary); color: var(--on-primary); }
.chip[aria-pressed="true"] svg { display: inline; }
.chip svg { width: 18px; height: 18px; display: none; }
.suggest:not(:empty) { display: grid; gap: var(--s2); padding: var(--s4); background: var(--accent-soft); border: var(--bw) solid var(--ink); border-radius: var(--r-card); box-shadow: var(--shadow-1); }
.suggest-title { font-weight: 650; }

/* ---------- badges ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px; min-height: 28px; padding: 2px 10px 2px 6px;
  border-radius: var(--r-pill); font-size: var(--fs-small); font-weight: 800; white-space: nowrap;
  border: 2px solid currentColor;
}
.badge svg { width: 18px; height: 18px; }
.badge[data-s="Weak"] { background: var(--weak-soft); color: var(--weak); }
.badge[data-s="Okay"] { background: var(--okay-soft); color: var(--okay); }
.badge[data-s="Strong"] { background: var(--strong-soft); color: var(--strong); }
.badge[data-s="Not tried"], .badge[data-s="Review"] { background: var(--untried-soft); color: var(--untried); }

/* ---------- cards ---------- */
.card { background: var(--surface); border: var(--bw) solid var(--ink); border-radius: var(--r-card); padding: var(--s5); box-shadow: var(--shadow-2); }
.section-title { font-size: var(--fs-sub); font-weight: 850; letter-spacing: -.01em; margin-bottom: var(--s3); }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); margin-bottom: var(--s4); flex-wrap: wrap; }
.section-head .section-title { margin: 0; }

/* root cause card: the hero */
.rc-card { position: relative; display: grid; gap: var(--s4); padding-top: var(--s6); margin-top: var(--s3); }
.rc-sticker {
  position: absolute; top: -16px; left: var(--s5); transform: rotate(-3deg);
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 14px 4px 10px;
  background: var(--accent); color: var(--on-accent); border: var(--bw) solid var(--ink); border-radius: 10px;
  font-weight: 850; box-shadow: var(--shadow-1);
}
.rc-sticker svg { width: 20px; height: 20px; }
.rc-kicker { font-weight: 650; color: var(--muted); display: flex; align-items: center; gap: var(--s2); }
.rc-kicker svg { width: 20px; height: 20px; color: var(--primary); }
.rc-name { font-size: var(--fs-title); font-weight: 900; letter-spacing: -.025em; overflow-wrap: anywhere; line-height: 1.1; }
.rc-score { display: flex; align-items: center; gap: var(--s3); flex-wrap: wrap; }
.rc-number { font-size: var(--fs-hero); font-weight: 900; line-height: 1; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.rc-number small { font-size: var(--fs-sub); font-weight: 700; margin-left: 1px; color: var(--muted); }
.rc-why { font-size: var(--fs-lead); }
.rc-meta { font-size: var(--fs-small); color: var(--muted); }
.rc-actions { display: flex; flex-wrap: wrap; gap: var(--s2); }
.rc-actions .btn-primary { flex: 1 1 100%; }
.rc-actions > .btn-ghost, .rc-actions > .speak { flex: 1 1 auto; }
.rc-actions .speak .say-btn { flex: 1 1 auto; }
.rc-actions .btn-ghost { padding-inline: var(--s4); }

/* change banner after a quiz */
.change {
  display: grid; gap: var(--s3); padding: var(--s4) var(--s5); border-radius: var(--r-card);
  background: var(--primary-soft); border: var(--bw) solid var(--ink); box-shadow: var(--shadow-2);
}
.change-title { font-weight: 750; font-size: var(--fs-lead); }
.change-row { display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap; }
.change-row .arrow { color: var(--muted); font-weight: 700; }

/* ---------- the root line ---------- */
.rootline { list-style: none; margin: 0; padding: 0; position: relative; }
.node { position: relative; display: grid; grid-template-columns: 48px 1fr; gap: var(--s3); align-items: center; padding-bottom: var(--s5); }
.node:last-child { padding-bottom: 0; }
.node-dot {
  position: relative; z-index: 1; justify-self: center;
  width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center;
  --sph: var(--sph-untried);
  background: radial-gradient(circle at 34% 28%, var(--sph)); color: #1A1A1A;
  border: var(--bw) solid var(--ink); box-shadow: 2px 3px 0 var(--shadow-color);
  transition: background .35s var(--ease), transform .25s var(--ease);
}
.node-dot svg { width: 20px; height: 20px; }
.node[data-s="Weak"] .node-dot, .crow[data-s="Weak"] .node-dot { --sph: var(--sph-weak); }
.node[data-s="Okay"] .node-dot, .crow[data-s="Okay"] .node-dot { --sph: var(--sph-okay); }
.node[data-s="Strong"] .node-dot, .crow[data-s="Strong"] .node-dot { --sph: var(--sph-strong); }
.node.current .node-dot { outline: 3px dashed var(--ink); outline-offset: 4px; }
.node.root .node-dot {
  width: 54px; height: 54px; --sph: var(--sph-root);
  box-shadow: 3px 4px 0 var(--shadow-color), 0 0 0 10px var(--accent-glow);
}
.node.root .node-dot svg { width: 24px; height: 24px; }
.node.healed .node-dot { animation: heal .45s var(--ease); }
@keyframes heal { 0% { transform: scale(1); } 40% { transform: scale(1.18); } 100% { transform: scale(1); } }

/* segment from this node down to the next */
.seg {
  position: absolute; left: 22px; top: 18px; width: 5px; bottom: -18px; border-radius: 3px;
  background: var(--line-untried); transform-origin: top; transition: background-color .5s var(--ease);
}
.node:last-child .seg { display: none; }
.node[data-s="Weak"] .seg { background: var(--line-weak); }
.node[data-s="Okay"] .seg { background: var(--line-okay); }
.node[data-s="Strong"] .seg { background: var(--line-strong); }
.rootline.drawing .seg { animation: grow var(--seg-dur, .15s) linear both; animation-delay: var(--seg-delay, 0s); }
.rootline.drawing .node-dot { animation: pop .2s var(--ease) both; animation-delay: var(--dot-delay, 0s); }
@keyframes grow { from { transform: scaleY(0); } to { transform: scaleY(1); } }

.node-body { display: grid; gap: 2px; min-width: 0; }
.node-name { font-weight: 750; overflow-wrap: anywhere; }
.node.root .node-name { font-size: var(--fs-lead); font-weight: 900; }
.node-meta { display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap; font-size: var(--fs-small); color: var(--muted); }
.node-tag { font-size: var(--fs-small); font-weight: 650; color: var(--muted); }
.node.root .node-tag { color: var(--text); }

.view-toggle { display: inline-flex; padding: 3px; border-radius: var(--r-pill); background: var(--surface-2); border: 2px solid var(--ink); }
.view-toggle button {
  min-height: 42px; padding: 0 var(--s4); border: 0; border-radius: var(--r-pill); background: transparent;
  font-weight: 650; font-size: var(--fs-small); cursor: pointer; color: var(--muted);
}
.view-toggle button[aria-pressed="true"] { background: var(--ink); color: var(--bg); }

/* ---------- plan ---------- */
.plan { display: grid; gap: var(--s4); }
.day { padding: var(--s4) var(--s5) var(--s5); }
.day-head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s3); margin-bottom: var(--s3); }
.day-title { font-size: var(--fs-sub); font-weight: 900; display: inline-block; padding: 0 10px; background: var(--accent); color: var(--on-accent); border: 2px solid var(--ink); border-radius: 8px; transform: rotate(-2deg); }
.day-time { font-size: var(--fs-small); color: var(--muted); font-variant-numeric: tabular-nums; }
.tasks { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s2); }
.task { display: grid; grid-template-columns: 48px 1fr; gap: var(--s2); align-items: start; padding: var(--s2) 0; border-top: 2px dashed var(--border); }
.task:first-child { border-top: 0; }
.tick { position: relative; width: 48px; height: 48px; display: grid; place-items: center; cursor: pointer; }
.tick input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.tick-box {
  width: 28px; height: 28px; border-radius: 8px; border: var(--bw) solid var(--ink); display: grid; place-items: center;
  color: transparent; background: var(--surface); transition: background-color .15s, border-color .15s, color .15s, transform .15s var(--ease);
}
.tick-box svg { width: 18px; height: 18px; }
.tick input:checked + .tick-box { background: var(--primary); border-color: var(--primary); color: var(--on-primary); transform: scale(1.06); }
.tick input:focus-visible + .tick-box { outline: 2px solid var(--accent); outline-offset: 3px; }
.task-body { display: grid; gap: var(--s1); padding-top: 10px; min-width: 0; }
.task-name { font-weight: 800; overflow-wrap: anywhere; }
.task.done .task-name { text-decoration: line-through; text-decoration-thickness: 2px; color: var(--muted); }
.task-text { color: var(--muted); }
.task-meta { display: flex; gap: var(--s2); align-items: center; flex-wrap: wrap; margin-top: var(--s1); }
.time { font-size: var(--fs-small); font-weight: 650; font-variant-numeric: tabular-nums; color: var(--muted); }
.notes { margin-top: var(--s2); border: 2px solid var(--ink); border-radius: var(--r-input); background: var(--surface-2); }
.notes summary {
  min-height: 44px; display: flex; align-items: center; gap: var(--s2); padding: 0 var(--s3); cursor: pointer;
  font-weight: 800; list-style: none;
}
.notes summary::-webkit-details-marker { display: none; }
.notes summary::before { content: "+"; width: 22px; height: 22px; display: grid; place-items: center; border-radius: 6px; background: var(--accent); color: var(--on-accent); border: 2px solid var(--ink); font-weight: 900; line-height: 1; }
.notes[open] summary::before { content: "2"; }
.notes[open] summary { border-bottom: 2px dashed var(--border); }
.notes-points { margin: var(--s3) 0 0; padding: 0 var(--s4) 0 calc(var(--s4) + 18px); display: grid; gap: var(--s2); }
.notes-ex, .notes-trap, .notes-links { margin: var(--s3) var(--s3) 0; padding: var(--s2) var(--s3); border-radius: 10px; }
.notes-ex { background: var(--primary-soft); }
.notes-trap { background: var(--weak-soft); }
.notes-ex b, .notes-trap b { display: block; font-size: var(--fs-small); }
.notes-links { color: var(--muted); padding: 0 var(--s1); }
.notes > :last-child { margin-bottom: var(--s3); }
.rc-why.swap { animation: fadeIn .4s var(--ease); }
.rc-source { font-size: var(--fs-small); color: var(--muted); font-weight: 650; margin-top: calc(-1 * var(--s2)); }
.plan-teaser { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); flex-wrap: wrap; }

/* ---------- progress ---------- */
.summary { display: grid; gap: var(--s4); margin-bottom: var(--s5); }
.summary-hero { display: flex; align-items: baseline; gap: var(--s2); flex-wrap: wrap; }
.segbar { display: flex; height: 20px; border-radius: var(--r-pill); overflow: hidden; background: var(--untried-soft); border: var(--bw) solid var(--ink); }
.segbar span + span { border-left: 2px solid var(--ink); }
.segbar span { display: block; height: 100%; transition: flex-grow .4s var(--ease); }
.segbar .w { background: var(--weak); } .segbar .o { background: var(--okay); } .segbar .s { background: var(--strong); } .segbar .n { background: var(--line-untried); }
.legend { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s2); list-style: none; margin: 0; padding: 0; }
.legend li { display: flex; align-items: center; justify-content: space-between; gap: var(--s2); padding: var(--s2) var(--s3); border-radius: var(--r-input); background: var(--surface-2); border: 2px solid var(--ink); }
.legend b { font-variant-numeric: tabular-nums; font-size: var(--fs-lead); }
.unit { margin-bottom: var(--s5); }
.unit-title { font-size: var(--fs-sub); font-weight: 900; letter-spacing: -.01em; margin-bottom: var(--s2); }
.concepts { list-style: none; margin: 0; padding: 0; position: relative; }
.concepts::before { content: ""; position: absolute; left: 22px; top: 24px; bottom: 24px; width: 5px; border-radius: 3px; background: var(--line-untried); }
.crow { position: relative; display: grid; grid-template-columns: 48px 1fr auto; gap: var(--s3); align-items: center; min-height: 56px; padding: var(--s1) 0; }
.crow .node-dot { width: 30px; height: 30px; }
.crow .node-dot svg { width: 16px; height: 16px; }
.crow-name { font-weight: 600; overflow-wrap: anywhere; min-width: 0; }
.crow-sub { font-size: var(--fs-small); color: var(--muted); }
.crow-score { font-weight: 750; font-variant-numeric: tabular-nums; text-align: right; display: grid; justify-items: end; gap: 2px; }
.filters { margin-bottom: var(--s5); }

/* ---------- quiz ---------- */
.quiz-head { gap: var(--s1); }
.qprog { display: flex; gap: 6px; margin-bottom: var(--s5); }
.qprog span { flex: 1; height: 12px; border-radius: var(--r-pill); background: var(--surface); border: 2px solid var(--ink); transition: background-color .2s; }
.qprog span.on { background: var(--accent); }
.qcount { font-size: var(--fs-small); color: var(--muted); font-weight: 650; }
.qtext { font-size: var(--fs-sub); font-weight: 700; margin: var(--s2) 0 var(--s4); overflow-wrap: anywhere; }
.options { list-style: none; margin: 0 0 var(--s4); padding: 0; display: grid; gap: var(--s3); }
.opt {
  width: 100%; min-height: 56px; display: grid; grid-template-columns: 36px 1fr 24px; gap: var(--s3); align-items: center;
  padding: var(--s3) var(--s4); text-align: left; border-radius: var(--r-input); border: var(--bw) solid var(--ink);
  background: var(--surface); cursor: pointer; font-weight: 700; box-shadow: var(--shadow-1);
  transition: transform .1s var(--ease), box-shadow .1s var(--ease), background-color .15s;
}
.opt:hover { background: var(--accent-soft); }
.opt:active { transform: translate(3px, 3px); box-shadow: none; }
.opt-key { width: 32px; height: 32px; border-radius: 8px; display: grid; place-items: center; background: var(--surface-2); border: 2px solid var(--ink); font-weight: 900; font-size: var(--fs-small); }
.opt-text { overflow-wrap: anywhere; }
.opt-icon { color: transparent; }
.opt-icon svg { width: 22px; height: 22px; }
.opt[aria-pressed="true"] { background: var(--primary-soft); transform: translate(3px, 3px); box-shadow: none; }
.opt[aria-pressed="true"] .opt-key { background: var(--primary); color: var(--on-primary); }
.opt[aria-pressed="true"] .opt-icon { color: var(--primary); }
.opt.correct { background: var(--strong-soft); }
.opt.correct .opt-key { background: var(--strong); color: var(--surface); }
.opt.correct .opt-icon { color: var(--strong); }
.opt.wrong { background: var(--weak-soft); }
.opt.wrong .opt-key { background: var(--weak); color: var(--surface); }
.opt.wrong .opt-icon { color: var(--weak); }
.opt[disabled] { cursor: default; }
.opt.reveal { animation: pop .22s var(--ease); }
.heard { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); flex-wrap: wrap; padding: var(--s3) var(--s4); border-radius: var(--r-input); background: var(--accent-soft); border: 2px solid var(--ink); margin-bottom: var(--s4); }
.qfoot { position: sticky; bottom: calc(var(--nav-h) + var(--safe-b) + var(--s2)); display: flex; gap: var(--s2); padding: var(--s3) 0; background: linear-gradient(to bottom, transparent, var(--bg) 30%); }
.qfoot .btn-primary { flex: 1; }
.review { display: grid; gap: var(--s4); }
.review-q { display: grid; gap: var(--s2); }
.review-why { color: var(--muted); }
.score-hero { display: grid; justify-items: start; gap: var(--s2); }
.score-big { font-size: 56px; font-weight: 900; line-height: 1; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }

/* ---------- states ---------- */
.skeleton { display: grid; gap: var(--s4); }
.sk { background: var(--surface-2); border-radius: var(--r-input); position: relative; overflow: hidden; }
.sk::after { content: ""; position: absolute; inset: 0; transform: translateX(-100%); background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--surface) 70%, transparent), transparent); animation: shimmer 1.2s infinite; }
@keyframes shimmer { to { transform: translateX(100%); } }
.sk-card { height: 220px; border-radius: var(--r-card); }
.sk-line { height: 16px; }
.sk-root { display: grid; gap: var(--s4); padding-left: 6px; position: relative; }
.sk-root::before { content: ""; position: absolute; left: 22px; top: 14px; bottom: 14px; width: 3px; border-radius: 3px; background: var(--surface-2); }
.sk-row { display: grid; grid-template-columns: 36px 1fr; gap: var(--s4); align-items: center; }
.sk-dot { width: 32px; height: 32px; border-radius: 50%; }
.empty, .error-state { display: grid; justify-items: center; text-align: center; gap: var(--s3); padding: var(--s6) var(--s4); }
.empty-title, .error-title { font-size: var(--fs-sub); font-weight: 700; }
.empty p, .error-state p { max-width: 34ch; }
.error-state { background: var(--weak-soft); border-radius: var(--r-card); border: var(--bw) solid var(--ink); box-shadow: var(--shadow-1); }
.error-state > svg { color: var(--weak); width: 32px; height: 32px; }

.student-list { list-style: none; margin: var(--s5) 0 0; padding: 0; display: grid; gap: var(--s3); }
.student-card {
  width: 100%; display: grid; grid-template-columns: 48px 1fr; gap: var(--s4); align-items: center; text-align: left;
  padding: var(--s4) var(--s5); border-radius: var(--r-card); border: var(--bw) solid var(--ink); background: var(--surface);
  box-shadow: var(--shadow-2); cursor: pointer; transition: transform .1s var(--ease), box-shadow .1s var(--ease);
}
.student-card:hover { transform: translate(-2px, -2px); box-shadow: 8px 8px 0 var(--shadow-color); }
.student-card:active { transform: translate(4px, 4px); box-shadow: 2px 2px 0 var(--shadow-color); }
.student-card .avatar { width: 48px; height: 48px; font-size: var(--fs-lead); }
.student-card b { font-size: var(--fs-lead); display: block; }
.student-card span.muted { font-size: var(--fs-small); }

.toast-wrap { position: fixed; left: 0; right: 0; bottom: calc(var(--nav-h) + var(--safe-b) + var(--s3)); display: grid; justify-items: center; pointer-events: none; z-index: 40; padding: 0 var(--s4); }
.toast { max-width: 560px; padding: var(--s3) var(--s5); border-radius: var(--r-pill); background: var(--accent); color: var(--on-accent); border: var(--bw) solid var(--ink); font-weight: 800; box-shadow: var(--shadow-1); animation: toastIn .2s var(--ease); }
@keyframes toastIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------- bottom nav ---------- */
.bottomnav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: grid; grid-template-columns: repeat(3, 1fr);
  height: calc(var(--nav-h) + var(--safe-b)); padding-bottom: var(--safe-b);
  background: var(--surface); border-top: var(--bw) solid var(--ink);
}
.bottomnav a {
  display: grid; justify-items: center; align-content: center; gap: 2px; text-decoration: none;
  color: var(--muted); font-size: var(--fs-small); font-weight: 650; position: relative;
}
.bottomnav a svg { width: 24px; height: 24px; }
.bottomnav a[aria-current="page"] { color: var(--text); font-weight: 850; }
.bottomnav a[aria-current="page"] svg { background: var(--accent); color: var(--on-accent); border: 2px solid var(--ink); border-radius: var(--r-pill); width: 52px; height: 30px; padding: 2px 12px; box-shadow: 2px 2px 0 var(--shadow-color); }

.results { display: grid; gap: var(--s5); scroll-margin-top: 80px; }
.rootline { scroll-margin-top: 80px; }
.col { display: grid; gap: var(--s5); align-content: start; min-width: 0; }
.results .plan-inline { display: none; }
.has-results .quick { display: none; }

/* ---------- isometric hero art ---------- */
.hero-art { flex: none; }
.hero-art svg.iso { width: 100%; height: auto; display: block; overflow: visible; }
.ask-hero { display: flex; align-items: center; gap: var(--s3); }
.ask-copy { display: grid; gap: var(--s2); min-width: 0; flex: 1; }
.ask-hero .hero-art { width: 104px; margin-right: 4px; }
.has-results .ask-hero .hero-art { display: none; }
.picker-art { width: 150px; margin: 0 auto var(--s4); }
.empty-art { width: 120px; }
.iso-ring { animation: isoPulse 2.4s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }
.iso-glow { animation: isoGlow 2.4s ease-in-out infinite; }
@keyframes isoPulse { 0%, 100% { transform: scale(1); opacity: 1; } 50% { transform: scale(1.25); opacity: .35; } }
@keyframes isoGlow { 0%, 100% { opacity: .8; } 50% { opacity: .3; } }

[data-3d] { position: relative; }
[data-3d] > canvas { position: absolute; inset: -14% -18%; width: 136%; height: 128%; display: block; opacity: 0; transition: opacity .5s ease; touch-action: pan-y; }
[data-3d].has-3d > canvas { opacity: 1; }
[data-3d].has-3d svg.iso { visibility: hidden; }

/* ---------- interactive root map (node-editor style, always on a dark canvas) ---------- */
.gmap { display: grid; gap: var(--s4); margin-bottom: var(--s5); }
.gmap-stage {
  position: relative; height: 460px; overflow: hidden; border-radius: 24px; border: var(--bw) solid var(--ink);
  background: radial-gradient(circle at 1px 1px, #3A3A3A 1.3px, transparent 1.8px) 0 0 / 20px 20px, #121212;
  touch-action: none; cursor: grab; user-select: none; -webkit-user-select: none;
  color-scheme: dark;
}
.gmap-stage.grabbing { cursor: grabbing; }
.gworld { position: absolute; left: 0; top: 0; transform-origin: 0 0; will-change: transform; }
.gedges { position: absolute; left: 0; top: 0; width: 100%; height: 100%; overflow: visible; pointer-events: none; }
.gline { fill: none; stroke: #5A5A5A; stroke-width: 2.5; stroke-linecap: round; stroke-dasharray: 1 7; transition: stroke .2s, opacity .2s; }
.gport { fill: #5A5A5A; transition: fill .2s, opacity .2s; }
.gedge.chain .gline { stroke: #4CE38A; stroke-width: 3; }
.gedge.chain .gport { fill: #4CE38A; }
.gflow { fill: none; stroke: #F5B700; stroke-width: 3.5; stroke-linecap: round; stroke-dasharray: 2 22; animation: gsap 1.2s linear infinite; }
@keyframes gsap { to { stroke-dashoffset: 24; } }

.gcard {
  position: absolute; width: 208px; min-height: 104px; display: grid; align-content: start; gap: 10px;
  padding: 14px 16px 16px; border: 0; border-radius: 20px; text-align: left; cursor: pointer;
  background: #FFFFFF; color: #141414; font: inherit;
  box-shadow: 0 1px 0 rgba(255, 255, 255, .06), 0 10px 24px rgba(0, 0, 0, .45);
  transition: transform .18s var(--ease), background-color .2s, opacity .2s, box-shadow .2s;
}
.gcard.off { background: #262626; color: #EDEDED; }
.gcard.root { background: #F5B700; color: #141414; }
.gcard:hover { transform: translateY(-2px); }
.gcard.sel {
  background: #4CE38A; color: #0B1F14; transform: rotate(-3deg) scale(1.05); z-index: 2;
  box-shadow: 0 0 0 3px #0B1F14, 0 18px 40px rgba(0, 0, 0, .55);
}
.gcard:focus-visible { outline: 3px solid var(--accent); outline-offset: 4px; }
.gcard-top { display: flex; align-items: center; gap: 8px; }
.gsph {
  width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; flex: none; color: #141414;
  background: radial-gradient(circle at 34% 28%, var(--a), var(--b)); border: 2px solid #141414;
}
.gsph svg { width: 15px; height: 15px; }
.gsph.big { width: 44px; height: 44px; }
.gsph.big svg { width: 24px; height: 24px; }
.gstatus { font-size: 15px; font-weight: 800; }
.gscore { margin-left: auto; padding: 2px 10px; border-radius: 999px; background: rgba(0, 0, 0, .08); font-size: 15px; font-weight: 800; font-variant-numeric: tabular-nums; }
.gcard.off .gscore { background: rgba(255, 255, 255, .1); }
.gname { font-size: 17px; font-weight: 800; line-height: 1.2; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.gtag {
  position: absolute; top: -14px; left: 14px; display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px; border-radius: 999px; font-size: 14px; font-weight: 800; white-space: nowrap;
}
.gtag svg { width: 15px; height: 15px; }
.gtag-root { background: #C62A2F; color: #FFFFFF; }
.gtag-stuck { background: #141414; color: #FFFFFF; border: 2px solid #FFFFFF; left: auto; right: 14px; }

.gmap-stage.focusing .gcard:not(.lit) { opacity: .35; }
.gmap-stage.focusing .gedge:not(.lit) { opacity: .2; }
.gmap-stage.focusing .gedge.lit .gline { stroke: #4CE38A; }
.gmap-stage.focusing .gedge.lit .gport { fill: #4CE38A; }
.gmap-stage.far .gcard-top { display: none; }
.gmap-stage.far .gtag { display: none; }

.gtools {
  position: absolute; left: 12px; bottom: 12px; display: grid; gap: 4px; padding: 6px;
  background: #1E1E1E; border: 1px solid #333; border-radius: 999px;
}
.gtools button {
  width: 48px; height: 48px; border-radius: 50%; border: 0; display: grid; place-items: center; cursor: pointer;
  background: transparent; color: #EDEDED; transition: background-color .15s, transform .1s;
}
.gtools button:hover { background: #2E2E2E; }
.gtools button:active { transform: scale(.94); }
.gtools button[aria-pressed="true"] { background: #4CE38A; color: #0B1F14; }
.gtools svg { width: 22px; height: 22px; }
.ghint {
  position: absolute; right: 12px; bottom: 12px; padding: 6px 12px; border-radius: 999px; background: #1E1E1E;
  color: #CFCFCF; font-size: 14px; font-weight: 700; pointer-events: none;
}

.gdetail {
  display: grid; gap: var(--s3); padding: var(--s5); border-radius: 24px; color: #141414;
  background: #C9BFF7; border: var(--bw) solid var(--ink); box-shadow: var(--shadow-1);
}
.gdetail.root { background: #F5B700; }
.gdetail.weak { background: #FFC9C2; }
.gdetail.calm { background: #C9F5DC; }
.gdetail-head { display: flex; align-items: center; gap: var(--s3); }
.gdetail-where { font-weight: 700; font-size: 15px; }
.gdetail-name { font-size: var(--fs-sub); font-weight: 900; line-height: 1.15; overflow-wrap: anywhere; }
.gdetail-facts { display: flex; flex-wrap: wrap; gap: var(--s2); align-items: center; }
.gdetail-facts > * { padding: 2px 10px; border-radius: 999px; background: rgba(0, 0, 0, .1); font-weight: 750; font-size: 15px; }
.gdetail-actions { display: flex; flex-wrap: wrap; gap: var(--s2); }
.gpill {
  min-height: 48px; padding: 0 var(--s5); border-radius: 999px; border: 2px solid #141414; cursor: pointer;
  background: #141414; color: #FFFFFF; font: 750 var(--fs-body) var(--font); transition: transform .1s;
}
.gpill.ghost { background: transparent; color: #141414; }
.gpill:active { transform: scale(.97); }
.gpill:focus-visible { outline: 3px solid #141414; outline-offset: 3px; }


/* ---------- full-screen map layer ---------- */
body.map-open-body { overflow: hidden; }
.map-open { padding-inline: var(--s4); }
.map-layer {
  position: fixed; inset: 0; z-index: 60; display: grid; grid-template-rows: auto 1fr;
  background: #0B0B0B; color: #F2F0EA; animation: fadeIn .18s var(--ease);
}
.map-bar {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s3);
  padding: var(--s3) var(--s4); padding-top: max(var(--s3), env(safe-area-inset-top)); border-bottom: 1px solid #2A2A2A;
}
.map-bar-title { display: flex; align-items: center; gap: var(--s3); min-width: 0; }
.map-bar-title .brand-mark { width: 30px; height: 30px; color: #4CE38A; }
.map-bar h2 { font-size: var(--fs-lead); font-weight: 900; }
.map-bar p { font-size: var(--fs-small); color: #BDBDBD; font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.map-close { background: #F2F0EA; color: #141414; border-color: #F2F0EA; }
.map-close:focus-visible { outline: 3px solid var(--accent); }
.map-layer .gmap { position: relative; margin: 0; min-height: 0; gap: 0; }
.map-layer .gmap-stage { height: 100%; border: 0; border-radius: 0; }
.map-layer .gmap-detail {
  position: absolute; left: var(--s3); right: var(--s3); bottom: calc(var(--s3) + env(safe-area-inset-bottom));
  max-height: 46%; overflow: auto; border-radius: 24px;
}
.map-layer .gmap-detail:empty { display: none; }
.map-layer .gdetail { box-shadow: 0 18px 40px rgba(0, 0, 0, .5); border-color: #141414; }
.map-layer .gtools { bottom: auto; top: var(--s3); }
.map-layer .ghint { bottom: auto; top: var(--s3); }
@media (min-width: 900px) {
  .map-layer .gmap-detail { left: auto; top: var(--s4); bottom: auto; width: 380px; max-height: calc(100% - 32px); }
  .map-layer .ghint { top: auto; bottom: var(--s3); }
}

/* ---------- larger screens ---------- */
@media (min-width: 900px) {
  main { max-width: 1200px; padding-top: var(--s5); }
  #view-home .ask, #view-home .picker, #view-plan, #view-progress, #view-quiz { max-width: 640px; margin-left: auto; margin-right: auto; }
  .results.has-data { grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); align-items: start; gap: var(--s6); }
  .results .plan-inline { display: grid; }
  .plan-teaser { display: none; }
  .rc-actions .btn-primary { flex: 0 1 auto; }
  .rc-actions .btn-ghost { flex: 0 1 auto; padding: 0 var(--s5); }
  .legend { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .ask-hero .hero-art { width: 180px; }
  .bottomnav {
    left: 50%; right: auto; bottom: var(--s4); width: 420px; transform: translateX(-50%);
    height: calc(var(--nav-h) + 8px); padding-bottom: 0; border: var(--bw) solid var(--ink); border-radius: var(--r-card); box-shadow: var(--shadow-2);
  }
  body { padding-bottom: calc(var(--nav-h) + var(--s7)); }
  .toast-wrap { bottom: calc(var(--nav-h) + var(--s6)); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-delay: 0s !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
  .sk::after { display: none; }
}
