:root {
  color-scheme: light;
  --ink: #173747;
  --muted: #536b78;
  --teal: #096b70;
  --teal-dark: #075156;
  --paper: #f3f6f7;
  --white: #ffffff;
  --line: #cfdbdf;
  --soft: #e8f0f2;
  --focus: #00777e;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--paper);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }
button, input, select { font: inherit; }
button, a, input, select, summary { -webkit-tap-highlight-color: transparent; }
button, select, summary, input[type="checkbox"], input[type="range"] { cursor: pointer; }
button { min-height: 40px; border: 1px solid transparent; border-radius: 5px; padding: 8px 13px; font-size: 0.87rem; font-weight: 600; transition: background-color 160ms ease-out, border-color 160ms ease-out; }
button:disabled { cursor: not-allowed; opacity: 0.55; }
a { color: var(--teal); text-decoration-thickness: 1px; text-underline-offset: 4px; }
a:hover { color: var(--teal-dark); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }
canvas:focus-visible { outline-color: #e5c47d; outline-offset: -4px; }
h1, h2, h3, p { margin: 0; }
h1, h2, h3 { line-height: 1.25; text-wrap: balance; }
h1 { font-size: 1.65rem; font-weight: 600; letter-spacing: -0.02em; }
h2 { font-size: 1.2rem; font-weight: 650; letter-spacing: -0.015em; }
h3 { font-size: 0.95rem; font-weight: 650; }
p { text-wrap: pretty; }
code, dd, output, input[type="number"], .element-count { font-family: Consolas, "SFMono-Regular", monospace; font-variant-numeric: tabular-nums; }
code { font-size: 0.9em; }
.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; }
.skip-link { position: absolute; left: 20px; top: -80px; background: var(--white); z-index: 20; padding: 12px; }
.skip-link:focus { top: 8px; }
.site-header { max-width: 1464px; margin: auto; padding: 18px 36px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; gap: 24px; }
.brand { display: inline-flex; gap: 13px; align-items: center; text-decoration: none; font-size: 1.45rem; font-weight: 650; letter-spacing: -0.02em; color: var(--ink); }
.brand svg { color: var(--teal); flex-shrink: 0; }
.brand-subtitle { display: block; font-size: 0.78rem; font-weight: 400; color: var(--muted); letter-spacing: 0; margin-top: 1px; }
.site-header nav { display: flex; align-items: center; gap: 25px; font-size: 0.87rem; }
.site-header nav a { text-decoration: none; font-weight: 600; }
.browser-note { color: var(--muted); padding-left: 25px; border-left: 1px solid var(--line); }
main { max-width: 1464px; padding: 24px 36px 0; margin: auto; }
.experiment-heading { display: flex; justify-content: space-between; align-items: center; gap: 28px; margin-bottom: 25px; scroll-margin-top: 20px; }
.experiment-heading p { color: var(--muted); font-size: 0.93rem; margin-top: 8px; }
.preset-controls { flex: 0 0 315px; }
.preset-controls > label { display: block; font-size: 0.8rem; color: var(--muted); margin-bottom: 5px; }
.preset-row { display: flex; gap: 8px; }
select, input[type="number"] { min-height: 40px; border: 1px solid #7d939e; border-radius: 4px; background: var(--white); color: var(--ink); padding: 7px 9px; }
select { min-width: 0; max-width: 100%; padding-right: 26px; font-size: 0.88rem; }
.preset-row select { flex: 1; width: 100%; }
input[type="number"] { width: 100%; font-size: 0.88rem; }
input:invalid:not(:focus) { border-color: #a23c2e; }
input[type="range"] { min-width: 0; width: 100%; accent-color: var(--teal); height: 25px; margin: 0; }
input[type="checkbox"] { width: 15px; height: 15px; accent-color: var(--teal); margin: 0; flex-shrink: 0; }
.primary-button { color: var(--white); background: var(--teal); }
.primary-button:hover:not(:disabled) { background: var(--teal-dark); }
.quiet-button { background: var(--white); color: var(--ink); border-color: var(--line); }
.quiet-button:hover:not(:disabled) { background: var(--soft); border-color: #a8c0c8; }
.secondary-button { background: var(--soft); color: var(--teal-dark); border-color: #bdcfd5; }
.secondary-button:hover:not(:disabled) { background: #d7e8eb; }
.experiment-grid { display: grid; grid-template-columns: minmax(0, 1fr) 326px; grid-template-areas: "stage controls"; gap: 24px 28px; align-items: start; }
.stage { grid-area: stage; min-width: 0; }
.stage-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 14px; padding: 0 0 12px; }
.field-heading { display: flex; align-items: center; gap: 12px; }
.play-state { color: var(--teal-dark); font-size: 0.73rem; padding: 2px 6px; background: #e1efed; border-radius: 3px; }
.play-state.is-paused { background: #e6eaed; color: #536270; }
.playback-controls { display: flex; gap: 7px; }
.playback-controls button { min-height: 40px; padding: 6px 10px; font-size: 0.8rem; }
.tunnel { position: relative; border-radius: 4px; overflow: hidden; background: #122c3b; }
#flow-canvas { display: block; width: 100%; height: auto; aspect-ratio: 1.65; min-height: 370px; touch-action: pan-y; }
.plot-caption { position: absolute; pointer-events: none; top: 13px; left: 14px; right: 14px; display: flex; justify-content: space-between; gap: 16px; font-size: 0.72rem; color: #d3e2e8; }
.plot-caption > span:first-child { padding: 3px 6px; background: #122c3bed; border: 1px solid #385464; border-radius: 3px; }
#tracer-clock { white-space: nowrap; font-family: Consolas, monospace; padding-top: 4px; }
.color-key { display: flex; align-items: center; gap: 8px; padding: 10px 14px; color: #d3e2e8; font-size: 0.72rem; border-top: 1px solid #385464; }
.color-ramp { width: 65px; height: 5px; border-radius: 1px; background: linear-gradient(90deg, #73bfcf, #ddd69a, #f39971); }
.color-cap { color: #b6cbd5; }
.canvas-help { font-size: 0.74rem; color: var(--muted); margin-top: 9px; line-height: 1.5; }
.view-options { display: flex; flex-wrap: wrap; align-items: center; gap: 3px 18px; padding: 10px 0 12px; border-bottom: 1px solid var(--line); }
.view-options > label { display: inline-flex; align-items: center; gap: 6px; min-height: 34px; font-size: 0.8rem; cursor: pointer; }
.view-options .rate-control { margin-left: auto; gap: 8px; }
.rate-control input { width: 75px; }
.rate-control output { width: 34px; color: var(--teal-dark); font-size: 0.78rem; }
.probe-readout { display: flex; align-items: center; gap: 20px; padding: 16px 0; border-bottom: 1px solid var(--line); }
.probe-readout > div { flex: 0 0 137px; }
.probe-readout h3 { font-size: 0.9rem; }
.probe-readout > div span { font-size: 0.74rem; color: var(--muted); }
.probe-readout dl { display: grid; grid-template-columns: 1fr 1.1fr 0.7fr; width: 100%; gap: 18px; margin: 0; }
.probe-readout dt { font-size: 0.77rem; color: var(--muted); }
.probe-readout dt span { font-size: 0.7rem; }
.probe-readout dd { font-size: 0.85rem; margin: 3px 0 0; min-height: 20px; }
.model-assumptions { font-size: 0.76rem; color: var(--muted); margin-top: 12px; max-width: 90ch; }
.controls { grid-area: controls; border-left: 1px solid var(--line); padding: 0 0 0 22px; min-width: 0; }
.mode-switch { display: flex; border-bottom: 1px solid var(--line); margin: -1px -1px 21px; gap: 4px; padding-bottom: 10px; }
.mode-switch button { flex: 1; background: transparent; color: var(--muted); padding: 9px 5px; font-size: 0.84rem; }
.mode-switch button[aria-pressed="true"] { background: var(--soft); color: var(--teal-dark); }
.mode-switch button:hover { background: var(--soft); }
.control-heading { display: flex; justify-content: space-between; align-items: center; gap: 7px; margin-bottom: 8px; }
.control-heading h2 { font-size: 1.12rem; }
.control-intro { color: var(--muted); font-size: 0.82rem; margin-bottom: 22px; }
.parameter { margin-top: 19px; }
.parameter label, .position-row label { display: flex; justify-content: space-between; gap: 8px; font-size: 0.83rem; font-weight: 600; }
.parameter label > span:last-child, .position-row label span { color: var(--muted); font-size: 0.75rem; font-weight: 400; }
.range-row { display: grid; grid-template-columns: minmax(0, 1fr) 75px; align-items: center; gap: 13px; margin-top: 7px; }
.field-hint { font-size: 0.76rem; color: var(--muted); margin-top: 7px; line-height: 1.55; }
.experiment-status { color: var(--muted); font-size: 0.74rem; border-top: 1px solid var(--line); padding-top: 12px; margin-top: 17px; min-height: 35px; }
.input-error { color: #943d2b; background: #fff0e8; padding: 10px; border: 1px solid #dcb6a6; border-radius: 3px; font-size: 0.8rem; margin-top: 15px; }
.add-element-row { display: flex; gap: 8px; margin-bottom: 12px; }
.add-element-row select { flex: 1; }
.element-count { font-size: 0.75rem; color: var(--muted); }
.element-list { list-style: none; padding: 0; margin: 0; }
.element-list li { display: flex; gap: 2px; border-bottom: 1px solid #e0e8eb; align-items: center; }
.element-list .select-element { display: flex; align-items: center; gap: 9px; border-radius: 3px; flex: 1; min-width: 0; text-align: left; padding: 9px 6px; background: transparent; color: var(--ink); font-size: 0.8rem; font-weight: 500; }
.select-element > .element-index { width: 20px; font-family: Consolas, monospace; color: var(--muted); font-size: 0.7rem; }
.select-element > .element-strength { font-family: Consolas, monospace; color: var(--muted); font-size: 0.74rem; margin-left: auto; }
.element-list .select-element[aria-pressed="true"] { color: var(--teal-dark); background: #e9f3f2; }
.element-list .select-element:hover { background: var(--soft); }
.element-list .remove-element { background: transparent; color: var(--muted); font-size: 1rem; padding: 5px 9px; flex-shrink: 0; }
.element-list .remove-element:hover { color: #943d2b; background: #fff0e8; }
.element-editor { margin-top: 22px; }
.element-editor h3 { padding-bottom: 2px; }
.position-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 17px; }
.position-row input { margin-top: 7px; }
.direction-field label { align-items: center; }
.builder-boundary-note { font-size: 0.76rem; color: var(--muted); margin-top: 20px; border-top: 1px solid var(--line); padding-top: 13px; }
.empty-state { background: var(--paper); border: 1px dashed #b6cbd1; padding: 14px; color: var(--muted); font-size: 0.82rem; border-radius: 4px; }
.flow-exercise { font-size: 0.84rem; color: var(--muted); margin-top: 18px; max-width: 73ch; line-height: 1.65; }
.flow-exercise strong { color: var(--ink); font-weight: 600; }
.learning-section { margin-top: 42px; padding-top: 28px; border-top: 1px solid var(--line); scroll-margin-top: 25px; }
.learning-heading { display: flex; justify-content: space-between; gap: 25px; align-items: baseline; margin-bottom: 18px; }
.learning-heading h2 { font-size: 1.3rem; }
.learning-heading p { font-size: 0.83rem; color: var(--muted); }
.learning-section details { border-bottom: 1px solid var(--line); }
.learning-section summary { padding: 17px 3px; font-weight: 600; font-size: 0.93rem; list-style-position: outside; margin-left: 19px; }
.learning-section summary::marker { color: var(--teal); }
.learning-section details[open] summary { color: var(--teal-dark); }
.lesson-body { max-width: 78ch; padding: 0 0 22px 22px; font-size: 0.9rem; line-height: 1.7; }
.lesson-body p + p { margin-top: 14px; }
.lesson-formula { padding: 13px 15px; background: var(--soft); border-radius: 3px; }
.flow-definitions { margin-block: 16px; }
.flow-definitions > div { display: grid; grid-template-columns: 90px 1fr; gap: 14px; padding-block: 6px; }
.flow-definitions dt { font-weight: 600; }
.flow-definitions dd { margin: 0; font-family: inherit; color: var(--muted); }
.flapping-note { max-width: 74ch; margin-top: 28px; font-size: 0.9rem; line-height: 1.7; }
.flapping-note p { margin-top: 12px; }
.flapping-note .source-note { color: var(--muted); font-size: 0.78rem; }
.code-map { padding-left: 19px; margin-top: 0; }
.code-map li { margin-bottom: 10px; }
footer { display: flex; justify-content: space-between; gap: 24px; font-size: 0.74rem; color: var(--muted); padding-block: 23px; margin-top: 10px; }
.noscript-note { padding: 20px; margin: 20px; background: #fff0e8; color: #943d2b; }
@media (min-width: 1400px) { #flow-canvas { min-height: 475px; } }
@media (max-width: 1100px) {
  main { padding-inline: 25px; }
  .site-header { padding-inline: 25px; }
  .experiment-grid { grid-template-columns: minmax(0, 1fr) 296px; gap: 22px; }
  .controls { padding-left: 18px; }
  .experiment-heading { gap: 20px; }
  h1 { font-size: 1.6rem; }
  .probe-readout { display: block; }
  .probe-readout > div { display: flex; gap: 12px; align-items: center; margin-bottom: 9px; }
  .view-options .rate-control { margin-left: 0; }
  .learning-heading { display: block; }
  .learning-heading p { margin-top: 8px; }
}
@media (max-width: 820px) {
  .experiment-grid { grid-template-columns: 1fr; grid-template-areas: "stage" "controls"; gap: 28px; }
  .experiment-heading { align-items: start; }
  .preset-controls { flex-basis: 265px; }
  .controls { padding: 20px 0 0; border-left: none; border-top: 1px solid var(--line); }
  .mode-switch { max-width: 400px; }
  .control-heading { justify-content: start; gap: 14px; }
  .probe-readout { display: flex; }
  .probe-readout > div { display: block; margin-bottom: 0; }
  .view-options .rate-control { margin-left: auto; }
  .element-list { max-width: 560px; }
  .element-editor { max-width: 560px; }
  #flow-canvas { min-height: 345px; }
}
@media (max-width: 560px) {
  :root { font-size: 15px; }
  main { padding: 23px 16px 0; }
  .site-header { padding: 17px 16px; gap: 12px; }
  .brand { font-size: 1.5rem; gap: 9px; }
  .brand svg { width: 33px; height: 29px; }
  .brand-subtitle, .browser-note { display: none; }
  .site-header nav { font-size: 0.8rem; }
  .experiment-heading { display: block; margin-bottom: 23px; }
  h1 { font-size: 1.65rem; }
  .experiment-heading p { font-size: 0.85rem; margin-top: 7px; max-width: 38ch; }
  .preset-controls { margin-top: 20px; }
  .preset-row select { font-size: 0.88rem; }
  button, select, input[type="number"] { min-height: 44px; }
  .stage-toolbar { gap: 8px; }
  .stage-toolbar h2 { font-size: 1.06rem; }
  .field-heading { gap: 7px; flex-wrap: wrap; }
  .play-state { font-size: 0.64rem; }
  .playback-controls { gap: 5px; }
  .playback-controls button { min-height: 40px; font-size: 0.73rem; padding-inline: 8px; }
  #flow-canvas { aspect-ratio: 1.06; min-height: 300px; }
  .plot-caption { top: 10px; left: 9px; right: 9px; gap: 6px; font-size: 0.62rem; }
  .plot-caption > span:first-child { padding: 3px 4px; }
  .color-key { gap: 7px; padding: 10px 11px; font-size: 0.66rem; }
  .color-ramp { width: 45px; }
  .view-options { gap: 1px 16px; }
  .view-options > label { min-height: 42px; font-size: 0.77rem; }
  .view-options .rate-control { margin-left: 0; }
  .rate-control input { width: 120px; }
  .probe-readout { display: block; padding-block: 14px; }
  .probe-readout > div { display: flex; align-items: center; margin-bottom: 10px; gap: 12px; }
  .probe-readout dl { gap: 11px; grid-template-columns: 1.15fr 1.2fr 0.6fr; }
  .probe-readout dd { font-size: 0.75rem; }
  .probe-readout dt { font-size: 0.73rem; }
  .canvas-help, .model-assumptions { font-size: 0.71rem; }
  .controls { padding: 18px 0 0; }
  #cylinder-panel .parameter { margin-top: 20px; }
  .control-heading { justify-content: space-between; gap: 7px; }
  .control-intro { margin-bottom: 20px; }
  .mode-switch { margin-bottom: 20px; }
  .mode-switch button { font-size: 0.88rem; }
  .learning-section { margin-top: 30px; padding-top: 23px; }
  .learning-heading h2 { font-size: 1.2rem; }
  .learning-section summary { font-size: 0.87rem; padding-block: 16px; }
  .lesson-body { padding-left: 0; font-size: 0.87rem; }
  footer { display: block; font-size: 0.68rem; padding-block: 18px; }
  footer span { display: block; margin-bottom: 6px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { scroll-behavior: auto !important; transition-duration: 0.01ms !important; } }
