/* ── Fonts (self-hosted) ─────────────────────────────────── */
@font-face { font-family: "Kalam"; font-weight: 400; font-display: swap; src: url("fonts/kalam-400-latin.woff2") format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Kalam"; font-weight: 400; font-display: swap; src: url("fonts/kalam-400-latin-ext.woff2") format("woff2"); unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+1E00-1E9F, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: "Kalam"; font-weight: 700; font-display: swap; src: url("fonts/kalam-700-latin.woff2") format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Kalam"; font-weight: 700; font-display: swap; src: url("fonts/kalam-700-latin-ext.woff2") format("woff2"); unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+1E00-1E9F, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: "Atkinson Hyperlegible"; font-weight: 400; font-display: swap; src: url("fonts/atkinson-hyperlegible-400-latin.woff2") format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Atkinson Hyperlegible"; font-weight: 400; font-display: swap; src: url("fonts/atkinson-hyperlegible-400-latin-ext.woff2") format("woff2"); unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+1E00-1E9F, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: "Atkinson Hyperlegible"; font-weight: 700; font-display: swap; src: url("fonts/atkinson-hyperlegible-700-latin.woff2") format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Atkinson Hyperlegible"; font-weight: 700; font-display: swap; src: url("fonts/atkinson-hyperlegible-700-latin-ext.woff2") format("woff2"); unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+1E00-1E9F, U+2C60-2C7F, U+A720-A7FF; }

/* ── Tokens: an exercise-book page, blue biro, red margin pen, highlighters ── */
:root {
  --paper: #fbfcfa;
  --paper-deep: #f1f4f0;
  --rule: 28px;
  --rule-line: rgba(70, 128, 205, 0.22);
  --margin-x: 76px;
  --margin-line: #e2626a;
  --ink: #2346a6;          /* blue biro: headings, doodles, the graph */
  --ink-soft: #4c66b3;
  --graphite: #26282e;     /* body text */
  --muted: #565b68;
  --red: #c8333f;          /* red pen: reserved for the concept in focus, and errors */
  --hl-yellow: #fff04a;
  --hl-pink: #ffa3cf;
  --hl-green: #aef29a;
  --good: #1d8a4c; --mid: #b46f00; --bad: #c8333f;
  --hand: "Kalam", "Segoe Print", cursive;
  --text: "Atkinson Hyperlegible", system-ui, sans-serif;
  --box-radius: 255px 14px 225px 14px / 14px 225px 14px 255px;  /* a box drawn by hand */
  --box-radius-2: 14px 225px 16px 255px / 255px 16px 225px 14px;
  --lift: 0 6px 18px -8px rgba(35, 50, 90, 0.35);
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 72px; }
body {
  margin: 0;
  font: 17px/var(--rule) var(--text);
  color: var(--graphite);
  background-color: var(--paper);
  background-image: linear-gradient(to bottom, transparent calc(var(--rule) - 1px), var(--rule-line) calc(var(--rule) - 1px));
  background-size: 100% var(--rule);
  caret-color: var(--ink);
  -webkit-font-smoothing: antialiased;
}
/* The red margin line runs down the whole page */
body { position: relative; }
body::before {
  content: ""; position: absolute; top: 0; bottom: 0; left: var(--margin-x); width: 2px;
  background: var(--margin-line); opacity: 0.75; pointer-events: none; z-index: 0;
}
::selection { background: var(--hl-yellow); color: var(--graphite); }
:focus-visible { outline: 2px dashed var(--red); outline-offset: 3px; border-radius: 4px; }
[hidden] { display: none !important; }
a { color: var(--ink); text-underline-offset: 4px; text-decoration-thickness: 1.5px; }
h1, h2, h3 { font-family: var(--hand); color: var(--ink); font-weight: 700; margin: 0; text-wrap: balance; }
p { margin: 0; }
code { font-family: ui-monospace, Consolas, monospace; font-size: .88em; background: var(--paper-deep); padding: 1px 5px; border-radius: 4px; }
html { scrollbar-color: var(--ink-soft) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--ink-soft); border-radius: 10px; border: 3px solid var(--paper); }
::-webkit-scrollbar-track { background: transparent; }

