/* ==========================================================================
   The Missing Package Manager — "Pinned"
   A manifest-native identity: the book presented as a pinned, versioned
   dependency you can trust. Dual voice: indigo = the human / manifest voice,
   amber = the machine / lockfile voice. Signature = the resolution spine.
   ========================================================================== */

:root {
  color-scheme: light dark;

  /* Surfaces & text — light */
  --bg: #F6F7FB;
  --surface: #FFFFFF;
  --surface-2: #EEF1F8;
  --text: #171A22;
  --muted: #5A6478;
  --border: #DCE1EC;

  /* Dual voice */
  --indigo: #5A54F0;          /* human / manifest */
  --indigo-strong: #3F38D6;
  --amber: #B87613;           /* machine / lockfile */
  --amber-strong: #8F5A0C;
  --on-indigo: #FFFFFF;       /* text on an indigo fill */

  /* Four-property cues (harmonized, distinct) */
  --prop-portability: #5A54F0;      /* indigo */
  --prop-reproducibility: #0EA5A5;  /* teal */
  --prop-security: #B87613;         /* amber */
  --prop-governance: #C2468A;       /* magenta */

  /* Code artifact "ink" — a dark manifest/terminal surface in BOTH themes */
  --ink: #10141F;
  --ink-2: #171D2C;
  --ink-text: #E6EAF6;
  --ink-muted: #9AA6C0;
  --ink-border: rgba(150, 162, 190, 0.16);
  --ink-amber: #E7B23D;
  --ink-indigo: #9E98FF;
  --ink-teal: #5BD6CF;
  --ink-green: #7FD0A6;
  --ink-violet: #C4A6FF;

  /* Effects */
  --shadow: 0 24px 60px -30px rgba(23, 26, 45, 0.42);
  --shadow-sm: 0 10px 28px -18px rgba(23, 26, 45, 0.36);
  --radius: 14px;
  --radius-sm: 9px;
  --sidebar-width: 20rem;

  /* Type roles */
  --font-display: "Bricolage Grotesque", "Segoe UI", system-ui, sans-serif;
  --font-body: "Literata", Georgia, "Times New Roman", serif;
  --font-mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;

  font-family: var(--font-body);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0D1017;
    --surface: #141926;
    --surface-2: #1A2130;
    --text: #EAEEF7;
    --muted: #97A1B6;
    --border: #232C3E;

    --indigo: #8B84FF;
    --indigo-strong: #ADA7FF;
    --amber: #E7B23D;
    --amber-strong: #F3C766;
    --on-indigo: #0D1017;

    --prop-portability: #8B84FF;
    --prop-reproducibility: #2FD4C6;
    --prop-security: #E7B23D;
    --prop-governance: #E67CB5;

    --shadow: 0 28px 64px -30px rgba(0, 0, 0, 0.62);
    --shadow-sm: 0 12px 30px -18px rgba(0, 0, 0, 0.55);
  }
}

/* ------------------------------------------------------------------ base */
* { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 1.06rem;
  line-height: 1.75;
  font-optical-sizing: auto;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: var(--indigo); text-decoration-thickness: 1px; text-underline-offset: 0.16em; transition: color 120ms ease; }
a:hover { color: var(--indigo-strong); text-decoration-thickness: 2px; }

a:focus-visible,
button:focus-visible,
summary:focus-visible {
  outline: 3px solid var(--indigo);
  outline-offset: 3px;
  border-radius: 4px;
}

::selection { background: color-mix(in srgb, var(--indigo) 26%, transparent); }

.container { width: min(1120px, calc(100% - 2.5rem)); margin-inline: auto; }

.skip-link {
  position: absolute;
  left: 1rem; top: 0.75rem;
  z-index: 40;
  transform: translateY(-160%);
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.6rem 0.9rem;
  font-family: var(--font-mono);
  font-size: 0.82rem;
}
.skip-link:focus { transform: translateY(0); }

/* ------------------------------------------------------------ typography */
h1, h2, h3, h4 {
  font-family: var(--font-display);
  line-height: 1.12;
  margin: 0 0 0.6em;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
}
h1 { font-size: clamp(2rem, 4.6vw, 3.1rem); letter-spacing: -0.03em; }
h2 { font-size: clamp(1.5rem, 2.7vw, 2.05rem); }
h3 { font-size: clamp(1.18rem, 2vw, 1.42rem); font-weight: 600; }
h4 { font-size: 1.06rem; font-weight: 600; letter-spacing: -0.01em; }

