/* Django Internals — The Django Press & Blueprint Monograph.

   One committed look. Zero theme pickers. Zero JavaScript.

   Two roots give this book its shape: Django's deep forest green (#092E20) and its birthplace
   at the Lawrence Journal-World newspaper. Deep Forest anchors the sticky contents spine, the
   running masthead, and every live Django console exhibit; crisp mineral broadsheet paper
   (#F8FAF8) carries the reading column, the right-margin AST pointers, and computed blueprint
   plates.

   Four strict functional colour roles (never decoration):
     Pine Ink          prose, headings, and what application code writes ("The Promise")
     Django Emerald    Django's internal machinery, call paths, AST pointers, chapter emblems
     Press Brass       SQL, the database wire, and History / DEPs
     Crimson           traps, leaks, and silent failure modes
*/

@font-face {
  font-family: "Source Serif 4";
  font-style: normal;
  font-weight: 200 900;
  font-display: swap;
  src: url("fonts/source-serif-4-latin-wght-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Source Serif 4";
  font-style: italic;
  font-weight: 200 900;
  font-display: swap;
  src: url("fonts/source-serif-4-latin-wght-italic.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Source Serif 4";
  font-style: normal;
  font-weight: 200 900;
  font-display: swap;
  src: url("fonts/source-serif-4-latin-ext-wght-normal.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Source Serif 4";
  font-style: italic;
  font-weight: 200 900;
  font-display: swap;
  src: url("fonts/source-serif-4-latin-ext-wght-italic.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Source Sans 3";
  font-style: normal;
  font-weight: 200 900;
  font-display: swap;
  src: url("fonts/source-sans-3-latin-wght-normal.woff2") format("woff2");
}
@font-face {
  font-family: "Source Code Pro";
  font-style: normal;
  font-weight: 200 900;
  font-display: swap;
  src: url("fonts/source-code-pro-latin-wght-normal.woff2") format("woff2");
}

:root {
  color-scheme: light;

  /* The Django spine (dark forest chrome & live console slabs) */
  --forest: #092e20;
  --forest-deep: #061f15;
  --forest-mid: #0c4b33;
  --forest-line: #174b37;
  --forest-soft: #103a2a;

  /* Broadsheet reading surfaces */
  --paper: #f8faf8;
  --paper-plate: #ffffff;
  --paper-2: #edf3ef;
  --rule: #cfdcd4;
  --rule-2: #a9bfb2;

  /* 1. Pine Ink — prose & what application code writes ("The Promise") */
  --ink: #101d17;
  --ink-2: #465b50;
  --ink-3: #687e73;
  --on-dark: #f1f6f3;
  --on-dark-2: #a9c8b9;
  --on-dark-3: #7da694;

  /* 2. Django Emerald — framework machinery & AST pointers */
  --django: #0c4b33;
  --django-bright: #198258;
  --django-tint: #e8f5ee;
  --emerald: #44b78b;
  --emerald-hi: #80e5bc;

  /* 3. Press Brass — SQL, database wire, and History / DEPs */
  --brass: #8f4e06;
  --brass-mid: #c47a20;
  --brass-tint: #fbf4e7;
  --brass-hi: #f2c464;

  /* 4. Proofreader's Crimson — traps, leaks, and silent failures */
  --crimson: #ae251b;
  --crimson-mid: #d45246;
  --crimson-tint: #fdf0ef;
  --crimson-hi: #ff8578;

  /* Typography & grid geometry */
  --serif: "Source Serif 4", "Iowan Old Style", Georgia, serif;
  --sans: "Source Sans 3", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "Source Code Pro", ui-monospace, "Cascadia Mono", Consolas, monospace;

  --rail: 17.25rem;        /* 276px sticky Deep Forest spine */
  --measure: 37.5rem;      /* 600px reading column */
  --gap: 2.25rem;          /* 36px gutter before right margin */
  --margin: 11.5rem;       /* 184px right margin for AST pointers; total frame = 820px */
  --gutter: 1.25rem;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scroll-padding-top: 3.5rem; background: var(--forest); }
body {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto auto 1fr auto;
  grid-template-areas: "running" "beside" "main" "foot";
  min-height: 100vh;
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 1.0625rem;
  line-height: 1.62;
  font-optical-sizing: auto;
  font-kerning: normal;
  font-variant-numeric: lining-nums;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-wrap: break-word;
}
@media (min-width: 48em) { body { font-size: 1.125rem; } }

::selection { background: var(--django); color: var(--on-dark); }
a { color: var(--django); text-decoration: underline; text-decoration-color: color-mix(in srgb, var(--django-bright) 52%, transparent); text-decoration-thickness: 1.25px; text-underline-offset: 0.2em; }
a:hover { color: var(--forest); text-decoration-color: var(--forest); }
a:focus-visible, input:focus-visible { outline: 2px solid var(--django-bright); outline-offset: 2px; border-radius: 1px; }
strong { font-weight: 650; color: var(--ink); }
em { font-style: italic; }
.planned { color: var(--ink-3); }
.spoken { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.emblem { display: inline-block; width: 16px; height: 16px; flex: none; vertical-align: middle; }

/* ---- 1. Running Masthead (Deep Django Forest) ---------------------------------------------- */
.running {
  grid-area: running;
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 2.75rem;
  padding: 0 var(--gutter);
  background: var(--forest);
  color: var(--on-dark);
  border-bottom: 1px solid var(--forest-line);
  font-family: var(--sans);
  font-size: 0.78rem;
  font-weight: 550;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.crumbs { display: flex; align-items: center; gap: 0.65em; min-width: 0; white-space: nowrap; overflow: hidden; }
.crumbs a, .crumbs .here { display: inline-flex; align-items: center; gap: 0.5em; color: var(--on-dark-2); text-decoration: none; overflow: hidden; text-overflow: ellipsis; }
.crumbs a:hover { color: var(--on-dark); text-decoration: none; }
.crumbs .book { color: var(--on-dark); font-family: var(--serif); font-size: 0.96rem; font-weight: 650; letter-spacing: 0.01em; text-transform: none; flex: none; }
.crumbs .book .mark { display: inline-block; width: 0.55rem; height: 0.55rem; background: var(--emerald); flex: none; }
.crumbs .book:hover { color: var(--emerald-hi); }
.crumbs .chapter .emblem { color: var(--emerald); }
.crumbs .here { color: var(--on-dark); }
.crumbs .sep { color: var(--forest-line); font-weight: 400; }
.crumbs .no { color: var(--emerald); font-variant-numeric: tabular-nums; }
.running-meta { display: flex; align-items: center; gap: 0.9rem; flex: none; }
.version-pill {
  padding: 0.18rem 0.5rem;
  border: 1px solid var(--forest-line);
  background: var(--forest-deep);
  font-family: var(--mono);
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  text-transform: none;
  color: var(--emerald);
}
.open-contents { position: relative; cursor: pointer; color: var(--on-dark); user-select: none; padding: 0.25rem 0.5rem; border: 1px solid var(--forest-line); }
.open-contents input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.open-contents::after { content: " +"; color: var(--emerald); }
.open-contents:has(input:checked)::after { content: " \2212"; }
@media (max-width: 48em) {
  .crumbs .here, .crumbs .chapter + .sep, .version-pill { display: none; }
}

/* ---- 2. Sticky Left Book Directory (Deep Django Forest Spine) ------------------------------ */
.booknav {
  grid-area: beside;
  display: none;
  padding: 1.1rem var(--gutter) 1.5rem;
  background: var(--forest);
  color: var(--on-dark);
  border-bottom: 2px solid var(--emerald);
  font-family: var(--sans);
  font-size: 0.875rem;
  line-height: 1.34;
  font-variant-numeric: tabular-nums;
}
body:has(#_contents-open:checked) .booknav { display: block; }
.nav-title { display: none; }
.booknav ol { margin: 0; padding: 0; list-style: none; }
.booknav li { margin: 0; }
.booknav .part {
  margin: 1.35rem 0 0.45rem;
  padding-top: 0.85rem;
  border-top: 1px solid var(--forest-line);
  font-size: 0.68rem;
  font-weight: 650;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--on-dark-3);
}
.booknav .parts > li:first-child .part { margin-top: 0; padding-top: 0; border-top: 0; }
.booknav a, .booknav .planned {
  display: grid;
  grid-template-columns: 1.35rem 1.45rem minmax(0, 1fr);
  align-items: start;
  column-gap: 0.25rem;
  padding: 0.34rem 0.4rem 0.34rem 0.55rem;
  margin-left: -0.55rem;
  border-left: 2px solid transparent;
  color: var(--on-dark-2);
  text-decoration: none;
}
.booknav a .emblem { margin-top: 0.08rem; color: var(--emerald); opacity: 0.82; }
.booknav .planned { color: var(--on-dark-3); }
.booknav .planned .emblem { margin-top: 0.08rem; color: var(--on-dark-3); opacity: 0.55; }
.booknav a:hover { color: var(--on-dark); background: var(--forest-soft); }
.booknav a:hover .emblem { opacity: 1; }
.booknav .no { font-size: 0.84em; color: var(--on-dark-3); }
.booknav a[aria-current] {
  color: #ffffff;
  font-weight: 650;
  border-left-color: var(--emerald);
  background: var(--forest-deep);
}
.booknav a[aria-current] .no, .booknav a[aria-current] .emblem, .booknav .open > a .emblem { color: var(--emerald); opacity: 1; }
.booknav .open > a { color: var(--on-dark); font-weight: 600; }

.booknav .under { margin: 0.15rem 0 0.6rem 0.5rem; padding-left: 0.7rem; border-left: 1px solid var(--forest-line); font-size: 0.94em; }
.booknav .under a, .booknav .under .planned { grid-template-columns: 2.35rem minmax(0, 1fr); margin-left: -0.75rem; padding-left: 0.7rem; }
.booknav .headings { margin: 0.1rem 0 0.45rem 2.35rem; font-size: 0.9em; }
.booknav .headings a { display: block; padding: 0.2rem 0.35rem; margin-left: 0; border-left: 0; color: var(--on-dark-3); font-weight: 400; }
.booknav .headings a:hover { color: var(--emerald-hi); background: transparent; }
.booknav code { background: transparent; padding: 0; color: inherit; font-size: 0.9em; }

@media (min-width: 64em) {
  body {
    grid-template-columns: var(--rail) minmax(0, 1fr);
    grid-template-rows: auto 1fr auto;
    grid-template-areas: "running running" "beside main" "beside foot";
  }
  body::before {
    content: "";
    grid-area: beside;
    background: var(--forest);
    border-right: 1px solid var(--forest-line);
  }
  .booknav, body:has(#_contents-open:checked) .booknav {
    display: block;
    position: sticky;
    top: 2.75rem;
    align-self: start;
    min-height: calc(100vh - 2.75rem);
    max-height: calc(100vh - 2.75rem);
    overflow-y: auto;
    padding: 1.5rem 0.95rem 4rem 1.3rem;
    border-bottom: 0;
    border-right: 0;
    scrollbar-width: thin;
    scrollbar-color: var(--forest-line) transparent;
  }
  .open-contents { display: none; }
}

/* ---- 3. Main Reading Column & Right-Margin AST Pointers ------------------------------------ */
main { grid-area: main; min-width: 0; padding-bottom: 3.5rem; background: var(--paper); }

.flow {
  display: grid;
  grid-template-columns: minmax(var(--gutter), 1fr) minmax(0, var(--measure)) minmax(var(--gutter), 1fr);
}
.flow > * { grid-column: 2; min-width: 0; }

@media (min-width: 78em) {
  .flow {
    grid-template-columns:
      minmax(2rem, 0.75fr)
      minmax(0, var(--measure))
      var(--gap)
      var(--margin)
      minmax(2rem, 1fr);
  }
  .flow > .sources { grid-column: 4; align-self: start; margin: 0.25rem 0 0.75rem; padding: 0 0 0 0.85rem; border-top: 0; border-left: 1.5px solid color-mix(in srgb, var(--django-bright) 55%, var(--rule)); background: transparent; }
  .flow > .sources .src { display: block; margin-bottom: 0.55rem; }
  .flow > .sources .src:last-child { margin-bottom: 0; }
  .flow > .figure.wide,
  .flow > .table,
  .flow > .tabular,
  .flow > .exhibit,
  .flow > pre,
  .head > .contrast,
  .outline > h2,
  .outline > .group,
  .outline > ol,
  .contents > h2,
  .contents > .part,
  .turn > .turn-inner { grid-column: 2 / 5; }
}

/* ---- 4. Page Heads, Broadsheet Title & Chapter Openers ------------------------------------- */
.head { padding-top: 2.8rem; padding-bottom: 1.8rem; }
.head::after { content: ""; grid-column: 2 / -2; max-width: calc(var(--measure) + var(--gap) + var(--margin)); border-bottom: 1px solid var(--rule); margin-top: 1.75rem; }
@media (min-width: 78em) { .head::after { grid-column: 2 / 5; max-width: none; } }

.kicker {
  display: flex;
  align-items: center;
  gap: 0.6em;
  margin: 0 0 0.85rem;
  font-family: var(--sans);
  font-size: 0.76rem;
  font-weight: 650;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--django);
}
.kicker a { display: inline-flex; align-items: center; gap: 0.55em; color: inherit; text-decoration: none; }
.kicker a:hover { color: var(--forest); text-decoration: underline; }
.kicker .emblem { color: var(--django-bright); }
.kicker .no { color: var(--ink-2); font-variant-numeric: tabular-nums; }

h1 {
  margin: 0 0 0.75rem;
  font-size: 2.45rem;
  line-height: 1.09;
  font-weight: 650;
  letter-spacing: -0.018em;
  color: var(--ink);
  text-wrap: balance;
}
.lede {
  margin: 0;
  font-size: 1.2em;
  line-height: 1.48;
  color: var(--ink-2);
  text-wrap: pretty;
}

/* Front page masthead */
.title-page { padding-top: 3.6rem; }
.title-page .kicker {
  padding-top: 0.85rem;
  border-top: 3px solid var(--forest);
  box-shadow: inset 0 1px 0 0 var(--paper), inset 0 2px 0 0 var(--rule-2);
  margin-bottom: 1.25rem;
}
.title-page h1 { font-size: clamp(2.8rem, 5.6vw, 4.1rem); line-height: 1.01; letter-spacing: -0.025em; color: var(--forest); }
.title-page .lede { font-size: 1.28em; color: var(--ink); }
.edition {
  margin: 1.25rem 0 0;
  font-family: var(--sans);
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--ink-2);
}
.edition a { color: var(--django); font-family: var(--mono); font-size: 0.92em; }

/* Chapter opener: numeral + The Promise vs. The Machinery */
.opener { padding-top: 3.1rem; }
.opener .kicker .emblem { width: 28px; height: 28px; color: var(--forest); }
.opener .numeral {
  margin: 0.05rem 0 0.2rem -0.04em;
  font-size: 5rem;
  font-weight: 300;
  line-height: 0.92;
  letter-spacing: -0.03em;
  color: var(--django-bright);
  font-variant-numeric: lining-nums;
}
.opener h1 { font-size: 2.9rem; margin-bottom: 1.5rem; }
.contrast {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1.15rem;
  padding: 1.25rem 1.4rem;
  background: var(--paper-plate);
  border: 1px solid var(--rule);
  border-top: 3px solid var(--forest);
}
@media (min-width: 54em) {
  .contrast { grid-template-columns: minmax(0, 0.85fr) minmax(0, 1.15fr); gap: 2rem; align-items: start; }
}
.says {
  display: block;
  margin-bottom: 0.35rem;
  font-family: var(--sans);
  font-size: 0.7rem;
  font-style: normal;
  font-weight: 700;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.contrast .promise { margin: 0; font-size: 1.38em; line-height: 1.26; font-style: italic; color: var(--ink); text-wrap: balance; }
.contrast .promise q { quotes: "\201C" "\201D"; }
.contrast .lede { font-size: 1.04em; line-height: 1.52; color: var(--ink-2); padding-left: 0; }
.contrast .lede .says { color: var(--django-bright); }
@media (min-width: 54em) {
  .contrast .lede { padding-left: 1.5rem; border-left: 1px solid var(--rule); }
}

/* ---- 5. Prose, Headings, and Four-Part Architectural Stationery ---------------------------- */
.brief { padding-top: 0.6rem; }
.section { margin-top: 2.8rem; }
p { margin: 0 0 1em; text-wrap: pretty; }
ul, ol { margin: 0 0 1em; padding-left: 1.35em; }
li { margin: 0.3em 0; }
li::marker { color: var(--django-bright); }
blockquote { margin: 1.25em 0; padding: 0.1em 0 0.1em 1.2em; border-left: 2px solid var(--rule-2); color: var(--ink-2); font-style: italic; }
hr { border: 0; border-top: 1px solid var(--rule); margin: 2.4em 0; }

h2 {
  position: relative;
  margin: 0 0 0.85em;
  padding-top: 1.05rem;
  font-size: 1.58rem;
  line-height: 1.2;
  font-weight: 650;
  letter-spacing: -0.01em;
  color: var(--forest);
  border-top: 1px solid var(--rule);
  text-wrap: balance;
}
h2::before {
  content: "";
  position: absolute;
  left: 0;
  top: -1px;
  width: 2.6rem;
  height: 3px;
  background: var(--forest);
}
h3 { margin: 1.85em 0 0.5em; font-size: 1.15rem; line-height: 1.3; font-weight: 650; color: var(--ink); }

/* Part I · The Request: signal wire + emerald bar */
[data-part="1"] h2::before {
  width: 2.8rem;
  height: 3px;
  background: linear-gradient(90deg, var(--forest) 0 2.1rem, transparent 2.1rem 2.35rem, var(--django-bright) 2.35rem 100%);
}
/* Part II · The ORM: schema ledger double rule with brass-and-emerald tick */
[data-part="2"] h2 { border-top: 3px double var(--rule-2); }
[data-part="2"] h2::before {
  top: -3px;
  width: 4.5rem;
  height: 3px;
  background: linear-gradient(90deg, var(--django-bright) 0 2.6rem, var(--paper) 2.6rem 2.85rem, var(--brass-mid) 2.85rem 100%);
}
/* Part III · Presentation & Systems: typesetter's rule with square notch */
[data-part="3"] h2 { border-top: 1px solid var(--rule-2); }
[data-part="3"] h2::before {
  top: -0.22rem;
  width: 0.45rem;
  height: 0.45rem;
  background: var(--forest);
  box-shadow: 0.75rem 0 0 0 var(--django-bright), 1.5rem 0 0 0 var(--rule-2);
}
/* Part IV · In Practice: dashed fault-line rule with crimson mark */
[data-part="4"] h2 { border-top: 1px dashed var(--rule-2); }
[data-part="4"] h2::before {
  top: -2px;
  width: 2.6rem;
  height: 3px;
  background: linear-gradient(90deg, var(--crimson) 0 0.8rem, var(--forest) 0.8rem 100%);
}
.outline h2::before, .contents > h2::before { width: 2.6rem; height: 3px; top: -1px; background: var(--forest); box-shadow: none; }
.outline h2, .contents > h2 { border-top: 1px solid var(--rule); font-family: var(--sans); font-size: 0.78rem; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-2); }

/* ---- 6. Inline Code, Pointers, and Right-Margin AST Sources -------------------------------- */
code, pre { font-family: var(--mono); font-variant-ligatures: none; font-variant-numeric: normal; }
code {
  font-size: 0.85em;
  font-weight: 460;
  color: var(--django);
}
code.whole { white-space: nowrap; }
h1 code, h2 code, h3 code { font-size: 0.88em; font-weight: 500; }
a.pointer { color: var(--django); text-decoration: underline dotted var(--django-bright); text-underline-offset: 0.22em; }
a.pointer:hover { color: var(--forest); text-decoration-style: solid; }
a.pointer code { background: transparent; padding: 0; color: inherit; }

.sources {
  margin: -0.45rem 0 1.2rem;
  padding: 0.45rem 0.75rem;
  border-left: 2px solid var(--django-bright);
  background: var(--paper-2);
  font-family: var(--sans);
  font-size: 0.74rem;
  line-height: 1.35;
  color: var(--ink-2);
}
.sources .src { display: inline-block; margin: 0 1rem 0.2rem 0; color: inherit; text-decoration: none; }
.sources .src code { display: block; font-size: 0.96em; font-weight: 550; color: var(--django); background: transparent; padding: 0; }
.sources .src .in { display: block; font-size: 0.9em; color: var(--ink-3); }
.sources .src:hover code { color: var(--forest); text-decoration: underline; }
td a.src { color: inherit; text-decoration: none; }
td a.src code { display: block; background: transparent; padding: 0; }
td a.src .in { display: block; font-family: var(--sans); font-size: 0.82em; color: var(--ink-3); }

/* ---- 7. Code Listings & Recessed Deep-Forest Live Recording Exhibits ----------------------- */
pre {
  margin: 0.5rem 0 1.4rem;
  padding: 0.95rem 1.15rem;
  overflow-x: auto;
  background: var(--paper-plate);
  border: 1px solid var(--rule);
  border-left: 3px solid var(--ink);
  font-size: 0.84rem;
  line-height: 1.58;
  color: var(--ink);
}
pre code { font-size: inherit; color: inherit; background: transparent; padding: 0; }
pre[data-kind="sql"] { border-left-color: var(--brass); background: var(--brass-tint); color: var(--ink); }
pre[data-kind]:not([data-kind="text"])::before {
  content: attr(data-kind);
  float: right;
  margin: -0.15rem -0.15rem 0.4rem 1.2rem;
  font-family: var(--sans);
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-3);
}
pre[data-kind="sql"]::before { color: var(--brass); }

/* Recessed Deep-Forest Console Exhibit (Recorded / Measured on Django 6.1.3) */
.exhibit {
  margin: 1.5rem 0 1.85rem;
  border: 1px solid var(--forest);
  background: var(--forest);
  box-shadow: 0 2px 10px rgba(9, 46, 32, 0.08);
}
.exhibit figcaption {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  margin: 0;
  padding: 0.55rem 1.1rem;
  background: var(--forest-deep);
  border-bottom: 1px solid var(--forest-line);
  font-family: var(--sans);
  font-size: 0.72rem;
  font-weight: 650;
  letter-spacing: 0.11em;
  text-transform: uppercase;
  color: var(--on-dark);
}
.exhibit .what::before {
  content: "";
  display: inline-block;
  width: 0.52rem;
  height: 0.52rem;
  margin-right: 0.55rem;
  background: var(--emerald);
  vertical-align: -0.05em;
}
.exhibit .name, .exhibit .program {
  font-family: var(--mono);
  font-size: 0.95em;
  font-weight: 500;
  letter-spacing: 0.01em;
  text-transform: none;
  color: var(--on-dark-2);
}
.exhibit .name { margin-left: auto; }
.exhibit figcaption a { color: inherit; text-decoration: none; }
.exhibit figcaption a:hover { color: var(--emerald-hi); text-decoration: underline; }
.exhibit pre {
  margin: 0;
  padding: 1rem 1.15rem 1.1rem;
  border: 0;
  background: var(--forest);
  color: var(--emerald-hi);
  font-size: 0.83rem;
  line-height: 1.62;
  scrollbar-width: thin;
  scrollbar-color: var(--forest-line) transparent;
}
.exhibit pre ::selection { background: var(--emerald); color: var(--forest-deep); }
.exhibit .call { color: var(--on-dark); font-weight: 550; }
.exhibit .sql { color: var(--brass-hi); }
.exhibit .fault { color: var(--crimson-hi); font-weight: 550; }
.exhibit .gap { color: var(--on-dark-3); }

/* ---- 8. Five Semantic Notes ---------------------------------------------------------------- */
.note {
  --kind: var(--django);
  --wash: var(--paper-2);
  margin: 1.5rem 0 1.65rem;
  padding: 0.9rem 1.2rem 0.95rem 1.25rem;
  background: var(--wash);
  border-left: 3px solid var(--kind);
  font-size: 0.95em;
  line-height: 1.56;
  color: var(--ink);
}
.note > :last-child { margin-bottom: 0; }
.note > p { margin: 0 0 0.7em; }
.note > p:first-child > strong:first-child {
  display: flex;
  align-items: center;
  gap: 0.55em;
  margin: 0 0 0.42rem;
  font-family: var(--sans);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--kind);
}
.note > p:first-child > strong:first-child::before { content: ""; flex: none; width: 0.58rem; height: 0.58rem; }

/* Why: Deep Forest + three dots of "because" */
.note[data-kind="why"] { --kind: var(--django); --wash: var(--paper-2); }
.note[data-kind="why"] > p:first-child > strong:first-child::before {
  background:
    radial-gradient(circle at 50% 18%, var(--kind) 0 0.095rem, transparent 0.11rem),
    radial-gradient(circle at 18% 82%, var(--kind) 0 0.095rem, transparent 0.11rem),
    radial-gradient(circle at 82% 82%, var(--kind) 0 0.095rem, transparent 0.11rem);
}
/* History: Press Brass + point on a timeline */
.note[data-kind="history"] { --kind: var(--brass); --wash: var(--brass-tint); }
.note[data-kind="history"] > p:first-child > strong:first-child::before {
  width: 0.9rem;
  background:
    linear-gradient(var(--kind), var(--kind)) center / 100% 1.5px no-repeat,
    radial-gradient(circle at 50% 50%, var(--kind) 0 0.15rem, transparent 0.17rem);
}
/* Trap: Proofreader's Crimson + double rule + warning triangle */
.note[data-kind="trap"] { --kind: var(--crimson); --wash: var(--crimson-tint); border-left: 4px double var(--crimson); }
.note[data-kind="trap"] > p:first-child > strong:first-child::before {
  width: 0; height: 0;
  border: 0.34rem solid transparent; border-top: 0; border-bottom: 0.58rem solid var(--kind);
}
/* Deeper: quiet dashed rule + downward point */
.note[data-kind="deeper"] { --kind: var(--ink-2); --wash: transparent; border-left: 1.5px dashed var(--rule-2); padding-top: 0.25rem; padding-bottom: 0.25rem; font-size: 0.92em; color: var(--ink-2); }
.note[data-kind="deeper"] > p:first-child > strong:first-child::before {
  width: 0; height: 0;
  border: 0.3rem solid transparent; border-bottom: 0; border-top: 0.48rem solid var(--kind);
}
/* Changed / New in 6.x: Django Emerald + rotated delta diamond */
.note[data-kind="changed"] { --kind: var(--django-bright); --wash: var(--django-tint); }
.note[data-kind="changed"] > p:first-child > strong:first-child::before {
  width: 0.46rem; height: 0.46rem; background: var(--kind); transform: rotate(45deg);
}

/* ---- 9. Tables ----------------------------------------------------------------------------- */
.table { margin: 1.35rem 0 1.65rem; overflow-x: auto; }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9em;
  line-height: 1.46;
  font-variant-numeric: tabular-nums lining-nums;
  border-top: 2px solid var(--forest);
  border-bottom: 1.5px solid var(--forest);
}
thead th {
  padding: 0.65rem 0.9rem 0.55rem;
  text-align: left;
  vertical-align: bottom;
  white-space: nowrap;
  background: var(--paper-2);
  font-family: var(--sans);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--forest);
  border-bottom: 1px solid var(--rule-2);
}
thead th code { text-transform: none; letter-spacing: 0; background: transparent; padding: 0; }
td { padding: 0.58rem 0.9rem; vertical-align: top; border-bottom: 1px solid var(--rule); }
tbody tr:last-child td { border-bottom: 0; }
th:first-child, td:first-child { padding-left: 0.5rem; }
.tabular { margin: 1.65rem 0 1.9rem; }
.tabular .table { margin: 0.6rem 0 0; }
.tabular figcaption { font-family: var(--sans); font-size: 0.84rem; line-height: 1.45; color: var(--ink-2); }
.tabular figcaption .no { font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--forest); margin-right: 0.5em; }
td > .label { display: none; }

