:root {
  --ink: #0e0d0b;
  --paper: #f3ecdc;
  --paper-warm: #ede4cf;
  --paper-deep: #1a1815;
  --rule: #2a2622;
  --rule-light: #c9bfa6;
  --amber: #d97a1c;
  --amber-soft: #e8a85a;
  --rust: #6b2e15;
  --rust-deep: #4a1f0d;
  --rust-light: #c97a4a;
  --muted: #6b6356;
  --muted-dark: #8a7f6b;
  --ok: #4a7d3f;

  --display: "Fraunces", "Iowan Old Style", "Apple Garamond", Georgia, serif;
  --mono: "JetBrains Mono", "SF Mono", "Cascadia Code", Menlo, monospace;

  --col: 1180px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--mono);
  font-size: 15px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

body {
  position: relative;
  overflow-x: hidden;
  background:
    radial-gradient(ellipse at 18% 0%, rgba(217,122,28,0.06) 0%, transparent 55%),
    radial-gradient(ellipse at 100% 30%, rgba(217,122,28,0.04) 0%, transparent 50%),
    var(--paper);
}

::selection { background: var(--amber); color: var(--paper); }

/* paper grain */
.grain {
  position: fixed; inset: 0;
  pointer-events: none;
  z-index: 1;
  opacity: 0.35;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='240' height='240'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0.05 0 0 0 0 0.04 0 0 0 0 0.03 0 0 0 0.18 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
}

a {
  color: inherit;
  text-decoration: none;
  border-bottom: 1px solid var(--rule-light);
  transition: color 120ms ease, border-color 120ms ease, background 120ms ease;
}
a:hover { color: var(--amber); border-bottom-color: var(--amber); }
a.ext { border-bottom: none; }
a.ext:hover { color: var(--amber); }

code {
  font-family: var(--mono);
  font-size: 0.92em;
  background: rgba(14,13,11,0.06);
  padding: 0.1em 0.4em;
  border-radius: 2px;
}

/* ---------- masthead ---------- */

.masthead {
  position: relative;
  z-index: 2;
  padding: 28px 40px 18px;
  max-width: var(--col);
  margin: 0 auto;
}
.masthead-inner {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 32px;
}
.brand {
  display: flex;
  align-items: baseline;
  gap: 10px;
  font-family: var(--display);
  font-weight: 900;
  font-size: 28px;
  letter-spacing: -0.02em;
}
.brand-mark {
  font-size: 26px;
  color: var(--amber);
  transform: translateY(2px);
  display: inline-block;
}
.brand-word { font-style: italic; }

.masthead-nav {
  display: flex;
  gap: 22px;
  font-size: 12px;
  letter-spacing: 0.05em;
  text-transform: lowercase;
}
.masthead-nav a {
  border-bottom: none;
  color: var(--muted);
  font-weight: 500;
}
.masthead-nav a:hover { color: var(--amber); }

.masthead-rule {
  height: 1px;
  background: var(--rule);
  margin: 14px 0 8px;
  position: relative;
}
.masthead-rule::after {
  content: "";
  position: absolute;
  left: 0; top: 3px;
  height: 1px; width: 100%;
  background: var(--rule);
  opacity: 0.4;
}

