/* TowerBridge project page: design system. Shared by every widget. Self-contained (no external requests). */
@font-face { font-family: "Source Serif 4"; src: url("../fonts/SourceSerif4-latin.woff2") format("woff2"); font-weight: 200 900; font-style: normal; font-display: swap; }
@font-face { font-family: "Source Serif 4"; src: url("../fonts/SourceSerif4-latin-italic.woff2") format("woff2"); font-weight: 200 900; font-style: italic; font-display: swap; }
@font-face { font-family: "Inter"; src: url("../fonts/Inter-latin.woff2") format("woff2"); font-weight: 100 900; font-style: normal; font-display: swap; }
@font-face { font-family: "JetBrains Mono"; src: url("../fonts/JetBrainsMono-latin.woff2") format("woff2"); font-weight: 100 800; font-style: normal; font-display: swap; }

:root {
  color-scheme: light;
  --bg: #faf8f4; --bg-2: #f3efe7; --surface: #ffffff; --surface-2: #f7f4ee;
  --ink: #15181e; --ink-2: #3a404b; --muted: #636b79; --faint: #9199a6;
  --rule: #e3ded3; --rule-2: #d3ccbd;
  /* semantic colours used by every chart and animation */
  --ours: #d95f02; --ours-soft: #fde7d3; --ours-ink: #a84600;       /* TowerBridge, mild shrink, hard-negative directions */
  --img: #2a6bd8; --img-soft: #dce8fb;                               /* image tower / image embeddings */
  --txt: #7a4bd3; --txt-soft: #e9e0fa;                               /* text tower / caption embeddings */
  --agent: #0c8f8a; --agent-soft: #d6f0ee;                           /* Astra, the LLM agent */
  --good: #1a8f5f; --good-soft: #d9f1e6;                             /* correct match, improvement */
  --bad: #cf3f57; --bad-soft: #fbe0e4;                               /* hub, hard negative, removal, degradation */
  --neutral: #8b93a1; --neutral-soft: #eceae4;                       /* zero-shot baseline, other methods */
  --shadow: 0 1px 2px rgba(20,24,30,.05), 0 8px 28px rgba(20,24,30,.07);
  --radius: 14px; --radius-sm: 9px;
  --serif: "Source Serif 4", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --sans: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --wrap: 1120px; --gutter: clamp(16px, 4vw, 40px);
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) {
  color-scheme: dark;
  --bg: #0d1015; --bg-2: #11151c; --surface: #161b23; --surface-2: #1b212b;
  --ink: #eceff4; --ink-2: #c9cfd9; --muted: #99a2b1; --faint: #6c7584;
  --rule: #262d38; --rule-2: #343c49;
  --ours: #ff8b3d; --ours-soft: #3a2415; --ours-ink: #ffb07a;
  --img: #6ea6ff; --img-soft: #172844; --txt: #b490ff; --txt-soft: #281f45;
  --agent: #3fc9c2; --agent-soft: #11302f; --good: #46c990; --good-soft: #12301f;
  --bad: #ff6f86; --bad-soft: #3a1820; --neutral: #808a9a; --neutral-soft: #222934;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 10px 30px rgba(0,0,0,.35);
} }
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0d1015; --bg-2: #11151c; --surface: #161b23; --surface-2: #1b212b;
  --ink: #eceff4; --ink-2: #c9cfd9; --muted: #99a2b1; --faint: #6c7584;
  --rule: #262d38; --rule-2: #343c49;
  --ours: #ff8b3d; --ours-soft: #3a2415; --ours-ink: #ffb07a;
  --img: #6ea6ff; --img-soft: #172844; --txt: #b490ff; --txt-soft: #281f45;
  --agent: #3fc9c2; --agent-soft: #11302f; --good: #46c990; --good-soft: #12301f;
  --bad: #ff6f86; --bad-soft: #3a1820; --neutral: #808a9a; --neutral-soft: #222934;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 10px 30px rgba(0,0,0,.35);
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 76px; -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 400 17px/1.65 var(--sans); -webkit-font-smoothing: antialiased; overflow-x: hidden; }
img, svg, canvas { max-width: 100%; display: block; }
a { color: var(--ours-ink); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--ours); }
::selection { background: var(--ours-soft); color: var(--ink); }
:focus-visible { outline: 2px solid var(--ours); outline-offset: 2px; border-radius: 4px; }
button { font: inherit; color: inherit; }
.wrap { width: min(var(--wrap), 100% - 2 * var(--gutter)); margin-inline: auto; }
.narrow { max-width: 720px; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--surface); padding: 8px 12px; border-radius: 8px; z-index: 100; }
.skip:focus { left: 12px; }

