:root {
  color-scheme: dark;
  --bg: #090d16;
  --panel: #101725;
  --panel-2: #0d1421;
  --line: rgba(157, 178, 207, .13);
  --line-strong: rgba(157, 178, 207, .23);
  --text: #edf3fb;
  --muted: #91a0b6;
  --soft: #64738a;
  --accent: #62e5d1;
  --accent-dim: rgba(98, 229, 209, .12);
  --a: #54d9ce;
  --b: #ae98ff;
  --c: #f3bf68;
  --trapped: #344257;
  --radius: 14px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; width: 100%; min-width: 320px; min-height: 100%; background: var(--bg); color: var(--text); }
body { height: 100vh; height: 100dvh; overflow: hidden; }
button, input { font: inherit; }
button { color: inherit; }
.app-shell { height: 100vh; height: 100dvh; display: flex; flex-direction: column; overflow: hidden; background: radial-gradient(ellipse at 38% 0%, rgba(28, 50, 74, .18), transparent 42%), var(--bg); }
.topbar { height: 68px; flex: 0 0 68px; display: flex; align-items: center; gap: 24px; padding: 0 24px; border-bottom: 1px solid var(--line); background: rgba(9, 13, 22, .94); }
.brand-lockup { display: flex; align-items: center; gap: 13px; min-width: 230px; }
.mark { width: 27px; height: 27px; position: relative; display: flex; align-items: center; justify-content: center; gap: 2px; transform: rotate(-20deg); }
.mark i { display: block; width: 6px; border-radius: 5px; background: var(--accent); box-shadow: 0 0 14px rgba(98,229,209,.28); }
.mark i:nth-child(1) { height: 13px; opacity: .55; transform: translateY(4px); }
.mark i:nth-child(2) { height: 22px; }
.mark i:nth-child(3) { height: 16px; opacity: .78; transform: translateY(-3px); }
.eyebrow, .section-kicker { color: var(--accent); font-size: 9px; font-weight: 800; letter-spacing: .17em; line-height: 1.3; }
h1 { margin: 2px 0 0; font-size: 19px; letter-spacing: -.035em; font-weight: 680; line-height: 1.1; }
.system-label { color: #9aa8bb; font-size: 10px; letter-spacing: .13em; font-weight: 700; display: flex; align-items: center; gap: 9px; }
.status-dot, .live-pill i { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 10px rgba(98,229,209,.65); }
.system-sep { color: #46556a; }
.header-action { margin-left: auto; display: inline-flex; align-items: center; gap: 8px; padding: 9px 13px; border: 1px solid var(--line-strong); border-radius: 9px; background: #111b29; color: #dce7f5; font-size: 11px; font-weight: 650; cursor: pointer; transition: border-color .18s, background .18s, transform .18s; }
.header-action:hover { border-color: rgba(98,229,209,.5); background: #142436; transform: translateY(-1px); }
.header-action svg { width: 15px; height: 15px; fill: none; stroke: var(--accent); stroke-width: 1.5; stroke-linejoin: round; }
.workspace { min-height: 0; flex: 1; display: grid; grid-template-columns: minmax(0, 1fr) 370px; gap: 14px; padding: 14px; }
.stage-card { animation: panel-arrive .68s cubic-bezier(.2,.75,.2,1) both; min-width: 0; min-height: 0; display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: var(--radius); background: linear-gradient(155deg, rgba(19,29,45,.98), rgba(10,16,27,.98)); overflow: hidden; box-shadow: 0 18px 50px rgba(0,0,0,.18); }
.stage-head { min-height: 65px; flex: 0 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 13px 17px 12px; border-bottom: 1px solid var(--line); }
.stage-subtitle { color: #a2b0c4; font-size: 11px; margin-top: 4px; }
.legend { display: flex; align-items: center; flex-wrap: wrap; justify-content: flex-end; gap: 8px 13px; color: #9caabe; font-size: 8px; letter-spacing: .09em; font-weight: 750; }
.legend span { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; }
.legend-dot { width: 7px; height: 7px; display: inline-block; border-radius: 50%; }
.exit-a { background: var(--a); box-shadow: 0 0 8px rgba(84,217,206,.35); }
.exit-b { background: var(--b); box-shadow: 0 0 8px rgba(174,152,255,.35); }
.exit-c { background: var(--c); box-shadow: 0 0 8px rgba(243,191,104,.35); }
.trapped { background: var(--trapped); }
.canvas-wrap { flex: 1; min-height: 0; position: relative; overflow: hidden; background: #080e18; }
#basinCanvas { display: block; width: 100%; height: 100%; touch-action: manipulation; cursor: crosshair; outline: none; }
#basinCanvas:focus-visible { outline: 2px solid var(--accent); outline-offset: -4px; }
.canvas-hint { position: absolute; left: 16px; bottom: 13px; color: rgba(184,201,222,.65); font-size: 8px; font-weight: 800; letter-spacing: .15em; pointer-events: none; text-shadow: 0 1px 5px #050912; }
.hint-crosshair { color: var(--accent); font-size: 14px; vertical-align: -1px; margin-right: 5px; }
.map-status { position: absolute; right: 13px; bottom: 12px; color: rgba(154,173,197,.64); font-size: 8px; font-weight: 750; letter-spacing: .13em; pointer-events: none; }
.loading-state { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; color: #a7b8cd; background: rgba(8,14,24,.72); font-size: 11px; letter-spacing: .04em; transition: opacity .25s; pointer-events: none; }
.loading-state.hidden { opacity: 0; }
.loader { width: 23px; height: 23px; border: 2px solid rgba(98,229,209,.18); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes panel-arrive { from { opacity: 0; transform: translateY(9px); } to { opacity: 1; transform: translateY(0); } }
.stage-foot { min-height: 51px; flex: 0 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 9px 16px; border-top: 1px solid var(--line); }
.stage-foot p { margin: 0; color: #c2ccda; font-size: 10px; line-height: 1.45; max-width: 66%; }
.foot-shortcuts { display: flex; align-items: center; gap: 5px; color: #718098; font-size: 7px; letter-spacing: .08em; white-space: nowrap; font-weight: 700; }
kbd { min-width: 17px; padding: 3px 4px; text-align: center; border: 1px solid rgba(154,173,197,.22); border-radius: 4px; background: rgba(255,255,255,.035); color: #c0ccdc; font-size: 8px; font-family: inherit; }
.control-panel { animation: panel-arrive .76s cubic-bezier(.2,.75,.2,1) .06s both; min-height: 0; overflow-y: auto; overflow-x: hidden; border: 1px solid var(--line); border-radius: var(--radius); background: linear-gradient(165deg, rgba(17,25,39,.98), rgba(12,19,31,.98)); padding: 17px 16px 13px; scrollbar-width: thin; scrollbar-color: #344258 transparent; }
.panel-title-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 15px; }
h2 { margin: 3px 0 0; font-size: 17px; letter-spacing: -.035em; font-weight: 680; }
.live-pill { display: inline-flex; align-items: center; gap: 6px; border: 1px solid rgba(98,229,209,.18); border-radius: 99px; padding: 5px 8px; color: #8fe4d7; background: rgba(98,229,209,.06); font-size: 7px; letter-spacing: .12em; font-weight: 800; }
.live-pill i { width: 5px; height: 5px; }
.preset-block { padding-bottom: 13px; border-bottom: 1px solid var(--line); }
.control-label-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.control-label-row label, .control-label { color: #9ba9bc; font-size: 8px; font-weight: 800; letter-spacing: .13em; }
.tiny-note { color: #66768d; font-size: 7px; letter-spacing: .12em; font-weight: 800; }
.preset-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; margin-top: 8px; }
.preset-btn { border: 1px solid var(--line-strong); border-radius: 7px; background: rgba(255,255,255,.025); color: #c1ccdc; padding: 8px 5px; font-size: 9px; font-weight: 650; cursor: pointer; transition: .18s; }
.preset-btn:hover, .preset-btn.active { border-color: rgba(98,229,209,.5); background: rgba(98,229,209,.08); color: #d9fff8; }
.sliders-block { display: grid; gap: 13px; padding: 14px 0 13px; border-bottom: 1px solid var(--line); }
.slider-control output { color: var(--accent); font-size: 11px; font-weight: 750; font-variant-numeric: tabular-nums; letter-spacing: .015em; }
.math-label { color: #6d8099; font-family: Georgia, serif; font-style: italic; font-size: 10px; margin-left: 3px; }
input[type=range] { width: 100%; height: 15px; margin: 6px 0 0; background: transparent; accent-color: var(--accent); cursor: pointer; display: block; }
input[type=range]::-webkit-slider-runnable-track { height: 3px; border-radius: 3px; background: linear-gradient(90deg, rgba(98,229,209,.6), rgba(98,229,209,.16)); }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; appearance: none; width: 12px; height: 12px; margin-top: -4.5px; border: 2px solid #08131c; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 2px rgba(98,229,209,.25), 0 0 12px rgba(98,229,209,.22); }
input[type=range]::-moz-range-track { height: 3px; border-radius: 3px; background: linear-gradient(90deg, rgba(98,229,209,.6), rgba(98,229,209,.16)); }
input[type=range]::-moz-range-thumb { width: 9px; height: 9px; border: 2px solid #08131c; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 2px rgba(98,229,209,.25); }
.range-ends { display: flex; justify-content: space-between; color: #65748a; font-size: 7px; letter-spacing: .08em; font-weight: 700; margin-top: 1px; }
.quality-row { display: flex; align-items: center; justify-content: space-between; padding: 12px 0; border-bottom: 1px solid var(--line); }
.segmented { display: inline-flex; padding: 3px; border: 1px solid var(--line); border-radius: 7px; background: rgba(0,0,0,.16); gap: 2px; }
.segmented button { min-width: 42px; border: 0; border-radius: 5px; background: transparent; color: #8291a7; padding: 5px 8px; font-size: 8px; font-weight: 750; cursor: pointer; }
.segmented button.selected { background: #1d3341; color: #aaf8ec; box-shadow: inset 0 0 0 1px rgba(98,229,209,.18); }
.playback-row { display: grid; grid-template-columns: 1.15fr 1fr 1fr; gap: 6px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.play-btn, .utility-btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 33px; border-radius: 7px; cursor: pointer; font-size: 9px; font-weight: 700; transition: background .18s, border-color .18s; }
.play-btn { border: 1px solid rgba(98,229,209,.32); background: rgba(98,229,209,.1); color: #aaf8ec; }
.play-btn:hover { background: rgba(98,229,209,.17); border-color: rgba(98,229,209,.55); }
.play-btn svg { width: 13px; height: 13px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.utility-btn { border: 1px solid var(--line-strong); background: rgba(255,255,255,.025); color: #b5c1d1; }
.utility-btn:hover { background: rgba(255,255,255,.07); border-color: rgba(157,178,207,.4); }
.utility-btn span { color: var(--accent); font-size: 12px; }
.readouts { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; padding: 12px 0 10px; }
.readout-card { min-width: 0; border: 1px solid var(--line); border-radius: 8px; padding: 9px 9px 8px; background: rgba(255,255,255,.018); }
.readout-label { display: flex; align-items: center; gap: 5px; color: #8493a9; font-size: 7px; font-weight: 800; letter-spacing: .1em; white-space: nowrap; }
.unit-tag { color: #71849a; font-size: 6px; letter-spacing: .1em; border: 1px solid rgba(143,163,190,.16); border-radius: 3px; padding: 2px 3px; }
.readout-value { margin-top: 6px; color: #edf5ff; font-size: 19px; font-weight: 650; letter-spacing: -.04em; font-variant-numeric: tabular-nums; white-space: nowrap; }
.readout-sub { margin-top: 1px; color: #728199; font-size: 8px; }
.selected-exit-row { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 9px; padding: 2px 0 12px; color: #7f8da3; font-size: 7px; font-weight: 800; letter-spacing: .1em; }
.selected-exit-row strong { color: var(--b); font-size: 8px; letter-spacing: .08em; }
.selected-exit-row #launchReadout { margin-left: auto; color: #a2b1c5; font-size: 8px; letter-spacing: .015em; font-weight: 600; font-variant-numeric: tabular-nums; }
.selected-exit-row small { color: #687991; font-size: 6px; letter-spacing: .08em; }
.chart-card { border: 1px solid var(--line); border-radius: 9px; padding: 10px 10px 8px; background: rgba(5,10,18,.27); }
.chart-heading { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.chart-heading h3 { margin: 3px 0 0; font-size: 11px; font-weight: 650; letter-spacing: -.01em; }
.chart-tag { color: #9a87db; border: 1px solid rgba(174,152,255,.2); border-radius: 4px; padding: 3px 5px; font-size: 6px; letter-spacing: .1em; font-weight: 800; }
#thresholdChart { display: block; width: 100%; height: 104px; margin-top: 3px; }
.chart-foot { display: flex; align-items: center; justify-content: space-between; gap: 6px; color: #74839a; font-size: 6px; letter-spacing: .08em; font-weight: 750; }
.chart-foot span { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; }
.chart-line { width: 12px; height: 2px; background: var(--accent); display: inline-block; }
.threshold-line { width: 2px; height: 9px; display: inline-block; background: var(--c); }
.check-card { display: flex; align-items: flex-start; gap: 9px; padding: 11px 0; border-bottom: 1px solid var(--line); }
.check-icon { display: flex; align-items: center; justify-content: center; flex: 0 0 20px; height: 20px; border: 1px solid rgba(98,229,209,.25); border-radius: 50%; color: var(--accent); background: rgba(98,229,209,.08); font-size: 11px; }
.check-content { min-width: 0; }
.check-title { color: #9eafc3; font-size: 7px; font-weight: 800; letter-spacing: .11em; display: flex; align-items: center; gap: 6px; }
.textbook-tag { color: #f2c878; border-color: rgba(243,191,104,.24); }
.check-equation { margin-top: 5px; color: #a9b8ca; font-size: 9px; font-variant-numeric: tabular-nums; }
.check-equation strong { color: #e9f2fc; font-size: 11px; font-weight: 700; }
.check-detail { margin-top: 3px; color: #73839a; font-size: 8px; font-variant-numeric: tabular-nums; }
.check-detail span { color: var(--accent); }
.science-panel { border-bottom: 1px solid var(--line); }
.science-panel summary { display: flex; align-items: center; justify-content: space-between; list-style: none; cursor: pointer; padding: 13px 1px; color: #b8c6d8; font-size: 8px; font-weight: 850; letter-spacing: .14em; }
.science-panel summary::-webkit-details-marker { display: none; }
.summary-plus { color: var(--accent); font-size: 16px; font-weight: 400; transition: transform .18s; }
.science-panel[open] .summary-plus { transform: rotate(45deg); }
.science-copy { padding: 0 1px 12px; color: #8e9db2; font-size: 9px; line-height: 1.55; }
.science-copy p { margin: 0 0 9px; }
.equation { padding: 5px 7px; margin: 4px 0; border-left: 2px solid rgba(98,229,209,.38); background: rgba(98,229,209,.035); color: #d1e1ef; font-family: "SFMono-Regular", Consolas, monospace; font-size: 8px; }
.science-copy strong { color: #d5e3f2; }
.science-copy .disclaimer { margin: 10px 0 0; color: #a8b7c9; font-style: italic; }
.panel-bottom-note { padding-top: 10px; color: #5f6e83; font-size: 6px; letter-spacing: .12em; font-weight: 800; }
button:focus-visible, input:focus-visible, summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

@media (max-width: 1050px) and (min-width: 701px) {
  .workspace { grid-template-columns: minmax(0, 1fr) 330px; gap: 10px; padding: 10px; }
  .topbar { padding: 0 17px; }
  .legend { gap: 7px 9px; }
  .legend span { font-size: 7px; }
}
@media (max-width: 700px) {
  body { overflow: auto; }
  .app-shell { height: auto; min-height: 100vh; min-height: 100dvh; overflow: visible; }
  .topbar { height: 57px; flex-basis: 57px; padding: 0 12px; gap: 8px; }
  .brand-lockup { min-width: 0; gap: 9px; }
  .mark { transform: scale(.86) rotate(-20deg); }
  .eyebrow { font-size: 7px; }
  h1 { font-size: 16px; }
  .system-label { display: none; }
  .header-action { padding: 8px 9px; font-size: 9px; gap: 5px; }
  .header-action svg { width: 13px; height: 13px; }
  .workspace { display: flex; flex-direction: column; gap: 9px; padding: 9px; min-height: calc(100dvh - 57px); }
  .stage-card { flex: 0 0 auto; height: min(48dvh, 410px); min-height: 300px; }
  .stage-head { min-height: 57px; padding: 9px 10px; align-items: flex-start; flex-direction: column; gap: 7px; }
  .stage-subtitle { font-size: 9px; margin-top: 2px; }
  .legend { width: 100%; justify-content: flex-start; gap: 5px 10px; }
  .legend span { font-size: 6px; }
  .legend-dot { width: 6px; height: 6px; }
  .stage-foot { min-height: 44px; padding: 7px 10px; }
  .stage-foot p { font-size: 9px; max-width: 100%; }
  .foot-shortcuts { display: none; }
  .control-panel { overflow: visible; padding: 14px 13px 12px; }
  .panel-title-row { margin-bottom: 12px; }
  .preset-btn { padding: 9px 5px; }
  .sliders-block { gap: 12px; }
  .readout-value { font-size: 18px; }
  #thresholdChart { height: 115px; }
}
@media (max-width: 700px) and (max-height: 700px) {
  .stage-card { height: 330px; min-height: 285px; }
}
body.embed-mode { height: 100vh; height: 100dvh; overflow: hidden; }
body.embed-mode .app-shell { height: 100vh; height: 100dvh; overflow: hidden; }
body.embed-mode .workspace { min-height: 0; }
@media (max-width: 700px) {
  body.embed-mode .workspace { flex: 1; min-height: 0; overflow: hidden; }
  body.embed-mode .stage-card { flex: 0 0 41%; height: auto; min-height: 260px; max-height: 390px; }
  body.embed-mode .control-panel { flex: 1 1 0; min-height: 0; 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; }
}
