/* Layout: a reading column (~66ch) beside a fixed contents rail on wide screens; one column on phones. Purple accent = the non-blanching rash. */
:root {
  --paper: #f7f6fa;
  --ink: #1f1b29;
  --muted: #5f5873;
  --rule: #dcd7e6;
  --accent: #6a2c8e;
  --box: #eeebf4;
  --precise: #F3F4F6;
  --bubble: #ffffff;
  --display: "Schibsted Grotesk", "Helvetica Neue", Arial, sans-serif;
  --body: "Literata", Georgia, "Times New Roman", serif;
  --mono: "JetBrains Mono", ui-monospace, Menlo, monospace;
  --measure: 66ch;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --paper: #15131b; --ink: #e8e5ef; --muted: #a59eb8; --rule: #302b3c; --accent: #c7a0e6; --box: #1e1a27; --precise: #1b1d22; --bubble: #241f2e; color-scheme: dark; }
}
:root[data-theme="dark"] { --paper: #15131b; --ink: #e8e5ef; --muted: #a59eb8; --rule: #302b3c; --accent: #c7a0e6; --box: #1e1a27; --precise: #1b1d22; --bubble: #241f2e; color-scheme: dark; }

html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
body { background: var(--paper); color: var(--ink); font-family: var(--body); font-size: 1.0625rem; line-height: 1.65; }
.shell { display: grid; grid-template-columns: minmax(0, 1fr); padding-inline: 16px; }
main { min-width: 0; max-width: var(--measure); margin-inline: auto; padding-block: 2rem 4rem; width: 100%; }
a { color: var(--accent); text-underline-offset: 2px; }
a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 2px; }

/* contents rail */
.toc { display: none; }
@media (min-width: 1120px) {
  .shell { grid-template-columns: 270px minmax(0, 1fr); gap: 3rem; padding-inline: 24px 32px; }
  .toc { display: block; position: sticky; top: env(safe-area-inset-top, 0px); align-self: start; max-height: 100vh; overflow-y: auto; padding-block: 2rem; font-family: var(--display); font-size: 0.8rem; line-height: 1.35; }
  main { margin-inline: 0; }
}
.toc ol { list-style: none; margin: 0; padding: 0; }
.toc .toc-title { font-weight: 800; font-size: 0.9rem; margin: 0 0 1rem; }
.toc .toc-title a { color: var(--ink); text-decoration: none; }
.toc .tp { margin-block: 0.9rem; }
.toc .tp > a { color: var(--ink); text-decoration: none; font-weight: 700; }
.toc .tp ol li a { display: flex; gap: 0.5rem; padding-block: 0.18rem; color: var(--muted); text-decoration: none; }
.toc .tp ol li a:hover { color: var(--accent); }
.toc .pn { display: block; font-size: 0.68rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--accent); font-weight: 700; }
.num { font-family: var(--mono); font-variant-numeric: tabular-nums; color: var(--accent); min-width: 1.6em; display: inline-block; margin-right: 0.35em; }

/* type */
h1, h2, h3, h4 { font-family: var(--display); line-height: 1.2; text-wrap: balance; color: var(--ink); }
h1 { font-size: clamp(1.9rem, 4.5vw, 2.6rem); font-weight: 800; letter-spacing: -0.015em; margin: 0.2em 0 0.5em; }
h2 { font-size: 1.35rem; font-weight: 700; margin: 2.4rem 0 0.6rem; }
h3, h4 { font-size: 1.05rem; font-weight: 700; margin: 1.8rem 0 0.4rem; }
p, ul, ol { margin: 0 0 1em; }
li { margin-block: 0.25em; }
strong { font-weight: 600; }
.eyebrow { font-family: var(--display); font-size: 0.75rem; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--accent); margin: 0; }
code { font-family: var(--mono); font-size: 0.86em; background: var(--box); padding: 0.05em 0.3em; border-radius: 3px; }
pre { background: var(--box); padding: 0.9rem 1rem; overflow-x: auto; border-radius: 4px; font-size: 0.85rem; line-height: 1.5; }
pre code { background: none; padding: 0; }
cite.src { font-style: normal; font-family: var(--mono); font-size: 0.82em; color: var(--muted); }

