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

:root {
  --bg:        #f4f2ed;
  --pine:      #2d5016;
  --mid:       rgba(45,80,22,0.58);
  --lo:        rgba(45,80,22,0.36);
  --body-text: rgba(45,80,22,0.80);
  --div:       rgba(45,80,22,0.09);
  --card-bg:   rgba(45,80,22,0.05);
  --card-bd:   rgba(45,80,22,0.10);
  --font:      'Space Grotesk', sans-serif;
}

html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  font-family: var(--font);
  color: var(--body-text);
  -webkit-font-smoothing: antialiased;
}

/* ── Reading progress bar ───────────────────── */
#progress-bar {
  position: fixed;
  top: 0; left: 0;
  height: 2px;
  width: 0%;
  background: linear-gradient(90deg, var(--pine), rgba(45,80,22,0.4));
  z-index: 200;
  transition: width 0.1s linear;
}

/* ── Nav ────────────────────────────────────── */
nav {
  position: sticky;
  top: 0;
  z-index: 100;
  height: 56px;
  background: rgba(244,242,237,0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--div);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 40px;
}

.nav-left {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
}

.nav-logo-text {
  font-size: 13px;
  font-weight: 600;
  color: var(--pine);
  letter-spacing: -0.01em;
}

.nav-right { display: flex; align-items: center; gap: 18px; }
.nav-right a.nav-link { font-size: 13px; color: var(--lo); text-decoration: none; transition: color 0.2s; }
.nav-right a.nav-link:hover { color: var(--pine); }

.nav-badge {
  font-size: 10.5px;
  font-weight: 500;
  color: var(--lo);
  letter-spacing: 0.10em;
  text-transform: uppercase;
  padding: 3px 10px;
  border: 1px solid var(--div);
  border-radius: 99px;
}

/* ── Icon SVG inline ────────────────────────── */
.hc-icon {
  width: 24px;
  height: 24px;
  flex-shrink: 0;
}

/* ── Table of contents (scroll-spy) ─────────── */
/* Reset the base nav{} styles this <nav> would otherwise inherit */
.toc {
  display: none;
  height: auto;
  padding: 0;
  background: none;
  border: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

@media (min-width: 1280px) {
  .toc {
    display: block;
    position: fixed;
    top: 96px;
    left: calc((100vw - 820px) / 2 - 210px);
    width: 190px;
    max-height: calc(100vh - 140px);
    overflow-y: auto;
    z-index: 90;
  }
}

.toc-title {
  font-size: 10.5px;
  font-weight: 600;
  color: var(--mid);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin: 0 0 12px 12px;
}

.toc ol {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.toc a {
  display: flex;
  gap: 9px;
  align-items: baseline;
  font-size: 12.5px;
  line-height: 1.35;
  color: var(--lo);
  text-decoration: none;
  padding: 6px 10px;
  border-left: 2px solid transparent;
  transition: color 0.15s, border-color 0.15s;
}
.toc a:hover { color: var(--pine); }

.toc a .toc-n {
  font-size: 10px;
  font-weight: 600;
  color: rgba(45,80,22,0.28);
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
  min-width: 13px;
}

.toc a.active {
  color: var(--pine);
  font-weight: 500;
  border-left-color: var(--pine);
}
.toc a.active .toc-n { color: var(--pine); }

.references { scroll-margin-top: 72px; }

/* ── Hero ───────────────────────────────────── */
.hero {
  max-width: 820px;
  margin: 0 auto;
  padding: 60px 40px 0;
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 24px;
}

.tag {
  font-size: 10.5px;
  font-weight: 500;
  color: var(--mid);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 3px 10px;
  border: 1px solid var(--card-bd);
  border-radius: 99px;
}

h1 {
  font-size: clamp(40px, 5.5vw, 60px);
  font-weight: 700;
  color: var(--pine);
  letter-spacing: -0.04em;
  line-height: 1.01;
  margin-bottom: 18px;
  text-wrap: balance;
}

.subtitle {
  font-size: clamp(17px, 2vw, 20px);
  color: var(--mid);
  line-height: 1.45;
  max-width: 620px;
  margin-bottom: 28px;
}

.byline {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  font-size: 13px;
  color: var(--mid);
}

.byline-dot {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--lo);
  flex-shrink: 0;
}

.byline span:not(.byline-dot):not(.author) {
  color: var(--lo);
}

.byline .author { color: var(--mid); }

/* ── Divider ────────────────────────────────── */
.rule {
  height: 1px;
  background: var(--div);
  margin: 36px auto 0;
  max-width: 820px;
}

/* ── Article body ───────────────────────────── */
.body {
  max-width: 820px;
  margin: 0 auto;
  padding: 40px 40px 0;
}

/* Keep a 700px reading measure, but left-aligned to the hero edge */
.body > * { max-width: 700px; }

.abstract {
  font-size: 17px;
  line-height: 1.76;
  color: var(--body-text);
  margin-bottom: 52px;
}

/* Section header */
.sec-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
  scroll-margin-top: 72px;
}

