/* puretensor.systems: lab recipe pages.
   Layout: one 1120px column; a mono "instrument" register (eyebrows, numbers, tables) against plain Inter prose.
   Dark-first, matching the PureTensor X cards; a light variant for light-mode readers. */
:root {
  --bg: #09090b;          /* zinc-950, the card ground */
  --panel: #111114;       /* raised surfaces: tables, terminal */
  --line: rgba(228, 228, 231, 0.12);
  --line-strong: rgba(228, 228, 231, 0.22);
  --fg: #fafafa;
  --muted: #a1a1aa;
  --faint: #71717a;
  --accent: #22d3ee;      /* PureTensor cyan */
  --accent-ink: #09090b;  /* text on accent */
  --accent-soft: rgba(34, 211, 238, 0.12);
  --amber: #f59e0b;       /* reference lines: ceilings, previous bests */
  --glow: rgba(34, 211, 238, 0.16);
  --display: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --body: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
  --step--1: 0.8125rem;
  --step-0: 1rem;
  --step-1: 1.1875rem;
  --step-2: 1.5rem;
  --step-3: 2.25rem;
  --step-4: clamp(2.5rem, 5.6vw, 4.5rem);
  --radius: 4px;
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #fafafa; --panel: #ffffff; --line: rgba(9, 9, 11, 0.1); --line-strong: rgba(9, 9, 11, 0.2);
    --fg: #09090b; --muted: #52525b; --faint: #71717a; --accent: #0e7490; --accent-ink: #ffffff;
    --accent-soft: rgba(14, 116, 144, 0.1); --amber: #b45309; --glow: rgba(14, 116, 144, 0.1);
    color-scheme: light;
  }
}
:root[data-theme="light"] {
  --bg: #fafafa; --panel: #ffffff; --line: rgba(9, 9, 11, 0.1); --line-strong: rgba(9, 9, 11, 0.2);
  --fg: #09090b; --muted: #52525b; --faint: #71717a; --accent: #0e7490; --accent-ink: #ffffff;
  --accent-soft: rgba(14, 116, 144, 0.1); --amber: #b45309; --glow: rgba(14, 116, 144, 0.1);
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--fg);
  font: 400 var(--step-0)/1.6 var(--body);
  -webkit-font-smoothing: antialiased;
}
img, svg { max-width: 100%; }
a { color: var(--accent); text-underline-offset: 3px; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 2px; }
code, kbd, pre { font-family: var(--mono); }
.num { font-variant-numeric: tabular-nums; }

