/* Deepwatch styles. Colours come only from theme tokens (see js/themes.js). */
:root { --scrim: color-mix(in srgb, var(--bg) 80%, transparent); }
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg); background-image: var(--bg-image); background-attachment: fixed;
  color: var(--text);
  font-family: 'Inter', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  font-variant-numeric: tabular-nums; font-feature-settings: 'tnum' 1, 'cv11' 1;
  font-size: 16px; line-height: 1.35; overflow: hidden; -webkit-font-smoothing: antialiased;
}
body.gated #title-screen, body.gated #game-root, body.gated #end-screen { display: none; }
h1, h2, h3, p, ul, ol, fieldset, figure { margin: 0; padding: 0; }
ul, ol { list-style: none; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.muted { color: var(--text3); }
.pad { padding: 12px; }
.grow { flex: 1; }
:focus-visible { outline: var(--ring) solid var(--focus); outline-offset: 2px; }
#app { height: 100vh; height: 100dvh; }

/* State icons: colour comes from the state token; the silhouette is what carries the state */
.state-icon { display: inline-block; flex: none; vertical-align: middle; }
.state-healthy { color: var(--healthy); } .state-caution { color: var(--caution); }
.state-alert { color: var(--alert); } .state-critical { color: var(--critical); }

/* Buttons and switches (min 44px touch targets) */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; min-width: 44px; padding: 0 16px;
  background: var(--surface2); border: var(--bw) solid var(--border); border-radius: 10px; font-weight: 600; }
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--btn); color: var(--on-accent); border-color: var(--btn); }
.btn.danger { border-color: var(--critical); }
.btn.big { min-height: 56px; padding: 0 28px; font-size: 1.125rem; }
.btn.small { min-height: 44px; padding: 0 12px; font-size: 0.875rem; }
.icon-btn { padding: 0; width: 44px; font-size: 1.35rem; position: relative; }
.icon-btn .dot { position: absolute; top: 7px; right: 7px; width: 10px; height: 10px; border-radius: 50%; background: var(--accent); border: 2px solid var(--surface2); }
.switch { display: inline-flex; align-items: center; gap: 10px; min-height: 44px; min-width: 92px; padding: 4px 12px 4px 6px;
  background: var(--surface2); border: var(--bw) solid var(--border); border-radius: 999px; font-weight: 700; font-size: 0.875rem; }
.switch-knob { width: 28px; height: 28px; border-radius: 50%; background: var(--text3); flex: none; }
.switch[aria-checked="true"] { border-color: var(--accent); }
.switch[aria-checked="true"] .switch-knob { background: var(--accent); order: 2; }
.switch[aria-checked="true"] { flex-direction: row-reverse; padding: 4px 6px 4px 12px; }

/* ---------- Size gate ---------- */
.size-gate { position: fixed; inset: 0; z-index: 1000; display: grid; place-items: center; text-align: center; background: var(--bg); padding: 32px; }
.size-gate i { font-size: 4rem; color: var(--accent); display: block; margin-bottom: 16px; }
.size-gate h1 { font-size: 2rem; margin-bottom: 8px; }
.size-gate p { color: var(--text2); max-width: 32rem; margin: 0 auto; }