.eyebrow {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 0.9rem;
}

.lead {
  color: var(--muted);
  font-size: clamp(1.08rem, 2vw, 1.28rem);
  line-height: 1.6;
  max-width: 62ch;
}

/* Version-pin tag — the "pinned dependency" motif (machine voice) */
.pin-tag {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--amber-strong);
  background: color-mix(in srgb, var(--amber) 13%, transparent);
  border: 1px solid color-mix(in srgb, var(--amber) 32%, var(--border));
  border-radius: 6px;
  padding: 0.08rem 0.4rem;
  white-space: nowrap;
}
.pin-tag--lg { font-size: 0.8rem; padding: 0.16rem 0.5rem; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  padding: 0.72rem 1.2rem;
  border-radius: 9px;
  border: 1px solid transparent;
  text-decoration: none;
  cursor: pointer;
  transition: transform 140ms ease, background 140ms ease, border-color 140ms ease, color 140ms ease;
}
.btn::after { content: ""; }
.btn-primary { background: var(--indigo); color: var(--on-indigo); }
.btn-primary:hover { background: var(--indigo-strong); color: var(--on-indigo); transform: translateY(-2px); }
.btn-primary::after { content: " \2192"; }
.btn-secondary { background: transparent; color: var(--text); border-color: var(--border); }
.btn-secondary:hover { border-color: var(--indigo); color: var(--indigo-strong); transform: translateY(-2px); }
.btn-secondary::after { content: " \2197"; }

/* =========================================================== INDEX: hero */
.site-header {
  padding: clamp(3rem, 7vw, 6rem) 0 clamp(2rem, 4vw, 3.5rem);
  background: linear-gradient(180deg, color-mix(in srgb, var(--indigo) 6%, var(--bg)), var(--bg));
  border-bottom: 1px solid var(--border);
}
.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr);
  gap: clamp(1.75rem, 4vw, 3.5rem);
  align-items: center;
}
.hero-title {
  font-size: clamp(2.6rem, 6vw, 4.6rem);
  font-weight: 800;
  line-height: 1.02;
  letter-spacing: -0.035em;
  margin: 0.3rem 0 1rem;
}
.hero-sub {
  color: var(--muted);
  font-size: clamp(1.08rem, 1.8vw, 1.26rem);
  line-height: 1.62;
  max-width: 48ch;
  margin: 0 0 1.9rem;
}
.hero-actions { display: flex; flex-wrap: wrap; gap: 0.75rem; }

/* The manifest artifact — an apm.yml card that reads as if resolving */
.manifest-artifact {
  margin: 0;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--ink);
  border: 1px solid var(--ink-border);
  box-shadow: var(--shadow);
}
.artifact-bar {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--ink-muted);
  background: var(--ink-2);
  border-bottom: 1px solid var(--ink-border);
  padding: 0.7rem 0.9rem;
}
.artifact-file { display: inline-flex; align-items: center; gap: 0.45rem; color: var(--ink-text); }
.artifact-file::before {
  content: "";
  width: 0.6rem; height: 0.6rem;
  border-radius: 2px;
  background: var(--ink-indigo);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--ink-indigo) 22%, transparent);
}
.artifact-stamp { margin-left: auto; display: inline-flex; align-items: center; gap: 0.35rem; color: var(--ink-amber); }
.artifact-stamp::before { content: "\2713"; }
.artifact-code {
  margin: 0;
  padding: 1.1rem 1.2rem;
  background: transparent;
  border: 0;
  border-radius: 0;
  font-size: 0.82rem;
  line-height: 1.7;
  overflow-x: auto;
}
.artifact-code code { font-family: var(--font-mono); color: var(--ink-text); background: none; border: 0; padding: 0; }
.reveal-line { display: block; white-space: pre; opacity: 1; }
.reveal-line .tok-c { color: var(--ink-muted); font-style: italic; }
.reveal-line .tok-k { color: var(--ink-amber); }
.reveal-line .tok-n { color: var(--ink-indigo); }
.reveal-line .tok-pin { color: var(--ink-amber); font-weight: 600; }
.reveal-line .tok-t { color: var(--ink-teal); }

