:root {
  color-scheme: dark;
  --ink: #161b36;        /* carbon-paper indigo: the page */
  --ink-raised: #1d2345;
  --rule: #2e3562;
  --text: #ecebf5;
  --muted: #a3a8ca;
  --paper: #ece6d6;      /* the tape */
  --paper-edge: #d9d1bd;
  --paper-ink: #1b2142;
  --mark: #f2d052;       /* highlighter: "now" */
  --loss: #f08b7b;

  --sans: "Archivo", system-ui, sans-serif;
  --mono: "Cutive Mono", ui-monospace, monospace;
  /* Code needs a legible monospace, not the tape's typewriter face. */
  --code: ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;

  --gutter: clamp(16px, 5vw, 64px);
  --measure: 62ch;
}

* { box-sizing: border-box; margin: 0; }

html { scroll-behavior: smooth; scroll-padding-top: 72px; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  background: var(--ink);
  color: var(--text);
  font: 400 1.0625rem/1.6 var(--sans);
  font-variation-settings: "wdth" 100;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

a { color: inherit; text-decoration-color: var(--mark); text-underline-offset: 3px; }
a:hover { color: var(--mark); }
:focus-visible { outline: 2px solid var(--mark); outline-offset: 3px; border-radius: 2px; }

.wrap { max-width: 72rem; margin: 0 auto; padding: 0 var(--gutter); }

/* Masthead */
.masthead {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  padding: 14px var(--gutter);
  background: color-mix(in srgb, var(--ink) 88%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--rule);
}
.wordmark {
  font: 400 1.25rem/1 var(--mono);
  color: var(--paper-ink);
  background: var(--paper);
  padding: 6px 14px 5px;
  border-radius: 2px;
  text-decoration: none;
  letter-spacing: 0.04em;
  box-shadow: 0 1px 0 var(--paper-edge);
}
.wordmark:hover { color: var(--paper-ink); }
.masthead nav { display: flex; gap: 1.75rem; font-size: 0.9375rem; color: var(--muted); }
.masthead nav a { text-decoration: none; }
.masthead nav a:hover { color: var(--text); }

/* Type */
h1, h2 {
  font-family: var(--sans);
  font-variation-settings: "wdth" 72;
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 0.98;
}
h1 { font-size: clamp(3.25rem, 11vw, 8.5rem); }
h2 { font-size: clamp(2.25rem, 5.5vw, 3.75rem); max-width: 18ch; }

.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.loss { color: var(--loss); }

/* Hero */
.hero { padding-top: clamp(56px, 11vw, 132px); }
.lede {
  margin-top: 1.75rem;
  max-width: 44ch;
  font-size: clamp(1.1875rem, 2vw, 1.4375rem);
  line-height: 1.5;
  color: var(--muted);
}

.tape-figure { margin-top: clamp(48px, 8vw, 96px); }
.tape-readout {
  display: flex;
  align-items: baseline;
  gap: 1.25rem;
  margin-bottom: 14px;
  font-variant-numeric: tabular-nums;
}
.readout-symbol { color: var(--muted); font-size: 0.9375rem; }
.readout-time { color: var(--muted); font-size: 0.9375rem; }
.readout-price {
  font-size: 1.5rem;
  font-weight: 600;
  font-variation-settings: "wdth" 85;
}
.readout-change { font-size: 0.9375rem; color: var(--muted); }
.readout-change[data-dir="down"] { color: var(--loss); }

.tape {
  height: clamp(150px, 22vw, 210px);
  background: var(--paper);
  border-top: 1px solid var(--paper-edge);
  border-bottom: 1px solid var(--paper-edge);
  box-shadow: 0 18px 40px -24px rgba(0, 0, 0, 0.6);
}
.tape canvas { display: block; width: 100%; height: 100%; }

.tape-figure figcaption {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1.5rem;
  margin-top: 16px;
  font-size: 0.9375rem;
  color: var(--muted);
}
.tape-figure figcaption span { max-width: 60ch; }
.tape-toggle {
  flex: none;
  font: inherit;
  color: var(--text);
  background: transparent;
  border: 1px solid var(--rule);
  border-radius: 999px;
  padding: 4px 14px;
  cursor: pointer;
}
.tape-toggle:hover { border-color: var(--muted); }
@media (prefers-reduced-motion: reduce) { .tape-toggle { display: none; } }
.tape-toggle[hidden] { display: none; }

/* Sections */
.section { padding-top: clamp(88px, 12vw, 160px); }
.section-intro {
  margin-top: 1.25rem;
  max-width: var(--measure);
  font-size: 1.125rem;
  color: var(--muted);
}
.section p { max-width: var(--measure); }

/* The five lies: a claim and tape's answer, side by side */
.lies { margin-top: 3rem; border-top: 1px solid var(--rule); }
.lie {
  display: grid;
  grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
  gap: 1rem 3rem;
  padding: 1.75rem 0;
  border-bottom: 1px solid var(--rule);
}
.lie dt {
  font-size: clamp(1.375rem, 2.4vw, 1.75rem);
  font-variation-settings: "wdth" 80;
  font-weight: 600;
  line-height: 1.2;
}
.lie dd { color: var(--muted); }

/* One trade: a real sequence, so it's numbered by time */
.timeline {
  list-style: none;
  padding: 0;
  margin-top: 3rem;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0;
  border-top: 2px solid var(--mark);
}
.timeline li { position: relative; padding: 1.5rem 1.5rem 0 0; }
.timeline li::before {
  content: "";
  position: absolute;
  top: -7px;
  left: 0;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--ink);
  border: 2px solid var(--mark);
}
.timeline .t {
  display: block;
  font-family: var(--mono);
  color: var(--mark);
  font-size: 1rem;
  margin-bottom: 0.5rem;
}
.timeline p { color: var(--muted); font-size: 1rem; }
.timeline .num { color: var(--text); }