/* ---------- Title ---------- */
.title-screen { height: 100%; display: grid; place-items: center; padding: 24px; overflow: auto; }
.title-card { position: relative; width: min(760px, 100%); background: var(--surface); border: var(--bw) solid var(--border); border-radius: 20px; padding: 36px 40px; text-align: center; }
.title-top { position: absolute; top: 12px; right: 12px; }
.title-mark { font-size: 3.2rem; color: var(--accent); line-height: 1; }
.title-card h1 { font-size: clamp(2.4rem, 7vh, 3.4rem); letter-spacing: -0.02em; margin: 6px 0 8px; }
.tagline { color: var(--text2); max-width: 36rem; margin: 0 auto 22px; font-size: 1.05rem; }
.diff { border: 0; display: flex; gap: 12px; justify-content: center; margin-bottom: 22px; }
.diff legend { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.diff-opt { flex: 1; cursor: pointer; }
.diff-opt input { position: absolute; opacity: 0; pointer-events: none; }
.diff-card { display: flex; flex-direction: column; gap: 4px; height: 100%; padding: 14px 12px; background: var(--surface2); border: var(--bw) solid var(--border); border-radius: 12px; }
.diff-card b { font-size: 1.15rem; }
.diff-card small { color: var(--text2); font-size: 0.8125rem; }
.diff-card .best { color: var(--text3); }
.diff-opt input:checked + .diff-card { border: calc(var(--bw) * 2) solid var(--accent); background: color-mix(in srgb, var(--accent) var(--tint), var(--surface2)); }
.diff-opt input:focus-visible + .diff-card { outline: var(--ring) solid var(--focus); outline-offset: 2px; }
.title-actions { display: flex; gap: 14px; justify-content: center; margin-bottom: 14px; }
.warn { color: var(--alert); font-weight: 600; margin-bottom: 10px; }
.title-foot { display: flex; gap: 12px; justify-content: center; margin-top: 18px; }

/* ---------- Game shell ---------- */
#game-root, .game { height: 100%; }
.game { display: flex; flex-direction: column; position: relative; min-height: 0; }
.topbar { display: flex; align-items: center; gap: 16px; padding: 6px 14px; background: var(--surface); border-bottom: var(--bw) solid var(--border); flex: none; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 1.1rem; color: var(--text2); }
.brand i { color: var(--accent); font-size: 1.4rem; }
.clock { font-weight: 700; font-size: 1.25rem; padding: 0 12px; border-left: var(--bw) solid var(--border); border-right: var(--bw) solid var(--border); }
.overall { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.1rem; flex: 1; min-width: 0; }
.overall span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.actions { display: flex; gap: 8px; }
.stage { flex: 1; min-height: 0; position: relative; display: flex; }

.crit-bar { display: flex; align-items: center; gap: 12px; padding: 8px 16px; background: color-mix(in srgb, var(--critical) 26%, var(--surface)); border-bottom: calc(var(--bw) * 3) solid var(--critical); font-size: 1.05rem; flex: none; }
.crisis-banner { flex: none; display: flex; align-items: center; gap: 14px; padding: 8px 16px;
  background: color-mix(in srgb, var(--critical) 30%, var(--surface)); border-bottom: calc(var(--bw) * 3) solid var(--critical); }
.crisis-banner svg { flex: none; }
.crisis-title { font-size: 1.1rem; font-weight: 800; letter-spacing: 0.02em; }
.crisis-sub { font-size: 0.9375rem; margin-top: 1px; }

/* ---------- Dashboard tiles ---------- */
.dashboard { flex: 1; min-width: 0; min-height: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); grid-template-rows: repeat(3, minmax(0, 1fr)); gap: 10px; padding: 10px; }
.tile { display: flex; flex-direction: column; gap: 4px; min-width: 0; min-height: 0; padding: clamp(6px, 1.4vh, 12px) 14px; text-align: left;
  background: var(--surface); border: var(--bw) solid var(--border); border-radius: 14px; overflow: hidden; }
.tile:hover { border-color: var(--accent); }
.tile-head { display: flex; align-items: center; gap: 8px; flex: none; }
.tile-icon { font-size: 1.25rem; color: var(--text3); }
.tile-name { font-weight: 700; font-size: clamp(0.95rem, 2.2vh, 1.15rem); flex: 1; }
.tile-badge { display: inline-flex; }
.tile-body { display: flex; align-items: center; gap: 10px; flex: 1; min-height: 0; }
.tile-gauge { height: 100%; aspect-ratio: 1; flex: none; min-height: 0; }
.tile-arc { width: 100%; height: 100%; overflow: visible; }
.arc-num { font-weight: 700; fill: var(--text); font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.arc-num.nosig { fill: var(--caution); letter-spacing: 0.04em; }
.arc-unit { fill: var(--text2); font-weight: 500; }
.tile-side { display: flex; flex-direction: column; align-items: flex-end; text-align: right; gap: 2px; flex: 1; min-width: 0; }
.side-label { font-size: clamp(0.72rem, 1.6vh, 0.85rem); color: var(--text2); overflow-wrap: anywhere; }
.side-val { font-size: clamp(1rem, 2.6vh, 1.35rem); font-weight: 700; }
.side-true, .card-true { font-size: 0.75rem; color: var(--text3); }
.tile-spark { align-self: stretch; height: clamp(16px, 4.5vh, 34px); margin-top: 4px; }
.spark { width: 100%; height: 100%; display: block; }
.spark-line { stroke: var(--c1); }

/* Healthy tiles are quiet; Caution and above get stronger treatment */
.tile[data-state="caution"] { border-color: var(--caution); background: color-mix(in srgb, var(--caution) var(--tint), var(--surface)); }
.tile[data-state="alert"] { border: calc(var(--bw) * 2) solid var(--alert); background: color-mix(in srgb, var(--alert) var(--tint), var(--surface)); }
.tile[data-state="critical"] { border: calc(var(--bw) * 3) solid var(--critical); background: color-mix(in srgb, var(--critical) var(--tint), var(--surface)); animation: crit-pulse 2s ease-in-out infinite; }
@keyframes crit-pulse { 50% { box-shadow: 0 0 0 4px color-mix(in srgb, var(--critical) 35%, transparent); } }

.station-tile { cursor: default; }
.station-tile:hover { border-color: var(--border); }
.station-tile[data-state="caution"]:hover { border-color: var(--caution); }
.station-body { flex: 1; min-height: 0; overflow: hidden; display: flex; flex-direction: column; gap: 6px; }
.station-status { font-weight: 700; font-size: clamp(1rem, 2.6vh, 1.3rem); }
.notices { display: flex; flex-direction: column; gap: 3px; font-size: clamp(0.8rem, 1.8vh, 0.95rem); color: var(--text2); }
.notices li { display: flex; align-items: center; gap: 6px; }
.station-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex: none; }
.station-day { color: var(--text2); font-size: 0.875rem; }

