/* Turning the Mismatch Knob: page styles.
   One serif for body and headings; figures follow the "LRT RL Training Results" page: Inter, panels on a light surface,
   blue segmented controls, swatch legends, hover crosshair with dots. Text and figures share one 700px column. */
:root {
  color-scheme: light;
  --bg: #ffffff; --surface: #ffffff; --panel: #f5f4f1; --squeeze: #f3f2ee;
  --text: #504945; --ink: #282828; --ink2: #6b6866; --muted: #99948d; --grid: #ebe9e4; --axis: #c8c4bd;
  --rule: rgba(11, 11, 11, .10); --link: #1c5cab; --accent: #2a78d6; --ctl: #1c5cab; --ctl-ink: #ffffff;
  --tip: #ffffff; --shadow: rgba(11, 11, 11, .14);
  /* methods (as on the results page) */
  --m-none: #52514e; --m-sc: #2a78d6; --m-tis: #eda100; --m-sc_tis: #1baf7a; --m-sc_kl: #e34948; --m-sc_klm: #e34948;
  /* lags: synchronous + ordinal blue ramp */
  --lag0: #52514e; --lag2: #fe8c2c; --lag4: #d4407c; --lag16: #7e259e; --lag64: #378a21;  /* as on the results page */
  --ok: #898781; --bad: #d03b3b; --base: #898781;
  /* score change vs. SFT baseline, 9 steps */
  --hm0: #ecebe6; --hb1: #cde2fb; --hb2: #86b6ef; --hb3: #2a78d6; --hb4: #184f95; --hr1: #f8d4d1; --hr2: #ee9f9b; --hr3: #d14f4d; --hr4: #9c2626;
  --ht0: #0b0b0b; --ht1: #0b0b0b; --ht2: #0b0b0b; --ht3: #ffffff; --ht4: #ffffff;
  --band: rgba(208, 59, 59, .10);
  --serif: "Source Serif 4", "Iowan Old Style", Georgia, serif;
  --sans: Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #151514; --surface: #151514; --panel: #1f1f1d; --squeeze: #222220;
    --text: #cfc9c0; --ink: #f0efec; --ink2: #aaa49b; --muted: #807b74; --grid: #2a2a28; --axis: #45443f;
    --rule: rgba(255, 255, 255, .10); --link: #6da7ec; --accent: #3987e5; --ctl: #3987e5; --ctl-ink: #0d0d0d; --tip: #262624; --shadow: rgba(0, 0, 0, .5);
    --m-none: #c3c2b7; --m-sc: #3987e5; --m-tis: #c98500; --m-sc_tis: #199e70; --m-sc_kl: #e66767; --m-sc_klm: #e66767;
    --lag0: #c3c2b7; --lag2: #964d09; --lag4: #cd3976; --lag16: #bd67e0; --lag64: #77b154;
    --ok: #898781; --bad: #e66767; --base: #898781;
    --hm0: #383835; --hb1: #104281; --hb2: #1c5cab; --hb3: #2a78d6; --hb4: #6da7ec; --hr1: #5c2020; --hr2: #8f2e2e; --hr3: #c94544; --hr4: #ee8f8c;
    --ht0: #f0efec; --ht1: #f0efec; --ht2: #f0efec; --ht3: #f0efec; --ht4: #0d0d0d;
    --band: rgba(230, 103, 103, .14);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #151514; --surface: #151514; --panel: #1f1f1d; --squeeze: #222220;
  --text: #cfc9c0; --ink: #f0efec; --ink2: #aaa49b; --muted: #807b74; --grid: #2a2a28; --axis: #45443f;
  --rule: rgba(255, 255, 255, .10); --link: #6da7ec; --accent: #3987e5; --ctl: #3987e5; --ctl-ink: #0d0d0d; --tip: #262624; --shadow: rgba(0, 0, 0, .5);
  --m-none: #c3c2b7; --m-sc: #3987e5; --m-tis: #c98500; --m-sc_tis: #199e70; --m-sc_kl: #e66767; --m-sc_klm: #e66767;
  --lag0: #c3c2b7; --lag2: #964d09; --lag4: #cd3976; --lag16: #bd67e0; --lag64: #77b154;
  --ok: #898781; --bad: #e66767; --base: #898781;
  --hm0: #383835; --hb1: #104281; --hb2: #1c5cab; --hb3: #2a78d6; --hb4: #6da7ec; --hr1: #5c2020; --hr2: #8f2e2e; --hr3: #c94544; --hr4: #ee8f8c;
  --ht0: #f0efec; --ht1: #f0efec; --ht2: #f0efec; --ht3: #f0efec; --ht4: #0d0d0d;
  --band: rgba(230, 103, 103, .14);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--serif); font-size: 16.8px; line-height: 1.55; }
