@font-face { font-family: "Merriweather"; src: url("./assets/fonts/merriweather-400.woff2") format("woff2"); font-weight: 400; font-style: normal; font-display: block; }
@font-face { font-family: "Merriweather"; src: url("./assets/fonts/merriweather-400-italic.woff2") format("woff2"); font-weight: 400; font-style: italic; font-display: block; }
@font-face { font-family: "Merriweather"; src: url("./assets/fonts/merriweather-700.woff2") format("woff2"); font-weight: 700; font-style: normal; font-display: block; }
@font-face { font-family: "Lato"; src: url("./assets/fonts/lato-700.woff2") format("woff2"); font-weight: 700; font-style: normal; font-display: block; }
@font-face { font-family: "Lato"; src: url("./assets/fonts/lato-900.woff2") format("woff2"); font-weight: 900; font-style: normal; font-display: block; }

:root {
  --bg: rgb(255, 255, 255);
  --panel: rgb(245, 245, 245);
  --text: rgb(31, 31, 31);
  --muted: rgb(108, 108, 108);
  --accent: rgb(30, 30, 30);
  --green: #1f9d57;
  --red: #d33a3f;
  --link: #2563eb;
  --border: rgb(238, 238, 238);
  --bar-track: rgb(234, 234, 234);
  --max: 820px;
  --radius: 8px;
  --font-body: "Merriweather", "PT Serif", Georgia, "Times New Roman", serif;
  --font-head: "Lato", "Helvetica Neue", Helvetica, -apple-system, sans-serif;
}

html[data-theme="dark"] {
  --bg: rgb(29, 30, 32);
  --panel: rgb(46, 46, 51);
  --text: rgb(196, 196, 197);
  --muted: rgb(155, 156, 157);
  --accent: rgb(218, 218, 219);
  --green: #2fbf71;
  --red: #e5484d;
  --link: #6ea8fe;
  --border: rgb(51, 51, 51);
  --bar-track: rgb(55, 56, 62);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  line-height: 1.7;
  font-size: 17px;
  transition: background 0.2s ease, color 0.2s ease;
}

.theme-toggle {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 10;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  font-size: 1.05rem;
  line-height: 1;
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 50%;
  cursor: pointer;
}
.theme-toggle:hover { border-color: var(--accent); }
.theme-toggle svg { width: 18px; height: 18px; display: block; }
.theme-toggle #sun { display: none; }
html[data-theme="dark"] .theme-toggle #moon { display: none; }
html[data-theme="dark"] .theme-toggle #sun { display: block; }

h1, h2, h3, .authors, .chip, .bar-label, .bar-fill, .breakdown {
  font-family: var(--font-head);
}

h1, h2, h3 { font-weight: 900; }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
a.ref { color: var(--link); text-decoration: none; }
a.ref:hover { text-decoration: underline; }
a.jump { color: var(--text); text-decoration: none; }
a.jump .jump-icon {
  display: inline-block;
  margin-left: 4px;
  font-size: 0.8em;
  color: var(--muted);
  transition: transform 0.15s ease, color 0.15s ease;
}
a.jump:hover .jump-icon { transform: translate(1px, -1px); color: var(--accent); }

main {
  max-width: var(--max);
  margin: 0 auto;
  padding: 0 24px 120px;
}

.hero { padding: 64px 0 24px; border-bottom: 1px solid var(--border); }
.hero h1 {
  font-size: 2.4rem;
  line-height: 1.15;
  margin: 0 0 8px;
  letter-spacing: -0.02em;
}
.authors { color: var(--muted); margin: 0 0 12px; font-size: 1rem; }
.hero-links {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 16px;
  margin: 0 0 20px;
  font-family: var(--font-head);
  font-size: 0.95rem;
}
.hero-code {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
  padding: 4px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
}
.gh-icon { display: block; }

.side-nav {
  position: fixed;
  top: 50%;
  left: 32px;
  transform: translateY(-75%);
  display: flex;
  flex-direction: column;
  gap: 9px;
  font-family: var(--font-head);
  font-size: 0.85rem;
  z-index: 5;
}
.side-nav-title {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.66rem;
  font-weight: 900;
  color: var(--muted);
  margin-bottom: 2px;
}
.side-nav a {
  color: var(--muted);
  text-decoration: none;
  white-space: nowrap;
  border-left: 2px solid var(--border);
  padding: 1px 0 1px 12px;
  transition: color 0.15s ease, border-color 0.15s ease;
}
.side-nav a:hover { color: var(--text); text-decoration: none; }
.side-nav a.active {
  color: var(--accent);
  font-weight: 700;
  border-left-color: var(--accent);
}
@media (max-width: 1320px) { .side-nav { display: none; } }
.subtitle { font-size: 1.15rem; color: var(--text); margin: 0 0 28px; }
.sim-note { font-size: 0.82rem; color: var(--muted); font-style: italic; margin: 8px 0 0; }

section { padding: 40px 0; border-bottom: 1px solid var(--border); scroll-margin-top: 70px; }
section h2 {
  font-size: 1.6rem;
  letter-spacing: -0.01em;
  margin: 0 0 16px;
}
section p { margin: 0 0 16px; }