/* Meters: every shape takes its level colour from --mc (set by state); shape and fill amount carry the level too */
.meter { display: block; --mc: var(--accent); }
.meter[data-state="caution"] { --mc: var(--caution); }
.meter[data-state="alert"] { --mc: var(--alert); }
.meter[data-state="critical"] { --mc: var(--critical); }
.arc-track { stroke: var(--border); }
.arc-value { stroke: var(--mc); }
.arc-dot { fill: var(--text); }
.m-well { fill: var(--surface2); }
.m-outline { fill: none; stroke: var(--text3); stroke-width: 2.2; }
.m-rim { stroke-width: 4; }
.m-fill { fill: var(--mc); }
.m-seg { fill: var(--border); }
.m-seg.on { fill: var(--mc); }
.m-seg-line, .m-seg-line.on { fill: none; }
.m-seg-line { stroke: var(--border); }
.m-seg-line.on { stroke: var(--mc); }
.m-nub { fill: var(--text3); }
.m-tick { stroke: var(--surface); stroke-opacity: 0.8; }
.m-axis { stroke: var(--text3); }
.m-needle { stroke: var(--text); }
.m-hub { fill: var(--text); }
.m-chip { fill: var(--surface); fill-opacity: 0.9; stroke: var(--border); stroke-width: 0.8; }
.ring-healthy { stroke: var(--healthy); opacity: 0.4; }
.ring-caution { stroke: var(--caution); } .ring-alert { stroke: var(--alert); } .ring-critical { stroke: var(--critical); }

/* ---------- Event log ---------- */
.logpanel { position: absolute; z-index: 20; top: 0; right: 0; bottom: 0; width: min(380px, 40vw); display: flex; flex-direction: column;
  background: var(--surface); border-left: calc(var(--bw) * 2) solid var(--border); }
.logpanel-head { display: flex; align-items: center; justify-content: space-between; padding: 8px 12px 0 16px; }
.logpanel-head h2 { font-size: 1.15rem; }
.logpanel-note { padding: 0 16px 8px; color: var(--text2); font-size: 0.8125rem; }
.loglist { overflow: auto; flex: 1; padding: 0 8px 12px; }
.log-entry { display: grid; grid-template-columns: 20px 62px 1fr; gap: 8px; align-items: start; padding: 7px 8px; border-bottom: var(--bw) solid var(--border); font-size: 0.9rem; }
.log-entry time { color: var(--text3); font-size: 0.78rem; padding-top: 2px; }
.log-glyph { color: var(--text3); font-size: 1.1rem; }
.log-entry.sev-3 { font-weight: 700; }

.pause-overlay { position: absolute; inset: 0; z-index: 40; display: grid; place-items: center; background: var(--scrim); }
.pause-card { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 28px 40px; background: var(--surface); border: calc(var(--bw) * 2) solid var(--accent); border-radius: 18px; text-align: center; }
.pause-card i { font-size: 3rem; color: var(--accent); }
.pause-card h2 { font-size: 2.2rem; letter-spacing: 0.12em; }
.pause-card p { color: var(--text2); }

/* ---------- Detail screen ---------- */
.detail { flex: 1; min-width: 0; min-height: 0; display: grid; grid-template-columns: 170px minmax(0, 1fr); }
.strip { display: flex; flex-direction: column; gap: 4px; padding: 8px; overflow: auto; background: var(--surface); border-right: var(--bw) solid var(--border); }
.strip-item { display: grid; grid-template-columns: 22px 1fr 18px; grid-template-areas: "i n s" "i v s"; column-gap: 8px; align-items: center; min-height: 44px; padding: 4px 8px; text-align: left;
  background: transparent; border: var(--bw) solid transparent; border-radius: 10px; }