.wrap {
  max-width: 1120px; margin: 0 auto;
  padding-left: max(24px, env(safe-area-inset-left, 0px));
  padding-right: max(24px, env(safe-area-inset-right, 0px));
}
@media (max-width: 480px) {
  .wrap { padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
}

/* Header */
.site-head { border-bottom: 1px solid var(--line); }
.site-head .wrap { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding-block: 18px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 14px; color: var(--fg); text-decoration: none; }
.wordmark { display: inline-flex; align-items: center; font-size: 20px; line-height: 1; letter-spacing: 0.02em; }
.wordmark b { font-weight: 700; }
.wordmark svg { width: 17px; height: 17px; margin: 0 1px; position: relative; top: 1px; }
.brand-tag { font: 500 11px/1 var(--mono); letter-spacing: 0.18em; color: var(--muted); padding-left: 14px; border-left: 1px solid var(--line-strong); }
.site-nav { display: flex; gap: 20px; font: 500 var(--step--1)/1 var(--body); }
.site-nav a { color: var(--muted); text-decoration: none; }
.site-nav a:hover, .site-nav a[aria-current] { color: var(--fg); }

/* Type */
.eyebrow { font: 500 12px/1.4 var(--mono); letter-spacing: 0.14em; text-transform: uppercase; color: var(--accent); margin: 0; }
.crumbs { font: 400 var(--step--1)/1.4 var(--mono); color: var(--faint); display: flex; gap: 8px; flex-wrap: wrap; margin: 0; }
.crumbs a { color: var(--muted); text-decoration: none; }
h1, h2, h3 { font-family: var(--display); text-wrap: balance; margin: 0; }
h1 { font-size: var(--step-4); line-height: 1.02; font-weight: 700; letter-spacing: -0.035em; }
h1 .dim { color: var(--muted); }
h1 .hot { color: var(--accent); }
h2 { font-size: var(--step-3); line-height: 1.1; font-weight: 700; letter-spacing: -0.025em; }
h3 { font-size: var(--step-1); line-height: 1.3; font-weight: 600; letter-spacing: -0.01em; }
p { margin: 0; }
.lede { font-size: var(--step-1); line-height: 1.55; color: var(--muted); max-width: 64ch; }
.lede strong { color: var(--fg); font-weight: 600; }
.prose { max-width: 66ch; color: var(--muted); display: flex; flex-direction: column; gap: 14px; }
.prose strong { color: var(--fg); font-weight: 600; }
.small { font-size: var(--step--1); color: var(--faint); }

/* Sections */
section { padding-block: 72px; border-top: 1px solid var(--line); }
.sec-head { display: flex; flex-direction: column; gap: 12px; margin-bottom: 32px; max-width: 760px; }
.sec-head p:not(.eyebrow) { color: var(--muted); }

/* Hero */
.hero { position: relative; overflow: hidden; border-top: 0; padding-block: 56px 64px; }
.hero::before {
  content: ""; position: absolute; right: -260px; top: -240px; width: 900px; height: 900px; pointer-events: none;
  background: radial-gradient(circle at center, var(--glow), transparent 62%);
}
.hero .wrap { position: relative; display: flex; flex-direction: column; gap: 24px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { font: 500 12px/1 var(--mono); letter-spacing: 0.04em; color: var(--muted); border: 1px solid var(--line-strong); border-radius: 999px; padding: 7px 11px; }
.chip.ok { color: var(--accent); border-color: var(--accent); }
.actions { display: flex; gap: 12px; flex-wrap: wrap; }
.btn {
  display: inline-flex; align-items: center; gap: 8px; padding: 12px 18px; border-radius: var(--radius);
  font: 600 var(--step--1)/1 var(--body); text-decoration: none; border: 1px solid var(--line-strong); color: var(--fg);
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn:hover { border-color: var(--accent); text-decoration: none; }

/* Stat row */
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); }
.stat { padding: 22px 22px 20px; display: flex; flex-direction: column; gap: 8px; border-left: 1px solid var(--line); }
.stat:first-child { border-left: 0; }
.stat .k { font: 500 11px/1.3 var(--mono); letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); }
.stat .v { font: 500 clamp(2rem, 4vw, 3rem)/1 var(--mono); letter-spacing: -0.04em; font-variant-numeric: tabular-nums; }
.stat .v small { font-size: 0.42em; letter-spacing: 0; color: var(--muted); margin-left: 4px; }
.stat .v.hot { color: var(--accent); }
.stat .s { font: 400 12px/1.45 var(--mono); color: var(--faint); }
.stat .s a { color: var(--muted); }
@media (max-width: 860px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat:nth-child(3) { border-left: 0; }
  .stat:nth-child(n+3) { border-top: 1px solid var(--line); }
}

/* Tables */
.table-scroll { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); }
table { width: 100%; border-collapse: collapse; font-size: var(--step--1); }
th, td { text-align: left; padding: 12px 16px; border-bottom: 1px solid var(--line); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
th { font: 500 11px/1.3 var(--mono); letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); white-space: nowrap; }
td.n, th.n { text-align: right; font-family: var(--mono); font-variant-numeric: tabular-nums; white-space: nowrap; }
td code { font-size: 0.92em; color: var(--fg); }
tr.best td { background: var(--accent-soft); }
tr.best td:first-child { box-shadow: inset 2px 0 0 var(--accent); }
.dimrow td { color: var(--muted); }
.ci { color: var(--faint); }
.swipe { display: none; }
@media (max-width: 700px) { .swipe { display: block; margin-top: 8px; } }

