:root {
  color-scheme: light;
  --bg: #ffffff;
  --surface: #ffffff;
  --panel: #f5f4f1;
  --text: #504945;
  --ink: #282828;
  --ink2: #6b6866;
  --muted: #706b63;
  --grid: #ebe9e4;
  --axis: #c8c4bd;
  --rule: rgba(11, 11, 11, .10);
  --link: #1c5cab;
  --accent: #d55e00;
  --tip: #ffffff;
  --shadow: rgba(11, 11, 11, .14);
  --c-loop: #d55e00;
  --c-naive: #777d87;
  --c-dense: #0072b2;
  --r1: #a39d94;
  --r2: #e3a67c;
  --r4: #dd7430;
  --r8: #9c3a00;
  --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;
  --cjk: Inter, "PingFang SC", "Hiragino Sans GB", "Noto Sans CJK SC", "Microsoft YaHei", system-ui, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #151514;
    --surface: #151514;
    --panel: #1f1f1d;
    --text: #cfc9c0;
    --ink: #f0efec;
    --ink2: #aaa49b;
    --muted: #908b84;
    --grid: #2a2a28;
    --axis: #45443f;
    --rule: rgba(255, 255, 255, .10);
    --link: #6da7ec;
    --accent: #f28a4a;
    --tip: #262624;
    --shadow: rgba(0, 0, 0, .5);
    --c-loop: #f28a4a;
    --c-naive: #9ba1aa;
    --c-dense: #4aa3db;
    --r1: #8d877f;
    --r2: #b9825c;
    --r4: #ee8a45;
    --r8: #ffc296;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #151514;
  --surface: #151514;
  --panel: #1f1f1d;
  --text: #cfc9c0;
  --ink: #f0efec;
  --ink2: #aaa49b;
  --muted: #908b84;
  --grid: #2a2a28;
  --axis: #45443f;
  --rule: rgba(255, 255, 255, .10);
  --link: #6da7ec;
  --accent: #f28a4a;
  --tip: #262624;
  --shadow: rgba(0, 0, 0, .5);
  --c-loop: #f28a4a;
  --c-naive: #9ba1aa;
  --c-dense: #4aa3db;
  --r1: #8d877f;
  --r2: #b9825c;
  --r4: #ee8a45;
  --r8: #ffc296;
}

* { 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;
  counter-reset: fig tab;
}
html[data-lang="en"] [lang="zh"],
html[data-lang="zh"] [lang="en"] { display: none !important; }
html[data-lang="zh"] body { font-family: var(--cjk); font-size: 16px; line-height: 1.8; }
html[data-lang="zh"] h1,
html[data-lang="zh"] h2,
html[data-lang="zh"] h3 { font-family: var(--cjk); }
html[data-lang="zh"] h2,
html[data-lang="zh"] h3,
html[data-lang="zh"] .fig-title { word-break: keep-all; overflow-wrap: anywhere; }

a {
  color: inherit;
  text-decoration: underline;
  text-decoration-color: var(--axis);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}
a:hover { text-decoration-color: var(--ink2); }
button { font: inherit; cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.topbar {
  max-width: 740px;
  margin: 0 auto;
  padding: 18px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  font-family: var(--sans);
  font-size: 14px;
}
.topbar .site {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-weight: 600;
  color: var(--ink);
  text-decoration: none;
}
.site .loop-mark {
  position: relative;
  display: inline-block;
  width: 36px;
  height: 26px;
  flex: none;
  color: #a94229;
  color: light-dark(#a94229, #ffab86);
}
.site .loop-mark::before, .site .loop-mark::after {
  content: "";
  position: absolute;
  top: -1px;
  width: 12px;
  height: 22px;
  box-sizing: content-box;
  border: 3px solid currentColor;
  border-radius: 100%;
  transform: rotate(38deg);
}
.site .loop-mark::before { left: 2px; }
.site .loop-mark::after { left: 13px; }
.topbar .tools { display: flex; align-items: center; gap: 10px; }
.topbar .theme {
  font-size: 13px;
  color: var(--ink2);
  background: none;
  border: 1px solid var(--axis);
  border-radius: 999px;
  padding: 3px 12px;
}
.lang {
  display: inline-flex;
  border: 1px solid var(--axis);
  border-radius: 999px;
  padding: 2px;
}
.lang button {
  font-size: 13px;
  color: var(--ink2);
  background: transparent;
  border: 0;
  border-radius: 999px;
  padding: 1px 10px;
}
.lang button[aria-pressed="true"] { background: var(--panel); color: var(--ink); font-weight: 500; }

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

header.post { padding: 40px 0 10px; text-align: center; }
.label {
  font-family: var(--sans);
  font-size: 11.5px;
  font-weight: 500;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--muted);
}
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 14px; }
h2 { font-size: 23px; line-height: 1.4; margin: 52px 0 12px; scroll-margin-top: 24px; }
h3 { font-size: 18px; line-height: 1.4; margin: 34px 0 8px; scroll-margin-top: 24px; }
p { margin: 0 0 18px; }
strong { color: var(--ink); font-weight: 600; }
.standfirst { font-size: 19px; line-height: 1.5; color: var(--ink); max-width: 620px; margin: 0 auto 18px; text-wrap: pretty; }
html[data-lang="zh"] .standfirst { font-size: 17.5px; line-height: 1.75; }
.byline { font-family: var(--sans); font-size: 13.5px; line-height: 1.6; color: var(--ink2); margin: 0 0 4px; }
.byline.small { font-size: 12.5px; color: var(--muted); }
.byline sup, .authors sup { font-size: .7em; }
.authors .au, .nb { white-space: nowrap; }

