:root {
  color-scheme: dark;
  --bg: #080d16;
  --panel: #0e1623;
  --panel-2: #111c2a;
  --panel-3: #152233;
  --line: rgba(164, 187, 213, .13);
  --line-strong: rgba(164, 187, 213, .22);
  --text: #e9f0f7;
  --muted: #9aabbd;
  --dim: #718398;
  --accent: #68d8d1;
  --accent-soft: rgba(104, 216, 209, .13);
  --accent-line: rgba(104, 216, 209, .36);
  --radius: 16px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--text); }
body { min-width: 320px; background-image: radial-gradient(ellipse at 8% 0%, rgba(32, 74, 88, .18), transparent 32%), radial-gradient(ellipse at 92% 20%, rgba(36, 49, 80, .16), transparent 30%); }
button, input { font: inherit; }
button { color: inherit; }
#app { min-height: 100vh; max-width: 1920px; margin: 0 auto; padding: 22px 26px 18px; display: flex; flex-direction: column; gap: 14px; }
.topbar { display: flex; align-items: center; justify-content: space-between; min-height: 76px; gap: 20px; }
.eyebrow, .section-kicker, .micro-label, .caption-label, .metric-name, .preset-title, .science-subhead, .panel-foot, .stage-corner, .clock-readout > span:first-child { font-size: 9px; letter-spacing: .15em; font-weight: 750; color: var(--dim); }
.eyebrow { display: flex; align-items: center; gap: 8px; color: #9db0c2; }
.eyebrow-dot, .status-pulse { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 12px rgba(104,216,209,.7); }
h1 { margin: 6px 0 2px; font-size: clamp(25px, 2.5vw, 35px); line-height: 1.08; font-weight: 650; letter-spacing: -.045em; }
h1 span { color: var(--accent); font-weight: 550; }
.subtitle { margin: 0; color: var(--muted); font-size: 12px; letter-spacing: .005em; }
.header-status { display: flex; align-items: center; gap: 9px; border: 1px solid var(--line); border-radius: 999px; padding: 9px 13px; color: #a8bac9; font-size: 9px; letter-spacing: .13em; font-weight: 750; white-space: nowrap; background: rgba(14,22,35,.65); }
.status-pulse { width: 6px; height: 6px; }
.toolbar { min-height: 46px; display: flex; align-items: center; gap: 8px; padding: 7px 9px; background: rgba(14,22,35,.82); border: 1px solid var(--line); border-radius: 13px; }
.transport-group { display: flex; gap: 6px; }
.toolbar-spacer { flex: 1; }
.btn { min-height: 32px; padding: 0 11px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid var(--line-strong); border-radius: 8px; background: #111c2a; color: #cbd7e2; font-size: 11px; font-weight: 650; cursor: pointer; transition: background .18s ease, border-color .18s ease, color .18s ease, transform .18s ease; }
.btn:hover, .preset-btn:hover { border-color: var(--accent-line); background: #172637; color: var(--text); }
.btn:active, .preset-btn:active { transform: translateY(1px); }
.btn:focus-visible, .preset-btn:focus-visible, input:focus-visible, summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.btn-primary { background: var(--accent); color: #071719; border-color: var(--accent); }
.btn-primary:hover { background: #83e5df; border-color: #83e5df; color: #071719; }
.btn-quiet { background: transparent; }
.btn-toggle { background: rgba(7,13,22,.5); color: #9aabbd; }
.btn-toggle.is-active { border-color: var(--accent-line); color: var(--accent); background: var(--accent-soft); }
.btn-icon { font-size: 15px; line-height: 1; }
.toggle-dot { width: 7px; height: 7px; border: 1px solid currentColor; border-radius: 50%; display: inline-block; }
.btn-toggle.is-active .toggle-dot { background: var(--accent); box-shadow: 0 0 8px rgba(104,216,209,.5); }
.quality-mark { width: 15px; height: 15px; border: 1px solid currentColor; border-radius: 4px; display: inline-grid; place-items: center; font-size: 8px; }
.workspace { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(330px, .82fr); gap: 14px; flex: 1; min-height: 0; }
.visual-column { display: grid; grid-template-rows: minmax(310px, 1.65fr) minmax(180px, .9fr); gap: 14px; min-height: 0; }
.panel { background: linear-gradient(155deg, rgba(17,28,42,.97), rgba(12,20,32,.98)); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 14px 40px rgba(0,0,0,.13), inset 0 1px 0 rgba(255,255,255,.018); overflow: hidden; }
.stage-panel, .plot-panel { display: flex; flex-direction: column; min-height: 0; }
.panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 15px 18px 11px; }
.panel-heading h2 { margin: 4px 0 0; font-size: 14px; letter-spacing: -.015em; font-weight: 620; }
.section-kicker { display: flex; align-items: center; gap: 8px; }
.tag { display: inline-flex; align-items: center; border-radius: 4px; padding: 3px 5px 2px; font-size: 7px; line-height: 1; letter-spacing: .12em; font-weight: 800; white-space: nowrap; }
.tag-scaled { color: #aebed0; background: rgba(164,187,213,.10); border: 1px solid rgba(164,187,213,.15); }
.tag-illustrative { color: var(--accent); background: var(--accent-soft); border: 1px solid rgba(104,216,209,.19); }
.tag-textbook { color: #c5d1df; background: rgba(177,195,215,.09); border: 1px solid rgba(177,195,215,.18); }
.phase-readout { text-align: right; display: flex; flex-direction: column; gap: 4px; }
.phase-readout strong { font-size: 18px; font-weight: 560; font-variant-numeric: tabular-nums; letter-spacing: -.04em; }
.micro-label { font-size: 8px; }
.stage-wrap { position: relative; flex: 1; min-height: 0; margin: 0 12px; border: 1px solid rgba(140,167,194,.10); border-radius: 12px; overflow: hidden; background: radial-gradient(ellipse at 50% 50%, rgba(22,45,61,.34), rgba(7,13,22,.96) 70%); }
canvas { display: block; width: 100%; height: 100%; }
.stage-corner { position: absolute; bottom: 10px; display: flex; align-items: center; gap: 7px; color: #8193a7; font-size: 7px; pointer-events: none; }
.stage-corner-left { left: 12px; }
.stage-corner-right { right: 12px; }
.legend-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; }
.pulsar-dot { background: var(--accent); box-shadow: 0 0 8px rgba(104,216,209,.6); }
.companion-dot { background: #c5d0dc; }
.legend-sep { width: 1px; height: 9px; background: var(--line-strong); margin: 0 2px; }
.stage-caption { display: flex; align-items: flex-start; gap: 10px; padding: 11px 18px 13px; min-height: 56px; }
.caption-icon { color: var(--accent); font-size: 14px; line-height: 1.2; }
.caption-label { color: #8195a8; font-size: 8px; margin-bottom: 3px; }
.stage-caption p { margin: 0; color: #b2c0ce; font-size: 10px; line-height: 1.45; }
.plot-heading { padding-top: 12px; padding-bottom: 6px; }
.plot-heading h2 { font-size: 13px; }
.plot-legend { display: flex; gap: 11px; flex-wrap: wrap; justify-content: flex-end; color: #93a5b7; font-size: 8px; }
.plot-legend span { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; }
.legend-line { display: inline-block; width: 13px; height: 2px; border-radius: 2px; background: #e8eff6; }
.line-total { background: #e5edf4; }
.line-roemer { background: var(--accent); }
.line-einstein { background: #7f8da0; }
.line-shapiro { background: #c4d2dd; border-top: 1px dashed #c4d2dd; height: 0; }
.plot-wrap { flex: 1; min-height: 0; padding: 0 10px 8px; }
.control-column { min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; padding-right: 2px; scrollbar-width: thin; scrollbar-color: rgba(120,145,170,.28) transparent; }
.control-column > * { flex: 0 0 auto; }
.controls-panel, .metrics-panel, .check-panel, .science-panel { padding: 0 16px 14px; }
.compact-heading { padding: 15px 0 12px; }
.compact-heading h2 { font-size: 14px; }
.fixed-mass-row { display: flex; align-items: center; gap: 8px; padding: 8px 10px; margin-bottom: 13px; border: 1px solid var(--line); border-radius: 8px; background: rgba(5,11,19,.32); color: #9bafc2; font-size: 10px; }
.fixed-mass-row strong { margin-left: auto; color: #dce6ef; font-size: 11px; font-weight: 650; font-variant-numeric: tabular-nums; }
.control-list { display: grid; gap: 13px; }
.control-item { min-width: 0; }
.control-top { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 6px; }
.control-top label { color: #d3deea; font-size: 10px; font-weight: 620; }
.control-top output { color: var(--accent); font-size: 10px; font-weight: 700; font-variant-numeric: tabular-nums; }
input[type="range"] { width: 100%; height: 13px; margin: 0; display: block; appearance: none; -webkit-appearance: none; background: transparent; cursor: pointer; }
input[type="range"]::-webkit-slider-runnable-track { height: 3px; border-radius: 10px; background: linear-gradient(90deg, var(--accent) 0%, var(--accent) var(--range-pct, 50%), #2b3a4b var(--range-pct, 50%), #2b3a4b 100%); }
input[type="range"]::-moz-range-track { height: 3px; border-radius: 10px; background: #2b3a4b; }
input[type="range"]::-moz-range-progress { height: 3px; background: var(--accent); border-radius: 10px; }
input[type="range"]::-webkit-slider-thumb { appearance: none; -webkit-appearance: none; width: 11px; height: 11px; margin-top: -4px; border-radius: 50%; background: var(--accent); border: 2px solid #d7fbf7; box-shadow: 0 0 0 3px rgba(104,216,209,.12); }
input[type="range"]::-moz-range-thumb { width: 9px; height: 9px; border-radius: 50%; background: var(--accent); border: 2px solid #d7fbf7; box-shadow: 0 0 0 3px rgba(104,216,209,.12); }
.range-ends { display: flex; align-items: center; justify-content: space-between; color: #687b90; font-size: 8px; margin-top: 1px; font-variant-numeric: tabular-nums; }
.range-class { color: #657c8c; font-size: 7px; letter-spacing: .1em; }
.preset-block { border-top: 1px solid var(--line); margin-top: 15px; padding-top: 12px; }
.preset-title { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; font-size: 8px; }
.preset-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.preset-btn { display: flex; align-items: center; gap: 8px; padding: 8px 9px; border: 1px solid var(--line); border-radius: 9px; background: rgba(5,11,19,.26); text-align: left; cursor: pointer; transition: border-color .18s ease, background .18s ease; }
.preset-btn.selected { border-color: var(--accent-line); background: var(--accent-soft); }
.preset-glyph { color: var(--accent); font-size: 16px; }
.preset-btn strong { display: block; color: #d9e4ee; font-size: 9px; font-weight: 700; }
.preset-btn small { display: block; margin-top: 2px; color: #7f93a7; font-size: 7px; line-height: 1.2; }
.playback-block { border-top: 1px solid var(--line); margin-top: 13px; padding-top: 12px; }
.clock-readout { display: flex; align-items: center; gap: 8px; margin-top: 9px; padding: 8px 9px; border-radius: 8px; background: rgba(5,11,19,.34); border: 1px solid var(--line); }
.clock-readout strong { margin-left: auto; color: #e0e9f1; font-size: 11px; font-variant-numeric: tabular-nums; }
.clock-readout > span:first-child { font-size: 8px; }
.metric-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.metric-card { min-height: 79px; padding: 10px; border: 1px solid var(--line); border-radius: 9px; background: rgba(5,11,19,.28); }
.metric-card.metric-highlight { border-color: var(--accent-line); background: linear-gradient(145deg, rgba(104,216,209,.10), rgba(5,11,19,.25)); }
.metric-name { display: block; color: #8296aa; font-size: 7px; letter-spacing: .12em; }
.metric-card strong { display: block; margin: 7px 0 3px; font-size: 18px; line-height: 1; letter-spacing: -.04em; font-weight: 620; color: #e8f1f7; font-variant-numeric: tabular-nums; }
.metric-highlight strong { color: var(--accent); }
.metric-card small { color: #72869a; font-size: 8px; }
.check-intro { margin: -1px 0 9px; color: #91a3b6; font-size: 9px; line-height: 1.4; }
.check-values { display: grid; gap: 7px; }
.check-values > div { display: flex; justify-content: space-between; gap: 8px; color: #899caf; font-size: 9px; }
.check-values strong { color: #dce6ef; font-size: 10px; font-variant-numeric: tabular-nums; }
.check-footer { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 10px; padding-top: 9px; border-top: 1px solid var(--line); color: #8295a9; font-size: 9px; }
.check-footer strong { margin-left: auto; color: var(--accent); font-size: 11px; font-variant-numeric: tabular-nums; }
.check-pass { color: var(--accent); font-size: 7px; letter-spacing: .13em; font-weight: 800; }
.science-panel { padding-top: 0; }
.science-panel summary { list-style: none; cursor: pointer; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 13px 0; }
.science-panel summary::-webkit-details-marker { display: none; }
.science-panel summary > span:first-child { display: flex; flex-direction: column; gap: 5px; }
.science-panel summary strong { font-size: 12px; font-weight: 650; }
.summary-plus { color: var(--accent); font-size: 17px; transition: transform .2s ease; }
.science-panel[open] .summary-plus { transform: rotate(45deg); }
.science-content { padding: 0 0 4px; color: #a1b1c1; font-size: 9px; line-height: 1.55; }
.science-subhead { display: flex; align-items: center; gap: 8px; margin: 10px 0 7px; color: #8297aa; font-size: 8px; }
.equation { margin: 6px 0; padding: 7px 8px; background: rgba(5,11,19,.35); border: 1px solid var(--line); border-radius: 6px; color: #8ea3b6; font-size: 8px; }
.equation span { display: block; margin-top: 3px; color: #e1eaf2; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 9px; overflow-wrap: anywhere; }
.equation-note { margin: 5px 0; color: #8397aa; font-size: 8px; }
.science-content p { margin: 6px 0; }
.disclaimer { padding-top: 8px; border-top: 1px solid var(--line); color: #c0ced9; font-style: italic; }
.panel-foot { display: flex; align-items: center; gap: 7px; padding: 1px 2px 5px; font-size: 7px; letter-spacing: .1em; color: #718398; }
.foot-sep { color: #415368; }

@media (min-width: 1500px) {
  #app { padding-left: 34px; padding-right: 34px; }
  .workspace { grid-template-columns: minmax(0, 1.65fr) minmax(360px, .75fr); }
}
@media (max-width: 980px) {
  #app { padding: 16px; }
  .workspace { grid-template-columns: minmax(0, 1.25fr) minmax(300px, .9fr); }
  .panel-heading { padding-left: 14px; padding-right: 14px; }
  .controls-panel, .metrics-panel, .check-panel, .science-panel { padding-left: 13px; padding-right: 13px; }
  .plot-legend { gap: 7px; }
}
@media (max-width: 760px) {
  #app { height: 100vh; height: 100dvh; min-height: 0; padding: 12px 11px max(10px, env(safe-area-inset-bottom)); gap: 9px; overflow: hidden; }
  .topbar { min-height: 66px; gap: 8px; }
  h1 { font-size: 23px; }
  .subtitle { font-size: 10px; }
  .header-status { padding: 7px 9px; font-size: 7px; gap: 6px; }
  .toolbar { min-height: 40px; padding: 5px; gap: 5px; flex-wrap: wrap; }
  .transport-group { gap: 4px; }
  .btn { min-height: 29px; padding: 0 8px; font-size: 9px; gap: 5px; }
  .btn-icon { font-size: 13px; }
  .toolbar-spacer { display: none; }
  .screenshot-btn { margin-left: auto; }
  .workspace { display: flex; flex-direction: column; flex: 1; min-height: 0; gap: 9px; overflow-y: auto; overflow-x: hidden; overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: rgba(120,145,170,.25) transparent; }
  .visual-column { display: contents; }
  .stage-panel { height: 310px; min-height: 310px; flex: none; }
  .plot-panel { height: 222px; min-height: 222px; flex: none; }
  .control-column { display: contents; overflow: visible; }
  .controls-panel, .metrics-panel, .check-panel, .science-panel { flex: none; }
  .panel { border-radius: 13px; }
  .panel-heading { padding: 11px 12px 8px; }
  .panel-heading h2 { font-size: 12px; }
  .phase-readout strong { font-size: 15px; }
  .stage-wrap { margin: 0 8px; }
  .stage-caption { padding: 8px 12px 10px; min-height: 49px; }
  .stage-caption p { font-size: 9px; }
  .stage-corner { bottom: 7px; font-size: 6px; }
  .plot-heading { align-items: flex-start; flex-direction: column; gap: 6px; }
  .plot-legend { justify-content: flex-start; font-size: 7px; }
  .plot-wrap { padding: 0 6px 6px; }
  .compact-heading { padding: 12px 0 10px; }
  .fixed-mass-row { margin-bottom: 11px; }
  .control-list { grid-template-columns: 1fr 1fr; column-gap: 14px; row-gap: 12px; }
  .control-top label, .control-top output { font-size: 9px; }
  .range-ends { font-size: 7px; }
  .range-class { font-size: 6px; }
  .preset-btn { padding: 7px; }
  .metric-card { min-height: 74px; }
  .metric-card strong { font-size: 16px; }
  .panel-foot { flex-wrap: wrap; padding-bottom: 10px; }
}
@media (max-width: 380px) {
  #app { padding-left: 8px; padding-right: 8px; }
  h1 { font-size: 21px; }
  .header-status { display: none; }
  .btn { padding: 0 6px; }
  .btn-toggle { font-size: 8px; }
  .stage-panel { height: 290px; min-height: 290px; }
  .control-list { column-gap: 10px; }
  .preset-btn 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 { height: 100vh; height: 100dvh; min-height: 0; }
body.embed-mode .workspace { min-height: 0; }
@media (max-width: 760px) {
  body.embed-mode .workspace { overflow-y: auto; }
}
