/* =========================================================================
   Untangle Agentic AI — character-led visual system
   Clean sans UI, knitted-mascot palette, minimal decorative thread art.
   ========================================================================= */

:root {
  /* Palette — wool colours pulled directly from the integrated knitted character.
     Cream paper is close to the hero image background so the image sits inside the
     page, not on top of it. */
  --paper:        #F7F1E6;
  --paper-soft:   #EFE8D7;
  --paper-deep:   #E5DCC5;
  --ink:          #14243F;        /* deep knitted navy */
  --ink-soft:     #2B3A55;
  --muted:        #5E6A7F;
  --hairline:     rgba(20,36,63,0.10);
  --hairline-strong: rgba(20,36,63,0.22);
  --line:         rgba(20,36,63,0.16);

  /* Wool colours — used as accents, not backgrounds */
  --blue:         #1F5BA8;        /* royal wool blue */
  --blue-deep:    #14243F;
  --blue-sky:     #6FB5CC;
  --teal:         #4EA6A6;        /* teal wool */
  --yellow:       #E2A91E;        /* golden wool */
  --yellow-deep:  #B07A00;
  --orange:       #E77722;        /* orange wool */
  --green:        #7E9B54;        /* soft green wool */
  --rose:         #C95F4A;        /* kept but de-emphasised */

  /* Type — humanist serif display + clean sans body, workbook feel */
  --display: "Newsreader", "Source Serif 4", Georgia, "Times New Roman", serif;
  --sans:    "Manrope", system-ui, -apple-system, "Segoe UI", Helvetica, Arial, sans-serif;
  --hand:    "Caveat", "Patrick Hand", cursive;
  --mono:    "JetBrains Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  /* Paper colours used by workbook cards / tags */
  --tag-paper:   #EFE2BF;
  --tag-edge:    #B89C5B;
  --thread-red:  #1F5BA8;   /* legacy var — now wool blue, not red */
  --thread-wool: #4EA6A6;

  /* Sizing */
  --maxw: 720px;
  --maxw-wide: 1080px;
  --gutter: clamp(20px, 4vw, 40px);
  --nav-w: 260px;

  /* Radii */
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 16px;
  --r-xl: 22px;

  /* Shadow */
  --shadow-sm: 0 1px 0 rgba(20,36,63,0.06), 0 1px 2px rgba(20,36,63,0.04);
  --shadow-md: 0 2px 0 rgba(20,36,63,0.04), 0 8px 24px rgba(20,36,63,0.06);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; overflow-x: clip; }
body { overflow-x: clip; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: 0.001s !important; transition-duration: 0.001s !important; }
}

html, body { background: var(--paper); color: var(--ink); }

body {
  margin: 0;
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.65;
  font-feature-settings: "kern", "ss01";
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  /* Very faint paper texture — workbook feel without a heavy parchment look. */
  background-image:
    radial-gradient(1200px 600px at 80% -10%, rgba(194,147,32,0.06), transparent 60%),
    radial-gradient(900px 500px at 0% 100%, rgba(46,125,143,0.05), transparent 60%),
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='220' height='220'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0.13  0 0 0 0 0.12  0 0 0 0 0.10  0 0 0 0.045 0'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
  background-attachment: fixed, fixed, scroll;
}

/* =========================================================================
   Type
   ========================================================================= */

h1, h2, h3, h4 {
  font-family: var(--display);
  color: var(--ink);
  font-weight: 600;
  line-height: 1.15;
  letter-spacing: -0.012em;
  text-wrap: balance;
  margin: 0 0 0.5em;
  font-variation-settings: "opsz" 24;
}
h1 {
  font-size: clamp(36px, 5.2vw, 58px);
  font-weight: 600;
  letter-spacing: -0.022em;
  font-variation-settings: "opsz" 48;
  line-height: 1.06;
}
h2 {
  font-size: clamp(24px, 2.6vw, 32px);
  margin-top: 0.2em;
  font-variation-settings: "opsz" 36;
  letter-spacing: -0.016em;
}
h3 {
  font-size: clamp(18px, 1.5vw, 21px);
  margin-top: 1.6em;
  font-weight: 600;
  letter-spacing: -0.008em;
  font-variation-settings: "opsz" 24;
}
h4 { font-size: 16px; font-variation-settings: "opsz" 18; }

p, li { text-wrap: pretty; }
p { margin: 0 0 1em; }
em { font-style: italic; }
strong { font-weight: 600; color: var(--ink); }

a { color: var(--blue); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { text-decoration-thickness: 2px; }

hr { border: none; height: 1px; background: var(--hairline); margin: 3rem auto; max-width: var(--maxw); }

ul, ol { padding-left: 1.4em; margin: 0 0 1em; }
li { margin: 0.25em 0; }

::selection { background: rgba(31,79,191,0.20); }

code, pre { font-family: var(--mono); font-size: 13.5px; }
code { background: var(--paper-soft); padding: 1px 6px; border-radius: 4px; font-size: 0.88em; color: var(--ink); }
pre code { background: none; padding: 0; font-size: 13.5px; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0;
  margin: -1px; overflow: hidden; clip: rect(0,0,0,0);
  white-space: nowrap; border: 0;
}

.handnote {
  font-family: var(--hand);
  color: var(--muted);
  font-size: 22px;
  line-height: 1.2;
}

/* =========================================================================
   Layout shell
   ========================================================================= */

.skip-link {
  position: absolute; left: -9999px; top: auto;
  background: var(--ink); color: var(--paper);
  padding: 12px 16px; font-size: 14px;
  border-radius: 4px; z-index: 9999;
}
.skip-link:focus { left: 12px; top: 12px; }

.shell {
  display: grid;
  grid-template-columns: var(--nav-w) minmax(0, 1fr);
  gap: 0;
  max-width: 1380px;
  margin: 0 auto;
  padding: 0 var(--gutter);
}
@media (max-width: 980px) {
  .shell { grid-template-columns: 1fr; }
}

main { min-width: 0; padding: 0 0 6rem; position: relative; }
section { scroll-margin-top: 90px; }

.chapter {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 4rem 0 1rem;
  position: relative;
}
.chapter--wide { max-width: var(--maxw-wide); }
.chapter--hero { padding-top: 0.5rem; }
.chapter--bleed { max-width: none; }

/* =========================================================================
   Top bar
   ========================================================================= */

.topbar {
  position: sticky; top: 0; z-index: 50;
  background: rgba(251,249,243,0.92);
  backdrop-filter: saturate(140%) blur(8px);
  -webkit-backdrop-filter: saturate(140%) blur(8px);
  border-bottom: 1px solid var(--hairline);
}
.topbar__inner {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px;
  max-width: 1380px; margin: 0 auto;
  padding: 12px var(--gutter);
  font-size: 14px;
}
.topbar__brand {
  display: flex; align-items: center; gap: 10px;
  font-weight: 700; color: var(--ink); text-decoration: none;
  white-space: nowrap;
  font-size: 15px;
  letter-spacing: -0.01em;
}
.topbar__brand:hover { text-decoration: none; }
.topbar__brand-mark {
  width: 30px; height: 30px;
  border-radius: 4px;
  background-image: url("img/character-integrated-cutout.png");
  background-size: 180% 180%;
  background-position: center 22%;
  background-repeat: no-repeat;
  background-color: var(--tag-paper);
  flex: none;
  box-shadow: inset 0 0 0 1px var(--tag-edge);
}
@media (max-width: 720px) { .topbar__brand .brand-text { display: none; } }

.topbar__right { display: flex; align-items: center; gap: 10px; flex-wrap: nowrap; }
@media (max-width: 720px) {
  .topbar__right .progress, .topbar__right .progress__label { display: none; }
}

.progress {
  position: relative;
  width: 140px; height: 4px;
  background: var(--hairline);
  border-radius: 2px;
  overflow: hidden;
}
.progress__bar {
  position: absolute; left: 0; top: 0; bottom: 0;
  width: 0%;
  background: var(--ink);
  transition: width 0.18s ease;
}
body.build-mode .progress__bar { background: var(--green); }
.progress__label {
  font-size: 12px; color: var(--muted);
  margin-right: 6px; white-space: nowrap;
}

.modeswitch {
  display: inline-flex; align-items: center; gap: 8px;
  font-family: var(--sans); font-size: 13px; font-weight: 600;
  background: var(--paper); color: var(--ink);
  border: 1px solid var(--hairline-strong);
  border-radius: 999px; padding: 6px 14px;
  cursor: pointer;
  min-height: 36px;
  white-space: nowrap;
  transition: background .12s ease, color .12s ease, border-color .12s ease;
}
.modeswitch:hover { border-color: var(--ink); }
.modeswitch:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
.modeswitch__dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: transparent; border: 1.5px solid var(--ink);
  transition: background 0.15s, border-color 0.15s;
}
.modeswitch[aria-pressed="true"] .modeswitch__dot { background: var(--green); border-color: var(--green); }
.modeswitch[aria-pressed="true"] { background: var(--ink); color: var(--paper); border-color: var(--ink); }

