/* The Prediction Machine — site styles. Progressive enhancement; usable without JS. */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: var(--font-body); line-height: var(--leading);
  font-size: 1rem;
}
img, svg, video { max-width: 100%; height: auto; }

h1, h2, h3, h4 { font-family: var(--font-display); line-height: 1.25; margin: 1.6em 0 0.5em; }
h1 { font-size: clamp(1.7rem, 4vw, 2.4rem); margin-top: 0.5em; }
h2 { font-size: clamp(1.3rem, 3vw, 1.7rem); }
h3 { font-size: clamp(1.1rem, 2.5vw, 1.3rem); }
p, li { max-width: var(--measure); }
a { color: var(--interactive); }
a:visited { color: var(--visited); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 2px; }

.skip-link {
  position: absolute; left: -999px; top: 0; z-index: 100;
  background: var(--surface); color: var(--text); padding: 0.75rem 1.25rem;
  border: 2px solid var(--focus); border-radius: var(--radius);
}
.skip-link:focus { left: 0.5rem; top: 0.5rem; }

.visually-hidden {
  position: absolute !important; width: 1px; height: 1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}

/* ---- Header ---- */
.site-header {
  background: var(--surface); border-bottom: 1px solid var(--border);
  padding: 0.5rem 1rem;
}
.site-header .bar {
  display: flex; flex-wrap: wrap; gap: 0.5rem 1rem; align-items: center;
  max-width: 70rem; margin-inline: auto;
}
.brand {
  font-family: var(--font-display); font-weight: 700; text-decoration: none;
  color: var(--text); font-size: 1.05rem; padding: 0.4rem 0; margin-right: auto;
}
.brand:visited { color: var(--text); }
.site-header nav a {
  display: inline-block; padding: 0.5rem 0.6rem; min-height: 24px;
  text-decoration: none; border-radius: var(--radius);
}
.site-header nav a[aria-current="page"] { text-decoration: underline; text-underline-offset: 4px; font-weight: 700; }
.site-header nav a:hover { background: var(--surface-raised); }

/* Accessibility preferences panel */
.prefs { position: relative; }
.prefs > summary {
  list-style: none; cursor: pointer; padding: 0.5rem 0.75rem;
  border: 1px solid var(--border); border-radius: var(--radius);
  min-height: var(--target); display: inline-flex; align-items: center; gap: 0.4rem;
  background: var(--surface);
}
.prefs > summary::-webkit-details-marker { display: none; }
.prefs[open] > summary { background: var(--surface-raised); }
.prefs .panel {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 50;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 1rem; width: min(20rem, 88vw);
  box-shadow: 0 6px 24px rgba(0,0,0,0.18);
}
.prefs .panel .row { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; margin-block: 0.6rem; }
.prefs label { font-weight: 600; }
.prefs select, .prefs input[type="checkbox"] { min-height: 28px; }
.prefs select { font-size: 1rem; padding: 0.3rem; border-radius: 6px; border: 1px solid var(--border); background: var(--surface); color: var(--text); }

/* ---- Layout ---- */
main { max-width: 70rem; margin-inline: auto; padding: 1rem; }
.lesson-main { max-width: 46rem; }
.breadcrumbs { font-size: 0.95rem; margin-block: 0.75rem; }
.breadcrumbs ol { list-style: none; display: flex; flex-wrap: wrap; gap: 0.25rem; padding: 0; margin: 0; }
.breadcrumbs li + li::before { content: "→"; margin-inline: 0.4rem; color: var(--text-2); }

