:root {
  color-scheme: light;
  --ink: #182337;
  --muted: #4b5d73;
  --paper: #fff;
  --line: #dbe3ee;
  --surface: #f7f9fc;
  --blue: #214caa;
  --blue-dark: #1c408d;
  --blue-pale: #ecf2ff;
  --green: #175943;
  --green-pale: #e9f6ef;
  --red: #8b2e3f;
  --red-pale: #fff0f1;
  --sans: Inter, ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: 'Cascadia Code', Consolas, 'SFMono-Regular', monospace;
  font-family: var(--sans);
  font-size: 100%;
  line-height: 1.5;
  background: var(--paper);
  color: var(--ink);
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; }
button, select, input { font: inherit; color: inherit; }
button, select { cursor: pointer; }
button { line-height: 1.25; }
a { color: var(--blue-dark); text-underline-offset: .18em; }
a:hover { color: var(--ink); }
:focus-visible { outline: 3px solid #2460dd; outline-offset: 3px; }
[hidden] { display: none !important; }

.skip { position: absolute; left: 1rem; top: -5rem; background: white; padding: .65rem 1rem; z-index: 2; }
.skip:focus { top: 1rem; }
.hero { max-width: 69rem; margin: 0 auto; text-align: center; padding: 3.7rem 1.25rem 2.65rem; }
.hero h1 { margin: 0; color: #152034; font-size: clamp(2.3rem, 6vw, 4rem); line-height: 1.04; letter-spacing: -.061em; font-weight: 735; }
.authors { margin: 1.3rem 0 .18rem; font-size: .99rem; font-weight: 550; }
.affiliation { margin: 0; font-size: .9rem; color: var(--muted); }
.hero nav { display: flex; justify-content: center; flex-wrap: wrap; gap: .45rem .6rem; margin-top: 1.3rem; }
.hero nav a { font-size: .88rem; font-weight: 635; padding: .4rem .73rem; border: 1px solid var(--line); border-radius: .42rem; text-decoration: none; background: #fff; }
.hero nav a:hover { border-color: #9ab0da; background: var(--blue-pale); }

main { width: min(calc(100% - 3rem), 69rem); margin: 0 auto; }
main section { scroll-margin-top: 1.1rem; margin: 0 0 3.25rem; }
.section-heading { display: flex; justify-content: space-between; align-items: end; gap: .6rem 1.5rem; margin-bottom: .95rem; }
.section-heading h2 { font-size: clamp(1.56rem, 3vw, 2.05rem); line-height: 1.15; letter-spacing: -.037em; margin: 0 0 .32rem; }
.section-heading p { color: var(--muted); margin: 0; }
.label { flex: none; align-self: start; border-radius: 2rem; background: var(--blue-pale); color: var(--blue-dark); padding: .35rem .68rem; font-size: .81rem; font-weight: 675; }

.workbench { border: 1px solid #cdd9e8; border-radius: .85rem; background: var(--surface); padding: 1rem; box-shadow: 0 .15rem .5rem #23395609; }
.workbench-controls { display: grid; grid-template-columns: minmax(14rem, .75fr) minmax(0, 1.25fr); align-items: end; gap: .9rem 1rem; }
.control-group { display: grid; align-content: start; gap: .36rem; }
.control-group > label, .control-group > span, .guess label { font-size: .84rem; color: var(--muted); font-weight: 665; }
select { appearance: none; width: 100%; height: 2.45rem; border: 1px solid #c8d4e5; border-radius: .4rem; padding: .35rem 2rem .35rem .68rem; background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Cpath d='m5 8 5 5 5-5' fill='none' stroke='%234b5d73' stroke-width='1.8'/%3E%3C/svg%3E") no-repeat right .68rem center / 1rem; font-size: .94rem; font-weight: 550; }
.choices { display: flex; flex-wrap: wrap; gap: .27rem; padding: .18rem; min-height: 2.45rem; background: #e8eef6; border-radius: .42rem; }
.choices button { flex: 1 0 auto; border: 1px solid transparent; background: transparent; border-radius: .28rem; padding: .29rem .5rem; font-size: .86rem; font-weight: 630; }
.choices button:hover { background: #f4f7fc; }
.choices button[aria-pressed='true'] { background: white; color: var(--blue-dark); border-color: #c7d5e9; box-shadow: 0 1px 2px #364b7422; }
.scenario { margin: .75rem .05rem; color: var(--muted); font-size: .91rem; }

.code-panels { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .8rem; }
.code-panel { min-width: 0; margin: 0; border: 1px solid #d9e2ee; border-radius: .53rem; background: white; overflow: hidden; }
.file-bar { display: flex; align-items: baseline; gap: .15rem .65rem; justify-content: space-between; flex-wrap: wrap; min-height: 2.25rem; padding: .42rem .68rem; font-size: .83rem; border-bottom: 1px solid #e2e9f2; background: #eff3f9; }
.file-bar span { font-weight: 660; }
.file-bar code { font-size: .79rem; color: var(--muted); overflow-wrap: anywhere; }
.source { margin: 0; min-height: 9.8rem; max-height: 20rem; overflow: auto; tab-size: 4; padding: .5rem 0; font: .83rem/1.63 var(--mono); }
.source-line { min-width: max-content; display: flex; min-height: 1.4rem; padding: 0 .6rem 0 0; }
.source-line code { white-space: pre; }
.line-number { flex: 0 0 2.35rem; padding-right: .57rem; color: #5e7088; text-align: right; font-variant-numeric: tabular-nums; user-select: none; }
.cursor-line { background: #eaf1ff; color: #173b83; }
.cursor { color: #2154bc; font-weight: 750; }
.retrieved-line { background: #e9f6ef; color: #235641; }
.empty-context { display: block; padding: .4rem .75rem; color: var(--muted); font: .86rem/1.5 var(--sans); white-space: normal; }
.retrieved-choices { display: flex; max-width: 100%; overflow-x: auto; padding: .32rem; gap: .3rem; border-bottom: 1px solid var(--line); }
.retrieved-choices button { border: 1px solid var(--line); border-radius: .25rem; background: #fff; padding: .24rem .45rem; white-space: nowrap; font: .76rem/1.35 var(--mono); }
.retrieved-choices button[aria-pressed='true'] { background: var(--blue-pale); color: var(--blue-dark); border-color: #a8bfea; }
.trace { display: flex; align-items: center; gap: .5rem; margin: .62rem .05rem .76rem; font-size: .88rem; color: var(--muted); }
.trace::before { content: ''; width: .55rem; height: .55rem; flex: 0 0 .55rem; border: 1.5px solid #5378be; border-radius: 50%; }

.guess { display: flex; flex-wrap: wrap; align-items: end; gap: .55rem; margin-top: .35rem; }
.guess-field { flex: 1 1 18rem; display: grid; gap: .24rem; }
.guess input { min-width: 0; width: 100%; height: 2.55rem; border: 1px solid #cbd7e7; border-radius: .42rem; background: #fff; padding: .44rem .68rem; font: .88rem/1.25 var(--mono); }
.guess input::placeholder { color: #52637a; opacity: 1; }
.guess button { min-height: 2.55rem; border-radius: .42rem; padding: .5rem .76rem; font-size: .88rem; font-weight: 685; }
.primary { border: 1px solid var(--blue); background: var(--blue); color: #fff; }
.primary:hover { background: var(--blue-dark); }
.secondary { border: 1px solid #cbd7e7; background: white; color: var(--blue-dark); }
.secondary:hover { background: var(--blue-pale); }
.guess-result { margin: .6rem 0 0; font-size: .88rem; color: var(--blue-dark); }
.comparison { margin-top: .88rem; padding-top: .75rem; border-top: 1px solid #d9e2ee; }
.comparison-head { display: flex; align-items: baseline; flex-wrap: wrap; gap: .4rem .6rem; margin-bottom: .5rem; }
.comparison h3 { margin: 0; font-size: .99rem; }
.match { color: var(--red); background: var(--red-pale); padding: .15rem .42rem; border-radius: .3rem; font-size: .8rem; font-weight: 720; }
.match.is-match { color: var(--green); background: var(--green-pale); }
.diff { border: 1px solid var(--line); border-radius: .42rem; overflow: hidden; }
.diff-row { display: grid; grid-template-columns: 5.6rem .8rem minmax(0, 1fr); gap: .32rem; padding: .34rem .55rem; font-size: .83rem; }
.diff-row code { white-space: pre-wrap; overflow-wrap: anywhere; }
.diff-label { font-weight: 670; }
.diff-sign { font-family: var(--mono); font-weight: bold; }
.removed { background: var(--red-pale); color: var(--red); }
.success { background: var(--green-pale); color: var(--green); }
.comparison-note { margin: .45rem 0 0; color: var(--muted); font-size: .88rem; }
.caption { font-size: .86rem; color: var(--muted); margin: .65rem .07rem 0; }

.flow { display: grid; grid-template-columns: minmax(7rem, 1fr) 2rem minmax(13rem, 3.3fr) 2rem minmax(8rem, 1fr); align-items: center; gap: .35rem; }
.flow-input, .flow-output { display: grid; gap: .3rem; min-height: 5.8rem; align-content: center; padding: .7rem; border: 1px solid var(--line); border-radius: .5rem; background: var(--surface); }
.flow-output { background: var(--blue-pale); color: #183c89; border-color: #cedcf4; }
.flow strong { font-size: .94rem; line-height: 1.3; }
.flow-label { font-size: .78rem; font-weight: 650; color: var(--muted); }
.connector { position: relative; height: 1px; background: #849bbf; margin-right: .25rem; }
.connector::after { position: absolute; right: 0; top: -.2rem; content: ''; width: .4rem; height: .4rem; transform: rotate(45deg); border-top: 1px solid #849bbf; border-right: 1px solid #849bbf; }
.signals { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .45rem; }
.signals > div { display: grid; align-content: start; gap: .25rem; min-height: 6.1rem; padding: .65rem; border: 1px solid var(--line); border-radius: .45rem; }
.signals span:not(.signal-icon) { color: var(--muted); font-size: .81rem; }
.signal-icon { display: inline-block; width: .9rem; height: .9rem; position: relative; margin-bottom: .1rem; }
.signal-text { border: 1.5px solid #4671c5; border-radius: .18rem; background: repeating-linear-gradient(0deg, #f3f7ff, #f3f7ff 2px, #9eb5e8 2px, #9eb5e8 3px); }
.signal-deps { border: 1.5px solid #4671c5; border-radius: 2px; transform: rotate(45deg) scale(.8); background: #e0eaff; }
.signal-structure { border-left: 1.5px solid #4671c5; border-bottom: 1.5px solid #4671c5; background: repeating-linear-gradient(90deg, #f3f7ff, #f3f7ff 2px, #9eb5e8 2px, #9eb5e8 3px); }

.evidence-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .85rem; }
.figure-card { display: flex; flex-direction: column; min-width: 0; margin: 0; padding: .95rem; border: 1px solid var(--line); border-radius: .55rem; }
.figure-card h3 { margin: 0; font-size: 1.12rem; letter-spacing: -.015em; }
.figure-card figcaption p { margin: .12rem 0 0; font-size: .86rem; color: var(--muted); }
.bars { display: grid; gap: .63rem; align-content: start; margin: .7rem 0 .75rem; flex: 1; }
.bar-group h4 { margin: 0 0 .18rem; font-size: .86rem; }
.bar-row { display: grid; grid-template-columns: 6.3rem minmax(0, 1fr) 4rem; align-items: center; gap: .42rem; color: var(--muted); font-size: .86rem; }
.bar-row strong { text-align: right; color: var(--ink); font-variant-numeric: tabular-nums; }
.bar-row sup { line-height: 0; }
.bar-track { display: block; height: .57rem; background: #eaf0f8; border-radius: 1rem; }
.bar-track i { display: block; width: var(--amount); min-width: 2px; height: 100%; background: #2f5cbd; border-radius: inherit; }
.alternate .bar-track i { background: #708abc; }
.latency .bar-track i { background: #90a2bf; }
.latency .accent .bar-track i { background: #2f5cbd; }
.figure-foot { margin: 0; font-size: .83rem; color: var(--muted); }
.ablation-details { margin-top: .68rem; border: 1px solid var(--line); border-radius: .48rem; padding: .55rem .72rem; }
.ablation-details summary { cursor: pointer; color: var(--blue-dark); font-weight: 650; }
.ablation-table { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .88rem; margin: .7rem 0 0; }
table caption { text-align: left; font-weight: 700; margin-bottom: .26rem; }
thead { background: var(--surface); }
td, th { padding: .36rem .5rem; border-bottom: 1px solid var(--line); text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
th:first-child { text-align: left; }
tbody th { font-weight: 530; }

.papers { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 1rem; }
.papers li { display: flex; flex-wrap: wrap; align-items: baseline; gap: .22rem .6rem; border-top: 1px solid var(--line); padding: .55rem 0; }
.papers li > span { color: var(--muted); font-size: .85rem; }
.papers li a { font-weight: 665; }
.papers li a span { display: inline-block; color: var(--muted); padding-left: .45rem; font-size: .77rem; font-weight: 500; }
footer { margin: 0 auto; border-top: 1px solid var(--line); text-align: center; padding: 1rem 1rem 1.3rem; color: var(--muted); font-size: .82rem; }

@media (max-width: 52rem) {
  .flow { grid-template-columns: minmax(7rem, 1fr) 1rem minmax(13rem, 3.3fr) 1rem minmax(8rem, 1fr); }
  .signals > div { padding: .45rem; }
}

@media (max-width: 41rem) {
  .hero { padding-top: 2.25rem; padding-bottom: 1.8rem; }
  .hero-break { display: none; }
  main { width: calc(100% - 1.5rem); }
  main section { margin-bottom: 2.5rem; }
  .section-heading { flex-direction: column; align-items: start; }
  .workbench { padding: .65rem; }
  .workbench-controls, .code-panels, .evidence-grid, .papers { grid-template-columns: minmax(0, 1fr); }
  .source { min-height: 0; }
  .flow { grid-template-columns: minmax(0, 1fr); }
  .flow-input, .flow-output { min-height: 0; }
  .connector { width: 1px; height: .68rem; justify-self: center; margin: 0; }
  .connector::after { top: auto; bottom: 0; right: -.18rem; transform: rotate(135deg); }
  .signals > div { padding: .5rem; }
}

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