/* self-hosted fonts (latin subset); no third-party requests */
@font-face { font-family: "Newsreader"; font-style: normal; font-weight: 300 800; font-display: swap; src: url(/fonts/newsreader-roman-latin.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: "Newsreader"; font-style: italic; font-weight: 300 800; font-display: swap; src: url(/fonts/newsreader-italic-latin.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: "JetBrains Mono"; font-style: normal; font-weight: 100 800; font-display: swap; src: url(/fonts/jetbrains-mono-latin.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; }

/* Stackap — editorial manual. Two families (Newsreader, JetBrains Mono), one signal colour. */
:root {
  --paper: #f4f7ff;
  --paper-2: #e7edfc;
  --paper-3: #d8e1f7;
  --ink: #0a0f1f;
  --ink-2: #2b3450;
  --muted: #5a6585;
  --rule: #cfd8ee;
  --accent: #2563eb;
  --accent-text: #1d4ed8;
  --accent-ink: #ffffff;
  --cyan: #00b8e6;
  --violet: #6d3df5;
  --grad: linear-gradient(90deg, #00b8e6 0%, #2563eb 48%, #6d3df5 100%);
  --grad-btn: linear-gradient(90deg, #2563eb, #5b3df0);
  --warn: #c97a00;
  --good: #0f7a55;
  --code-bg: #05060a;
  --code-ink: #eef2ff;
  --code-dim: #8e98b8;
  --font-serif: "Newsreader", "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --measure: 40.5rem;
  --space-1: 0.5rem;
  --space-2: 1rem;
  --space-3: 1.5rem;
  --space-4: 2.5rem;
  --space-5: 4rem;
  --space-6: clamp(4rem, 3rem + 6vw, 8rem);
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #05060a;
    --paper-2: #0c101b;
    --paper-3: #151b2c;
    --ink: #eef2ff;
    --ink-2: #c3cbe6;
    --muted: #8590b3;
    --rule: #1c2438;
    --accent: #3d8bff;
    --accent-text: #6aa8ff;
    --accent-ink: #ffffff;
    --cyan: #22d3ee;
    --violet: #8b5cf6;
    --grad: linear-gradient(90deg, #22d3ee 0%, #3d8bff 48%, #8b5cf6 100%);
    --grad-btn: linear-gradient(90deg, #2563eb, #6d3df5);
    --warn: #f2b134;
    --good: #5fd3a0;
    --code-bg: #0a0d16;
    --code-ink: #eef2ff;
    --code-dim: #7e89ad;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 1.5rem; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-serif);
  font-size: 1.1875rem;
  line-height: 1.65;
  font-optical-sizing: auto;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}
img, svg { max-width: 100%; display: block; }
a { color: var(--accent-text); text-decoration-thickness: 0.06em; text-underline-offset: 0.18em; }
a:hover { text-decoration-thickness: 0.12em; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; border-radius: 2px; }
::selection { background: var(--accent); color: var(--accent-ink); }

.skip { position: absolute; left: -9999px; top: 0; background: var(--ink); color: var(--paper); padding: 0.75rem 1rem; z-index: 100; font-family: var(--font-mono); font-size: 0.85rem; }
.skip:focus { left: 1rem; top: 1rem; }

#progress { position: fixed; inset: 0 auto auto 0; height: 3px; width: 100%; transform-origin: 0 50%; transform: scaleX(0); background: var(--grad); z-index: 60; }

/* ——— masthead ——— */
.mast { border-bottom: 1px solid var(--rule); background: var(--paper); }
.mast-inner { max-width: 1240px; margin: 0 auto; padding: 1rem 1.5rem; display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.brand { font-family: var(--font-mono); font-weight: 700; font-size: 1.05rem; letter-spacing: -0.02em; color: var(--ink); text-decoration: none; display: inline-flex; align-items: center; gap: 0.6rem; }
.brand svg { width: 1.7rem; height: 1.7rem; flex: none; }
.brand { text-transform: uppercase; letter-spacing: 0.1em; font-size: 0.95rem; }
.brand .ap { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.mast nav { display: flex; gap: 1.25rem; font-family: var(--font-mono); font-size: 0.78rem; letter-spacing: 0.04em; text-transform: uppercase; }
.mast nav a { color: var(--ink-2); text-decoration: none; }
.mast nav a:hover { color: var(--accent-text); }
.pill { font-family: var(--font-mono); font-size: 0.7rem; letter-spacing: 0.08em; text-transform: uppercase; border: 1px solid var(--rule); padding: 0.25rem 0.6rem; border-radius: 999px; color: var(--muted); }

/* ——— hero ——— */
.hero { max-width: 1240px; margin: 0 auto; padding: var(--space-6) 1.5rem var(--space-5); position: relative; }
.eyebrow { font-family: var(--font-mono); font-size: 0.78rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--accent-text); margin: 0 0 var(--space-3); display: flex; align-items: center; gap: 0.75rem; }
.eyebrow::before { content: ""; width: 2.5rem; height: 2px; background: var(--grad); }
.hero h1 { font-size: clamp(2.7rem, 1.2rem + 7.4vw, 6.4rem); line-height: 0.98; letter-spacing: -0.035em; font-weight: 500; margin: 0 0 var(--space-4); max-width: 15ch; font-variation-settings: "opsz" 72; }
.hero h1 em { font-style: italic; font-weight: 400; background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; padding-right: 0.08em; }
.lede { font-size: clamp(1.25rem, 1rem + 1vw, 1.7rem); line-height: 1.45; color: var(--ink-2); max-width: 34em; margin: 0 0 var(--space-4); }
.cta-row { display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: center; margin-bottom: var(--space-5); }
.btn { font-family: var(--font-mono); font-size: 0.85rem; letter-spacing: 0.04em; text-transform: uppercase; text-decoration: none; padding: 0.95rem 1.4rem; border-radius: 0.3rem; border: 1.5px solid var(--ink); color: var(--ink); background: transparent; transition: transform 0.2s var(--ease), background 0.2s, color 0.2s; display: inline-block; }
.btn:hover { transform: translateY(-2px); }
.btn.primary { background: var(--grad-btn); border-color: transparent; color: #fff; font-weight: 700; }
.btn.primary:hover { filter: brightness(1.12); }

.term { background: var(--code-bg); color: var(--code-ink); border-radius: 0.5rem; font-family: var(--font-mono); font-size: 0.86rem; line-height: 1.7; padding: 1.25rem 1.4rem 1.4rem; max-width: 46rem; overflow-x: auto; box-shadow: 0 1px 0 var(--rule), 0 24px 48px -28px rgba(37, 99, 235, 0.55); position: relative; }
.term::before { content: "● ● ●"; display: block; color: var(--code-dim); letter-spacing: 0.35em; font-size: 0.6rem; margin-bottom: 0.9rem; }
.term .d { color: var(--code-dim); }
.term .p { color: var(--cyan); }
.term .ok { color: #7fd6a8; }
.term pre, .code pre { margin: 0; font: inherit; white-space: pre; }

.stats { list-style: none; padding: 0; margin: var(--space-5) 0 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr)); border-top: 1.5px solid var(--ink); }
.stats li { padding: 1.25rem 1.25rem 1.25rem 0; border-bottom: 1px solid var(--rule); }
.stats b { display: block; font-size: clamp(2rem, 1.4rem + 2vw, 3.1rem); line-height: 1; letter-spacing: -0.03em; font-weight: 500; font-variation-settings: "opsz" 72; }
.stats span { display: block; font-family: var(--font-mono); font-size: 0.72rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); margin-top: 0.6rem; line-height: 1.5; }

/* ——— shell: contents rail + article ——— */
.shell { max-width: 1240px; margin: 0 auto; padding: 0 1.5rem var(--space-6); display: grid; grid-template-columns: 15.5rem minmax(0, 1fr); column-gap: clamp(2rem, 5vw, 5rem); align-items: start; }
.toc { position: sticky; top: 1.25rem; padding-top: var(--space-4); max-height: calc(100vh - 2.5rem); overflow-y: auto; font-family: var(--font-mono); font-size: 0.74rem; }
.toc h2 { font-size: 0.7rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); margin: 0 0 0.9rem; font-weight: 500; }
.toc ol { list-style: none; margin: 0; padding: 0; border-left: 1px solid var(--rule); }
.toc a { display: block; padding: 0.4rem 0 0.4rem 0.9rem; color: var(--ink-2); text-decoration: none; border-left: 2px solid transparent; margin-left: -1px; line-height: 1.35; }
.toc a:hover { color: var(--accent-text); }
.toc a[aria-current="true"] { color: var(--ink); border-left-color: var(--accent); font-weight: 700; }
.toc-mobile { display: none; }

article { min-width: 0; }
section.sec { padding-top: var(--space-5); border-top: 1.5px solid var(--ink); margin-top: var(--space-5); }
section.sec:first-of-type { margin-top: var(--space-4); }
.sec-head { display: grid; gap: 0.8rem; margin-bottom: var(--space-3); }
.sec-no { font-family: var(--font-mono); font-size: 0.8rem; letter-spacing: 0.12em; color: var(--accent-text); }
article h2 { font-size: clamp(2rem, 1.4rem + 2.6vw, 3.4rem); line-height: 1.05; letter-spacing: -0.03em; font-weight: 500; margin: 0; font-variation-settings: "opsz" 72; max-width: 18ch; }
article h3 { font-size: 1.55rem; line-height: 1.2; letter-spacing: -0.015em; font-weight: 600; margin: var(--space-4) 0 var(--space-1); }
article h4 { font-family: var(--font-mono); font-size: 0.8rem; letter-spacing: 0.08em; text-transform: uppercase; margin: var(--space-3) 0 0.4rem; color: var(--ink); }
article p, article ul, article ol, article dl, article .note, article table, article details, article .code, article blockquote, article figure { max-width: var(--measure); }
article p { margin: 0 0 1.15em; }
article ul, article ol { padding-left: 1.3em; margin: 0 0 1.3em; }
article li { margin-bottom: 0.55em; padding-left: 0.2em; }
article li::marker { color: var(--accent-text); }
article strong { font-weight: 700; }
.dropcap::first-letter { font-size: 4.6em; float: left; line-height: 0.82; padding: 0.06em 0.12em 0 0; font-weight: 500; color: var(--accent-text); font-variation-settings: "opsz" 72; }

blockquote { margin: var(--space-4) 0; padding: 0 0 0 1.4rem; border-left: 3px solid var(--accent); font-size: 1.55rem; line-height: 1.35; font-style: italic; letter-spacing: -0.01em; max-width: 34rem; }
blockquote footer { font-family: var(--font-mono); font-style: normal; font-size: 0.74rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); margin-top: 0.8rem; }

.note { background: var(--paper-2); border-left: 4px solid var(--ink); padding: 1.1rem 1.3rem; margin: var(--space-3) 0; font-size: 1.05rem; line-height: 1.55; }
.note.warn { border-left-color: var(--warn); }
.note.good { border-left-color: var(--good); }
.note p:last-child { margin-bottom: 0; }
.note .tag { font-family: var(--font-mono); font-size: 0.7rem; letter-spacing: 0.1em; text-transform: uppercase; display: block; margin-bottom: 0.4rem; color: var(--ink); font-weight: 700; }

.code { background: var(--code-bg); color: var(--code-ink); border-radius: 0.4rem; font-family: var(--font-mono); font-size: 0.82rem; line-height: 1.65; padding: 1rem 1.2rem; margin: var(--space-3) 0; overflow-x: auto; }
.code .d { color: var(--code-dim); }
code { font-family: var(--font-mono); font-size: 0.82em; background: var(--paper-2); padding: 0.1em 0.38em; border-radius: 0.25rem; }
.code code { background: none; padding: 0; font-size: 1em; }

/* tables */
.tablewrap { overflow-x: auto; margin: var(--space-3) 0; max-width: 100%; border-top: 1.5px solid var(--ink); border-bottom: 1px solid var(--rule); }
.tablewrap table { width: 100%; border-collapse: collapse; font-size: 0.98rem; line-height: 1.45; max-width: none; min-width: 34rem; }
.tablewrap th { font-family: var(--font-mono); font-size: 0.7rem; letter-spacing: 0.08em; text-transform: uppercase; text-align: left; color: var(--muted); font-weight: 500; padding: 0.7rem 0.9rem 0.7rem 0; border-bottom: 1px solid var(--ink); vertical-align: bottom; }
.tablewrap td { padding: 0.75rem 0.9rem 0.75rem 0; border-bottom: 1px solid var(--rule); vertical-align: top; }
.tablewrap tr:last-child td { border-bottom: 0; }
.tablewrap td:first-child { font-weight: 600; }
.num { font-family: var(--font-mono); font-variant-numeric: tabular-nums; white-space: nowrap; }

/* lists as definition grids */
dl.defs { display: grid; gap: 0; margin: var(--space-3) 0; }
dl.defs > div { display: grid; grid-template-columns: 11rem minmax(0, 1fr); gap: 1.2rem; padding: 0.9rem 0; border-top: 1px solid var(--rule); }
dl.defs dt { font-family: var(--font-mono); font-size: 0.78rem; letter-spacing: 0.04em; text-transform: uppercase; color: var(--ink); font-weight: 700; padding-top: 0.25rem; }
dl.defs dd { margin: 0; }

/* diagram + chart */
figure { margin: var(--space-4) 0; }
figcaption { font-family: var(--font-mono); font-size: 0.72rem; letter-spacing: 0.05em; color: var(--muted); margin-top: 0.7rem; text-transform: uppercase; line-height: 1.5; max-width: 40rem; }
.diagram { width: 100%; height: auto; border: 1px solid var(--rule); background: var(--paper-2); border-radius: 0.4rem; }
.diagram text { font-family: var(--font-mono); fill: var(--ink); }
.diagram .box { fill: var(--paper); stroke: var(--ink); stroke-width: 1.5; }
.diagram .hot { fill: var(--accent); stroke: var(--accent); }
.diagram .hot-text { fill: var(--accent-ink); }
.diagram .dim { fill: var(--muted); }
.diagram .line { stroke: var(--ink); stroke-width: 1.5; fill: none; }
.diagram .flow { stroke: var(--cyan); stroke-width: 2; fill: none; stroke-dasharray: 5 6; animation: dash 1.4s linear infinite; }
@keyframes dash { to { stroke-dashoffset: -22; } }

.bars { display: grid; gap: 0.9rem; margin: var(--space-3) 0; max-width: 44rem; }
.bar-row { display: grid; grid-template-columns: 9.5rem minmax(0, 1fr) 5.5rem; gap: 0.9rem; align-items: center; font-family: var(--font-mono); font-size: 0.78rem; }
.bar-row .track { height: 1.9rem; background: var(--paper-2); border: 1px solid var(--rule); position: relative; }
.bar-row .fill { position: absolute; inset: 0 auto 0 0; background: var(--ink); transition: width 0.7s var(--ease); }
.bar-row.us .fill { background: var(--grad); }
.bar-row .val { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }

/* calculator */
.calc { border: 1.5px solid var(--ink); background: var(--paper-2); padding: clamp(1.1rem, 3vw, 2rem); margin: var(--space-4) 0; max-width: 46rem; }
.calc h3 { margin-top: 0; }
.calc form { display: grid; grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr)); gap: 1rem 1.2rem; margin-bottom: var(--space-3); }
.calc label { display: grid; gap: 0.4rem; font-family: var(--font-mono); font-size: 0.72rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-2); }
.calc input, .calc select { font: inherit; font-family: var(--font-mono); font-size: 1rem; letter-spacing: 0; text-transform: none; padding: 0.7rem 0.8rem; border: 1.5px solid var(--ink); background: var(--paper); color: var(--ink); border-radius: 0.25rem; width: 100%; }
.calc output { display: block; }
.result { display: grid; grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr)); gap: 0; border-top: 1.5px solid var(--ink); }
.result div { padding: 1rem 1rem 1rem 0; border-bottom: 1px solid var(--rule); }
.result b { display: block; font-size: 2.1rem; line-height: 1; letter-spacing: -0.03em; font-weight: 500; font-variant-numeric: tabular-nums; }
.result span { font-family: var(--font-mono); font-size: 0.68rem; letter-spacing: 0.07em; text-transform: uppercase; color: var(--muted); display: block; margin-top: 0.5rem; }
.result .big b { color: var(--accent-text); }
.fine { font-size: 0.92rem; color: var(--muted); margin: 1rem 0 0; line-height: 1.5; }