.menutoggle {
  display: none;
  background: transparent; border: 1px solid var(--hairline-strong);
  border-radius: 8px;
  width: 40px; height: 40px;
  align-items: center; justify-content: center;
  cursor: pointer; color: var(--ink);
}
@media (max-width: 980px) {
  .menutoggle { display: inline-flex; }
}

/* =========================================================================
   Sidenav
   ========================================================================= */

.sidenav {
  position: sticky;
  top: 64px;
  align-self: start;
  height: calc(100vh - 80px);
  overflow-y: auto;
  padding: 28px 18px 28px 0;
  font-size: 13.5px;
  color: var(--muted);
  scrollbar-width: thin;
}
.sidenav__heading {
  font-family: var(--mono);
  font-size: 10.5px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--muted);
  margin: 0 0 6px 18px;
}
.sidenav ol { list-style: none; padding: 0; margin: 0; position: relative; }
.sidenav li { position: relative; margin: 0; }
.sidenav a {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 10px 6px 18px;
  color: var(--muted);
  text-decoration: none;
  border-radius: 6px;
  line-height: 1.25;
  min-height: 32px;
  border-left: 2px solid transparent;
  margin-left: 6px;
}
.sidenav a:hover { color: var(--ink); background: rgba(20,36,63,0.04); }
.sidenav a:focus-visible { outline: 2px solid var(--blue); outline-offset: -2px; }
.sidenav a[aria-current="true"] {
  color: var(--ink);
  font-weight: 600;
  border-left-color: var(--blue);
  background: rgba(31,79,191,0.05);
}
.sidenav a.is-done .sidenav__num { color: var(--green); }
.sidenav a.is-done::after {
  content: "✓";
  margin-left: auto;
  color: var(--green);
  font-weight: 700;
  font-size: 12px;
}
.sidenav__num {
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  font-size: 11px;
  min-width: 18px;
  font-weight: 600;
}
.sidenav__title { flex: 1; }
.sidenav__divider {
  height: 1px; background: var(--hairline); margin: 16px 18px;
}

/* Mobile drawer */
@media (max-width: 980px) {
  .menutoggle { display: inline-flex; }
  .sidenav {
    position: fixed; top: 56px; left: 0; right: 0; bottom: 0;
    height: auto;
    background: var(--paper);
    border-bottom: 1px solid var(--hairline);
    padding: 24px var(--gutter) 32px;
    overflow-y: auto;
    transform: translateY(-110%);
    transition: transform 0.25s ease;
    z-index: 40;
  }
  .sidenav[data-open="true"] { transform: translateY(0); }
  .sidenav__heading { margin-left: 0; }
}

/* =========================================================================
   Returning-visitor banner
   ========================================================================= */

[hidden] { display: none !important; }

.returning {
  background: var(--paper-soft);
  border: 1px solid var(--hairline-strong);
  border-radius: var(--r-md);
  padding: 14px 18px;
  max-width: 760px;
  margin: 14px auto 0;
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px;
  font-size: 14px;
}
.returning button {
  font-size: 13px; font-weight: 600;
  background: var(--ink); color: var(--paper);
  border: none; border-radius: 8px;
  padding: 8px 14px; cursor: pointer;
  min-height: 36px;
}
.returning button.ghost { background: transparent; color: var(--muted); }

/* =========================================================================
   HERO — character-led
   ========================================================================= */

.hero {
  max-width: var(--maxw-wide);
  margin: 0 auto;
  padding: 2.5rem 0 2rem;
  position: relative;
}
.hero__copy {
  max-width: 760px;
  padding-right: clamp(0px, 4vw, 60px);
}

.hero__eyebrow {
  display: inline-flex; align-items: center; gap: 10px;
  font-family: var(--mono);
  font-size: 11.5px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--muted);
  margin: 0 0 18px;
  padding: 0;
  background: transparent;
  border: none;
  border-radius: 0;
}
.hero__eyebrow::before {
  content: "";
  width: 22px; height: 1px;
  background: var(--blue);
  display: inline-block;
}

.hero h1 {
  margin: 0 0 18px;
}
.hero h1 em {
  font-style: italic;
  position: relative;
  display: inline-block;
  /* a hand-drawn underline in wool blue, drawn as SVG so it scales */
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 200 14' preserveAspectRatio='none'><path d='M2 9 q 30 -6 60 -1 t 60 1 t 60 -2 t 18 0' fill='none' stroke='%231F5BA8' stroke-width='2.4' stroke-linecap='round'/></svg>");
  background-repeat: no-repeat;
  background-position: 0 100%;
  background-size: 100% 0.18em;
  padding-bottom: 0.05em;
}

.hero__subhead {
  font-size: clamp(17px, 1.6vw, 19px);
  line-height: 1.55;
  color: var(--ink-soft);
  margin: 0 0 22px;
  max-width: 520px;
}

.hero__audiences {
  display: flex; flex-wrap: wrap; gap: 10px;
  margin: 0 0 26px;
  padding: 0;
  list-style: none;
}
.hero__audiences li {
  list-style: none;
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 500;
  color: var(--ink-soft);
  background: transparent;
  border: 0;
  padding: 0;
  border-radius: 0;
  margin: 0;
  display: inline-flex; align-items: baseline; gap: 8px;
}
.hero__audiences li::before {
  content: "—";
  color: var(--blue);
  font-weight: 600;
  background: none;
  width: auto; height: auto;
  border-radius: 0;
}
.hero__audiences li + li { padding-left: 0; }

/* Hero image band — a wide field-guide plate, integrated into the paper.
   No card, no rounded corners, no glossy shadow. Subtle top/bottom rules
   and a faint caption sit it inside the workbook page. */
