:root {
  color-scheme: dark;
  --bg: #07101d;
  --bg-soft: #0b1728;
  --panel: rgba(15, 31, 51, 0.78);
  --panel-solid: #0f1f33;
  --line: rgba(163, 187, 218, 0.16);
  --line-strong: rgba(163, 187, 218, 0.28);
  --text: #edf6ff;
  --muted: #9fb2c8;
  --cyan: #5eead4;
  --cyan-strong: #2dd4bf;
  --amber: #fbbf24;
  --red: #fb7185;
  --blue: #60a5fa;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.28);
  --radius: 20px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background:
    radial-gradient(circle at 8% 4%, rgba(45, 212, 191, 0.11), transparent 31rem),
    radial-gradient(circle at 92% 14%, rgba(96, 165, 250, 0.10), transparent 32rem),
    var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.6;
}

a { color: var(--cyan); text-underline-offset: 0.2em; }
a:hover { color: #99f6e4; }
a:focus-visible, summary:focus-visible, .table-scroll:focus-visible {
  outline: 3px solid var(--amber);
  outline-offset: 4px;
}
code, .big-number, .speedup, td, .hero-facts dt {
  font-family: "Cascadia Code", "SFMono-Regular", Consolas, monospace;
  font-variant-numeric: tabular-nums;
}
code { color: #c9fff4; font-size: 0.92em; }

.skip-link {
  position: fixed;
  z-index: 100;
  top: 1rem;
  left: 1rem;
  padding: 0.7rem 1rem;
  transform: translateY(-200%);
  background: var(--text);
  color: var(--bg);
  border-radius: 10px;
}
.skip-link:focus { transform: translateY(0); }
.shell { width: min(1400px, calc(100% - 40px)); margin-inline: auto; }

.hero { padding: clamp(4.5rem, 10vw, 8rem) 0 clamp(3.5rem, 7vw, 6rem); border-bottom: 1px solid var(--line); }
.hero-grid { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(310px, 0.85fr); gap: clamp(2rem, 8vw, 8rem); align-items: end; }
.eyebrow {
  margin: 0 0 0.75rem;
  color: var(--cyan);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
h1, h2, h3 { margin-top: 0; line-height: 1.08; letter-spacing: -0.035em; }
h1 { margin-bottom: 1.5rem; max-width: 900px; font-size: clamp(3.2rem, 8vw, 7.2rem); }
h1 span { color: var(--cyan); }
h2 { margin-bottom: 0; font-size: clamp(2.1rem, 4.3vw, 4.2rem); }
h3 { font-size: 1.3rem; }
.lede { max-width: 760px; margin: 0; color: #c4d4e6; font-size: clamp(1.05rem, 2vw, 1.35rem); }
.hero-actions { display: flex; flex-wrap: wrap; gap: 0.75rem; margin-top: 2rem; }
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 0.75rem 1.15rem;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  color: var(--text);
  font-weight: 750;
  text-decoration: none;
}
.button.primary { border-color: var(--cyan-strong); background: var(--cyan); color: #05201d; }
.button:hover { border-color: var(--cyan); background: rgba(94, 234, 212, 0.08); color: var(--text); }
.button.primary:hover { background: #99f6e4; color: #05201d; }
.hero-facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); margin: 0; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: rgba(7, 16, 29, 0.5); box-shadow: var(--shadow); }
.hero-facts div { min-height: 145px; padding: 1.35rem; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.hero-facts div:nth-child(2n) { border-right: 0; }
.hero-facts div:nth-last-child(-n + 2) { border-bottom: 0; }
.hero-facts dt { color: var(--text); font-size: clamp(1.9rem, 4vw, 3.2rem); font-weight: 800; line-height: 1; }
.hero-facts dd { margin: 0.55rem 0 0; color: var(--muted); }

.page-nav { position: sticky; z-index: 20; top: 0; border-bottom: 1px solid var(--line); background: rgba(7, 16, 29, 0.88); backdrop-filter: blur(16px); }
.nav-inner { display: flex; gap: 1.4rem; overflow-x: auto; scrollbar-width: thin; }
.nav-inner a { flex: 0 0 auto; padding: 0.9rem 0; color: #c4d4e6; font-size: 0.88rem; font-weight: 750; text-decoration: none; }
.nav-inner a:hover { color: var(--cyan); }

.section { padding-block: clamp(4.5rem, 8vw, 8rem); scroll-margin-top: 58px; }
.section + .section { border-top: 1px solid var(--line); }
.section-heading, .subsection-heading { display: flex; justify-content: space-between; gap: 2rem; align-items: end; margin-bottom: 2.5rem; }
.section-heading > p, .subsection-heading > p { max-width: 570px; margin: 0; color: var(--muted); }
.subsection-heading { margin-top: 4.5rem; }
.subsection-heading h3 { margin-bottom: 0; font-size: clamp(1.7rem, 3vw, 2.6rem); }

.choice-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; }
.choice-card, .info-card, .speedup-grid article, .formula-grid article {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(145deg, rgba(17, 36, 59, 0.88), rgba(10, 23, 39, 0.88));
  box-shadow: var(--shadow);
}
.choice-card { padding: clamp(1.35rem, 3vw, 2rem); }
.choice-card.winner { border-color: rgba(251, 191, 36, 0.42); }
.choice-card.recommended { border-color: rgba(94, 234, 212, 0.45); }
.choice-top { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: 2.4rem; }
.rank { color: var(--muted); font: 800 1.05rem/1 "Cascadia Code", monospace; }
.tag, .contract { display: inline-flex; align-items: center; min-height: 26px; padding: 0.2rem 0.55rem; border-radius: 999px; font-size: 0.72rem; font-weight: 800; letter-spacing: 0.035em; white-space: nowrap; }
.tag.green, .contract.full { background: rgba(45, 212, 191, 0.12); color: #99f6e4; border: 1px solid rgba(45, 212, 191, 0.28); }
.tag.amber, .contract.core { background: rgba(251, 191, 36, 0.11); color: #fde68a; border: 1px solid rgba(251, 191, 36, 0.26); }
.tag.red { background: rgba(251, 113, 133, 0.12); color: #fecdd3; border: 1px solid rgba(251, 113, 133, 0.26); }
.tag.neutral { background: rgba(159, 178, 200, 0.12); color: #d8e4f0; border: 1px solid var(--line-strong); }
.choice-card h3 { margin-bottom: 0.8rem; font-size: 1.45rem; }
.choice-card > p:not(.big-number) { min-height: 4.8rem; color: var(--muted); }
.big-number { margin: 0; color: var(--text); font-size: clamp(2rem, 4vw, 3.2rem); font-weight: 800; letter-spacing: -0.07em; }
.big-number small { color: var(--muted); font: 650 0.82rem/1.4 ui-sans-serif, system-ui, sans-serif; letter-spacing: 0; }
.mini-stats { display: grid; grid-template-columns: repeat(3, 1fr); margin: 1.5rem 0 0; padding-top: 1rem; border-top: 1px solid var(--line); }
.mini-stats div + div { padding-left: 0.7rem; border-left: 1px solid var(--line); }
.mini-stats dt { color: var(--muted); font-size: 0.7rem; text-transform: uppercase; }
.mini-stats dd { margin: 0.25rem 0 0; font: 750 0.9rem/1 "Cascadia Code", monospace; }

.callout { display: flex; justify-content: space-between; gap: 2rem; margin-top: 1.5rem; padding: 1.35rem 1.5rem; border: 1px solid rgba(94, 234, 212, 0.3); border-radius: 16px; background: rgba(45, 212, 191, 0.06); }
.callout > div, .callout > p { margin: 0; }
.callout p { max-width: 780px; color: #c5d7e8; }
.callout-label { display: block; margin-bottom: 0.4rem; color: var(--cyan); font-size: 0.72rem; font-weight: 850; letter-spacing: 0.1em; text-transform: uppercase; }
.command-callout code { font-size: 1.05rem; }
.caution { border-color: rgba(251, 191, 36, 0.32); background: rgba(251, 191, 36, 0.055); }
.caution .callout-label { color: var(--amber); }

.legend { display: flex; flex-wrap: wrap; gap: 0.8rem 1.4rem; margin-bottom: 0.9rem; color: var(--muted); font-size: 0.83rem; }
.legend span { display: inline-flex; align-items: center; }
.dot { width: 8px; height: 8px; margin-right: 0.45rem; border-radius: 50%; }
.green-dot { background: var(--cyan-strong); box-shadow: 0 0 12px rgba(45, 212, 191, 0.5); }
.amber-dot { background: var(--amber); box-shadow: 0 0 12px rgba(251, 191, 36, 0.4); }
.scroll-hint { margin: 0 0 0.7rem; color: var(--muted); font-size: 0.78rem; }
.table-scroll { overflow-x: auto; border: 1px solid var(--line); border-radius: 16px; background: rgba(7, 16, 29, 0.6); box-shadow: var(--shadow); scrollbar-color: var(--line-strong) transparent; }
table { width: 100%; min-width: 1850px; border-collapse: separate; border-spacing: 0; font-size: 0.83rem; }
caption { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
thead th { position: sticky; z-index: 2; top: 0; padding: 0.85rem 0.75rem; border-bottom: 1px solid var(--line-strong); background: #101f32; color: #b8cadc; font-size: 0.68rem; letter-spacing: 0.07em; text-align: right; text-transform: uppercase; white-space: nowrap; }
thead th:nth-child(-n + 5), thead th:last-child { text-align: left; }
tbody td, tbody th { padding: 0.78rem 0.75rem; border-bottom: 1px solid var(--line); text-align: right; white-space: nowrap; }
tbody th { color: var(--text); text-align: left; font-size: 0.86rem; }
tbody td:nth-child(3), tbody td:nth-child(4), tbody td:nth-child(5), tbody td:last-child { text-align: left; font-family: inherit; }
tbody td:nth-child(3) { color: var(--muted); }
tbody tr:last-child td, tbody tr:last-child th { border-bottom: 0; }
tbody tr:hover { background: rgba(96, 165, 250, 0.055); }
.mean-column { background: rgba(94, 234, 212, 0.045); }
thead .mean-column { color: var(--cyan); background: #122b39; }
.compact-table table { min-width: 1260px; }

.speedup-grid, .formula-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; }
.speedup-grid article, .formula-grid article { padding: 1.7rem; }
.speedup { display: block; margin-bottom: 1.8rem; color: var(--cyan); font-size: clamp(2.4rem, 5vw, 4rem); font-weight: 850; letter-spacing: -0.08em; }
.speedup-grid h3, .formula-grid h3 { margin-bottom: 0.55rem; }
.speedup-grid p, .formula-grid p { margin: 0; color: var(--muted); }

.correctness-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; }
.info-card { padding: 1.7rem; }
.info-card .step { display: inline-block; margin-bottom: 2.2rem; color: var(--cyan); font: 800 0.8rem/1 "Cascadia Code", monospace; }
.info-card > p { color: #c4d4e6; }
.muted { color: var(--muted) !important; }
.check-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.35rem 1rem; margin: 1.3rem 0 0; padding: 0; list-style: none; color: var(--muted); font-size: 0.84rem; }
.check-list li::before { content: "×"; margin-right: 0.4rem; color: var(--red); font-weight: 900; }
.pass-list { color: #99f6e4 !important; font-size: 0.87rem; }
.warning-card { border-color: rgba(251, 191, 36, 0.28); }
.warning-card .step { color: var(--amber); }

.method-steps { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0; margin: 0; padding: 0; border: 1px solid var(--line); border-radius: var(--radius); list-style: none; overflow: hidden; background: rgba(10, 23, 39, 0.62); box-shadow: var(--shadow); }
.method-steps li { min-width: 0; padding: 1.6rem; border-right: 1px solid var(--line); }
.method-steps li:last-child { border-right: 0; }
.method-steps li > span { display: block; margin-bottom: 3rem; color: var(--cyan); font: 800 0.8rem/1 "Cascadia Code", monospace; }
.method-steps h3 { margin-bottom: 0.6rem; }
.method-steps p { margin: 0; color: var(--muted); font-size: 0.9rem; }
.method-steps .hash { margin-top: 1rem; font-size: 0.73rem; overflow-wrap: anywhere; }
.method-steps .hash code { font-size: 0.72rem; }
.formula-grid { margin-top: 1rem; }
.formula-grid article { box-shadow: none; }
.method-notes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; margin-top: 2rem; }
.method-notes .callout { display: block; margin: 0; }
details { margin-top: 1rem; border: 1px solid var(--line); border-radius: 14px; background: rgba(10, 23, 39, 0.55); }
summary { padding: 1rem 1.2rem; cursor: pointer; color: var(--text); font-weight: 750; }
.details-body { padding: 0 1.2rem 1.2rem; color: var(--muted); }
.details-body li + li { margin-top: 0.45rem; }

.artifact-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0.8rem; }
.artifact-grid a { display: flex; min-height: 150px; padding: 1.2rem; flex-direction: column; border: 1px solid var(--line); border-radius: 14px; background: rgba(15, 31, 51, 0.65); color: var(--text); text-decoration: none; }
.artifact-grid a:hover { border-color: var(--cyan-strong); background: rgba(45, 212, 191, 0.06); }
.artifact-grid span { margin-bottom: auto; color: var(--cyan); font-size: 0.72rem; font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase; }
.artifact-grid strong { margin-top: 1.5rem; }
.artifact-grid small { margin-top: 0.25rem; color: var(--muted); }

footer { border-top: 1px solid var(--line); background: #050b14; }
.footer-inner { display: flex; justify-content: space-between; align-items: center; gap: 2rem; padding-block: 2.5rem; color: var(--muted); font-size: 0.85rem; }
.footer-inner p { margin: 0; }

@media (max-width: 1000px) {
  .hero-grid, .choice-grid, .correctness-grid { grid-template-columns: 1fr; }
  .hero-grid { gap: 3rem; }
  .choice-card > p:not(.big-number) { min-height: 0; }
  .speedup-grid, .formula-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .method-steps { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .method-steps li:nth-child(2) { border-right: 0; }
  .method-steps li:nth-child(-n + 2) { border-bottom: 1px solid var(--line); }
  .artifact-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 680px) {
  .shell { width: min(100% - 24px, 1400px); }
  .hero { padding-top: 4rem; }
  .hero-facts { grid-template-columns: 1fr; }
  .hero-facts div { min-height: 110px; border-right: 0; }
  .hero-facts div:nth-last-child(2) { border-bottom: 1px solid var(--line); }
  .section-heading, .subsection-heading, .callout, .footer-inner { align-items: flex-start; flex-direction: column; }
  .section-heading { margin-bottom: 2rem; }
  .speedup-grid, .formula-grid, .method-notes, .artifact-grid { grid-template-columns: 1fr; }
  .method-steps { grid-template-columns: 1fr; }
  .method-steps li { border-right: 0; border-bottom: 1px solid var(--line); }
  .method-steps li:nth-child(3) { border-bottom: 1px solid var(--line); }
  .method-steps li:last-child { border-bottom: 0; }
  .method-steps li > span { margin-bottom: 1.8rem; }
  .check-list { grid-template-columns: 1fr; }
  .artifact-grid a { min-height: 130px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}
