/* ============================================================
   ALGORITHMS / AUTHORS
   Women pioneering computer art, 1960–1990
   Design: a catalogue raisonné rendered as a plotter score.
   Three voices — Bricolage (curatorial) · Fraunces/Newsreader (author) · Plex Mono (score).
   ============================================================ */

:root {
  /* — type — */
  --serif: 'Newsreader', 'Iowan Old Style', Georgia, serif;
  --grot:  'Bricolage Grotesque', 'Helvetica Neue', Helvetica, Arial, sans-serif;
  --mono:  'IBM Plex Mono', 'SFMono-Regular', ui-monospace, monospace;

  --t-name:  clamp(2.75rem, 6vw, 4.75rem);
  --t-quote: clamp(1.5rem, 3vw, 2.25rem);
  --t-h2:    1.5rem;
  --t-body:  1.0625rem;
  --t-data:  0.75rem;
  --t-label: 0.6875rem;
  --t-tag:   0.625rem;
  --lh-body: 1.6;
  --measure: 64ch;
  --track-label: 0.14em;
  --track-tag:   0.16em;

  /* — color — base :root is the "Blueprint" theme (cool light blue-grey, slate ink) — */
  --paper:       #E9EDF3;
  --paper-plate: #DEE4EC;
  --ink:         #15191F;
  --ink-soft:    #39414C;
  --ink-fade:    #7C8795;
  --rule:        rgba(21,30,45,0.18);
  --rule-strong: rgba(21,30,45,0.50);
  --hair: 1px;
  --accent:       #1F4E79;   /* overridden per-artist from JS */
  --accent-press: #163A5A;
  --accent-tint:  rgba(31,78,121,0.12);
  --blueprint:    #1F3A5F;

  /* — space (8px unit) — */
  --s1: 4px; --s2: 8px; --s3: 16px; --s4: 24px; --s5: 32px;
  --s6: 48px; --s7: 64px; --s8: 96px;

  /* — layout — */
  --sidebar: clamp(280px, 24vw, 340px);
  --maxw: 1120px;
  --gutter: 24px;
  --margin-col: 64px;

  /* — motion — */
  --ease: cubic-bezier(0.2, 0.6, 0.2, 1);
  --dur-in: 280ms;
  --dur-nav: 150ms;
}
@media (prefers-reduced-motion: reduce) {
  :root { --dur-in: 0ms; --dur-nav: 0ms; }
}

/* selectable text size (sidebar) — scales all rem-based type */
:root[data-fontsize="small"] { font-size: 14px; }
:root[data-fontsize="large"] { font-size: 17.5px; }

/* ─── sidebar switcher (text size) — the site's one palette is the base :root "Blueprint" ─── */
.theme-switch { margin: 0 0 var(--s4) 0; }
.theme-switch .theme-label {
  display: block; font-family: var(--grot); font-size: var(--t-label); font-weight: 600;
  letter-spacing: var(--track-label); text-transform: uppercase; color: var(--ink-fade);
  margin-bottom: var(--s2);
}
.theme-opts { display: flex; flex-wrap: wrap; gap: 4px; }
.theme-opts button {
  font-family: var(--mono); font-size: var(--t-tag); letter-spacing: 0.04em;
  text-transform: uppercase; background: var(--paper); color: var(--ink-soft);
  border: var(--hair) solid var(--rule-strong); padding: 4px 9px; cursor: pointer;
}
.theme-opts button.active { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.theme-opts button:hover:not(.active) { background: var(--paper-plate); }

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { background: var(--paper); color: var(--ink); }
/* guard against sub-pixel border rounding re-introducing a horizontal wiggle */
body { overflow-x: clip; }
body {
  font-family: var(--serif);
  font-size: var(--t-body);
  line-height: var(--lh-body);
  min-height: 100vh;
  font-variant-numeric: oldstyle-nums proportional-nums;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
::selection { background: var(--ink); color: var(--paper); }
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-press); text-decoration: underline; text-underline-offset: 2px; }

/* ─── shared type helpers ─────────────────────────────────── */
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums lining-nums; }
.label {
  font-family: var(--grot);
  font-size: var(--t-label);
  font-weight: 600;
  letter-spacing: var(--track-label);
  text-transform: uppercase;
  color: var(--ink-fade);
}