/* ====================================================== INDEX: how to read */
.intro-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: clamp(1.35rem, 3vw, 2rem);
  margin: clamp(2rem, 4vw, 3rem) 0 2.75rem;
}
.intro-panel h2 { font-size: clamp(1.4rem, 2.4vw, 1.85rem); }
.intro-panel p { max-width: 74ch; color: var(--muted); }
.intro-panel p:last-child { margin-bottom: 0; }

/* ================================================ INDEX: parts + dep list */
.parts-intro { margin: 0 0 2rem; }
.parts-intro h2 { font-size: clamp(1.5rem, 2.6vw, 2rem); margin-bottom: 0.5rem; }
.parts-intro p { color: var(--muted); max-width: 66ch; margin: 0; }

.part { margin: 0 0 2.75rem; }
.part-head {
  display: flex;
  align-items: baseline;
  gap: 0.9rem;
  padding-bottom: 0.6rem;
  margin-bottom: 1.25rem;
  border-bottom: 1px solid var(--border);
}
.part-roman {
  font-family: var(--font-mono);
  font-size: 0.74rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--amber-strong);
  white-space: nowrap;
}
.part-title { font-size: clamp(1.3rem, 2.2vw, 1.7rem); margin: 0; }

.dep-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.9rem; }
.dep-entry {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.5rem 1rem;
  align-items: start;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem 1.25rem;
  position: relative;
  transition: border-color 140ms ease, transform 140ms ease, box-shadow 140ms ease;
}
.dep-entry:hover {
  border-color: color-mix(in srgb, var(--indigo) 45%, var(--border));
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
}
.dep-pin { padding-top: 0.2rem; }
.dep-body { min-width: 0; }
.dep-title { font-family: var(--font-display); font-size: 1.2rem; font-weight: 600; letter-spacing: -0.01em; margin: 0 0 0.3rem; }
.dep-title a { color: var(--text); text-decoration: none; }
.dep-title a:hover { color: var(--indigo-strong); }
/* Stretched link — the whole entry is one click target for its chapter */
.dep-title a::after { content: ""; position: absolute; inset: 0; z-index: 1; }
.dep-entry:hover .dep-title a,
.dep-entry:focus-within .dep-title a { color: var(--indigo-strong); }
.dep-entry:focus-within {
  border-color: color-mix(in srgb, var(--indigo) 45%, var(--border));
  box-shadow: var(--shadow-sm);
}
.dep-title a:focus-visible { outline: 2px solid var(--indigo); outline-offset: 4px; border-radius: 3px; }
.dep-objective { color: var(--muted); margin: 0 0 0.75rem; max-width: 72ch; }

/* Typed field tags — apm_features rendered as manifest keys (machine voice) */
.field-tags { display: flex; flex-wrap: wrap; gap: 0.4rem; list-style: none; margin: 0; padding: 0; }
.field-tags li {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--amber-strong);
  background: color-mix(in srgb, var(--amber) 11%, transparent);
  border: 1px solid color-mix(in srgb, var(--amber) 28%, var(--border));
  border-radius: 6px;
  padding: 0.1rem 0.42rem;
}
/* Overflow summary — quiet, so it reads as a count, not another feature */
.field-tags li.field-tags-more {
  color: var(--muted);
  background: transparent;
  border-color: var(--border);
}

/* ================================= INDEX: the resolution path (part map) */
/* Renders the chapter spine motif on the index: a connected row of part
   nodes, each anchoring to its section, so any part is one click away. */
