/* ==========================================================================
   Mathbench — editorial print-inspired design system
   Palette is taken from the book's cover so the site and the PDF read as one
   product: navy #16305c, gold #c8a24a, ink on warm paper.
   Deliberately avoids: gradients-as-decoration, glassmorphism, blur, heavy
   drop shadows, emoji-as-iconography, pill buttons. Rules, not shadows.
   ========================================================================== */

:root {
  /* paper & ink */
  --paper:        #faf8f4;
  --paper-raised: #ffffff;
  --paper-sunk:   #f2efe8;
  --ink:          #16181d;
  --ink-soft:     #4a4f5a;
  --ink-faint:    #7c8290;

  /* brand — lifted from the book cover */
  --navy:         #16305c;
  --navy-deep:    #0f2244;
  --navy-wash:    #eef1f7;
  --gold:         #c8a24a;
  --gold-wash:    #faf4e6;

  /* semantic */
  --good:         #1d6b4f;
  --good-wash:    #e8f3ee;
  --bad:          #a02c26;
  --bad-wash:     #fbecea;

  /* structure */
  --rule:         #ddd8ce;
  --rule-strong:  #b9b2a4;
  --radius:       3px;

  --serif: Georgia, "Iowan Old Style", "Palatino Linotype", Palatino, "Times New Roman", serif;
  --sans:  ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono:  ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;

  --measure: 68ch;
  --gutter: 1.5rem;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper:        #14161a;
    --paper-raised: #1b1e24;
    --paper-sunk:   #101216;
    --ink:          #e9e6e0;
    --ink-soft:     #b0b5bf;
    --ink-faint:    #838a96;
    --navy:         #9fbbe8;
    --navy-deep:    #c3d5f2;
    --navy-wash:    #1a2130;
    --gold:         #d7b366;
    --gold-wash:    #2a2418;
    --good:         #6cc39a;
    --good-wash:    #16241e;
    --bad:          #e88b84;
    --bad-wash:     #2a1817;
    --rule:         #2c3038;
    --rule-strong:  #454b56;
  }
}
:root[data-theme="dark"] {
  --paper: #14161a; --paper-raised: #1b1e24; --paper-sunk: #101216;
  --ink: #e9e6e0; --ink-soft: #b0b5bf; --ink-faint: #838a96;
  --navy: #9fbbe8; --navy-deep: #c3d5f2; --navy-wash: #1a2130;
  --gold: #d7b366; --gold-wash: #2a2418;
  --good: #6cc39a; --good-wash: #16241e; --bad: #e88b84; --bad-wash: #2a1817;
  --rule: #2c3038; --rule-strong: #454b56;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

body {
  font-family: var(--serif);
  background: var(--paper);
  color: var(--ink);
  line-height: 1.65;
  font-size: 1.0625rem;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* ---------- typography ---------------------------------------------------- */
h1, h2, h3, h4 { font-family: var(--serif); font-weight: 700; line-height: 1.15; letter-spacing: -0.012em; color: var(--ink); }
h1 { font-size: clamp(2.1rem, 5.2vw, 3.4rem); }
h2 { font-size: clamp(1.5rem, 3vw, 2.1rem); }
h3 { font-size: 1.25rem; }
h4 { font-size: 1.05rem; }
p  { margin: 0 0 1.1em 0; }
a  { color: var(--navy); text-decoration: underline; text-underline-offset: 2px; text-decoration-thickness: 1px; }
a:hover { color: var(--navy-deep); text-decoration-thickness: 2px; }
strong { font-weight: 700; }
small { font-size: 0.875rem; }

.prose { max-width: var(--measure); }
.prose ul, .prose ol { margin: 0 0 1.1em 1.3em; }
.prose li { margin-bottom: 0.4em; }

/* the editorial signature: a small caps label with a rule */
.eyebrow {
  font-family: var(--sans);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-faint);
  display: block;
  margin-bottom: 0.9rem;
}
.eyebrow--gold { color: var(--gold); }
.rule { border: 0; border-top: 1px solid var(--rule); margin: 2.5rem 0; }
.rule--short { width: 3.5rem; border-top: 2px solid var(--gold); margin: 1.4rem 0; }
.rule--strong { border-top: 2px solid var(--ink); }

/* numbered section headings — "01 — MENTAL MATHS" */
.numbered { display: flex; align-items: baseline; gap: 0.85rem; }
.numbered .num {
  font-family: var(--mono); font-size: 0.8rem; font-weight: 700;
  color: var(--gold); letter-spacing: 0.06em; flex: none;
}

.lede { font-size: 1.2rem; line-height: 1.6; color: var(--ink-soft); max-width: 62ch; }
.mono { font-family: var(--mono); }
.sans { font-family: var(--sans); }

/* ---------- layout -------------------------------------------------------- */
.container { width: 100%; max-width: 1140px; margin: 0 auto; padding: 0 var(--gutter); }
.container--narrow { max-width: 780px; }
.flex { display: flex; } .grid { display: grid; }
.items-center { align-items: center; } .items-start { align-items: flex-start; }
.justify-between { justify-content: space-between; } .justify-center { justify-content: center; }
.flex-wrap { flex-wrap: wrap; }
.gap-2{gap:.5rem}.gap-3{gap:.75rem}.gap-4{gap:1rem}.gap-5{gap:1.25rem}.gap-6{gap:1.5rem}.gap-8{gap:2rem}
.mt-2{margin-top:.5rem}.mt-3{margin-top:.75rem}.mt-4{margin-top:1rem}.mt-6{margin-top:1.5rem}.mt-8{margin-top:2rem}
.mb-2{margin-bottom:.5rem}.mb-3{margin-bottom:.75rem}.mb-4{margin-bottom:1rem}.mb-5{margin-bottom:1.25rem}
.mb-6{margin-bottom:1.5rem}.mb-8{margin-bottom:2rem}.mb-10{margin-bottom:2.5rem}
.py-4{padding-top:1rem;padding-bottom:1rem}.py-8{padding-top:2rem;padding-bottom:2rem}
.py-12{padding-top:3rem;padding-bottom:3rem}
.hidden { display: none !important; }
.text-center { text-align: center; }
.w-full { width: 100%; }
.sticky { position: sticky; } .top-24 { top: 5.5rem; }

.grid-cols-1{grid-template-columns:repeat(1,minmax(0,1fr))}
.grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}
.grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}
.grid-cols-12{grid-template-columns:repeat(12,minmax(0,1fr))}
@media (min-width:768px){
  .md\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}
  .md\:grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}
  .md\:grid-cols-4{grid-template-columns:repeat(4,minmax(0,1fr))}
  .md\:grid-cols-12{grid-template-columns:repeat(12,minmax(0,1fr))}
  .md\:col-span-8{grid-column:span 8/span 8}.md\:col-span-4{grid-column:span 4/span 4}
}
@media (min-width:1024px){
  .lg\:grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}
  .lg\:col-span-2{grid-column:span 2/span 2}.lg\:col-span-1{grid-column:span 1/span 1}
}