.hero__band {
  margin: 2.4rem 0 0;
  padding: clamp(20px, 3vw, 36px) 0 14px;
  border-top: 1px solid var(--hairline);
  border-bottom: 1px solid var(--hairline);
  position: relative;
}
.hero__band::before,
.hero__band::after {
  /* paper-tag corner ticks so the band reads as a workbook plate */
  content: "";
  position: absolute;
  width: 38px; height: 1px;
  background: var(--blue);
  top: -1px;
  opacity: 0.55;
}
.hero__band::before { left: 0; }
.hero__band::after  { right: 0; }
.hero__band img {
  display: block;
  width: 100%;
  height: auto;
  max-width: 100%;
  /* Transparent PNG sits directly on the cream paper — no card, no shadow */
}
.hero__band figcaption {
  font-family: var(--mono);
  font-size: 11.5px;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 14px 0 0;
  display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap;
}
.hero__band figcaption::before {
  content: "Plate 01";
  color: var(--blue);
  font-weight: 600;
}
.hero__band figcaption .sep {
  width: 18px; height: 1px; background: var(--hairline-strong);
  display: inline-block; align-self: center;
}

.cta-row {
  display: flex; flex-wrap: wrap; gap: 12px; align-items: center;
  margin: 0 0 14px;
}

.btn {
  font-family: var(--sans); font-size: 15px; font-weight: 600;
  display: inline-flex; align-items: center; gap: 8px;
  padding: 12px 22px;
  border-radius: 999px;
  text-decoration: none;
  cursor: pointer;
  border: 1.5px solid var(--ink);
  min-height: 48px;
  transition: transform 0.08s ease, background 0.15s ease, border-color .15s ease;
  white-space: nowrap;
  letter-spacing: -0.005em;
}
.btn:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
.btn:hover { text-decoration: none; }
.btn--primary { background: var(--ink); color: var(--paper); }
.btn--primary:hover { background: var(--blue-deep); border-color: var(--blue-deep); }
.btn--ghost { background: transparent; color: var(--ink); }
.btn--ghost:hover { background: rgba(20,36,63,0.06); }
.btn--accent { background: var(--yellow); color: var(--ink); border-color: var(--ink); }
.btn--accent:hover { background: var(--yellow-deep); border-color: var(--ink); color: var(--ink); }
.btn--blue { background: var(--blue); color: var(--paper); border-color: var(--blue); }
.btn--blue:hover { background: var(--blue-deep); border-color: var(--blue-deep); }
.btn:active { transform: translateY(1px); }

/* Hero numbers strip */
.hero__numbers {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0;
  margin: 2.4rem 0 0;
  border-top: 1px solid var(--hairline);
  border-bottom: 1px solid var(--hairline);
  padding: 1.2rem 0;
}
.hero__num {
  padding: 0 22px;
  border-right: 1px solid var(--hairline);
}
.hero__num:last-child { border-right: none; }
.hero__num .n {
  font-family: var(--display);
  font-weight: 700;
  font-size: clamp(26px, 3vw, 36px);
  line-height: 1;
  color: var(--ink);
  display: block;
  margin-bottom: 8px;
  letter-spacing: -0.02em;
}
.hero__num .l {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.35;
}
@media (max-width: 640px) {
  .hero__numbers { grid-template-columns: 1fr; padding: 0.5rem 0; }
  .hero__num { padding: 14px 0; border-right: none; border-bottom: 1px solid var(--hairline); }
  .hero__num:last-child { border-bottom: none; }
}

/* =========================================================================
   Three-state story strip
   ========================================================================= */

.story {
  max-width: var(--maxw-wide);
  margin: 0 auto;
  padding: 4rem 0 2rem;
}
.story__head {
  display: block;
  margin-bottom: 32px;
  max-width: 720px;
}
.story__head h2 { margin: 0 0 10px; }
.story__head .sub {
  font-size: 16px;
  color: var(--ink-soft);
  margin: 0;
  max-width: 560px;
  line-height: 1.5;
}
.story__grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
  align-items: stretch;
}
@media (max-width: 880px) {
  .story__grid { grid-template-columns: 1fr; }
}
.state {
  background: var(--paper);
  border: 1px solid var(--hairline-strong);
  border-radius: 2px;
  padding: 22px 22px 26px;
  display: flex;
  flex-direction: column;
  position: relative;
  box-shadow: none;
}
.state::after {
  /* paper-tab corner so cards feel like loose pages */
  content: "";
  position: absolute;
  top: -1px; right: 18px;
  width: 42px; height: 8px;
  background: var(--tag-paper);
  border: 1px solid var(--tag-edge);
  border-bottom: none;
  border-radius: 4px 4px 0 0;
  transform: translateY(-100%);
}
.state__stage {
  display: inline-flex; align-items: center; gap: 8px;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--muted);
  margin: 0 0 12px;
}
.state__stage::before {
  content: "";
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--muted);
}
.state--simple .state__stage::before { background: var(--blue); }
.state--tangled .state__stage::before { background: var(--orange); }
.state--integrated .state__stage::before { background: var(--green); }

.state__char {
  position: relative;
  height: 220px;
  display: flex; align-items: flex-end; justify-content: center;
  margin: 0 0 14px;
  background-image:
    repeating-linear-gradient(0deg, transparent 0 28px, rgba(20,36,63,0.04) 28px 29px);
  background-size: 100% 100%;
  border-bottom: 1px solid var(--hairline);
}
.state__char::before {
  /* a faint baseline tick instead of a floating product shadow */
  content: "";
  position: absolute;
  inset: auto 0 0 0;
  height: 1px;
  background: var(--hairline-strong);
}
.state__char img {
  position: relative;
  max-height: 100%;
  width: auto;
  max-width: 86%;
  /* No glossy drop-shadow — the cutouts should sit on the page like specimens */
  filter: drop-shadow(0 2px 0 rgba(20,36,63,0.04));
}
.state h3 {
  margin: 0 0 6px;
  font-size: 22px;
  letter-spacing: -0.015em;
}
.state p {
  margin: 0 0 14px;
  color: var(--ink-soft);
  font-size: 15px;
  line-height: 1.5;
}
.state__tags {
  list-style: none;
  padding: 0;
  margin: auto 0 0;
  display: flex; flex-direction: column; gap: 4px;
  font-family: var(--mono);
}
.state__tags li {
  font-size: 12px;
  font-weight: 500;
  color: var(--ink-soft);
  background: transparent;
  border-radius: 0;
  padding: 0 0 0 14px;
  margin: 0;
  position: relative;
  letter-spacing: 0.01em;
}
.state__tags li::before {
  content: "—";
  position: absolute; left: 0; top: 0;
  color: var(--muted);
}
.state--simple .state__tags li::before { color: var(--blue); }
.state--tangled .state__tags li::before { color: var(--orange); }
.state--integrated .state__tags li::before { color: var(--green); }
.state--simple { border-top: 3px solid var(--blue); box-shadow: none; }
.state--tangled { border-top: 3px solid var(--orange); box-shadow: none; }
.state--integrated { border-top: 3px solid var(--green); box-shadow: none; }

.state__arrow {
  display: none;
}
@media (min-width: 881px) {
  .state__arrow {
    display: block;
    position: absolute;
    top: 110px;
    right: -22px;
    width: 28px; height: 28px;
    z-index: 3;
    color: var(--muted);
  }
}

/* =========================================================================
   Audiences picker — "Choose your starting point"
   ========================================================================= */