/* ─── shell ───────────────────────────────────────────────── */
.shell {
  display: grid;
  /* minmax(0,…): without it the widest canvas's min-content width propagates
     up and forces the whole page wider than the viewport on phones */
  grid-template-columns: var(--sidebar) minmax(0, 1fr);
  min-height: 100vh;
}

/* ─── sidebar ─────────────────────────────────────────────── */
.sidebar {
  background: var(--paper);
  border-right: var(--hair) solid var(--rule-strong);
  padding: var(--s5) var(--s4);
  position: sticky; top: 0;
  height: 100vh;
  overflow-y: auto;
  display: flex; flex-direction: column;
}

.masthead {
  border-bottom: 2px solid var(--ink);
  padding-bottom: var(--s3);
  margin-bottom: var(--s4);
}
.masthead .title {
  font-family: var(--grot);
  font-weight: 700;
  font-size: 1.125rem;
  letter-spacing: 0.04em;
  line-height: 1.1;
  text-transform: uppercase;
}
.masthead .title span.slash { color: var(--accent); margin: 0 0.15em; font-weight: 400; }
.masthead .subtitle {
  font-family: var(--serif);
  font-style: italic;
  font-size: 0.95rem;
  color: var(--ink-soft);
  margin-top: var(--s2);
  line-height: 1.3;
}
.masthead .meta {
  font-family: var(--mono);
  font-size: var(--t-tag);
  letter-spacing: 0.16em;
  color: var(--ink-fade);
  margin-top: var(--s2);
  text-transform: uppercase;
  font-variant-numeric: tabular-nums;
}

.nav-label {
  font-family: var(--grot);
  font-size: var(--t-label);
  font-weight: 600;
  letter-spacing: var(--track-label);
  color: var(--ink-fade);
  text-transform: uppercase;
  margin-bottom: var(--s2);
  padding-bottom: var(--s1);
  border-bottom: var(--hair) solid var(--rule);
}

.nav-list { list-style: none; }
.nav-item {
  padding: var(--s2) var(--s2) var(--s2) var(--s3);
  border-bottom: var(--hair) solid var(--rule);
  cursor: pointer;
  display: grid;
  grid-template-columns: 2.2ch 1fr;
  gap: var(--s2);
  align-items: baseline;
  position: relative;
  transition: background var(--dur-nav) var(--ease);
}
.nav-item::before {
  content: "";
  position: absolute; left: 0; top: 0; bottom: 0;
  width: 2px; background: var(--accent);
  transform: scaleY(0); transform-origin: top;
  transition: transform var(--dur-nav) var(--ease);
}
.nav-item:hover { background: var(--paper-plate); }
.nav-item.active::before { transform: scaleY(1); }
.nav-item.active .nav-name { color: var(--ink); font-style: italic; }
.nav-item.unbuilt { opacity: 0.4; cursor: default; }
.nav-item.unbuilt:hover { background: transparent; }
.nav-num {
  font-family: var(--mono);
  font-size: var(--t-tag);
  font-weight: 500;
  color: var(--ink-fade);
  font-variant-numeric: tabular-nums lining-nums;
}
.nav-item.active .nav-num { color: var(--accent); }
.nav-name {
  font-family: var(--serif);
  font-size: 1.0625rem;
  font-weight: 400;
  line-height: 1.2;
  color: var(--ink-soft);
}
.nav-dates {
  font-family: var(--mono);
  font-size: var(--t-tag);
  color: var(--ink-fade);
  grid-column: 2;
  margin-top: 2px;
  font-variant-numeric: tabular-nums;
}

.colophon {
  margin-top: auto;
  padding-top: var(--s4);
  border-top: var(--hair) solid var(--rule);
  font-family: var(--mono);
  font-size: 0.6875rem;
  line-height: 1.65;
  color: var(--ink-fade);
  letter-spacing: 0.02em;
}

/* ─── main column ─────────────────────────────────────────── */
.main {
  padding: 0 var(--s7) var(--s8) var(--s7);
  max-width: var(--maxw);
  min-width: 0;
}