a { color: inherit; text-decoration: underline; text-decoration-color: var(--axis); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { text-decoration-color: currentColor; }

.topbar { max-width: 740px; margin: 0 auto; padding: 18px 20px; display: flex; justify-content: space-between; align-items: center; font-family: var(--sans); font-size: 14px; }
.topbar a { text-decoration: none; color: var(--ink); letter-spacing: .02em; }
.topbar .theme { font: inherit; font-size: 13px; color: var(--ink2); background: none; border: 1px solid var(--axis); border-radius: 999px; padding: 3px 12px; cursor: pointer; }

main { padding: 0 20px 80px; }
.col, .wide { max-width: 680px; margin-left: auto; margin-right: auto; }

/* headings share the body serif */
header.post { padding: 40px 0 10px; text-align: center; }
.kicker, .tldr .label, .toc .label, .side-toc .label { font-family: var(--sans); font-size: 11.5px; font-weight: 500; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); }
.kicker { margin: 0 0 12px; }
h1, h2, h3 { font-family: var(--serif); font-weight: 600; color: var(--ink); text-wrap: balance; }
h1 { font-size: clamp(26px, 3.6vw, 31px); line-height: 1.3; margin: 0 0 12px; }
.byline { font-family: var(--sans); font-size: 13.5px; color: var(--ink2); margin: 0; }
strong, b { color: var(--ink); }
h2 { font-size: 23px; line-height: 1.4; margin: 52px 0 12px; scroll-margin-top: 24px; }
h3 { font-size: 18px; margin: 28px 0 8px; }
p { margin: 0 0 18px; }
ul, ol { padding-left: 24px; margin: 0 0 18px; }
li { margin: 6px 0; }
strong { font-weight: 600; }

.tldr { border-left: 3px solid var(--axis); padding: 2px 0 2px 18px; margin: 28px auto 8px; }
.tldr p:last-child { margin: 0; }
.tldr .label { display: block; margin-bottom: 6px; }

/* one highlighted takeaway at the top of a results section */
.takeaway { background: var(--panel); border-left: 3px solid var(--accent); border-radius: 0 8px 8px 0; padding: 14px 18px; margin: 16px 0 24px; }
.takeaway p:last-child { margin: 0; }
.takeaway .label { display: block; margin-bottom: 6px; font-family: var(--sans); font-size: 11.5px; font-weight: 500; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); }