.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 1.25rem; margin-block: 1rem;
}
.card.raised { background: var(--surface-raised); }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
  min-height: var(--target); padding: 0.6rem 1.2rem;
  border-radius: var(--radius); border: 2px solid var(--interactive);
  background: var(--interactive); color: var(--surface);
  font: inherit; font-weight: 700; cursor: pointer; text-decoration: none;
}
[data-theme="dark"] .btn { color: #10201F; }
.btn:visited { color: var(--surface); }
.btn.secondary { background: transparent; color: var(--interactive); }
.btn.secondary:visited { color: var(--interactive); }
.btn.quiet { background: transparent; border-color: var(--border); color: var(--text); font-weight: 600; }
.btn:hover { filter: brightness(1.08); }
.btn[disabled], .btn[aria-disabled="true"] { opacity: 0.55; cursor: not-allowed; filter: none; }

/* ---- Semantic panels ---- */
.panel { border-radius: var(--radius-lg); padding: 1rem 1.25rem; margin-block: 1.25rem; border: 1px solid var(--border); }
.panel > .panel-label {
  display: inline-flex; gap: 0.4rem; align-items: center;
  font-family: var(--font-display); font-weight: 700; font-size: 0.95rem;
  text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 0.4rem;
}
.panel.concept { background: var(--c-process-soft); border-left: 6px solid var(--c-process); }
.panel.analogy { background: var(--c-input-soft); border-left: 6px solid var(--c-input); }
.panel.caution {
  background: var(--c-warn-soft); border: 2px dashed var(--c-warn);
}
.panel.human { background: var(--c-human-soft); border-left: 6px solid var(--c-human); }
.panel.example { background: var(--surface-raised); border-left: 6px solid var(--c-knowledge); }
.panel.takeaway { background: var(--c-output-soft); border-left: 6px solid var(--c-output); }

details.deeper {
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  margin-block: 1.25rem; background: var(--surface);
}
details.deeper > summary {
  cursor: pointer; padding: 0.9rem 1.25rem; font-weight: 700;
  font-family: var(--font-display); min-height: var(--target);
}
details.deeper > .inner { padding: 0 1.25rem 1rem; }

/* ---- Prediction prompt ---- */
.predict { border: 2px solid var(--c-process); border-radius: var(--radius-lg); padding: 1rem 1.25rem; margin-block: 1.25rem; background: var(--surface); }
.predict .options { display: flex; flex-wrap: wrap; gap: 0.6rem; margin-block: 0.75rem; }
.predict .options .btn { flex: 1 1 12rem; }
.predict .made { font-weight: 600; }

/* ---- Interactive shells ---- */
.interactive {
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  background: var(--surface); padding: 1.25rem; margin-block: 1.25rem;
}
.interactive .controls { display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: center; margin-block: 0.75rem; }
.interactive label { font-weight: 600; }
.interactive input[type="range"] { flex: 1 1 10rem; min-height: 32px; accent-color: var(--interactive); }
.interactive input[type="text"], .interactive select {
  font: inherit; padding: 0.5rem; border: 1px solid var(--border);
  border-radius: var(--radius); background: var(--surface); color: var(--text);
  min-height: var(--target);
}
.interactive output, .interactive .value { font-weight: 700; font-variant-numeric: tabular-nums; }

/* Probability / evidence bars (HTML, not SVG — inherently accessible) */
.bars { display: grid; gap: 0.45rem; margin-block: 0.75rem; }
.bar-row { display: grid; grid-template-columns: minmax(5.5rem, auto) 1fr minmax(3.2rem, auto); gap: 0.6rem; align-items: center; }
.bar-row .token { font-family: var(--font-display); font-weight: 600; overflow-wrap: anywhere; }
.bar-track { background: var(--surface-raised); border: 1px solid var(--border); border-radius: 6px; height: 1.4rem; overflow: hidden; }
.bar-fill { height: 100%; background: var(--c-process); min-width: 2px; transition: width var(--dur-slow) var(--ease); }
.bar-row.chosen .bar-fill { background: var(--c-output-fill); }
.bar-row.chosen .token::after { content: " ✓ drawn"; font-weight: 400; font-size: 0.85em; color: var(--c-output); }
.bar-row .pct { text-align: right; font-variant-numeric: tabular-nums; }

/* Token blocks */
.token-strip { display: flex; flex-wrap: wrap; gap: 0.35rem; margin-block: 0.75rem; }
.token-chip {
  border: 1.5px solid var(--c-process); border-radius: 8px;
  padding: 0.2rem 0.5rem; font-family: var(--font-display);
  background: var(--c-process-soft); font-size: 0.95rem;
}
.token-chip .tid { display: block; font-size: 0.72em; color: var(--text-2); }

/* ---- Quiz ---- */
.quiz fieldset { border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 1rem 1.25rem; margin: 0; }
.quiz legend { font-weight: 700; padding-inline: 0.4rem; max-width: var(--measure); }
.quiz .opt { display: flex; gap: 0.6rem; align-items: flex-start; padding: 0.55rem 0.4rem; border-radius: var(--radius); }
.quiz .opt input { width: 1.35rem; height: 1.35rem; margin-top: 0.2rem; flex-shrink: 0; accent-color: var(--interactive); }
.quiz .opt label { cursor: pointer; }
.quiz .feedback { border-radius: var(--radius); padding: 0.9rem 1.1rem; margin-top: 0.9rem; border-left: 6px solid var(--border); background: var(--surface-raised); }
.quiz .feedback.good { border-left-color: var(--success); }
.quiz .feedback.partial { border-left-color: var(--caution); }
.quiz .feedback.wrong { border-left-color: var(--error); }
.quiz .feedback .verdict { font-weight: 700; }

/* ---- Lesson chrome ---- */
.lesson-meta { display: flex; flex-wrap: wrap; gap: 0.5rem 1.25rem; color: var(--text-2); font-size: 0.95rem; align-items: center; }
.lesson-steps { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-block: 0.9rem; padding: 0; list-style: none; }
.lesson-steps li {
  border: 1.5px solid var(--border); border-radius: 999px; padding: 0.3rem 0.8rem;
  font-size: 0.9rem; background: var(--surface); color: var(--text-2);
}
.lesson-steps li[data-done="true"] { border-color: var(--success); color: var(--text); font-weight: 600; }
.lesson-steps li[data-done="true"]::before { content: "✓ "; color: var(--success); }
.lesson-nav { display: flex; justify-content: space-between; gap: 1rem; margin-block: 2rem; flex-wrap: wrap; }
.fieldnote textarea {
  width: 100%; min-height: 5.5rem; font: inherit; padding: 0.75rem;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); color: var(--text);
}
.stamp {
  display: inline-flex; align-items: center; gap: 0.5rem; font-family: var(--font-display);
  font-weight: 700; color: var(--success); border: 2px solid var(--success);
  border-radius: 999px; padding: 0.4rem 1rem; margin-top: 0.75rem;
}