.sec-num {
  font-size: 11px;
  font-weight: 700;
  color: rgba(45,80,22,0.22);
  letter-spacing: 0.08em;
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}

.sec-rule {
  flex: 1;
  height: 1px;
  background: rgba(45,80,22,0.10);
}

.sec-label {
  font-size: 10.5px;
  font-weight: 600;
  color: var(--mid);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  flex-shrink: 0;
  text-align: right;
}

/* Subsection heading */
h3.subhead {
  font-size: 18px;
  font-weight: 600;
  color: var(--pine);
  letter-spacing: -0.02em;
  line-height: 1.3;
  margin: 34px 0 16px;
}

/* Body text */
p {
  font-size: 16.5px;
  line-height: 1.78;
  color: var(--body-text);
  margin-bottom: 22px;
}

p + .sec-head { margin-top: 40px; }

.body a {
  color: var(--pine);
  text-decoration: none;
  border-bottom: 1px solid rgba(45,80,22,0.28);
  transition: border-color 0.15s, color 0.15s;
}
.body a:hover { border-color: var(--pine); }

/* Inline citation markers */
a.cite {
  font-size: 0.72em;
  font-weight: 600;
  color: var(--pine);
  vertical-align: super;
  line-height: 0;
  border-bottom: none;
  padding: 0 1px;
}
a.cite:hover { border-bottom: none; opacity: 0.7; }

/* Inline code */
code {
  font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  font-size: 0.86em;
  background: rgba(45,80,22,0.06);
  border: 1px solid rgba(45,80,22,0.08);
  border-radius: 5px;
  padding: 1px 5px;
  color: var(--pine);
  white-space: nowrap;
}

/* Code blocks */
pre {
  background: rgba(45,80,22,0.045);
  border: 1px solid var(--card-bd);
  border-radius: 12px;
  padding: 18px 20px;
  margin: 8px 0 28px;
  overflow-x: auto;
}
pre code {
  font-size: 13.5px;
  line-height: 1.7;
  background: none;
  border: none;
  padding: 0;
  color: var(--body-text);
  white-space: pre;
  display: block;
}

/* Math */
.math-block {
  margin: 6px 0 26px;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 4px 0;
}
.katex { color: var(--pine); }

/* Pull quote */
blockquote {
  margin: 0 0 22px;
  padding: 4px 0 4px 24px;
  border-left: 3px solid rgba(45,80,22,0.22);
}

blockquote p {
  font-size: 18px;
  font-weight: 500;
  color: var(--pine);
  line-height: 1.55;
  letter-spacing: -0.01em;
  margin-bottom: 0;
}

/* Figure / screenshot */
figure {
  margin: 8px 0 34px;
}
figure img {
  width: 100%;
  max-width: 420px;
  height: auto;
  display: block;
  margin: 0 auto;
  border: 1px solid var(--card-bd);
  border-radius: 14px;
  background: var(--card-bg);
}
figcaption {
  font-size: 12.5px;
  color: var(--lo);
  line-height: 1.55;
  margin-top: 12px;
  letter-spacing: 0.01em;
}