.audiences {
  max-width: var(--maxw-wide);
  margin: 0 auto;
  padding: 2rem 0;
}
.audiences__head {
  display: block;
  margin-bottom: 26px;
  max-width: 720px;
}
.audiences__head h2 { margin: 0 0 8px; }
.audiences__head .sub { font-size: 16px; color: var(--ink-soft); margin: 0; max-width: 560px; line-height: 1.5; }

.audiences__grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}
@media (max-width: 880px) {
  .audiences__grid { grid-template-columns: 1fr; }
}
.aud {
  display: flex; flex-direction: column;
  background: var(--paper);
  border: 1px solid var(--hairline-strong);
  border-radius: 4px;
  padding: 22px;
  text-decoration: none;
  color: var(--ink);
  transition: border-color .12s ease, background .12s ease;
  position: relative;
}
.aud:hover {
  text-decoration: none;
  border-color: var(--ink);
  background: #FCFAF4;
}
.aud::before {
  /* a tiny folder-tab at top-left so the card reads as a file tab */
  content: "";
  position: absolute;
  top: -1px; left: 22px;
  width: 60px; height: 8px;
  background: var(--tag-paper);
  border: 1px solid var(--tag-edge);
  border-bottom: none;
  border-radius: 3px 3px 0 0;
  transform: translateY(-100%);
}
.aud__icon {
  width: 56px; height: 56px;
  border-radius: 6px;
  background-color: var(--paper-soft);
  background-size: 230% 230%;
  background-repeat: no-repeat;
  margin-bottom: 14px;
  box-shadow: inset 0 0 0 1px var(--hairline);
}
.aud--scratch .aud__icon {
  background-image: url("img/character-simple-cutout.png");
  background-position: center 22%;
}
.aud--messy .aud__icon {
  background-image: url("img/character-tangled-cutout.png");
  background-position: center 28%;
}
.aud--stronger .aud__icon {
  background-image: url("img/character-integrated-cutout.png");
  background-position: center 26%;
}
.aud__step {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--muted);
  margin: 0 0 4px;
}
.aud h3 {
  margin: 0 0 8px;
  font-size: 19px;
  font-weight: 600;
  letter-spacing: -0.012em;
}
.aud p {
  font-size: 14px;
  color: var(--ink-soft);
  margin: 0 0 14px;
}
.aud__cta {
  margin-top: auto;
  font-size: 14px;
  font-weight: 600;
  color: var(--blue);
  display: inline-flex; align-items: center; gap: 6px;
}
.aud__cta::after { content: "→"; transition: transform .12s ease; }
.aud:hover .aud__cta::after { transform: translateX(3px); }

/* =========================================================================
   Chapter heading — clean, numeric badge instead of paper tag
   ========================================================================= */

.ch-head {
  display: flex; align-items: flex-start; gap: 18px;
  margin-bottom: 0.5rem;
}
.ch-head__symbol {
  flex: none;
  width: 56px; height: 56px;
  border-radius: 14px;
  background: var(--paper-soft);
  border: 1px solid var(--hairline-strong);
  display: inline-flex; align-items: center; justify-content: center;
  font-family: var(--display);
  font-weight: 700;
  font-size: 22px;
  color: var(--ink);
  letter-spacing: -0.02em;
  font-variation-settings: "wdth" 96, "opsz" 24;
}
.ch-head__symbol[data-tone="blue"]   { background: rgba(31,79,191,0.10); border-color: rgba(31,79,191,0.30); color: var(--blue-deep); }
.ch-head__symbol[data-tone="teal"]   { background: rgba(46,125,143,0.12); border-color: rgba(46,125,143,0.30); color: var(--teal); }
.ch-head__symbol[data-tone="yellow"] { background: rgba(242,198,59,0.20); border-color: rgba(194,147,32,0.40); color: var(--yellow-deep); }
.ch-head__symbol[data-tone="orange"] { background: rgba(229,136,56,0.15); border-color: rgba(229,136,56,0.40); color: #B16224; }
.ch-head__symbol[data-tone="green"]  { background: rgba(110,154,85,0.15); border-color: rgba(110,154,85,0.40); color: #4F7740; }
.ch-head__symbol[data-tone="rose"]   { background: rgba(201,95,74,0.12); border-color: rgba(201,95,74,0.36); color: var(--rose); }

.ch-head__body { flex: 1; min-width: 0; }
.ch-tab {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--muted);
  margin: 4px 0 10px;
}
.ch-head h2 { margin: 0 0 0.1em; }
.ch-head__lead {
  font-family: var(--sans);
  color: var(--ink-soft);
  font-size: 17px;
  margin: 6px 0 1rem;
  font-style: normal;
  max-width: 60ch;
}

/* =========================================================================
   Workbook (code block)
   ========================================================================= */

.workbook {
  position: relative;
  background: var(--ink);
  color: #E2E8F2;
  border-radius: var(--r-md);
  padding: 0;
  margin: 1.5rem 0;
  overflow: hidden;
  border: 1px solid var(--ink);
}
.workbook__head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
  font-size: 12px; font-weight: 600;
  color: rgba(255,255,255,0.6);
  padding: 10px 16px;
  background: rgba(255,255,255,0.04);
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.workbook__head .label {
  display: inline-flex; align-items: center; gap: 8px;
  font-family: var(--mono);
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
}
.workbook__head .label::before {
  content: "";
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--yellow);
  flex: none;
}
.workbook pre {
  margin: 0;
  white-space: pre;
  overflow-x: auto;
  font-size: 13px;
  line-height: 1.55;
  color: #E6ECF7;
  padding: 16px 18px 18px;
}
.workbook pre code { font-family: var(--mono); color: inherit; }

.copybtn {
  font-family: var(--sans); font-size: 12px; font-weight: 600;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.16);
  color: #E6ECF7;
  padding: 5px 10px;
  border-radius: 6px;
  cursor: pointer;
  min-height: 30px;
  display: inline-flex; align-items: center; gap: 6px;
  transition: background .12s ease, border-color .12s ease;
}
.copybtn:hover { background: rgba(255,255,255,0.12); }
.copybtn:focus-visible { outline: 2px solid var(--yellow); outline-offset: 2px; }
.copybtn[data-copied="true"] {
  background: var(--green); border-color: var(--green); color: white;
}
.copybtn[data-copied="true"]::after {
  content: " · Copied";
  font-weight: 500;
}

/* =========================================================================
   Callouts — clean panels, single-colour accent line
   ========================================================================= */

.callout {
  position: relative;
  padding: 16px 20px 16px 56px;
  margin: 1.5rem 0;
  border-radius: var(--r-md);
  background: var(--paper-soft);
  border: 1px solid var(--hairline);
  border-left: 4px solid var(--muted);
}
.callout__title {
  font-family: var(--display);
  font-size: 16px;
  font-weight: 600;
  margin: 0 0 4px;
  letter-spacing: -0.01em;
  color: var(--ink);
}
.callout p:last-child { margin-bottom: 0; }
.callout__icon { display: none; }
.callout::before {
  content: "";
  position: absolute;
  left: 18px; top: 18px;
  width: 22px; height: 22px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px;
  color: white;
}

.callout--try {
  background: rgba(110,154,85,0.10);
  border-left-color: var(--green);
}
.callout--try .callout__title::before {
  content: "Try this now";
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.12em;
  color: #4F7740;
  display: block; margin-bottom: 2px;
}
.callout--try::before { background: var(--green); content: "→"; font-size: 14px; line-height: 22px; text-align: center; }

