/* Fonts match the personal page: Manrope for headings, DM Sans for text. */
@font-face {
  font-family: "Manrope";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("../fonts/manrope-latin-600-normal.woff2") format("woff2");
}
@font-face {
  font-family: "Manrope";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("../fonts/manrope-latin-700-normal.woff2") format("woff2");
}
@font-face {
  font-family: "DM Sans";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("../fonts/dm-sans-latin-400-normal.woff2") format("woff2");
}
@font-face {
  font-family: "DM Sans";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("../fonts/dm-sans-latin-500-normal.woff2") format("woff2");
}
@font-face {
  font-family: "DM Sans";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("../fonts/dm-sans-latin-600-normal.woff2") format("woff2");
}

:root {
  --ink: #1e2a36;
  --body: #344452;
  --author: #3e5265;
  --aff: #5b6c7b;
  --note: #667684;
  --sup: #5f7890;
  --btn: #292d32;
  --panel: #f7f9fb;
  --panel-line: #e3eaf0;
  /* Thought colours. Textual thought stays a neutral slate so only the
     latent visual side carries colour (yellow). Both are clear of the
     token colours (gdino #F5D889, gdepth #CDC8F6, instance #F2B3AE,
     point #A9DCD4). */
  --term-text: #5b6c7b;
  --term-visual: #e8b10c;
  --display: Manrope, "Helvetica Neue", Arial, sans-serif;
  --sans: "DM Sans", "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  color: var(--body);
  background: #fff;
  font-family: var(--sans);
  font-size: 18.4px;
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }

.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 24px;
}

/* ---------- hero ---------- */
.hero {
  padding: 64px 0 8px;
  text-align: center;
}

.title {
  margin: 0 auto;
  max-width: 1040px;
  font-family: var(--display);
  color: var(--ink);
}
.title-first,
.title-second {
  display: block;
  font-size: clamp(34px, 6.2vw, 68px);
  font-weight: 700;
  line-height: 1.04;
  letter-spacing: -0.05em;
  text-wrap: balance;
}
.term-text { color: var(--term-text); }
.term-visual { color: var(--term-visual); }
/* "Multimodal": slate (textual) fading into yellow (latent visual) */
.term-multi {
  background: linear-gradient(90deg, var(--term-text) 10%, var(--term-visual) 90%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.paper-authors { margin-top: 34px; }

.author-list,
.affiliation-list,
.author-notes {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
}
.author-list {
  gap: 2px 11px;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.55;
  color: var(--author);
}
.affiliation-list {
  margin-top: 8px;
  gap: 3px 14px;
  font-size: 14px;
  line-height: 1.5;
  color: var(--aff);
}
.author-notes {
  margin-top: 5px;
  font-size: 12px;
  line-height: 1.5;
  color: var(--note);
}
sup {
  margin-left: 2px;
  font-size: 0.72em;
  line-height: 0;
  color: var(--sup);
}
.affiliation-list sup,
.author-notes sup { margin: 0 2px 0 0; }

.links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
  margin-top: 24px;
}
.btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 10px 21px;
  border-radius: 999px;
  background: var(--btn);
  color: #fff;
  font-size: 16px;
  font-weight: 600;
  line-height: 1.2;
  box-shadow: 0 2px 4px rgba(24, 35, 47, 0.094);
  transition: transform 0.15s ease, background 0.15s ease;
}
.btn:hover { background: #000; transform: translateY(-1px); }
.btn svg { width: 17px; height: 17px; }
.btn.disabled { opacity: 0.45; pointer-events: none; }

/* ---------- corner logo ---------- */
.monogram {
  position: fixed;
  top: 18px;
  left: 22px;
  z-index: 50;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: var(--ink);
  font-family: var(--display);
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -0.03em;
}
.monogram .logo {
  height: 22px;
  width: auto;
  transition: transform 0.3s cubic-bezier(.2, .8, .2, 1);
}
.monogram:hover .logo { transform: rotate(-8deg); }

/* ---------- reveal (as on the personal page) ---------- */
.reveal {
  opacity: 0;
  transform: translateY(24px) scale(0.99);
  transition: opacity 700ms ease, transform 700ms cubic-bezier(0.2, 0.8, 0.2, 1);
  transition-delay: var(--d, 0ms);
}
.reveal.visible {
  opacity: 1;
  transform: none;
}
@media (prefers-reduced-motion: reduce) {
  .reveal { opacity: 1; transform: none; transition: none; }
}

/* ---------- live demo (top of page) ---------- */
/* Token colours follow the teaser figure; module colours follow the paper figures. */
.demo {
  --gdino: #f0cf70;
  --gdepth: #a1a6f1;
  --inst1: #f39394;
  --inst2: #f5b3db;
  --inst3: #84debb;
  --special: #9aa3ab;
  --m-depth: #80b5ff;
  --m-sam: #e89a95;
  --ok: #009e73;
  position: relative;
  margin: 40px 0 64px;
  padding: 24px 24px 16px;
  background: var(--panel);
  border: 1px solid var(--panel-line);
  border-radius: 14px;
}

/* stage: image | trace | decoders */
.stage {
  display: grid;
  grid-template-columns: 24% minmax(0, 1fr) 236px;
  gap: 22px;
  padding: 18px;
  background: #fff;
  border: 1px solid var(--panel-line);
  border-radius: 12px;
  transition: opacity 320ms ease;
}
.stage.fading { opacity: 0; }

.st-media {
  margin: 0;
  align-self: start;
  aspect-ratio: 361 / 431;
  border-radius: 8px;
  overflow: hidden;
}
.st-img { display: block; width: 100%; height: 100%; object-fit: contain; }

.st-text { display: flex; flex-direction: column; min-width: 0; height: 430px; }
.st-kind {
  margin: 0 0 6px;
  font-family: var(--display);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--aff);
}
.st-q {
  margin: 0 0 10px;
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1.5;
  white-space: pre-line;
  color: var(--ink);
}
.st-trace {
  position: relative;
  flex: 1 1 0;
  min-height: 0;
  margin: 0;
  padding: 2px 10px 6px 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  font-size: 13.5px;
  line-height: 1.8;
  white-space: pre-wrap;
  color: var(--term-text);
  overflow-wrap: anywhere;
  scrollbar-width: thin;
  scrollbar-color: #cdd7e0 transparent;
  -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 18px);
  mask-image: linear-gradient(to bottom, transparent 0, #000 18px);
}
.st-trace .tag {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.86em;
  color: #9aa8b4;
}
.st-trace .elide { color: var(--ink); font-weight: 700; }
/* each streamed word fades in */
.st-trace .w { animation: word-in 420ms ease-out both; }
@keyframes word-in { from { opacity: 0; filter: blur(2px); } }
.st-trace .caret { display: none; }
.st-answer {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  padding-top: 10px;
  border-top: 1px dashed var(--panel-line);
  font-size: 15px;
  font-weight: 700;
  line-height: 1.35;
  color: var(--ink);
  opacity: 0;
  transition: opacity 400ms ease;
}
.st-answer.on { opacity: 1; }
.ans-tag {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  font-weight: 400;
  color: #9aa8b4;
}
.ans-box {
  padding: 1px 10px;
  border: 1.5px solid var(--ink);
  border-radius: 3px;
}
.ans-choice:empty { display: none; }
.ans-check {
  flex: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--ok) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M6.5 12.5l3.6 3.6 7.4-8' fill='none' stroke='%23fff' stroke-width='2.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / 16px no-repeat;
}

