/* Study site styles. Colours, type, spacing, radii and shadows follow the
   Automagical Machines design system tokens (Paper and Ink themes). */
:root {
  color-scheme: light;
  --paper: #f2ecdd; --surface: #fffcf5; --stage: #e7e0d1; --ink: #151515;
  --pink: #f43b86; --pink-text: #ac1656; --acid: #dbff3f; --muted: #5c5852;
  --muted-on-ink: #c5bfb4; --border: #817c72; --rule-faint: #15151533;
  --error: #a61b36; --success: #22603e; --line: #151515; --band: #151515;
  --on-band: #f2ecdd; --on-accent: #151515; --purple: #b64dff; --slate: #a7a7a7;
  --font-display: "Noto Sans Display", Impact, "Arial Black", sans-serif;
  --font-body: Inter, Arial, sans-serif;
  --font-editorial: Georgia, "Times New Roman", serif;
  --font-meta: "Courier Prime", "Courier New", monospace;
  --font-marker: "Permanent Marker", "Marker Felt", cursive;
  --band-edge: #151515; --print-offset: 2px;
  --font-math: "STIX Two Math", "Cambria Math", "Latin Modern Math", Georgia, serif;
  --space-1: 4px; --space-2: 8px; --space-3: 12px; --space-4: 16px;
  --space-5: 24px; --space-6: 32px; --space-7: 48px; --space-8: 64px;
  --radius-control: 2px; --radius-card: 4px;
  --shadow-hard: 4px 4px 0 var(--line); --shadow-button: 3px 3px 0 var(--line);
  --shadow-button-hover: 2px 2px 0 var(--line); --focus-halo: 0 0 0 6px var(--acid);
  --stroke-frame: 2px; --stroke-hairline: 1px; --stroke-rule-heavy: 3px;
  --max-width: 1280px; --target: 48px; --target-min: 44px; --gutter: 32px;
  --code-bg: #161616; --code-ink: #f0ede3; --code-kw: #ff5ca8; --code-ty: #d7ff00;
  --code-str: #ffc2dc; --code-num: #f0ede3; --code-com: #c5bfb4; --code-mac: #d7ff00;
  --press: 140ms; --ease: cubic-bezier(.2, .7, .2, 1);
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --paper: #0b0b0b; --surface: #1a1a1a; --stage: #1f1f1f; --ink: #f0ede3;
  --pink: #ff2d90; --pink-text: #ff2d90; --acid: #d7ff00; --muted: #a7a7a7;
  --border: #7a776f; --rule-faint: #f0ede333; --error: #ff6b81; --success: #5fd38d;
  --line: #f0ede3; --band: #161616; --on-band: #f0ede3; --on-accent: #0b0b0b; --slate: #3a3a3a;
  --code-bg: #000000; --band-edge: #7a776f;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --paper: #0b0b0b; --surface: #1a1a1a; --stage: #1f1f1f; --ink: #f0ede3;
    --pink: #ff2d90; --pink-text: #ff2d90; --acid: #d7ff00; --muted: #a7a7a7;
    --border: #7a776f; --rule-faint: #f0ede333; --error: #ff6b81; --success: #5fd38d;
    --line: #f0ede3; --band: #161616; --on-band: #f0ede3; --on-accent: #0b0b0b; --slate: #3a3a3a;
    --code-bg: #000000; --band-edge: #7a776f;
  }
}
@media (max-width: 849px) { :root { --gutter: 24px; } }
@media (max-width: 639px) { :root { --gutter: 20px; } }

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 16px; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font: 400 17px/1.6 var(--font-body); overflow-wrap: break-word;
}
img, svg { max-width: 100%; }
a { color: var(--ink); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--pink-text); text-decoration-thickness: 2px; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3, h4, p, figure, dl, dd { margin: 0; }
:is(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
  outline: 3px solid var(--line); outline-offset: 4px; box-shadow: var(--focus-halo);
}
.sr-only {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip {
  position: absolute; left: var(--space-4); top: -60px; z-index: 100; background: var(--acid);
  color: var(--on-accent); padding: 10px 14px; border: 2px solid var(--line); font-weight: 800;
}
.skip:focus { top: var(--space-4); }

/* ── Meta text ─────────────────────────────── */
.eyebrow {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  font: 700 11px/1.5 var(--font-meta); letter-spacing: .065em; text-transform: uppercase;
}
.eyebrow--dot { display: block; }
.eyebrow--dot::before {
  content: ""; display: inline-block; width: 8px; height: 8px; margin-right: 8px; vertical-align: 1px;
  border-radius: 50%; background: var(--pink-text);
}
.serial { font: 400 10px/1.5 var(--font-meta); letter-spacing: .04em; text-transform: uppercase; }
.period { color: var(--pink-text); }
.muted { color: var(--muted); }
.tag {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 8px;
  border: 1px solid var(--border); font: 700 10px/1.4 var(--font-meta);
  letter-spacing: .06em; text-transform: uppercase; white-space: nowrap;
}
.tag--acid { background: var(--acid); color: var(--on-accent); border-color: var(--line); }
.tag--pink { background: var(--pink); color: var(--on-accent); border-color: var(--line); }
.tag--ink { background: var(--band); color: var(--on-band); border-color: var(--band); }
.tag--ok { color: var(--success); border-color: var(--success); }
.sticker {
  --g-bg: var(--acid); --g-bd: var(--line); display: inline-block; color: var(--on-accent);
  padding: 3px 8px; font: 700 10px/1.3 var(--font-meta); text-transform: uppercase;
  letter-spacing: .04em; transform: rotate(-2deg); white-space: nowrap;
}
.sticker--pink { --g-bg: var(--pink); }
.sticker--ink { --g-bg: var(--band); --g-bd: var(--band-edge); color: var(--on-band); }
.sticker--big { font: 900 19px/.95 var(--font-display); letter-spacing: -.02em; padding: 12px 16px; --g-sh: var(--shadow-button); }

/* ── Buttons (hand-cut grunge kit) ─────────── */
.btn {
  --g-bg: var(--surface); --g-bd: var(--line); --g-sh: var(--shadow-button);
  position: relative; isolation: isolate; display: inline-flex; align-items: center; justify-content: center;
  gap: 10px; min-height: var(--target); padding: 12px 20px; border: 0; background: none; color: var(--ink);
  font: 800 15px/1.2 var(--font-body); text-decoration: none; cursor: pointer; text-align: center;
  transition: transform var(--press) var(--ease);
}
.btn::before {
  content: ""; position: absolute; inset: 0; z-index: -1; pointer-events: none; background: var(--g-bg);
  border: var(--stroke-frame) solid var(--g-bd); border-radius: 3px; box-shadow: var(--g-sh); filter: url(#am-grit);
}
.btn:hover { color: inherit; --g-sh: var(--shadow-button-hover); }
.btn:active { --g-sh: none; transform: translate(2px, 2px); }
.btn--primary { --g-bg: var(--pink); color: var(--on-accent); }
.btn--primary:hover { color: var(--on-accent); }
.btn--acid { --g-bg: var(--acid); color: var(--on-accent); }
.btn--acid:hover { color: var(--on-accent); }
.btn--ink { --g-bg: var(--band); --g-bd: var(--band); color: var(--on-band); }
.btn--ink:hover { color: var(--on-band); }
.btn--ghost {
  --g-bg: transparent; --g-bd: transparent; --g-sh: none; text-decoration: underline;
  text-decoration-thickness: 2px; text-underline-offset: 5px; padding-inline: 4px;
}
.btn--ghost:hover { --g-bg: var(--rule-faint); }
.btn--danger { --g-bg: var(--error); color: var(--paper); }
.btn--danger:hover { color: var(--paper); }
.btn--sm { min-height: var(--target-min); padding: 8px 14px; font-size: 13px; gap: 7px; }
.btn[aria-pressed="true"] { --g-bg: var(--acid); color: var(--on-accent); }
.btn:disabled { opacity: .45; cursor: not-allowed; --g-sh: none; }
.btn .glyph { font-weight: 400; }
.on-band .btn { --g-bd: var(--on-band); }
@media (forced-colors: active) { .btn::before { filter: none; border-color: ButtonText; } }

.link-btn {
  display: inline-flex; align-items: center; gap: 6px; min-height: var(--target-min); padding: 6px 0;
  border: 0; background: none; color: var(--ink); font: 700 14px/1.3 var(--font-body);
  text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 4px; cursor: pointer;
}
.link-btn:hover { color: var(--pink-text); text-decoration-thickness: 2px; }

/* ── Page frame ───────────────────────────── */
.edition {
  background: var(--band); color: var(--on-band); display: flex; flex-wrap: wrap; justify-content: space-between;
  gap: 4px 24px; padding: 10px var(--gutter); font: 11px/1.5 var(--font-meta); letter-spacing: .04em; text-transform: uppercase;
}
.edition .star { color: var(--acid); }
.masthead {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 32px;
  padding: 14px var(--gutter); border-bottom: var(--stroke-frame) solid var(--line);
}
.brand { display: inline-flex; flex-direction: column; gap: 3px; text-decoration: none; color: var(--ink); padding: 4px 0; }
.brand:hover { color: var(--ink); }
.brand__word { font: 900 30px/.9 var(--font-display); letter-spacing: -.06em; text-transform: uppercase; }
.brand__turn { font: italic 400 17px/1.1 var(--font-editorial); color: var(--pink-text); }
.mainnav { display: flex; flex-wrap: wrap; align-items: center; gap: 0 26px; }
.mainnav a {
  display: inline-flex; align-items: center; min-height: var(--target); text-decoration: none; color: var(--ink);
  font-size: 14px; font-weight: 700; border-bottom: var(--stroke-frame) solid transparent;
}
.mainnav a[aria-current="page"] { border-bottom-color: var(--pink-text); }
.mainnav a:hover { border-bottom-color: var(--border); color: var(--ink); }
.theme-toggle { font: 12px/1.2 var(--font-meta); }
.page { max-width: var(--max-width); margin: 0 auto; padding: var(--space-7) var(--gutter) var(--space-8); }
.page:focus { outline: none; }
.footer {
  border-top: var(--stroke-frame) solid var(--line); padding: 20px var(--gutter); display: flex; flex-wrap: wrap;
  justify-content: space-between; gap: 8px 32px; font: 11px/1.6 var(--font-meta); letter-spacing: .04em;
  text-transform: uppercase; color: var(--muted);
}
@media (max-width: 639px) {
  #edition-left { display: none; }
  .masthead { padding-block: 8px; gap: 0 24px; }
  .brand__word { font-size: 24px; }
  .brand__turn { font-size: 15px; }
  .mainnav { gap: 0 16px; }
  .mainnav a { font-size: 15px; }
  .page { padding-top: var(--space-5); }
}

/* ── Headings and text ─────────────────────── */
.display {
  font: 900 clamp(36px, 5.4vw, 58px)/1.03 var(--font-display); letter-spacing: -.05em; text-wrap: balance;
  text-shadow: var(--print-offset) 0 var(--pink);
}
.h2 { font: 800 clamp(26px, 3.4vw, 36px)/1.1 var(--font-body); letter-spacing: -.04em; text-wrap: balance; }
.h2 em, .display em { font-family: var(--font-editorial); font-weight: 400; color: var(--pink-text); }
.h3 { font: 700 21px/1.15 var(--font-body); letter-spacing: -.025em; }
.deck { font-size: clamp(18px, 2vw, 21px); line-height: 1.45; letter-spacing: -.02em; color: var(--muted); max-width: 62ch; }
.section-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 10px 32px; margin-bottom: var(--space-5); }
.section-head p { font-size: 14px; color: var(--muted); max-width: 48ch; }
.stack { display: flex; flex-direction: column; gap: var(--space-5); }
.stack-lg { display: flex; flex-direction: column; gap: var(--space-7); }
.row { display: flex; flex-wrap: wrap; gap: var(--space-4); align-items: center; }

/* Long-form reading */
.prose { max-width: 70ch; font-size: 18px; line-height: 1.68; }
.prose > * + * { margin-top: 1em; }
.prose h2 { font: 800 28px/1.15 var(--font-body); letter-spacing: -.035em; margin-top: 1.8em; }
.prose h3 { font: 700 21px/1.2 var(--font-body); letter-spacing: -.025em; margin-top: 1.6em; }
.prose ul, .prose ol { padding-left: 1.4em; }
.prose li + li { margin-top: .45em; }
.prose code, .inline-code {
  font: 400 .9em/1.4 var(--font-meta); background: var(--surface); border: 1px solid var(--rule-faint);
  padding: .05em .3em; border-radius: var(--radius-control); overflow-wrap: anywhere;
}
.prose strong { font-weight: 800; }
.prose a.ext::after, a.ext::after { content: " ↗"; font-size: .85em; }
@media (max-width: 639px) { .prose { font-size: 17px; } }

.file-ref { font-weight: 700; }
.file-ref__path { display: inline-block; font: 400 12px/1.4 var(--font-meta); color: var(--muted); }

/* Unicode math inside prose */
.m { font-family: var(--font-editorial); font-size: 1.05em; white-space: nowrap; letter-spacing: .01em; }
.m i { font-style: italic; }
.m sub, .m sup, .prose sub, .prose sup { font-size: .72em; line-height: 0; }
math { font-family: var(--font-math); font-size: 1.12em; }
math[display="block"] { font-size: 1.5em; overflow-x: auto; overflow-y: hidden; padding: 6px 0; }

/* Symbol buttons inside text */
.sym {
  display: inline; padding: 0 1px; margin: 0; border: 0; background: none; color: inherit; font: inherit;
  cursor: help; border-bottom: 2px dotted var(--pink-text); line-height: inherit;
}
.sym:hover { background: var(--rule-faint); }
.sym[aria-expanded="true"] { background: var(--acid); color: var(--on-accent); }
.mcs-ref {
  display: inline; padding: 0 2px; border: 0; background: none; color: inherit; font: inherit; cursor: pointer;
  border-bottom: 2px dotted var(--border); line-height: inherit;
}
.mcs-ref:hover { background: var(--rule-faint); }

/* ── Cards and plates ──────────────────────── */
.card { background: var(--surface); border: 1px solid var(--border); padding: var(--space-5); min-width: 0; }
.plate { background: var(--surface); border: 2px solid var(--line); box-shadow: var(--shadow-hard); padding: var(--space-5); min-width: 0; }
.band { background: var(--band); color: var(--on-band); padding: var(--space-6) var(--space-5); min-width: 0; }
.band .muted, .band .meter__note { color: var(--muted-on-ink); }
.grid { display: grid; gap: var(--space-5); grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr)); }
.grid--tight { gap: var(--space-4); grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)); }

