/*
 * Project page: Learning ab initio phase-field models (arXiv:2610.01432).
 * Layout follows the Hamiltonian Flow Maps project page (MIT); the stylesheet is our own.
 * System fonts only, no CDN. Light theme (the figures are drawn for a white page).
 */
:root {
  color-scheme: light;
  --ink: #1d1a1c;
  --ink-2: #4a4347;
  --muted: #6b6168;
  --line: #ebe3e7;
  --paper: #ffffff;
  --off: #fbf8f9;
  --pink: #D40054;
  --pink-deep: #b0004a;
  --pink-soft: #FFF2F7;
  --teal: #006680;
  --teal-soft: #eaf6f8;
  --orange: #E87A00;      /* Fig. 1a: the term the figure defines */
  --orange-soft: #FFF3E6;
  --blue: #16679f;
  --blue-soft: #ECF7FF;
  --green: #23803a;
  --green-soft: #F0FBF1;
  --eq-bg: #FCFAFB;
  --code-bg: #24202a;
  --radius: 12px;
  --gutter: 16px;
  --gap: 28px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --grey-filter: grayscale(1) opacity(.35);
  --fade: 140ms;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 16px/1.65 var(--font);
  overflow-x: hidden;
}
img { max-width: 100%; }
sub, sup { line-height: 0; }
a { color: var(--pink-deep); }
a:hover { color: var(--pink); }
p { margin: 0 0 1.2rem; }

.container { max-width: 1100px; margin: 0 auto; padding: 0 clamp(16px, 3vw, 24px); }
.narrow { max-width: none; margin: 0 auto; }
section { padding: clamp(48px, 7vw, 80px) 0; }
.light-bg { background: var(--off); }

h1, h2, h3, h4 { margin: 0; color: var(--ink); letter-spacing: -0.012em; line-height: 1.2; }
h2 { font-size: clamp(26px, 4vw, 34px); text-align: center; margin-bottom: 24px; }
h3 { font-size: clamp(20px, 3vw, 24px); }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* "ab initio", wherever it occurs */
.abinit {
  font-style: italic;
  color: var(--orange);
  background: var(--orange-soft);
  padding: 0 0.22em;
  border-radius: 3px;
}
h1 .abinit { padding: 0 0.16em; border-radius: 6px; }

/* ---------- hero ---------- */
.hero {
  position: relative;
  padding: clamp(40px, 7vw, 72px) 0 36px;
  text-align: center;
  background: var(--paper);
  border-bottom: 1px solid var(--line);
  overflow: hidden;
}
/* flat ab initio orange tint (option G) */
.hero::before { content: ""; position: absolute; inset: 0; z-index: 0; background: var(--orange-soft); }
.hero > .container { position: relative; z-index: 1; }
h1.title { font-size: clamp(30px, 5.2vw, 50px); margin-bottom: 12px; font-weight: 750; }
p.subtitle { font-size: clamp(17px, 2.2vw, 21px); color: var(--ink-2); font-weight: 400; max-width: 760px; margin: 0 auto 22px; }
.authors { font-size: 1.08rem; margin-bottom: 10px; }
.author { display: inline-block; margin: 0 8px; }
.affiliations { font-size: 0.9rem; color: var(--muted); margin-bottom: 26px; }
.affiliations p { margin: 0 0 2px; }

.action-buttons { display: flex; justify-content: center; gap: 12px; flex-wrap: wrap; }
.hero-group {
  display: inline-flex; align-items: stretch;
  border-radius: 999px; overflow: hidden;
  border: 1px solid var(--ink);
  background: var(--paper);
  font-size: 0.95rem;
}
.hero-group-label {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 16px; font-weight: 600; white-space: nowrap;
  background: var(--ink); color: #fff;
}
.hero-group-option {
  display: inline-flex; align-items: center; padding: 8px 16px;
  font-weight: 550; text-decoration: none; color: var(--ink);
  transition: background .15s;
}
.hero-group-option:hover { background: rgba(0,0,0,.06); color: var(--ink); }
.hero-group--paper { border-color: var(--pink); }
.hero-group--paper .hero-group-label { background: var(--pink); }
.hero-group--paper .hero-group-option { color: var(--pink-deep); }
.hero-group--paper .hero-group-option:hover { background: var(--pink-soft); }
.hero-group--run { border-color: var(--teal); background: var(--teal-soft); }
.hero-group--run .hero-group-label { background: transparent; color: var(--teal); }
a.hero-group--solo { text-decoration: none; transition: filter .15s; }
a.hero-group--solo:hover { filter: brightness(.95); }
.hero-group svg { flex: none; }