@media (max-width: 48em) {
  .stacks table, .stacks tbody, .stacks tr, .stacks td { display: block; }
  .stacks thead { display: none; }
  .stacks tr { padding: 0.75rem 0 0.85rem; border-bottom: 1px solid var(--rule); }
  .stacks td { padding: 0; border: 0; }
  .stacks td:empty { display: none; }
  .stacks td:first-child { font-weight: 650; color: var(--forest); }
  .stacks td + td { display: flow-root; margin-top: 0.35rem; padding-left: 7.2rem; }
  .stacks td > .label {
    display: block; float: left; width: 6.6rem; margin-left: -7.2rem; padding-top: 0.2rem;
    font-family: var(--sans); font-size: 0.68rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-3);
  }
}

/* ---- 10. Computed Architectural SVG Plates ------------------------------------------------- */
.figure {
  margin: 1.9rem 0 2.15rem;
  background: var(--paper-plate);
  border: 1px solid var(--rule-2);
  border-top: 2px solid var(--forest);
}
.figure .art { padding: 20px 18px 18px; overflow-x: auto; scrollbar-width: thin; scrollbar-color: var(--rule-2) transparent; }
.figure svg { display: block; width: 100%; max-width: var(--natural); min-width: calc(var(--natural) * 0.74); height: auto; margin: 0 auto; overflow: visible; }
.figure figcaption {
  margin: 0;
  padding: 0.75rem 1.25rem 0.8rem;
  border-top: 1px solid var(--rule);
  background: var(--paper-2);
  font-family: var(--sans);
  font-size: 0.84rem;
  line-height: 1.48;
  color: var(--ink-2);
}
.figure figcaption .no {
  margin-right: 0.65em;
  font-weight: 700;
  font-size: 0.82em;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--forest);
}

