:root {
  color-scheme: dark;
  --bg: #081116;
  --panel: #0d1a20;
  --panel-2: #102128;
  --panel-3: #132830;
  --line: rgba(151, 190, 194, .12);
  --line-strong: rgba(151, 190, 194, .2);
  --text: #e8f2ef;
  --muted: #8aa3a4;
  --dim: #5e777b;
  --accent: #55dbc9;
  --accent-soft: rgba(85, 219, 201, .12);
  --accent-glow: rgba(85, 219, 201, .28);
  --warn: #e8bd78;
  --danger: #e18e83;
  --radius: 12px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; width: 100%; height: 100%; background: var(--bg); color: var(--text); }
body { overflow: hidden; }
button, input { font: inherit; }
button { color: inherit; }
button:focus-visible, input:focus-visible, summary:focus-visible, canvas:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.app-shell { height: 100%; min-height: 0; display: flex; flex-direction: column; background: radial-gradient(ellipse at 18% -8%, rgba(28, 72, 77, .24), transparent 42%), var(--bg); }
.topbar { height: 68px; flex: 0 0 68px; display: flex; align-items: center; justify-content: space-between; padding: 0 24px; border-bottom: 1px solid var(--line); background: rgba(7, 16, 20, .92); z-index: 2; }
.brand-lockup { display: flex; align-items: center; gap: 13px; min-width: 0; }
.brand-mark { width: 31px; height: 31px; border: 1px solid rgba(85,219,201,.35); border-radius: 9px; display: grid; grid-template-columns: repeat(2, 1fr); gap: 3px; padding: 6px; transform: rotate(-4deg); background: rgba(85,219,201,.05); }
.brand-mark span { border-radius: 2px; background: var(--accent); opacity: .9; }
.brand-mark span:nth-child(2), .brand-mark span:nth-child(3) { opacity: .35; }
.brand-copy { min-width: 0; }
.eyebrow { color: #799496; font-size: 9px; font-weight: 750; letter-spacing: .16em; line-height: 1.4; }
.eyebrow span { color: #3d5a5d; padding: 0 4px; }
h1 { margin: 2px 0 0; font-size: 20px; line-height: 1; letter-spacing: -.04em; font-weight: 650; }
h1 em { color: var(--accent); font-style: normal; font-weight: 500; }
.topbar-right { display: flex; align-items: center; gap: 18px; }
.model-chip { display: flex; align-items: center; gap: 8px; color: #9cb3b3; font-size: 9px; font-weight: 750; letter-spacing: .12em; white-space: nowrap; }
.live-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 10px var(--accent-glow); }
.chip-divider { height: 12px; width: 1px; background: var(--line-strong); margin: 0 2px; }
.button { border: 1px solid var(--line-strong); border-radius: 8px; height: 36px; padding: 0 12px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; font-size: 11px; font-weight: 650; cursor: pointer; transition: background .18s ease, border-color .18s ease, transform .18s ease; }
.button:hover { border-color: rgba(85,219,201,.42); transform: translateY(-1px); }
.button svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.button-quiet { background: rgba(255,255,255,.025); color: #b6c9c6; }
.button-primary { background: var(--accent); color: #06211f; border-color: var(--accent); min-width: 102px; }
.button-primary:hover { background: #7ce7d8; border-color: #7ce7d8; }
.button-secondary { background: #14262c; color: #d5e4e0; }
.button-icon { width: 38px; padding: 0; background: #14262c; color: #a9bfbb; }
.button-icon svg { width: 17px; height: 17px; }
.app-main { min-height: 0; flex: 1; display: grid; grid-template-columns: minmax(0, 1fr) 352px; }
.visual-column { min-width: 0; min-height: 0; display: grid; grid-template-rows: minmax(0, 1fr) 196px; border-right: 1px solid var(--line); }
.stage-panel { position: relative; min-height: 0; overflow: hidden; background: radial-gradient(ellipse at 50% 52%, rgba(21, 61, 64, .25), transparent 58%), #09151a; }
#lattice { position: absolute; z-index: 0; inset: 0; width: 100%; height: 100%; display: block; outline: none; }
.stage-topline, .stage-bottomline { position: absolute; z-index: 2; left: 22px; right: 22px; display: flex; justify-content: space-between; align-items: center; pointer-events: none; }
.stage-topline { top: 18px; }
.stage-bottomline { bottom: 16px; }
.stage-label { display: flex; align-items: baseline; gap: 10px; color: #b5c8c4; font-size: 10px; font-weight: 700; letter-spacing: .12em; }
.stage-kicker { color: #627f80; font-size: 8px; font-weight: 800; letter-spacing: .16em; }
.stage-count strong { color: var(--accent); font-variant-numeric: tabular-nums; font-size: 12px; letter-spacing: .06em; }
.direction-key, .wrap-note { color: #799293; font-size: 8px; letter-spacing: .13em; font-weight: 750; display: flex; align-items: center; gap: 7px; }
.key-arrow { color: var(--accent); font-size: 17px; line-height: 10px; font-weight: 700; }
.key-arrow.south { transform: translateY(-2px); }
.key-separator { height: 10px; width: 1px; background: var(--line-strong); margin: 0 4px; }
.wrap-note span { color: var(--accent); font-size: 14px; }
.stage-vignette { pointer-events: none; position: absolute; z-index: 1; inset: 0; background: linear-gradient(180deg, rgba(5,12,16,.15), transparent 18%, transparent 78%, rgba(5,12,16,.22)); }
.graph-panel { min-height: 0; padding: 13px 22px 9px; border-top: 1px solid var(--line); background: #0a171c; display: grid; grid-template-rows: auto minmax(0,1fr) auto; }
.graph-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.graph-title { margin-top: 2px; font-size: 13px; font-weight: 650; letter-spacing: -.02em; color: #dce9e5; }
.graph-title span { color: var(--accent); font-weight: 550; margin-left: 4px; }
.graph-legend { display: flex; align-items: center; gap: 14px; color: #809a9b; font-size: 9px; white-space: nowrap; }
.graph-legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend-line { display: inline-block; width: 14px; height: 2px; background: var(--accent); }
.legend-point { width: 7px; height: 7px; border-radius: 50%; background: #f1d7a5; box-shadow: 0 0 0 3px rgba(241,215,165,.13); }
#flowChart { width: 100%; height: 100%; display: block; min-height: 0; }
.graph-footnote { display: flex; justify-content: space-between; align-items: center; color: #688284; font-size: 8px; font-weight: 750; letter-spacing: .12em; }
.graph-footnote b { color: #9aaca7; font-size: 7px; margin-left: 5px; }
.control-panel { min-height: 0; overflow: hidden; background: linear-gradient(180deg, #0d1a20, #0b171c); }
.panel-scroll { height: 100%; overflow-y: auto; overscroll-behavior: contain; padding: 19px 18px 15px; scrollbar-width: thin; scrollbar-color: #27444a transparent; }
.panel-scroll::-webkit-scrollbar { width: 5px; }
.panel-scroll::-webkit-scrollbar-thumb { background: #27444a; border-radius: 10px; }
.panel-section { padding-bottom: 17px; border-bottom: 1px solid var(--line); }
.section-heading { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.section-heading .eyebrow { font-size: 9px; }
.state-badge { padding: 4px 7px; border-radius: 5px; font-size: 8px; font-weight: 800; letter-spacing: .12em; border: 1px solid var(--line-strong); color: #8fa6a5; background: rgba(255,255,255,.025); }
.state-live { color: var(--accent); border-color: rgba(85,219,201,.25); background: rgba(85,219,201,.07); }
.state-jam { color: #e8bd78; border-color: rgba(232,189,120,.3); background: rgba(232,189,120,.08); }
.state-wait { color: #8fa6a5; }
.readout-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.readout-card { min-width: 0; padding: 10px 10px 9px; border: 1px solid rgba(145,184,183,.11); border-radius: 8px; background: rgba(255,255,255,.022); }
.readout-label { color: #8ba4a3; font-size: 8px; letter-spacing: .11em; font-weight: 800; white-space: nowrap; }
.readout-label span { display: block; margin-top: 3px; color: #587174; font-size: 7px; letter-spacing: .1em; }
.readout-value { margin-top: 7px; color: #e7f2ee; font-size: 23px; line-height: 1; font-weight: 570; letter-spacing: -.045em; font-variant-numeric: tabular-nums; }
.readout-card:first-child .readout-value, .readout-card:nth-child(3) .readout-value { color: var(--accent); }
.readout-unit { margin-top: 5px; color: #6f898b; font-size: 8px; }
.state-caption { margin: 11px 1px 0; min-height: 32px; color: #9ab0ad; font-size: 10px; line-height: 1.55; }

.mini-audit { display: flex; flex-direction: column; align-items: flex-start; justify-content: center; gap: 3px; margin-top: 9px; padding: 7px 9px; border: 1px solid rgba(85,219,201,.15); border-radius: 6px; background: rgba(85,219,201,.035); }
.mini-audit span { color: #6f8b89; font-size: 7px; font-weight: 800; letter-spacing: .1em; }
.mini-audit strong { color: var(--accent); font-size: 8px; font-weight: 750; font-variant-numeric: tabular-nums; white-space: nowrap; }

.controls-section { padding-top: 16px; }
.scale-tag { color: #5c7779; font-size: 7px; font-weight: 800; letter-spacing: .12em; }
.control-row { margin: 0 0 13px; }
.control-top { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 7px; }
.control-top label { color: #c3d3cf; font-size: 10px; font-weight: 620; }
.control-top label i { color: var(--accent); font-style: italic; }
.control-top output { color: var(--accent); font-size: 10px; font-weight: 750; font-variant-numeric: tabular-nums; }
input[type="range"] { appearance: none; width: 100%; height: 14px; margin: 0; padding: 0; background: transparent; cursor: pointer; }
input[type="range"]::-webkit-slider-runnable-track { height: 3px; border-radius: 10px; background: linear-gradient(90deg, rgba(85,219,201,.55), rgba(85,219,201,.14)); }
input[type="range"]::-moz-range-track { height: 3px; border-radius: 10px; background: linear-gradient(90deg, rgba(85,219,201,.55), rgba(85,219,201,.14)); }
input[type="range"]::-webkit-slider-thumb { appearance: none; width: 12px; height: 12px; margin-top: -4.5px; border: 2px solid #071a1c; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 2px rgba(85,219,201,.2); }
input[type="range"]::-moz-range-thumb { width: 9px; height: 9px; border: 2px solid #071a1c; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 2px rgba(85,219,201,.2); }
.range-ends { display: flex; justify-content: space-between; color: #587174; font-size: 7px; letter-spacing: .04em; margin-top: 1px; }
.preset-block { margin-top: 17px; }
.preset-heading { color: #809999; font-size: 8px; font-weight: 800; letter-spacing: .14em; margin-bottom: 8px; }
.preset-heading span { color: #526c70; margin-left: 5px; font-size: 7px; }
.preset-buttons { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.preset-button { min-width: 0; border: 1px solid var(--line); border-radius: 7px; background: rgba(255,255,255,.02); padding: 8px 6px; display: flex; align-items: center; gap: 6px; text-align: left; cursor: pointer; transition: .16s ease; }
.preset-button:hover { border-color: rgba(85,219,201,.35); background: rgba(85,219,201,.045); }
.preset-button.active { border-color: rgba(85,219,201,.4); background: rgba(85,219,201,.075); }
.preset-icon { display: grid; place-items: center; flex: 0 0 21px; height: 21px; border-radius: 5px; color: var(--accent); background: rgba(85,219,201,.1); font-size: 14px; }
.preset-button strong { display: block; color: #cbdad5; font-size: 8px; font-weight: 700; white-space: nowrap; }
.preset-button small { display: block; margin-top: 3px; color: #688184; font-size: 7px; white-space: nowrap; }
.transport-bar { display: flex; gap: 7px; padding: 14px 0 10px; }
.transport-bar .button-primary { flex: 1; }
.transport-bar .button-secondary { flex: 1; }
.quality-row { display: flex; align-items: center; justify-content: space-between; padding: 1px 0 14px; color: #688184; font-size: 8px; font-weight: 800; letter-spacing: .12em; }
.segmented { display: inline-flex; padding: 3px; gap: 2px; border: 1px solid var(--line); border-radius: 7px; background: rgba(0,0,0,.12); }
.segmented button { border: 0; background: transparent; border-radius: 4px; padding: 4px 9px; color: #799394; font-size: 8px; font-weight: 750; cursor: pointer; }
.segmented button.selected { background: #1a3438; color: var(--accent); }
.science-panel { border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.science-panel summary { list-style: none; min-height: 43px; display: flex; align-items: center; gap: 9px; cursor: pointer; color: #d0dfda; font-size: 10px; font-weight: 680; }
.science-panel summary::-webkit-details-marker { display: none; }
.science-icon { display: grid; place-items: center; width: 21px; height: 21px; border-radius: 6px; background: rgba(85,219,201,.1); color: var(--accent); font-size: 13px; }
.summary-hint { margin-left: auto; color: #597478; font-size: 7px; font-weight: 800; letter-spacing: .1em; }
.chevron { color: #779395; font-size: 15px; transition: transform .18s ease; }
.science-panel[open] .chevron { transform: rotate(180deg); }
.science-content { padding: 0 1px 14px; color: #9bb0ac; font-size: 9px; line-height: 1.65; }
.science-content h3 { margin: 5px 0 6px; color: #d8e5df; font-size: 11px; }
.science-content p { margin: 7px 0; }
.science-content b { color: #c9e2dc; }
.equation-card { margin: 9px 0; padding: 9px 10px; border: 1px solid rgba(145,184,183,.12); border-radius: 7px; background: rgba(255,255,255,.025); }
.equation-label { color: var(--accent); font-size: 7px; font-weight: 800; letter-spacing: .13em; margin-bottom: 5px; }
.equation-card p { margin: 3px 0; color: #c0d2cc; font-size: 9px; }
.equation-card .equation-note { color: #789293; font-size: 8px; margin-top: 6px; }
.check-card { display: flex; gap: 8px; padding: 9px; margin: 10px 0; border: 1px solid rgba(85,219,201,.18); border-radius: 7px; background: rgba(85,219,201,.045); }
.check-icon { color: var(--accent); font-size: 14px; }
.check-card strong { color: #d5e5df; font-size: 9px; }
.check-card p { margin: 3px 0 5px; color: #829b98; font-size: 8px; }
.audit-value { color: var(--accent); font-size: 9px; font-weight: 750; font-variant-numeric: tabular-nums; }
.science-content .disclaimer { margin-top: 12px; padding-top: 8px; border-top: 1px solid var(--line); color: #6f898a; font-size: 8px; font-style: italic; }
.keyboard-hint { display: flex; align-items: center; gap: 6px; padding: 12px 0 3px; color: #5e777b; font-size: 7px; letter-spacing: .05em; }
.keyboard-hint span { color: #9ab1ad; border: 1px solid rgba(151,190,194,.17); border-radius: 3px; padding: 2px 4px; font-size: 7px; font-weight: 800; margin-left: 4px; }
.keyboard-hint span:first-child { margin-left: 0; }
@media (max-width: 820px) {
  body { overflow: hidden; }
  .topbar { height: 60px; flex-basis: 60px; padding: 0 15px; }
  .brand-mark { width: 27px; height: 27px; padding: 5px; }
  .eyebrow { font-size: 8px; }
  h1 { font-size: 18px; }
  .model-chip { display: none; }
  .topbar-right { gap: 8px; }
  .button { height: 33px; }
  .app-main { grid-template-columns: minmax(0,1fr); grid-template-rows: minmax(285px, 41dvh) minmax(0,1fr); }
  .visual-column { grid-template-rows: minmax(0,1fr) 108px; border-right: 0; border-bottom: 1px solid var(--line); }
  .stage-topline { left: 13px; right: 13px; top: 11px; }
  .stage-bottomline { left: 13px; right: 13px; bottom: 9px; }
  .stage-label { font-size: 8px; gap: 6px; }
  .stage-kicker { font-size: 7px; }
  .direction-key, .wrap-note { font-size: 7px; }
  .graph-panel { padding: 8px 13px 6px; }
  .graph-heading { gap: 8px; }
  .graph-title { font-size: 11px; }
  .graph-legend { font-size: 7px; gap: 8px; }
  .graph-footnote { font-size: 7px; }
  .graph-footnote b { font-size: 6px; }
  .control-panel { min-height: 0; }
  .panel-scroll { padding: 13px 14px 14px; }
  .panel-section { padding-bottom: 12px; }
  .section-heading { margin-bottom: 9px; }
  .readout-grid { gap: 6px; }
  .readout-card { padding: 8px 9px 7px; }
  .readout-value { font-size: 20px; margin-top: 5px; }
  .state-caption { margin-top: 8px; min-height: 0; font-size: 9px; }
  .mini-audit { margin-top: 7px; padding: 6px 8px; }
  .mini-audit span { font-size: 6px; }
  .mini-audit strong { font-size: 7px; }
  .controls-section { padding-top: 12px; }
  .control-row { margin-bottom: 10px; }
  .preset-block { margin-top: 12px; }
  .transport-bar { padding-top: 11px; }
}
@media (max-width: 430px) {
  .topbar { padding: 0 11px; }
  .brand-lockup { gap: 9px; }
  .brand-copy .eyebrow { letter-spacing: .11em; }
  .snapshot-button { width: 35px; padding: 0; }
  .snapshot-button span { display: none; }
  .app-main { grid-template-rows: minmax(270px, 39dvh) minmax(0,1fr); }
  .visual-column { grid-template-rows: minmax(0,1fr) 102px; }
  .graph-legend { gap: 6px; }
  .graph-legend span { gap: 4px; }
  .readout-label { font-size: 7px; }
  .readout-label span { font-size: 6px; }
  .readout-unit { font-size: 7px; }
  .preset-button { gap: 4px; padding: 7px 4px; }
  .preset-icon { flex-basis: 18px; height: 18px; font-size: 12px; }
  .preset-button strong { font-size: 7px; }
  .preset-button small { font-size: 6px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}
body.embed-mode { height: 100vh; height: 100dvh; overflow: hidden; }
body.embed-mode .app-shell { height: 100vh; height: 100dvh; }
