/* Tokens ------------------------------------------------------------------ */
:root {
  color-scheme: light;
  --paper: #fcfbf9;
  --ink: #23262b;
  --ink-2: #5b5f66;
  --ink-3: #8a8d94;
  --rule: #e3e1dc;
  --panel: #f1efea;
  --accent: #b4232c;         /* AFT, ours: the saliency red */
  --accent-soft: #f3d9d9;
  --s-clip: #0f8f7c;         /* plain CLIP */
  --s-aft: #b4232c;          /* AFT, our retrained model */
  --s-rel: #2e6bb5;          /* AFT, released checkpoint */
  --s-iou: #2e6bb5;
  --s-ge: #0f8f7c;
  --focus: #2e6bb5;

  --font: "Newsreader", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --text: 1.1875rem;   /* 19px */
  --small: 0.9375rem;  /* 15px */
  --measure: 34rem;
  --gutter: 1rem;
  --page: 74rem;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --paper: #17181b;
    --ink: #eceae4;
    --ink-2: #a7a9ae;
    --ink-3: #75787f;
    --rule: #2c2e33;
    --panel: #1f2125;
    --accent: #d9575d;
    --accent-soft: #3a2224;
    --s-clip: #2aa58f;
    --s-aft: #d9575d;
    --s-rel: #5e96dc;
    --s-iou: #5e96dc;
    --s-ge: #2aa58f;
    --focus: #5e96dc;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --paper: #17181b;
  --ink: #eceae4;
  --ink-2: #a7a9ae;
  --ink-3: #75787f;
  --rule: #2c2e33;
  --panel: #1f2125;
  --accent: #d9575d;
  --accent-soft: #3a2224;
  --s-clip: #2aa58f;
  --s-aft: #d9575d;
  --s-rel: #5e96dc;
  --s-iou: #5e96dc;
  --s-ge: #2aa58f;
  --focus: #5e96dc;
}

/* Base ---------------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font);
  font-size: var(--text);
  line-height: 1.55;
  font-optical-sizing: auto;
  font-feature-settings: "kern", "liga", "onum" 0;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
a { color: inherit; text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 0.16em; text-decoration-color: var(--ink-3); }
a:hover { text-decoration-color: var(--accent); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; border-radius: 2px; }
h1, h2, h3 { font-weight: 500; line-height: 1.15; margin: 0; text-wrap: balance; letter-spacing: -0.005em; }
h1 { font-size: clamp(2rem, 1.2rem + 3.2vw, 3.4rem); font-weight: 400; max-width: 22ch; }
h2 { font-size: clamp(1.6rem, 1.2rem + 1.4vw, 2.1rem); margin-bottom: 1.1rem; }
h3 { font-size: 1.25rem; margin-bottom: 0.45rem; }
p { margin: 0 0 1.05em; }
p:last-child { margin-bottom: 0; }
sub { font-size: 0.7em; line-height: 0; }
.var { font-style: italic; }
.num { font-variant-numeric: tabular-nums; }
.small, .hint, figcaption, .compare-note, .verdict-note, .facts, .formula-note, .explorer-ticks, .foot, .cost, .affil, .venue {
  font-size: var(--small);
  color: var(--ink-2);
}
svg text { font-family: var(--font); }

/* Page grid ----------------------------------------------------------------- */
/* One grid for everything: [gutter] text column | side column [gutter]. */
.masthead, .section, .foot {
  display: grid;
  grid-template-columns: minmax(var(--gutter), 1fr) minmax(0, var(--measure)) minmax(0, 15rem) minmax(var(--gutter), 1fr);
  column-gap: 2.5rem;
  row-gap: 0;
  align-items: start;
}
.masthead > *, .section > *, .foot > * { grid-column: 2; }
.section > .side { grid-column: 3; }
.section > .wide, .masthead > .wide { grid-column: 2 / 4; }
@media (max-width: 62rem) {
  .masthead, .section, .foot { grid-template-columns: minmax(var(--gutter), 1fr) minmax(0, var(--measure)) minmax(var(--gutter), 1fr); column-gap: 0; }
  .section > .side { grid-column: 2; margin-top: 1.25rem; }
  .section > .wide, .masthead > .wide { grid-column: 2; }
}
.text { min-width: 0; }
.section { padding: 5.5rem 0 0; }
.section:first-of-type { padding-top: 4rem; }
main { padding-bottom: 5rem; }

