/* ============================================================
   Real Analysis — shared stylesheet for all chapters
   Style anchor for the whole book. Structure copied verbatim from
   categoryTheory/index.html; ONLY the palette tokens are swapped
   (mint + plum) and the code theme is centralized on ONE light
   scheme via --code-* tokens. No dark code surfaces anywhere.
   ============================================================ */

/* === TOKENS === */
:root {
  --bg: #FAFAF8;
  --bg-card: #FFFFFF;
  --bg-sunken: #F4F3F9;
  --text: #1A1A2E;
  --text-muted: #5C5C7A;
  --accent: #4A8C7A;           /* mint — primary */
  --accent-dark: #36695C;
  --accent-light: #DBEDE7;
  --accent-secondary: #7A4A78; /* plum — secondary */
  --accent-secondary-light: #EFE4EE;
  --warn: #D97706;
  --warn-light: #FDF1E0;
  --ok: #2D7D46;
  --ok-light: #E8F5EC;
  --err: #DC2626;
  --err-light: #FEE8E8;
  --grid-line: rgba(74, 140, 122, 0.07);
  --border: #E5E3EC;
  --shadow: rgba(40, 30, 90, 0.07);
  --radius: 0.75rem;
  --mono: 'SF Mono', 'JetBrains Mono', 'Fira Code', ui-monospace, Menlo, Consolas, monospace;

  /* code theme — ONE light scheme for every code surface (panes, REPL,
     live widget code, eval panes). Light, cool surface that stays
     distinct from the paper --bg. Never dark. */
  --code-bg: #EEF2F5;          /* light cool surface */
  --code-bg-soft: #E1E7EC;     /* tab bar / chips */
  --code-border: #D3DAE0;
  --code-fg: #1F2533;          /* near-black code text */
  --code-cm: #7A8590;          /* comment (grey, italic) */
  --code-kw: #9C2D6E;          /* keyword (magenta) */
  --code-ty: #2D6E78;          /* type (teal) */
  --code-fn: #2F5FA3;          /* function / value name (blue) */
  --code-op: #B5552A;          /* operator (rust) */
  --code-st: #3B7A4B;          /* string / literal (green) */
}

/* === RESET === */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* === LAYOUT === */
.container { max-width: 1040px; margin: 0 auto; padding: 0 1.5rem; }
.wide { max-width: 1040px; }