.callout--mvp {
  background: rgba(31,79,191,0.07);
  border-left-color: var(--blue);
}
.callout--mvp .callout__title::before {
  content: "Minimum viable";
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--blue);
  display: block; margin-bottom: 2px;
}
.callout--mvp::before { background: var(--blue); content: "★"; font-size: 13px; line-height: 22px; text-align: center; }

.callout--warn {
  background: rgba(242,198,59,0.16);
  border-left-color: var(--yellow-deep);
}
.callout--warn .callout__title::before {
  content: "Heads up";
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--yellow-deep);
  display: block; margin-bottom: 2px;
}
.callout--warn::before {
  background: var(--yellow-deep);
  content: "!"; font-size: 13px; line-height: 22px; text-align: center;
}

.callout--danger {
  background: rgba(201,95,74,0.10);
  border-left-color: var(--rose);
}
.callout--danger .callout__title::before {
  content: "Stop and think";
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--rose);
  display: block; margin-bottom: 2px;
}
.callout--danger::before {
  background: var(--rose);
  content: "✕"; font-size: 12px; line-height: 22px; text-align: center;
}

/* =========================================================================
   Quiz
   ========================================================================= */

.quiz {
  background: var(--paper);
  border: 1px solid var(--hairline-strong);
  border-radius: var(--r-lg);
  padding: 24px;
  margin: 1.5rem 0;
}
.quiz__intro {
  font-size: 14px; color: var(--muted);
  margin: 0 0 16px;
}
.quiz fieldset {
  border: none;
  border-top: 1px solid var(--hairline);
  padding: 16px 0 4px;
  margin: 0;
}
.quiz fieldset:first-of-type { border-top: none; padding-top: 4px; }
.quiz legend {
  font-family: var(--display);
  font-size: 17px;
  font-weight: 600;
  color: var(--ink);
  padding: 0;
  margin-bottom: 10px;
  letter-spacing: -0.012em;
}
.quiz__opts { display: flex; flex-wrap: wrap; gap: 14px; font-size: 14px; }
.quiz__opts label {
  display: inline-flex; align-items: center; gap: 8px;
  cursor: pointer;
  min-height: 36px;
  padding: 4px 12px 4px 4px;
  background: var(--paper-soft);
  border: 1px solid var(--hairline);
  border-radius: 999px;
  transition: background .1s ease, border-color .1s ease;
}
.quiz__opts label:hover { border-color: var(--ink); }
.quiz__opts label:has(input:checked) {
  background: var(--ink); color: var(--paper); border-color: var(--ink);
}
.quiz__opts input[type="radio"] {
  appearance: none; -webkit-appearance: none;
  width: 16px; height: 16px;
  border: 1.5px solid currentColor;
  border-radius: 50%;
  margin: 0 0 0 8px; flex: none;
  position: relative;
}
.quiz__opts input[type="radio"]:checked::after {
  content: "";
  position: absolute; inset: 3px;
  background: currentColor;
  border-radius: 50%;
}
.quiz__opts input[type="radio"]:focus-visible {
  outline: 2px solid var(--blue); outline-offset: 2px;
}
.quiz__actions {
  display: flex; gap: 12px; align-items: center;
  margin-top: 18px;
}
.quiz__result {
  background: var(--paper-soft);
  border: 1px solid var(--hairline-strong);
  border-radius: var(--r-md);
  padding: 18px 20px;
  margin-top: 16px;
  display: none;
}
.quiz__result.is-shown { display: block; }
.quiz__result h3 { margin-top: 0; font-size: 22px; }
.quiz__tag {
  display: inline-block;
  background: var(--yellow);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  padding: 5px 12px;
  border-radius: 4px;
  margin-bottom: 10px;
}

/* =========================================================================
   Build-mode block
   ========================================================================= */

.build-block {
  display: none;
  background: var(--paper);
  border: 1px dashed var(--green);
  border-left: 4px solid var(--green);
  border-radius: var(--r-md);
  padding: 18px 22px;
  margin: 1.5rem 0;
  position: relative;
}
body.build-mode .build-block { display: block; }
.build-block__label {
  position: absolute; top: -10px; left: 18px;
  background: var(--paper);
  font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.14em;
  color: var(--green);
  padding: 0 8px;
}
.build-block dl { margin: 6px 0 14px; display: grid; grid-template-columns: max-content 1fr; column-gap: 16px; row-gap: 6px; }
.build-block dt {
  font-size: 12px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--muted);
  align-self: start; padding-top: 2px;
}
.build-block dd { margin: 0; }
.build-block__row {
  display: flex; flex-wrap: wrap; gap: 12px; align-items: center;
  border-top: 1px solid rgba(110,154,85,0.25);
  padding-top: 14px;
}
.donebox {
  display: inline-flex; align-items: center; gap: 10px;
  font-size: 14px; font-weight: 600;
  cursor: pointer;
  min-height: 40px;
  padding: 4px 12px 4px 4px;
}
.donebox input[type="checkbox"] {
  appearance: none; -webkit-appearance: none;
  width: 22px; height: 22px;
  border: 2px solid var(--ink);
  border-radius: 5px;
  background: var(--paper);
  position: relative;
  flex: none;
  cursor: pointer;
}
.donebox input[type="checkbox"]:checked {
  background: var(--green);
  border-color: var(--green);
}
.donebox input[type="checkbox"]:checked::after {
  content: "";
  position: absolute;
  left: 5px; top: 1px;
  width: 7px; height: 13px;
  border-right: 2.5px solid var(--paper);
  border-bottom: 2.5px solid var(--paper);
  transform: rotate(45deg);
}
.donebox input[type="checkbox"]:focus-visible {
  outline: 2px solid var(--blue); outline-offset: 2px;
}
.donebox--checked {
  text-decoration: line-through;
  text-decoration-color: var(--green);
  text-decoration-thickness: 2px;
}

/* The build-mode "hidden" template blocks (used as copy source) */
.build-block [hidden] { display: none !important; }

/* =========================================================================
   System overview ("What you'll build")
   ========================================================================= */

.layers {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 12px;
  margin: 1.5rem 0;
}
.layer {
  background: var(--paper);
  border: 1px solid var(--hairline-strong);
  border-radius: var(--r-md);
  padding: 16px 16px 18px;
  position: relative;
  text-decoration: none;
  color: var(--ink);
  display: block;
}
.layer:hover { text-decoration: none; border-color: var(--ink); box-shadow: var(--shadow-sm); }
.layer__num {
  font-family: var(--display);
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  margin: 0 0 6px;
  letter-spacing: 0.04em;
}
.layer__name {
  font-family: var(--display);
  font-size: 17px;
  font-weight: 600;
  color: var(--ink);
  margin: 0 0 4px;
  letter-spacing: -0.012em;
}
.layer__what {
  font-size: 13.5px;
  color: var(--muted);
  margin: 0;
  line-height: 1.45;
}
.layer__tone { display: block; width: 28px; height: 4px; border-radius: 2px; background: var(--muted); margin-bottom: 10px; }
.layer:nth-child(9n+1) .layer__tone { background: var(--blue); }
.layer:nth-child(9n+2) .layer__tone { background: var(--teal); }
.layer:nth-child(9n+3) .layer__tone { background: var(--yellow); }
.layer:nth-child(9n+4) .layer__tone { background: var(--orange); }
.layer:nth-child(9n+5) .layer__tone { background: var(--green); }
.layer:nth-child(9n+6) .layer__tone { background: var(--blue-deep); }
.layer:nth-child(9n+7) .layer__tone { background: var(--rose); }
.layer:nth-child(9n+8) .layer__tone { background: var(--teal); }
.layer:nth-child(9n+9) .layer__tone { background: var(--orange); }