/* Data table */
.data-table-wrap {
  margin: 8px 0 36px;
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

thead th {
  text-align: left;
  padding: 8px 14px;
  border-bottom: 2px solid rgba(45,80,22,0.13);
  font-size: 10.5px;
  font-weight: 600;
  color: var(--mid);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

tbody tr:nth-child(even) { background: rgba(45,80,22,0.03); }

tbody td {
  padding: 11px 14px;
  border-bottom: 1px solid rgba(45,80,22,0.06);
  color: rgba(45,80,22,0.78);
  font-variant-numeric: tabular-nums;
  vertical-align: top;
}

tbody td:first-child {
  color: var(--pine);
  font-weight: 500;
}

.table-caption {
  font-size: 11px;
  color: var(--lo);
  margin-top: 10px;
  letter-spacing: 0.02em;
}

/* Stat callout */
.stat-callout {
  background: var(--card-bg);
  border: 1px solid var(--card-bd);
  border-radius: 12px;
  padding: 26px 32px;
  margin: 8px 0 36px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.stat-value {
  font-size: 60px;
  font-weight: 700;
  color: var(--pine);
  letter-spacing: -0.05em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.stat-label {
  font-size: 13px;
  color: var(--mid);
}

/* Bullet list */
.bullet-list {
  list-style: none;
  padding: 0;
  margin: 0 0 22px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.bullet-list li {
  position: relative;
  padding-left: 22px;
  font-size: 16px;
  color: var(--body-text);
  line-height: 1.7;
}

.bullet-list li::before {
  content: '';
  position: absolute;
  left: 4px;
  top: 0.72em;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: rgba(45,80,22,0.30);
}
.bullet-list li strong { color: var(--pine); font-weight: 600; }

/* References */
.references {
  max-width: 820px;
  margin: 0 auto;
  padding: 0 40px;
}
.references > * { max-width: 700px; }
.references ol {
  list-style: none;
  counter-reset: ref;
  padding: 0;
  margin: 0;
}
.references li {
  counter-increment: ref;
  position: relative;
  padding-left: 38px;
  font-size: 13px;
  line-height: 1.65;
  color: var(--mid);
  margin-bottom: 14px;
  scroll-margin-top: 72px;
}
.references li::before {
  content: '[' counter(ref) ']';
  position: absolute;
  left: 0;
  top: 0;
  color: var(--lo);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.references a {
  color: var(--pine);
  text-decoration: none;
  border-bottom: 1px solid rgba(45,80,22,0.22);
  word-break: break-word;
}
.references a:hover { border-color: var(--pine); }

/* ── Footer ─────────────────────────────────── */
footer {
  margin-top: 80px;
  border-top: 1px solid var(--div);
  background: rgba(45,80,22,0.03);
}

.footer-inner {
  max-width: 820px;
  margin: 0 auto;
  padding: 48px 40px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 48px;
  align-items: start;
}

@media (max-width: 600px) {
  .footer-inner { grid-template-columns: 1fr; gap: 32px; }
  nav { padding: 0 20px; }
  .nav-right a.nav-link { display: none; }
  .hero, .body, .references { padding-left: 20px; padding-right: 20px; }
  .rule { margin-left: 20px; margin-right: 20px; }
}

.footer-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}

.footer-brand-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--pine);
  letter-spacing: -0.01em;
}

.footer-desc {
  font-size: 13px;
  color: var(--lo);
  line-height: 1.65;
  margin-bottom: 0;
}

.footer-col-title {
  font-size: 10.5px;
  font-weight: 600;
  color: var(--mid);
  letter-spacing: 0.10em;
  text-transform: uppercase;
  margin-bottom: 16px;
}

.footer-links {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.footer-links a {
  font-size: 13px;
  color: var(--mid);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 6px;
}

.footer-links a:hover { color: var(--pine); }

.ai-disclaimer {
  max-width: 820px;
  margin: 0 auto;
  padding: 32px 40px;
}

.ai-disclaimer p {
  font-size: 12px;
  line-height: 1.7;
  color: var(--lo);
  margin: 0;
}

.footer-bottom {
  max-width: 820px;
  margin: 0 auto;
  padding: 20px 40px;
  border-top: 1px solid var(--div);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

.footer-bottom span {
  font-size: 11px;
  color: var(--lo);
}