.compare {
  margin-top: 3.5rem;
  width: 100%;
  max-width: 48rem;
  border-collapse: collapse;
  font-size: 1rem;
}
.compare caption {
  text-align: left;
  font-weight: 600;
  font-size: 1.125rem;
  padding-bottom: 0.75rem;
}
.compare th, .compare td {
  text-align: left;
  padding: 0.75rem 1rem 0.75rem 0;
  border-bottom: 1px solid var(--rule);
  vertical-align: top;
}
.compare thead th { color: var(--muted); font-weight: 500; }
.compare tbody th { color: var(--muted); font-weight: 400; width: 22%; }
.compare td:last-child { color: var(--text); }
.compare td:nth-child(2) { color: var(--muted); }
.note { margin-top: 1.5rem; color: var(--muted); }

/* Custom strategy editor */
.custom { margin-top: 1.5rem; }
.custom[hidden] { display: none; }
.custom-bar { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 0.75rem 1.5rem; }
.custom-note { flex: 1 1 22rem; max-width: 56ch; font-size: 0.875rem; color: var(--muted); }
.custom-note code, .editor-help code { font-family: var(--code); font-size: 0.8125rem; color: var(--text); }
.editor {
  --code-line: 1.6;
  margin-top: 1rem;
  display: grid;
  grid-template-columns: auto 1fr;
  height: clamp(18rem, 50vh, 28rem);
  background: var(--ink);
  border: 1px solid var(--rule);
  border-radius: 8px;
  overflow: hidden;
}
.editor:focus-within { border-color: var(--muted); }
.editor-gutter {
  overflow: hidden;
  padding: 0.85rem 0.6rem 0.85rem 0.9rem;
  border-right: 1px solid var(--rule);
  font: 13px/var(--code-line) var(--code);
  color: var(--muted);
  opacity: 0.7;
  text-align: right;
  user-select: none;
}
.editor-gutter span { display: block; min-width: 2ch; }
.editor-gutter span.is-error { color: var(--loss); opacity: 1; font-weight: 700; }
.editor textarea {
  resize: none;
  border: 0;
  outline: none;
  padding: 0.85rem 1rem;
  background: transparent;
  color: var(--text);
  font: 13px/var(--code-line) var(--code);
  tab-size: 2;
  white-space: pre;
  overflow: auto;
}
.editor-help { margin-top: 0.5rem; font-size: 0.8125rem; color: var(--muted); }
.editor-error {
  margin-top: 0.75rem;
  padding: 0.7rem 0.9rem;
  border-left: 2px solid var(--loss);
  background: color-mix(in srgb, var(--loss) 10%, transparent);
  font: 13px/1.5 var(--code);
  color: var(--text);
  white-space: pre-wrap;
}
.editor-error[hidden] { display: none; }
.button:disabled { opacity: 0.55; cursor: progress; }