/* Replay terminal */
.term { border: 1px solid var(--line-strong); border-radius: 6px; background: var(--panel); overflow: hidden; }
.term-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.term-title { font: 500 12px/1.3 var(--mono); color: var(--muted); letter-spacing: 0.04em; }
.seg { display: inline-flex; border: 1px solid var(--line-strong); border-radius: var(--radius); overflow: hidden; }
.seg button { font: 500 12px/1 var(--mono); color: var(--muted); background: transparent; border: 0; padding: 9px 12px; cursor: pointer; border-left: 1px solid var(--line-strong); }
.seg button:first-child { border-left: 0; }
.seg button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }
.term-out { height: 360px; overflow: auto; margin: 0; padding: 18px 20px; font: 400 13px/1.6 var(--mono); color: var(--fg); white-space: pre-wrap; word-break: break-word; }
.term-out .cursor { display: inline-block; width: 0.6em; height: 1.1em; vertical-align: text-bottom; background: var(--accent); }
.term-foot { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 12px 16px; border-top: 1px solid var(--line); font: 500 12px/1.3 var(--mono); color: var(--muted); font-variant-numeric: tabular-nums; }
.term-foot b { color: var(--accent); font-weight: 500; }
.replay-btn { font: 500 12px/1 var(--mono); color: var(--fg); background: transparent; border: 1px solid var(--line-strong); border-radius: var(--radius); padding: 8px 12px; cursor: pointer; }
.replay-btn:hover { border-color: var(--accent); }

/* Ceiling chart */
.ceiling { border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); padding: 24px 24px 18px; }
.ceiling svg { display: block; width: 100%; height: auto; overflow: visible; }
.ceiling text { font-family: var(--mono); }
.legend { display: flex; flex-wrap: wrap; gap: 18px; margin-top: 14px; font: 500 11px/1.3 var(--mono); letter-spacing: 0.08em; color: var(--muted); text-transform: uppercase; }
.legend span { display: inline-flex; align-items: center; gap: 8px; }
.sw { width: 12px; height: 12px; border-radius: 2px; display: inline-block; }
.sw.line { height: 0; border-top: 2px dashed var(--amber); border-radius: 0; width: 16px; }

/* Two-column explainers */
.cols { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 40px 48px; }
.cols > div { min-width: 0; display: flex; flex-direction: column; gap: 10px; }
.cols p { color: var(--muted); }
.cols p strong { color: var(--fg); }
@media (max-width: 760px) { .cols { grid-template-columns: minmax(0, 1fr); gap: 32px; } }

.formula { display: flex; align-items: baseline; flex-wrap: wrap; gap: 10px 14px; padding: 20px 22px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); font-family: var(--mono); }
.formula .big { font-size: 1.75rem; font-weight: 500; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.formula .u { font-size: 11px; letter-spacing: 0.12em; color: var(--muted); text-transform: uppercase; }
.formula .op { color: var(--faint); font-size: 1.25rem; }
.formula .hot { color: var(--accent); }

/* Steps and code */
.steps { display: flex; flex-direction: column; gap: 28px; }
.step { display: grid; grid-template-columns: 40px minmax(0, 1fr); gap: 16px; }
.step-n { font: 500 13px/1 var(--mono); color: var(--accent-ink); background: var(--accent); width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; margin-top: 2px; }
.step > div { min-width: 0; display: flex; flex-direction: column; gap: 12px; }
.step p { color: var(--muted); }
.codeblock { position: relative; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); }
.codeblock pre { margin: 0; padding: 16px 18px; padding-right: 76px; overflow-x: auto; font-size: 13px; line-height: 1.65; color: var(--fg); }
.codeblock .c { color: var(--faint); }
.copy { position: absolute; top: 10px; right: 10px; font: 500 11px/1 var(--mono); letter-spacing: 0.06em; color: var(--muted); background: var(--bg); border: 1px solid var(--line-strong); border-radius: var(--radius); padding: 7px 9px; cursor: pointer; }
.copy:hover { color: var(--fg); border-color: var(--accent); }

