/* ═══════════════════════════════════════════════════════════════════════════
   Pump-Aspirated Confined Space Gas Monitor Simulator
   Extends shared/base_fluid/_theme/simulator-theme.css — colours come from the
   shared :root variables only, never hardcoded.
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Layout ───────────────────────────────────────────────────────────────*/
#main {
    display: grid;
    grid-template-columns: 300px minmax(0, 1fr) 320px;
    grid-template-rows: minmax(0, 1fr);
    gap: 6px;
    padding: 6px;
    height: calc(100vh - 42px);
    position: relative;
    z-index: 1;
}

#side, #rp {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow-y: auto;
    min-height: 0;
}

#ctr {
    display: flex;
    flex-direction: column;
    min-height: 0;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

#op-bar {
    flex-shrink: 0;
    padding: 8px 14px;
    border-bottom: 1px solid var(--border);
    background: var(--bg3);
}

.op-title {
    font-family: var(--font-mono);
    font-size: 12px;
    letter-spacing: 0.08em;
    color: var(--cyan);
}

#device-wrap {
    flex: 1 1 0;
    min-height: 0;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    padding: 16px 14px;
}

#ctrl-bar {
    flex-shrink: 0;
    display: flex;
    gap: 8px;
    padding: 8px;
    border-top: 1px solid var(--border);
    background: var(--bg2);
}

.big-btn {
    flex: 1;
    padding: 10px 12px;
    font-family: var(--font-ui);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.04em;
    color: var(--white);
    background: var(--bg3);
    border: 1px solid var(--border2);
    border-radius: var(--radius);
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
}
.big-btn:hover      { background: var(--bg); border-color: var(--cyan); }
.big-btn.ok         { border-color: var(--green); color: var(--green); }
.big-btn.ok:hover   { background: rgba(37, 198, 133, 0.12); }
.big-btn.reset      { border-color: var(--red); color: var(--red); }
.big-btn.reset:hover{ background: rgba(239, 68, 88, 0.12); }

/* ── Sample line indicator ────────────────────────────────────────────────
   The visible embodiment of the transit delay.                              */
.sample-line {
    width: 100%;
    max-width: 640px;
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 9px 12px 11px;
}

.sl-head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 7px;
}

.sl-title {
    font-family: var(--font-mono);
    font-size: 10px;
    letter-spacing: 0.12em;
    color: var(--cyan);
}

.sl-sub {
    font-family: var(--font-ui);
    font-size: 10px;
    color: var(--muted);
}

.transit-track {
    height: 9px;
    background: var(--bg);
    border: 1px solid var(--border2);
    border-radius: 5px;
    overflow: hidden;
}

.transit-fill {
    height: 100%;
    width: 0;
    background: var(--amber);
    transition: width 0.4s linear, background 0.3s;
}
.transit-fill.full { background: var(--green); }

/* ── The instrument ───────────────────────────────────────────────────────*/
.device { display: flex; flex-direction: column; align-items: center; gap: 10px; }

.device-boot {
    display: flex;
    align-items: stretch;
    gap: 0;
    background: #8f2733;
    border-radius: 20px;
    padding: 10px;
    box-shadow: 0 8px 26px rgba(0, 0, 0, 0.45);
}

/* The alarm LED arrays down each side of the boot. */
.device-led {
    width: 16px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.10);
    align-self: stretch;
    margin: 6px 4px;
}
.device-led.led-slow  { animation: led-blink 1s steps(2, end) infinite; }
.device-led.led-fast  { animation: led-blink 0.5s steps(2, end) infinite; }
.device-led.led-fault { animation: led-blink 1s steps(2, end) infinite; background: var(--amber); }
.device-led.led-slow, .device-led.led-fast { background: var(--red); }

@keyframes led-blink { 0%, 100% { opacity: 1; } 50% { opacity: 0.12; } }

.device-face {
    width: min(74vw, 560px);
    background: #14181d;
    border: 1px solid #2a3038;
    border-radius: 12px;
    padding: 10px 12px 12px;
}

.face-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.face-brand {
    font-family: var(--font-ui);
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.06em;
    color: var(--cyan);
}

.face-model {
    font-family: var(--font-mono);
    font-size: 12px;
    letter-spacing: 0.16em;
    color: var(--muted);
}

.face-body { display: flex; align-items: center; gap: 10px; }

.btn-col { display: flex; flex-direction: column; gap: 12px; flex-shrink: 0; }

