:root {
  --bg: #f4f2ec;
  --surface: #ffffff;
  --surface-2: #ecebe4;
  --text: #121212;
  --muted: #5e5d58;
  --line: #d8d6cc;
  --accent: #0b8f5d;
  --accent-2: #7b3fe4;
  --bad: #c2362f;
  --good: #0b8f5d;
  --supply: #c2362f;
  --demand: #0b8f5d;
  --radius: 10px;
  --sans: "Space Grotesk", system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, monospace;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b0c0e;
    --surface: #131519;
    --surface-2: #1b1e23;
    --text: #ecebe6;
    --muted: #8d8f95;
    --line: #262a31;
    --accent: #14f195;
    --accent-2: #9945ff;
    --bad: #ff5a4f;
    --good: #14f195;
    --supply: #ff5a4f;
    --demand: #14f195;
  }
}
:root[data-theme="dark"] {
  --bg: #0b0c0e;
  --surface: #131519;
  --surface-2: #1b1e23;
  --text: #ecebe6;
  --muted: #8d8f95;
  --line: #262a31;
  --accent: #14f195;
  --accent-2: #9945ff;
  --bad: #ff5a4f;
  --good: #14f195;
  --supply: #ff5a4f;
  --demand: #14f195;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
.mono { font-family: var(--mono); }
.muted { color: var(--muted); }
.accent { color: var(--accent); }
a { color: inherit; }

main, .nav, .foot { max-width: 1120px; margin: 0 auto; padding-left: 24px; padding-right: 24px; }
section { padding: 72px 0; border-top: 1px solid var(--line); }
section.hero { border-top: 0; }
h1, h2, h3 { line-height: 1.1; margin: 0 0 16px; letter-spacing: -0.02em; }
h1 { font-size: clamp(2.2rem, 6vw, 4.4rem); font-weight: 700; }
h2 { font-size: clamp(1.6rem, 3.5vw, 2.4rem); }
h3 { font-size: 1.1rem; }

/* NAV */
.nav {
  display: flex; align-items: center; gap: 24px;
  height: 64px; position: sticky; top: 0; z-index: 10;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: blur(8px);
}
.logo { display: flex; align-items: center; gap: 10px; font-weight: 700; text-decoration: none; }
.logo-mark {
  width: 22px; height: 22px; border: 2.5px solid var(--accent); border-radius: 4px; position: relative;
}
.logo-mark::after { content: ""; position: absolute; inset: -2px 6px; background: var(--accent); }
.nav nav { display: flex; gap: 20px; margin-left: auto; }
.nav nav a { text-decoration: none; color: var(--muted); font-size: 0.95rem; }
.nav nav a:hover { color: var(--text); }
.theme-toggle {
  background: none; border: 1px solid var(--line); color: var(--text);
  border-radius: 8px; width: 36px; height: 36px; cursor: pointer; font-size: 1rem;
}

/* HERO */
.hero { display: grid; grid-template-columns: 1.4fr 1fr; gap: 48px; align-items: end; padding-top: 80px; }
.hero > :not(.quote-card) { grid-column: 1; }
.eyebrow { color: var(--accent); font-size: 0.8rem; letter-spacing: 0.15em; margin: 0 0 20px; }
.lede { font-size: 1.15rem; color: var(--muted); max-width: 56ch; margin: 0 0 32px; }
.cta-row { display: flex; gap: 12px; flex-wrap: wrap; }
.quote-card {
  grid-column: 2; grid-row: 1 / span 4;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px; font-size: 0.85rem;
}
.qc-row { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px dashed var(--line); }
.qc-row em { font-style: normal; margin-left: 8px; }
.qc-row.bad em, .qc-row.bad span:last-child { color: var(--bad); }
.qc-row.good em, .qc-row.good span:last-child { color: var(--good); }
.qc-row.good { border-bottom: 0; }
.qc-note { color: var(--muted); font-size: 0.75rem; margin: 12px 0 0; }

/* BUTTONS */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 12px 20px; border-radius: 8px; font: 500 0.95rem var(--sans);
  text-decoration: none; cursor: pointer; border: 1px solid var(--line);
  background: var(--surface); color: var(--text); transition: transform .1s, border-color .15s;
}
.btn:hover { border-color: var(--accent); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #06140d; }
.btn.ghost { background: transparent; }
.btn.small { padding: 8px 14px; font-size: 0.85rem; }

/* PROBLEM */
.problem { display: grid; grid-template-columns: repeat(3, 1fr); gap: 24px; }
.stat { display: flex; flex-direction: column; gap: 8px; }
.stat-num { font-size: 1.8rem; color: var(--accent-2); }
.stat-label { color: var(--muted); }

/* HOW */
.timeline { list-style: none; padding: 0; margin: 32px 0 0; display: grid; grid-template-columns: repeat(5, 1fr); gap: 0; }
.timeline li { padding: 20px 20px 0 0; border-top: 2px solid var(--line); position: relative; }
.timeline li::before {
  content: ""; position: absolute; top: -7px; left: 0; width: 12px; height: 12px;
  border-radius: 50%; background: var(--bg); border: 2px solid var(--accent);
}
.timeline li:nth-child(4)::before { background: var(--accent); }
.timeline p { color: var(--muted); font-size: 0.95rem; margin: 0; }
.step { display: inline-block; font-size: 0.75rem; color: var(--accent); margin-bottom: 8px; letter-spacing: 0.08em; text-transform: uppercase; }

/* SIM */
.sim-head p { color: var(--muted); max-width: 60ch; }
.sim-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 32px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; min-width: 0; }
.panel.wide { grid-column: 1 / -1; }
.panel-title { display: flex; justify-content: space-between; align-items: center; gap: 12px; font-weight: 500; margin-bottom: 16px; font-size: 0.95rem; flex-wrap: wrap; }
.panel-title .mono { font-size: 0.75rem; }
.order-form { display: grid; grid-template-columns: 1fr 1fr auto; gap: 8px; margin-bottom: 12px; }
.order-form input {
  min-width: 0; padding: 9px 10px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--surface-2); color: var(--text); font: 0.85rem var(--mono);
}
.order-form input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.order-list { list-style: none; padding: 0; margin: 0; font-size: 0.82rem; max-height: 220px; overflow: auto; }
.order-list li { display: flex; justify-content: space-between; align-items: center; padding: 7px 0; border-bottom: 1px dashed var(--line); gap: 8px; }
.order-list button { background: none; border: 0; color: var(--muted); cursor: pointer; font-size: 1rem; }
.order-list button:hover { color: var(--bad); }
.order-list .empty { color: var(--muted); justify-content: center; border: 0; }