/* =========================================================================
   Paywall gate
   ========================================================================= */

.gate {
  position: relative;
  background: var(--paper);
  border: 1px solid var(--hairline-strong);
  border-radius: 4px;
  padding: 28px;
  margin: 2rem 0;
}
.gate--accent {
  background: var(--paper);
  border-color: var(--hairline-strong);
  border-top: 1px solid var(--thread-red);
  border-radius: 2px;
}
.gate__eyebrow {
  font-family: var(--mono);
  font-size: 11.5px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--muted);
  margin: 0 0 8px;
}
.gate h3 { margin: 0 0 8px; font-size: 24px; }
.gate__lead { color: var(--ink-soft); margin: 0 0 16px; }
.gate__form {
  display: flex; gap: 10px; flex-wrap: wrap;
  margin: 14px 0 8px;
}
.gate__form input[type="email"] {
  flex: 1; min-width: 220px;
  font-family: var(--sans); font-size: 15px;
  padding: 12px 14px;
  border: 1.5px solid var(--hairline-strong);
  border-radius: 10px;
  background: var(--paper);
  color: var(--ink);
  min-height: 48px;
}
.gate__form input[type="email"]:focus-visible {
  outline: 2px solid var(--blue); outline-offset: 2px;
  border-color: var(--blue);
}
.gate__msg {
  font-size: 13px;
  color: var(--muted);
  margin: 8px 0 0;
  min-height: 1.4em;
}
.gate__msg.is-error { color: var(--rose); }
.gate__msg.is-success { color: var(--green); }
.gate__secondary {
  font-size: 14px;
  color: var(--muted);
}
.gate__pricing {
  display: grid; grid-template-columns: 1fr 1fr; gap: 14px;
  margin: 18px 0;
}
@media (max-width: 640px) {
  .gate__pricing { grid-template-columns: 1fr; }
}
.plan {
  background: var(--paper);
  border: 1px solid var(--hairline-strong);
  border-radius: 4px;
  padding: 18px 18px 16px;
  position: relative;
}
.plan--recommended {
  border-color: var(--hairline-strong);
  border-left: 3px solid var(--thread-red);
}
.plan--recommended::before {
  content: "Maintenance plan";
  position: absolute; top: -1px; left: 22px;
  font-family: var(--mono);
  background: var(--tag-paper); color: var(--ink);
  font-size: 10px; font-weight: 500;
  text-transform: uppercase; letter-spacing: 0.14em;
  padding: 3px 10px 4px; border-radius: 0 0 4px 4px;
  border: 1px solid var(--tag-edge);
  border-top: none;
}
.plan__name {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--muted);
  margin: 0 0 6px;
}
.plan__price { font-family: var(--display); font-size: 30px; font-weight: 700; margin: 0 0 4px; line-height: 1; letter-spacing: -0.022em; }
.plan__role { font-size: 14px; color: var(--ink-soft); margin: 8px 0 12px; line-height: 1.3; font-style: italic; }
.plan ul { padding-left: 18px; font-size: 14px; color: var(--ink-soft); margin: 8px 0 0; }
.plan li { margin: 3px 0; }

/* Blurred locked content */
.locked {
  position: relative;
  min-height: 320px;
}
.locked > .locked__content {
  filter: blur(7px);
  pointer-events: none;
  user-select: none;
  opacity: 0.7;
  transition: filter 0.3s ease, opacity 0.3s ease;
}
.locked.is-unlocked > .locked__content {
  filter: none;
  pointer-events: auto;
  user-select: text;
  opacity: 1;
}
.locked__overlay {
  position: sticky;
  top: 90px;
  z-index: 5;
  display: flex; justify-content: center;
  pointer-events: none;
  margin: 0 0 24px;
}
.locked.is-unlocked .locked__overlay { display: none; }
.locked__stamp {
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 700;
  color: var(--paper);
  background: var(--ink);
  padding: 10px 22px;
  border-radius: 999px;
  letter-spacing: 0.01em;
  pointer-events: auto;
  cursor: pointer;
  text-decoration: none;
  box-shadow: var(--shadow-md);
  border: 1.5px solid var(--ink);
}
.locked__stamp:hover { background: var(--blue-deep); border-color: var(--blue-deep); text-decoration: none; }

.trust-note {
  font-size: 13px; color: var(--muted);
  margin-top: 14px;
}
.trust-note ul { list-style: none; padding-left: 0; margin: 6px 0 0; }
.trust-note li { padding-left: 22px; position: relative; margin: 3px 0; }
.trust-note li::before {
  content: "✓";
  position: absolute; left: 0;
  color: var(--green); font-weight: 700;
}

/* Folder download */
.folder-dl {
  position: relative;
  display: inline-flex; align-items: flex-end;
  margin: 0;
}
.folder-dl > a {
  position: relative;
  display: inline-flex; flex-direction: column; gap: 4px;
  font-family: var(--sans);
  text-decoration: none;
  background: var(--yellow);
  border: 1.5px solid var(--ink);
  border-radius: 10px;
  padding: 18px 22px 16px;
  min-width: 240px;
  color: var(--ink);
  box-shadow: var(--shadow-sm);
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.folder-dl > a:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  text-decoration: none;
}
.folder-dl__title {
  font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.14em;
  color: rgba(20,36,63,0.7);
  line-height: 1;
}
.folder-dl__sub {
  font-size: 17px; font-weight: 700;
  line-height: 1.15;
}
.folder-dl[aria-disabled="true"] > a {
  opacity: 0.55; cursor: not-allowed;
}

/* =========================================================================
   Accordion
   ========================================================================= */

.trouble {
  border-top: 1px solid var(--hairline-strong);
  margin: 1rem 0;
}
.trouble__row { border-bottom: 1px solid var(--hairline); }
.trouble__btn {
  display: flex; align-items: flex-start; gap: 14px;
  width: 100%; text-align: left;
  background: transparent; border: none;
  padding: 18px 6px;
  cursor: pointer;
  font-family: var(--display);
  font-size: 18px;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.3;
  min-height: 56px;
  letter-spacing: -0.012em;
}
.trouble__btn:focus-visible { outline: 2px solid var(--blue); outline-offset: -4px; }
.trouble__btn::before {
  content: "+";
  font-family: var(--sans); font-weight: 400;
  font-size: 24px;
  color: var(--muted);
  line-height: 1;
  flex: none;
  width: 20px;
  transition: transform 0.2s ease;
  margin-top: 0.05em;
}
.trouble__btn[aria-expanded="true"]::before { content: "−"; }
.trouble__panel {
  padding: 0 6px 18px 40px;
  display: block !important;
  overflow: hidden;
  max-height: 0;
  opacity: 0;
  padding-top: 0; padding-bottom: 0;
  transition: max-height 0.32s ease, opacity 0.22s ease, padding 0.22s ease;
}
.trouble__btn[aria-expanded="true"] + .trouble__panel {
  max-height: 600px;
  opacity: 1;
  padding-bottom: 18px;
}
.trouble__panel h3 { display: none; }