.tldr { border-left: 3px solid var(--accent); padding: 2px 0 2px 18px; margin: 30px auto 8px; }
.tldr .label { display: block; margin-bottom: 8px; }
.findings { list-style: none; margin: 0 0 18px; padding: 0; }
.findings li { position: relative; padding-left: 18px; margin-bottom: 10px; }
.findings li::before {
  content: "";
  position: absolute;
  left: 2px;
  top: .68em;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
}
.tldr .findings { margin-bottom: 4px; }
.task-results { margin-top: 8px; }
.task-results details { margin: 0; }
.task-results details + details { border-top: 1px solid var(--rule); }
.task-results summary { padding: 9px 0; color: var(--ink2); font-weight: 400; }
.task-results summary::marker { color: var(--accent); }
.task-results p { margin: 0 0 12px 1.1em; }

.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-bottom: 0; }
.note { font-size: 14.5px; color: var(--ink2); }
html[data-lang="zh"] .note { font-size: 14px; }

.toc {
  font-family: var(--sans);
  font-size: 14px;
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
  padding: 14px 0 6px;
  margin-top: 28px;
  margin-bottom: 8px;
}
.toc .label { display: block; margin-bottom: 6px; }
.toc ol { columns: 2; column-gap: 28px; margin: 0 0 8px; padding-left: 20px; color: var(--ink2); }
.toc li { margin-bottom: 4px; break-inside: avoid; }
.toc a { text-decoration: none; }
.toc a:hover { text-decoration: underline; }

.side-toc-wrap { display: none; }
@media (min-width: 1280px) {
  html.js .side-toc-wrap {
    display: block;
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    width: calc(50% - 340px - 56px);
    pointer-events: none;
  }
  .side-toc {
    position: sticky;
    top: 32px;
    margin-left: auto;
    width: 231px;
    padding-left: 21px;
    font-family: var(--sans);
    font-size: 13px;
    line-height: 1.4;
    max-height: calc(100vh - 48px);
    overflow-y: auto;
    pointer-events: auto;
    transition: opacity .2s, visibility .2s;
  }
  .side-toc.covered { opacity: 0; visibility: hidden; pointer-events: none; }
  .side-toc a { display: block; padding: 4px 0; color: var(--muted); text-decoration: none; }
  .side-toc a:hover { color: var(--text); }
  .side-toc a.on { color: var(--ink); }
  .toc-marker {
    position: absolute;
    left: 6px;
    top: 0;
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: var(--accent);
    transform: translateY(var(--y, 0));
    transition: transform .2s;
  }
  html.js nav.toc { display: none; }
}

figure { margin: 40px auto 36px; counter-increment: fig; }
figure.tbl { counter-increment: tab; }
figure.hero { counter-increment: none; margin-top: 26px; }
.fig-title { font-family: var(--sans); font-size: 14px; font-weight: 600; color: var(--ink); margin: 0 0 3px; line-height: 1.4; text-wrap: balance; }
.fig-sub { font-family: var(--sans); font-size: 12.5px; line-height: 1.5; color: var(--ink2); margin: 0 0 14px; }
figcaption { font-family: var(--sans); font-size: 12.5px; line-height: 1.5; color: var(--ink2); margin-top: 14px; }
html[data-lang="zh"] figcaption, html[data-lang="zh"] .fig-sub { line-height: 1.7; }
figcaption::before { content: "Figure " counter(fig) ": "; font-weight: 600; color: var(--ink); }
html[data-lang="zh"] figcaption::before { content: "图 " counter(fig) "："; }
figure.tbl figcaption::before { content: "Table " counter(tab) ": "; }
html[data-lang="zh"] figure.tbl figcaption::before { content: "表 " counter(tab) "："; }
figure.hero figcaption::before { content: none; }
figure.hero figcaption { text-align: center; }
figure.xwide { max-width: min(900px, calc(100% - 8px)); }
figure.xwide > :not(.scroll) { max-width: 680px; margin-left: auto; margin-right: auto; }