/* FAQ */
details { border-top: 1px solid var(--rule); padding: 0; }
details:last-of-type { border-bottom: 1px solid var(--rule); }
details summary { cursor: pointer; list-style: none; padding: 1.05rem 2rem 1.05rem 0; font-weight: 600; font-size: 1.12rem; line-height: 1.35; position: relative; }
details summary::-webkit-details-marker { display: none; }
details summary::after { content: "+"; position: absolute; right: 0.2rem; top: 0.85rem; font-family: var(--font-mono); font-size: 1.4rem; color: var(--accent-text); transition: transform 0.2s var(--ease); }
details[open] summary::after { transform: rotate(45deg); }
details > div { padding: 0 0 1.1rem; }
details p:last-child { margin-bottom: 0; }

footer.site { border-top: 1.5px solid var(--ink); background: var(--paper-2); }
.foot { max-width: 1240px; margin: 0 auto; padding: var(--space-4) 1.5rem; display: grid; grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr)); gap: 2rem; font-size: 0.95rem; line-height: 1.55; }
.foot h2 { font-family: var(--font-mono); font-size: 0.72rem; letter-spacing: 0.1em; text-transform: uppercase; margin: 0 0 0.6rem; }
.foot p { margin: 0 0 0.6rem; color: var(--ink-2); }
.notfound { max-width: 40rem; margin: 20vh auto; padding: 0 1.5rem; }