.resolution-path { margin: 0 0 2.5rem; }
.spine-track {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  --spine-gap: 0.4rem;
  --spine-pad-y: 0.9rem;
  --spine-pad-x: 0.55rem;
  --spine-dot: 0.72rem;
  --spine-line: calc(var(--spine-pad-y) + var(--spine-dot) / 2);
  gap: var(--spine-gap);
}
.spine-node { position: relative; }
.spine-node:not(:last-child)::before {
  content: "";
  position: absolute;
  z-index: 0;
  top: var(--spine-line);
  left: 50%;
  width: calc(100% + var(--spine-gap));
  height: 2px;
  background: color-mix(in srgb, var(--indigo) 32%, var(--border));
}
.spine-link {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  text-align: center;
  padding: var(--spine-pad-y) var(--spine-pad-x) 0.8rem;
  border-radius: var(--radius-sm);
  text-decoration: none;
  color: var(--text);
  transition: background 140ms ease, transform 140ms ease;
}
.spine-dot {
  width: var(--spine-dot);
  height: var(--spine-dot);
  border-radius: 50%;
  box-sizing: border-box;
  border: 2px solid color-mix(in srgb, var(--indigo) 55%, var(--border));
  background: var(--surface);
  transition: transform 140ms ease, background 140ms ease, border-color 140ms ease, box-shadow 140ms ease;
}
.spine-text { display: flex; flex-direction: column; gap: 0.28rem; align-items: center; }
.spine-meta { display: inline-flex; align-items: baseline; gap: 0.45rem; flex-wrap: wrap; justify-content: center; }
.spine-part {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--amber-strong);
  white-space: nowrap;
}
.spine-pins { font-family: var(--font-mono); font-size: 0.66rem; color: var(--muted); white-space: nowrap; }
.spine-title {
  font-family: var(--font-display);
  font-size: 0.9rem;
  font-weight: 500;
  line-height: 1.28;
  letter-spacing: -0.01em;
  color: var(--text);
  max-width: 15ch;
  text-wrap: balance;
}
.spine-link:hover { background: var(--surface-2); transform: translateY(-1px); }
.spine-link:hover .spine-dot,
.spine-link:focus-visible .spine-dot {
  background: var(--indigo);
  border-color: var(--indigo);
  transform: scale(1.18);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--indigo) 20%, transparent);
}
.spine-link:hover .spine-title { color: var(--indigo-strong); }
.spine-link:focus-visible { outline: 2px solid var(--indigo); outline-offset: 3px; }
/* the h2 anchor lands with breathing room below the map */
.part-title { scroll-margin-top: 1.5rem; }

/* ====================================== INDEX: reading paths (the on-ramp) */
/* Two entry points in one panel: the developer path and the leader path,
   both visible and enterable. The leader lane carries the indigo aside cue. */
.reading-paths {
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin: 1.4rem 0 0;
}
.reading-path { display: flex; flex-direction: column; gap: 0.4rem; padding: 1.05rem 1.2rem; }
.reading-path + .reading-path { border-left: 1px solid var(--border); }
.reading-path--leader { background: color-mix(in srgb, var(--indigo) 5%, var(--surface)); }
.path-lane-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0;
}
.reading-path--leader .path-lane-label { color: var(--indigo); }
.reading-path--leader .path-lane-label::before { content: "\25c6"; font-size: 0.7em; }
.reading-path p:not(.path-lane-label) { color: var(--muted); margin: 0; font-size: 0.95rem; }
.path-link {
  align-self: flex-start;
  margin-top: 0.15rem;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--indigo-strong);
  text-decoration: none;
}
.path-link::after { content: " \2192"; }
.path-link:hover { text-decoration: underline; }
.reading-note { color: var(--muted); margin: 0.9rem 0 0; font-size: 0.92rem; }

/* ============================================= CHAPTER PAGE: shell + spine */
.page-shell { display: grid; grid-template-columns: var(--sidebar-width) minmax(0, 1fr); min-height: 100vh; }
.sidebar { background: var(--surface); border-right: 1px solid var(--border); }
.sidebar-inner { position: sticky; top: 0; max-height: 100vh; overflow-y: auto; padding: 1.5rem 1.25rem; }
.site-title {
  display: block;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: -0.02em;
  line-height: 1.2;
  color: var(--text);
  text-decoration: none;
}
.site-title:hover { color: var(--indigo); }
.sidebar-tagline {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin: 0.35rem 0 1.5rem;
}

/* The resolution spine: chapters as a resolved dependency path */
.chapter-nav ol {
  list-style: none;
  margin: 0;
  padding: 0;
  position: relative;
  --spine-x: 0.9rem;
  --node-top: 1.05rem;
}
.chapter-nav li { position: relative; }
.chapter-nav li::before {
  content: "";
  position: absolute;
  left: var(--spine-x);
  top: 0;
  height: 100%;
  width: 2px;
  transform: translateX(-50%);
  background: var(--border);
  z-index: 0;
}
.chapter-nav li:first-child::before { top: var(--node-top); height: calc(100% - var(--node-top)); }
.chapter-nav li:last-child::before { height: var(--node-top); }
.chapter-nav li[data-state="resolved"]::before,
.chapter-nav li[data-state="current"]::before { background: color-mix(in srgb, var(--indigo) 55%, var(--border)); }