/* =========================================================================
   Tool cards
   ========================================================================= */

.toolcard {
  border: 1px solid var(--hairline-strong);
  border-radius: var(--r-md);
  margin: 12px 0;
  background: var(--paper);
}
.toolcard summary {
  list-style: none;
  cursor: pointer;
  padding: 16px 20px;
  font-family: var(--display);
  font-size: 18px;
  font-weight: 600;
  display: flex; align-items: center; justify-content: space-between;
  min-height: 56px;
  letter-spacing: -0.012em;
}
.toolcard summary::-webkit-details-marker { display: none; }
.toolcard summary::after {
  content: "+";
  font-family: var(--sans); font-size: 22px; color: var(--muted);
}
.toolcard[open] summary::after { content: "−"; }
.toolcard summary:focus-visible { outline: 2px solid var(--blue); outline-offset: -2px; }
.toolcard__body { padding: 0 20px 18px; }

/* =========================================================================
   Glossary
   ========================================================================= */

.glossary {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 8px 24px;
  font-size: 15px;
}
.glossary dt {
  font-weight: 700;
  font-family: var(--display);
  border-bottom: 1px solid var(--hairline);
  padding: 8px 0 4px;
  letter-spacing: -0.012em;
}
.glossary dd {
  margin: 0;
  border-bottom: 1px solid var(--hairline);
  padding: 8px 0 4px;
  color: var(--ink-soft);
}
@media (max-width: 640px) {
  .glossary { grid-template-columns: 1fr; gap: 0; }
  .glossary dt { padding-bottom: 0; border-bottom: none; }
  .glossary dd { padding-top: 4px; margin-bottom: 8px; }
}

/* =========================================================================
   Templates (workbook appendix)
   ========================================================================= */

.template {
  margin: 1rem 0;
  border: 1px solid var(--hairline-strong);
  border-radius: var(--r-md);
  background: var(--paper);
  overflow: hidden;
}
.template > summary {
  list-style: none;
  cursor: pointer;
  font-family: var(--display);
  font-size: 17px;
  font-weight: 600;
  color: var(--ink);
  padding: 14px 18px;
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
  letter-spacing: -0.012em;
}
.template > summary::-webkit-details-marker { display: none; }
.template > summary::after {
  content: "Open";
  font-family: var(--sans);
  font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.14em;
  color: var(--muted);
  background: var(--paper-soft);
  border: 1px solid var(--hairline);
  padding: 5px 10px;
  border-radius: 999px;
  white-space: nowrap;
}
.template[open] > summary::after { content: "Close"; }
.template > .workbook { margin: 0 18px 18px; }

/* =========================================================================
   Footer
   ========================================================================= */

footer.foot {
  max-width: var(--maxw-wide);
  margin: 4rem auto 0;
  padding: 2.5rem 0 3rem;
  border-top: 1px solid var(--hairline-strong);
  font-size: 13px;
  color: var(--muted);
  display: flex; flex-wrap: wrap; gap: 16px;
  justify-content: space-between; align-items: baseline;
}
footer.foot a { color: var(--muted); }
footer.foot .reviewed { font-family: var(--hand); font-size: 18px; }

/* =========================================================================
   Misc
   ========================================================================= */

.kbd {
  font-family: var(--mono); font-size: 12px;
  padding: 1px 6px; background: var(--paper-soft);
  border: 1px solid var(--hairline-strong); border-bottom-width: 2px;
  border-radius: 3px;
  color: var(--ink);
}

/* First week list */
.firstweek {
  list-style: none;
  padding: 0;
  margin: 1rem 0;
  border-top: 1px solid var(--hairline);
}
.firstweek li {
  padding: 18px 0;
  border-bottom: 1px solid var(--hairline);
  display: flex; gap: 18px; align-items: flex-start;
}
.firstweek .day {
  font-family: var(--display);
  font-weight: 700;
  font-size: 18px;
  color: var(--blue);
  flex: none;
  width: 80px;
  letter-spacing: -0.012em;
}
.firstweek .body { flex: 1; font-size: 15.5px; color: var(--ink-soft); }
.firstweek strong { color: var(--ink); }

/* =========================================================================
   Grouped sidenav — calm by default, expands only the current section
   ========================================================================= */
.sidenav .nav-group { margin: 0; padding: 0; }
.sidenav .nav-group + .nav-group { margin-top: 6px; }
.sidenav .nav-group__sum {
  list-style: none;
  cursor: pointer;
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px 8px 18px;
  margin-left: 6px;
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  border-left: 2px solid transparent;
  border-radius: 4px;
  min-height: 36px;
  user-select: none;
}
.sidenav .nav-group__sum::-webkit-details-marker { display: none; }
.sidenav .nav-group__sum::after {
  content: "›";
  margin-left: auto;
  color: var(--muted);
  font-size: 16px;
  line-height: 1;
  transition: transform 0.18s ease;
  transform: rotate(0deg);
}
.sidenav .nav-group[open] > .nav-group__sum::after { transform: rotate(90deg); }
.sidenav .nav-group__sum:hover { background: rgba(20,36,63,0.04); }
.sidenav .nav-group[open] > .nav-group__sum {
  border-left-color: var(--thread-red);
  background: rgba(185,74,58,0.04);
}
.sidenav .nav-group__list {
  padding: 2px 0 10px;
  margin: 0;
  list-style: none;
}
.sidenav .nav-group__list a {
  font-size: 13px;
  padding: 5px 10px 5px 36px;
  min-height: 30px;
}
.sidenav .nav-group__list a[aria-current="true"] {
  border-left-color: var(--thread-red);
  background: rgba(185,74,58,0.06);
}
.sidenav .nav-group__list .sidenav__num {
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--muted);
  min-width: 16px;
}

/* Single-link group (e.g. "First week") — render as a plain link */
.sidenav .nav-link {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px 8px 18px;
  margin-left: 6px;
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  text-decoration: none;
  border-left: 2px solid transparent;
  border-radius: 4px;
  min-height: 36px;
}
.sidenav .nav-link:hover { background: rgba(20,36,63,0.04); }
.sidenav .nav-link[aria-current="true"] {
  border-left-color: var(--thread-red);
  background: rgba(185,74,58,0.06);
}

@media (max-width: 980px) {
  .sidenav .nav-group__sum,
  .sidenav .nav-link { margin-left: 0; }
}

/* =========================================================================
   Paper repair-tag — used on hero, migration callouts, etc.
   ========================================================================= */
.papertag {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--tag-paper);
  border: 1px solid var(--tag-edge);
  color: var(--ink);
  font-family: var(--mono);
  font-size: 11.5px;
  font-weight: 500;
  letter-spacing: 0.04em;
  padding: 4px 10px 4px 22px;
  border-radius: 3px 8px 8px 3px;
  position: relative;
  text-transform: none;
  box-shadow: 0 1px 0 rgba(20,36,63,0.08);
}
.papertag::before {
  content: "";
  position: absolute;
  left: 8px; top: 50%;
  width: 7px; height: 7px;
  margin-top: -3.5px;
  border-radius: 50%;
  background: var(--paper);
  box-shadow: inset 0 0 0 1.2px var(--tag-edge);
}
.papertag--rotate-l { transform: rotate(-1.5deg); }
.papertag--rotate-r { transform: rotate(1.5deg); }