.topbar {
  position: sticky; top: 0;
  background: var(--paper);
  border-bottom: var(--hair) solid var(--rule-strong);
  padding: var(--s3) 0;
  margin-bottom: var(--s6);
  z-index: 50;
  display: flex; align-items: center;
}
.crumbs {
  font-family: var(--mono);
  font-size: var(--t-data);
  letter-spacing: 0.14em;
  color: var(--ink-fade);
  text-transform: uppercase;
  font-variant-numeric: tabular-nums;
}
.crumbs .sep { color: var(--rule-strong); margin: 0 0.6em; }
.crumbs strong { color: var(--accent); font-weight: 500; }

/* ─── artist header ───────────────────────────────────────── */
.artist-header {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: var(--s6);
  align-items: start;
  padding-bottom: var(--s5);
  margin-bottom: var(--s5);
  border-bottom: 2px solid var(--ink);
  animation: rise var(--dur-in) var(--ease) both;
}
.artist-meta { max-width: var(--measure); }
.artist-meta .order {
  font-family: var(--mono);
  font-size: var(--t-data);
  letter-spacing: 0.18em;
  color: var(--ink-fade);
  text-transform: uppercase;
  margin-bottom: var(--s3);
  font-variant-numeric: tabular-nums;
}
.artist-meta .order b { color: var(--accent); font-weight: 500; }
.artist-meta h1 {
  font-family: var(--serif);
  font-weight: 400;
  font-size: var(--t-name);
  line-height: 0.98;
  letter-spacing: -0.015em;
  margin-bottom: var(--s3);
}
.artist-meta h1 em { font-style: italic; }
.artist-meta .dates {
  font-family: var(--mono);
  font-size: var(--t-data);
  letter-spacing: 0.12em;
  color: var(--ink-fade);
  margin-bottom: var(--s4);
  font-variant-numeric: tabular-nums;
}
.artist-meta .bio {
  font-size: var(--t-body);
  line-height: var(--lh-body);
  color: var(--ink-soft);
}
.artist-meta .bio + .bio { margin-top: var(--s3); }
.artist-meta .bio em { font-style: italic; color: var(--ink); }
.pull {
  font-family: var(--serif);
  font-style: italic;
  font-size: var(--t-quote);
  line-height: 1.2;
  color: var(--ink);
  margin-top: var(--s4);
  padding-left: var(--s3);
  border-left: 2px solid var(--accent);
}

/* the SVG mark, as a printer's-device colophon */
.mark-block { justify-self: end; text-align: center; }
.mark {
  width: 116px; height: 116px;
  background: var(--paper-plate);
  border: var(--hair) solid var(--rule-strong);
  position: relative; overflow: hidden;
}
.mark svg { display: block; width: 100%; height: 100%; }
.mark-caption {
  font-family: var(--mono);
  font-size: 0.5625rem;
  letter-spacing: 0.12em;
  color: var(--ink-fade);
  text-transform: uppercase;
  margin-top: var(--s2);
  max-width: 116px;
  line-height: 1.4;
}

/* ─── plate row (museum contact sheet) ────────────────────── */
.plate-row {
  display: flex;
  gap: var(--s4);
  overflow-x: auto;
  padding-bottom: var(--s3);
  margin-bottom: var(--s5);
  border-bottom: var(--hair) solid var(--rule);
}
.plate-row .plate-fig { flex: 0 0 auto; max-width: 280px; }
.plate {
  background: var(--paper-plate);
  border: var(--hair) solid var(--rule-strong);
  padding: var(--s2);
}
.plate img {
  display: block;
  height: 200px; width: auto; max-width: 100%;
  mix-blend-mode: multiply;
}
.plate-row .plate img { height: 180px; }
.plate-cap {
  font-family: var(--mono);
  font-size: var(--t-data);
  color: var(--ink-soft);
  margin-top: var(--s2);
  line-height: 1.45;
  font-variant-numeric: tabular-nums;
}
.plate-cap b { color: var(--accent); font-weight: 500; }
.plate-cap em { font-family: var(--serif); font-style: italic; color: var(--ink); }
.plate-cap a { color: var(--ink-fade); }
.plate-cap a:hover { color: var(--accent); }

