:root {
  color-scheme: dark;
  --bg: #091117;
  --panel: #101a22;
  --panel-2: #14212b;
  --line: rgba(174, 204, 213, .13);
  --line-strong: rgba(174, 204, 213, .22);
  --text: #e7f0ef;
  --muted: #92a5aa;
  --quiet: #60747c;
  --accent: #58d8c1;
  --accent-soft: rgba(88, 216, 193, .12);
  --accent-glow: rgba(88, 216, 193, .28);
  --water: #62c8e4;
  --danger: #d2a875;
  --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%; min-width: 0; min-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 { outline: 2px solid var(--accent); outline-offset: 3px; }
.app-shell { width: 100%; height: 100vh; height: 100dvh; display: flex; flex-direction: column; overflow: hidden; background: radial-gradient(ellipse at 45% 30%, rgba(36, 69, 76, .12), transparent 55%), var(--bg); }
.topbar { height: 58px; flex: 0 0 58px; display: flex; align-items: center; justify-content: space-between; padding: 0 22px; border-bottom: 1px solid var(--line); background: rgba(8, 16, 22, .9); z-index: 2; }
.brand-lockup { display: flex; align-items: center; gap: 12px; }
.brand-mark { width: 25px; height: 25px; border: 1px solid rgba(88,216,193,.6); border-radius: 50%; position: relative; display: flex; align-items: center; justify-content: center; gap: 2px; transform: rotate(30deg); }
.brand-mark span { display: block; width: 2px; height: 12px; border-radius: 2px; background: var(--accent); opacity: .9; }
.brand-mark span:nth-child(2) { height: 17px; }
.brand-name { font-size: 10px; font-weight: 750; letter-spacing: .18em; color: #dce9e7; }
.brand-name span { color: var(--accent); padding: 0 3px; }
.brand-sub { margin-top: 3px; color: var(--quiet); font-size: 8px; letter-spacing: .2em; font-weight: 650; }
.topbar-meta { display: flex; align-items: center; gap: 9px; color: #80969d; font-size: 9px; letter-spacing: .13em; font-weight: 650; }
.topbar-meta b { color: #dce8e6; font-weight: 700; margin-left: 3px; }
.topbar-meta small { font-size: 7px; color: var(--accent); letter-spacing: .1em; margin-left: 4px; }
.archive-dot, .live-dot { width: 6px; height: 6px; display: inline-block; border-radius: 50%; background: var(--accent); box-shadow: 0 0 10px var(--accent-glow); }
.workspace { min-height: 0; flex: 1; display: grid; grid-template-columns: minmax(0, 1fr) 360px; overflow: hidden; }
.stage-column { min-width: 0; min-height: 0; display: flex; flex-direction: column; border-right: 1px solid var(--line); padding: 16px 18px 10px; }
.stage-toolbar { height: 44px; flex: 0 0 44px; display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.view-switch { display: flex; align-items: center; gap: 4px; padding: 3px; background: #101b23; border: 1px solid var(--line); border-radius: 9px; }
.view-button { border: 0; border-radius: 6px; background: transparent; color: #7f959b; padding: 7px 11px; font-size: 10px; font-weight: 650; cursor: pointer; transition: background .2s ease, color .2s ease; }
.view-button:hover { color: var(--text); }
.view-button.active { color: #071511; background: var(--accent); box-shadow: 0 2px 12px rgba(88,216,193,.14); }
.icon-button { height: 32px; display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 0 10px; border: 1px solid var(--line-strong); border-radius: 8px; color: #a9bbbe; background: rgba(16,27,35,.85); font-size: 9px; font-weight: 650; cursor: pointer; transition: border-color .2s ease, color .2s ease, background .2s ease; }
.icon-button:hover { color: var(--accent); border-color: rgba(88,216,193,.45); background: var(--accent-soft); }
.icon-button svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.canvas-wrap { min-height: 0; flex: 1; position: relative; overflow: hidden; border: 1px solid rgba(151, 188, 195, .13); border-radius: 13px; background: #0b151c; box-shadow: 0 16px 40px rgba(0,0,0,.18), inset 0 1px rgba(255,255,255,.02); }
#machine-canvas { display: block; width: 100%; height: 100%; outline: none; }
.canvas-hud { position: absolute; pointer-events: none; z-index: 1; }
.hud-top-left { top: 19px; left: 20px; display: flex; flex-direction: column; gap: 5px; }
.hud-kicker { color: var(--accent); font-size: 8px; font-weight: 750; letter-spacing: .19em; }
.hud-title { color: #dbe9e7; font-size: 16px; font-weight: 620; letter-spacing: -.025em; }
.hud-bottom-left { left: 20px; bottom: 17px; display: flex; flex-direction: column; gap: 5px; }
.hud-scale { font-size: 7px; font-weight: 700; letter-spacing: .14em; color: #617981; }
.hud-scale b { color: var(--accent); font-weight: 700; }
.hud-note { color: #90a4a9; font-size: 9px; letter-spacing: .015em; }
.hud-bottom-right { right: 19px; bottom: 18px; display: flex; gap: 13px; }
.legend-item { display: inline-flex; align-items: center; gap: 5px; color: #7e969c; font-size: 7px; letter-spacing: .12em; font-weight: 700; }
.legend-line { display: inline-block; width: 13px; height: 2px; border-radius: 2px; }
.legend-line.water { background: var(--water); box-shadow: 0 0 7px rgba(98,200,228,.45); }
.legend-line.torque { background: var(--accent); }
.stage-footer { height: 28px; flex: 0 0 28px; display: flex; justify-content: space-between; align-items: flex-end; color: #5e737a; font-size: 7px; letter-spacing: .14em; font-weight: 700; }
.stage-footer-left { display: flex; align-items: center; gap: 8px; }
.stage-footer .live-dot { width: 5px; height: 5px; }
.footer-divider { color: #344a52; }
.stage-footer-right { display: flex; align-items: center; gap: 6px; }
.quality-mini-dot { width: 5px; height: 5px; border-radius: 50%; background: var(--accent); }
.control-panel { min-height: 0; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: #29404a transparent; padding: 18px 18px 14px; background: linear-gradient(180deg, rgba(17,29,38,.98), rgba(13,23,31,.98)); }
.control-panel::-webkit-scrollbar { width: 5px; }
.control-panel::-webkit-scrollbar-thumb { background: #29404a; border-radius: 6px; }
.panel-heading { padding-bottom: 15px; border-bottom: 1px solid var(--line); }
.eyebrow, .section-label { color: #81969b; font-size: 8px; letter-spacing: .16em; font-weight: 750; }
.eyebrow span { color: var(--accent); padding: 0 3px; }
h1 { margin: 8px 0 4px; color: #edf5f2; font-size: 27px; line-height: 1.1; letter-spacing: -.055em; font-weight: 650; }
.panel-deck { margin: 0; color: #91a5a9; font-size: 10px; line-height: 1.55; }
.history-chip { display: inline-flex; align-items: center; gap: 7px; margin-top: 11px; padding: 6px 8px; border: 1px solid rgba(88,216,193,.17); border-radius: 6px; background: rgba(88,216,193,.055); color: #a9c1c0; font-size: 8px; letter-spacing: .015em; }
.history-chip b { color: var(--accent); font-size: 7px; letter-spacing: .1em; }
.chip-icon { color: var(--accent); font-size: 11px; }
.state-card { margin-top: 13px; padding: 11px 12px 10px; background: rgba(6,14,19,.42); border: 1px solid var(--line); border-radius: 9px; }
.state-topline { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.state-pill { padding: 4px 7px; border: 1px solid rgba(88,216,193,.23); border-radius: 4px; color: var(--accent); background: var(--accent-soft); font-size: 7px; font-weight: 800; letter-spacing: .13em; }
.state-pill.stalled { color: var(--danger); border-color: rgba(210,168,117,.25); background: rgba(210,168,117,.08); }
.state-card p { margin: 8px 0 0; color: #9aadb0; font-size: 9px; line-height: 1.55; }
.readout-section, .controls-section, .preset-section, .transport-section { margin-top: 17px; }
.section-heading { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 9px; }
.micro-tag { color: #5d7b80; font-size: 7px; font-weight: 750; letter-spacing: .12em; white-space: nowrap; }
.readout-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 7px; }
.readout-card { min-width: 0; min-height: 71px; padding: 9px 10px 8px; background: rgba(6,14,19,.45); border: 1px solid var(--line); border-radius: 8px; }
.readout-label { color: #758c92; font-size: 7px; letter-spacing: .12em; font-weight: 750; white-space: nowrap; }
.readout-value { margin-top: 6px; color: #e5f0ed; font-size: 21px; line-height: 1; font-weight: 620; letter-spacing: -.04em; font-variant-numeric: tabular-nums; white-space: nowrap; }
.readout-value small { color: #82999e; font-size: 9px; font-weight: 600; letter-spacing: 0; }
.readout-foot { margin-top: 5px; color: #60767d; font-size: 7px; }
.efficiency-card { position: relative; }
.efficiency-card .readout-value { color: var(--accent); }
.efficiency-track { position: absolute; left: 10px; right: 10px; bottom: 7px; height: 2px; background: rgba(88,216,193,.13); border-radius: 4px; overflow: hidden; }
.efficiency-track span { display: block; width: 0; height: 100%; background: var(--accent); box-shadow: 0 0 8px var(--accent-glow); transition: width .15s linear; }
.slider-control { margin: 0 0 11px; }
.slider-heading { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-bottom: 5px; }
.slider-heading label { color: #c6d5d3; font-size: 9px; font-weight: 620; }
.slider-heading output { color: var(--accent); font-size: 9px; font-weight: 700; font-variant-numeric: tabular-nums; }
input[type="range"] { display: block; width: 100%; height: 13px; margin: 0; appearance: none; background: transparent; cursor: pointer; }
input[type="range"]::-webkit-slider-runnable-track { height: 3px; border-radius: 4px; background: linear-gradient(90deg, var(--accent) 0%, rgba(88,216,193,.25) 100%); }
input[type="range"]::-moz-range-track { height: 3px; border-radius: 4px; background: linear-gradient(90deg, var(--accent) 0%, rgba(88,216,193,.25) 100%); }
input[type="range"]::-webkit-slider-thumb { appearance: none; width: 11px; height: 11px; margin-top: -4px; border-radius: 50%; background: #dffaf3; border: 2px solid var(--accent); box-shadow: 0 0 0 3px rgba(88,216,193,.12); }
input[type="range"]::-moz-range-thumb { width: 8px; height: 8px; border-radius: 50%; background: #dffaf3; border: 2px solid var(--accent); box-shadow: 0 0 0 3px rgba(88,216,193,.12); }
.slider-hints { display: flex; justify-content: space-between; margin-top: 2px; color: #536a71; font-size: 6px; letter-spacing: .12em; font-weight: 700; }
.last-slider { margin-bottom: 0; }
.preset-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 7px; }
.preset-button { display: flex; align-items: center; gap: 8px; min-width: 0; padding: 9px 8px; border: 1px solid var(--line); border-radius: 8px; background: rgba(6,14,19,.36); text-align: left; cursor: pointer; transition: border-color .2s ease, background .2s ease; }
.preset-button:hover, .preset-button.active { border-color: rgba(88,216,193,.36); background: rgba(88,216,193,.07); }
.preset-icon { width: 23px; height: 23px; flex: 0 0 23px; display: grid; place-items: center; border-radius: 6px; color: var(--accent); background: rgba(88,216,193,.1); font-size: 13px; }
.preset-button b { display: block; color: #d0dedb; font-size: 8px; font-weight: 700; }
.preset-button small { display: block; margin-top: 3px; color: #71878d; font-size: 7px; white-space: nowrap; }
.transport-section { padding: 12px 0 0; border-top: 1px solid var(--line); }
.transport-buttons { display: grid; grid-template-columns: 1.35fr .8fr .8fr; gap: 6px; }
.primary-button, .secondary-button { height: 32px; display: inline-flex; align-items: center; justify-content: center; gap: 7px; border-radius: 7px; cursor: pointer; font-size: 9px; font-weight: 700; transition: background .2s ease, border-color .2s ease, color .2s ease; }
.primary-button { color: #071511; background: var(--accent); border: 1px solid var(--accent); }
.primary-button:hover { background: #7ce6d3; }
.secondary-button { color: #a5b8ba; background: rgba(6,14,19,.35); border: 1px solid var(--line-strong); }
.secondary-button:hover { color: var(--accent); border-color: rgba(88,216,193,.38); }
.play-icon { font-size: 10px; }
.quality-row { display: flex; align-items: center; justify-content: space-between; margin-top: 12px; }
.quality-switch { display: flex; padding: 2px; border: 1px solid var(--line); border-radius: 6px; background: rgba(5,13,18,.4); }
.quality-switch button { border: 0; border-radius: 4px; padding: 4px 9px; color: #748a90; background: transparent; font-size: 8px; cursor: pointer; }
.quality-switch button.active { color: #061511; background: var(--accent); font-weight: 750; }
.toggle-row { position: relative; display: flex; align-items: center; justify-content: space-between; margin-top: 10px; padding: 9px 0 1px; border-top: 1px solid var(--line); cursor: pointer; }
.toggle-row b { display: block; color: #bdccca; font-size: 8px; font-weight: 650; }
.toggle-row small { display: block; margin-top: 3px; color: #687f85; font-size: 7px; }
.toggle-row input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.toggle-ui { width: 28px; height: 15px; border: 1px solid #496069; border-radius: 10px; background: #20323b; transition: background .2s ease, border-color .2s ease; }
.toggle-ui::after { content: ""; display: block; width: 9px; height: 9px; margin: 2px; border-radius: 50%; background: #82969b; transition: transform .2s ease, background .2s ease; }
.toggle-row input:checked + .toggle-ui { background: rgba(88,216,193,.2); border-color: var(--accent); }
.toggle-row input:checked + .toggle-ui::after { transform: translateX(12px); background: var(--accent); }
.toggle-row input:focus-visible + .toggle-ui { outline: 2px solid var(--accent); outline-offset: 3px; }
.science-panel { margin-top: 15px; border: 1px solid var(--line); border-radius: 8px; background: rgba(5,13,18,.34); }
.science-panel summary { display: flex; align-items: center; justify-content: space-between; padding: 11px 12px; color: #c1d1cf; font-size: 8px; font-weight: 800; letter-spacing: .15em; cursor: pointer; list-style: none; }
.science-panel summary::-webkit-details-marker { display: none; }
.summary-plus { color: var(--accent); font-size: 14px; font-weight: 400; transition: transform .2s ease; }
.science-panel[open] .summary-plus { transform: rotate(45deg); }
.science-content { padding: 0 12px 12px; }
.science-intro { margin: 0 0 11px; color: #90a6a9; font-size: 8px; line-height: 1.6; }
.equation-block { padding: 9px 0; border-top: 1px solid var(--line); }
.equation-name { display: block; color: #6e878d; font-size: 6px; font-weight: 800; letter-spacing: .14em; margin-bottom: 6px; }
.equation-block code { display: block; color: #d6e7e2; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 10px; line-height: 1.6; }
.equation-block small { display: block; margin-top: 4px; color: #71888e; font-size: 7px; line-height: 1.5; }
.check-values { display: grid; grid-template-columns: 1fr auto; gap: 5px 10px; color: #789197; font-size: 7px; letter-spacing: .1em; }
.check-values b { color: var(--accent); font-size: 9px; letter-spacing: 0; font-variant-numeric: tabular-nums; }
.check-diff { margin-top: 7px; color: #82979b; font-size: 8px; }
.check-diff b { color: #e4f0ed; margin-left: 4px; }
.constants-note { margin-top: 8px; padding: 9px; border-radius: 6px; background: rgba(88,216,193,.045); color: #82989c; font-size: 7px; line-height: 1.7; }
.constants-note b { color: #a9c8c3; font-size: 6px; letter-spacing: .09em; }
.history-source { margin: 9px 0 0; color: #61777e; font-size: 7px; line-height: 1.55; }
.disclaimer { margin: 8px 0 0; color: #91aaa8; font-size: 7px; line-height: 1.5; }
.panel-footer { display: flex; justify-content: space-between; gap: 8px; padding-top: 14px; margin-top: 13px; border-top: 1px solid var(--line); color: #52676e; font-size: 6px; font-weight: 750; letter-spacing: .14em; }
.panel-footer b { color: var(--accent); }

@media (max-width: 900px) {
  .workspace { grid-template-columns: minmax(0, 1fr) 330px; }
  .stage-column { padding: 12px 12px 8px; }
  .control-panel { padding: 15px 14px 12px; }
}
@media (max-width: 680px) {
  body { overflow: hidden; }
  .topbar { height: 52px; flex-basis: 52px; padding: 0 13px; }
  .brand-mark { width: 22px; height: 22px; }
  .topbar-meta { font-size: 7px; gap: 6px; }
  .topbar-meta small { font-size: 6px; }
  .workspace { display: flex; flex-direction: column; min-height: 0; }
  .stage-column { flex: 0 0 43%; min-height: 250px; max-height: 390px; padding: 8px 9px 6px; border-right: 0; border-bottom: 1px solid var(--line); }
  .stage-toolbar { height: 38px; flex-basis: 38px; align-items: flex-start; gap: 6px; }
  .view-switch { gap: 1px; padding: 2px; }
  .view-button { padding: 7px 7px; font-size: 8px; }
  .icon-button { height: 29px; padding: 0 7px; font-size: 8px; }
  .icon-button svg { width: 12px; height: 12px; }
  .canvas-wrap { border-radius: 9px; }
  .hud-top-left { top: 12px; left: 12px; }
  .hud-title { font-size: 13px; }
  .hud-bottom-left { left: 12px; bottom: 11px; }
  .hud-bottom-right { right: 11px; bottom: 12px; gap: 7px; }
  .legend-item { font-size: 6px; }
  .hud-note { font-size: 7px; }
  .stage-footer { height: 21px; flex-basis: 21px; font-size: 6px; }
  .control-panel { flex: 1 1 auto; min-height: 0; padding: 13px 13px calc(12px + env(safe-area-inset-bottom)); }
  h1 { font-size: 23px; margin-top: 6px; }
  .panel-heading { padding-bottom: 11px; }
  .history-chip { margin-top: 8px; }
  .state-card { margin-top: 10px; }
  .readout-section, .controls-section, .preset-section, .transport-section { margin-top: 14px; }
}
@media (max-width: 390px) {
  .topbar { padding: 0 10px; }
  .brand-name { font-size: 9px; }
  .topbar-meta { letter-spacing: .07em; }
  .stage-column { flex-basis: 41%; min-height: 235px; }
  .view-button { padding-left: 6px; padding-right: 6px; font-size: 7px; }
  .screenshot-button span { display: none; }
  .screenshot-button { width: 30px; padding: 0; }
  .readout-value { font-size: 19px; }
}
@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; overflow: hidden; }
input[type="range"]::-webkit-slider-runnable-track { background: linear-gradient(90deg, var(--accent) 0%, var(--accent) var(--progress, 50%), rgba(88,216,193,.2) var(--progress, 50%), rgba(88,216,193,.2) 100%); }
input[type="range"]::-moz-range-track { background: linear-gradient(90deg, var(--accent) 0%, var(--accent) var(--progress, 50%), rgba(88,216,193,.2) var(--progress, 50%), rgba(88,216,193,.2) 100%); }
