:root {
  --paper: #ffffff;
  --paper-raised: #fcfcfd;
  --ink: #16181d;
  --ink-soft: #2b2f38;
  --muted: #5d636e;
  --faint: #878d99;
  --line: #e2e5ea;
  --line-soft: #eceef2;
  --oxide: #2159c4;
  --oxide-strong: #1b48a0;
  --oxide-soft: #dbe6fb;
  --copper: #545d70;
  --copper-strong: #343b49;
  --copper-soft: #e8ebf1;
  --good: #12715a;
  --focus: #2159c4;
  --reading: 760px;
  --wide: 1180px;
  --shadow: 0 1px 2px rgba(20, 26, 40, .05), 0 8px 28px -12px rgba(20, 26, 40, .18);
  color-scheme: light;
}

:root[data-theme="dark"] {
  --paper: #0e1014;
  --paper-raised: #14171d;
  --ink: #e9ebf1;
  --ink-soft: #ccd1dc;
  --muted: #99a0ae;
  --faint: #767d8c;
  --line: #272b34;
  --line-soft: #1e222a;
  --oxide: #7aa5f5;
  --oxide-strong: #9dbcff;
  --oxide-soft: #1b2740;
  --copper: #aab3c4;
  --copper-strong: #d0d6e2;
  --copper-soft: #252b36;
  --good: #4fc3a1;
  --focus: #9dbcff;
  --shadow: 0 1px 2px rgba(0, 0, 0, .5), 0 10px 30px -14px rgba(0, 0, 0, .8);
  color-scheme: dark;
}

* { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  scroll-padding-top: 70px;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink-soft);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  font-size: 17px;
  line-height: 1.72;
  text-rendering: optimizeLegibility;
}

a {
  color: var(--oxide);
  text-decoration: none;
}

a:hover { text-decoration: underline; text-underline-offset: 3px; }

button,
select,
input { font: inherit; }

button,
select {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper-raised);
  color: var(--ink);
}

button {
  min-height: 34px;
  padding: 6px 13px;
  cursor: pointer;
  transition: background-color 150ms ease, border-color 150ms ease, color 150ms ease;
}

button:hover {
  border-color: var(--faint);
  background: var(--line-soft);
}

button:disabled {
  cursor: not-allowed;
  opacity: .55;
}

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

::selection {
  background: var(--oxide-soft);
  color: var(--ink);
}

.page {
  width: min(calc(100% - 48px), var(--reading));
  margin-inline: auto;
}

.skip-link {
  position: fixed;
  top: 8px;
  left: 8px;
  z-index: 100;
  padding: 9px 13px;
  background: var(--ink);
  color: var(--paper);
  transform: translateY(-160%);
}

.skip-link:focus { transform: none; }

.reading-progress {
  position: fixed;
  inset: 0 auto auto 0;
  z-index: 110;
  width: 0;
  height: 3px;
  background: var(--oxide);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 90;
  display: flex;
  align-items: center;
  gap: 18px;
  height: 54px;
  padding: 0 22px;
  border-bottom: 1px solid transparent;
  background: color-mix(in srgb, var(--paper) 86%, transparent);
  backdrop-filter: saturate(180%) blur(14px);
}

.topbar.stuck { border-bottom-color: var(--line); }

.project-mark {
  flex: 0 0 auto;
  color: var(--ink);
  font-family: "DM Sans", "Google Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
}

.topbar nav {
  display: flex;
  gap: 2px;
  margin-left: auto;
  overflow-x: auto;
  scrollbar-width: none;
}

.topbar nav::-webkit-scrollbar { display: none; }

.topbar nav a {
  padding: 5px 9px;
  border-radius: 7px;
  color: var(--muted);
  font-size: 13px;
  text-decoration: none;
  white-space: nowrap;
}

.topbar nav a:hover,
.topbar nav a.current {
  background: var(--line-soft);
  color: var(--ink);
}