/* ---------- abstract ---------- */
#abstract .col-text { text-align: justify; hyphens: auto; }
#abstract h2 { text-align: left; }

/* ---------- "ab initio" section with the interactive figure ---------- */
#abinitio .narrow { text-align: left; }
#abinitio h2 { margin-bottom: 20px; }
.lede { margin: 0 0 28px; color: var(--ink-2); }

/* ---------- panels ---------- */
.panel { margin: 0; min-width: 0; }
.panel-head { height: 30px; display: flex; align-items: flex-end; padding-bottom: 6px; }
.panel-letter { font-weight: 700; font-size: 18px; line-height: 1; }

.stage {
  position: relative;
  width: 100%;
  background: var(--paper);
  /* aspect-ratio set inline from the SVG viewBox */
}
.stage-img, .stage-grey img {
  display: block;
  width: 100%;
  height: 100%;
  max-width: none;
}
.stage-grey {
  position: absolute;
  inset: 0;
  background: var(--paper);     /* hides the colour copy underneath */
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity var(--fade) ease, visibility 0s linear var(--fade);
}
.stage-grey img { filter: var(--grey-filter); }
.stage.is-greyed .stage-grey {
  opacity: 1;
  visibility: visible;
  transition: opacity var(--fade) ease, visibility 0s;
}

/* transparent hover zones; positioned by fig1.js from data-pt (pt in viewBox units) */
.zone {
  position: absolute;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.zone:focus { outline: none; }
.zone:focus-visible { outline: 2px solid var(--pink); outline-offset: -2px; }

.ladder-line {
  margin: 10px 0 0;
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink-2);
}

/* ---------- text / equation boxes ---------- */
.box {
  display: grid;            /* all states share one cell, so the box height is the */
  min-width: 0;             /* tallest state and nothing below it jumps on hover */
  border: 1px solid var(--line);
  border-left: 3px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 18px 16px;
  background: var(--paper);
  font-size: 15px;
  line-height: 1.6;
}
.state {
  grid-area: 1 / 1;
  min-width: 0;
  visibility: hidden;
}
.state.is-current { visibility: visible; }
.state > p { margin: 0 0 10px; }
.state > p:last-child { margin-bottom: 0; }

