:root {
  color-scheme: dark;
  --bg: #050608;
  --panel: rgba(11, 14, 19, 0.8);
  --panel-solid: #0b0e13;
  --line: rgba(255, 255, 255, 0.08);
  --line-2: rgba(255, 255, 255, 0.14);
  --text: #e9edf2;
  --muted: #8a94a3;
  --dim: #5b6472;
  --accent: #6fd6ff;
  --accent-soft: rgba(111, 214, 255, 0.12);
  --warm: #ffb45e;
  --serif: 'Instrument Serif', 'Cormorant Garamond', Georgia, serif;
  --sans: 'IBM Plex Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, 'SF Mono', Menlo, monospace;
  --left: 350px;
  --right: 348px;
  --det-h: clamp(170px, 27vh, 250px);
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.5 var(--sans); -webkit-font-smoothing: antialiased; }
body { overflow: hidden; }
[hidden] { display: none !important; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
em { font-style: italic; color: var(--accent); }
b { font-weight: 600; color: #fff; }
kbd { font: 11px var(--mono); padding: 1px 5px; border: 1px solid var(--line-2); border-radius: 4px; color: var(--muted); }

#gl { position: fixed; inset: 0; width: 100vw; height: 100vh; display: block; touch-action: none; }
body::after { content: ''; position: fixed; inset: 0; pointer-events: none; background: radial-gradient(ellipse at 50% 45%, transparent 55%, rgba(0, 0, 0, 0.55)); }
#labels { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 1; }
.lbl { position: absolute; left: 0; top: 0; opacity: 0; display: flex; align-items: center; gap: 6px; transition: opacity 0.3s; font: 500 10.5px var(--mono); letter-spacing: 0.02em; color: #cfe9f5; white-space: nowrap; }
.lbl i { width: 18px; height: 1px; background: rgba(111, 214, 255, 0.6); position: relative; }
.lbl i::before { content: ''; position: absolute; left: -3px; top: -2px; width: 5px; height: 5px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 6px var(--accent); }
.lbl span { background: rgba(5, 7, 10, 0.66); padding: 2px 7px; border-radius: 4px; border: 1px solid rgba(111, 214, 255, 0.18); pointer-events: auto; cursor: pointer; transition: border-color 0.15s, background 0.15s; }
.lbl span:hover, .lbl span:focus-visible, .lbl.active span { border-color: var(--accent); background: rgba(12, 30, 40, 0.9); color: #fff; outline: none; }
.lbl.off span { pointer-events: none; }
.lede .hint { display: block; margin-top: 8px; color: var(--accent); font-size: 12.5px; }
.lbl.left { flex-direction: row-reverse; transform-origin: right; }
.lbl.left i::before { left: auto; right: -3px; }
.lbl.left { translate: -100% 0; }
.lbl { translate: 0 -50%; }
.lbl.left { translate: -100% -50%; }

.eyebrow { margin: 0 0 10px; font: 500 10.5px var(--mono); letter-spacing: 0.18em; text-transform: uppercase; color: var(--muted); }
.muted { color: var(--muted); }

.hero { position: fixed; top: 24px; left: 30px; width: 330px; z-index: 2; pointer-events: none; }
.hero h1 { margin: 0 0 12px; font: 400 50px/0.98 var(--serif); letter-spacing: -0.01em; }
.hero h1 em { display: block; }
.lede { margin: 0; color: #b5bdc8; font-size: 13.5px; max-width: 300px; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); z-index: 3; }

.modes { position: fixed; top: 16px; left: calc(var(--left) + (100vw - var(--left) - var(--right)) / 2); transform: translateX(-50%); z-index: 3; display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 10px; padding: 5px 8px 6px; max-width: calc(100vw - var(--left) - var(--right) - 20px); background: var(--panel); border: 1px solid var(--line); border-radius: 12px; backdrop-filter: blur(14px); }
.grp small { display: block; font: 500 8.5px var(--mono); letter-spacing: 0.16em; text-transform: uppercase; color: var(--dim); padding: 0 0 2px 8px; }
.grp > div { display: flex; gap: 2px; }
.modes button { position: relative; padding: 5px 16px 5px 9px; border-radius: 8px; font: 600 12.5px var(--sans); color: var(--muted); transition: background 0.2s, color 0.2s; white-space: nowrap; }
.modes button kbd { position: absolute; top: 3px; right: 3px; font-size: 8px; padding: 0 2px; border: 0; color: var(--dim); }
.modes button:hover { color: var(--text); background: rgba(255, 255, 255, 0.04); }
.modes button.on { color: var(--text); background: var(--accent-soft); box-shadow: inset 0 0 0 1px rgba(111, 214, 255, 0.35); }

.chead { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.chead .eyebrow { margin: 0; }
.icons { display: flex; gap: 6px; }
.icons button { width: 30px; height: 30px; display: grid; place-items: center; border-radius: 10px; background: var(--panel); border: 1px solid var(--line); color: var(--muted); }
.icons button:hover { color: var(--text); border-color: var(--line-2); }
.icons svg { width: 17px; height: 17px; }

.explain { position: fixed; left: 14px; bottom: 14px; width: calc(var(--left) - 24px); max-height: calc(100vh - 300px); overflow-y: auto; padding: 18px 20px 16px; scrollbar-width: thin; }
.explain h2, .modal h2 { margin: 0 0 10px; font: 400 29px/1.05 var(--serif); }
.explain .body { color: #c3cad3; font-size: 13.3px; }
.explain .body b { color: #fff; }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 14px; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); }
.stats div { min-width: 0; }
.stats small { display: block; font: 500 9.5px var(--mono); letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); }
.stats b { display: block; font: 500 15px var(--mono); color: #fff; margin: 3px 0 1px; }
.stats span { display: block; font-size: 11px; color: var(--muted); line-height: 1.3; }
.change { margin-top: 14px; padding: 11px 13px; border-radius: 10px; background: linear-gradient(135deg, rgba(111, 214, 255, 0.09), rgba(111, 214, 255, 0.02)); border: 1px solid rgba(111, 214, 255, 0.2); }
.change small { display: block; font: 500 9.5px var(--mono); letter-spacing: 0.14em; text-transform: uppercase; color: var(--accent); margin-bottom: 4px; }
.change p { margin: 0; font-size: 12.8px; color: #d2d8e0; }
.change .warn { color: var(--warm); }
.change .ok { color: #7ee2a8; }
.change.flash { animation: flash 0.9s ease-out; }
@keyframes flash { 0% { box-shadow: 0 0 0 0 rgba(111, 214, 255, 0.45); border-color: rgba(111, 214, 255, 0.7); } 100% { box-shadow: 0 0 0 14px rgba(111, 214, 255, 0); } }

.detector { position: fixed; bottom: 14px; left: calc(var(--left) + 4px); right: calc(var(--right) + 18px); max-width: 820px; margin-inline: auto; padding: 10px 12px 12px; }
.dhead { display: flex; align-items: center; gap: 8px; white-space: nowrap; overflow: hidden; font: 500 10.5px var(--mono); letter-spacing: 0.1em; text-transform: uppercase; margin-bottom: 8px; color: var(--text); }
.dhead .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 8px var(--accent); animation: pulse 1.6s infinite; }
.dhead .sp { flex: 1; }
.dhead #secTitle { overflow: hidden; text-overflow: ellipsis; }
@keyframes pulse { 50% { opacity: 0.35; } }
.dbody { display: flex; gap: 10px; height: var(--det-h); }
#detMain { height: 100%; aspect-ratio: 1; border-radius: 8px; background: #000; cursor: grab; touch-action: none; }
#detMain:active { cursor: grabbing; }
body[data-mode='4d'] #detMain { cursor: crosshair; }
#detSec { flex: 1; min-width: 0; height: 100%; border-radius: 8px; background: #06080b; touch-action: none; }
body[data-mode='eels'] #detSec, body[data-mode='4d'] #detSec { cursor: ew-resize; }
body[data-mode='eds'] #detSec, body[data-mode='bse'] #detSec { cursor: pointer; }

.controls { position: fixed; top: 14px; right: 14px; bottom: 14px; width: calc(var(--right) - 14px); overflow-y: auto; padding: 16px 16px 20px; scrollbar-width: thin; scrollbar-color: rgba(255, 255, 255, 0.12) transparent; }
.clarity { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 6px; }
.clarity button { text-align: left; padding: 10px 11px; border-radius: 10px; border: 1px solid var(--line); background: rgba(255, 255, 255, 0.02); transition: all 0.2s; }
.clarity button b { display: block; font-size: 12.5px; font-weight: 600; color: var(--muted); }
.clarity button small { display: block; font-size: 11px; color: var(--dim); line-height: 1.3; margin-top: 2px; }
.clarity button.on { border-color: rgba(111, 214, 255, 0.45); background: var(--accent-soft); }
.clarity button.on b { color: #fff; }
.clarity button.on small { color: #a9c7d6; }
h3.sec { margin: 20px 0 10px; padding-top: 14px; border-top: 1px solid var(--line); font: 500 10.5px var(--mono); letter-spacing: 0.18em; text-transform: uppercase; color: var(--muted); }
.ctl { margin-bottom: 12px; }
.ctl .row { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-bottom: 2px; }
.ctl label { font-size: 13px; font-weight: 500; color: #dfe4ea; }
.ctl .val { font: 500 12.5px var(--mono); color: var(--accent); white-space: nowrap; }
.ctl .ends { display: flex; justify-content: space-between; font: 10.5px var(--sans); color: var(--dim); margin-top: -2px; }
.ctl .ends span:nth-child(2) { text-align: center; }
.ctl .note { margin: 4px 0 0; font-size: 11px; color: var(--dim); }
input[type='range'] { -webkit-appearance: none; appearance: none; width: 100%; height: 22px; background: transparent; margin: 0; cursor: pointer; --p: 50%; }
input[type='range']:focus { outline: none; }
input[type='range']::-webkit-slider-runnable-track { height: 2px; border-radius: 2px; background: linear-gradient(to right, var(--accent) var(--p), rgba(255, 255, 255, 0.14) var(--p)); }
input[type='range']::-webkit-slider-thumb { -webkit-appearance: none; width: 15px; height: 15px; margin-top: -6.5px; border-radius: 50%; background: #0b0e12; border: 2px solid var(--accent); box-shadow: 0 0 10px rgba(111, 214, 255, 0.45); }
input[type='range']::-moz-range-track { height: 2px; background: rgba(255, 255, 255, 0.14); }
input[type='range']::-moz-range-progress { height: 2px; background: var(--accent); }
input[type='range']::-moz-range-thumb { width: 12px; height: 12px; border-radius: 50%; background: #0b0e12; border: 2px solid var(--accent); }
input[type='range']:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 4px rgba(111, 214, 255, 0.3); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { padding: 5px 11px; border-radius: 99px; border: 1px solid var(--line-2); font-size: 12px; color: #c3cad3; transition: all 0.15s; }
.chips.small .chip { font-size: 11px; padding: 3px 9px; }
.chip:hover { border-color: rgba(111, 214, 255, 0.4); color: #fff; }
.chip.on { border-color: var(--accent); background: var(--accent-soft); color: #fff; }
.buttons { display: flex; gap: 8px; }
.btn { flex: 1; padding: 7px 10px; border-radius: 9px; border: 1px solid var(--line-2); font-size: 12px; color: #c3cad3; background: rgba(255, 255, 255, 0.02); }
.btn:hover { border-color: rgba(111, 214, 255, 0.45); color: #fff; }
.toggles { display: flex; flex-wrap: wrap; gap: 8px; }
.toggles.grid { display: grid; grid-template-columns: 1fr 1fr; }
.tog { display: flex; align-items: center; gap: 9px; padding: 8px 10px; border-radius: 9px; border: 1px solid var(--line); font-size: 12.5px; color: #c3cad3; text-align: left; }
.tog i { width: 24px; height: 13px; border-radius: 99px; background: rgba(255, 255, 255, 0.12); position: relative; flex: none; transition: background 0.2s; }
.tog i::after { content: ''; position: absolute; top: 2px; left: 2px; width: 9px; height: 9px; border-radius: 50%; background: #8a94a3; transition: all 0.2s; }
.tog.on { border-color: rgba(111, 214, 255, 0.35); color: #fff; }
.tog.on i { background: rgba(111, 214, 255, 0.35); }
.tog.on i::after { left: 13px; background: var(--accent); }
.exp { display: flex; gap: 13px; align-items: center; width: 100%; padding: 12px 13px; margin-bottom: 8px; text-align: left; border-radius: 11px; border: 1px solid var(--line); background: rgba(255, 255, 255, 0.02); transition: all 0.2s; }
.exp:hover { border-color: rgba(111, 214, 255, 0.35); }
.exp.on { border-color: var(--accent); background: var(--accent-soft); }
.exp.disabled { opacity: 0.4; pointer-events: none; }
.exp .ico { flex: none; width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; border: 1px solid rgba(111, 214, 255, 0.3); color: var(--accent); }
.exp .ico svg { width: 22px; height: 22px; }
.exp b { display: block; font-size: 13.5px; }
.exp small { display: block; font-size: 11.5px; color: var(--muted); line-height: 1.35; margin-top: 2px; }
table.data { width: 100%; border-collapse: collapse; font-size: 12px; }
table.data td { padding: 6px 0; border-bottom: 1px solid var(--line); color: var(--muted); }
table.data td:last-child { text-align: right; font: 12px var(--mono); color: var(--text); }

.status { font: 10px var(--mono); color: var(--dim); letter-spacing: 0.04em; text-transform: none; }

.tourcap { position: fixed; top: 92px; left: calc(var(--left) + (100vw - var(--left) - var(--right)) / 2); transform: translateX(-50%); width: min(460px, calc(100vw - var(--left) - var(--right) - 40px)); z-index: 4; padding: 14px 18px; border-radius: 12px; background: rgba(8, 11, 15, 0.86); border: 1px solid rgba(111, 214, 255, 0.3); backdrop-filter: blur(10px); }
.tourcap small { font: 10px var(--mono); color: var(--accent); letter-spacing: 0.14em; }
.tourcap b { display: block; font: 400 24px/1.1 var(--serif); margin: 2px 0 6px; }
.tourcap p { margin: 0; font-size: 13px; color: #c3cad3; }
.tourcap.in { animation: capIn 0.6s ease-out; }
@keyframes capIn { from { opacity: 0; transform: translate(-50%, 8px); } }

.modal { position: fixed; inset: 0; z-index: 10; display: grid; place-items: center; background: rgba(0, 0, 0, 0.55); padding: 20px; }
.modal .card { position: relative; width: min(640px, 100%); max-height: calc(100vh - 40px); overflow-y: auto; padding: 24px 28px; background: var(--panel-solid); }
.modal ul { padding-left: 18px; margin: 0 0 18px; }
.modal li { margin-bottom: 8px; color: #c3cad3; font-size: 13.5px; }
.modal p { color: #c3cad3; font-size: 13.5px; }
.modal .close { position: absolute; top: 12px; right: 16px; font-size: 24px; color: var(--muted); }

/* ------------------------------------------------ narrow screens: stack everything */
body.stacked { overflow-y: auto; }
body.stacked #gl { position: relative; height: 62vh; }
body.stacked::after { display: none; }
body.stacked #labels { position: absolute; top: 0; left: 0; right: 0; height: 62vh; }
body.stacked .hero { position: absolute; top: 16px; left: 16px; width: auto; right: 16px; }
body.stacked .hero h1 { font-size: 34px; }
body.stacked .hero .lede { display: none; }

body.stacked .modes, body.stacked .explain, body.stacked .detector, body.stacked .controls { position: static; transform: none; width: auto; max-height: none; margin: 12px 16px; }
body.stacked #detMain { aspect-ratio: 1; }
body.stacked .dhead #secTitle { display: none; }
body.stacked .modes { flex-wrap: wrap; justify-content: center; }
body.stacked .grp > div { flex-wrap: wrap; }
body.stacked .detector { max-width: none; }
body.stacked .dbody { flex-direction: column; height: auto; }
body.stacked #detMain { width: 100%; height: auto; }
body.stacked #detSec { width: 100%; height: 220px; flex: none; }
body.stacked .tourcap { position: fixed; top: auto; bottom: 16px; left: 50%; width: calc(100vw - 32px); }

/* ------------------------------------------------ component (instrument physics) card */
.comp { position: fixed; z-index: 6; width: 360px; max-height: min(620px, calc(100vh - 40px)); overflow-y: auto; padding: 18px 20px 16px; background: rgba(9, 12, 16, 0.95); border-color: rgba(111, 214, 255, 0.3); box-shadow: 0 18px 50px rgba(0, 0, 0, 0.55); scrollbar-width: thin; animation: capIn2 0.25s ease-out; }
@keyframes capIn2 { from { opacity: 0; transform: translateY(6px); } }
.comp .close { position: absolute; top: 10px; right: 14px; font-size: 22px; color: var(--muted); }
.comp h3 { margin: 0 0 8px; font: 400 27px/1.05 var(--serif); padding-right: 20px; }
.comp h4 { margin: 14px 0 5px; font: 500 9.5px var(--mono); letter-spacing: 0.14em; text-transform: uppercase; color: var(--accent); }
.comp p { margin: 0; font-size: 12.8px; color: #c7ced7; }
.comp .role { color: #e3e8ee; font-size: 13.3px; }
.comp table.kv { width: 100%; border-collapse: collapse; font-size: 12px; }
.comp table.kv td { padding: 4px 0; border-bottom: 1px solid var(--line); color: var(--muted); vertical-align: top; }
.comp table.kv td:last-child { text-align: right; font: 12px var(--mono); color: var(--text); padding-left: 10px; }
.comp table.live td:last-child { color: var(--accent); }
body.stacked .comp { left: 12px !important; right: 12px; top: auto !important; bottom: 12px; width: auto; max-height: 70vh; }
.comp .eyebrow { padding-right: 28px; }