.theme-toggle {
  display: grid;
  flex: 0 0 auto;
  width: 32px;
  height: 32px;
  padding: 0;
  place-items: center;
}

.theme-toggle svg {
  width: 15px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-width: 1.7;
}

.hero {
  padding: 78px 0 16px;
  text-align: center;
}

.hero-inner {
  width: min(calc(100% - 48px), 1080px);
  margin-inline: auto;
}

h1,
h2,
h3,
p { margin-top: 0; }

h1,
h2,
h3 {
  font-family: "DM Sans", "Google Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  color: var(--ink);
}

h1 {
  margin: 0 auto;
  font-size: clamp(33px, 5.1vw, 62px);
  font-weight: 400;
  line-height: 1.13;
  letter-spacing: -.014em;
  text-wrap: balance;
}

h1 span { color: var(--oxide-strong); }

h2 {
  margin-bottom: 6px;
  font-size: 27px;
  font-weight: 600;
  line-height: 1.28;
  letter-spacing: -.015em;
}

h3 {
  margin-bottom: 9px;
  font-size: 19px;
  font-weight: 600;
  letter-spacing: -.01em;
}

.authors {
  margin: 34px 0 0;
  color: var(--ink);
  font-family: "DM Sans", "Google Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  font-size: clamp(17px, 1.65vw, 21px);
  font-weight: 500;
  letter-spacing: -.004em;
}

.authors sup,
.affils sup {
  margin-left: 1px;
  font-size: .62em;
  vertical-align: super;
}

.affils {
  display: flex;
  justify-content: center;
  margin: 12px 0 0;
  color: var(--ink-soft);
  font-size: 15.5px;
}

.emails {
  margin: 9px 0 0;
  font-size: 15px;
}

.paper-actions {
  display: flex;
  justify-content: center;
  gap: 9px;
  flex-wrap: wrap;
  margin-top: 30px;
}

.paper-actions a {
  font-size: 14.5px;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 18px;
  border: 1px solid var(--ink);
  border-radius: 999px;
  background: var(--ink);
  color: var(--paper);
  font-weight: 560;
  text-decoration: none;
}

.pill:hover { opacity: .88; text-decoration: none; }
.pill.ghost { border-color: var(--line); background: transparent; color: var(--ink); }
.pill.ghost:hover { border-color: var(--faint); }
.pill svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }

.paper-meta {
  margin: 22px 0 0;
  color: var(--muted);
  font-size: 12.5px;
  letter-spacing: .02em;
}

.spectrum-stage {
  margin-top: 0;
}

.figure-heading,
.section-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 28px;
}

.figure-heading h2,
.section-heading h2 { margin-bottom: 5px; }

.figure-heading p,
.section-heading p {
  max-width: 620px;
  margin-bottom: 0;
  color: var(--muted);
}

.spectrum-controls {
  display: grid;
  grid-template-columns: auto minmax(180px, 1fr) auto;
  align-items: center;
  gap: 16px;
  margin: 24px 0 9px;
}

.spectrum-controls label,
.spectrum-controls output,
.section-heading label,
.growth-toolbar label,
.fusion-toolbar label {
  color: var(--muted);
  font-size: 15px;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--oxide-strong);
  cursor: pointer;
}

select {
  min-height: 40px;
  margin-left: 6px;
  padding: 5px 32px 5px 10px;
}

.legend {
  display: flex;
  gap: 20px;
  justify-content: flex-end;
  color: var(--muted);
  font-size: 14px;
}

.legend span { display: inline-flex; align-items: center; gap: 7px; }

.legend i {
  width: 14px;
  height: 3px;
}

.projective-key { background: var(--copper); }
.transient-key { background: var(--oxide); }

.chart-shell {
  width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
}

.chart-shell svg {
  display: block;
  width: 100%;
  min-width: 720px;
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
}

.spectrum-readout {
  display: grid;
  grid-template-columns: minmax(130px, .8fr) minmax(190px, 1fr) minmax(220px, 1.5fr);
  align-items: baseline;
  gap: 16px;
  padding: 12px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  font-size: 15px;
}