.legend { font-size: 0.75rem; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.sw { display: inline-block; width: 12px; height: 3px; margin-left: 8px; }
.sw.supply { background: var(--supply); }
.sw.demand { background: var(--demand); }
.chart { width: 100%; aspect-ratio: 16 / 6; min-height: 200px; }
.chart svg { width: 100%; height: 100%; display: block; }
.chart text { fill: var(--muted); font: 10px var(--mono); }
.result { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin: 16px 0; }
.result div { background: var(--surface-2); border-radius: 8px; padding: 12px; }
.result small { display: block; color: var(--muted); font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.08em; margin-bottom: 4px; }
.result strong { font-size: 1rem; font-weight: 600; }
.sim-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.fills { margin-top: 16px; font-size: 0.8rem; display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.fills h4 { font-family: var(--sans); margin: 0 0 8px; font-size: 0.9rem; }
.fills ul { list-style: none; margin: 0; padding: 0; }
.fills li { padding: 5px 0; border-bottom: 1px dashed var(--line); display: flex; justify-content: space-between; gap: 8px; }
.tag { font-size: 0.7rem; padding: 1px 6px; border-radius: 4px; background: var(--surface-2); }
.tag.full { color: var(--good); }
.tag.partial { color: var(--accent-2); }
.tag.none { color: var(--muted); }

/* WINDOWS */
.table-wrap { overflow-x: auto; margin-top: 24px; border: 1px solid var(--line); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; font-size: 0.85rem; min-width: 560px; }
th, td { text-align: left; padding: 14px 16px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { color: var(--muted); font-weight: 400; font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.08em; background: var(--surface); }
tbody tr:last-child td { border-bottom: 0; }
td.ticker { color: var(--accent); font-weight: 600; }
.bar { display: inline-block; height: 6px; border-radius: 3px; background: var(--accent-2); vertical-align: middle; margin-right: 8px; }

/* FAQ */
.faq details { border-bottom: 1px solid var(--line); padding: 18px 0; }
.faq summary { cursor: pointer; font-weight: 500; font-size: 1.05rem; }
.faq p { color: var(--muted); margin: 12px 0 0; max-width: 70ch; }

/* FOOT */
.foot { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; padding-top: 32px; padding-bottom: 48px; border-top: 1px solid var(--line); font-size: 0.85rem; }

/* NEXT PILL */
.next-pill {
  display: inline-flex; align-items: center; gap: 10px; margin-top: 28px;
  padding: 8px 14px; border: 1px solid var(--line); border-radius: 999px;
  font-size: 0.8rem; color: var(--muted); text-decoration: none; width: fit-content;
}
.next-pill:hover { border-color: var(--accent); color: var(--text); }
.next-pill b { color: var(--text); font-weight: 600; }
.pulse { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); position: relative; }
.pulse::after {
  content: ""; position: absolute; inset: 0; border-radius: 50%; background: var(--accent);
  animation: pulse 1.8s ease-out infinite;
}
@keyframes pulse { to { transform: scale(3); opacity: 0; } }

/* CALCULATOR */
.calc-head p { max-width: 60ch; }
.calc-grid { display: grid; grid-template-columns: 1fr 1.3fr; gap: 16px; margin-top: 32px; }
.calc-inputs { display: flex; flex-direction: column; gap: 22px; }
.calc-inputs label { display: flex; flex-direction: column; gap: 10px; font-size: 0.92rem; }
.lbl { display: flex; justify-content: space-between; gap: 12px; }
.lbl output { color: var(--accent); font-size: 0.85rem; }
input[type="range"] { width: 100%; accent-color: var(--accent); }
.hint { font-size: 0.78rem; margin: 0; }
.calc-out { display: flex; flex-direction: column; justify-content: space-between; gap: 24px; }
.bars { display: flex; flex-direction: column; gap: 18px; }
.bar-row { display: grid; grid-template-columns: 130px 1fr 110px; align-items: center; gap: 12px; font-size: 0.88rem; }
.bar-track { height: 14px; background: var(--surface-2); border-radius: 4px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 4px; transition: width .35s cubic-bezier(.2,.8,.2,1); }
.bar-fill.paper { background: var(--muted); opacity: .5; }
.bar-fill.amm { background: var(--bad); }
.bar-fill.win { background: var(--good); }
.bar-val { text-align: right; font-size: 0.82rem; }
.calc-verdict { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.calc-verdict div { background: var(--surface-2); border-radius: 8px; padding: 14px; }
.calc-verdict small { display: block; color: var(--muted); font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.08em; margin-bottom: 4px; }
.calc-verdict strong { font-size: 1.35rem; }
.bad-t { color: var(--bad); }
.good-t { color: var(--good); }

/* NAV ACTIVE */
.nav nav a.active { color: var(--accent); }

/* REVEAL */
.js .reveal { opacity: 0; transform: translateY(16px); transition: opacity .6s ease, transform .6s ease; }
.js .reveal.in { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) {
  .js .reveal { opacity: 1; transform: none; transition: none; }
  .pulse::after { animation: none; }
  html { scroll-behavior: auto; }
}

/* RESPONSIVE */
@media (max-width: 860px) {
  .hero { grid-template-columns: 1fr; }
  .quote-card { grid-column: 1; grid-row: auto; }
  .timeline { grid-template-columns: 1fr; }
  .timeline li { border-top: 0; border-left: 2px solid var(--line); padding: 0 0 24px 24px; }
  .timeline li::before { top: 0; left: -7px; }
  .problem { grid-template-columns: 1fr; }
  .sim-grid { grid-template-columns: 1fr; }
  .result { grid-template-columns: 1fr 1fr; }
  .fills { grid-template-columns: 1fr; }
  .calc-grid { grid-template-columns: 1fr; }
  .bar-row { grid-template-columns: 1fr auto; }
  .bar-row .bar-track { grid-column: 1 / -1; grid-row: 2; }
  .nav nav { display: none; }
  .theme-toggle { margin-left: auto; }
}
@media (max-width: 480px) {
  main, .nav, .foot { padding-left: 16px; padding-right: 16px; }
  section { padding: 48px 0; }
  .order-form { grid-template-columns: 1fr 1fr; }
  .order-form button { grid-column: 1 / -1; }
}
