:root {
  --text: #1f2328;
  --muted: #6b7280;
  --rule: #e5e7eb;
  --rule-strong: #9ca3af;
  --accent: #1a5490;
  --accent-soft: #eaf1f8;
  --bg: #fbfbfa;
  --paper-bg: #ffffff;
  --section-bg: #fafafa;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --serif: "Source Serif Pro", "Charter", Georgia, "Times New Roman", serif;
  --content-width: 720px;
  --toc-width: 220px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--serif);
  font-size: 17px;
  line-height: 1.6;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- layout ---------- */

.page {
  display: grid;
  grid-template-columns: var(--toc-width) minmax(0, var(--content-width));
  gap: 56px;
  max-width: calc(var(--toc-width) + var(--content-width) + 56px + 80px);
  margin: 0 auto;
  padding: 40px 40px 80px;
}

.paper {
  background: var(--paper-bg);
  padding: 48px 56px 64px;
  border: 1px solid var(--rule);
  border-radius: 2px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
}

/* ---------- TOC sidebar ---------- */

.toc {
  position: sticky;
  top: 40px;
  align-self: start;
  font-family: var(--sans);
  font-size: 0.85rem;
  line-height: 1.45;
  max-height: calc(100vh - 80px);
  overflow-y: auto;
}

.toc-title {
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.7rem;
  color: var(--muted);
  font-weight: 700;
  margin: 0 0 12px;
}

.toc ol {
  list-style: none;
  padding: 0;
  margin: 0;
  counter-reset: toc;
}

.toc > nav > ol > li {
  counter-increment: toc;
  margin-bottom: 6px;
}

.toc > nav > ol > li > a::before {
  content: counter(toc) ". ";
  color: var(--muted);
  margin-right: 2px;
}

.toc ol ol {
  padding-left: 16px;
  margin-top: 4px;
  border-left: 1px solid var(--rule);
}

.toc ol ol li {
  margin: 3px 0;
}

.toc a {
  color: var(--text);
  display: block;
  padding: 1px 0;
}

.toc a:hover {
  color: var(--accent);
  text-decoration: none;
}

.toc-note {
  margin-top: 20px;
  padding: 10px 12px;
  background: var(--accent-soft);
  border-left: 2px solid var(--accent);
  font-size: 0.78rem;
  color: var(--text);
  line-height: 1.45;
}

/* ---------- paper header ---------- */

.paper-header {
  padding-bottom: 24px;
  border-bottom: 1px solid var(--rule);
  margin-bottom: 32px;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.72rem;
  color: var(--accent);
  margin: 0 0 10px;
  font-family: var(--sans);
  font-weight: 700;
}

.paper-header h1 {
  font-family: var(--serif);
  font-size: 1.85rem;
  line-height: 1.25;
  font-weight: 700;
  margin: 0 0 16px;
}

.authors {
  font-size: 0.92rem;
  line-height: 1.5;
  margin: 0 0 12px;
  color: var(--text);
}

.pub-info {
  margin: 4px 0;
  color: var(--muted);
  font-size: 0.88rem;
  font-family: var(--sans);
}

/* ---------- headings & sections ---------- */

h2 {
  font-family: var(--serif);
  font-size: 1.4rem;
  font-weight: 700;
  margin: 40px 0 14px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--rule);
  scroll-margin-top: 20px;
}

h3 {
  font-family: var(--serif);
  font-size: 1.1rem;
  font-weight: 700;
  margin: 28px 0 10px;
  scroll-margin-top: 20px;
}

section > p {
  margin: 0 0 14px;
  text-align: justify;
  hyphens: auto;
}

section#abstract > p {
  font-size: 0.95rem;
  background: var(--section-bg);
  padding: 16px 18px;
  border-left: 3px solid var(--accent);
  font-style: italic;
  text-align: left;
}

section#abstract em { font-style: normal; }

p.placeholder {
  background: #fff8e1;
  border-left: 3px solid #d4a017;
  padding: 12px 14px;
  font-family: var(--sans);
  font-size: 0.88rem;
  color: #5b4a10;
  text-align: left;
}

p.note {
  font-family: var(--sans);
  font-size: 0.85rem;
  color: var(--muted);
}

/* ---------- interactive figures ---------- */

figure.interactive {
  margin: 28px 0;
  padding: 18px 18px 12px;
  background: #fdfdfc;
  border: 1px solid var(--rule);
  border-radius: 2px;
}

.fig-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

figcaption {
  font-family: var(--sans);
  font-size: 0.92rem;
  line-height: 1.4;
  flex: 1;
  min-width: 240px;
}

.controls {
  font-family: var(--sans);
  font-size: 0.85rem;
}

.controls label { color: var(--muted); margin-right: 6px; }

.controls select {
  font: inherit;
  padding: 3px 6px;
  border: 1px solid var(--rule-strong);
  border-radius: 3px;
  background: #fff;
  cursor: pointer;
}

.n-summary {
  font-family: var(--sans);
  color: var(--muted);
  font-size: 0.85rem;
  margin: 2px 0 12px;
  text-align: left;
}

/* ---------- data tables ---------- */

table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--sans);
  font-size: 0.86rem;
}

.data-table thead th {
  text-align: left;
  border-bottom: 2px solid var(--rule-strong);
  padding: 8px 10px;
  font-weight: 600;
}

.data-table th.col-num, .data-table td.col-num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.data-table tbody tr.section-row td {
  padding: 12px 10px 4px;
  font-weight: 700;
  border-bottom: 1px solid var(--rule);
  background: var(--section-bg);
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.data-table tbody td {
  padding: 5px 10px;
  border-bottom: 1px solid var(--rule);
}

.data-table tbody tr:last-child td { border-bottom: 0; }

.data-table.compact { font-size: 0.82rem; }

.data-table.compact tbody td,
.data-table.compact thead th { padding: 4px 8px; }

/* ---------- plots ---------- */

.plot {
  width: 100%;
  min-height: 340px;
  margin: 8px 0 12px;
}

.plot-readout {
  margin-top: 4px;
  margin-bottom: 6px;
}

/* ---------- footnotes ---------- */

.footnote {
  font-family: var(--sans);
  font-size: 0.78rem;
  color: var(--muted);
  margin-top: 10px;
  margin-bottom: 0;
  font-style: italic;
  text-align: left;
}

/* ---------- references ---------- */

ol.references {
  padding-left: 22px;
  font-size: 0.88rem;
  line-height: 1.5;
}

ol.references li {
  margin-bottom: 6px;
  text-align: left;
}

/* ---------- paper footer ---------- */

.paper-footer {
  margin-top: 56px;
  padding-top: 20px;
  border-top: 1px solid var(--rule);
  color: var(--muted);
  font-size: 0.85rem;
  font-family: var(--sans);
}

.paper-footer p {
  margin: 0 0 8px;
  text-align: left;
}

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

@media (max-width: 1000px) {
  .page {
    grid-template-columns: 1fr;
    gap: 0;
    padding: 24px 20px 60px;
  }
  .toc {
    position: static;
    max-height: none;
    margin-bottom: 20px;
    padding: 16px;
    background: #fff;
    border: 1px solid var(--rule);
    border-radius: 2px;
  }
  .paper {
    padding: 28px 24px 48px;
  }
  .paper-header h1 { font-size: 1.5rem; }
}