/* Masthead ------------------------------------------------------------------ */
.masthead { padding: 4.5rem 0 0; }
.venue { margin-bottom: 1.4rem; }
.masthead h1 { margin-bottom: 1.6rem; }
.authors { margin-bottom: 1.1rem; line-height: 1.45; }
.affil { display: inline-block; margin-top: 0.2rem; }
.links { margin-bottom: 2.4rem; display: flex; flex-wrap: wrap; gap: 0.3rem 1.4rem; }
.lede { font-size: clamp(1.25rem, 1.05rem + 0.8vw, 1.5rem); line-height: 1.42; max-width: 30em; font-style: italic; font-weight: 400; }

/* Side column ---------------------------------------------------------------- */
.side { padding-top: 0.35rem; }
.facts { margin: 0; display: grid; grid-template-columns: max-content 1fr; column-gap: 0.9rem; row-gap: 0.35rem; line-height: 1.4; }
.facts dt { color: var(--ink-3); }
.facts dd { margin: 0; color: var(--ink); }
.side-links { line-height: 1.7; }

/* Compare widget ------------------------------------------------------------- */
.compare { margin-top: 1.6rem; }
.compare-thumbs { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 1rem; }
.thumb {
  padding: 0; border: 0; background: none; cursor: pointer;
  width: 3.75rem; height: 3.75rem; border-radius: 2px; overflow: hidden;
  opacity: 0.55; transition: opacity 0.18s; position: relative;
}
.thumb img { width: 100%; height: 100%; aspect-ratio: auto; object-fit: cover; display: block; }
.thumb:hover { opacity: 0.85; }
.thumb[aria-selected="true"] { opacity: 1; box-shadow: 0 0 0 2px var(--paper), 0 0 0 4px var(--accent); }
.thumb-sep { width: 1px; background: var(--rule); align-self: stretch; margin: 0 0.35rem; }
.compare-controls { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.6rem 2.2rem; margin-bottom: 1rem; }
.prompts, .methods { display: flex; flex-wrap: wrap; gap: 0.2rem 1.1rem; align-items: baseline; }
.prompts::before { content: "Prompt"; color: var(--ink-3); font-size: var(--small); margin-right: 0.2rem; }
.methods::before { content: "Method"; color: var(--ink-3); font-size: var(--small); margin-right: 0.2rem; }
.chip {
  font: inherit; background: none; border: 0; padding: 0.1rem 0; cursor: pointer; color: var(--ink-2);
  border-bottom: 1.5px solid transparent; line-height: 1.3;
}
.chip:hover { color: var(--ink); }
.chip[aria-checked="true"] { color: var(--ink); border-bottom-color: var(--accent); }
.prompts .chip::before { content: "“"; } .prompts .chip::after { content: "”"; }
.compare-panels { display: grid; grid-template-columns: repeat(auto-fit, minmax(9.5rem, 1fr)); gap: 0.75rem; }
.panel { min-width: 0; }
.panel img { width: 100%; height: auto; aspect-ratio: 1 / 1; display: block; border-radius: 2px; background: var(--panel); object-fit: cover; }
.panel figcaption { margin-top: 0.4rem; line-height: 1.3; }
.panel .lbl { color: var(--ink); }
.panel.ours .lbl { color: var(--accent); }
.compare-note { margin-top: 0.9rem; max-width: 60ch; }
@media (max-width: 40rem) {
  .compare-panels { grid-template-columns: 1fr 1fr; }
  .formula math { font-size: 0.95em; }
}
@media (prefers-reduced-motion: no-preference) {
  .panel img.swap { animation: fadein 0.28s ease-out; }
  @keyframes fadein { from { opacity: 0.35; } to { opacity: 1; } }
}

/* Diagram -------------------------------------------------------------------- */
.diagram { margin: 2.2rem 0 0; }
.diagram figcaption { margin-top: 0.6rem; max-width: 52ch; }
.aft-diagram { width: 100%; height: auto; max-width: 48rem; display: block; color: var(--ink); }
.d-accent-stroke { stroke: var(--accent); }
.d-accent-fill { fill: var(--accent); }
.d-muted { stroke: var(--ink-3); }
.d-small { fill: var(--ink-2); font-size: 12px; }

/* Ledger of claims ------------------------------------------------------------ */
.ledger { list-style: none; margin: 2rem 0 0; padding: 0; }
.claim {
  display: grid; grid-template-columns: 11rem minmax(0, var(--measure)); column-gap: 2.5rem;
  padding: 1.6rem 0 1.9rem; border-top: 1px solid var(--rule);
}
.claim:last-child { border-bottom: 1px solid var(--rule); }
.claim-verdict { display: flex; flex-direction: column; gap: 0.3rem; padding-top: 0.25rem; }
.verdict { font-style: italic; font-size: 1.2rem; line-height: 1.25; color: var(--accent); }
.claim-body h3 { font-weight: 500; }
@media (max-width: 62rem) {
  .claim { grid-template-columns: 1fr; row-gap: 0.6rem; }
  .claim-verdict { flex-direction: row; flex-wrap: wrap; align-items: baseline; gap: 0.2rem 0.8rem; }
}