.console { margin-top: 1.5rem; }
.console[hidden] { display: none; }
.console-title { font-size: 1rem; font-weight: 600; }
.console pre {
  margin-top: 0.5rem;
  max-height: 14rem;
  overflow: auto;
  padding: 0.85rem 1rem;
  background: var(--ink-raised);
  border: 1px solid var(--rule);
  border-radius: 8px;
  font: 13px/1.55 var(--code);
  color: var(--text);
  white-space: pre-wrap;
}
.console pre.is-empty { color: var(--muted); }

/* Experiment */
.steps {
  margin-top: 2.5rem;
  padding-left: 1.5rem;
  max-width: var(--measure);
  display: grid;
  gap: 0.9rem;
}
.steps li { padding-left: 0.5rem; color: var(--muted); }
.steps li::marker { color: var(--mark); font-variant-numeric: tabular-nums; }
.steps strong { color: var(--text); font-weight: 600; }
.steps + p { margin-top: 2rem; }

/* Under the hood */
.facts {
  margin-top: 2.5rem;
  padding: 0;
  list-style: none;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0 3rem;
  max-width: 60rem;
}
.facts li { padding: 1rem 0; border-top: 1px solid var(--rule); color: var(--muted); }

/* Footer */
.site-footer {
  margin-top: clamp(96px, 14vw, 180px);
  padding: 2rem 0 3rem;
  border-top: 1px solid var(--rule);
  color: var(--muted);
  font-size: 0.9375rem;
}
.site-footer .wrap { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }

@media (max-width: 860px) {
  .masthead nav { display: none; }
  .lie { grid-template-columns: 1fr; gap: 0.5rem; }
  .timeline {
    grid-template-columns: 1fr;
    border-top: 0;
    border-left: 2px solid var(--mark);
    margin-left: 6px;
  }
  .timeline li { padding: 0 0 1.75rem 1.5rem; }
  .timeline li::before { top: 4px; left: -7px; }
  .facts { grid-template-columns: 1fr; }
  .compare tbody th { width: auto; }
}

@media (max-width: 520px) {
  .tape-figure figcaption { flex-direction: column; gap: 0.75rem; }
  .tape-readout { gap: 0.9rem; flex-wrap: wrap; }
  .compare { font-size: 0.9375rem; }
}

/* Buttons */
.actions { display: flex; flex-wrap: wrap; gap: 0.75rem; margin-top: 2.25rem; }
.button {
  display: inline-flex;
  align-items: center;
  font: 600 1rem/1 var(--sans);
  padding: 0.85rem 1.25rem;
  border-radius: 999px;
  border: 1px solid var(--rule);
  color: var(--text);
  background: transparent;
  text-decoration: none;
  cursor: pointer;
}
.button:hover { border-color: var(--muted); color: var(--text); }
.button.primary { background: var(--mark); border-color: var(--mark); color: var(--paper-ink); }
.button.primary:hover { background: #f7dd76; border-color: #f7dd76; color: var(--paper-ink); }

/* Section heading with an optional placeholder flag */
.section-head { display: flex; align-items: flex-start; gap: 1rem 1.5rem; flex-wrap: wrap; }
.placeholder-flag {
  margin-top: 0.6rem;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--paper-ink);
  background: var(--mark);
  padding: 4px 10px;
  border-radius: 999px;
  white-space: nowrap;
}
.placeholder-flag[hidden] { display: none; }

h3.chart-title {
  margin-top: 3.5rem;
  font-size: 1.375rem;
  font-weight: 600;
  font-variation-settings: "wdth" 85;
}
.chart-sub { margin-top: 0.4rem; color: var(--muted); }