.masthead-meta {
  display: flex;
  gap: 14px;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.masthead-meta .dot { opacity: 0.5; }

/* ---------- hero ---------- */

main { position: relative; z-index: 2; }

.hero {
  max-width: var(--col);
  margin: 80px auto 110px;
  padding: 0 40px;
}
.kicker {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 28px;
  padding-left: 4px;
  border-left: 2px solid var(--amber);
  padding: 4px 0 4px 14px;
}
h1.display {
  font-family: var(--display);
  font-weight: 400;
  font-size: clamp(56px, 9vw, 132px);
  line-height: 0.95;
  letter-spacing: -0.035em;
  margin-bottom: 36px;
  font-variation-settings: "SOFT" 50, "opsz" 144;
}
h1.display em {
  font-style: italic;
  font-weight: 300;
  color: var(--amber);
}
.lede {
  font-family: var(--display);
  font-size: 22px;
  line-height: 1.45;
  font-weight: 300;
  max-width: 720px;
  color: var(--ink);
  margin-bottom: 40px;
}
.lede strong {
  font-weight: 700;
  font-style: italic;
  color: var(--amber);
}

.hero-actions {
  display: flex;
  gap: 14px;
  margin-bottom: 56px;
  flex-wrap: wrap;
}
.btn {
  display: inline-flex;
  align-items: center;
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.02em;
  padding: 14px 22px;
  border: 1px solid var(--ink);
  border-bottom: 1px solid var(--ink);
  transition: all 140ms ease;
}
.btn.primary {
  background: var(--ink);
  color: var(--paper);
}
.btn.primary:hover {
  background: var(--amber);
  border-color: var(--amber);
  color: var(--ink);
}
.btn.ghost {
  background: transparent;
  color: var(--ink);
}
.btn.ghost:hover {
  background: var(--ink);
  color: var(--paper);
}

.hero-snippet {
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.85;
  background: var(--ink);
  color: var(--paper);
  padding: 22px 26px;
  max-width: 640px;
  border-left: 3px solid var(--amber);
  white-space: pre;
  overflow-x: auto;
}
.hero-snippet .prompt { color: var(--amber); margin-right: 8px; }
.hero-snippet .ok { color: #a8c97e; }

/* ---------- section primitives ---------- */

.section {
  padding: 90px 40px;
  position: relative;
}
.section.dark {
  background: var(--paper-deep);
  color: var(--paper);
}
.section.dark a { color: var(--paper); border-bottom-color: rgba(243,236,220,0.3); }
.section.dark a:hover { color: var(--amber-soft); border-bottom-color: var(--amber-soft); }
.section.dark code {
  background: rgba(243,236,220,0.08);
  color: var(--amber-soft);
}

.section.rust {
  background: var(--rust);
  color: var(--paper);
  background-image:
    radial-gradient(ellipse at 80% 0%, rgba(217,122,28,0.18) 0%, transparent 50%),
    radial-gradient(ellipse at 0% 100%, rgba(74,31,13,0.5) 0%, transparent 60%);
}
.section.rust a { color: var(--paper); border-bottom-color: rgba(243,236,220,0.35); }
.section.rust a:hover { color: var(--amber-soft); border-bottom-color: var(--amber-soft); }
.section.rust code {
  background: rgba(0,0,0,0.22);
  color: var(--amber-soft);
}
.section.rust .section-head { border-bottom-color: rgba(243,236,220,0.25); }
.section.rust .section-num { color: var(--amber-soft); }
.section.rust .install-lede { color: var(--paper); }

.section-head {
  max-width: var(--col);
  margin: 0 auto 50px;
  display: flex;
  align-items: baseline;
  gap: 24px;
  border-bottom: 1px solid var(--rule);
  padding-bottom: 22px;
}
.section.dark .section-head { border-bottom-color: rgba(243,236,220,0.18); }

.section-num {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.15em;
  color: var(--amber);
  font-weight: 600;
}
.section-head h2 {
  font-family: var(--display);
  font-weight: 400;
  font-style: italic;
  font-size: clamp(34px, 5vw, 56px);
  letter-spacing: -0.025em;
  line-height: 1;
}

.section-body {
  max-width: var(--col);
  margin: 0 auto;
}
.section-body > p {
  max-width: 720px;
  font-family: var(--display);
  font-size: 19px;
  line-height: 1.6;
  font-weight: 300;
}
.section-body > p + p { margin-top: 18px; }

/* ---------- §1 two-column ---------- */

.two-col {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 60px;
  align-items: start;
}
.two-col > div p {
  font-family: var(--display);
  font-size: 19px;
  line-height: 1.6;
  font-weight: 300;
}
.two-col > div p + p { margin-top: 18px; }

.callout {
  border-left: 2px solid var(--amber);
  padding: 4px 0 4px 22px;
}
.callout-label {
  font-family: var(--mono) !important;
  font-size: 11px !important;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 16px !important;
  font-weight: 500;
}
.callout-quote {
  font-family: var(--display) !important;
  font-size: 26px !important;
  line-height: 1.3 !important;
  font-style: italic;
  font-weight: 400 !important;
  letter-spacing: -0.01em;
}
.callout-cite {
  font-family: var(--mono) !important;
  font-size: 12px !important;
  margin-top: 18px !important;
  color: var(--muted-dark);
}

/* ---------- §2 numbered list ---------- */

.numbered {
  list-style: none;
  counter-reset: item;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 50px 60px;
}
.numbered li {
  counter-increment: item;
  position: relative;
  padding-top: 8px;
  border-top: 1px solid rgba(243,236,220,0.18);
}
.numbered li::before {
  content: counter(item, decimal-leading-zero);
  position: absolute;
  top: -12px;
  left: 0;
  background: var(--paper-deep);
  padding-right: 12px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  color: var(--amber);
  font-weight: 600;
}
.numbered li h3 {
  font-family: var(--display);
  font-style: italic;
  font-weight: 400;
  font-size: 26px;
  line-height: 1.2;
  letter-spacing: -0.015em;
  margin: 22px 0 12px;
}
.numbered li p {
  font-family: var(--mono);
  font-size: 14px;
  line-height: 1.7;
  color: rgba(243,236,220,0.78);
}

/* ---------- §3 diagram + cards ---------- */

.diagram {
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.45;
  color: var(--ink);
  background: var(--paper-warm);
  padding: 36px 28px;
  margin: 8px 0 60px;
  border: 1px solid var(--rule-light);
  overflow-x: auto;
  white-space: pre;
}

.grid-three {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 28px;
  margin-bottom: 50px;
}
.card {
  background: var(--paper-warm);
  border: 1px solid var(--rule-light);
  padding: 28px;
  position: relative;
}
.card::before {
  content: "";
  position: absolute;
  top: 0; left: 0;
  width: 32px; height: 2px;
  background: var(--amber);
}
.card h3 {
  font-family: var(--display);
  font-style: italic;
  font-weight: 500;
  font-size: 28px;
  letter-spacing: -0.015em;
  margin-bottom: 14px;
}
.card p {
  font-family: var(--mono);
  font-size: 13.5px;
  line-height: 1.65;
  color: var(--ink);
}

.frame-example {
  border: 1px solid var(--rule);
  padding: 18px 22px;
  background: var(--paper-warm);
}
.frame-example summary {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
  font-weight: 600;
  color: var(--ink);
  list-style: none;
}
.frame-example summary::before {
  content: "▸ ";
  color: var(--amber);
  margin-right: 4px;
}
.frame-example[open] summary::before { content: "▾ "; }
.frame-example pre {
  margin-top: 16px;
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.7;
  white-space: pre-wrap;
  word-break: break-word;
}
.frame-example .comment { color: var(--muted); font-style: italic; }

/* ---------- §4 install ---------- */

.install-lede {
  max-width: 720px;
  font-family: var(--display) !important;
  font-size: 19px !important;
  line-height: 1.6 !important;
  font-weight: 300 !important;
  margin-bottom: 50px;
}
.section.dark .install-lede { color: var(--paper); }

.install-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 28px;
  margin-bottom: 36px;
}
.install-card {
  background: rgba(243,236,220,0.04);
  border: 1px solid rgba(243,236,220,0.18);
  padding: 28px;
}
.install-card h3.os {
  font-family: var(--display);
  font-style: italic;
  font-weight: 500;
  font-size: 32px;
  letter-spacing: -0.02em;
  margin-bottom: 6px;
  color: var(--amber-soft);
}
.install-card .install-desc {
  font-family: var(--mono);
  font-size: 12.5px;
  color: rgba(243,236,220,0.7);
  margin-bottom: 18px;
}
.install-card pre {
  font-family: var(--mono);
  font-size: 11.5px;
  line-height: 1.7;
  background: rgba(0,0,0,0.35);
  color: var(--paper);
  padding: 16px 18px;
  white-space: pre-wrap;
  word-break: break-all;
  border-left: 2px solid var(--amber);
}
.install-foot {
  font-family: var(--mono);
  font-size: 12.5px;
  color: rgba(243,236,220,0.7);
  text-align: right;
}

/* ---------- §5 invariants ---------- */

.invariants .never {
  list-style: none;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px 36px;
  margin-top: 36px;
}
.invariants .never li {
  font-family: var(--mono);
  font-size: 14px;
  line-height: 1.55;
  padding: 14px 0;
  border-bottom: 1px dotted rgba(243,236,220,0.25);
  display: flex;
  gap: 14px;
  align-items: baseline;
  color: rgba(243,236,220,0.92);
}
.never-tag {
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--rust-deep);
  background: var(--amber-soft);
  padding: 3px 8px;
  font-weight: 700;
  flex-shrink: 0;
}