/* ---- Pathway ---- */
.act-block { margin-block: 2rem; }
.act-block > h2 { border-bottom: 3px solid var(--c-process); padding-bottom: 0.3rem; }
.lesson-card {
  display: grid; grid-template-columns: auto 1fr; gap: 0.9rem;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 1rem 1.25rem; margin-block: 0.75rem;
}
.lesson-card .num {
  font-family: var(--font-display); font-weight: 700; font-size: 1.3rem;
  background: var(--c-process-soft); color: var(--text);
  border-radius: var(--radius); min-width: 2.6rem; height: 2.6rem;
  display: flex; align-items: center; justify-content: center;
}
.lesson-card h3 { margin: 0 0 0.2rem; }
.lesson-card h3 a { color: var(--text); }
.lesson-card .promise { margin: 0 0 0.4rem; color: var(--text-2); }
.lesson-card .meta { display: flex; flex-wrap: wrap; gap: 0.4rem 1rem; font-size: 0.88rem; color: var(--text-2); }
.status {
  display: inline-flex; align-items: center; gap: 0.3rem; border-radius: 999px;
  padding: 0.1rem 0.65rem; font-size: 0.85rem; font-weight: 600; border: 1.5px solid var(--border);
}
.status[data-s="done"] { border-color: var(--success); color: var(--success); }
.status[data-s="progress"] { border-color: var(--caution); color: var(--caution); }
.status[data-s="soon"] { border-color: var(--border); color: var(--text-2); font-style: italic; }

/* ---- Home ---- */
.hero { padding-block: 2rem 1rem; }
.hero .lede { font-size: 1.15rem; max-width: var(--measure); }
.hero .fact-strip { display: flex; flex-wrap: wrap; gap: 0.5rem 1.5rem; color: var(--text-2); margin-block: 1rem; padding: 0; list-style: none; }
.hero .fact-strip li::before { content: "✓ "; color: var(--success); }
.acts-journey { display: grid; gap: 0.75rem; grid-template-columns: repeat(auto-fit, minmax(11.5rem, 1fr)); padding: 0; list-style: none; }
.acts-journey li {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  border-top: 6px solid var(--c-process);
}
.acts-journey .act-link { display: block; padding: 1rem; color: inherit; text-decoration: none; height: 100%; border-radius: var(--radius-lg); }
.acts-journey .act-link:visited { color: inherit; }
.acts-journey li:hover { border-color: var(--c-process); box-shadow: 0 3px 12px rgba(0,0,0,0.1); }
.acts-journey .act-link:hover h3 { text-decoration: underline; text-underline-offset: 3px; }
.acts-journey .act-link:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.acts-journey .act-n { font-family: var(--font-display); color: var(--text-2); font-size: 0.9rem; }
.acts-journey h3 { margin: 0.2rem 0 0.35rem; font-size: 1.05rem; }
.acts-journey p { font-size: 0.92rem; margin: 0; color: var(--text-2); }

/* ---- Footer ---- */
.site-footer { border-top: 1px solid var(--border); margin-top: 3rem; padding: 1.5rem 1rem 2.5rem; color: var(--text-2); font-size: 0.95rem; }
.site-footer .inner { max-width: 70rem; margin-inline: auto; display: grid; gap: 0.5rem; }

