@layer reset, base, layout, components, utilities;

@layer reset {
  *, *::before, *::after { box-sizing: border-box; border-radius: 0; }
  html { scroll-behavior: smooth; }
  body, h1, h2, h3, h4, h5, h6, p, figure, dl, dd { margin: 0; }
  img { display: block; max-width: 100%; }
  button, input { font: inherit; }
  [hidden] { display: none !important; }
}

@layer base {
  :root {
    color-scheme: light;
    --canvas: #f0eafb;
    --ink: #302839;
    --violet: #644577;
    --surface: #ddd1ef;
    --muted: #5c4f66;
    --line: #a18aaf;
    --display: 'Avenir Next Condensed', 'Arial Narrow', Impact, sans-serif;
    --reading: Georgia, 'Times New Roman', serif;
  }
  body { background: var(--canvas); color: var(--ink); font: 400 19px/1.7 var(--reading); }
  h1, h2, h3, h4, h5, h6 { font-family: var(--display); font-weight: 700; line-height: 1.06; text-wrap: balance; }
  h1 { font-size: clamp(60px, 7.6vw, 108px); letter-spacing: -.025em; }
  h2 { font-size: clamp(38px, 4.2vw, 60px); letter-spacing: -.015em; }
  h3 { font-size: clamp(29px, 2.9vw, 40px); }
  p, li, dd { max-width: 66ch; }
  p + p { margin-top: 18px; }
  a { color: var(--violet); text-underline-offset: .22em; text-decoration-thickness: 1.5px; overflow-wrap: anywhere; }
  a[href] { display: inline-flex; align-items: center; min-height: 44px; min-width: 44px; max-width: 100%; }
  a:hover { text-decoration-thickness: 3px; }
  a:focus-visible, button:focus-visible, input:focus-visible { outline: 3px solid var(--violet); outline-offset: 5px; }
  button, input { min-height: 48px; min-width: 48px; }
  button { cursor: pointer; }
  button:disabled { cursor: default; }
  input { width: 100%; min-width: 0; color: var(--ink); background: var(--canvas); border: 2px solid var(--violet); padding: 12px 16px; }
  input::placeholder { color: var(--muted); opacity: 1; }
  ::selection { background: var(--violet); color: var(--canvas); }
  main[id], section[id], div[id], h2[id] { scroll-margin-top: 100px; }
}

