/* w0zro — Essays. "Technical Report": yellowed paper, typewriter labels, book serif. */

/* ---------- Fonts (self-hosted, OFL; licenses in /assets/fonts) ---------- */

@font-face {
  font-family: "Crimson Pro";
  src: url("../fonts/crimson-pro-var.woff2") format("woff2");
  font-weight: 400 500;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Crimson Pro";
  src: url("../fonts/crimson-pro-var-italic.woff2") format("woff2");
  font-weight: 400;
  font-style: italic;
  font-display: swap;
}
@font-face {
  font-family: "Courier Prime";
  src: url("../fonts/courier-prime-400.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Courier Prime";
  src: url("../fonts/courier-prime-700.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Courier Prime";
  src: url("../fonts/courier-prime-400-italic.woff2") format("woff2");
  font-weight: 400;
  font-style: italic;
  font-display: swap;
}

/* ---------- Tokens ---------- */

:root {
  /* datum (datum.w0zro.com), light and dark. Direct from the palette:
     paper bg0, paper-2 bg1, ink fg0, muted fg1, rule-soft bg2, accent purple,
     accent-hover the tier-2 purple. The rest are OKLCH mixes of those, each
     checked for WCAG contrast on paper. */
  --paper: #f1f6fd;
  --paper-2: #e7ecf2;
  --ink: #292e35;
  --body: #292e35;
  --ink-2: #3c424b;       /* fg0 → fg1 35%; 9.3:1 */
  --ink-3: #4a515b;       /* subtitles; fg0 → fg1 60%; 7.4:1 */
  --muted: #616a76;       /* 5.1:1 */
  --muted-2: #666f7b;     /* read Contents items; 4.7:1 */
  --faint: #9098a1;       /* decorative only */
  --rule-soft: #ced3d9;
  --rule-dot: #a1a7b0;
  --track: #ced3d9;
  --accent: #973070;      /* datum purple; 6.5:1 (6.0:1 on paper-2) */
  --accent-hover: #633750;/* tier-2 purple ("call"); 8.8:1 */
  --backdrop: rgb(41 46 53 / 0.35);
  color-scheme: light;
  --serif: "Crimson Pro", Georgia, serif;
  --mono: "Courier Prime", "Courier New", monospace;

  --max: 1040px;
  --pad: 20px;
  --bar-h: 48px;
  --anchor-gap: calc(var(--bar-h) + 3px + 24px);
}

/* Dark follows the system unless the reader picked light; the toggle sets data-theme. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #0f1318;
    --paper-2: #181c21;
    --ink: #dbe0e8;
    --body: #dbe0e8;
    --ink-2: #c0c6cf;       /* fg0 → fg1 35%; 10.9:1 */
    --ink-3: #adb4be;       /* fg0 → fg1 60%; 8.9:1 */
    --muted: #8f98a3;       /* 6.4:1 */
    --muted-2: #7f8791;     /* fg1 → bg2 15%; 5.1:1 */
    --faint: #60666f;       /* decorative only */
    --rule-soft: #2b2f35;
    --rule-dot: #51575e;
    --track: #2b2f35;
    --accent: #fa94cd;      /* 9.0:1 */
    --accent-hover: #f5b9d9;/* 11.4:1 */
    --backdrop: rgb(0 0 0 / 0.55);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #0f1318;
  --paper-2: #181c21;
  --ink: #dbe0e8;
  --body: #dbe0e8;
  --ink-2: #c0c6cf;       /* fg0 → fg1 35%; 10.9:1 */
  --ink-3: #adb4be;       /* fg0 → fg1 60%; 8.9:1 */
  --muted: #8f98a3;       /* 6.4:1 */
  --muted-2: #7f8791;     /* fg1 → bg2 15%; 5.1:1 */
  --faint: #60666f;       /* decorative only */
  --rule-soft: #2b2f35;
  --rule-dot: #51575e;
  --track: #2b2f35;
  --accent: #fa94cd;      /* 9.0:1 */
  --accent-hover: #f5b9d9;/* 11.4:1 */
  --backdrop: rgb(0 0 0 / 0.55);
  color-scheme: dark;
}

@media (min-width: 720px) {
  :root { --pad: 40px; --bar-h: 56px; }
}
@media (min-width: 1024px) {
  :root { --pad: clamp(40px, calc((100vw - 1040px) / 2), 120px); }
}

/* ---------- Base ---------- */

*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 19px;
  line-height: 1.5;
  overflow-wrap: break-word;
}

