/* --- design tokens --- */
:root {
  --paper: #f6f3ec;
  --paper-2: #fbf9f3;
  --paper-3: #efe9da;
  --ink: #16161a;
  --ink-2: #2a2823;
  --mute: #6b6660;
  --mute-2: #9a958b;
  --rule: #d6d1c4;
  --rule-2: #c5bfae;
  --accent: #1f5266;             /* Prussian teal */
  --accent-2: #2b7891;
  --accent-soft: #d9e6ea;
  --warn: #b9612a;
  --good: #3f7048;
  --bad: #a23a3a;

  --serif: "Source Serif 4", "Source Serif Pro", "Iowan Old Style", Georgia, serif;
  --sans:  "IBM Plex Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --mono:  "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 17px;
  line-height: 1.6;
  font-feature-settings: "kern", "liga", "onum";
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* subtle paper grain */
body::before {
  content: "";
  position: fixed; inset: 0;
  pointer-events: none;
  z-index: 0;
  background:
    radial-gradient(circle at 20% 10%, rgba(120,100,70,.035), transparent 60%),
    radial-gradient(circle at 80% 80%, rgba(80,90,110,.04), transparent 55%);
  mix-blend-mode: multiply;
}

a { color: var(--accent); text-decoration: none; border-bottom: 1px solid currentColor; }
a:hover { color: var(--accent-2); }

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

/* --- layout --- */
.page {
  position: relative;
  z-index: 1;
  max-width: 1240px;
  margin: 0 auto;
  padding: 0 56px 120px;
}
@media (max-width: 720px) {
  .page { padding: 0 24px 80px; }
  body { font-size: 16px; }
}

/* --- top journal bar --- */
.journal-bar {
  display: flex; justify-content: space-between; align-items: baseline;
  border-bottom: 1px solid var(--ink);
  padding: 18px 0 10px;
  font-family: var(--sans);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink);
}
.journal-bar .meta { color: var(--mute); letter-spacing: 0.1em; }
.journal-bar .meta b { color: var(--ink); font-weight: 600; }

/* --- nav --- */
.toc {
  position: sticky; top: 0;
  z-index: 50;
  background: var(--paper);
  border-bottom: 1px solid var(--rule);
  padding: 12px 0;
  margin-bottom: 48px;
  backdrop-filter: blur(6px);
}
.toc-inner {
  display: flex; align-items: center; gap: 28px;
  font-family: var(--sans);
  font-size: 12px;
  letter-spacing: 0.06em;
  color: var(--mute);
  overflow-x: auto;
  scrollbar-width: none;
}
.toc-inner::-webkit-scrollbar { display: none; }
.toc-inner .doi {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0;
  color: var(--mute);
  margin-left: auto;
  white-space: nowrap;
}
.toc-link {
  border: none;
  color: var(--mute);
  cursor: pointer;
  white-space: nowrap;
  position: relative;
  padding: 4px 0;
  transition: color .2s;
}
.toc-link:hover, .toc-link.active { color: var(--ink); }
.toc-link.active::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -13px;
  height: 2px; background: var(--ink);
}
.toc-num {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--mute-2);
  margin-right: 6px;
}

/* --- typography --- */
.eyebrow {
  font-family: var(--sans);
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--mute);
  display: flex; align-items: center; gap: 12px;
}
.eyebrow .rule { flex: 0 0 32px; height: 1px; background: var(--ink); }
.eyebrow-num { font-family: var(--mono); color: var(--ink); }

h1.title {
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(38px, 5.4vw, 68px);
  line-height: 1.05;
  letter-spacing: -0.02em;
  margin: 28px 0 32px;
  text-wrap: balance;
}
h1.title em { font-style: italic; color: var(--accent); }

h2.section-title {
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(28px, 3vw, 40px);
  line-height: 1.15;
  letter-spacing: -0.01em;
  margin: 0 0 12px;
  text-wrap: balance;
}
h3 {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 19px;
  letter-spacing: -0.005em;
  margin: 0 0 8px;
}
.lede {
  font-size: 20px;
  line-height: 1.5;
  color: var(--ink-2);
  max-width: 56ch;
  text-wrap: pretty;
}
p { text-wrap: pretty; }
.col-text { max-width: 64ch; }

.caption {
  font-family: var(--sans);
  font-size: 12px;
  line-height: 1.55;
  color: var(--mute);
  letter-spacing: 0.005em;
}
.caption .fig {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--ink);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  margin-right: 6px;
}

/* --- section block --- */
section.block {
  padding: 64px 0;
  border-top: 1px solid var(--rule);
}
section.block:first-of-type { border-top: none; }
.section-head {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 48px;
  margin-bottom: 40px;
}
@media (max-width: 820px) {
  .section-head { grid-template-columns: 1fr; gap: 12px; }
}