@layer layout {
  .wrap { width: min(1240px, calc(100% - 96px)); margin-inline: auto; }
  .masthead { padding-block: 22px; }
  .masthead-inner { display: flex; justify-content: space-between; align-items: center; gap: 24px; }
  .wordmark { gap: 14px; color: var(--ink); text-decoration: none; font-family: var(--display); font-size: 25px; font-weight: 700; line-height: 1.2; }
  .wordmark::before { content: ''; width: 5px; height: 32px; background: var(--violet); flex: 0 0 auto; }
  .masthead-note { color: var(--muted); font-size: 17px; font-style: italic; }
  .rail { position: sticky; top: 0; z-index: 10; background: var(--canvas); border-block: 2px solid var(--line); }
  .rail-inner { display: flex; align-items: center; justify-content: space-between; gap: 28px; }
  .chapter-nav, .anchor-nav { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
  .chapter-nav a, .anchor-nav a { padding: 10px 15px; font-size: 17px; text-decoration: underline; text-decoration-color: transparent; white-space: nowrap; }
  .chapter-nav a[aria-current='page'] { color: var(--violet); font-weight: 700; box-shadow: inset 0 -4px var(--violet); }
  .chapter-nav a:hover, .anchor-nav a:hover { text-decoration-color: currentColor; }
  .anchor-nav a { color: var(--muted); padding-inline: 10px; }
  .hero { padding-block: 64px 74px; }
  .hero-grid { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); gap: 64px; align-items: center; }
  .hero-grid > * { min-width: 0; }
  .hero-copy { position: relative; }
  .hero h1 { max-width: 12ch; }
  .hero .intro { font-size: 21px; max-width: 43ch; margin-top: 28px; }
  .hero-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 20px 32px; margin-top: 32px; }
  .chapter-hero { padding-block: 32px 68px; }
  .chapter-hero h1 { max-width: 17ch; margin-top: 24px; }
  .chapter-hero .intro { max-width: 55ch; font-size: 21px; margin-top: 28px; }
  .panel { border-top: 2px solid var(--line); padding-block: 76px; }
  .panel-surface { background: var(--surface); }
  .margin-layout { display: grid; grid-template-columns: minmax(0, 210px) minmax(0, 1fr); gap: 72px; }
  .reading-column { min-width: 0; max-width: 780px; }
  .reading-column > h2 { margin-bottom: 30px; max-width: 21ch; }
  .reading-column > h3 { margin-block: 34px 16px; }
  .margin-notes { display: flex; flex-direction: column; gap: 30px; padding-top: 8px; }
  .margin-notes dt { color: var(--violet); font-weight: 700; font-size: 18px; line-height: 1.35; margin-bottom: 10px; }
  .margin-notes dd { font-size: 17px; color: var(--muted); line-height: 1.65; max-width: 25ch; }
  .note-rule { display: block; width: 64px; height: 4px; background: var(--violet); margin-bottom: 16px; }
  .route-list { margin-top: 34px; }
  .route-row { display: grid; grid-template-columns: 60px minmax(0, 1fr); gap: 28px; padding-block: 36px; border-top: 2px solid var(--line); }
  .route-row:last-child { border-bottom: 2px solid var(--line); }
  .route-row h3 { margin-bottom: 16px; }
  .route-marker { width: 56px; border-top: 4px solid var(--violet); padding-top: 10px; font: 700 42px/1 var(--display); color: var(--violet); }
  .reading-list { padding-left: 24px; margin-block: 18px; }
  .reading-list li { padding-left: 6px; margin-block: 14px; }
  .reading-list li::marker { color: var(--violet); }
  .question-pair { border-top: 2px solid var(--line); padding-block: 28px; }
  .question-pair h3 { margin-bottom: 14px; }
  .next-chapter { padding-block: 44px; background: var(--surface); border-top: 4px solid var(--violet); }
  .next-inner { display: flex; gap: 36px; justify-content: space-between; align-items: center; }
  .next-chapter p { max-width: 46ch; }
  .footer { padding-block: 40px 50px; border-top: 2px solid var(--line); }
  .footer-inner { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 44px; }
  .footer p { font-size: 17px; color: var(--muted); max-width: 62ch; }
  .footer-links { display: flex; gap: 8px; flex-wrap: wrap; align-items: start; }
  .footer-links a { font-size: 17px; padding-inline: 12px; }
}

