:root {
  --bg: #fbfcfd;
  --fg: #1c2430;
  --muted: #586374;
  --rule: #dde3ea;
  --band: #f0f3f7;
  --accent: #2b62a6;
  --hilite: #d98a1f;
  --hilite-ink: #986116;
  --viewer: #e8ecf1;
  --btn: #1f2733;
  --btn-fg: #ffffff;
  --venue: #c62828;
  --chip: #e4e9ef;
  --code: #f4f6f9;
  --font-display: "Source Serif 4", "Iowan Old Style", Georgia, serif;
  --font-body: "Noto Sans", "Segoe UI", system-ui, -apple-system, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --col: 62rem;
  --text: 46rem;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #11151b; --fg: #e5e9ef; --muted: #9aa5b4; --rule: #29313b; --band: #171c23;
    --accent: #7fa9e2; --hilite: #f0ac4a; --hilite-ink: #f0ac4a; --viewer: #1a2028; --btn: #e5e9ef; --btn-fg: #11151b;
    --venue: #ff7a73; --chip: #232b35; --code: #171c23; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #11151b; --fg: #e5e9ef; --muted: #9aa5b4; --rule: #29313b; --band: #171c23;
  --accent: #7fa9e2; --hilite: #f0ac4a; --hilite-ink: #f0ac4a; --viewer: #1a2028; --btn: #e5e9ef; --btn-fg: #11151b;
  --venue: #ff7a73; --chip: #232b35; --code: #171c23; color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  background: var(--bg); color: var(--fg);
  font: 400 16px/1.65 var(--font-body);
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}
a { color: var(--accent); }
h1, h2, h3 { font-family: var(--font-display); font-weight: 600; text-wrap: balance; line-height: 1.2; margin: 0; }
h2 { font-size: 1.85rem; }
h3 { font-size: 1.2rem; }
p { margin: 0; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.wrap { max-width: var(--col); margin-inline: auto; }
.prose { max-width: var(--text); margin-inline: auto; }
section { padding-block: 3.5rem; }
section + section { border-top: 1px solid var(--rule); }
.band {
  background: var(--band);
  margin-left: calc(-1 * max(16px, env(safe-area-inset-left, 0px))); margin-right: calc(-1 * max(16px, env(safe-area-inset-right, 0px)));
  padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px));
}
.section-head { display: grid; gap: .6rem; text-align: center; margin-bottom: 2rem; }
.section-head p { color: var(--muted); max-width: var(--text); margin-inline: auto; }
.eyebrow { font: 500 .75rem/1 var(--font-mono); letter-spacing: .08em; text-transform: uppercase; color: var(--accent); }

.hero { text-align: center; padding-block: 3.25rem 2rem; display: grid; gap: 1.1rem; }
.hero h1 { font-size: clamp(1.9rem, 4.2vw, 2.9rem); max-width: 54rem; margin-inline: auto; }
.hero h1 em { font-style: italic; }
.authors { display: flex; flex-wrap: wrap; justify-content: center; gap: .2rem 1.1rem; font-size: 1.08rem; }
.authors sup, .contrib sup { font-size: .7em; line-height: 0; }
.affil { color: var(--muted); }
.contrib { font-size: .85rem; margin-top: .3rem; }
.venue { font-weight: 600; color: var(--venue); letter-spacing: .02em; }
.links { display: flex; flex-wrap: wrap; justify-content: center; gap: .6rem; margin-top: .4rem; }
.btn {
  display: inline-flex; align-items: center; gap: .45rem; padding: .5rem 1.05rem; border-radius: 999px;
  background: var(--btn); color: var(--btn-fg); text-decoration: none; font-weight: 500; font-size: .95rem;
  border: 1px solid var(--btn);
}
.btn[aria-disabled="true"] { background: transparent; color: var(--muted); border-color: var(--rule); cursor: default; }
.btn svg { width: 1em; height: 1em; fill: currentColor; }

figure { margin: 0; }
.teaser img { width: 100%; height: auto; display: block; border-radius: 6px; }
figcaption { color: var(--muted); font-size: .92rem; margin-top: .8rem; }
figcaption b { color: var(--fg); }

.abstract p + p { margin-top: 1rem; }
.abstract { text-align: justify; hyphens: auto; }

