/* Pristine Models project page.
   Layout: masthead, comparison galleries, then sticky contents + essay column.
   Colors follow the paper's own figures: green = safe, orange = unsafe, navy = Pristine. */

@font-face {
  font-family: Inter;
  src: url('../fonts/inter-latin-wght-normal.woff2') format('woff2');
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
}

:root {
  --paper: #fafbfc;
  --panel: #f3f1ea;
  --ink: #1d1c1a;
  --muted: #66635c;
  --rule: #e3dfd5;

  --safe: #2f6b2a;
  --safe-bg: #e8f2e2;
  --unsafe: #b4501a;
  --unsafe-bg: #fbece2;
  --pristine: #17324f;
  --pristine-bg: #e7edf4;
  --shadow-panel: 0 1px 2px rgba(29,28,26,0.04), 0 14px 34px rgba(29,28,26,0.07);
  --shadow-media: 0 1px 2px rgba(29,28,26,0.08);

  --serif: Charter, "Bitstream Charter", "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: Inter, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

*, *::before, *::after { box-sizing: border-box; }

html { scroll-behavior: smooth; scroll-padding-top: 24px; -webkit-text-size-adjust: 100%; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 1.125rem;
  line-height: 1.7;
  text-rendering: optimizeLegibility;
}

img, video { max-width: 100%; display: block; }
a { color: var(--pristine); text-underline-offset: 0.18em; }
a:hover { color: #0b1e32; }
:focus-visible { outline: 3px solid #3a78b8; outline-offset: 2px; border-radius: 2px; }

.skip {
  position: absolute; left: -999px; top: 8px; background: var(--ink); color: #fff;
  padding: 8px 12px; font-family: var(--sans); font-size: 0.9rem; z-index: 10;
}
.skip:focus { left: 8px; }

/* ---------- Masthead ---------- */

.masthead { max-width: 1280px; margin: 0 auto; padding: 36px 24px 8px; text-align: center; }

.masthead h1 {
  font-size: 4rem;
  line-height: 1.04;
  letter-spacing: 0;
  font-weight: 600;
  margin: 0 0 14px;
}

.subtitle {
  font-size: 1.3rem;
  line-height: 1.4;
  color: var(--muted);
  max-width: 48em;
  margin: 0 auto 20px;
}

.authors {
  list-style: none; margin: 0 0 6px; padding: 0;
  display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 22px;
  font-family: var(--sans); font-size: 0.95rem;
}
.authors sup { font-size: 0.7em; margin-left: 1px; }

.affiliations, .notes {
  font-family: var(--sans); font-size: 0.9rem; color: var(--muted); margin: 0;
}
.affiliations { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px 36px; list-style: none; padding: 0; margin-top: 14px; }
.affiliations li { display: flex; align-items: center; gap: 8px; }
.affiliations sup { margin-right: 3px; }
.affiliations .logo { height: 40px; width: auto; }
.authors a { color: inherit; text-decoration: none; border-bottom: 1px solid var(--rule); }
.authors a:hover { border-bottom-color: currentColor; }
.notes { margin-top: 4px; font-size: 0.8rem; }

.links { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin: 22px 0 0; padding: 0; list-style: none; }
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  font-family: var(--sans); font-size: 0.95rem; font-weight: 600;
  padding: 9px 18px; border-radius: 999px;
  border: 1.5px solid var(--ink); color: var(--ink); background: transparent;
  text-decoration: none; cursor: pointer;
}
.btn:hover { background: var(--ink); color: var(--paper); }
.btn svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.btn.is-soon { border-color: var(--rule); color: var(--muted); cursor: default; font-weight: 500; }
.btn.is-soon:hover { background: transparent; color: var(--muted); }
.btn .soon { font-weight: 400; font-size: 0.8rem; }

/* ---------- Opening galleries ---------- */

.opener {
  max-width: 1320px; margin: 30px auto 0; padding: 0 28px;
}
.eyebrow {
  font-family: var(--sans); font-size: 0.72rem; font-weight: 700; letter-spacing: 0; text-transform: uppercase;
  color: var(--unsafe); margin: 0 0 4px;
}
.result-title-row {
  display: flex; align-items: center; justify-content: space-between; gap: 24px; margin-bottom: 20px;
}
.result-title-row h2 { font-size: 1.85rem; line-height: 1.2; margin: 0; font-weight: 700; }
.result-title-row h2 span { display: inline-block; }
.trailer-link {
  display: flex; align-items: center; gap: 12px; flex-shrink: 0;
  padding: 6px 12px 6px 6px; border: 1px solid #dce0e3; border-radius: 8px;
  background: #fff; color: var(--ink); text-decoration: none; font-family: var(--sans);
  transition: border-color 150ms, box-shadow 150ms;
}
.trailer-link:hover { color: var(--ink); border-color: #94a2ae; box-shadow: 0 3px 12px #17324f12; }
.trailer-link strong { display: block; font-size: 0.875rem; line-height: 1.4; }
.trailer-link small { display: block; font-size: 0.75rem; color: var(--muted); }
.trailer-preview { position: relative; width: 88px; flex: none; }
.trailer-preview > img { width: 100%; height: auto; aspect-ratio: 940 / 614; object-fit: contain; border-radius: 4px; }
.play-icon {
  position: absolute; inset: 0; margin: auto; display: grid; place-items: center;
  width: 30px; height: 30px; border-radius: 50%; background: #fff; box-shadow: 0 1px 8px #0003;
}
.qual { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px; }
.qual-col {
  --accent: var(--unsafe); --tint: #fff3ec; --edge: #efd3c2;
  min-width: 0; background: #fff; border: 1px solid #dfe3e5; border-top: 3px solid var(--accent);
  border-radius: 8px; box-shadow: 0 2px 5px #15202b06;
}
.qual-col.safe { --accent: var(--safe); --tint: #eff6ec; --edge: #cfe0c7; }
.qual-intro {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 4px 12px;
  padding: 12px 16px 14px; background: var(--tint); border-radius: 5px 5px 0 0;
}
.qual-intro h3 { font-family: var(--sans); font-size: 1.125rem; line-height: 1.3; font-weight: 700; color: var(--accent); margin: 0; }
.qual-sub { grid-column: 1 / -1; font-family: var(--sans); font-size: 0.875rem; line-height: 1.5; color: #575b5c; margin: 0; }
.qual-content { padding: 16px 16px 0; }
.qual-head, .qual-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.qual-head { font-family: var(--sans); font-size: 0.875rem; font-weight: 700; text-align: center; margin-bottom: 10px; line-height: 1.2; }
.qual-head small { display: block; font-size: 0.6875rem; font-weight: 400; color: var(--muted); margin-top: 3px; }
.qual-head span:nth-child(1) { color: var(--safe); }
.qual-head span:nth-child(2) { color: var(--unsafe); }
.qual-head span:nth-child(3) { color: var(--pristine); }
.qual-strip {
  display: flex; position: relative; gap: 16px; overflow-x: auto;
  scroll-snap-type: x mandatory; overscroll-behavior-x: contain;
  scrollbar-width: thin; scrollbar-color: #bcc1c5 #f0f1f2; padding-bottom: 10px;
}
.qual-strip::-webkit-scrollbar { height: 6px; }
.qual-strip::-webkit-scrollbar-track { background: #f0f1f2; border-radius: 4px; }
.qual-strip::-webkit-scrollbar-thumb { background: #bcc1c5; border-radius: 4px; }
.qual-row { flex: 0 0 100%; margin: 0; align-content: start; scroll-snap-align: start; }
.qual-row img { width: 100%; height: auto; aspect-ratio: 1; object-fit: contain; border-radius: 4px; background: #f3f4f5; }
.qual-row p {
  grid-column: 1 / -1; min-height: 3em; margin: 5px 4px 0;
  font-family: var(--sans); font-size: 0.875rem; font-style: italic; line-height: 1.5; text-align: center; color: #606365;
}
.qual-row p strong { font-style: normal; color: var(--ink); }
.gallery-controls {
  grid-column: 2; grid-row: 1; font-family: var(--sans);
}
.gallery-name { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.gallery-actions { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.gallery-count { min-width: 38px; margin-right: 5px; color: var(--muted); font-size: 0.75rem; font-variant-numeric: tabular-nums; }
.icon-button {
  width: 34px; height: 34px; flex-shrink: 0; display: inline-grid; place-items: center; padding: 0;
  background: #fff; border: 1px solid #dce0e3; border-radius: 50%; cursor: pointer;
  transition: background 150ms, border-color 150ms;
}
.icon-button img { width: 18px; height: 18px; }
.icon-button:hover { background: #f0f3f5; border-color: #a5afb7; }
.icon-button:disabled { opacity: 0.3; cursor: default; }
.gallery-thumbs {
  display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 8px;
  padding: 12px 16px 14px; margin-top: 12px; border-top: 1px solid #eceff0; background: #fafbfc; border-radius: 0 0 7px 7px;
}
.gallery-thumb {
  width: 100%; min-width: 0; padding: 3px; border: 2px solid transparent; border-radius: 5px;
  background: transparent; cursor: pointer; opacity: 0.65; transition: opacity 150ms, border-color 150ms;
}
.gallery-thumb img { width: 100%; height: 54px; object-fit: contain; border-radius: 2px; }
.gallery-thumb:hover { opacity: 1; border-color: #c4cbd0; }
.gallery-thumb[aria-pressed="true"] { opacity: 1; border-color: var(--accent); background: var(--tint); }
.result-note { font-family: var(--sans); font-size: 0.75rem; color: var(--muted); margin: 10px 0 0; text-align: right; }
.takeaway { display: grid; grid-template-columns: 1fr 1fr 1.2fr; gap: 24px; margin-top: 28px; padding: 20px 0; border-top: 1px solid #dfe3e5; border-bottom: 1px solid #dfe3e5; }
.takeaway p { margin: 0; font-family: var(--sans); font-size: 0.875rem; line-height: 1.5; }
.takeaway p + p { padding-left: 24px; border-left: 1px solid #dfe3e5; }
.takeaway strong { display: block; margin-bottom: 4px; }
.takeaway span { color: #606365; }

/* ---------- Media viewers ---------- */

body:has(.media-dialog[open]) { overflow: hidden; }
.media-dialog {
  width: min(1100px, calc(100% - 48px)); max-width: none; max-height: calc(100dvh - 48px);
  padding: 20px; background: #fff; color: var(--ink); border: 1px solid #dce0e3; border-radius: 8px;
  box-shadow: 0 20px 80px #0004;
}
.media-dialog::backdrop { background: rgba(20, 25, 30, 0.72); }
.dialog-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 16px; }
.dialog-heading h2 { font-size: 1.4rem; line-height: 1.25; margin: 0; }
.video-dialog { width: min(920px, calc(100% - 48px)); }
.video-frame { position: relative; }
.video-frame video { width: 100%; max-height: calc(100dvh - 150px); aspect-ratio: 940 / 614; object-fit: contain; background: #fff; border-radius: 4px; }
.video-frame.no-video::after {
  content: "Video unavailable";
  position: absolute; right: 12px; bottom: 12px;
  font-family: var(--sans); font-size: 0.8rem; color: var(--muted);
  background: rgba(255,255,255,0.92); border: 1px solid var(--rule); border-radius: 999px; padding: 3px 12px;
}
figcaption {
  font-family: var(--sans); font-size: 0.88rem; line-height: 1.5; color: var(--muted); margin-top: 10px;
}
figcaption strong { color: var(--ink); font-weight: 600; }

/* ---------- Page grid ---------- */

.page {
  max-width: 1200px; margin: 64px auto 0; padding: 0 24px;
  display: grid; grid-template-columns: 200px minmax(0, 720px); gap: 56px; justify-content: center;
}

.toc { position: sticky; top: 32px; align-self: start; font-family: var(--sans); font-size: 0.9rem; }
.toc h2 { font-size: 0.85rem; font-weight: 700; margin: 0 0 10px; color: var(--muted); }
.toc ol { list-style: none; margin: 0; padding: 0; border-left: 1px solid var(--rule); }
.toc li a {
  display: block; padding: 5px 0 5px 14px; margin-left: -1px; border-left: 2px solid transparent;
  color: var(--muted); text-decoration: none; line-height: 1.35;
}
.toc li a:hover { color: var(--ink); }
.toc li a[aria-current="true"] { color: var(--ink); border-left-color: var(--pristine); font-weight: 600; }

/* ---------- Essay ---------- */

article section { margin-bottom: 72px; }
article h2 {
  font-size: 2.3rem; line-height: 1.15; letter-spacing: 0; font-weight: 700; margin: 0 0 22px;
}
article h3 {
  font-size: 1.5rem; line-height: 1.25; letter-spacing: 0; font-weight: 700;
  margin: 56px 0 14px; padding-left: 14px; border-left: 4px solid var(--pristine);
}
article h4 { font-family: var(--sans); font-size: 1.05rem; line-height: 1.3; font-weight: 700; color: var(--pristine); margin: 0 0 8px; }
.option { background: var(--panel); border: 1px solid var(--rule); border-radius: 8px; padding: 18px 22px 6px; margin: 0 0 18px; }
.callout { background: var(--pristine-bg); border-left: 4px solid var(--pristine); border-radius: 0 8px 8px 0; padding: 14px 20px; margin: 22px 0 0; }
.core-idea { background: var(--pristine-bg); border: 1px solid var(--pristine); border-radius: 8px; padding: 20px 26px; margin: 26px 0 28px; box-shadow: 0 6px 20px rgba(23, 50, 79, 0.08); }
.core-idea .eyebrow { color: var(--pristine); }
.core-text { font-size: 1.3rem; line-height: 1.4; margin: 0; color: var(--pristine); }
.core-list { margin: 4px 0 0; padding-left: 1.3em; font-size: 1.15rem; line-height: 1.45; color: var(--pristine); }
.core-list li { margin-bottom: 0.35em; }
.core-list li:last-child { margin-bottom: 0; }
.note { background: var(--panel); border-left: 3px solid var(--muted); border-radius: 0 8px 8px 0; padding: 12px 18px; font-size: 0.95rem; color: var(--muted); }
.note strong { color: var(--ink); }
.decomp.single { grid-template-columns: minmax(0, 30rem); }
.when-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin: 0 0 1.4em; }
.when { border-radius: 8px; padding: 14px 18px; border: 1px solid var(--rule); }
.when p { margin: 0 0 4px; }
.when-pre { background: var(--pristine-bg); }
.when-post { background: var(--panel); }
.when-label { font-family: var(--sans); font-size: 0.72rem; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }
.when-tool { font-family: var(--sans); font-weight: 700; color: var(--pristine); }
.when-post .when-tool { color: var(--ink); }
article p { margin: 0 0 1.1em; }
article ul { padding-left: 1.2em; margin: 0 0 1.1em; }
article li { margin-bottom: 0.4em; }
.safe-t { color: var(--safe); font-weight: 600; }
.unsafe-t { color: var(--unsafe); font-weight: 600; }
.pristine-t { color: var(--pristine); font-weight: 600; }

code, .mono { font-family: var(--mono); font-size: 0.88em; background: var(--panel); padding: 1px 5px; border-radius: 4px; }

.fig { margin: 30px 0; }
.fig:not(.blend) { background: #fff; border: 1px solid var(--rule); border-radius: 8px; padding: 12px; box-shadow: var(--shadow-panel); }
.fig img { width: 100%; height: auto; border: 1px solid var(--rule); border-radius: 6px; background: #fff; }
.fig:not(.blend) img { border: 0; }
.fig.plain img { border: 0; }
.fig.blend img { border: 0; background: transparent; mix-blend-mode: multiply; }
a.cite { text-decoration: none; color: var(--muted); font-size: 0.92em; }
a.cite:hover { color: var(--pristine); text-decoration: underline; }
.refs { font-family: var(--sans); font-size: 0.9rem; line-height: 1.5; color: var(--muted); padding-left: 1.4em; }
.refs li { margin-bottom: 8px; }
.refs li:target { background: var(--pristine-bg); }
@media (min-width: 1200px) { .fig.wide { margin-right: -160px; } }

.eq {
  font-family: var(--serif); font-size: 1.1rem; background: var(--panel); border-radius: 6px;
  padding: 14px 18px; margin: 0 0 1.2em; overflow-x: auto; line-height: 1.9; white-space: nowrap;
}
.eq.sm { font-size: 0.95rem; }
.eq var { font-style: italic; }

/* prompt decomposition card */
.decomp { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin: 26px 0; font-family: var(--sans); font-size: 0.92rem; line-height: 1.5; }
.decomp > div { border-radius: 8px; padding: 14px 16px; border: 1px solid var(--rule); }
.decomp .u { background: var(--unsafe-bg); border-color: #efd0bb; }
.decomp .s { background: var(--safe-bg); border-color: #cfe3c4; }
.decomp h4 { margin: 0 0 8px; font-size: 0.9rem; font-weight: 700; }
.decomp .u h4 { color: var(--unsafe); }
.decomp .s h4 { color: var(--safe); }
.decomp dl { margin: 0; }
.decomp dt { font-weight: 600; margin-top: 8px; }
.decomp dd { margin: 0; font-family: var(--serif); font-style: italic; font-size: 0.98rem; }

/* ---------- Tables ---------- */

.table-wrap { overflow-x: auto; margin: 26px 0; }
table { border-collapse: collapse; width: 100%; font-family: var(--sans); font-size: 0.88rem; line-height: 1.35; }
caption { text-align: left; font-size: 0.88rem; color: var(--muted); padding-bottom: 10px; caption-side: top; }
th, td { padding: 8px 10px; text-align: right; border-bottom: 1px solid var(--rule); white-space: nowrap; }
th:first-child, td:first-child { text-align: left; white-space: normal; }
thead th { font-weight: 600; border-bottom: 1.5px solid var(--ink); vertical-align: bottom; }
thead th[colspan] { text-align: center; border-bottom: 0; }
thead th small, tr.group span, table th small { font-size: 0.78em; font-weight: 400; }
tbody th { font-weight: 400; }
tr.group th { background: var(--panel); font-weight: 700; text-align: left; font-size: 0.82rem; }
tr.ours td, tr.ours th { background: var(--pristine-bg); }
td.best { font-weight: 700; }
tr.detached td { color: var(--muted); }
#imagenet .table-wrap table { min-width: 850px; }

/* ---------- Interactive demos ---------- */

.demo {
  border: 1px solid var(--rule); border-radius: 8px; background: #fff;
  padding: 20px; margin: 30px 0; font-family: var(--sans); box-shadow: var(--shadow-panel);
}
@media (min-width: 1200px) { .demo { margin-right: -160px; } }
.demo h3 { margin: 0 0 4px; font-size: 1.05rem; }
.demo .hint { margin: 0 0 14px; font-size: 0.9rem; color: var(--muted); line-height: 1.5; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.chip {
  font: inherit; font-size: 0.88rem; padding: 6px 14px; border-radius: 999px;
  border: 1px solid var(--rule); background: var(--paper); color: var(--ink); cursor: pointer;
}
.chip:hover { border-color: var(--ink); }
.chip[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: #fff; }

.prompt {
  font-family: var(--serif); font-style: italic; font-size: 0.98rem; line-height: 1.5;
  background: var(--panel); border-radius: 6px; padding: 10px 14px; margin: 0 0 16px;
}

.tiles { display: grid; gap: 12px; }
.tiles.t3 { grid-template-columns: repeat(3, 1fr); }
.tile { margin: 0; }
.tile img { width: 100%; height: auto; aspect-ratio: 1; object-fit: cover; border-radius: 6px; border: 1px solid var(--rule); }
.tile .label { margin-top: 7px; font-size: 0.85rem; font-weight: 600; line-height: 1.3; }
.tile .sub { font-size: 0.8rem; color: var(--muted); font-weight: 400; }
.tile.pristine img { border: 2px solid var(--pristine); }
.tile.pristine .label { color: var(--pristine); }

.switch-row { display: flex; align-items: center; gap: 12px; margin: 16px 0 6px; font-size: 0.92rem; flex-wrap: wrap; }
.switch {
  position: relative; width: 52px; height: 28px; border-radius: 999px; border: 0; cursor: pointer; padding: 0;
  background: var(--safe); flex: none;
}
.switch::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%;
  background: #fff; transition: transform 0.15s;
}
.switch[aria-checked="true"] { background: var(--unsafe); }
.switch[aria-checked="true"]::after { transform: translateX(24px); }
@media (prefers-reduced-motion: reduce) { .switch::after { transition: none; } }
.state-note { margin: 4px 0 0; font-size: 0.9rem; line-height: 1.5; min-height: 2.8em; }

/* ---------- Cite ---------- */

.bibtex {
  position: relative; background: var(--panel); border-radius: 8px; padding: 16px 18px; margin: 0 0 12px;
  font-family: var(--mono); font-size: 0.82rem; line-height: 1.55; overflow-x: auto; white-space: pre;
}
.copy-row { display: flex; align-items: center; gap: 12px; font-family: var(--sans); font-size: 0.88rem; color: var(--muted); }

footer {
  max-width: 1200px; margin: 24px auto 0; padding: 28px 24px 64px;
  font-family: var(--sans); font-size: 0.85rem; color: var(--muted);
}
footer .inner { max-width: 976px; margin: 0 auto; border-top: 1px solid var(--rule); padding-top: 20px; }

/* ---------- Responsive ---------- */

@media (max-width: 1080px) {
  .qual-sub { min-height: 3em; }
  .page { grid-template-columns: minmax(0, 1fr); gap: 0; margin-top: 40px; }
  .toc { display: none; }
  .demo { margin-right: 0; }
}
@media (max-width: 760px) {
  .qual { grid-template-columns: minmax(0, 1fr); gap: 20px; }
  .result-title-row { flex-direction: column; align-items: stretch; gap: 16px; }
  .trailer-link { align-self: flex-start; }
  .qual-sub { min-height: 0; }
  .takeaway { grid-template-columns: minmax(0, 1fr); gap: 14px; }
  .takeaway p + p { padding: 0; border: 0; }
  .takeaway strong { margin-bottom: 2px; }
}
@media (max-width: 640px) {
  body { font-size: 1.05rem; }
  .masthead { padding: 28px 18px 0; }
  .masthead h1 { font-size: 2.75rem; }
  .subtitle { font-size: 1.125rem; }
  .authors { font-size: 0.825rem; gap: 6px 14px; }
  .affiliations { gap: 12px; }
  .affiliations .logo { height: 32px; }
  .notes { font-size: 0.6875rem; margin-top: 10px; }
  .links { gap: 6px; margin-top: 18px; }
  .btn { padding: 8px; font-size: 0.75rem; gap: 4px; }
  .btn svg { width: 14px; height: 14px; }
  .btn .soon { font-size: 0.625rem; }
  .opener { margin-top: 28px; padding: 0 16px; }
  .result-title-row h2 { font-size: 1.65rem; }
  .trailer-link { align-self: stretch; }
  .qual-intro { padding: 12px; gap: 4px 8px; }
  .qual-intro h3 { font-size: 1rem; }
  .qual-content { padding: 14px 10px 0; }
  .qual-head, .qual-row { gap: 5px; }
  .qual-head { font-size: 0.75rem; min-height: 40px; }
  .qual-head small { font-size: 0.625rem; }
  .qual-row p { font-size: 0.8125rem; min-height: 4.5em; margin-left: 2px; margin-right: 2px; }
  .gallery-actions { gap: 4px; }
  .gallery-count { min-width: 30px; margin-right: 2px; }
  .gallery-thumbs { padding: 10px; gap: 4px; }
  .gallery-thumb { padding: 2px; }
  .result-note { text-align: left; }
  .media-dialog { width: calc(100% - 24px); padding: 14px; max-height: calc(100dvh - 24px); }
  .dialog-heading h2 { font-size: 1.125rem; }
  .decomp { grid-template-columns: 1fr; }
  .when-grid { grid-template-columns: 1fr; }
  .core-text { font-size: 1.15rem; }
  .tiles.t3 { grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
  .tile .label { font-size: 0.75rem; }
  .tile .sub { display: none; }
  article h2 { font-size: 1.55rem; }
}
@media (max-width: 359px) {
  .masthead h1 { font-size: 2.4rem; }
  .links { gap: 4px; }
  .btn { padding-inline: 6px; }
  .gallery-actions { gap: 3px; }
  .icon-button { width: 30px; height: 30px; }
  .gallery-count { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .trailer-link, .icon-button, .gallery-thumb { transition: none; }
}
