/* ═══════════════════════════════════════════════════════════════════════════
   WARNER LEWIS — JET A1 FUEL FARM  ·  STYLES
   Design language: aviation SCADA / HMI control screen.
   ── Edit the tokens in :root to re-skin the whole page for branding. ──
   ═══════════════════════════════════════════════════════════════════════════ */

:root {
  /* ---- Palette — matched to the Al Majd · Warner Lewis logo ----
     Brand electric blue sampled from the logo glow (#34bcfb → #86f8ff);
     navy family sampled from the logo background (#204070 / #2a466e).
     Amber + safety-yellow are kept strictly functional (Jet A1 fuel / hazard). */
  --navy-900: #0a2239;   /* canvas — logo blue-navy, deepened   */
  --navy-850: #0d2a47;
  --panel:    #103257;   /* raised panels — logo mid navy       */
  --panel-2:  #0b2742;   /* inset displays                      */
  --steel:    #244c76;   /* structures, pipes — logo #204070 fam*/
  --steel-lt: #5181b0;   /* idle metal, lines                   */
  --fuel-blue:#34bef9;   /* logo electric blue (#34bcfb)        */
  --brand-glo:#86f8ff;   /* logo brightest glow                 */
  --jet-amber:#eb9a3c;   /* Jet A1 fuel (functional)            */
  --safety:   #f4c430;   /* hazard / handrail (functional)      */
  --ok:       #34d399;   /* valve open / OK                     */
  --alarm:    #f25555;   /* alarm / ESD                         */

  --text:     #e7f1fb;
  --text-dim: #9dbad6;
  --text-mut: #6a89a8;
  --line:     #163e63;   /* hairline borders  */
  --line-lt:  #245686;

  /* ---- Type ---- */
  --f-display: "Saira Condensed", "Arial Narrow", system-ui, sans-serif;
  --f-body:    "IBM Plex Sans", system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  --f-mono:    "IBM Plex Mono", ui-monospace, "Cascadia Code", Consolas, monospace;

  /* ---- Geometry / motion ---- */
  --r:   6px;             /* squared instrument radius */
  --r-s: 3px;
  --gap: clamp(10px, 1.4vw, 18px);
  --hud-h: clamp(58px, 8vh, 76px);
  --flow-speed: 1s;
  --ease: cubic-bezier(.4, .1, .2, 1);

  --shadow: 0 10px 30px -12px rgba(0,0,0,.7);
  --glow-blue: 0 0 14px rgba(52,190,249,.5);
}

/* ─────────────────────────── Reset / base ─────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--f-body);
  color: var(--text);
  background:
    radial-gradient(1100px 720px at 26% -14%, #1d5798 0%, transparent 55%),
    radial-gradient(1000px 680px at 86% 116%, #15406f 0%, transparent 60%),
    var(--navy-900);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow: hidden;
}
h1, h2, p, ol { margin: 0; }
button { font-family: inherit; color: inherit; cursor: pointer; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
:focus-visible {
  outline: 2px solid var(--fuel-blue);
  outline-offset: 2px;
  border-radius: var(--r-s);
}

/* ─────────────────────────── App grid ─────────────────────────── */
.app {
  display: grid;
  grid-template-rows: var(--hud-h) 1fr auto 4px;
  height: 100dvh;
  gap: 0;
}

