:root {
  color-scheme: light dark;
  --bg: var(--color-surface);
  --surface: var(--color-surface-container-lowest);
  --surface-2: var(--color-surface-container-low);
  --surface-3: var(--color-surface-container);
  --line: var(--color-outline-variant);
  --line-strong: light-dark(rgba(101, 104, 120, 0.38), rgba(196, 197, 215, 0.28));
  --text: var(--color-on-surface);
  --text-2: var(--color-on-surface-variant);
  --text-3: var(--color-outline);
  --accent: var(--color-primary);
  --accent-2: light-dark(#003cb2, #a5c8ff);
  --nightly: light-dark(#5a6072, #9aa3b5);
  --teal: light-dark(#0d7468, #5fd0c0);
  --good-2: var(--color-accent-success);
  --bad: var(--color-accent-failure);
  --warm: var(--color-accent-warning);
  --old: light-dark(#cfd4e0, #434c5c);
  --radius: 8px;
  --sans: var(--font-sans, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif);
  --mono: var(--font-mono, ui-monospace, SFMono-Regular, Menlo, Consolas, monospace);
}

@supports not (color: light-dark(#000, #fff)) {
  :root {
    --line-strong: rgba(101, 104, 120, 0.38);
    --accent-2: #003cb2;
    --nightly: #5a6072;
    --teal: #0d7468;
    --old: #cfd4e0;
  }
  @media (prefers-color-scheme: dark) {
    :root {
      --line-strong: rgba(196, 197, 215, 0.28);
      --accent-2: #a5c8ff;
      --nightly: #9aa3b5;
      --teal: #5fd0c0;
      --old: #434c5c;
    }
  }
}

*, *::before, *::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

@media (prefers-reduced-motion: no-preference) {
  html {
    scroll-behavior: smooth;
  }
}

h1, h2, h3, p, figure, dl, dd {
  margin: 0;
}

code {
  font-family: var(--mono);
  font-size: 0.86em;
  padding: 0.08em 0.36em;
  border-radius: 4px;
  background: var(--surface-2);
  color: var(--text);
}

.vh {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.page {
  padding: 4px 0 48px;
  display: grid;
  gap: 18px;
}

.masthead {
  display: flex;
  flex-direction: column;
  gap: var(--space-2, 8px);
}

.masthead a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-color: color-mix(in srgb, var(--accent) 45%, transparent);
  text-underline-offset: 2px;
}

.masthead a:hover {
  text-decoration-color: currentColor;
}

.cadence-note {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
  margin-top: 4px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
  font-size: 0.8125rem;
  line-height: 1.45;
  color: var(--text-2);
}

.cadence-badge {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--text);
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  white-space: nowrap;
}

.from {
  color: var(--text-3);
  font-weight: 500;
}

.arrow {
  margin: 0 0.2em;
  color: var(--text-3);
  font-weight: 400;
}

.unit {
  margin-left: 0.25em;
  font-size: 0.62em;
  font-weight: 500;
  color: var(--text-2);
  letter-spacing: 0;
}

.good {
  color: var(--accent);
}

.bad {
  color: var(--bad);
}

.warn {
  color: var(--warm);
}

/* Cards */
.card {
  position: relative;
  min-width: 0;
  padding: 22px 24px 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  scroll-margin-top: 24px;
}

.card-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px 24px;
  margin-bottom: 16px;
}

.card h2 {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--sans);
  font-size: 1.1875rem;
  font-weight: 700;
  letter-spacing: -0.018em;
  line-height: 1.25;
  color: var(--text);
}

.hero-card h2 {
  font-size: 1.375rem;
  letter-spacing: -0.02em;
}

.sub {
  margin-top: 4px;
  font-size: 0.8125rem;
  color: var(--text-2);
}

.takeaway {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  font-size: 0.875rem;
  color: var(--text-2);
}

.takeaway strong {
  color: var(--text);
  font-weight: 600;
}

.panel-title {
  margin-bottom: 8px;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-2);
}

/* Segmented control */
.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.seg {
  display: inline-flex;
  gap: 2px;
  margin: 0;
  padding: 2px;
  min-inline-size: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
}

.seg-wrap {
  flex-wrap: wrap;
}

.seg label {
  position: relative;
  display: block;
}

.seg input {
  position: absolute;
  inset: 0;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.seg span {
  display: block;
  padding: 4px 11px;
  border-radius: 6px;
  border: 1px solid transparent;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-2);
  transition: color 0.15s, background-color 0.15s, border-color 0.15s;
}

.seg label:hover span {
  color: var(--text);
}

.seg input:checked + span {
  color: var(--text);
  font-weight: 600;
  background: color-mix(in srgb, var(--accent) 14%, var(--surface));
  border-color: color-mix(in srgb, var(--accent) 45%, var(--line));
}

.seg input:focus-visible + span {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

/* SVG charts */
.chart {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
}

.chart text {
  font-family: var(--sans);
  font-size: 12px;
  fill: var(--text-2);
}

.chart .mono {
  font-family: var(--mono);
  font-size: 11.5px;
}

.chart .axis {
  font-size: 11px;
  fill: var(--text-3);
  font-variant-numeric: tabular-nums;
}

.chart .axis-title {
  font-size: 11.5px;
  fill: var(--text-3);
}

.chart .strong {
  fill: var(--text);
  font-weight: 600;
}

.chart .halo {
  paint-order: stroke;
  stroke: var(--surface);
  stroke-width: 5px;
  stroke-linejoin: round;
}

.chart .grid {
  stroke: var(--line);
}

.chart .baseline {
  stroke: var(--line-strong);
}

.chart .hit {
  fill: transparent;
}

/* Section 1 (A) */
.a-phase {
  fill: color-mix(in srgb, var(--accent) 6%, transparent);
}

.a-phase-rule {
  stroke: var(--line-strong);
}

.chart .a-phase-label {
  font-size: 11px;
  fill: var(--text-3);
  letter-spacing: 0.04em;
}

.a-ci {
  fill: none;
  stroke: var(--accent);
  stroke-opacity: 0.38;
  stroke-width: 1.5;
}

.a-cf-line {
  fill: none;
  stroke: var(--accent);
  stroke-width: 1.5;
  stroke-dasharray: 3 3;
  stroke-opacity: 0.65;
}

.a-gate-drop {
  stroke: var(--bad);
  stroke-width: 1.5;
}

.chart .a-cf-label {
  font-size: 11.5px;
  fill: var(--text-2);
  font-variant-numeric: tabular-nums;
}

.chart .a-row-label {
  font-size: 11px;
  font-weight: 600;
}

.chart .a-row {
  font-size: 12px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  fill: var(--text);
}

.chart .a-row.is-bad {
  fill: var(--bad);
}

.chart .a-row.is-current {
  fill: var(--accent-2);
}

.chart .a-row.is-research,
.chart .a-row.is-ceiling {
  fill: var(--text-2);
  font-weight: 500;
}

.chart .is-accent {
  fill: var(--accent);
}

.a-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 6px 24px;
  margin: -4px 0 6px;
}

.a-note {
  font-size: 0.78125rem;
  color: var(--text-2);
}

.a-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 18px;
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: 0.75rem;
  color: var(--text-2);
}