@layer components {
  .skip-link { position: absolute; left: 24px; top: 16px; z-index: 30; background: var(--violet); color: var(--canvas); padding: 10px 18px; transform: translateY(-180%); }
  .skip-link:focus { transform: translateY(0); }
  .eyebrow { color: var(--violet); font-size: 18px; font-weight: 400; font-style: italic; margin-bottom: 22px; }
  .pill { padding: 15px 22px; background: var(--violet); color: var(--canvas); font-weight: 700; text-decoration: none; line-height: 1.4; min-height: 56px !important; }
  .pill:hover { background: #523661; }
  .pill::after { content: '↗'; margin-left: 20px; font-size: 23px; line-height: 1; }
  .text-link { gap: 16px; font-weight: 700; }
  .text-link::after { content: '→'; }
  .breadcrumb { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; color: var(--muted); font-size: 17px; }
  .breadcrumb a { padding-right: 8px; }
  .breadcrumb span[aria-current] { color: var(--ink); }
  /* Preserve the supplied photo targets; do not fabricate the missing assets. */
  .paper-stage { position: relative; margin-block: 10px 24px; border-block: 3px solid var(--violet); padding-block: 18px; }
  .collage-grain { width: 100%; height: auto; aspect-ratio: 5 / 4; object-fit: cover; object-position: center; background: var(--surface); color: transparent; }
  .route-circle { display: none; }
  .paper-caption { margin-top: 18px; color: var(--violet); font-size: 22px; font-style: italic; }
  .hero-definition { margin-top: 22px; }
  .hero-definition dt { color: var(--violet); font-weight: 700; font-size: 18px; margin-bottom: 8px; }
  .hero-definition dd { color: var(--muted); font-size: 18px; max-width: 40ch; }
  .prompt { border-left: 4px solid var(--violet); padding-left: 22px; font-style: italic; margin-block: 24px; }
  .source-link { display: inline-flex; color: var(--violet); font-size: 17px; padding-block: 8px; gap: 12px; margin-top: 8px; margin-right: 18px; }
  .source-link::after { content: '↗'; flex-shrink: 0; }
  .label-link { color: var(--violet); }
  .caution { border-block: 3px solid var(--violet); padding-block: 28px; margin-block: 34px; }
  .caution h3 { margin-bottom: 18px; }
  .emergency { font-size: 21px; font-weight: 700; color: var(--violet); }
  .price-block { padding-block: 28px; margin-block: 32px; border-block: 3px solid var(--violet); }
  .price-figure { font: 700 clamp(50px, 5.6vw, 80px)/1.1 var(--display); font-variant-numeric: tabular-nums; letter-spacing: -.02em; color: var(--violet); margin-block: 18px 24px; }
  .bridge-block .price-figure { color: var(--ink); }
  .study-row { padding: 32px 0; border-bottom: 2px solid var(--line); }
  .study-row:first-of-type { border-top: 2px solid var(--line); }
  .study-row h3 { margin-bottom: 22px; }
  .study-figure { font: 700 clamp(48px, 5.4vw, 78px)/1.1 var(--display); color: var(--violet); font-variant-numeric: tabular-nums; margin-block: 24px; }
  .glossary-tools { margin-block: 34px; padding-block: 26px; border-block: 3px solid var(--violet); }
  .glossary-tools label { display: block; font-weight: 700; margin-bottom: 12px; }
  .filter-line { display: flex; gap: 12px; align-items: stretch; }
  .filter-line button { flex: 0 0 auto; color: var(--canvas); background: var(--violet); border: 2px solid var(--violet); padding: 10px 18px; }
  .filter-line button:hover { background: #523661; }
  .filter-status { font-size: 17px; color: var(--muted); margin-top: 16px; min-height: 29px; }
  .glossary-list { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 28px 36px; }
  .glossary-item { border-top: 2px solid var(--line); padding-top: 20px; }
  .glossary-item dt { color: var(--violet); font-weight: 700; margin-bottom: 8px; }
  .glossary-item dd { font-size: 18px; }
  .source-entry { border-top: 2px solid var(--line); padding-block: 28px; }
  .source-entry h3 { margin-bottom: 16px; }
  .source-entry a { font-size: 17px; }
  .source-collage { width: 100%; margin-top: 40px; border-top: 3px solid var(--violet); padding-top: 20px; }
  .source-collage img { width: 100%; height: auto; aspect-ratio: 5 / 2; object-fit: cover; background: var(--surface); color: transparent; }
  .source-collage figcaption { color: var(--violet); font-size: 21px; font-style: italic; margin-top: 16px; }
  .next-chapter .pill { flex: 0 0 auto; }
  .not-found { padding-block: 54px 100px; }
  .not-found .eyebrow { margin-top: 24px; }
  .not-found h1 { max-width: 12ch; margin-block: 26px; }
  .not-found .hero-actions { margin-top: 36px; }
}

@layer utilities {
  .u-muted { color: var(--muted); }
  .u-lime { color: var(--violet); }
  .u-space-top { margin-top: 28px; }
  .u-prose { max-width: 66ch; }
  .u-nowrap { white-space: nowrap; }
  .u-sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
}

@media (max-width: 1000px) {
  .wrap { width: calc(100% - 56px); }
  .rail-inner { flex-wrap: wrap; gap: 0; padding-block: 6px; }
  .anchor-nav { gap: 4px; }
  .hero-grid { gap: 32px; }
  .margin-layout { grid-template-columns: minmax(0, 170px) minmax(0, 1fr); gap: 40px; }
  .footer-inner { grid-template-columns: minmax(0, 1fr); gap: 24px; }
}

@media (max-width: 650px) {
  main[id], section[id], div[id], h2[id] { scroll-margin-top: 24px; }
  body { font-size: 18px; }
  .wrap { width: calc(100% - 40px); }
  .masthead { padding-block: 16px; }
  .masthead-inner { gap: 12px; flex-wrap: wrap; }
  .masthead-note { font-size: 16px; }
  .wordmark { font-size: 23px; }
  .rail { position: static; }
  .chapter-nav { display: grid; width: 100%; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 4px; }
  .chapter-nav a { justify-content: center; padding: 10px 4px; }
  .anchor-nav { width: 100%; justify-content: space-between; gap: 0; margin-top: 4px; }
  .anchor-nav a { padding-inline: 4px; font-size: 15px; }
  .hero { padding-block: 36px 48px; }
  .hero-grid { grid-template-columns: minmax(0, 1fr); gap: 36px; }
  .hero h1 { font-size: clamp(52px, 14vw, 78px); max-width: 12ch; }
  .hero .intro, .chapter-hero .intro { font-size: 19px; margin-top: 24px; }
  .hero-actions { gap: 16px 24px; margin-top: 28px; }
  .pill { padding-inline: 18px; }
  .paper-stage { margin-block: 0 24px; }
  .collage-grain { aspect-ratio: 5 / 3; }
  .chapter-hero { padding-block: 22px 44px; }
  .chapter-hero h1 { font-size: clamp(52px, 14vw, 72px); }
  .panel { padding-block: 48px; }
  .margin-layout { display: flex; flex-direction: column; gap: 36px; }
  .margin-notes { order: 2; flex-direction: row; flex-wrap: wrap; gap: 24px; border-top: 2px solid var(--line); padding-top: 24px; }
  .margin-notes dl { flex: 1 1 180px; }
  .margin-notes dd { max-width: 38ch; }
  .note-rule { display: none; }
  .reading-column > h2 { margin-bottom: 24px; }
  .route-row { grid-template-columns: 38px minmax(0, 1fr); gap: 16px; padding-block: 28px; }
  .route-marker { width: 38px; font-size: 34px; }
  .price-figure { font-size: clamp(48px, 13vw, 64px); }
  .filter-line { flex-wrap: wrap; }
  .filter-line button { width: 100%; }
  .glossary-list { grid-template-columns: minmax(0, 1fr); }
  .next-inner { flex-direction: column; align-items: start; }
  .next-chapter { padding-block: 32px; }
  .next-chapter .pill { flex-shrink: 1; }
  .footer { padding-block: 32px; }
  .footer-links a { padding-inline: 10px; }
  .not-found { padding-block: 32px 64px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

@media print {
  body { background: #ffffff; color: #000000; font-size: 12pt; }
  .rail, .skip-link, .paper-stage, .source-collage, .glossary-tools, .hero-actions, .next-chapter, .footer-links { display: none; }
  .wrap { width: 100%; }
  .panel, .chapter-hero, .hero, .footer { padding-block: 20px; }
  .panel-surface, .price-block, .caution, .margin-notes { background: transparent; }
  .margin-layout, .hero-grid { display: block; }
  .margin-notes { display: flex; flex-direction: row; margin-bottom: 22px; gap: 30px; }
  a, .source-link, .margin-notes dt, .margin-notes dd, .eyebrow, .price-figure, .study-figure, .emergency, .footer p, .u-muted, .glossary-item dt { color: #000000; }
  a[href] { min-height: 0; }
  h1 { font-size: 38pt; }
  h2 { font-size: 26pt; }
  h3 { font-size: 20pt; }
  .price-block, .caution, .glossary-item, .source-entry { break-inside: avoid; }
  .glossary-item[hidden] { display: block !important; }
}