.media { margin: 24px 0; }
.media video, .media img {
  width: 100%;
  height: auto;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #000;
  display: block;
}
figcaption {
  margin-top: 8px;
  font-size: 0.9rem;
  color: var(--muted);
  text-align: center;
}
.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}
@media (max-width: 640px) { .two-col { grid-template-columns: 1fr; } }

.loop-layout {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 24px;
  align-items: center;
  margin: 16px 0;
}
.loop-layout .media { margin: 0; }
.loop-text p { margin: 0 0 12px; }
.loop-text p:last-child { margin-bottom: 0; }
@media (max-width: 640px) { .loop-layout { grid-template-columns: 1fr; } }

.callout {
  background: var(--panel);
  border-left: 3px solid var(--link);
  padding: 14px 18px;
  border-radius: 6px;
}
.tldr-list, .delta-list { padding-left: 20px; }
.tldr-list li, .delta-list li { margin: 8px 0; }

.chip {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 600;
  color: #fff;
}
.chip.green { background: var(--green); }
.chip.red { background: var(--red); }
.chip.yellow { background: #e6b800; color: #1a1a1a; }
.chip.purple { background: #8b5cf6; }
.chip.orange { background: #e8742c; }

.results {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 28px;
  align-items: center;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
  margin: 8px 0 24px;
}
@media (max-width: 640px) { .results { grid-template-columns: 1fr; } }

.bar-row { display: flex; align-items: center; gap: 12px; margin: 10px 0; }
.bar-label { width: 72px; font-size: 0.9rem; color: var(--muted); }
.bar {
  flex: 1;
  background: var(--bar-track);
  border-radius: 6px;
  overflow: hidden;
  height: 30px;
}
.bar-fill {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-right: 8px;
  font-size: 0.85rem;
  font-weight: 700;
  color: #fff;
  border-radius: 6px;
}
.bar-fill.recovery { background: var(--green); }
.bar-fill.baseline { background: var(--muted); }
.bar-caption { font-size: 0.85rem; color: var(--muted); margin-top: 10px; }

.breakdown { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
.breakdown caption { color: var(--muted); font-size: 0.82rem; margin-bottom: 8px; text-align: left; }
.breakdown td { padding: 7px 0; border-bottom: 1px solid var(--border); }
.breakdown td:last-child { text-align: right; font-weight: 700; }

.result-table {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px 22px;
  margin: 8px 0 20px;
}
.matrix { width: 100%; border-collapse: collapse; font-family: var(--font-head); font-size: 0.92rem; }
.matrix caption { color: var(--muted); font-size: 0.82rem; margin-bottom: 10px; text-align: left; }
.matrix th, .matrix td { padding: 9px 8px; border-bottom: 1px solid var(--border); }
.matrix thead th {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  text-align: right;
}
.matrix thead th:first-child { text-align: left; }
.matrix tbody th { text-align: left; font-weight: 700; }
.matrix tbody td { text-align: right; }
.matrix tbody tr:last-child th, .matrix tbody tr:last-child td { border-bottom: none; }
.matrix td.best { color: var(--green); font-weight: 900; }

section h3 {
  font-size: 1.3rem;
  margin: 24px 0 10px;
}
.caption-note { font-size: 0.9rem; color: var(--muted); margin-top: 10px; }
.legend-title {
  font-family: var(--font-head);
  font-weight: 900;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin: 0 0 8px;
}
.legend-list { padding-left: 20px; }
.legend-list li { margin: 8px 0; }

.setup {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin: 24px 0;
}
.setup-title {
  font-family: var(--font-head);
  font-weight: 900;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 12px;
}
.setup dl {
  margin: 0;
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: 8px 16px;
}
@media (max-width: 560px) { .setup dl { grid-template-columns: 1fr; gap: 2px 0; } }
.setup dt { font-weight: 700; }
.setup dd { margin: 0; color: var(--text); }
.setup code {
  font-family: "Source Code Pro", Consolas, ui-monospace, Menlo, monospace;
  font-size: 0.85em;
  background: var(--bar-track);
  padding: 1px 5px;
  border-radius: 4px;
}

.eqn {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: center;
  gap: 8px 18px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px 24px 16px;
  margin: 16px 0 24px;
}
.eqn-factor {
  display: flex;
  flex-direction: column;
  align-items: center;
  max-width: 168px;
}
.eqn-sym {
  font-family: var(--font-body);
  font-size: 1.55rem;
  line-height: 1.05;
  letter-spacing: 0.01em;
}
.eqn-sym em { font-style: italic; }
.eqn-sym sub { font-size: 0.55em; font-style: normal; }
.eqn-factor.result .eqn-sym { color: var(--green); }
.eqn-brace {
  width: 72%;
  height: 6px;
  margin: 5px 0 6px;
  border: 1px solid var(--border);
  border-top: 0;
  border-radius: 0 0 6px 6px;
}
.eqn-ann {
  font-family: var(--font-head);
  font-size: 0.76rem;
  color: var(--muted);
  line-height: 1.35;
  text-align: center;
}
.eqn-op {
  font-family: var(--font-body);
  font-size: 1.4rem;
  color: var(--muted);
  line-height: 1.05;
  padding-top: 3px;
}

.citation {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  overflow-x: auto;
  font-size: 0.85rem;
  line-height: 1.5;
}
.citation code { font-family: "Source Code Pro", Consolas, ui-monospace, Menlo, monospace; }

.site-footer {
  padding: 32px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
  text-align: center;
}