.a-legend li {
  display: flex;
  align-items: center;
  gap: 8px;
}

.a-legend li::before {
  content: "";
  width: 18px;
  border-top: 3px solid var(--accent);
}

.a-legend small {
  color: var(--text-3);
  font-size: 0.71875rem;
}

.a-area {
  fill: url(#a-fill);
}

.a-fill-0 {
  stop-color: var(--accent);
  stop-opacity: 0.16;
}

.a-fill-1 {
  stop-color: var(--accent);
  stop-opacity: 0;
}

.a-line {
  fill: none;
  stroke: var(--accent);
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.a-line-research {
  fill: none;
  stroke: var(--accent);
  stroke-width: 2;
  stroke-dasharray: 5 5;
  stroke-opacity: 0.65;
}

.a-pt .dot {
  fill: var(--accent);
  stroke: var(--surface);
  stroke-width: 2.5;
  transform-box: fill-box;
  transform-origin: center;
  transition: transform 0.15s;
}

.a-pt:hover .dot {
  transform: scale(1.3);
}

.a-pt.is-bad .dot {
  fill: var(--bad);
}

.a-pt.is-research .dot,
.a-pt.is-cf .dot {
  fill: var(--surface);
  stroke: var(--accent);
  stroke-width: 2;
  stroke-dasharray: 3 2;
}

.a-pt.is-ceiling .dot {
  fill: var(--surface);
  stroke: var(--text-2);
  stroke-width: 2;
}

.a-ring {
  fill: var(--accent);
  fill-opacity: 0.16;
}

.chart .a-delta {
  font-size: 11px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.chart .a-delta.is-good {
  fill: var(--accent);
}

.chart .a-delta.is-bad {
  fill: var(--bad);
}

.chart .a-delta.is-muted {
  fill: var(--text-3);
}

.chart .a-x {
  font-size: 11px;
  letter-spacing: -0.02em;
  fill: var(--text);
}

.chart .a-x.is-bad {
  fill: var(--bad);
}

.chart .a-x.is-current {
  fill: var(--accent-2);
}

.chart .a-x.is-research,
.chart .a-x.is-ceiling {
  fill: var(--text-2);
}

.chart .a-x-sub {
  font-size: 11.5px;
  fill: var(--text-3);
}

.chart.is-static .a-reveal,
.chart.is-static .a-line {
  animation: none;
  stroke-dashoffset: 0;
}

.sparks {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 14px;
}

.spark {
  display: grid;
  gap: 2px;
  padding: 10px 12px 6px;
  text-align: left;
  font: inherit;
  color: inherit;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color 0.15s, background-color 0.15s;
}

.spark:hover {
  border-color: var(--line-strong);
}

.spark[aria-pressed="true"] {
  border-color: color-mix(in srgb, var(--accent) 55%, var(--line));
  background: color-mix(in srgb, var(--accent) 8%, var(--surface));
}

.spark:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.spark-name {
  font-size: 0.78125rem;
  font-weight: 600;
}

.spark-name small {
  margin-left: 4px;
  font-weight: 400;
  color: var(--text-3);
}

.spark-svg {
  display: block;
  width: 100%;
  height: auto;
  margin-top: 4px;
  overflow: visible;
}

.spark-line {
  fill: none;
  stroke: var(--accent);
  stroke-width: 2;
  stroke-linejoin: round;
}

.spark-line.is-research {
  stroke-dasharray: 3 3;
  stroke-opacity: 0.65;
}

.spark-dot {
  fill: var(--accent);
}

.spark-dot.is-bad {
  fill: var(--bad);
}

.spark-dot.is-research,
.spark-dot.is-cf {
  fill: var(--surface-2);
  stroke: var(--accent);
  stroke-width: 1.5;
}

.spark-dot.is-ceiling {
  fill: var(--surface-2);
  stroke: var(--text-2);
  stroke-width: 1.5;
}

/* Metric guide */
.num {
  margin-right: 2px;
  font: 600 0.75rem/1 var(--mono);
  color: var(--text-3);
  letter-spacing: 0.02em;
}

.metric-guide {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.metric-guide h3 {
  margin-bottom: 10px;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-2);
}

.mg-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
  margin: 0;
}

.mg-grid > div {
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
}

.mg-grid dt {
  font-size: 0.84375rem;
  font-weight: 600;
}

.mg-grid dt small {
  display: block;
  margin-top: 3px;
  font-size: 0.71875rem;
  font-weight: 500;
  color: var(--accent-2);
}

.mg-grid dd {
  margin: 8px 0 0;
  font-size: 0.75rem;
  line-height: 1.5;
  color: var(--text-2);
}

/* Section 2: Milestones table */
.table-wrap {
  overflow-x: auto;
}

.m-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.78125rem;
  line-height: 1.45;
}

.m-table th {
  padding: 0 10px 8px;
  border-bottom: 1px solid var(--line-strong);
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--text-2);
  text-align: left;
  white-space: nowrap;
}