/* --- cards / panels --- */
.panel {
  background: var(--paper-2);
  border: 1px solid var(--rule);
  padding: 28px;
  position: relative;
}
.panel.dim { background: var(--paper); }
.panel-num {
  position: absolute;
  top: -10px; left: 16px;
  background: var(--paper);
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink);
  padding: 0 6px;
}

.figure {
  background: var(--paper-2);
  border: 1px solid var(--rule);
  position: relative;
}
.figure .fig-body { padding: 24px; }
.figure .fig-cap {
  border-top: 1px solid var(--rule);
  padding: 14px 24px;
  background: var(--paper-3);
}

/* --- chip / pill --- */
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--sans);
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border: 1px solid var(--ink);
  padding: 4px 10px;
  color: var(--ink);
  background: transparent;
}
.chip.accent { background: var(--accent); color: var(--paper-2); border-color: var(--accent); }
.chip.warn { background: var(--warn); color: var(--paper-2); border-color: var(--warn); }
.chip.good { background: var(--good); color: var(--paper-2); border-color: var(--good); }
.chip.dim { color: var(--mute); border-color: var(--rule-2); }

/* metric */
.metric {
  border: 1px solid var(--rule);
  background: var(--paper-2);
  padding: 22px;
  position: relative;
}
.metric .k {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--mute);
}
.metric .v {
  font-family: var(--serif);
  font-size: 44px;
  line-height: 1;
  letter-spacing: -0.02em;
  margin-top: 14px;
  color: var(--ink);
}
.metric .u {
  font-family: var(--sans);
  font-size: 12px;
  color: var(--mute);
  margin-top: 6px;
}

/* buttons */
.btn {
  font-family: var(--sans);
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 9px 14px;
  background: var(--ink);
  color: var(--paper-2);
  border: 1px solid var(--ink);
  cursor: pointer;
  transition: all .15s;
}
.btn:hover { background: var(--accent); border-color: var(--accent); }
.btn.ghost { background: transparent; color: var(--ink); }
.btn.ghost:hover { background: var(--ink); color: var(--paper-2); }
.btn.sm { padding: 6px 10px; font-size: 11px; }

/* slider */
.slider-wrap {
  display: flex; flex-direction: column; gap: 8px;
}
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 2px;
  background: var(--rule-2);
  outline: none;
  margin: 18px 0;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--ink);
  border: 3px solid var(--paper);
  box-shadow: 0 0 0 1px var(--ink);
  cursor: grab;
}
input[type="range"]::-moz-range-thumb {
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--ink);
  border: 3px solid var(--paper);
  box-shadow: 0 0 0 1px var(--ink);
  cursor: grab;
}

/* tick marks under slider */
.ticks {
  display: flex; justify-content: space-between;
  font-family: var(--mono);
  font-size: 10px;
  color: var(--mute);
  margin-top: -8px;
}

/* hover anim */
.fadein {
  opacity: 0; transform: translateY(10px);
  animation: fadein 0.7s forwards;
}
@keyframes fadein {
  to { opacity: 1; transform: translateY(0); }
}

/* small label */
.label {
  font-family: var(--sans);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--mute);
}

/* tabular numbers */
.tnum { font-variant-numeric: tabular-nums; }

/* citation footnote */
sup.cite {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--accent);
  cursor: pointer;
  margin-left: 1px;
}
sup.cite:hover { color: var(--ink); }

/* refs list */
.ref-item {
  display: grid;
  grid-template-columns: 32px 1fr;
  gap: 12px;
  padding: 14px 0;
  border-bottom: 1px dotted var(--rule);
  font-size: 14px;
  line-height: 1.45;
}
.ref-item .ref-n {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--mute);
  padding-top: 2px;
}

/* drop cap */
.dropcap::first-letter {
  font-family: var(--serif);
  font-weight: 400;
  float: left;
  font-size: 64px;
  line-height: 0.85;
  padding: 6px 8px 0 0;
  color: var(--accent);
}

/* svg fig common */
svg text { font-family: var(--mono); font-size: 10px; fill: var(--mute); }
svg .axis { stroke: var(--ink); }
svg .gridline { stroke: var(--rule); stroke-dasharray: 2 3; }
svg .label-l { font-family: var(--sans); font-size: 11px; fill: var(--ink); }

/* phone frame */
.phone {
  width: 260px;
  border: 8px solid #1c1c1f;
  border-radius: 32px;
  background: #0d0d0f;
  padding: 6px;
  box-shadow: 0 14px 40px rgba(20,15,5,0.18), 0 2px 8px rgba(20,15,5,0.1);
  position: relative;
}
.phone-screen {
  background: var(--paper-2);
  border-radius: 22px;
  overflow: hidden;
  aspect-ratio: 9/19;
  position: relative;
}

/* keyboard shortcut chip */
.kbd {
  font-family: var(--mono);
  font-size: 10px;
  background: var(--paper-3);
  border: 1px solid var(--rule);
  padding: 1px 5px;
  border-radius: 3px;
  color: var(--ink);
}
