/* ============================================================
   Scala → Haskell — shared stylesheet for all chapters
   Extracted from the per-chapter inline <style> blocks.
   Palette: steel-blue + rust on a paper/black-text base.
   Code surfaces share one light syntax theme (--code-* tokens).
   ============================================================ */

/* === TOKENS === */
:root {
  --bg: #FAFAF8;
  --bg-card: #FFFFFF;
  --bg-sunken: #F4F3F9;
  --text: #1A1A2E;
  --text-muted: #5C5C7A;
  --accent: #446B7A;          /* steel-blue — primary */
  --accent-dark: #345560;
  --accent-light: #DEEBF0;
  --accent-secondary: #D17A4A; /* rust — secondary */
  --accent-secondary-light: #F3E0D2;
  --warn: #D97706;
  --warn-light: #FDF1E0;
  --ok: #2D7D46;
  --ok-light: #E8F5EC;
  --err: #DC2626;
  --err-light: #FEE8E8;
  --grid-line: rgba(68, 107, 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. */
  --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-pill-soon { 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 dashed var(--border); background: transparent; white-space: nowrap; cursor: default; }
.ch-pill-soon .ch-num { font-family: var(--mono); font-weight: 700; font-size: 0.7rem; color: var(--text-muted); }
.ch-pill-soon .ch-name { font-weight: 500; opacity: 0.7; }
.ch-divider {
  width: 12px; height: 1px; background: var(--border); flex-shrink: 0;
}
@media (max-width: 640px) { .ch-pill-soon .ch-name { display: none; } }

/* === 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 #c8dde5;
  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 strong { color: var(--accent-dark); }
.callout.warn strong { color: var(--warn); }

/* === 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;
}
/* stepper (ch.2) */
.stepper { display: inline-flex; align-items: center; gap: 0.25rem; border: 1px solid var(--border); border-radius: 8px; background: var(--bg-card); padding: 0.1rem; }
.stepper button { font: inherit; font-family: var(--mono); font-weight: 700; width: 26px; height: 26px; border: none; background: transparent; color: var(--accent); cursor: pointer; border-radius: 6px; }
.stepper button:hover { background: var(--accent-light); }
.stepper .val { font-family: var(--mono); font-size: 0.9rem; min-width: 1.6rem; text-align: center; }
/* toggle pills (ch.3 ADT builder) */
.toggle-row { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
label.toggle {
  display: inline-flex; align-items: center; gap: 0.45rem;
  font-size: 0.85rem; font-weight: 500;
  border: 1px solid var(--border); background: var(--bg-card);
  color: var(--text); border-radius: 999px;
  padding: 0.35rem 0.8rem; cursor: pointer;
  transition: all 0.15s ease-out;
  user-select: none;
}
label.toggle:hover { border-color: var(--accent); }
label.toggle.on { background: var(--accent-light); border-color: var(--accent); color: var(--accent-dark); }
label.toggle input { accent-color: var(--accent); cursor: pointer; }

/* === CODE THEME (shared, dark — 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, pre.live {
  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;
}
/* live code rendered inside widgets (ch.3) */
pre.live { padding: 0.9rem 1.1rem; line-height: 1.75; border-radius: 0.5rem; white-space: pre-wrap; }
pre.code .cm, pre.live .cm { color: var(--code-cm); font-style: italic; }
pre.code .kw, pre.live .kw { color: var(--code-kw); }
pre.code .ty, pre.live .ty { color: var(--code-ty); }
pre.code .fn, pre.live .fn { color: var(--code-fn); }
pre.code .op, pre.live .op { color: var(--code-op); }
pre.code .st, pre.live .st { color: var(--code-st); }
pre.live .hl { background: rgba(240, 168, 120, 0.26); border-radius: 3px; box-shadow: 0 0 0 2px rgba(240, 168, 120, 0.26); }
pre.live .dim { opacity: 0.38; }
.trace-line { transition: opacity 0.2s, background 0.2s; }
.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); }

/* === CH.1 — LAZY STEPPER === */
.thunk-row { display: flex; align-items: center; gap: 0.55rem; flex-wrap: wrap; }
.thunk-row .lbl { font-family: var(--mono); font-size: 0.8rem; color: var(--text-muted); width: 100%; margin-bottom: 0.2rem; }
.thunk {
  min-width: 46px; height: 46px; padding: 0 0.4rem; border-radius: 10px;
  display: grid; place-items: center;
  font-family: var(--mono); font-weight: 600; font-size: 0.95rem;
  background: var(--bg-sunken); color: var(--text-muted);
  border: 1px dashed #c9c6da;
  transition: transform 0.35s cubic-bezier(.34,1.56,.64,1), background 0.35s, color 0.35s, border-color 0.35s;
}
.thunk.forced {
  background: var(--accent-secondary-light); color: var(--accent-secondary);
  border: 1px solid #e3bfa3; border-style: solid;
  transform: translateY(-4px) scale(1.05);
}
.thunk.taken { box-shadow: 0 0 0 2px var(--accent) inset; }
.ctx { font-family: var(--mono); color: var(--text-muted); font-size: 1.1rem; }

/* === CH.1 — EXPRESSION VS STATEMENT (dark code panes) === */
.ev-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.9rem; }
@media (max-width: 640px) { .ev-grid { grid-template-columns: 1fr; } }
.ev-pane { background: var(--code-bg); border: 1px solid var(--code-border); border-radius: 0.5rem; padding: 0.85rem 1rem; }
.ev-pane .ev-cap { font-family: var(--mono); font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--code-cm); margin-bottom: 0.55rem; }
.ev-line { font-family: var(--mono); font-size: 0.85rem; line-height: 1.9; white-space: pre; color: var(--code-fg); }
.ev-line .v { background: rgba(240, 168, 120, 0.22); color: var(--code-op); border-radius: 4px; padding: 0.02em 0.3em; }
.ev-line .stmt { color: var(--code-cm); }
.ev-line .kw { color: var(--code-kw); font-weight: 600; }