/* ---- Layer map (interactive stack, Lesson 1) ---- */
.layer-stack { display: grid; gap: 4px; margin-block: 1rem; padding: 0; list-style: none; max-width: 30rem; }
.layer-stack button {
  width: 100%; text-align: left; font: inherit; font-weight: 600;
  padding: 0.65rem 1rem; min-height: var(--target); cursor: pointer;
  border: 1.5px solid var(--border); border-radius: 8px;
  background: var(--surface); color: var(--text);
  display: flex; justify-content: space-between; gap: 0.75rem; align-items: center;
}
.layer-stack button .which { font-weight: 400; font-size: 0.85em; color: var(--text-2); white-space: nowrap; }
.layer-stack button[aria-expanded="true"] { border-color: var(--focus); border-width: 2.5px; }
.layer-stack li[data-band="engine"] button { border-left: 8px solid var(--c-process); }
.layer-stack li[data-band="context"] button { border-left: 8px solid var(--c-input); }
.layer-stack li[data-band="knowledge"] button { border-left: 8px solid var(--c-knowledge); }
.layer-stack li[data-band="tool"] button { border-left: 8px solid var(--c-tool); }
.layer-stack li[data-band="human"] button { border-left: 8px solid var(--c-human); }
.layer-detail {
  border: 1.5px solid var(--focus); border-radius: var(--radius-lg);
  padding: 1rem 1.25rem; margin-block: 0.75rem; background: var(--surface-raised);
}
.layer-detail h3 { margin-top: 0; }

