:root {
  color-scheme: dark;
  --bg: #071018;
  --panel: #0c1823;
  --panel-2: #101f2b;
  --line: rgba(156, 181, 202, .13);
  --line-strong: rgba(156, 181, 202, .22);
  --text: #e8f0f5;
  --muted: #8da2b3;
  --dim: #5e7282;
  --accent: #63e6cf;
  --accent-2: #a0f2e3;
  --accent-soft: rgba(99, 230, 207, .12);
  --wild: #8194a7;
  --amber: #f2c27c;
  --radius: 16px;
  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-x: hidden; }
body.embed-mode { height: 100vh; height: 100dvh; overflow: hidden; }
button, input { font: inherit; }
button { color: inherit; }
.app-shell { min-height: 100vh; display: grid; grid-template-rows: 72px minmax(0, 1fr); background: radial-gradient(ellipse at 12% 0%, rgba(28, 76, 83, .15), transparent 34%), var(--bg); }
body.embed-mode .app-shell { height: 100%; min-height: 0; }
.topbar { display: flex; align-items: center; justify-content: space-between; padding: 0 28px; border-bottom: 1px solid var(--line); background: rgba(8, 18, 27, .9); position: relative; z-index: 2; }
.brand-lockup { display: flex; align-items: center; gap: 13px; min-width: 0; }
.brandmark { width: 42px; height: 42px; border-radius: 13px; display: grid; place-items: center; background: linear-gradient(145deg, rgba(99,230,207,.15), rgba(99,230,207,.035)); border: 1px solid rgba(99,230,207,.23); box-shadow: inset 0 0 22px rgba(99,230,207,.04); }
.brandmark svg { width: 30px; height: 30px; }
.eyebrow, .micro-label, .section-label, .metric-label, .stage-topline, .stage-note, .insight-heading, .quality-control > span, .check-title { font-size: 9px; letter-spacing: .15em; font-weight: 750; color: var(--muted); }
.title-stack .eyebrow { font-size: 8px; margin-bottom: 3px; }
h1 { margin: 0; font-size: 20px; font-weight: 680; letter-spacing: -.035em; line-height: 1.1; }
.header-status { display: flex; align-items: center; gap: 22px; }
.live-chip { display: flex; align-items: center; gap: 8px; color: var(--accent); font-size: 9px; letter-spacing: .14em; font-weight: 750; }
.live-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 12px rgba(99,230,207,.8); }
.live-dot.paused { background: var(--amber); box-shadow: 0 0 10px rgba(242,194,124,.5); }
.generation-chip { display: grid; grid-template-columns: auto auto; column-gap: 8px; align-items: baseline; padding-left: 18px; border-left: 1px solid var(--line-strong); }
.generation-chip .micro-label { grid-column: 1 / -1; font-size: 8px; margin-bottom: 1px; }
.generation-chip strong { font-size: 17px; font-variant-numeric: tabular-nums; letter-spacing: .04em; }
.number-tag { color: var(--dim); font-size: 8px; font-style: normal; }
.workspace { min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) 366px; gap: 14px; padding: 14px; }
.stage-panel { min-width: 0; min-height: 0; display: grid; grid-template-rows: 34px minmax(0, 1fr) 30px; overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius); background: linear-gradient(155deg, rgba(15, 31, 43, .95), rgba(8, 17, 26, .98)); box-shadow: 0 18px 50px rgba(0,0,0,.16); }
.stage-topline { padding: 0 17px; display: flex; align-items: center; justify-content: space-between; font-size: 8px; letter-spacing: .14em; border-bottom: 1px solid rgba(156,181,202,.07); }
.stage-mode { color: #6f8597; display: flex; align-items: center; gap: 8px; }
.stage-mode i { width: 4px; height: 4px; border-radius: 50%; background: var(--accent); }
#simCanvas { display: block; width: 100%; height: 100%; min-height: 0; outline: none; }
.stage-footer { display: flex; align-items: center; gap: 18px; padding: 0 17px; border-top: 1px solid rgba(156,181,202,.07); }
.legend-item { display: flex; align-items: center; gap: 6px; color: #9aabba; font-size: 8px; letter-spacing: .09em; font-weight: 700; }
.legend-swatch { display: inline-block; width: 7px; height: 7px; border-radius: 2px; }
.legend-swatch.drive { background: var(--accent); box-shadow: 0 0 9px rgba(99,230,207,.55); }
.legend-swatch.wild { background: var(--wild); }
.stage-note { margin-left: auto; font-size: 7px; color: #64798a; }
.control-panel { min-width: 0; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 17px 17px 14px; border: 1px solid var(--line); border-radius: var(--radius); background: linear-gradient(160deg, rgba(15,29,41,.98), rgba(10,21,31,.98)); scrollbar-width: thin; scrollbar-color: #344958 transparent; }
.panel-heading { display: flex; align-items: center; justify-content: space-between; margin-bottom: 15px; }
.panel-heading .eyebrow { font-size: 8px; }
h2 { margin: 4px 0 0; font-size: 16px; font-weight: 650; letter-spacing: -.025em; }
.panel-glyph { color: var(--accent); font-size: 24px; opacity: .8; }
.preset-block { margin-bottom: 16px; }
.section-label { display: flex; justify-content: space-between; margin-bottom: 8px; font-size: 8px; }
.section-label span { color: var(--dim); font-size: 7px; }
.preset-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.preset-button { min-height: 32px; padding: 5px 4px; border-radius: 8px; border: 1px solid var(--line-strong); background: rgba(255,255,255,.018); color: #91a4b3; font-size: 9px; font-weight: 650; cursor: pointer; transition: background .18s ease, border-color .18s ease, color .18s ease; }
.preset-button:hover { border-color: rgba(99,230,207,.45); color: var(--text); }
.preset-button.active { background: var(--accent-soft); color: var(--accent-2); border-color: rgba(99,230,207,.42); }
.controls-list { display: grid; gap: 13px; }
.control-item { min-width: 0; }
.control-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.control-heading label { font-size: 10px; color: #d7e1e8; font-weight: 620; }
.control-heading output { white-space: nowrap; color: var(--accent); font-size: 11px; font-weight: 750; font-variant-numeric: tabular-nums; }
.control-heading output small { color: var(--dim); font-size: 7px; font-weight: 550; }
input[type="range"] { width: 100%; height: 14px; margin: 0; display: block; appearance: none; -webkit-appearance: none; background: transparent; cursor: pointer; accent-color: var(--accent); }
input[type="range"]::-webkit-slider-runnable-track { height: 4px; border-radius: 4px; background: linear-gradient(90deg, var(--accent) 0 var(--range-progress, 50%), #2b3c49 var(--range-progress, 50%) 100%); }
input[type="range"]::-moz-range-track { height: 4px; border-radius: 4px; background: #2b3c49; }
input[type="range"]::-moz-range-progress { height: 4px; border-radius: 4px; background: var(--accent); }
input[type="range"]::-webkit-slider-thumb { appearance: none; -webkit-appearance: none; width: 13px; height: 13px; margin-top: -4.5px; border-radius: 50%; background: #08151d; border: 2px solid var(--accent); box-shadow: 0 0 0 3px rgba(99,230,207,.11), 0 0 12px rgba(99,230,207,.28); }
input[type="range"]::-moz-range-thumb { width: 10px; height: 10px; border-radius: 50%; background: #08151d; border: 2px solid var(--accent); box-shadow: 0 0 0 3px rgba(99,230,207,.11); }
input[type="range"]:focus-visible { outline: 2px solid var(--accent); outline-offset: 5px; border-radius: 6px; }
.range-ends { display: flex; justify-content: space-between; margin-top: 0; color: #687e8e; font-size: 7px; }
.control-help { margin: 3px 0 0; color: #8296a5; font-size: 8px; line-height: 1.35; }
.metrics-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-top: 16px; }
.metric-card { min-width: 0; padding: 9px 10px 8px; border: 1px solid rgba(156,181,202,.11); border-radius: 9px; background: rgba(255,255,255,.018); display: flex; flex-direction: column; gap: 3px; }
.primary-metric { background: linear-gradient(130deg, rgba(99,230,207,.1), rgba(99,230,207,.025)); border-color: rgba(99,230,207,.22); }
.metric-label { font-size: 7px; letter-spacing: .12em; color: #8da2b2; }
.metric-card strong { font-size: 19px; line-height: 1.1; letter-spacing: -.035em; font-weight: 680; font-variant-numeric: tabular-nums; }
.primary-metric strong { color: var(--accent); }
.metric-unit { color: #6f8494; font-size: 7px; }
.insight-card { margin-top: 9px; padding: 10px 11px; border: 1px solid rgba(99,230,207,.15); border-radius: 10px; background: rgba(99,230,207,.045); }
.insight-heading { display: flex; align-items: center; gap: 7px; font-size: 7px; letter-spacing: .13em; color: #9ab0bd; }
.insight-icon { color: var(--accent); font-size: 13px; line-height: 1; }
.insight-state { margin-left: auto; color: var(--accent); font-size: 7px; }
.insight-card p { margin: 7px 0 0; color: #b4c3cc; font-size: 9px; line-height: 1.45; }
.transport-row { display: grid; grid-template-columns: 1.25fr 1fr 1fr; gap: 6px; margin-top: 11px; }
.transport-button { min-height: 34px; border: 1px solid var(--line-strong); border-radius: 8px; background: rgba(255,255,255,.025); color: #b8c6cf; font-size: 9px; font-weight: 650; display: flex; align-items: center; justify-content: center; gap: 7px; cursor: pointer; transition: background .16s ease, border-color .16s ease; }
.transport-button:hover, .utility-button:hover { border-color: rgba(99,230,207,.45); background: rgba(99,230,207,.07); }
.run-button { color: #06221e; background: var(--accent); border-color: var(--accent); }
.run-button:hover { background: #8bf0df; border-color: #8bf0df; }
.button-icon { font-size: 13px; line-height: 1; }
.utility-row { display: flex; align-items: center; justify-content: space-between; margin-top: 8px; }
.utility-button { min-height: 29px; padding: 0 9px; border: 1px solid var(--line); border-radius: 7px; background: transparent; color: #9eb0bc; font-size: 8px; cursor: pointer; }
.utility-button span { margin-right: 5px; color: var(--accent); }
.quality-control { display: flex; align-items: center; gap: 7px; }
.quality-control > span { font-size: 7px; }
.quality-switch { display: flex; padding: 2px; border: 1px solid var(--line); border-radius: 7px; background: rgba(0,0,0,.12); }
.quality-switch button { padding: 4px 7px; border: 0; border-radius: 5px; background: transparent; color: #778b9a; font-size: 8px; cursor: pointer; }
.quality-switch button.selected { color: var(--accent); background: rgba(99,230,207,.1); }
.science-panel { margin-top: 12px; border-top: 1px solid var(--line); padding-top: 10px; }
.science-panel summary { display: flex; align-items: center; gap: 8px; list-style: none; cursor: pointer; color: #d0dce3; font-size: 10px; font-weight: 650; }
.science-panel summary::-webkit-details-marker { display: none; }
.science-panel summary::after { content: "+"; margin-left: auto; color: var(--accent); font-size: 15px; font-weight: 400; }
.science-panel[open] summary::after { content: "−"; }
.science-icon { color: var(--accent); font-size: 15px; }
.summary-hint { color: #617686; font-size: 7px; letter-spacing: .1em; font-weight: 600; }
.science-content { padding: 10px 1px 2px; color: #9fb0bb; font-size: 9px; line-height: 1.5; }
.science-content h3 { margin: 8px 0 5px; color: #dbe5eb; font-size: 10px; }
.science-content p { margin: 6px 0; }
.equation { margin: 7px 0; padding: 8px 9px; border-left: 2px solid rgba(99,230,207,.65); border-radius: 0 6px 6px 0; background: rgba(99,230,207,.055); color: #d7e8e8; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 9px; overflow-wrap: anywhere; }
.check-card { margin: 9px 0; padding: 9px; border: 1px solid rgba(99,230,207,.16); border-radius: 8px; background: rgba(99,230,207,.035); }
.check-title { color: var(--accent); font-size: 7px; }
.check-values { display: flex; flex-wrap: wrap; gap: 10px; margin: 6px 0 4px; color: #8fa5b1; font-size: 8px; }
.check-values b { color: #e3eeef; font-variant-numeric: tabular-nums; }
.check-card p { margin: 0; color: #8296a5; font-size: 8px; }
.disclaimer { color: #c3d2d9; font-style: italic; }
.number-key { color: #637b8b; font-size: 7px; }
button:focus-visible, summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
@media (min-width: 1500px) {
  .workspace { grid-template-columns: minmax(0, 1fr) 390px; }
  .control-panel { padding: 20px; }
  .controls-list { gap: 16px; }
}
@media (max-width: 900px) {
  .app-shell { grid-template-rows: 64px minmax(0, 1fr); }
  .topbar { padding: 0 16px; }
  .workspace { grid-template-columns: minmax(0, 1fr) 330px; gap: 9px; padding: 9px; }
  .control-panel { padding: 14px 12px; }
  .stage-footer { gap: 10px; }
}
@media (max-width: 680px) {
  .app-shell { grid-template-rows: 58px minmax(0, 1fr); }
  .topbar { padding: 0 12px; }
  .brandmark { width: 35px; height: 35px; border-radius: 11px; }
  .brandmark svg { width: 26px; height: 26px; }
  .title-stack .eyebrow { font-size: 7px; }
  h1 { font-size: 17px; }
  .header-status { gap: 11px; }
  .live-chip { font-size: 7px; gap: 5px; }
  .generation-chip { padding-left: 10px; column-gap: 5px; }
  .generation-chip strong { font-size: 14px; }
  .generation-chip .micro-label { font-size: 7px; }
  .number-tag { font-size: 7px; }
  .workspace { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(245px, 41dvh) minmax(0, 1fr); gap: 8px; padding: 8px; }
  .stage-panel { grid-template-rows: 27px minmax(0, 1fr) 24px; border-radius: 12px; }
  .stage-topline { padding: 0 10px; font-size: 7px; }
  .stage-mode { font-size: 6px; gap: 5px; }
  .stage-footer { padding: 0 9px; gap: 9px; }
  .legend-item { font-size: 6px; gap: 4px; }
  .legend-swatch { width: 6px; height: 6px; }
  .stage-note { display: none; }
  .control-panel { border-radius: 12px; padding: 13px 13px calc(14px + env(safe-area-inset-bottom)); }
  .panel-heading { margin-bottom: 11px; }
  h2 { font-size: 15px; }
  .controls-list { gap: 12px; }
  .metrics-grid { margin-top: 13px; }
}
@media (max-width: 380px) {
  .header-status { gap: 7px; }
  .live-chip { letter-spacing: .08em; }
  .generation-chip { padding-left: 7px; }
  .stage-footer { gap: 7px; }
  .legend-item { letter-spacing: .04em; }
  .preset-button { font-size: 8px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .001ms !important; animation-duration: .001ms !important; animation-iteration-count: 1 !important; }
}