figure.hero video {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 9;
  border-radius: 10px;
  border: 1px solid var(--rule);
  background: #fdfdfd;
}

.chart svg { display: block; width: 100%; height: auto; overflow: visible; font-family: var(--sans); }
html[data-lang="zh"] .chart svg { font-family: var(--cjk); }
/* A table wider than the column scrolls sideways; a soft edge shows on the side that has more. */
.scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  background:
    linear-gradient(to right, var(--bg) 40%, transparent) left center / 34px 100% no-repeat local,
    linear-gradient(to left, var(--bg) 40%, transparent) right center / 34px 100% no-repeat local,
    linear-gradient(to right, color-mix(in srgb, var(--ink) 20%, transparent), transparent) left center / 11px 100% no-repeat scroll,
    linear-gradient(to left, color-mix(in srgb, var(--ink) 20%, transparent), transparent) right center / 11px 100% no-repeat scroll;
}
.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 20px;
  align-items: center;
  margin: 0 0 12px;
  font-family: var(--sans);
  font-size: 13px;
}
.group-label { color: var(--muted); margin-right: 4px; }
.seg { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 2px; }
.seg button {
  color: var(--ink2);
  background: transparent;
  border: 0;
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 13px;
}
.seg button:hover { color: var(--ink); }
.seg button[aria-pressed="true"] { background: var(--panel); color: var(--ink); font-weight: 500; }
.slider-row { display: inline-flex; align-items: center; gap: 10px; color: var(--ink2); }
.slider-row input[type="range"] { width: 130px; accent-color: var(--accent); }
.slider-row output { font-variant-numeric: tabular-nums; font-weight: 600; color: var(--ink); min-width: 3.2em; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 18px; font-family: var(--sans); font-size: 13px; color: var(--ink2); margin: 0 0 10px; }
.legend > span { display: inline-flex; align-items: center; gap: 7px; }
.sw { display: inline-block; width: 22px; height: 0; border-top: 2.2px solid currentColor; }
.sw.dash { border-top-style: dashed; }
.sw.dot { width: 9px; height: 9px; border: 0; border-radius: 50%; background: currentColor; }
.sw.box { width: 11px; height: 11px; border: 0; border-radius: 2px; background: currentColor; }
.k-loop { color: var(--c-loop); }
.k-naive { color: var(--c-naive); }
.k-dense { color: var(--c-dense); }
.k-ink { color: var(--ink2); }
.readout { font-family: var(--sans); font-size: 12.5px; line-height: 1.55; color: var(--ink2); margin-top: 10px; font-variant-numeric: tabular-nums; }
.readout b { color: var(--ink); font-weight: 600; }

/* chart primitives: colours come from variables so a theme change needs no redraw */
.ax text, .lbl { fill: var(--muted); font-size: 10.5px; }
.ax line, .ax path { stroke: var(--axis); fill: none; }
.gridline { stroke: var(--grid); }
.lbl-ink { fill: var(--ink); font-size: 11.5px; font-weight: 600; }
.lbl-ink2 { fill: var(--ink2); font-size: 11px; }
.lbl-cap { fill: var(--muted); font-size: 9.5px; letter-spacing: .08em; }
.st-loop { stroke: var(--c-loop); }
.st-naive { stroke: var(--c-naive); }
.st-dense { stroke: var(--c-dense); }
.st-ink { stroke: var(--ink); }
.st-axis { stroke: var(--axis); }
.fl-loop { fill: var(--c-loop); }
.fl-naive { fill: var(--c-naive); }
.fl-dense { fill: var(--c-dense); }
.fl-ink { fill: var(--ink); }
.fl-bg { fill: var(--bg); }
.fl-panel { fill: var(--panel); }
.st-r1 { stroke: var(--r1); } .fl-r1 { fill: var(--r1); }
.st-r2 { stroke: var(--r2); } .fl-r2 { fill: var(--r2); }
.st-r4 { stroke: var(--r4); } .fl-r4 { fill: var(--r4); }
.st-r8 { stroke: var(--r8); } .fl-r8 { fill: var(--r8); }
.dim { opacity: .13; }
.series { transition: opacity .15s; }
.hit { fill: transparent; cursor: crosshair; }