.m-table td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
  color: var(--text-2);
}

.m-table .m-name {
  min-width: 120px;
  font: 500 0.75rem/1.45 var(--mono);
  color: var(--text);
}

.m-table .when {
  min-width: 92px;
  font-size: 0.75rem;
  color: var(--text-3);
}

.m-table .n {
  text-align: right;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.m-table td.n {
  font-weight: 600;
  color: var(--text);
}

.m-table td.same {
  font-weight: 400;
  color: var(--text-3);
  text-align: center;
}

.m-table a {
  color: var(--accent-2);
  text-decoration: none;
}

.m-table a:hover {
  text-decoration: underline;
}

.m-table tr.is-bad .m-name,
.m-table tr.is-bad td.n {
  color: var(--bad);
}

.m-table tr.is-current .m-name,
.m-table tr.is-current td.n {
  color: var(--accent-2);
}

.m-table tr:is(.is-cf, .is-research, .is-ceiling, .is-oracle) :is(.m-name, td.n) {
  color: var(--text-2);
  font-weight: 500;
}

.m-table td.n small {
  margin-left: 5px;
  font-size: 0.6875rem;
  font-weight: 500;
  color: var(--text-3);
}

/* Section 3 (A2): K horizon */
.k-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 18px;
  margin: -4px 0 8px;
  padding: 0;
  list-style: none;
  font-size: 0.75rem;
  color: var(--text-2);
}