/* ---------- masthead ------------------------------------------------------ */
.masthead {
  position: sticky; top: 0; z-index: 50;
  background: var(--paper);
  border-bottom: 1px solid var(--rule);
}
.masthead__inner { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 0.85rem var(--gutter); max-width: 1140px; margin: 0 auto; }
.wordmark { display: inline-flex; align-items: baseline; gap: .5rem; text-decoration: none; color: var(--ink); }
.wordmark__name { font-family: var(--serif); font-weight: 700; font-size: 1.35rem; letter-spacing: -0.02em; }
.wordmark__dot { width: 7px; height: 7px; background: var(--gold); display: inline-block; flex: none; }
.wordmark:hover { color: var(--ink); text-decoration: none; }

.nav { display: flex; align-items: center; gap: 1.4rem; font-family: var(--sans); font-size: .9rem; }
.nav a { color: var(--ink-soft); text-decoration: none; padding: .25rem 0; border-bottom: 2px solid transparent; }
.nav a:hover { color: var(--ink); border-bottom-color: var(--rule-strong); }
.nav a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--gold); font-weight: 600; }

.nav-toggle { display: none; background: none; border: 1px solid var(--rule); border-radius: var(--radius); padding: .4rem .6rem; cursor: pointer; color: var(--ink); font-family: var(--sans); font-size: .85rem; }
@media (max-width: 700px) {
  .nav-toggle { display: block; }
  .nav { display: none; position: absolute; top: 100%; left: 0; right: 0; flex-direction: column; align-items: stretch; gap: 0; background: var(--paper); border-bottom: 1px solid var(--rule); padding: .5rem var(--gutter) 1rem; }
  .nav[data-open="true"] { display: flex; }
  .nav a { padding: .6rem 0; border-bottom: 1px solid var(--rule); }
}