a { color: var(--accent); }
a:hover { color: var(--accent-hover); }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

[hidden] { display: none !important; }

.skip {
  position: absolute;
  left: 8px;
  top: -100px;
  z-index: 50;
  padding: 10px 14px;
  background: var(--paper);
  border: 1px solid var(--ink);
  font-family: var(--mono);
  font-size: 14px;
}
.skip:focus { top: 8px; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.label {
  margin: 0;
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 400;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.accent { color: var(--accent); }

/* ---------- Shell, header, footer ---------- */

.shell {
  max-width: calc(var(--max) + 2 * var(--pad));
  margin: 0 auto;
  padding: 32px var(--pad) 48px;
  display: flex;
  flex-direction: column;
  gap: 48px;
}
@media (min-width: 720px) {
  .shell { padding-block: 64px; gap: 64px; }
  .essay-shell { gap: 56px; }
}

.site-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px 32px;
  font-family: var(--mono);
  font-size: 15px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.site-header a { color: var(--ink); text-decoration: none; }
.site-header a:hover { color: var(--accent); }
.site-name { font-weight: 700; }
.site-header nav,
.site-actions { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 32px; }
.theme-toggle {
  padding: 12px 0;
  margin: -12px 0;
  background: none;
  border: 0;
  font: inherit;
  letter-spacing: inherit;
  text-transform: inherit;
  color: var(--muted);
  cursor: pointer;
}
.theme-toggle:hover { color: var(--accent); }
.site-header nav a,
.site-back {
  display: inline-block;
  padding-block: 12px;
  margin-block: -12px;
}
.site-header nav a[aria-current="page"] {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 4px;
}
@media (max-width: 719px) {
  .site-header nav,
  .site-actions { gap: 0 20px; }
}

.site-footer {
  display: flex;
  justify-content: space-between;
  font-family: var(--mono);
  font-size: 13px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

/* ---------- Index ---------- */

.index main {
  display: flex;
  flex-direction: column;
  gap: 48px;
}
@media (min-width: 720px) {
  .index main { gap: 64px; }
}

.intro {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  column-gap: 24px;
  row-gap: 24px;
  padding: 32px 0;
  border-top: 3px double var(--ink);
  border-bottom: 1px solid var(--ink);
}
.intro-text {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.intro-text .label { font-size: 14px; }
.intro h1 {
  margin: 0;
  font-weight: 400;
  font-size: 34px;
  line-height: 1.1;
  letter-spacing: -0.01em;
  text-wrap: balance;
}
.intro-aside {
  grid-column: 1 / -1;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-family: var(--mono);
  font-size: 14px;
  color: var(--accent);
}
@media (min-width: 720px) {
  .intro h1 { font-size: 44px; }
}
@media (min-width: 1024px) {
  .intro-text { grid-column: span 8; }
  .intro-aside { grid-column: 10 / span 3; align-self: end; }
  .intro h1 { font-size: 56px; line-height: 1.08; }
}

.listing-rows { margin: 0; padding: 0; list-style: none; }

.listing-head,
.listing-row {
  display: grid;
  grid-template-columns: 80px minmax(0, 1fr) 160px 140px;
  column-gap: 32px;
}
.listing-head {
  padding-bottom: 12px;
  border-bottom: 1px solid var(--ink);
  font-family: var(--mono);
  font-size: 13px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.listing-head span:last-child { text-align: right; }

.listing-row {
  align-items: baseline;
  padding: 22px 0;
  border-bottom: 1px dotted var(--rule-dot);
  color: var(--ink);
  text-decoration: none;
}
.listing-row:hover { color: var(--ink); }
.listing-row:hover .entry-title { color: var(--accent); }
.listing-row .no,
.listing-row .filed,
.listing-row .date {
  font-family: var(--mono);
  font-size: 15px;
}
.listing-row .no { color: var(--accent); }
.entry { display: flex; flex-direction: column; gap: 4px; }
.entry-title { font-size: 27px; line-height: 1.2; }
.entry-subtitle { font-size: 20px; line-height: 1.3; font-style: italic; color: var(--ink-3); text-wrap: balance; }
.listing-row .date {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  color: var(--muted);
}
.listing-row .mins { font-size: 13px; }
.draft {
  font-family: var(--mono);
  font-size: 13px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.kicker .draft { font-size: inherit; }

@media (max-width: 1023px) {
  .listing-head,
  .listing-row { grid-template-columns: 64px minmax(0, 1fr) 150px 110px; column-gap: 20px; }
}

@media (max-width: 719px) {
  .listing-head { display: none; }
  .listing-row {
    grid-template-columns: auto minmax(0, 1fr);
    grid-template-areas:
      "no filed"
      "entry entry"
      "date date";
    gap: 6px 0;
    padding: 20px 0;
  }
  .listing-row .no { grid-area: no; font-size: 13px; }
  .listing-row .filed { grid-area: filed; font-size: 13px; color: var(--muted); }
  .listing-row .filed::before { content: "\00a0·\00a0"; }
  .listing-row .entry { grid-area: entry; }
  .listing-row .date { grid-area: date; flex-direction: row; gap: 0; font-size: 13px; }
  .listing-row .mins::before { content: "\00a0·\00a0"; }
  .listing-row .draft::before { content: "\00a0·\00a0"; }
  .entry-title { font-size: 24px; }
  .entry-subtitle { font-size: 18px; }
}

.empty {
  margin: 0;
  font-family: var(--mono);
  font-size: 14px;
  color: var(--muted);
}

/* ---------- Simple pages (404) ---------- */

.page-body {
  max-width: 660px;
  padding-top: 32px;
  border-top: 3px double var(--ink);
  font-size: 20px;
  line-height: 1.58;
  color: var(--body);
}
.page-body p { margin: 0 0 22px; text-wrap: pretty; }
.page-title {
  margin: 0 0 32px;
  font-weight: 400;
  font-size: 44px;
  line-height: 1.05;
  letter-spacing: -0.01em;
  color: var(--ink);
}
@media (min-width: 720px) {
  .page-title { font-size: 56px; }
}

/* ---------- Essay header ---------- */

.essay-header {
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding-top: 28px;
  border-top: 3px double var(--ink);
}
.kicker {
  margin: 0;
  font-family: var(--mono);
  font-size: 14px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
}
.essay-title {
  margin: 0;
  max-width: 920px;
  font-weight: 400;
  font-size: 44px;
  line-height: 1.02;
  letter-spacing: -0.02em;
  text-wrap: balance;
  color: var(--ink);
}
.subtitle {
  margin: -8px 0 0;
  max-width: 880px;
  font-size: 22px;
  font-style: italic;
  line-height: 1.25;
  text-wrap: balance;
  color: var(--ink-3);
}
@media (min-width: 720px) {
  .essay-header { gap: 28px; padding-top: 32px; }
  .subtitle { font-size: 36px; line-height: 1.2; }
  .kicker { font-size: 15px; }
  .essay-title { font-size: 64px; line-height: 1; }
}
@media (min-width: 1024px) {
  .essay-title { font-size: 84px; }
}

.meta {
  margin: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px 24px;
  padding: 14px 0;
  border-top: 1px solid var(--ink);
  border-bottom: 1px solid var(--ink);
  font-family: var(--mono);
  font-size: 14px;
  color: var(--ink);
}
@media (min-width: 720px) {
  .meta {
    grid-template-columns: none;
    grid-auto-flow: column;
    grid-auto-columns: minmax(0, 1fr);
  }
}
.meta div { display: flex; flex-direction: column; gap: 4px; }
.meta dt { text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
.meta dd { margin: 0; }
.meta .updated { display: block; color: var(--muted); }

.resume {
  margin: -8px 0 0;
  font-family: var(--mono);
  font-size: 14px;
}
.resume a { text-underline-offset: 3px; }

/* ---------- Essay body layout ---------- */

.essay-layout {
  display: flex;
  flex-direction: column;
  margin-top: 40px;
}
.essay-layout > * { max-width: 660px; }

/* Wide screens: the text is centred on the page, with a sticky Contents
   rail in the left column and an empty column of the same width on the right. */
@media (min-width: 1024px) {
  .essay-shell {
    --max: 1236px; /* 240 rail + 48 gap + 660 text + 48 gap + 240 */
    --pad: clamp(40px, calc((100vw - 1236px) / 2), 120px);
  }
  .essay-layout {
    display: grid;
    grid-template-columns: minmax(200px, 1fr) minmax(0, 660px) minmax(0, 1fr);
    grid-template-areas: "toc prose .";
    column-gap: 48px;
    margin-top: 56px;
  }
  .essay-layout > .toc { width: 100%; max-width: 240px; }
  .prose { grid-area: prose; align-self: start; }
  .toc {
    grid-area: toc;
    align-self: start;
    position: sticky;
    top: calc(var(--bar-h) + 3px + 48px);
    max-height: calc(100vh - var(--bar-h) - 3px - 96px);
    overflow-y: auto;
    /* Room for the current item's accent rule, which sits 12px outside. */
    margin-left: -12px;
    padding-left: 12px;
  }
}

/* ---------- Contents ---------- */

.toc {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 40px;
  padding: 16px 0;
  border-top: 1px solid var(--ink);
  border-bottom: 1px solid var(--ink);
}
.toc-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 16px;
  line-height: 1.3;
}
.toc-list a {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  color: var(--ink);
  text-decoration: none;
}
.toc-list a:hover { color: var(--accent); }
.toc-no {
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.6;
  color: var(--accent);
}
.toc-extra { display: none; }

@media (max-width: 1023px) {
  .toc-list { gap: 0; font-size: 18px; }
  .toc-list a { padding-block: 8px; }
}

@media (min-width: 1024px) {
  .toc { margin-bottom: 0; gap: 14px; padding: 0; border: 0; }
  .toc-list { gap: 9px; }
  .toc-extra {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin: 0;
    padding-top: 14px;
    border-top: 1px solid var(--rule-soft);
    font-family: var(--mono);
    font-size: 13px;
  }
  .toc-extra a { color: var(--ink-2); text-decoration: none; }
  .toc-extra a:hover { color: var(--accent); }
}

/* Read state (set by essay.js): rail and phone sheet. */
.toc-list li.is-read a { color: var(--muted-2); }
.toc-list li.is-read .toc-no { color: var(--muted-2); }
.toc-list li.is-current a {
  margin-left: -12px;
  padding: 8px 0 8px 10px;
  border-left: 2px solid var(--accent);
  font-weight: 500;
}
.toc-list li.is-current .toc-no { color: var(--accent); }
.toc-list li.is-upcoming .toc-no { color: var(--muted); }
@media (max-width: 1023px) {
  .toc .toc-list li a { color: var(--ink); margin-left: 0; padding-left: 0; border: 0; font-weight: 400; }
  .toc .toc-list li .toc-no { color: var(--accent); }
}

/* ---------- Prose ---------- */

.prose {
  counter-reset: section figure listing;
  font-size: 19px;
  line-height: 1.6;
  color: var(--body);
}
@media (min-width: 720px) {
  .prose { font-size: 22px; line-height: 1.58; }
}

.prose > * { margin: 0 0 26px; }
.prose > :last-child { margin-bottom: 0; }
.prose p { text-wrap: pretty; }

.prose h2 {
  counter-increment: section;
  margin: 48px 0 26px;
  font-family: var(--mono);
  font-weight: 700;
  font-size: 15px;
  line-height: 1.4;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink);
}
.prose h2::before {
  content: counter(section) ". ";
  color: var(--accent);
}
.prose h3 {
  margin: 36px 0 18px;
  font-family: var(--mono);
  font-weight: 700;
  font-size: 15px;
  line-height: 1.4;
  letter-spacing: 0.04em;
  color: var(--ink);
}
@media (min-width: 720px) {
  .prose h2 { font-size: 17px; }
}

.prose h2,
.prose h3,
.prose [id],
.footnotes li,
#notes {
  scroll-margin-top: var(--anchor-gap);
}

.prose a {
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

.prose ul,
.prose ol { padding-left: 1.4em; }
.prose li + li { margin-top: 8px; }

.prose hr {
  height: 0;
  margin: 48px auto;
  border: 0;
  border-top: 1px solid var(--rule-soft);
  width: 40%;
}

.prose blockquote {
  margin-left: 0;
  margin-right: 0;
  padding-left: 24px;
  border-left: 2px solid var(--accent);
  font-style: italic;
}
.prose blockquote > * { margin: 0 0 16px; }
.prose blockquote > :last-child { margin-bottom: 0; }

/* Era label: <p class="era">1950s–1960s</p> directly after a section or subsection heading.
   Sits under the heading in the caption style; kept out of the heading so Contents stays clean. */
.prose h2 + .era,
.prose h3 + .era {
  margin: -18px 0 26px;
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.5;
  letter-spacing: 0.08em;
  color: var(--muted);
}

/* Asides: <aside class="aside" markdown="1"><p class="aside-label">Title</p> … </aside>.
   Set smaller, between hairlines, with a mono label in the manner of a caption. */
.prose aside.aside {
  margin: 36px 0;
  padding: 18px 0 20px;
  border-top: 1px solid var(--rule-soft);
  border-bottom: 1px solid var(--rule-soft);
  font-size: 0.86em;
  line-height: 1.55;
  color: var(--ink-2);
}
.prose aside.aside > * { margin: 0 0 14px; }
.prose aside.aside > :last-child { margin-bottom: 0; }
.prose .aside-label {
  margin: 0 0 12px;
  font-family: var(--mono);
  font-size: 14px;
  line-height: 1.5;
  letter-spacing: 0.02em;
  color: var(--ink);
}
.prose .aside-label::before {
  content: "Aside \00b7 ";
  color: var(--accent);
}

.prose :not(pre) > code {
  padding: 0.05em 0.25em;
  background: var(--paper-2);
  font-family: var(--mono);
  font-size: 0.8em;
}

/* Note references. kramdown: <sup role="doc-noteref"><a class="footnote">1</a></sup> */
sup[role="doc-noteref"] {
  font-family: var(--mono);
  font-size: 13px;
  line-height: 0;
  vertical-align: super;
  margin-left: 1px;
}
sup[role="doc-noteref"] a {
  color: var(--accent);
  text-decoration: none;
}
sup[role="doc-noteref"] a:hover { text-decoration: underline; }

/* Figures: <figure><img …><figcaption>Caption. <span class="source">Source: …</span></figcaption></figure> */
.prose figure { margin-left: 0; margin-right: 0; }
.prose figure:not(.listing) { counter-increment: figure; }
.prose figure img,
.prose figure svg {
  display: block;
  max-width: 100%;
  height: auto;
  border: 1px solid var(--ink);
}
.prose figcaption {
  margin-top: 12px;
  font-family: var(--mono);
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink-2);
}
.prose figure:not(.listing) figcaption::before {
  content: "Fig. " counter(figure) ". ";
  color: var(--accent);
}
.prose figcaption .source { color: var(--muted); }

/* Listings: fenced code, optionally inside <figure class="listing" markdown="1">. */
.prose figure.listing { counter-increment: listing; }
.prose figure.listing figcaption::before {
  content: "Listing " counter(listing) ". ";
  color: var(--accent);
}
.prose figure.listing > .highlighter-rouge { margin: 0; }

.prose pre,
.prose .highlighter-rouge {
  margin-left: 0;
  margin-right: 0;
}
.prose div.highlight,
.prose > pre {
  overflow-x: auto;
  padding: 16px 0;
  background: var(--paper-2);
  border-top: 1px solid var(--ink);
  border-bottom: 1px solid var(--ink);
}
.prose pre {
  margin: 0;
  font-family: var(--mono);
  font-size: 14px;
  line-height: 1.6;
  color: var(--ink);
}
@media (min-width: 720px) {
  .prose pre { font-size: 16px; }
}
.prose div.highlight > pre { padding: 0 16px; }
.prose > pre { padding: 16px; }
.prose pre code { font: inherit; }

.prose .rouge-table { border-collapse: collapse; margin: 0; }
.prose .rouge-table td { padding: 0; border: 0; vertical-align: top; }
.prose .rouge-table pre { padding: 0; background: none; border: 0; }
.prose .rouge-table .rouge-gutter pre,
.prose .rouge-table .gutter pre {
  padding-right: 16px;
  text-align: right;
  color: var(--faint);
  user-select: none;
}
/* Quiet syntax colours: comments muted, everything else ink. */
.prose .highlight .c,
.prose .highlight .c1,
.prose .highlight .cm,
.prose .highlight .cs,
.prose .highlight .cp { color: var(--muted); font-style: italic; }
.prose .highlight .k,
.prose .highlight .kd,
.prose .highlight .kn,
.prose .highlight .kr { font-weight: 700; }

/* Tables */
.prose table:not(.rouge-table) {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85em;
}
.prose th,
.prose td { padding: 8px 12px 8px 0; text-align: left; border-bottom: 1px dotted var(--rule-dot); }
.prose th {
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 400;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  border-bottom: 1px solid var(--ink);
}

/* ---------- Inline notes (built by essay.js) ---------- */

/* Narrow screens: references become tappable chips. */

@media (max-width: 1023px) {
  .js sup[role="doc-noteref"] {
    vertical-align: 0.1em;
    line-height: 1;
  }
  .js sup[role="doc-noteref"] a {
    position: relative;
    display: inline-block;
    min-width: 28px;
    padding: 0 4px;
    border-radius: 3px;
    background: var(--accent);
    color: var(--paper);
    font-size: 13px;
    line-height: 20px;
    text-align: center;
  }
  .js sup[role="doc-noteref"] a::after {
    content: "";
    position: absolute;
    inset: -12px -8px;
  }
  .js sup[role="doc-noteref"] a[aria-expanded="true"] {
    background: var(--accent-hover);
  }
}

.inline-note {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: -10px;
  padding: 12px 14px 0;
  background: var(--paper-2);
  border-top: 2px solid var(--accent);
  font-size: 16px;
  line-height: 1.45;
  color: var(--ink-2);
}
@media (min-width: 720px) {
  .inline-note { padding: 14px 18px 0; font-size: 17px; line-height: 1.5; }
}
.in-no {
  font-family: var(--mono);
  color: var(--accent);
}
.inline-note-text p { margin: 0 0 8px; }
.inline-note-text p:last-child { margin-bottom: 0; }
.inline-note-text .reversefootnote { display: none; }
.inline-note button {
  align-self: flex-start;
  min-height: 44px;
  padding: 0;
  background: none;
  border: 0;
  font-family: var(--mono);
  font-size: 13px;
  color: var(--ink-2);
  cursor: pointer;
}
.inline-note button:hover { color: var(--accent); }

/* ---------- Notes (endnotes) ---------- */

.notes {
  max-width: 760px;
  margin-top: 72px;
  padding-top: 24px;
  border-top: 3px double var(--ink);
}
.notes > h2 {
  margin: 0 0 16px;
  font-family: var(--mono);
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink);
}
.footnotes ol {
  counter-reset: note;
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 14px;
  font-size: 17px;
  line-height: 1.5;
  color: var(--body);
}
.footnotes li {
  counter-increment: note;
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr);
}
.footnotes li::before {
  content: counter(note) ".";
  grid-column: 1;
  grid-row: 1 / span 20;
  font-family: var(--mono);
  font-size: 15px;
  line-height: 1.7;
  color: var(--accent);
}
.footnotes li > * { grid-column: 2; margin: 0 0 8px; }
.footnotes li > :last-child { margin-bottom: 0; }
.footnotes li:target {
  background: var(--paper-2);
  outline: 8px solid var(--paper-2);
}
.footnotes a { text-decoration-thickness: 1px; text-underline-offset: 3px; }
.footnotes .reversefootnote {
  display: inline-block;
  min-width: 24px;
  margin-left: 4px;
  font-family: var(--mono);
  text-align: center;
  text-decoration: none;
}
.footnotes .reversefootnote sup { font-size: 11px; }

/* ---------- Prev / next ---------- */

.prevnext {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-top: 64px;
  padding-top: 20px;
  border-top: 1px solid var(--ink);
  font-family: var(--mono);
  font-size: 15px;
}
.prevnext a { color: var(--ink-2); text-decoration: none; }
.prevnext a:hover { color: var(--accent); }
.prevnext .next { text-align: right; }
@media (min-width: 720px) {
  .prevnext { flex-direction: row; justify-content: space-between; gap: 32px; }
}

/* ---------- Sticky reading bar ---------- */

.reading-bar {
  position: fixed;
  inset: 0 0 auto;
  z-index: 20;
  background: var(--paper);
}
.reading-bar-inner {
  display: flex;
  align-items: center;
  gap: 24px;
  height: var(--bar-h);
  padding: 0 var(--pad);
  border-bottom: 1px solid var(--ink);
  font-family: var(--mono);
  font-size: 13px;
  letter-spacing: 0.03em;
  white-space: nowrap;
}
.reading-bar p { margin: 0; }
.rb-where {
  display: none;
  min-width: 0;
  margin-right: auto !important;
  overflow: hidden;
  text-overflow: ellipsis;
}
.rb-site {
  font-weight: 700;
  text-transform: uppercase;
  color: var(--ink);
  text-decoration: none;
}
.rb-sep { margin: 0 12px; color: var(--faint); }
.rb-section {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--ink);
}
.rb-sec-num { color: var(--accent); }
.rb-left { color: var(--muted); }
.rb-left .rb-sep { display: none; }

@media (min-width: 720px) {
  .reading-bar-inner { font-size: 14px; letter-spacing: 0.04em; }
  .rb-where { display: block; }
  .rb-section { flex: 0 1 auto; color: var(--ink-2); }
  .rb-of { display: none; }
  .rb-left { color: var(--ink-2); }
  .rb-left .rb-sep { display: inline; margin: 0 24px; }
  .reading-bar-inner { gap: 0; }
  .rb-where { padding-right: 32px; }
}

/* Before §1 the bar shows only the essay and the minutes left. */
@media (min-width: 720px) {
  .before-first .rb-section,
  .before-first .rb-left .rb-sep { display: none; }
}

/* Line the bar up with the essay page, which is wider than the index. */
@media (min-width: 1024px) {
  .reading-bar .reading-bar-inner {
    padding-inline: max(40px, calc((100vw - 1236px) / 2));
  }
}

.progress { height: 3px; background: var(--track); }
.progress-fill {
  height: 100%;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: 0 50%;
}

/* ---------- Phone bottom bar and contents sheet ---------- */

.bottom-bar { display: none; }

@media (max-width: 719px) {
  .bottom-bar {
    position: fixed;
    inset: auto 0 0;
    z-index: 20;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    align-items: center;
    height: calc(64px + env(safe-area-inset-bottom));
    padding: 0 12px env(safe-area-inset-bottom);
    background: var(--paper);
    border-top: 1px solid var(--ink);
    font-family: var(--mono);
    font-size: 13px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    transition: transform 200ms ease;
  }
  .bottom-bar.is-hidden { transform: translateY(100%); }
  .bottom-bar button,
  .bottom-bar a {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 0;
    background: none;
    border: 0;
    font: inherit;
    letter-spacing: inherit;
    text-transform: inherit;
    color: var(--ink);
    text-decoration: none;
    cursor: pointer;
  }
  .has-bottom-bar { padding-bottom: calc(64px + env(safe-area-inset-bottom)); }
}

.sheet {
  width: 100%;
  max-width: 100%;
  max-height: 80vh;
  margin: auto 0 0;
  padding: 16px 20px calc(24px + env(safe-area-inset-bottom));
  background: var(--paper);
  color: var(--ink);
  border: 0;
  border-top: 3px double var(--ink);
}
.sheet::backdrop { background: var(--backdrop); }
.sheet-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}
.sheet-close {
  min-height: 44px;
  padding: 0;
  background: none;
  border: 0;
  font-family: var(--mono);
  font-size: 13px;
  color: var(--ink-2);
  cursor: pointer;
}
.sheet .toc-list { gap: 0; font-size: 18px; }
.sheet .toc-list a { padding-block: 10px; }
.sheet .toc-list li.is-current a { margin-left: 0; padding-left: 10px; }

