:root {
  color-scheme: dark;
  --bg: #07121b;
  --panel: #0b1a25;
  --panel-2: #0e202d;
  --line: rgba(160, 195, 211, .13);
  --line-strong: rgba(160, 195, 211, .23);
  --text: #e5f0f3;
  --muted: #8ca4b0;
  --dim: #607987;
  --accent: #55e3d0;
  --accent-soft: rgba(85, 227, 208, .13);
  --amber: #ffb879;
  --red: #ff8c82;
  --radius: 12px;
  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-width: 320px; }
button, input { font: inherit; }
button { color: inherit; }
.app { min-height: 100vh; display: flex; flex-direction: column; background: radial-gradient(ellipse at 14% -12%, rgba(31, 87, 96, .22), transparent 40%), var(--bg); }
.topbar { height: 68px; flex: 0 0 68px; display: flex; align-items: center; justify-content: space-between; padding: 0 28px; border-bottom: 1px solid var(--line); background: rgba(5, 15, 23, .84); }
.brand-lockup, .topbar-right { display: flex; align-items: center; }
.brand-lockup { gap: 12px; }
.brand-mark { width: 30px; height: 30px; border: 1px solid rgba(85, 227, 208, .55); border-radius: 9px; display: flex; align-items: center; justify-content: center; gap: 3px; transform: rotate(-8deg); background: rgba(85, 227, 208, .05); }
.brand-mark span { display: block; width: 3px; border-radius: 4px; background: var(--accent); box-shadow: 0 0 8px rgba(85,227,208,.5); }
.brand-mark span:nth-child(1) { height: 8px; opacity: .55; }
.brand-mark span:nth-child(2) { height: 17px; }
.brand-mark span:nth-child(3) { height: 11px; opacity: .75; }
.eyebrow { color: #a9c3cd; font-size: 9px; font-weight: 750; letter-spacing: .19em; }
.eyebrow span { color: var(--accent); padding: 0 3px; }
.brand-sub { color: var(--dim); font-size: 8px; letter-spacing: .16em; margin-top: 4px; }
.topbar-right { gap: 18px; }
.live-indicator { display: flex; align-items: center; gap: 7px; color: var(--accent); font-size: 9px; letter-spacing: .12em; font-weight: 750; }
.live-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 10px var(--accent); }
.topbar-meta { color: var(--dim); font-size: 9px; letter-spacing: .13em; }
.topbar-meta span { color: var(--accent); padding: 0 5px; }
.layout { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) 358px; gap: 16px; padding: 18px 20px 18px 24px; }
.stage-column { min-width: 0; min-height: 0; display: flex; flex-direction: column; gap: 12px; }
.stage-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 50px; }
.stage-heading h1 { font-size: clamp(18px, 2.1vw, 25px); letter-spacing: -.045em; line-height: 1.12; font-weight: 650; margin: 5px 0 0; }
.stage-state { flex: 0 0 auto; display: flex; align-items: center; gap: 8px; padding: 8px 11px; border: 1px solid rgba(255, 184, 121, .25); background: rgba(255, 184, 121, .07); border-radius: 99px; color: var(--amber); font-size: 9px; font-weight: 800; letter-spacing: .1em; }
.state-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; box-shadow: 0 0 9px currentColor; }
.stage-state.clear { color: var(--accent); border-color: rgba(85, 227, 208, .25); background: rgba(85, 227, 208, .07); }
.stage-state.responding { color: #b9d5ff; border-color: rgba(135, 173, 255, .28); background: rgba(135, 173, 255, .08); }
.stage-frame { min-height: 0; flex: 1; display: flex; flex-direction: column; overflow: hidden; border: 1px solid var(--line-strong); border-radius: 15px; background: #081722; box-shadow: 0 18px 50px rgba(0,0,0,.18); }
.canvas-topline { flex: 0 0 32px; height: 32px; display: flex; align-items: center; justify-content: space-between; padding: 0 14px; border-bottom: 1px solid var(--line); color: #9cb3bd; font-size: 8px; letter-spacing: .15em; font-weight: 750; }
.canvas-topline-right { color: #67818d; font-weight: 600; }
.canvas-topline-right b { color: var(--accent); padding: 0 5px; }
.tiny-cross { display: inline-block; width: 7px; height: 7px; margin-right: 7px; position: relative; }
.tiny-cross::before, .tiny-cross::after { content: ""; position: absolute; background: var(--accent); }
.tiny-cross::before { width: 7px; height: 1px; top: 3px; }
.tiny-cross::after { height: 7px; width: 1px; left: 3px; }
#viz { display: block; width: 100%; min-height: 0; flex: 1; }
.canvas-legend { height: 31px; flex: 0 0 31px; display: flex; align-items: center; gap: clamp(8px, 1.7vw, 22px); padding: 0 14px; border-top: 1px solid var(--line); color: #8ba3af; font-size: 8px; letter-spacing: .03em; }
.canvas-legend > span { white-space: nowrap; }
.legend-dot { display: inline-block; width: 6px; height: 6px; margin-right: 5px; border-radius: 50%; vertical-align: 1px; }
.legend-dot.own { background: var(--accent); box-shadow: 0 0 7px var(--accent); }
.legend-dot.neighbour { background: var(--amber); box-shadow: 0 0 7px var(--amber); }
.legend-dot.receptor { background: #e9f6ff; box-shadow: 0 0 7px #e9f6ff; }
.legend-note { margin-left: auto; color: #5d7885; letter-spacing: .12em; font-size: 7px; }
.caption-panel { display: flex; align-items: center; gap: 12px; min-height: 76px; padding: 12px 15px; border: 1px solid var(--line); border-radius: 12px; background: linear-gradient(105deg, rgba(85,227,208,.055), rgba(13,29,40,.65) 40%); }
.caption-symbol { width: 29px; height: 29px; flex: 0 0 29px; display: flex; align-items: center; justify-content: center; gap: 3px; border-radius: 8px; border: 1px solid rgba(85,227,208,.22); background: rgba(85,227,208,.07); }
.caption-symbol span { width: 2px; border-radius: 3px; background: var(--accent); }
.caption-symbol span:nth-child(1) { height: 7px; opacity: .5; }
.caption-symbol span:nth-child(2) { height: 14px; }
.caption-symbol span:nth-child(3) { height: 9px; opacity: .7; }
.caption-copy { min-width: 0; flex: 1; }
.caption-label { color: var(--accent); font-size: 8px; font-weight: 800; letter-spacing: .14em; }
.caption-copy p { margin: 4px 0 0; color: #b8c9d0; font-size: 11px; line-height: 1.45; }
.caption-direction { flex: 0 0 112px; align-self: stretch; display: flex; flex-direction: column; justify-content: center; gap: 5px; padding-left: 12px; border-left: 1px solid var(--line); }
.caption-direction .caption-label { color: #78919d; font-size: 7px; }
.caption-direction strong { color: #d8e8eb; font-size: 10px; letter-spacing: .07em; }
.control-rail { min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 1px 2px 2px 0; scrollbar-width: thin; scrollbar-color: #294552 transparent; }
.rail-section { padding: 13px 14px; margin-bottom: 10px; border: 1px solid var(--line); border-radius: 12px; background: linear-gradient(145deg, rgba(14,32,45,.92), rgba(9,23,33,.92)); }
.section-heading { display: flex; align-items: center; justify-content: space-between; color: #a9c1cb; font-size: 8px; font-weight: 800; letter-spacing: .16em; margin-bottom: 11px; }
.section-index { color: #56717d; font-size: 8px; font-weight: 600; }
.preset-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.preset-button { display: flex; align-items: center; gap: 8px; min-width: 0; padding: 9px 8px; border: 1px solid var(--line); border-radius: 9px; background: rgba(4,14,21,.4); text-align: left; cursor: pointer; transition: border-color .18s ease, background .18s ease, transform .18s ease; }
.preset-button:hover { border-color: rgba(85,227,208,.42); transform: translateY(-1px); }
.preset-button.active { border-color: rgba(85,227,208,.5); background: rgba(85,227,208,.08); }
.preset-button b { display: block; color: #dce9ed; font-size: 9px; font-weight: 700; line-height: 1.2; }
.preset-button small { display: block; color: #718b97; font-size: 7px; margin-top: 4px; white-space: nowrap; }
.preset-glyph { width: 25px; height: 25px; flex: 0 0 25px; display: flex; align-items: center; justify-content: center; gap: 2px; border-radius: 7px; background: rgba(85,227,208,.08); }
.preset-glyph i { width: 2px; border-radius: 3px; background: var(--accent); }
.preset-glyph i:nth-child(1) { height: 7px; opacity: .5; }
.preset-glyph i:nth-child(2) { height: 15px; }
.preset-glyph i:nth-child(3) { height: 9px; opacity: .65; }
.clear-glyph { background: rgba(255,184,121,.08); }
.clear-glyph i { background: var(--amber); }
.clear-glyph i:nth-child(1) { height: 12px; }
.clear-glyph i:nth-child(2) { height: 5px; }
.clear-glyph i:nth-child(3) { height: 15px; }
.controls-section { padding-bottom: 10px; }
.control-list { display: flex; flex-direction: column; gap: 10px; }
.control-row { min-width: 0; }
.control-label-line { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin-bottom: 5px; }
.control-label-line label { color: #d1e0e4; font-size: 10px; font-weight: 600; }
.control-label-line output { color: var(--accent); font-size: 10px; font-weight: 700; font-variant-numeric: tabular-nums; }
input[type="range"] { appearance: none; -webkit-appearance: none; width: 100%; height: 14px; margin: 0; background: transparent; cursor: pointer; touch-action: pan-y; }
input[type="range"]::-webkit-slider-runnable-track { height: 3px; border-radius: 5px; background: linear-gradient(90deg, rgba(85,227,208,.75), rgba(85,227,208,.16)); }
input[type="range"]::-moz-range-track { height: 3px; border-radius: 5px; background: linear-gradient(90deg, rgba(85,227,208,.75), rgba(85,227,208,.16)); }
input[type="range"]::-webkit-slider-thumb { appearance: none; -webkit-appearance: none; width: 12px; height: 12px; margin-top: -4.5px; border: 2px solid #07121b; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 1px rgba(85,227,208,.65), 0 0 9px rgba(85,227,208,.4); }
input[type="range"]::-moz-range-thumb { width: 9px; height: 9px; border: 2px solid #07121b; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 1px rgba(85,227,208,.65), 0 0 9px rgba(85,227,208,.4); }
input:focus-visible, button:focus-visible, summary:focus-visible { outline: 2px solid #a4fff1; outline-offset: 3px; }
.range-ends { display: flex; justify-content: space-between; color: #617d89; font-size: 7px; font-variant-numeric: tabular-nums; margin-top: 1px; }
.range-ends em { color: #547b7d; font-style: normal; font-size: 6px; letter-spacing: .1em; }
.toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 12px; padding-top: 11px; border-top: 1px solid var(--line); cursor: pointer; }
.toggle-copy b { display: block; color: #d2e1e5; font-size: 10px; }
.toggle-copy small { display: block; color: #718b97; font-size: 8px; margin-top: 3px; }
.toggle-row input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.toggle-ui { width: 34px; height: 19px; flex: 0 0 34px; border-radius: 99px; background: #243b47; border: 1px solid #3c5964; position: relative; transition: background .18s ease; }
.toggle-ui::after { content: ""; position: absolute; width: 11px; height: 11px; top: 3px; left: 3px; border-radius: 50%; background: #9bb0b8; transition: transform .18s ease, background .18s ease; }
.toggle-row input:checked + .toggle-ui { background: rgba(85,227,208,.25); border-color: rgba(85,227,208,.6); }
.toggle-row input:checked + .toggle-ui::after { transform: translateX(15px); background: var(--accent); box-shadow: 0 0 8px rgba(85,227,208,.5); }
.toggle-row input:focus-visible + .toggle-ui { outline: 2px solid #a4fff1; outline-offset: 3px; }
.measurement-section { padding-bottom: 11px; }
.metrics-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.metric-card { min-width: 0; padding: 9px 9px 8px; border: 1px solid rgba(155,190,204,.12); border-radius: 8px; background: rgba(3,13,20,.42); }
.metric-label { color: #718c98; font-size: 7px; font-weight: 800; letter-spacing: .1em; white-space: nowrap; }
.metric-label i { color: #4d7778; font-style: normal; font-size: 5px; letter-spacing: .07em; margin-left: 3px; }
.metric-value { color: #e7f3f5; font-size: 20px; font-weight: 650; letter-spacing: -.05em; margin-top: 4px; font-variant-numeric: tabular-nums; }
.metric-value small { color: #83a0aa; font-size: 10px; font-weight: 500; letter-spacing: 0; }
.metric-foot { color: #6d8792; font-size: 7px; margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.check-card { margin-top: 8px; padding: 9px 10px; border: 1px solid rgba(85,227,208,.18); border-radius: 8px; background: rgba(85,227,208,.045); }
.check-top { display: flex; align-items: center; gap: 6px; color: #85aaa9; font-size: 7px; font-weight: 800; letter-spacing: .1em; }
.check-icon { width: 13px; height: 13px; display: inline-flex; align-items: center; justify-content: center; border-radius: 50%; color: #07121b; background: var(--accent); font-size: 9px; font-weight: 900; }
.check-tag { margin-left: auto; color: var(--accent); font-size: 6px; }
.check-result { margin-top: 7px; color: #d8eeec; font-size: 11px; font-weight: 650; font-variant-numeric: tabular-nums; }
.check-result span { color: #6f8b95; font-size: 8px; font-weight: 500; padding: 0 4px; }
.check-detail { margin-top: 3px; color: #6f8994; font-size: 7px; }
.action-section { padding-bottom: 10px; }
.action-row { display: grid; grid-template-columns: 1.2fr 1fr 34px 34px; gap: 6px; }
.action-button { min-height: 34px; display: flex; align-items: center; justify-content: center; gap: 6px; padding: 0 8px; border: 1px solid var(--line-strong); border-radius: 8px; background: rgba(4,14,21,.45); color: #a8bec6; font-size: 9px; font-weight: 700; cursor: pointer; transition: background .18s ease, border-color .18s ease, color .18s ease; }
.action-button:hover { border-color: rgba(85,227,208,.4); color: var(--text); }
.action-button.primary { border-color: rgba(85,227,208,.5); background: rgba(85,227,208,.14); color: var(--accent); }
.action-button.primary:hover { background: rgba(85,227,208,.21); }
.play-icon { font-size: 12px; }
.icon-action { font-size: 15px; }
.quality-row { display: flex; align-items: center; justify-content: space-between; margin-top: 11px; color: #68838f; font-size: 7px; font-weight: 800; letter-spacing: .12em; }
.quality-switch { display: flex; padding: 2px; border: 1px solid var(--line); border-radius: 7px; background: rgba(2,12,19,.5); }
.quality-switch button { border: 0; border-radius: 5px; padding: 4px 8px; color: #718a95; background: transparent; font-size: 7px; font-weight: 800; letter-spacing: .08em; cursor: pointer; }
.quality-switch button[aria-pressed="true"] { color: var(--accent); background: rgba(85,227,208,.12); }
.science-panel { margin: 0 0 9px; border: 1px solid var(--line); border-radius: 12px; background: rgba(11,26,37,.94); overflow: hidden; }
.science-panel summary { display: flex; align-items: center; gap: 9px; padding: 13px 14px; list-style: none; cursor: pointer; color: #bdd0d7; font-size: 8px; font-weight: 800; letter-spacing: .16em; }
.science-panel summary::-webkit-details-marker { display: none; }
.science-icon { width: 19px; height: 19px; display: inline-flex; align-items: center; justify-content: center; border: 1px solid rgba(85,227,208,.3); border-radius: 6px; color: var(--accent); font-size: 13px; }
.science-chevron { margin-left: auto; color: #6e8994; font-size: 15px; transition: transform .18s ease; }
.science-panel[open] .science-chevron { transform: rotate(180deg); }
.science-content { padding: 0 14px 14px; color: #9fb4bd; font-size: 9px; line-height: 1.55; }
.science-kicker { color: var(--accent); font-size: 7px; font-weight: 800; letter-spacing: .14em; }
.science-content h2 { color: #e0ecef; font-size: 15px; letter-spacing: -.02em; margin: 5px 0 7px; }
.science-content p { margin: 6px 0 10px; }
.equation-block { display: grid; gap: 6px; margin: 10px 0; }
.equation-block > div { padding: 7px 8px; border: 1px solid var(--line); border-radius: 6px; background: rgba(2,12,19,.45); }
.equation-block span { display: block; color: #6f9698; font-size: 6px; font-weight: 800; letter-spacing: .12em; margin-bottom: 3px; }
.equation-block code { color: #c8e7e4; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 8px; white-space: normal; overflow-wrap: anywhere; }
.science-facts { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin: 10px 0; }
.science-facts > div { padding: 8px; border-left: 2px solid var(--accent); background: rgba(85,227,208,.05); }
.science-facts b { display: block; color: #bde9e2; font-size: 7px; letter-spacing: .06em; }
.science-facts span { display: block; color: #7e99a4; font-size: 7px; line-height: 1.45; margin-top: 4px; }
.science-content h3 { color: #d5e4e8; font-size: 10px; margin: 12px 0 5px; }
.science-content ul { padding-left: 16px; margin: 5px 0 11px; }
.science-content li { padding-left: 2px; margin: 4px 0; }
.selection-note, .reference-note { display: grid; gap: 4px; padding: 8px; margin-top: 7px; border: 1px solid var(--line); border-radius: 7px; background: rgba(3,13,20,.38); }
.selection-note b, .reference-note b { color: #7ea8a7; font-size: 7px; letter-spacing: .1em; }
.selection-note span, .reference-note span { color: #829aa4; font-size: 7px; }
.disclaimer { color: #647e88; font-size: 7px; margin: 10px 0 0 !important; }
.rail-footer { display: flex; justify-content: space-between; padding: 2px 5px 6px; color: #48636f; font-size: 6px; font-weight: 750; letter-spacing: .14em; }

@media (max-width: 980px) {
  .layout { grid-template-columns: minmax(0,1fr) 320px; padding: 14px; gap: 12px; }
  .topbar { padding: 0 18px; }
  .preset-button { padding: 8px 6px; gap: 6px; }
  .preset-button b { font-size: 8px; }
  .preset-button small { font-size: 6px; }
}
@media (max-width: 760px) {
  .app { min-height: 100vh; }
  .topbar { height: 56px; flex-basis: 56px; padding: 0 13px; }
  .brand-mark { width: 26px; height: 26px; }
  .brand-sub { font-size: 7px; }
  .topbar-meta { display: none; }
  .layout { display: flex; flex-direction: column; padding: 10px 10px 18px; gap: 10px; }
  .stage-column { min-height: 520px; gap: 9px; }
  .stage-heading { min-height: 48px; }
  .stage-heading h1 { font-size: 18px; }
  .stage-state { padding: 7px 8px; font-size: 7px; }
  .stage-frame { min-height: 380px; }
  .canvas-topline { flex-basis: 27px; height: 27px; padding: 0 10px; font-size: 7px; }
  .canvas-legend { height: auto; min-height: 30px; flex-basis: auto; flex-wrap: wrap; gap: 7px 12px; padding: 6px 10px; font-size: 7px; }
  .legend-note { display: none; }
  .caption-panel { min-height: 75px; padding: 10px; gap: 9px; }
  .caption-copy p { font-size: 10px; }
  .caption-direction { flex-basis: 90px; padding-left: 8px; }
  .caption-direction strong { font-size: 8px; }
  .control-rail { overflow: visible; padding: 0; }
  .rail-section { padding: 12px; }
  .preset-button b { font-size: 9px; }
  .preset-button small { font-size: 7px; }
}
@media (max-width: 420px) {
  .topbar-right { gap: 0; }
  .live-indicator { font-size: 8px; }
  .stage-heading h1 { font-size: 16px; }
  .stage-state { gap: 5px; padding: 6px 7px; letter-spacing: .06em; }
  .stage-column { min-height: 495px; }
  .stage-frame { min-height: 355px; }
  .caption-direction { flex-basis: 82px; }
  .preset-button { gap: 6px; }
  .preset-glyph { width: 22px; height: 22px; flex-basis: 22px; }
}
html.embed-mode { height: 100vh; height: 100dvh; overflow: hidden; }
body.embed-mode { position: fixed; inset: 0; width: 100%; height: 100vh; height: 100dvh; overflow: hidden; }
body.embed-mode .app { height: 100%; min-height: 0; overflow: hidden; }
body.embed-mode .layout { height: calc(100% - 68px); overflow: hidden; }
body.embed-mode .stage-column { overflow: hidden; }
body.embed-mode .control-rail { overflow-y: auto; }
@media (max-width: 760px) {
  body.embed-mode .layout { display: grid; grid-template-columns: minmax(0,1fr); grid-template-rows: minmax(320px, 1fr) minmax(250px, 37%); gap: 9px; padding: 8px 9px 9px; }
  body.embed-mode .stage-column { min-height: 0; }
  body.embed-mode .stage-frame { min-height: 0; }
  body.embed-mode .control-rail { min-height: 0; overflow-y: auto; }
  body.embed-mode .rail-section { margin-bottom: 7px; }
  body.embed-mode .caption-panel { min-height: 66px; }
  body.embed-mode .science-panel { margin-bottom: 7px; }
}
@media (max-width: 420px) {
  body.embed-mode .topbar { height: 52px; flex-basis: 52px; }
  body.embed-mode .layout { height: calc(100% - 52px); grid-template-rows: minmax(300px, 1fr) minmax(250px, 39%); }
  body.embed-mode .stage-heading { min-height: 40px; }
  body.embed-mode .stage-heading h1 { font-size: 15px; }
  body.embed-mode .stage-frame { min-height: 0; }
  body.embed-mode .canvas-legend { min-height: 25px; padding: 4px 7px; gap: 5px 9px; }
  body.embed-mode .caption-panel { min-height: 60px; padding: 7px; }
  body.embed-mode .caption-copy p { font-size: 9px; }
  body.embed-mode .caption-symbol { width: 24px; height: 24px; flex-basis: 24px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}