/* ─── studies intro + fidelity note ───────────────────────── */
.viz-intro {
  margin: var(--s5) 0 var(--s3) 0;
  display: flex; align-items: baseline; justify-content: space-between;
  gap: var(--s4);
}
.viz-intro h2 {
  font-family: var(--grot);
  font-weight: 600;
  font-size: var(--t-label);
  letter-spacing: var(--track-label);
  text-transform: uppercase;
}
.viz-intro .count {
  font-family: var(--mono);
  font-size: var(--t-tag);
  letter-spacing: 0.12em;
  color: var(--ink-fade);
  text-transform: uppercase;
}
.fidelity-note {
  font-size: 0.9375rem;
  line-height: 1.55;
  color: var(--ink-soft);
  max-width: var(--measure);
  margin-bottom: var(--s6);
}
.fidelity-note strong {
  display: block;
  font-family: var(--grot);
  font-size: var(--t-label);
  font-weight: 600;
  letter-spacing: var(--track-label);
  text-transform: uppercase;
  color: var(--ink-fade);
  margin-bottom: var(--s2);
}

/* ─── study card (SOURCE → RE-READING diptych) ────────────── */
.viz-card {
  margin-bottom: var(--s7);
  display: grid;
  grid-template-columns: var(--margin-col) minmax(0, 1fr);
  column-gap: var(--s4);
  align-items: start;
}
.viz-card .cat-no {
  grid-column: 1; grid-row: 1 / span 3;
  font-family: var(--mono);
  display: grid; gap: 2px;
  position: sticky; top: var(--s7);
}
.cat-no .lbl {
  font-size: 0.5625rem; letter-spacing: 0.12em;
  text-transform: uppercase; color: var(--ink-fade);
}
.cat-no .num {
  font-size: 1.5rem; font-weight: 500; line-height: 1;
  font-variant-numeric: tabular-nums lining-nums;
}
.cat-no::after {
  content: ""; display: block; width: 2.5ch;
  border-top: 2px solid var(--accent);
  margin-top: var(--s1);
}

.viz-header { grid-column: 2; }
.viz-header .fidelity-tag {
  font-family: var(--mono);
  font-size: var(--t-tag);
  font-weight: 500;
  letter-spacing: var(--track-tag);
  text-transform: uppercase;
  color: var(--ink-soft);
  display: inline-flex; align-items: center; gap: 0.6em;
  margin-bottom: var(--s2);
}
.viz-header .fidelity-tag::before {
  content: ""; width: 0.55em; height: 0.55em; background: var(--accent);
}
.viz-header .fidelity-tag.is-ext::before { background: var(--blueprint); }
.viz-header h3 {
  font-family: var(--serif);
  font-style: italic; font-weight: 400;
  font-size: var(--t-h2);
  line-height: 1.2;
}
.viz-header h3 em { font-style: normal; } /* title already italic; nested em → upright */
.viz-header .year {
  font-family: var(--mono);
  font-size: var(--t-data);
  letter-spacing: 0.1em;
  color: var(--ink-fade);
  margin-top: var(--s1);
  font-variant-numeric: tabular-nums;
}
.viz-header .caption {
  font-size: 0.9375rem;
  line-height: 1.55;
  color: var(--ink-soft);
  max-width: var(--measure);
  margin-top: var(--s2);
}
.viz-header .caption em { font-style: italic; color: var(--ink); }
.viz-header .ref {
  font-family: var(--mono);
  font-size: var(--t-data);
  line-height: 1.5;
  color: var(--ink-fade);
  margin-top: var(--s3);
  padding-top: var(--s2);
  border-top: var(--hair) solid var(--rule);
  max-width: var(--measure);
}
.viz-header .ref-label {
  display: block;
  font-family: var(--grot);
  font-size: var(--t-tag); font-weight: 600;
  letter-spacing: var(--track-tag);
  color: var(--ink-fade);
  text-transform: uppercase;
  margin-bottom: var(--s1);
}
.viz-header .ref a { color: var(--accent); }
.viz-header .fidelity {
  font-family: var(--serif);
  font-style: italic;
  font-size: 0.875rem;
  color: var(--ink-soft);
  margin-top: var(--s1);
}

/* body: plate | stage. Without a plate, stage spans full width. */
.viz-body {
  grid-column: 2; margin-top: var(--s4);
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--s4);
  align-items: start;
}
.viz-card.has-plate .viz-body {
  grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
}
.viz-card.has-plate .viz-stage {
  padding-left: var(--s4);
}
.viz-plate { align-self: start; }
.viz-plate .src-label {
  font-family: var(--grot);
  font-size: var(--t-tag); font-weight: 600;
  letter-spacing: var(--track-tag);
  text-transform: uppercase;
  color: var(--ink-fade);
  margin-bottom: var(--s2);
}
/* max-height guards very tall scroll-format plates (e.g. 1:4 banners): show a
   top-anchored crop in the diptych; the full work stays one click away via its
   source link. object-fit keeps the crop undistorted. */