/* ---------- Motion ---------- */

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

/* ---------- Print ---------- */

@media print {
  /* Always print light, whatever the screen theme (selectors match the dark rules' specificity). */
  :root, :root:not([data-theme="light"]), :root[data-theme] {
    --paper: #f1f6fd;
    --paper-2: #e7ecf2;
    --ink: #292e35;
    --body: #292e35;
    --ink-2: #3c424b;       /* fg0 → fg1 35%; 9.3:1 */
    --ink-3: #4a515b;       /* subtitles; fg0 → fg1 60%; 7.4:1 */
    --muted: #616a76;       /* 5.1:1 */
    --muted-2: #666f7b;     /* read Contents items; 4.7:1 */
    --faint: #9098a1;       /* decorative only */
    --rule-soft: #ced3d9;
    --rule-dot: #a1a7b0;
    --track: #ced3d9;
    --accent: #973070;      /* datum purple; 6.5:1 (6.0:1 on paper-2) */
    --accent-hover: #633750;/* tier-2 purple ("call"); 8.8:1 */
    --backdrop: rgb(41 46 53 / 0.35);
    color-scheme: light;
    --paper: #fff;
    --paper-2: #f3f3f3;
  }
  body { background: #fff; font-size: 11pt; }
  .reading-bar,
  .bottom-bar,
  .sheet,
  .toc,
  .resume,
  .inline-note,
  .prevnext,
  .site-header nav,
  .site-back,
  .skip { display: none !important; }
  .shell { max-width: none; padding: 0; gap: 24pt; }
  .essay-layout { display: block; margin-top: 18pt; }
  .essay-title { font-size: 32pt; }
  .prose { font-size: 11.5pt; line-height: 1.5; }
  .prose > * { margin-bottom: 9pt; }
  .prose h2 { break-after: avoid; margin-top: 18pt; }
  .js sup[role="doc-noteref"] a { background: none; color: var(--accent); padding: 0; min-width: 0; }
  .footnotes ol { font-size: 9.5pt; }
  .footnotes a[href^="http"]::after { content: " <" attr(href) ">"; word-break: break-all; }
  .footnotes .reversefootnote { display: none; }
  .notes { break-before: auto; margin-top: 24pt; }
  figure, pre, aside.aside { break-inside: avoid; }
}