.strip-item:hover { border-color: var(--border); }
.strip-item.active { background: var(--surface2); border-color: var(--accent); }
.strip-icon { grid-area: i; color: var(--text3); font-size: 1.15rem; }
.strip-name { grid-area: n; font-weight: 600; font-size: 0.875rem; line-height: 1.1; }
.strip-val { grid-area: v; font-size: 0.78rem; color: var(--text2); line-height: 1.1; }
.strip-state { grid-area: s; display: inline-flex; }
.strip-item[data-state="caution"] { border-color: var(--caution); } .strip-item[data-state="alert"] { border-color: var(--alert); border-width: calc(var(--bw) * 2); }
.strip-item[data-state="critical"] { border-color: var(--critical); border-width: calc(var(--bw) * 3); }

.detail-main { min-width: 0; min-height: 0; overflow: auto; padding: 12px 16px 20px; display: flex; flex-direction: column; gap: 12px; }
.detail-head { display: flex; align-items: center; gap: 12px; }
.detail-head h2 { font-size: 1.6rem; }
.detail-icon { font-size: 1.8rem; color: var(--accent); }
.detail-state { display: inline-flex; align-items: center; gap: 8px; font-weight: 700; font-size: 1.1rem; margin-left: 8px; }
.detail-grid { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.col-left, .col-right { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.readouts { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; }
.card { background: var(--surface); border: var(--bw) solid var(--border); border-radius: 12px; padding: 10px 12px; }
.card[data-state="caution"] { border-color: var(--caution); background: color-mix(in srgb, var(--caution) var(--tint), var(--surface)); }
.card[data-state="alert"] { border: calc(var(--bw) * 2) solid var(--alert); background: color-mix(in srgb, var(--alert) var(--tint), var(--surface)); }
.card[data-state="critical"] { border: calc(var(--bw) * 3) solid var(--critical); background: color-mix(in srgb, var(--critical) var(--tint), var(--surface)); }
.card-top { display: flex; justify-content: space-between; align-items: center; min-height: 22px; }
.card-label { color: var(--text2); font-size: 0.875rem; font-weight: 600; }
.card-body { display: flex; align-items: center; gap: 10px; margin-top: 4px; }
.card-body-bar { flex-direction: column; align-items: flex-start; }
.card-body-gauge { justify-content: center; margin-top: 0; }
.card-arc { width: clamp(92px, 17vh, 128px); height: clamp(92px, 17vh, 128px); flex: none; overflow: visible; }
.card-val { display: flex; align-items: baseline; gap: 4px; flex-wrap: wrap; }
.card-val .val { font-size: 2rem; font-weight: 700; line-height: 1; }
.card-val .val.nosig { font-size: 1.1rem; color: var(--caution); }
.card-val .unit { color: var(--text2); font-size: 0.9rem; }
.bar { width: 100%; height: 8px; border-radius: 4px; background: var(--surface2); border: var(--bw) solid var(--border); overflow: hidden; order: 2; }
.bar i { display: block; height: 100%; background: var(--accent); }
.charts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.chart-card { background: var(--surface); border: var(--bw) solid var(--border); border-radius: 12px; padding: 8px 10px; min-width: 0; }
.chart-card figcaption { font-size: 0.8125rem; font-weight: 600; color: var(--text2); margin-bottom: 2px; }
.chart { width: 100%; height: auto; display: block; }
.chart-line { stroke: var(--c1); } .chart-dot { fill: var(--c1); }
.chart-axis { fill: var(--text3); font-size: 10px; font-family: inherit; }
.chart-grid { stroke: var(--border); stroke-width: 0.6; stroke-dasharray: 2 4; }

.col-left > section, .col-right > section, .col-right > details { background: var(--surface); border: var(--bw) solid var(--border); border-radius: 12px; padding: 12px 14px; }
.col-left h3, .col-right h3 { font-size: 0.8125rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text2); margin-bottom: 8px; }
.col-right h3.sub { margin-top: 16px; }
.recent summary { display: flex; align-items: center; gap: 8px; min-height: 44px; margin: -12px -14px; padding: 12px 14px; cursor: pointer; list-style: none; border-radius: 12px;
  font-size: 0.8125rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text2); }