.viz-plate .plate img {
  height: auto; width: 100%;
  max-height: min(70vh, 520px);
  object-fit: cover; object-position: top center;
}

.viz-stage {
  position: relative;
  display: flex; align-items: flex-start; justify-content: center;
  min-width: 0;
}
/* light outline frame around each artwork (like the source plates), so a study
   reads as finished. Sits just inside the stage; works on light or dark canvases. */
.viz-canvas {
  max-width: 100%; height: auto; display: block;
  border: var(--hair) solid var(--rule-strong);
}
.viz-canvas.zoomable { cursor: zoom-in; }
.viz-card.hero .cat-no .num { font-size: 2.25rem; }

/* ─── controls — a plotter "score strip" ──────────────────── */
.viz-panel {
  grid-column: 2; margin-top: var(--s4);
  padding: var(--s3) var(--s4);
  background: var(--paper-plate);
  border-top: var(--hair) solid var(--rule-strong);
  border-bottom: var(--hair) solid var(--rule);
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: var(--s3) var(--s5);
  align-items: start;
}
.ctrl { min-width: 0; }
.ctrl-row {
  display: flex; justify-content: space-between; align-items: baseline;
  font-family: var(--mono);
  font-size: var(--t-tag);
  letter-spacing: 0.06em;
  color: var(--ink-soft);
  text-transform: uppercase;
  margin-bottom: var(--s1);
}
.ctrl-row .val { color: var(--accent); font-weight: 500; font-variant-numeric: tabular-nums; }
.ctrl input[type="range"] {
  width: 100%; -webkit-appearance: none; appearance: none;
  background: transparent; height: 16px; cursor: pointer;
}
.ctrl input[type="range"]::-webkit-slider-runnable-track {
  background: var(--paper); border: var(--hair) solid var(--ink); height: 6px;
}
.ctrl input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 10px; height: 14px;
  background: var(--ink); border: none; cursor: pointer; margin-top: -5px;
}
.ctrl input[type="range"]::-moz-range-track {
  background: var(--paper); border: var(--hair) solid var(--ink); height: 6px;
}
.ctrl input[type="range"]::-moz-range-thumb {
  width: 10px; height: 14px; background: var(--ink); border: none; border-radius: 0; cursor: pointer;
}

.ctrl-buttons { display: flex; flex-wrap: wrap; gap: var(--s1); }
.ctrl-buttons button {
  flex: 1 1 auto; min-width: 0;
  background: var(--paper);
  border: var(--hair) solid var(--ink);
  font-family: var(--mono);
  font-size: var(--t-tag);
  letter-spacing: 0.06em;
  padding: var(--s1) var(--s2);
  cursor: pointer; color: var(--ink);
  text-transform: uppercase; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
}
.ctrl-buttons button.active { background: var(--ink); color: var(--paper); }
.ctrl-buttons button:hover:not(.active) { background: var(--paper-plate); }

.ctrl-action {
  width: 100%;
  background: var(--ink); color: var(--paper);
  border: var(--hair) solid var(--ink);
  font-family: var(--mono);
  font-size: var(--t-tag);
  letter-spacing: 0.16em;
  padding: var(--s2) var(--s3);
  cursor: pointer; text-transform: uppercase;
}
.ctrl-action:hover { background: var(--accent); border-color: var(--accent); }

.ctrl-checkbox {
  display: flex; align-items: center;
  font-family: var(--mono);
  font-size: var(--t-tag);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-soft); cursor: pointer;
}
.ctrl-checkbox input { margin-right: var(--s2); accent-color: var(--accent); }