/* ---------- typography ---------- */
h1, h2, h3 { font-family: var(--serif); font-weight: 600; line-height: 1.15; letter-spacing: -0.012em; margin: 0; text-wrap: balance; }
h1 { font-size: clamp(2.2rem, 5.4vw, 4rem); letter-spacing: -0.02em; }
h2 { font-size: clamp(1.7rem, 3.4vw, 2.5rem); }
h3 { font-size: 1.22rem; line-height: 1.3; }
p { margin: 0 0 1em; text-wrap: pretty; }
.eyebrow { font: 600 0.74rem/1 var(--sans); letter-spacing: 0.14em; text-transform: uppercase; color: var(--ours-ink); margin: 0 0 14px; display: flex; align-items: center; gap: 10px; }
.eyebrow::before { content: ""; width: 26px; height: 2px; background: var(--ours); border-radius: 2px; }
.lede { font-size: clamp(1.05rem, 1.5vw, 1.2rem); color: var(--ink-2); max-width: 64ch; }
.muted { color: var(--muted); }
.small { font-size: 0.88rem; }
.num { font-family: var(--mono); font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
code, .code { font-family: var(--mono); font-size: 0.9em; }
:not(pre) > code { background: var(--surface-2); border: 1px solid var(--rule); padding: 1px 6px; border-radius: 6px; }
.c-ours { color: var(--ours-ink); } .c-img { color: var(--img); } .c-txt { color: var(--txt); } .c-agent { color: var(--agent); } .c-good { color: var(--good); } .c-bad { color: var(--bad); }
strong { font-weight: 650; }
/* inline math written in HTML: <span class="m"><i>S</i><sup>⊤</sup></span>; no math fonts required */
.m { font-family: var(--serif); font-size: 1.08em; white-space: nowrap; font-variant-numeric: lining-nums; }
.m i { font-style: italic; } .m b { font-weight: 700; font-style: normal; }
.m sub, .m sup { font-size: 0.68em; line-height: 0; }
.m-ss { display: inline-flex; flex-direction: column; vertical-align: middle; line-height: 1; font-size: 0.68em; margin-left: 1px; }
.m-ss sup, .m-ss sub { font-size: 1em; line-height: 1.05; position: static; vertical-align: baseline; }
.eq.m { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 10px 6px; white-space: normal; font-size: 1.22rem; }
.m-row { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; }
.m-op { margin: 0 4px; }
.m-under { display: inline-flex; flex-direction: column; align-items: center; line-height: 1; margin: 0 2px; }
.m-under small { font: 500 0.56em/1.2 var(--sans); color: var(--muted); margin-top: 3px; white-space: nowrap; }
.m-big { font-size: 1.25em; font-family: var(--sans); font-weight: 300; }
.m-br { font-size: 1.5em; font-weight: 200; line-height: 1; }
.m-frac { display: inline-flex; flex-direction: column; align-items: center; font-size: 0.72em; line-height: 1.05; }
.m-frac span:first-child { border-bottom: 1px solid currentColor; padding: 0 3px 1px; }

/* ---------- layout ---------- */
section { padding: clamp(64px, 9vw, 120px) 0; position: relative; }
section.alt { background: var(--bg-2); border-block: 1px solid var(--rule); }
.section-head { margin-bottom: clamp(28px, 4vw, 48px); }
.section-head .lede { margin-top: 16px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: clamp(20px, 3vw, 40px); align-items: start; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: clamp(16px, 2vw, 24px); }
.split { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); gap: clamp(24px, 4vw, 56px); align-items: start; }
.stack > * + * { margin-top: 18px; }
@media (max-width: 860px) { .grid-2, .grid-3, .split { grid-template-columns: minmax(0, 1fr); } }

/* ---------- components ---------- */
.card { background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius); padding: clamp(18px, 2.4vw, 26px); box-shadow: var(--shadow); }
.card--flat { box-shadow: none; }
.card h3 { margin-bottom: 8px; }
.card p:last-child { margin-bottom: 0; }