.recent summary::-webkit-details-marker { display: none; }
.recent summary::before { content: ''; width: 0; height: 0; border-left: 7px solid currentColor; border-top: 5px solid transparent; border-bottom: 5px solid transparent; transition: transform 0.15s; }
.recent[open] summary::before { transform: rotate(90deg); }
.recent[open] summary { margin-bottom: 0; }
.recent summary:hover { color: var(--text); }
.recent summary:focus-visible { outline: var(--ring) solid var(--focus); outline-offset: 2px; }
.recent-count { font-weight: 500; letter-spacing: 0; text-transform: none; color: var(--text3); }
.recent[open] .recent-list { margin-top: 14px; }
.ctl { margin-bottom: 14px; }
.ctl:last-child { margin-bottom: 0; }
.ctl-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.ctl-head label { font-weight: 700; }
.ctl-vals { font-size: 0.875rem; color: var(--text2); }
.ctl-vals b { color: var(--text); }
.hint { color: var(--text3); font-size: 0.8125rem; margin-top: 4px; }
.fader { position: relative; height: 44px; --thumb: 28px; --f: 0; }
.fader input { -webkit-appearance: none; appearance: none; width: 100%; height: 44px; margin: 0; background: transparent; cursor: pointer; }
.fader input::-webkit-slider-runnable-track { height: 12px; border-radius: 6px; background: var(--surface2); border: var(--bw) solid var(--border); }
.fader input::-moz-range-track { height: 12px; border-radius: 6px; background: var(--surface2); border: var(--bw) solid var(--border); }
.fader input::-webkit-slider-thumb { -webkit-appearance: none; width: var(--thumb); height: var(--thumb); margin-top: -10px; border-radius: 50%; background: var(--accent); border: 3px solid var(--surface); box-shadow: 0 0 0 var(--bw) var(--accent); }
.fader input::-moz-range-thumb { width: var(--thumb); height: var(--thumb); border-radius: 50%; background: var(--accent); border: 3px solid var(--surface); }
.fader input:focus-visible { outline: var(--ring) solid var(--focus); outline-offset: 2px; border-radius: 8px; }
.fader-ghost { position: absolute; top: 50%; left: calc(var(--thumb) / 2 + (100% - var(--thumb)) * var(--f)); width: 5px; height: 26px; border-radius: 2px; background: var(--text); transform: translate(-50%, -50%); pointer-events: none; transition: left 0.25s linear; }
/* ---------- Control variety: knob / valve wheel, vertical fader, step selector, lever, guarded switch, two-step button ---------- */
.knob-wrap { display: flex; justify-content: center; padding: 6px 0 2px; }
.knob { width: 124px; height: 124px; touch-action: none; cursor: grab; overflow: visible; border-radius: 50%; -webkit-tap-highlight-color: transparent; }
.knob:active { cursor: grabbing; }
.knob:focus-visible { outline: var(--ring) solid var(--focus); outline-offset: 6px; }
.k-track { stroke: var(--border); } .k-value { stroke: var(--accent); } .k-tick { stroke: var(--text3); }
.k-body { fill: var(--surface2); stroke: var(--text3); stroke-width: 2.5; }
.k-pointer-line { stroke: var(--accent); }
.k-rim, .k-spoke { stroke: var(--text3); } .k-rim { fill: none; } .k-hub { fill: var(--text3); } .k-pointer { fill: var(--accent); }
.k-ghost { fill: var(--text); stroke: var(--surface); stroke-width: 1.6; }
.overshooting .k-ghost { fill: var(--alert); }

.vfader-wrap { display: flex; justify-content: center; align-items: stretch; gap: 12px; margin: 6px 0; }
.vfader { position: relative; width: 44px; height: 168px; --thumb: 28px; --f: 0; flex: none; }
.vfader-rot { position: absolute; left: 0; top: 0; width: 168px; height: 44px; transform-origin: 0 0; transform: translateY(168px) rotate(-90deg); }
.vfader .fader-ghost { top: auto; left: 50%; width: 28px; height: 5px; bottom: calc(var(--thumb) / 2 + (100% - var(--thumb)) * var(--f)); transform: translate(-50%, 50%); transition: bottom 0.25s linear; }
.overshooting .vfader .fader-ghost { height: 7px; }
.vfader-scale { display: flex; flex-direction: column; justify-content: space-between; padding: 8px 0; font-size: 0.8125rem; font-weight: 600; color: var(--text2); }
.vfader-scale .mid { color: var(--text3); }

.steps { --n: 3; display: grid; grid-template-columns: repeat(var(--n), minmax(0, 1fr)); gap: 6px; margin-top: 6px; }
.step { position: relative; min-height: 58px; padding: 6px 2px 15px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0;
  background: var(--surface2); border: var(--bw) solid var(--border); border-radius: 10px; font-weight: 700; font-size: 0.875rem; }