/* === HEADER === */
header {
  position: sticky; top: 0; z-index: 100;
  background: rgba(250, 250, 248, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid transparent;
  transition: border-color 0.3s, box-shadow 0.3s;
}
header.scrolled {
  border-bottom-color: var(--border);
  box-shadow: 0 1px 8px var(--shadow);
}
header .container {
  display: flex; align-items: center; justify-content: space-between;
  height: 56px; max-width: 1040px;
}
.wordmark {
  display: flex; align-items: center; gap: 0.5rem;
  font-weight: 600; font-size: 0.95rem; color: var(--text);
}
.wordmark:hover { text-decoration: none; }
.wordmark .mk {
  width: 26px; height: 26px; border-radius: 7px;
  background: var(--accent); color: #fff;
  display: grid; place-items: center;
  font-family: var(--mono); font-weight: 700; font-size: 0.85rem;
}
.wordmark span { opacity: 0.5; font-weight: 400; }
header nav { display: flex; gap: 1.2rem; }
header nav a {
  font-size: 0.85rem; color: var(--text-muted);
  transition: color 0.2s;
}
header nav a:hover { color: var(--accent); text-decoration: none; }
/* scroll progress */
.progress {
  position: absolute; left: 0; bottom: -1px; height: 2px;
  background: var(--accent); width: 0%;
  transition: width 0.1s linear;
}

/* === CHAPTER STRIP === */
.ch-strip {
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.ch-strip::-webkit-scrollbar { display: none; }
.ch-strip .container {
  display: flex; align-items: center; gap: 0.4rem;
  padding-top: 0.55rem; padding-bottom: 0.55rem;
  max-width: 1040px;
}
.ch-pill {
  flex-shrink: 0;
  display: inline-flex; align-items: center; gap: 0.45rem;
  font-size: 0.78rem; color: var(--text-muted);
  padding: 0.32rem 0.7rem; border-radius: 999px;
  border: 1px solid var(--border); background: var(--bg-card);
  transition: all 0.15s ease-out;
  text-decoration: none;
  white-space: nowrap;
}
.ch-pill:hover { color: var(--accent-dark); border-color: var(--accent); text-decoration: none; }
.ch-pill .ch-num {
  font-family: var(--mono); font-weight: 700; font-size: 0.7rem;
  color: var(--accent);
}
.ch-pill .ch-name { font-weight: 500; }
.ch-pill.current {
  background: var(--accent); color: #fff;
  border-color: var(--accent);
}
.ch-pill.current .ch-num { color: rgba(255,255,255,0.75); }
.ch-pill.current:hover { color: #fff; background: var(--accent-dark); border-color: var(--accent-dark); }
.ch-divider {
  width: 12px; height: 1px; background: var(--border); flex-shrink: 0;
}
@media (max-width: 767px) {
  .ch-pill .ch-name { display: none; }
  .ch-pill { padding: 0.28rem 0.5rem; }
  .ch-divider { width: 6px; }
}

/* === HERO === */
.hero {
  padding: 4.5rem 0 3rem;
  text-align: center;
  position: relative;
  overflow: hidden;
  background-image:
    linear-gradient(var(--grid-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
  background-size: 28px 28px;
}
.hero::after {
  content: '';
  position: absolute; bottom: 0; left: 0; right: 0; height: 80px;
  background: linear-gradient(transparent, var(--bg));
  pointer-events: none;
}
.eyebrow {
  display: inline-flex; align-items: center; gap: 0.5rem;
  font-size: 0.72rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.12em;
  color: var(--accent-dark);
  background: var(--accent-light);
  padding: 0.35rem 0.8rem; border-radius: 999px;
  margin-bottom: 1.25rem;
  animation: fadeUp 0.6s ease-out both;
}
.hero-title {
  font-family: 'Fraunces', Georgia, serif;
  font-size: 3rem; font-weight: 600;
  letter-spacing: -0.02em; line-height: 1.1;
  margin-bottom: 0.85rem;
  animation: fadeUp 0.6s ease-out 0.08s both;
}
.hero-title em { font-style: italic; color: var(--accent); }
.hero-subtitle {
  font-size: 1.15rem; color: var(--text-muted);
  max-width: 600px; margin: 0 auto 2rem;
  animation: fadeUp 0.6s ease-out 0.16s both;
}
.hero-arrows { animation: fadeUp 0.6s ease-out 0.28s both; }

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* === SECTIONS === */
section.lesson { padding: 1rem 0; }
.block { margin: 2.75rem 0; }
h2.sec {
  font-family: 'Fraunces', Georgia, serif;
  font-size: 1.7rem; font-weight: 600; letter-spacing: -0.01em;
  margin-bottom: 0.4rem;
  scroll-margin-top: 72px;
}
h2.sec .num {
  font-family: var(--mono); font-size: 0.95rem; font-weight: 500;
  color: var(--accent); margin-right: 0.5rem;
  vertical-align: 0.12em;
}
h3.sub { font-size: 1.1rem; font-weight: 600; margin: 1.5rem 0 0.5rem; }
p.lead { font-size: 1.05rem; color: var(--text-muted); margin-bottom: 1rem; }
.prose p { margin-bottom: 0.9rem; }
.prose ul { margin: 0.4rem 0 1rem 1.3rem; }
.prose li { margin-bottom: 0.35rem; }

/* inline math-ish */
.m {
  font-family: var(--mono); font-size: 0.92em;
  background: var(--bg-sunken);
  padding: 0.08em 0.38em; border-radius: 4px;
  white-space: nowrap;
}
.m.obj { color: var(--accent-secondary); background: var(--accent-secondary-light); }
.m.mor { color: var(--accent-dark); background: var(--accent-light); }

/* === CALLOUT === */
.callout {
  display: flex; gap: 0.85rem;
  background: var(--accent-light);
  border: 1px solid #c3e0d7;
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  padding: 1rem 1.15rem;
  margin: 1.5rem 0;
  font-size: 0.95rem;
}
.callout .ic { font-size: 1.2rem; flex-shrink: 0; line-height: 1.5; }
.callout.warn { background: var(--warn-light); border-color: #f3dcb6; border-left-color: var(--warn); }
.callout.hist { background: var(--accent-secondary-light); border-color: #dcc6da; border-left-color: var(--accent-secondary); }
.callout strong { color: var(--accent-dark); }
.callout.warn strong { color: var(--warn); }
.callout.hist strong { color: var(--accent-secondary); }

/* === FIGURE / WIDGET === */
.widget {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin: 1.5rem 0;
  box-shadow: 0 1px 3px var(--shadow);
}
.widget-head {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 0.6rem;
  margin-bottom: 0.5rem;
}
.widget-title {
  font-size: 0.78rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--text-muted);
  display: flex; align-items: center; gap: 0.45rem;
}
.widget-title .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }
.hint { font-size: 0.8rem; color: var(--text-muted); }

svg.diagram { width: 100%; height: auto; display: block; touch-action: none; user-select: none; }
.diagram-wrap { background: var(--bg-sunken); border-radius: 0.5rem; padding: 0.5rem; }

/* === BUTTONS / CONTROLS === */
.controls { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.85rem; align-items: center; }
.btn {
  font: inherit; font-size: 0.85rem; font-weight: 500;
  border: 1px solid var(--border); background: var(--bg-card);
  color: var(--text); border-radius: 8px;
  padding: 0.45rem 0.85rem; cursor: pointer;
  transition: all 0.15s ease-out;
  display: inline-flex; align-items: center; gap: 0.4rem;
}
.btn:hover { border-color: var(--accent); color: var(--accent-dark); }
.btn.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn.primary:hover { background: var(--accent-dark); color: #fff; }
.btn.active { background: var(--accent-light); border-color: var(--accent); color: var(--accent-dark); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.readout {
  font-family: var(--mono); font-size: 0.85rem;
  color: var(--text-muted); margin-left: auto;
}
select.pick {
  font: inherit; font-family: var(--mono); font-size: 0.85rem;
  padding: 0.3rem 0.5rem; border-radius: 6px;
  border: 1px solid var(--border); background: var(--bg-card); color: var(--text);
  cursor: pointer;
}

/* === CODE THEME (shared, LIGHT — every code surface) === */
.code-card { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; margin: 1.5rem 0; }
.code-tabs { display: flex; background: var(--code-bg-soft); border-bottom: 1px solid var(--code-border); }
.code-tab {
  font: inherit; font-size: 0.82rem; font-weight: 500;
  font-family: var(--mono);
  color: var(--text-muted); background: transparent; border: none;
  padding: 0.6rem 1.05rem; cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: color 0.15s, border-color 0.15s;
}
.code-tab:hover { color: var(--text); }
.code-tab.active { color: var(--accent-dark); border-bottom-color: var(--accent); }
.code-tab .lang-ic { opacity: 0.9; margin-right: 0.4rem; }
pre.code {
  margin: 0; padding: 1.1rem 1.2rem;
  background: var(--code-bg); color: var(--code-fg);
  font-family: var(--mono); font-size: 0.84rem; line-height: 1.7;
  overflow-x: auto;
}
pre.code .cm { color: var(--code-cm); font-style: italic; } /* comment */
pre.code .kw { color: var(--code-kw); }                      /* keyword */
pre.code .ty { color: var(--code-ty); }                      /* type */
pre.code .fn { color: var(--code-fn); }                      /* function/value name */
pre.code .op { color: var(--code-op); }                      /* operator */
pre.code .st { color: var(--code-st); }                      /* string/literal */
.code-pane { display: none; }
.code-pane.active { display: block; }

/* === QUIZ === */
.quiz-q { margin-bottom: 1.4rem; }
.quiz-q:last-child { margin-bottom: 0; }
.quiz-q .q { font-weight: 600; margin-bottom: 0.6rem; }
.quiz-q .q .qn {
  font-family: var(--mono); color: var(--accent); font-size: 0.85rem; margin-right: 0.4rem;
}
.opt {
  display: block; width: 100%; text-align: left;
  font: inherit; font-size: 0.92rem;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 8px; padding: 0.6rem 0.85rem; margin-bottom: 0.5rem;
  cursor: pointer; transition: all 0.12s ease-out;
  display: flex; align-items: center; gap: 0.6rem;
}
.opt:hover:not(.locked) { border-color: var(--accent); background: var(--accent-light); }
.opt .mark { width: 18px; flex-shrink: 0; font-weight: 700; }
.opt.correct { border-color: var(--ok); background: var(--ok-light); color: #1b5e2e; }
.opt.wrong { border-color: var(--err); background: var(--err-light); color: #b91c1c; }
.opt.locked { cursor: default; }
.quiz-fb { font-size: 0.88rem; margin-top: 0.4rem; min-height: 1.2em; color: var(--text-muted); }
.quiz-fb.show.ok { color: var(--ok); }
.quiz-fb.show.no { color: var(--err); }

/* === NEXT / FOOTER === */
.next-card {
  display: flex; align-items: center; gap: 1rem;
  background: linear-gradient(135deg, var(--accent-light), var(--accent-secondary-light));
  border: 1px solid #c3e0d7; border-radius: var(--radius);
  padding: 1.25rem 1.4rem; margin: 2.5rem 0 1rem;
}
.next-card .big { font-size: 1.6rem; }
.next-card .t1 { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.1em; color: var(--text-muted); font-weight: 600; }
.next-card .t2 { font-weight: 600; font-size: 1.05rem; }
.next-card .t3 { font-size: 0.88rem; color: var(--text-muted); }
.next-card .lock { margin-left: auto; font-size: 0.8rem; color: var(--text-muted); }
a.next-card { color: inherit; text-decoration: none; transition: transform 0.2s ease-out, box-shadow 0.2s ease-out; }
a.next-card:hover { transform: translateY(-2px); box-shadow: 0 6px 18px var(--shadow); text-decoration: none; }
.next-card .arrow { margin-left: auto; font-size: 1.4rem; color: var(--accent-dark); transition: transform 0.2s ease-out; }
a.next-card:hover .arrow { transform: translateX(4px); }

footer {
  padding: 2.5rem 0; text-align: center;
  font-size: 0.8rem; color: var(--text-muted);
  border-top: 1px solid var(--border); margin-top: 1rem;
}

/* === REDUCED MOTION === */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* === RESPONSIVE === */
@media (max-width: 767px) {
  .hero { padding: 3rem 0 2rem; }
  .hero-title { font-size: 2.1rem; }
  .hero-subtitle { font-size: 1rem; }
  h2.sec { font-size: 1.4rem; }
  header nav a:not(.nav-keep) { display: none; }
  .readout { margin-left: 0; width: 100%; }
}

/* ============================================================
   Chapter 1 — uniquely-named widget rules (prefix c1-).
   All light; no dark code surfaces.
   ============================================================ */

/* number-line readout tags shared by both widgets */
.c1-tag {
  display: inline-block; font-family: var(--mono); font-weight: 700;
  font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em;
  border-radius: 999px; padding: 0.12rem 0.55rem; vertical-align: 0.05em;
}
.c1-tag.yes { background: var(--ok-light); color: #1b5e2e; }
.c1-tag.no  { background: var(--err-light); color: #b91c1c; }
.c1-tag.sup { background: var(--accent-light); color: var(--accent-dark); }
.c1-tag.gap { background: var(--accent-secondary-light); color: var(--accent-secondary); }

/* Widget A — sup finder: readout row + value chip */
.c1-supout {
  margin-top: 0.85rem; display: flex; flex-wrap: wrap; align-items: center; gap: 0.6rem;
  font-size: 0.92rem;
}
.c1-supout .c1-val {
  font-family: var(--mono); font-weight: 700; color: var(--accent-dark);
  background: var(--bg-sunken); border-radius: 6px; padding: 0.1em 0.45em;
}

/* Widget B — Dedekind cut verdict banner */
.c1-cutout {
  margin-top: 0.85rem; font-size: 0.92rem; line-height: 1.55;
  border-radius: 0.5rem; padding: 0.7rem 0.9rem;
  border: 1px solid var(--border); background: var(--bg-sunken);
  color: var(--text);
  transition: background 0.25s, border-color 0.25s;
}
.c1-cutout.on-rational { background: var(--accent-light); border-color: #c3e0d7; }
.c1-cutout.in-gap { background: var(--accent-secondary-light); border-color: #dcc6da; }
.c1-cutout code {
  font-family: var(--mono); font-size: 0.85em;
  background: rgba(255,255,255,0.6); border-radius: 4px; padding: 0.05em 0.35em;
}
.c1-cutout .c1-newreal {
  display: inline-block; margin-left: 0.35rem;
  font-weight: 700; color: var(--accent-secondary);
}

/* ============================================================
   Chapter 2 — uniquely-named widget rules (prefix c2-).
   All light; no dark code surfaces.
   ============================================================ */

/* ε-band widget — sequence picker row */
.c2-seqrow {
  display: flex; flex-wrap: wrap; gap: 0.5rem;
  margin-bottom: 0.75rem;
}

/* ε-band widget — readout row + value chips */
.c2-ebandout {
  margin-top: 0.85rem; display: flex; flex-wrap: wrap; align-items: center; gap: 0.6rem;
  font-size: 0.92rem;
}
.c2-ebandout .c2-val {
  font-family: var(--mono); font-weight: 700; color: var(--accent-dark);
  background: var(--bg-sunken); border-radius: 6px; padding: 0.1em 0.45em;
}

/* verdict pill */
.c2-verdict {
  display: inline-block; font-family: var(--mono); font-weight: 700;
  font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em;
  border-radius: 999px; padding: 0.12rem 0.55rem; vertical-align: 0.05em;
}
.c2-verdict.yes { background: var(--ok-light);  color: #1b5e2e; }
.c2-verdict.no  { background: var(--err-light); color: #b91c1c; }

/* teaching note banner under the plot */
.c2-note {
  margin-top: 0.75rem; font-size: 0.9rem; line-height: 1.55;
  border-radius: 0.5rem; padding: 0.7rem 0.9rem;
  border: 1px solid var(--border); background: var(--bg-sunken);
  color: var(--text);
  transition: background 0.25s, border-color 0.25s;
}
.c2-note.conv { background: var(--accent-light); border-color: #c3e0d7; }
.c2-note.div  { background: var(--accent-secondary-light); border-color: #dcc6da; }
.c2-note strong { color: var(--accent-dark); }
.c2-note.div strong { color: var(--accent-secondary); }

/* ============================================================
   Chapter 3 — uniquely-named widget rules (prefix c3-).
   All light; no dark code surfaces.
   ============================================================ */

/* ε–δ game — verdict banner under the diagram */
.c3-verdict {
  margin-top: 0.85rem;
  display: flex; flex-wrap: wrap; align-items: center; gap: 0.6rem;
  font-size: 0.92rem; line-height: 1.5;
  border-radius: 0.5rem; padding: 0.7rem 0.9rem;
  border: 1px solid var(--border); background: var(--bg-sunken);
  transition: background 0.25s, border-color 0.25s;
}
.c3-verdict.ok   { background: var(--accent-light); border-color: #c3e0d7; }
.c3-verdict.fail { background: var(--err-light); border-color: #f3c9c9; }

.c3-verdict .c3-vrow { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 0.4rem; }

.c3-val {
  font-family: var(--mono); font-weight: 700; color: var(--accent-dark);
  background: rgba(255,255,255,0.65); border-radius: 6px; padding: 0.1em 0.45em;
}

/* verdict pill — continuous (ok) vs discontinuous (no) */
.c3-tag {
  margin-left: auto;
  display: inline-block; font-family: var(--mono); font-weight: 700;
  font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.05em;
  border-radius: 999px; padding: 0.14rem 0.6rem; vertical-align: 0.05em;
}
.c3-tag.ok { background: var(--ok-light); color: #1b5e2e; }
.c3-tag.no { background: var(--err-light); color: #b91c1c; }

@media (max-width: 767px) {
  .c3-tag { margin-left: 0; }
}

/* ============================================================
   Chapter 4 — uniquely-named widget rules (prefix c4-).
   Secant → tangent readout row. All light; no dark surfaces.
   ============================================================ */
.c4-out {
  margin-top: 0.85rem;
  display: flex; flex-wrap: wrap; align-items: center; gap: 0.55rem 0.9rem;
  font-size: 0.92rem;
}
.c4-out .c4-val {
  font-family: var(--mono); font-weight: 700; color: var(--accent-dark);
  background: var(--bg-sunken); border-radius: 6px; padding: 0.1em 0.45em;
  margin-left: 0.15rem;
}
.c4-out .c4-val.target {
  color: var(--accent-secondary); background: var(--accent-secondary-light);
}
.c4-tag {
  display: inline-block; font-family: var(--mono); font-weight: 700;
  font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em;
  border-radius: 999px; padding: 0.12rem 0.55rem; vertical-align: 0.05em;
  background: var(--err-light); color: #b91c1c;
}
.c4-tag.close { background: var(--warn-light); color: var(--warn); }
.c4-tag.ok    { background: var(--accent-light); color: var(--accent-dark); }

/* ============================================================
   Chapter 5 — Riemann-sum widget rules (prefix c5-).
   All light; no dark code surfaces.
   ============================================================ */

/* readout row beneath the Riemann-sum diagram */
.c5-out {
  margin-top: 0.9rem;
  display: flex; flex-wrap: wrap; gap: 0.75rem;
}
.c5-stat {
  flex: 1 1 150px;
  display: flex; flex-direction: column; gap: 0.15rem;
  background: var(--bg-sunken);
  border: 1px solid var(--border);
  border-radius: 0.55rem;
  padding: 0.55rem 0.75rem;
}
.c5-stat.c5-grow { flex: 1.4 1 200px; }
.c5-lab {
  font-size: 0.68rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.07em;
  color: var(--text-muted);
}
.c5-num {
  font-family: var(--mono); font-weight: 700; font-size: 1.05rem;
  color: var(--accent-dark);
}
.c5-num.c5-err { color: var(--accent-secondary); }

/* error bar: full at the coarse (n=1) error, empties toward 0 */
.c5-bar {
  margin-top: 0.35rem; height: 7px;
  background: var(--accent-secondary-light);
  border-radius: 999px; overflow: hidden;
}
.c5-fill {
  height: 100%; width: 100%;
  background: var(--accent-secondary);
  border-radius: 999px;
  transition: width 0.15s ease-out;
}

@media (prefers-reduced-motion: reduce) {
  .c5-fill { transition-duration: 0.01ms; }
}

/* ============================================================
   Chapter 6 — uniquely-named widget rules (prefix c6-).
   Partial-sums walker. All light; no dark code surfaces.
   ============================================================ */

/* series picker row */
.c6-series-row {
  display: flex; flex-wrap: wrap; gap: 0.5rem;
  margin-bottom: 0.7rem;
}

/* geometric ratio slider row (toggled to display:none for non-geo) */
.c6-rrow {
  display: flex; align-items: center; gap: 0.75rem;
  margin-bottom: 0.85rem; flex-wrap: wrap;
}
.c6-rlabel {
  font-size: 0.85rem; color: var(--text-muted);
  display: inline-flex; align-items: center; gap: 0.4rem;
}
.c6-rval {
  font-family: var(--mono); font-weight: 700; font-size: 0.8rem;
  color: var(--accent-dark);
  background: var(--accent-light); border-radius: 6px; padding: 0.1em 0.5em;
}
.c6-slider {
  flex: 1; min-width: 160px; max-width: 340px;
  accent-color: var(--accent);
  cursor: pointer;
}

/* readout stat strip under the diagram */
.c6-out {
  margin-top: 0.9rem;
  display: flex; flex-wrap: wrap; gap: 0.6rem;
}
.c6-stat {
  display: flex; flex-direction: column; gap: 0.1rem;
  flex: 1; min-width: 120px;
  background: var(--bg-sunken);
  border: 1px solid var(--border); border-radius: 0.5rem;
  padding: 0.5rem 0.7rem;
}
.c6-stat .c6-k {
  font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--text-muted); font-weight: 600;
}
.c6-stat .c6-v {
  font-family: var(--mono); font-weight: 700; font-size: 1.05rem;
  color: var(--accent-dark);
}

@media (max-width: 767px) {
  .c6-stat { min-width: 0; }
  .c6-stat .c6-v { font-size: 0.95rem; }
}

/* ============================================================
   Chapter 7 — History & the rigor crisis (prefix c7-).
   All light; no dark surfaces. Plus the .next-card.finale variant.
   ============================================================ */

/* Timeline widget — milestone dots + moving highlight ring */
.c7-dot { transition: r 0.15s ease-out; outline: none; }
.c7-dot:focus-visible { stroke: var(--accent-dark); stroke-width: 3; }
.c7-ring { transition: cx 0.35s ease-out, opacity 0.2s linear; pointer-events: none; }

/* Timeline detail panel */
.c7-panel {
  margin-top: 0.9rem;
  border: 1px solid var(--border);
  border-left: 3px solid var(--border);
  background: var(--bg-sunken);
  border-radius: 0.5rem;
  padding: 0.8rem 1rem;
  transition: background 0.25s, border-color 0.25s;
}
.c7-panel.found  { background: var(--accent-light); border-color: #c3e0d7; border-left-color: var(--accent); }
.c7-panel.attack { background: var(--accent-secondary-light); border-color: #dcc6da; border-left-color: var(--accent-secondary); }
.c7-panel-head { display: flex; align-items: baseline; flex-wrap: wrap; gap: 0.6rem; margin-bottom: 0.35rem; }
.c7-year {
  font-family: var(--mono); font-weight: 700; font-size: 0.82rem;
  color: var(--accent-dark);
  background: rgba(255,255,255,0.6); border-radius: 6px; padding: 0.08em 0.5em;
}
.c7-panel.attack .c7-year { color: var(--accent-secondary); }
.c7-name { font-family: 'Fraunces', Georgia, serif; font-weight: 600; font-size: 1.05rem; color: var(--text); }
.c7-fix { font-size: 0.92rem; line-height: 1.5; color: var(--text); margin: 0; }

/* Who's who reference table (rendered on the shared light code surface) */
table.c7-who {
  width: 100%; border-collapse: collapse;
  background: var(--code-bg); color: var(--code-fg);
  font-size: 0.86rem; line-height: 1.5;
}
table.c7-who th, table.c7-who td {
  text-align: left; padding: 0.55rem 1.1rem;
  border-bottom: 1px solid var(--code-border);
  vertical-align: top;
}
table.c7-who thead th {
  font-family: var(--mono); font-size: 0.72rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--text-muted); background: var(--code-bg-soft);
}
table.c7-who tbody tr:last-child td { border-bottom: none; }
table.c7-who td:first-child { font-weight: 600; white-space: nowrap; color: var(--accent-dark); }
table.c7-who td:nth-child(2) { font-family: var(--mono); font-size: 0.8rem; color: var(--text-muted); white-space: nowrap; }
@media (max-width: 620px) {
  table.c7-who th, table.c7-who td { padding: 0.5rem 0.7rem; }
  table.c7-who td:first-child { white-space: normal; }
}

/* Payoff map — Ch.1–6 → the people who nailed each down */
.c7-map { margin: 1.25rem 0; display: flex; flex-direction: column; gap: 0.5rem; }
.c7-map-row {
  display: grid;
  grid-template-columns: 3.2rem minmax(9rem, 1fr) 2.2fr;
  gap: 0.75rem; align-items: baseline;
  background: var(--bg-card);
  border: 1px solid var(--border); border-left: 3px solid var(--accent);
  border-radius: 0.5rem; padding: 0.7rem 0.9rem;
}
.c7-map-ch {
  font-family: var(--mono); font-weight: 700; font-size: 0.78rem;
  color: #fff; background: var(--accent);
  border-radius: 999px; padding: 0.12em 0.55em; text-align: center;
  justify-self: start;
}
.c7-map-idea { font-family: 'Fraunces', Georgia, serif; font-weight: 600; font-size: 0.98rem; color: var(--text); }
.c7-map-who { font-size: 0.9rem; color: var(--text-muted); line-height: 1.45; }
.c7-map-who strong { color: var(--accent-dark); font-weight: 600; }
@media (max-width: 620px) {
  .c7-map-row { grid-template-columns: 3.2rem 1fr; }
  .c7-map-who { grid-column: 1 / -1; }
}

/* Finale next-card variant (last chapter) */
.next-card.finale { background: linear-gradient(135deg, var(--accent-light), var(--accent-secondary-light)); }
.next-card.finale .big { font-size: 2.2rem; }
.next-card.finale .t2 { font-family: 'Fraunces', Georgia, serif; font-size: 1.35rem; }
