:root {
  color-scheme: dark;
  --ink: #e9edf0;
  --muted: #a8b4ba;
  --line: #33414a;
  --paper: #090d12;
  --white: #101820;
  --panel: #121b22;
  --panel-strong: #17222a;
  --teal: #55b8ad;
  --blue: #748fc5;
  --gold: #c79a47;
  --rose: #b65b63;
  --ember: #d7b46b;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.46);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background:
    radial-gradient(circle at 12% 18%, rgba(255, 255, 255, 0.18) 0 1px, transparent 1.5px),
    radial-gradient(circle at 68% 8%, rgba(215, 180, 107, 0.18) 0 1px, transparent 1.5px),
    radial-gradient(circle at 84% 44%, rgba(85, 184, 173, 0.16) 0 1px, transparent 1.5px),
    linear-gradient(180deg, #070a0f 0%, #0b1117 42%, #090d12 100%);
  background-attachment: fixed;
  background-size: 180px 180px, 260px 260px, 340px 340px, auto;
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.5;
}

body::before {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  content: "";
  background:
    linear-gradient(90deg, rgba(199, 154, 71, 0.05) 1px, transparent 1px),
    linear-gradient(180deg, rgba(199, 154, 71, 0.035) 1px, transparent 1px);
  background-size: 76px 76px;
  mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.5), transparent 74%);
}

a {
  color: inherit;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 64px;
  padding: 10px clamp(16px, 4vw, 44px);
  border-bottom: 1px solid rgba(199, 154, 71, 0.24);
  background: rgba(8, 12, 17, 0.88);
  backdrop-filter: blur(18px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 760;
  text-decoration: none;
}

.brand-mark {
  display: inline-grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border: 1px solid rgba(199, 154, 71, 0.75);
  background: #05080c;
  color: var(--ember);
  font-size: 12px;
}

.nav {
  display: flex;
  gap: clamp(10px, 3vw, 24px);
  color: #b7c3c8;
  font-size: 14px;
}

.nav a {
  text-decoration: none;
}

main {
  overflow: hidden;
}

.summary-band,
.lab-section,
.results-section,
.mechanism-section,
.review-section,
.sources-section {
  padding: clamp(36px, 7vw, 84px) clamp(16px, 4vw, 52px);
}

.summary-band {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(320px, 0.95fr);
  gap: clamp(28px, 6vw, 80px);
  min-height: calc(100svh - 64px);
  align-items: center;
  border-bottom: 1px solid rgba(199, 154, 71, 0.2);
}

.eyebrow {
  margin: 0 0 12px;
  color: var(--ember);
  font-size: 12px;
  font-weight: 780;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  overflow-wrap: anywhere;
}

h1 {
  max-width: 940px;
  margin: 0;
  font-size: clamp(42px, 8vw, 92px);
  line-height: 0.95;
  letter-spacing: 0;
}

h2 {
  margin: 0;
  font-size: clamp(30px, 5vw, 58px);
  line-height: 1;
  letter-spacing: 0;
}

h3 {
  margin: 0;
  font-size: 20px;
  line-height: 1.18;
  letter-spacing: 0;
}

.lede {
  max-width: 760px;
  margin: 24px 0 0;
  color: var(--muted);
  font-size: clamp(18px, 2.3vw, 23px);
}

.source-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 28px;
}

.source-actions a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 9px 14px;
  border: 1px solid rgba(199, 154, 71, 0.72);
  background: rgba(16, 24, 32, 0.86);
  text-decoration: none;
  font-weight: 680;
}

.source-actions a:first-child {
  background: var(--ember);
  color: #081018;
}

.thesis-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.thesis-cell {
  min-height: 180px;
  padding: 18px;
  border: 1px solid rgba(199, 154, 71, 0.22);
  background:
    linear-gradient(135deg, rgba(199, 154, 71, 0.08), transparent 32%),
    var(--panel);
  box-shadow: var(--shadow);
  clip-path: polygon(0 0, calc(100% - 16px) 0, 100% 16px, 100% 100%, 16px 100%, 0 calc(100% - 16px));
}

.thesis-cell span,
.result-list article span,
.metric-strip span {
  display: block;
  color: #b9c4ca;
  font-size: 12px;
  font-weight: 760;
  text-transform: uppercase;
}

.thesis-cell strong {
  display: block;
  margin-top: 16px;
  font-size: clamp(24px, 4vw, 42px);
  line-height: 1;
}

.thesis-cell p {
  margin: 18px 0 0;
  color: var(--muted);
}

.thesis-cell:nth-child(1) {
  border-top: 6px solid var(--teal);
}

.thesis-cell:nth-child(2) {
  border-top: 6px solid var(--gold);
}

.thesis-cell.wide {
  grid-column: 1 / -1;
  min-height: 130px;
  border-top: 6px solid var(--blue);
}

.section-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  max-width: 1180px;
  margin: 0 auto 28px;
}

.lab-shell {
  display: grid;
  grid-template-columns: minmax(250px, 340px) minmax(0, 1fr);
  gap: 18px;
  max-width: 1180px;
  margin: 0 auto;
}

.controls-panel,
.chart-panel {
  border: 1px solid rgba(199, 154, 71, 0.22);
  background:
    linear-gradient(135deg, rgba(85, 184, 173, 0.05), transparent 36%),
    var(--panel);
  box-shadow: var(--shadow);
  clip-path: polygon(0 0, calc(100% - 14px) 0, 100% 14px, 100% 100%, 14px 100%, 0 calc(100% - 14px));
}

.controls-panel {
  display: grid;
  align-content: start;
  gap: 20px;
  padding: 20px;
}