/* Home */
.desk { display: flex; flex-wrap: wrap; gap: var(--space-6); align-items: stretch; }
.desk__main { flex: 999 1 560px; min-width: 0; display: flex; flex-direction: column; gap: 18px; }
.desk__side { flex: 1 1 300px; min-width: 0; }
.next { display: flex; flex-direction: column; gap: 14px; margin-top: 6px; }
.next h2 { font: 800 27px/1.12 var(--font-body); letter-spacing: -.035em; }
.meter { display: flex; flex-direction: column; gap: 7px; }
.meter + .meter { margin-top: 20px; }
.meter__top { display: flex; justify-content: space-between; gap: 12px; font-size: 14px; font-weight: 700; }
.meter__num { font-family: var(--font-meta); white-space: nowrap; }
.meter__bar { height: 12px; border: 2px solid var(--on-band); }
.meter__fill { height: 100%; background: var(--pink); }
.meter__note { font-size: 13px; line-height: 1.5; }
.begin li { display: flex; flex-direction: column; gap: 10px; }
.begin { list-style: none; margin: 0; padding: 0; }
.begin strong { font-size: 18px; line-height: 1.25; letter-spacing: -.02em; }

/* Route grid */
.route-card { background: var(--surface); border: 1px solid var(--border); min-width: 0; }
.route-card__head {
  display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 14px 18px 10px;
  border-bottom: 2px solid var(--line);
}
.route-card__head strong { font: 800 20px/1.1 var(--font-body); letter-spacing: -.025em; }
.route-card ul { list-style: none; margin: 0; padding: 0; }
.route-card li + li { border-top: 1px solid var(--rule-faint); }
.week-link {
  display: flex; gap: 12px; align-items: flex-start; padding: 11px 18px; min-height: var(--target);
  text-decoration: none; color: var(--ink);
}
.week-link:hover { background: var(--rule-faint); color: var(--ink); }
.week-link__n { font: 700 13px/1.5 var(--font-meta); min-width: 22px; padding-top: 1px; }
.week-link__t { flex: 1 1 auto; font-size: 14px; line-height: 1.4; }
.week-link__s { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; flex: none; }
.week-link[aria-current="true"] { background: var(--paper); box-shadow: inset 0 0 0 2px var(--line); }