/* ---------- colophon ---------- */

.colophon {
  position: relative;
  z-index: 2;
  background: var(--ink);
  color: var(--paper);
  padding: 70px 40px 50px;
  border-top: 4px solid var(--amber);
}
.colophon-inner {
  max-width: var(--col);
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 36px;
  padding-bottom: 40px;
  border-bottom: 1px solid rgba(243,236,220,0.15);
}
.colophon-block .colophon-label {
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--amber-soft);
  margin-bottom: 8px;
  font-weight: 600;
}
.colophon-block p:not(.colophon-label) {
  font-family: var(--display);
  font-style: italic;
  font-size: 17px;
  font-weight: 400;
  color: var(--paper);
}
.colophon-block a { color: var(--paper); border-bottom-color: rgba(243,236,220,0.3); }
.colophon-footnote {
  max-width: var(--col);
  margin: 32px auto 0;
  font-family: var(--display);
  font-style: italic;
  font-weight: 300;
  font-size: 16px;
  line-height: 1.6;
  color: rgba(243,236,220,0.65);
  max-width: 720px;
}

/* ---------- responsive ---------- */

@media (max-width: 900px) {
  .masthead { padding: 22px 22px 14px; }
  .masthead-inner { flex-direction: column; align-items: flex-start; gap: 14px; }
  .masthead-nav { flex-wrap: wrap; gap: 14px 18px; }

  .hero { padding: 0 22px; margin: 50px auto 70px; }
  h1.display { font-size: clamp(44px, 12vw, 72px); }
  .lede { font-size: 18px; }

  .section { padding: 60px 22px; }
  .section-head { margin-bottom: 36px; flex-direction: column; gap: 8px; }

  .two-col { grid-template-columns: 1fr; gap: 36px; }
  .numbered { grid-template-columns: 1fr; gap: 36px; }
  .grid-three, .install-grid { grid-template-columns: 1fr; gap: 18px; }

  .invariants .never { grid-template-columns: 1fr; gap: 0; }

  .colophon { padding: 50px 22px 36px; }
  .colophon-inner { grid-template-columns: 1fr 1fr; gap: 26px; }
}
