:root {
  color-scheme: dark;
  --bg: #071018;
  --panel: #0b1720;
  --panel-2: #0f202b;
  --line: rgba(150, 190, 199, 0.13);
  --line-strong: rgba(150, 190, 199, 0.22);
  --text: #e7f1f2;
  --muted: #8aa1a8;
  --dim: #5e777f;
  --cyan: #6fe0d4;
  --cyan-soft: rgba(111, 224, 212, 0.13);
  --amber: #f2a36b;
  --red: #e77b52;
  --radius: 12px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
}

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

.app-shell { height: 100dvh; min-height: 580px; display: flex; flex-direction: column; background: radial-gradient(ellipse at 36% 22%, rgba(16, 61, 70, 0.17), transparent 42%), var(--bg); }
.topbar { height: 72px; flex: 0 0 72px; display: flex; align-items: center; justify-content: space-between; padding: 0 24px 0 28px; border-bottom: 1px solid var(--line); background: rgba(6, 15, 22, 0.84); z-index: 5; }
.brand-lockup { display: flex; align-items: center; gap: 13px; }
.brand-mark { width: 34px; height: 34px; border: 1px solid rgba(111, 224, 212, .36); border-radius: 50%; position: relative; display: flex; align-items: center; justify-content: center; gap: 3px; transform: rotate(-22deg); }
.brand-mark span { display: block; width: 4px; border-radius: 4px; background: var(--cyan); box-shadow: 0 0 9px rgba(111, 224, 212, .45); }
.brand-mark span:nth-child(1) { height: 9px; opacity: .55; }
.brand-mark span:nth-child(2) { height: 17px; }
.brand-mark span:nth-child(3) { height: 12px; opacity: .75; }
.eyebrow, .section-kicker { color: #83a5ad; font-size: 9px; line-height: 1.2; letter-spacing: .16em; font-weight: 750; }
.brand-lockup h1 { margin: 4px 0 0; font-size: 19px; letter-spacing: -.035em; line-height: 1; font-weight: 650; }
.topbar-meta { display: flex; align-items: center; gap: 9px; color: #8299a1; font-size: 9px; letter-spacing: .14em; font-weight: 700; }
.status-dot, .chip-pulse { width: 6px; height: 6px; border-radius: 50%; background: #62d7c3; box-shadow: 0 0 10px rgba(98, 215, 195, .75); }
.meta-divider { width: 1px; height: 14px; background: var(--line-strong); margin: 0 7px; }
.seed-label { color: #5f7c84; }

.workspace { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 0; }
.stage-column { min-width: 0; min-height: 0; display: flex; flex-direction: column; padding: 14px 14px 10px 18px; }
.stage-frame { position: relative; flex: 1; min-height: 300px; overflow: hidden; border: 1px solid rgba(126, 174, 184, .16); border-radius: 14px; background: radial-gradient(ellipse at 50% 42%, #102933 0%, #091820 48%, #061018 100%); box-shadow: 0 20px 60px rgba(0,0,0,.24), inset 0 1px rgba(255,255,255,.035); }
#sceneCanvas { display: block; width: 100%; height: 100%; touch-action: none; outline: none; }
.stage-vignette { position: absolute; inset: 0; pointer-events: none; background: linear-gradient(180deg, rgba(3, 10, 15, .16), transparent 22%, transparent 72%, rgba(3, 9, 14, .48)), linear-gradient(90deg, rgba(3, 10, 15, .14), transparent 20%, transparent 78%, rgba(3, 10, 15, .12)); }
.stage-topline { position: absolute; top: 16px; left: 17px; right: 17px; display: flex; align-items: center; justify-content: space-between; pointer-events: none; }
.scene-chip { display: flex; align-items: center; gap: 8px; border: 1px solid rgba(127, 184, 186, .19); border-radius: 100px; padding: 7px 10px; background: rgba(7, 21, 28, .64); backdrop-filter: blur(12px); color: #a8c5c8; font-size: 8px; letter-spacing: .15em; font-weight: 750; }
.chip-pulse { width: 5px; height: 5px; }
.stage-top-actions { display: flex; gap: 7px; pointer-events: auto; }
.icon-button { width: 32px; height: 32px; border-radius: 8px; border: 1px solid rgba(140, 181, 190, .2); background: rgba(7, 20, 28, .7); color: #b4cbd0; font-size: 16px; cursor: pointer; transition: border-color .18s, background .18s, transform .18s; backdrop-filter: blur(12px); }
.icon-button:hover { border-color: rgba(111, 224, 212, .6); background: rgba(20, 53, 61, .78); transform: translateY(-1px); }
.camera-glyph { font-size: 20px; line-height: 1; }
.scene-annotations { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.scene-label { position: absolute; left: 0; top: 0; display: flex; align-items: center; gap: 6px; padding: 5px 8px; border: 1px solid rgba(123, 193, 190, .22); border-radius: 4px; background: rgba(4, 17, 23, .75); color: #a6c8c8; font-size: 8px; letter-spacing: .12em; font-weight: 750; white-space: nowrap; opacity: 0; transition: opacity .2s; }
.scene-label i { width: 5px; height: 5px; display: block; border-radius: 50%; background: var(--cyan); box-shadow: 0 0 8px rgba(111,224,212,.7); }
.label-band i { background: var(--amber); box-shadow: 0 0 8px rgba(242,163,107,.75); }
.label-front i { background: #6ce0d4; }
.stage-footer { position: absolute; bottom: 14px; left: 17px; right: 17px; display: flex; align-items: center; justify-content: space-between; pointer-events: none; }
.stage-legend { display: flex; gap: 14px; align-items: center; color: #8eaab0; font-size: 9px; letter-spacing: .04em; }
.stage-legend span { display: flex; align-items: center; gap: 6px; }
.legend-dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }
.legend-dot.reagent { background: #74e7dc; box-shadow: 0 0 8px rgba(116,231,220,.65); }
.legend-dot.precipitate { background: #e88a53; box-shadow: 0 0 8px rgba(232,138,83,.5); }
.orbit-hint { color: #68828a; font-size: 8px; letter-spacing: .12em; font-weight: 700; }
.orbit-hint b { color: #3d6069; padding: 0 4px; }
.mouse-icon { font-size: 15px; vertical-align: -1px; margin-right: 4px; }
.webgl-message { position: absolute; inset: 0; z-index: 10; display: grid; place-items: center; background: rgba(4, 12, 18, .86); backdrop-filter: blur(12px); }
.webgl-message[hidden] { display: none; }
.webgl-message-card { width: min(360px, calc(100% - 36px)); padding: 28px; border: 1px solid var(--line-strong); border-radius: 14px; background: #0c1b25; text-align: center; box-shadow: 0 22px 70px rgba(0,0,0,.45); }
.message-icon { color: var(--cyan); font-size: 30px; }
.webgl-message-card h2 { margin: 12px 0 8px; font-size: 17px; }
.webgl-message-card p { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.6; }

.timeline-bar { height: 78px; flex: 0 0 78px; margin-top: 10px; padding: 13px 16px; display: flex; align-items: center; justify-content: space-between; gap: 18px; border: 1px solid var(--line); border-radius: 12px; background: rgba(11, 24, 33, .9); }
.timeline-main { display: flex; align-items: center; gap: 16px; flex: 1; min-width: 0; }
.playback-controls { display: flex; gap: 6px; flex: 0 0 auto; }
.control-button { width: 32px; height: 32px; border-radius: 8px; border: 1px solid var(--line-strong); background: #12232d; color: #b4c9cd; cursor: pointer; font-size: 16px; transition: .18s; }
.control-button:hover { border-color: rgba(111,224,212,.6); color: var(--cyan); }
.control-button.primary { background: #174b4c; border-color: rgba(111,224,212,.32); color: #b8f5e9; font-size: 13px; }
.control-button.primary.paused { background: #15343c; }
.timeline-readout { flex: 1; min-width: 80px; }
.timeline-label-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 9px; gap: 10px; }
.timeline-label-row span, .timeline-side label { color: #78939a; font-size: 8px; font-weight: 750; letter-spacing: .14em; }
.timeline-label-row strong { color: #d2e4e5; font-size: 11px; font-weight: 650; font-variant-numeric: tabular-nums; }
.timeline-track { height: 4px; position: relative; border-radius: 10px; background: #1c343d; }
.timeline-progress { width: 0; height: 100%; border-radius: 10px; background: linear-gradient(90deg, #4baca5, #9de1c7); box-shadow: 0 0 10px rgba(111,224,212,.28); }
.timeline-marker { position: absolute; left: 0; top: 50%; width: 8px; height: 8px; transform: translate(-50%, -50%); border-radius: 50%; background: #c4f5e9; box-shadow: 0 0 8px rgba(111,224,212,.8); }
.timeline-side { display: flex; align-items: center; gap: 9px; flex: 0 0 auto; }
.timeline-side select { width: 68px; padding: 7px 8px; border: 1px solid var(--line-strong); border-radius: 7px; background: #10212a; color: #c1d6d8; font-size: 10px; cursor: pointer; }

.control-rail { min-height: 0; border-left: 1px solid var(--line); background: linear-gradient(180deg, rgba(11, 23, 32, .96), rgba(8, 18, 26, .98)); }
.rail-scroll { height: 100%; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: #28434c transparent; padding: 19px 18px 20px; }
.rail-scroll::-webkit-scrollbar { width: 5px; }
.rail-scroll::-webkit-scrollbar-thumb { background: #28434c; border-radius: 10px; }
.rail-section { padding: 0 0 17px; margin: 0 0 16px; border-bottom: 1px solid var(--line); }
.intro-section { padding-bottom: 15px; }
.intro-copy { margin: 9px 0 12px; color: #a4b8bd; font-size: 11px; line-height: 1.6; }
.process-flow { display: flex; align-items: center; justify-content: space-between; gap: 4px; padding: 9px 10px; border-radius: 8px; background: rgba(18, 41, 50, .72); border: 1px solid rgba(117, 169, 176, .1); }
.process-step { display: flex; flex-direction: column; gap: 4px; }
.process-step b { color: #5ec9be; font-size: 8px; letter-spacing: .08em; }
.process-step span { color: #b0c5c8; font-size: 7px; font-weight: 750; letter-spacing: .08em; white-space: nowrap; }
.process-flow > i { color: #4e747a; font-size: 15px; font-style: normal; margin: 0 1px; }
.section-heading { display: flex; align-items: center; justify-content: space-between; margin-bottom: 11px; }
.section-heading h2 { margin: 4px 0 0; font-size: 13px; font-weight: 650; letter-spacing: -.015em; }
.live-pill { color: #78d8c9; border: 1px solid rgba(111,224,212,.24); border-radius: 4px; padding: 4px 6px; font-size: 7px; letter-spacing: .12em; font-weight: 800; background: rgba(111,224,212,.07); }
.metric-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.metric-card { padding: 9px 10px 8px; border: 1px solid rgba(139, 180, 188, .12); border-radius: 8px; background: rgba(16, 34, 44, .7); min-height: 66px; }
.metric-card > span { display: block; color: #759198; font-size: 7px; letter-spacing: .12em; font-weight: 750; }
.metric-card strong { display: block; margin: 6px 0 2px; color: #d9f0eb; font-size: 17px; font-weight: 620; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.metric-card small { color: #68838a; font-size: 8px; }
.preset-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.preset-button { min-width: 0; min-height: 68px; display: flex; flex-direction: column; align-items: flex-start; gap: 4px; padding: 8px; border: 1px solid rgba(139,180,188,.14); border-radius: 8px; background: rgba(16, 34, 44, .6); text-align: left; cursor: pointer; transition: border-color .18s, background .18s; }
.preset-button:hover { border-color: rgba(111,224,212,.42); }
.preset-button.active { border-color: rgba(111,224,212,.48); background: rgba(23, 65, 67, .48); box-shadow: inset 0 0 0 1px rgba(111,224,212,.08); }
.preset-swatch { width: 28px; height: 8px; border-radius: 10px; display: block; background: repeating-linear-gradient(90deg, #db8053 0 4px, transparent 4px 7px); }
.preset-swatch.dense { background: repeating-linear-gradient(90deg, #e2a06a 0 2px, transparent 2px 4px); }
.preset-swatch.sparse { background: repeating-linear-gradient(90deg, #e18b54 0 5px, transparent 5px 12px); }
.preset-button b { color: #c9dadd; font-size: 9px; font-weight: 650; white-space: nowrap; }
.preset-button small { color: #789198; font-size: 7px; white-space: nowrap; }
.text-button { border: 0; background: transparent; color: #70cfc3; font-size: 8px; font-weight: 800; letter-spacing: .1em; cursor: pointer; padding: 5px 0 5px 8px; }
.text-button:hover { color: #b1fff0; }
.parameter-list { display: flex; flex-direction: column; gap: 14px; }
.parameter-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 6px; }
.parameter-top label { color: #b3c7ca; font-size: 9px; font-weight: 550; }
.parameter-top output { color: #8ce0d2; font-size: 9px; font-weight: 700; font-variant-numeric: tabular-nums; }
.parameter input[type="range"] { display: block; width: 100%; height: 4px; margin: 0; appearance: none; -webkit-appearance: none; border-radius: 10px; background: linear-gradient(90deg, #398f88, #27565c); cursor: pointer; }
.parameter input[type="range"]::-webkit-slider-thumb { appearance: none; -webkit-appearance: none; width: 12px; height: 12px; border: 2px solid #b5f2e5; border-radius: 50%; background: #327d78; box-shadow: 0 0 0 3px rgba(111,224,212,.12), 0 0 8px rgba(111,224,212,.36); }
.parameter input[type="range"]::-moz-range-thumb { width: 9px; height: 9px; border: 2px solid #b5f2e5; border-radius: 50%; background: #327d78; box-shadow: 0 0 0 3px rgba(111,224,212,.12); }
.range-ends { display: flex; justify-content: space-between; margin-top: 6px; color: #5e777f; font-size: 7px; }
.validation-icon { width: 21px; height: 21px; display: grid; place-items: center; border: 1px solid rgba(111,224,212,.25); border-radius: 50%; color: #75d6c9; font-size: 11px; }
.validation-intro { margin: -3px 0 10px; color: #91a9ae; font-size: 9px; line-height: 1.5; }
.validation-table { border: 1px solid rgba(139,180,188,.12); border-radius: 8px; overflow: hidden; }
.validation-table > div { display: flex; align-items: center; justify-content: space-between; padding: 8px 9px; background: rgba(15, 32, 42, .6); border-bottom: 1px solid rgba(139,180,188,.08); }
.validation-table > div:last-child { border-bottom: 0; }
.validation-table span { color: #769198; font-size: 7px; letter-spacing: .1em; font-weight: 750; }
.validation-table strong { color: #c7dcde; font-size: 10px; font-variant-numeric: tabular-nums; }
.validation-diff { background: rgba(25, 68, 64, .25) !important; }
.validation-diff strong { color: #86ddca; }
.validation-footnote { margin-top: 7px; color: #69848b; font-size: 8px; line-height: 1.5; }
.science-section { padding-bottom: 0; border-bottom: 0; }
.science-toggle { width: 100%; display: flex; justify-content: space-between; align-items: center; padding: 0; border: 0; background: transparent; text-align: left; cursor: pointer; }
.science-toggle > span:first-child { display: flex; flex-direction: column; gap: 5px; }
.science-toggle b { color: #d5e6e6; font-size: 13px; font-weight: 650; }
.chevron { color: #7b9ca1; font-size: 19px; transition: transform .2s; }
.science-toggle.expanded .chevron { transform: rotate(180deg); }
.science-panel { padding-top: 14px; color: #9db2b6; font-size: 9px; line-height: 1.65; }
.science-panel h3 { margin: 13px 0 5px; color: #c8dcde; font-size: 10px; font-weight: 700; }
.science-panel h3:first-child { margin-top: 0; }
.science-panel p { margin: 5px 0 8px; }
.science-panel ul { margin: 6px 0 0; padding-left: 16px; }
.science-panel li { margin: 4px 0; }
.equation { padding: 8px 10px; border: 1px solid rgba(111,224,212,.14); border-radius: 6px; background: rgba(15, 42, 47, .48); color: #a8e5da; font-family: Georgia, "Times New Roman", serif; font-size: 13px; letter-spacing: .015em; }
.science-constants { display: flex; flex-direction: column; gap: 6px; margin: 10px 0; }
.science-constants div { display: flex; flex-direction: column; gap: 2px; padding: 7px 8px; border-left: 2px solid #4a9991; background: rgba(14, 34, 42, .55); }
.science-constants b { color: #6fd1c5; font-size: 7px; letter-spacing: .1em; }
.science-constants span { color: #9eb5b8; font-size: 8px; }
.rail-bottom-note { margin-top: 8px; color: #516b73; font-size: 7px; line-height: 1.5; }

.app-footer { height: 32px; flex: 0 0 32px; display: flex; align-items: center; justify-content: space-between; padding: 0 20px; border-top: 1px solid var(--line); color: #5f7a82; font-size: 7px; letter-spacing: .13em; font-weight: 750; }
.quality-switch { display: flex; align-items: center; gap: 4px; }
.quality-switch > span { margin-right: 5px; color: #6e878e; }
.quality-switch button { padding: 4px 7px; border: 1px solid transparent; border-radius: 4px; background: transparent; color: #69848b; font-size: 7px; letter-spacing: .08em; cursor: pointer; }
.quality-switch button.selected { border-color: rgba(111,224,212,.22); background: rgba(111,224,212,.08); color: #8de0d3; }
.footer-shortcuts b { color: #3d5b64; padding: 0 4px; }

.embed-mode .topbar, .embed-mode .app-footer { display: none; }
.embed-mode .app-shell { min-height: 0; }
.embed-mode .workspace { grid-template-columns: minmax(0, 1fr) 340px; }
.embed-mode .stage-column { padding-top: 10px; }

@media (max-width: 1100px) {
  .workspace { grid-template-columns: minmax(0, 1fr) 330px; }
  .rail-scroll { padding-left: 14px; padding-right: 14px; }
  .stage-column { padding-left: 12px; padding-right: 10px; }
  .orbit-hint { display: none; }
}

@media (max-width: 760px) {
  html, body { height: 100%; overflow: auto; }
  .app-shell { height: auto; min-height: 100dvh; overflow: visible; }
  .topbar { height: 58px; flex-basis: 58px; padding: 0 14px; }
  .brand-mark { width: 29px; height: 29px; }
  .brand-lockup h1 { font-size: 16px; }
  .eyebrow { font-size: 7px; }
  .topbar-meta { font-size: 7px; gap: 6px; }
  .topbar-meta .meta-divider, .seed-label { display: none; }
  .workspace { display: flex; flex-direction: column; gap: 0; min-height: 0; }
  .stage-column { height: 48dvh; min-height: 340px; max-height: 470px; padding: 9px 9px 8px; }
  .stage-frame { min-height: 0; border-radius: 11px; }
  .stage-topline { top: 10px; left: 10px; right: 10px; }
  .scene-chip { font-size: 7px; padding: 6px 8px; }
  .icon-button { width: 29px; height: 29px; }
  .stage-footer { bottom: 9px; left: 10px; right: 10px; }
  .stage-legend { gap: 9px; font-size: 7px; }
  .stage-legend span { gap: 4px; }
  .orbit-hint { display: none; }
  .timeline-bar { height: 68px; flex-basis: 68px; margin-top: 7px; padding: 9px 10px; gap: 10px; }
  .timeline-main { gap: 9px; }
  .control-button { width: 29px; height: 29px; }
  .playback-controls { gap: 4px; }
  .timeline-label-row span { font-size: 7px; }
  .timeline-label-row strong { font-size: 9px; }
  .timeline-side { gap: 5px; }
  .timeline-side label { display: none; }
  .timeline-side select { width: 61px; font-size: 9px; padding: 6px; }
  .control-rail { border-left: 0; border-top: 1px solid var(--line); }
  .rail-scroll { height: auto; overflow: visible; padding: 17px 14px 20px; }
  .rail-section { padding-bottom: 15px; margin-bottom: 14px; }
  .intro-copy { font-size: 11px; }
  .process-step span { font-size: 7px; }
  .app-footer { padding: 0 12px; font-size: 6px; }
  .footer-shortcuts { display: none; }
  .embed-mode .workspace { display: flex; }
  .embed-mode .stage-column { height: 48dvh; }
}

@media (max-width: 390px) {
  .stage-column { height: 46dvh; min-height: 320px; }
  .stage-legend { font-size: 6px; }
  .metric-card { padding: 8px; }
  .metric-card strong { font-size: 15px; }
  .preset-button { 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; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
  .icon-button:hover { transform: none; }
}
