:root {
  color-scheme: dark;
  --bg: #0a0d14;
  --panel: #111722;
  --panel-2: #151d2a;
  --line: #263143;
  --line-soft: #1d2736;
  --text: #edf1f8;
  --muted: #929daf;
  --dim: #647186;
  --accent: #a78bfa;
  --accent-soft: rgba(167,139,250,.14);
  --accent-glow: rgba(167,139,250,.28);
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --sans: 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); font-family: var(--sans); }
body { min-width: 320px; }
button, input { font: inherit; }
button { color: inherit; }
.app { width: min(1440px, 100%); margin: 0 auto; padding: 20px 24px 12px; display: flex; flex-direction: column; gap: 14px; }
.topbar { min-height: 52px; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.brand { display: flex; align-items: center; gap: 13px; min-width: 0; }
.brand-mark { width: 38px; height: 38px; flex: 0 0 38px; position: relative; border: 1px solid rgba(167,139,250,.48); border-radius: 12px; background: linear-gradient(145deg, rgba(167,139,250,.16), rgba(167,139,250,.035)); transform: rotate(0deg); }
.brand-mark span { position: absolute; width: 9px; height: 9px; border: 1.4px solid var(--accent); transform: rotate(45deg); }
.brand-mark span:nth-child(1) { top: 6px; left: 13px; }.brand-mark span:nth-child(2) { top: 13px; left: 6px; }.brand-mark span:nth-child(3) { top: 13px; right: 6px; }.brand-mark span:nth-child(4) { bottom: 5px; left: 13px; }
.brand-copy { min-width: 0; }.eyebrow { margin: 0 0 3px; color: var(--accent); font: 700 9px/1.3 var(--mono); letter-spacing: .16em; }
h1 { margin: 0; font-size: clamp(17px, 2vw, 22px); line-height: 1.2; letter-spacing: -.035em; font-weight: 650; }
.top-actions { display: flex; align-items: center; gap: 10px; flex: 0 0 auto; }
.seed-tag { border: 1px solid var(--line); border-radius: 999px; padding: 7px 10px; color: var(--muted); font: 10px var(--mono); letter-spacing: .08em; }
.icon-button, .close-science { border: 1px solid var(--line); background: var(--panel); border-radius: 10px; padding: 8px 11px; display: inline-flex; align-items: center; gap: 7px; color: #d9d2f5; font-size: 11px; cursor: pointer; transition: border-color .2s, background .2s; }
.icon-button:hover, .close-science:hover { border-color: var(--accent); background: var(--accent-soft); }
.icon-button svg, .primary-button svg, .secondary-button svg, .screenshot-button svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.readouts { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.metric { min-width: 0; padding: 10px 13px 9px; background: linear-gradient(135deg, rgba(20,29,42,.96), rgba(14,20,30,.96)); border: 1px solid var(--line-soft); border-radius: 11px; }
.metric-label { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 10px; line-height: 1.3; }
.metric-dot { width: 5px; height: 5px; flex: 0 0 5px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 10px var(--accent-glow); }
.metric-value { margin-top: 5px; font: 600 21px/1.1 var(--mono); letter-spacing: -.05em; color: #f4f0ff; font-variant-numeric: tabular-nums; }
.metric-unit { margin-top: 4px; color: var(--dim); font: 9px/1.2 var(--mono); }
.stage-wrap { min-height: 310px; display: flex; flex-direction: column; gap: 7px; }
.stage-head { min-height: 26px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.stage-title { display: flex; align-items: center; gap: 8px; min-width: 0; color: #dce2ec; font-size: 11px; font-weight: 600; }
.stage-divider, .muted { color: var(--dim); font-weight: 400; }
.live-pip { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 11px var(--accent); }
.quality-control { display: flex; gap: 3px; padding: 3px; border: 1px solid var(--line); border-radius: 8px; background: #0e141e; }
.quality-btn { padding: 4px 9px; border: 0; border-radius: 5px; color: var(--dim); background: transparent; font: 10px var(--mono); cursor: pointer; }
.quality-btn.active { color: #f1eaff; background: var(--accent-soft); box-shadow: inset 0 0 0 1px rgba(167,139,250,.22); }
.canvas-frame { position: relative; flex: 1 1 auto; min-height: 260px; overflow: hidden; border: 1px solid #283347; border-radius: 13px; background: radial-gradient(ellipse at 42% 46%, #111a29 0%, #0b111b 64%, #090e16 100%); box-shadow: 0 12px 36px rgba(0,0,0,.18), inset 0 1px 0 rgba(255,255,255,.025); }
#vizCanvas { display: block; width: 100%; height: 100%; touch-action: pan-y; }
.canvas-legend { position: absolute; bottom: 11px; left: 14px; display: flex; gap: 14px; align-items: center; pointer-events: none; color: #9ca9bb; font: 9px var(--mono); }
.canvas-legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend-point { width: 5px; height: 5px; border-radius: 50%; background: #d6c8ff; box-shadow: 0 0 7px rgba(167,139,250,.8); }
.legend-line { width: 12px; height: 1px; background: rgba(167,139,250,.5); }
.legend-peak { width: 7px; height: 7px; border-radius: 50%; background: #e5dbff; box-shadow: 0 0 8px #a78bfa; }
.canvas-hint { position: absolute; right: 13px; bottom: 11px; color: #7c899c; font: 8px var(--mono); letter-spacing: .1em; pointer-events: none; }
.what-seeing { margin: 0; min-height: 17px; color: #aab4c4; font-size: 10px; line-height: 1.5; }
.what-seeing::before { content: "WHAT YOU'RE SEEING  /  "; color: var(--accent); font: 700 9px var(--mono); letter-spacing: .08em; }
.control-deck { padding: 12px 14px 11px; background: linear-gradient(145deg, #121a27, #0f1621); border: 1px solid var(--line); border-radius: 13px; }
.control-topline { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 11px; }
.control-heading { color: #e1e6ef; font-size: 11px; font-weight: 650; }.control-heading span { color: var(--dim); font-size: 9px; font-weight: 400; }
.preset-group { display: flex; gap: 5px; }
.preset-btn { border: 1px solid var(--line); border-radius: 7px; padding: 6px 9px; color: #9ba7b9; background: #0d141f; font-size: 9px; cursor: pointer; transition: .2s; }
.preset-btn:hover, .preset-btn.selected { border-color: rgba(167,139,250,.5); color: #eee8ff; background: var(--accent-soft); }
.controls-grid { display: grid; grid-template-columns: repeat(5, minmax(0,1fr)); gap: 13px; }
.control { min-width: 0; display: flex; flex-direction: column; gap: 7px; }
.control-label { display: flex; justify-content: space-between; gap: 6px; color: #b8c2d1; font-size: 9px; white-space: nowrap; }
.control-label output { color: #e5dfff; font: 10px var(--mono); }
input[type="range"] { width: 100%; height: 14px; margin: 0; appearance: none; background: transparent; cursor: pointer; }
input[type="range"]::-webkit-slider-runnable-track { height: 3px; border-radius: 99px; background: linear-gradient(90deg, rgba(167,139,250,.65), #354155); }
input[type="range"]::-moz-range-track { height: 3px; border-radius: 99px; background: linear-gradient(90deg, rgba(167,139,250,.65), #354155); }
input[type="range"]::-webkit-slider-thumb { appearance: none; width: 12px; height: 12px; margin-top: -4.5px; border-radius: 50%; border: 2px solid #d8ccff; background: #8e71e6; box-shadow: 0 0 0 3px rgba(167,139,250,.14), 0 0 9px rgba(167,139,250,.5); }
input[type="range"]::-moz-range-thumb { width: 9px; height: 9px; border-radius: 50%; border: 2px solid #d8ccff; background: #8e71e6; box-shadow: 0 0 0 3px rgba(167,139,250,.14); }
.range-ends { display: flex; justify-content: space-between; color: #5f6c80; font: 8px var(--mono); }
.transport-row { display: flex; align-items: center; gap: 12px; margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--line-soft); }
.transport-buttons { display: flex; gap: 6px; flex: 0 0 auto; }
.primary-button, .secondary-button, .screenshot-button { min-height: 30px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 6px 10px; border-radius: 7px; font-size: 9px; cursor: pointer; transition: .2s; }
.primary-button { border: 1px solid rgba(167,139,250,.55); color: #f4efff; background: linear-gradient(135deg, #7e62d4, #5f4ca9); box-shadow: 0 3px 12px rgba(113,84,190,.18); }
.primary-button:hover { filter: brightness(1.13); }.secondary-button { border: 1px solid var(--line); color: #b5bfd0; background: #111a27; }.secondary-button:hover, .screenshot-button:hover { border-color: var(--accent); color: #f0eaff; background: var(--accent-soft); }
.progress-wrap { flex: 1 1 auto; min-width: 50px; }.progress-label { display: flex; justify-content: space-between; gap: 8px; margin-bottom: 6px; color: #8491a5; font: 8px var(--mono); }.progress-label span:last-child { color: #c5b8f2; }
.progress-track { height: 3px; border-radius: 9px; overflow: hidden; background: #263144; }.progress-fill { width: 0; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #7660c6, #c1aaff); transition: width .18s ease; }
.screenshot-button { flex: 0 0 auto; border: 1px solid var(--line); color: #b5bfd0; background: #111a27; }
.science-panel { padding: 17px; border: 1px solid rgba(167,139,250,.28); border-radius: 13px; background: linear-gradient(145deg, #151b2a, #101722); box-shadow: 0 16px 40px rgba(0,0,0,.22); }
.science-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 13px; }.science-head h2 { margin: 0; font-size: 17px; letter-spacing: -.03em; }.close-science { width: 30px; height: 30px; justify-content: center; padding: 0; font-size: 20px; }
.science-grid { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 8px; }.science-card { padding: 11px; border: 1px solid var(--line); border-radius: 9px; background: rgba(9,14,22,.45); min-width: 0; }.science-card h3 { margin: 0 0 7px; color: #e8e1ff; font-size: 11px; }.science-card p { margin: 0 0 7px; color: #9ca9ba; font-size: 9px; line-height: 1.5; }.science-card p:last-child { margin-bottom: 0; }.equation { margin: 7px 0; padding: 7px; border-radius: 6px; color: #ded3ff; background: rgba(167,139,250,.09); font: 10px/1.5 var(--mono); overflow-wrap: anywhere; }
.simplifications, .disclaimer { margin: 10px 0 0; color: #8d9aab; font-size: 9px; line-height: 1.5; }.simplifications strong { color: #c7d0de; }.disclaimer { color: #6f7c90; font-style: italic; }
.footer { display: flex; justify-content: space-between; gap: 12px; color: #526075; font: 8px var(--mono); letter-spacing: .08em; }
button:focus-visible, input:focus-visible { outline: 2px solid #d1c1ff; outline-offset: 3px; }
body.embed-mode { height: 100vh; height: 100dvh; overflow: hidden; }
body.embed-mode .app { height: 100%; overflow: hidden; }
body.embed-mode .stage-wrap { flex: 1 1 auto; min-height: 0; }
body.embed-mode .canvas-frame { min-height: 0; }
body.embed-mode .control-deck { flex: 0 0 auto; }
@media (min-width: 1000px) {
  body.embed-mode .app { display: grid; grid-template-rows: auto auto minmax(240px,1fr) auto auto; gap: 10px; }
}
@media (max-width: 900px) {
  .app { padding: 15px 16px 10px; gap: 10px; }
  .controls-grid { grid-template-columns: repeat(3,minmax(0,1fr)); row-gap: 12px; }
  .science-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .metric { padding: 9px 10px; }
  .metric-value { font-size: 18px; }
}
@media (max-width: 560px) {
  .app { padding: 10px 10px 8px; gap: 8px; }
  .topbar { min-height: 43px; gap: 8px; }
  .brand { gap: 9px; }.brand-mark { width: 32px; height: 32px; flex-basis: 32px; border-radius: 9px; }.brand-mark span:nth-child(1) { top: 4px; left: 10px; }.brand-mark span:nth-child(2) { top: 10px; left: 4px; }.brand-mark span:nth-child(3) { top: 10px; right: 4px; }.brand-mark span:nth-child(4) { bottom: 4px; left: 10px; }
  .eyebrow { font-size: 7px; } h1 { font-size: 14px; max-width: 220px; }
  .top-actions { gap: 5px; }.seed-tag { display: none; }.icon-button { padding: 7px 8px; font-size: 9px; }.icon-button svg { width: 14px; height: 14px; }
  .readouts { grid-template-columns: repeat(2,minmax(0,1fr)); gap: 6px; }.metric { padding: 7px 9px; border-radius: 9px; }.metric-label { font-size: 9px; }.metric-value { margin-top: 3px; font-size: 16px; }.metric-unit { margin-top: 2px; font-size: 7px; }
  .stage-wrap { min-height: 220px; gap: 5px; }.stage-head { min-height: 21px; }.stage-title { font-size: 9px; gap: 5px; }.quality-btn { padding: 3px 7px; font-size: 8px; }.canvas-frame { min-height: 180px; border-radius: 10px; }.canvas-legend { left: 8px; bottom: 7px; gap: 8px; font-size: 7px; }.canvas-legend span { gap: 4px; }.canvas-hint { display: none; }.what-seeing { font-size: 8px; line-height: 1.35; min-height: 23px; }.what-seeing::before { font-size: 7px; }
  .control-deck { padding: 9px; border-radius: 10px; }.control-topline { align-items: flex-start; flex-direction: column; gap: 7px; margin-bottom: 9px; }.control-heading { font-size: 10px; }.control-heading span { font-size: 8px; }.preset-btn { padding: 5px 8px; font-size: 8px; }
  .controls-grid { grid-template-columns: repeat(2,minmax(0,1fr)); gap: 9px 12px; }.control { gap: 5px; }.control-label { font-size: 8px; }.control-label output { font-size: 9px; }.range-ends { font-size: 7px; }
  .transport-row { flex-wrap: wrap; gap: 7px; margin-top: 9px; padding-top: 8px; }.transport-buttons { gap: 4px; }.primary-button, .secondary-button, .screenshot-button { min-height: 28px; padding: 5px 7px; font-size: 8px; gap: 4px; }.primary-button svg, .secondary-button svg, .screenshot-button svg { width: 13px; height: 13px; }.progress-wrap { order: 3; flex-basis: 100%; }.screenshot-button { margin-left: auto; }
  .science-panel { padding: 12px; }.science-head h2 { font-size: 14px; }.science-grid { grid-template-columns: 1fr; }.science-card { padding: 9px; }.science-card p { font-size: 8px; }.equation { font-size: 9px; }.footer { font-size: 7px; }
  body.embed-mode .app { display: flex; gap: 7px; padding: 8px 8px 6px; }
  body.embed-mode .topbar { flex: 0 0 auto; }
  body.embed-mode .readouts { flex: 0 0 auto; }
  body.embed-mode .stage-wrap { flex: 1 1 auto; min-height: 170px; }
  body.embed-mode .canvas-frame { min-height: 150px; }
  body.embed-mode .control-deck { flex: 0 0 auto; max-height: 42dvh; overflow-y: auto; overscroll-behavior: contain; }
  body.embed-mode .footer { display: none; }
  body.embed-mode .science-panel { flex: 0 0 auto; max-height: 44dvh; overflow-y: auto; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
