:root {
  color-scheme: dark;
  --bg: #090d12;
  --panel: #101720;
  --panel-2: #121d27;
  --line: #263441;
  --line-soft: rgba(137, 164, 184, .13);
  --text: #e8f0f5;
  --muted: #8da0ae;
  --subtle: #607381;
  --accent: #52e0c1;
  --accent-dim: rgba(82, 224, 193, .13);
  --accent-line: rgba(82, 224, 193, .48);
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  --sans: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; width: 100%; min-width: 320px; height: 100%; background: var(--bg); color: var(--text); font-family: var(--sans); }
body { overflow: hidden; }
button, input { font: inherit; }
button { color: inherit; }
.app-root { min-height: 100%; height: 100dvh; display: flex; flex-direction: column; background: radial-gradient(ellipse at 18% 0%, rgba(31, 72, 75, .16), transparent 42%), var(--bg); }
.topbar { height: 66px; flex: 0 0 66px; display: flex; align-items: center; padding: 0 22px; gap: 13px; border-bottom: 1px solid var(--line-soft); background: rgba(9, 13, 18, .94); }
.brand-mark { width: 27px; height: 27px; display: grid; grid-template-columns: repeat(2, 1fr); grid-template-rows: repeat(2, 1fr); gap: 3px; transform: rotate(-8deg); }
.brand-mark span { border: 1px solid var(--accent-line); background: var(--accent-dim); border-radius: 2px; }
.brand-mark span:nth-child(2), .brand-mark span:nth-child(3) { background: var(--accent); border-color: var(--accent); }
.brand-copy { display: flex; flex-direction: column; gap: 2px; }
.eyebrow { font: 700 9px/1.2 var(--mono); letter-spacing: .17em; color: var(--subtle); }
.brand-title { font-size: 15px; font-weight: 650; letter-spacing: -.02em; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 16px; }
.live-indicator { display: flex; align-items: center; gap: 7px; color: var(--muted); font: 700 9px var(--mono); letter-spacing: .13em; }
.live-dot { width: 6px; height: 6px; border-radius: 50%; background: #657986; box-shadow: 0 0 0 3px rgba(101, 121, 134, .12); }
.live-indicator.running .live-dot { background: var(--accent); box-shadow: 0 0 0 3px rgba(82, 224, 193, .12), 0 0 12px rgba(82, 224, 193, .65); }
.quality-button { background: transparent; border: 1px solid var(--line); border-radius: 5px; padding: 7px 10px; color: var(--muted); font: 700 9px var(--mono); letter-spacing: .1em; cursor: pointer; }
.quality-button:hover, .quality-button:focus-visible { border-color: var(--accent-line); color: var(--accent); outline: none; }
.app-shell { min-height: 0; flex: 1; display: grid; grid-template-columns: minmax(0, 1fr) 338px; gap: 14px; padding: 14px; }
.panel { min-width: 0; min-height: 0; border: 1px solid var(--line); border-radius: 9px; background: linear-gradient(155deg, rgba(18, 29, 39, .97), rgba(13, 20, 28, .98)); box-shadow: 0 18px 50px rgba(0,0,0,.17); }
.visual-panel { display: flex; flex-direction: column; overflow: hidden; }
.stage-heading { min-height: 58px; flex: 0 0 58px; display: flex; align-items: center; justify-content: space-between; padding: 0 18px; border-bottom: 1px solid var(--line-soft); }
.stage-title { margin-top: 4px; font-size: 14px; font-weight: 620; letter-spacing: -.015em; }
.round-readout { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }
.round-readout span { font: 700 8px var(--mono); letter-spacing: .12em; color: var(--subtle); }
.round-readout strong { font: 600 15px var(--mono); color: var(--accent); }
.stage-wrap { position: relative; flex: 1 1 auto; min-height: 190px; overflow: hidden; background: linear-gradient(180deg, rgba(8, 14, 20, .58), rgba(11, 19, 26, .28)); }
#populationCanvas, #phaseCanvas { display: block; width: 100%; height: 100%; }
.canvas-overlay { position: absolute; top: 15px; display: flex; flex-direction: column; gap: 3px; pointer-events: none; }
.overlay-left { left: 17px; }
.overlay-right { right: 17px; align-items: flex-end; }
.overlay-kicker { color: var(--subtle); font: 700 8px var(--mono); letter-spacing: .13em; }
.canvas-overlay strong { font: 600 18px var(--mono); color: var(--text); }
.canvas-overlay small { color: var(--subtle); font: 700 8px var(--mono); letter-spacing: .08em; }
.overlay-right strong { color: var(--accent); }
.stage-caption { flex: 0 0 27px; min-height: 27px; display: flex; align-items: center; padding: 0 14px; border-top: 1px solid rgba(124,153,169,.09); background: rgba(8,14,20,.55); color: #8297a5; font-size: 9px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.phase-section { flex: 0 0 206px; min-height: 170px; display: flex; flex-direction: column; border-top: 1px solid var(--line); padding: 12px 17px 9px; background: rgba(8, 13, 18, .37); }
.phase-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.phase-title { margin-top: 3px; font-size: 12px; font-weight: 620; }
.phase-legend { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 11px; padding-top: 3px; color: var(--subtle); font: 8px var(--mono); }
.phase-legend span { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; }
.phase-legend i { display: inline-block; width: 13px; height: 2px; background: var(--accent); }
.phase-legend .legend-dash { height: 0; border-top: 2px dashed #9baab4; background: none; }
.phase-legend .legend-dot { width: 6px; height: 6px; border-radius: 50%; }
.chart-wrap { flex: 1; min-height: 85px; margin-top: 4px; }
.chart-foot { display: flex; justify-content: space-between; gap: 10px; color: var(--subtle); font: 8px var(--mono); letter-spacing: .025em; }
.control-panel { overflow-y: auto; scrollbar-width: thin; scrollbar-color: #344652 transparent; padding: 15px 15px 12px; display: flex; flex-direction: column; gap: 12px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; }
.panel-title { margin-top: 4px; font-size: 15px; font-weight: 650; }
.seed-chip { border: 1px solid var(--line); border-radius: 4px; padding: 5px 7px; color: var(--subtle); font: 8px var(--mono); letter-spacing: .1em; }
.readout-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.readout-card { min-width: 0; padding: 10px 11px 9px; border: 1px solid var(--line-soft); border-radius: 6px; background: rgba(5, 10, 15, .28); }
.readout-wide { grid-column: 1 / -1; }
.readout-label { display: flex; justify-content: space-between; gap: 4px; color: var(--subtle); font: 700 8px var(--mono); letter-spacing: .09em; }
.readout-label span { color: #536c79; font-size: 7px; }
.readout-value { margin-top: 5px; font: 600 21px/1.1 var(--mono); letter-spacing: -.045em; color: var(--text); }
.readout-unit { margin-top: 3px; color: var(--subtle); font: 8px var(--mono); }
.alpha-line { display: flex; align-items: baseline; gap: 12px; }
.alpha-line .readout-value { color: var(--accent); }
.alpha-reference { color: #8da0ae; font: 9px var(--mono); }
.alpha-reference b { color: #647987; font-size: 7px; letter-spacing: .08em; }
.control-group { display: flex; flex-direction: column; gap: 7px; }
.control-label-row { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.control-label-row label, .control-static-label { color: #c6d3db; font-size: 10px; font-weight: 600; }
.unit-label { margin-left: 3px; color: var(--subtle); font: 8px var(--mono); font-weight: 400; }
.control-label-row output { color: var(--accent); font: 600 11px var(--mono); }
input[type="range"] { width: 100%; height: 13px; margin: 0; background: transparent; appearance: none; cursor: pointer; accent-color: var(--accent); }
input[type="range"]::-webkit-slider-runnable-track { height: 3px; background: linear-gradient(90deg, rgba(82,224,193,.5), #31434f); border-radius: 4px; }
input[type="range"]::-moz-range-track { height: 3px; background: #31434f; border-radius: 4px; }
input[type="range"]::-webkit-slider-thumb { appearance: none; width: 12px; height: 12px; margin-top: -4.5px; border-radius: 50%; background: var(--accent); border: 2px solid #0c171c; box-shadow: 0 0 0 1px var(--accent-line), 0 0 12px rgba(82,224,193,.25); }
input[type="range"]::-moz-range-thumb { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); border: 2px solid #0c171c; box-shadow: 0 0 0 1px var(--accent-line); }
input[type="range"]:focus-visible { outline: 1px solid var(--accent-line); outline-offset: 4px; border-radius: 4px; }
.range-ends { display: flex; justify-content: space-between; margin-top: -3px; color: #536672; font: 8px var(--mono); }
.mode-group { gap: 6px; }
.segmented { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 3px; border: 1px solid var(--line); border-radius: 6px; background: rgba(4, 9, 13, .38); }
.segment { border: 1px solid transparent; border-radius: 4px; padding: 7px 9px; color: var(--muted); background: transparent; font: 600 9px var(--mono); cursor: pointer; }
.segment.active { color: var(--accent); border-color: rgba(82,224,193,.23); background: var(--accent-dim); }
.segment:hover, .segment:focus-visible, .preset-button:hover, .preset-button:focus-visible { outline: none; border-color: var(--accent-line); color: var(--accent); }
.preset-block { display: flex; flex-direction: column; gap: 7px; }
.preset-row { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 5px; }
.preset-button { border: 1px solid var(--line); border-radius: 5px; background: rgba(5, 10, 15, .28); padding: 7px 4px; color: var(--muted); font-size: 9px; font-weight: 600; cursor: pointer; }
.preset-button.selected { color: var(--accent); border-color: var(--accent-line); background: var(--accent-dim); }
.transport-row { display: grid; grid-template-columns: 1.25fr .85fr .85fr 36px; gap: 5px; }
.transport { border: 1px solid var(--line); border-radius: 5px; min-height: 32px; background: rgba(5, 10, 15, .28); color: #9aabb6; font: 700 8px var(--mono); letter-spacing: .07em; cursor: pointer; }
.transport:hover, .transport:focus-visible { border-color: var(--accent-line); color: var(--accent); outline: none; }
.transport.primary { border-color: rgba(82,224,193,.42); background: var(--accent-dim); color: var(--accent); }
.transport.primary span { margin-left: 4px; }
.transport.screenshot { font-size: 17px; line-height: 1; }
.check-card { border: 1px solid rgba(82,224,193,.2); border-radius: 6px; padding: 9px 10px 8px; background: linear-gradient(110deg, rgba(82,224,193,.055), rgba(7,14,19,.28)); }
.check-head { display: flex; align-items: center; gap: 6px; color: #9cb1bd; font: 700 8px var(--mono); letter-spacing: .08em; }
.check-icon { display: inline-grid; place-items: center; width: 14px; height: 14px; border-radius: 50%; background: rgba(82,224,193,.15); color: var(--accent); font-size: 9px; }
.check-tag { margin-left: auto; color: #637b88; font-size: 7px; }
.check-main { display: flex; align-items: baseline; gap: 9px; margin: 8px 0 4px 20px; font: 600 15px var(--mono); color: var(--text); }
.check-equals { color: var(--subtle); font-size: 9px; }
.check-foot { display: grid; grid-template-columns: 1fr 1fr auto; gap: 6px; margin-left: 20px; color: var(--subtle); font: 7px var(--mono); }
.check-foot strong { color: var(--accent); font-weight: 600; }
.science-panel { border-top: 1px solid var(--line-soft); padding-top: 10px; }
.science-panel summary { list-style: none; display: flex; justify-content: space-between; align-items: center; color: #b9c8d0; font: 700 9px var(--mono); letter-spacing: .13em; cursor: pointer; }
.science-panel summary::-webkit-details-marker { display: none; }
.summary-plus { color: var(--accent); font-size: 14px; transition: transform .2s ease; }
.science-panel[open] .summary-plus { transform: rotate(45deg); }
.science-content { padding: 10px 1px 2px; color: #91a3ae; font-size: 10px; line-height: 1.55; }
.science-content p { margin: 7px 0; }
.science-lead { color: #c0cdd5; }
.science-content h3 { margin: 12px 0 4px; color: #c7d4dc; font: 700 8px var(--mono); letter-spacing: .11em; text-transform: uppercase; }
.equation { margin: 5px 0; padding: 7px 9px; border-left: 2px solid var(--accent-line); background: rgba(82,224,193,.045); color: #d5e4e9; font: 11px var(--mono); }
.textbook-note { color: #6d8793; font: 700 7px var(--mono); letter-spacing: .08em; }
.model-note { padding-top: 8px; border-top: 1px solid var(--line-soft); color: #6f8592; font-style: italic; }
.panel-footer { margin-top: auto; padding-top: 5px; color: #4e626e; font: 7px var(--mono); letter-spacing: .12em; text-align: center; }
.panel-footer span { color: var(--accent); padding: 0 4px; }
button:active { transform: translateY(1px); }
@media (max-width: 900px) {
  .app-shell { grid-template-columns: minmax(0, 1fr) 310px; gap: 10px; padding: 10px; }
  .control-panel { padding: 12px; gap: 10px; }
  .phase-section { flex-basis: 190px; }
  .phase-legend { gap: 7px; }
}
@media (max-width: 680px) {
  body { overflow: hidden; }
  .app-root { height: 100dvh; min-height: 0; }
  body.embed-mode { height: 100vh; height: 100dvh; overflow: hidden; }
  .topbar { height: 54px; flex-basis: 54px; padding: 0 13px; gap: 9px; }
  .brand-mark { width: 22px; height: 22px; gap: 2px; }
  .eyebrow { font-size: 8px; }
  .brand-title { font-size: 13px; }
  .topbar-right { gap: 9px; }
  .quality-button { padding: 6px 7px; font-size: 8px; }
  .live-indicator { font-size: 8px; }
  .app-shell { display: flex; flex-direction: column; gap: 8px; padding: 8px; overflow: hidden; }
  .visual-panel { flex: 0 0 45%; min-height: 270px; }
  .stage-heading { min-height: 46px; flex-basis: 46px; padding: 0 12px; }
  .stage-title { font-size: 12px; }
  .round-readout span { font-size: 7px; }
  .round-readout strong { font-size: 12px; }
  .stage-wrap { min-height: 130px; }
  .canvas-overlay { top: 9px; }
  .overlay-left { left: 10px; }
  .overlay-right { right: 10px; }
  .overlay-kicker, .canvas-overlay small { font-size: 7px; }
  .canvas-overlay strong { font-size: 14px; }
  .stage-caption { flex-basis: 24px; min-height: 24px; padding: 0 10px; font-size: 8px; }
  .phase-section { flex: 1 1 118px; min-height: 108px; padding: 8px 10px 7px; }
  .phase-title { font-size: 10px; }
  .phase-legend { font-size: 7px; gap: 6px; }
  .phase-legend span:nth-child(1) { display: none; }
  .chart-wrap { min-height: 45px; margin-top: 2px; }
  .chart-foot { font-size: 7px; }
  .control-panel { flex: 1 1 0; min-height: 0; padding: 11px 12px 10px; gap: 10px; }
  .panel-head { flex: 0 0 auto; }
  .panel-title { font-size: 13px; }
  .readout-card { padding: 8px 9px 7px; }
  .readout-value { font-size: 18px; }
  .readout-unit { font-size: 7px; }
  .readout-label { font-size: 7px; }
  .control-label-row label, .control-static-label { font-size: 9px; }
  .unit-label { font-size: 7px; }
  .control-group { gap: 5px; }
  .preset-button { font-size: 8px; }
  .transport { min-height: 30px; }
  .check-foot { font-size: 6px; }
  .science-content { font-size: 9px; }
  .panel-footer { padding-bottom: 2px; }
}
@media (max-width: 390px) {
  .visual-panel { flex-basis: 43%; }
  .phase-legend span:nth-child(2) { display: none; }
  .alpha-reference { font-size: 8px; }
  .check-foot { grid-template-columns: 1fr 1fr; }
  .check-foot strong { grid-column: 1 / -1; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}
