:root {
  --paper: #faf9f7;
  --paper-dark: #f2efea;
  --ink: #1a1a1a;
  --ink-mid: #3a3a3a;
  --ink-light: #6a6a6a;
  --ink-faint: #999;
  --rule: #e0e0e0;
  --rule-dark: #c0c0c0;
  --red: #c41e3a;
  --red-light: #fce8ea;
  --amber: #e65100;
  --amber-dim: rgba(230,81,0,0.05);
  --green: #2e7d32;
  --green-dim: rgba(46,125,50,0.05);
  --cyan: #0d6efd;
  --mono: 'IBM Plex Mono', monospace;
  --display: 'Playfair Display', serif;
  --body: 'Source Serif 4', serif;
  --col-total: 1100px;
  --space-xs: 4px;
  --space-s: 8px;
  --space-m: 16px;
  --space-l: 24px;
  --space-xl: 48px;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  background: var(--paper);
  color: var(--ink-mid);
  font-family: var(--body);
  font-size: 16px;
  line-height: 1.7;
  font-weight: 300;
}

h1, h2, h3, .site-logo, .site-nav, .footer-brand, .hero-title, .part-title {
  font-family: var(--display);
}

.lead {
  font-size: 1.1rem;
  font-weight: 350;
  line-height: 1.85;
  color: var(--ink);
}

.site-header {
  background: var(--paper);
  border-bottom: 1px solid var(--rule);
  padding: 0 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 65px;
  position: sticky;
  top: 0;
  z-index: 100;
}

.site-logo {
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.15em;
  text-decoration: none;
  color: var(--ink);
  text-transform: uppercase;
}

.site-logo-sep {
  color: var(--red);
}

.site-logo-sub {
  font-weight: 400;
  color: var(--ink-light);
}

.site-nav {
  display: flex;
  gap: 0;
}

.site-nav a {
  color: var(--ink-mid);
  text-decoration: none;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  padding: 0 1rem;
  height: 65px;
  display: flex;
  align-items: center;
  border-left: 1px solid var(--rule);
  transition: color 0.15s, background 0.15s;
}

.site-nav a:hover {
  color: var(--red);
  background: var(--red-light);
}

.nav-cta {
  background: var(--red) !important;
  color: var(--paper) !important;
  font-weight: 700;
}

.nav-cta:hover {
  background: #a01830 !important;
}

.section-label {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--red);
  display: inline-block;
  margin-bottom: 1rem;
  border-left: 3px solid var(--red);
  padding-left: 0.75rem;
}

.doc-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 180px;
  gap: 2rem;
  max-width: var(--col-total);
  margin: 0 auto;
  padding: 0 2rem;
}

.doc-main {
  min-width: 0;
}

.doc-margin {
  position: relative;
}

.margin-note {
  font-size: 11px;
  line-height: 1.6;
  color: var(--ink-light);
  border-left: 1px solid var(--rule-dark);
  padding-left: 1rem;
  margin-bottom: 1.25rem;
}

.margin-note strong {
  color: var(--ink);
  font-weight: 600;
  display: block;
  margin-bottom: 0.25rem;
}

.finding {
  background: var(--paper-dark);
  border-left: 4px solid var(--red);
  padding: 1.5rem 2rem;
  margin: 2rem 0;
  font-style: italic;
  color: var(--ink);
}

.finding p {
  margin-bottom: 0.5rem;
}

.finding cite {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--ink-light);
  font-style: normal;
}

.formula {
  background: var(--paper-dark);
  border: 1px solid var(--rule);
  border-left: 3px solid var(--cyan);
  padding: 1.25rem 1.5rem;
  margin: 1.5rem 0;
  font-family: var(--mono);
  font-size: 13px;
  overflow-x: auto;
}

.formula-id {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.15em;
  color: var(--ink-faint);
  margin-bottom: 0.5rem;
}

.formula-name {
  font-weight: 700;
  margin-bottom: 0.75rem;
  color: var(--ink);
}

.formula-body {
  font-size: 13px;
  line-height: 2;
  color: var(--ink-mid);
}

.formula-vars {
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--rule);
  font-size: 11px;
  line-height: 1.6;
}

.formula-vars .var {
  color: var(--cyan);
  font-weight: 500;
}

.formula-result {
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--rule);
  font-weight: 600;
  color: var(--red);
}

.footnotes {
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--rule);
  font-size: 12px;
  color: var(--ink-light);
}

.footnotes-title {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  margin-bottom: 1rem;
}

.footnote-item {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
  line-height: 1.6;
}

.footnote-num {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--red);
  flex-shrink: 0;
}

.callout {
  padding: 1.25rem 1.5rem;
  margin: 1.5rem 0;
  background: var(--paper-dark);
  border-left: 3px solid var(--red);
}

.callout-label {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--red);
  margin-bottom: 0.5rem;
}

.callout p {
  margin-bottom: 0;
  font-size: 0.9rem;
}

.access-gate {
  border: 1px solid var(--rule-dark);
  padding: 2rem;
  background: var(--paper);
  text-align: center;
  max-width: 560px;
  margin: 0 auto;
}

.gate-label {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.2em;
  color: var(--red);
  text-transform: uppercase;
  margin-bottom: 1rem;
}

.gate-title {
  font-family: var(--display);
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  color: var(--ink);
}

.gate-sub {
  color: var(--ink-light);
  margin-bottom: 1.5rem;
  font-size: 0.9rem;
}

.gate-tiers {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.gate-tier {
  border: 1px solid var(--rule);
  padding: 1rem;
  background: var(--paper);
  transition: border-color 0.15s;
}

.tier-active {
  border-color: var(--red);
  background: var(--red-light);
}

.tier-name {
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 0.25rem;
}

.tier-price {
  font-family: var(--mono);
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--red);
  margin-bottom: 0.5rem;
}

.tier-desc {
  font-size: 0.75rem;
  color: var(--ink-light);
  line-height: 1.5;
}

.gate-form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  max-width: 400px;
  margin: 0 auto;
}

.gate-input {
  padding: 0.75rem;
  border: 1px solid var(--rule-dark);
  font-family: var(--mono);
  font-size: 12px;
  background: var(--paper);
}

.gate-btn {
  background: var(--red);
  color: var(--paper);
  border: none;
  padding: 0.75rem;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  cursor: pointer;
}

.gate-btn:hover {
  background: #a01830;
}

.site-footer {
  border-top: 1px solid var(--rule);
  padding: 2rem;
  margin-top: 3rem;
}

.footer-inner {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1.5rem;
  max-width: var(--col-total);
  margin: 0 auto;
}

.footer-brand {
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.15em;
  color: var(--ink);
}

.footer-copy {
  font-size: 10px;
  color: var(--ink-light);
  line-height: 1.6;
  margin-top: 0.5rem;
}

.footer-col-title {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin-bottom: 0.75rem;
}

.footer-links {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.footer-links a {
  color: var(--ink-light);
  text-decoration: none;
  font-size: 11px;
}

.footer-links a:hover {
  color: var(--red);
}

.footer-legal {
  font-size: 9px;
  color: var(--ink-faint);
  text-align: center;
  margin-top: 2rem;
  padding-top: 1rem;
  border-top: 1px solid var(--rule);
  line-height: 1.6;
}

@media (max-width: 800px) {
  .doc-layout {
    grid-template-columns: 1fr;
  }
  .doc-margin {
    display: none;
  }
  .site-nav {
    display: none;
  }
  .hero h1 {
    font-size: 1.8rem;
  }
  .part-nav {
    flex-direction: column;
    gap: 1rem;
  }
}