.shelf-card {
  display: flex; flex-direction: column; gap: 6px; padding: 16px 18px; background: var(--surface);
  border: 2px solid var(--line); text-decoration: none; color: var(--ink); min-height: 88px;
}
.shelf-card:hover { color: var(--ink); box-shadow: var(--shadow-button); }
.shelf-card strong { font-size: 17px; line-height: 1.2; letter-spacing: -.02em; }
.shelf-card span:last-child { font-size: 13px; color: var(--muted); }

/* ── Week layout ───────────────────────────── */
.crumbs { font-size: 13px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: var(--space-4); }
.crumbs a { color: var(--muted); }
.week-head { display: flex; flex-direction: column; gap: 14px; margin-bottom: var(--space-6); }
.week-head__facts { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.week-layout { display: flex; flex-wrap: wrap; gap: var(--space-7); align-items: flex-start; }
.rail { flex: 1 1 250px; min-width: 0; position: sticky; top: 16px; }
.rail ol { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.rail a {
  display: flex; gap: 12px; align-items: flex-start; padding: 10px 12px; min-height: var(--target);
  text-decoration: none; color: var(--ink); border: 2px solid transparent;
}
.rail a:hover { background: var(--rule-faint); color: var(--ink); }
.rail a[aria-current="step"] { border-color: var(--line); background: var(--surface); }
.rail__n { font: 700 13px/1.5 var(--font-meta); min-width: 20px; }
.rail__l { flex: 1 1 auto; font-size: 14px; line-height: 1.35; font-weight: 700; }
.rail__short { display: none; }
.rail__done { font: 700 13px/1.5 var(--font-meta); color: var(--success); }
.rail__note { margin-top: 12px; font-size: 13px; line-height: 1.5; color: var(--muted); }
.week-main { flex: 999 1 640px; min-width: 0; display: flex; flex-direction: column; gap: var(--space-6); }
.step-head { display: flex; flex-direction: column; gap: 10px; }
.step-foot {
  display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 16px;
  border-top: 2px solid var(--line); padding-top: var(--space-5); margin-top: var(--space-4);
}
.step-foot__done { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.step-foot__nav { display: flex; flex-wrap: wrap; gap: 12px; }
@media (max-width: 949px) {
  .week-layout { gap: var(--space-5); }
  .rail { position: static; flex-basis: 100%; }
  .rail ol { flex-direction: row; overflow-x: auto; gap: 6px; padding-bottom: 6px; scrollbar-width: thin; }
  .rail li { flex: none; }
  .rail a { padding: 8px 10px; gap: 6px; }
  .rail__l { display: none; }
  .rail__short { display: inline; font-size: 13px; font-weight: 700; }
  .rail__note { display: none; }
}

.facts { display: grid; grid-template-columns: minmax(130px, max-content) 1fr; gap: 8px 20px; font-size: 15px; }
.facts dt { font: 700 11px/1.9 var(--font-meta); letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
@media (max-width: 639px) { .facts { grid-template-columns: 1fr; gap: 2px; } .facts dd + dt { margin-top: 10px; } }
.outcome { font-size: 20px; line-height: 1.45; letter-spacing: -.015em; }

/* Notices and source labels */
.supp-note {
  display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: baseline; font-size: 13px; color: var(--muted);
  border-top: 1px solid var(--rule-faint); padding-top: 10px;
}
.notice { border: 2px solid var(--line); background: var(--surface); padding: 14px 16px; font-size: 15px; }
.notice--warn { border-color: var(--error); color: var(--ink); }
.notice--warn strong { color: var(--error); }
.from-lesson {
  margin: 0; padding: 10px 14px; background: var(--paper); border: 1px dashed var(--border);
  font-size: 15px; line-height: 1.5;
}
.from-lesson .eyebrow { margin-bottom: 4px; color: var(--muted); }

/* Formula cards */
.formula { background: var(--surface); border: 2px solid var(--line); box-shadow: var(--shadow-hard); min-width: 0; }
.formula__head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px 16px; padding: 12px 20px; border-bottom: 1px solid var(--rule-faint); }
.formula__body { display: flex; flex-wrap: wrap; gap: 20px 40px; padding: 22px 24px; align-items: center; }
.formula__math { flex: 1 1 300px; min-width: 0; text-align: center; overflow-x: auto; }
.formula__words { flex: 1 1 300px; min-width: 0; display: flex; flex-direction: column; gap: 10px; }
.formula__say { font: italic 400 17px/1.45 var(--font-editorial); }
.formula__syms { display: flex; flex-wrap: wrap; gap: 8px; padding: 0 24px 22px; margin: 0; list-style: none; }
.formula__syms li {
  display: inline-flex; gap: 10px; align-items: baseline; padding: 6px 12px; background: var(--paper);
  border: 1px solid var(--border); border-radius: var(--radius-control); font-size: 14px; line-height: 1.35; min-width: 0;
}
.formula__syms math { font-size: 1.2em; }
.formula .from-lesson { margin: 0 24px 22px; }

/* Worked steps */
.worked { border-top: 2px solid var(--line); list-style: none; margin: 0; padding: 0; }
.worked li { display: grid; grid-template-columns: 74px minmax(0, 1fr); gap: 4px 20px; padding: 18px 0; border-bottom: 1px solid var(--rule-faint); }
.worked__n { font: 700 11px/2 var(--font-meta); letter-spacing: .06em; text-transform: uppercase; }
.worked__math { font-size: 1.15em; overflow-x: auto; }
.worked__math math { font-size: 1.12em; }
.worked__math > div + div { margin-top: 2px; }
[data-scrolls] { outline-offset: 2px; }
.worked__why { color: var(--muted); font-size: 16px; grid-column: 2; }
.worked li[hidden] { display: none; }
@media (max-width: 639px) { .worked li { grid-template-columns: 1fr; } .worked__why { grid-column: 1; } }

/* Code */
.codebox { min-width: 0; margin: 1.2em 0; font-size: 16px; }
.prose .codebox { max-width: none; }
.codebox__bar {
  display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px 16px;
  background: var(--band); color: var(--on-band); padding: 6px 8px 6px 14px; border: 2px solid var(--band);
}
:root[data-theme="dark"] .codebox__bar { border-color: var(--border); }
.codebox__label { font: 700 11px/1.5 var(--font-meta); letter-spacing: .06em; text-transform: uppercase; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.codebox__label .path { text-transform: none; letter-spacing: .02em; font-weight: 400; }
.codebox pre {
  margin: 0; background: var(--code-bg); color: var(--code-ink); padding: 16px 0; overflow-x: auto;
  font: 400 15px/1.65 var(--font-meta); border: 2px solid var(--band); border-top: 0; tab-size: 4;
}
:root[data-theme="dark"] .codebox pre { border-color: var(--border); }
.codebox pre code { display: block; min-width: max-content; padding: 0 18px; background: none; border: 0; font: inherit; }
.codebox--lines pre code { padding-left: 0; }
.ln { display: block; padding-right: 18px; }
.ln::before {
  content: attr(data-n); display: inline-block; width: 3.2em; padding-right: 1.2em; text-align: right;
  color: #8a867d; user-select: none; -webkit-user-select: none;
}
@media (max-width: 639px) {
  .codebox pre { font-size: 13.5px; }
  .ln::before { width: 2.2em; padding-right: .9em; }
  .codebox__bar { padding-left: 10px; }
}
.ln--todo { background: rgba(255, 45, 144, .2); box-shadow: inset 4px 0 0 var(--pink); }
.codebox--exercise pre { border-style: dashed; border-color: var(--pink); }
.codebox--exercise .codebox__bar { border-color: var(--pink); }
.codebox__note { font-size: 14px; line-height: 1.5; padding: 10px 14px; background: var(--surface); border: 1px solid var(--border); border-top: 0; }
.codebox--output pre { color: var(--acid); }
.tok-kw { color: var(--code-kw); font-weight: 700; }
.tok-ty { color: var(--code-ty); }
.tok-str { color: var(--code-str); }
.tok-num { color: var(--code-num); font-weight: 700; }
.tok-com { color: var(--code-com); font-style: italic; }
.tok-mac { color: var(--code-mac); font-weight: 700; }
.tok-attr { color: var(--code-com); }
.tok-fn { color: var(--code-ink); font-weight: 700; }
.copy { --g-bg: var(--surface); --g-bd: var(--on-band); color: var(--ink); }
.copy:hover { color: var(--ink); }

.explain { border: 1px solid var(--border); border-top: 0; background: var(--surface); }
.explain > summary {
  cursor: pointer; padding: 12px 14px; min-height: var(--target); font-weight: 800; font-size: 15px;
  list-style-position: inside;
}
.explain ol { list-style: none; margin: 0; padding: 0 14px 14px; }
.explain > ol > li { padding: 10px 0; border-top: 1px solid var(--rule-faint); }
.explain__code {
  display: block; font: 400 14px/1.5 var(--font-meta); background: var(--code-bg); color: var(--code-ink);
  padding: 6px 10px; overflow-x: auto; white-space: pre;
}
.explain__terms { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; font-size: 15px; line-height: 1.5; }
.explain__terms code { font: 700 14px var(--font-meta); background: var(--paper); padding: 0 4px; border: 1px solid var(--rule-faint); }
.explain__src { font: 10px/1.5 var(--font-meta); text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin-left: 6px; white-space: nowrap; }
.explain__comment { font-size: 15px; margin-top: 6px; color: var(--muted); }

/* Practice */
.drill { display: flex; flex-direction: column; gap: 12px; }
.drill__q { font-weight: 700; font-size: 18px; line-height: 1.5; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label, .label { font-size: 12px; font-weight: 700; }
.input, textarea.input, select.input {
  display: block; width: 100%; min-height: var(--target); padding: 11px 12px; border: 1px solid var(--border);
  border-radius: var(--radius-control); background: var(--surface); color: var(--ink); font-size: 16px; line-height: 1.5;
}
textarea.input { min-height: 96px; resize: vertical; }
.hint { font-size: 12px; color: var(--muted); }
.reveal { border: 2px solid var(--line); background: var(--surface); }
.reveal > summary {
  cursor: pointer; display: flex; align-items: center; gap: 10px; min-height: var(--target); padding: 10px 16px;
  font-weight: 800; font-size: 15px; list-style: none;
}
.reveal > summary::-webkit-details-marker { display: none; }
.reveal > summary::before { content: "↓"; font-weight: 400; }
.reveal[open] > summary::before { content: "↑"; }
.reveal[open] > summary { border-bottom: 1px solid var(--rule-faint); }
.reveal__body { padding: 14px 18px 16px; }
.reveal__body > * + * { margin-top: .8em; }
.prose .reveal { margin-top: 1em; }

/* Checklists */
.checks { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.check { display: flex; gap: 14px; align-items: flex-start; padding: 10px 12px; border: 1px solid transparent; cursor: pointer; min-height: var(--target); }
.check:hover { background: var(--rule-faint); }
.check input { appearance: none; -webkit-appearance: none; flex: none; width: 24px; height: 24px; margin: 1px 0 0; border: 2px solid var(--line); background: var(--surface); display: grid; place-items: center; cursor: pointer; border-radius: var(--radius-control); }
.check input::after { content: "✓"; font: 800 15px/1 var(--font-body); color: var(--on-accent); opacity: 0; }
.check input:checked { background: var(--acid); }
.check input:checked::after { opacity: 1; }
.check span { font-size: 16px; line-height: 1.5; }
.radios { display: flex; flex-wrap: wrap; gap: 8px; border: 0; padding: 0; margin: 0; }
.radios legend { font-size: 12px; font-weight: 700; margin-bottom: 8px; padding: 0; }
.radio { position: relative; }
.radio input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.radio span {
  display: inline-flex; align-items: center; min-height: var(--target-min); padding: 8px 14px; border: 2px solid var(--line);
  background: var(--surface); font: 700 13px/1.2 var(--font-meta); text-transform: uppercase; letter-spacing: .04em;
}
.radio input:checked + span { background: var(--acid); color: var(--on-accent); }
.radio input:checked + span::before { content: "✓ "; }
.radio input:focus-visible + span { outline: 3px solid var(--line); outline-offset: 4px; box-shadow: var(--focus-halo); }

/* Tables */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); background: var(--surface); max-width: 100%; }
.prose .table-wrap { margin-top: 1.2em; }
table { border-collapse: collapse; width: 100%; font-size: 15px; line-height: 1.45; }
th, td { text-align: left; vertical-align: top; padding: 10px 14px; border-bottom: 1px solid var(--rule-faint); }
th { font: 700 11px/1.5 var(--font-meta); letter-spacing: .06em; text-transform: uppercase; border-bottom: 2px solid var(--line); background: var(--paper); }
td code { white-space: nowrap; }
.prose td code { white-space: normal; }
tr[hidden] { display: none; }

/* Task lists rendered from Markdown (non-interactive copies) */
.prose ul.tasks { list-style: none; padding-left: 0; }
.task { display: flex; gap: 10px; align-items: flex-start; }
.task__box { flex: none; width: 20px; height: 20px; border: 2px solid var(--line); margin-top: 4px; display: grid; place-items: center; font-size: 12px; }

/* Popover, drawer, dialogs, toast */
.pop {
  position: absolute; z-index: 60; width: min(360px, calc(100vw - 32px)); background: var(--surface);
  border: 2px solid var(--line); box-shadow: var(--shadow-hard); padding: 16px 18px 18px;
  display: flex; flex-direction: column; gap: 10px; font-size: 15px; line-height: 1.5;
}
.pop[hidden] { display: none; }
.pop:focus { outline: none; }
.pop__top { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.pop__glyph { font: 400 40px/1 var(--font-editorial); }
.pop__say { font-size: 18px; font-weight: 800; letter-spacing: -.02em; }
.pop dl { display: flex; flex-direction: column; gap: 8px; }
.pop dt { font: 700 10px/1.5 var(--font-meta); letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.pop code { font: .92em var(--font-meta); background: var(--paper); padding: 0 3px; }
.icon-btn {
  flex: none; width: var(--target-min); height: var(--target-min); display: grid; place-items: center; border: 2px solid var(--line);
  background: transparent; color: var(--ink); font: 700 18px/1 var(--font-body); cursor: pointer; border-radius: var(--radius-control);
}
.icon-btn:hover { background: var(--rule-faint); }
@media (max-width: 639px) {
  .pop { position: fixed; left: 0 !important; right: 0; bottom: 0; top: auto !important; width: auto; border-width: 2px 0 0; box-shadow: 0 -4px 0 var(--line); max-height: 70vh; overflow-y: auto; padding-bottom: 28px; }
}

dialog { color: var(--ink); }
.drawer {
  margin: 0 0 0 auto; height: 100%; max-height: 100%; width: min(760px, 100%); max-width: 100%; padding: 0;
  border: 0; border-left: 2px solid var(--line); background: var(--paper); box-shadow: -6px 0 0 var(--line);
}
.drawer::backdrop { background: rgba(21, 21, 21, .45); }
.drawer__bar {
  position: sticky; top: 0; z-index: 2; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: 8px 16px; padding: 10px 20px; background: var(--band); color: var(--on-band);
}
.drawer__bar .icon-btn { border-color: var(--on-band); color: var(--on-band); }
.drawer__bar .icon-btn:hover { background: #ffffff22; }
.drawer__body { padding: 24px 28px 64px; }
.drawer__actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.drawer__actions .btn--ghost { color: var(--on-band); }
@media (max-width: 639px) { .drawer { width: 100%; border-left: 0; box-shadow: none; } .drawer__body { padding: 20px var(--gutter) 64px; } }

.modal { max-width: min(520px, calc(100vw - 32px)); padding: 0; border: 2px solid var(--line); box-shadow: var(--shadow-hard); background: var(--surface); }
.modal::backdrop { background: rgba(21, 21, 21, .45); }
.modal form { padding: 24px; display: flex; flex-direction: column; gap: 16px; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 90; background: var(--band); color: var(--on-band);
  padding: 12px 18px; border: 2px solid var(--acid); box-shadow: 4px 4px 0 var(--pink); font-size: 14px; max-width: calc(100vw - 32px);
}
.toast[hidden] { display: none; }
.status { font-size: 13px; color: var(--muted); min-height: 1.4em; }

.local { border: 1px solid var(--border); background: var(--surface); }
.local__head { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; justify-content: space-between; padding: 12px 16px; border-bottom: 1px solid var(--rule-faint); }
.local__body { padding: 12px 16px 16px; display: flex; flex-direction: column; gap: 10px; font-size: 15px; }
.local code, .path { font: 400 13px/1.5 var(--font-meta); overflow-wrap: anywhere; }
.local ul { margin: 0; padding-left: 1.2em; }

.toc { font-size: 14px; }
.toc ol { margin: 8px 0 0; padding-left: 1.2em; }
.doc-layout { display: flex; flex-wrap: wrap; gap: var(--space-7); align-items: flex-start; }
.doc-layout .prose { flex: 999 1 640px; min-width: 0; }
.doc-layout .toc { flex: 1 1 220px; position: sticky; top: 16px; }
@media (max-width: 949px) { .doc-layout .toc { position: static; flex-basis: 100%; } }

.progress-table td:first-child, .progress-table th:first-child { white-space: nowrap; }
.num { font-family: var(--font-meta); white-space: nowrap; }
.row:has(#import-file:focus-visible) label[for="import-file"] { outline: 3px solid var(--line); outline-offset: 4px; box-shadow: var(--focus-halo); }
.danger-zone { border: 2px solid var(--error); padding: var(--space-5); background: var(--surface); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0ms !important; animation-duration: 0ms !important; scroll-behavior: auto !important; }
}
@media (forced-colors: active) { .meter__fill { background: Highlight; } .sticker, .tag--acid { border: 2px solid CanvasText; } }
@media print {
  .edition, .masthead, .rail, .step-foot, .footer, .copy, .theme-toggle { display: none !important; }
  .codebox pre { white-space: pre-wrap; }
}

/* ══════════ Zine layer ══════════
   Hand-cut pieces from the Automagical Machines system: icons (am-ink),
   grit paint layers (am-grit), tiles, seals, tape, quotes, ticker, orbits,
   backdrops and stamps. Wild at the edges; lesson text stays clean. */

/* Grit paint layer: fill, frame and hard shadow on ::before, text above it. */
.gk { position: relative; isolation: isolate; }
.gk::before {
  content: ""; position: absolute; inset: 0; z-index: -1; pointer-events: none; background: var(--g-bg, transparent);
  border: var(--g-bw, var(--stroke-frame)) solid var(--g-bd, transparent); border-radius: var(--g-r, 3px);
  box-shadow: var(--g-sh, none); filter: url(#am-grit);
}
@media (forced-colors: active) { .gk::before { filter: none; border-color: CanvasText; } }

/* Icons */
.am-icon { width: 1.25em; height: 1.25em; display: inline-block; flex: none; vertical-align: -.25em; overflow: visible; }
.am-icon .a, .am-icon .af { fill: none; stroke: none; }
.am-icon .as { fill: none; }
.am-icon .f { fill: currentColor; stroke: none; }
.am-icon .af { fill: currentColor; }
.am-icon .tooth { stroke-width: 3.4; stroke-linecap: butt; }
.am-icon--duo { --am-icon-accent: var(--pink); }
.am-icon--duo .a, .am-icon--duo .as { fill: var(--am-icon-accent); }
.am-icon--duo .af { fill: var(--am-icon-accent); stroke: currentColor; stroke-width: 1.2; }
.mainnav a .am-icon { width: 18px; height: 18px; margin-right: 7px; color: var(--pink-text); }
.btn .am-icon { width: 1.25em; height: 1.25em; }

/* Icon tiles */
.tile {
  --g-bg: var(--band); --g-bd: var(--band-edge); --g-r: var(--radius-card); display: inline-grid; place-items: center;
  width: var(--tile, 48px); height: var(--tile, 48px); color: var(--pink); font-size: calc(var(--tile, 48px) * .5); flex: none;
}
.tile .am-icon { width: 1.1em; height: 1.1em; }
.tile--acid { --g-bg: var(--acid); --g-bd: var(--line); color: var(--on-accent); }
.tile--pink { --g-bg: var(--pink); --g-bd: var(--line); color: var(--on-accent); }
.tile--paper { --g-bg: var(--surface); --g-bd: var(--line); color: var(--ink); }
.tile--round { --g-r: 50%; }

/* Seal badges */
.seal { position: relative; display: inline-block; flex: none; width: var(--seal); height: var(--seal); transform: rotate(-2deg); }
.seal svg { width: 100%; height: 100%; display: block; overflow: visible; }
.seal__bg { fill: var(--band); stroke: var(--pink); stroke-width: 4; }
.seal__ring { fill: none; stroke: var(--pink); stroke-width: 3; }
.seal__txt { fill: var(--on-band); font: 700 12px var(--font-meta); letter-spacing: .06em; }
.seal__mid { position: absolute; inset: 0; display: grid; place-items: center; color: var(--on-band); }
.seal__mid .am-icon { width: 36%; height: 36%; --am-icon-accent: var(--pink); }
.seal__num { font: 900 calc(var(--seal) * .17)/1 var(--font-display); letter-spacing: -.05em; text-align: center; max-width: 62%; }
.seal--acid .seal__bg { fill: var(--acid); stroke: var(--line); }
.seal--acid .seal__ring { stroke: var(--line); }
.seal--acid .seal__txt { fill: var(--on-accent); }
.seal--acid .seal__mid { color: var(--on-accent); }
.seal--paper .seal__bg { fill: var(--surface); stroke: var(--line); }
.seal--paper .seal__ring { stroke: var(--line); }
.seal--paper .seal__txt { fill: var(--ink); }
.seal--paper .seal__mid { color: var(--ink); }
.seal--accent .seal__bg { fill: var(--pink); stroke: var(--line); }
.seal--accent .seal__ring { stroke: var(--line); }
.seal--accent .seal__txt { fill: var(--on-accent); }
.seal--accent .seal__mid { color: var(--on-accent); }
.seal--accent .seal__mid .am-icon { --am-icon-accent: var(--acid); }

/* Brush tape (marker face: decoration and shouts only, never controls) */
.tape {
  display: inline-flex; align-items: center; gap: 10px; min-height: 40px; padding: 8px 20px 8px 16px;
  font: 400 18px/1 var(--font-marker); text-transform: uppercase; color: var(--on-accent); background: var(--pink);
  clip-path: polygon(0 8%, 4% 0, 30% 6%, 58% 0, 88% 5%, 100% 0, 98% 50%, 100% 100%, 70% 94%, 40% 100%, 12% 93%, 0 100%, 2% 50%);
  transform: rotate(-1deg); white-space: nowrap;
}
.tape .am-icon { width: 1em; height: 1em; }
.tape--acid { background: var(--acid); }
.tape--ink { background: var(--band); color: var(--on-band); }
.tape--ink .am-icon { color: var(--pink); }

/* Margin scrawl, registration marks, checker rule */
.scrawl { display: inline-block; font: italic 400 23px/1.1 var(--font-editorial); color: var(--pink-text); transform: rotate(-2deg); }
.reg { display: flex; gap: 10px; align-items: center; font: 9px/1.5 var(--font-meta); letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.checker-rule {
  height: 14px; border-block: 2px solid var(--line);
  background-image: repeating-conic-gradient(var(--line) 0 25%, transparent 0 50%); background-size: 14px 14px;
}

/* Ticker strip (static: no looping motion) */
.ticker {
  display: flex; flex-wrap: wrap; justify-content: space-around; align-items: center; gap: 8px 18px;
  padding: 14px var(--gutter); background: var(--pink); color: var(--on-accent); border-bottom: 2px solid var(--line);
  font: 900 19px/1.1 var(--font-display); letter-spacing: -.04em; text-transform: uppercase;
}
.ticker i { font-style: normal; font-size: 26px; line-height: 1; }
@media (max-width: 639px) { .ticker { font-size: 14px; gap: 4px 10px; justify-content: flex-start; padding-block: 10px; } .ticker i { font-size: 17px; } }

/* Quote cards on torn panels */
.quote {
  position: relative; margin: 0; padding: 26px 24px 22px 72px; background: var(--band); color: var(--on-band); min-height: 120px;
  font: 17px/1.5 var(--font-meta);
  clip-path: polygon(0 3%, 6% 0, 40% 4%, 75% 0, 100% 3%, 99% 50%, 100% 97%, 60% 100%, 25% 96%, 0 100%, 1% 50%);
}
.quote::before { content: "\201C"; position: absolute; left: 18px; top: 8px; font: 900 72px/1 var(--font-display); color: var(--pink); }
.quote blockquote { margin: 0; }
.quote figcaption { margin-top: 12px; color: var(--muted-on-ink); }
.quote--acid { background: var(--acid); color: var(--on-accent); }
.quote--pink { background: var(--pink); color: var(--on-accent); }
.quote--acid::before, .quote--pink::before { color: var(--on-accent); }
.quote--acid figcaption, .quote--pink figcaption { color: var(--on-accent); }
:root[data-theme="dark"] .quote--ink { box-shadow: inset 0 0 0 1px var(--border); }
@media (forced-colors: active) { .tape, .quote { clip-path: none; border: 2px solid CanvasText; } }

/* Backdrops (copy always sits on a plate above them) */
.halftone {
  background-color: var(--paper); padding: var(--space-6);
  background-image: radial-gradient(circle, var(--line) 1.2px, transparent 1.6px); background-size: 6px 6px;
}
@media (max-width: 639px) { .halftone { padding: 12px; } }

/* Home cover: desk beside a poster built from symbol, orbits and flares */
.cover { display: flex; flex-wrap: wrap; gap: var(--space-7) var(--space-6); align-items: flex-start; }
.cover__desk { flex: 1.5 1 480px; min-width: 0; display: flex; flex-direction: column; gap: 18px; }
.cover__art { flex: 1 1 340px; min-width: 0; max-width: 560px; }
.cover .scrawl { align-self: flex-end; margin-right: 12px; }
.poster { position: relative; margin: 22px 10px 0 16px; isolation: isolate; }
.poster .reg { position: absolute; top: -20px; left: 0; right: 0; justify-content: space-between; }
.poster__frame {
  position: relative; display: grid; place-items: center; min-height: 290px; padding: 56px 22px 64px; overflow: hidden;
  background: var(--band); color: var(--on-band); border: 2px solid var(--line); box-shadow: 8px 8px 0 var(--pink);
}
.poster__math { position: relative; z-index: 2; max-width: 100%; overflow-x: auto; color: var(--acid); text-align: center; }
.poster__math math { font-size: clamp(26px, 3vw, 38px); padding: 0; }
.poster__glyph { position: relative; z-index: 2; font: 900 150px/1 var(--font-display); color: var(--acid); }
.poster__tiles { position: absolute; top: 14px; right: 14px; z-index: 4; display: flex; gap: 8px; }
.poster__checker {
  position: absolute; left: 0; right: 0; bottom: 0; height: 18px; z-index: 1; border-top: 2px solid var(--on-band);
  background-image: repeating-conic-gradient(var(--on-band) 0 25%, transparent 0 50%); background-size: 18px 18px;
}
.poster .sticker { position: absolute; left: 12px; bottom: 24px; z-index: 5; }
.poster__bar {
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 12px; padding: 10px 12px; background: var(--band);
  color: var(--on-band); border: 2px solid var(--line); border-top: 0; font: 10px/1.5 var(--font-meta); letter-spacing: .04em; text-transform: uppercase;
}
.poster__say { margin: 0; padding: 12px 14px; background: var(--surface); border: 2px solid var(--line); border-top: 0; font: italic 17px/1.4 var(--font-editorial); }
.poster__say a { font: 700 13px/1.4 var(--font-body); font-style: normal; display: inline-block; margin-top: 6px; }
.orbit { position: absolute; z-index: 1; pointer-events: none; border: 2px solid var(--acid); border-radius: 50%; width: 82%; height: 24%; top: 38%; left: 9%; transform: rotate(-23deg); }
.orbit--two { border-color: var(--pink); top: 8%; left: 55%; width: 40%; height: 16%; transform: rotate(27deg); }
.flare { position: absolute; z-index: 3; line-height: 1; pointer-events: none; }
.flare--one { right: 16px; bottom: 22%; font-size: 56px; color: var(--pink); }
.flare--two { top: 12%; left: 16px; font-size: 44px; color: var(--acid); }
@media (max-width: 639px) {
  .poster { margin: 22px 6px 0 6px; }
  .poster__frame { min-height: 220px; }
  .poster__glyph { font-size: 110px; }
  .flare--one { font-size: 40px; }
  .poster .sticker--big { font-size: 15px; padding: 8px 10px; bottom: 18px; }
}

/* Progress seals */
.seals { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr)); gap: var(--space-5); }
.seal-stat { display: flex; gap: 16px; align-items: center; min-width: 0; }
.seal-stat__text { display: flex; flex-direction: column; gap: 6px; min-width: 0; font-size: 14px; line-height: 1.45; }
.seal-stat__text strong { font-size: 16px; }
.band .seal-stat__text span { color: var(--muted-on-ink); }

/* The punch card: 24 weeks at a glance */
.punch { background: var(--surface); border: 2px solid var(--line); box-shadow: var(--shadow-hard); padding: var(--space-5); }
.punch__groups { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 20px 26px; }
.punch__group { display: flex; flex-direction: column; gap: 8px; }
.punch__label { display: flex; gap: 6px; align-items: center; font: 700 10px/1.4 var(--font-meta); letter-spacing: .06em; text-transform: uppercase; }
.punch__label .am-icon { width: 18px; height: 18px; color: var(--pink-text); }
.punch__weeks { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.cell {
  position: relative; display: flex; flex-direction: column; justify-content: space-between; width: 58px; height: 66px; padding: 6px;
  color: var(--ink); text-decoration: none; background: var(--paper); border: 2px solid var(--line);
}
.cell:hover { color: var(--ink); box-shadow: var(--shadow-button); }
.cell__n { position: relative; z-index: 2; font: 900 22px/1 var(--font-display); letter-spacing: -.04em; }
.cell__steps { display: flex; gap: 2px; }
.cell__steps i { flex: 1; height: 6px; border: 1px solid currentColor; }
.cell__steps i.on { background: currentColor; }
.cell__mark { position: absolute; top: 3px; right: 5px; font: 700 13px/1 var(--font-body); }
.cell--studying { background: var(--acid); color: var(--on-accent); }
.cell--studying:hover { color: var(--on-accent); }
.cell--repair { border-style: dashed; border-color: var(--pink-text); }
.cell--ready { background: var(--band); color: var(--on-band); border-color: var(--band-edge); }
.cell--ready:hover { color: var(--on-band); }
.cell--ready .cell__mark { color: var(--acid); }
.cell--assessed { background: var(--pink); color: var(--on-accent); }
.cell--assessed:hover { color: var(--on-accent); }
.cell .orbit { width: 150%; height: 46%; left: -25%; top: 30%; border-color: var(--pink); transform: rotate(-18deg); z-index: 1; }
.legend { display: flex; flex-wrap: wrap; gap: 8px 18px; margin: 18px 0 0; padding: 0; list-style: none; font-size: 13px; }
.legend li { display: flex; gap: 8px; align-items: center; }
.legend i { width: 18px; height: 18px; border: 2px solid var(--line); background: var(--paper); flex: none; }
.legend .l-studying { background: var(--acid); }
.legend .l-repair { border-style: dashed; border-color: var(--pink-text); }
.legend .l-ready { background: var(--band); border-color: var(--band-edge); }
.legend .l-assessed { background: var(--pink); }
@media (max-width: 639px) { .cell { width: 48px; height: 58px; } .cell__n { font-size: 19px; } .punch { padding: 16px; } }

/* Three records flow */
.flow { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 32px; }
.flow li { position: relative; display: flex; flex-direction: column; gap: 10px; padding: 18px; background: var(--surface); border: 2px solid var(--line); box-shadow: var(--shadow-hard); }
.flow li + li::before { content: "→"; position: absolute; left: -30px; top: 32px; font: 900 26px/1 var(--font-display); }
.flow strong { font: 900 22px/1 var(--font-display); letter-spacing: -.03em; text-transform: uppercase; }
@media (max-width: 849px) {
  .flow { grid-template-columns: 1fr; gap: 34px; }
  .flow li + li::before { content: "↓"; left: 24px; top: -32px; }
}

/* Week numbers, step heads, rail icons, stats */
.week-head { position: relative; }
.week-head__top { display: flex; gap: 20px 28px; align-items: flex-start; }
.week-head__text { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 14px; }
.week-head .seal { margin-top: 4px; }
@media (max-width: 639px) { .week-head .seal { --seal: 76px !important; } }
.step-head { flex-direction: row; flex-wrap: wrap; align-items: center; gap: 12px 18px; }
.step-head__text { flex: 1 1 280px; min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.rail__ico { display: inline-grid; place-items: center; width: 26px; height: 26px; flex: none; margin-top: -2px; }
.rail__ico .am-icon { width: 20px; height: 20px; }
.rail a[aria-current="step"] .rail__ico { background: var(--acid); color: var(--on-accent); border-radius: 2px; }
.rail__done { display: inline-grid; place-items: center; }
.rail__done .seal { --seal: 26px !important; }
@media (max-width: 949px) { .rail__ico { width: 22px; height: 22px; } .rail__ico .am-icon { width: 18px; height: 18px; } }
.stats { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 132px), 1fr)); gap: 10px; }
.stat { display: flex; gap: 10px; align-items: center; padding: 10px; background: var(--surface); border: 1px solid var(--border); min-width: 0; }
.stat__n { display: block; font: 900 26px/1 var(--font-display); letter-spacing: -.04em; }
.stat__l { display: block; font: 700 10px/1.4 var(--font-meta); letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.tag .am-icon { width: 15px; height: 15px; }
.worked__n { display: inline-grid; place-items: center; width: 52px; height: 52px; --g-bg: var(--acid); --g-bd: var(--line); --g-r: 50%; color: var(--on-accent); line-height: 1.1; text-align: center; }
.step-stamp { display: inline-flex; }
.local__head .am-icon { color: var(--pink-text); }

/* Stamp: a 220ms press when a step is marked done (max 4px travel) */
@keyframes am-stamp { 0% { opacity: 0; transform: translate(4px, -4px) rotate(-8deg) scale(1.12); } 70% { opacity: 1; } 100% { opacity: 1; transform: rotate(-2deg); } }
.stamp-in { animation: am-stamp 220ms var(--ease) both; }

/* Edition bar issue chip */
.edition b { background: var(--pink); color: var(--on-accent); padding: 2px 6px; margin-left: 8px; font-weight: 700; }

/* Footer stack */
.footer__stack { display: flex; flex-direction: column; font: 700 11px/1.35 var(--font-meta); letter-spacing: .06em; color: var(--ink); }

/* Calm mode: quieter edges for long reading. Same content, same identity. */
.calm-toggle .dot { color: var(--pink-text); padding-left: 4px; }
:root[data-calm="true"] :is(.btn, .gk)::before { filter: none; }
:root[data-calm="true"] .seal g[filter], :root[data-calm="true"] .am-icon g { filter: none; }
:root[data-calm="true"] .display { text-shadow: none; }
:root[data-calm="true"] :is(.sticker, .scrawl, .tape, .seal) { transform: none; }
:root[data-calm="true"] .halftone { background-image: none; }
:root[data-calm="true"] .checker-rule { background-image: none; height: 0; border-bottom: 0; }
:root[data-calm="true"] .stamp-in { animation: none; }
@media (forced-colors: active) { .orbit, .flare, .poster__checker { display: none; } .display { text-shadow: none; } }
.shelf-card__top { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; }
.codebox__label .am-icon { color: var(--acid); }
.reveal > summary .am-icon { color: var(--pink-text); }
.route-card__head .am-icon { color: var(--pink-text); }
.step-head .tape { margin-left: auto; }
@media (max-width: 639px) { .step-head .tape { margin-left: 0; font-size: 15px; } .step-head .tile { --tile: 44px !important; } }

/* Calm goes all the way back to the plain reading layout: the zine pieces
   disappear and plain versions stand in wherever they carried information
   (meter numbers, the titled route list, ✓ marks, "Step 1" labels). */
.calm-only { display: none !important; }
:root[data-calm="true"] .calm-only { display: revert !important; }
:root[data-calm="true"] :is(.zine-only, #strip, .cover__art, .scrawl, .quote, .checker-rule, .seal, .tape, .tile,
  .am-icon, .rail__ico, .orbit, .flare, .reg, .footer__stack, .edition b, .step-stamp) { display: none !important; }
:root[data-calm="true"] .rail__check { color: var(--success); font: 700 13px/1.5 var(--font-meta); }
:root[data-calm="true"] .shelf-card__top { margin-bottom: 0; }
:root[data-calm="true"] .worked__n {
  display: block; width: auto; height: auto; --g-bg: transparent; --g-bd: transparent; color: var(--ink);
  font: 700 11px/2 var(--font-meta); letter-spacing: .06em; text-align: left;
}
:root[data-calm="true"] .worked__n .serial { display: inline; font: inherit; }
:root[data-calm="true"] .worked__n b { display: inline !important; font: inherit !important; margin-left: .35em; }
:root[data-calm="true"] .flow li { box-shadow: none; border-width: 1px; border-color: var(--border); }
:root[data-calm="true"] .flow strong { font: 700 18px/1.2 var(--font-body); letter-spacing: -.02em; text-transform: none; }
:root[data-calm="true"] .seal-stat__text { gap: 7px; }
/* The progress band sits under the cover in zine mode and beside the desk in Calm, as it used to. */
.cover > .band { flex: 1 1 100%; }
:root[data-calm="true"] .cover { align-items: stretch; gap: var(--space-6); }
:root[data-calm="true"] .cover > .band { flex: 1 1 300px; }
:root[data-calm="true"] .cover .seals { grid-template-columns: 1fr; gap: 20px; }