/* Architectural plate SVG grammar (classes only — zero inline colours) */
.fig {
  --pen: var(--django);
  --pen-hi: var(--django-bright);
  --pen-lo: #6ca089;
  --pen-fill: var(--django-tint);
}
.fig .sql, .fig .past {
  --pen: var(--brass);
  --pen-hi: var(--brass-mid);
  --pen-lo: #d29c56;
  --pen-fill: var(--brass-tint);
}
.fig .trap, .fig .fault {
  --pen: var(--crimson);
  --pen-hi: var(--crimson-mid);
  --pen-lo: #df867e;
  --pen-fill: var(--crimson-tint);
}
.fig .promise {
  --pen: var(--ink);
  --pen-hi: var(--ink);
  --pen-lo: var(--ink-3);
  --pen-fill: var(--paper-2);
}
.fig text { font-family: var(--sans); font-size: 13px; font-weight: 450; fill: var(--ink); font-variant-numeric: lining-nums tabular-nums; }
.fig .label { font-size: 10.5px; font-weight: 700; letter-spacing: 0.11em; text-transform: uppercase; fill: var(--ink-2); }
.fig .val { font-family: var(--mono); font-size: 12.5px; font-weight: 550; fill: var(--pen); }
.fig .big { font-size: 17px; font-weight: 650; }
.fig .small { font-size: 11.5px; }
.fig .val.small { font-size: 11px; }
.fig text.hi { fill: var(--forest); font-weight: 650; }
.fig text.lo { fill: var(--ink-3); }
.fig .val.hi { fill: var(--pen); font-weight: 700; }
.fig .val.lo { fill: var(--pen-lo); }
.fig .wire { fill: none; stroke: var(--pen); stroke-width: 1.4; }
.fig .wire.hi { stroke: var(--pen-hi); stroke-width: 2; }
.fig .wire.lo { stroke: var(--pen-lo); stroke-width: 1; }
.fig .wire.dash { stroke-dasharray: 4 3; }
.fig .cell { fill: var(--paper-plate); stroke: var(--pen-lo); stroke-width: 1; }
.fig .cell.on { fill: var(--pen-fill); stroke: var(--pen); stroke-width: 1.35; }
.fig .cell.solid { fill: var(--pen); stroke: var(--pen); stroke-width: 1; }
.fig .cell.off { fill: var(--paper); stroke: var(--rule-2); stroke-dasharray: 3 3; }
.fig .hatch { fill: none; stroke: var(--pen-lo); stroke-width: 0.9; opacity: 0.55; }
.fig .pip { fill: var(--pen); stroke: none; }
.fig .story { fill: var(--paper); stroke: var(--ink); stroke-width: 1.35; }
.fig .dim { fill: none; stroke: var(--ink-3); stroke-width: 1; }
.fig .dim.dash { stroke-dasharray: 2 3; }
.fig .grid { fill: none; stroke: var(--rule); stroke-width: 1; }
.fig .head { fill: var(--ink-3); stroke: none; }
.fig .head.pen { fill: var(--pen); }
.fig .inv { fill: var(--on-dark); }