.chapter-nav li::after {
  content: "";
  position: absolute;
  left: var(--spine-x);
  top: var(--node-top);
  width: 0.62rem; height: 0.62rem;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: var(--surface);
  transform: translate(-50%, -50%);
  box-sizing: border-box;
  z-index: 1;
  transition: transform 140ms ease, box-shadow 140ms ease, border-color 140ms ease, background 140ms ease;
}
.chapter-nav li[data-state="resolved"]::after { background: var(--indigo); border-color: var(--indigo); opacity: 0.5; }
.chapter-nav li[data-state="current"]::after {
  background: var(--indigo);
  border-color: var(--indigo);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--indigo) 22%, transparent);
}
.chapter-nav li:hover::after { border-color: var(--indigo); transform: translate(-50%, -50%) scale(1.18); }

.chapter-nav a {
  display: flex;
  align-items: flex-start;
  gap: 0.55rem;
  padding: 0.5rem 0.55rem 0.5rem calc(var(--spine-x) + 1.2rem);
  border-radius: 8px;
  text-decoration: none;
  color: var(--text);
}
.chapter-nav a:hover { background: var(--surface-2); }
.chapter-nav a.is-current { background: color-mix(in srgb, var(--indigo) 12%, transparent); }
.chapter-nav .pin-tag { margin-top: 0.06rem; }
.chapter-nav .chapter-name {
  font-family: var(--font-display);
  font-size: 0.92rem;
  font-weight: 500;
  line-height: 1.3;
  letter-spacing: -0.01em;
}
.chapter-nav a.is-current .chapter-name { color: var(--indigo-strong); font-weight: 600; }

/* Content column */
.content-shell { min-width: 0; }
.chapter-header {
  border-bottom: 1px solid var(--border);
  padding: clamp(1.75rem, 4vw, 3.25rem) clamp(1.25rem, 4vw, 3rem);
}
.breadcrumb { font-family: var(--font-mono); font-size: 0.78rem; color: var(--muted); margin-bottom: 1rem; }
.breadcrumb a { color: var(--muted); }
.breadcrumb a:hover { color: var(--indigo); }
.chapter-header h1 { margin-top: 0.2rem; }

.chapter-main { margin: 0 auto; max-width: 60rem; padding: clamp(1.5rem, 4vw, 3rem) clamp(1.25rem, 4vw, 3rem); }

/* Metadata panels (on this page / features / prerequisites) — machine metadata */
.chapter-meta { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem; margin-bottom: 2.25rem; }
.metadata-card { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 1rem 1.1rem; }
.metadata-card h2 {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 0.7rem;
}
.metadata-card ol, .metadata-card ul { margin: 0; padding-left: 1.1rem; }
.metadata-card li { margin: 0.3rem 0; }
.metadata-card li::marker { color: var(--amber); }
.metadata-card a { font-family: var(--font-mono); font-size: 0.8rem; }
.tag-list { display: flex; flex-wrap: wrap; gap: 0.4rem; list-style: none; margin: 0; padding: 0; }
.tag-list li {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--amber-strong);
  background: color-mix(in srgb, var(--amber) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--amber) 30%, var(--border));
  border-radius: 6px;
  padding: 0.12rem 0.45rem;
}
.tag-list li::marker { content: ""; }

/* Sections: flowing prose, divided by hairlines (a book, not boxes) */
.chapter-section { margin: 2.4rem 0; scroll-margin-top: 1.5rem; }
.chapter-section > h2 { position: relative; padding-top: 1.7rem; border-top: 1px solid var(--border); }
.chapter-section:first-of-type > h2 { padding-top: 0; border-top: 0; }
.anchor-link { color: inherit; text-decoration: none; }
.anchor-link:hover { color: var(--indigo); }
.anchor-link:hover::after { content: " #"; color: var(--indigo); font-family: var(--font-mono); }
.section-content { min-height: 2rem; }

.pending-note {
  background: color-mix(in srgb, var(--amber) 8%, var(--surface-2));
  border: 1px dashed color-mix(in srgb, var(--amber) 45%, var(--border));
  border-radius: var(--radius-sm);
  color: var(--muted);
  margin: 0;
  padding: 1rem;
}