/* === CH.1 — FAUX :t REPL === */
.repl { background: var(--code-bg); border-radius: var(--radius); padding: 1rem 1.1rem; font-family: var(--mono); font-size: 0.85rem; }
.repl-chips { display: flex; flex-wrap: wrap; gap: 0.45rem; margin-bottom: 0.85rem; }
.repl-chip {
  font: inherit; font-family: var(--mono); font-size: 0.82rem;
  background: var(--bg-card); color: var(--text); border: 1px solid var(--code-border);
  border-radius: 7px; padding: 0.3rem 0.6rem; cursor: pointer;
  transition: all 0.15s ease-out;
}
.repl-chip:hover { border-color: var(--accent); color: var(--accent-dark); }
.repl-chip.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.repl-out { color: var(--code-fg); min-height: 3.4em; }
.repl-out .prompt { color: var(--code-ty); }
.repl-out .ty { color: var(--code-ty); }
.repl-out .op { color: var(--code-op); }
.repl-out .cm { color: var(--code-cm); font-style: italic; display: block; margin-top: 0.3rem; }
.repl-out .caret { display: inline-block; width: 0.55em; background: var(--code-st); color: transparent; animation: blink 1s step-end infinite; }
@keyframes blink { 50% { opacity: 0; } }

/* === CH.2 — CURRYING BOXES === */
.curry-stage { display: flex; flex-direction: column; gap: 0.9rem; align-items: center; }
.type-display { font-family: var(--mono); font-size: 1.15rem; font-weight: 600; color: var(--accent-dark); letter-spacing: 0.01em; }
.type-display .consumed { color: var(--text-muted); opacity: 0.4; text-decoration: line-through; }
.type-display .result { color: var(--accent-secondary); }
.box-row { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; justify-content: center; }
.cbox {
  border: 2px solid var(--accent); border-radius: 12px;
  padding: 0.7rem 1rem; background: var(--accent-light);
  font-family: var(--mono); font-size: 0.95rem; color: var(--accent-dark);
  display: flex; flex-direction: column; align-items: center; gap: 0.3rem;
  transition: opacity 0.4s ease-out, transform 0.4s ease-out, background 0.3s;
  min-width: 5.5rem; text-align: center;
}
.cbox.collapsed { opacity: 0.25; transform: scale(0.85); border-style: dashed; }
.cbox .arg { font-weight: 700; font-size: 1.1rem; }
.cbox .lbl { font-size: 0.72rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.06em; }
.cbox.result-box { border-color: var(--accent-secondary); background: var(--accent-secondary-light); color: var(--accent-secondary); }

/* === CH.2 — PIPELINE === */
.pipe-stage { display: flex; flex-direction: column; gap: 1rem; }
.pipe-track { display: flex; align-items: center; gap: 0.4rem; flex-wrap: wrap; justify-content: center; }
.pipe-tile {
  border: 1px solid var(--border); border-radius: 10px;
  background: var(--bg-card); padding: 0.55rem 0.8rem;
  font-family: var(--mono); font-size: 0.92rem; color: var(--accent-dark);
  cursor: grab; user-select: none;
  box-shadow: 0 1px 2px var(--shadow);
  transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
}
.pipe-tile:hover { border-color: var(--accent); }
.pipe-tile.dragging { opacity: 0.5; }
.pipe-tile.dragover { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-light); }
.pipe-val {
  font-family: var(--mono); font-weight: 700; font-size: 1rem;
  color: var(--accent-secondary); background: var(--accent-secondary-light);
  border-radius: 8px; padding: 0.3rem 0.6rem; min-width: 2.6rem; text-align: center;
  transition: background 0.3s;
}
.pipe-val.bump { background: var(--accent-light); color: var(--accent-dark); }
.pipe-arrow { color: var(--text-muted); font-family: var(--mono); }