/* ─── footnote ────────────────────────────────────────────── */
.footnote {
  font-family: var(--mono);
  font-size: 0.625rem;
  letter-spacing: 0.1em;
  color: var(--ink-fade);
  text-transform: uppercase;
  margin-top: var(--s7);
  padding-top: var(--s3);
  border-top: var(--hair) solid var(--rule);
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* reference-image standing notice */
.ref-notice {
  font-family: var(--mono);
  font-size: 0.625rem;
  letter-spacing: 0.04em;
  color: var(--ink-fade);
  line-height: 1.5;
  margin-top: var(--s2);
  max-width: var(--measure);
}

/* ─── scrollbars / motion ─────────────────────────────────── */
.sidebar::-webkit-scrollbar { width: 6px; }
.sidebar::-webkit-scrollbar-track { background: var(--paper); }
.sidebar::-webkit-scrollbar-thumb { background: var(--rule-strong); }

@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.viz-card { animation: rise var(--dur-in) var(--ease) both; }
.viz-card:nth-child(2) { animation-delay: 40ms; }
.viz-card:nth-child(3) { animation-delay: 80ms; }
.viz-card:nth-child(4) { animation-delay: 120ms; }
.viz-card:nth-child(5) { animation-delay: 160ms; }

/* ─── variant tools (Phase 2 review) ──────────────────────── */
.viz-tools {
  display: flex; align-items: center; gap: var(--s3);
  flex-wrap: wrap;   /* variant chips + expand must wrap on narrow columns */
  margin-top: var(--s3); padding-top: var(--s2);
  border-top: var(--hair) solid var(--rule);
}
.variant-switch { flex-wrap: wrap; }
.fav-star {
  font-family: var(--mono); font-size: 0.8rem; line-height: 1;
  background: var(--paper); color: var(--ink-fade);
  border: var(--hair) solid var(--rule-strong);
  padding: 4px 9px; cursor: pointer;
  transition: background var(--dur-nav) var(--ease), color var(--dur-nav) var(--ease);
}
.fav-star:hover { color: var(--ink); }
.fav-star.on { background: var(--accent); color: var(--paper); border-color: var(--accent); }
.variant-switch { display: inline-flex; border: var(--hair) solid var(--ink); }
.variant-switch button {
  font-family: var(--mono); font-size: var(--t-tag); letter-spacing: 0.08em;
  text-transform: uppercase; background: transparent; color: var(--ink);
  border: none; border-left: var(--hair) solid var(--ink);
  padding: 4px 11px; cursor: pointer;
}
.variant-switch button:first-child { border-left: none; }
.variant-switch button.active { background: var(--ink); color: var(--paper); }
.variant-switch button:hover:not(.active) { background: var(--paper-plate); }

/* "⤢ Expand" button in each study's tools row */
.viz-expand {
  font-family: var(--mono); font-size: var(--t-tag); letter-spacing: 0.08em;
  text-transform: uppercase; background: var(--paper); color: var(--ink);
  border: var(--hair) solid var(--rule-strong); padding: 4px 10px; cursor: pointer;
}
.viz-expand:hover { background: var(--ink); color: var(--paper); border-color: var(--ink); }

/* ─── responsive ──────────────────────────────────────────── */
@media (max-width: 1000px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: relative; height: auto; }
  .main { padding: 0 var(--s4) var(--s7) var(--s4); }
  .artist-header { grid-template-columns: 1fr; gap: var(--s4); }
  .mark-block { justify-self: start; }
  .viz-card { grid-template-columns: minmax(0, 1fr); }
  .viz-card .cat-no { grid-row: auto; position: static; flex-direction: row; display: flex; gap: var(--s2); align-items: baseline; }
  .viz-card .cat-no::after { display: none; }
  .viz-header, .viz-body, .viz-panel { grid-column: 1; }
  .viz-card.has-plate .viz-body { grid-template-columns: minmax(0, 1fr); }
  .viz-card.has-plate .viz-stage { border-left: none; padding-left: 0; }
}

/* ─── phones — compact chrome, chip-row nav ───────────────── */
@media (max-width: 640px) {
  .main { padding: 0 var(--s3) var(--s6) var(--s3); }

  /* sidebar collapses to masthead + horizontally swipeable artist chips */
  .sidebar {
    padding: var(--s3);
    border-right: none;
    border-bottom: var(--hair) solid var(--rule-strong);
  }
  .colophon, .nav-dates, .masthead .meta { display: none; }
  .nav-list { display: flex; overflow-x: auto; gap: var(--s2); padding-bottom: var(--s1); }
  .nav-item {
    flex: 0 0 auto;
    display: flex; align-items: baseline; gap: var(--s1);
    border: var(--hair) solid var(--rule);
    padding: 8px 12px;
    white-space: nowrap;
  }
  .nav-item.active { border-color: var(--accent); }
  .theme-switch { display: inline-block; margin-right: var(--s3); }

  /* plate contact sheet: smaller thumbs, keep the horizontal swipe */
  .plate-row { gap: var(--s3); }
  .plate-row .plate-fig { max-width: 200px; }
  .plate-row .plate img { height: 132px; }
}