/* ---------- buttons ------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  font-family: var(--sans); font-size: .95rem; font-weight: 600;
  padding: .7rem 1.35rem; border-radius: var(--radius);
  border: 1px solid transparent; cursor: pointer; text-decoration: none;
  transition: background-color .15s ease, border-color .15s ease, color .15s ease;
  line-height: 1.2;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--navy); color: #fff; border-color: var(--navy); }
.btn-primary:hover { background: var(--navy-deep); border-color: var(--navy-deep); color: #fff; }
.btn-ghost { background: transparent; color: var(--ink); border-color: var(--rule-strong); }
.btn-ghost:hover { background: var(--paper-sunk); color: var(--ink); border-color: var(--ink-faint); }
.btn-soft { background: var(--navy-wash); color: var(--navy); border-color: transparent; }
.btn-soft:hover { background: var(--paper-sunk); color: var(--navy-deep); }
.btn-danger { background: var(--bad-wash); color: var(--bad); border-color: transparent; }
.btn-danger:hover { background: var(--bad); color: #fff; }
.btn-lg { font-size: 1.02rem; padding: .9rem 1.7rem; }
.btn:focus-visible, a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, summary:focus-visible {
  outline: 2px solid var(--gold); outline-offset: 2px;
}

/* ---------- cards & panels ------------------------------------------------ */
.card {
  background: var(--paper-raised);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 1.5rem;
}
.card--flush { padding: 0; overflow: hidden; }
.card--quiet { background: transparent; border-color: var(--rule); }

/* the homepage pillar: a bordered block with a gold top rule */
.pillar {
  background: var(--paper-raised);
  border: 1px solid var(--rule);
  border-top: 3px solid var(--gold);
  border-radius: 0;
  padding: 1.8rem 1.6rem;
  display: flex; flex-direction: column; height: 100%;
}
.pillar h3 { margin-bottom: .5rem; }
.pillar p { color: var(--ink-soft); font-size: .98rem; }
.pillar .btn { align-self: flex-start; margin-top: auto; }
.pillar__stats { font-family: var(--mono); font-size: .78rem; color: var(--ink-faint); letter-spacing: .03em; margin-bottom: 1.1rem; }

/* ---------- forms --------------------------------------------------------- */
.input-base {
  width: 100%; padding: .7rem .9rem;
  border: 1px solid var(--rule-strong); border-radius: var(--radius);
  background: var(--paper-raised); color: var(--ink);
  font-family: var(--sans); font-size: .95rem;
  outline: none; transition: border-color .15s ease;
}
.input-base:focus { border-color: var(--navy); box-shadow: 0 0 0 3px var(--navy-wash); }
select.input-base { appearance: none; padding-right: 2.2rem;
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%), linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: calc(100% - 18px) 51%, calc(100% - 13px) 51%;
  background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; }
input[type="range"] { accent-color: var(--navy); cursor: pointer; width: 100%; }
label { cursor: pointer; }

.switch { position: relative; display: inline-block; width: 42px; height: 23px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; inset: 0; cursor: pointer; background: var(--rule-strong); border-radius: 999px; transition: background-color .18s ease; }
.slider:before { content: ""; position: absolute; height: 17px; width: 17px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: transform .18s ease; }
.switch input:checked + .slider { background: var(--navy); }
.switch input:checked + .slider:before { transform: translateX(19px); }