.tip {
  position: absolute;
  z-index: 5;
  pointer-events: none;
  background: var(--tip);
  border: 1px solid var(--axis);
  border-radius: 8px;
  box-shadow: 0 4px 16px var(--shadow);
  padding: 8px 10px;
  font-family: var(--sans);
  font-size: 12px;
  line-height: 1.45;
  color: var(--ink2);
  min-width: 170px;
  max-width: 290px;
  opacity: 0;
  transition: opacity .1s;
  font-variant-numeric: tabular-nums;
}
.tip.on { opacity: 1; }
.tip b { color: var(--ink); font-weight: 600; }

table.data { border-collapse: collapse; font-family: var(--sans); font-size: 13px; font-variant-numeric: tabular-nums; width: 100%; }
html[data-lang="zh"] table.data { font-family: var(--cjk); }
table.data th, table.data td { padding: 6px 10px; border-bottom: 1px solid var(--grid); text-align: left; white-space: nowrap; }
table.data th { font-weight: 500; color: var(--ink2); border-bottom-color: var(--axis); vertical-align: bottom; }
table.data td { color: var(--text); }
table.data .num { text-align: right; }
table.data tr.ours td { color: var(--ink); font-weight: 500; }
table.data tr.ours td:first-child { box-shadow: inset 3px 0 0 var(--c-loop); }
table.data td.best { font-weight: 700; color: var(--ink); }
table.data tr.sep td { border-top: 1px solid var(--axis); }
table.data.compact th, table.data.compact td { padding: 6px 8px; }
table.data.math td { white-space: normal; }

.plot { background: #fff; border: 1px solid var(--rule); border-radius: 10px; padding: 10px; }
.plot img, .photo img { display: block; width: 100%; height: auto; }
.photo img { border-radius: 8px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid2 .plot { padding: 6px; }
.grid2.labelled .cell-label { font-family: var(--sans); font-size: 12px; color: var(--ink2); text-align: center; margin: 0 0 6px; }
.trio { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.narrow-only { display: none; }

details { font-family: var(--sans); font-size: 14px; margin: 0 0 18px; }
details summary { font-weight: 600; color: var(--ink); cursor: pointer; padding: 4px 0; }
details > *:not(summary) { margin-top: 12px; }
details figure { margin: 16px auto 20px; }
details .cap { font-size: 12.5px; line-height: 1.5; color: var(--ink2); margin: 8px 0 0; }

.tex.display { display: block; margin: 4px 0 18px; overflow-x: auto; overflow-y: hidden; padding: 2px 0; }
/* two equations on one line where they fit, one above the other where they do not */
.eqrow { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 0 2.2em; margin: calc(4px + .5em) 0 calc(18px + .5em); }
.eqrow .tex.display { margin: 0; max-width: 100%; padding: 2px 3px; }
.eqrow .katex-display { margin: .5em 0; }
.katex { font-size: 1.04em; }
table.data .katex { font-size: 1em; }

ol.recipe { padding-left: 24px; margin: 0 0 18px; }
ol.recipe li { margin-bottom: 8px; padding-left: 4px; }
ol.refs { font-size: 14.5px; line-height: 1.5; padding-left: 26px; }
html[data-lang="zh"] ol.refs { font-family: var(--serif); }
ol.refs li { margin-bottom: 7px; scroll-margin-top: 24px; }
ol.refs li:target { background: var(--panel); box-shadow: 0 0 0 6px var(--panel); border-radius: 2px; }
a.ref { text-decoration-style: dotted; }
.cite pre {
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.5;
  white-space: pre-wrap;
  background: var(--panel);
  border-radius: 8px;
  padding: 12px;
  margin: 0;
  color: var(--text);
}
footer {
  font-family: var(--sans);
  font-size: 13px;
  color: var(--muted);
  border-top: 1px solid var(--rule);
  margin-top: 56px;
  padding-top: 16px;
}

@media (max-width: 600px) {
  body { font-size: 16px; }
  html[data-lang="zh"] body { font-size: 15.5px; }
  h2 { font-size: 21px; }
  .standfirst { font-size: 17.5px; }
  .toc ol { columns: 1; }
  .topbar { padding: 14px 16px; }
  main { padding: 0 16px 64px; }
  .slider-row input[type="range"] { width: 110px; }
  .grid2, .trio { grid-template-columns: 1fr; }
  .grid2 { gap: 14px; }
  .plot .wide-only { display: none; }
  .narrow-only { display: block; }
  .narrow-only img + img { margin-top: 8px; }
  figure.xwide { max-width: 100%; }
  table.data.math { font-size: 12px; }
  table.data.math th, table.data.math td { padding: 6px 5px; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .toc-marker, .series, .tip, .side-toc { transition: none; }
}
@media print {
  .topbar .tools, html.js .side-toc-wrap, .controls { display: none; }
}

.st-bg { stroke: var(--bg); }
.halo { paint-order: stroke; stroke: var(--bg); stroke-width: 3.5px; stroke-linejoin: round; }