.step:hover { border-color: var(--accent); }
.step:focus-visible { outline: var(--ring) solid var(--focus); outline-offset: 2px; }
.step-val { font-size: 0.72rem; font-weight: 500; color: var(--text2); }
.step[aria-checked="true"] { background: var(--btn); color: var(--on-accent); border-color: var(--btn); }
.step[aria-checked="true"] .step-val { color: inherit; }
.step.is-actual .step-actual { position: absolute; bottom: 3px; left: 50%; width: 0; height: 0; transform: translateX(-50%); border-left: 6px solid transparent; border-right: 6px solid transparent; border-bottom: 8px solid currentColor; }
.overshooting .step.is-actual .step-actual { border-bottom-width: 11px; }

.lever { display: inline-flex; align-items: center; gap: 12px; min-height: 80px; padding: 8px 14px; background: var(--surface2); border: var(--bw) solid var(--border); border-radius: 14px; font-weight: 700; font-size: 0.875rem; }
.lever-slot { position: relative; width: 22px; height: 62px; border-radius: 11px; background: var(--bg); border: var(--bw) solid var(--border); flex: none; }
.lever-handle { position: absolute; left: 50%; bottom: -5px; width: 38px; height: 26px; border-radius: 8px; background: var(--text3); border: 3px solid var(--surface2); transform: translateX(-50%); transition: bottom 0.15s; }
.lever[aria-checked="true"] { border-color: var(--accent); }
.lever[aria-checked="true"] .lever-handle { bottom: calc(100% - 21px); background: var(--btn); }
.lever .switch-text { min-width: 30px; text-align: left; }
.lever:focus-visible, .switch:focus-visible, .guard-cover:focus-visible { outline: var(--ring) solid var(--focus); outline-offset: 3px; }

.guard { position: relative; display: inline-block; }
.guard-cover { position: absolute; inset: -4px; z-index: 1; display: flex; align-items: center; justify-content: center; border-radius: 999px; cursor: pointer;
  border: calc(var(--bw) * 2) solid var(--alert); color: var(--text); font-weight: 800; font-size: 0.75rem; letter-spacing: 0.06em; text-transform: uppercase;
  background: repeating-linear-gradient(-45deg, color-mix(in srgb, var(--alert) 38%, var(--surface2)) 0 8px, var(--surface2) 8px 16px); }
.guard-cover[hidden] { display: none; }
.guard-text { padding: 2px 8px; border-radius: 6px; background: var(--surface2); }
.guard.is-armed .switch { box-shadow: 0 0 0 3px var(--alert); }
.job.is-armed { border: calc(var(--bw) * 2) solid var(--alert); background: repeating-linear-gradient(-45deg, color-mix(in srgb, var(--alert) 30%, var(--surface2)) 0 8px, var(--surface2) 8px 16px); }
.job.is-armed .job-label { background: var(--surface2); padding: 0 6px; border-radius: 4px; }
.job.is-armed .job-sub { background: var(--surface2); padding: 0 6px; border-radius: 4px; color: var(--text); font-weight: 700; margin-top: 2px; }
.ctl-pending { display: flex; align-items: center; gap: 8px; margin-top: 4px; padding: 6px 10px; border: var(--bw) dashed var(--accent); border-radius: 8px; font-size: 0.8125rem; font-weight: 600; flex-wrap: wrap; }
.pend-glyph { color: var(--accent); font-size: 1.1rem; }
.pbar { flex: 1 1 80px; height: 6px; background: var(--surface2); border-radius: 3px; overflow: hidden; border: var(--bw) solid var(--border); }
.pbar i { display: block; height: 100%; width: 0; background: var(--accent); }
.overshooting .fader-ghost { background: var(--alert); width: 7px; }
.job { position: relative; overflow: hidden; width: 100%; flex-direction: column; gap: 0; padding: 6px 14px; min-height: 52px; align-items: flex-start; justify-content: center; text-align: left; }
.job-bar { position: absolute; left: 0; top: 0; bottom: 0; width: 0; background: var(--accent); opacity: 0.28; }
.job-label, .job-sub { position: relative; }
.order-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.order-grid .ctl { margin-bottom: 0; }
.order-grid .hint:empty { display: none; }
.job-sub { font-size: 0.78rem; color: var(--text2); font-weight: 500; }
.job[aria-disabled="true"] { cursor: not-allowed; color: var(--text2); border-style: dashed; }
.job.small { min-height: 44px; width: auto; padding: 4px 10px; font-size: 0.8125rem; align-items: center; text-align: center; }
.link-row { display: flex; flex-wrap: wrap; gap: 8px; }
.link-chip { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 4px 12px; background: var(--surface2); border: var(--bw) solid var(--border); border-radius: 10px; font-size: 0.875rem; }
.link-chip:hover { border-color: var(--accent); }
.link-name small { color: var(--text2); } .link-val { font-weight: 700; }
.wear-row { display: flex; align-items: center; gap: 10px; }
.wearbar { flex: 1; height: 12px; border-radius: 6px; background: var(--surface2); border: var(--bw) solid var(--border); overflow: hidden; }
.wearbar i { display: block; height: 100%; background: var(--c1); }
.wearbar.high i { background: var(--alert); }
.recent-list li { display: grid; grid-template-columns: 62px 1fr; gap: 8px; padding: 5px 0; border-bottom: var(--bw) solid var(--border); font-size: 0.875rem; }
.recent-list time { color: var(--text3); font-size: 0.78rem; }
.sensor-table { margin-bottom: 14px; }
.sensor-row { display: grid; grid-template-columns: 1.1fr 1.4fr 0.8fr auto; gap: 8px; align-items: center; padding: 4px 0; border-bottom: var(--bw) solid var(--border); font-size: 0.8125rem; }
.sensor-head { color: var(--text2); font-weight: 700; text-transform: uppercase; font-size: 0.72rem; letter-spacing: 0.06em; }
.sensor-row.poor .sname { color: var(--caution); font-weight: 700; }
.shealth { display: flex; flex-direction: column; gap: 2px; }
.sact { display: flex; gap: 4px; }
.sv { font-variant-numeric: tabular-nums; }