.dev-btn {
    width: 66px;
    height: 66px;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 30%, #3a424c, #1c2128 70%);
    border: 1px solid #454e59;
    color: var(--white);
    font-family: var(--font-ui);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    line-height: 1.1;
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    touch-action: none;
    transition: transform 0.12s, box-shadow 0.12s, border-color 0.12s;
}
.dev-btn:hover { border-color: var(--cyan); }
.dev-btn.is-held {
    transform: scale(0.95);
    border-color: var(--amber);
    box-shadow: 0 0 0 3px rgba(230, 165, 50, 0.35);
}
.db-1 { font-size: 13px; }
.db-2 { font-size: 10px; font-weight: 700; letter-spacing: 0.05em; }
.db-2.wide { font-size: 9.5px; }
.db-3 { font-size: 9px; color: var(--muted); }

/* ── LCD ──────────────────────────────────────────────────────────────────*/
.lcd {
    flex: 1 1 0;
    min-width: 0;
    aspect-ratio: 16 / 10;
    background: linear-gradient(180deg, #cfe3c8 0%, #b9d3b0 100%);
    border: 2px solid #0d1b12;
    border-radius: 6px;
    padding: 6px 8px 7px;
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
}

.lcd.is-off { background: #10130f; }
.lcd.is-off > * { visibility: hidden; }

.lcd-status {
    display: flex;
    align-items: center;
    gap: 7px;
    font-family: var(--font-mono);
    font-size: 10px;
    color: #14301c;
    flex-shrink: 0;
}
.lcd-pilot { color: #14301c; transition: opacity 0.2s; }
.lcd-pump  { transition: transform 0.4s linear, opacity 0.3s; }
.lcd-mode  { flex: 1; text-align: center; letter-spacing: 0.1em; font-weight: 700; }
.lcd-clock { font-variant-numeric: tabular-nums; }

/* Battery icon drawn in CSS so it needs no image. */
.lcd-batt {
    width: 20px; height: 10px;
    border: 1.5px solid #14301c;
    border-radius: 2px;
    position: relative;
}
.lcd-batt::after {
    content: ''; position: absolute; right: -3.5px; top: 2px;
    width: 2px; height: 4px; background: #14301c; border-radius: 0 1px 1px 0;
}
.lcd-batt::before {
    content: ''; position: absolute; left: 1px; top: 1px; bottom: 1px;
    background: #14301c; transition: width 0.4s;
}
.lcd-batt.b3::before { width: 14px; }
.lcd-batt.b2::before { width: 9px; }
.lcd-batt.b1::before { width: 4px; }
.lcd-batt.b0::before { width: 4px; animation: led-blink 1.2s steps(2, end) infinite; }

.lcd-grid {
    flex: 1 1 0;
    min-height: 0;
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr;
    gap: 4px 10px;
    margin-top: 3px;
}

.lcd-cell { display: flex; flex-direction: column; justify-content: center; min-width: 0; }

.lcd-lbl {
    font-family: var(--font-mono);
    font-size: clamp(8px, 1.05vw, 11px);
    letter-spacing: 0.06em;
    color: #24462c;
    line-height: 1;
}
.lcd-lbl em { font-style: normal; opacity: 0.75; }

.lcd-val {
    font-family: var(--font-mono);
    font-size: clamp(20px, 3.7vw, 44px);
    font-weight: 400;
    line-height: 1;
    color: #0f2a17;
    font-variant-numeric: tabular-nums;
}

.lcd-bar {
    display: block;
    height: 5px;
    background: rgba(20, 48, 28, 0.16);
    border-radius: 2px;
    overflow: hidden;
    margin-top: 3px;
}

.lcd-bar-fill {
    display: block;
    height: 100%;
    width: 0;
    background: #2f5c3a;
    transition: width 0.4s linear, background 0.3s;
}
.lcd-bar-fill.at-first  { background: #9a6a12; }
.lcd-bar-fill.at-second { background: #a32235; }

.lcd-cell.alarm-first  .lcd-val { animation: lcd-flash 1s steps(2, end) infinite; }
.lcd-cell.alarm-second .lcd-val { animation: lcd-flash 0.5s steps(2, end) infinite; color: #8e1526; }
.lcd-cell.is-failed    .lcd-val { opacity: 0.55; }

@keyframes lcd-flash { 0%, 100% { opacity: 1; } 50% { opacity: 0.15; } }

/* Message screen overlays the readout for warm-up, air cal and the menus. */
.lcd-msg {
    display: none;
    position: absolute;
    inset: 22px 8px 7px;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
}
.lcd.is-msg .lcd-msg  { display: flex; }
.lcd.is-msg .lcd-grid { visibility: hidden; }

.lcd-msg-top {
    font-family: var(--font-mono);
    font-size: clamp(16px, 2.6vw, 30px);
    letter-spacing: 0.09em;
    color: #0f2a17;
    text-align: center;
}
.lcd-msg-rule { width: 78%; height: 1.5px; background: rgba(20, 48, 28, 0.35); }
.lcd-msg-bot {
    font-family: var(--font-mono);
    font-size: clamp(9px, 1.25vw, 14px);
    letter-spacing: 0.05em;
    color: #24462c;
    text-align: center;
}

.face-ports {
    display: flex;
    gap: 16px;
    justify-content: center;
    margin-top: 9px;
}
.port {
    font-family: var(--font-mono);
    font-size: 8.5px;
    letter-spacing: 0.12em;
    color: var(--muted);
    border: 1px solid var(--border2);
    border-radius: 3px;
    padding: 2px 8px;
}

.device-hint {
    max-width: 640px;
    font-family: var(--font-ui);
    font-size: 11.5px;
    line-height: 1.6;
    color: var(--muted);
    text-align: center;
}
.device-hint strong { color: var(--cyan); font-weight: 600; }

/* ── Left panel controls ──────────────────────────────────────────────────*/
.s-hd, .rp-hd {
    font-family: var(--font-mono);
    font-size: 10px;
    letter-spacing: 0.12em;
    color: var(--cyan);
    padding: 8px 12px;
    border-bottom: 1px solid var(--border);
    background: var(--bg3);
    position: sticky;
    top: 0;
    z-index: 2;
}

.ctrl-section { padding: 10px 12px; border-bottom: 1px solid var(--border); }

.ctrl-section-hdr {
    font-family: var(--font-mono);
    font-size: 9.5px;
    letter-spacing: 0.11em;
    color: var(--muted);
    margin-bottom: 8px;
}

.ctrl-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 8px;
    font-family: var(--font-ui);
    font-size: 11.5px;
    color: var(--white);
    margin-bottom: 6px;
}
.ctrl-row .val { font-family: var(--font-mono); color: var(--cyan); }

.ctrl-section input[type="range"] {
    width: 100%;
    accent-color: var(--cyan);
    margin-bottom: 6px;
}

.ctrl-section select {
    width: 100%;
    padding: 6px 8px;
    font-family: var(--font-ui);
    font-size: 11px;
    color: var(--white);
    background: var(--bg3);
    border: 1px solid var(--border2);
    border-radius: 4px;
    cursor: pointer;
}

.ctrl-note {
    font-family: var(--font-ui);
    font-size: 10.5px;
    line-height: 1.5;
    color: var(--muted);
    margin-top: 6px;
}
.ctrl-note strong { color: var(--white); }
.ctrl-note.ok   { color: var(--green); }
.ctrl-note.wait { color: var(--amber); }
.ctrl-note.bad  { color: var(--red); }

.ctrl-btn {
    padding: 6px 9px;
    font-family: var(--font-ui);
    font-size: 11px;
    color: var(--white);
    background: var(--bg3);
    border: 1px solid var(--border2);
    border-radius: 4px;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
}
.ctrl-btn:hover   { border-color: var(--cyan); background: var(--bg); }
.ctrl-btn.active  { border-color: var(--green); color: var(--green); }
.ctrl-btn.wide    { display: block; width: 100%; margin-bottom: 5px; text-align: left; }

.lvl-row { display: flex; gap: 5px; margin-bottom: 6px; }
.lvl-row .ctrl-btn { flex: 1; text-align: center; }
.lvl-d { display: block; font-family: var(--font-mono); font-size: 9px; color: var(--muted); }

/* ── Right panel ──────────────────────────────────────────────────────────*/
#rp { display: flex; flex-direction: column; overflow: hidden; }
.rp-block { display: flex; flex-direction: column; min-height: 0; border-bottom: 1px solid var(--border); }
.rp-grow  { flex: 1 1 0; }
.rp-body  { padding: 8px 10px; }
.rp-scroll { overflow-y: auto; max-height: 210px; }
#alm-cnt { color: var(--red); font-family: var(--font-mono); }
.alm-list { flex: 1 1 0; overflow-y: auto; padding: 6px; min-height: 0; }

.alarm-item {
    display: grid;
    grid-template-columns: 52px 1fr auto;
    gap: 6px;
    align-items: start;
    padding: 5px 6px;
    margin-bottom: 4px;
    border-radius: 4px;
    border-left: 3px solid var(--border2);
    background: var(--bg2);
    font-family: var(--font-ui);
    font-size: 11px;
    line-height: 1.45;
    cursor: pointer;
}
.alarm-item.active-alarm { border-left-color: var(--red);   background: rgba(239, 68, 88, 0.10); }
.alarm-item.active-warn  { border-left-color: var(--amber); background: rgba(230, 165, 50, 0.10); }
.alarm-item.active-fault { border-left-color: var(--orange);background: rgba(232, 116, 59, 0.10); }
.alarm-item.active-info  { border-left-color: var(--cyan);  background: rgba(43, 184, 224, 0.08); }
.alarm-item.ack          { opacity: 0.55; }

.alarm-tag {
    font-family: var(--font-mono);
    font-size: 8.5px;
    letter-spacing: 0.06em;
    padding: 1px 4px;
    border-radius: 2px;
    text-align: center;
}
.alarm-tag.A { color: var(--red); }
.alarm-tag.W { color: var(--amber); }
.alarm-tag.F { color: var(--orange); }
.alarm-tag.I { color: var(--cyan); }
.alarm-text  { color: var(--white); }
.alarm-time  { font-family: var(--font-mono); font-size: 9px; color: var(--muted); }

.checklist-item {
    display: flex;
    gap: 7px;
    align-items: flex-start;
    padding: 4px 2px;
    font-family: var(--font-ui);
    font-size: 11px;
    line-height: 1.45;
    cursor: pointer;
    color: var(--white);
}
.checklist-item.done { color: var(--green); }
.checklist-item.done .chk-text { text-decoration: line-through; opacity: 0.75; }
.chk-icon { flex-shrink: 0; font-family: var(--font-mono); }

/* ── Scenario modal ───────────────────────────────────────────────────────*/
#modal-bg {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(7, 11, 16, 0.88);
    z-index: 100;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

#modal {
    max-width: 620px;
    width: 100%;
    max-height: 86vh;
    overflow-y: auto;
    background: var(--panel);
    border: 1px solid var(--border2);
    border-radius: var(--radius-lg);
    padding: 22px 24px;
}
#modal h2 { font-family: var(--font-ui); font-size: 18px; color: var(--cyan); margin-bottom: 8px; }
#modal p  { font-family: var(--font-ui); font-size: 12.5px; line-height: 1.65; color: var(--muted); margin-bottom: 16px; }

.mg { display: grid; gap: 9px; }

.mb {
    text-align: left;
    padding: 12px 14px;
    background: var(--bg2);
    border: 1px solid var(--border2);
    border-radius: var(--radius);
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
}
.mb:hover { border-color: var(--cyan); background: var(--bg3); }
.mt { font-family: var(--font-ui); font-size: 13px; font-weight: 600; color: var(--white); margin-bottom: 4px; }
.md { font-family: var(--font-ui); font-size: 11.5px; line-height: 1.5; color: var(--muted); }

.badge {
    font-family: var(--font-mono);
    font-size: 8.5px;
    letter-spacing: 0.08em;
    padding: 2px 6px;
    border-radius: 3px;
    margin-left: 6px;
    vertical-align: middle;
}
.badge.beginner     { color: var(--green); border: 1px solid var(--green); }
.badge.intermediate { color: var(--amber); border: 1px solid var(--amber); }
.badge.advanced     { color: var(--red);   border: 1px solid var(--red); }

/* ── Responsive ───────────────────────────────────────────────────────────*/
@media (max-width: 1400px) {
    #main { grid-template-columns: 260px minmax(0, 1fr) 280px; }
}
@media (max-width: 1150px) {
    #main { grid-template-columns: 230px minmax(0, 1fr) 250px; }
    .dev-btn { width: 54px; height: 54px; }
}

/* ═══════════════════════════════════════════════════════════════════════════
   LIGHT THEME  (owner request 2026-09-04)
   Only the page SHELL goes light — header, side/right panels, control bar,
   modals and the shared fault/replay framework UI. The physical instrument
   (boot, faceplate, buttons, green LCD) is a realistic device and is left
   unchanged. Loaded after simulator-theme.css + sim-framework.css, so these
   win by cascade order without editing the shared files (which every other
   simulator uses). Palette is overridden on :root; the few shell rules that
   hard-code dark colours in the shared files are overridden explicitly below.
   ═══════════════════════════════════════════════════════════════════════════ */
:root {
  --bg:       #eef2f6;
  --bg2:      #e3eaf1;
  --bg3:      #d7e0e9;
  --panel:    #ffffff;
  --border:   rgba(30, 50, 80, 0.14);
  --border2:  rgba(30, 50, 80, 0.24);
  --green:    #1e9e6a;
  --green2:   #17835a;
  --amber:    #b9770e;
  --red:      #d62f44;
  --red2:     #b81f33;
  --orange:   #cf5f27;
  --cyan:     #0b6e93;
  --blue:     #2f6fd6;
  --white:    #16202c;   /* primary text is dark on a light shell */
  --muted:    #566579;
  /* Glows read as smudges on a light ground — neutralise them but keep the
     value list-composable so `box-shadow: var(--glow), …` stays valid CSS. */
  --glow-cyan:  0 0 0 rgba(0,0,0,0);
  --glow-green: 0 0 0 rgba(0,0,0,0);
  --glow-red:   0 0 0 rgba(0,0,0,0);
  --glow-amber: 0 0 0 rgba(0,0,0,0);
  --glass:        rgba(255, 255, 255, 0.92);
  --glass-border: rgba(30, 50, 80, 0.10);
}

/* Subtle grid overlay — darken the lines so they read on a light ground. */
body::before {
  background-image:
    linear-gradient(rgba(30,50,80,0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(30,50,80,0.05) 1px, transparent 1px);
}

/* Header bar */
#header, #hdr {
  background: linear-gradient(180deg, #ffffff 0%, #e7edf3 100%);
  box-shadow: 0 1px 4px rgba(30,50,80,0.10), inset 0 -1px 0 rgba(30,50,80,0.06);
  border-bottom: 1px solid var(--border2);
}
#clock, #hclock { color: var(--green2); text-shadow: none; }

/* Panels + panel headers (shared file hard-codes dark gradients/shadows) */
.panel { box-shadow: 0 2px 12px rgba(30,50,80,0.10), inset 0 1px 0 rgba(255,255,255,0.6); }
.panel-header, .ph, .rp-hd, .s-hd {
  background: linear-gradient(180deg, #f2f6f9 0%, #e7edf3 100%);
  text-shadow: none;
}
.op-title, .sl-title, .rp-hd, .s-hd { text-shadow: none; }

/* Scrollbars (shared tracks/thumbs are tuned for dark) */
.panel-body::-webkit-scrollbar-track, .pb::-webkit-scrollbar-track,
.scrollable::-webkit-scrollbar-track { background: rgba(30,50,80,0.06); }
.panel-body::-webkit-scrollbar-thumb, .pb::-webkit-scrollbar-thumb,
.rp-body::-webkit-scrollbar-thumb, .rp-scroll::-webkit-scrollbar-thumb,
.scrollable::-webkit-scrollbar-thumb { background: rgba(30,50,80,0.22); }
.scrollable::-webkit-scrollbar-thumb:hover { background: rgba(30,50,80,0.32); }

/* Shared framework UI (sim-framework.css) hard-codes light-on-dark text that
   would vanish on a light panel — repoint those to the light palette. */
.sf-tw-label, .sf-tw-btn, .sf-icon-btn, .sf-score-label, .sf-pause-sub,
.sf-fault-close, .sf-fault-group, .sf-fault-toggle, .sf-fault-label,
.sf-trend-close, .sf-scorecard, .sf-help-table td:last-child { color: var(--muted); }
.sf-tw-group, .sf-score-box { background: rgba(30,50,80,0.05); border-color: rgba(30,50,80,0.12); }
.sf-icon-btn { border-color: rgba(30,50,80,0.14); }
.sf-fault-group { background: rgba(30,50,80,0.04); }
.sf-fault-toggle { background: rgba(30,50,80,0.06); }
.sf-fault-row { border-bottom-color: rgba(30,50,80,0.06); }
.sf-fault-row:hover { background: rgba(30,50,80,0.05); }
.sf-fault-close:hover { color: var(--white); }
.sf-help-table td { border-bottom-color: rgba(30,50,80,0.08); }

/* The instrument body stays dark in the light theme, so its on-device labels
   must keep LIGHT ink — they were inheriting the shell's --white/--muted, which
   are now dark and turned the button text dark-on-dark. Pin them explicitly. */
.dev-btn              { color: #eef4fa; }
.db-3                 { color: #93a3b5; }   /* ENTER sublabel */
.face-brand           { color: #2bb8e0; }   /* device's own bright cyan */
.face-model,
.face-ports .port     { color: #93a3b5; }