.check-row {
  display: flex; align-items: center; gap: .7rem;
  padding: .7rem .85rem;
  border: 1px solid var(--rule); border-radius: var(--radius);
  background: var(--paper-raised); cursor: pointer; -webkit-user-select: none; user-select: none;
  font-family: var(--sans); font-size: .92rem;
  transition: border-color .15s ease, background-color .15s ease;
}
.check-row:hover { border-color: var(--rule-strong); }
.check-row[data-checked="true"] { background: var(--navy-wash); border-color: var(--navy); }
.check-row input[type="checkbox"], .check-row input[type="radio"] { accent-color: var(--navy); width: 1.05rem; height: 1.05rem; cursor: pointer; flex: none; }

/* ---------- tabs ---------------------------------------------------------- */
.tabs { display: flex; gap: 0; border: 1px solid var(--rule); border-radius: var(--radius); overflow: hidden; }
.tab-btn {
  padding: .5rem 1.1rem; border: none; background: var(--paper-raised);
  color: var(--ink-soft); font-family: var(--sans); font-weight: 600; font-size: .88rem;
  cursor: pointer; transition: background-color .15s ease, color .15s ease;
}
.tab-btn + .tab-btn { border-left: 1px solid var(--rule); }
.tab-btn[data-active="true"] { background: var(--navy); color: #fff; }
.tab-btn:hover:not([data-active="true"]) { background: var(--paper-sunk); color: var(--ink); }

/* ---------- practice drill ------------------------------------------------ */
.big-question {
  font-family: var(--mono); font-weight: 700;
  font-size: clamp(2.6rem, 7vw, 4.6rem);
  text-align: center; margin: 1.8rem 0; letter-spacing: -0.02em; color: var(--ink);
}
.answer-input {
  font-family: var(--mono); font-size: 2.4rem; font-weight: 700; text-align: center;
  width: 100%; max-width: 300px; padding: .7rem;
  border: 2px solid var(--rule-strong); border-radius: var(--radius);
  background: var(--paper-raised); color: var(--ink);
  margin: 0 auto; display: block; outline: none; transition: border-color .15s ease, background-color .15s ease;
}
.answer-input:focus { border-color: var(--navy); box-shadow: 0 0 0 3px var(--navy-wash); }
.answer-input.correct { border-color: var(--good); background: var(--good-wash); color: var(--good); }
.answer-input.wrong   { border-color: var(--bad);  background: var(--bad-wash);  color: var(--bad); }

.progress-track { width: 100%; height: 4px; background: var(--rule); overflow: hidden; margin: 1.3rem 0; }
.progress-fill { height: 100%; background: var(--navy); transition: width .35s ease; }
.pill {
  display: inline-flex; align-items: center; justify-content: center;
  padding: .3rem .7rem; background: var(--paper-sunk); border: 1px solid var(--rule);
  border-radius: var(--radius); font-family: var(--mono); font-size: .82rem; font-weight: 700; color: var(--ink-soft);
}
.pill.active { background: var(--navy-wash); color: var(--navy); border-color: var(--navy); }
.streak-hot { color: #8a6d1f !important; background: var(--gold-wash) !important; border-color: var(--gold) !important; }
.timer-urgent { color: var(--bad) !important; background: var(--bad-wash) !important; border-color: var(--bad) !important; }

@keyframes qSlideIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.q-animate { animation: qSlideIn .18s ease-out; }

.feedback-flash { position: fixed; inset: 0; pointer-events: none; opacity: 0; transition: opacity .15s; z-index: 10; }
.feedback-flash.show { opacity: .12; }
.flash-good { background: var(--good); }
.flash-bad  { background: var(--bad); }

.key {
  display: inline-block; padding: 1px 6px; font-size: .74rem;
  border-radius: var(--radius); background: var(--paper-sunk);
  border: 1px solid var(--rule-strong); color: var(--ink-soft);
  font-family: var(--mono); font-weight: 700;
}

.toast-notification {
  position: fixed; bottom: 1.6rem; left: 50%; transform: translateX(-50%);
  padding: .75rem 1.2rem; border-radius: var(--radius);
  font-family: var(--sans); font-weight: 600; font-size: .92rem;
  background: var(--ink); color: var(--paper); z-index: 100;
  animation: toastIn .2s ease-out forwards;
}
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 8px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* ---------- text utilities (kept for the ported app markup) --------------- */
.text-xs{font-size:.75rem}.text-sm{font-size:.875rem}.text-base{font-size:1rem}
.text-lg{font-size:1.125rem}.text-xl{font-size:1.25rem}.text-2xl{font-size:1.5rem}
.text-3xl{font-size:1.875rem}.text-4xl{font-size:2.25rem}.text-5xl{font-size:3rem}
.font-medium{font-weight:500}.font-semibold{font-weight:600}.font-bold{font-weight:700}.font-extrabold{font-weight:700}
.text-primary{color:var(--ink)}.text-secondary{color:var(--ink-soft)}
.text-muted{color:var(--ink-faint)}.text-accent{color:var(--navy)}

/* ---------- footer -------------------------------------------------------- */
.site-footer { border-top: 1px solid var(--rule); background: var(--paper-sunk); margin-top: 4rem; padding: 2.5rem 0 3rem; }
.site-footer .container { display: grid; gap: 2rem; }
@media (min-width: 700px) { .site-footer .container { grid-template-columns: 2fr 1fr 1fr; } }
.site-footer h4 { font-family: var(--sans); font-size: .78rem; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-faint); margin-bottom: .8rem; font-weight: 700; }
.site-footer ul { list-style: none; }
.site-footer li { margin-bottom: .45rem; }
.site-footer a { color: var(--ink-soft); text-decoration: none; font-size: .94rem; }
.site-footer a:hover { color: var(--ink); text-decoration: underline; }
.site-footer .fine { font-size: .84rem; color: var(--ink-faint); line-height: 1.6; }

/* ---------- advertising ---------------------------------------------------
   Ads are given a reserved, labelled, bordered slot so they never shift the
   layout (CLS) and are never mistakable for site content. Height is reserved
   up-front for the same reason. They are removed entirely when printing.
   -------------------------------------------------------------------------- */
.ad-slot {
  margin: 2.5rem auto;
  padding: 0;
  max-width: 728px;
  text-align: center;
  min-height: 108px;          /* reserve space: prevents layout shift */
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
  background: transparent;
}
.ad-slot::before {
  content: "Advertisement";
  display: block;
  font-family: var(--sans); font-size: .62rem; font-weight: 600;
  letter-spacing: .14em; text-transform: uppercase;
  color: var(--ink-faint); opacity: .7;
  padding: .5rem 0 .4rem;
}
.ad-slot > ins, .ad-slot > .ad-inner { width: 100%; }
.ad-slot--placeholder { color: var(--ink-faint); font-family: var(--sans); font-size: .85rem; padding-bottom: .9rem; }
/* an in-article slot sits between prose sections and is a little quieter */
.ad-slot--inline { max-width: var(--measure); margin: 2.8rem 0; }

/* ---------- book / chapter reading ---------------------------------------- */
.chapter-body { max-width: var(--measure); }
.chapter-body h2 { margin: 2.6rem 0 1rem; padding-bottom: .4rem; border-bottom: 1px solid var(--rule); }
.chapter-body h3 { margin: 2rem 0 .6rem; }
.chapter-body table { width: 100%; border-collapse: collapse; margin: 1.2rem 0; font-size: .95rem; }
.chapter-body th, .chapter-body td { border: 1px solid var(--rule); padding: .45rem .6rem; text-align: left; }
.chapter-body th { background: var(--paper-sunk); font-family: var(--sans); font-size: .85rem; }
.chapter-body blockquote { border-left: 3px solid var(--gold); padding-left: 1rem; margin: 1.2rem 0; color: var(--ink-soft); }

.question {
  border: 1px solid var(--rule);
  border-left: 3px solid var(--navy);
  background: var(--paper-raised);
  padding: 1.2rem 1.3rem;
  margin: 1.8rem 0;
  border-radius: var(--radius);
}
.question__head { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; margin-bottom: .8rem; flex-wrap: wrap; }
.question__id { font-family: var(--mono); font-weight: 700; font-size: .9rem; color: var(--navy); }
.question__level { font-family: var(--sans); font-size: .7rem; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-faint); }
.question .opt { display: block; padding: .3rem 0 .3rem 1.6rem; text-indent: -1.6rem; }