/* Charts */
.chart-host { margin-top: 2.5rem; }
.chart { position: relative; }
.chart-plot { position: relative; }
.chart-svg { display: block; overflow: visible; }
.chart-svg:focus-visible { outline: 2px solid var(--mark); outline-offset: 4px; }
.chart-grid { stroke: var(--rule); stroke-width: 1; }
.chart-axis { fill: var(--muted); font: 12px var(--sans); font-variant-numeric: tabular-nums; }
.chart-axis-title { fill: var(--muted); font: 13px var(--sans); }
.chart-line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart-dot { stroke: var(--ink); stroke-width: 2; }
.chart-end-label { fill: var(--text); font: 600 13px var(--sans); }
.chart-cross { stroke: var(--muted); stroke-width: 1; }
.chart-ref { stroke: var(--muted); stroke-width: 1; opacity: 0.6; }
.chart-baseline { stroke: var(--muted); stroke-width: 1; }
.chart-row-label { fill: var(--text); font: 14px var(--sans); paint-order: stroke; stroke: var(--ink); stroke-width: 5px; stroke-linejoin: round; }
.chart-value { fill: var(--text); font: 600 13px var(--sans); font-variant-numeric: tabular-nums; paint-order: stroke; stroke: var(--ink); stroke-width: 4px; stroke-linejoin: round; }
.chart-bar { outline: none; }
.chart-bar:focus-visible path { stroke: var(--mark); stroke-width: 2; }
.chart-ref-label { fill: var(--muted); font: 12px var(--sans); paint-order: stroke; stroke: var(--ink); stroke-width: 4px; stroke-linejoin: round; }
.chart-hit { fill: transparent; }
.chart-point { cursor: default; outline: none; }
.chart-point:focus-visible .chart-dot, .chart-point:focus-visible .chart-ring { stroke: var(--mark); }
.chart-legend { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: 0.5rem 1.5rem; margin-bottom: 1rem; font-size: 0.9375rem; color: var(--muted); }
.chart-legend li { display: flex; align-items: center; gap: 0.5rem; }
.chart-legend-key { display: inline-block; }
.chart-legend-key.line { width: 18px; height: 2px; border-radius: 1px; }
.chart-legend-key.dot { width: 10px; height: 10px; border-radius: 50%; }
.chart-legend-key.dot.hollow { background: transparent; border: 1.5px solid; box-sizing: border-box; }
.chart-tip {
  position: absolute;
  z-index: 5;
  pointer-events: none;
  min-width: 11rem;
  padding: 0.6rem 0.75rem;
  background: var(--ink-raised);
  border: 1px solid var(--rule);
  border-radius: 6px;
  box-shadow: 0 10px 30px -12px rgba(0, 0, 0, 0.6);
  font-size: 0.875rem;
}
.chart-tip[hidden] { display: none; }
.chart-tip-title { color: var(--muted); margin-bottom: 0.35rem; }
.chart-tip-row { display: flex; align-items: center; gap: 0.5rem; }
.chart-tip-row strong { font-variant-numeric: tabular-nums; color: var(--text); }
.chart-tip-label { color: var(--muted); }
.chart-tip-key { width: 12px; height: 2px; border-radius: 1px; flex: none; }
.chart-tip-label:empty { display: none; }
.chart-table { margin-top: 1rem; font-size: 0.9375rem; color: var(--muted); }
.chart-table summary { cursor: pointer; width: fit-content; }
.chart-table summary:hover { color: var(--text); }
.chart-table-scroll { max-height: 22rem; overflow: auto; margin-top: 0.75rem; }
.chart-table table { border-collapse: collapse; min-width: 28rem; }
.chart-table th, .chart-table td { text-align: left; padding: 0.4rem 1.5rem 0.4rem 0; border-bottom: 1px solid var(--rule); font-variant-numeric: tabular-nums; }
.chart-table th { font-weight: 500; }
.chart-table td { color: var(--text); }

.stats-table { margin-top: 2.5rem; }

/* Demo */
.demo {
  margin-top: 2.5rem;
  padding: clamp(1.25rem, 3vw, 2rem);
  background: var(--ink-raised);
  border: 1px solid var(--rule);
  border-radius: 10px;
}
.demo-row { display: flex; flex-wrap: wrap; gap: 1rem 1.25rem; }
.field { display: flex; flex-direction: column; gap: 0.4rem; font-size: 0.875rem; color: var(--muted); }
.field[hidden] { display: none; }
.field select, .field input {
  font: 500 1rem var(--sans);
  color: var(--text);
  background: var(--ink);
  border: 1px solid var(--rule);
  border-radius: 6px;
  padding: 0.55rem 0.7rem;
  min-width: 9rem;
}
.field input[type="number"] { width: 9rem; font-variant-numeric: tabular-nums; }
.field select:hover, .field input:hover { border-color: var(--muted); }

