:root {
  color-scheme: dark;
  --bg: #07110f;
  --panel: #0c1916;
  --panel-2: #10211d;
  --line: rgba(151, 190, 177, .14);
  --line-strong: rgba(151, 190, 177, .24);
  --text: #e8f1eb;
  --muted: #8ca49a;
  --faint: #61766d;
  --accent: #79e1bd;
  --accent-2: #3cbf9a;
  --amber: #e8b86c;
  --danger: #e68a78;
  --radius: 14px;
}
* { box-sizing: border-box; }
html, body { width: 100%; min-height: 100%; margin: 0; background: var(--bg); color: var(--text); font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
body { overflow: hidden; }
button, input { font: inherit; }
button { color: inherit; }
.app { height: 100vh; height: 100dvh; min-height: 0; display: flex; flex-direction: column; overflow: hidden; background: radial-gradient(ellipse at 38% 10%, rgba(27, 69, 55, .2), transparent 42%), var(--bg); }
.topbar { height: 88px; flex: 0 0 88px; display: flex; align-items: center; gap: 17px; padding: 0 26px; border-bottom: 1px solid var(--line); background: rgba(7, 17, 15, .9); }
.brand-symbol { width: 48px; height: 48px; flex: 0 0 48px; display: grid; place-items: center; color: var(--accent); border: 1px solid rgba(121, 225, 189, .24); border-radius: 14px; background: rgba(121, 225, 189, .055); }
.brand-symbol svg { width: 37px; height: 37px; }
.brand-copy { min-width: 0; }
.eyebrow, .section-kicker { color: #8ba99b; font-size: 9px; line-height: 1.2; letter-spacing: .16em; font-weight: 750; }
.eyebrow span { color: #4f7566; padding: 0 4px; }
.eyebrow-tag { margin-left: 9px; color: var(--accent); border: 1px solid rgba(121,225,189,.22); padding: 3px 6px; border-radius: 4px; font-size: 8px; letter-spacing: .12em; }
h1 { margin: 5px 0 2px; font-size: 21px; line-height: 1.1; letter-spacing: -.035em; font-weight: 670; }
.brand-copy p { margin: 0; color: var(--muted); font-size: 11px; letter-spacing: .005em; }
.top-actions { margin-left: auto; display: flex; align-items: center; gap: 17px; }
.run-indicator { display: flex; align-items: center; gap: 7px; color: #9db6aa; font-size: 9px; letter-spacing: .14em; font-weight: 750; white-space: nowrap; }
.status-light { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 10px rgba(121,225,189,.8); }
.run-indicator.paused .status-light { background: var(--amber); box-shadow: none; }
.icon-button { display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--line-strong); background: rgba(255,255,255,.025); padding: 9px 12px; border-radius: 8px; color: #c9d9d0; cursor: pointer; font-size: 10px; transition: border-color .18s, background .18s; }
.icon-button:hover { border-color: rgba(121,225,189,.55); background: rgba(121,225,189,.07); }
.icon-button svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.5; }
.main-layout { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) 362px; gap: 18px; padding: 18px 20px 20px; }
.stage-column { min-width: 0; min-height: 0; display: flex; flex-direction: column; }
.stage-heading { display: flex; justify-content: space-between; align-items: center; padding: 2px 4px 12px; }
.stage-heading b, .section-kicker b { color: #4e7464; padding: 0 4px; }
.stage-scale { color: #6d897d; font-size: 8px; letter-spacing: .13em; font-weight: 700; }
.canvas-shell { position: relative; flex: 1; min-height: 200px; overflow: hidden; border: 1px solid rgba(132, 178, 157, .18); border-radius: 13px; background: #091511; box-shadow: inset 0 0 90px rgba(13, 41, 30, .24), 0 16px 44px rgba(0,0,0,.14); }
.canvas-shell::after { content: ""; position: absolute; inset: 0; pointer-events: none; border-radius: inherit; box-shadow: inset 0 0 0 1px rgba(255,255,255,.018); }
#world { display: block; width: 100%; height: 100%; }
.canvas-hud { position: absolute; z-index: 1; top: 15px; display: flex; align-items: center; gap: 7px; color: rgba(181, 205, 192, .72); font-size: 8px; letter-spacing: .13em; font-weight: 750; pointer-events: none; }
.hud-top-left { left: 16px; }
.hud-dot { width: 5px; height: 5px; background: var(--accent); border-radius: 50%; box-shadow: 0 0 8px var(--accent); }
.hud-top-right { right: 15px; padding: 6px 8px; border: 1px solid rgba(121,225,189,.22); border-radius: 5px; color: var(--accent); background: rgba(5,18,14,.7); }
.hud-top-right.stressed { color: var(--amber); border-color: rgba(232,184,108,.25); }
.hud-top-right.collapsed { color: var(--danger); border-color: rgba(230,138,120,.3); }
.canvas-legend { position: absolute; left: 15px; bottom: 13px; display: flex; flex-wrap: wrap; gap: 13px; color: rgba(166, 192, 179, .75); font-size: 9px; pointer-events: none; }
.canvas-legend span { display: inline-flex; align-items: center; gap: 6px; }
.canvas-legend i { display: inline-block; width: 13px; height: 3px; border-radius: 3px; }
.legend-cord { background: #55b99b; }
.legend-flow { background: #b4f5d9; box-shadow: 0 0 7px #8de9c5; }
.legend-patch { width: 7px !important; height: 7px !important; border-radius: 50% !important; background: var(--amber); }
.stage-bottom { padding: 12px 5px 0; }
.endpoint-labels { display: flex; justify-content: space-between; color: #5f7c6e; font-size: 8px; letter-spacing: .16em; font-weight: 750; }
.stage-bottom p { min-height: 30px; margin: 7px 0 0; color: #a8bdb1; font-size: 11px; line-height: 1.45; }
.control-column { min-height: 0; overflow-y: auto; padding: 0 1px 2px 0; display: flex; flex-direction: column; gap: 12px; scrollbar-width: thin; scrollbar-color: #294338 transparent; }
.readouts { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.readout-card { min-width: 0; padding: 12px 12px 10px; border: 1px solid var(--line); border-radius: 10px; background: linear-gradient(140deg, rgba(17,37,30,.96), rgba(10,23,19,.96)); }
.primary-readout { border-color: rgba(121,225,189,.26); background: linear-gradient(140deg, rgba(20,53,42,.86), rgba(10,25,20,.98)); }
.readout-label { display: flex; justify-content: space-between; align-items: center; gap: 5px; color: #8ca69a; font-size: 8px; letter-spacing: .105em; font-weight: 750; white-space: nowrap; }
.unit-tag { color: #608f7c; font-size: 7px; letter-spacing: .1em; }
.readout-value { display: flex; align-items: baseline; gap: 5px; margin-top: 8px; }
.readout-value strong { font-size: 27px; line-height: 1; letter-spacing: -.045em; font-weight: 640; font-variant-numeric: tabular-nums; color: #e6f3eb; }
.primary-readout .readout-value strong { color: var(--accent); }
.readout-value span { color: #88a195; font-size: 10px; }
.readout-foot { margin-top: 7px; color: #698176; font-size: 8px; }
.flow-track { height: 4px; margin-top: 10px; overflow: hidden; border-radius: 4px; background: rgba(255,255,255,.07); }
.flow-track i { display: block; width: 100%; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #3eaa88, #93e9c9); transition: width .25s ease; }
.control-panel, .check-panel, .science-panel { border: 1px solid var(--line); border-radius: var(--radius); background: rgba(12, 26, 22, .92); }
.control-panel { padding: 14px 14px 12px; }
.panel-heading { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 14px; }
.panel-heading h2 { margin: 4px 0 0; font-size: 14px; line-height: 1.2; font-weight: 630; letter-spacing: -.02em; }
.small-chip { padding: 5px 7px; border: 1px solid rgba(121,225,189,.2); border-radius: 5px; color: #83c9ac; font-size: 7px; letter-spacing: .12em; font-weight: 750; white-space: nowrap; }
.slider-grid { display: grid; grid-template-columns: 1fr; gap: 12px; }
.slider-control { display: block; min-width: 0; cursor: pointer; }
.slider-head { display: flex; justify-content: space-between; gap: 8px; color: #c6d7cd; font-size: 10px; }
.slider-head output { color: var(--accent); font-size: 10px; font-weight: 700; font-variant-numeric: tabular-nums; }
input[type="range"] { appearance: none; -webkit-appearance: none; display: block; width: 100%; height: 14px; margin: 6px 0 0; background: transparent; cursor: pointer; }
input[type="range"]::-webkit-slider-runnable-track { height: 3px; border-radius: 5px; background: linear-gradient(90deg, #438e74, #274438); }
input[type="range"]::-moz-range-track { height: 3px; border-radius: 5px; background: linear-gradient(90deg, #438e74, #274438); }
input[type="range"]::-webkit-slider-thumb { appearance: none; -webkit-appearance: none; width: 12px; height: 12px; margin-top: -4.5px; border: 2px solid #c6f5df; border-radius: 50%; background: #277d60; box-shadow: 0 0 0 3px rgba(121,225,189,.1); }
input[type="range"]::-moz-range-thumb { width: 9px; height: 9px; border: 2px solid #c6f5df; border-radius: 50%; background: #277d60; box-shadow: 0 0 0 3px rgba(121,225,189,.1); }
.range-ends { display: flex; justify-content: space-between; color: #5e786c; font-size: 7px; margin-top: 1px; }
.preset-row { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; margin-top: 14px; }
.preset-button { display: flex; align-items: center; gap: 8px; min-width: 0; padding: 8px 8px; text-align: left; border: 1px solid var(--line); border-radius: 8px; background: rgba(255,255,255,.018); cursor: pointer; transition: border-color .18s, background .18s; }
.preset-button:hover, .preset-button.selected { border-color: rgba(121,225,189,.38); background: rgba(121,225,189,.055); }
.preset-glyph { display: grid; place-items: center; width: 24px; height: 24px; flex: 0 0 24px; border-radius: 7px; background: rgba(121,225,189,.1); color: var(--accent); font-size: 16px; }
.stress-glyph { color: var(--amber); background: rgba(232,184,108,.09); }
.preset-button b { display: block; overflow: hidden; color: #d4e2d9; font-size: 9px; line-height: 1.3; white-space: nowrap; text-overflow: ellipsis; }
.preset-button small { display: block; margin-top: 2px; color: #789084; font-size: 7px; white-space: nowrap; }
.transport-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 13px; padding-top: 11px; border-top: 1px solid var(--line); }
.transport-buttons { display: flex; gap: 6px; }
.action-button, .quality-button { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 30px; padding: 0 9px; border: 1px solid var(--line-strong); border-radius: 7px; color: #a9bdb2; background: rgba(255,255,255,.02); cursor: pointer; font-size: 9px; transition: .18s ease; }
.action-button:hover, .quality-button:hover { border-color: rgba(121,225,189,.45); color: var(--text); }
.action-button span { color: #81a899; font-size: 11px; }
.run-button { min-width: 72px; border-color: rgba(121,225,189,.36); color: var(--accent); background: rgba(121,225,189,.07); }
.run-button span { color: var(--accent); }
.play-icon { font-size: 10px !important; }
.quality-button { min-width: 61px; color: #85bba4; font-size: 8px; letter-spacing: .1em; font-weight: 750; }
.quality-dot { width: 5px; height: 5px; border-radius: 50%; background: var(--accent); }
.quality-button[aria-pressed="false"] .quality-dot { background: var(--amber); }
.check-panel { padding: 12px 14px 11px; }
.check-heading { display: flex; align-items: center; justify-content: space-between; }
.check-badge { padding: 4px 6px; border: 1px solid rgba(232,184,108,.22); border-radius: 4px; color: var(--amber); font-size: 7px; letter-spacing: .11em; font-weight: 750; }
.check-title { margin-top: 7px; color: #d5e2d9; font-size: 11px; font-weight: 620; }
.check-values { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 7px; margin-top: 9px; }
.check-values div { min-width: 0; }
.check-values span { display: block; color: #738b80; font-size: 7px; }
.check-values b { display: block; margin-top: 4px; color: #c8e6d6; font-size: 11px; font-variant-numeric: tabular-nums; }
.check-values div:last-child b { color: var(--accent); }
.check-panel p { margin: 8px 0 0; color: #647e72; font-size: 8px; line-height: 1.4; }
.science-panel { overflow: hidden; }
.science-panel summary { display: flex; align-items: center; gap: 8px; padding: 11px 13px; color: #c9d9cf; cursor: pointer; list-style: none; font-size: 10px; font-weight: 620; }
.science-panel summary::-webkit-details-marker { display: none; }
.science-icon { display: grid; place-items: center; width: 19px; height: 19px; border-radius: 6px; color: var(--accent); background: rgba(121,225,189,.09); font-size: 12px; }
.chevron { margin-left: auto; color: #759184; font-size: 14px; transition: transform .18s; }
.science-panel[open] .chevron { transform: rotate(180deg); }
.science-content { padding: 0 13px 13px; color: #91a99c; font-size: 9px; line-height: 1.5; }
.science-content h3 { margin: 8px 0 4px; color: #cfe0d5; font-size: 10px; }
.science-content p { margin: 5px 0; }
.science-content ul { margin: 5px 0 9px; padding-left: 17px; }
.science-content li { margin: 3px 0; }
.equation { margin: 7px 0; padding: 8px; border: 1px solid rgba(121,225,189,.14); border-radius: 6px; background: rgba(121,225,189,.035); color: #b8ecd4; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 10px; text-align: center; }
.disclaimer { padding-top: 7px; border-top: 1px solid var(--line); color: #6e8a7b; font-style: italic; }
button:focus-visible, input:focus-visible, summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

@media (min-width: 1500px) {
  .main-layout { grid-template-columns: minmax(0, 1fr) 390px; gap: 22px; padding: 22px 26px 24px; }
  .topbar { padding: 0 30px; }
  .slider-grid { grid-template-columns: 1fr 1fr; column-gap: 14px; row-gap: 14px; }
  .control-panel { padding: 16px; }
}
@media (max-width: 980px) {
  .topbar { height: 76px; flex-basis: 76px; padding: 0 18px; }
  .main-layout { grid-template-columns: minmax(0, 1fr) 330px; gap: 12px; padding: 13px; }
  .readout-card { padding: 10px; }
  .readout-value strong { font-size: 24px; }
}
@media (max-width: 700px) {
  body { overflow: auto; }
  .app { height: 100vh; height: 100dvh; }
  .topbar { height: 62px; flex-basis: 62px; gap: 10px; padding: 0 12px; }
  .brand-symbol { width: 38px; height: 38px; flex-basis: 38px; border-radius: 11px; }
  .brand-symbol svg { width: 30px; height: 30px; }
  .eyebrow { font-size: 7px; letter-spacing: .12em; }
  .eyebrow-tag { display: none; }
  h1 { margin-top: 4px; font-size: 16px; }
  .brand-copy p { font-size: 9px; }
  .top-actions { gap: 8px; }
  .run-indicator { font-size: 7px; letter-spacing: .08em; }
  .icon-button { width: 32px; height: 32px; padding: 0; justify-content: center; }
  .icon-button span { display: none; }
  .main-layout { display: flex; flex-direction: column; gap: 10px; padding: 10px 10px 12px; overflow: hidden; }
  .stage-column { flex: 0 0 43%; min-height: 230px; }
  .stage-heading { padding: 0 3px 8px; }
  .section-kicker { font-size: 8px; }
  .stage-scale { font-size: 7px; }
  .canvas-shell { min-height: 0; border-radius: 10px; }
  .canvas-hud { top: 10px; font-size: 7px; }
  .hud-top-left { left: 10px; }
  .hud-top-right { right: 9px; padding: 5px 6px; }
  .canvas-legend { left: 10px; bottom: 8px; gap: 8px; font-size: 7px; }
  .canvas-legend i { width: 10px; }
  .stage-bottom { padding: 8px 3px 0; }
  .endpoint-labels { font-size: 7px; }
  .stage-bottom p { min-height: 27px; margin-top: 5px; font-size: 9px; line-height: 1.35; }
  .control-column { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding-right: 2px; gap: 8px; }
  .readouts { gap: 6px; }
  .readout-card { padding: 8px 9px 7px; border-radius: 8px; }
  .readout-label { font-size: 7px; letter-spacing: .07em; }
  .unit-tag { font-size: 6px; }
  .readout-value { margin-top: 5px; }
  .readout-value strong { font-size: 22px; }
  .readout-value span { font-size: 9px; }
  .readout-foot { margin-top: 4px; font-size: 7px; }
  .flow-track { margin-top: 7px; }
  .control-panel { padding: 10px; border-radius: 10px; }
  .panel-heading { margin-bottom: 10px; }
  .panel-heading h2 { font-size: 12px; }
  .small-chip { font-size: 6px; padding: 4px 5px; }
  .slider-grid { grid-template-columns: 1fr 1fr; gap: 10px 12px; }
  .slider-head { font-size: 9px; }
  .slider-head output { font-size: 9px; }
  input[type="range"] { margin-top: 4px; }
  .range-ends { font-size: 6px; }
  .preset-row { margin-top: 10px; }
  .preset-button { padding: 6px; gap: 6px; }
  .preset-glyph { width: 20px; height: 20px; flex-basis: 20px; font-size: 13px; }
  .preset-button b { font-size: 8px; }
  .preset-button small { font-size: 6px; }
  .transport-row { margin-top: 9px; padding-top: 8px; }
  .action-button, .quality-button { min-height: 28px; padding: 0 8px; font-size: 8px; }
  .check-panel { padding: 9px 11px; border-radius: 10px; }
  .check-title { font-size: 10px; margin-top: 5px; }
  .check-values { margin-top: 6px; }
  .check-values b { font-size: 10px; }
  .check-panel p { margin-top: 5px; font-size: 7px; }
  .science-panel summary { padding: 9px 11px; }
}
@media (max-width: 380px) {
  .topbar { padding: 0 9px; gap: 8px; }
  .brand-copy p { max-width: 210px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .main-layout { padding: 8px; }
  .stage-column { flex-basis: 41%; min-height: 210px; }
  .readout-label { font-size: 6px; }
  .readout-value strong { font-size: 20px; }
  .slider-grid { column-gap: 8px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}
/* Embed layout is fixed to the iframe viewport; the control rail scrolls independently on narrow screens. */
body.embed-mode { height: 100vh; height: 100dvh; overflow: hidden; }
body.embed-mode .app { height: 100vh; height: 100dvh; overflow: hidden; }
@media (max-width: 700px) {
  body.embed-mode .main-layout { min-height: 0; }
  body.embed-mode .control-column { overscroll-behavior: contain; }
}
/* Keep every sidebar section at its natural height; the rail, not its panels, owns scrolling. */
.control-column > * { flex: 0 0 auto; }