.spectrum-readout strong {
  color: var(--ink);
  font-family: "IBM Plex Mono", monospace;
  font-size: 19px;
  overflow-wrap: anywhere;
}

.scale-strip,
.growth-readout {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  margin: 22px 0 0;
}

.scale-strip div,
.growth-readout div {
  min-width: 0;
  padding: 0 16px;
  border-left: 1px solid var(--line);
}

.scale-strip div:first-child,
.growth-readout div:first-child {
  padding-left: 0;
  border-left: 0;
}

dt {
  color: var(--muted);
  font-size: 14px;
}

dd {
  margin: 2px 0 0;
  color: var(--ink);
}

.scale-strip dd,
.growth-readout dd {
  font-family: "IBM Plex Mono", monospace;
  font-size: clamp(17px, 2.1vw, 23px);
  font-weight: 600;
  overflow-wrap: anywhere;
}

figcaption {
  margin-top: 18px;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.55;
}

main { padding: 0 0 80px; }

section {
  padding: 48px 0 0;
  scroll-margin-top: 62px;
}

.first-figure-section { padding-top: 34px; }

section p { margin-bottom: 1em; }

hr {
  height: 1px;
  margin: 44px 0 0;
  border: 0;
  background: var(--line);
}

.display-math {
  margin: 18px 0;
  overflow-x: auto;
  color: var(--ink);
}

.glossary {
  margin: 36px 0 0;
  border-top: 1px solid var(--line);
}

.glossary div {
  display: grid;
  grid-template-columns: 170px 1fr;
  gap: 22px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line-soft);
}

.glossary dt {
  color: var(--ink);
  font-weight: 700;
}

.glossary dd { margin: 0; }

.theorem {
  margin: 22px 0;
  padding: 18px 20px 18px 22px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--copper);
  border-radius: 0 12px 12px 0;
  background: var(--paper-raised);
}

.theorem.accent { border-left-color: var(--oxide); }
.theorem p:last-child { margin-bottom: 0; }

.live-figure {
  width: min(var(--wide), calc(100vw - 48px));
  margin: 34px 50% 8px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--paper-raised);
  box-shadow: var(--shadow);
  transform: translateX(-50%);
}

.carry-workspace {
  display: grid;
  grid-template-columns: minmax(420px, 1.15fr) minmax(300px, .85fr);
  gap: 42px;
  align-items: center;
}

#carry-wheel { display: block; width: 100%; }

.carry-actions,
.fusion-toolbar,
.growth-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.primary-button {
  border-color: var(--ink);
  background: var(--ink);
  color: var(--paper);
  font-weight: 700;
}

.primary-button:hover {
  border-color: var(--ink-soft);
  background: var(--ink-soft);
}

.current-state {
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
}

.current-state strong,
.carry-output {
  color: var(--ink);
  font-family: "IBM Plex Mono", monospace;
}

.rule-line {
  min-height: 74px;
  margin: 20px 0;
  color: var(--ink);
  font-size: 1.1rem;
}

.carry-output {
  min-height: 92px;
  padding: 16px 0;
  border-top: 1px solid var(--line-soft);
  border-bottom: 1px solid var(--line-soft);
  font-size: 16px;
}

.carry-term + .carry-term::before {
  content: "+";
  margin: 0 10px;
  color: var(--faint);
}

.muted { color: var(--muted); font-size: 15px; }

.fusion-toolbar,
.growth-toolbar {
  justify-content: space-between;
  margin-bottom: 18px;
}

.fusion-toolbar label,
.growth-toolbar label {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
}

.fusion-toolbar input { width: min(260px, 30vw); }
.fusion-shell { background: var(--paper-raised); }

.mode-switch {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 7px;
  overflow: hidden;
}

.mode-switch button {
  border: 0;
  border-radius: 0;
}

.mode-switch button + button { border-left: 1px solid var(--line); }