/* token chips: every pad is drawn, with start / end tokens in grey */
.tok {
  display: inline-block;
  width: 0.78em;
  height: 0.95em;
  margin: 0 1px;
  vertical-align: -0.14em;
  border: 1px solid rgba(30, 42, 54, 0.5);
  border-radius: 2.5px;
}
.tok.sp { background: var(--special); }
.tok.gdino { background: var(--gdino); }
.tok.gdepth { background: var(--gdepth); }
.tok.inst1 { background: var(--inst1); }
.tok.inst2 { background: var(--inst2); }
.tok.inst3 { background: var(--inst3); }
.tok-group { white-space: nowrap; }
.st-trace .tok { animation: tok-in 220ms cubic-bezier(0.2, 0.8, 0.2, 1) both; }
.st-trace.instant .tok { animation: none; }
@keyframes tok-in { from { transform: scale(0.3); opacity: 0; } }
.tok-group.sent .tok:not(.sp) { box-shadow: 0 0 0 2px rgba(30, 42, 54, 0.12); }

/* clickable token spans */
.st-trace .tok-group {
  padding: 2px 1px;
  border-radius: 4px;
  cursor: pointer;
  transition: background 150ms ease, box-shadow 150ms ease;
}
.st-trace .tok-group:hover { background: rgba(30, 42, 54, 0.07); }
.st-trace .tok-group:focus-visible { outline: none; box-shadow: 0 0 0 2px var(--aff); }
.st-trace .tok-group.focus { background: rgba(30, 42, 54, 0.1); box-shadow: 0 0 0 1.5px var(--ink); }
.tok-pop {
  position: absolute;
  z-index: 6;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 11px;
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  font-size: 12.5px;
  line-height: 1.4;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 180ms ease, transform 180ms ease;
}
.tok-pop.on { opacity: 1; transform: none; }
.tok-pop strong { font-weight: 700; }
.tok-pop span { color: #c9d3dc; }
.dec-out.focus { box-shadow: 0 0 0 3px color-mix(in srgb, var(--ink) 25%, transparent); }
.demo .dec-out .o-inst.dimmed { opacity: 0.12; }

/* decoders */
.st-dec {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding-left: 20px;
  border-left: 1px dashed var(--panel-line);
  transition: opacity 400ms ease;
}
.st-dec.idle { opacity: 0.35; }
.dec-title {
  margin: 0;
  font-family: var(--display);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--aff);
}
.dec-title span { font-family: var(--sans); font-weight: 500; text-transform: none; letter-spacing: 0; }
.dec {
  display: grid;
  grid-template-columns: 86px 1fr;
  align-items: center;
  gap: 18px;
}
.dec-box {
  position: relative;
  display: grid;
  place-items: center;
  height: 72px;
  border: 1.5px solid var(--ink);
  border-radius: 9px;
  background: color-mix(in srgb, var(--m-depth) 55%, #fff);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.25;
  text-align: center;
  color: var(--ink);
  transition: transform 250ms ease, box-shadow 250ms ease;
}
.dec-box.sam { background: color-mix(in srgb, var(--m-sam) 60%, #fff); }
.dec-box::after {
  content: "";
  position: absolute;
  top: 50%;
  right: -16px;
  width: 12px;
  border-top: 1.5px solid var(--ink);
}
.dec-box.busy {
  transform: scale(1.06);
  box-shadow: 0 0 0 5px color-mix(in srgb, var(--m-depth) 30%, transparent);
}
.dec-box.sam.busy { box-shadow: 0 0 0 5px color-mix(in srgb, var(--m-sam) 30%, transparent); }
.dec-out {
  position: relative;
  aspect-ratio: 361 / 431;
  width: 100%;
  max-width: 104px;
  border: 1.5px dashed #c5d0da;
  border-radius: 7px;
  overflow: hidden;
}
.dec-out img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 450ms ease, filter 450ms ease;
}
.dec-out.on { border-style: solid; border-color: var(--ink); }
.dec-out.on .o-depth,
.dec-out.on .o-base,
.dec-out .o-inst.on { opacity: 1; }
.dec-out .o-base { filter: brightness(0.6); }

/* chips flying from the trace into a decoder */
.flyer {
  position: absolute;
  z-index: 5;
  white-space: nowrap;
  pointer-events: none;
  font-size: 14px;
  transform-origin: 0 0;
  transition: transform 650ms cubic-bezier(0.55, 0, 0.25, 1), opacity 650ms ease;
}

/* timeline (like a Ponder scene bar) */
.timeline {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 14px;
}
.tl-play {
  flex: none;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 1px solid #cdd7e0;
  border-radius: 50%;
  background: #fff;
  color: var(--aff);
  cursor: pointer;
}
.tl-play:hover { color: var(--ink); border-color: var(--aff); }
.tl-play svg { width: 11px; height: 11px; fill: currentColor; }
.tl-play .i-play,
.tl-play[aria-pressed="true"] .i-pause { display: none; }
.tl-play[aria-pressed="true"] .i-play { display: block; }
.tl-scenes { flex: none; display: flex; gap: 6px; }
.tl-scene {
  padding: 3px 11px;
  border: 1px solid #cdd7e0;
  border-radius: 999px;
  background: #fff;
  color: var(--aff);
  font: 600 12px/1.5 var(--sans);
  cursor: pointer;
  transition: background 200ms ease, color 200ms ease, border-color 200ms ease;
}
.tl-scene:hover { color: var(--ink); }
.tl-scene[aria-selected="true"] { background: var(--btn); border-color: var(--btn); color: #fff; }
.tl-bar {
  position: relative;
  flex: 1;
  height: 8px;
  cursor: pointer;
  border-radius: 999px;
  background: #e3eaf0;
}
.tl-fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0;
  border-radius: inherit;
  background: var(--term-text);
}
.tl-ticks { position: absolute; inset: 0; }
.tl-tick {
  position: absolute;
  padding: 0;
  cursor: pointer;
  transition: transform 150ms ease;
  top: 50%;
  width: 10px;
  height: 10px;
  margin: -5px 0 0 -5px;
  border: 1.5px solid #fff;
  border-radius: 2.5px;
  box-shadow: 0 0 0 1px rgba(30, 42, 54, 0.45);
}
.tl-tick:hover,
.tl-tick:focus-visible { transform: scale(1.35); }
.tl-bar::before { content: ""; position: absolute; inset: -8px 0; }

.demo-legend {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 4px 18px;
  margin-top: 12px;
  font-size: 13px;
  line-height: 1.6;
  color: var(--aff);
}
.demo-legend .lg { display: inline-flex; align-items: center; gap: 5px; }
.demo-legend .lg-text { font-family: var(--display); font-weight: 700; color: var(--term-text); }
.demo-legend .term-text,
.demo-legend .term-visual { font-weight: 600; }
.demo-hint { width: 100%; text-align: center; font-size: 12px; color: #8a98a5; }

@media (max-width: 900px) {
  .stage { grid-template-columns: 30% minmax(0, 1fr); }
  .st-dec {
    grid-column: 1 / -1;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    padding: 14px 0 0;
    border-left: 0;
    border-top: 1px dashed var(--panel-line);
  }
  .dec-title { width: 100%; }
  .dec { flex: 1 1 220px; }
}
@media (max-width: 560px) {
  .demo { padding: 12px 10px 10px; }
  /* image | question on top, then the trace, then both decoders in one row */
  .stage {
    grid-template-columns: 34% minmax(0, 1fr);
    gap: 10px 12px;
    padding: 12px;
  }
  .st-text { display: contents; }
  .st-media { grid-column: 1; grid-row: 1 / 3; }
  .st-kind { grid-column: 2; grid-row: 1; margin: 0; font-size: 11px; }
  .st-q { grid-column: 2; grid-row: 2; margin: 0; font-size: 12.5px; align-self: start; }
  .st-trace { grid-column: 1 / -1; flex: none; height: 290px; font-size: 13px; }
  .st-answer { grid-column: 1 / -1; padding-top: 8px; min-height: 58px; font-size: 14px; }
  .st-dec {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px 14px;
    padding-top: 10px;
  }
  .dec-title { grid-column: 1 / -1; font-size: 11px; }
  .dec { grid-template-columns: 1fr 1fr; gap: 12px; }
  .dec-box { height: 52px; font-size: 11px; border-radius: 7px; }
  .dec-box::after { right: -11px; width: 8px; }
  .dec-out { max-width: none; }
  .timeline { flex-wrap: wrap; gap: 8px 10px; }
  .tl-bar { flex-basis: 100%; order: 3; }
  .demo-legend { font-size: 12px; gap: 2px 12px; }
}

@media (max-width: 760px) {
  body { font-size: 16px; }
  .hero { padding-top: 72px; }
  .monogram { position: absolute; top: 12px; left: 14px; font-size: 17px; }
  .monogram .logo { height: 19px; }
  .demo { margin-top: 28px; }
}

/* ---------- content sections ---------- */
.section {
  padding: 24px 24px 40px;
  scroll-margin-top: 24px;
}
.section-title {
  margin: 0 0 22px;
  text-align: center;
  font-family: var(--display);
  font-size: clamp(28px, 3.6vw, 40px);
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -0.04em;
  color: var(--ink);
}
.abstract {
  max-width: 860px;
  margin: 0 auto;
  font-size: 17px;
  line-height: 1.75;
  text-align: justify;
  color: var(--body);
}

.paper-figure { margin: 0; }
.figure-frame {
  padding: 24px;
  background: #fff;
  border: 1px solid var(--panel-line);
  border-radius: 10px;
}
.figure-frame img {
  display: block;
  width: 100%;
  height: auto;
}
.paper-figure figcaption {
  max-width: 960px;
  margin: 16px auto 0;
  font-size: 15px;
  line-height: 1.65;
  color: var(--aff);
}
.paper-figure figcaption strong { color: var(--ink); font-weight: 600; }

@media (max-width: 760px) {
  .abstract { font-size: 16px; text-align: left; }
  .figure-frame { padding: 10px; }
  .paper-figure figcaption { font-size: 14px; }
}

/* ---------- method animation ---------- */
/* Same panel, colours and timeline as the demo at the top. Drawn as a schematic, not a trace. */
.mth {
  --gdino: #f0cf70;
  --gdepth: #a1a6f1;
  --inst1: #f39394;
  --inst2: #f5b3db;
  --inst3: #84debb;
  --special: #9aa3ab;
  --m-dino: #eaba3e;
  --m-depth: #80b5ff;
  --m-sam: #e89a95;
  --tx: #e6ebef;
  position: relative;
  padding: 24px 24px 16px;
  background: var(--panel);
  border: 1px solid var(--panel-line);
  border-radius: 14px;
}
.mth-stage {
  padding: 22px;
  background: #fff;
  border: 1px solid var(--panel-line);
  border-radius: 12px;
}
.mth-grid {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr);
  gap: 22px;
}
.mth-input { align-self: center; }
.mth-img {
  margin: 0;
  aspect-ratio: 319 / 239;
  border: 1.5px solid var(--ink);
  border-radius: 8px;
  overflow: hidden;
  transition: box-shadow 300ms ease;
}
.mth-img img { display: block; width: 100%; height: 100%; object-fit: cover; }
.mth-q { margin: 8px 0 0; font-size: 12.5px; font-weight: 600; line-height: 1.45; color: var(--ink); }
.mth-input.lit .mth-img { box-shadow: 0 0 0 4px color-mix(in srgb, var(--ink) 14%, transparent); }
/* the scene's top area, then the chain and the VLM */
.mth-main {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-areas:
    "top"
    "stream"
    "vlm";
}
.mth-top { grid-area: top; display: grid; column-gap: 16px; align-items: center; }
.mth-top[hidden] { display: none; }
/* Stage 1: frozen teachers | loss box | trained heads */
.mth-top[data-scene="sft"] { grid-template-columns: auto minmax(0, 1fr) auto; grid-template-areas: "teach loss heads"; }
/* Stage 2: reward | quality score | text-only teacher */
.mth-top[data-scene="rl"] { grid-template-columns: 112px minmax(0, 1fr) 312px; grid-template-areas: "opd loss rew"; column-gap: 30px; align-items: stretch; }
.mth-top[data-scene="rl"] .lossrow { flex-direction: row; align-items: stretch; justify-content: space-between; gap: 18px; padding-top: 0; }
/* Stage 2: the token-level advantage box, beside the quality box. Its slots wait for a group, its score and the result. */
.mth .lb-t { flex: 1; min-width: 0; max-width: 270px; padding: 6px 12px 8px; }
.mth .tq-slots { display: flex; align-items: flex-start; justify-content: center; gap: 10px; }
.mth .tq-slot { margin: 0; text-align: center; }
.mth .tq-slot figcaption { margin-top: 4px; font-size: 10.5px; line-height: 1.3; color: var(--aff); white-space: nowrap; }
.mth .tq-slot figcaption sub { font-size: 0.75em; }
.mth .tq-in {
  display: grid;
  place-items: center;
  height: 34px;
  border: 1.5px dashed #c5d0da;
  border-radius: 7px;
  background: #fff;
  transition: border-color 250ms ease;
}
.mth .tq-grp .tq-in { width: 92px; padding: 0 4px; font-size: 9px; line-height: 1; overflow: hidden; }
.mth .tq-q .tq-in { width: 34px; border-radius: 50%; }
.mth .tq-out .tq-in { width: 34px; }
.mth .tq-slot.on .tq-in { border-style: solid; border-color: var(--ink); }
.mth .tq-op { margin-top: 8px; font-size: 15px; color: var(--aff); }
.mth .tq-in .grp { position: relative; display: inline-flex; transform-origin: 50% 100%; }
.mth .tq-in .grp .bump, .mth .tq-in .grp::after { display: none; }
/* the group sits low in its slot so its ball fits above it */
.mth .tq-grp .tq-in { align-items: end; padding-bottom: 6px; }
/* the score circle, large, filling from the bottom */
.mth .tq-in .qm.big { position: static; margin: 0; width: 24px; height: 24px; box-shadow: inset 0 0 0 1.5px var(--ink); }
.mth .tq-val.set { color: var(--ink); font-weight: 600; }
/* the result arrow, large */
.mth .tq-in .bump { position: static; margin: 0; border-left-width: 7px; border-right-width: 7px; }
.mth .tq-in .bump.up { border-bottom-width: 10px; }
.mth .tq-in .bump.down { border-top-width: 10px; }
.mth .tq-f { margin: 10px 0 0; font-size: 13px; line-height: 1.55; font-style: italic; text-align: center; color: var(--aff); white-space: nowrap; }
.mth .tq-f sub { font-size: 0.75em; }
.mth .lb-t[data-k="gdino"] { --acc: var(--gdino); }
.mth .lb-t[data-k="gdepth"] { --acc: var(--gdepth); }
.mth .lb-t[data-k="inst"] { --acc: var(--inst1); }
/* q with a tilde, drawn so it sits right over the q in any font */
.mth .qt, .mth-pop .qt { position: relative; display: inline-block; }
.mth .qt::before, .mth-pop .qt::before { content: "~"; position: absolute; left: 50%; top: -0.62em; transform: translateX(-45%); font-size: 0.85em; font-style: normal; font-weight: 500; }
.mth .qm.mth-ball {
  position: absolute;
  z-index: 6;
  right: auto;
  bottom: auto;
  margin: 0;
  pointer-events: none;
  transition: left 650ms cubic-bezier(0.55, 0, 0.25, 1), top 650ms cubic-bezier(0.55, 0, 0.25, 1),
    width 650ms cubic-bezier(0.55, 0, 0.25, 1), height 650ms cubic-bezier(0.55, 0, 0.25, 1), box-shadow 650ms ease;
}
.mth .mth-fly.qm { bottom: auto; margin-left: 0; transition: transform 650ms cubic-bezier(0.55, 0, 0.25, 1), opacity 220ms ease; }
.mth .fly-arrow.up { background: var(--ink); clip-path: polygon(50% 0, 100% 100%, 0 100%); }
.mth .fly-arrow.down { background: #9aa8b4; clip-path: polygon(0 0, 100% 0, 50% 100%); }
.mth .heads { grid-area: heads; }
.mth .teachers { grid-area: teach; }
.mth .lossrow { grid-area: loss; }
.mth .rewards { grid-area: rew; }
.mth .opd { grid-area: opd; }
.mth-stream { grid-area: stream; }
.mth-vlm { grid-area: vlm; }

.mth .side {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 10px 14px 14px;
  background: var(--panel);
  border: 1px solid var(--panel-line);
  border-radius: 12px;
}
.mth .side-label {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0 0 2px;
  font-family: var(--display);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--aff);
}
.mth .side-label svg { width: 13px; height: 13px; }
.mth .heads .side-label svg { color: #e07a3f; }
.mth .teachers .side-label svg { color: #5d9be0; }

/* one row per token family */
.mth .hrow {
  display: grid;
  grid-template-columns: 74px 78px 16px 94px;
  align-items: center;
  height: 46px;
}
.mth .tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--aff);
  transition: color 300ms ease;
}
.mth .tag .tok { width: 10px; height: 13px; }
.mth .hrow.act .tag { color: var(--ink); }
.mth .arr { position: relative; height: 1.5px; margin: 0 4px 0 3px; background: #9aa8b4; }
.mth .arr::after {
  content: "";
  position: absolute;
  right: -2px;
  top: -3.5px;
  border-top: 4px solid transparent;
  border-bottom: 4px solid transparent;
  border-left: 5px solid #9aa8b4;
}

.mth .mod {
  position: relative;
  display: grid;
  place-items: center;
  border: 1.5px solid var(--ink);
  border-radius: 9px;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.25;
  text-align: center;
  color: var(--ink);
  transition: transform 250ms ease, box-shadow 250ms ease, opacity 500ms ease;
}
.mth .proj { height: 32px; background: #f5f5f5; font-weight: 500; }
.mth .dec { height: 46px; padding: 0 8px; }
.mth .dec[data-k="gdepth"] { background: color-mix(in srgb, var(--m-depth) 30%, #fff); }
.mth .dec[data-k="inst"] { background: color-mix(in srgb, var(--m-sam) 32%, #fff); }
.mth .tch { width: 142px; height: 46px; padding: 0 12px 0 8px; }
.mth .tch[data-k="gdino"] { background: color-mix(in srgb, var(--m-dino) 55%, #fff); }
.mth .tch[data-k="gdepth"] { background: color-mix(in srgb, var(--m-depth) 55%, #fff); }
.mth .tch[data-k="inst"] { background: color-mix(in srgb, var(--m-sam) 60%, #fff); }
/* frozen: a small snowflake in the corner */
.mth .tch::after {
  content: "";
  position: absolute;
  right: 6px;
  bottom: 5px;
  width: 11px;
  height: 11px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%231e2a36' stroke-width='2.2' stroke-linecap='round'%3E%3Cpath d='M12 2v20M3.3 7l17.4 10M3.3 17L20.7 7M9 4l3 3 3-3M9 20l3-3 3 3'/%3E%3C/svg%3E") center / contain no-repeat;
  opacity: 0.5;
}
.mth .mod.busy { transform: scale(1.07); box-shadow: 0 0 0 5px color-mix(in srgb, var(--ink) 10%, transparent); }
.mth .tch[data-k="gdino"].busy { box-shadow: 0 0 0 5px color-mix(in srgb, var(--m-dino) 40%, transparent); }
.mth .tch[data-k="gdepth"].busy, .mth .dec[data-k="gdepth"].busy { box-shadow: 0 0 0 5px color-mix(in srgb, var(--m-depth) 40%, transparent); }
.mth .tch[data-k="inst"].busy, .mth .dec[data-k="inst"].busy { box-shadow: 0 0 0 5px color-mix(in srgb, var(--m-sam) 40%, transparent); }

/* the loss box: ground truth on the left, decoded on the right */
.mth .lossrow {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding-top: 30px;
}
.mth .lossbox {
  position: relative;
  padding: 8px 16px 10px;
  border: 1.5px solid var(--ink);
  border-radius: 12px;
  background: #fbfcfd;
  overflow: hidden;
  transition: box-shadow 300ms ease, opacity 500ms ease;
}
.mth .lb-name {
  margin: 0 0 6px;
  font-size: 12px;
  font-weight: 600;
  font-style: italic;
  text-align: center;
  color: var(--ink);
}
.mth .lb-slots { display: flex; align-items: center; gap: 12px; }
.mth .lb-slot { margin: 0; width: 118px; text-align: center; }
.mth .lb-img {
  position: relative;
  aspect-ratio: 239 / 179;
  border: 1.5px dashed #c5d0da;
  border-radius: 7px;
  overflow: hidden;
  background: #fff;
}
.mth .lb-img img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0; transition: opacity 350ms ease; }
.mth .lb-slot.on .lb-img { border-style: solid; border-color: var(--ink); }
.mth .lb-slot.on .lb-img img { opacity: 1; }
.mth .lb-slot figcaption { margin-top: 4px; font-size: 11px; line-height: 1.3; color: var(--aff); }
.mth .lb-vs { font-size: 12px; font-weight: 600; font-style: italic; color: #8a98a5; }
/* running: a light band sweeps across, the box glows in the family colour */
.mth .lossbox::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--acc, #fff) 45%, transparent), transparent);
  transform: translateX(-100%);
  pointer-events: none;
}
.mth .lossbox.running { box-shadow: 0 0 0 5px color-mix(in srgb, var(--acc) 40%, transparent); }
.mth .lossbox.running::after { animation: lb-sweep 800ms ease-in-out 2; }
@keyframes lb-sweep { to { transform: translateX(100%); } }
.mth .lossbox[data-k="gdino"] { --acc: var(--gdino); }
.mth .lossbox[data-k="gdepth"] { --acc: var(--gdepth); }
.mth .lossbox[data-k="inst"] { --acc: var(--inst1); }

.mth .tally { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; min-height: 26px; }
.mth .lpill {
  display: inline-block;
  padding: 2px 11px;
  border: 1.5px solid var(--ink);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  font-style: italic;
  line-height: 1.5;
  white-space: nowrap;
  color: var(--ink);
}
.mth .lpill.pop { animation: pill-in 380ms cubic-bezier(0.2, 0.8, 0.2, 1) both; }
@keyframes pill-in { from { transform: translateX(-24px) scale(0.6); opacity: 0; } }
.mth .lpill.gdino { background: color-mix(in srgb, var(--gdino) 45%, #fff); }
.mth .lpill.gdepth { background: color-mix(in srgb, var(--gdepth) 45%, #fff); }
.mth .lpill.inst { background: color-mix(in srgb, var(--inst1) 45%, #fff); }
.mth .lpill.ce { background: color-mix(in srgb, var(--term-text) 16%, #fff); }
/* token stream: the VLM's output, spread over the VLM with a stem down to it from each segment */
.mth-stream {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin: 30px 8px 16px;
  font-size: 14px;
  line-height: 1;
}
.mth .tok.tx { background: var(--tx, #e6ebef); border-color: rgba(91, 108, 123, 0.7); }
.mth .tok.off { visibility: hidden; }
.mth .tok.ell { width: auto; border: 0; background: none; font-size: 0.9em; line-height: 0.9; color: var(--aff); }
.mth .tok.pop { animation: tok-in 220ms cubic-bezier(0.2, 0.8, 0.2, 1) both; }
.mth .grp, .mth .run { position: relative; display: inline-flex; white-space: nowrap; }
.mth .grp.sent .tok:not(.sp) { box-shadow: 0 0 0 2px rgba(30, 42, 54, 0.12); }
.mth .grp::after, .mth .run::after {
  content: "";
  position: absolute;
  left: 50%;
  top: calc(100% + 3px);
  width: 1.5px;
  height: 13px;
  margin-left: -0.75px;
  background: #9aa8b4;
  opacity: 0;
  transform: scaleY(0);
  transform-origin: bottom;
  transition: opacity 200ms ease, transform 250ms ease;
}
.mth .shown::after { opacity: 1; transform: none; }
.mth .run .ce {
  position: absolute;
  left: 50%;
  bottom: 100%;
  margin-bottom: 4px;
  transform: translateX(-50%) translateY(4px);
  font-size: 10.5px;
  font-weight: 600;
  font-style: italic;
  line-height: 1.2;
  white-space: nowrap;
  color: var(--term-text);
  opacity: 0;
  transition: opacity 300ms ease, transform 300ms ease;
}
.mth .run.ce-on .ce { opacity: 1; transform: translateX(-50%); }
.mth .run.ce-on .tok { box-shadow: 0 0 0 2px color-mix(in srgb, var(--term-text) 22%, transparent); }

.mth-vlm {
  display: grid;
  place-items: center;
  width: 100%;
  height: 42px;
  border: 1.5px solid var(--ink);
  border-radius: 9px;
  background: #f4f5f6;
  font-family: var(--display);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--ink);
  transition: box-shadow 300ms ease;
}
.mth-vlm.lit { box-shadow: 0 0 0 5px color-mix(in srgb, var(--ink) 9%, transparent); }
/* inference: the training-only parts fade */
.mth .side, .mth .lossrow { transition: opacity 500ms ease; }
.mth.optional .side,
.mth.optional .lossrow { opacity: 0.3; }
.mth .dim { opacity: 0.3; }

/* Stage 2: the reward as an equation, one colour per term */
.mth .rewards { min-width: 0; }
.mth .eq { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 4px; margin: 0; }
.mth .eqo { font-size: 14px; color: var(--aff); }
.mth .eqt {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px;
  border: 1.5px solid var(--ink);
  border-radius: 7px;
  background: #fff;
  font-size: 12.5px;
  font-weight: 600;
  font-style: italic;
  color: var(--ink);
  transition: transform 250ms ease, box-shadow 250ms ease;
}
.mth .eqt sub { font-size: 0.75em; font-weight: 500; }
.mth .eqt i { width: 10px; height: 10px; border-radius: 2px; }
.mth .eqt[data-r="sum"] { background: var(--ink); color: #fff; }
.mth .eqt[data-r="pen"] { border-style: dashed; }
.mth .flash { transform: scale(1.08); box-shadow: 0 0 0 4px color-mix(in srgb, var(--ink) 12%, transparent); }
/* term colours, shared by the equation and the stacked R bars */
.mth [data-r="answer"] i, .mth .seg-answer { background: color-mix(in srgb, var(--term-text) 55%, #fff); }
.mth [data-r="gdino"] i, .mth .seg-gdino { background: var(--gdino); }
.mth [data-r="gdepth"] i, .mth .seg-gdepth { background: var(--gdepth); }
.mth [data-r="inst"] i, .mth .seg-inst { background: var(--inst1); }
.mth [data-r="pen"] i, .mth .seg-pen { background: repeating-linear-gradient(-45deg, #fff 0 3px, var(--inst1) 3px 5px); }

/* Stage 2: a small quality box */
.mth .lb-q .lb-slot { width: 78px; }
.mth .lb-q { padding: 6px 10px 8px; }
.mth .lb-q .lb-slot figcaption { font-size: 10.5px; }

/* Stage 2: text-only teacher */
.mth .opd { padding: 10px 10px 12px; }
.mth .opd .side-label { font-size: 11.5px; line-height: 1.3; }
.mth .tchr { height: 46px; padding: 0 6px; font-size: 11.5px; }
.mth .lb-k { font-style: normal; color: var(--aff); }
.mth .tchr { height: 54px; padding: 0 10px; background: color-mix(in srgb, var(--term-text) 22%, #fff); }
.mth .side-note { margin: 0; font-size: 11.5px; line-height: 1.4; color: var(--aff); }
.mth .lpill.q { background: #fff; }

/* Stage 2: several rollouts of the same question, one row each, with reward R and advantage A */
.mth-rolls { grid-area: stream; display: none; margin: 26px 0 6px; }
.mth[data-scene="rl"] .mth-rolls { display: grid; grid-template-columns: 112px minmax(0, 1fr); column-gap: 30px; align-items: end; margin-top: 18px; }
.mth .rvlm {
  display: grid;
  place-items: center;
  height: 148px;
  padding: 0 10px;
  border: 1.5px solid var(--ink);
  border-radius: 10px;
  background: #f4f5f6;
  font-family: var(--display);
  font-size: 14px;
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: -0.01em;
  text-align: center;
  color: var(--ink);
  transition: transform 250ms ease, box-shadow 250ms ease;
}
.mth .rlist { min-width: 0; }
/* an arrow from the policy to each rollout */
.mth .roll::before {
  content: "";
  position: absolute;
  left: -30px;
  top: 50%;
  width: 18px;
  height: 1.5px;
  background: #9aa8b4;
  opacity: 0;
  transition: opacity 300ms ease;
}
.mth .roll::after {
  content: "";
  position: absolute;
  left: -13px;
  top: calc(50% - 3.25px);
  border-top: 4px solid transparent;
  border-bottom: 4px solid transparent;
  border-left: 5px solid #9aa8b4;
  opacity: 0;
  transition: opacity 300ms ease;
}
.mth .roll.live::before, .mth .roll.live::after { opacity: 1; }
.mth[data-scene="rl"] .mth-stream { display: none; }
/* Stage 2 needs neither the input image nor the VLM bar */
.mth[data-scene="rl"] .mth-input,
.mth[data-scene="rl"] .mth-vlm { display: none; }
.mth[data-scene="rl"] .mth-grid { grid-template-columns: minmax(0, 1fr); }
.mth .rhead .rq { font-style: normal; font-weight: 600; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mth .rhead, .mth .roll {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 18px 190px 84px;
  column-gap: 10px;
  align-items: center;
}
.mth .rhead { margin-bottom: 12px; font-size: 11.5px; font-weight: 600; font-style: italic; color: var(--aff); }
.mth .rlist { position: relative; }
/* the frame spans the Reward and Advantage columns, from the header to the last rollout */
.mth .rabox {
  --rw: 284px;
  position: absolute;
  top: -8px;
  bottom: -6px;
  right: -8px;
  width: calc(var(--rw) + 16px);
  border: 1px solid var(--panel-line);
  border-radius: 10px;
  pointer-events: none;
}
.mth.opd-on .rabox { visibility: hidden; }
.mth .rhead span:nth-child(n + 3) { text-align: center; }
.mth .roll {
  position: relative;
  height: 34px;
  padding: 0 8px;
  margin: 0 -8px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 250ms ease, box-shadow 250ms ease, opacity 400ms ease;
}
.mth .roll:hover { background: color-mix(in srgb, var(--ink) 4%, transparent); }
.mth .roll.focus { background: color-mix(in srgb, var(--ink) 6%, transparent); box-shadow: inset 0 0 0 1.5px var(--ink); }
.mth .chain { display: flex; align-items: flex-end; gap: 4px; font-size: 12px; line-height: 1; white-space: nowrap; }
.mth .chain .grp, .mth .chain .run { position: relative; display: inline-flex; }
.mth .chain .grp::after, .mth .chain .run::after { display: none; }
.mth .verdict { font-size: 14px; font-weight: 700; text-align: center; opacity: 0; transition: opacity 300ms ease; }
.mth .verdict.right { color: #3c8d5a; }
.mth .verdict.wrong { color: #c2564f; }
.mth .roll.judged .verdict { opacity: 1; }
/* reward bar from the left, advantage bar from the middle */
.mth .rbar, .mth .abar { position: relative; height: 12px; border-radius: 3px; background: #eef2f5; }
.mth .abar::before { content: ""; position: absolute; left: 50%; top: -3px; bottom: -3px; width: 1px; background: #b6c2cc; }
.mth .rbar { overflow: hidden; height: 14px; }
.mth .rbar .seg { position: absolute; top: 0; bottom: 0; transition: width 450ms cubic-bezier(0.2, 0.8, 0.2, 1); }
.mth .rbar .seg.ghost { background: none; box-shadow: inset 0 0 0 1px #c3ccd4; border-radius: 0; }
.mth .rbar .seg + .seg { box-shadow: inset 1px 0 0 #fff; }
.mth .rbar .seg.ghost + .seg, .mth .rbar .seg + .seg.ghost { box-shadow: inset 0 0 0 1px #c3ccd4; }
.mth .abar i {
  position: absolute;
  top: 0;
  bottom: 0;
  border-radius: 3px;
  background: var(--ink);
  transition: width 500ms cubic-bezier(0.2, 0.8, 0.2, 1), left 500ms cubic-bezier(0.2, 0.8, 0.2, 1);
}
.mth .abar i { left: 50%; width: 0; }
.mth .abar i.neg { background: #9aa8b4; }
/* a group's quality score: a small circle centered above the group fills from the bottom with the score,
   and the group's pads fade when the score is low */
@property --q { syntax: "<number>"; inherits: true; initial-value: 0; }
.mth .qm {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 2px);
  width: 11px;
  height: 11px;
  margin-left: -5.5px;
  border-radius: 50%;
  background: linear-gradient(to top, var(--ink) calc(var(--q) * 100%), #fff 0);
  box-shadow: inset 0 0 0 1.5px var(--ink), 0 0 0 1.5px #fff;
  transition: --q 600ms cubic-bezier(0.2, 0.8, 0.2, 1);
}
.mth .grp { --qt: 1; }
.mth .grp .tok:not(.sp):not(.ell) { transition: opacity 600ms ease; }
.mth .grp.scored .tok:not(.sp):not(.ell) { opacity: calc(0.3 + 0.7 * var(--qt)); }

/* the quality bump on a group's start token */
.mth .bump {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 2px);
  width: 0;
  height: 0;
  margin-left: -4px;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  animation: tok-in 260ms cubic-bezier(0.2, 0.8, 0.2, 1) both;
}
.mth .bump.up { border-bottom: 6px solid var(--ink); }
.mth .bump.down { border-top: 6px solid #9aa8b4; bottom: calc(100% + 1px); }
/* distillation: the teacher guides the text tokens */
.mth .roll.kl .tok.tx { box-shadow: 0 0 0 2px color-mix(in srgb, var(--term-text) 35%, transparent); }
/* the KL tag sits over the hidden R column, outside the grid, so the row keeps its layout */
.mth .klcol { display: none; position: absolute; right: 210px; top: 50%; transform: translateY(-50%); font-size: 11.5px; font-weight: 600; font-style: italic; color: var(--term-text); }
.mth .roll.kl .klcol { display: block; }
.mth.opd-on .rbar, .mth.opd-on .abar, .mth.opd-on .verdict, .mth.opd-on .rhead span:nth-child(n + 2) { visibility: hidden; }

/* details on click */
.mth .grp, .mth .run, .mth .eqt, .mth .teachers, .mth .heads, .mth .lb-sft, .mth .lb-q, .mth .opd, .mth .rvlm, .mth-vlm, .mth .rbar, .mth .abar, .mth .rhead span { cursor: pointer; }
.mth .grp:hover .tok, .mth .run:hover .tok { box-shadow: 0 0 0 2px rgba(30, 42, 54, 0.16); }
.mth .picked { outline: 2px solid var(--ink); outline-offset: 3px; border-radius: 6px; }
.mth-pop {
  position: absolute;
  z-index: 8;
  width: 300px;
  max-width: calc(100% - 16px);
  padding: 12px 14px;
  background: #fff;
  border: 1px solid var(--panel-line);
  border-radius: 10px;
  box-shadow: 0 10px 30px rgba(30, 42, 54, 0.14);
  font-size: 13px;
  line-height: 1.5;
  color: var(--body);
}
.mth-pop[hidden] { display: none; }
.mth-pop p { margin: 0 0 6px; }
.mth-pop p:last-child { margin-bottom: 0; }
.mth-pop .pop-t { font-family: var(--display); font-size: 14px; font-weight: 700; color: var(--ink); }
.mth-pop b { color: var(--ink); }
.mth-pop .pop-other { font-size: 12px; color: var(--aff); }
.mth-pop sub { font-size: 0.72em; }
.mth-stage { position: relative; transition: height 460ms cubic-bezier(0.4, 0, 0.2, 1); }
.mth-stage.sizing { overflow: hidden; }
/* the scene change: the stage's content fades out and back in */
.mth-stage > * { transition: opacity 320ms ease; }
.mth-stage.swapping > * { opacity: 0; }
/* room above the stage for the badge */
.mth { padding-top: 56px; }
/* top-right badge: the parts can be clicked */
.mth-badge {
  position: absolute;
  z-index: 3;
  top: 14px;
  right: 24px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin: 0;
  padding: 5px 14px 5px 9px;
  border: 1px solid #cdd7e0;
  border-radius: 999px;
  background: #fff;
  font-size: 13px;
  font-weight: 600;
  color: var(--aff);
  pointer-events: none;
}
.mth-badge svg { width: 26px; height: 26px; margin: -5px 0; color: var(--ink); }
.mth-badge.nudge svg { animation: badge-nudge 1.6s ease-in-out 2; }
@keyframes badge-nudge { 0%, 100% { transform: none; } 40% { transform: translate(-2px, -2px); } 55% { transform: scale(0.85); } 70% { transform: none; } }

/* the bar: one segment per step */
.mth .tl-bar { background: none; }
.mth .tl-fill { display: none; }
.mth .tl-seg {
  position: absolute;
  top: 0;
  bottom: 0;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
}
/* the pill sits inside the segment and leaves a 4px gap before the next one */
.mth .tl-seg::before {
  content: "";
  position: absolute;
  inset: 0 4px 0 0;
  border-radius: 999px;
  background: linear-gradient(to right, var(--term-text) calc(var(--f, 0) * 100%), #e3eaf0 0);
}
.mth .tl-seg:last-child::before { right: 0; }
.mth .tl-seg:hover::before { box-shadow: inset 0 0 0 1px rgba(30, 42, 54, 0.25); }
.mth .tl-seg span {
  position: absolute;
  left: 50%;
  top: 12px;
  transform: translateX(-50%);
  font-size: 10.5px;
  font-weight: 600;
  line-height: 1;
  color: #a3b0bb;
  transition: color 200ms ease;
}
.mth .tl-seg.cur span { color: var(--ink); }
/* a few segments also carry their block's name */
.mth .tl-seg span b { margin-left: 4px; font-weight: 600; white-space: nowrap; }
.mth .tl-seg span { white-space: nowrap; }
.mth .tl-seg .short { display: none; }
.mth .timeline { margin-bottom: 14px; }

/* things in flight */
.mth-fly {
  position: absolute;
  z-index: 6;
  margin: 0;
  pointer-events: none;
  transform-origin: 0 0;
  transition: transform 650ms cubic-bezier(0.55, 0, 0.25, 1), opacity 220ms ease;
}
.mth .mth-fly.grp, .mth .mth-fly.run { position: absolute; display: inline-flex; margin: 0; font-size: 14px; line-height: 1; }
.mth .mth-fly.run { font-size: inherit; }
.mth .mth-fly.grp::after, .mth .mth-fly.run::after { display: none; }
img.mth-fly { object-fit: cover; border: 1.5px solid var(--ink); border-radius: 6px; }
.mth-fly.feat { border: 1.5px solid var(--ink); border-radius: 3px; }

.mth-step {
  display: flex;
  justify-content: center;
  align-items: baseline;
  gap: 10px;
  min-height: 3.2em;
  margin: 14px auto 0;
  max-width: 820px;
  font-size: 15px;
  line-height: 1.6;
  text-align: center;
  color: var(--body);
  transition: opacity 250ms ease;
}
.mth-step.swap { opacity: 0; }
.mth-step-n {
  flex: none;
  font-family: var(--display);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--aff);
}
.mth .tl-scene:disabled { opacity: 0.45; cursor: default; }

.mth-paper { margin-top: 14px; }
.mth-paper summary {
  width: max-content;
  margin: 0 auto;
  padding: 3px 12px;
  border: 1px solid #cdd7e0;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  color: var(--aff);
  cursor: pointer;
  list-style: none;
}
.mth-paper summary::-webkit-details-marker { display: none; }
.mth-paper summary::before { content: "+ "; }
.mth-paper[open] summary::before { content: "− "; }
.mth-paper summary:hover { color: var(--ink); border-color: var(--aff); }
.mth-paper .figure-frame { margin-top: 12px; }
/* phones and narrow windows: image and question on top, teachers | heads, then the loss box */
@media (max-width: 900px) {
  .mth { padding: 50px 10px 10px; }
  .mth-badge { top: 11px; right: 10px; }
  .mth-stage { padding: 14px 12px; }
  .mth-grid { grid-template-columns: 1fr; gap: 16px; }
  .mth-input { display: grid; grid-template-columns: 32% 1fr; gap: 12px; align-items: center; }
  .mth-q { margin: 0; }
  .mth-top { column-gap: 10px; }
  .mth-top[data-scene="sft"] { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); grid-template-areas: "teach heads" "loss loss"; }
  .mth-top[data-scene="rl"] { grid-template-columns: minmax(0, 1fr); grid-template-areas: "rew" "opd" "loss"; row-gap: 10px; column-gap: 0; }
  .mth .opd { width: auto; display: grid; grid-template-columns: auto 1fr; align-items: center; column-gap: 10px; }
  .mth .opd .side-label { grid-column: 1 / -1; }
  .mth .opd .tchr { height: 36px; padding: 0 12px; }
  .mth-top[data-scene="rl"] .lossrow { flex-direction: column; align-items: center; }
  .mth .lb-t, .mth .lb-q { max-width: none; width: 100%; box-sizing: border-box; }
  .mth .side { gap: 8px; }
  .mth .side-label { font-size: 11px; }
  .mth .teachers .side-label { justify-content: flex-start; }
  .mth .hrow { grid-template-columns: 1fr; height: 72px; gap: 4px; align-content: center; }
  .mth .hrow .tag, .mth .hrow .arr { display: none; }
  .mth .mod { font-size: 10.5px; border-radius: 8px; }
  .mth .proj { height: 26px; }
  .mth .dec { height: 36px; }
  .mth .hrow .dec { order: -1; }
  .mth .tch { width: 100%; height: 72px; padding: 0 14px 0 6px; }
  .mth .tch::after { right: 5px; bottom: 4px; width: 9px; height: 9px; }
  .mth .lossrow { padding-top: 14px; }
  .mth .lossbox { padding: 6px 10px 8px; }
  .mth .lb-slot { width: 104px; }
  .mth .tally { min-height: 56px; align-content: flex-start; }
  .mth-stream { flex-wrap: wrap; justify-content: center; gap: 24px 6px; margin: 22px 0 6px; font-size: 12px; }
  .mth .grp::after, .mth .run::after { display: none; }
  .mth .rewards, .mth .opd { width: auto; }
  .mth .rbox { padding: 0 8px; font-size: 11.5px; }
  .mth .rhead, .mth .roll { grid-template-columns: minmax(0, 1fr) 14px 60px 60px; column-gap: 6px; }
  .mth .rhead { font-size: 10.5px; }
  .mth .rabox { --rw: 126px; right: -6px; width: calc(var(--rw) + 12px); }
  .mth .rewards { max-width: none; }
  .mth .eqt { font-size: 11px; padding: 1px 6px; }
  .mth[data-scene="rl"] .mth-rolls { grid-template-columns: 1fr; row-gap: 12px; }
  .mth .rvlm { height: 36px; }
  .mth .roll::before, .mth .roll::after { display: none; }
  .mth .roll { height: auto; min-height: 30px; padding: 4px 6px; margin: 0 -6px; }
  .mth .chain { flex-wrap: wrap; gap: 3px; row-gap: 11px; font-size: 8px; padding-top: 8px; }
  .mth .klcol { right: 70px; }
  .mth .qm { width: 7px; height: 7px; margin-left: -3.5px; box-shadow: 0 0 0 1px #fff; }
  .mth .side { padding: 8px 8px 10px; }
  .mth .lpill { font-size: 11px; padding: 1px 9px; }
  .mth-vlm { height: 36px; font-size: 14px; }
  .mth-step { font-size: 14px; flex-direction: column; align-items: center; gap: 2px; min-height: 5em; }
  .mth .timeline { flex-wrap: wrap; gap: 8px 10px; }
  .mth .tl-bar { flex-basis: 100%; order: 3; }
  .mth .tl-seg .long { display: none; }
  .mth .tl-seg .short { display: inline; margin-left: 2px; }
}
.mth-pop .pop-why { padding-top: 6px; border-top: 1px solid var(--panel-line); color: var(--ink); }