details.solution { margin-top: 1rem; border-top: 1px solid var(--rule); padding-top: .8rem; }
details.solution > summary {
  cursor: pointer; font-family: var(--sans); font-size: .88rem; font-weight: 600;
  color: var(--navy); list-style: none; display: inline-flex; align-items: center; gap: .4rem;
}
details.solution > summary::-webkit-details-marker { display: none; }
details.solution > summary::before { content: "+"; font-family: var(--mono); font-weight: 700; }
details.solution[open] > summary::before { content: "−"; }
details.solution[open] > summary { margin-bottom: .8rem; }
.solution__body { font-size: .98rem; }
.takeaway {
  background: var(--gold-wash); border-left: 3px solid var(--gold);
  padding: .8rem 1rem; margin: 1rem 0 0; border-radius: var(--radius); font-size: .95rem;
}

/* chapter list on the book page */
.toc-list { list-style: none; border-top: 1px solid var(--rule); }
.toc-list li { border-bottom: 1px solid var(--rule); }
.toc-list a { display: flex; align-items: baseline; gap: 1rem; padding: .95rem .3rem; text-decoration: none; color: var(--ink); transition: background-color .12s ease; }
.toc-list a:hover { background: var(--paper-sunk); }
.toc-list .n { font-family: var(--mono); font-size: .8rem; color: var(--gold); font-weight: 700; flex: none; width: 2.2rem; }
.toc-list .t { flex: 1; font-weight: 700; }
.toc-list .c { font-family: var(--mono); font-size: .78rem; color: var(--ink-faint); flex: none; }