/* ---- <ai-stack-map> web component ---- */
ai-stack-map { display: block; max-width: 46rem; margin-block: 1rem; }
ai-stack-map svg { display: block; width: 100%; height: auto; }
ai-stack-map text {
  font-family: var(--font-body); font-size: 15px; fill: var(--text);
}
ai-stack-map .map-title { font-family: var(--font-display); font-weight: 700; font-size: 17px; }
ai-stack-map .overall-label { fill: var(--text-2); font-size: 14px; }
ai-stack-map .overall-track { fill: var(--surface-raised); stroke: var(--border); }
ai-stack-map .overall-value { fill: var(--c-process); }
ai-stack-map .stack-layer { cursor: default; opacity: 0.68; transition: opacity var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease); }
ai-stack-map[interactive] .stack-layer { cursor: pointer; }
ai-stack-map .stack-layer .band { fill: var(--surface); stroke: var(--border); stroke-width: 1.5; }
ai-stack-map .stack-layer .accent { fill: var(--border); }
ai-stack-map .stack-layer[data-band="engine"] .accent { fill: var(--c-process); }
ai-stack-map .stack-layer[data-band="context"] .accent { fill: var(--c-input); }
ai-stack-map .stack-layer[data-band="knowledge"] .accent { fill: var(--c-knowledge); }
ai-stack-map .stack-layer[data-band="tool"] .accent { fill: var(--c-tool); }
ai-stack-map .stack-layer[data-band="human"] .accent { fill: var(--c-human); }
ai-stack-map .stack-layer .title { font-weight: 700; }
ai-stack-map .stack-layer .range { fill: var(--text-2); font-size: 13px; }
ai-stack-map .stack-layer .status-icon { font-size: 15px; text-anchor: middle; }
ai-stack-map .stack-layer .progress-track { fill: var(--surface-raised); stroke: var(--border); stroke-width: 0.75; }
ai-stack-map .stack-layer .progress-value { fill: var(--success); }
ai-stack-map .stack-layer[data-state="upcoming"] { opacity: 0.55; }
ai-stack-map .stack-layer[data-state="partial"],
ai-stack-map .stack-layer[data-state="completed"] { opacity: 1; }
ai-stack-map .stack-layer[data-state="completed"] .band { stroke: var(--success); }
ai-stack-map .stack-layer[data-state="completed"] .status-icon { fill: var(--success); }
ai-stack-map .stack-layer[data-state="current"] { opacity: 1; transform: translateX(10px); }
ai-stack-map .stack-layer[data-state="current"] .band { stroke: var(--focus); stroke-width: 3; }
ai-stack-map .stack-layer.is-open .band { stroke: var(--focus); stroke-width: 3; stroke-dasharray: 6 3; }
ai-stack-map .stack-layer:focus-visible { outline: none; }
ai-stack-map .stack-layer:focus-visible .band { stroke: var(--focus); stroke-width: 4; }
ai-stack-map .current-marker rect { fill: var(--c-process); }
ai-stack-map .current-marker text { fill: var(--surface); font-weight: 700; font-size: 14px; }
[data-theme="dark"] ai-stack-map .current-marker text { fill: #10201F; }
ai-stack-map .stack-detail { margin-top: 0.5rem; }
@media (max-width: 40rem) {
  ai-stack-map text { font-size: 17px; }
  ai-stack-map .stack-layer .range { font-size: 15px; }
}

/* ---- "You are here" strip (every lesson) ---- */
.layer-strip { display: flex; flex-wrap: wrap; gap: 0.35rem; padding: 0; margin: 0.9rem 0 0; list-style: none; font-size: 0.85rem; }
.layer-strip li {
  border: 1.5px solid var(--border); border-radius: 6px; padding: 0.15rem 0.6rem;
  color: var(--text-2); background: var(--surface);
}
.layer-strip li[aria-current="true"] {
  border-color: var(--c-process); background: var(--c-process-soft);
  color: var(--text); font-weight: 700;
}
.layer-strip li[aria-current="true"]::before { content: "📍 "; }

/* ---- Simplification signpost ---- */
.simplify-note {
  display: block; border: 1.5px dashed var(--c-process); border-radius: var(--radius);
  padding: 0.6rem 0.9rem; margin-top: 0.9rem; font-size: 0.92rem;
  background: var(--surface); color: var(--text);
}
.simplify-note::before { content: "⚙ Deliberately simplified — "; font-weight: 700; }

/* ---- Lesson figures ---- */
figure.lesson-fig { margin: 1.25rem 0; }
figure.lesson-fig svg { display: block; max-width: 100%; height: auto; }
figure.lesson-fig figcaption { font-size: 0.92rem; color: var(--text-2); margin-top: 0.5rem; max-width: var(--measure); }

/* ---- Evidence labels ---- */
.elabel {
  display: inline-block; font-size: 0.78rem; font-weight: 700; letter-spacing: 0.03em;
  border-radius: 5px; padding: 0.1rem 0.5rem; vertical-align: middle;
  border: 1.5px solid; margin-right: 0.3rem;
}
.elabel.how { color: var(--c-process); border-color: var(--c-process); background: var(--c-process-soft); }
.elabel.mental { color: var(--c-input); border-color: var(--c-input); background: var(--c-input-soft); }
.elabel.uncertain { color: var(--c-warn); border-color: var(--c-warn); background: var(--c-warn-soft); }

/* ---- Token conveyor (Lesson 1 hero) ---- */
.conveyor { border: 2px solid var(--c-process); border-radius: var(--radius-lg); padding: 1.25rem; background: var(--surface); margin-block: 1.25rem; }
.conveyor .sequence { display: flex; flex-wrap: wrap; gap: 0.35rem; align-items: center; min-height: 3rem; padding: 0.6rem; border-radius: var(--radius); background: var(--surface-raised); }
.conveyor .seq-tile {
  border: 1.5px solid var(--c-input); background: var(--c-input-soft); color: var(--text);
  border-radius: 8px; padding: 0.3rem 0.6rem; font-family: var(--font-display); font-weight: 600;
}
.conveyor .seq-tile.generated { border-color: var(--c-output); background: var(--c-output-soft); }
.conveyor .seq-cursor { color: var(--text-2); font-size: 1.2rem; }
.conveyor .cands { margin-top: 1rem; }
.conveyor .sim-label {
  display: inline-block; font-size: 0.82rem; font-weight: 700; color: var(--c-warn);
  border: 1.5px dashed var(--c-warn); border-radius: 6px; padding: 0.15rem 0.6rem; margin-bottom: 0.6rem;
}

/* ---- Decision scenario ---- */
.decision .choices { display: grid; gap: 0.5rem; margin-block: 0.75rem; }
.decision .choices button {
  text-align: left; font: inherit; padding: 0.7rem 1rem; min-height: var(--target);
  border: 1.5px solid var(--border); border-radius: var(--radius); cursor: pointer;
  background: var(--surface); color: var(--text);
}
.decision .choices button[aria-pressed="true"] { border-color: var(--focus); border-width: 2.5px; }
.decision .outcome { border-radius: var(--radius); padding: 0.9rem 1.1rem; margin-top: 0.75rem; border-left: 6px solid var(--border); background: var(--surface-raised); }
.decision .outcome.good { border-left-color: var(--success); }
.decision .outcome.partial { border-left-color: var(--caution); }
.decision .outcome.risky { border-left-color: var(--error); }

/* ---- Rubric ---- */
.rubric { list-style: none; padding: 0; margin: 0.75rem 0; display: grid; gap: 0.4rem; }
.rubric li { padding-left: 1.6rem; position: relative; color: var(--text-2); }
.rubric li::before { content: "○"; position: absolute; left: 0.2rem; }
.rubric li[data-hit="true"] { color: var(--text); font-weight: 600; }
.rubric li[data-hit="true"]::before { content: "✓"; color: var(--success); }

/* ---- Recall warm-up ---- */
details.recall {
  border: 1.5px solid var(--c-input); border-radius: var(--radius-lg);
  background: var(--c-input-soft); margin-block: 1rem;
}
details.recall > summary { cursor: pointer; padding: 0.7rem 1rem; font-weight: 700; min-height: var(--target); }
details.recall > .inner { padding: 0 1rem 0.9rem; }

/* ---- Apply it to your work ---- */
.panel.apply { background: var(--c-human-soft); border-left: 6px solid var(--c-human); }

/* ---- Self-check ---- */
.selfcheck fieldset { border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 0.9rem 1.1rem; margin-block: 0.75rem; }
.selfcheck legend { font-weight: 700; padding-inline: 0.4rem; max-width: var(--measure); }
.selfcheck .sc-opts { display: grid; gap: 0.4rem; }
.selfcheck .sc-opts button {
  text-align: left; font: inherit; padding: 0.6rem 0.9rem; min-height: var(--target);
  border: 1.5px solid var(--border); border-radius: var(--radius); cursor: pointer;
  background: var(--surface); color: var(--text);
}
.selfcheck .sc-opts button[data-picked="true"][data-ok="true"] { border-color: var(--success); font-weight: 700; }
.selfcheck .sc-opts button[data-picked="true"][data-ok="false"] { border-color: var(--error); }
.selfcheck .sc-why { margin: 0.5rem 0 0; padding: 0.5rem 0.8rem; border-left: 5px solid var(--border); background: var(--surface-raised); border-radius: var(--radius); }
.selfcheck .sc-why[data-ok="true"] { border-left-color: var(--success); }
.selfcheck .sc-why[data-ok="false"] { border-left-color: var(--error); }

/* ---- Mastery ---- */
.status[data-s="mastered"], .statuspill[data-s="mastered"] { border-color: var(--c-human); color: var(--c-human); }

/* ---- Claim register table ---- */
.claims table { border-collapse: collapse; width: 100%; font-size: 0.9rem; }
.claims th, .claims td { border: 1px solid var(--border); padding: 0.45rem 0.6rem; text-align: left; vertical-align: top; }
.claims th { background: var(--surface-raised); }

/* ---- Live region toast ---- */
#announcer { position: fixed; bottom: -999px; }

/* ---- Responsive ---- */
@media (max-width: 40rem) {
  .site-header nav { display: flex; flex-wrap: wrap; gap: 0.1rem; width: 100%; }
  .lesson-nav .btn { flex: 1 1 100%; }
}
@media (min-width: 64rem) {
  .with-rail { display: grid; grid-template-columns: 1fr 16rem; gap: 2.5rem; align-items: start; }
  .rail { position: sticky; top: 1rem; font-size: 0.92rem; }
  .rail ol { padding-left: 1.2rem; }
}

/* ================================================================
   NAVIGATION REDESIGN — identity, two-level header, progress, footers
   ================================================================ */

/* ---- Brand identity: token-tile mark ---- */
.brand { display: inline-flex; align-items: center; gap: 0.6rem; text-decoration: none; color: var(--text); margin-right: auto; padding: 0.3rem 0; }
.brand:visited { color: var(--text); }
.brand-mark { display: inline-flex; gap: 3px; }
.brand-mark .tile {
  display: inline-flex; align-items: center; justify-content: center;
  width: 1.55rem; height: 1.55rem; border-radius: 6px;
  font-family: var(--font-display); font-weight: 700; font-size: 0.95rem;
  background: var(--c-process); color: var(--surface);
}
[data-theme="dark"] .brand-mark .tile { color: #10201F; }
.brand-mark .tile:nth-child(2) { background: var(--c-input); }
.brand-mark .tile-cursor { background: var(--c-output-fill); color: #2B2005; animation: pm-arrive 700ms var(--ease) 1 both; }
@keyframes pm-arrive { from { opacity: 0; transform: translateX(-6px); } to { opacity: 1; transform: none; } }
[data-motion="reduce"] .brand-mark .tile-cursor { animation: none; }
@media (prefers-reduced-motion: reduce) { .brand-mark .tile-cursor { animation: none; } }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-name { font-family: var(--font-display); font-weight: 700; font-size: 1.02rem; }
.brand-tag { font-size: 0.74rem; color: var(--text-2); }

/* ---- Global header ---- */
.site-header { padding: 0; border-bottom: 1px solid var(--border); background: var(--surface); }
.global-header {
  display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem 1.25rem;
  max-width: 72rem; margin-inline: auto; padding: 0.55rem 1rem; min-height: 72px;
}
.primary-nav { display: flex; gap: 0.15rem; flex-wrap: wrap; }
.primary-nav a {
  display: inline-block; padding: 0.55rem 0.7rem; min-height: 24px; text-decoration: none;
  border-radius: 8px 8px 0 0; border-bottom: 3px solid transparent; color: var(--text);
}
.primary-nav a:visited { color: var(--text); }
.primary-nav a:hover { background: var(--surface-raised); }
.primary-nav a[aria-current="page"] {
  border-bottom-color: var(--c-process); font-weight: 700; background: var(--surface-raised);
}
.learner-controls { display: flex; align-items: center; gap: 0.5rem; margin-left: auto; }
.progress-chip {
  display: inline-flex; align-items: center; gap: 0.35rem; text-decoration: none;
  border: 1.5px solid var(--border); border-radius: 999px; padding: 0.35rem 0.85rem;
  min-height: 38px; color: var(--text); font-weight: 700; font-size: 0.9rem;
  font-variant-numeric: tabular-nums; background: var(--surface);
}
.progress-chip:visited { color: var(--text); }
.progress-chip:hover { border-color: var(--c-process); }
.prefs > summary {
  min-width: var(--target); min-height: var(--target); justify-content: center;
  font-family: var(--font-display); font-weight: 700; padding: 0.4rem 0.7rem;
  border-radius: 999px;
}

/* ---- Lesson context bar ---- */
.lesson-context {
  position: sticky; top: 0; z-index: 40;
  background: var(--surface-raised); border-top: 1px solid var(--border);
  transition: box-shadow var(--dur-fast) var(--ease);
}
.lesson-context.stuck { box-shadow: 0 3px 14px rgba(0,0,0,0.14); }
.lesson-context .lc-row {
  display: flex; flex-wrap: wrap; align-items: center; gap: 0.2rem 1.25rem;
  max-width: 72rem; margin-inline: auto; padding: 0.45rem 1rem; min-height: 48px;
}
.lc-act { color: var(--c-process); font-weight: 700; font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.04em; }
[data-theme="dark"] .lc-act { color: var(--c-process); }
.lc-title { font-family: var(--font-display); font-weight: 700; font-size: 0.98rem; flex: 1 1 14rem; }
.lc-nav { display: flex; gap: 0.75rem; align-items: center; }
.lc-nav a { text-decoration: none; font-weight: 700; padding: 0.35rem 0.5rem; border-radius: var(--radius); }
.lc-nav a:hover { background: var(--surface); }
.lc-compact { display: none; font-variant-numeric: tabular-nums; color: var(--text-2); font-size: 0.88rem; }

/* Segmented 21-lesson progress line */
.seg-line {
  display: flex; gap: 3px; padding: 0 1rem 0.5rem; max-width: 72rem; margin-inline: auto;
  text-decoration: none; align-items: center;
}
.seg-line .seg {
  flex: 1 1 auto; height: 7px; border-radius: 4px;
  background: var(--border); opacity: 0.5; min-width: 8px;
}
.seg-line .seg[data-s="done"] { background: var(--success); opacity: 1; }
.seg-line .seg[data-s="current"] {
  background: var(--surface); border: 2px solid var(--c-process); opacity: 1; height: 11px;
}
.seg-line:hover .seg { opacity: 0.85; }
.seg-line:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 4px; }

/* ---- Status pill ---- */
.statuspill {
  display: inline-flex; align-items: center; gap: 0.35rem;
  border-radius: 999px; padding: 0.15rem 0.75rem; font-size: 0.85rem; font-weight: 700;
  border: 1.5px solid var(--border); color: var(--text-2); background: var(--surface);
}
.statuspill[data-s="done"] { border-color: var(--success); color: var(--success); }
.statuspill[data-s="progress"] { border-color: var(--caution); color: var(--caution); }

/* ---- Learning footer (lesson pages) ---- */
.learning-footer {
  border: 2px solid var(--c-process); border-radius: var(--radius-lg);
  background: var(--surface); padding: 1.5rem; margin-block: 2.5rem 1rem;
}
.learning-footer .lf-head { display: flex; flex-wrap: wrap; gap: 0.5rem 1rem; align-items: center; justify-content: space-between; }
.learning-footer .lf-overall { font-variant-numeric: tabular-nums; font-weight: 700; color: var(--text-2); }
.learning-footer .lf-recap { font-size: 1.05rem; margin-block: 0.9rem; }
.lf-actions { display: flex; flex-wrap: wrap; gap: 1rem; align-items: stretch; }
.lf-actions .btn.quiet { align-self: center; }
.next-card {
  flex: 1 1 18rem; display: flex; flex-direction: column; gap: 0.25rem;
  text-decoration: none; color: var(--text);
  background: var(--c-process-soft); border: 1.5px solid var(--c-process);
  border-radius: var(--radius-lg); padding: 1rem 1.25rem;
}
.next-card:visited { color: var(--text); }
.next-card:hover { border-width: 2.5px; }
.next-card .nc-kicker { font-weight: 700; color: var(--c-process); font-size: 0.9rem; }
[data-theme="dark"] .next-card .nc-kicker { color: var(--c-process); }
.next-card .nc-title { font-family: var(--font-display); font-weight: 700; font-size: 1.25rem; }
.next-card .nc-tease { color: var(--text-2); }
.next-card .nc-time { font-size: 0.85rem; color: var(--text-2); }

/* ---- Grouped site footer ---- */
.site-footer { background: var(--surface-raised); border-top: 1px solid var(--border); margin-top: 2.5rem; padding: 2rem 1rem 2.5rem; color: var(--text); font-size: 0.95rem; }
.site-footer .cols {
  max-width: 72rem; margin-inline: auto; display: grid; gap: 1.5rem 2.5rem;
  grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr));
}
.site-footer h2 { font-size: 0.9rem; text-transform: uppercase; letter-spacing: 0.05em; margin: 0 0 0.5rem; color: var(--text-2); }
.site-footer ul { list-style: none; padding: 0; margin: 0; display: grid; gap: 0.35rem; }
.site-footer a { color: var(--text); }
.site-footer a:visited { color: var(--text); }
.site-footer .brand-close { max-width: 72rem; margin: 1.75rem auto 0; padding-top: 1.25rem; border-top: 1px solid var(--border); display: grid; gap: 0.4rem; }
.site-footer .brand-close p { margin: 0; }
.site-footer .save-note { color: var(--text-2); font-size: 0.88rem; }
.site-footer .credit-line { font-family: Georgia, "Times New Roman", serif; font-style: italic; font-size: 0.82rem; color: var(--text-2); opacity: 0.85; }

