:root {
  --ink: #171313;
  --muted: #625b58;
  --paper: #f5f0e7;
  --panel: #fffaf1;
  --line: #d8cdbf;
  --red: #8f1d2c;
  --red-dark: #5f101c;
  --gold: #a9772a;
  --green: #2f6750;
  --blue: #315e78;
  --shadow: 0 14px 40px rgba(67, 48, 32, .10);
  --sans: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --serif: Iowan Old Style, Palatino Linotype, Book Antiqua, Palatino, Georgia, serif;
  color-scheme: light;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  overflow-x: clip;
  color: var(--ink);
  background:
    linear-gradient(rgba(143, 29, 44, .025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(143, 29, 44, .025) 1px, transparent 1px),
    var(--paper);
  background-size: 24px 24px;
  font-family: var(--sans);
  line-height: 1.64;
}
a { color: var(--red-dark); text-decoration-thickness: .08em; text-underline-offset: .15em; }
a:hover { color: var(--red); }
img, svg { max-width: 100%; height: auto; }
code { font-size: .91em; }
pre { max-width: 100%; overflow-x: auto; padding: 1rem; background: rgba(255,250,241,.7); border: 1px solid var(--line); }
pre code { white-space: pre; }

.skip-link { position: absolute; left: -999px; top: 0; }
.skip-link:focus { left: 1rem; top: 1rem; z-index: 20; background: var(--panel); padding: .75rem; }

.topbar {
  border-bottom: 1px solid var(--line);
  background: rgba(245, 240, 231, .96);
  position: sticky;
  top: 0;
  z-index: 10;
  backdrop-filter: blur(14px);
}
.topbar-inner { max-width: 1240px; margin: auto; padding: .72rem 1.4rem; display: flex; align-items: center; gap: 1rem; }
.brand { display: flex; align-items: center; gap: .7rem; color: var(--ink); text-decoration: none; font-weight: 700; letter-spacing: .01em; white-space: nowrap; }
.brand-mark { width: 27px; height: 27px; border: 2px solid var(--gold); border-radius: 50%; display: grid; place-items: center; color: var(--red); font-family: var(--serif); }
.topnav { display: flex; gap: 1rem; margin-left: auto; width: min-content; max-width: 100%; overflow-x: auto; font-size: .91rem; }
.topnav a { color: var(--muted); text-decoration: none; white-space: nowrap; }
.topnav a[aria-current="page"] { color: var(--red-dark); font-weight: 700; }

.shell { max-width: 1240px; margin: auto; padding: 2.4rem 1.4rem 5rem; display: grid; grid-template-columns: minmax(0, 1fr) 250px; gap: 3.2rem; }
main { min-width: 0; }
.eyebrow { color: var(--red); text-transform: uppercase; letter-spacing: .14em; font-weight: 800; font-size: .76rem; }
h1, h2, h3 { font-family: var(--serif); line-height: 1.14; text-wrap: balance; }
h1 { font-size: clamp(2.6rem, 7vw, 5.8rem); margin: .35rem 0 1.15rem; letter-spacing: -.04em; }
h2 { font-size: clamp(1.8rem, 3vw, 2.55rem); margin: 3.1rem 0 1rem; padding-top: .2rem; }
h3 { font-size: 1.34rem; margin: 2rem 0 .6rem; }
.lede { color: var(--muted); font-family: var(--serif); font-size: clamp(1.18rem, 2vw, 1.45rem); max-width: 820px; }
.hero { padding: 2.8rem 0 1rem; }

.status-strip { display: flex; flex-wrap: wrap; gap: .55rem; margin: 1.7rem 0; }
.pill { border: 1px solid var(--line); border-radius: 99px; padding: .32rem .68rem; font-size: .78rem; font-weight: 700; background: var(--panel); }
.pill.demo { color: var(--green); }
.pill.derived { color: var(--blue); }
.pill.hypothesis { color: var(--red-dark); }

.card-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; margin: 1.4rem 0; }
.card { border: 1px solid var(--line); background: rgba(255, 250, 241, .82); padding: 1.25rem; box-shadow: var(--shadow); }
.card h3 { margin-top: 0; }
.card p:last-child { margin-bottom: 0; }
.card-number { font-family: var(--serif); font-size: 2rem; color: var(--red); }

.callout { border-left: 4px solid var(--gold); background: rgba(255, 250, 241, .78); padding: 1rem 1.15rem; margin: 1.5rem 0; }
.callout.danger { border-color: var(--red); }
.callout.success { border-color: var(--green); }
.callout > :first-child { margin-top: 0; }
.callout > :last-child { margin-bottom: 0; }

.diagram { background: var(--panel); border: 1px solid var(--line); padding: 1rem; margin: 1.7rem 0; box-shadow: var(--shadow); }
.diagram figcaption { color: var(--muted); font-size: .88rem; margin-top: .65rem; }

.table-wrap { width: 100%; max-width: 100%; overflow-x: auto; margin: 1.25rem 0; }
table { border-collapse: collapse; width: 100%; min-width: 650px; background: rgba(255,250,241,.56); }
th, td { border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; padding: .78rem .72rem; }
th { color: var(--red-dark); font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; }

.steps { counter-reset: steps; padding: 0; list-style: none; }
.steps li { counter-increment: steps; position: relative; padding: .15rem 0 1.4rem 3.2rem; border-left: 1px solid var(--line); margin-left: 1rem; }
.steps li::before { content: counter(steps); position: absolute; left: -1.05rem; top: -.1rem; width: 2rem; height: 2rem; display: grid; place-items: center; border-radius: 50%; color: var(--panel); background: var(--red-dark); font-weight: 800; }

.toc { position: sticky; top: 5rem; align-self: start; font-size: .86rem; }
.toc strong { display: block; margin-bottom: .7rem; text-transform: uppercase; letter-spacing: .09em; font-size: .72rem; color: var(--muted); }
.toc ol { list-style: none; margin: 0; padding: 0; border-left: 1px solid var(--line); }
.toc li { margin: 0; }
.toc a { display: block; padding: .32rem .7rem; color: var(--muted); text-decoration: none; }
.toc a:hover { color: var(--red-dark); }

.file-tree { columns: 2; column-gap: 2rem; }
.file-tree li { break-inside: avoid; margin-bottom: .45rem; }
.metric { font-family: var(--serif); font-size: 2.2rem; color: var(--red-dark); line-height: 1; }
.caption { color: var(--muted); font-size: .88rem; }
.source { padding-left: 1.1rem; border-left: 2px solid var(--line); margin: 1.1rem 0; }

footer { border-top: 1px solid var(--line); color: var(--muted); padding: 2rem 1.4rem; font-size: .85rem; }
footer > div { max-width: 1240px; margin: auto; }

@media (max-width: 880px) {
  .shell { grid-template-columns: 1fr; gap: 1rem; }
  .toc { position: static; order: -1; }
  .toc ol { columns: 2; }
  .topnav { gap: .7rem; }
}
@media (max-width: 620px) {
  .topbar-inner { align-items: flex-start; flex-direction: column; }
  .topnav { width: 100%; margin-left: 0; padding-bottom: .15rem; }
  .card-grid { grid-template-columns: 1fr; }
  .file-tree { columns: 1; }
  .toc ol { columns: 1; }
  h1 { font-size: 2.75rem; }
}
@media print {
  .topbar, .toc, .skip-link { display: none; }
  body { background: white; }
  .shell { display: block; max-width: none; padding: 0; }
  .card, .diagram { box-shadow: none; break-inside: avoid; }
  a { color: black; }
  a[href^="http"]::after { content: " (" attr(href) ")"; font-size: .75em; }
}