/* cover */
.cover { padding-block: 2rem 2.5rem; border-bottom: 1px solid var(--rule); margin-bottom: 2rem; }
.cover .title { font-size: clamp(2.4rem, 7vw, 3.9rem); line-height: 1.02; letter-spacing: -0.03em; margin: 0.6rem 0 1rem; }
.cover .sub { font-size: 1.15rem; color: var(--muted); max-width: 58ch; }
.msg { margin: 2rem 0 0; display: grid; gap: 0.5rem; justify-items: start; }
.bubble { position: relative; background: var(--bubble); border: 1px solid var(--rule); border-radius: 18px 18px 18px 4px; padding: 0.9rem 1.1rem 1.6rem; max-width: 34rem; font-family: var(--display); font-size: 1rem; line-height: 1.45; box-shadow: 0 1px 0 var(--rule); }
.bubble p { margin: 0; }
.bubble .time { position: absolute; right: 0.9rem; bottom: 0.45rem; font-family: var(--mono); font-size: 0.72rem; color: var(--muted); }
.msg figcaption { font-family: var(--display); font-size: 0.78rem; color: var(--muted); }

.cover .draftline { font-family: var(--display); font-size: 0.9rem; font-weight: 500; color: var(--muted); margin: -1.1rem 0 1.4rem; letter-spacing: 0.02em; }
.cover .byline { font-family: var(--display); font-size: 1rem; font-weight: 500; color: var(--ink); margin: -0.2rem 0 1.4rem; letter-spacing: 0.01em; }

/* contents */
.contents { border-block: 1px solid var(--rule); padding-block: 1rem 1.5rem; margin-block: 2.5rem; }
.contents h2 { margin-top: 0.8rem; }
.contents > ol { list-style: none; padding: 0; margin: 0; display: grid; gap: 1rem; }
.contents .pn { display: block; font-family: var(--display); font-size: 0.7rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--accent); font-weight: 700; }
.contents > ol > li > a { font-family: var(--display); font-weight: 700; color: var(--ink); text-decoration: none; }
.contents ol ol { list-style: none; padding: 0; margin: 0.3rem 0 0; }
.contents ol ol a { color: var(--ink); text-decoration: none; display: flex; gap: 0.4rem; }
.contents ol ol a:hover { color: var(--accent); }
.contents .pg { display: none; }

/* parts and chapters */
.part { margin-top: 5rem; padding-top: 2rem; border-top: 3px solid var(--accent); }
.part .ptitle { font-size: clamp(2rem, 5vw, 2.8rem); }
.pblurb { color: var(--muted); font-size: 1.1rem; }
.plist { list-style: none; padding: 0; font-family: var(--display); }
.plist a { color: var(--ink); text-decoration: none; display: flex; gap: 0.4rem; }
.chapter { margin-top: 4.5rem; padding-top: 1.5rem; border-top: 1px solid var(--rule); }
.chapter header { margin-bottom: 1rem; }
.standfirst { font-size: 1.15rem; line-height: 1.55; color: var(--muted); }
blockquote { margin: 1.4rem 0; padding: 0.2rem 0 0.2rem 1.1rem; border-left: 3px solid var(--rule); color: var(--ink); }
blockquote.idea { border-left-color: var(--accent); font-size: 1.08rem; }
.label { display: block; font-family: var(--display); font-size: 0.72rem; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--accent); margin-bottom: 0.25rem; }
.precise { background: var(--precise); border-left: 5px solid var(--accent); border-radius: 0; padding: 1.3rem 1.5rem 0.7rem; margin: 2.2rem 0; font-family: "IBM Plex Sans", "Helvetica Neue", Arial, sans-serif; font-size: 0.9rem; line-height: 1.75; }
.precise .label { color: var(--ink); }
.precise .label span { color: var(--muted); font-weight: 400; font-style: italic; text-transform: none; letter-spacing: 0; margin-left: 0.35rem; }
.precise .mathd { margin: 1.5rem 0; }
.precise p { margin: 0.9rem 0; }
.precise p.label { display: block; }
.mathd { display: block; overflow-x: auto; overflow-y: hidden; margin: 0.8rem 0; text-align: center; }
.mathi svg { vertical-align: middle; }
mjx-container { display: inline; }
.mathd mjx-container { display: block; }

