:root {
  color-scheme: dark;
  --bg: #070d15;
  --panel: #0c1520;
  --panel-raised: #101d2a;
  --line: rgba(142, 177, 196, 0.14);
  --line-strong: rgba(142, 177, 196, 0.25);
  --text: #e8f0f4;
  --muted: #8398a7;
  --muted-2: #5d7382;
  --cyan: #61d5df;
  --cyan-bright: #7fe8ee;
  --gold: #e4bd7d;
  --green: #81d6a7;
  --danger: #e7a078;
  --radius: 12px;
  --space: 8px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--text); }
body { min-width: 320px; font-size: 13px; line-height: 1.45; }
button, input { font: inherit; }
button { color: inherit; }
button:focus-visible, input:focus-visible, summary:focus-visible { outline: 2px solid var(--cyan); outline-offset: 3px; }

.app-shell { min-height: 100vh; display: flex; flex-direction: column; background: radial-gradient(ellipse at 24% 0%, rgba(25, 66, 81, 0.16), transparent 42%), var(--bg); }
.topbar { min-height: 72px; padding: 12px 24px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 16px; background: rgba(7, 13, 21, 0.92); }
.brand-lockup { display: flex; align-items: center; gap: 12px; }
.brand-mark { width: 35px; height: 35px; border: 1px solid rgba(97, 213, 223, 0.34); border-radius: 10px; display: flex; align-items: center; justify-content: center; gap: 3px; transform: rotate(-8deg); background: linear-gradient(145deg, rgba(97, 213, 223, 0.14), rgba(97, 213, 223, 0.02)); }
.brand-mark span { display: block; width: 4px; border-radius: 4px; background: var(--cyan); box-shadow: 0 0 10px rgba(97, 213, 223, 0.45); }
.brand-mark span:nth-child(1) { height: 11px; opacity: .65; }
.brand-mark span:nth-child(2) { height: 19px; }
.brand-mark span:nth-child(3) { height: 14px; opacity: .8; }
.eyebrow, .section-kicker, .overlay-label, .readout-label, .control-section-title, .unit-note, .seed-label, .app-footer, .summary-hint { font-size: 9px; letter-spacing: .15em; font-weight: 700; color: var(--muted-2); }
.eyebrow { margin-bottom: 1px; }
h1 { font-size: 19px; line-height: 1.1; margin: 0; font-weight: 650; letter-spacing: -.035em; }
h1 span { color: var(--cyan-bright); }
.topbar-meta { display: flex; align-items: center; gap: 8px; }
.category-chip, .model-chip { border: 1px solid var(--line); border-radius: 999px; padding: 6px 10px; color: #a6bac6; font-size: 9px; font-weight: 700; letter-spacing: .09em; white-space: nowrap; }
.category-chip { display: flex; align-items: center; gap: 7px; }
.chip-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--gold); box-shadow: 0 0 9px rgba(228,189,125,.6); }
.model-chip { color: var(--cyan); border-color: rgba(97,213,223,.25); }

.workspace { width: min(1600px, 100%); margin: 0 auto; padding: 16px 20px 14px; display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; flex: 1; min-height: 0; }
.stage-column { min-width: 0; display: flex; flex-direction: column; gap: 12px; }
.stage-topline { display: flex; justify-content: space-between; align-items: end; gap: 12px; padding: 0 2px; }
.stage-heading { display: flex; flex-direction: column; gap: 2px; }
.stage-title { font-size: 15px; font-weight: 600; letter-spacing: -.02em; }
.live-state { display: inline-flex; align-items: center; gap: 7px; padding: 5px 9px; border-radius: 999px; border: 1px solid rgba(129,214,167,.18); background: rgba(129,214,167,.055); color: var(--green); font-size: 9px; letter-spacing: .11em; font-weight: 700; white-space: nowrap; }
.live-state i { width: 6px; height: 6px; border-radius: 50%; background: var(--green); box-shadow: 0 0 8px rgba(129,214,167,.65); }
.live-state.paused { color: var(--gold); border-color: rgba(228,189,125,.2); background: rgba(228,189,125,.05); }
.live-state.paused i { background: var(--gold); box-shadow: 0 0 8px rgba(228,189,125,.6); }

