:root {
  color-scheme: dark;
  --bg: #0b1118;
  --panel: #111a24;
  --panel-2: #15212d;
  --line: #263442;
  --muted: #8293a3;
  --text: #e8eff4;
  --soft: #b7c5cf;
  --accent: #61d6c4;
  --accent-dim: rgba(97,214,196,.13);
  --water: #42a9c9;
  --wood: #9a7046;
  --radius: 15px;
}
* { box-sizing: border-box; }
html, body { margin: 0; width: 100%; min-height: 100%; background: var(--bg); color: var(--text); font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
body { min-height: 100vh; min-height: 100dvh; overflow: hidden; }
body.embed-mode { height: 100vh; height: 100dvh; 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 { height: 100vh; height: 100dvh; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) 352px; gap: 12px; padding: 12px; }
.stage-panel { min-width: 0; min-height: 0; position: relative; overflow: hidden; border: 1px solid #24323f; border-radius: 18px; background: #0d1721; box-shadow: 0 18px 48px rgba(0,0,0,.28); }
#machineCanvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.stage-topbar { position: absolute; z-index: 2; left: 22px; right: 22px; top: 18px; display: flex; align-items: center; justify-content: space-between; gap: 12px; pointer-events: none; }
.brand-lockup, .top-actions { display: flex; align-items: center; gap: 12px; }
.brand-mark { width: 37px; height: 37px; display: grid; place-items: center; border: 1px solid rgba(97,214,196,.4); border-radius: 11px; color: var(--accent); background: rgba(97,214,196,.08); font-size: 19px; font-family: serif; }
.eyebrow { color: #7f93a4; font-size: 9px; font-weight: 800; letter-spacing: .17em; line-height: 1.4; }
.stage-title { color: #edf4f8; font-size: 16px; font-weight: 650; letter-spacing: -.025em; margin-top: 2px; }
.top-actions { pointer-events: auto; }
.live-indicator { display: inline-flex; align-items: center; gap: 7px; color: #8fa3b2; font-size: 9px; font-weight: 800; letter-spacing: .12em; }
.live-indicator i, .note-dot, .caption-pulse { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 10px rgba(97,214,196,.55); }
.live-indicator.paused i { background: #7d8a95; box-shadow: none; }
.icon-button { display: inline-flex; align-items: center; gap: 8px; padding: 9px 12px; border: 1px solid #344656; border-radius: 9px; background: rgba(17,26,36,.85); color: #c9d5dd; cursor: pointer; font-size: 11px; font-weight: 650; transition: border-color .18s, background .18s, transform .18s; }
.icon-button:hover { border-color: var(--accent); background: #172733; transform: translateY(-1px); }
.icon-button svg { width: 15px; height: 15px; fill: none; stroke: var(--accent); stroke-width: 1.6; }
.stage-note { position: absolute; top: 76px; left: 26px; z-index: 1; display: flex; align-items: center; gap: 8px; color: #718697; font-size: 9px; font-weight: 800; letter-spacing: .14em; pointer-events: none; }
.note-dot { width: 5px; height: 5px; }
.note-divider { color: #425362; }
.stage-footer { position: absolute; z-index: 2; left: 20px; right: 20px; bottom: 17px; display: flex; justify-content: space-between; align-items: center; gap: 12px; pointer-events: none; }
.view-switch { display: inline-flex; gap: 3px; padding: 4px; border: 1px solid #2a3946; border-radius: 10px; background: rgba(13,23,33,.9); pointer-events: auto; }
.view-button { border: 0; border-radius: 7px; padding: 8px 12px; background: transparent; color: #8ea0ae; font-size: 10px; font-weight: 700; cursor: pointer; transition: color .16s, background .16s; }
.view-button:hover { color: #dbe7ed; }
.view-button.active { color: #0d1b21; background: var(--accent); }
.stage-legend { display: flex; align-items: center; gap: 7px; color: #718493; font-size: 8px; font-weight: 800; letter-spacing: .1em; }
.legend-water, .legend-chain { width: 13px; height: 5px; display: inline-block; border-radius: 3px; background: var(--water); }
.legend-chain { margin-left: 9px; background: #bd9564; }
.control-panel { min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 17px 16px 12px; border: 1px solid #253340; border-radius: 18px; background: linear-gradient(180deg, #121c27 0%, #0f1822 100%); scrollbar-width: thin; scrollbar-color: #354653 transparent; }
.panel-heading { display: flex; justify-content: space-between; align-items: flex-end; gap: 8px; margin-bottom: 13px; }
.panel-heading h1 { margin: 3px 0 0; font-size: 22px; line-height: 1.1; letter-spacing: -.045em; font-weight: 690; }
.model-tag { margin-bottom: 2px; padding: 5px 7px; border: 1px solid #344451; border-radius: 5px; color: #8fa1af; font-size: 7px; letter-spacing: .12em; font-weight: 800; white-space: nowrap; }
.readout-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; margin-bottom: 17px; }
.readout-card { min-width: 0; padding: 10px 10px 9px; border: 1px solid #2b3a47; border-radius: 10px; background: rgba(22,34,46,.76); }
.primary-readout { grid-column: 1 / -1; padding: 12px 12px 10px; border-color: rgba(97,214,196,.33); background: linear-gradient(110deg, rgba(97,214,196,.10), rgba(22,34,46,.8) 65%); }
.readout-label { display: flex; justify-content: space-between; gap: 5px; color: #8194a3; font-size: 8px; font-weight: 800; letter-spacing: .1em; }
.readout-label span { color: #617785; font-size: 7px; }
.readout-value { display: flex; align-items: baseline; gap: 5px; margin-top: 4px; white-space: nowrap; }
.readout-value strong { color: #e8f1f5; font-size: 23px; font-weight: 680; letter-spacing: -.045em; font-variant-numeric: tabular-nums; }
.primary-readout .readout-value strong { color: var(--accent); font-size: 29px; }
.readout-value small { color: #8da0ad; font-size: 10px; font-weight: 650; }
.readout-foot { margin-top: 2px; color: #647887; font-size: 8px; }
.section-heading { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.section-heading h2 { margin: 0; color: #d9e3e9; font-size: 12px; font-weight: 700; letter-spacing: -.01em; }
.section-heading > span { color: #627686; font-size: 7px; font-weight: 800; letter-spacing: .12em; }
.control-section { padding-bottom: 13px; border-bottom: 1px solid #263541; }
.slider-control { margin: 11px 0 0; }
.slider-heading { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.slider-heading label { color: #b9c7d0; font-size: 10px; font-weight: 620; }
.slider-heading output { color: var(--accent); font-size: 10px; font-weight: 750; font-variant-numeric: tabular-nums; }
input[type="range"] { width: 100%; height: 16px; margin: 5px 0 0; background: transparent; cursor: pointer; appearance: none; -webkit-appearance: none; accent-color: var(--accent); }
input[type="range"]::-webkit-slider-runnable-track { height: 4px; border-radius: 99px; background: linear-gradient(90deg, rgba(97,214,196,.75), #3a4a57); }
input[type="range"]::-moz-range-track { height: 4px; border-radius: 99px; background: linear-gradient(90deg, rgba(97,214,196,.75), #3a4a57); }
input[type="range"]::-webkit-slider-thumb { width: 13px; height: 13px; margin-top: -4.5px; border: 2px solid #0e1b23; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 2px rgba(97,214,196,.25); appearance: none; -webkit-appearance: none; }
input[type="range"]::-moz-range-thumb { width: 10px; height: 10px; border: 2px solid #0e1b23; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 2px rgba(97,214,196,.25); }
.range-ends { display: flex; justify-content: space-between; color: #5f7280; font-size: 8px; font-variant-numeric: tabular-nums; }
.preset-section { padding: 13px 0 12px; border-bottom: 1px solid #263541; }
.preset-row { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.preset-button { display: flex; align-items: center; gap: 8px; min-width: 0; padding: 9px 8px; border: 1px solid #2e3e4b; border-radius: 9px; background: #15212c; text-align: left; cursor: pointer; transition: border-color .18s, background .18s, transform .18s; }
.preset-button:hover { border-color: var(--accent); background: #192b35; transform: translateY(-1px); }
.preset-icon { width: 25px; height: 25px; display: grid; flex: 0 0 auto; place-items: center; border-radius: 7px; background: rgba(97,214,196,.10); color: var(--accent); font-size: 15px; }
.preset-button b { display: block; color: #d6e0e6; font-size: 9px; font-weight: 700; }
.preset-button small { display: block; margin-top: 2px; color: #778b99; font-size: 7px; white-space: nowrap; }
.motion-section { padding: 12px 0 11px; border-bottom: 1px solid #263541; }
.motion-buttons { display: grid; grid-template-columns: 1.25fr 1fr 1fr; gap: 6px; }
.action-button { min-height: 34px; display: flex; justify-content: center; align-items: center; gap: 6px; padding: 7px 8px; border: 1px solid #344553; border-radius: 8px; background: #16232f; color: #b6c4ce; font-size: 11px; font-weight: 700; cursor: pointer; transition: border-color .18s, background .18s; }
.action-button:hover { border-color: var(--accent); background: #1a2c37; }
.action-button span { font-size: 9px; }
.primary-action { border-color: rgba(97,214,196,.4); background: rgba(97,214,196,.13); color: var(--accent); }
.quality-row { display: flex; align-items: center; justify-content: space-between; margin-top: 10px; }
.quality-row > span { color: #6f8391; font-size: 7px; font-weight: 800; letter-spacing: .12em; }
.quality-switch { display: inline-flex; padding: 2px; border: 1px solid #2d3d49; border-radius: 7px; background: #0f1821; }
.quality-switch button { border: 0; padding: 4px 9px; border-radius: 5px; background: transparent; color: #7d909e; font-size: 8px; font-weight: 750; cursor: pointer; }
.quality-switch button.active { background: #2a3d48; color: #dce7ec; }
.caption-card { margin-top: 12px; padding: 10px 11px 9px; border: 1px solid #2d3d49; border-radius: 10px; background: #14212c; }
.caption-kicker { display: flex; align-items: center; gap: 7px; color: #8499a8; font-size: 7px; font-weight: 800; letter-spacing: .13em; }
.caption-pulse { width: 5px; height: 5px; }
.caption-card p { min-height: 32px; margin: 7px 0 8px; color: #c2cfd7; font-size: 10px; line-height: 1.5; }
.torque-margin { display: flex; justify-content: space-between; align-items: center; padding-top: 7px; border-top: 1px solid #2b3b47; color: #718593; font-size: 7px; font-weight: 800; letter-spacing: .1em; }
.torque-margin strong { color: var(--accent); font-size: 10px; letter-spacing: 0; font-variant-numeric: tabular-nums; }
.torque-margin strong.negative { color: #e2a36c; }
.science-panel { margin-top: 12px; border: 1px solid #2b3a46; border-radius: 10px; background: rgba(17,27,38,.78); }
.science-panel summary { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 11px; list-style: none; cursor: pointer; }
.science-panel summary::-webkit-details-marker { display: none; }
.science-panel summary::after { content: "+"; color: var(--accent); font-size: 17px; line-height: 10px; }
.science-panel[open] summary::after { content: "−"; }
.science-panel summary > span:first-child { color: #dce7ec; font-size: 9px; font-weight: 800; letter-spacing: .13em; }
.summary-hint { margin-left: auto; color: #718593; font-size: 8px; }
.science-content { padding: 0 11px 11px; }
.science-intro { margin: 0 0 10px; color: #a7b7c2; font-size: 9px; line-height: 1.55; }
.equation { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 6px 0; border-top: 1px solid #253440; }
.equation b { color: #8498a6; font-size: 8px; font-weight: 650; }
.equation code { color: #b9e5dd; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 9px; white-space: nowrap; }
.check-card { margin: 10px 0; padding: 9px; border: 1px solid rgba(97,214,196,.25); border-radius: 8px; background: rgba(97,214,196,.06); }
.check-title { display: flex; justify-content: space-between; gap: 8px; margin-bottom: 7px; color: #b9d9d4; font-size: 7px; font-weight: 800; letter-spacing: .08em; }
.check-title span { color: #6d968f; font-size: 6px; }
.check-row, .check-difference { display: flex; justify-content: space-between; gap: 8px; padding: 3px 0; color: #8398a5; font-size: 8px; }
.check-row b { color: #d7e4e8; font-size: 8px; font-variant-numeric: tabular-nums; }
.check-difference { margin-top: 4px; padding-top: 6px; border-top: 1px solid rgba(97,214,196,.17); }
.check-difference strong { color: var(--accent); font-size: 9px; font-variant-numeric: tabular-nums; }
.science-small { margin: 8px 0; color: #8496a3; font-size: 8px; line-height: 1.55; }
.science-small b { color: #b9c8d0; }
.science-disclaimer { margin: 10px 0 0; color: #8fa1ad; font-size: 8px; line-height: 1.5; font-style: italic; }
.panel-foot { display: flex; justify-content: space-between; gap: 8px; padding: 11px 2px 0; color: #536877; font-size: 7px; font-weight: 800; letter-spacing: .11em; }
@media (max-width: 780px) {
  body { overflow: hidden; }
  .app-shell { grid-template-columns: minmax(0,1fr); grid-template-rows: minmax(270px, 48dvh) minmax(0,1fr); gap: 8px; padding: 8px; }
  .stage-panel { border-radius: 14px; }
  .stage-topbar { top: 10px; left: 12px; right: 12px; gap: 8px; }
  .brand-lockup { min-width: 0; gap: 8px; }
  .stage-title { white-space: nowrap; font-size: 11px; }
  .live-indicator { display: none; }
  .brand-mark { width: 31px; height: 31px; border-radius: 9px; font-size: 16px; }
  .eyebrow { font-size: 7px; }
  .stage-title { font-size: 12px; }
  .live-indicator { font-size: 7px; }
  .icon-button { padding: 7px 8px; font-size: 9px; }
  .icon-button svg { width: 13px; height: 13px; }
  .stage-note { top: 52px; left: 14px; font-size: 7px; }
  .stage-footer { left: 10px; right: 10px; bottom: 9px; }
  .view-switch { gap: 1px; padding: 3px; }
  .view-button { padding: 7px 9px; font-size: 8px; }
  .stage-legend { gap: 4px; font-size: 6px; letter-spacing: .07em; }
  .legend-water, .legend-chain { width: 9px; height: 4px; }
  .legend-chain { margin-left: 4px; }
  .control-panel { border-radius: 14px; padding: 13px 12px 10px; }
  .panel-heading { margin-bottom: 10px; }
  .panel-heading h1 { font-size: 19px; }
  .readout-grid { margin-bottom: 12px; }
  .readout-card { padding: 8px; }
  .primary-readout { padding: 9px 10px; }
  .readout-value strong { font-size: 20px; }
  .primary-readout .readout-value strong { font-size: 25px; }
  .readout-foot { font-size: 7px; }
  .control-section { padding-bottom: 10px; }
  .slider-control { margin-top: 8px; }
  .preset-section { padding: 10px 0; }
  .motion-section { padding: 10px 0; }
  .caption-card { margin-top: 10px; }
}
@media (max-width: 390px) {
  .stage-legend { display: none; }
  .view-button { padding-left: 8px; padding-right: 8px; }
  .model-tag { font-size: 6px; padding: 4px 5px; }
  .readout-label { font-size: 7px; }
  .preset-button { gap: 6px; padding: 8px 6px; }
  .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; }
}