/* A long display equation must scroll inside its own box rather than widen the
   page — without this, chapters overflowed sideways on a 380px screen.
   (overflow-x:auto is safe here; it is only in *print* that Chromium reacts to
   it by shrinking the whole document, which is why the PDF build clips instead.) */
.chapter-body .katex-display { overflow-x: auto; overflow-y: hidden; padding: 3px 0; }
.chapter-body .katex-display > .katex { text-align: initial; }
/* wide tables get their own scroller too */
.chapter-body table { display: block; width: max-content; max-width: 100%; overflow-x: auto; }

/* "In this chapter" jump list — these pages are long */
.chapter-toc {
  border: 1px solid var(--rule); border-left: 3px solid var(--gold);
  background: var(--paper-raised); border-radius: var(--radius);
  padding: 1.1rem 1.3rem; margin: 0 0 2.5rem;
}
.chapter-toc ol { list-style: none; counter-reset: toc; columns: 2; column-gap: 2rem; }
@media (max-width: 620px) { .chapter-toc ol { columns: 1; } }
.chapter-toc li { counter-increment: toc; break-inside: avoid; margin-bottom: .35rem; font-size: .93rem; }
.chapter-toc li::before {
  content: counter(toc, decimal-leading-zero) " ";
  font-family: var(--mono); font-size: .74rem; color: var(--gold); font-weight: 700; margin-right: .4rem;
}
.chapter-toc a { color: var(--ink-soft); text-decoration: none; }
.chapter-toc a:hover { color: var(--navy); text-decoration: underline; }
/* keep anchor targets clear of the sticky masthead */
.chapter-body h2 { scroll-margin-top: 5rem; }

/* prev / next chapter navigation */
.chapter-nav { display: flex; justify-content: space-between; gap: 1rem; margin-top: 3rem; padding-top: 1.2rem; border-top: 1px solid var(--rule); font-family: var(--sans); font-size: .9rem; }
.chapter-nav a { text-decoration: none; color: var(--navy); max-width: 45%; }
.chapter-nav a:hover { text-decoration: underline; }
.chapter-nav .dir { display: block; font-size: .7rem; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-faint); margin-bottom: .15rem; }