/* A "figure" is the standard frame of every interactive widget. */
.figure { background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; margin: 0; }
.figure__head { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center; justify-content: space-between; padding: 14px clamp(14px, 2vw, 22px); border-bottom: 1px solid var(--rule); }
.figure__title { font: 600 0.95rem/1.3 var(--sans); margin: 0; }
.figure__title small { display: block; font-weight: 400; color: var(--muted); font-size: 0.82rem; margin-top: 2px; }
.figure__body { padding: clamp(14px, 2vw, 22px); }
.figure__note { padding: 12px clamp(14px, 2vw, 22px); border-top: 1px solid var(--rule); background: var(--surface-2); color: var(--muted); font-size: 0.84rem; line-height: 1.5; }
.mount:empty { min-height: 220px; border: 1px dashed var(--rule-2); border-radius: var(--radius); }

.btn { display: inline-flex; align-items: center; gap: 8px; padding: 10px 18px; border-radius: 999px; border: 1px solid var(--rule-2); background: var(--surface); color: var(--ink); font: 600 0.92rem/1 var(--sans); text-decoration: none; cursor: pointer; transition: transform .15s ease, border-color .15s ease, background .15s ease; }
.btn:hover { border-color: var(--ours); color: var(--ink); transform: translateY(-1px); }
.btn--primary { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.btn--primary:hover { background: var(--ours); border-color: var(--ours); color: #fff; }
.btn[aria-disabled="true"] { opacity: .62; cursor: default; pointer-events: none; }
.btn .soon { font-weight: 500; font-size: 0.72rem; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.btn--primary .soon { color: inherit; opacity: .7; }
.btn--sm { padding: 7px 12px; font-size: 0.82rem; }

.chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; font: 600 0.74rem/1.2 var(--sans); background: var(--neutral-soft); color: var(--ink-2); white-space: nowrap; }
.chip--ours { background: var(--ours-soft); color: var(--ours-ink); } .chip--good { background: var(--good-soft); color: var(--good); }
.chip--bad { background: var(--bad-soft); color: var(--bad); } .chip--agent { background: var(--agent-soft); color: var(--agent); }
.chip--img { background: var(--img-soft); color: var(--img); } .chip--txt { background: var(--txt-soft); color: var(--txt); }
.dot { width: 9px; height: 9px; border-radius: 50%; background: currentColor; display: inline-block; flex: none; }

/* segmented control: <div class="seg" role="tablist"><button aria-selected="true">..</button>..</div> */
.seg { display: inline-flex; flex-wrap: wrap; background: var(--surface-2); border: 1px solid var(--rule); border-radius: 999px; padding: 3px; gap: 2px; }
.seg button { border: 0; background: transparent; padding: 7px 14px; border-radius: 999px; font: 600 0.82rem/1 var(--sans); color: var(--muted); cursor: pointer; transition: background .15s, color .15s; }
.seg button:hover { color: var(--ink); }
.seg button[aria-selected="true"], .seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.14); }

/* range slider: <input type="range" class="tb-range"> ; set --pct (0..100) from JS for the filled track */
.tb-range { -webkit-appearance: none; appearance: none; width: 100%; height: 28px; background: transparent; cursor: pointer; margin: 0; --pct: 50; }
.tb-range::-webkit-slider-runnable-track { height: 6px; border-radius: 6px; background: linear-gradient(to right, var(--ours) calc(var(--pct) * 1%), var(--rule-2) calc(var(--pct) * 1%)); }
.tb-range::-moz-range-track { height: 6px; border-radius: 6px; background: var(--rule-2); }
.tb-range::-moz-range-progress { height: 6px; border-radius: 6px; background: var(--ours); }
.tb-range::-webkit-slider-thumb { -webkit-appearance: none; width: 22px; height: 22px; margin-top: -8px; border-radius: 50%; background: var(--surface); border: 3px solid var(--ours); box-shadow: 0 2px 6px rgba(0,0,0,.2); }
.tb-range::-moz-range-thumb { width: 16px; height: 16px; border-radius: 50%; background: var(--surface); border: 3px solid var(--ours); box-shadow: 0 2px 6px rgba(0,0,0,.2); }

.stat { display: flex; flex-direction: column; gap: 4px; }
.stat__value { font: 600 clamp(1.7rem, 3.2vw, 2.5rem)/1 var(--serif); letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.stat__label { font-size: 0.84rem; color: var(--muted); line-height: 1.35; }
.readout { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; }
.readout__item { background: var(--surface-2); border: 1px solid var(--rule); border-radius: var(--radius-sm); padding: 10px 12px; }
.readout__label { font-size: 0.74rem; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; font-weight: 600; }
.readout__value { font: 600 1.3rem/1.2 var(--mono); font-variant-numeric: tabular-nums; letter-spacing: -0.03em; margin-top: 2px; }

.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 0.8rem; color: var(--muted); align-items: center; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 12px; height: 12px; border-radius: 3px; display: inline-block; background: currentColor; flex: none; }
.legend i.line { height: 3px; width: 18px; border-radius: 2px; }