/* ---- Mobile sticky lesson bar ---- */
.mobile-lessonbar {
  display: none; position: fixed; inset-inline: 0; bottom: 0; z-index: 45;
  background: var(--surface); border-top: 1px solid var(--border);
  padding: 0.4rem 0.75rem; align-items: center; justify-content: space-between; gap: 0.5rem;
  box-shadow: 0 -3px 14px rgba(0,0,0,0.12);
}
.mobile-lessonbar .mb-count { font-variant-numeric: tabular-nums; font-weight: 700; font-size: 0.9rem; }
.mobile-lessonbar.suppressed { display: none !important; }

@media (max-width: 46rem) {
  .brand-tag { display: none; }
  .global-header { min-height: 60px; }
  .primary-nav { order: 3; width: 100%; overflow-x: auto; }
  .lc-title { font-size: 0.9rem; }
  .seg-line { display: none; }
  .lc-compact { display: inline; }
  .mobile-lessonbar { display: flex; }
  body[data-lesson] main { padding-bottom: 4.5rem; }
}

/* ---- Print ---- */
@media print {
  :root { --bg: #fff; --surface: #fff; --text: #000; --text-2: #333; --border: #999; }
  .site-header, .site-footer, .lesson-nav, .prefs, .skip-link, .btn, .predict .options,
  .lesson-context, .mobile-lessonbar, .lf-actions, .progress-chip { display: none !important; }
  details.deeper { border: none; }
  details.deeper > summary { display: none; }
  details.deeper > .inner { display: block !important; }
  details.deeper[open] > .inner, details.deeper:not([open]) > .inner { display: block; }
  a[href^="http"]::after { content: " (" attr(href) ")"; font-size: 0.85em; }
  .card, .panel, .interactive { break-inside: avoid; border: 1px solid #999; }
}