/* ---- 11. Chapter Outline & Front Page Contents --------------------------------------------- */
.outline { margin-top: 2.8rem; }
.outline ol { margin: 0; padding: 0; list-style: none; }
.outline li {
  display: grid;
  grid-template-columns: 3.1rem minmax(0, 1fr);
  column-gap: 0.5rem;
  padding: 0.85rem 0 0.9rem;
  border-bottom: 1px solid var(--rule);
}
.outline li > a, .outline li > .planned { display: contents; text-decoration: none; color: var(--ink); font-weight: 650; font-size: 1.06em; }
.outline li > .planned { color: var(--ink-3); font-weight: 500; }
.outline li > a .title { justify-self: start; text-decoration: underline; text-decoration-color: color-mix(in srgb, var(--django-bright) 50%, transparent); text-underline-offset: 0.2em; }
.outline li > a:hover .title { color: var(--forest); text-decoration-color: var(--forest); }
.outline .no { font-family: var(--sans); font-size: 0.86em; font-weight: 650; color: var(--django-bright); padding-top: 0.15rem; font-variant-numeric: tabular-nums; }
.outline .planned .no { color: var(--ink-3); }
.outline .about { grid-column: 2; font-size: 0.93em; line-height: 1.48; color: var(--ink-2); margin-top: 0.2rem; }