/* === CH.2 — SECTION BUILDER === */
.sec-build { display: flex; flex-direction: column; gap: 0.9rem; align-items: center; }
.sec-result { font-family: var(--mono); font-size: 1.4rem; font-weight: 700; color: var(--accent-dark); }
.sec-result .hole { color: var(--accent-secondary); }
.sec-type { font-family: var(--mono); font-size: 0.9rem; color: var(--text-muted); }
.sec-apply { font-family: var(--mono); font-size: 1rem; color: var(--text); }
.sec-apply b { color: var(--accent-secondary); }

/* === 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 #c8dde5; 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); }
.next-card.next-soon { opacity: 0.7; cursor: default; }
.next-card.next-soon:hover { transform: none; box-shadow: none; }
.badge-soon { margin-left: auto; font-size: 0.72rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; color: var(--accent-dark); background: var(--accent-light); padding: 0.3rem 0.6rem; border-radius: 999px; }

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; }
  .repl-out .caret { display: none; }
}

/* === 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%; }
  .ch-pill .ch-name { display: none; }
  .ch-pill { padding: 0.28rem 0.5rem; }
  .ch-divider { width: 6px; }
}

/* ============================================================
   Per-chapter widget rules (ch.7–10). Uniquely prefixed; merged
   from the chapter builds. All light — no dark code surfaces.
   ============================================================ */

/* === NEXT-CARD FINALE (ch.10) === */
.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; }

/* === CH.7 — IO: faux console (light) + do-stepper bindings + core/shell sorter === */
.c7-console-wrap { margin-top: 0.85rem; }
.c7-console-cap { font-family: var(--mono); font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--code-cm); margin-bottom: 0.35rem; }
pre.live.c7-console { background: #E9EEEA; color: var(--code-fg); min-height: 2.6em; border-radius: 0.5rem; white-space: pre-wrap; border: 1px solid var(--code-border); }
.c7-bindings { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.85rem; min-height: 0; }
.c7-bindings.filled { min-height: 2rem; }
.c7-bind { font-family: var(--mono); font-size: 0.82rem; background: var(--accent-secondary-light); color: var(--accent-secondary); border: 1px solid #e3bfa3; border-radius: 8px; padding: 0.3rem 0.6rem; }
.c7-bind-n { font-weight: 700; color: var(--accent-dark); }
.c7-bind-v { font-weight: 700; }
.c7-sorter { display: flex; flex-wrap: wrap; gap: 0.6rem; }
.c7-op { display: flex; flex-direction: column; align-items: flex-start; gap: 0.15rem; text-align: left; font: inherit; cursor: pointer; border-radius: 10px; padding: 0.55rem 0.75rem; min-width: 9.5rem; position: relative; transition: all 0.15s ease-out; border: 1px solid var(--border); background: var(--bg-card); }
.c7-op:hover { border-color: var(--accent); }
.c7-op-core { border-color: var(--accent); background: var(--accent-light); }
.c7-op-shell { border-color: var(--accent-secondary); background: var(--accent-secondary-light); }
.c7-op-where { font-size: 0.66rem; text-transform: uppercase; letter-spacing: 0.08em; font-weight: 700; color: var(--text-muted); }
.c7-op-core .c7-op-where { color: var(--accent-dark); }
.c7-op-shell .c7-op-where { color: var(--accent-secondary); }
.c7-op-name { font-family: var(--mono); font-weight: 700; font-size: 0.95rem; color: var(--text); }
.c7-op-sig { font-family: var(--mono); font-size: 0.75rem; color: var(--text-muted); }
.c7-op-ok { box-shadow: 0 0 0 2px var(--ok) inset; }
.c7-op-bad { box-shadow: 0 0 0 2px var(--err) inset; }
.c7-op-badge { position: absolute; top: 0.4rem; right: 0.55rem; font-weight: 700; }
.c7-op-ok .c7-op-badge { color: var(--ok); }
.c7-op-bad .c7-op-badge { color: var(--err); }

/* === CH.8 — WHNF stepper + foldl/foldl' buildup === */
.c8-whnf-stage { display: flex; justify-content: center; width: 100%; }
.c8-whnf-row { display: inline-flex; align-items: center; gap: 0.35rem; flex-wrap: wrap; justify-content: center; }
.c8-shell { font-family: var(--mono); font-size: 1.1rem; font-weight: 700; color: var(--accent-dark); }
.c8-thunk {
  min-width: 52px; padding: 0.4rem 0.7rem; border-radius: 10px;
  display: inline-grid; place-items: center;
  font-family: var(--mono); font-weight: 600; font-size: 0.95rem;
  background: var(--accent-secondary-light); color: var(--accent-secondary);
  border: 1px dashed #e3bfa3;
  transition: transform 0.35s cubic-bezier(.34,1.56,.64,1), background 0.35s, color 0.35s, border-color 0.35s;
}
.c8-thunk.forced {
  background: var(--accent-light); color: var(--accent-dark);
  border: 1px solid #c8dde5; border-style: solid;
  transform: translateY(-3px) scale(1.05);
}
.c8-fold-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.9rem; }
@media (max-width: 640px) { .c8-fold-grid { grid-template-columns: 1fr; } }
.c8-fold-col {
  border: 1px solid var(--code-border); border-radius: 0.5rem;
  background: var(--code-bg); padding: 0.85rem 0.95rem;
  display: flex; flex-direction: column; gap: 0.55rem;
}
.c8-fold-cap {
  font-family: var(--mono); font-size: 0.74rem; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--code-cm);
}
.c8-fold-cap code { background: transparent; color: var(--code-fg); font-size: 0.9em; }
.c8-fold-acc {
  margin: 0; border-radius: 6px; padding: 0.65rem 0.8rem;
  font-size: 0.82rem; line-height: 1.5; white-space: pre-wrap; word-break: break-all;
  min-height: 2.6em;
}
.c8-fold-meter { font-family: var(--mono); font-size: 0.8rem; color: var(--text-muted); }
.c8-fold-meter b { color: var(--accent-secondary); }