/* ---------------------------------------------- authored prose typography */
.section-content > :first-child { margin-top: 0; }
.section-content > :last-child { margin-bottom: 0; }
.section-content p { margin: 0 0 1.15rem; }
.section-content p, .section-content li { max-width: 68ch; }
.section-content h3 { margin-top: 2rem; }
.section-content h4 { margin-top: 1.6rem; }
.section-content ul, .section-content ol { margin: 0 0 1.15rem; padding-left: 1.3rem; }
.section-content li { margin: 0.35rem 0; }
.section-content li::marker { color: var(--amber); }
.section-content strong { font-weight: 600; }
.section-content em { font-style: italic; }

.section-content table { border-collapse: collapse; width: 100%; margin: 1.6rem 0; font-size: 0.92rem; }
.section-content caption { caption-side: bottom; color: var(--muted); font-family: var(--font-mono); font-size: 0.8rem; padding-top: 0.6rem; text-align: left; }
.section-content th, .section-content td { border: 1px solid var(--border); padding: 0.6rem 0.75rem; text-align: left; vertical-align: top; }
.section-content thead th { background: var(--surface-2); font-family: var(--font-display); font-weight: 600; font-size: 0.9rem; }
.section-content tbody tr:nth-child(even) { background: color-mix(in srgb, var(--surface-2) 55%, transparent); }
.section-content blockquote {
  position: relative;
  margin: 1.6rem 0;
  padding: 0.15rem 0 0.15rem 2.15rem;
  color: var(--muted);
  font-style: italic;
}
.section-content blockquote::before {
  content: "\201C";
  position: absolute;
  left: 0;
  top: 0.3rem;
  font-family: var(--font-display);
  font-size: 2.3rem;
  line-height: 1;
  color: color-mix(in srgb, var(--indigo) 42%, transparent);
}
.section-content blockquote > :last-child { margin-bottom: 0; }

/* ------------------------------------------------- code as artifact cards */
pre {
  margin: 1.6rem 0;
  background: var(--ink);
  color: var(--ink-text);
  border: 1px solid var(--ink-border);
  border-radius: var(--radius-sm);
  padding: 1rem 1.1rem;
  overflow-x: auto;
  font-size: 0.86rem;
  line-height: 1.65;
}
code { font-family: var(--font-mono); font-size: 0.95em; }
pre code { font-family: var(--font-mono); }
:not(pre) > code {
  font-family: var(--font-mono);
  font-size: 0.86em;
  background: color-mix(in srgb, var(--amber) 10%, var(--surface-2));
  border: 1px solid color-mix(in srgb, var(--amber) 22%, var(--border));
  border-radius: 5px;
  padding: 0.06em 0.34em;
  color: var(--text);
}

.code-block { position: relative; }
.copy-code {
  position: absolute;
  right: 0.6rem; top: 0.6rem;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  background: rgba(255, 255, 255, 0.08);
  color: var(--ink-text);
  border: 1px solid var(--ink-border);
  border-radius: 7px;
  padding: 0.25rem 0.55rem;
  cursor: pointer;
  opacity: 0.82;
  transition: opacity 140ms ease, background 140ms ease;
}
.copy-code:hover { opacity: 1; background: rgba(255, 255, 255, 0.16); }

.code-example {
  background: var(--ink);
  border: 1px solid var(--ink-border);
  border-radius: var(--radius);
  margin: 1.9rem 0;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.code-example > figcaption {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  line-height: 1.6;
  color: var(--ink-muted);
  background: var(--ink-2);
  border-bottom: 1px solid var(--ink-border);
  padding: 0.65rem 0.9rem;
}
.code-example > figcaption code { background: rgba(255, 255, 255, 0.07); border: 0; color: var(--ink-text); font-size: 0.9em; padding: 0.05em 0.3em; }
.code-example > figcaption em { color: var(--ink-text); font-style: italic; }
.code-example > figcaption a { color: var(--ink-indigo); }
.code-example pre { margin: 0; border: 0; border-radius: 0; }
.code-example .code-block { border-radius: 0; }

/* Amber machine stamp (version) + distinct "needs network" badge, on ink */
.apm-version {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--ink-amber);
  background: color-mix(in srgb, var(--ink-amber) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--ink-amber) 32%, transparent);
  border-radius: 6px;
  padding: 0.1rem 0.45rem;
  margin-left: auto;
  white-space: nowrap;
}
.needs-network {
  font-family: var(--font-mono);
  font-size: 0.62rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-amber);
  background: color-mix(in srgb, var(--ink-amber) 15%, transparent);
  border: 1px solid color-mix(in srgb, var(--ink-amber) 45%, transparent);
  border-radius: 999px;
  padding: 0.12rem 0.5rem;
  white-space: nowrap;
}
.needs-network::before { content: "\25d0 "; }