.contents { margin-top: 2.4rem; }
.contents .part + .part { margin-top: 2.6rem; }
.part-head {
  display: flex;
  align-items: baseline;
  gap: 0.9rem;
  margin: 0;
  padding: 0 0 0.6rem;
  border-bottom: 2px solid var(--forest);
  font-size: 1.42rem;
  line-height: 1.2;
}
.part-no {
  flex: none;
  font-family: var(--sans);
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--django-bright);
}
.part-title { font-weight: 650; color: var(--forest); }
.toc { margin: 0; padding: 0; list-style: none; }
.toc li {
  display: grid;
  grid-template-columns: 2.7rem 1.85rem minmax(0, 1fr) auto;
  align-items: baseline;
  margin: 0;
  padding: 1.05rem 0 1.1rem;
  border-bottom: 1px solid var(--rule);
}
.toc .mark { grid-row: 1 / span 3; align-self: start; padding-top: 0.15rem; color: var(--rule-2); }
.toc .written .mark { color: var(--forest); }
.toc .mark .emblem { width: 26px; height: 26px; }
.toc .entry { display: contents; }
.toc .entry a, .toc .entry .planned { display: contents; text-decoration: none; font-weight: 650; line-height: 1.3; }
.toc .entry a { color: var(--ink); }
.toc .entry .planned { color: var(--ink-3); font-weight: 550; }
.toc .entry .no { font-family: var(--sans); font-size: 0.9em; font-weight: 650; color: var(--django-bright); font-variant-numeric: tabular-nums; }
.toc .entry .planned .no { color: var(--ink-3); }
.toc .entry .title { justify-self: start; font-size: 1.14em; }
.toc .entry a .title { text-decoration: underline; text-decoration-color: color-mix(in srgb, var(--django-bright) 48%, transparent); text-underline-offset: 0.2em; }
.toc .entry a:hover .title { color: var(--forest); text-decoration-color: var(--forest); }
.toc .count {
  margin: 0;
  grid-row: 1;
  grid-column: 4;
  justify-self: end;
  font-family: var(--sans);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-3);
  white-space: nowrap;
}
.toc .promise { margin: 0.28rem 0 0; grid-column: 3 / -1; font-style: italic; font-size: 1.01em; line-height: 1.38; color: var(--ink); }
.toc .promise q { quotes: "\201C" "\201D"; }
.toc .about { margin: 0.2rem 0 0; grid-column: 3 / -1; max-width: 39rem; font-size: 0.91em; line-height: 1.48; color: var(--ink-2); }