.execution { margin-top: 1.75rem; border: 0; padding: 0; }
.execution legend { font-weight: 600; font-size: 1rem; margin-bottom: 0.75rem; }
.presets { display: inline-flex; border: 1px solid var(--rule); border-radius: 999px; padding: 3px; gap: 2px; }
.presets label { position: relative; }
.presets input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.presets span { display: block; padding: 0.4rem 0.95rem; border-radius: 999px; font-size: 0.9375rem; color: var(--muted); }
.presets input:checked + span { background: var(--text); color: var(--ink); }
.presets input:focus-visible + span { outline: 2px solid var(--mark); outline-offset: 2px; }
.sliders { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem 2.5rem; margin-top: 1.25rem; align-items: start; }
.slider { display: grid; grid-template-columns: 1fr auto; align-items: center; align-content: start; gap: 0.35rem 1rem; font-size: 0.9375rem; color: var(--muted); }
.slider input { grid-column: 1 / -1; width: 100%; accent-color: var(--mark); }
.slider output { color: var(--text); font-variant-numeric: tabular-nums; }
.slider .hint { grid-column: 1 / -1; font-size: 0.8125rem; color: var(--muted); line-height: 1.4; }
.hint-inline { font-size: 0.8125rem; }
.demo-meta.error { color: var(--loss); }
.check { display: flex; align-items: center; gap: 0.6rem; font-size: 0.9375rem; color: var(--muted); align-self: end; }
.check input { accent-color: var(--mark); width: 1.05rem; height: 1.05rem; }
.check[hidden] { display: none; }

.demo-submit { display: flex; align-items: center; flex-wrap: wrap; gap: 1rem 1.5rem; margin-top: 1.75rem; }
.demo-meta { color: var(--muted); font-size: 0.9375rem; }
.demo-output { margin-top: 2.5rem; transition: opacity 150ms ease; }
.demo-output.is-running { opacity: 0.5; }
.demo-hash { margin-top: 1rem; font-size: 0.875rem; color: var(--muted); }

.tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1px; background: var(--rule); border: 1px solid var(--rule); border-radius: 8px; overflow: hidden; }
.tile { display: flex; flex-direction: column; gap: 0.3rem; padding: 1rem 1.25rem; background: var(--ink); }
.tile-label { font-size: 0.875rem; color: var(--muted); }
.tile-value { font-size: 1.75rem; font-weight: 600; font-variation-settings: "wdth" 85; line-height: 1.1; }
.tile-note { font-size: 0.8125rem; color: var(--muted); }

/* Experiment */
.funnel { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 1.5rem; margin-top: 3rem; }
.luck-figures { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1.5rem; margin-top: 1.5rem; max-width: 52rem; }
.luck-figures .figure:last-child .figure-value { color: var(--text); }
.run-meta { margin-top: 1rem; color: var(--muted); font-size: 0.9375rem; }
.figure { display: flex; flex-direction: column; gap: 0.35rem; padding-top: 1rem; border-top: 1px solid var(--rule); }
.figure-value { font-size: clamp(2.25rem, 5vw, 3.25rem); font-weight: 700; font-variation-settings: "wdth" 75; line-height: 1; }
.figure:last-child .figure-value { color: var(--mark); }
.figure-label { color: var(--muted); font-size: 0.9375rem; }

.notebook { list-style: none; padding: 0; margin-top: 1.25rem; display: grid; gap: 0; max-width: 52rem; }
.notebook li { padding: 1.5rem 0; border-top: 1px solid var(--rule); }
.notebook h4 { font-size: 1.125rem; font-weight: 600; }
.notebook p { margin-top: 0.35rem; color: var(--muted); }
.notebook .notebook-scores { color: var(--text); font-variant-numeric: tabular-nums; font-size: 0.9375rem; }
.notebook blockquote { margin-top: 0.75rem; padding-left: 1rem; border-left: 2px solid var(--mark); color: var(--text); }
#experiment .notebook + p { margin-top: 2rem; }

@media (max-width: 640px) {
  .sliders { grid-template-columns: 1fr; }
  .field { flex: 1 1 100%; }
  .field select, .field input, .field input[type="number"] { width: 100%; }
  .tile-value { font-size: 1.4rem; }
  .funnel { gap: 1.25rem; }
}

/* Responsive overrides for components defined above. Keep these last. */
@media (max-width: 960px) {
  .funnel { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 860px) {
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .luck-figures { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .funnel { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