/* highlight.js — retheme tokens to the ink palette (keys = amber machine voice) */
.hljs { color: var(--ink-text); background: transparent; }
.hljs-comment, .hljs-quote { color: var(--ink-muted); font-style: italic; }
.hljs-keyword, .hljs-selector-tag, .hljs-literal, .hljs-section, .hljs-name, .hljs-doctag { color: var(--ink-indigo); }
.hljs-built_in, .hljs-title, .hljs-title.function_, .hljs-function .hljs-title, .hljs-type { color: var(--ink-teal); }
.hljs-string, .hljs-regexp, .hljs-addition, .hljs-meta .hljs-string { color: var(--ink-green); }
.hljs-number, .hljs-symbol, .hljs-bullet, .hljs-link { color: var(--ink-amber); }
.hljs-attr, .hljs-attribute, .hljs-selector-attr, .hljs-selector-class, .hljs-selector-id { color: var(--ink-amber); }
.hljs-variable, .hljs-template-variable, .hljs-params { color: var(--ink-violet); }
.hljs-meta { color: #7C88AC; }
.hljs-deletion { color: #E28A93; }
.hljs-emphasis { font-style: italic; }
.hljs-strong { font-weight: 700; }

/* --------------------------------------------------------------- callouts */
/* Leader aside — a quiet indigo-tinted margin note for leaders */
.leader-callout {
  background: color-mix(in srgb, var(--indigo) 5%, var(--surface-2));
  border: 1px solid color-mix(in srgb, var(--indigo) 30%, var(--border));
  border-radius: var(--radius);
  margin: 1.9rem 0;
  padding: 1.15rem 1.35rem;
}
.leader-callout > h3 {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--indigo);
  margin: 0 0 0.55rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.leader-callout > h3::before { content: "\25c6"; font-size: 0.7em; }
.leader-callout p { color: var(--muted); }
.leader-callout > :last-child { margin-bottom: 0; }

/* Meridian — the running thread; its node echoes the resolution spine */
.meridian-beat {
  position: relative;
  background: color-mix(in srgb, var(--indigo) 6%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--indigo) 26%, var(--border));
  border-radius: var(--radius);
  margin: 1.9rem 0;
  padding: 1.15rem 1.35rem;
}
.meridian-beat::before {
  content: "";
  position: absolute;
  left: -0.4rem; top: 1.4rem;
  width: 0.7rem; height: 0.7rem;
  border-radius: 50%;
  background: var(--indigo);
  border: 2px solid var(--surface);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--indigo) 22%, transparent);
}
.meridian-beat > h3 {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--indigo);
  margin: 0 0 0.55rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.meridian-beat > h3::before { content: "\25cf"; font-size: 0.6em; }
.meridian-beat > :last-child { margin-bottom: 0; }

/* General callouts — info (indigo) / warn (amber) */
.callout {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin: 1.6rem 0;
  padding: 1rem 1.25rem;
}
.callout > h3 { font-family: var(--font-display); font-size: 1.02rem; margin: 0 0 0.5rem; display: flex; align-items: center; gap: 0.5rem; }
.callout > :last-child { margin-bottom: 0; }
.callout-info { background: color-mix(in srgb, var(--indigo) 6%, var(--surface)); border-color: color-mix(in srgb, var(--indigo) 32%, var(--border)); }
.callout-info > h3 { color: var(--indigo); }
.callout-info > h3::before { content: "\24d8"; font-weight: 700; }
.callout-warn { background: color-mix(in srgb, var(--amber) 9%, var(--surface)); border-color: color-mix(in srgb, var(--amber) 40%, var(--border)); }
.callout-warn > h3 { color: var(--amber-strong); }
.callout-warn > h3::before { content: "\26a0"; }