.callout { border-left: 3px solid var(--ours); background: var(--ours-soft); color: var(--ink); padding: 14px 18px; border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.callout p:last-child { margin: 0; }
.callout--agent { border-color: var(--agent); background: var(--agent-soft); }
.callout--plain { border-color: var(--rule-2); background: var(--surface-2); }

.eq { overflow-x: auto; padding: 16px 18px; background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius-sm); text-align: center; font-size: 1.05rem; }
pre.codeblock { margin: 0; overflow-x: auto; padding: 16px 18px; background: #12161d; color: #e6e9ef; border-radius: var(--radius-sm); font: 400 0.82rem/1.6 var(--mono); border: 1px solid #252c38; tab-size: 4; }
pre.codeblock .k { color: #ff9d5c; } pre.codeblock .c { color: #7e8a9c; font-style: italic; } pre.codeblock .n { color: #8ec5ff; } pre.codeblock .s { color: #9fe0b5; }

table.tb-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.tb-table th { text-align: left; font: 600 0.74rem/1.3 var(--sans); letter-spacing: .06em; text-transform: uppercase; color: var(--muted); padding: 8px 10px; border-bottom: 1px solid var(--rule-2); }
.tb-table td { padding: 9px 10px; border-bottom: 1px solid var(--rule); vertical-align: middle; }
.tb-table td.num, .tb-table th.num { text-align: right; }
.tb-table tr.is-ours td { background: var(--ours-soft); font-weight: 600; }
.table-scroll { overflow-x: auto; }

/* tooltip (one shared element, positioned by TB.tip) */
.tb-tooltip { position: fixed; z-index: 60; pointer-events: none; background: var(--ink); color: var(--bg); padding: 8px 11px; border-radius: 8px; font: 500 0.8rem/1.4 var(--sans); max-width: 260px; opacity: 0; transform: translateY(4px); transition: opacity .12s, transform .12s; box-shadow: 0 6px 20px rgba(0,0,0,.25); }
.tb-tooltip.is-on { opacity: 1; transform: none; }
.tb-tooltip b { font-weight: 650; } .tb-tooltip .num { font-size: 0.86em; }

/* scroll reveal: add class="reveal"; core.js adds .is-in when the element enters the viewport */
.reveal { opacity: 0; transform: translateY(18px); transition: opacity .7s cubic-bezier(.2,.7,.2,1), transform .7s cubic-bezier(.2,.7,.2,1); transition-delay: var(--d, 0ms); }
.reveal.is-in { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) { .reveal { opacity: 1; transform: none; transition: none; } html { scroll-behavior: auto; } }
html.no-js .reveal { opacity: 1; transform: none; }

/* ---------- nav ---------- */
.nav { position: sticky; top: 0; z-index: 40; background: color-mix(in srgb, var(--bg) 86%, transparent); backdrop-filter: saturate(1.4) blur(12px); -webkit-backdrop-filter: saturate(1.4) blur(12px); border-bottom: 1px solid transparent; transition: border-color .2s; }
.nav.is-stuck { border-bottom-color: var(--rule); }
.nav__in { display: flex; align-items: center; gap: 18px; height: 60px; }
.nav__brand { display: inline-flex; align-items: center; gap: 9px; font: 650 1.05rem/1 var(--serif); color: var(--ink); text-decoration: none; margin-right: auto; }
.nav__brand img { width: 34px; height: 26px; object-fit: contain; }
.nav__links { display: flex; gap: 2px; list-style: none; margin: 0; padding: 0; }
.nav__links a { display: block; padding: 8px 11px; border-radius: 8px; color: var(--muted); text-decoration: none; font: 550 0.86rem/1 var(--sans); }
.nav__links a:hover { color: var(--ink); background: var(--surface-2); }
.nav__links a.is-active { color: var(--ink); background: var(--surface-2); }
.theme-toggle { width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--rule-2); background: var(--surface); cursor: pointer; display: grid; place-items: center; flex: none; }
.theme-toggle svg { width: 17px; height: 17px; }
.theme-toggle .moon { display: none; }
:root[data-theme="dark"] .theme-toggle .sun { display: none; } :root[data-theme="dark"] .theme-toggle .moon { display: block; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .theme-toggle .sun { display: none; } :root:not([data-theme="light"]) .theme-toggle .moon { display: block; } }
.progress { position: fixed; top: 0; left: 0; height: 2px; width: 100%; background: var(--ours); transform-origin: 0 50%; transform: scaleX(0); z-index: 50; }
@media (max-width: 900px) { .nav__links { display: none; } }

/* ---------- hero ---------- */
.hero { padding: clamp(36px, 6vw, 72px) 0 clamp(48px, 7vw, 88px); overflow: hidden; }
.hero__grid { display: grid; grid-template-columns: minmax(0, 11fr) minmax(0, 10fr); gap: clamp(24px, 4vw, 56px); align-items: center; }
.hero__status { display: inline-flex; align-items: center; gap: 8px; font: 600 0.76rem/1 var(--sans); letter-spacing: .1em; text-transform: uppercase; color: var(--muted); border: 1px solid var(--rule-2); padding: 7px 12px; border-radius: 999px; margin-bottom: 22px; background: var(--surface); }
.hero__status .dot { color: var(--ours); animation: pulse 2.4s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: .45; transform: scale(.8); } }
.hero h1 .tb { color: var(--ours); }
.hero h1 small { display: block; font: 500 clamp(1.15rem, 2.3vw, 1.7rem)/1.25 var(--serif); letter-spacing: -0.01em; color: var(--ink-2); margin-top: 14px; }
.hero__authors { margin: 22px 0 6px; font-size: 1.02rem; color: var(--ink-2); }
.hero__authors a { color: inherit; text-decoration: underline; text-decoration-color: var(--rule-2); }
.hero__affil { color: var(--muted); font-size: 0.92rem; margin: 0 0 24px; }
.hero__cta { display: flex; flex-wrap: wrap; gap: 10px; }
.hero__viz { position: relative; aspect-ratio: 1 / 0.92; width: 100%; min-height: 320px; border-radius: 20px; background: var(--surface); border: 1px solid var(--rule); box-shadow: var(--shadow); overflow: hidden; }
.hero__stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0; margin-top: clamp(32px, 5vw, 56px); border: 1px solid var(--rule); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.hero__stats .stat { padding: 20px clamp(14px, 2vw, 24px); border-left: 1px solid var(--rule); }
.hero__stats .stat:first-child { border-left: 0; }
@media (max-width: 860px) { .hero__grid { grid-template-columns: minmax(0, 1fr); } .hero__stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } .hero__stats .stat:nth-child(3) { border-left: 0; } .hero__stats .stat:nth-child(n+3) { border-top: 1px solid var(--rule); } }