/* contents: inline box on narrow screens, sticky column on the left on wide ones */
.toc { font-family: var(--sans); font-size: 14px; border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule); padding: 12px 0; margin: 28px auto 0; }
.toc ol { margin: 4px 0 0; padding-left: 20px; columns: 2; column-gap: 32px; }
.toc li { margin: 3px 0; break-inside: avoid; }
.toc a { text-decoration: none; color: var(--ink); }
/* contents column as on thinkingmachines.ai: from 1180px up, sticky beside the article, a 4px dot marks the section in view */
.shell { position: relative; }
.side-toc-wrap { display: none; }
@media (min-width: 1180px) {
  .toc { display: none; }
  .side-toc-wrap { display: block; position: absolute; top: 0; bottom: 0; left: 0; width: calc(50% - 340px - 56px); }
  .side-toc { position: sticky; top: 32px; transform: translateY(10px); margin-left: auto; width: 190px; padding-left: 21px;
    font-family: var(--sans); font-size: 13px; line-height: 1.4; max-height: calc(100vh - 48px); overflow-y: auto; scrollbar-width: none; }
  .side-toc ol { list-style: none; margin: 0; padding: 0; position: relative; }
  .side-toc li { margin: 0 0 .7rem; }
  .side-toc a { color: var(--ink2); text-decoration: none; transition: color .2s ease-in-out; }
  .side-toc a:hover { color: var(--ink); text-decoration: underline; text-decoration-color: var(--axis); text-underline-offset: 2px; }
  .side-toc a.active { color: var(--ink); }
  .toc-marker { position: absolute; left: 8px; top: 0; width: 4px; height: 4px; border-radius: 50%; background: var(--ink); opacity: 0;
    transform: translate3d(0, calc(var(--y, 0px) - 50%), 0); transition: transform .28s cubic-bezier(.22, 1, .36, 1), opacity .16s ease-in-out; pointer-events: none; }
  .side-toc.has-marker .toc-marker { opacity: 1; }
}
@media (max-width: 600px) { .toc ol { columns: 1; } }
/* below 1180px there is no room beside the article: a Contents button in the corner opens the same list */
.toc-fab { display: none; position: fixed; right: 16px; bottom: 16px; z-index: 20; font-family: var(--sans); }
@media (max-width: 1179px) { .toc-fab.on { display: block; } }
.toc-fab > button { font: inherit; font-size: 13px; font-weight: 500; color: var(--ink); background: var(--tip); border: 1px solid var(--axis); border-radius: 999px;
  padding: 7px 14px; cursor: pointer; box-shadow: 0 2px 10px var(--shadow); display: inline-flex; align-items: center; gap: 7px; }
.toc-fab > button:hover { border-color: var(--ink2); }
.toc-fab > button:focus-visible, .toc-pop a:focus-visible { outline: 2px solid var(--ctl); outline-offset: 2px; }
.toc-fab > button svg { flex: none; }
.toc-pop { position: absolute; right: 0; bottom: calc(100% + 8px); width: min(300px, calc(100vw - 32px)); max-height: min(70vh, 460px); overflow-y: auto;
  background: var(--tip); border: 1px solid var(--axis); border-radius: 10px; box-shadow: 0 6px 24px var(--shadow); padding: 12px 14px; font-size: 13.5px; line-height: 1.4; }
.toc-pop .label { display: block; margin-bottom: 8px; font-size: 11.5px; font-weight: 500; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); }
.toc-pop ol { list-style: none; margin: 0; padding: 0; }
.toc-pop li { margin: 0; }
.toc-pop a { display: block; padding: 6px 8px 6px 14px; margin: 0 -8px; border-radius: 6px; color: var(--ink2); text-decoration: none; position: relative; }
.toc-pop a:hover { color: var(--ink); background: var(--panel); }
.toc-pop a.active { color: var(--ink); font-weight: 500; }
.toc-pop a.active::before { content: ""; position: absolute; left: 4px; top: calc(6px + .7em - 2px); width: 4px; height: 4px; border-radius: 50%; background: var(--ink); }
@media print { .toc-fab { display: none !important; } }

.findings { list-style: none; padding: 0; }
.findings li { padding-left: 18px; position: relative; margin: 10px 0; }
.findings li::before { content: ""; position: absolute; left: 0; top: .68em; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); }

/* figures */
body { counter-reset: fig; }
figure { margin: 40px auto 36px; counter-increment: fig; }
figure .fig-title { font-family: var(--sans); font-size: 14px; font-weight: 600; color: var(--ink); line-height: 1.4; margin: 0 0 2px; }
figure .fig-sub { font-family: var(--sans); font-size: 12.5px; color: var(--ink2); margin: 0 0 14px; line-height: 1.5; }
figcaption { font-family: var(--sans); font-size: 12.5px; line-height: 1.5; color: var(--ink2); margin: 14px 0 0; }
figcaption::before { content: "Figure " counter(fig) ": "; font-weight: 600; color: var(--ink); }
.chart { position: relative; width: 100%; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; font-family: var(--sans); }
.scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.scroll > .chart { min-width: 600px; }
.scroll > .chart.fit { min-width: 0; }

