@font-face {
  font-family: "Instrument Sans";
  src: url("fonts/instrument-sans.woff2") format("woff2");
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
}

@font-face {
  font-family: "IBM Plex Mono";
  src: url("fonts/ibm-plex-mono.woff2") format("woff2");
  font-style: normal;
  font-weight: 400;
  font-display: swap;
}

:root {
  color-scheme: light;
  --paper: #f3f5ef;
  --surface: #fcfdf9;
  --ink: #182d28;
  --muted: #51655d;
  --line: #dbe5db;
  --teal: #117666;
  --teal-dark: #0d5d50;
  --teal-pale: #e2f2e9;
  --orange: #a75936;
  --film: #121e27;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
  font-family: "Instrument Sans", Arial, sans-serif;
  font-synthesis: none;
  background: var(--paper);
  color: var(--ink);
}

*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; min-width: 300px; }
button, input { font: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
a { color: var(--teal-dark); text-underline-offset: 3px; }
button:focus-visible, input:focus-visible, summary:focus-visible, a:focus-visible, .film-plane:focus-visible {
  outline: 3px solid #399989;
  outline-offset: 3px;
}
button:disabled { cursor: default; opacity: .48; }

.topbar { border-bottom: 1px solid var(--line); background: var(--surface); }
.topbar-inner, .page { width: min(1360px, calc(100% - 80px)); margin-inline: auto; }
.topbar-inner { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 65px; }
.brand, .topbar-actions { display: flex; align-items: center; gap: 12px; }
.brand { font-size: 16px; font-weight: 700; letter-spacing: -.03em; }
.brand-mark { position: relative; display: grid; place-items: center; width: 29px; height: 29px; border-radius: 8px; background: #153e35; flex: none; }
.brand-mark::before, .brand-mark::after, .brand-mark i { position: absolute; content: ""; border: 1px solid #9ae0c7; border-radius: 3px; width: 16px; height: 16px; }
.brand-mark::after { width: 10px; height: 10px; }
.brand-mark i { width: 4px; height: 4px; background: #9ae0c7; border: 0; }

.button { display: inline-flex; justify-content: center; align-items: center; gap: 8px; min-height: 40px; padding: 0 14px; border: 1px solid transparent; border-radius: 8px; color: var(--ink); background: transparent; font-size: 14px; font-weight: 650; line-height: 1.1; text-decoration: none; white-space: nowrap; }
.button-primary { background: var(--teal-dark); color: #fbfff9; border-color: var(--teal-dark); }
.button-primary:hover:not(:disabled) { background: #164e44; }
.button-quiet:hover:not(:disabled) { background: #ecf1e9; }
.button-quiet { color: var(--muted); }
.button-outline { border-color: #cfddd1; background: #fbfcf7; }
.button-outline:hover:not(:disabled) { background: #edf4ec; }
.button-small { min-height: 34px; padding-inline: 11px; font-size: 13px; }
.button-selected { background: var(--teal-pale); color: var(--teal-dark); border-color: #cae6d6; }
.button-link { min-height: 28px; padding: 0; color: var(--teal-dark); font-size: 12px; text-decoration: underline; text-underline-offset: 3px; }
.button-link:hover:not(:disabled) { color: var(--ink); }
.upload-mark { font: 18px/1 var(--mono); margin-top: -1px; }

.page { padding: 30px 0 28px; }
.page-intro { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 24px; }
h1, h2, h3, p { margin: 0; }
h1 { max-width: 880px; font-size: clamp(31px, 4vw, 53px); letter-spacing: -.058em; line-height: 1.04; font-weight: 700; }
.page-intro p { margin-top: 10px; color: var(--muted); font-size: clamp(15px, 1.55vw, 18px); line-height: 1.43; }
.model-link { display: flex; align-items: center; gap: 12px; margin-bottom: 3px; padding: 8px 0; border-bottom: 1px solid #98b9a6; color: var(--teal-dark); white-space: nowrap; font: 12px var(--mono); text-decoration: none; }
.model-link:hover { border-color: var(--teal-dark); }
.notice { background: #fff2e6; border: 1px solid #e3baa0; color: #743c27; padding: 12px 16px; margin-bottom: 12px; border-radius: 9px; font-size: 14px; }

.lab-grid { display: grid; grid-template-columns: minmax(0, 1.94fr) minmax(300px, 1fr); gap: 18px; align-items: start; }
.panel { min-width: 0; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); box-shadow: 0 2px 8px rgba(25, 55, 42, .035); }
.viewer { padding: 17px 17px 15px; }
.viewer-header, .parameters-title, .section-line, .outcomes-header { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
h2 { font-size: 21px; letter-spacing: -.035em; line-height: 1.16; font-weight: 700; }
h3 { font-size: 14px; font-weight: 700; letter-spacing: -.01em; }
.image-heading { min-width: 0; }
.image-heading h2 { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.image-heading p, .outcomes-header p { color: var(--muted); margin-top: 5px; font-size: 12px; }
.segments { display: inline-flex; flex-shrink: 0; padding: 3px; border: 1px solid #e4eae2; border-radius: 8px; background: #edf1eb; gap: 2px; }
.segments button { border: 1px solid transparent; min-height: 28px; padding: 0 9px; border-radius: 5px; background: transparent; color: var(--muted); font-size: 12px; font-weight: 650; white-space: nowrap; }
.segments button[aria-pressed="true"] { color: var(--teal-dark); background: #fff; border-color: #d8e4da; box-shadow: 0 1px 2px #29443113; }
.segments button:hover:not(:disabled):not([aria-pressed="true"]) { color: var(--ink); background: #e2eae1; }

.film-stage {
  position: relative;
  display: grid;
  place-items: center;
  height: clamp(340px, 27vw, 415px);
  margin-top: 14px;
  overflow: hidden;
  border-radius: 10px;
  isolation: isolate;
  background-color: var(--film);
  background-image: radial-gradient(ellipse at center, #263740, #121e27 74%);
  box-shadow: inset 0 0 0 1px #2d3c43;
}
.film-stage::before { position: absolute; inset: 0; z-index: -1; content: ""; background-image: linear-gradient(#9ac1ba0b 1px, transparent 1px), linear-gradient(90deg, #9ac1ba0b 1px, transparent 1px); background-size: 24px 24px; }
.film-stage.dragging { outline: 3px solid #4bcead; outline-offset: 2px; }
.film-plane { position: relative; width: min(78%, 360px); height: 90%; cursor: crosshair; }
.film-plane img, .film-plane canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; user-select: none; pointer-events: none; }
.film-plane img { object-fit: fill; outline: 1px solid #66807b55; }
.film-readout { position: absolute; z-index: 2; display: flex; gap: 7px; flex-direction: column; top: 14px; left: 14px; color: #b9cfcb; font: 10px var(--mono); pointer-events: none; }
.film-readout span, .film-readout strong { align-self: flex-start; padding: 4px 6px; border-radius: 4px; background: #0d1b24cc; font-weight: 400; }
.film-readout strong { color: #e6fff4; font-size: 12px; }
.seed-marker { position: absolute; display: block; transform: translate(-50%, -50%); width: 15px; height: 15px; border-radius: 50%; border: 1px solid #efffd9; background: #2f6d5d44; box-shadow: 0 0 0 2px #20373399; pointer-events: none; }
.seed-marker::before, .seed-marker::after { content: ""; position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); background: #efffd9; }
.seed-marker::before { width: 7px; height: 1px; }
.seed-marker::after { width: 1px; height: 7px; }
.film-plane.is-calibrating .seed-marker { border-color: #f7cf7a; }
.scale-bar, .density-key { position: absolute; z-index: 2; bottom: 12px; pointer-events: none; padding: 6px; border-radius: 5px; background: #0d1a23d9; color: #e0f1e8; font: 10px var(--mono); }
.scale-bar { left: 14px; display: grid; gap: 4px; }
#scale-ticks { height: 5px; border: 1px solid #e0f1e8; border-top: 0; min-width: 1px; }
.density-key { right: 14px; width: 116px; display: grid; gap: 4px; white-space: nowrap; }
.density-ramp { height: 6px; border-radius: 3px; background: linear-gradient(90deg, #197d7d, #38c2a6, #f1cb6d, #f17e56); }
.key-bounds { display: flex; justify-content: space-between; }

.image-actions { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.image-buttons { display: flex; align-items: center; gap: 7px; flex-shrink: 0; }
.seed-help { color: var(--muted); font-size: 12px; text-align: right; line-height: 1.35; }
.timeline { display: flex; align-items: center; gap: 14px; padding-top: 13px; }
.button-play { color: var(--teal-dark); border-color: #cee3d2; background: #e7f2e8; min-width: 83px; }
.button-play:hover:not(:disabled) { background: #d9ebdd; }
.play-icon { width: 0; height: 0; border-top: 5px solid transparent; border-bottom: 5px solid transparent; border-left: 7px solid var(--teal-dark); }
.button-play[aria-pressed="true"] .play-icon { width: 8px; height: 10px; border: 0; border-right: 2px solid var(--teal-dark); border-left: 2px solid var(--teal-dark); }
.time-field { flex: 1; min-width: 0; }
.time-label, .range-label { display: flex; align-items: baseline; justify-content: space-between; gap: 6px; color: var(--ink); font-size: 13px; font-weight: 650; }
.time-label output, .range-label output { font: 12px var(--mono); color: var(--teal-dark); white-space: nowrap; }
.time-ticks { position: relative; height: 13px; color: var(--muted); font: 10px var(--mono); margin: 1px 7px 0; }
.time-ticks span { position: absolute; left: 50%; transform: translateX(-50%); }
.time-ticks span:first-child { left: 0; transform: none; }
.time-ticks span:nth-child(2) { left: 25%; }
.time-ticks span:nth-child(4) { left: 75%; }
.time-ticks span:last-child { left: auto; right: 0; transform: none; }

.parameters { padding: 17px 18px 0; }
.parameters-title { min-height: 41px; margin-bottom: 4px; }
.settings-section { padding: 15px 0 13px; border-top: 1px solid var(--line); }
.settings-section h3 { margin-bottom: 12px; }
.range-field + .range-field { margin-top: 8px; }
.symbol { display: inline-block; padding-left: 3px; color: var(--teal); font: 12px var(--mono); }
input[type="range"] { --filled: 0%; display: block; margin: 3px 0 0; padding: 0; width: 100%; height: 19px; cursor: pointer; appearance: none; background: transparent; }
input[type="range"]:disabled { opacity: .39; cursor: default; }
input[type="range"]::-webkit-slider-runnable-track { height: 4px; border-radius: 12px; background: linear-gradient(90deg, #278776 var(--filled), #dbe5db var(--filled)); }
input[type="range"]::-moz-range-track { height: 4px; border-radius: 12px; background: linear-gradient(90deg, #278776 var(--filled), #dbe5db var(--filled)); }
input[type="range"]::-webkit-slider-thumb { appearance: none; width: 15px; height: 15px; margin-top: -5.5px; border: 2px solid #fafdf6; background: #167767; border-radius: 50%; box-shadow: 0 0 0 1px #187e6c; }
input[type="range"]::-moz-range-thumb { width: 12px; height: 12px; border: 2px solid #fafdf6; background: #167767; border-radius: 50%; box-shadow: 0 0 0 1px #187e6c; }
.section-line { margin-bottom: 10px; }
.section-line h3 { margin: 0; }
.switch { position: relative; display: inline-flex; align-items: center; cursor: pointer; }
.switch input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; margin: 0; cursor: pointer; }
.switch-track { pointer-events: none; display: block; width: 37px; height: 20px; border-radius: 20px; background: #cddbd1; }
.switch-track::after { content: ""; display: block; width: 14px; height: 14px; border-radius: 100%; margin: 3px; background: #fff; box-shadow: 0 1px 2px #253c3066; }
.switch input:checked + .switch-track { background: var(--teal); }
.switch input:checked + .switch-track::after { transform: translateX(17px); }
.switch input:focus-visible + .switch-track { outline: 3px solid #399989; outline-offset: 3px; }
.treatment-fields { border: 0; padding: 0; margin: 0; min-width: 0; }
.treatment-fields:disabled { opacity: .56; }
.duration-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 9px 0 11px; }
.duration-fields label, .calibration-controls label { display: grid; gap: 5px; min-width: 0; color: var(--muted); font-size: 12px; font-weight: 650; }
input[type="number"] { min-width: 0; width: 100%; min-height: 34px; border: 1px solid #d8e3d9; border-radius: 6px; padding: 5px 8px; color: var(--ink); background: #f5f8f2; font: 13px var(--mono); }
input[type="number"]:disabled { opacity: .55; }
.scenario-segments { display: flex; }
.scenario-segments button { flex: 1 1 0; }
.settings-display { padding-block: 12px; }

details > summary { cursor: pointer; list-style: none; }
details > summary::-webkit-details-marker { display: none; }
details > summary::after { content: "+"; justify-self: end; color: var(--teal-dark); font: 17px var(--mono); }
details[open] > summary::after { content: "−"; }
.scale-settings { border-top: 1px solid var(--line); }
.scale-settings summary { display: grid; grid-template-columns: minmax(0, 1fr) auto 15px; align-items: center; gap: 9px; min-height: 43px; font-size: 13px; font-weight: 700; }
.scale-status { color: var(--muted); font: 11px var(--mono); }
.scale-body { padding: 0 0 14px; }
.scale-body p { margin-bottom: 8px; color: var(--muted); font-size: 12px; line-height: 1.4; }
.calibration-controls { margin-top: 10px; }
.calibration-row { display: grid; align-items: center; grid-template-columns: minmax(0, 1fr) auto auto; gap: 6px; margin-top: 4px; }
#clear-scale { margin-left: 8px; }

.outcomes { display: grid; grid-template-columns: minmax(0, 1.94fr) minmax(300px, 1fr); margin-top: 18px; overflow: hidden; }
.outcomes-graph { min-width: 0; padding: 18px 15px 8px 17px; }
.outcomes-header { gap: 12px; padding-right: 2px; }
.chart-legend { display: flex; flex-wrap: wrap; justify-content: flex-end; align-items: center; gap: 8px 14px; font-size: 12px; color: var(--muted); }
.chart-legend span { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.legend-line { display: inline-block; width: 18px; border-top: 2px solid var(--teal); }
.treated-line { border-top: 2px dashed var(--orange); }
#burden-chart { width: 100%; height: 185px; display: block; cursor: crosshair; margin-top: 7px; }
.outcomes-numbers { padding: 18px 20px; background: #f2f7ef; border-left: 1px solid var(--line); }
.numbers-context { color: var(--muted); font: 11px var(--mono); margin-bottom: 14px; }
.number-item { display: flex; flex-direction: column; gap: 3px; }
.number-item + .number-item { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); }
.number-item strong { font-size: 31px; line-height: 1.1; font-weight: 650; letter-spacing: -.035em; font-variant-numeric: tabular-nums; }
.number-item span { color: var(--muted); font-size: 12px; }

.method { margin-top: 14px; }
.method summary { display: grid; grid-template-columns: 1fr auto; align-items: center; min-height: 48px; padding-inline: 17px; font-size: 14px; font-weight: 700; }
.method-body { padding: 0 17px 18px; max-width: 1000px; font-size: 14px; line-height: 1.55; color: var(--muted); }
.equation { margin-bottom: 10px; color: var(--teal-dark); font: 16px/1.45 var(--mono); overflow-wrap: anywhere; }
.method-body p + p { margin-top: 8px; }
.method-sources { display: flex; flex-wrap: wrap; gap: 8px 18px; margin-top: 12px; font-size: 13px; }
.site-footer { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px 16px; color: var(--muted); font-size: 11px; line-height: 1.3; padding: 16px 2px 0; }

@media (max-width: 1020px) {
  .topbar-inner, .page { width: calc(100% - 42px); }
  .lab-grid, .outcomes { grid-template-columns: minmax(0, 1.5fr) minmax(270px, 1fr); gap: 12px; }
  .outcomes { gap: 0; }
  .viewer, .parameters { padding-inline: 13px; }
  .segments button { padding-inline: 7px; }
  .image-actions { flex-wrap: wrap; }
  .seed-help { text-align: left; }
}

@media (max-width: 735px) {
  .topbar-inner, .page { width: calc(100% - 28px); }
  .topbar-inner { min-height: 56px; }
  .brand { font-size: 14px; gap: 7px; }
  .brand-mark { width: 24px; height: 24px; }
  .topbar-actions { gap: 3px; }
  .topbar-actions .button { min-height: 35px; padding-inline: 8px; font-size: 12px; }
  .upload-mark { display: none; }
  .page { padding-top: 22px; }
  .page-intro { margin-bottom: 16px; }
  .model-link { display: none; }
  .lab-grid, .outcomes { grid-template-columns: minmax(0, 1fr); }
  .film-stage { height: clamp(260px, 72vw, 410px); }
  .viewer { padding: 13px 11px; }
  .image-actions { min-height: 49px; }
  .parameters { padding-top: 10px; }
  .outcomes-numbers { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding: 13px 16px 16px; border-left: 0; border-top: 1px solid var(--line); }
  .numbers-context { grid-column: 1 / -1; margin-bottom: 0; }
  .number-item + .number-item { margin: 0; padding: 0; border: 0; }
  .outcomes-header { align-items: flex-start; }
}

@media (max-width: 400px) {
  .topbar-inner, .page { width: calc(100% - 22px); }
  .brand { font-size: 12px; }
  .brand-mark { width: 20px; height: 20px; border-radius: 5px; }
  .brand-mark::before { width: 13px; height: 13px; }
  .brand-mark::after { width: 8px; height: 8px; }
  .topbar-actions .button { padding-inline: 6px; }
  .viewer-header { gap: 6px; }
  .viewer-header h2 { font-size: 17px; }
  .viewer-header p { font-size: 10px; }
  .segments button { font-size: 11px; padding-inline: 5px; }
  .film-readout { top: 7px; left: 7px; }
  .scale-bar { left: 7px; bottom: 7px; }
  .density-key { right: 7px; bottom: 7px; width: 111px; }
  .time-label { font-size: 11px; }
  .chart-legend { gap: 4px; flex-direction: column; align-items: flex-end; font-size: 10px; }
  .outcomes-header h2 { font-size: 18px; }
}