.tabs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .5rem; margin-bottom: 1.25rem; }
.tab {
  font: 600 .95rem/1.3 var(--font-body); color: var(--muted); background: transparent; cursor: pointer;
  border: 1px solid var(--rule); border-radius: 8px; padding: .8rem .7rem; text-align: left;
  display: grid; gap: .25rem;
}
.tab small { font-weight: 400; font-size: .8rem; }
.tab[aria-selected="true"] { color: var(--fg); border-color: var(--accent); box-shadow: inset 0 -3px 0 var(--accent); }
.tabpanel { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(0, 1fr); gap: 2rem; align-items: center; }
.tabpanel.text-only { grid-template-columns: minmax(0, 1fr); max-width: var(--text); margin-inline: auto; }
.tabpanel img { width: 100%; height: auto; border-radius: 6px; background: #fff; }
.tabpanel .copy { display: grid; gap: .8rem; }
.tabpanel .copy p { color: var(--muted); }

.bench { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 1rem; align-items: stretch; height: clamp(26rem, 70vh, 36rem); }
.stage { position: relative; background: var(--viewer); border-radius: 10px; overflow: hidden; min-height: 0; }
.stage canvas { display: block; width: 100%; height: 100%; position: absolute; inset: 0; touch-action: none; }
.stage .tip {
  position: absolute; pointer-events: none; font: 500 .78rem/1.3 var(--font-mono); padding: .3rem .5rem;
  background: var(--bg); color: var(--fg); border: 1px solid var(--rule); border-radius: 4px; white-space: nowrap;
}
.stage .status { position: absolute; left: .8rem; bottom: .7rem; font: .78rem/1.3 var(--font-mono); color: var(--muted); }
.stage .loading { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); font-size: .9rem; }
.stage .hint { position: absolute; right: .8rem; bottom: .7rem; font-size: .78rem; color: var(--muted); }
.toolbar { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; justify-content: space-between; margin-bottom: .8rem; }
.chips { display: flex; flex-wrap: wrap; gap: .4rem; }
.chip {
  font: 500 .85rem/1 var(--font-body); padding: .5rem .8rem; border-radius: 999px; cursor: pointer;
  background: var(--chip); color: var(--fg); border: 1px solid transparent;
}
.chip[aria-pressed="true"] { background: var(--btn); color: var(--btn-fg); }
.chip .n { font-family: var(--font-mono); font-size: .75rem; opacity: .7; margin-left: .25rem; }
.seg { display: inline-flex; border: 1px solid var(--rule); border-radius: 999px; overflow: hidden; }
.seg button { font: 500 .8rem/1 var(--font-body); padding: .45rem .75rem; border: 0; background: transparent; color: var(--muted); cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--hilite); color: #1c1407; }
.seg button:disabled { opacity: .45; cursor: not-allowed; }
.side { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; gap: .8rem; min-width: 0; min-height: 0; }
.side > .panel { overflow: auto; }
#surface .side { grid-template-rows: auto auto minmax(0, 1fr); }
.panel { border: 1px solid var(--rule); border-radius: 10px; padding: .9rem; min-width: 0; }
.panel h3 { font-family: var(--font-body); font-size: .8rem; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin-bottom: .6rem; font-weight: 600; }

