:root {
  color-scheme: dark;
  --bg: #07101a;
  --panel: #0e1926;
  --panel-2: #111f2d;
  --line: rgba(147, 184, 190, .14);
  --line-strong: rgba(147, 184, 190, .24);
  --text: #e8f0ec;
  --muted: #90a5a6;
  --dim: #62797e;
  --teal: #63d4c8;
  --teal-2: #2e9e9a;
  --amber: #d6a56a;
  --radius: 13px;
  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 42% -20%, rgba(33, 86, 92, .18), transparent 46%); }
button, input { font: inherit; }
button { color: inherit; }
button:focus-visible, input:focus-visible { outline: 2px solid var(--teal); outline-offset: 3px; }

.app-shell { max-width: 1900px; margin: 0 auto; min-height: 100vh; display: flex; flex-direction: column; }
.topbar { height: 78px; flex: 0 0 78px; display: grid; grid-template-columns: 196px minmax(300px, 1fr) 290px; align-items: center; gap: 22px; padding: 10px 22px; border-bottom: 1px solid var(--line); background: rgba(7, 16, 26, .88); }
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; }
.brand-symbol { width: 27px; height: 27px; display: flex; align-items: end; gap: 3px; padding: 4px; border: 1px solid rgba(99, 212, 200, .45); border-radius: 8px; background: rgba(42, 117, 117, .13); }
.brand-symbol span { width: 4px; border-radius: 4px; background: var(--teal); box-shadow: 0 0 10px rgba(99, 212, 200, .3); }
.brand-symbol span:nth-child(1) { height: 9px; opacity: .65; }
.brand-symbol span:nth-child(2) { height: 15px; }
.brand-symbol span:nth-child(3) { height: 11px; opacity: .8; }
.brand-name { font-size: 11px; font-weight: 800; letter-spacing: .14em; }
.brand-name span { display: block; color: #86a0a1; font-size: 8px; letter-spacing: .25em; margin-top: 2px; }
.title-block { min-width: 0; }
.eyebrow { color: #8ba3a4; font-size: 9px; font-weight: 750; letter-spacing: .18em; }
.eyebrow i, .footer i, .status-right i { display: inline-block; width: 3px; height: 3px; border-radius: 50%; background: #4e9290; vertical-align: middle; margin: 0 6px; }
.title-block h1 { margin: 3px 0 0; font-size: 20px; line-height: 1.1; font-weight: 650; letter-spacing: -.035em; }
.title-block p { margin: 3px 0 0; color: #91a5a5; font-size: 11px; }
.top-meta { justify-self: end; display: flex; align-items: center; gap: 10px; }
.model-chip, .seed-chip { border: 1px solid var(--line-strong); border-radius: 99px; padding: 7px 10px; color: #a7bbba; font-size: 8px; letter-spacing: .12em; white-space: nowrap; }
.model-chip { color: #8ce0d4; border-color: rgba(99, 212, 200, .25); background: rgba(49, 132, 125, .1); }
.model-chip b { display: inline-block; width: 5px; height: 5px; margin-right: 5px; border-radius: 50%; background: var(--teal); box-shadow: 0 0 8px var(--teal); vertical-align: 1px; }

.workspace { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 14px; padding: 14px 16px 12px; flex: 1 1 auto; min-height: 0; }
.stage-column { display: flex; flex-direction: column; min-width: 0; min-height: 0; gap: 10px; }
.viewport { position: relative; min-height: 400px; flex: 1 1 auto; overflow: hidden; border: 1px solid rgba(120, 168, 174, .17); border-radius: var(--radius); background: radial-gradient(ellipse at 50% 38%, #142a34 0%, #0a1824 48%, #07111c 100%); box-shadow: inset 0 1px 0 rgba(255,255,255,.035), 0 18px 60px rgba(0,0,0,.18); }
.webgl-root { position: absolute; inset: 0; width: 100%; height: 100%; }
.simulation-canvas { display: block; width: 100%; height: 100%; outline: none; }
.viewport::after { content: ""; position: absolute; inset: 0; pointer-events: none; background: linear-gradient(180deg, rgba(4, 11, 18, .46), transparent 29%, transparent 70%, rgba(4, 11, 18, .25)); }
.viewport-topline { position: absolute; z-index: 2; inset: 20px 22px auto; display: flex; justify-content: space-between; align-items: flex-start; pointer-events: none; }
.scene-index { color: #71c8c1; font-size: 9px; letter-spacing: .17em; font-weight: 800; }
.scene-heading h2 { margin: 9px 0 7px; font-size: clamp(19px, 2vw, 26px); line-height: 1.08; letter-spacing: -.045em; font-weight: 620; text-shadow: 0 2px 20px rgba(0,0,0,.5); }
.scene-heading p { margin: 0; color: #a3b8b8; font-size: 10px; line-height: 1.55; text-shadow: 0 1px 10px #07101a; }
.scene-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; color: #c0d0cb; font-size: 9px; letter-spacing: .1em; text-shadow: 0 1px 8px #07101a; }
.scene-meta strong { font-size: 10px; font-weight: 700; color: #e0e9e2; }
.meta-label { color: #82a09e; font-size: 8px; letter-spacing: .18em; }
.meta-divider { width: 35px; height: 1px; margin: 3px 0; background: rgba(129, 175, 172, .35); }
.scene-legend { position: absolute; z-index: 2; left: 20px; bottom: 49px; display: flex; flex-wrap: wrap; gap: 14px; color: #a7b9b6; font-size: 9px; text-shadow: 0 1px 8px #07101a; pointer-events: none; }
.scene-legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend-dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; box-shadow: 0 0 9px currentColor; }
.legend-dot.reagent { color: #62dcd1; background: #62dcd1; }
.legend-dot.mineral { color: #d8a568; background: #d8a568; }
.legend-dot.gel { color: #8fae9d; background: #8fae9d; }
.scene-cause { position: absolute; z-index: 2; right: 18px; bottom: 17px; display: flex; align-items: center; gap: 8px; color: #91aaa9; font-size: 8px; letter-spacing: .12em; pointer-events: none; }
.cause-step b { color: #62cfc5; font-weight: 800; margin-right: 4px; }
.cause-arrow { color: #597f83; font-size: 13px; }
.context-overlay { position: absolute; z-index: 6; inset: 0; display: grid; place-items: center; background: rgba(5, 12, 20, .86); backdrop-filter: blur(8px); }
.context-overlay[hidden] { display: none; }
.context-card { max-width: 320px; padding: 24px; border: 1px solid var(--line-strong); border-radius: 14px; background: #101e2b; text-align: center; }
.context-icon { color: var(--teal); font-size: 24px; }
.context-card h3 { margin: 10px 0 6px; font-size: 16px; }
.context-card p { color: var(--muted); font-size: 12px; line-height: 1.6; }

.transport-bar { min-height: 56px; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 11px; background: rgba(14, 25, 38, .9); }
.transport-main, .transport-tools { display: flex; align-items: center; gap: 7px; min-width: 0; }
.primary-button, .icon-button, .tool-button, .quality-button { border: 1px solid var(--line-strong); background: #142433; border-radius: 8px; height: 34px; display: inline-flex; align-items: center; justify-content: center; gap: 7px; cursor: pointer; transition: background .18s ease, border-color .18s ease, transform .18s ease; }
.primary-button:hover, .icon-button:hover, .tool-button:hover, .quality-button:hover { background: #1a3442; border-color: rgba(99, 212, 200, .42); }
.primary-button:active, .icon-button:active, .tool-button:active { transform: translateY(1px); }
.primary-button { padding: 0 14px; border-color: rgba(99, 212, 200, .34); background: #17413f; color: #d9f7ef; font-size: 11px; font-weight: 700; }
.primary-button:hover { background: #1d5550; }
.button-icon { font-size: 12px; }
.icon-button { min-width: 39px; padding: 0 9px; color: #b8cbca; font-size: 11px; }
.icon-button span { font-size: 13px; }
.transport-divider { width: 1px; height: 24px; margin: 0 5px; background: var(--line-strong); }
.speed-control { display: flex; align-items: center; gap: 2px; }
.speed-label { margin-right: 4px; color: #728d91; font-size: 8px; font-weight: 800; letter-spacing: .13em; }
.speed-control button { height: 27px; min-width: 34px; padding: 0 6px; border: 1px solid transparent; border-radius: 6px; background: transparent; color: #91a8a8; font-size: 9px; cursor: pointer; }
.speed-control button:hover { background: rgba(255,255,255,.045); }
.speed-control button.is-selected { border-color: rgba(99, 212, 200, .25); background: rgba(52, 139, 133, .17); color: #8ce2d6; }
.tool-button { padding: 0 9px; color: #9fb4b2; font-size: 9px; white-space: nowrap; }
.tool-button span { color: #73c8bf; font-size: 14px; }
.quality-button { min-width: 48px; padding: 0 8px; color: #82d7cc; border-color: rgba(99, 212, 200, .22); font-size: 8px; font-weight: 800; letter-spacing: .1em; }

.timeline-block { padding: 2px 3px 0; }
.timeline-head, .timeline-foot { display: flex; align-items: center; justify-content: space-between; color: #82999a; font-size: 8px; letter-spacing: .11em; }
.timeline-head span:first-child { color: #b0c1bd; font-weight: 800; }
.timeline-head span:last-child { letter-spacing: .02em; }
.progress-track { height: 4px; margin: 8px 0 5px; border-radius: 8px; background: #1a2a35; overflow: hidden; }
.progress-fill { width: 0; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #3b9e9b, #80d6c5); box-shadow: 0 0 10px rgba(99,212,200,.3); transition: width .12s linear; }
.timeline-foot { color: #5f767d; font-size: 8px; }
.status-row { min-height: 15px; display: flex; align-items: center; justify-content: space-between; padding: 0 2px; }
.status-indicator { color: #75d4c8; font-size: 8px; font-weight: 800; letter-spacing: .13em; }
.status-indicator[data-state="neutral"] { color: #92a8a7; }
.status-indicator[data-state="warning"] { color: #e2b36f; }
.status-right { color: #60787d; font-size: 8px; letter-spacing: .08em; }
kbd { padding: 2px 4px; border: 1px solid rgba(127, 160, 161, .22); border-radius: 3px; color: #9bb1af; font: inherit; }

.control-panel { min-width: 0; max-height: calc(100vh - 106px); overflow: auto; padding: 17px 16px 16px; border: 1px solid var(--line); border-radius: var(--radius); background: linear-gradient(180deg, rgba(16, 29, 43, .98), rgba(11, 22, 34, .98)); scrollbar-width: thin; scrollbar-color: #29454d transparent; }
.control-panel::-webkit-scrollbar { width: 5px; }
.control-panel::-webkit-scrollbar-thumb { background: #29454d; border-radius: 5px; }
.panel-heading { display: flex; justify-content: space-between; align-items: center; margin-bottom: 17px; }
.panel-heading h2 { margin: 5px 0 0; font-size: 16px; font-weight: 650; letter-spacing: -.025em; }
.panel-number { color: #55777c; font-size: 24px; font-weight: 300; letter-spacing: -.06em; }
.preset-section, .sliders-section, .data-section { padding-bottom: 15px; margin-bottom: 15px; border-bottom: 1px solid var(--line); }
.section-label { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; color: #a8bdb9; font-size: 8px; font-weight: 800; letter-spacing: .14em; }
.section-note { color: #5f7d80; font-size: 7px; letter-spacing: .12em; }
.preset-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.preset-button { min-height: 50px; display: flex; align-items: center; gap: 7px; padding: 7px; border: 1px solid var(--line); border-radius: 8px; background: rgba(255,255,255,.018); text-align: left; cursor: pointer; transition: .18s ease; }
.preset-button b { color: #68888b; font-size: 8px; font-weight: 800; align-self: flex-start; }
.preset-button span { color: #9db2af; font-size: 9px; line-height: 1.35; }
.preset-button:hover { border-color: rgba(99,212,200,.3); background: rgba(99,212,200,.06); }
.preset-button.is-selected { border-color: rgba(99,212,200,.38); background: rgba(53,135,128,.13); box-shadow: inset 0 0 0 1px rgba(99,212,200,.045); }
.preset-button.is-selected b, .preset-button.is-selected span { color: #9be0d5; }

.slider-control { margin: 0 0 13px; }
.slider-label { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin-bottom: 6px; }
.slider-label label { color: #c0ceca; font-size: 10px; }
.slider-label em { color: #86c9c0; font-style: normal; }
.slider-label output { color: #91d9ce; font-size: 9px; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
input[type="range"] { appearance: none; display: block; width: 100%; height: 13px; margin: 0; background: transparent; cursor: pointer; }
input[type="range"]::-webkit-slider-runnable-track { height: 3px; border-radius: 5px; background: linear-gradient(90deg, #398f8d, #28414a); }
input[type="range"]::-moz-range-track { height: 3px; border-radius: 5px; background: linear-gradient(90deg, #398f8d, #28414a); }
input[type="range"]::-webkit-slider-thumb { appearance: none; width: 11px; height: 11px; margin-top: -4px; border: 2px solid #a7eee0; border-radius: 50%; background: #2c8581; box-shadow: 0 0 0 3px rgba(99,212,200,.1), 0 0 10px rgba(99,212,200,.3); }
input[type="range"]::-moz-range-thumb { width: 8px; height: 8px; border: 2px solid #a7eee0; border-radius: 50%; background: #2c8581; box-shadow: 0 0 0 3px rgba(99,212,200,.1); }
.slider-scale { display: flex; justify-content: space-between; margin-top: 2px; color: #607a7e; font-size: 8px; }
.derived-value { display: flex; justify-content: space-between; margin-top: 6px; padding: 5px 7px; border-radius: 5px; background: rgba(67, 147, 140, .09); color: #769594; font-size: 8px; }
.derived-value strong { color: #a4d8ce; font-size: 8px; font-weight: 700; }
.control-hint { display: flex; align-items: center; gap: 7px; margin: 4px 0 0; color: #6f8889; font-size: 8px; line-height: 1.4; }
.control-hint span { color: #6dcfc4; font-size: 12px; }

.metric-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; }
.metric-card { min-height: 67px; padding: 9px 9px 7px; border: 1px solid rgba(137, 173, 174, .12); border-radius: 8px; background: rgba(255,255,255,.018); }
.metric-card > span { display: block; color: #789193; font-size: 7px; font-weight: 800; letter-spacing: .12em; }
.metric-card strong { display: block; margin-top: 5px; color: #e1ece4; font-size: 19px; line-height: 1; font-weight: 600; letter-spacing: -.04em; font-variant-numeric: tabular-nums; }
.metric-card strong small { color: #8eaaa6; font-size: 9px; font-weight: 500; letter-spacing: 0; }
.metric-card i { display: block; margin-top: 5px; color: #5d777b; font-size: 8px; font-style: normal; }
.profile-card { margin-top: 9px; padding: 9px 9px 7px; border: 1px solid rgba(137, 173, 174, .12); border-radius: 8px; background: rgba(5, 13, 21, .25); }
.profile-heading { display: flex; justify-content: space-between; align-items: center; color: #8ca6a4; font-size: 7px; font-weight: 800; letter-spacing: .11em; }
.profile-heading strong { color: #75cfc4; font-size: 8px; }
.profile-svg { width: 100%; height: 84px; display: block; margin-top: 4px; overflow: visible; }
.profile-gridline { fill: none; stroke: rgba(128, 163, 163, .16); stroke-width: 1; }
.profile-threshold { stroke: #d2a568; stroke-width: 1; stroke-dasharray: 4 4; opacity: .72; }
.profile-line { fill: none; stroke: #6bd8cc; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; filter: drop-shadow(0 0 3px rgba(99,212,200,.32)); }
.profile-axis { display: flex; justify-content: space-between; color: #60777b; font-size: 7px; }

.validation-section { padding: 11px 10px 9px; border: 1px solid rgba(98, 174, 158, .18); border-radius: 9px; background: rgba(40, 104, 93, .075); }
.validation-head { display: flex; align-items: center; gap: 8px; }
.validation-check { width: 20px; height: 20px; display: grid; place-items: center; border-radius: 50%; background: rgba(73, 161, 139, .16); color: #80d7bd; font-size: 12px; }
.validation-head div { flex: 1; min-width: 0; }
.validation-head div span { display: block; color: #77a49b; font-size: 7px; font-weight: 800; letter-spacing: .12em; }
.validation-head div strong { display: block; margin-top: 2px; color: #d4e2da; font-size: 10px; font-weight: 650; }
.textbook-tag { padding: 4px 5px; border: 1px solid rgba(99,212,200,.2); border-radius: 4px; color: #8bd5c8; font-size: 7px; letter-spacing: .1em; }
.validation-values { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-top: 12px; }
.validation-values div { min-width: 0; }
.validation-values span { display: block; color: #6e8e8a; font-size: 6px; font-weight: 800; letter-spacing: .09em; white-space: nowrap; }
.validation-values strong { display: block; margin-top: 4px; color: #c7d9d0; font-size: 11px; font-variant-numeric: tabular-nums; }
.validation-diff strong { color: #83d9c7; }
.validation-meta { margin: 8px 0 0; color: #6f8987; font-size: 7px; line-height: 1.4; }
.science-toggle { width: 100%; display: flex; justify-content: space-between; align-items: center; margin-top: 11px; padding: 10px 2px 3px; border: 0; background: transparent; color: #c1d1cb; font-size: 10px; font-weight: 650; text-align: left; cursor: pointer; }
.science-toggle span { color: #75cfc4; font-size: 16px; font-weight: 400; }
.science-panel { padding: 8px 1px 2px; color: #91a8a4; font-size: 9px; line-height: 1.55; }
.science-intro { margin-bottom: 11px; color: #9bb0ab; }
.equation-block { margin: 8px 0; padding: 8px; border: 1px solid rgba(135, 177, 171, .12); border-radius: 7px; background: rgba(255,255,255,.018); }
.equation-block > span:first-child { display: block; margin-bottom: 5px; color: #7fc7bb; font-size: 7px; font-weight: 800; letter-spacing: .12em; }
.equation-block code { display: block; color: #d5e4db; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 9px; white-space: normal; }
.equation-note { display: block; margin-top: 5px; color: #7e9995; font-size: 8px; }
.science-list { margin: 9px 0; }
.science-list b { color: #8cc9bf; font-size: 7px; letter-spacing: .1em; }
.science-list p { margin: 4px 0 0; color: #849c98; }
.science-list i { color: #b6d6cc; font-style: normal; }

.footer { min-height: 27px; display: flex; align-items: center; justify-content: space-between; gap: 15px; padding: 0 20px 7px; color: #526b70; font-size: 7px; letter-spacing: .1em; }
.footer span:first-child { color: #647a7b; }

.embed-mode .topbar, .embed-mode .footer { display: none; }
.embed-mode .workspace { min-height: 100vh; padding-top: 10px; padding-bottom: 10px; }
.embed-mode .control-panel { max-height: calc(100vh - 20px); }

@media (min-width: 1500px) {
  .workspace { grid-template-columns: minmax(0, 1fr) 390px; gap: 18px; padding-left: 22px; padding-right: 22px; }
  .viewport { min-height: 500px; }
  .control-panel { padding: 20px; }
}

@media (max-width: 1120px) {
  .workspace { grid-template-columns: minmax(0, 1fr) 330px; gap: 10px; padding: 10px; }
  .control-panel { padding: 14px 12px; }
  .topbar { grid-template-columns: 170px minmax(250px, 1fr) 250px; padding: 9px 14px; }
  .transport-tools .tool-button { padding: 0 7px; }
  .transport-tools .tool-button { font-size: 8px; }
}

@media (max-width: 820px) {
  .topbar { height: 68px; flex-basis: 68px; grid-template-columns: 36px 1fr auto; gap: 10px; padding: 8px 12px; }
  .brand-name { display: none; }
  .title-block h1 { font-size: 17px; }
  .title-block p { font-size: 9px; }
  .eyebrow { font-size: 7px; }
  .top-meta { gap: 5px; }
  .model-chip { font-size: 7px; padding: 6px 7px; }
  .seed-chip { display: none; }
  .workspace { grid-template-columns: 1fr; padding: 9px; gap: 10px; }
  .stage-column { gap: 8px; }
  .viewport { min-height: 440px; height: 55vh; flex: none; }
  .control-panel { max-height: none; overflow: visible; }
  .footer { padding: 5px 12px 10px; flex-wrap: wrap; }
}

@media (max-width: 520px) {
  .topbar { height: 62px; flex-basis: 62px; grid-template-columns: 29px 1fr auto; gap: 7px; padding: 7px 9px; }
  .brand-symbol { width: 25px; height: 25px; }
  .title-block h1 { font-size: 15px; }
  .title-block p { font-size: 8px; }
  .eyebrow { font-size: 6px; letter-spacing: .13em; }
  .model-chip { font-size: 6px; padding: 5px 6px; letter-spacing: .06em; }
  .model-chip b { width: 4px; height: 4px; margin-right: 3px; }
  .workspace { padding: 7px; }
  .viewport { height: 470px; min-height: 420px; border-radius: 10px; }
  .viewport-topline { inset: 14px 13px auto; }
  .scene-index { font-size: 7px; }
  .scene-heading h2 { margin-top: 7px; font-size: 19px; }
  .scene-heading p { font-size: 8px; }
  .scene-meta { font-size: 7px; }
  .scene-meta strong { font-size: 8px; }
  .scene-legend { left: 12px; bottom: 47px; gap: 8px; font-size: 7px; }
  .scene-cause { right: 10px; bottom: 15px; gap: 5px; font-size: 6px; }
  .cause-arrow { font-size: 10px; }
  .transport-bar { flex-wrap: wrap; padding: 7px; gap: 7px; }
  .transport-main { flex: 1 1 100%; justify-content: space-between; }
  .transport-tools { width: 100%; justify-content: flex-end; }
  .primary-button { flex: 1; }
  .transport-divider { margin: 0 2px; }
  .speed-label { font-size: 7px; }
  .speed-control button { min-width: 30px; }
  .timeline-head, .timeline-foot { font-size: 7px; }
  .status-right { display: none; }
  .control-panel { padding: 14px 12px; }
  .panel-heading h2 { font-size: 15px; }
  .preset-button { min-height: 48px; padding: 6px; gap: 5px; }
  .preset-button span { font-size: 8px; }
  .preset-button b { font-size: 7px; }
  .slider-label label { font-size: 9px; }
  .slider-label output { font-size: 8px; }
  .metric-card strong { font-size: 18px; }
  .footer { font-size: 6px; line-height: 1.5; }
  .embed-mode .workspace { padding: 0; }
  .embed-mode .viewport { height: 60vh; min-height: 380px; }
}

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