/* ─── touch devices — bigger targets, any width ───────────── */
@media (pointer: coarse) {
  .ctrl input[type="range"] { height: 32px; }
  .ctrl input[type="range"]::-webkit-slider-thumb { width: 22px; height: 22px; margin-top: -8px; }
  .ctrl input[type="range"]::-moz-range-thumb { width: 22px; height: 22px; }
  .ctrl-buttons button, .ctrl-action, .theme-opts button,
  .fav-star, .viz-expand, .variant-switch button, .ov-btn { padding: 9px 12px; }
  .ov-close { width: 44px; height: 44px; }
  .ov-swatch { width: 34px; height: 34px; }
}

/* ============================================================
   FULL-SCREEN OVERLAY + EXPORT
   ============================================================ */
body.ov-open { overflow: hidden; }

.ov-modal {
  position: fixed; inset: 0; z-index: 1000;
  display: flex; align-items: center; justify-content: center;
}
.ov-modal[hidden] { display: none; }
.ov-scrim {
  position: absolute; inset: 0;
  background: rgba(8, 10, 14, 0.82);
  backdrop-filter: blur(2px);
}
.ov-dialog {
  position: relative;
  width: min(1280px, 96vw);
  height: min(900px, 94vh);
  background: var(--paper);
  border: var(--hair) solid var(--rule-strong);
  box-shadow: 0 24px 80px rgba(0,0,0,0.5);
  display: flex; flex-direction: column;
  animation: rise var(--dur-in) var(--ease) both;
}

/* header */
.ov-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: var(--s4);
  padding: var(--s3) var(--s4);
  border-bottom: 2px solid var(--ink);
}
.ov-kicker {
  display: block;
  font-family: var(--mono); font-size: var(--t-tag);
  letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink-fade);
}
.ov-title {
  font-family: var(--serif); font-style: italic; font-weight: 400;
  font-size: 1.5rem; line-height: 1.15; margin-top: 2px;
}
.ov-title em { font-style: normal; }
.ov-close {
  flex: 0 0 auto;
  font-family: var(--mono); font-size: 1rem; line-height: 1;
  background: var(--paper); color: var(--ink);
  border: var(--hair) solid var(--rule-strong);
  width: 34px; height: 34px; cursor: pointer;
}
.ov-close:hover { background: var(--ink); color: var(--paper); border-color: var(--ink); }

/* body grid: matte | sidebar */
.ov-main {
  flex: 1 1 auto; min-height: 0;
  display: grid; grid-template-columns: 1fr 320px;
}
.ov-matte {
  position: relative; min-width: 0; min-height: 0;
  display: flex; align-items: center; justify-content: center;
  overflow: auto;
  padding: var(--s5);
  background: #F4F1E8;   /* overridden inline by JS */
}
.ov-art { margin: auto; line-height: 0; }
.ov-matte .viz-canvas {
  max-width: none; height: auto; display: block;
  box-shadow: 0 6px 30px rgba(0,0,0,0.28);
  border: var(--hair) solid rgba(0,0,0,0.25);
  cursor: default;
}
.ov-err { line-height: 1.5; }

/* sidebar */
.ov-side {
  border-left: var(--hair) solid var(--rule-strong);
  background: var(--paper);
  overflow-y: auto;
  padding: var(--s3) var(--s4) var(--s5);
  display: flex; flex-direction: column; gap: var(--s4);
}
.ov-block { display: flex; flex-direction: column; gap: var(--s2); }
.ov-block-h {
  font-family: var(--grot); font-size: var(--t-label); font-weight: 600;
  letter-spacing: var(--track-label); text-transform: uppercase; color: var(--ink-fade);
  padding-bottom: var(--s1); border-bottom: var(--hair) solid var(--rule);
}
.ov-controls { display: flex; flex-direction: column; gap: var(--s3); }