.mode-switch button.active {
  background: var(--ink);
  color: var(--paper);
}

.growth-readout {
  padding: 18px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.proof-route {
  margin: 34px 0 0;
  padding: 0;
  border-top: 1px solid var(--ink);
  list-style: none;
  counter-reset: proof-step;
}

.proof-route li {
  display: grid;
  grid-template-columns: 30px 190px 1fr;
  gap: 18px;
  padding: 18px 0;
  border-bottom: 1px solid var(--line-soft);
  counter-increment: proof-step;
}

.proof-route li::before {
  content: counter(proof-step, decimal-leading-zero);
  color: var(--oxide-strong);
  font-family: "IBM Plex Mono", monospace;
  font-size: 14px;
}

.proof-route strong { color: var(--ink); }

.resource-table {
  margin-top: 34px;
  padding: 0;
  overflow-x: auto;
}

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

th,
td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line-soft);
  text-align: left;
  vertical-align: top;
}

th {
  border-top: 2px solid var(--ink);
  border-bottom-color: var(--ink);
  color: var(--ink);
}

code,
pre { font-family: "IBM Plex Mono", monospace; }

code { font-size: .88em; }

pre {
  padding: 18px 0;
  border-top: 1px solid var(--ink);
  border-bottom: 1px solid var(--line);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.65;
  overflow-x: auto;
}

#copy-bibtex { margin-top: 10px; }

footer {
  padding: 28px 0 48px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 14px;
}

.footer-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.reveal {
  opacity: 0;
  transition: opacity 500ms ease;
}

.reveal.visible {
  opacity: 1;
}

.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

@media (max-width: 900px) {
  .project-mark { display: none; }
  .topbar nav { margin-left: 0; }
  .carry-workspace { grid-template-columns: 1fr; }
  .section-heading { align-items: start; }
  .scale-strip,
  .growth-readout { grid-template-columns: repeat(2, 1fr); gap: 18px 0; }
  .scale-strip div:nth-child(3),
  .growth-readout div:nth-child(3) { padding-left: 0; border-left: 0; }
}

@media (max-width: 640px) {
  body { font-size: 17px; }
  .page { width: min(calc(100% - 34px), var(--reading)); }
  .topbar { min-height: 54px; padding-inline: 12px; }
  .topbar nav a { padding-inline: 7px; font-size: 14px; }
  .theme-toggle { width: 38px; }
  .hero { min-height: auto; padding: 38px 17px 32px; }
  h1 { font-size: clamp(2.15rem, 11vw, 3.2rem); }
  .paper-actions { align-items: flex-start; flex-direction: column; gap: 2px; }
  .spectrum-stage { margin-top: 40px; }
  .figure-heading,
  .section-heading { align-items: flex-start; flex-direction: column; gap: 12px; }
  .spectrum-controls { grid-template-columns: 1fr auto; }
  .spectrum-controls input { grid-column: 1 / -1; grid-row: 2; }
  .spectrum-readout { grid-template-columns: 1fr; gap: 2px; }
  .legend { justify-content: flex-start; }
  .glossary div { grid-template-columns: 1fr; gap: 2px; }
  .live-figure { width: calc(100vw - 34px); }
  .carry-workspace { gap: 20px; }
  .fusion-toolbar label,
  .growth-toolbar label { width: 100%; margin-left: 0; }
  .fusion-toolbar input,
  .growth-toolbar input { flex: 1 1 auto; width: auto; }
  .proof-route li { grid-template-columns: 28px 1fr; gap: 8px 12px; }
  .proof-route li span { grid-column: 2; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: .01ms !important;
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
  }
  .reveal { opacity: 1; }
}

@media print {
  .topbar,
  .reading-progress,
  .carry-actions,
  .fusion-toolbar,
  .growth-toolbar,
  .theme-toggle { display: none !important; }
  .hero { min-height: auto; }
  .live-figure { width: 100%; margin-inline: 0; transform: none; }
  .reveal { opacity: 1; }
}
