:root {
  color-scheme: dark;
  --bg: #07131d;
  --panel: #0b1b27;
  --panel-2: #0e2230;
  --line: rgba(127, 192, 203, .14);
  --line-strong: rgba(127, 192, 203, .25);
  --text: #e5f2f2;
  --muted: #829da5;
  --faint: #58737d;
  --cyan: #56d1dc;
  --cyan-soft: #1c8796;
  --gold: #f4b46f;
  --green: #72d6b1;
  --radius: 12px;
  --shadow: 0 14px 40px rgba(0,0,0,.18);
  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-height: 100vh; overflow: hidden; }
button, input { font: inherit; }
button { color: inherit; }
button:focus-visible, input:focus-visible { outline: 2px solid var(--cyan); outline-offset: 3px; }
.app-shell { min-height: 100vh; height: 100vh; display: flex; flex-direction: column; background: radial-gradient(ellipse at 53% 35%, rgba(12,54,68,.16), transparent 55%), var(--bg); }
.topbar { min-height: 76px; display: grid; grid-template-columns: 260px minmax(0,1fr) 220px; align-items: center; gap: 22px; padding: 0 22px; border-bottom: 1px solid var(--line); background: rgba(6,17,26,.88); }
.brand-lockup { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand-mark { width: 31px; height: 31px; display: flex; align-items: flex-end; justify-content: center; gap: 3px; padding: 6px; border: 1px solid rgba(86,209,220,.35); border-radius: 9px; background: rgba(86,209,220,.06); }
.brand-mark span { display: block; width: 4px; border-radius: 4px; background: var(--cyan); box-shadow: 0 0 10px rgba(86,209,220,.4); }
.brand-mark span:nth-child(1) { height: 8px; opacity: .6; }
.brand-mark span:nth-child(2) { height: 15px; }
.brand-mark span:nth-child(3) { height: 11px; opacity: .8; }
.brand-name { font-size: 11px; letter-spacing: .16em; font-weight: 800; white-space: nowrap; }
.brand-name span { color: var(--cyan); font-weight: 600; }
.brand-subtitle, .eyebrow { color: var(--muted); font-size: 9px; letter-spacing: .16em; font-weight: 700; }
.brand-subtitle { margin-top: 5px; font-size: 8px; }
.topbar-title { min-width: 0; }
.topbar-title .eyebrow { display: block; margin-bottom: 5px; }
h1 { margin: 0; font-size: 17px; line-height: 1.2; letter-spacing: -.025em; font-weight: 720; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
h1 span { color: #9db8be; font-weight: 480; }
.topbar-actions { display: flex; justify-content: flex-end; align-items: center; gap: 14px; }
.live-indicator { display: inline-flex; align-items: center; gap: 7px; color: #a3c2c7; font-size: 9px; font-weight: 750; letter-spacing: .12em; white-space: nowrap; }
.live-indicator i, .pulse-dot, .telemetry-dot { width: 6px; height: 6px; border-radius: 50%; display: inline-block; background: var(--green); box-shadow: 0 0 12px rgba(114,214,177,.7); }
.icon-button { border: 1px solid var(--line-strong); background: #0d202c; color: #a6c7cc; width: 28px; height: 28px; border-radius: 8px; cursor: pointer; font-weight: 700; }
.icon-button:hover, .scene-icon-button:hover { border-color: var(--cyan); color: var(--cyan); }
.workspace { flex: 1; min-height: 0; display: grid; grid-template-columns: 306px minmax(400px,1fr) 266px; gap: 12px; padding: 12px; }
.panel { background: linear-gradient(160deg, rgba(14,34,47,.96), rgba(9,25,36,.96)); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); min-height: 0; overflow-y: auto; scrollbar-width: thin; scrollbar-color: #23434f transparent; }
.control-panel { padding: 17px 16px 14px; }
.panel-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; margin-bottom: 15px; }
.panel-heading h2 { margin: 5px 0 0; font-size: 17px; letter-spacing: -.02em; font-weight: 680; }
.status-pill { border: 1px solid rgba(86,209,220,.28); color: var(--cyan); background: rgba(37,142,155,.1); border-radius: 100px; padding: 5px 8px; font-size: 8px; letter-spacing: .1em; font-weight: 800; white-space: nowrap; }
.status-pill.stable { color: #a2b5bd; border-color: rgba(155,179,190,.24); background: rgba(155,179,190,.08); }
.cause-chain { background: rgba(3,14,22,.42); border: 1px solid rgba(116,180,190,.1); border-radius: 9px; padding: 9px 10px; margin-bottom: 17px; }
.cause-chain > div:not(.chain-arrow) { display: flex; align-items: center; gap: 10px; }
.chain-index { width: 23px; height: 23px; flex: 0 0 23px; display: grid; place-items: center; border-radius: 7px; background: rgba(86,209,220,.09); color: var(--cyan); font-size: 9px; font-weight: 800; }
.cause-chain b { display: block; font-size: 10px; font-weight: 700; }
.cause-chain small { display: block; margin-top: 2px; color: var(--muted); font-size: 9px; line-height: 1.35; }
.chain-arrow { color: #3e8994; margin: 2px 0 2px 7px; font-size: 12px; line-height: 10px; }
.section-label { display: flex; justify-content: space-between; align-items: center; margin: 0 0 9px; color: #a9c1c6; font-size: 9px; font-weight: 800; letter-spacing: .13em; }
.section-label span { color: #5c7b85; font-size: 7px; letter-spacing: .1em; }
.preset-block { margin-bottom: 17px; }
.preset-buttons { display: grid; grid-template-columns: repeat(3,1fr); gap: 6px; }
.preset-button { min-width: 0; text-align: left; padding: 8px 7px 7px; border: 1px solid var(--line); border-radius: 8px; background: rgba(3,15,23,.35); cursor: pointer; transition: border-color .18s, background .18s, transform .18s; }
.preset-button b { display: block; font-size: 9px; line-height: 1.25; white-space: nowrap; }
.preset-button small { display: block; margin-top: 4px; color: var(--muted); font-size: 8px; line-height: 1.25; }
.preset-button:hover { border-color: rgba(86,209,220,.45); transform: translateY(-1px); }
.preset-button.active { border-color: rgba(86,209,220,.56); background: rgba(37,142,155,.14); box-shadow: inset 0 0 0 1px rgba(86,209,220,.07); }
.preset-button.active b { color: #9ce9ed; }
.controls-block { margin-bottom: 16px; }
.control-row { position: relative; margin: 0 0 12px; padding-bottom: 1px; }
.control-row label { display: inline-block; color: #c5d7da; font-size: 10px; font-weight: 620; }
.control-row label em { color: var(--cyan); font-family: Georgia, serif; font-size: 12px; font-style: italic; margin-left: 3px; }
.control-row output { float: right; color: #dff4f2; font-size: 10px; font-variant-numeric: tabular-nums; }
.control-row input[type=range] { appearance: none; width: 100%; height: 4px; margin: 9px 0 4px; border-radius: 99px; background: linear-gradient(90deg, #1c8290, #2b5968); display: block; cursor: pointer; }
.control-row input[type=range]::-webkit-slider-thumb { appearance: none; width: 12px; height: 12px; border: 2px solid #d2fbf8; border-radius: 50%; background: #43b8c5; box-shadow: 0 0 0 3px rgba(67,184,197,.13), 0 0 10px rgba(67,184,197,.4); }
.control-row input[type=range]::-moz-range-thumb { width: 9px; height: 9px; border: 2px solid #d2fbf8; border-radius: 50%; background: #43b8c5; box-shadow: 0 0 0 3px rgba(67,184,197,.13); }
.range-ends { display: flex; justify-content: space-between; color: #5f7e88; font-size: 8px; font-variant-numeric: tabular-nums; }
.playback-block { border-top: 1px solid var(--line); padding-top: 14px; }
.playback-actions { display: grid; grid-template-columns: 1fr 1fr 34px; gap: 6px; margin-bottom: 13px; }
.primary-button, .secondary-button { min-height: 34px; border-radius: 8px; cursor: pointer; font-size: 9px; font-weight: 800; letter-spacing: .06em; transition: background .18s, border-color .18s; }
.primary-button { border: 1px solid rgba(86,209,220,.42); background: linear-gradient(135deg, #147c8a, #17606d); color: #e7ffff; display: inline-flex; justify-content: center; align-items: center; gap: 8px; }
.primary-button:hover { background: linear-gradient(135deg, #1b95a4, #1a7380); }
.play-icon { font-size: 11px; }
.secondary-button { border: 1px solid var(--line-strong); background: rgba(4,17,25,.45); color: #a6c3c8; }
.secondary-button:hover { border-color: var(--cyan); color: var(--cyan); }
.square-button { font-size: 17px; }
.compact-row { margin-bottom: 2px; }
.panel-footnote { margin-top: 13px; padding-top: 10px; border-top: 1px solid var(--line); color: #69838c; font-size: 8px; }
kbd { border: 1px solid #29444e; background: #0a202b; border-radius: 4px; padding: 2px 4px; color: #b6d0d4; font-size: 8px; }
.scene-panel { min-width: 0; min-height: 0; display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: radial-gradient(ellipse at 50% 45%, #0b2735, #07131d 70%); box-shadow: var(--shadow); }
.scene-topline { min-height: 47px; padding: 0 13px; display: flex; justify-content: space-between; align-items: center; gap: 10px; border-bottom: 1px solid var(--line); background: rgba(7,20,29,.72); }
.scene-tag { color: #b8d0d3; font-size: 8px; font-weight: 800; letter-spacing: .13em; white-space: nowrap; }
.scene-tag .pulse-dot { margin-right: 6px; }
.scene-separator { color: #41616b; padding: 0 5px; }
.scene-top-actions { display: flex; align-items: center; gap: 6px; }
.field-switch { display: flex; padding: 3px; gap: 2px; border: 1px solid var(--line); border-radius: 7px; background: rgba(1,12,19,.5); }
.field-switch button { padding: 5px 7px; border: 0; border-radius: 5px; background: transparent; color: #72919a; font-size: 7px; letter-spacing: .09em; font-weight: 800; cursor: pointer; }
.field-switch button.selected { color: #c9fbf8; background: rgba(44,151,163,.23); }
.scene-icon-button { width: 27px; height: 27px; border: 1px solid var(--line-strong); border-radius: 7px; background: rgba(4,17,25,.45); color: #93b0b6; cursor: pointer; font-size: 14px; }
.scene-icon-button.active { color: var(--gold); border-color: rgba(244,180,111,.4); }
.scene-viewport { position: relative; flex: 1; min-height: 300px; overflow: hidden; }
.scene-viewport canvas { display: block; width: 100%; height: 100%; outline: none; }
.scene-loading { position: absolute; inset: 0; z-index: 3; display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 14px; background: #07131d; color: #79aab1; font-size: 9px; font-weight: 800; letter-spacing: .15em; }
.scene-loading[hidden], .scene-error[hidden] { display: none; }
.loader-ring { width: 34px; height: 34px; border: 2px solid rgba(86,209,220,.16); border-top-color: var(--cyan); border-radius: 50%; animation: spin 1.2s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.scene-error { position: absolute; z-index: 5; inset: 20px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; text-align: center; border: 1px solid rgba(244,180,111,.24); border-radius: 10px; background: rgba(5,18,27,.94); padding: 20px; }
.scene-error b { color: #f4c18c; font-size: 14px; }
.scene-error span { max-width: 360px; color: #91aeb4; font-size: 11px; line-height: 1.6; }
.scene-overlay { position: absolute; top: 20px; z-index: 2; display: flex; flex-direction: column; gap: 5px; pointer-events: none; text-shadow: 0 2px 12px rgba(0,0,0,.8); }
.overlay-left { left: 17px; }
.overlay-right { right: 18px; text-align: right; }
.overlay-kicker { color: #79a8b1; font-size: 8px; letter-spacing: .16em; font-weight: 800; }
.scene-overlay b { font-size: 11px; letter-spacing: .08em; color: #d7f4f1; }
.scene-overlay span:last-child { color: #91adb4; font-size: 9px; line-height: 1.4; }
.scene-bottom-caption { position: absolute; bottom: 15px; left: 16px; z-index: 2; display: flex; align-items: center; gap: 7px; color: #a3c2c7; font-size: 8px; font-weight: 800; letter-spacing: .09em; pointer-events: none; text-shadow: 0 2px 8px #000; }
.legend-dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }
.salt-dot { background: #2cc8e7; box-shadow: 0 0 9px rgba(44,200,231,.7); }
.fresh-dot { background: #ffb36b; box-shadow: 0 0 9px rgba(255,179,107,.6); }
.legend-divider { width: 1px; height: 12px; margin: 0 4px; background: #41606a; }
.caption-note { margin-left: 8px; color: #698790; font-size: 7px; font-weight: 600; }
.drag-hint { position: absolute; bottom: 15px; right: 15px; color: #72939b; font-size: 8px; letter-spacing: .08em; pointer-events: none; }
.drag-hint span { font-size: 12px; color: var(--cyan); }
.scene-footer { min-height: 53px; display: grid; grid-template-columns: 90px 105px minmax(90px,1fr) auto; gap: 14px; align-items: center; padding: 0 15px; border-top: 1px solid var(--line); background: rgba(7,20,29,.84); }
.scene-footer > div { min-width: 0; }
.footer-label { display: block; margin-bottom: 4px; color: #64838d; font-size: 7px; letter-spacing: .12em; font-weight: 800; }
.scene-footer b { font-size: 11px; color: #d4e9e8; font-variant-numeric: tabular-nums; }
.progress-wrap { max-width: 170px; }
.progress-track { height: 4px; border-radius: 9px; background: #1b3641; overflow: hidden; }
.progress-track i { display: block; width: 2%; height: 100%; background: linear-gradient(90deg, #2698a6, #7ee0d8); box-shadow: 0 0 8px rgba(86,209,220,.5); transition: width .2s; }
.footer-note { color: #5e7d87; font-size: 8px; white-space: nowrap; }
.data-panel { padding: 17px 14px 13px; }
.data-heading { align-items: center; margin-bottom: 14px; }
.telemetry-dot { width: 7px; height: 7px; background: var(--cyan); box-shadow: 0 0 10px rgba(86,209,220,.65); }
.metric-card { border-bottom: 1px solid var(--line); padding: 10px 1px 10px; }
.metric-card.featured-metric { padding: 12px 10px 11px; border: 1px solid rgba(86,209,220,.16); border-radius: 9px; background: linear-gradient(120deg, rgba(28,111,123,.16), rgba(5,23,33,.25)); margin-bottom: 3px; }
.metric-top { display: flex; justify-content: space-between; align-items: center; gap: 4px; color: #88a7af; font-size: 8px; letter-spacing: .11em; font-weight: 800; }
.metric-kind { color: #5f7d86; font-size: 6px; letter-spacing: .08em; white-space: nowrap; }
.metric-value { margin-top: 6px; color: #e1f3f0; font-size: 21px; font-weight: 660; letter-spacing: -.04em; font-variant-numeric: tabular-nums; white-space: nowrap; }
.metric-value small { color: #7ea2aa; font-size: 10px; font-weight: 500; letter-spacing: 0; }
.metric-foot { margin-top: 4px; color: #6e8b94; font-size: 8px; line-height: 1.4; }
.slim-metric { padding-bottom: 11px; }
.slim-metric .metric-value { font-size: 18px; }
.validation-card { margin-top: 13px; padding: 11px 10px 10px; border: 1px solid rgba(114,214,177,.18); border-radius: 9px; background: rgba(15,68,61,.11); }
.validation-title { display: flex; align-items: center; gap: 7px; color: #a7d9c7; font-size: 8px; letter-spacing: .1em; }
.validation-check { width: 15px; height: 15px; display: grid; place-items: center; border-radius: 50%; background: rgba(114,214,177,.15); color: var(--green); font-size: 10px; }
.validation-subtitle { margin: 6px 0 9px; color: #779b98; font-size: 8px; line-height: 1.4; }
.validation-row, .validation-result { display: flex; justify-content: space-between; gap: 7px; margin-top: 6px; font-size: 8px; color: #789a99; }
.validation-row b { color: #c2e7dc; font-size: 8px; font-variant-numeric: tabular-nums; }
.validation-result { border-top: 1px solid rgba(114,214,177,.12); padding-top: 8px; margin-top: 9px; color: #b2d6c8; }
.validation-result b { color: #7de0ba; font-size: 10px; font-variant-numeric: tabular-nums; }
.validation-note { margin-top: 7px; color: #5e827f; font-size: 7px; line-height: 1.4; }
.science-toggle { width: 100%; display: flex; justify-content: space-between; align-items: center; margin-top: 13px; padding: 10px 10px; border: 1px solid var(--line); border-radius: 8px; background: rgba(4,17,25,.4); text-align: left; cursor: pointer; }
.science-toggle b { display: block; font-size: 10px; }
.science-toggle small { display: block; margin-top: 3px; color: var(--muted); font-size: 8px; }
.chevron { color: var(--cyan); font-size: 16px; transition: transform .2s; }
.science-toggle.open .chevron { transform: rotate(180deg); }
.science-panel { padding: 8px 2px 2px; }
.science-section { padding: 8px 2px; border-bottom: 1px solid var(--line); }
.science-section b { display: block; margin-bottom: 6px; color: #c2d9db; font-size: 9px; }
.science-section code { display: block; margin: 4px 0; padding: 6px 7px; border-radius: 5px; background: rgba(3,14,21,.65); color: #80d8dc; font-size: 8px; white-space: normal; line-height: 1.4; }
.science-section p { margin: 5px 0 1px; color: #829da5; font-size: 8px; line-height: 1.55; }
.science-constants { padding: 9px 2px 2px; color: #5f7e87; font-size: 7px; line-height: 1.5; }
.global-footer { min-height: 24px; display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 0 18px; color: #56717a; font-size: 8px; border-top: 1px solid rgba(127,192,203,.08); }
.global-footer span:last-child { letter-spacing: .12em; font-size: 7px; }
.global-footer i { color: var(--cyan); font-style: normal; }

.embed-mode .topbar, .embed-mode .global-footer, .embed-mode .data-panel { display: none; }
.embed-mode .workspace { grid-template-columns: 270px minmax(0,1fr); padding: 0; gap: 0; }
.embed-mode .control-panel { border-radius: 0; }
.embed-mode .scene-panel { border-radius: 0; }

@media (max-width: 1180px) {
  .workspace { grid-template-columns: 280px minmax(340px,1fr) 240px; gap: 8px; padding: 8px; }
  .topbar { grid-template-columns: 220px minmax(0,1fr) 180px; padding: 0 16px; gap: 12px; }
  .control-panel { padding: 14px 12px; }
  .data-panel { padding: 14px 11px; }
  .scene-footer { grid-template-columns: 80px 90px minmax(70px,1fr); }
  .footer-note { display: none; }
}
@media (max-width: 900px) {
  body { overflow: auto; }
  .app-shell { height: auto; min-height: 100vh; }
  .topbar { min-height: 68px; grid-template-columns: 1fr auto; }
  .topbar-title { grid-column: 1 / -1; grid-row: 2; padding: 0 0 12px; }
  .topbar-actions { grid-column: 2; grid-row: 1; }
  .brand-lockup { grid-column: 1; grid-row: 1; }
  .workspace { display: flex; flex-direction: column; min-height: 0; }
  .scene-panel { order: 0; min-height: 500px; }
  .control-panel { order: 1; overflow: visible; }
  .data-panel { order: 2; overflow: visible; }
  .scene-viewport { min-height: 430px; }
  .control-panel, .data-panel { padding: 16px; }
  .global-footer { min-height: 32px; }
}
@media (max-width: 560px) {
  .topbar { padding: 12px 13px 0; grid-template-columns: 1fr auto; gap: 6px; }
  .brand-mark { width: 28px; height: 28px; }
  .brand-name { font-size: 10px; }
  .brand-subtitle { font-size: 7px; }
  .topbar-title { padding-bottom: 10px; }
  .topbar-title .eyebrow { font-size: 7px; }
  h1 { font-size: 15px; white-space: normal; }
  h1 span { display: block; margin-top: 2px; font-size: 12px; }
  .live-indicator { display: none; }
  .workspace { padding: 7px; gap: 8px; }
  .scene-panel { min-height: 0; height: 490px; }
  .scene-topline { min-height: 43px; padding: 0 8px; }
  .scene-tag { max-width: 106px; overflow: hidden; text-overflow: ellipsis; font-size: 6px; letter-spacing: .035em; }
  .scene-topline { gap: 5px; }
  .scene-top-actions { gap: 3px; flex: 0 0 auto; }
  .field-switch { gap: 0; }
  .field-switch button { padding: 5px 4px; font-size: 6px; }
  .scene-icon-button { width: 23px; height: 23px; flex: 0 0 23px; }
  .scene-viewport { min-height: 0; }
  .scene-overlay { top: 13px; }
  .overlay-left { left: 10px; }
  .overlay-right { right: 10px; }
  .overlay-kicker { font-size: 7px; }
  .scene-overlay b { font-size: 9px; }
  .scene-overlay span:last-child { font-size: 8px; }
  .scene-bottom-caption { left: 10px; bottom: 11px; gap: 5px; font-size: 7px; }
  .caption-note { display: none; }
  .drag-hint { display: none; }
  .scene-footer { min-height: 50px; grid-template-columns: 74px 85px minmax(70px,1fr); gap: 7px; padding: 0 9px; }
  .footer-label { font-size: 6px; }
  .scene-footer b { font-size: 10px; }
  .panel-heading h2 { font-size: 16px; }
  .control-panel, .data-panel { padding: 14px 12px; }
  .preset-button { padding: 8px 5px; }
  .preset-button b { font-size: 8px; }
  .preset-button small { font-size: 7px; }
  .global-footer { padding: 7px 10px; align-items: flex-start; font-size: 7px; }
  .global-footer span:last-child { display: none; }
  .embed-mode .workspace { display: flex; padding: 0; }
  .embed-mode .control-panel { display: none; }
  .embed-mode .scene-panel { height: 100vh; min-height: 400px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important; transition-duration: .01ms !important; }
}

.scene-viewport.renderer-failed .scene-overlay, .scene-viewport.renderer-failed .scene-bottom-caption, .scene-viewport.renderer-failed .drag-hint { display: none; }