@media (max-width: 1080px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .toc { display: none; }
  .toc-mobile { display: block; margin: var(--space-3) 0 0; border: 1px solid var(--rule); background: var(--paper-2); }
  .toc-mobile summary { font-family: var(--font-mono); font-size: 0.78rem; letter-spacing: 0.08em; text-transform: uppercase; padding: 0.9rem 1rem; font-weight: 700; }
  .toc-mobile summary::after { top: 0.55rem; right: 0.8rem; }
  .toc-mobile ol { list-style: none; margin: 0; padding: 0 1rem 1rem; columns: 1; }
  .toc-mobile a { display: block; padding: 0.45rem 0; font-family: var(--font-mono); font-size: 0.8rem; text-decoration: none; color: var(--ink-2); border-top: 1px solid var(--rule); }
}
@media (max-width: 640px) {
  body { font-size: 1.0625rem; }
  .mast nav { display: none; }
  dl.defs > div { grid-template-columns: minmax(0, 1fr); gap: 0.2rem; }
  .bar-row { grid-template-columns: 1fr 4.5rem; }
  .bar-row .name { grid-column: 1 / -1; }
  blockquote { font-size: 1.3rem; }
  .stats li { padding-right: 0.8rem; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .diagram .flow { animation: none; }
  .bar-row .fill, .btn { transition: none; }
}
@media print {
  .mast, .toc, .toc-mobile, #progress, .cta-row, .calc form { display: none !important; }
  body { background: #fff; color: #000; font-size: 11pt; }
  a { color: #000; }
  .shell { display: block; }
  details { display: block; }
  details > div { display: block !important; }
}

/* brand plate: the supplied logo artwork, on its own black field */
.logo-plate { margin: 0 0 var(--space-4); max-width: 26rem; border-radius: 0.9rem; overflow: hidden; background: #05060a; box-shadow: 0 30px 80px -30px rgba(61, 139, 255, 0.55), 0 0 0 1px var(--rule); }
.logo-plate img { width: 100%; height: auto; display: block; }
@media (min-width: 1100px) {
  .hero h1 { font-size: clamp(3rem, 4.7vw, 5.2rem); max-width: 12ch; }
  .hero .eyebrow, .hero .lede { max-width: 58%; }
  .hero { position: relative; }
  .logo-plate { position: absolute; right: 1.5rem; top: var(--space-5); width: 31%; max-width: 27rem; margin: 0; }
}

/* utility classes replacing inline styles (the CSP forbids inline style attributes) */
.w-100 { width: 100%; }
.w-3 { width: 3%; }
.measure { max-width: var(--measure); }
