:root {
  color-scheme: dark;
  --bg: #0b1014;
  --panel: #11191e;
  --panel-2: #141f24;
  --line: rgba(160, 190, 190, .13);
  --line-strong: rgba(160, 190, 190, .23);
  --text: #e8eee9;
  --muted: #8a9b9b;
  --muted-2: #607373;
  --cyan: #65cbd0;
  --cyan-soft: rgba(101, 203, 208, .13);
  --amber: #d49a57;
  --green: #88c9a4;
  --radius: 14px;
  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-height: 100vh; overflow-x: hidden; }
button, input { font: inherit; }
button { color: inherit; }
.app-shell { width: min(1680px, 100%); margin: 0 auto; padding: 0 22px 14px; }
.topbar { min-height: 70px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); gap: 20px; }
.brand-lockup { display: flex; align-items: center; gap: 12px; }
.brand-mark { width: 28px; height: 28px; border: 1px solid rgba(101,203,208,.42); border-radius: 8px; display: flex; align-items: center; justify-content: center; gap: 2px; transform: rotate(-8deg); background: linear-gradient(145deg, rgba(101,203,208,.16), rgba(212,154,87,.08)); }
.brand-mark span { width: 3px; border-radius: 3px; background: var(--cyan); display: block; }
.brand-mark span:nth-child(1) { height: 9px; opacity: .55; }
.brand-mark span:nth-child(2) { height: 16px; }
.brand-mark span:nth-child(3) { height: 12px; opacity: .75; }
.eyebrow { font-size: 9px; letter-spacing: .16em; color: #7f9999; font-weight: 750; line-height: 1.4; }
.brand-title { font-size: 14px; font-weight: 650; letter-spacing: .015em; margin-top: 3px; }
.brand-title span { color: var(--cyan); padding: 0 4px; }
.topbar-right { display: flex; align-items: center; gap: 16px; }
.live-pill, .seed-tag { border: 1px solid var(--line); border-radius: 999px; padding: 7px 11px; color: #9eb0ad; font-size: 9px; letter-spacing: .11em; font-weight: 750; display: flex; align-items: center; gap: 7px; }
.live-pill i { width: 6px; height: 6px; border-radius: 50%; background: #647978; display: block; box-shadow: 0 0 0 3px rgba(100,121,120,.12); }
.live-pill.is-running i { background: var(--green); box-shadow: 0 0 0 3px rgba(136,201,164,.13), 0 0 10px rgba(136,201,164,.45); }
.seed-tag b { color: #d8e2dc; font-size: 10px; letter-spacing: .04em; }
.workspace { display: grid; grid-template-columns: minmax(0, 1.64fr) minmax(320px, .86fr); gap: 16px; padding-top: 16px; align-items: start; }
.visual-column, .control-column { min-width: 0; display: flex; flex-direction: column; gap: 14px; }
.scene-card, .control-card, .transport-card, .science-card, .validation-card { background: linear-gradient(155deg, rgba(20,30,35,.98), rgba(14,22,26,.98)); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 12px 40px rgba(0,0,0,.14); }
.scene-card { padding: 16px 16px 12px; }
.scene-topline { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 0 2px 12px; }
h1, h2, h3, p { margin-top: 0; }
.scene-topline h1 { margin: 5px 0 1px; font-size: clamp(23px, 2.3vw, 31px); line-height: 1.04; letter-spacing: -.045em; font-weight: 650; }
.scene-subtitle { margin: 0; color: #9baaa6; font-size: 12px; letter-spacing: .01em; }
.scene-actions { display: flex; gap: 6px; }
.icon-button { width: 34px; height: 34px; border: 1px solid var(--line-strong); background: rgba(255,255,255,.025); border-radius: 9px; color: #a8c3c0; cursor: pointer; font-size: 15px; transition: background .18s ease, border-color .18s ease, transform .18s ease; }
.icon-button:hover { background: var(--cyan-soft); border-color: rgba(101,203,208,.42); transform: translateY(-1px); }
#qualityToggle { font-size: 9px; font-weight: 800; letter-spacing: .05em; }
.scene-viewport { height: clamp(330px, 43vw, 510px); min-height: 310px; position: relative; overflow: hidden; border-radius: 10px; background: radial-gradient(ellipse at 46% 42%, #1b292b 0%, #0c1519 60%, #091014 100%); border: 1px solid rgba(157,192,187,.12); isolation: isolate; }
.three-mount { position: absolute; inset: 0; z-index: 1; }
.three-mount canvas { display: block; width: 100%; height: 100%; outline: none; touch-action: none; }
.scene-vignette { position: absolute; inset: 0; z-index: 2; pointer-events: none; background: linear-gradient(90deg, rgba(6,12,15,.12), transparent 24%, transparent 72%, rgba(6,12,15,.12)), linear-gradient(0deg, rgba(6,12,15,.34), transparent 28%, transparent 82%, rgba(6,12,15,.2)); }
.scene-hud { position: absolute; z-index: 3; display: flex; flex-direction: column; gap: 2px; pointer-events: none; padding: 9px 10px; border: 1px solid rgba(134,179,176,.16); background: rgba(9,17,20,.55); backdrop-filter: blur(8px); border-radius: 8px; min-width: 96px; }
.hud-left { left: 12px; bottom: 12px; }
.hud-right { right: 12px; bottom: 12px; text-align: right; }
.hud-kicker { color: #8ba5a1; font-size: 8px; font-weight: 800; letter-spacing: .13em; }
.scene-hud strong { font-size: 20px; line-height: 1.15; letter-spacing: -.03em; font-weight: 650; color: #e4eee6; font-variant-numeric: tabular-nums; }
.hud-unit { font-size: 8px; color: #6f8582; letter-spacing: .11em; }
.scene-annotation { position: absolute; z-index: 4; color: #a8c2bd; font-size: 8px; font-weight: 800; letter-spacing: .13em; white-space: nowrap; pointer-events: none; transform-origin: top left; text-shadow: 0 1px 6px #081114; transition: opacity .2s ease; }
.scene-annotation span { display: inline-block; width: 6px; height: 6px; background: var(--cyan); border-radius: 50%; margin-right: 5px; box-shadow: 0 0 8px rgba(101,203,208,.8); vertical-align: 1px; }
.annotation-bands span { background: var(--amber); box-shadow: 0 0 8px rgba(212,154,87,.8); }
.scene-loading, .context-lost { position: absolute; inset: 0; z-index: 8; display: flex; align-items: center; justify-content: center; flex-direction: column; gap: 12px; background: rgba(7,13,16,.88); color: #9eb3af; font-size: 11px; letter-spacing: .04em; }
.scene-loading.is-hidden { opacity: 0; pointer-events: none; transition: opacity .4s ease; }
.loader-ring { width: 26px; height: 26px; border: 2px solid rgba(101,203,208,.16); border-top-color: var(--cyan); border-radius: 50%; animation: spin 1s linear infinite; }
.context-lost { background: rgba(7,13,16,.92); text-align: center; padding: 24px; }
.context-lost[hidden] { display: none; }
.context-lost strong { color: #e6eeea; font-size: 14px; }
.context-lost span { max-width: 300px; line-height: 1.6; }
@keyframes spin { to { transform: rotate(360deg); } }
.scene-legend { min-height: 31px; display: flex; align-items: center; gap: 15px; padding: 10px 2px 0; flex-wrap: wrap; color: #849692; font-size: 9px; }
.scene-legend > div { display: flex; align-items: center; gap: 6px; }
.legend-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; }
.legend-dot.ion { background: #65cbd0; box-shadow: 0 0 7px rgba(101,203,208,.6); }
.legend-dot.mineral { background: #c48649; }
.legend-line { width: 15px; height: 2px; background: #65cbd0; opacity: .75; }
.legend-note { margin-left: auto; color: #647a77; }
.metrics-grid { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 8px; }
.metric-card { min-width: 0; padding: 12px 13px 10px; border: 1px solid var(--line); border-radius: 11px; background: linear-gradient(150deg, #121d21, #10171b); }
.metric-label { display: flex; align-items: center; gap: 5px; justify-content: space-between; font-size: 9px; color: #a4b4af; line-height: 1.35; min-height: 24px; }
.metric-type { font-size: 7px; color: #69817e; letter-spacing: .1em; white-space: nowrap; }
.metric-value { font-size: clamp(18px, 2vw, 25px); font-weight: 650; letter-spacing: -.045em; margin: 5px 0 3px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.metric-value small { font-size: 10px; color: #8da09b; font-weight: 500; letter-spacing: 0; margin-left: 4px; }
.metric-foot { color: #667b77; font-size: 8px; line-height: 1.45; min-height: 23px; }
.validation-card { padding: 14px 16px 12px; }
.validation-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.validation-heading h2, .panel-heading h2 { font-size: 15px; margin: 4px 0 0; font-weight: 630; letter-spacing: -.02em; }
.validation-status { border: 1px solid rgba(212,154,87,.25); background: rgba(212,154,87,.08); color: #d5a66b; border-radius: 999px; padding: 5px 8px; font-size: 8px; letter-spacing: .08em; font-weight: 800; white-space: nowrap; }
.validation-status.pass { color: #8dcba8; border-color: rgba(136,201,164,.24); background: rgba(136,201,164,.08); }
.validation-copy { margin: 9px 0 12px; color: #82938e; font-size: 10px; line-height: 1.55; }
.validation-values { display: grid; grid-template-columns: repeat(3,1fr); gap: 8px; }
.validation-values > div { border-left: 1px solid var(--line-strong); padding-left: 10px; display: flex; flex-direction: column; gap: 4px; }
.validation-values > div:first-child { border-left: 0; padding-left: 0; }
.validation-values span { color: #6f8580; font-size: 7px; letter-spacing: .11em; font-weight: 800; }
.validation-values strong { font-size: 15px; font-weight: 620; font-variant-numeric: tabular-nums; }
.validation-foot { margin-top: 11px; padding-top: 9px; border-top: 1px solid var(--line); color: #647874; font-size: 8px; letter-spacing: .025em; }
.control-card, .transport-card { padding: 16px; }
.panel-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.panel-heading h2 { font-size: 17px; }
.panel-index { font-size: 8px; color: #617976; letter-spacing: .12em; padding-top: 3px; font-weight: 800; }
.preset-row { display: grid; grid-template-columns: repeat(3,1fr); gap: 5px; padding: 13px 0 15px; border-bottom: 1px solid var(--line); }
.preset-button { border: 1px solid var(--line); background: rgba(255,255,255,.025); border-radius: 7px; padding: 8px 4px; color: #8ea09a; font-size: 9px; cursor: pointer; transition: .18s ease; }
.preset-button:hover { border-color: rgba(101,203,208,.35); color: #d4e3de; }
.preset-button.active { color: #d8eeea; border-color: rgba(101,203,208,.45); background: rgba(101,203,208,.11); box-shadow: inset 0 0 0 1px rgba(101,203,208,.06); }
.control-list { display: flex; flex-direction: column; gap: 12px; padding: 15px 0 13px; }
.control-item { display: flex; flex-direction: column; gap: 6px; cursor: pointer; }
.control-title { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; color: #aab8b2; font-size: 10px; }
.control-title b { color: #d9e5de; font-size: 10px; font-weight: 620; font-variant-numeric: tabular-nums; }
input[type="range"] { width: 100%; height: 4px; appearance: none; border-radius: 99px; background: linear-gradient(90deg, rgba(101,203,208,.78), rgba(101,203,208,.14)); outline: none; cursor: pointer; margin: 4px 0; }
input[type="range"]::-webkit-slider-thumb { appearance: none; width: 13px; height: 13px; border-radius: 50%; background: #d8ece5; border: 2px solid #5fb9bd; box-shadow: 0 0 0 3px rgba(101,203,208,.12); }
input[type="range"]::-moz-range-thumb { width: 10px; height: 10px; border-radius: 50%; background: #d8ece5; border: 2px solid #5fb9bd; box-shadow: 0 0 0 3px rgba(101,203,208,.12); }
input[type="range"]:focus-visible { outline: 2px solid rgba(101,203,208,.65); outline-offset: 6px; }
.range-ends { display: flex; justify-content: space-between; color: #617672; font-size: 8px; }
.transport-readout { border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 10px 0; display: flex; justify-content: space-between; gap: 10px; }
.transport-readout div { display: flex; flex-direction: column; gap: 4px; }
.transport-readout span { color: #6f8580; font-size: 8px; }
.transport-readout strong { color: #d9e4dd; font-size: 12px; font-weight: 620; font-variant-numeric: tabular-nums; }
.transport-readout small { color: #81958f; font-size: 8px; font-weight: 500; }
.porosity-row { display: flex; align-items: center; gap: 10px; padding-top: 11px; color: #9bada7; font-size: 9px; }
.porosity-row label { white-space: nowrap; }
.porosity-row input { flex: 1; }
.porosity-row b { color: #d9e5de; font-size: 9px; min-width: 40px; text-align: right; }
.panel-heading.compact { margin-bottom: 13px; }
.panel-heading.compact h2 { font-size: 15px; }
.transport-buttons { display: grid; grid-template-columns: 1.25fr 1fr 1fr; gap: 6px; }
.primary-button, .secondary-button { min-height: 37px; border-radius: 8px; border: 1px solid var(--line-strong); cursor: pointer; font-size: 10px; font-weight: 700; transition: .18s ease; }
.primary-button { background: linear-gradient(135deg, #2b7778, #21595d); color: #e8f7f0; border-color: rgba(101,203,208,.36); box-shadow: 0 5px 18px rgba(23,95,96,.18); }
.primary-button:hover { filter: brightness(1.13); transform: translateY(-1px); }
.primary-button.is-running { background: linear-gradient(135deg, #775535, #5b412a); border-color: rgba(212,154,87,.4); }
.button-icon { font-size: 10px; margin-right: 5px; }
.secondary-button { background: rgba(255,255,255,.035); color: #a7b7b1; }
.secondary-button:hover { border-color: rgba(101,203,208,.38); color: #e1eee7; background: rgba(101,203,208,.08); }
.speed-control { display: flex; flex-direction: column; gap: 8px; padding-top: 14px; color: #93a59e; font-size: 9px; }
.speed-control span { display: flex; justify-content: space-between; }
.speed-control b { color: #d9e5de; font-weight: 650; }
.keyboard-hints { display: flex; gap: 12px; flex-wrap: wrap; color: #667b76; font-size: 8px; padding-top: 9px; }
kbd { background: #1d2b2e; color: #a8c0b9; border: 1px solid rgba(150,190,181,.15); border-radius: 4px; padding: 2px 4px; font-size: 8px; }
.science-card { overflow: hidden; }
.science-toggle { width: 100%; display: flex; justify-content: space-between; align-items: center; text-align: left; padding: 14px 16px; background: transparent; border: 0; cursor: pointer; }
.science-toggle > span:first-child { display: flex; align-items: center; gap: 10px; }
.science-icon { width: 30px; height: 30px; display: grid; place-items: center; border-radius: 8px; background: rgba(212,154,87,.11); border: 1px solid rgba(212,154,87,.2); color: #d9ad72; font-size: 16px; }
.science-toggle b { display: block; font-size: 11px; font-weight: 650; }
.science-toggle small { display: block; margin-top: 3px; color: #728780; font-size: 8px; }
.chevron { color: #8ca19a; font-size: 17px; transition: transform .2s ease; }
.science-toggle.expanded .chevron { transform: rotate(180deg); }
.science-content { border-top: 1px solid var(--line); padding: 14px 16px 16px; }
.science-content[hidden] { display: none; }
.science-block { margin-bottom: 14px; }
.science-block h3 { color: #d6e2db; font-size: 10px; margin: 0 0 6px; font-weight: 700; }
.science-block p, .science-block li { color: #899b94; font-size: 9px; line-height: 1.58; }
.science-block p { margin-bottom: 7px; }
.science-block ul { margin: 0; padding-left: 16px; }
.equation { color: #d9b47e; background: rgba(212,154,87,.07); border: 1px solid rgba(212,154,87,.12); border-radius: 6px; padding: 8px 9px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 10px; }
.science-limit { border-top: 1px solid var(--line); padding-top: 11px; color: #7e918a; font-size: 9px; line-height: 1.55; }
.science-limit b { color: #cba46f; }
.panel-footer { display: flex; flex-direction: column; gap: 6px; padding: 0 2px; color: #5f736e; font-size: 8px; line-height: 1.5; }
.panel-footer span:last-child { color: #516965; letter-spacing: .12em; font-weight: 750; }
.app-footer { display: flex; justify-content: space-between; gap: 12px; padding: 15px 2px 0; color: #516965; font-size: 8px; letter-spacing: .12em; font-weight: 750; }
.app-footer span:last-child { display: flex; align-items: center; gap: 7px; }
.app-footer i { display: inline-block; width: 5px; height: 5px; border-radius: 50%; background: #75b99a; }
.embed-mode .app-shell { padding-top: 0; }
.embed-mode .topbar, .embed-mode .app-footer { display: none; }
.embed-mode .workspace { padding-top: 0; }
.embed-mode .scene-viewport { height: clamp(300px, 55vh, 520px); }
.reduced-motion *, .reduced-motion *::before, .reduced-motion *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; }
button:focus-visible { outline: 2px solid rgba(101,203,208,.75); outline-offset: 3px; }

@media (max-width: 1080px) {
  .app-shell { padding-left: 14px; padding-right: 14px; }
  .workspace { grid-template-columns: minmax(0,1.35fr) minmax(300px,.9fr); gap: 12px; }
  .scene-viewport { height: clamp(320px, 42vw, 440px); }
  .metric-card { padding: 10px; }
  .metric-foot { font-size: 7px; }
}
@media (max-width: 820px) {
  .workspace { grid-template-columns: 1fr; }
  .control-column { display: grid; grid-template-columns: 1fr 1fr; align-items: start; }
  .control-card { grid-row: span 2; }
  .science-card, .panel-footer { grid-column: 2; }
  .scene-viewport { height: clamp(340px, 55vw, 480px); }
}
@media (max-width: 560px) {
  .app-shell { padding: 0 10px 12px; }
  .topbar { min-height: 58px; }
  .brand-title { font-size: 12px; }
  .eyebrow { font-size: 8px; }
  .topbar-right { gap: 6px; }
  .live-pill, .seed-tag { padding: 6px 8px; font-size: 7px; }
  .seed-tag b { font-size: 8px; }
  .workspace { padding-top: 10px; gap: 10px; }
  .scene-card { padding: 12px 10px 10px; }
  .scene-topline h1 { font-size: 24px; }
  .scene-subtitle { font-size: 10px; }
  .scene-actions { gap: 4px; }
  .icon-button { width: 30px; height: 30px; }
  .scene-viewport { height: 360px; min-height: 330px; }
  .scene-legend { gap: 10px; font-size: 8px; }
  .legend-note { width: 100%; margin-left: 0; }
  .metrics-grid { grid-template-columns: repeat(2, minmax(0,1fr)); gap: 7px; }
  .metric-card { padding: 10px 11px 8px; }
  .metric-value { font-size: 23px; }
  .metric-foot { font-size: 8px; }
  .validation-card { padding: 12px; }
  .validation-values { gap: 5px; }
  .validation-values strong { font-size: 12px; }
  .validation-values span { font-size: 6px; }
  .control-column { display: flex; }
  .control-card, .transport-card { padding: 14px; }
  .control-list { gap: 13px; }
  .science-card, .panel-footer { grid-column: auto; }
  .app-footer { font-size: 7px; flex-direction: column; gap: 6px; }
  .scene-hud { padding: 7px 8px; min-width: 82px; }
  .scene-hud strong { font-size: 17px; }
  .scene-annotation { font-size: 7px; }
}
@media (max-width: 360px) {
  .scene-viewport { height: 320px; }
  .scene-actions .icon-button { width: 27px; }
  .validation-values strong { font-size: 10px; }
  .preset-button { font-size: 8px; }
}