.controls { display: flex; flex-wrap: wrap; gap: 10px 22px; align-items: center; margin: 0 0 12px; font-family: var(--sans); font-size: 13px; }
.controls .group-label { color: var(--muted); margin-right: 8px; }
.seg { display: inline-flex; flex-wrap: wrap; gap: 2px; vertical-align: middle; }
.seg button { font: inherit; color: var(--ink2); background: transparent; border: 0; border-radius: 999px; padding: 5px 12px; cursor: pointer; }
.seg button:hover { color: var(--ink); }
.seg button[aria-pressed="true"] { background: var(--panel); color: var(--ink); font-weight: 500; }
.seg button:focus-visible, .chip:focus-visible { outline: 2px solid var(--ctl); outline-offset: 1px; }
.zoom-back { font: inherit; color: var(--ink); background: var(--panel); border: 0; border-radius: 999px; padding: 5px 12px; cursor: pointer; }
.zoom-back:hover { color: var(--link); }
.zoom-back:focus-visible { outline: 2px solid var(--ctl); outline-offset: 1px; }
.chips { display: flex; flex-wrap: wrap; gap: 4px 16px; font-family: var(--sans); font-size: 13px; }
.chip { font: inherit; display: inline-flex; align-items: center; gap: 6px; color: var(--ink); background: none; border: 0; padding: 2px 0; cursor: pointer; }
.chip[aria-pressed="false"] { color: var(--muted); text-decoration: line-through; }
.chip[aria-pressed="false"] .sw { opacity: .25; }
.sw { display: inline-block; flex: none; width: 22px; height: 0; border-top: 2.2px solid; border-radius: 2px; vertical-align: middle; margin-right: 6px; }
.chip .sw, .tip .sw { margin-right: 0; }
.sw.dash { border-top-style: dashed; }
.sw.dot { border-top-style: dotted; border-top-width: 2.6px; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 16px; font-family: var(--sans); font-size: 13px; color: var(--ink2); margin: 0 0 8px; }

.hm-key { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; font-family: var(--sans); font-size: 12px; color: var(--ink2); margin: 0 0 10px; font-variant-numeric: tabular-nums; }
.hm-key span { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; }
.hm-key i { display: inline-block; width: 20px; height: 12px; border-radius: 2px; }

.slider-row { display: flex; flex-wrap: wrap; gap: 12px 28px; align-items: center; font-family: var(--sans); font-size: 13.5px; margin: 0 0 10px; }
.slider-row label { display: inline-flex; align-items: center; gap: 10px; }
.slider-row input[type=range] { width: 130px; accent-color: var(--ink); }
.slider-row output { font-variant-numeric: tabular-nums; font-weight: 600; min-width: 1ch; }
.readout { font-family: var(--sans); font-size: 12.5px; color: var(--ink2); margin: 10px 0 0; }
.readout strong { color: var(--ink); }

.tip { position: absolute; z-index: 10; pointer-events: none; background: var(--tip); color: var(--ink); border: 1px solid var(--axis); border-radius: 8px;
  box-shadow: 0 4px 14px var(--shadow); padding: 8px 10px; font-family: var(--sans); font-size: 12px; line-height: 1.45; min-width: 170px; max-width: 290px;
  font-variant-numeric: tabular-nums; opacity: 0; transition: opacity .08s; }
.tip b { display: block; font-weight: 600; margin-bottom: 4px; }
.tip .row { display: flex; align-items: center; gap: 6px; }
.tip .row i { font-style: normal; margin-left: auto; padding-left: 12px; }
.tip .row.off { color: var(--muted); }