.mode-control {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  padding: 4px;
  border: 1px solid rgba(199, 154, 71, 0.28);
  background: #090f15;
}

.mode-button {
  min-height: 44px;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font: inherit;
  font-size: 13px;
  font-weight: 760;
}

.mode-button.active {
  background: var(--ember);
  color: #081018;
}

.controls-panel label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.controls-panel label span {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

output {
  color: var(--ember);
  font-variant-numeric: tabular-nums;
}

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

.chart-panel {
  min-width: 0;
  padding: 18px;
}

.metric-strip {
  display: grid;
  grid-template-columns: 170px 1fr;
  gap: 12px;
  margin-bottom: 12px;
}

.metric-strip div {
  min-height: 72px;
  padding: 12px;
  border: 1px solid rgba(199, 154, 71, 0.25);
  background: rgba(8, 13, 18, 0.72);
}

.metric-strip strong {
  display: block;
  margin-top: 6px;
  font-size: clamp(22px, 3vw, 34px);
  line-height: 1;
}

.state-summary {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 14px;
}

#contractChart {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 15 / 8;
  border: 1px solid rgba(199, 154, 71, 0.25);
  background: #071017;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 12px;
  color: var(--muted);
  font-size: 13px;
}

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

.legend i {
  display: inline-block;
  width: 22px;
  height: 4px;
  border-radius: 999px;
}

.legend .front {
  background: var(--teal);
}

.legend .smooth {
  background: var(--gold);
}

.legend .band {
  background: rgba(116, 143, 197, 0.32);
}

.fine-print {
  max-width: 1180px;
  margin: 16px auto 0;
  color: var(--muted);
  font-size: 13px;
}

.math-details {
  max-width: 1180px;
  margin: 12px auto 0;
  color: var(--muted);
  font-size: 14px;
}

.math-details summary {
  min-height: 44px;
  cursor: pointer;
  color: var(--ink);
  font-weight: 760;
}

.math-details code {
  color: var(--ink);
}

.results-section,
.review-section {
  background: rgba(14, 25, 29, 0.82);
}

.result-list,
.review-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  max-width: 1180px;
  margin: 0 auto;
}

.result-list article,
.review-grid article {
  min-height: 240px;
  padding: 18px;
  border: 1px solid rgba(199, 154, 71, 0.22);
  background:
    linear-gradient(135deg, rgba(199, 154, 71, 0.07), transparent 34%),
    var(--panel);
  clip-path: polygon(0 0, calc(100% - 14px) 0, 100% 14px, 100% 100%, 14px 100%, 0 calc(100% - 14px));
}

.result-list article:nth-child(1),
.review-grid article:nth-child(1) {
  border-top: 6px solid var(--teal);
}

.result-list article:nth-child(2),
.review-grid article:nth-child(2) {
  border-top: 6px solid var(--gold);
}

.result-list article:nth-child(3),
.review-grid article:nth-child(3) {
  border-top: 6px solid var(--blue);
}

.result-list article:nth-child(4),
.review-grid article:nth-child(4) {
  border-top: 6px solid var(--rose);
}

.result-list h3,
.review-grid h3 {
  margin-top: 18px;
}

.result-list p,
.review-grid p {
  margin: 14px 0 0;
  color: var(--muted);
}

.timeline {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0;
  max-width: 1180px;
  margin: 0 auto;
  border: 1px solid rgba(199, 154, 71, 0.22);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.timeline div {
  min-height: 180px;
  padding: 18px;
  border-right: 1px solid rgba(199, 154, 71, 0.16);
}

.timeline div:last-child {
  border-right: 0;
}

.timeline span {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  background: var(--ember);
  color: #081018;
  font-weight: 760;
}

.timeline strong {
  display: block;
  margin-top: 18px;
}

.timeline p {
  margin: 10px 0 0;
  color: var(--muted);
}

.source-table {
  max-width: 980px;
  margin: 0 auto;
  border: 1px solid rgba(199, 154, 71, 0.22);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.source-table > div {
  display: grid;
  grid-template-columns: 220px 1fr;
  border-bottom: 1px solid rgba(199, 154, 71, 0.16);
}

.source-table > div:last-child {
  border-bottom: 0;
}

.source-table span,
.source-table a {
  padding: 14px 16px;
  min-width: 0;
  overflow-wrap: anywhere;
}

.source-table span:first-child {
  color: var(--muted);
  font-weight: 760;
}

@media (max-width: 980px) {
  .summary-band,
  .lab-shell {
    grid-template-columns: 1fr;
  }

  .summary-band {
    align-items: start;
    min-height: auto;
  }

  .result-list,
  .review-grid,
  .timeline {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .timeline div {
    border-bottom: 1px solid var(--line);
  }
}

@media (max-width: 680px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
    min-height: 96px;
  }

  .nav {
    width: 100%;
    justify-content: space-between;
  }

  .summary-band,
  .lab-section,
  .results-section,
  .mechanism-section,
  .review-section,
  .sources-section {
    padding: 28px 14px;
  }

  h1 {
    font-size: clamp(38px, 14vw, 58px);
  }

  .thesis-grid,
  .result-list,
  .review-grid,
  .timeline,
  .metric-strip {
    grid-template-columns: 1fr;
  }

  .section-heading {
    display: block;
  }

  .result-list article,
  .review-grid article,
  .timeline div {
    min-height: auto;
  }

  .timeline div {
    border-right: 0;
  }

  .source-table > div {
    grid-template-columns: 1fr;
  }

  .source-table span:first-child {
    padding-bottom: 2px;
  }

  .source-table a,
  .source-table span:last-child {
    padding-top: 2px;
  }
}