/* ---- 12. Page Turn & Colophon -------------------------------------------------------------- */
.turn { margin-top: 3.4rem; }
.turn-inner {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
  padding-top: 1.15rem;
  border-top: 2px solid var(--forest);
}
.turn a, .turn-inner > span { display: block; color: var(--ink); text-decoration: none; font-weight: 650; font-size: 1.04em; line-height: 1.35; }
.turn a:hover { color: var(--django); }
.turn .after { text-align: right; grid-column: 2; }
.turn .dir { display: block; margin-bottom: 0.28rem; font-family: var(--sans); font-size: 0.7rem; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-3); }
.turn .no { font-family: var(--sans); font-size: 0.86em; font-weight: 650; color: var(--django-bright); margin-right: 0.25em; }

.colophon {
  grid-area: foot;
  background: var(--paper-2);
  border-top: 1px solid var(--rule);
  padding: 1.65rem var(--gutter) 2.25rem;
  font-family: var(--sans);
  font-size: 0.8rem;
  line-height: 1.55;
  color: var(--ink-2);
}
.colophon-inner { max-width: calc(var(--measure) + var(--gap) + var(--margin)); margin: 0 auto; }
.colophon p { margin: 0 0 0.35rem; }
.colophon .ver { color: var(--ink); font-weight: 500; }
.colophon a { color: var(--django); }

@media (max-width: 48em) {
  h1 { font-size: 2rem; }
  .opener .numeral { font-size: 3.8rem; }
  .opener h1 { font-size: 2.25rem; }
  .head { padding-top: 2rem; }
  .title-page { padding-top: 2.5rem; }
  .figure .art { padding: 14px 12px 12px; }
  .toc li { grid-template-columns: 2.2rem 1.5rem minmax(0, 1fr) auto; }
}
@media print {
  .running, .booknav, .turn { display: none !important; }
  body { display: block; background: #fff; }
}
