:root {
  color-scheme: dark;
  --bg: #071116;
  --panel: #0b191f;
  --panel-soft: #0e2026;
  --panel-raised: #11262d;
  --line: rgba(170, 204, 204, 0.12);
  --line-strong: rgba(170, 204, 204, 0.2);
  --text: #edf7f5;
  --muted: #91a9aa;
  --faint: #637a7e;
  --accent: #73e4c3;
  --accent-dim: rgba(115, 228, 195, 0.12);
  --accent-line: rgba(115, 228, 195, 0.35);
  --radius: 12px;
  --space: 8px;
}

* { box-sizing: border-box; }
html, body { margin: 0; width: 100%; min-height: 100%; background: var(--bg); color: var(--text); }
body { font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; font-size: 13px; letter-spacing: .005em; }
body.embed-mode { height: 100vh; height: 100dvh; overflow: hidden; }
button, input { font: inherit; }
button { color: inherit; }
button:focus-visible, input:focus-visible, summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.app-shell { width: 100%; height: 100vh; height: 100dvh; min-height: 0; display: grid; grid-template-rows: 66px minmax(0, 1fr); overflow: hidden; background: var(--bg); }

.masthead { display: flex; align-items: center; gap: 20px; padding: 0 22px; border-bottom: 1px solid var(--line); background: rgba(7, 17, 22, .96); position: relative; z-index: 3; }
.brand-lockup { display: flex; align-items: center; gap: 13px; min-width: 260px; }
.brand-symbol { width: 29px; height: 29px; border: 1px solid var(--accent-line); border-radius: 50%; display: grid; place-items: center; position: relative; flex: 0 0 auto; }
.brand-symbol span { position: absolute; border: 1px solid rgba(115, 228, 195, .7); border-radius: 50%; }
.brand-symbol span:nth-child(1) { width: 6px; height: 6px; background: var(--accent); box-shadow: 0 0 10px rgba(115,228,195,.45); }
.brand-symbol span:nth-child(2) { width: 15px; height: 15px; opacity: .7; }
.brand-symbol span:nth-child(3) { width: 23px; height: 23px; opacity: .4; }
.brand-copy { min-width: 0; }
.eyebrow { color: var(--muted); font-size: 9px; font-weight: 700; letter-spacing: .16em; line-height: 1.4; }
.eyebrow-divider { color: var(--accent); padding: 0 4px; }
h1 { margin: 2px 0 0; font-size: 19px; line-height: 1.1; font-weight: 600; letter-spacing: -.035em; }
.header-status { display: flex; align-items: center; gap: 8px; color: #a6b8b7; font-size: 9px; letter-spacing: .14em; font-weight: 700; margin-left: auto; white-space: nowrap; }
.status-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 10px rgba(115,228,195,.65); }
.status-dot.paused { background: #809399; box-shadow: none; }
.status-dot.inactive { background: #d1a66a; box-shadow: none; }
.header-actions { display: flex; align-items: center; gap: 8px; }
.quiet-button, .screenshot-button { height: 34px; border: 1px solid var(--line-strong); border-radius: 7px; padding: 0 11px; background: transparent; color: #c5d5d2; font-size: 9px; font-weight: 700; letter-spacing: .1em; cursor: pointer; transition: background .18s ease, border-color .18s ease, color .18s ease; white-space: nowrap; }
.quiet-button:hover, .screenshot-button:hover { border-color: var(--accent-line); color: var(--accent); background: rgba(115,228,195,.05); }
.screenshot-button { display: flex; align-items: center; gap: 7px; color: var(--bg); background: var(--accent); border-color: var(--accent); letter-spacing: .04em; font-size: 11px; text-transform: none; }
.screenshot-button:hover { background: #9af0d6; color: #061216; border-color: #9af0d6; }
.screenshot-button svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.4; stroke-linejoin: round; }

.workspace { min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) 384px; overflow: hidden; }
.stage { min-width: 0; min-height: 0; position: relative; overflow: hidden; background: radial-gradient(ellipse at 48% 44%, #11252b 0%, #0a171c 58%, #071116 100%); border-right: 1px solid var(--line); }
#sceneCanvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.stage-topline { position: absolute; top: 19px; left: 22px; right: 22px; display: flex; justify-content: space-between; align-items: flex-start; pointer-events: none; }
.stage-kicker { display: flex; align-items: center; gap: 8px; color: #a6b9b8; font-size: 9px; letter-spacing: .15em; font-weight: 700; }
.kicker-line { width: 18px; height: 1px; background: var(--accent); display: inline-block; }
.stage-time { display: flex; flex-direction: column; align-items: flex-end; gap: 3px; }
.stage-time span { color: var(--faint); font-size: 8px; letter-spacing: .16em; font-weight: 700; }
.stage-time strong { color: #e4f0ec; font-size: 16px; font-weight: 500; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.stage-legend { position: absolute; left: 22px; bottom: 20px; display: flex; flex-wrap: wrap; gap: 15px; color: #8ea4a5; font-size: 9px; pointer-events: none; }
.stage-legend span { display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.legend-dot { display: inline-block; width: 6px; height: 6px; border-radius: 50%; }
.dot-inner { background: #b5c8c3; }
.dot-outer { background: #547b80; border: 1px solid #9eb4b0; }
.dot-solid { background: var(--accent); box-shadow: 0 0 8px rgba(115,228,195,.5); }
.stage-bottomline { position: absolute; right: 22px; bottom: 21px; display: flex; gap: 7px; color: #617a7c; font-size: 8px; letter-spacing: .14em; font-weight: 700; pointer-events: none; }
.stage-bottom-sep { color: var(--accent); }

.control-panel { min-width: 0; min-height: 0; overflow: auto; overscroll-behavior: contain; background: var(--panel); scrollbar-width: thin; scrollbar-color: #294148 transparent; }
.control-panel::-webkit-scrollbar { width: 6px; }
.control-panel::-webkit-scrollbar-thumb { background: #294148; border-radius: 6px; }
.panel-section { padding: 18px 19px; border-bottom: 1px solid var(--line); }
.section-heading, .profile-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.section-index { font-size: 9px; letter-spacing: .16em; }
.section-index span { color: var(--accent); padding: 0 3px; }
h2 { margin: 4px 0 0; font-size: 16px; font-weight: 550; letter-spacing: -.025em; }
.section-mark { color: var(--accent); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11px; padding-top: 17px; }
.preset-row { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; margin: 15px 0 16px; }
.preset-button { height: 32px; border: 1px solid var(--line-strong); border-radius: 6px; color: #9cb0af; background: rgba(255,255,255,.015); font-size: 10px; font-weight: 600; cursor: pointer; transition: all .18s ease; }
.preset-button:hover { border-color: var(--accent-line); color: var(--text); }
.preset-button.active { color: var(--accent); border-color: var(--accent-line); background: var(--accent-dim); }
.control-list { display: grid; gap: 13px; }
.control-item { min-width: 0; }
.control-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 7px; }
.control-heading label { color: #d1dfdc; font-size: 11px; font-weight: 550; }
.control-heading output { color: var(--accent); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 10px; font-variant-numeric: tabular-nums; white-space: nowrap; }
input[type="range"] { width: 100%; height: 13px; margin: 0; appearance: none; -webkit-appearance: none; background: transparent; cursor: pointer; display: block; }
input[type="range"]::-webkit-slider-runnable-track { height: 3px; border-radius: 3px; background: linear-gradient(90deg, rgba(115,228,195,.68), rgba(115,228,195,.2)); }
input[type="range"]::-moz-range-track { height: 3px; border-radius: 3px; background: linear-gradient(90deg, rgba(115,228,195,.68), rgba(115,228,195,.2)); }
input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; appearance: none; width: 12px; height: 12px; margin-top: -4.5px; border-radius: 50%; border: 2px solid #0a171c; background: var(--accent); box-shadow: 0 0 0 1px var(--accent-line), 0 0 9px rgba(115,228,195,.35); }
input[type="range"]::-moz-range-thumb { width: 10px; height: 10px; border-radius: 50%; border: 2px solid #0a171c; background: var(--accent); box-shadow: 0 0 0 1px var(--accent-line), 0 0 9px rgba(115,228,195,.35); }
.range-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 4px; color: #617a7e; font-size: 8px; font-variant-numeric: tabular-nums; }
.number-tag, .metric-origin { color: #6f898a; font-size: 7px; font-weight: 700; letter-spacing: .13em; white-space: nowrap; }
.range-foot .number-tag { margin-left: auto; }
.last-control { margin-bottom: 2px; }

.transport-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding-top: 15px; margin-top: 15px; border-top: 1px solid var(--line); }
.transport-buttons { display: flex; align-items: center; gap: 5px; }
.transport-buttons button { height: 32px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; border-radius: 6px; padding: 0 9px; cursor: pointer; font-size: 10px; font-weight: 600; transition: all .18s ease; }
.transport-buttons svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.transport-primary { color: #071116; background: var(--accent); border: 1px solid var(--accent); min-width: 80px; }
.transport-primary:hover { background: #a1f2d9; }
.transport-secondary { color: #b7c8c4; background: transparent; border: 1px solid var(--line-strong); }
.transport-secondary:hover { border-color: var(--accent-line); color: var(--accent); }
.speed-control { display: flex; flex-direction: column; align-items: flex-end; gap: 5px; }
.speed-control > span { color: #6d8587; font-size: 7px; letter-spacing: .13em; font-weight: 700; }
.speed-control > span i { color: #4f696c; font-style: normal; }
.speed-options { display: flex; gap: 2px; padding: 2px; border-radius: 5px; background: #071318; border: 1px solid var(--line); }
.speed-options button { border: 0; background: transparent; color: #81989a; border-radius: 3px; min-width: 24px; height: 20px; font-size: 9px; cursor: pointer; }
.speed-options button.selected { color: var(--accent); background: rgba(115,228,195,.12); }

.results-section { padding-top: 15px; padding-bottom: 15px; }
.metric-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; margin-top: 11px; }
.metric-card { position: relative; min-width: 0; padding: 10px 11px 9px; border: 1px solid var(--line); border-radius: 7px; background: rgba(255,255,255,.018); display: grid; grid-template-columns: 1fr auto; align-items: end; gap: 3px 5px; }
.metric-label { color: #8da4a3; font-size: 9px; line-height: 1.2; grid-column: 1 / -1; }
.metric-card strong { color: #edf8f4; font-size: 18px; font-weight: 500; letter-spacing: -.04em; line-height: 1.15; font-variant-numeric: tabular-nums; }
.metric-card strong small { color: #9bb0ae; font-size: 9px; font-weight: 500; letter-spacing: 0; }
.metric-origin { align-self: end; padding-bottom: 2px; }
.profile-section { padding-top: 15px; padding-bottom: 13px; }
.profile-heading { align-items: flex-end; }
.profile-note { color: #607a7c; font-size: 7px; letter-spacing: .13em; padding-bottom: 2px; white-space: nowrap; }
#profileCanvas { display: block; width: 100%; height: 94px; margin-top: 7px; }
.profile-legend { display: flex; gap: 13px; flex-wrap: wrap; color: #81999a; font-size: 8px; margin-top: 2px; }
.profile-legend span { display: flex; align-items: center; gap: 5px; }
.profile-line { display: inline-block; width: 13px; height: 2px; border-radius: 2px; }
.line-a { background: #a5b6b3; }
.line-b { background: var(--accent); }
.line-p { background: #e1eee9; opacity: .8; }
.spacing-readout { display: flex; align-items: center; gap: 8px; border-top: 1px solid var(--line); margin-top: 10px; padding-top: 9px; color: #8da3a2; font-size: 9px; }
.spacing-readout strong { color: #e8f4ef; font-size: 13px; font-weight: 550; margin-left: auto; font-variant-numeric: tabular-nums; }
.spacing-readout strong small { color: #93aaa7; font-size: 9px; font-weight: 400; }

.explanation-section { padding-top: 15px; padding-bottom: 15px; }
.process-chain { display: grid; grid-template-columns: 1fr 13px 1fr 13px 1fr; align-items: center; gap: 4px; margin: 11px 0 9px; }
.process-chain div:not(.chain-arrow) { min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.process-chain span { color: var(--accent); font-size: 7px; letter-spacing: .14em; font-weight: 700; }
.process-chain strong { color: #b8c9c5; font-size: 9px; font-weight: 550; line-height: 1.25; }
.chain-arrow { color: #587275; text-align: center; font-size: 13px; }
.dynamic-caption { color: #a8bbb7; font-size: 10px; line-height: 1.55; margin: 0; }

.check-section { padding-top: 14px; padding-bottom: 14px; }
.check-heading { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.check-kind { color: #71898b; font-size: 7px; letter-spacing: .1em; white-space: nowrap; }
.check-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 7px; margin-top: 10px; }
.check-grid > div { min-width: 0; padding: 8px 8px 7px; border: 1px solid var(--line); border-radius: 6px; background: rgba(255,255,255,.015); display: flex; flex-direction: column; gap: 4px; }
.check-grid span { color: #7f9998; font-size: 8px; white-space: nowrap; }
.check-grid strong { color: #e3efea; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; font-weight: 500; white-space: nowrap; }
.check-grid strong small { color: #91a9a6; font-size: 8px; }
.check-grid em { color: #60797b; font-size: 6px; font-style: normal; letter-spacing: .12em; font-weight: 700; }
.check-difference strong { color: var(--accent); }
.check-note { color: #71898b; font-size: 8px; line-height: 1.5; margin: 8px 0 0; }

.science-panel { border-bottom: 1px solid var(--line); }
.science-panel summary { list-style: none; cursor: pointer; padding: 16px 19px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.science-panel summary::-webkit-details-marker { display: none; }
.science-panel summary > span:first-child { display: flex; flex-direction: column; gap: 4px; }
.science-panel summary strong { color: #dce9e5; font-size: 12px; font-weight: 550; }
.details-plus { width: 22px; height: 22px; border: 1px solid var(--line-strong); border-radius: 50%; display: grid; place-items: center; color: var(--accent); font-size: 16px; line-height: 1; transition: transform .2s ease; }
.science-panel[open] .details-plus { transform: rotate(45deg); }
.science-content { padding: 0 19px 18px; }
.science-intro { color: #a6bbb6; font-size: 10px; line-height: 1.6; margin: 0 0 12px; }
.equation-block { padding: 10px 0; border-top: 1px solid var(--line); }
.equation-label { color: #7c9696; font-size: 7px; letter-spacing: .14em; font-weight: 700; display: flex; align-items: center; gap: 8px; margin-bottom: 7px; }
.equation-block code { display: block; color: #d5e7df; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 10px; line-height: 1.65; white-space: normal; }
.equation-block p { color: #829a99; font-size: 9px; line-height: 1.55; margin: 6px 0 0; }
.model-limits p { color: #829a99; font-size: 9px; line-height: 1.6; margin: 6px 0; }
.disclaimer { color: #8ca4a0; font-size: 9px; line-height: 1.5; padding-top: 10px; border-top: 1px solid var(--line); margin: 5px 0 0; }
.panel-tail { display: flex; justify-content: space-between; gap: 8px; padding: 11px 19px 14px; color: #4f686c; font-size: 7px; letter-spacing: .13em; font-weight: 700; }

@media (max-width: 900px) {
  .workspace { grid-template-columns: minmax(0, 1fr) 350px; }
  .masthead { padding: 0 16px; }
  .brand-lockup { min-width: 220px; }
  .panel-section { padding-left: 16px; padding-right: 16px; }
  .science-panel summary { padding-left: 16px; padding-right: 16px; }
  .science-content { padding-left: 16px; padding-right: 16px; }
}

@media (max-width: 700px) {
  .app-shell { grid-template-rows: 58px minmax(0, 1fr); }
  .masthead { gap: 8px; padding: 0 12px; }
  .brand-lockup { gap: 9px; min-width: 0; }
  .brand-symbol { width: 25px; height: 25px; }
  .brand-symbol span:nth-child(2) { width: 13px; height: 13px; }
  .brand-symbol span:nth-child(3) { width: 20px; height: 20px; }
  .eyebrow { font-size: 7px; }
  h1 { font-size: 16px; }
  .header-status { display: none; }
  .header-actions { margin-left: auto; gap: 5px; }
  .quiet-button, .screenshot-button { height: 30px; padding: 0 8px; font-size: 8px; }
  .screenshot-button { font-size: 9px; gap: 4px; }
  .screenshot-button svg { width: 13px; height: 13px; }
  .workspace { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(255px, 36dvh) minmax(0, 1fr); }
  .stage { border-right: 0; border-bottom: 1px solid var(--line); }
  .stage-topline { top: 12px; left: 14px; right: 14px; }
  .stage-legend { left: 14px; bottom: 12px; gap: 10px; font-size: 8px; }
  .stage-bottomline { right: 14px; bottom: 13px; font-size: 7px; }
  .control-panel { min-height: 0; }
  .panel-section { padding: 15px 15px; }
  .control-list { gap: 12px; }
  .transport-row { align-items: flex-end; }
}

@media (max-width: 390px) {
  .masthead { padding: 0 9px; }
  .brand-symbol { display: none; }
  h1 { font-size: 15px; }
  .quiet-button { padding: 0 6px; font-size: 7px; }
  .screenshot-button { padding: 0 7px; }
  .stage-legend { gap: 7px; font-size: 7px; }
  .stage-bottomline { display: none; }
  .panel-section { padding-left: 13px; padding-right: 13px; }
  .science-panel summary { padding-left: 13px; padding-right: 13px; }
  .science-content { padding-left: 13px; padding-right: 13px; }
  .transport-buttons button { padding: 0 7px; }
  .transport-primary { min-width: 70px; }
}

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