/* ----------------------------------------------- four-property cue pills */
.property {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-family: var(--font-mono);
  font-size: 0.66rem;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.12rem 0.5rem 0.12rem 0.42rem;
  line-height: 1.5;
  vertical-align: baseline;
  white-space: nowrap;
}
.property::before { content: ""; width: 0.48rem; height: 0.48rem; border-radius: 50%; flex: none; }
.property--portability { border-color: color-mix(in srgb, var(--prop-portability) 45%, var(--border)); }
.property--portability::before { background: var(--prop-portability); }
.property--reproducibility { border-color: color-mix(in srgb, var(--prop-reproducibility) 45%, var(--border)); }
.property--reproducibility::before { background: var(--prop-reproducibility); }
.property--security { border-color: color-mix(in srgb, var(--prop-security) 45%, var(--border)); }
.property--security::before { background: var(--prop-security); }
.property--governance { border-color: color-mix(in srgb, var(--prop-governance) 45%, var(--border)); }
.property--governance::before { background: var(--prop-governance); }

/* ----------------------------------------------------------- pager/footer */
.pager { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin: 3rem 0 1rem; }
.pager-link {
  display: block;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.15rem;
  text-decoration: none;
  color: var(--text);
  font-size: 0.95rem;
  transition: border-color 140ms ease, transform 140ms ease, color 140ms ease;
}
.pager-link:hover { border-color: var(--indigo); transform: translateY(-2px); color: var(--indigo-strong); }
.pager-link[rel="next"] { text-align: right; }
.pager-link.is-disabled { color: var(--muted); border-style: dashed; }

.site-footer {
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.76rem;
  padding: 1.75rem 0;
  margin-top: 3rem;
}
.chapter-footer { padding: 1.75rem clamp(1.25rem, 4vw, 3rem); margin-top: 2rem; }
.site-footer a { color: var(--text); text-decoration: underline; text-underline-offset: 0.16em; }
.site-footer a:hover { color: var(--indigo-strong); }
.site-footer code {
  background: color-mix(in srgb, var(--amber) 10%, var(--surface-2));
  border: 1px solid color-mix(in srgb, var(--amber) 20%, var(--border));
  border-radius: 5px;
  padding: 0.05em 0.3em;
}

/* ----------------------------------------------------- responsive/mobile */
.sidebar-toggle { display: none; }

@media (max-width: 900px) {
  .page-shell { display: block; }
  .hero { grid-template-columns: minmax(0, 1fr); }
  .sidebar-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    position: fixed;
    right: 1rem; bottom: 1rem;
    z-index: 30;
    font-family: var(--font-mono);
    font-size: 0.85rem;
    font-weight: 500;
    background: var(--indigo);
    color: var(--on-indigo);
    border: 0;
    border-radius: 999px;
    padding: 0.7rem 1.05rem;
    cursor: pointer;
    box-shadow: var(--shadow);
  }
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(86vw, var(--sidebar-width));
    max-width: 24rem;
    transform: translateX(-105%);
    transition: transform 200ms ease;
    z-index: 25;
    box-shadow: var(--shadow);
  }
  .sidebar.is-open { transform: translateX(0); }
  .chapter-header { padding-top: 3.25rem; }
  .pager { grid-template-columns: 1fr; }
  .pager-link[rel="next"] { text-align: left; }
  .dep-entry { grid-template-columns: 1fr; }
  .dep-pin { padding-top: 0; }
}

@media (max-width: 760px) {
  /* The part map becomes a vertical spine — mirrors the chapter-nav rail */
  .spine-track { grid-template-columns: 1fr; gap: 0; }
  .spine-node:not(:last-child)::before {
    top: var(--spine-line);
    left: calc(var(--spine-pad-x) + var(--spine-dot) / 2);
    width: 2px;
    height: 100%;
    transform: translateX(-50%);
  }
  .spine-link {
    flex-direction: row;
    align-items: flex-start;
    text-align: left;
    gap: 0.7rem;
    padding: var(--spine-pad-y) var(--spine-pad-x);
  }
  .spine-text { align-items: flex-start; }
  .spine-meta { justify-content: flex-start; }
  .spine-title { max-width: none; }
}

@media (max-width: 620px) {
  .reading-paths { grid-template-columns: 1fr; }
  .reading-path + .reading-path { border-left: 0; border-top: 1px solid var(--border); }
}

@media (max-width: 520px) {
  .chapter-meta { grid-template-columns: 1fr; }
}

/* --------------------------------------------------------------- motion */
@keyframes reveal-line {
  from { opacity: 0; transform: translateY(9px); }
  to { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: no-preference) {
  .manifest-artifact.reveal-on .reveal-line {
    opacity: 0;
    animation: reveal-line 0.5s cubic-bezier(0.2, 0.7, 0.2, 1) forwards;
    animation-delay: calc(var(--i, 0) * 80ms);
  }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