/* ---------- Menu and theme picker ---------- */
.menu-host { position: absolute; z-index: 50; top: 0; right: 0; }
.title-card .menu-panel { position: absolute; top: 60px; right: 12px; text-align: left; }
.menu-panel { position: absolute; top: 56px; right: 8px; width: 380px; max-height: calc(100vh - 72px); overflow: auto; z-index: 60;
  background: var(--surface); border: calc(var(--bw) * 2) solid var(--border); border-radius: 14px; padding: 12px 14px; }
.menu-head { display: flex; justify-content: space-between; align-items: center; }
.menu-head h2 { font-size: 1.2rem; }
.menu-sec { padding: 10px 0; border-top: var(--bw) solid var(--border); margin-top: 8px; }
.menu-sec h3 { font-size: 0.8125rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text2); margin-bottom: 8px; }
.menu-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 6px; }
.menu-actions { display: flex; flex-direction: column; gap: 8px; }
.search { display: flex; align-items: center; gap: 8px; padding: 0 10px; min-height: 44px; background: var(--surface2); border: var(--bw) solid var(--border); border-radius: 10px; margin-bottom: 8px; }
.search input { flex: 1; min-width: 0; background: transparent; border: 0; outline: none; min-height: 40px; }
.search:focus-within { outline: var(--ring) solid var(--focus); outline-offset: 2px; }
.theme-current { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 44px; padding: 4px 12px; text-align: left; background: var(--surface2); border: var(--bw) solid var(--border); border-radius: 10px; }
.theme-current:hover { border-color: var(--accent); }
.theme-current[aria-expanded="true"] { border-color: var(--accent); }
.theme-caret { display: inline-flex; transition: transform 0.15s; }
.theme-current[aria-expanded="true"] .theme-caret { transform: rotate(180deg); }
.theme-drop { margin-top: 8px; }
.theme-drop[hidden] { display: none; }
@media (prefers-reduced-motion: reduce) { .theme-caret { transition: none; } }
.no-icons .theme-caret::after { content: '\25BE'; }
.theme-list { max-height: 34vh; overflow: auto; border: var(--bw) solid var(--border); border-radius: 10px; }
.group-title { position: sticky; top: 0; padding: 6px 12px; background: var(--surface2); color: var(--text2); font-size: 0.75rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; }
.theme-opt { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 44px; padding: 4px 12px; text-align: left; background: transparent; border: 0; border-bottom: var(--bw) solid var(--border); }
.theme-opt:hover, .theme-opt:focus-visible { background: var(--surface2); }
.theme-opt[aria-selected="true"] { font-weight: 700; }
.swatch { display: inline-flex; border: var(--bw) solid var(--border); border-radius: 6px; overflow: hidden; flex: none; }
.swatch i { width: 12px; height: 22px; display: block; }
.theme-name { flex: 1; }
.theme-check { color: var(--accent); font-size: 1.1rem; width: 20px; }
input[type="range"] { accent-color: var(--accent); }
.menu-row input[type="range"] { flex: 1; min-height: 44px; }