/* figures, boxes, references, glossary */
.fig { margin: 1.6rem 0 0.4rem; overflow-x: auto; }
.fig svg { display: block; width: 100%; height: auto; max-width: 720px; border: 1px solid var(--rule); border-radius: 4px; background: #ffffff; }
p.caption { font-family: var(--display); font-size: 0.82rem; color: var(--muted); margin-top: 0.3rem; }
blockquote.aside-box { border-left: 0; background: var(--box); border-radius: 6px; padding: 0.9rem 1.1rem 0.1rem; }
.refs { margin-top: 2.4rem; font-size: 0.86rem; line-height: 1.5; color: var(--muted); }
.refs h2 { font-size: 1.05rem; color: var(--ink); }
.refs p strong { font-family: var(--display); font-size: 0.72rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--accent); }
.refs ul { padding-left: 1.1rem; }
.refs li { overflow-wrap: anywhere; margin-block: 0.35em; }
.refs a { color: var(--muted); }
.glossary { margin-top: 5rem; padding-top: 2rem; border-top: 3px solid var(--accent); }
.glossary ul { list-style: none; padding: 0; }
.glossary li { margin-block: 0.6em; }

/* tables */
.tw { overflow-x: auto; margin: 1.2rem 0; }
table { border-collapse: collapse; width: 100%; font-size: 0.92rem; line-height: 1.45; }
th, td { text-align: left; vertical-align: top; padding: 0.5rem 0.6rem; border-bottom: 1px solid var(--rule); }
th { font-family: var(--display); font-weight: 700; font-size: 0.82rem; border-bottom: 2px solid var(--ink); }

.at-step { margin-top: 2.6rem; font-style: italic; }
.appendix { margin-top: 5rem; padding-top: 2rem; border-top: 3px solid var(--accent); }
.appendix .refs { margin-top: 0; }
.appendix .refs h2 { font-family: var(--display); font-size: 1.6rem; }
.appendix .refs h3 { font-family: var(--display); font-size: 0.95rem; color: var(--ink); margin: 1.8em 0 0.4em; break-after: avoid; }
.closing { margin-top: 5rem; padding-top: 2rem; border-top: 3px solid var(--accent); }
.closing blockquote { font-size: 1.12rem; border-left-color: var(--accent); }
.colophon { margin-top: 4rem; padding-top: 1rem; border-top: 1px solid var(--rule); font-family: var(--display); font-size: 0.8rem; color: var(--muted); }

