:root {
  color-scheme: light;
  font-family: Georgia, "Times New Roman", serif;
  color: #292d31;
  background: #faf9f6;
  --paper: #faf9f6;
  --ink: #292d31;
  --muted: #61666b;
  --rule: #d2d2cc;
  --blue: #254c6b;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body { margin: 0; }

button, input, select { font: inherit; }

button, select { border-radius: 0; }

button, input, select, summary { -webkit-tap-highlight-color: transparent; }

[hidden] { display: none !important; }

.experiment {
  width: min(100% - 64px, 1280px);
  margin: 0 auto;
  padding: 18px 0;
}

.introduction { display: flex; align-items: center; justify-content: space-between; gap: 24px; border-bottom: 1px solid var(--rule); padding-bottom: 14px; }

#expand-view { flex: none; font-family: var(--sans); }

h1 {
  margin: 0 0 9px;
  font-size: clamp(28px, 3.5vw, 35px);
  font-weight: 400;
  letter-spacing: -0.035em;
  line-height: 1.12;
}

.introduction p {
  margin: 0;
  font-size: 17px;
  line-height: 1.5;
  max-width: 46em;
}

.experiment-figure { display: grid; grid-template-columns: minmax(0, 1fr) 284px; gap: 28px; align-items: start; margin: 16px 0 0; }

.ink-stage {
  position: relative;
  width: 100%;
  /* Keep the whole observation volume visible and leave room for its controls.
     The minimum protects the visual at high zoom; the page can then scroll. */
  height: clamp(430px, calc(100svh - 186px), 860px);
  overflow: hidden;
  background: var(--paper);
}

#ink-canvas { display: block; width: 100%; height: 100%; }

.boundary-outline {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  pointer-events: none;
  fill: none;
  stroke: var(--muted);
  stroke-opacity: 0.2;
  stroke-width: 1;
}

.boundary-outline line { vector-effect: non-scaling-stroke; }

.stage-message {
  position: absolute;
  left: 24px;
  right: 24px;
  top: 45%;
  margin: 0 auto;
  max-width: 38em;
  text-align: center;
  font-size: 17px;
  line-height: 1.5;
  color: var(--muted);
}

.stage-error { color: #793529; background: var(--paper); padding: 16px; }

.controls {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 17px;
  padding-left: 22px;
  border-left: 1px solid var(--rule);
  font-family: var(--sans);
}

.control-group { min-width: 0; margin: 0; padding: 0; border: 0; }

.control-group + .control-group { padding-top: 13px; border-top: 1px solid var(--rule); }

.control-group legend { padding: 0 0 8px; font-size: 14px; line-height: 1.35; font-weight: 600; }

.control-group + .control-group legend { float: left; width: 100%; }

.group-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: end; gap: 8px 12px; clear: both; }

.playback { display: flex; grid-column: 1 / -1; gap: 7px; }

.full-width, .seed-parameter { grid-column: 1 / -1; }

.ink-selection { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 6px; }

.ink-selection select { min-width: 0; width: 100%; }

.ink-selection button { padding-right: 10px; padding-left: 10px; }

.colour-parameter { display: grid; grid-template-columns: auto 39px minmax(0, 1fr); align-items: center; gap: 8px; }

input[type="color"] { width: 39px; height: 36px; padding: 3px; border: 1px solid #9ba1a4; border-radius: 0; background: var(--paper); cursor: pointer; }

input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }

input[type="color"]::-webkit-color-swatch { border: 0; }

input[type="color"]::-moz-color-swatch { border: 0; }

#ink-hex { width: 100%; min-width: 0; font-variant-numeric: tabular-nums; }

button {
  min-height: 38px;
  padding: 7px 14px;
  border: 1px solid #9ba1a4;
  background: transparent;
  color: var(--ink);
  font-size: 14px;
  line-height: 1.4;
  cursor: pointer;
}

#toggle { min-width: 76px; border-color: var(--blue); color: var(--blue); }

button:hover { background: #eceeea; }

button:active { background: #e2e6e4; }

button:disabled { opacity: 0.5; cursor: default; }

:focus-visible { outline: 2px solid var(--blue); outline-offset: 4px; }

.parameter { min-width: 0; }

.parameter-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }

.parameter label, .parameter output { font-size: 14px; line-height: 1.5; }

.parameter-heading output { color: var(--blue); font-variant-numeric: tabular-nums; white-space: nowrap; }

.select-parameter label { display: block; margin-bottom: 4px; }

.select-parameter label.visually-hidden { margin: -1px; }

.select-parameter select { display: block; width: 100%; }

.seed-controls { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 7px; }

.seed-parameter { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 9px; }

.inline-parameter { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 9px; }

.inline-parameter label { margin: 0; }

.seed-controls input { min-width: 0; width: 100%; }

.seed-controls button { white-space: nowrap; }

input[type="range"] {
  display: block;
  width: 100%;
  height: 26px;
  margin: 5px 0 0;
  padding: 0;
  accent-color: var(--blue);
  cursor: pointer;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.model-details { margin-top: 12px; padding-top: 11px; border-top: 1px solid var(--rule); }

.model-details summary { width: fit-content; font: 14px/1.5 var(--sans); cursor: pointer; color: #4e5459; }

.model-details[open] summary { color: var(--ink); }

.model-copy { max-width: 49em; padding-top: 2px; }

.model-copy p { margin: 13px 0 0; font-size: 16px; line-height: 1.6; }

.model-copy section { margin-top: 27px; }

.model-copy h2 {
  margin: 0;
  font-size: 22px;
  line-height: 1.3;
  font-weight: 400;
  letter-spacing: -0.015em;
}

.equation {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr);
  align-items: center;
  gap: 12px 22px;
  margin: 21px 0;
}

.equation-label { color: var(--muted); font: 14px/1.5 var(--sans); }

.equation math { margin: 0; font-family: "Cambria Math", "STIX Two Math", math; font-size: 20px; text-align: left; }
.equation mtable { math-style: normal; }
.equation mi[mathvariant="bold"] { font-weight: 700; }

.model-copy p math { font-size: 1em; }

.math-term { white-space: nowrap; }

.model-parameters {
  width: 100%;
  border-collapse: collapse;
  margin-top: 22px;
  font-size: 15px;
  line-height: 1.5;
  text-align: left;
}

.model-parameters caption { margin-bottom: 9px; text-align: left; font: 14px/1.5 var(--sans); color: var(--muted); }

.model-parameters th, .model-parameters td { padding: 8px 14px 8px 0; border-bottom: 1px solid var(--rule); vertical-align: top; }

.model-parameters th { font-weight: 400; }

.model-parameters thead th { font: 14px/1.5 var(--sans); color: var(--muted); border-top: 1px solid var(--rule); }

.model-parameters td:last-child { padding-right: 0; }

.model-parameters tbody th { width: 45%; }

select, input[type="number"], input[type="text"] { min-height: 36px; padding: 5px 8px; border: 1px solid #9ba1a4; border-radius: 0; background: var(--paper); color: var(--ink); font-size: 14px; }

select { padding-right: 24px; }

.no-script { border-top: 1px solid var(--rule); padding-top: 15px; font-size: 16px; line-height: 1.5; }

@media (min-width: 640px) and (max-width: 899px) {
  .experiment { width: calc(100% - 40px); }
  .experiment-figure { grid-template-columns: minmax(0, 1fr) 254px; gap: 18px; }
  .controls { padding-left: 16px; }
  .group-fields { column-gap: 10px; }
}

@media (max-width: 639px) {
  .experiment { width: calc(100% - 36px); padding: 16px 0; }
  .introduction { padding-bottom: 12px; }
  .introduction p { font-size: 16px; }
  .experiment-figure { display: block; margin-top: 10px; }
  .ink-stage { height: clamp(300px, 58svh, 540px); }
  .controls { border-left: 0; border-top: 1px solid var(--rule); padding: 16px 0 0; gap: 15px; }
  .group-fields { gap: 9px 18px; }
  button { padding-right: 12px; padding-left: 12px; }
  #toggle { min-width: 72px; }
  .equation { grid-template-columns: 1fr; gap: 9px; margin: 20px 0; }
  .equation math { font-size: 19px; }
  .model-copy h2 { font-size: 21px; }
}

@media (min-width: 640px) and (max-height: 760px) {
  .experiment { padding: 10px 0; }
  .introduction { padding-bottom: 10px; }
  .experiment-figure { margin-top: 12px; }
  .controls { gap: 7px; }
  .control-group + .control-group { padding-top: 8px; }
  .control-group legend { padding-bottom: 5px; }
  .group-fields { row-gap: 4px; }
  .controls button, .controls select, .controls input[type="number"], .controls input[type="text"] { min-height: 32px; padding-top: 4px; padding-bottom: 4px; }
  .controls input[type="color"] { height: 32px; }
  .controls input[type="range"] { height: 22px; margin-top: 2px; }
  .ink-stage { height: clamp(280px, calc(100svh - 164px), 600px); }
}

@media (max-width: 359px) {
  .introduction { gap: 10px; flex-wrap: wrap; }
  .group-fields { column-gap: 12px; }
}

@media (pointer: coarse) {
  button, select, input[type="number"], input[type="text"], .controls button, .controls select, .controls input[type="number"], .controls input[type="text"] { min-height: 44px; }
  select, input[type="number"], input[type="text"] { font-size: 16px; }
  input[type="color"], .controls input[type="color"] { height: 44px; width: 44px; }
  .colour-parameter { grid-template-columns: auto 44px minmax(0, 1fr); }
  input[type="range"], .controls input[type="range"] { height: 44px; }
  .model-details summary { min-height: 44px; padding: 10px 0; }
}

.experiment:fullscreen {
  width: 100%; min-height: 100%; padding: 20px 28px; overflow: auto; background: var(--paper);
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; }
}

body{--serif:"EB Garamond",Georgia,serif;} h1,h2,h3,.model-description{font-family:var(--tool-serif,"EB Garamond",Georgia,serif)}