/* === CH.10 — type-level verdict banners + series recap map === */
.c10-verdict {
  margin-top: 0.85rem;
  font-size: 0.9rem; line-height: 1.6;
  border-radius: 0.5rem;
  padding: 0.7rem 0.9rem;
  border: 1px solid var(--border);
  background: var(--bg-sunken);
  color: var(--text);
}
.c10-verdict.ok { background: var(--ok-light); border-color: #bfe3c9; }
.c10-verdict.err { background: var(--err-light); border-color: #f3c4c4; }
.c10-verdict code {
  font-family: var(--mono); font-size: 0.85em;
  background: rgba(255,255,255,0.55);
  border-radius: 4px; padding: 0.05em 0.35em;
}
.c10-verdict.err code { color: #b91c1c; }
.c10-verdict.ok code { color: #1b5e2e; }
.c10-badge {
  display: inline-block;
  font-size: 0.7rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.06em;
  border-radius: 999px; padding: 0.15rem 0.6rem;
  margin-right: 0.5rem; vertical-align: 0.05em;
}
.c10-badge.ok { background: var(--ok); color: #fff; }
.c10-badge.err { background: var(--err); color: #fff; }
.c10-map {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 0.5rem;
}
.c10-node {
  font: inherit; text-align: left; cursor: pointer;
  display: flex; align-items: center; gap: 0.55rem;
  border: 1px solid var(--border); background: var(--bg-card);
  border-radius: 10px; padding: 0.5rem 0.7rem;
  transition: all 0.15s ease-out;
}
.c10-node:hover { border-color: var(--accent); color: var(--accent-dark); transform: translateY(-1px); }
.c10-node.active { background: var(--accent-light); border-color: var(--accent); color: var(--accent-dark); }
.c10-node-num {
  flex-shrink: 0;
  font-family: var(--mono); font-weight: 700; font-size: 0.75rem;
  width: 24px; height: 24px; border-radius: 6px;
  display: grid; place-items: center;
  background: var(--accent); color: #fff;
}
.c10-node.active .c10-node-num { background: var(--accent-dark); }
.c10-node-name { font-size: 0.82rem; font-weight: 500; line-height: 1.2; }
.c10-recall {
  margin-top: 0.85rem;
  border: 1px solid var(--border); border-left: 3px solid var(--accent);
  border-radius: 0.5rem; background: var(--bg-sunken);
  padding: 0.85rem 1rem;
}
.c10-recall-head {
  font-family: 'Fraunces', Georgia, serif;
  font-size: 1.05rem; font-weight: 600; color: var(--accent-dark);
  margin-bottom: 0.4rem;
}
.c10-recall-body { font-size: 0.9rem; color: var(--text-muted); margin-bottom: 0.3rem; }
.c10-recall-body strong { color: var(--text); }
.c10-recall-link {
  display: inline-block; margin-top: 0.35rem;
  font-size: 0.85rem; font-weight: 600; color: var(--accent);
}
.c10-recall-link:hover { color: var(--accent-dark); }
@media (max-width: 640px) {
  .c10-map { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }
}