/* print / PDF */
@page { size: Letter; margin: 0.85in 0.9in 0.9in; @bottom-center { content: counter(page); font-family: "Schibsted Grotesk", sans-serif; font-size: 9pt; color: #6b6480; } }
@page :first { @bottom-center { content: none; } }
@media print {
  :root, :root[data-theme="dark"], :root:not([data-theme="light"]) { --paper: #ffffff; --ink: #1a1722; --muted: #5a5468; --rule: #d6d1e0; --accent: #5e2580; --box: #f2eff7; --precise: #F3F4F6; --bubble: #ffffff; color-scheme: light; }
  body { font-size: 10.5pt; line-height: 1.5; }
  .shell { display: block; padding: 0; }
  .toc { display: none !important; }
  main { max-width: none; padding: 0; }
  .cover { height: 9in; box-sizing: border-box; padding: 0; margin: 0; border: 0; display: flex; flex-direction: column; justify-content: center; overflow: hidden; }
  .preface, .front, .contents, .part, .chapter, .closing, .appendix, .glossary { break-before: page; }
  .appendix { border-top: 0; margin-top: 0; padding-top: 0; }
  .preface { padding-top: 1.5in; }
  .glossary { border-top: 0; margin-top: 0; padding-top: 0; }
  .fig { break-inside: avoid; overflow: visible; }
  .fig svg { border-color: #d6d1e0; }
  .part { height: auto; padding: 0 0 1rem; margin: 0 0 2rem; border-top: 0; border-bottom: 3px solid var(--accent); }
  .part .ptitle { font-size: 2.1rem; margin: 0.3rem 0 0.4rem; }
  .part .pblurb { margin: 0; }
  .part + .chapter { break-before: auto; }
  .contents { padding: 0; margin: 0; font-size: 10pt; line-height: 1.35; }
  .contents > ol { gap: 0.55rem; }
  .contents li { margin-block: 0.08em; }
  .chapter, .closing { margin-top: 0; border-top: 0; padding-top: 0; }
  .contents { border: 0; }
  .contents .pg { display: inline; margin-left: auto; padding-left: 1rem; font-variant-numeric: tabular-nums; }
  .figwrap { break-inside: avoid; }
  p, li { orphans: 3; widows: 3; }
  h1, h2, h3, h4 { break-after: avoid; }
  tr, .bubble, blockquote, .mathd { break-inside: avoid; }
  .precise { box-decoration-break: clone; -webkit-box-decoration-break: clone; }
  a { color: var(--ink); text-decoration: none; }
  .tw { overflow: visible; }
}

.preface { max-width: 36rem; margin: 2rem 0 3rem; }
.preface p { font-size: 1.05em; }
.preface .signature { text-align: right; margin-top: 1.5rem; }

/* the shorter edition: chapters run on mid-page; parts still open a page */
@media print { .chapter { break-before: auto; margin-top: 2.2rem; padding-top: 1.2rem; border-top: 1px solid var(--rule); } .part + .chapter { margin-top: 0; padding-top: 0; border-top: 0; } .chapter > header { break-after: avoid; break-inside: avoid; } }
.topbar { display: flex; gap: 1.1rem; align-items: baseline; flex-wrap: wrap; padding: 0.9rem 0 0.4rem; font-family: var(--display); font-size: 0.85rem; border-bottom: 1px solid var(--rule); margin-bottom: 1.5rem; }
.topbar a { color: var(--ink); text-decoration: none; } .topbar a:hover { color: var(--accent); }
.topbar .brand { font-weight: 700; margin-right: auto; }
.pager { display: flex; justify-content: space-between; gap: 1rem; margin: 3rem 0 1rem; padding-top: 1rem; border-top: 1px solid var(--rule); font-family: var(--display); font-size: 0.9rem; }
.pager a { color: var(--accent); text-decoration: none; max-width: 48%; } .pager .next { text-align: right; margin-left: auto; }
.pager small { display: block; color: var(--muted); font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.06em; }
.chapter-notes { margin-top: 2.5rem; font-size: 0.92rem; } .chapter-notes h2 { font-size: 1.1rem; }
.site-foot { margin: 3rem 0 2rem; font-size: 0.8rem; color: var(--muted); border-top: 1px solid var(--rule); padding-top: 1rem; }
.site-foot a { color: inherit; }
.toc a[aria-current] { color: var(--accent); font-weight: 600; }
.toc .extra { margin-top: 1rem; padding-top: 0.6rem; border-top: 1px solid var(--rule); list-style: none; padding-left: 0; }
.shell.solo { grid-template-columns: minmax(0, 1fr); }
.shell.solo main { margin-inline: auto; max-width: 44rem; padding-inline: 16px; }
.home { max-width: none; }
.home h3 { font-family: var(--display); font-size: 1.3rem; margin: 2.2rem 0 0.6rem; }
.home .buttons { display: flex; flex-wrap: wrap; gap: 0.6rem; margin: 1.2rem 0; }
.home .buttons a { font-family: var(--display); font-weight: 600; text-decoration: none; padding: 0.55rem 1rem; border-radius: 6px; border: 1px solid var(--accent); color: var(--accent); }
.home .buttons a:first-child { background: var(--accent); color: var(--paper); }
.home h1 { font-family: var(--display); font-size: clamp(2rem, 6vw, 3rem); line-height: 1.1; margin: 1.5rem 0 0.5rem; }
.home .subtitle { font-size: 1.15rem; font-style: italic; }
.home .meta { color: var(--muted); font-size: 0.9rem; }
.chapter-list { list-style: none; padding: 0; } .chapter-list li { margin: 0.3rem 0; }
main a, .chapter-notes, .refs, .glossary { overflow-wrap: anywhere; }
@media (max-width: 600px) { .topbar .brand { flex-basis: 100%; } .topbar { gap: 0.4rem 1.1rem; } }
/* the reader can hide the contents sidebar; the choice is remembered */
.toc-toggle { display: none; background: none; border: 0; padding: 0; font: inherit; color: var(--ink); cursor: pointer; }
.toc-toggle:hover { color: var(--accent); }
@media (min-width: 1120px) {
  .toc-toggle { display: inline; }
  html.toc-off .shell:not(.solo) { grid-template-columns: minmax(0, 1fr); }
  html.toc-off .toc { display: none; }
  html.toc-off main { margin-inline: auto; }
}
@media print { .topbar, .pager, .site-foot, .toc { display: none !important; } }