/* Needs grid */
.needs { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0; border: 1px solid var(--line); border-radius: var(--radius); }
.needs > div { padding: 20px; border-left: 1px solid var(--line); display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.needs > div:first-child { border-left: 0; }
.needs h3 { font-size: var(--step-0); }
.needs p { color: var(--muted); font-size: var(--step--1); }
@media (max-width: 860px) {
  .needs { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .needs > div:nth-child(3) { border-left: 0; }
  .needs > div:nth-child(n+3) { border-top: 1px solid var(--line); }
}
@media (max-width: 480px) {
  .needs { grid-template-columns: minmax(0, 1fr); }
  .needs > div { border-left: 0; }
  .needs > div + div { border-top: 1px solid var(--line); }
}

/* Recipe index cards */
.recipes { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr)); gap: 16px; }
.recipe { display: flex; flex-direction: column; gap: 14px; padding: 22px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); color: var(--fg); text-decoration: none; }
.recipe:hover { border-color: var(--accent); text-decoration: none; }
.recipe .meta { font: 500 11px/1.4 var(--mono); letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); }
.recipe h3 { font-size: var(--step-2); letter-spacing: -0.02em; }
.recipe .nums { display: flex; gap: 24px; flex-wrap: wrap; font-family: var(--mono); }
.recipe .nums b { display: block; font-size: 1.75rem; font-weight: 500; letter-spacing: -0.03em; color: var(--accent); font-variant-numeric: tabular-nums; }
.recipe .nums span { font-size: 11px; letter-spacing: 0.1em; color: var(--muted); text-transform: uppercase; }
.recipe .go { font: 500 var(--step--1)/1 var(--mono); color: var(--accent); }

/* Footer */
.site-foot { border-top: 1px solid var(--line); }
.site-foot .wrap { padding-block: 32px 40px; display: flex; justify-content: space-between; gap: 16px 32px; flex-wrap: wrap; font: 400 12px/1.6 var(--mono); color: var(--faint); letter-spacing: 0.04em; }
.site-foot a { color: var(--muted); }

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

/* Race: the same reply, three setups, replayed at measured speed */
.race { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.lane { border: 1px solid var(--line); border-radius: 6px; background: var(--panel); display: flex; flex-direction: column; min-width: 0; overflow: hidden; }
.lane.lead { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent-soft), 0 18px 48px -24px var(--glow); }
.lane-head { padding: 14px 16px 12px; border-bottom: 1px solid var(--line); display: flex; flex-direction: column; gap: 6px; }
.lane-name { font: 500 11px/1.3 var(--mono); letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); }
.lane-rate { font: 500 1.75rem/1 var(--mono); letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.lane.lead .lane-rate { color: var(--accent); }
.lane-rate small { font-size: 0.45em; color: var(--muted); letter-spacing: 0; margin-left: 4px; }
.lane-out { height: 230px; overflow: hidden; margin: 0; padding: 12px 14px; font: 400 11px/1.55 var(--mono); color: var(--muted); white-space: pre-wrap; word-break: break-word; display: flex; flex-direction: column; justify-content: flex-end; }
.lane-out span { display: block; }
.lane-bar { height: 3px; background: var(--line); }
.lane-bar i { display: block; height: 100%; width: 0; background: var(--accent); }
.lane:not(.lead) .lane-bar i { background: var(--muted); }
.lane-foot { display: flex; justify-content: space-between; gap: 8px; padding: 10px 14px; font: 500 11px/1.3 var(--mono); color: var(--faint); font-variant-numeric: tabular-nums; }
.lane-foot .done { color: var(--accent); }
.race-meta { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; font: 400 12px/1.5 var(--mono); color: var(--faint); }
@media (max-width: 760px) {
  .race { grid-template-columns: minmax(0, 1fr); }
  .lane-out { height: 120px; }
}

/* Receipts ledger */
.ledger { border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); font-family: var(--mono); font-size: 12.5px; }
.ledger-row { display: grid; grid-template-columns: minmax(0, 1.9fr) minmax(0, 1.2fr) 70px 64px minmax(250px, 1.7fr); gap: 12px; padding: 11px 16px; border-bottom: 1px dashed var(--line-strong); align-items: baseline; }
.ledger-row:last-child { border-bottom: 0; }
.ledger-row.head { font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); border-bottom-style: solid; }
.ledger-row .r { text-align: right; font-variant-numeric: tabular-nums; }
.ledger-row a { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ledger-row a:hover { color: var(--accent); }
.ledger-row .what { color: var(--fg); min-width: 0; }
.ledger-row .what small { color: var(--faint); display: block; font-size: 11px; }
.ledger-row .ok { color: var(--accent); }
.ledger-row > span:last-child { white-space: nowrap; }
.ledger-scroll { overflow-x: auto; }
.ledger-scroll .ledger { min-width: 860px; }
section.tight { padding-block: 40px; }
.ceiling { overflow-x: auto; }
.ceiling svg { min-width: 620px; }
.cols.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 32px; }
@media (max-width: 960px) { .cols.cols-3 { grid-template-columns: minmax(0, 1fr); } }