/* ---------- Debug ---------- */
.debug-panel { position: absolute; z-index: 45; left: 50%; bottom: 6px; transform: translateX(-50%); padding: 2px 10px; font-size: 0.8125rem;
  background: var(--surface); border: var(--bw) dashed var(--accent); border-radius: 10px; max-width: 440px; }
.debug-panel summary { cursor: pointer; font-weight: 700; min-height: 28px; display: flex; align-items: center; }
.debug-panel[open] { padding-bottom: 8px; display: flex; flex-direction: column; gap: 6px; }
.dbg-row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.dbg-row select { min-height: 36px; background: var(--surface2); border: var(--bw) solid var(--border); border-radius: 8px; }
.dbg-row [aria-pressed="true"] { background: var(--btn); color: var(--on-accent); }

/* ---------- End screen ---------- */
.end-screen { height: 100%; overflow: auto; padding: 24px; display: grid; place-items: start center; }
.end-card { width: min(1100px, 100%); background: var(--surface); border: var(--bw) solid var(--border); border-radius: 20px; padding: 28px 32px; }
.end-head { display: flex; align-items: center; gap: 16px; margin-bottom: 18px; }
.end-head h1 { font-size: 2.2rem; } .end-head p { color: var(--text2); }
.end-score { display: flex; gap: 40px; margin-bottom: 20px; padding: 14px 18px; background: var(--surface2); border-radius: 12px; }
.end-score div { display: flex; flex-direction: column; } .end-score span:last-child { color: var(--text2); font-size: 0.875rem; }
.big-num { font-size: 2.4rem; font-weight: 700; line-height: 1.1; }
.end-cols { display: grid; grid-template-columns: 1.2fr 1fr 1fr; gap: 20px; }
.end-cols h2 { font-size: 0.8125rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text2); margin-bottom: 8px; }
.chain li { display: grid; grid-template-columns: 70px 1fr; gap: 8px; padding: 6px 0; position: relative; }
.chain .arrow { position: absolute; left: 24px; top: -10px; color: var(--text3); font-size: 0.9rem; }
.chain .chain-t { color: var(--text3); font-size: 0.8rem; padding-top: 2px; } .chain li.final { font-weight: 700; }
.chain em { color: var(--text2); font-weight: 500; }
.endlog li { font-size: 0.85rem; padding: 4px 0; border-bottom: var(--bw) solid var(--border); } .endlog time { color: var(--text3); }
.stab li { display: grid; grid-template-columns: 120px 1fr 44px; align-items: center; gap: 8px; padding: 3px 0; font-size: 0.85rem; }
.stab-bar { height: 10px; background: var(--surface2); border: var(--bw) solid var(--border); border-radius: 5px; overflow: hidden; } .stab-bar i { display: block; height: 100%; background: var(--c1); }
.stab-v { text-align: right; font-weight: 700; }
.end-actions { display: flex; gap: 12px; margin-top: 24px; }

/* ---------- Walkthrough ---------- */
.tutorial-root { position: fixed; inset: 0; z-index: 500; }
.demo-stage { position: absolute; inset: 0; background: var(--bg); background-image: var(--bg-image); display: flex; flex-direction: column; }
.dim { position: absolute; background: var(--scrim); }
.spot-ring { position: absolute; border: 3px solid var(--accent); border-radius: 12px; pointer-events: none; }
.tut-card { position: absolute; width: min(430px, calc(100vw - 24px)); padding: 16px 18px; background: var(--surface); border: calc(var(--bw) * 2) solid var(--accent); border-radius: 14px; z-index: 5; }
.tut-card h2 { font-size: 1.3rem; margin: 2px 0 6px; } .tut-card p { color: var(--text2); }
.tut-count { color: var(--text3); font-size: 0.78rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; }
.tut-actions { display: flex; gap: 8px; align-items: center; margin-top: 12px; flex-wrap: wrap; }
.legend { display: flex; flex-direction: column; gap: 8px; margin: 6px 0 8px; } .legend li { display: flex; gap: 10px; align-items: center; }
.pulse-ok { outline: var(--ring) solid var(--focus); outline-offset: 2px; }
.demo-stage .menu-host { display: none; }

/* Icon font unreachable: show text labels instead of blank icon buttons */
.no-icons .ph { display: none; }
.no-icons .icon-btn { width: auto; padding: 0 12px; font-size: 0.875rem; }
.no-icons .icon-btn::after { content: attr(aria-label); font-weight: 600; }
.no-icons .theme-opt[aria-selected="true"] .theme-check::after { content: '\2713'; font-weight: 700; }
.no-icons .title-top .icon-btn::after { content: 'Menu'; }

/* Reduced motion: no pulsing, no sweeps */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
