:root {
  color-scheme: dark;
  --bg: #0b141b;
  --panel: #101c25;
  --panel-2: #14232d;
  --line: #253641;
  --line-soft: rgba(133, 159, 173, .16);
  --text: #e9f0f3;
  --muted: #93a5ae;
  --dim: #657984;
  --accent: #58d6c2;
  --accent-soft: rgba(88, 214, 194, .12);
  --accent-line: rgba(88, 214, 194, .42);
  --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; min-width: 320px; min-height: 100%; background: var(--bg); color: var(--text); }
body { overflow-x: hidden; }
button, input { font: inherit; }
button { color: inherit; }
.topbar {
  height: 48px; padding: 0 22px; display: flex; align-items: center; gap: 24px;
  border-bottom: 1px solid var(--line); background: #0d1820; color: var(--muted);
  letter-spacing: .12em; font-size: 9px; font-weight: 750;
}
.topbar-mark { display: flex; align-items: center; gap: 9px; color: var(--text); }
.mark-dot, .live-dot, .state-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 12px rgba(88,214,194,.42); }
.topbar-meta { display: flex; gap: 10px; align-items: center; }
.meta-divider { color: var(--dim); }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 9px; }
.app-shell {
  height: calc(100vh - 48px); height: calc(100dvh - 48px);
  display: grid; grid-template-columns: minmax(0, 1fr) 408px; min-height: 0;
}
.stage-column { min-width: 0; min-height: 0; display: flex; flex-direction: column; background: #0c171f; border-right: 1px solid var(--line); }
.stage-head { flex: 0 0 auto; min-height: 86px; padding: 16px 24px 12px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.eyebrow, .section-kicker { color: var(--accent); font-size: 9px; letter-spacing: .16em; line-height: 1.4; font-weight: 800; }
.eyebrow { display: flex; align-items: center; gap: 9px; }
.eyebrow-line { display: inline-block; width: 28px; height: 1px; background: var(--accent-line); }
h1 { margin: 4px 0 2px; font-size: clamp(23px, 2.3vw, 30px); line-height: 1.06; font-weight: 650; letter-spacing: -.04em; }
.stage-head p { margin: 0; color: var(--muted); font-size: 11px; }
.stage-state { display: flex; align-items: center; gap: 8px; padding: 7px 9px; border: 1px solid var(--line); border-radius: 99px; color: var(--muted); font-size: 8px; letter-spacing: .11em; white-space: nowrap; }
.state-dot { width: 5px; height: 5px; }
.canvas-wrap { position: relative; flex: 1 1 auto; min-height: 180px; overflow: hidden; background: #0a151d; }
#scene { display: block; width: 100%; height: 100%; touch-action: none; cursor: grab; outline: none; }
#scene.dragging { cursor: grabbing; }
.canvas-fallback { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); font-size: 13px; }
.stage-footer { flex: 0 0 34px; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 0 22px; color: var(--dim); font-size: 8px; letter-spacing: .11em; font-weight: 750; border-top: 1px solid rgba(133,159,173,.12); }
.stage-footer span { white-space: nowrap; }
.stage-footer b { color: var(--accent); padding: 0 4px; }
.footer-swatch { display: inline-block; width: 13px; height: 2px; vertical-align: middle; margin: 0 7px 2px 0; background: var(--accent); box-shadow: 0 0 8px rgba(88,214,194,.5); }
.control-panel { min-width: 0; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 18px 18px 20px; background: var(--panel); scrollbar-width: thin; scrollbar-color: #354a55 transparent; }
.control-panel::-webkit-scrollbar { width: 6px; }
.control-panel::-webkit-scrollbar-thumb { background: #354a55; border-radius: 8px; }
.section-kicker { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.section-kicker > span { color: var(--dim); font-size: 8px; letter-spacing: .12em; }
.readout-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 8px; margin-top: 10px; }
.readout-card { min-width: 0; min-height: 76px; padding: 10px 11px 8px; border: 1px solid var(--line); border-radius: 9px; background: #12212a; }
.readout-card-accent { border-color: var(--accent-line); background: linear-gradient(135deg, rgba(88,214,194,.09), rgba(18,33,42,.95) 65%); }
.readout-label { color: var(--muted); font-size: 8px; letter-spacing: .1em; font-weight: 750; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.readout-value { margin-top: 5px; color: var(--text); font-size: 21px; font-weight: 650; letter-spacing: -.045em; font-variant-numeric: tabular-nums; white-space: nowrap; }
.readout-value small { color: var(--muted); font-size: 10px; font-weight: 600; letter-spacing: 0; }
.readout-note { margin-top: 1px; color: var(--dim); font-size: 8px; }
.state-caption { margin: 10px 1px 0; min-height: 31px; color: #b7c5cb; font-size: 10px; line-height: 1.5; }
.controls-section, .preset-section, .motion-section, .checks-section, .experiment-section, .science-panel { margin-top: 18px; padding-top: 15px; border-top: 1px solid var(--line); }
.section-heading { display: flex; align-items: end; justify-content: space-between; gap: 10px; }
.section-heading h2, .experiment-section h2 { margin: 3px 0 0; font-size: 15px; font-weight: 630; letter-spacing: -.02em; }
.input-tag { padding: 4px 6px; border: 1px solid var(--line); border-radius: 4px; color: var(--dim); font-size: 7px; letter-spacing: .12em; font-weight: 800; white-space: nowrap; }
.control-list { display: grid; gap: 13px; margin-top: 13px; }
.control-row { min-width: 0; }
.control-label { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 6px; }
.control-label label { color: #dce5e9; font-size: 10px; font-weight: 580; }
.control-label output { color: var(--accent); font-size: 10px; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.control-hint { margin-top: 3px; color: var(--dim); font-size: 8px; line-height: 1.35; }
input[type="range"] { display: block; width: 100%; height: 14px; margin: 0; accent-color: var(--accent); cursor: pointer; background: transparent; }
input[type="range"]::-webkit-slider-runnable-track { height: 3px; border-radius: 99px; background: #344852; }
input[type="range"]::-webkit-slider-thumb { width: 12px; height: 12px; margin-top: -4.5px; appearance: none; border: 2px solid #0f1c24; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 1px var(--accent-line); }
input[type="range"]::-moz-range-track { height: 3px; border-radius: 99px; background: #344852; }
input[type="range"]::-moz-range-thumb { width: 9px; height: 9px; border: 2px solid #0f1c24; border-radius: 50%; background: var(--accent); }
.preset-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 7px; margin-top: 10px; }
.preset-button { min-width: 0; min-height: 54px; display: flex; align-items: center; gap: 8px; padding: 8px; border: 1px solid var(--line); border-radius: 8px; background: #12212a; text-align: left; cursor: pointer; transition: border-color .18s, background .18s; }
.preset-button:hover, .preset-button.active { border-color: var(--accent-line); background: var(--accent-soft); }
.preset-index { flex: 0 0 23px; display: grid; place-items: center; width: 23px; height: 23px; border-radius: 6px; background: #1c303a; color: var(--accent); font-size: 8px; font-weight: 800; }
.preset-button b { display: block; font-size: 9px; font-weight: 700; }
.preset-button small { display: block; margin-top: 3px; color: var(--dim); font-size: 7px; line-height: 1.25; }
.preset-break .preset-index { color: #d5e0e5; background: #26343d; }
.motion-controls { display: flex; align-items: center; gap: 6px; margin-top: 10px; }
.action-button, .quality-button { min-height: 32px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 0 10px; border: 1px solid var(--line); border-radius: 7px; background: #14242d; color: #c7d3d8; font-size: 9px; font-weight: 650; cursor: pointer; }
.action-button:hover, .quality-button:hover { border-color: var(--accent-line); color: var(--text); }
.primary-action { border-color: var(--accent-line); background: var(--accent-soft); color: var(--accent); }
.button-icon { font-size: 13px; line-height: 1; }
.quality-button { margin-left: auto; padding: 0 8px; color: var(--accent); font-size: 7px; letter-spacing: .1em; }
.compact-heading { align-items: center; }
.pass-count { color: var(--accent); font-size: 8px; font-weight: 800; letter-spacing: .1em; white-space: nowrap; }
.check-list { display: grid; gap: 8px; margin-top: 11px; }
.check-row { display: grid; grid-template-columns: 14px minmax(0,1fr) auto; align-items: center; gap: 7px; font-size: 9px; }
.check-mark { display: grid; place-items: center; width: 13px; height: 13px; border: 1px solid var(--accent-line); border-radius: 50%; color: var(--accent); font-size: 9px; line-height: 1; }
.check-name { color: #b8c6cc; }
.check-row output { color: var(--accent); font-size: 9px; font-weight: 700; font-variant-numeric: tabular-nums; }
.check-footnote { margin: 9px 0 0; color: var(--dim); font-size: 8px; line-height: 1.45; }
.experiment-section h2 { margin-top: 4px; }
.experiment-section p { margin: 7px 0 10px; color: var(--muted); font-size: 9px; line-height: 1.5; }
.experiment-button { width: 100%; min-height: 34px; display: flex; justify-content: space-between; align-items: center; padding: 0 11px; border: 1px solid var(--accent-line); border-radius: 7px; background: var(--accent-soft); color: var(--accent); font-size: 9px; font-weight: 750; cursor: pointer; }
.experiment-button:hover { background: rgba(88,214,194,.18); }
.experiment-button span { font-size: 15px; }
.experiment-result { margin-top: 8px; padding: 8px 9px; border: 1px solid var(--line); border-radius: 7px; color: #aebfc6; background: #101d25; font-size: 8px; line-height: 1.5; font-variant-numeric: tabular-nums; }
.science-panel { padding-bottom: 2px; }
.science-panel summary { display: flex; align-items: center; justify-content: space-between; gap: 10px; list-style: none; cursor: pointer; }
.science-panel summary::-webkit-details-marker { display: none; }
.science-panel summary > span:first-child { display: grid; gap: 3px; }
.science-panel summary strong { font-size: 14px; font-weight: 650; }
.details-plus { display: grid; place-items: center; width: 24px; height: 24px; border: 1px solid var(--line); border-radius: 6px; color: var(--accent); font-size: 16px; transition: transform .2s; }
.science-panel[open] .details-plus { transform: rotate(45deg); }
.science-content { padding: 12px 1px 2px; color: #afbec5; font-size: 9px; line-height: 1.55; }
.science-content h3 { margin: 12px 0 5px; color: var(--text); font-size: 10px; font-weight: 700; }
.science-content p { margin: 5px 0 7px; }
.science-content ul { margin: 5px 0 8px; padding-left: 16px; }
.science-content li { margin: 4px 0; }
.equation { overflow-x: auto; margin: 7px 0; padding: 8px 10px; border-left: 2px solid var(--accent); border-radius: 0 6px 6px 0; background: #0c1820; color: #e3f0f0; font-family: Georgia, "Times New Roman", serif; font-size: 13px; white-space: nowrap; }
.science-note { padding: 8px 9px; border: 1px solid var(--line); border-radius: 6px; color: #c0cdd2; }
.panel-endnote { margin-top: 15px; padding-top: 11px; border-top: 1px solid var(--line); color: var(--dim); font-size: 7px; letter-spacing: .13em; text-align: center; }
.panel-endnote span { color: var(--accent); padding: 0 5px; }
body.embed-mode { height: 100vh; height: 100dvh; overflow: hidden; }
body.embed-mode .topbar { display: none; }
body.embed-mode .app-shell { height: 100vh; height: 100dvh; }
@media (max-width: 900px) {
  .app-shell { grid-template-columns: minmax(0,1fr) 360px; }
  .control-panel { padding-left: 14px; padding-right: 14px; }
  .stage-head { padding-left: 18px; padding-right: 18px; }
}
@media (max-width: 700px) {
  html, body { min-width: 320px; }
  .topbar { height: 40px; padding: 0 13px; font-size: 8px; }
  .topbar-meta { display: none; }
  .app-shell, body.embed-mode .app-shell {
    height: auto; min-height: calc(100dvh - 40px); display: grid;
    grid-template-columns: minmax(0,1fr); grid-template-rows: 340px auto;
  }
  .stage-column { min-height: 0; border-right: 0; border-bottom: 1px solid var(--line); }
  .stage-head { min-height: 68px; padding: 10px 14px 8px; }
  .stage-head p { max-width: 250px; font-size: 9px; }
  .stage-state { padding: 6px 7px; font-size: 7px; }
  h1 { font-size: 23px; }
  .canvas-wrap { min-height: 0; }
  .stage-footer { flex-basis: 25px; padding: 0 12px; font-size: 7px; }
  .stage-footer span:nth-child(2) { display: none; }
  .control-panel { overflow: visible; padding: 16px 14px 22px; }
  body.embed-mode { height: 100vh; height: 100dvh; overflow: hidden; }
  body.embed-mode .app-shell {
    height: 100vh; height: 100dvh; min-height: 0; overflow: hidden;
    grid-template-rows: minmax(240px, 42dvh) minmax(0,1fr);
  }
  body.embed-mode .stage-column { min-height: 0; }
  body.embed-mode .control-panel { overflow-y: auto; min-height: 0; }
}
@media (max-width: 390px) {
  .stage-state { font-size: 6px; gap: 5px; }
  .stage-head { gap: 5px; }
  .stage-head p { max-width: 205px; }
  .control-panel { padding-left: 12px; padding-right: 12px; }
  .readout-value { font-size: 19px; }
  .preset-button { gap: 6px; padding: 7px 6px; }
  .preset-button b { font-size: 8px; }
  .preset-button small { font-size: 6px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; }
}
.canvas-fallback[hidden] { display: none; }