/* generic small button */
.ov-btn {
  font-family: var(--mono); font-size: var(--t-tag); letter-spacing: 0.06em;
  text-transform: uppercase; background: var(--paper); color: var(--ink);
  border: var(--hair) solid var(--ink); padding: 5px 10px; cursor: pointer;
}
.ov-btn.active { background: var(--ink); color: var(--paper); }
.ov-btn:hover:not(.active):not(:disabled) { background: var(--paper-plate); }
.ov-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.ov-row { display: flex; align-items: center; gap: var(--s2); }
.ov-zoomwrap { flex: 1 1 auto; display: flex; align-items: center; gap: var(--s2); min-width: 0; }
.ov-zoomwrap input[type="range"] {
  flex: 1 1 auto; -webkit-appearance: none; appearance: none;
  background: transparent; height: 16px; cursor: pointer; min-width: 0;
}
.ov-zoomwrap input[type="range"]::-webkit-slider-runnable-track { background: var(--paper-plate); border: var(--hair) solid var(--ink); height: 6px; }
.ov-zoomwrap input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 10px; height: 14px; background: var(--ink); margin-top: -5px; }
.ov-zoomwrap input[type="range"]::-moz-range-track { background: var(--paper-plate); border: var(--hair) solid var(--ink); height: 6px; }
.ov-zoomwrap input[type="range"]::-moz-range-thumb { width: 10px; height: 14px; background: var(--ink); border: none; border-radius: 0; }
.ov-zoomval { font-family: var(--mono); font-size: var(--t-tag); color: var(--accent); white-space: nowrap; font-variant-numeric: tabular-nums; }

/* matte swatches */
.ov-swatches { display: flex; flex-wrap: wrap; gap: var(--s2); align-items: center; }
.ov-swatch {
  width: 26px; height: 26px; cursor: pointer; padding: 0;
  border: 2px solid var(--rule-strong);
}
.ov-swatch.active { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-tint); }
.ov-color { width: 36px; height: 26px; padding: 0; border: var(--hair) solid var(--rule-strong); background: var(--paper); cursor: pointer; }

/* export fields */
.ov-field { display: flex; flex-direction: column; gap: var(--s1); }
.ov-field > label {
  font-family: var(--mono); font-size: var(--t-tag); letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--ink-soft);
}
.ov-export select, .ov-num {
  font-family: var(--mono); font-size: var(--t-data);
  background: var(--paper); color: var(--ink);
  border: var(--hair) solid var(--ink); padding: 5px 8px; width: 100%;
}
.ov-scalebtns { display: flex; gap: var(--s1); }
.ov-scalebtns .ov-btn { flex: 1 1 auto; }
.ov-dims {
  font-family: var(--mono); font-size: var(--t-tag); letter-spacing: 0.06em;
  color: var(--accent); font-variant-numeric: tabular-nums;
}
.ov-check {
  display: flex; align-items: center; gap: var(--s2);
  font-family: var(--mono); font-size: var(--t-tag); letter-spacing: 0.04em;
  text-transform: uppercase; color: var(--ink-soft); cursor: pointer;
}
.ov-check input { accent-color: var(--accent); }
.ov-gifopts { display: flex; flex-direction: column; gap: var(--s2); }
.ov-gifopts[hidden] { display: none; }
.ov-note {
  font-family: var(--serif); font-style: italic; font-size: 0.8125rem;
  color: var(--ink-fade); line-height: 1.4; min-height: 1em;
}
.ov-export-btn {
  width: 100%; background: var(--ink); color: var(--paper);
  border: var(--hair) solid var(--ink);
  font-family: var(--mono); font-size: var(--t-tag); letter-spacing: 0.16em;
  padding: var(--s2) var(--s3); cursor: pointer; text-transform: uppercase;
}
.ov-export-btn:hover:not(:disabled) { background: var(--accent); border-color: var(--accent); }
.ov-export-btn:disabled { opacity: 0.6; cursor: progress; }
.ov-status {
  font-family: var(--mono); font-size: var(--t-tag); letter-spacing: 0.04em;
  color: var(--ink-soft); min-height: 1.2em; font-variant-numeric: tabular-nums;
}
.ov-modal.ov-busy .ov-matte { cursor: progress; }

@media (max-width: 760px) {
  .ov-dialog { width: 100vw; height: 100vh; }
  .ov-main { grid-template-columns: 1fr; grid-template-rows: 1fr auto; }
  .ov-side { border-left: none; border-top: var(--hair) solid var(--rule-strong); max-height: 42vh; }
}