/* loss table */
table.losses { border-collapse: collapse; width: 100%; margin: 16px 0 8px; color: var(--ink); }
table.losses th { font-family: var(--sans); font-size: 12px; font-weight: 600; color: var(--ink); text-align: left; padding: 6px 12px 6px 0; border-bottom: 1px solid var(--axis); }
table.losses td { padding: 9px 12px 9px 0; border-bottom: 1px solid var(--grid); vertical-align: middle; }
table.losses tr:last-child td { border-bottom: 0; }
table.losses td:first-child { font-family: var(--sans); font-size: 13.5px; white-space: nowrap; width: 1%; padding-right: 22px; }
table.losses td:last-child { font-size: 15px; overflow-x: auto; }
.katex { font-size: 1.06em; }
.eq { margin: 2px 0 6px; overflow-x: auto; overflow-y: hidden; }
.eq .katex-display { margin: .7em 0; }
/* the one symbol that differs between the wanted and the computed gradient: q blue and p black, as in the figure below; red is kept for the mismatch */
.katex .tq, .katex .tp { font-weight: 700; padding: 0 2px; border-radius: 3px; background: color-mix(in srgb, currentColor 14%, transparent); }
.katex .tq { color: var(--accent); }
.katex .tp { color: var(--ink); }
.note { font-size: 14.5px; color: var(--ink2); }

details { font-family: var(--sans); font-size: 14px; margin: 18px auto; }
details > summary { cursor: pointer; font-weight: 600; color: var(--ink); }
details[open] > summary { margin-bottom: 10px; }
details p, details li { font-family: var(--serif); font-size: 15.5px; }

table.data { border-collapse: collapse; font-family: var(--sans); font-size: 13px; font-variant-numeric: tabular-nums; width: 100%; margin: 6px 0 4px; }
table.data th, table.data td { text-align: left; padding: 6px 10px; border-bottom: 1px solid var(--grid); white-space: nowrap; }
table.data th { font-weight: 500; color: var(--ink2); border-bottom-color: var(--axis); }
table.data td.num, table.data th.num { text-align: right; }
table.data td.bad { color: var(--bad); }
details table.data th, details table.data td { padding: 6px 7px; font-size: 12.5px; }

ol.refs { font-size: 14.5px; line-height: 1.5; padding-left: 26px; }
ol.refs li { margin: 8px 0; }
.cite pre { font-family: var(--mono); font-size: 12.5px; white-space: pre; overflow-x: auto; background: var(--panel); border-radius: 8px; padding: 12px; margin: 0; }
footer { font-family: var(--sans); font-size: 13px; color: var(--muted); border-top: 1px solid var(--rule); margin-top: 56px; padding-top: 16px; }
footer a { color: var(--ink2); }

/* chart text */
.ax text, .lbl { fill: var(--muted); font-size: 10.5px; }
.ax line, .ax path { stroke: var(--axis); }
.gridline { stroke: var(--grid); }
.ttl { fill: var(--ink); font-size: 12.5px; font-weight: 500; }
.sub { fill: var(--ink2); font-size: 11.5px; }
.ink { fill: var(--ink); }
.ink2 { fill: var(--ink2); }
.panel-bg { fill: none; stroke: none; }
@media (max-width: 600px) { body { font-size: 16px; } h2 { font-size: 21px; } }

/* Figure 4 is a small table-like heatmap: draw it at its own size, centred */
#fig-gap .scroll > .chart { min-width: 560px; max-width: 660px; margin: 0 auto; }

/* Figures 6 and 7: the chart is wider than the text and centred; title, controls and caption stay on the text column */
figure.xwide { max-width: min(960px, calc(100% - 32px)); }
figure.xwide > :not(.scroll) { max-width: 680px; margin-left: auto; margin-right: auto; }
.side-toc { transition: opacity .2s ease; }
.side-toc.covered { opacity: 0; pointer-events: none; }
ul.corrections { margin-top: 18px; }

/* Figure 8 (async curves): five panels, so it gets more width; its legend stays on one line */
#fig-async { max-width: min(1120px, calc(100% - 32px)); }
#as-legend { flex-wrap: nowrap; gap: 4px 12px; white-space: nowrap; }
@media (max-width: 720px) { #as-legend { flex-wrap: wrap; } }

/* Figure 2 legend: small drawn glyphs next to their meaning */
.legend .lg { display: inline-flex; align-items: center; gap: 6px; }
.legend .lg svg { flex: none; }