/* A thin wool-blue thread divider, used sparingly */
.thread-rule {
  border: none;
  height: 14px;
  margin: 2rem auto;
  max-width: 320px;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 320 14' preserveAspectRatio='none'><path d='M0 7 q 40 -6 80 0 t 80 0 t 80 0 t 80 0' fill='none' stroke='%231F5BA8' stroke-width='1.8' stroke-linecap='round'/></svg>");
  background-repeat: no-repeat;
  background-position: center;
  background-size: 100% 100%;
  opacity: 0.85;
}

/* =========================================================================
   Quiz extensions — maturity + health rows, healthtag, warn block
   ========================================================================= */
.quiz__row {
  display: flex; align-items: baseline; gap: 14px;
  margin-top: 10px;
  flex-wrap: wrap;
}
.quiz__row + .quiz__rowtext { margin-top: 2px; }
.quiz__rowlabel {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  min-width: 110px;
}
.quiz__rowtext {
  color: var(--ink-soft);
  font-size: 15px;
  margin: 0 0 6px;
}
.quiz__result h3 {
  margin: 0;
  font-size: 22px;
  font-family: var(--display);
  letter-spacing: -0.014em;
}
.healthtag {
  display: inline-flex; align-items: center; gap: 8px;
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 600;
  padding: 4px 12px;
  border-radius: 4px;
  border: 1px solid var(--hairline-strong);
  background: var(--paper);
  color: var(--ink);
}
.healthtag::before {
  content: "";
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--muted);
}
.healthtag[data-tone="green"]  { background: rgba(110,154,85,0.10); border-color: rgba(110,154,85,0.4); color: #4F7740; }
.healthtag[data-tone="green"]::before  { background: var(--green); }
.healthtag[data-tone="yellow"] { background: rgba(242,198,59,0.18); border-color: rgba(194,147,32,0.45); color: var(--yellow-deep); }
.healthtag[data-tone="yellow"]::before { background: var(--yellow-deep); }
.healthtag[data-tone="orange"] { background: rgba(229,136,56,0.14); border-color: rgba(229,136,56,0.45); color: #B16224; }
.healthtag[data-tone="orange"]::before { background: var(--orange); }
.healthtag[data-tone="rose"]   { background: rgba(201,95,74,0.12); border-color: rgba(201,95,74,0.45); color: var(--rose); }
.healthtag[data-tone="rose"]::before   { background: var(--rose); }
.quiz__warn {
  background: rgba(201,95,74,0.08);
  border-left: 3px solid var(--rose);
  padding: 12px 16px;
  border-radius: 0 4px 4px 0;
  font-size: 14.5px;
  color: var(--ink);
  margin: 14px 0 0;
}
.quiz__warn strong { color: var(--rose); }
.quiz__section-head {
  margin: 22px 0 6px;
  display: flex; align-items: baseline; gap: 12px;
  padding-top: 18px;
  border-top: 1px dashed var(--hairline-strong);
}
.quiz__section-head .label {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--thread-red);
}
.quiz__section-head .sub {
  font-size: 14px; color: var(--muted);
}

/* =========================================================================
   Migration with judgement — the workbook spread
   ========================================================================= */
.migration {
  background: var(--paper);
  border: 1px solid var(--hairline-strong);
  border-radius: 4px;
  padding: 0;
  margin: 1.5rem 0 2rem;
  position: relative;
}
.migration__head {
  padding: 22px 26px 14px;
  border-bottom: 1px dashed var(--hairline-strong);
  display: flex; flex-wrap: wrap; gap: 12px 22px; align-items: baseline;
}
.migration__head .papertag { transform: rotate(-1deg); }
.migration__head h3 {
  margin: 0;
  font-family: var(--display);
  font-size: clamp(20px, 2.2vw, 26px);
  letter-spacing: -0.014em;
}

.migration__steps {
  padding: 18px 26px 22px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px 28px;
  margin: 0;
  list-style: none;
  counter-reset: migstep;
}
@media (max-width: 720px) {
  .migration__steps { grid-template-columns: 1fr; }
}
.migration__steps li {
  counter-increment: migstep;
  display: flex;
  gap: 12px;
  padding: 6px 0;
  font-size: 15px;
  color: var(--ink-soft);
  line-height: 1.4;
  border-bottom: 1px dotted var(--hairline);
}
.migration__steps li:last-child,
.migration__steps li:nth-last-child(2):not(:nth-child(odd)) {
  border-bottom: none;
}
.migration__steps li::before {
  content: counter(migstep, decimal-leading-zero);
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 500;
  color: var(--thread-red);
  flex: none;
  width: 24px;
  letter-spacing: 0.04em;
}
.migration__steps strong { color: var(--ink); font-weight: 600; }

.migration__gate {
  padding: 18px 26px 24px;
  background: var(--paper-soft);
  border-top: 1px dashed var(--hairline-strong);
}
.migration__gate h4 {
  font-family: var(--display);
  margin: 0 0 10px;
  font-size: 17px;
  letter-spacing: -0.01em;
}
.migration__gate ul {
  padding: 0;
  margin: 0;
  list-style: none;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px 24px;
}
@media (max-width: 720px) {
  .migration__gate ul { grid-template-columns: 1fr; }
}
.migration__gate li {
  padding-left: 22px;
  position: relative;
  font-size: 14.5px;
  color: var(--ink-soft);
  line-height: 1.5;
  margin: 4px 0;
}
.migration__gate li::before {
  content: "?";
  position: absolute;
  left: 0; top: 1px;
  width: 14px; height: 14px;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  color: var(--thread-red);
  background: var(--paper);
  border: 1px solid var(--thread-red);
  border-radius: 50%;
  text-align: center;
  line-height: 12px;
}

/* Small inline migration note inside each layer section */
.migration-note {
  margin: 1rem 0 1.5rem;
  background: var(--paper);
  border: 1px solid var(--hairline);
  border-left: 3px solid var(--thread-red);
  border-radius: 0 4px 4px 0;
  padding: 12px 16px 12px 18px;
  font-size: 14.5px;
  color: var(--ink-soft);
  line-height: 1.5;
  position: relative;
}
.migration-note__label {
  display: inline-block;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--thread-red);
  margin: 0 0 4px;
}
.migration-note p { margin: 0; }
.migration-note p + p { margin-top: 6px; }
.migration-note strong { color: var(--ink); }

/* Two-card mini layout (e.g. "Bad vs Good" inside troubleshooting) */
.compare {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin: 1rem 0 1.2rem;
}
@media (max-width: 640px) {
  .compare { grid-template-columns: 1fr; }
}
.compare > div {
  padding: 14px 16px;
  border-radius: 4px;
  font-size: 14.5px;
  line-height: 1.5;
}
.compare__bad { background: rgba(201,95,74,0.08); border: 1px solid rgba(201,95,74,0.35); }
.compare__good { background: rgba(110,154,85,0.10); border: 1px solid rgba(110,154,85,0.40); }
.compare__bad strong, .compare__good strong { display: block; margin-bottom: 4px; font-family: var(--mono); font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase; }
.compare__bad strong { color: var(--rose); }
.compare__good strong { color: #4F7740; }

/* tweak: more comfortable body width on wide screens */
@media (min-width: 1280px) {
  :root { --maxw-wide: 1080px; }
}

/* Final overflow safety belt for the hero band at small widths */
.hero__band { overflow: hidden; }
@media (max-width: 480px) {
  .hero__band figcaption { font-size: 10.5px; }
}