/* ---------- worksheet preview & print ------------------------------------- */
.ws-preview { background: #fff; color: #000; border: 1px solid var(--rule); border-radius: var(--radius); padding: 2rem; max-height: 70vh; overflow: auto; }
.ws-preview .ws-title { font-size: 1.6rem; font-weight: 700; margin-bottom: .4rem; }
.ws-preview .ws-meta { font-size: .92rem; color: #555; margin-bottom: 1.3rem; display: flex; justify-content: space-between; border-bottom: 2px solid #222; padding-bottom: .6rem; }
.ws-preview .ws-grid { display: grid; gap: 1.3rem; }
.ws-preview .ws-grid-2 { grid-template-columns: repeat(2,1fr); }
.ws-preview .ws-grid-3 { grid-template-columns: repeat(3,1fr); }
.ws-preview .ws-grid-4 { grid-template-columns: repeat(4,1fr); }
.ws-preview .ws-list .ws-item { display: flex; align-items: baseline; gap: .5rem; padding: .2rem 0; }
.ws-preview .ws-list .ws-line { flex: 1; border-bottom: 2px dotted #aaa; height: 0; }
.ws-preview .ws-cell { font-size: 1.1rem; font-weight: 700; font-family: var(--mono); padding: .2rem 0; border-bottom: 1px solid #eee; }
.ws-preview .ws-answer-cell { font-size: 1.1rem; font-family: var(--mono); font-weight: 700; padding: .2rem 0; border-bottom: 1px solid #f5f5f5; color: #16305c; }
.ws-preview .ws-section-title { font-size: 1.05rem; font-weight: 700; margin: 1.3rem 0 .5rem; text-transform: uppercase; letter-spacing: .05em; border-bottom: 2px solid #222; display: inline-block; }

.print-only { display: none; }
@media print {
  @page { size: A4; margin: 14mm; }
  html, body { background: #fff !important; color: #000 !important; font-size: 11pt; }
  .no-print, .screen-only, .ad-slot, .masthead, .site-footer, .chapter-nav { display: none !important; }
  .print-only { display: block; }
  a { color: #000; text-decoration: none; }
  details.solution { border: 0; }
  details.solution > summary { display: none; }
  details.solution > .solution__body { display: block !important; }
  .question { break-inside: avoid; border-left-color: #000; }
  .worksheet-sheet { page-break-after: always; }
  .worksheet-sheet:last-child { page-break-after: auto; }
  .ws-title { font-size: 22pt; font-weight: 700; margin-bottom: 6pt; }
  .ws-meta { font-size: 11pt; color: #333; margin-bottom: 14pt; display: flex; justify-content: space-between; border-bottom: 2px solid #000; padding-bottom: 6pt; }
  .ws-grid { display: grid; gap: 8mm 4mm; }
  .ws-grid-2 { grid-template-columns: repeat(2,1fr); }
  .ws-grid-3 { grid-template-columns: repeat(3,1fr); }
  .ws-grid-4 { grid-template-columns: repeat(4,1fr); }
  .ws-list .ws-item { display: flex; align-items: baseline; gap: 8pt; padding: 4pt 0; }
  .ws-list .ws-line { flex: 1; border-bottom: 2px dotted #999; height: 0; }
  .ws-cell { font-size: 13pt; font-weight: 700; font-family: var(--mono); padding: 4pt 0; border-bottom: 1px solid #ddd; }
  .ws-answer-cell { font-size: 13pt; font-family: var(--mono); font-weight: 700; padding: 4pt 0; border-bottom: 1px solid #eee; }
  .ws-section-title { font-size: 13pt; font-weight: 700; margin: 14pt 0 6pt; text-transform: uppercase; letter-spacing: .05em; border-bottom: 2px solid #000; display: inline-block; }
}

/* skip link for keyboard users */
.skip-link { position: absolute; left: -9999px; top: 0; background: var(--ink); color: var(--paper); padding: .6rem 1rem; z-index: 999; font-family: var(--sans); }
.skip-link:focus { left: 0; }