.scene-frame { height: clamp(340px, 47vh, 520px); min-height: 320px; position: relative; overflow: hidden; border: 1px solid rgba(117, 159, 178, .19); border-radius: 14px; background: radial-gradient(ellipse at 50% 50%, #102333 0%, #09131f 52%, #070d15 100%); box-shadow: 0 18px 55px rgba(0,0,0,.26), inset 0 0 50px rgba(63,125,148,.08); }
.scene-host { position: absolute; inset: 0; z-index: 1; touch-action: pan-y; }
.scene-host canvas { display: block; width: 100%; height: 100%; outline: none; }
.scene-vignette { position: absolute; inset: 0; pointer-events: none; z-index: 2; background: linear-gradient(90deg, rgba(7,13,21,.22), transparent 22%, transparent 78%, rgba(7,13,21,.24)), linear-gradient(0deg, rgba(7,13,21,.42), transparent 28%, transparent 78%, rgba(7,13,21,.28)); }
.scene-overlay { position: absolute; z-index: 3; top: 16px; display: flex; flex-direction: column; gap: 2px; pointer-events: none; }
.scene-overlay-left { left: 17px; }
.scene-overlay-right { right: 17px; text-align: right; }
.overlay-label { color: #7d9baa; font-size: 8px; }
.overlay-value { color: #c3d4dc; font-size: 10px; font-weight: 650; letter-spacing: .08em; }
.scene-legend { position: absolute; z-index: 3; bottom: 16px; left: 17px; display: flex; gap: 14px; flex-wrap: wrap; pointer-events: none; color: #a4b7c1; font-size: 10px; }
.scene-legend span { display: flex; align-items: center; gap: 6px; }
.legend-dot { width: 7px; height: 7px; display: inline-block; border-radius: 50%; }
.legend-dot.reagent { background: var(--cyan); box-shadow: 0 0 8px rgba(97,213,223,.8); }
.legend-dot.precipitate { background: var(--gold); box-shadow: 0 0 8px rgba(228,189,125,.7); }
.stage-controls { position: absolute; right: 14px; bottom: 12px; z-index: 4; display: flex; align-items: center; gap: 7px; }
.icon-button { width: 32px; height: 30px; display: grid; place-items: center; border-radius: 8px; border: 1px solid rgba(154,190,205,.22); background: rgba(8,17,27,.76); color: #b9cbd4; font-size: 18px; cursor: pointer; backdrop-filter: blur(12px); transition: border-color .18s, background .18s, color .18s; }
.icon-button:hover { border-color: rgba(97,213,223,.55); color: var(--cyan-bright); background: rgba(16,37,49,.88); }
.export-button { font-size: 16px; }
.quality-switch { display: flex; padding: 3px; border: 1px solid rgba(154,190,205,.20); border-radius: 8px; background: rgba(8,17,27,.76); backdrop-filter: blur(12px); }
.quality-button { border: 0; background: transparent; color: #8095a3; font-size: 8px; letter-spacing: .1em; font-weight: 800; padding: 5px 7px; border-radius: 5px; cursor: pointer; }
.quality-button.active { color: var(--cyan-bright); background: rgba(97,213,223,.13); }
.context-banner { position: absolute; z-index: 6; inset: auto 16px 58px; padding: 10px 12px; border: 1px solid rgba(231,160,120,.35); border-radius: 8px; color: #f2c4a7; background: rgba(53,29,23,.92); text-align: center; font-size: 11px; }
.stage-caption-row { display: flex; justify-content: space-between; gap: 12px; align-items: center; padding: 0 2px; }
.stage-caption-row p { margin: 0; color: #8297a5; font-size: 10px; }
.stage-caption-row p strong { color: #c2d2db; font-weight: 650; }
.drag-hint { color: #617785; font-size: 8px; font-weight: 700; letter-spacing: .1em; white-space: nowrap; }
.drag-hint b { color: var(--cyan); padding: 0 3px; }

.readout-section, .profile-section { border-top: 1px solid var(--line); padding-top: 12px; }
.section-heading-row, .profile-heading { display: flex; justify-content: space-between; align-items: end; gap: 10px; margin-bottom: 9px; }
h2 { margin: 2px 0 0; font-size: 14px; font-weight: 620; letter-spacing: -.02em; }
.unit-note { font-size: 8px; letter-spacing: .1em; }
.readout-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.readout-card { min-width: 0; border: 1px solid var(--line); border-radius: 9px; padding: 10px 11px 8px; background: linear-gradient(145deg, rgba(19,34,47,.88), rgba(10,20,30,.92)); }
.readout-label { font-size: 8px; letter-spacing: .09em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.readout-value { font-size: clamp(16px, 1.55vw, 22px); font-weight: 620; letter-spacing: -.04em; line-height: 1.35; margin-top: 4px; font-variant-numeric: tabular-nums; color: #e1edf1; white-space: nowrap; }
.readout-foot { color: #708592; font-size: 9px; display: flex; justify-content: space-between; align-items: center; }
.readout-indicator { font-size: 8px; }
.readout-indicator.cyan { color: var(--cyan); }
.readout-indicator.gold { color: var(--gold); }

.profile-section { padding-top: 10px; }
.profile-heading { margin-bottom: 4px; }
.profile-legend { display: flex; align-items: center; gap: 12px; color: #8298a5; font-size: 8px; letter-spacing: .1em; }
.profile-legend span:first-child { display: flex; align-items: center; gap: 5px; }
.profile-legend i { width: 12px; height: 2px; background: var(--cyan); display: inline-block; }
.profile-front-key { color: var(--gold); }
.profile-chart-wrap { padding: 4px 0 0; }
.profile-chart { width: 100%; height: 56px; overflow: visible; }
.profile-gridline { fill: none; stroke: rgba(136,167,183,.14); stroke-width: .7; stroke-dasharray: 2 3; }
.profile-area { fill: url(#profileFill); stroke: none; }
.profile-line { fill: none; stroke: var(--cyan); stroke-width: 1.5; vector-effect: non-scaling-stroke; }
.profile-front { stroke: var(--gold); stroke-width: 1.1; stroke-dasharray: 3 3; vector-effect: non-scaling-stroke; }
.profile-axis { display: flex; justify-content: space-between; color: #617987; font-size: 8px; letter-spacing: .06em; }

.control-panel { min-width: 0; align-self: stretch; border: 1px solid var(--line); border-radius: 13px; background: linear-gradient(180deg, rgba(14,24,36,.98), rgba(10,18,28,.98)); padding: 15px 15px 12px; display: flex; flex-direction: column; gap: 13px; box-shadow: 0 14px 40px rgba(0,0,0,.15); }
.panel-header { display: flex; align-items: end; justify-content: space-between; gap: 8px; }
.panel-header h2 { font-size: 16px; }
.seed-label { color: #6b8492; font-size: 8px; letter-spacing: .08em; white-space: nowrap; }
.transport-row { display: grid; grid-template-columns: 1fr 1fr 36px; gap: 7px; }
.primary-button, .transport-button { border: 1px solid var(--line-strong); border-radius: 8px; height: 36px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; cursor: pointer; font-size: 10px; font-weight: 750; letter-spacing: .06em; transition: background .18s, border-color .18s, transform .18s; }
.primary-button { background: linear-gradient(135deg, rgba(53,139,151,.32), rgba(27,84,99,.26)); border-color: rgba(97,213,223,.35); color: #a6f0f0; }
.primary-button:hover { background: rgba(47,132,144,.36); border-color: rgba(97,213,223,.7); }
.play-icon { font-size: 12px; }
.transport-button { background: rgba(20,34,47,.85); color: #a5b8c2; }
.transport-button:hover { background: rgba(29,53,68,.9); border-color: rgba(97,213,223,.4); color: var(--cyan-bright); }
.reset-button { font-size: 18px; }
.time-row { display: flex; justify-content: space-between; align-items: center; color: #6f8795; font-size: 8px; letter-spacing: .12em; font-weight: 750; margin-top: -5px; }
.time-row strong { color: #d8e5eb; font-size: 11px; letter-spacing: 0; font-weight: 650; font-variant-numeric: tabular-nums; }
.timeline-track { height: 3px; background: rgba(128,158,174,.15); border-radius: 99px; overflow: hidden; margin-top: -8px; }
.timeline-fill { width: 53.3%; height: 100%; background: linear-gradient(90deg, #2f8996, var(--cyan)); border-radius: inherit; transition: width .12s linear; }
.preset-section { border-top: 1px solid var(--line); padding-top: 10px; }
.control-section { border-top: 1px solid var(--line); padding-top: 10px; }
.control-section-title { display: flex; justify-content: space-between; align-items: center; margin-bottom: 9px; font-size: 8px; letter-spacing: .12em; }
.subtle { color: #526977; font-size: 7px; letter-spacing: .08em; }
.preset-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.preset-button { min-width: 0; min-height: 48px; border: 1px solid var(--line); border-radius: 7px; background: rgba(20,34,47,.55); padding: 6px 7px; display: flex; gap: 6px; align-items: center; text-align: left; cursor: pointer; transition: border-color .18s, background .18s; }
.preset-button b { font-size: 8px; color: #607987; align-self: start; }
.preset-button span { font-size: 9px; color: #a2b4be; font-weight: 600; line-height: 1.2; }
.preset-button.active { border-color: rgba(97,213,223,.42); background: rgba(38,101,112,.18); }
.preset-button.active b, .preset-button.active span { color: var(--cyan-bright); }

.slider-control { margin-bottom: 10px; }
.slider-control:last-child { margin-bottom: 0; }
.slider-label { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-bottom: 4px; }
.slider-label label { color: #b5c6cf; font-size: 10px; font-weight: 560; }
.slider-label output { color: var(--cyan-bright); font-size: 10px; font-weight: 650; font-variant-numeric: tabular-nums; white-space: nowrap; }
input[type="range"] { width: 100%; height: 13px; margin: 0; accent-color: var(--cyan); background: transparent; cursor: pointer; }
input[type="range"]::-webkit-slider-runnable-track { height: 3px; border-radius: 99px; background: linear-gradient(90deg, rgba(97,213,223,.55), rgba(97,213,223,.18)); }
input[type="range"]::-moz-range-track { height: 3px; border-radius: 99px; background: linear-gradient(90deg, rgba(97,213,223,.55), rgba(97,213,223,.18)); }
input[type="range"]::-webkit-slider-thumb { appearance: none; width: 11px; height: 11px; border-radius: 50%; margin-top: -4px; background: #a5f1f0; border: 2px solid #246d78; box-shadow: 0 0 0 3px rgba(97,213,223,.12); }
input[type="range"]::-moz-range-thumb { width: 9px; height: 9px; border-radius: 50%; background: #a5f1f0; border: 2px solid #246d78; box-shadow: 0 0 0 3px rgba(97,213,223,.12); }
.slider-scale { display: flex; justify-content: space-between; color: #526a78; font-size: 8px; margin-top: -1px; }
.speed-section { padding-top: 10px; }
.speed-section .slider-label { margin-bottom: 2px; }

.science-panel { border: 1px solid rgba(97,213,223,.18); border-radius: 9px; background: rgba(16,35,47,.44); overflow: hidden; }
.science-panel summary { list-style: none; cursor: pointer; min-height: 40px; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 0 10px; color: #c5d7df; font-size: 10px; font-weight: 650; }
.science-panel summary::-webkit-details-marker { display: none; }
.science-panel summary::after { content: '+'; color: var(--cyan); font-size: 17px; font-weight: 400; margin-left: auto; }
.science-panel[open] summary::after { content: '−'; }
.science-panel summary > span:first-child { display: flex; align-items: center; gap: 7px; }
.science-icon { display: grid; place-items: center; width: 20px; height: 20px; border-radius: 6px; color: var(--cyan); background: rgba(97,213,223,.1); font-size: 13px; }
.summary-hint { font-size: 7px; letter-spacing: .08em; color: #647e8b; font-weight: 600; }
.science-content { padding: 0 10px 11px; border-top: 1px solid var(--line); }
.science-block { padding: 10px 0 8px; border-bottom: 1px solid rgba(142,177,196,.10); }
.science-block h3 { margin: 0 0 5px; font-size: 9px; color: #b8cbd4; letter-spacing: .05em; }
.science-block p, .limitations { margin: 5px 0 0; color: #7f96a4; font-size: 9px; line-height: 1.55; }
.equation { color: #a7e4e5; background: rgba(97,213,223,.06); border-left: 2px solid rgba(97,213,223,.42); padding: 6px 8px; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 10px; overflow-wrap: anywhere; }
.validation-grid { display: grid; grid-template-columns: 1fr; gap: 4px; margin-top: 7px; }
.validation-grid span { display: flex; justify-content: space-between; gap: 8px; color: #708795; font-size: 8px; letter-spacing: .08em; }
.validation-grid b { color: #c6d9e0; font-size: 9px; font-weight: 650; letter-spacing: 0; font-variant-numeric: tabular-nums; }
.validation-status { margin-top: 7px; color: var(--green); font-size: 8px; font-weight: 800; letter-spacing: .1em; }
.limitations { padding-top: 9px; }
.limitations b { color: var(--gold); }
.panel-footnote { color: #536a78; font-size: 8px; line-height: 1.45; padding-top: 2px; }

.app-footer { width: min(1600px, 100%); margin: 0 auto; padding: 8px 22px 12px; display: flex; justify-content: space-between; gap: 12px; color: #536977; font-size: 8px; letter-spacing: .1em; }
.app-footer b { color: #2f7884; padding: 0 3px; }

body.embed .topbar, body.embed .app-footer { display: none; }
body.embed .workspace { padding: 8px; grid-template-columns: minmax(0, 1fr) 320px; }
body.embed .scene-frame { height: min(55vh, 500px); }
body.embed .stage-caption-row { display: none; }

@media (max-width: 1080px) {
  .workspace { grid-template-columns: minmax(0, 1fr) 310px; padding: 14px; gap: 12px; }
  .control-panel { padding: 12px; }
  .readout-grid { gap: 6px; }
  .readout-card { padding: 8px; }
  .readout-label { font-size: 7px; }
  .readout-value { font-size: 17px; }
}

@media (max-width: 820px) {
  .topbar { min-height: 62px; padding: 10px 14px; }
  .workspace { display: flex; flex-direction: column; padding: 12px; gap: 14px; }
  .scene-frame { height: clamp(320px, 52vh, 470px); }
  .control-panel { display: grid; grid-template-columns: 1fr 1fr; align-items: start; gap: 12px; }
  .panel-header, .transport-row, .time-row, .timeline-track, .preset-section, .control-section, .speed-section, .science-panel, .panel-footnote { grid-column: 1 / -1; }
  .control-section { display: grid; grid-template-columns: 1fr 1fr; column-gap: 18px; }
  .control-section-title { grid-column: 1 / -1; }
  .science-panel[open] { grid-column: 1 / -1; }
  .readout-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .app-footer { padding: 8px 14px 12px; }
  body.embed .workspace { display: flex; }
}

@media (max-width: 540px) {
  body { font-size: 12px; }
  .topbar { padding: 9px 12px; min-height: 58px; }
  .brand-mark { width: 31px; height: 31px; }
  h1 { font-size: 17px; }
  .eyebrow { font-size: 8px; }
  .topbar-meta { gap: 5px; }
  .category-chip, .model-chip { font-size: 7px; padding: 5px 7px; }
  .workspace { padding: 10px; gap: 12px; }
  .stage-topline { align-items: center; }
  .stage-title { font-size: 13px; }
  .scene-frame { height: 44vh; min-height: 290px; max-height: 390px; border-radius: 11px; }
  .scene-overlay { top: 11px; }
  .scene-overlay-left { left: 11px; }
  .scene-overlay-right { right: 11px; }
  .overlay-label { font-size: 7px; }
  .overlay-value { font-size: 8px; }
  .scene-legend { left: 11px; bottom: 12px; gap: 8px; font-size: 8px; }
  .stage-controls { right: 9px; bottom: 8px; gap: 5px; }
  .icon-button { width: 29px; height: 27px; }
  .quality-button { padding: 4px 6px; }
  .stage-caption-row { display: block; }
  .stage-caption-row p { font-size: 9px; }
  .drag-hint { display: none; }
  .readout-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .readout-card { padding: 9px 10px 7px; }
  .readout-label { font-size: 8px; }
  .readout-value { font-size: 19px; }
  .unit-note { font-size: 7px; }
  .profile-chart { height: 48px; }
  .control-panel { display: flex; padding: 12px; gap: 12px; }
  .control-section { display: block; }
  .preset-button { min-height: 46px; padding: 6px 5px; gap: 4px; }
  .preset-button span { font-size: 8px; }
  .slider-control { margin-bottom: 12px; }
  .slider-label label { font-size: 10px; }
  .app-footer { flex-direction: column; gap: 3px; font-size: 7px; padding: 8px 12px 10px; }
  .summary-hint { display: none; }
  body.embed .workspace { padding: 5px; }
  body.embed .scene-frame { height: 42vh; min-height: 270px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}