/* ═══════════════════════ HUD / status bar ═══════════════════════ */
.hud {
  display: flex;
  align-items: center;
  gap: var(--gap);
  padding: 0 clamp(12px, 2vw, 26px);
  background: linear-gradient(180deg, #11315a, #0a2239);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 1px 0 rgba(255,255,255,.03) inset;
  min-width: 0;
}
.hud__brand { display: flex; align-items: center; gap: 10px; flex: 0 0 auto; }
/* Actual Al Majd · Warner Lewis logo, cropped to its artwork band and framed
   as a brand plate that sits naturally on the blue HUD. Swap the file in
   index.html (assets/) to rebrand. */
.hud__logo-img {
  height: clamp(38px, 5.6vh, 54px);
  width: clamp(152px, 16.5vw, 208px);
  object-fit: cover;
  object-position: 50% 45%;
  border: 1px solid var(--line-lt);
  border-radius: var(--r);
  box-shadow: inset 0 0 24px rgba(7,20,35,.5), 0 0 0 1px rgba(0,0,0,.2);
  background: #16365f;
}

.hud__title { flex: 1 1 auto; min-width: 0; padding-left: clamp(8px, 1.6vw, 22px); border-left: 1px solid var(--line); }
.hud__title h1 {
  font-family: var(--f-display); font-weight: 600;
  font-size: clamp(16px, 2vw, 24px); letter-spacing: .02em; line-height: 1;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.hud__title p { color: var(--text-dim); font-size: clamp(10px, 1.1vw, 12.5px); margin-top: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.hud__telemetry { display: flex; gap: 8px; flex: 0 0 auto; }
.chip {
  display: flex; flex-direction: column; gap: 1px;
  padding: 6px 11px; min-width: 74px;
  background: var(--panel-2); border: 1px solid var(--line);
  border-radius: var(--r); border-top-color: var(--line-lt);
}
.chip__k { font-size: 9.5px; letter-spacing: .1em; text-transform: uppercase; color: var(--text-mut); }
.chip__v { font-family: var(--f-mono); font-size: 15px; color: var(--text); display: flex; align-items: baseline; gap: 3px; }
.chip__v b { font-weight: 600; color: var(--fuel-blue); }
.chip__v i { font-style: normal; font-size: 10px; color: var(--text-mut); }
.chip--status { justify-content: center; }
.chip--status .chip__v { font-family: var(--f-display); font-size: 14px; letter-spacing: .08em; color: var(--text-dim); }
.status-led {
  width: 9px; height: 9px; border-radius: 50%; margin-right: 7px; display: inline-block;
  background: var(--steel-lt); box-shadow: 0 0 0 3px rgba(255,255,255,.04);
  vertical-align: middle;
}
/* status colours driven by [data-sys] on .app */
.app[data-sys="live"]  .status-led { background: var(--ok);    box-shadow: 0 0 10px var(--ok); animation: ledpulse 1.4s var(--ease) infinite; }
.app[data-sys="live"]  #t-status    { color: var(--ok); }
.app[data-sys="alarm"] .status-led { background: var(--alarm); box-shadow: 0 0 12px var(--alarm); animation: ledpulse .5s steps(2,end) infinite; }
.app[data-sys="alarm"] #t-status    { color: var(--alarm); }

/* ═══════════════════════ Workspace ═══════════════════════ */
.workspace {
  display: grid;
  grid-template-columns: clamp(248px, 23vw, 320px) 1fr;
  min-height: 0;
}

/* ───── Stage rail ───── */
.rail {
  display: flex; flex-direction: column; min-height: 0;
  border-right: 1px solid var(--line);
  background: linear-gradient(180deg, #0e2c4d, #0a2138);
}
.stages {
  list-style: none; padding: 12px; margin: 0;
  display: flex; flex-direction: column; gap: 4px;
  overflow: auto; flex: 1 1 auto; min-height: 0;
  scrollbar-width: thin; scrollbar-color: var(--steel) transparent;
}
.stage {
  display: grid; grid-template-columns: 30px 1fr; align-items: center; gap: 10px;
  width: 100%; text-align: left;
  padding: 9px 11px; border: 1px solid transparent; border-radius: var(--r);
  background: transparent; color: var(--text-dim);
  transition: background .2s, color .2s, border-color .2s;
}
.stage:hover { background: rgba(56,189,248,.06); color: var(--text); }
.stage__no {
  font-family: var(--f-mono); font-size: 12px; font-weight: 600; color: var(--text-mut);
  text-align: center; padding: 2px 0; border-right: 1px solid var(--line); transition: color .2s;
}
.stage__name { font-size: 13.5px; font-weight: 500; line-height: 1.15; }
.stage.is-current {
  background: linear-gradient(90deg, rgba(56,189,248,.16), rgba(56,189,248,.02));
  border-color: rgba(56,189,248,.4); color: var(--text);
}
.stage.is-current .stage__no { color: var(--fuel-blue); }
.stage.is-done .stage__no { color: var(--ok); }

/* ───── Readout panel ───── */
.readout {
  border-top: 1px solid var(--line);
  padding: 14px 16px 16px;
  background: var(--panel-2);
  flex: 0 0 auto;
}
.readout__head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.readout__step {
  font-family: var(--f-mono); font-size: 12px; font-weight: 600;
  color: var(--navy-900); background: var(--fuel-blue);
  padding: 3px 7px; border-radius: var(--r-s);
}
.readout__title { font-family: var(--f-display); font-weight: 600; font-size: 18px; letter-spacing: .01em; }
.readout__body { color: var(--text-dim); font-size: 13px; line-height: 1.5; min-height: 3.2em; }
.readout__flow {
  margin-top: 12px; padding-top: 11px; border-top: 1px dashed var(--line-lt);
  font-family: var(--f-mono); font-size: 10.5px; line-height: 1.55; color: var(--text-mut);
}
.readout__flow span {
  display: block; color: var(--safety); letter-spacing: .14em; text-transform: uppercase;
  font-family: var(--f-display); font-size: 11px; margin-bottom: 4px;
}

/* ───── Scene ───── */
.scene { position: relative; min-width: 0; min-height: 0; padding: var(--gap); display: flex; }
.scene__frame {
  position: relative; flex: 1 1 auto; min-height: 0;
  border: 1px solid var(--line-lt); border-radius: var(--r);
  background:
    linear-gradient(180deg, rgba(22,56,96,.45), rgba(9,28,48,.6)),
    repeating-linear-gradient(0deg, transparent 0 23px, rgba(120,200,255,.025) 23px 24px),
    repeating-linear-gradient(90deg, transparent 0 23px, rgba(120,200,255,.025) 23px 24px),
    var(--navy-900);
  box-shadow: var(--shadow), inset 0 0 60px rgba(0,0,0,.4);
  overflow: hidden;
}
.farm { display: block; width: 100%; height: 100%; }

/* corner registration ticks */
.tick { position: absolute; width: 14px; height: 14px; border: 2px solid var(--steel-lt); opacity: .7; }
.tick--tl { top: 7px; left: 7px;  border-right: 0; border-bottom: 0; }
.tick--tr { top: 7px; right: 7px; border-left: 0;  border-bottom: 0; }
.tick--bl { bottom: 7px; left: 7px;  border-right: 0; border-top: 0; }
.tick--br { bottom: 7px; right: 7px; border-left: 0;  border-top: 0; }

/* ═══════════════════════ SVG schematic styling ═══════════════════════ */

/* Pipework casing */
.pipe { fill: none; stroke: var(--steel); stroke-width: 9; stroke-linecap: round; stroke-linejoin: round; }
.pipe--buried { stroke: #21384a; stroke-dasharray: 1 0; }

/* Animated fuel flow (dashed stroke scrolled via dashoffset) */
.flow {
  fill: none; stroke-width: 4.5; stroke-linecap: round;
  stroke-dasharray: 9 15; stroke-dashoffset: 0;
  opacity: 0; transition: opacity .35s var(--ease);
  pointer-events: none;
}
.flow--raw   { stroke: var(--jet-amber); }
.flow--clean { stroke: var(--fuel-blue); filter: drop-shadow(0 0 4px rgba(56,189,248,.5)); }
.flow.is-live { opacity: 1; animation: flow var(--flow-speed) linear infinite; }
[data-flow="off"] .flow { display: none; }

/* Pumps */
.pump .impeller { animation: spin 1.05s linear infinite; animation-play-state: paused; }
.pump.is-running .impeller { animation-play-state: running; }
.pump.is-running circle { stroke: var(--fuel-blue); }
.pump:not(.is-running) { opacity: .82; }

/* Valves — gate colour via currentColor on the <use> */
.valve { color: var(--steel-lt); transition: color .3s var(--ease); }
.valve use { transition: filter .3s; }
.valve[data-state="open"] { color: var(--ok); }
.valve[data-state="open"] use { filter: drop-shadow(0 0 4px rgba(52,211,153,.6)); }
.valve[data-state="shut"] { color: var(--alarm); }

/* Instruments / ISA bubbles */
.instr text, .svg-instr { fill: var(--fuel-blue); font-family: var(--f-mono); font-size: 11px; font-weight: 600; text-anchor: middle; }
.svg-instr-lg { fill: var(--fuel-blue); font-family: var(--f-mono); font-size: 15px; font-weight: 600; text-anchor: middle; }
.svg-instr-sm { fill: var(--text-mut); font-family: var(--f-mono); font-size: 9px; text-anchor: middle; }

/* In-SVG text helpers */
.svg-note        { fill: var(--text-mut); font-family: var(--f-mono); font-size: 11px; letter-spacing: .12em; }
.svg-badge       { fill: var(--safety); font-family: var(--f-display); font-weight: 700; font-size: 12px; text-anchor: middle; letter-spacing: .08em; }
.svg-tankname    { fill: rgba(10,22,34,.55); font-family: var(--f-display); font-weight: 700; font-size: 22px; text-anchor: middle; letter-spacing: .06em; }
.svg-header-label{ fill: var(--text-mut); font-family: var(--f-mono); font-size: 10px; letter-spacing: .1em; text-anchor: middle; }
.svg-stage-label { fill: var(--text-dim); font-family: var(--f-mono); font-size: 9.5px; letter-spacing: .08em; text-anchor: middle; }
.svg-area-title  { fill: var(--safety); font-family: var(--f-display); font-weight: 600; font-size: 13px; letter-spacing: .1em; }
.svg-bay         { fill: var(--text); font-family: var(--f-display); font-weight: 700; font-size: 17px; }
.svg-bc-k        { fill: var(--text-mut); font-family: var(--f-mono); font-size: 9.5px; letter-spacing: .1em; }
.svg-bc-v        { fill: var(--fuel-blue); font-family: var(--f-mono); font-size: 18px; font-weight: 600; }
.svg-bc-s        { fill: var(--ok); font-family: var(--f-mono); font-size: 10px; letter-spacing: .06em; }
.svg-cutlabel    { fill: var(--text-mut); font-family: var(--f-mono); font-size: 9px; letter-spacing: .12em; }

/* Bays */
.bay.active rect { stroke: var(--ok); }
.bay.active .svg-bay { fill: var(--ok); }

/* DP needle + water + bonding */
.dp-needle { transition: transform .8s var(--ease); }
.water-fill { transition: y .6s var(--ease), height .6s var(--ease); }
.bond-dot { fill: var(--steel-lt); transition: fill .3s; }
.app[data-sys="live"] .bond-dot, .bay.active ~ * .bond-dot { fill: var(--ok); }

/* Hazard accent */
.hazard rect { fill: var(--steel); }

/* SCADA mini-display */
.led { stroke: #0a1622; stroke-width: 1; }
.led--ok   { fill: var(--ok); }
.led--idle { fill: #2a4055; }
.led--alarm{ fill: var(--alarm); }
#scada-trace { filter: drop-shadow(0 0 3px rgba(56,189,248,.5)); }

/* ───── Toggleable layers ───── */
.cutaway { display: none; }
.app[data-cutaway="on"] .cutaway { display: inline; }
.app[data-cutaway="on"] #tank-shell rect:first-of-type { opacity: .25; }
.app[data-cutaway="on"] .svg-tankname { opacity: 0; }

.layer--hydrant { display: none; }
.app[data-hydrant="on"] .layer--hydrant { display: inline; }

.app[data-safety="off"] .layer--safety { display: none; }

/* Labels */
.layer--labels .lbl line { stroke: var(--steel-lt); stroke-width: 1; opacity: .7; }
.layer--labels .lbl text {
  fill: var(--text-dim); font-family: var(--f-mono); font-size: 11px;
  text-anchor: middle; paint-order: stroke; stroke: var(--navy-900); stroke-width: 3px;
}
.lbl--l text { text-anchor: end; }
.lbl--r text { text-anchor: start; }
.app[data-labels="off"] .layer--labels { display: none; }
.lbl.cut-only, .lbl.hyd-only { display: none; }
.app[data-cutaway="on"] .lbl.cut-only { display: inline; }
.app[data-hydrant="on"] .lbl.hyd-only { display: inline; }

/* Fire & safety */
.fire-line { fill: none; stroke: var(--alarm); stroke-width: 3; stroke-dasharray: 2 8; opacity: .55; stroke-linecap: round; }

/* Settling droplets in tank */
.settle circle { animation: drip 2.6s var(--ease) infinite; }
.settle circle:nth-child(2) { animation-delay: .9s; }
.settle circle:nth-child(3) { animation-delay: 1.7s; }
.float { animation: bob 3.2s var(--ease) infinite; }

/* Interactive units */
.unit { cursor: help; }
.unit:hover .pipe, .unit:focus-visible { outline: none; }
.unit:hover > rect:first-of-type,
.unit:hover > ellipse:first-of-type { filter: drop-shadow(0 0 6px rgba(56,189,248,.5)); }
.unit.is-hl > rect, .unit.is-hl > circle, .unit.is-hl > path { filter: drop-shadow(0 0 7px rgba(244,196,48,.6)); }

/* dim non-active areas when a stage focuses one (subtle) */
.area { transition: opacity .4s var(--ease); }
.app[data-focus="receipt"] .area:not(.area--receipt),
.app[data-focus="tank"]    .area:not(.area--tank),
.app[data-focus="pumps"]   .area:not(.area--pumps):not(.area--tank),
.app[data-focus="filters"] .area:not(.area--filters):not(.area--pumps),
.app[data-focus="meter"]   .area:not(.area--meter):not(.area--filters),
.app[data-focus="bays"]    .area:not(.area--bays):not(.area--meter) { opacity: .42; }

/* ═══════════════════════ ESD / alarm overlay ═══════════════════════ */
.app[data-sys="alarm"] .scene__frame::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  box-shadow: inset 0 0 0 3px var(--alarm), inset 0 0 70px rgba(242,85,85,.28);
  animation: alarmpulse 1s steps(2, end) infinite;
}
.app[data-sys="alarm"] .pump.is-running .impeller { animation-play-state: paused; }

/* ═══════════════════════ Controls ═══════════════════════ */
.controls {
  display: flex; align-items: center; justify-content: space-between; gap: var(--gap);
  flex-wrap: wrap;
  padding: 10px clamp(12px, 2vw, 26px);
  background: linear-gradient(0deg, #11315a, #0a2239);
  border-top: 1px solid var(--line);
}
.controls__transport, .controls__toggles { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.btn {
  display: inline-flex; align-items: center; gap: 8px;
  border: 1px solid var(--line-lt); background: var(--panel);
  color: var(--text); border-radius: var(--r); padding: 9px 12px;
  font-size: 13px; transition: background .2s, border-color .2s, transform .05s;
}
.btn:hover { background: #163e66; border-color: var(--steel-lt); }
.btn:active { transform: translateY(1px); }
.btn--icon { width: 40px; height: 40px; justify-content: center; padding: 0; font-size: 15px; }
.btn--play {
  background: linear-gradient(180deg, #1f93da, #1370b4);
  border-color: #34bef9; font-family: var(--f-display); font-weight: 600;
  letter-spacing: .04em; padding: 9px 18px; min-width: 96px; justify-content: center;
}
.btn--play:hover { background: linear-gradient(180deg, #2aa3ec, #1780c8); }
.btn__icon-pause { display: none; }
.app[data-playing="true"] .btn--play .btn__icon-play  { display: none; }
.app[data-playing="true"] .btn--play .btn__icon-pause { display: inline; }
.app[data-playing="true"] .btn--play .btn__label::after { content: "Pause"; }
.app[data-playing="true"] .btn--play .btn__label { font-size: 0; }
.app[data-playing="true"] .btn--play .btn__label::after { font-size: 13px; }

.stage-count { font-family: var(--f-mono); font-size: 12.5px; color: var(--text-dim); margin-left: 6px; }

.tog {
  display: inline-flex; align-items: center; text-decoration: none;
  border: 1px solid var(--line-lt); background: var(--panel);
  color: var(--text-dim); border-radius: 999px; padding: 8px 14px;
  font-size: 12.5px; letter-spacing: .02em; position: relative;
  transition: background .2s, color .2s, border-color .2s;
}
.tog--link { color: var(--text); border-color: rgba(52,190,249,.45); }
.tog--link:hover { background: #163e66; }
.tog::before {
  content: ""; width: 8px; height: 8px; border-radius: 50%;
  background: var(--steel-lt); display: inline-block; margin-right: 8px; vertical-align: middle;
  transition: background .2s, box-shadow .2s;
}
.tog[aria-pressed="true"] { color: var(--text); border-color: rgba(56,189,248,.45); background: #112c41; }
.tog[aria-pressed="true"]::before { background: var(--fuel-blue); box-shadow: 0 0 8px var(--fuel-blue); }
.tog--ghost::before { display: none; }
.tog--ghost { color: var(--text-dim); }

/* progress bar */
.progress { background: var(--panel-2); overflow: hidden; }
.progress__bar { display: block; height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--jet-amber), var(--fuel-blue));
  transition: width .5s linear; }

/* ═══════════════════════ Tooltip ═══════════════════════ */
.tooltip {
  position: absolute; z-index: 30; max-width: 250px;
  background: rgba(8,18,28,.97); border: 1px solid var(--steel-lt);
  border-radius: var(--r); padding: 9px 11px; pointer-events: none;
  box-shadow: var(--shadow); transform: translate(-50%, -112%);
  opacity: 0; transition: opacity .12s; backdrop-filter: blur(2px);
}
.tooltip.show { opacity: 1; }
.tooltip__tag { font-family: var(--f-mono); font-size: 10px; color: var(--safety); letter-spacing: .08em; }
.tooltip__name { font-family: var(--f-display); font-weight: 600; font-size: 14.5px; margin: 1px 0 4px; line-height: 1.1; }
.tooltip__tip { font-size: 11.5px; color: var(--text-dim); line-height: 1.45; }

/* ═══════════════════════ Keyframes ═══════════════════════ */
@keyframes flow      { to { stroke-dashoffset: -24; } }
@keyframes spin      { to { transform: rotate(360deg); } }
@keyframes ledpulse  { 50% { opacity: .35; } }
@keyframes alarmpulse{ 50% { opacity: .35; } }
@keyframes drip      { 0% { transform: translateY(-18px); opacity: 0; } 30% { opacity: .9; } 100% { transform: translateY(150px); opacity: 0; } }
@keyframes bob       { 50% { transform: translateY(3px); } }

/* ═══════════════════════ Fullscreen ═══════════════════════ */
.scene:fullscreen { padding: 0; background: var(--navy-900); }
.scene:fullscreen .scene__frame { border-radius: 0; border: 0; }
.app.is-fs .scene { position: fixed; inset: 0; z-index: 50; background: var(--navy-900); padding: 0; }

/* ═══════════════════════ Responsive ═══════════════════════ */
@media (max-width: 1024px) {
  body { overflow: auto; }
  .app { height: auto; min-height: 100dvh; grid-template-rows: auto auto auto 4px; }
  .hud { flex-wrap: wrap; padding-top: 10px; padding-bottom: 10px; }
  .hud__title { order: 3; flex-basis: 100%; border-left: 0; padding-left: 0; }
  .hud__telemetry { order: 2; flex-wrap: wrap; }
  .workspace { grid-template-columns: 1fr; }
  .scene { order: -1; min-height: 52vh; }
  .rail { border-right: 0; border-top: 1px solid var(--line); }
  .stages { flex-direction: row; overflow-x: auto; padding: 10px; }
  .stage { min-width: 168px; flex: 0 0 auto; }
  .stage__name { font-size: 12.5px; }
}
@media (max-width: 600px) {
  :root { --hud-h: auto; }
  .hud__brand-text small { display: none; }
  .hud__telemetry { gap: 6px; }
  .chip { min-width: 0; padding: 5px 8px; flex: 1 0 auto; }
  .scene { min-height: 46vh; padding: 8px; }
  .controls { gap: 8px; padding: 8px 10px; }
  .controls__transport, .controls__toggles { gap: 6px; }
  .btn--play { min-width: 78px; padding: 9px 12px; }
  .tog { padding: 7px 11px; font-size: 12px; }
  .readout__title { font-size: 16px; }
}

/* ═══════════════════════ Guide · legend · hints (intuitiveness layer) ═══════════════════════ */

/* HUD help button */
.hud__help {
  flex: 0 0 auto; width: 34px; height: 34px; border-radius: 50%;
  border: 1px solid var(--line-lt); background: var(--panel);
  color: var(--fuel-blue); font-family: var(--f-display); font-weight: 700; font-size: 17px;
  display: grid; place-items: center; transition: background .2s, border-color .2s, color .2s;
}
.hud__help:hover { background: #163e66; border-color: var(--fuel-blue); color: var(--brand-glo); }
.hud__help.pulse { animation: helppulse 1.8s var(--ease) 3; }
@keyframes helppulse { 0%,100% { box-shadow: 0 0 0 0 rgba(52,190,249,.0); } 50% { box-shadow: 0 0 0 6px rgba(52,190,249,.22); } }

/* Always-on flow key + hover hint (overlay on the scene) */
.scene-key {
  position: absolute; left: 14px; bottom: 12px; z-index: 8;
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 7px 11px; max-width: calc(100% - 28px);
  background: rgba(8,22,38,.74); border: 1px solid var(--line);
  border-radius: var(--r); backdrop-filter: blur(3px);
  font-size: 11px; color: var(--text-dim); pointer-events: none;
}
.scene-key__sw { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.scene-key__hint { color: var(--text-mut); border-left: 1px solid var(--line-lt); padding-left: 12px; }
.sw { width: 18px; height: 4px; border-radius: 2px; display: inline-block; }
.sw--raw { background: var(--jet-amber); }
.sw--clean { background: var(--fuel-blue); box-shadow: 0 0 6px rgba(52,190,249,.6); }

/* First-run orientation hint */
.hint {
  position: fixed; left: 50%; bottom: 80px; transform: translateX(-50%);
  z-index: 60; width: min(440px, calc(100vw - 28px));
  background: linear-gradient(180deg, #123a64, #0c2742);
  border: 1px solid var(--fuel-blue); border-radius: var(--r);
  box-shadow: var(--shadow), 0 0 0 4px rgba(52,190,249,.12);
  padding: 14px 16px; animation: hintin .4s var(--ease);
}
.hint[hidden] { display: none; }
.hint__txt { font-size: 13.5px; color: var(--text); line-height: 1.5; }
.hint__txt b { color: var(--brand-glo); }
.hint__row { display: flex; gap: 8px; justify-content: flex-end; margin-top: 11px; }
.hint__btn { border-radius: var(--r); padding: 8px 14px; font-size: 12.5px; border: 1px solid var(--line-lt); background: var(--panel); color: var(--text); }
.hint__ok { background: linear-gradient(180deg, var(--fuel-blue), #1f93da); color: var(--navy-900); border-color: #34bef9; font-weight: 600; }
.hint__btn:hover { filter: brightness(1.08); }
@keyframes hintin { from { opacity: 0; transform: translate(-50%, 12px); } }

/* Guide / legend modal */
.guide {
  position: fixed; inset: 0; z-index: 70; display: grid; place-items: center;
  background: rgba(5,14,24,.74); backdrop-filter: blur(4px); padding: 20px;
  animation: guidein .2s var(--ease);
}
.guide[hidden] { display: none; }
.guide__panel {
  width: min(820px, 100%); max-height: 88vh; overflow: auto;
  background: linear-gradient(180deg, #0e2c4d, #0a2138);
  border: 1px solid var(--line-lt); border-radius: 10px; box-shadow: var(--shadow);
}
.guide__head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 15px 20px; border-bottom: 1px solid var(--line);
  position: sticky; top: 0; background: linear-gradient(180deg, #11315a, #0e2c4d);
}
.guide__head h2 { font-family: var(--f-display); font-weight: 600; font-size: 21px; letter-spacing: .01em; }
.guide__close { width: 34px; height: 34px; border-radius: 8px; border: 1px solid var(--line-lt); background: var(--panel-2); color: var(--text-dim); font-size: 15px; }
.guide__close:hover { background: #163e66; color: var(--text); }
.guide__body { display: grid; grid-template-columns: 1fr 1fr; gap: 26px; padding: 20px 22px 24px; }
.guide__col h3 { font-family: var(--f-display); font-weight: 600; font-size: 13px; letter-spacing: .12em; text-transform: uppercase; color: var(--safety); margin: 0 0 11px; }
.guide__col h3 + ul + h3 { margin-top: 22px; }
.guide__list, .guide__keys, .legend { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 9px; }
.guide__list li { font-size: 13px; color: var(--text-dim); line-height: 1.45; padding-left: 16px; position: relative; }
.guide__list li::before { content: ""; position: absolute; left: 0; top: 7px; width: 6px; height: 6px; border-radius: 50%; background: var(--fuel-blue); }
.guide__list b, .legend b { color: var(--text); }
.guide__keys li { font-size: 12.5px; color: var(--text-dim); }
kbd { font-family: var(--f-mono); font-size: 11px; background: var(--panel-2); border: 1px solid var(--line-lt); border-bottom-width: 2px; border-radius: 4px; padding: 2px 6px; color: var(--text); }
.legend li { display: flex; align-items: center; gap: 10px; font-size: 12.5px; color: var(--text-dim); line-height: 1.35; }
.lg { flex: 0 0 auto; width: 26px; height: 14px; border-radius: 3px; display: inline-grid; place-items: center; }
.lg--raw { background: var(--jet-amber); }
.lg--clean { background: var(--fuel-blue); box-shadow: 0 0 7px rgba(52,190,249,.6); }
.lg--open { background: var(--ok); }
.lg--shut { background: var(--alarm); }
.lg--idle { background: var(--steel-lt); }
.lg--pump { width: 18px; height: 18px; border-radius: 50%; background: radial-gradient(circle at 50% 50%, var(--fuel-blue) 32%, #0e1c28 34%); border: 1px solid var(--steel-lt); }
.lg--instr { width: 22px; height: 22px; border-radius: 50%; background: #0e1c28; border: 1.5px solid var(--fuel-blue); color: var(--fuel-blue); font-family: var(--f-mono); font-size: 9px; font-weight: 600; }
.guide__note { margin-top: 14px; padding-top: 13px; border-top: 1px dashed var(--line-lt); font-size: 12px; color: var(--text-mut); line-height: 1.55; }
.guide__note b { color: var(--text-dim); }
@keyframes guidein { from { opacity: 0; } }

@media (max-width: 600px) {
  .guide__body { grid-template-columns: 1fr; gap: 18px; }
  .scene-key__hint { display: none; }
  .hint { bottom: 12px; }
  .hud__help { width: 30px; height: 30px; font-size: 15px; }
}
@media (prefers-reduced-motion: reduce) {
  .hint, .guide, .hud__help.pulse { animation: none; }
}

/* ═══════════════════════ Reduced motion ═══════════════════════ */
@media (prefers-reduced-motion: reduce) {
  .flow.is-live { animation: none; opacity: 1; }
  .pump .impeller { animation: none; }
  .settle circle, .float { animation: none; }
  .status-led, .scene__frame::after { animation: none !important; }
  .dp-needle, .water-fill, .area, .flow, .tooltip { transition: none; }
  .progress__bar { transition: none; }
}
