:root {
  color-scheme: dark;
  --ink: #f1f6f5;
  --muted: #b2c3c7;
  --line: #344951;
  --panel: #15252c;
  --accent: #ffcc76;
  --accent-dark: #312718;
  --mint: #94deca;
  font: 100%/1.45 system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--ink);
  background: #101a20;
}
* {box-sizing: border-box}
body {margin: 0}
h1,h2,h3,p {margin: 0}
button,select,summary {font: inherit}
button,select {min-height: 40px; padding: .52rem .9rem; color: var(--ink); background: #21343d; border: 1px solid #455d68; border-radius: .5rem; font-size: .92rem; font-weight: 660}
button,summary,select {cursor: pointer}
button:hover:not(:disabled),select:hover {background-color: #314954; border-color: #8da6ad}
button:active:not(:disabled) {transform: translateY(1px)}
button:disabled {opacity: .58; cursor: default}
button[aria-pressed=true] {background: #26483f; color: #c8fae7; border-color: #619787}
:focus-visible {outline: 3px solid var(--accent); outline-offset: 3px}
[hidden],body.clean .console,body.clean .after {display: none!important}
.wrap {width: min(96%,1750px); margin-inline: auto}
.masthead {background: #111e25; border-bottom: 1px solid var(--line)}
.mast-inner {display: flex; align-items: center; gap: 1rem; min-height: 56px}
.brand {display: inline-flex; align-items: center; gap: .28em; font-weight: 720; text-decoration: none; color: #fbfbf7}
.brand img {width: 28px; height: 28px; margin-right: .35em}
.brand span {color: var(--muted)}
.masthead h1 {border-left: 1px solid var(--line); padding-left: 1rem; font-size: 1rem; font-weight: 580; color: var(--muted)}
.vr {margin-left: auto; color: #ffe4ac; background: #483c2a; border-color: #856d47}
.workspace {display: grid; grid-template-columns: minmax(0,1fr) minmax(268px,328px); gap: .9rem; padding-top: .9rem; align-items: start}
.clean .workspace {grid-template-columns: minmax(0,1fr)}
.stage-card,.console,.after article {border: 1px solid var(--line); background: var(--panel); border-radius: 12px}
.stage-card {overflow: hidden; margin-bottom: .65rem}
.stage-header,.transport,.console-header,.section-label,.detail-bar {display: flex; align-items: center; justify-content: space-between; gap: .8rem}
.stage-header {padding: .65rem 1rem; border-bottom: 1px solid var(--line)}
.plant-title {display: flex; align-items: baseline; flex-wrap: wrap; gap: .25rem .9rem}
.plant-title h2 {font-size: clamp(1.15rem,2.2vw,1.6rem); line-height: 1.2; letter-spacing: -.036em}
.plant-title span {color: var(--muted); font-size: .87rem}
#panels {white-space: nowrap}
.viewport {position: relative; isolation: isolate; height: clamp(340px,calc(100svh - 270px),980px); background: #587076; overflow: hidden}
.scene,.scene canvas {position: absolute; inset: 0; width: 100%; height: 100%; display: block}
.scene canvas {touch-action: none; cursor: grab}
.scene canvas.dragging {cursor: grabbing}
.stage-overlay,.zoom-control,.scene-status {position: absolute; z-index: 1}
.stage-overlay {top: .85rem; left: .85rem; pointer-events: none}
.run-badge,.zoom-control,.scene-status {border: 1px solid #7a929b; color: #f3fafc; border-radius: 7px; background: #12212bf2}
.run-badge {display: inline-flex; align-items: center; gap: .55rem; font-size: .88rem; font-weight: 670; padding: .35rem .65rem}
.run-badge i {width: .65rem; height: .65rem; border-radius: 50%; background: #f5c264}
.run-badge.on i {background: #76e1ab}
.run-badge.emergency i,body.emergency .run-badge i {background: #ff6d64}
.zoom-control {right: .85rem; top: .85rem; display: flex; flex-direction: column; overflow: hidden}
.zoom-control button {font-size: 1.35rem; line-height: 1; background: transparent; border: 0; border-radius: 0; width: 44px; min-height: 42px}
.zoom-control button + button {border-top: 1px solid #58707d}
.zoom-control button:focus-visible {outline-offset: -3px}
.scene-status {top: 50%; left: 50%; transform: translate(-50%,-50%); width: max-content; max-width: 90%; padding: .7rem 1.1rem; text-align: center; pointer-events: none}
.transport {justify-content: flex-start; flex-wrap: wrap; padding: .7rem 1rem; border-top: 1px solid var(--line)}
.main-controls {display: flex; flex-wrap: wrap; gap: .45rem}
.primary,.primary:hover:not(:disabled) {color: var(--accent-dark); background: var(--accent); border-color: var(--accent)}
.primary:hover:not(:disabled) {background: #ffe1a6}
#emergency {border-color: #b7625e; color: #ffcbc3; background: #3b282b}
#emergency:hover:not(:disabled) {background: #593032; border-color: #e68779}
.guide {color: #d7e6e8; font-size: .95rem; flex: 1 1 16rem}
.progress-track {display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 1px; background: #30434b; border-top: 1px solid var(--line)}
.progress-track div {display: flex; align-items: center; justify-content: center; gap: .5rem; padding: .45rem .25rem; background: #1c2c34; color: #c0cdd0; font-size: .87rem; font-weight: 620}
.progress-track b {width: .5rem; height: .5rem; border: 1px solid #8da0a8; border-radius: 50%}
.progress-track .current {color: #ffe1aa; background: #413826}
.progress-track .current b {background: var(--accent); border-color: var(--accent)}
.progress-track .finished b {background: var(--mint); border-color: var(--mint)}
.scene-hint {padding: .32rem 1rem; color: var(--muted); text-align: center; font-size: .81rem}
.console,.after article {padding: 1rem}
.console h2,.after h2 {font-size: 1.2rem; letter-spacing: -.025em}
.console h3,.console summary {font-size: 1rem; font-weight: 660}
.option-section {padding-top: .8rem; margin-top: .8rem; border-top: 1px solid var(--line)}
.console p,.after p {color: #bacbd0; font-size: .96rem; margin-top: .3rem}
.scenarios,.tour,.control-actions {display: flex; gap: .35rem; flex-wrap: wrap; margin: .55rem 0}
.scenarios button,.tour button,.control-actions button {min-height: 36px; padding: .35rem .58rem; font-size: .88rem}
.subhead {font-size: .73rem; letter-spacing: .055em; color: var(--mint)}
.section-label span,.select-label {font-size: .85rem; color: var(--muted)}
.items,.counts {display: grid; gap: .28rem; margin-top: .5rem}
.item-button,.count-row {display: grid; grid-template-columns: .6rem 1fr auto; gap: .5rem; align-items: center; text-align: left}
.dot {width: .5rem; height: .5rem; border-radius: 50%; background: var(--item-color)}
.count-row {font-size: .9rem; color: var(--muted)}
.count-row strong {color: var(--ink)}
#activity,.live-reading {color: var(--accent); font-size: .88rem; margin-top: .5rem}
.after {display: grid; grid-template-columns: 1.45fr 1fr; gap: .9rem; margin-bottom: 1rem}
.select-label {display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; margin: .6rem 0}
select {max-width: 100%}
@media(max-width:840px) {
  .workspace {grid-template-columns: 1fr}
  .after {margin-top: .9rem}
  .viewport {height: clamp(300px,56svh,660px)}
}
@media(max-width:620px) {
  .wrap {width: 100%}
  .mast-inner {padding: .45rem .65rem; min-height: 54px; gap: .5rem}
  .masthead h1 {position: absolute; width: 1px; height: 1px; clip-path: inset(50%); overflow: hidden}
  .brand {font-size: .86rem}
  .brand img {width: 22px; margin-right: .15rem}
  .vr {font-size: .82rem; padding-inline: .6rem}
  .workspace {padding-top: 0; gap: .5rem}
  .stage-card {border-radius: 0; border-inline-width: 0}
  .stage-header,.transport {padding: .65rem}
  .plant-title {display: block}
  .plant-title span {font-size: .78rem}
  #panels {font-size: .85rem; padding-inline: .55rem}
  .viewport {height: clamp(270px,49svh,590px)}
  .main-controls {display: grid; grid-template-columns: 1fr 1fr; width: 100%; gap: .35rem}
  #primary {grid-column: 1/-1}
  .main-controls button {min-height: 43px; padding-inline: .32rem; font-size: .9rem}
  .transport {gap: .5rem}
  .guide {font-size: .9rem}
  .progress-track div {font-size: .74rem; gap: .2rem}
  .scene-hint {padding: .35rem .5rem}
  .after {grid-template-columns: 1fr; gap: .5rem}
  .after,.console {margin-inline: .65rem}
}
@media (max-width:355px) {.brand span {display: none}}
@media (max-height:530px) and (orientation:landscape) {
  .mast-inner {min-height: 45px}
  .viewport {height: clamp(170px,55svh,300px)}
  .scene-hint {display: none}
}


.instrument-strip {display:flex; align-items:center; justify-content:space-between; gap:.45rem; padding:.15rem .75rem; border-top:1px solid var(--line); background:#111f25}
.instrument-strip .run-badge {border:0; background:transparent; padding:.3rem .2rem; font-weight:560}
.lens {display:flex; align-items:center; gap:.05rem}
.lens button {background:transparent; border:0; font-size:1.3rem; min-width:40px; padding:.15rem .5rem}
.lens #fit-view {font-size:.84rem; font-weight:560; margin-right:.4rem; color:var(--muted)}
.lens output {font-size:.82rem; text-align:center; min-width:3.4rem; font-variant-numeric:tabular-nums; color:var(--mint)}
#emergency[aria-pressed=true] {color:white; background:#893a39; border-color:#f28a7c}
.scene canvas[data-hit=true] {cursor:pointer}
.transport {align-items:center}
@media(max-width:620px){
  .instrument-strip {padding:0 .35rem}
  .lens button {min-width:34px}
  .lens #fit-view {padding:.2rem;margin:0}
  .lens output {min-width:2.9rem}
  .instrument-strip .run-badge {font-size:.78rem}
}

.stage-tools{display:flex;align-items:center;gap:.45rem}
#focus-view{background:transparent;color:var(--muted);border-color:transparent}
body.focus-mode .masthead,body.focus-mode .after,body.focus-mode .console,body.focus-mode #panels,body.focus-mode .scene-hint,body.focus-mode .progress-track,body.focus-mode #fit-view,body.focus-mode .plant-title span{display:none!important}
body.focus-mode main.wrap{width:100%}
body.focus-mode .workspace{display:block;padding:0}
body.focus-mode .stage-card{height:100dvh;min-height:0;overflow:auto;display:flex;flex-direction:column;margin:0;border:0;border-radius:0}
body.focus-mode .viewport{flex:1 0 130px;min-height:130px;height:auto}
@media(max-width:620px){.stage-tools{gap:.2rem}.stage-tools button{font-size:.8rem;padding-inline:.4rem}.stage-header{gap:.3rem}}

.tour-guide { flex:1 1 18rem; }
.tour-guide .guide { margin:0; }
#tour-caption { color:#90e8c9; font-size:.86rem; font-weight:700; }
#tour-caption:not([hidden]) { display:block; margin-bottom:.2rem; }

.stage-tools{flex-wrap:wrap;justify-content:flex-end}
.stage-tools .vr{margin-left:0}
#focus-view{border-color:#4f6974;color:#ecf4f3}
.stage-card:fullscreen{width:100%;height:100%;background:var(--panel)}
body.focus-mode .stage-header{position:sticky;top:0;z-index:2;background:var(--panel)}
.tour{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:.42rem}
.tour .station-card{display:flex;align-items:center;gap:.48rem;text-align:left;min-height:56px;padding:.42rem;background:var(--station-bg);border:1px solid transparent;border-left:3px solid var(--station-accent)}
.tour .station-card[aria-pressed=true]{border-color:var(--station-accent);color:white}
.station-card .station-icon{width:23px;height:23px;flex-shrink:0}
.station-copy strong,.station-copy small{display:block;line-height:1.25}
.station-copy small{font-size:.78rem;color:#e2ecee;font-weight:450;margin-top:.15rem}
@media(max-width:690px){.stage-header{align-items:flex-start;flex-wrap:wrap}.stage-tools{justify-content:flex-start}.stage-tools button{min-height:38px}}
@media(max-height:460px){body.focus-mode .tour-guide{display:none}}
