:root {
  --page-gutter: clamp(22px, 6vw, 88px);
  --paper: #f3f5f4;
  --paper-dark: #e9eeec;
  --ink: #1b292c;
  --muted: #52615e;
  --subtle: #4c5b56;
  --line: #d2dbd7;
  --accent: #a9573d;
  --white: #ffffff;
  --mono: 'SFMono-Regular', 'Cascadia Mono', 'Roboto Mono', ui-monospace, Menlo, monospace;
  --sans: 'Avenir Next', Avenir, 'Segoe UI', sans-serif;
  font-family: var(--sans);
  color: var(--ink);
  background: var(--paper);
  color-scheme: light;
}

* { box-sizing: border-box; }
html { scroll-padding-top: 20px; }
body { min-width: 320px; margin: 0; background: var(--paper); }
a { color: inherit; }
button, input, select { font: inherit; }
button, a, input, select { -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
::selection { color: var(--white); background: var(--ink); }

.site-header, .hero, .section, .site-footer {
  max-width: 1440px;
  margin-inline: auto;
  padding-inline: var(--page-gutter);
}
.site-header {
  min-height: 66px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 28px;
  border-bottom: 1px solid var(--line);
}
.wordmark { font-size: 14px; font-weight: 700; letter-spacing: -.02em; text-decoration: none; white-space: nowrap; }
.site-nav { display: flex; align-items: center; gap: 28px; font-size: 12px; }
.site-nav a { text-decoration: none; text-underline-offset: 4px; }
.site-nav a:hover { color: var(--accent); text-decoration: underline; }

.hero { padding-block: 66px 72px; }
.hero-copy { max-width: 760px; }
h1, h2, h3, h4, h5, p { margin-top: 0; }
h1 {
  max-width: 760px;
  margin-bottom: 18px;
  font-size: clamp(2.5rem, 6vw, 5rem);
  line-height: 1.04;
  letter-spacing: -.035em;
  font-weight: 600;
}
h1 em { color: var(--accent); font-style: normal; font-weight: 600; }
.hero-description { max-width: 58ch; margin-bottom: 0; color: var(--muted); font-size: 15px; line-height: 1.65; }
.hero-copy .button { margin-top: 24px; }
.button {
  display: inline-flex;
  align-items: center;
  min-height: 42px;
  padding: 0 15px;
  border: 1px solid var(--ink);
  border-radius: 2px;
  color: var(--white);
  background: var(--ink);
  text-decoration: none;
  font-size: 12px;
  font-weight: 600;
  transition: background-color .15s ease;
}
.button:hover { background: #304347; }

.gallery-section, .studies-section { padding-block: 76px 82px; }
.section-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 28px;
  margin-bottom: 42px;
}
.section-heading h2 { margin-bottom: 0; }
h2 { font-size: clamp(2rem, 4vw, 3.5rem); line-height: 1.08; letter-spacing: -.03em; font-weight: 600; }
.section-heading-note { max-width: 38ch; margin: 0 0 3px; color: var(--muted); font-size: 13px; line-height: 1.55; }

.gallery-group-heading {
  display: flex;
  align-items: baseline;
  gap: 18px;
  margin: 0 0 20px;
  padding-top: 24px;
  border-top: 1px solid var(--line);
}
.gallery-group-heading h3 { margin: 0; font: 600 12px var(--mono); letter-spacing: .025em; }
.gallery-group-heading p { max-width: 62ch; margin: 0; color: var(--subtle); font-size: 12px; line-height: 1.5; }
.family-section { margin: 0 0 46px; }
.family-section:last-child { margin-bottom: 0; }
.family-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 18px;
}
.family-heading h4 { margin: 0 0 5px; font-size: 16px; font-weight: 600; letter-spacing: -.015em; }
.family-heading p { max-width: 66ch; margin: 0; color: var(--muted); font-size: 12px; line-height: 1.55; }
.family-details { display: flex; flex-direction: column; align-items: flex-end; gap: 7px; flex: 0 0 auto; }
.family-meta { color: var(--subtle); font: 12px var(--mono); }
.study-jump { color: var(--accent); font-size: 12px; text-decoration: underline; text-underline-offset: 3px; }
.study-jump:hover { color: var(--ink); }
.art-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 24px; }
.art-card { min-width: 0; }
.art-canvas-wrap { position: relative; overflow: hidden; aspect-ratio: 1 / 1.08; background: #e3e8e5; }
.art-canvas-wrap::after { position: absolute; inset: 0; border: 1px solid rgba(27, 41, 44, .1); content: ''; pointer-events: none; }
.art-canvas { display: block; width: 100%; height: 100%; object-fit: cover; }
.art-card-copy { padding-top: 12px; }
.art-card h5 { margin: 0; font-size: 14px; font-weight: 600; letter-spacing: -.015em; }
.art-caption { margin: 6px 0 9px; color: var(--muted); font-size: 12px; line-height: 1.5; }
.term-label { color: var(--accent); font-weight: 600; }
.open-lab { color: var(--ink); font-size: 12px; font-weight: 600; text-decoration: underline; text-underline-offset: 3px; }
.open-lab:hover { color: var(--accent); }
.loading-note { color: var(--muted); font-size: 13px; }
.error-note { padding: 12px 14px; border: 1px solid #d9b5aa; border-radius: 2px; color: #713b2e; background: #f8ebe7; font-size: 12px; line-height: 1.5; }

.lab-section { padding: 74px var(--page-gutter) 78px; background: var(--paper-dark); }
.lab-section > .section { padding-inline: 0; }
.lab-heading { display: flex; align-items: end; justify-content: space-between; gap: 28px; margin-bottom: 34px; }
.lab-heading .section-heading-note { max-width: 34ch; }
.lab-shell { display: grid; grid-template-columns: minmax(245px, .7fr) minmax(0, 1.3fr); gap: 42px; padding-block: 0; }
.lab-controls { min-width: 0; padding: 0 34px 0 0; border-right: 1px solid var(--line); }
.lab-control-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.lab-control-heading h3 { margin: 0; font-size: 14px; font-weight: 600; }
.text-button { border: 0; padding: 4px 0; color: var(--muted); background: transparent; font-size: 12px; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.text-button:hover { color: var(--accent); }
.field-label { display: block; margin: 15px 0 7px; color: var(--muted); font-size: 12px; }
.select-control, .number-control {
  width: 100%;
  min-height: 40px;
  border: 1px solid #c6d0cc;
  border-radius: 2px;
  padding: 0 10px;
  color: var(--ink);
  background: var(--white);
  font-size: 12px;
}
.select-control { cursor: pointer; }
.control-fields { margin-top: 10px; }
.control-field { padding-top: 3px; }
.control-field .field-label { margin-top: 13px; }
.range-topline { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.range-value { color: var(--ink); font: 12px var(--mono); font-variant-numeric: tabular-nums; }
input[type="range"] { width: 100%; height: 20px; margin: 3px 0 2px; accent-color: var(--accent); cursor: pointer; }
.range-limits { display: flex; justify-content: space-between; color: var(--subtle); font: 12px var(--mono); font-variant-numeric: tabular-nums; }
.seed-row { margin-top: 10px; }
.seed-row .number-control { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.lab-family-note { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line); color: var(--muted); font-size: 12px; line-height: 1.55; }
.lab-hint { margin: 16px 0 0; color: var(--subtle); font-size: 12px; line-height: 1.5; }
.lab-preview-wrap { min-width: 0; }
.preview-topline { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 10px; color: var(--ink); font-size: 12px; font-weight: 600; }
#render-status { color: var(--muted); font: 12px var(--mono); text-align: right; }
#render-status[data-error="true"] { color: #713b2e; }
.lab-canvas-frame { position: relative; display: grid; place-items: center; min-height: 320px; aspect-ratio: 1.25 / 1; background: var(--white); border: 1px solid var(--line); }
#lab-canvas { display: block; width: min(100%, 520px); height: auto; aspect-ratio: 1; }
.canvas-placeholder { position: absolute; inset: 0; display: grid; place-items: center; padding: 20px; color: var(--muted); font-size: 12px; text-align: center; pointer-events: none; }
.canvas-placeholder[hidden] { display: none; }
.lab-art-meta { padding-top: 13px; }
.lab-art-meta h3 { margin: 0 0 4px; font-size: 15px; font-weight: 600; }
.lab-art-meta p { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.5; }

.study-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 32px; align-items: start; }
.study-card { min-width: 0; padding-top: 18px; border-top: 1px solid var(--line); }
.study-card h3 { margin: 0 0 9px; font-size: 17px; line-height: 1.25; letter-spacing: -.015em; font-weight: 600; }
.study-card > p:not(.chart-note) { margin-bottom: 12px; color: var(--muted); font-size: 12px; line-height: 1.6; }
.chart-frame { width: 100%; min-height: 220px; }
.chart-frame-small { min-height: 145px; margin: 0 0 6px; }
.chart-frame svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart-tick { fill: #586762; font: 10px var(--mono); }
.chart-axis-label { fill: #475753; font: 10px var(--mono); }
.chart-tick-mobile { font-size: 11px; }
.chart-axis-mobile { font-size: 11px; }
.chart-note { margin: 8px 0 0; color: var(--subtle); font: 12px/1.5 var(--mono); }
.analysis-status { min-height: 16px; margin: 16px 0 0; color: #713b2e; font-size: 12px; }

.site-footer { min-height: 56px; display: flex; align-items: center; border-top: 1px solid var(--line); color: var(--muted); font-size: 12px; }

@media (max-width: 1000px) {
  .art-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); row-gap: 28px; }
  .lab-shell { grid-template-columns: minmax(230px, .8fr) minmax(0, 1.2fr); gap: 28px; }
  .study-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .study-card:last-child { grid-column: 1 / -1; }
  .study-card:last-child .chart-frame { max-width: 640px; }
}

@media (max-width: 700px) {
  .site-header { min-height: 60px; gap: 16px; }
  .site-nav { gap: 16px; }
  .site-nav a { font-size: 12px; }
  .hero { padding-block: 48px 56px; }
  h1 { font-size: clamp(2.35rem, 9vw, 3.75rem); }
  .hero-description { font-size: 14px; }
  .section-heading { align-items: flex-start; flex-direction: column; gap: 12px; margin-bottom: 30px; }
  .gallery-section, .studies-section { padding-block: 58px 62px; }
  .gallery-group-heading { align-items: flex-start; flex-direction: column; gap: 6px; padding-top: 18px; }
  .family-heading { align-items: flex-start; flex-direction: column; gap: 10px; }
  .family-details { align-items: flex-start; flex-direction: row; flex-wrap: wrap; gap: 14px; }
  .art-grid { gap: 22px 14px; }
  .art-canvas-wrap { aspect-ratio: 1 / 1.02; }
  .lab-section { padding: 58px var(--page-gutter) 62px; }
  .lab-heading { align-items: flex-start; flex-direction: column; gap: 12px; margin-bottom: 26px; }
  .lab-shell { display: flex; flex-direction: column-reverse; gap: 24px; }
  .lab-controls { padding: 22px 0 0; border-top: 1px solid var(--line); border-right: 0; }
  .lab-canvas-frame { min-height: 0; aspect-ratio: 1; }
  #lab-canvas { width: 100%; }
  .study-grid { grid-template-columns: 1fr; gap: 28px; }
  .study-card:last-child { grid-column: auto; }
  .study-card:last-child .chart-frame { max-width: none; }
  .chart-frame { min-height: 200px; }
  .chart-frame-small { min-height: 155px; }
}

@media (max-width: 430px) {
  .site-header { align-items: flex-start; flex-direction: column; justify-content: center; gap: 8px; padding-block: 12px; }
  .site-nav { gap: 18px; }
  .art-grid { grid-template-columns: 1fr; }
  .art-canvas-wrap { aspect-ratio: 1 / 1; }
}

/* Learn extends the exhibition's existing type, paper, and ink. */
.learn-section { padding-block: 76px 82px; border-top: 1px solid var(--line); }
.learn-intro { max-width: 68ch; margin-bottom: 32px; color: var(--muted); font-size: 16px; line-height: 1.7; }
.lesson-index { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 32px; margin-bottom: 70px; }
.lesson-group { min-width: 0; border-top: 1px solid var(--line); padding-top: 16px; }
.lesson-group h3 { margin: 0 0 5px; font-size: 20px; font-weight: 600; letter-spacing: -.015em; }
.lesson-group > p { font-size: 13px; color: var(--muted); margin-bottom: 22px; }
.lesson-group ol { list-style: none; margin: 0; padding: 0; }
.lesson-group li { margin-bottom: 22px; }
.lesson-group li > a { font-size: 14px; line-height: 1.5; font-weight: 600; text-underline-offset: 4px; }
.lesson-group li > a:hover, .lesson-group li > a[aria-current] { color: var(--accent); }
.lesson-group li p { font-size: 13px; line-height: 1.5; margin: 7px 0 5px; color: var(--muted); }
.lesson-group small { display: block; font-size: 12px; line-height: 1.5; color: var(--subtle); }
.lesson-code { font: 12px var(--mono); margin-right: 4px; }
.lesson { padding-top: 30px; border-top: 1px solid var(--ink); scroll-margin-top: 24px; }
.lesson[hidden] { display: none; }
.lesson-header { margin-bottom: 38px; }
.lesson-header h3 { max-width: 30ch; font-size: clamp(1.8rem, 3.2vw, 2.7rem); font-weight: 600; letter-spacing: -.025em; line-height: 1.12; margin-bottom: 16px; }
.lesson-header > p { max-width: 70ch; font-size: 16px; color: var(--muted); line-height: 1.65; }
.lesson-header .lesson-prereqs { font-size: 13px; }
.lesson a { text-underline-offset: 4px; }
.lesson-layout { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: clamp(28px, 5vw, 72px); align-items: start; }
.lesson-prose, .lesson-ending { max-width: 70ch; font-size: 16px; line-height: 1.8; overflow-wrap: break-word; }
.lesson h4 { font-size: 18px; line-height: 1.4; font-weight: 600; margin: 30px 0 12px; }
.lesson h4:first-child { margin-top: 0; }
.lesson-prose p, .lesson-ending p { margin-bottom: 18px; }
.lesson-notice { font-size: 21px; line-height: 1.5; }
.lesson-equation { max-width: 100%; overflow-x: auto; padding: 14px 16px; background: var(--paper-dark); font-size: 17px; }
.lesson-equation math { font-family: var(--sans); }
.lesson code { font-family: var(--mono); font-size: .88em; overflow-wrap: anywhere; }
.lesson-demo { min-width: 0; padding: 22px; background: var(--white); border: 1px solid var(--line); }
.lesson-demo > p { font-size: 14px; color: var(--muted); line-height: 1.65; }
.demo-controls { display: flex; flex-wrap: wrap; gap: 12px 10px; }
.demo-field { display: grid; grid-template-columns: 1fr auto; align-items: baseline; width: 100%; gap: 6px 12px; font-size: 13px; line-height: 1.5; }
.demo-field output { font: 12px var(--mono); }
.demo-field input, .demo-field select { grid-column: 1 / -1; width: 100%; min-width: 0; }
.demo-field select { min-height: 40px; color: var(--ink); border: 1px solid var(--line); background: var(--paper); padding: 6px; border-radius: 2px; }
.demo-button { padding: 8px 13px; min-height: 42px; border: 1px solid var(--ink); border-radius: 2px; color: var(--ink); background: var(--white); font-size: 13px; cursor: pointer; }
.demo-button:hover { color: var(--white); background: var(--ink); }
.demo-button:disabled { cursor: default; color: var(--muted); border-color: var(--line); background: var(--paper); }
.demo-field input:disabled { opacity: .45; }
.demo-visual { margin-top: 20px; }
.demo-visual svg { display: block; width: 100%; height: auto; }
.demo-visual svg text { fill: var(--ink); font: 13px var(--sans); }
.demo-result, .demo-fallback { font-size: 13px; line-height: 1.7; margin: 16px 0 0; }
.demo-result { font-variant-numeric: tabular-nums; }
.demo-extra { font-size: 13px; line-height: 1.7; overflow-wrap: anywhere; }
.demo-extra p { margin: 16px 0 0; }
.demo-extra mark { background: #f3ded3; color: var(--ink); padding-inline: 2px; }
.demo-table-wrap { max-height: 290px; overflow: auto; margin-top: 14px; }
.demo-extra table { border-collapse: collapse; width: 100%; text-align: left; font-size: 12px; font-variant-numeric: tabular-nums; }
.demo-extra caption { text-align: left; color: var(--muted); margin-bottom: 8px; }
.demo-extra th, .demo-extra td { border-bottom: 1px solid var(--line); padding: 6px 8px 6px 0; vertical-align: top; }
.lesson-ending { margin-top: 34px; }
.lesson-ending details { border-block: 1px solid var(--line); padding-block: 14px; }
.lesson-ending summary { cursor: pointer; font-size: 14px; font-weight: 600; }
.lesson-ending details p { margin: 14px 0 0; }
.lesson-pagination { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 18px; padding-top: 24px; margin-top: 40px; border-top: 1px solid var(--line); font-size: 14px; }
.exercise-note { font-size: 13px; line-height: 1.65; padding-block: 14px; border-bottom: 1px solid var(--line); }
.lab-family-note a { display: inline-block; margin-top: 6px; text-underline-offset: 3px; }
@media (max-width: 1000px) {
  .lesson-index { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .lesson-layout { grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 28px; }
  .lesson-demo { padding: 16px; }
}
@media (max-width: 800px) {
  .lesson-layout { grid-template-columns: 1fr; }
  .lesson-demo { max-width: 560px; padding: 22px; }
}
@media (max-width: 700px) {
  .learn-section { padding-block: 58px 62px; }
  .lesson-index { gap: 24px; margin-bottom: 44px; }
  .lesson-group h3 { font-size: 18px; }
}
@media (max-width: 480px) {
  .lesson-index { grid-template-columns: 1fr; gap: 16px; }
  .lesson-header { margin-bottom: 26px; }
  .lesson-demo { padding: 14px; }
  .lesson-equation { padding: 10px; font-size: 15px; }
  .demo-visual { overflow-x: auto; }
  .demo-visual svg { min-width: 300px; }
  .demo-visual svg text { font-size: 17px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; }
}