.skip { position: absolute; left: -999px; top: 8px; background: var(--hl-yellow); padding: 4px 12px; z-index: 50; }
.skip:focus { left: calc(var(--margin-x) + 16px); }

/* Highlighter swipe behind a word: slightly tilted, uneven ends */
mark.hl, .hl {
  background: linear-gradient(100deg, transparent 0.6%, var(--hl-yellow) 2%, var(--hl-yellow) 97%, transparent 99.5%);
  background-size: 100% 62%; background-position: 0 78%; background-repeat: no-repeat;
  color: inherit; padding: 0 0.12em; margin: 0 -0.06em;
  border-radius: 6px 12px 8px 14px;
}

/* ── Header ──────────────────────────────────────────────── */
.top {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 24px;
  padding: 10px clamp(16px, 4vw, 48px) 10px calc(var(--margin-x) + 20px);
  background: color-mix(in srgb, var(--paper) 92%, transparent);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--rule-line);
}
.wordmark { display: flex; align-items: center; gap: 10px; text-decoration: none; font: 700 1.35rem/1 var(--hand); color: var(--ink); }
.mark { width: 34px; height: 34px; }
.top nav { margin-left: auto; display: flex; align-items: center; gap: clamp(12px, 2.4vw, 28px); font-family: var(--hand); font-size: 1.1rem; }
.top nav a { text-decoration: none; }
.top nav a:hover { text-decoration: underline wavy var(--ink-soft) 1.5px; }
.nav-cta { white-space: nowrap; padding: 2px 14px; border: 2px solid var(--ink); border-radius: var(--box-radius); background: var(--hl-yellow); color: var(--graphite) !important; }

/* ── Layout: everything sits right of the margin line ─────── */
main > section, .foot { position: relative; z-index: 1; padding-left: calc(var(--margin-x) + clamp(20px, 4vw, 56px)); padding-right: clamp(16px, 4vw, 56px); }

/* ── Buttons ─────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  font: 700 1.25rem/1.2 var(--hand); text-decoration: none; cursor: pointer;
  padding: 10px 26px; border: 2.5px solid var(--ink); border-radius: var(--box-radius);
  color: var(--graphite); background: var(--paper);
  transition: transform .35s var(--ease), box-shadow .35s var(--ease), background-color .2s;
}
.btn-primary { background: var(--hl-yellow); transform: rotate(-1.2deg); box-shadow: var(--lift); }
.btn-primary:hover:not(:disabled) { transform: rotate(0deg) translateY(-2px); box-shadow: 0 10px 22px -8px rgba(35, 50, 90, .45); }
.btn-primary:active:not(:disabled) { transform: translateY(1px); box-shadow: none; }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; box-shadow: none; background: var(--paper-deep); }
.btn-link { font: 1.15rem var(--hand); }
.btn-sm {
  font: 700 1rem/1.3 var(--hand); padding: 4px 14px; cursor: pointer; color: var(--ink);
  background: var(--paper); border: 2px solid var(--ink-soft); border-radius: var(--box-radius-2);
  transition: background-color .2s, transform .25s var(--ease);
}
.btn-sm:hover:not(:disabled) { background: var(--hl-yellow); transform: rotate(-1deg); }
.btn-sm:disabled { opacity: .5; cursor: not-allowed; }
.btn-ink { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.btn-ink:hover:not(:disabled) { background: var(--ink-soft); color: var(--paper); }

/* ── Hero ────────────────────────────────────────────────── */
.hero {
  display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); align-items: center; gap: clamp(24px, 4vw, 64px);
  min-height: calc(100svh - 64px); padding-top: calc(var(--rule) * 2); padding-bottom: calc(var(--rule) * 2);
}
.hero h1 { font-size: clamp(2.6rem, 5.4vw, 4.6rem); line-height: 1.12; letter-spacing: -0.01em; max-width: 13ch; }
.lede { margin-top: calc(var(--rule) * 1); font-size: 1.15rem; line-height: var(--rule); max-width: 46ch; }
.lede em { font-style: normal; background: linear-gradient(transparent 55%, var(--hl-pink) 55%, var(--hl-pink) 92%, transparent 92%); }
.hero-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 18px 28px; margin-top: calc(var(--rule) * 1.5); }
.scribble-note { margin-top: var(--rule); font: 1.05rem var(--hand); color: var(--muted); transform: rotate(-1deg); width: fit-content; }