.tree { overflow: auto; min-height: 0; font-size: .9rem; }
.tree ul { list-style: none; margin: 0; padding-left: 1rem; border-left: 1px solid var(--rule); }
.tree > ul { padding-left: 0; border-left: 0; }
.tree li { margin: .1rem 0; }
.node {
  display: inline-flex; align-items: baseline; gap: .4rem; padding: .15rem .4rem; border-radius: 4px; cursor: pointer;
  background: transparent; border: 0; color: var(--fg); font: inherit; text-align: left;
}
.node:hover { background: var(--chip); }
.node[aria-current="true"] { background: var(--hilite); color: #1c1407; }
.node .n { font: .72rem var(--font-mono); color: var(--muted); }
.node[aria-current="true"] .n { color: #3d2a08; }
.sel-list { display: flex; flex-wrap: wrap; gap: .35rem; align-items: center; }
.selchip {
  display: inline-flex; align-items: center; gap: .3rem; font: 500 .78rem/1.2 var(--font-mono);
  background: var(--hilite); color: #1c1407; border-radius: 4px; padding: .2rem .25rem .2rem .45rem;
}
.selchip button { border: 0; background: transparent; color: inherit; cursor: pointer; font: 600 .85rem/1 var(--font-body); padding: 0 .2rem; }
.sel-total { font: .78rem var(--font-mono); color: var(--muted); }
.sel-clear { font-size: .78rem; color: var(--accent); background: none; border: 0; cursor: pointer; padding: .1rem .2rem; }
.panel-head { display: flex; justify-content: space-between; align-items: baseline; gap: .5rem; }
.panel-head h3 { margin-bottom: .6rem; }
.twisty { display: inline-block; width: 1rem; color: var(--muted); cursor: pointer; border: 0; background: none; font: inherit; padding: 0; }
.more { font-size: .8rem; color: var(--accent); background: none; border: 0; cursor: pointer; padding: .1rem .4rem; }
pre.hps {
  margin: 0; font: .76rem/1.5 var(--font-mono); background: var(--code); border-radius: 6px; padding: .7rem;
  overflow: auto; max-height: 10rem; white-space: pre;
}
pre.hps .lbl { color: var(--accent); }

.control { display: grid; gap: .35rem; }
.control + .control { margin-top: .9rem; }
.control label { display: flex; justify-content: space-between; font-weight: 500; font-size: .92rem; }
.control output { font: 500 .85rem var(--font-mono); color: var(--hilite); }
.control input[type="range"] { width: 100%; accent-color: var(--hilite); }
.scale { display: flex; justify-content: space-between; font-size: .74rem; color: var(--muted); }
.actions { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: 1rem; }
.action {
  font: 500 .85rem/1 var(--font-body); padding: .55rem .85rem; border-radius: 6px; cursor: pointer;
  border: 1px solid var(--rule); background: var(--bg); color: var(--fg);
}
.formula { font: .8rem/1.6 var(--font-mono); color: var(--muted); }
.grid-out { display: none; margin-top: 1rem; }
.grid-out.on { display: block; }
.matrix { display: grid; grid-template-columns: auto repeat(4, minmax(0, 1fr)); gap: .4rem; align-items: center; }
.matrix img { width: 100%; aspect-ratio: 1; max-width: 100%; border-radius: 6px; background: var(--viewer); display: block; }
.matrix .ax { font: .74rem var(--font-mono); color: var(--muted); text-align: center; }
.matrix .ay { font: .74rem var(--font-mono); color: var(--muted); writing-mode: horizontal-tb; text-align: right; padding-right: .3rem; }

.method img { width: 100%; height: auto; border-radius: 6px; background: #fff; }
.steps { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1.25rem; margin-top: 1.5rem; }
.steps div { display: grid; gap: .35rem; }
.steps b { font-family: var(--font-display); font-size: 1.1rem; font-weight: 600; }
.steps p { color: var(--muted); font-size: .95rem; }
code { font-family: var(--font-mono); font-size: .88em; background: var(--code); padding: .05rem .3rem; border-radius: 3px; }

.tablewrap { overflow-x: auto; border: 1px solid var(--rule); border-radius: 8px; }
table { border-collapse: collapse; width: 100%; font-size: .85rem; font-variant-numeric: tabular-nums; }
th, td { padding: .45rem .55rem; text-align: right; white-space: nowrap; }
th:first-child, td:first-child { text-align: left; }
thead th { font-weight: 600; color: var(--muted); border-bottom: 1px solid var(--rule); }
thead tr:first-child th { color: var(--fg); }
tbody tr.ours { background: var(--band); }
tbody tr.ours td:first-child { font-weight: 600; }
td.best { font-weight: 700; }
td.second { text-decoration: underline; text-underline-offset: .18em; }
.grp { border-left: 1px solid var(--rule); }
.tnote { color: var(--muted); font-size: .85rem; margin-top: .6rem; }

.bib { position: relative; }
.bib pre { margin: 0; font: .82rem/1.55 var(--font-mono); background: var(--code); border-radius: 8px; padding: 1rem; overflow-x: auto; }
.copybtn { position: absolute; top: .6rem; right: .6rem; }
footer { color: var(--muted); font-size: .85rem; text-align: center; padding-block: 2.5rem; border-top: 1px solid var(--rule); }

.tag { font: 500 .72rem/1.3 var(--font-mono); letter-spacing: .06em; text-transform: uppercase; color: var(--hilite); }
.stepper { display: flex; align-items: center; gap: .6rem; }
.step-label { font: 500 .88rem/1 var(--font-mono); min-width: 7.5rem; text-align: center; }
.action:disabled { opacity: .4; cursor: default; }
.prompt-details { margin-top: 1rem; border: 1px solid var(--rule); border-radius: 10px; }
.prompt-details summary { cursor: pointer; padding: .7rem .95rem; font-weight: 600; font-size: .92rem; }
.prompt-details .kind { font: 400 .75rem var(--font-mono); color: var(--muted); margin-left: .5rem; }
.prompt-body { padding: 0 .95rem .9rem; max-height: 24rem; overflow: auto; color: var(--muted); font-size: .9rem;
  display: grid; gap: .45rem; }
.prompt-body h4 { margin: .45rem 0 0; font: 600 .88rem/1.4 var(--font-body); color: var(--fg); }
.prompt-body ul { margin: 0; padding-left: 1.2rem; }
.prompt-body img { width: min(100%, 26rem); height: auto; border-radius: 6px; background: #ffffff; }
.prompt-body .after { color: var(--fg); }
.edit-card { display: grid; gap: .65rem; align-content: start; }
.edit-card p { color: var(--muted); font-size: .93rem; }
.edit-card .instr { font: 600 1.05rem/1.4 var(--font-body); }
.edit-card img { width: 100%; max-height: 13rem; object-fit: contain; border-radius: 6px; background: #ffffff; }

.edit-count { font: 500 .93rem/1.45 var(--font-body); color: var(--muted); padding-inline: .2rem; }
.edit-count.changed { color: var(--hilite-ink); padding-left: 1.25rem; text-indent: -1.05rem; }
.edit-count .nb { white-space: nowrap; }
.edit-count .dot { display: inline-block; width: .6rem; height: .6rem; border-radius: 50%; background: var(--hilite);
  margin-right: .45rem; vertical-align: .02em; }

.gallery { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1.1rem .9rem; }
.gal-item { display: grid; gap: .45rem; align-content: start; min-width: 0; padding: 0; border: 0; background: none;
  color: inherit; font: inherit; text-align: left; cursor: pointer; }
.gal-media { display: block; aspect-ratio: 1; max-width: 100%; border-radius: 10px; overflow: hidden; background: #eef1f4;
  outline: 2px solid transparent; outline-offset: 2px; transition: outline-color .15s; }
.gal-media video { display: block; width: 100%; height: 100%; object-fit: cover; }
.gal-item:hover .gal-media { outline-color: var(--rule); }
.gal-item:focus-visible { outline: none; }
.gal-item:focus-visible .gal-media { outline-color: var(--accent); }
.gal-item[aria-pressed="true"] .gal-media { outline-color: var(--hilite); }
.gal-cap { display: grid; gap: .1rem; font-size: .92rem; line-height: 1.35; }
.gal-cap span { font: .72rem/1.35 var(--font-mono); color: var(--muted); }
.gal-prompt { grid-column: 1 / -1; }

.tables2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.5rem; align-items: start; margin-top: 2rem; }
.tables2 > div { min-width: 0; }
.tables2 h3 { margin-bottom: .7rem; }
tr.sub th { text-align: left; font: 600 .74rem/1.2 var(--font-body); letter-spacing: .06em; text-transform: uppercase; color: var(--muted);
  padding-top: .75rem; border-bottom: 1px solid var(--rule); }

@media (max-width: 860px) {
  .bench, .tabpanel { grid-template-columns: minmax(0, 1fr); }
  .bench { height: auto; }
  .stage { height: 22rem; }
  .tree { max-height: 16rem; }
  .steps { grid-template-columns: minmax(0, 1fr); }
  .gallery { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .tables2 { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 600px) {
  .tabs { grid-template-columns: minmax(0, 1fr); }
  .gallery { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; } }