.k-legend li {
  display: flex;
  align-items: center;
  gap: 8px;
}

.k-legend li::before {
  content: "";
  width: 18px;
  border-top: 2.5px solid var(--c);
}

.k-legend li.is-dashed::before {
  border-top-style: dashed;
}

.k-legend small {
  font-size: 0.71875rem;
  color: var(--text-3);
}

.k-line {
  fill: none;
  stroke-width: 2.25;
  stroke-linejoin: round;
}

.k-peak {
  fill: none;
  stroke-width: 1.5;
}

.k-guide {
  stroke: var(--line-strong);
  stroke-dasharray: 2 3;
}

.chart .k-guide-label {
  font-size: 11px;
  fill: var(--text-3);
}

.k-oracle {
  fill: var(--surface);
  stroke: var(--good-2);
  stroke-width: 1.5;
}

.chart .k-oracle-label {
  font-size: 11.5px;
  fill: var(--good-2);
}

/* Section 4 (B): Price vs. quality */
.b-layout {
  display: grid;
  grid-template-columns: minmax(0, 2.1fr) minmax(210px, 1fr);
  gap: 24px;
  align-items: center;
}

.chart .b-better {
  font-size: 11px;
  fill: var(--text-3);
}

.b-path {
  fill: none;
  stroke: var(--text-3);
  stroke-width: 1.5;
  stroke-opacity: 0.75;
}

.b-arrowhead {
  fill: var(--text-3);
}