/* Dot grid (detectors) --------------------------------------------------------- */
.dots { margin: 1.3rem 0 0; display: flex; flex-wrap: wrap; gap: 1.6rem 2.2rem; }
.dots figure { margin: 0; flex: 0 1 15rem; min-width: 11rem; }
.dots svg { display: block; width: 100%; max-width: 15rem; height: auto; }
.dots figcaption { margin-top: 0.45rem; }
.dot { fill: var(--rule); }
.dot.on { fill: var(--accent); }

/* Charts ----------------------------------------------------------------------- */
.chart { margin: 1.3rem 0 0; }
.chart svg { display: block; width: 100%; height: auto; max-width: 40rem; overflow: visible; }
.chart figcaption { margin-top: 0.5rem; max-width: 52ch; }
.chart .grid line { stroke: var(--rule); stroke-width: 1; }
.chart .axis text { fill: var(--ink-2); font-size: 12px; }
.chart .lab { fill: var(--ink-2); font-size: 12px; font-variant-numeric: tabular-nums; }
.chart .lab.on { fill: var(--ink); font-weight: 500; }
.chart .baseline { stroke: var(--ink-3); stroke-width: 1; }
.chart .legend { display: flex; flex-wrap: wrap; gap: 0.3rem 1.3rem; margin-bottom: 0.7rem; font-size: var(--small); color: var(--ink-2); }
.chart .legend span::before { content: ""; display: inline-block; width: 0.7em; height: 0.7em; border-radius: 50%; margin-right: 0.4em; background: var(--sw); vertical-align: -0.02em; }
.chart .guide { stroke: var(--ink-3); stroke-dasharray: 3 3; }
.chart .series-line { fill: none; stroke-width: 2; stroke-linejoin: round; }
.chart .mark { stroke: var(--paper); stroke-width: 2; }
.chart .tip { fill: var(--ink); font-size: 12px; }

/* Formula ------------------------------------------------------------------------ */
.formula { margin: 1.4rem 0 1.4rem; padding: 1rem 1.2rem; background: var(--panel); border-radius: 3px; overflow-x: auto; }
.formula math { font-size: 1.15em; }
.formula-note { margin: 0.7rem 0 0; }

/* Explorer -------------------------------------------------------------------------- */
.explorer { margin: 1.4rem 0 2.4rem; display: grid; grid-template-columns: minmax(0, 22rem) minmax(0, 1fr); column-gap: 3rem; row-gap: 1.2rem; align-items: start; }
.explorer-control { grid-column: 1; }
.explorer-readout { grid-column: 1; }
.explorer .chart { grid-column: 2; grid-row: 1 / span 3; margin: 0; }
.explorer-cost { grid-column: 1; }
@media (max-width: 62rem) {
  .explorer { grid-template-columns: 1fr; }
  .explorer-control, .explorer-readout, .explorer .chart, .explorer-cost { grid-column: 1; grid-row: auto; }
}
.explorer-control label { display: block; margin-bottom: 0.5rem; }
input[type="range"] { width: 100%; margin: 0; accent-color: var(--accent); cursor: pointer; }
.explorer-ticks { display: flex; justify-content: space-between; padding: 0 0.3rem; margin-top: 0.15rem; font-variant-numeric: tabular-nums; }
.readout { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: 1fr auto auto; column-gap: 1rem; row-gap: 0.3rem; align-items: baseline; }
.readout .k { color: var(--ink-2); }
.readout .v { font-variant-numeric: tabular-nums; font-size: 1.35rem; line-height: 1.1; }
.readout .d { font-variant-numeric: tabular-nums; color: var(--ink-2); font-size: var(--small); min-width: 5ch; text-align: right; }
.readout .d.up { color: var(--accent); }
.readout li { display: contents; }

/* BibTeX and footer ---------------------------------------------------------------- */
.bibtex { margin-top: 1.4rem; }
.bibtex summary { cursor: pointer; color: var(--ink-2); font-size: var(--small); }
.bibtex pre { font-size: 0.82rem; line-height: 1.45; background: var(--panel); padding: 0.9rem 1rem; border-radius: 3px; overflow-x: auto; margin: 0.6rem 0 0; font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; }
.cost { margin-top: 1.2rem; }
.foot { padding: 2rem 0 3rem; border-top: 1px solid var(--rule); }
.foot p { max-width: 60ch; }