/* ---------- small page-specific pieces ---------- */
.tldr { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: clamp(14px, 2vw, 22px); counter-reset: tl; }
.tldr .card { position: relative; padding-top: 46px; }
.tldr .card::before { counter-increment: tl; content: "0" counter(tl); position: absolute; top: 16px; left: clamp(18px, 2.4vw, 26px); font: 600 0.8rem/1 var(--mono); color: var(--ours-ink); letter-spacing: .04em; }
@media (max-width: 860px) { .tldr { grid-template-columns: minmax(0, 1fr); } }
.steps { list-style: none; padding: 0; margin: 0; counter-reset: st; }
.steps li { position: relative; padding: 0 0 18px 44px; counter-increment: st; }
.steps li::before { content: counter(st); position: absolute; left: 0; top: 0; width: 30px; height: 30px; border-radius: 50%; background: var(--ours-soft); color: var(--ours-ink); font: 700 0.86rem/30px var(--mono); text-align: center; }
.steps li strong { display: block; }
.paperfig { border: 1px solid var(--rule); border-radius: var(--radius); background: #fff; padding: 12px; }
.paperfig img { width: 100%; height: auto; }
.bibtex { position: relative; }
.bibtex .btn { position: absolute; top: 10px; right: 10px; background: #1d2330; color: #e6e9ef; border-color: #333c4c; }
footer { padding: 40px 0 56px; border-top: 1px solid var(--rule); color: var(--muted); font-size: 0.88rem; }
footer .wrap { display: flex; flex-wrap: wrap; gap: 10px 24px; justify-content: space-between; }
/* dev aid: ?solo=<section id> shows one section only */
html[data-solo] main > section:not(.is-solo), html[data-solo] footer { display: none; }
