:root {
  --bg: #f6f7f8;
  --paper: #ffffff;
  --paper-2: #fafbfb;
  --ink: #17201f;
  --muted: #5d6967;
  --soft: #dfe7e4;
  --line: #cfd9d5;
  --line-strong: #9eb1aa;
  --teal: #0d7f75;
  --teal-deep: #07534d;
  --teal-soft: #dff3ee;
  --amber: #b86b16;
  --amber-soft: #fff2df;
  --coral: #c64f3c;
  --bluegray: #536e87;
  --shadow: 0 24px 80px rgba(23, 32, 31, 0.08);
  --mono: "SFMono-Regular", "Cascadia Code", "Roboto Mono", Consolas, monospace;
  --sans: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  overflow-x: hidden;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  line-height: 1.55;
  overflow-x: clip;
}

body::before {
  position: fixed;
  inset: 0;
  z-index: -1;
  content: "";
  background:
    linear-gradient(rgba(13, 127, 117, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(13, 127, 117, 0.035) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.82), rgba(0, 0, 0, 0.08));
}

a {
  color: inherit;
}

button,
input,
select {
  font: inherit;
}

.site-header {
  padding: 22px 28px 40px;
  background: linear-gradient(180deg, #ffffff 0%, #f7faf9 68%, #eef5f3 100%);
  border-bottom: 1px solid var(--line);
}

.topbar {
  position: sticky;
  top: 14px;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: 10px 12px 10px 14px;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(158, 177, 170, 0.52);
  border-radius: 8px;
  box-shadow: 0 10px 36px rgba(23, 32, 31, 0.07);
  backdrop-filter: blur(14px);
}

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

.brand-mark {
  display: grid;
  width: 28px;
  height: 28px;
  grid-template-columns: repeat(2, 1fr);
  gap: 3px;
  padding: 5px;
  border-radius: 7px;
  background: var(--ink);
}

.brand-mark span {
  background: var(--teal-soft);
  border-radius: 2px;
}

.brand-mark span:nth-child(4) {
  background: var(--amber-soft);
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 4px;
}

.nav-links a {
  padding: 8px 10px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 680;
  text-decoration: none;
  border-radius: 7px;
}

.nav-links a:hover,
.nav-links a:focus-visible {
  color: var(--teal-deep);
  background: var(--teal-soft);
  outline: none;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(480px, 1.1fr);
  gap: 46px;
  width: min(1180px, 100%);
  margin: 84px auto 0;
  align-items: center;
}

.hero h1 {
  max-width: 780px;
  margin: 0;
  font-size: 4rem;
  line-height: 1;
  letter-spacing: 0;
}

.lede {
  max-width: 640px;
  margin: 24px 0 0;
  color: #33413f;
  font-size: 1.16rem;
}

.authors {
  margin: 18px 0 0;
  color: var(--muted);
  font-weight: 660;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 30px;
}

.button,
.button-ghost {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: 8px;
  font-weight: 760;
  text-decoration: none;
}

.button {
  color: #ffffff;
  background: var(--teal-deep);
  border: 1px solid var(--teal-deep);
}

.button:hover,
.button:focus-visible {
  background: var(--teal);
  outline: 3px solid rgba(13, 127, 117, 0.18);
}

.button-ghost {
  color: var(--teal-deep);
  background: #ffffff;
  border: 1px solid var(--line);
}

.button-ghost:hover,
.button-ghost:focus-visible {
  border-color: var(--teal);
  outline: 3px solid rgba(13, 127, 117, 0.14);
}

.hero-panel {
  overflow: hidden;
  background: var(--paper);
  border: 1px solid rgba(158, 177, 170, 0.7);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.panel-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

.panel-title {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 780;
}

.panel-caption {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.mini-frontier {
  min-height: 330px;
  padding: 16px;
}

.metric-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1px;
  background: var(--line);
  border-top: 1px solid var(--line);
}

.metric-tile {
  min-width: 0;
  padding: 18px;
  background: var(--paper-2);
}

.metric-tile strong {
  display: block;
  color: var(--ink);
  font-family: var(--mono);
  font-size: 1.52rem;
  line-height: 1.1;
}

.metric-tile span {
  display: block;
  margin-top: 7px;
  color: var(--muted);
  font-size: 0.88rem;
}

.main-shell {
  width: min(1180px, calc(100% - 56px));
  margin: 0 auto;
}

.section {
  padding: 72px 0;
  border-bottom: 1px solid var(--line);
}

.section-header {
  display: grid;
  grid-template-columns: minmax(0, 0.8fr) minmax(280px, 0.42fr);
  gap: 34px;
  margin-bottom: 24px;
  align-items: end;
}

.section h2 {
  margin: 0;
  font-size: 2.1rem;
  line-height: 1.08;
  letter-spacing: 0;
}

.section-kicker {
  margin: 0 0 12px;
  color: var(--teal-deep);
  font-size: 0.84rem;
  font-weight: 800;
  text-transform: uppercase;
}

.section-copy {
  margin: 14px 0 0;
  color: #35413f;
  font-size: 1rem;
}

.note {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.control-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 18px;
}

.segmented {
  display: inline-flex;
  align-items: center;
  padding: 3px;
  background: #eef4f2;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.segmented button {
  min-width: 92px;
  min-height: 34px;
  padding: 6px 10px;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-radius: 6px;
  font-size: 0.88rem;
  font-weight: 750;
  cursor: pointer;
}

.segmented button[aria-pressed="true"] {
  color: #ffffff;
  background: var(--teal-deep);
  box-shadow: 0 8px 22px rgba(7, 83, 77, 0.18);
}

.chart-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(320px, 0.85fr);
  gap: 18px;
}

.chart-grid.spaced-top {
  margin-top: 18px;
}

.chart-grid.three {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(260px, 0.62fr);
}

.chart-tool,
.inspector,
.table-wrap {
  min-width: 0;
  background: rgba(255, 255, 255, 0.86);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.chart-tool {
  padding: 14px;
}

.chart-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.chart-title h3,
.inspector h3 {
  margin: 0;
  font-size: 0.98rem;
  letter-spacing: 0;
}

.chart-title span {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.78rem;
}

.chart {
  width: 100%;
  min-height: 320px;
  overflow: hidden;
}

.chart svg {
  display: block;
  max-width: 100%;
  overflow: hidden;
}

.heatmap {
  display: grid;
  grid-template-columns: 52px repeat(4, minmax(72px, 1fr));
  grid-auto-rows: 72px;
  gap: 6px;
  align-items: stretch;
}

.heat-axis,
.heat-label {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.8rem;
  font-weight: 720;
}

.heat-axis.corner {
  align-items: end;
  justify-content: start;
  padding-bottom: 6px;
}

.heat-cell {
  position: relative;
  overflow: hidden;
  padding: 8px;
  color: var(--ink);
  background: var(--paper-2);
  border: 1px solid rgba(23, 32, 31, 0.08);
  border-radius: 8px;
  cursor: pointer;
  text-align: left;
}

.heat-cell:hover,
.heat-cell:focus-visible {
  outline: 3px solid rgba(13, 127, 117, 0.24);
}

.heat-cell.selected {
  border-color: var(--teal-deep);
  box-shadow: inset 0 0 0 2px rgba(7, 83, 77, 0.35);
}

.heat-main {
  display: block;
  font-family: var(--mono);
  font-size: 1rem;
  font-weight: 800;
}

.heat-sub {
  display: block;
  margin-top: 4px;
  color: rgba(23, 32, 31, 0.72);
  font-family: var(--mono);
  font-size: 0.72rem;
}

.inspector {
  padding: 18px;
}

.inspector h3 {
  margin-bottom: 12px;
}

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

.stat {
  min-width: 0;
  padding: 12px;
  background: var(--paper-2);
  border: 1px solid var(--soft);
  border-radius: 8px;
}

.stat span {
  display: block;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 760;
  text-transform: uppercase;
}

.stat strong {
  display: block;
  margin-top: 4px;
  font-family: var(--mono);
  font-size: 1.1rem;
}

.callout {
  padding: 16px;
  background: var(--teal-soft);
  border: 1px solid rgba(13, 127, 117, 0.22);
  border-radius: 8px;
}

.callout.amber {
  background: var(--amber-soft);
  border-color: rgba(184, 107, 22, 0.28);
}

.callout.spaced-top {
  margin-top: 14px;
}

.callout h3 {
  margin: 0 0 8px;
  font-size: 1rem;
}

.callout p,
.figure-card p {
  margin: 0;
  color: #35413f;
}

.table-wrap {
  overflow-x: auto;
  max-width: 100%;
  contain: layout paint;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

th,
td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--line);
  text-align: right;
  white-space: nowrap;
}

th:first-child,
td:first-child {
  text-align: left;
}

th {
  color: var(--muted);
  background: #f2f6f4;
  font-size: 0.76rem;
  font-weight: 800;
  text-transform: uppercase;
}

td {
  font-family: var(--mono);
}

td.label-cell {
  font-family: var(--sans);
  font-weight: 760;
}

.figure-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.figure-card {
  overflow: hidden;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.figure-card img {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 10;
  object-fit: contain;
  background: #ffffff;
  border-bottom: 1px solid var(--line);
}

.figure-card div {
  padding: 12px;
}

.figure-card h3 {
  margin: 0 0 6px;
  font-size: 0.95rem;
}

.source-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 18px;
  margin: 18px 0 0;
  padding: 0;
  list-style: none;
}

.source-list li {
  padding: 8px 0;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
  font-family: var(--mono);
  font-size: 0.86rem;
}

.footer {
  width: min(1180px, calc(100% - 56px));
  margin: 0 auto;
  padding: 32px 0 54px;
  color: var(--muted);
  font-size: 0.9rem;
}

.tooltip {
  position: fixed;
  z-index: 40;
  max-width: 260px;
  pointer-events: none;
  padding: 10px 12px;
  color: #ffffff;
  background: rgba(23, 32, 31, 0.95);
  border-radius: 8px;
  box-shadow: 0 14px 36px rgba(23, 32, 31, 0.22);
  font-size: 0.82rem;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 120ms ease, transform 120ms ease;
}

.tooltip.visible {
  opacity: 1;
  transform: translateY(0);
}

.axis text,
.chart-label {
  fill: var(--muted);
  font-family: var(--mono);
  font-size: 11px;
}

.axis line,
.axis path,
.grid-line {
  stroke: #d9e2de;
}

.series-line {
  fill: none;
  stroke-width: 3;
}

.point {
  cursor: pointer;
}

.loading,
.error {
  padding: 20px;
  color: var(--muted);
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
}

@media (max-width: 1040px) {
  .hero,
  .section-header,
  .chart-grid,
  .chart-grid.three {
    grid-template-columns: 1fr;
  }

  .hero {
    margin-top: 58px;
  }

  .metric-strip,
  .figure-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 720px) {
  .site-header {
    min-height: auto;
    padding: 14px 16px 28px;
  }

  .topbar {
    position: static;
    align-items: flex-start;
    flex-direction: column;
  }

  .nav-links {
    width: 100%;
    flex-wrap: wrap;
    overflow: visible;
    gap: 6px;
    padding-bottom: 0;
  }

  .nav-links a {
    flex: 1 1 calc(33.333% - 8px);
    padding: 8px 6px;
    text-align: center;
  }

  .hero {
    gap: 26px;
    margin-top: 42px;
  }

  .hero h1 {
    font-size: 2.65rem;
  }

  .lede {
    font-size: 1.02rem;
  }

  .main-shell,
  .footer {
    width: calc(100% - 32px);
  }

  .section {
    padding: 48px 0;
  }

  .section h2 {
    font-size: 1.7rem;
  }

  .metric-strip,
  .figure-grid,
  .source-list,
  .inspector-grid {
    grid-template-columns: 1fr;
  }

  .heatmap {
    grid-template-columns: 42px repeat(4, minmax(58px, 1fr));
    grid-auto-rows: 68px;
    gap: 4px;
  }

  .heat-cell {
    padding: 7px;
  }

  .heat-main {
    font-size: 0.86rem;
  }

  .heat-sub {
    font-size: 0.66rem;
  }
}