.hero-demo { margin: 0; color: var(--ink); }
.hero-demo svg { width: 100%; height: auto; overflow: visible; }
.hero-demo figcaption { font-size: .85rem; line-height: 1.45; color: var(--muted); margin-top: 6px; max-width: 46ch; }
.demo-nodes circle { stroke: var(--ink); stroke-width: 2.2; filter: url(#wobble); }
.demo-nodes text { fill: var(--graphite); font-size: 15px; }
.demo-labels text { fill: var(--ink-soft); }
.fill-y { fill: var(--hl-yellow); } .fill-p { fill: var(--hl-pink); } .fill-g { fill: var(--hl-green); }
.demo-pen { stroke: var(--red); }
.bubble { fill: var(--paper); stroke: var(--ink); stroke-width: 2; }
.demo-ask text { fill: var(--graphite); font-family: var(--text); }
.cite-tag rect { fill: none; stroke: var(--red); stroke-width: 2; }
.cite-tag text { fill: var(--red); font-family: var(--hand); font-weight: 700; }

/* The one authored moment: the example map draws itself, then the red pen circles the answer */
@media (prefers-reduced-motion: no-preference) {
  .demo-lines path { stroke-dasharray: 1; stroke-dashoffset: 1; animation: draw 1.1s var(--ease) forwards; animation-delay: .6s; }
  .demo-lines path:nth-child(2) { animation-delay: .9s; } .demo-lines path:nth-child(3) { animation-delay: 1.1s; }
  .demo-lines path:nth-child(4) { animation-delay: 1.4s; } .demo-lines .arrowheads { animation-delay: 1.9s; }
  .dn { opacity: 0; transform: scale(.85); transform-box: fill-box; transform-origin: center; animation: pop .7s var(--ease) forwards; animation-delay: calc(var(--d) * .28s + .2s); }
  .demo-labels { opacity: 0; animation: fade .6s ease-out 2.1s forwards; }
  .demo-ask { opacity: 0; transform: translateY(8px); animation: rise .7s var(--ease) 2.5s forwards; }
  .demo-pen { stroke-dasharray: 1; stroke-dashoffset: 1; animation: draw 1s cubic-bezier(.6, 0, .2, 1) 3.2s forwards; }
}
@keyframes draw { to { stroke-dashoffset: 0; } }
@keyframes pop { to { opacity: 1; transform: none; } }
@keyframes fade { to { opacity: 1; } }
@keyframes rise { to { opacity: 1; transform: none; } }

/* ── How it works ────────────────────────────────────────── */
.how { padding-top: calc(var(--rule) * 3); padding-bottom: calc(var(--rule) * 3); }
.how h2, .app h2 { font-size: clamp(2rem, 3.6vw, 2.9rem); line-height: calc(var(--rule) * 2); }
.steps { list-style: none; margin: calc(var(--rule) * 1.5) 0 0; padding: 0; display: grid; gap: calc(var(--rule) * 1.5); max-width: 980px; }
.step-row { display: grid; grid-template-columns: 120px minmax(0, 1fr); gap: 28px; align-items: start; }
.step-row:nth-child(even) { margin-left: clamp(0px, 8vw, 120px); }
.step-row h3 { font-size: 1.6rem; line-height: calc(var(--rule) * 1.5); }
.step-row p { max-width: 62ch; margin-top: 4px; }
.doodle { width: 120px; height: 100px; color: var(--ink); }
.doodle.small { width: 76px; height: 64px; }
.hl-stroke { stroke: var(--hl-yellow); }
.tick { stroke: var(--good); }
.pen-red { color: var(--red); }

/* ── Small print: a sticky note ──────────────────────────── */
.small-print { padding-bottom: calc(var(--rule) * 3); }
.sticky {
  max-width: 560px; padding: 22px 28px 26px; background: #fff7a8; transform: rotate(1.2deg);
  box-shadow: 0 14px 24px -14px rgba(60, 50, 10, .45), 0 2px 4px rgba(60, 50, 10, .08);
  border-radius: 2px 2px 18px 2px;
  background-image: none;
}
.sticky h2 { font-size: 1.8rem; line-height: 1.4; color: var(--graphite); }
.sticky ul { margin: 10px 0 0; padding-left: 20px; }
.sticky li { margin: 6px 0; line-height: 1.5; }
.sticky li::marker { content: "–  "; font-family: var(--hand); color: var(--ink); }

/* ── App workspace ───────────────────────────────────────── */
.app { padding-top: calc(var(--rule) * 2); padding-bottom: calc(var(--rule) * 2); }
.workspace {
  margin-top: var(--rule);
  display: grid; grid-template-columns: 300px minmax(0, 1fr) 380px; gap: 18px;
  height: max(640px, calc(100svh - 150px));
}
.workspace:has(.study[hidden]) { grid-template-columns: 300px minmax(0, 1fr); }
.panel, .graph-area, .study {
  background: var(--paper); border: 2px solid var(--ink); border-radius: var(--box-radius);
  box-shadow: var(--lift); min-height: 0;
}
.upload-panel { padding: 18px 18px 22px; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; border-radius: var(--box-radius-2); }
.field-label { display: block; font: 700 1.1rem/1.5 var(--hand); color: var(--ink); margin-top: 8px; }
.hint { font-size: .85rem; line-height: 1.4; color: var(--muted); }
.muted { font-size: .85rem; line-height: 1.45; color: var(--muted); }

input[type="text"], select {
  width: 100%; font: 1rem/1.4 var(--text); color: var(--graphite);
  padding: 9px 12px; background: var(--paper);
  border: 2px solid var(--ink-soft); border-radius: 10px 14px 9px 16px;
  transition: border-color .2s, box-shadow .2s;
}
input[type="text"]::placeholder { color: #6b7080; }
input[type="text"]:focus, select:focus { outline: none; border-color: var(--ink); box-shadow: 0 0 0 4px color-mix(in srgb, var(--hl-yellow) 70%, transparent); }

.upload-zone {
  position: relative; text-align: center; padding: 14px 12px 12px; color: var(--ink);
  border: 2px dashed var(--ink-soft); border-radius: var(--box-radius); cursor: pointer;
  transition: background-color .2s, border-color .2s;
}
.upload-zone:hover, .upload-zone.drag-over { background: color-mix(in srgb, var(--hl-yellow) 35%, transparent); border-color: var(--ink); }
.upload-zone:focus-within { outline: 2px dashed var(--red); outline-offset: 3px; }
.upload-zone input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; }
.upload-zone p { font-size: .92rem; color: var(--graphite); }
.upload-zone strong { font-family: var(--hand); font-size: 1.1rem; color: var(--ink); }
.file-info { display: flex; align-items: center; gap: 8px; padding: 6px 6px 6px 12px; background: color-mix(in srgb, var(--hl-green) 55%, transparent); border-radius: 10px 16px 10px 14px; }
.file-name { flex: 1; font-weight: 700; font-size: .92rem; line-height: 1.35; overflow-wrap: anywhere; }
.remove-btn { display: grid; place-items: center; width: 30px; height: 30px; padding: 0; border: 0; background: none; color: var(--graphite); border-radius: 50%; cursor: pointer; }
.remove-btn svg { width: 16px; height: 16px; }
.remove-btn:hover { color: var(--red); background: var(--paper); }

.btn-generate { width: 100%; margin-top: 14px; }
.progress { min-height: 1.4em; font: 1rem/1.4 var(--hand); color: var(--ink-soft); }
.pencil { width: 22px; height: 22px; border-radius: 50%; border: 2.5px solid var(--ink); border-right-color: transparent; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.error-banner { padding: 8px 12px; color: var(--red); font-size: .92rem; line-height: 1.45; border: 2px solid var(--red); border-radius: 12px 6px 14px 8px; background: #fff3f3; }
.api-alert { padding: 10px 12px; font-size: .88rem; line-height: 1.45; background: #fff7a8; border-radius: 4px 4px 14px 4px; transform: rotate(-.6deg); }

.graph-stats { margin-top: 12px; padding-top: 10px; border-top: 2px dashed var(--rule-line); display: flex; flex-direction: column; gap: 8px; }
.graph-title { font-size: 1.35rem; line-height: 1.25; }
.counts { font-size: .9rem; line-height: 1.4; }
.counts span { font: 700 1.15rem var(--hand); color: var(--ink); }
.legend { display: flex; flex-wrap: wrap; gap: 6px; }
.legend-item { display: inline-flex; align-items: center; gap: 6px; font-size: .82rem; line-height: 1.6; padding: 0 9px 0 5px; border: 1.5px solid var(--rule-line); border-radius: 12px 8px 14px 9px; }
.legend-dot { width: 13px; height: 13px; border-radius: 50% 40% 55% 45%; border: 1.5px solid var(--ink); }
.controls { display: flex; flex-wrap: wrap; gap: 6px; }
.k-good { color: var(--good); font-weight: 700; } .k-mid { color: var(--mid); font-weight: 700; } .k-bad, .k-pen { color: var(--red); font-weight: 700; }

/* Graph canvas: a fresh ruled page */
.graph-area { display: flex; flex-direction: column; overflow: hidden; position: relative; min-width: 0; }
.graph-toolbar { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 16px; padding: 6px 16px; font: 1rem/1.5 var(--hand); color: var(--muted); border-bottom: 1.5px dashed var(--rule-line); }
#hoverInfo { color: var(--ink); font-weight: 700; }
#graph-svg-container { position: relative; flex: 1; min-height: 0; }
#graph-svg { width: 100%; height: 100%; display: block; cursor: grab; }
#graph-svg:active { cursor: grabbing; }
.empty-state { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; text-align: center; gap: 6px; padding: 24px; color: var(--muted); pointer-events: none; }
.empty-arrow { width: 160px; color: var(--ink-soft); margin-left: -120px; }
.empty-title { font: 700 1.6rem/1.3 var(--hand); color: var(--ink); }
.empty-state p:last-child { max-width: 36ch; }

/* Graph marks (built by app.js with rough.js) */
.node { cursor: pointer; transition: opacity .25s; }
.node .label { font: 700 14px var(--hand); fill: var(--graphite); paint-order: stroke; stroke: var(--paper); stroke-width: 4px; stroke-linejoin: round; pointer-events: none; }
.node .pen-ring { opacity: 0; transition: opacity .3s; }
.node.rag-used .pen-ring { opacity: 1; }
.node .importance-ring { fill: none; filter: url(#wobble); }
.node:hover .body, .node:focus-visible .body { filter: drop-shadow(0 3px 4px rgba(35, 70, 166, .35)); }
.link { fill: none; stroke: var(--ink); stroke-linecap: round; opacity: .5; transition: opacity .25s; }
.link.highlighted { opacity: 1; }
.links.dim .link:not(.highlighted) { opacity: .12; }
.link-label { font: 12px var(--hand); fill: var(--ink-soft); paint-order: stroke; stroke: var(--paper); stroke-width: 3.5px; pointer-events: none; text-anchor: middle; }

/* Tooltips: a sticky note and a pencil label */
.tooltip { position: fixed; z-index: 100; max-width: 260px; padding: 10px 14px 12px; background: #fff7a8; border-radius: 2px 2px 12px 2px; box-shadow: 0 10px 18px -10px rgba(60, 50, 10, .5); pointer-events: none; opacity: 0; transform: rotate(-1deg) translateY(4px); transition: opacity .15s, transform .2s var(--ease); }
.tooltip.show { opacity: 1; transform: rotate(-1deg); }
.tooltip-title { font: 700 1.15rem/1.3 var(--hand); color: var(--ink); }
.tooltip-category { font: .78rem/1.4 var(--text); color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.tooltip-desc { font-size: .88rem; line-height: 1.45; margin-top: 4px; }
.edge-tooltip { position: fixed; z-index: 99; padding: 4px 10px; font: 1rem/1.4 var(--hand); color: var(--ink); background: var(--paper); border: 1.5px solid var(--ink-soft); border-radius: 10px 6px 12px 8px; pointer-events: none; opacity: 0; transition: opacity .15s; }
.edge-tooltip.show { opacity: 1; }

/* ── Study panel: notebook divider tabs ──────────────────── */
.study { display: flex; flex-direction: column; overflow: hidden; }
.tabs { display: flex; gap: 6px; padding: 10px 12px 0; border-bottom: 2px solid var(--ink); flex-shrink: 0; }
.tabs button {
  flex: 1; font: 700 1.2rem/1.2 var(--hand); color: var(--graphite); cursor: pointer;
  padding: 8px 6px 6px; border: 2px solid var(--ink); border-bottom: 0; border-radius: 14px 18px 0 0;
  background: var(--paper-deep); transform: translateY(2px); transition: transform .2s var(--ease), background-color .2s;
}
.tabs button[data-tab="ask"] { background: color-mix(in srgb, var(--hl-yellow) 55%, var(--paper)); }
.tabs button[data-tab="learn"] { background: color-mix(in srgb, var(--hl-green) 55%, var(--paper)); }
.tabs button[data-tab="revise"] { background: color-mix(in srgb, var(--hl-pink) 55%, var(--paper)); }
.tabs button[aria-selected="true"] { background: var(--paper); transform: translateY(2px); padding-top: 12px; position: relative; z-index: 1; box-shadow: 0 2px 0 var(--paper); }
.tabs button[aria-selected="false"]:hover { transform: translateY(-1px); }
.study-body { flex: 1; overflow-y: auto; padding: 14px 16px 20px; font-size: .95rem; line-height: 1.55; }
.study p { margin: 8px 0; overflow-wrap: anywhere; }
.study h3 { font-size: 1.35rem; line-height: 1.3; margin: 14px 0 4px; }
.study .section-label { font-size: 1.1rem; margin: 14px 0 2px; color: var(--muted); }
.study form.row { display: flex; gap: 8px; }
.study select { margin-bottom: 6px; }
.good { color: var(--good); } .bad { color: var(--red); } .warn { color: var(--mid); font-weight: 700; }
.cite { font: 700 .85rem/1 var(--hand); color: var(--red); background: none; border: 1.5px solid var(--red); border-radius: 6px 4px 7px 5px; padding: 1px 5px; margin: 0 2px; cursor: pointer; vertical-align: 1px; }
.cite:hover { background: #fff0f0; }
.source { border: 1.5px dashed var(--ink-soft); border-radius: 10px 6px 12px 8px; padding: 4px 10px; margin: 6px 0; font-size: .86rem; }
.source summary { cursor: pointer; font-family: var(--hand); font-weight: 700; color: var(--ink); }
.source p { color: var(--muted); }
.path { list-style: none; margin: 4px 0 12px 8px; padding: 0; border-left: 2px dashed var(--ink-soft); }
.path li { position: relative; padding-left: 12px; }
.path li::before { content: ""; position: absolute; left: -8px; top: 15px; width: 14px; height: 14px; border-radius: 50% 45% 55% 40%; background: var(--paper); border: 2px solid var(--ink); }
.path li.ready::before { background: var(--hl-yellow); }
.path li.mastered::before { background: var(--hl-green); }
.path li.locked::before { background: var(--paper-deep); border-color: var(--muted); }
.path li.locked .step > span:first-child { color: var(--muted); }
.step { display: flex; flex-direction: column; width: 100%; text-align: left; padding: 6px 8px; background: none; border: 0; border-radius: 10px 6px 12px 8px; color: var(--graphite); font: inherit; cursor: pointer; }
.step > span:first-child { font: 700 1.1rem/1.35 var(--hand); color: var(--ink); }
.step:hover { background: color-mix(in srgb, var(--hl-yellow) 40%, transparent); }
.next { display: flex; flex-direction: column; padding: 10px 14px; margin: 4px 0 10px; background: #fff7a8; border-radius: 2px 2px 14px 2px; transform: rotate(-.6deg); box-shadow: 0 8px 14px -10px rgba(60, 50, 10, .45); }
.next strong { font: 700 1.25rem/1.3 var(--hand); color: var(--ink); }
.study fieldset { border: 0; margin: 14px 0; padding: 0; min-width: 0; }
.study legend { font-weight: 700; margin-bottom: 6px; line-height: 1.4; }
.option { display: flex; gap: 10px; align-items: flex-start; padding: 7px 10px; margin: 5px 0; border: 1.5px solid var(--rule-line); border-radius: 10px 6px 12px 8px; cursor: pointer; line-height: 1.4; transition: background-color .15s, border-color .15s; }
.option:hover { border-color: var(--ink-soft); }
.option input { accent-color: var(--ink); margin-top: 3px; }
.option:has(input:checked) { border-color: var(--ink); background: color-mix(in srgb, var(--hl-yellow) 35%, transparent); }
.option.right, .option.right:has(input:checked) { border-color: var(--good); background: color-mix(in srgb, var(--hl-green) 45%, transparent); }
.option.wrong, .option.wrong:has(input:checked) { border-color: var(--red); background: #fff0f0; }

/* ── Footer ──────────────────────────────────────────────── */
.foot { padding-top: calc(var(--rule) * 2); padding-bottom: calc(var(--rule) * 2); font-size: .9rem; color: var(--muted); }
.foot strong { font-family: var(--hand); font-size: 1.1rem; color: var(--ink); }

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 1180px) {
  .workspace, .workspace:has(.study[hidden]) { grid-template-columns: 290px minmax(0, 1fr); height: auto; }
  .graph-area { height: 70svh; min-height: 480px; }
  .study { grid-column: 1 / -1; max-height: 80svh; }
}
@media (max-width: 860px) {
  :root { --margin-x: 26px; }
  .hero { grid-template-columns: 1fr; min-height: 0; padding-top: var(--rule); }
  .hero-demo { max-width: 520px; }
  .top nav a:not(.nav-cta) { display: none; }
  .wordmark { font-size: 1.15rem; } .mark { width: 28px; height: 28px; }
  .step-row { grid-template-columns: 76px minmax(0, 1fr); gap: 16px; }
  .step-row:nth-child(even) { margin-left: 0; }
  .doodle { width: 76px; height: 64px; }
  .workspace, .workspace:has(.study[hidden]) { grid-template-columns: 1fr; }
  .graph-area { height: 64svh; min-height: 400px; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition-duration: .01ms !important; animation-duration: .01ms !important; }
}