.bubble {
  fill: light-dark(#64748b, #5d6c86);
  fill-opacity: 0.3;
  stroke: light-dark(#475569, #7d8ba3);
  stroke-width: 1.5;
  transition: r 0.45s cubic-bezier(0.3, 0.7, 0.2, 1);
}

.b-pt.is-bad .bubble {
  fill: var(--bad);
  stroke: var(--bad);
  fill-opacity: 0.24;
}

.b-pt.is-current .bubble {
  fill: var(--accent);
  stroke: var(--accent);
  fill-opacity: 0.32;
}

.b-core {
  fill: var(--text);
}

.b-research {
  fill: var(--surface);
  stroke: var(--accent);
  stroke-width: 1.5;
  stroke-dasharray: 3 2;
}

.b-research.is-ceiling {
  stroke: var(--text-2);
  stroke-dasharray: none;
}

.b-band {
  stroke: var(--old);
  stroke-width: 10;
  stroke-linecap: round;
}

.b-history {
  fill: light-dark(#475569, #7d8ba3);
}

.chart .b-label {
  fill: var(--text);
}

.chart .b-sub {
  font-size: 11px;
  fill: var(--text-3);
  font-variant-numeric: tabular-nums;
}

.chart .b-anno {
  font-size: 12.5px;
  font-weight: 600;
  fill: var(--accent);
}

.chart .b-anno-sub {
  font-size: 11px;
  fill: var(--text-3);
}

.b-panel {
  display: grid;
  gap: 14px;
  padding: 18px 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
}

.b-stat + .b-stat {
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.b-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.b-name {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-2);
}

.b-name small {
  margin-left: 4px;
  font-size: 0.6875rem;
  font-weight: 400;
  color: var(--text-3);
}

.b-value {
  margin-top: 4px;
  font-size: 1.625rem;
  font-weight: 700;
  letter-spacing: -0.025em;
  line-height: 1.15;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.b-value small {
  margin-left: 0.3em;
  font-size: 0.52em;
  font-weight: 500;
  color: var(--text-2);
  letter-spacing: 0;
}

.b-change {
  font-size: 0.78125rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.b-panel-note {
  padding-top: 12px;
  border-top: 1px solid var(--line);
  font-size: 0.75rem;
  line-height: 1.45;
  color: var(--text-3);
}

/* Section 5: Methodology */
.notes-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr);
  gap: 36px;
  margin-top: 12px;
}

.methodology h3 {
  margin-bottom: 6px;
  font-size: 0.8125rem;
  font-weight: 600;
}

.methodology :is(p, dd) {
  font-size: 0.78125rem;
  line-height: 1.55;
  color: var(--text-2);
}

.methodology dl {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: 5px 14px;
  margin-top: 10px;
}

.methodology dt {
  font: 600 0.71875rem/1.65 var(--mono);
  color: var(--text);
}

.methodology a {
  color: var(--accent-2);
  text-decoration: none;
}

.methodology a:hover {
  text-decoration: underline;
}

/* Tooltip */
.tip {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 30;
  max-width: 280px;
  padding: 10px 12px 11px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 8px 24px var(--color-shadow);
  font-size: 0.78125rem;
  line-height: 1.45;
  color: var(--text-2);
  pointer-events: none;
}

.tip-title {
  font-weight: 600;
  color: var(--text);
}

.tip-note {
  margin-top: 6px;
}

.tip-meta {
  margin-top: 6px;
  font-size: 0.71875rem;
  color: var(--text-3);
}

.tip-grid {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 2px 14px;
  margin-top: 8px;
  font-variant-numeric: tabular-nums;
}

.tip-grid b {
  color: var(--text);
  font-weight: 500;
  text-align: right;
}

.tip-grid b small {
  margin-left: 6px;
  font-size: 0.6875rem;
  font-weight: 400;
  color: var(--text-3);
}

.tip hr {
  margin: 8px 0;
  border: 0;
  border-top: 1px solid var(--line);
}

@keyframes fade-in {
  from {
    opacity: 0;
  }
}

@media (prefers-reduced-motion: no-preference) {
  .a-line {
    stroke-dasharray: var(--len);
    stroke-dashoffset: var(--len);
    animation: draw 1.1s cubic-bezier(0.35, 0.6, 0.2, 1) 0.1s forwards;
  }
  .a-reveal {
    animation: fade-in 0.4s ease both;
    animation-delay: calc(var(--i) * 170ms + 120ms);
  }
  @keyframes draw {
    to {
      stroke-dashoffset: 0;
    }
  }
}

@media (max-width: 860px) {
  .b-layout,
  .notes-grid,
  .sparks,
  .mg-grid {
    grid-template-columns: minmax(0, 1fr);
  }
  .card {
    padding: 20px 18px;
  }
  .page {
    padding: 4px 0 36px;
  }
}

@media (max-width: 560px) {
  .methodology dl {
    grid-template-columns: minmax(0, 1fr);
    gap: 2px;
  }
  .methodology dd + dt {
    margin-top: 6px;
  }
}