.box[data-tone="derivation"] { border-left-color: #3DADFF; }
.box[data-tone="learning"]   { border-left-color: #66D575; }
.box[data-tone="work"]       { border-left-color: var(--pink); }

.eyebrow {
  margin: 0 0 6px;
  font-size: 12.5px;
  font-weight: 650;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}
.state[data-state="derivation"] .eyebrow { color: var(--blue); }
.state[data-state="learning"] .eyebrow { color: var(--green); }
.state[data-tone="work"] .eyebrow { color: var(--pink); }

.badge {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--pink-soft);
  color: var(--pink);
  font-size: 11.5px;
  letter-spacing: 0.04em;
  text-transform: lowercase;
  vertical-align: 1px;
}

.eq {
  font-size: 15px;          /* 1 em = the equation's own font size */
  margin: 0 0 12px;
  padding: 10px 12px;
  background: var(--eq-bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}
.state[data-tone="work"] .eq { background: var(--pink-soft); border-color: #f6d3e1; }
.eq img { display: block; height: auto; max-width: 100%; }
.eq img + img { margin-top: 8px; }
.eq .eq-indent { margin-left: 1.2em; max-width: calc(100% - 1.2em); }

.examples-head {
  margin: 14px 0 6px !important;
  font-size: 12.5px;
  font-weight: 650;
  color: var(--muted);
}
.eq-example { margin-bottom: 8px; }
.eq-label {
  display: block;
  margin-bottom: 4px;
  font: 600 12.5px/1.3 var(--font);
  color: var(--ink-2);
}

@media (max-width: 759px) {
  .box { padding: 12px 14px 14px; }
  .eq { font-size: 14px; padding: 8px 10px; }
}

@media (prefers-reduced-motion: reduce) {
  .stage-grey, .stage.is-greyed .stage-grey { transition: none; }
}

/* ---------- method ---------- */
.section-intro { text-align: center; max-width: none; margin: 0 auto 40px; font-size: 1.06rem; color: var(--ink-2); }
.section-intro.lead-in { margin-bottom: 16px; }
.equation {
  display: flex; justify-content: center;
  background: var(--eq-bg); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 20px; max-width: 760px; margin: 0 auto 18px; overflow-x: auto;
  font-size: 16px;
}
.equation img { display: block; height: auto; max-width: 100%; }
.figure-container { text-align: center; }
.main-figure { width: 100%; height: auto; border-radius: 8px; border: 1px solid var(--line); background: #fff; }
.scroll-x { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.caption { font-size: 0.95rem; color: var(--muted); text-align: left; margin: 12px auto 0; }

/* ---------- results ---------- */
#results .section-intro { margin-bottom: 8px; }

/* one video per row, text beside it */
.dyn-row {
  display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr);
  gap: 32px; align-items: center;
  margin: 28px 0 0; padding: 20px;
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--paper);
}
.dyn-row + .dyn-row { margin-top: 24px; }
.dyn-media video { display: block; width: 100%; height: auto; border-radius: 8px; background: #fff; }
.dyn-row--portrait { grid-template-columns: minmax(0, 2fr) minmax(0, 3fr); }
.dyn-media--portrait { max-width: 420px; margin: 0 auto; }
.dyn-media--portrait video { max-height: 640px; object-fit: contain; }
.dyn-text h4 { font-size: 1.25rem; margin: 4px 0 10px; }
.dyn-text p:last-child { margin-bottom: 0; color: var(--ink-2); }

.thermo-row { display: grid; gap: 24px; margin-top: 24px; align-items: start; }
.thermo-row--two { grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); }
.thermo-row--three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.chart-card { margin: 0; padding: 16px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--paper); }
.chart-card .result-img { display: block; width: 100%; height: auto; border-radius: 6px; }
.chart-card figcaption { margin-top: 10px; font-size: 0.92rem; color: var(--muted); }
.thermo-row--three .chart-card:first-child .result-img { max-height: 320px; object-fit: contain; }
.thermo-row--three .chart-card:nth-child(2) .result-img { max-height: 320px; object-fit: contain; }
.thermo-row--three .chart-card:nth-child(3) .result-img { max-height: 320px; object-fit: contain; }

:not(pre) > code {
  font-family: var(--mono); font-size: 0.86em;
  background: #f1ecee; color: var(--ink); padding: 2px 6px; border-radius: 5px; overflow-wrap: anywhere;
}

/* ---------- resources ---------- */
.resources-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.resource-card {
  background: var(--paper); border: 1px solid var(--line); border-radius: 14px; padding: 24px;
  text-align: center;
}
.resource-card.highlight { border-color: var(--pink); box-shadow: 0 10px 30px rgba(212, 0, 84, .08); text-align: left; }
.resource-card.wide { grid-column: 1 / -1; }
.resource-title { font-weight: 700; font-size: 1.1rem; margin-bottom: 6px; }
#quick-start .resource-title { font-size: 1.3rem; margin-bottom: 12px; }
.resource-desc { color: var(--muted); font-size: 0.95rem; margin-bottom: 14px; }
.resource-actions.inline { display: flex; gap: 10px; flex-wrap: wrap; }
.resource-actions.center { justify-content: center; }
.btn {
  display: inline-flex; align-items: center; padding: 9px 18px; border-radius: 999px;
  text-decoration: none; font-weight: 550; font-size: 0.95rem; transition: all .15s;
}
.btn.secondary { background: var(--paper); color: var(--ink); border: 1px solid var(--line); }
.btn.secondary:hover { border-color: var(--pink); color: var(--pink-deep); }
.resource-card p { margin-bottom: 10px; }
.resource-card pre {
  background: var(--code-bg); border-radius: 10px; padding: 14px 18px; overflow-x: auto;
  line-height: 1.5; margin: 0 0 1.2rem;
}
pre code { font-family: var(--mono); color: #efe9ec; font-size: 0.9rem; }

/* ---------- citation ---------- */
.cite-note { text-align: center; color: var(--muted); }
.bibtex-box { position: relative; background: var(--code-bg); padding: 22px 24px; border-radius: var(--radius); }
.bibtex-scroll { overflow-x: auto; }
.bibtex-box pre { margin: 0; padding-right: 48px; }
.btn-copy {
  position: absolute; top: 12px; right: 12px; width: 36px; height: 36px; padding: 0;
  display: flex; align-items: center; justify-content: center;
  border: none; border-radius: 8px; background: rgba(255,255,255,.1); color: #c9bfc4; cursor: pointer;
}
.btn-copy:hover { background: rgba(255,255,255,.16); color: #fff; }
.btn-copy.copied { background: rgba(0,102,128,.35); color: #9fe3f2; }
.btn-copy .hidden { display: none; }

/* ---------- footer ---------- */
footer { padding: 36px 0; text-align: center; color: var(--muted); font-size: 0.9rem; border-top: 1px solid var(--line); }
footer p { margin: 0 0 6px; }

/* ---------- responsive ---------- */
@media (max-width: 900px) {
  .resources-grid { grid-template-columns: 1fr; }
  .thermo-row--three { grid-template-columns: 1fr; }
  .thermo-row--three .chart-card .result-img { max-height: none; }
}
@media (max-width: 768px) {
  .dyn-row, .dyn-row--portrait { grid-template-columns: 1fr; }
  .thermo-row--two { grid-template-columns: 1fr; }
  .scroll-x .main-figure.full { min-width: 640px; }
  #abstract .col-text { text-align: left; }
}

/* ---------- Fig. 1 rows: one panel per row, its box beside it ---------- */
/* sub-headings inside a section: same mark as the results headings, so the structure reads at a glance */
.sub-title, .results-head {
  margin: 44px 0 18px; padding-bottom: 8px;
  border-bottom: 2px solid var(--orange-soft);
  font-size: clamp(20px, 3vw, 24px); font-weight: 700; color: var(--ink);
}
.sub-title::before, .results-head::before {
  content: ""; display: inline-block; width: 10px; height: 10px; border-radius: 50%;
  background: var(--orange); margin-right: 10px; vertical-align: 2px;
}
.sub-title:first-of-type { margin-top: 12px; }
#abinitio .fig-row--a + .sub-title { margin-top: 72px; }
.fig-row { display: grid; grid-template-columns: minmax(0, 1fr); gap: 20px; align-items: start; }
.fig-row .panel { max-width: 640px; }
.fig-row--a .panel { max-width: 380px; }
.panel-c { max-width: none; }
.eq-inline { display: inline-block; vertical-align: middle; height: auto; margin: 0 .25em; position: relative; top: -1px; }
.lede-c { max-width: none; }
@media (min-width: 760px) {
  .fig-row--a { grid-template-columns: minmax(0, 188fr) minmax(0, 415fr); column-gap: var(--gap); }
  .fig-row--b, .fig-row--c { grid-template-columns: minmax(0, 303fr) minmax(0, 300fr); column-gap: var(--gap); }
  .fig-row .panel { max-width: none; }
}
/* the mobility ladder speaks teal */
.box[data-tone="meso"] { border-left-color: var(--teal); }
.state[data-tone="meso"] .eyebrow { color: var(--teal); }
.state[data-tone="meso"] .eq { background: var(--teal-soft); border-color: #cfe6ec; }
.state[data-tone="meso"] .badge { background: var(--teal-soft); color: var(--teal); }

/* ---------- results by system ---------- */
.results-sub { max-width: none; margin: -6px 0 18px; color: var(--ink-2); }
.row-label { margin: 28px 0 10px; font-size: 12.5px; font-weight: 650; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.chart-card--wide { margin-top: 16px; }
.chart-card--wide .result-img { max-height: 520px; object-fit: contain; }
.pending-note { font-size: .9rem; color: var(--muted); font-style: italic; border-left: 3px solid var(--line); padding-left: 10px; }
.dyn-text .pending-note { margin-top: 12px; }
.caption--card { margin: 10px 0 0; font-size: .92rem; }

/* ---------- ladder tabs ---------- */
.ladder-tabs { display: flex; gap: 8px; flex-wrap: wrap; margin: 0 0 18px; }
.ladder-tab {
  appearance: none; cursor: pointer; font: inherit; font-weight: 600; font-size: .95rem;
  padding: 8px 18px; border-radius: 999px; border: 1px solid var(--line); background: var(--paper); color: var(--ink-2);
  transition: all .15s;
}
.ladder-tab:hover { border-color: var(--ink-2); color: var(--ink); }
.ladder-tab:focus-visible { outline: 2px solid var(--pink); outline-offset: 2px; }
.ladder-tab.is-current[data-pane="fe"] { background: var(--pink); border-color: var(--pink); color: #fff; }
.ladder-tab.is-current[data-pane="mob"] { background: var(--teal); border-color: var(--teal); color: #fff; }
.ladder-pane[hidden] { display: none; }
.ladder-pane .lede { margin-bottom: 18px; }

/* ---------- key insights ---------- */
.insight-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.insight-card {
  position: relative; padding: 22px 20px 18px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--paper);
  overflow: hidden; transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}
.insight-card::before { content: ""; position: absolute; left: 0; top: 0; right: 0; height: 4px; background: var(--teal); }
.insight-card:hover { transform: translateY(-3px); box-shadow: 0 14px 30px -14px rgba(0,102,128,.35); border-color: #bfdde5; }
.insight-icon {
  display: inline-flex; align-items: center; justify-content: center; width: 48px; height: 48px; border-radius: 12px;
  background: var(--teal-soft); color: var(--teal); margin-bottom: 12px;
}
.insight-icon svg { display: block; }
.insight-card h3 { font-size: 1.02rem; margin-bottom: 8px; line-height: 1.3; }
.insight-card p { margin: 0; color: var(--ink-2); font-size: .92rem; line-height: 1.5; }
@media (max-width: 1000px) { .insight-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 560px) { .insight-grid { grid-template-columns: 1fr; } }

/* helium-rain row: schematic | planets | snapshots */
.thermo-row--rain { grid-template-columns: minmax(0, 308fr) minmax(0, 532fr) minmax(0, 900fr); }
.thermo-row--rain .result-img { max-height: 300px; object-fit: contain; }
/* a single video row */
.video-solo { max-width: 460px; margin: 0 auto; }
.video-solo video { display: block; width: 100%; height: auto; border-radius: 6px; background: #fff; }
@media (max-width: 900px) { .thermo-row--rain { grid-template-columns: 1fr; } .thermo-row--rain .result-img { max-height: none; } }

/* abstract + key insights share one section, as on the template page */
.abstract-text { text-align: justify; hyphens: auto; }
.abstract-text p { margin-bottom: 1rem; }
.abstract-text p:last-child { margin-bottom: 0; }
.insights-heading { margin-top: 48px; }
@media (max-width: 768px) { .abstract-text { text-align: left; } }



/* the two requirements: a plain numbered list */
.req-plain { max-width: none; margin: 0 0 36px; padding-left: 1.4em; color: var(--ink-2); font-size: 1.04rem; }
.req-plain li { margin: 0 0 8px; padding-left: .3em; line-height: 1.6; }
.req-plain li::marker { font-weight: 700; color: var(--ink); }
.req-intro { margin: 0 0 10px; font-size: 1.04rem; color: var(--ink-2); }
.req-question { margin: 22px 0 14px; font-size: 1.12rem; font-weight: 650; color: var(--ink); }
.req-hint { font-weight: 400; font-size: .95rem; color: var(--muted); margin-left: 6px; }
.chain--plain li { font-weight: 400; }
.assume { margin: 6px 0 0; padding-left: 1.1em; list-style: disc; }
.assume li { margin: 0 0 3px; font-size: .92em; color: var(--ink-2); }
.assume li::marker { color: var(--blue); }

/* ---------- KaTeX math ---------- */
.katex { font-size: 1.08em; }
.eq .katex-display, .equation .katex-display { margin: .35em 0; overflow-x: auto; overflow-y: hidden; padding: 2px 0; }
.eq .katex-display > .katex, .equation .katex-display > .katex { text-align: left; }
.eq .katex-display > .katex { font-size: 1.12em; }
.equation .katex-display > .katex { text-align: center; font-size: 1.3em; }
.equation { display: block; }
.eq .katex-display + .katex-display { margin-top: .2em; }
.lede .katex, .state p .katex, .section-intro .katex, figcaption .katex, .dyn-text .katex { font-size: 1.04em; }
.sym-list { margin: 0 0 10px; padding-left: 1.1em; }
.sym-list li { margin: 0 0 6px; line-height: 1.5; }
.sym-list li::marker { color: var(--teal); }
.sym-list .katex-display { margin: .3em 0 .1em; text-align: left; }
.sym-list .katex-display > .katex { text-align: left; }

/* ---------- method: three numbered steps, plain text with display math ---------- */
.steps { margin: 28px auto 0; padding-left: 1.4em; max-width: 900px; color: var(--ink-2); font-size: 1.02rem; }
.steps > li { margin: 0 0 18px; padding-left: .3em; }
.steps > li::marker { font-weight: 700; color: var(--ink); }
.steps p { margin: 0 0 6px; line-height: 1.6; }
.steps b { color: var(--ink); }
.steps .katex-display { margin: 10px 0 12px; }
.steps .katex-display > .katex { font-size: 1.18em; }

/* equations in the hover boxes: no filled panel, just the math on the page */
.eq, .state[data-tone="work"] .eq, .state[data-tone="meso"] .eq { background: transparent; border: 0; padding: 2px 0; margin: 0 0 8px; overflow-x: auto; overflow-y: hidden; }
.eq .katex-display { margin: .2em 0; }
.eq-example { padding-left: 12px !important; border-left: 2px solid var(--line) !important; }
.eq-example .eq-label { margin-bottom: 0; }
.hl { color: var(--teal); font-weight: 650; background: var(--teal-soft); padding: 0 .2em; border-radius: 3px; }

/* inference: one row per equation, label left, equations aligned on one left edge */
.eq-rows { display: grid; gap: 8px; margin: 12px 0 4px; }
.eq-row { display: grid; grid-template-columns: 9.5em minmax(0, 1fr); align-items: center; column-gap: 16px;
  padding: 6px 16px; border-left: 3px solid; border-radius: 0 8px 8px 0; }
.eq-row.is-thermo { border-color: #D40054; background: #FFF6FA; }
.eq-row.is-dyn { border-color: var(--teal); background: #F2F9FB; }
.eq-row .eq-tag { font-size: .8rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.eq-row.is-thermo .eq-tag { color: #D40054; }
.eq-row.is-dyn .eq-tag { color: var(--teal); }
.eq-body { overflow-x: auto; overflow-y: hidden; }
.eq-body .katex-display { margin: 0; text-align: left; }
.eq-body .katex-display > .katex { text-align: left; font-size: 1.2em; }
@media (max-width: 640px) { .eq-row { grid-template-columns: 1fr; row-gap: 2px; } }

/* wide result videos (Lennard-Jones dynamics) */
.video-wide { margin: 12px 0 20px; padding: 12px; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; }
.video-wide video { display: block; width: 100%; height: auto; border-radius: 6px; background: #fff; }
.video-wide figcaption { margin-top: 8px; font-size: .92rem; color: var(--muted); }
.video-slab { max-width: 820px; margin-left: auto; margin-right: auto; }

/* result takeaways and panel guides */
.takeaway { margin: 6px 0 16px; padding: 10px 14px; border-left: 3px solid var(--orange); background: var(--orange-soft); color: var(--ink); border-radius: 0 8px 8px 0; }
.panel-guide { margin: 6px 0 0; padding-left: 1.4em; }
.panel-guide li { margin: 0 0 4px; }
.panel-guide li::marker { font-weight: 700; color: var(--ink); }
#results > .container > .katex-display { margin: 4px 0 6px; }

/* H/He rows: column widths follow each panel's aspect ratio, so the panels in a row share one height */
.fit-row { display: grid; gap: 16px; align-items: start; margin-top: 8px; }
.fit-row .chart-card { padding: 12px; }
.fit-row .result-img { max-height: none !important; object-fit: contain; }
.fit-row--ab  { grid-template-columns: minmax(0, 1.071fr) minmax(0, 0.827fr); }
.fit-row--cde { grid-template-columns: minmax(0, 0.651fr) minmax(0, 1.125fr) minmax(0, 1.125fr); }
.fit-row--rain { grid-template-columns: minmax(0, 0.745fr) minmax(0, 2.05fr); }
.fit-row--rain video { display: block; width: 100%; height: auto; border-radius: 6px; background: #fff; }
@media (max-width: 860px) { .fit-row--ab, .fit-row--cde, .fit-row--rain { grid-template-columns: 1fr; } .fit-row--rain video { max-width: 420px; margin: 0 auto; } }
.rain-card { margin-top: 8px; padding: 12px; }
.rain-pair { display: grid; grid-template-columns: minmax(0, 0.745fr) minmax(0, 2.05fr); gap: 16px; align-items: center; }
.rain-pair video, .rain-pair img { display: block; width: 100%; height: auto; border-radius: 6px; background: #fff; }
.rain-card figcaption { margin-top: 10px; font-size: .92rem; color: var(--muted); }
@media (max-width: 860px) { .rain-pair { grid-template-columns: 1fr; } .rain-pair video { max-width: 420px; margin: 0 auto; } }
/* rows of panels: equal card heights, images on one top line, captions on one top line */
.fit-row { align-items: stretch; }
.fit-row .chart-card { display: flex; flex-direction: column; }
.fit-row .chart-card .result-img { flex: none; }
.fit-row .chart-card figcaption { margin-top: 10px; }
/* flex instead of grid: grow factors = image aspect ratios, so after equal padding the images get exactly equal heights */
.fit-row { display: flex; gap: 16px; }
.fit-row > .chart-card { flex: var(--a, 1) 1 0; min-width: 0; }
@media (max-width: 860px) { .fit-row { flex-direction: column; } .fit-row > .chart-card { flex: none; } }
.fit-row--ab { max-width: 760px; margin-left: auto; margin-right: auto; }
.lj-dyn { margin-top: 8px; padding: 14px; }
.lj-dyn video { display: block; width: 100%; height: auto; border-radius: 6px; background: #fff; }
.lj-dyn .lj-growth { display: block; max-width: 620px; margin: 6px auto 0; }
.lj-dyn figcaption { margin-top: 10px; font-size: .92rem; color: var(--muted); }
.lj-pair { display: flex; gap: 14px; align-items: center; }
.lj-pair > * { flex: var(--a) 1 0; min-width: 0; }
.lj-dyn .lj-pair .lj-growth { max-width: none; margin: 0; }
@media (max-width: 760px) { .lj-pair { flex-direction: column; } .lj-pair > * { flex: none; width: 100%; } }
.lj-pd { max-width: 820px; margin-left: auto; margin-right: auto; }

/* full-width figures: no height cap, so the Fe-B composite fills the column */
.chart-card--wide .result-img { max-height: none; }

/* key insights: one row of five, four cards and the helium-rain video */
#insights .container { max-width: 1280px; }
.insight-layout { display: grid; grid-template-columns: minmax(0, 4fr) minmax(0, 1.1fr); gap: 14px; align-items: stretch; }
.insight-layout .insight-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.insight-video { margin: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 12px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--paper); position: relative; overflow: hidden; }
.insight-video::before { content: ""; position: absolute; left: 0; top: 0; right: 0; height: 4px; background: var(--orange); }
.insight-video video { display: block; width: 100%; height: auto; max-height: 100%; border-radius: 6px; background: #fff; }
.insight-video figcaption { margin-top: 8px; font-size: .78rem; line-height: 1.35; color: var(--muted); text-align: center; }
.rain-card .result-img { display: block; width: 100%; height: auto; }
@media (max-width: 1100px) {
  .insight-layout { grid-template-columns: 1fr; }
  .insight-layout .insight-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .insight-video { max-width: 320px; justify-self: center; }
}
@media (max-width: 560px) { .insight-layout .insight-grid { grid-template-columns: 1fr; } }
.insight-video { justify-content: flex-start; padding-top: 22px; }
.insight-video-title { align-self: stretch; margin: 0 0 10px; font-size: 1.02rem; line-height: 1.3; }
.insight-video video { flex: 1 1 auto; min-height: 0; object-fit: contain; }
