/* ==========================================================================
   RailRaksha v8.3 — Machined Cool Titanium Tactile Hardware System
   Material language: Anodized mineral titanium ground, molded matte ceramic
   instrument faces with 1px chamfered seams, debossed LCD wells, calibrated
   232px aluminum proximity dial, 3-layer pushable keys, physical rockers,
   and ONE intentional active chroma: Signal Vermilion (#E5481F).
   ========================================================================== */

:root,
[data-theme="light"] {
  color-scheme: light;

  /* Wall Ground — Anodized Cool Mineral Titanium */
  --wall-top: #D2DAE3;
  --wall-bot: #C4CEDB;

  /* Molded Ceramic Hardware Surfaces */
  --face: #F2F5F9;
  --face-hover: #F7F9FC;
  --edge: #AEBAC9;
  --well: #C5D0DD;
  --hairline: rgba(24, 32, 43, 0.14);
  --well-border: rgba(24, 32, 43, 0.16);

  /* Ink Hierarchy (WCAG AAA/AA Verified) */
  --ink: #161E29;
  --muted: #525F72;
  --on-ink: #F2F5F9;

  /* Single Active Hardware Chroma — International Signal Vermilion */
  --accent: #E5481F;
  --accent-hi: #F5643D;
  --accent-deep: #B8310F;
  --accent-glow: rgba(229, 72, 31, 0.34);
  --accent-soft: rgba(229, 72, 31, 0.12);

  /* Strict Life-Safety Emergency Escalation (CRITICAL only) */
  --danger: #C81E1E;
  --danger-glow: rgba(200, 30, 30, 0.34);

  /* Machined Aluminum Metal (Dial & Linear Slider Index) */
  --metal-grad: linear-gradient(180deg, #E8EEF5 0%, #C6D1DD 54%, #AEB9C7 100%);
  --metal-knurl: repeating-conic-gradient(from 0deg, transparent 0deg 3deg, rgba(22, 32, 46, 0.08) 3deg 6deg);

  /* Crisp Non-Muddy Instrument Elevation Recipes */
  --raised:
    inset 0 1px 0 rgba(255, 255, 255, 0.86),
    inset 0 -1px 0 rgba(22, 32, 46, 0.06),
    0 1px 2px rgba(20, 30, 44, 0.11),
    0 6px 14px -8px rgba(20, 30, 44, 0.22);

  --raised-sm:
    inset 0 1px 0 rgba(255, 255, 255, 0.86),
    inset 0 -1px 1px rgba(22, 32, 46, 0.08),
    0 1px 2px rgba(20, 30, 44, 0.14);

  --pressed:
    inset 0 2px 5px rgba(20, 30, 44, 0.28);

  --debossed:
    inset 0 1px 3px rgba(20, 30, 44, 0.22),
    inset 0 -1px 0 rgba(255, 255, 255, 0.65);

  --edge-shadow: 0 2px 4px rgba(20, 30, 44, 0.22);
  --dial-shadow:
    inset 0 1px 1px rgba(255, 255, 255, 0.80),
    inset 0 -1px 2px rgba(20, 30, 44, 0.12),
    0 4px 12px -4px rgba(20, 30, 44, 0.24);

  --spark-idle: rgba(22, 30, 41, 0.22);
  --track-ring: rgba(22, 30, 41, 0.12);
  --modal-scrim: rgba(18, 26, 37, 0.56);

  /* Typography */
  --font-display: 'Familjen Grotesk', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-body: 'Karla', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, monospace;
  --font-te: 'Noto Sans Telugu', 'Karla', sans-serif;
}

/* Night Shift Hardware — Machined Anodized Gunmetal */
[data-theme="night"] {
  color-scheme: dark;

  --wall-top: #181F29;
  --wall-bot: #12171F;

  --face: #232C39;
  --face-hover: #293342;
  --edge: #10151C;
  --well: #151B24;
  --hairline: rgba(237, 242, 248, 0.11);
  --well-border: rgba(237, 242, 248, 0.10);

  --ink: #EDF2F8;
  --muted: #93A1B5;
  --on-ink: #151B24;

  --accent: #F05A30;
  --accent-hi: #FF754F;
  --accent-deep: #C43D18;
  --accent-glow: rgba(240, 90, 48, 0.36);
  --accent-soft: rgba(240, 90, 48, 0.16);

  --danger: #EF4444;
  --danger-glow: rgba(239, 68, 68, 0.38);

  --metal-grad: linear-gradient(180deg, #394454 0%, #242D39 55%, #1A2029 100%);
  --metal-knurl: repeating-conic-gradient(from 0deg, transparent 0deg 3deg, rgba(255, 255, 255, 0.06) 3deg 6deg);

  --raised:
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    inset 0 -1px 2px rgba(0, 0, 0, 0.32),
    0 2px 4px rgba(0, 0, 0, 0.34),
    0 8px 18px -10px rgba(0, 0, 0, 0.56);

  --raised-sm:
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    inset 0 -1px 2px rgba(0, 0, 0, 0.32),
    0 1px 3px rgba(0, 0, 0, 0.36);

  --pressed:
    inset 0 2px 6px rgba(0, 0, 0, 0.58);

  --debossed:
    inset 0 2px 5px rgba(0, 0, 0, 0.50),
    inset 0 -1px 0 rgba(255, 255, 255, 0.06);

  --edge-shadow: 0 3px 6px rgba(0, 0, 0, 0.44);
  --dial-shadow:
    inset 0 1px 1px rgba(255, 255, 255, 0.12),
    inset 0 -1px 2px rgba(0, 0, 0, 0.40),
    0 6px 16px -4px rgba(0, 0, 0, 0.52);

  --spark-idle: rgba(237, 242, 248, 0.20);
  --track-ring: rgba(237, 242, 248, 0.12);
  --modal-scrim: rgba(7, 10, 15, 0.72);
}

/* ── Reset & Base ────────────────────────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

[hidden], .hidden { display: none !important; }

.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;
}

html, body {
  min-height: 100%;
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.45;
  color: var(--ink);
  background: linear-gradient(180deg, var(--wall-top), var(--wall-bot));
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea {
  font-family: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  border: none;
  background: none;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.mono {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

.accent-text { color: var(--accent); }

/* ── Frameless App Shell ─────────────────────────────────────────────────── */
.app-shell {
  width: 100%;
  max-width: 460px;
  min-height: 100dvh;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  position: relative;
}

/* ── Sticky Raised Top Bar ───────────────────────────────────────────────── */
.top-bar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: calc(11px + env(safe-area-inset-top, 0px)) 16px 11px;
  background: var(--face);
  border-bottom: 1px solid var(--hairline);
  border-radius: 0;
  box-shadow: var(--raised);
}

.top-bar-left {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
}

.brand-name {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--ink);
  line-height: 1;
}

.brand-tag {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  padding-left: 9px;
  border-left: 1px solid var(--hairline);
  white-space: nowrap;
}

.weather-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 8px;
  border-radius: 6px;
  border: 1px solid var(--well-border);
  background: var(--well);
  box-shadow: var(--debossed);
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  flex-shrink: 0;
}

.weather-chip:hover { color: var(--accent); }

.top-bar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.round-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--hairline);
  background: var(--face);
  box-shadow: var(--raised-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--ink);
  font-size: 15px;
  font-weight: 700;
  transition: transform 0.1s ease;
  flex-shrink: 0;
}

.round-btn:active {
  background: var(--well);
  box-shadow: var(--pressed);
  transform: scale(0.96);
}

/* ── Main Content Column ─────────────────────────────────────────────────── */
.main-content {
  flex: 1;
  padding: 14px 14px 96px;
}

.screen {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.console-grid {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.console-col-primary,
.console-col-secondary {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Section Micro-Label (10.5px uppercase tracked +0.09em) */
.sec-micro-label {
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--muted);
  margin-top: 2px;
  padding-left: 2px;
}

/* ── Simulation Drill Banner ─────────────────────────────────────────────── */
.drill-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 8px;
  background: var(--well);
  box-shadow: var(--debossed);
  border: 1px solid var(--accent-glow);
}

.drill-strip-left {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.drill-strip-text {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.04em;
  line-height: 1.3;
  color: var(--accent-deep);
  white-space: normal;
}

[data-theme="night"] .drill-strip-text { color: var(--accent-hi); }

/* ── Horizontal Beat Station Chip Row ────────────────────────────────────── */
.beat-strip-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}

.beat-chips {
  display: flex;
  align-items: center;
  gap: 7px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  padding: 3px 16px 5px 2px;
  flex: 1;
  scrollbar-width: none;
  -webkit-mask-image: linear-gradient(90deg, #000 0%, #000 90%, transparent 100%);
  mask-image: linear-gradient(90deg, #000 0%, #000 90%, transparent 100%);
}

.beat-chips::-webkit-scrollbar { display: none; }

.beat-chip {
  scroll-snap-align: start;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 11px;
  border-radius: 7px;
  border: 1px solid var(--hairline);
  background: var(--face);
  box-shadow: var(--raised-sm);
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  flex-shrink: 0;
  transition: transform 0.1s ease;
}

.beat-chip .chip-pilot {
  display: none;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
}

.beat-chip.pressed {
  background: var(--well);
  box-shadow: var(--pressed);
  border-color: var(--well-border);
  color: var(--ink);
}

.beat-chip.pressed .chip-pilot {
  display: inline-block;
}

.beat-nudge-group {
  display: flex;
  gap: 5px;
  flex-shrink: 0;
  padding: 0 0 2px 8px;
  border-left: 1px solid var(--hairline);
}

.micro-key {
  padding: 6px 8px;
  border-radius: 7px;
  border: 1px solid var(--hairline);
  background: var(--face);
  box-shadow: var(--raised-sm);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
}

.micro-key:active {
  background: var(--well);
  box-shadow: var(--pressed);
  color: var(--ink);
}

/* ── Raised Molded Ceramic Hardware Card ─────────────────────────────────── */
.hw-card {
  background: var(--face);
  border: 1px solid var(--hairline);
  border-radius: 12px;
  padding: 15px;
  box-shadow: var(--raised);
}

/* ── Hero Brushed-Aluminum Proximity Dial Card ───────────────────────────── */
.dial-card {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.dial-top-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.mode-btn-row {
  display: flex;
  align-items: center;
  gap: 7px;
}

.mode-round {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid var(--hairline);
  background: var(--face);
  box-shadow: var(--raised-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  transition: transform 0.1s ease;
}

.mode-round.pressed,
.mode-round[aria-checked="true"] {
  background: var(--well);
  box-shadow: var(--pressed);
  border-color: var(--accent-glow);
  color: var(--accent);
}

.feed-well {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 10px;
  border-radius: 6px;
  border: 1px solid var(--well-border);
  background: var(--well);
  box-shadow: var(--debossed);
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.07em;
  color: var(--ink);
}

.pilot-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--muted);
  opacity: 0.45;
  flex-shrink: 0;
}

.pilot-dot.dot-live {
  background: var(--accent);
  opacity: 1;
  box-shadow: 0 0 5px var(--accent-glow);
}

/* 232px Machined Brushed-Aluminum Rotary Dial */
.dial-stage {
  display: flex;
  justify-content: center;
  padding: 2px 0 4px;
}

.metal-dial {
  position: relative;
  width: 232px;
  height: 232px;
  border-radius: 50%;
  border: 1px solid var(--hairline);
  background: var(--metal-grad);
  box-shadow: var(--dial-shadow);
}

.dial-knurl {
  position: absolute;
  inset: 5px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.45);
  pointer-events: none;
}

[data-theme="night"] .dial-knurl {
  border-color: rgba(255, 255, 255, 0.06);
}

.dial-well {
  position: absolute;
  inset: 14px;
  border-radius: 50%;
  border: 1px solid var(--well-border);
  background: var(--well);
  box-shadow: var(--debossed);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.dial-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.dial-tick {
  stroke: var(--muted);
  stroke-width: 0.85;
  opacity: 0.42;
}

.dial-tick.major {
  stroke: var(--ink);
  stroke-width: 1.4;
  opacity: 0.52;
}

.dial-inner-ring {
  fill: none;
  stroke: var(--hairline);
  stroke-width: 0.8;
}

.dial-track {
  fill: none;
  stroke: var(--track-ring);
  stroke-width: 3;
}

.dial-arc {
  fill: none;
  stroke: var(--accent);
  stroke-width: 3.6;
  stroke-linecap: butt;
  transition: stroke-dashoffset 0.55s cubic-bezier(0.22, 1, 0.36, 1);
}

body[data-level="CRITICAL"] .dial-arc {
  stroke: var(--danger);
}

.dial-led {
  position: absolute;
  top: 4px;
  left: 50%;
  transform: translateX(-50%);
  width: 6px;
  height: 6px;
  border-radius: 50%;
  z-index: 3;
  background: var(--muted);
  opacity: 0.4;
}

.dial-led.lit {
  background: var(--accent);
  opacity: 1;
  box-shadow: 0 0 6px var(--accent-glow);
}

body[data-level="CRITICAL"] .dial-led {
  background: var(--danger);
  opacity: 1;
  box-shadow: 0 0 7px var(--danger-glow);
}

.dial-readout {
  position: relative;
  z-index: 2;
  text-align: center;
  width: 100%;
  padding: 0 4px;
  max-width: 134px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.dial-num {
  font-family: var(--font-display);
  font-size: 46px;
  font-weight: 700;
  line-height: 0.96;
  letter-spacing: -0.03em;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.dial-num.num-word {
  font-size: 33px;
  letter-spacing: 0.02em;
}

body[data-level="CRITICAL"] .dial-num {
  color: var(--danger);
}

.dial-caption {
  font-family: var(--font-mono);
  font-size: 8.8px;
  font-weight: 600;
  letter-spacing: 0.015em;
  text-transform: uppercase;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dial-te {
  font-family: var(--font-te);
  font-size: 10.5px;
  font-weight: 500;
  line-height: 1.25;
  max-width: 124px;
  color: var(--muted);
}

body[data-level="CRITICAL"] .dial-te,
body[data-level="WARN"] .dial-te {
  color: var(--accent-deep);
}
[data-theme="night"] body[data-level="WARN"] .dial-te,
[data-theme="night"] body[data-level="CRITICAL"] .dial-te {
  color: var(--accent-hi);
}

/* ── Three-Layer Physical Pushable Keys (4-up Controls Grid) ─────────────── */
.push-grid-4 {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 9px;
}

.push-key {
  position: relative;
  border-radius: 10px;
  padding: 0;
  min-height: 70px;
  display: block;
}

.push-edge {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: var(--edge);
  box-shadow: var(--edge-shadow);
}

.push-front {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  border-radius: inherit;
  border: 1px solid var(--hairline);
  background: var(--face);
  box-shadow: var(--raised-sm);
  transform: translateY(-3px);
  transition: transform 0.1s ease, box-shadow 0.1s ease, background-color 0.1s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 8px 5px;
  color: var(--muted);
}

.push-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--ink);
}

.push-label {
  font-size: 10.5px;
  font-weight: 700;
  line-height: 1.15;
  text-align: center;
  color: var(--muted);
}

.push-sub {
  font-size: 10px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--accent-deep);
}

[data-theme="night"] .push-sub { color: var(--accent-hi); }

.push-key:active .push-front,
.push-key.pressed .push-front {
  transform: translateY(0);
  background: var(--well);
  box-shadow: var(--pressed);
  border-color: var(--well-border);
}

.push-key.pressed .push-icon {
  color: var(--accent);
}

.push-key.pressed .push-label {
  color: var(--ink);
}

/* Wide Three-Layer Action Push Buttons (Camera, Analyze, Format, Save, Acknowledge) */
.push-wide {
  position: relative;
  border-radius: 10px;
  width: 100%;
  display: block;
  margin-top: 4px;
}

.push-wide .push-front {
  flex-direction: row;
  padding: 10px 14px;
  font-size: 13.5px;
  font-weight: 700;
  color: var(--ink);
  min-height: 44px;
}

.push-wide:active .push-front {
  transform: translateY(0);
  background: var(--well);
  box-shadow: var(--pressed);
}

.push-wide.push-accent .push-edge {
  background: var(--accent-deep);
}

.push-wide.push-accent .push-front {
  border-color: rgba(255, 255, 255, 0.16);
  background: linear-gradient(180deg, var(--accent-hi), var(--accent));
  color: #FFFFFF;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.28),
    inset 0 -1px 2px rgba(0, 0, 0, 0.16),
    0 2px 5px rgba(184, 49, 15, 0.30);
}

.push-wide.push-accent:active .push-front {
  background: var(--accent-deep);
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.35);
}

.push-wide.push-danger .push-edge {
  background: #8E1313;
}

.push-wide.push-danger .push-front {
  border-color: rgba(255, 255, 255, 0.16);
  background: var(--danger);
  color: #FFFFFF;
  box-shadow: 0 2px 8px var(--danger-glow);
}

/* ── 2-Column Tactile Instrument Grid ────────────────────────────────────── */
.inst-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.inst-span-2 {
  grid-column: span 2;
}

.inst-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.inst-head-left {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
}

.inst-titles {
  min-width: 0;
}

.inst-name {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.inst-sub {
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  line-height: 1.3;
  margin-top: 2px;
}

/* Debossed Icon Well */
.icon-well {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  border: 1px solid var(--well-border);
  background: var(--well);
  box-shadow: var(--debossed);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  flex-shrink: 0;
  position: relative;
}

.icon-well.round-well {
  border-radius: 8px;
}

.icon-well.well-lg {
  width: 52px;
  height: 52px;
  border-radius: 10px;
}

.icon-well.well-lit {
  color: var(--accent);
  border-color: var(--accent-glow);
}

/* ── Physical Rocker Toggle (46×26px Debossed Track + Raised Thumb + Pilot) ─ */
.rocker {
  position: relative;
  width: 46px;
  height: 26px;
  border-radius: 999px;
  border: 1px solid var(--well-border);
  background: var(--well);
  box-shadow: var(--debossed);
  flex-shrink: 0;
  padding: 0;
}

.rocker-pilot {
  position: absolute;
  left: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: transparent;
  transition: background-color 0.18s ease;
}

.rocker.on .rocker-pilot {
  background: var(--accent);
  box-shadow: 0 0 5px var(--accent-glow);
}

.rocker-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 1px solid var(--hairline);
  background: var(--face);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.85),
    0 1px 2px rgba(20, 30, 44, 0.24);
  transition: transform 0.18s cubic-bezier(0.22, 1, 0.36, 1);
}

.rocker.on .rocker-thumb {
  transform: translateX(20px);
}

/* ── Precision Linear Proximity / Thermal Slider Track ───────────────────── */
.knurl-slider-wrap {
  margin-top: 13px;
}

.knurl-track {
  position: relative;
  height: 8px;
  border-radius: 4px;
  border: 1px solid var(--well-border);
  background: var(--well);
  box-shadow: var(--debossed);
}

.knurl-fill {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  border-radius: 3px;
  background: linear-gradient(180deg, var(--accent-hi), var(--accent));
  transition: width 0.45s cubic-bezier(0.22, 1, 0.36, 1);
}

.knurl-thumb {
  position: absolute;
  top: 50%;
  width: 12px;
  height: 18px;
  border-radius: 3px;
  border: 1px solid var(--hairline);
  transform: translate(-50%, -50%);
  background: var(--metal-grad);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.80),
    0 2px 4px rgba(20, 30, 44, 0.28);
  transition: left 0.45s cubic-bezier(0.22, 1, 0.36, 1);
}

.knurl-thumb::after {
  content: '';
  position: absolute;
  top: 3px;
  bottom: 3px;
  left: 50%;
  width: 1.5px;
  transform: translateX(-50%);
  background: var(--muted);
  opacity: 0.45;
}

.knurl-meta {
  display: flex;
  justify-content: space-between;
  margin-top: 7px;
  font-size: 11px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
}

/* ── Half-Width Instrument Tiles (Audio VU + Position Lock) ──────────────── */
.inst-tile {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 13px;
}

.inst-tile-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.inst-tile-mid {
  min-width: 0;
}

.vu-well {
  height: 30px;
  border-radius: 7px;
  border: 1px solid var(--well-border);
  background: var(--well);
  box-shadow: var(--debossed);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 6px;
  padding: 6px 14px;
}

.vu-bar {
  width: 4px;
  border-radius: 1.5px;
  background: var(--spark-idle);
  transition: background-color 0.2s ease;
}

.vu-bar.lit {
  background: var(--accent);
}

.vu-well.vu-off .vu-bar.lit {
  background: var(--spark-idle);
}

.status-well {
  height: 30px;
  border-radius: 7px;
  border: 1px solid var(--well-border);
  background: var(--well);
  box-shadow: var(--debossed);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

/* Lookout Guard Row + Solid Ink Badge */
.guard-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 14px;
}

.ink-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  border-radius: 6px;
  background: var(--ink);
  color: var(--on-ink);
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  white-space: nowrap;
  flex-shrink: 0;
}

.ink-pill.pill-danger {
  background: var(--danger);
  color: #FFFFFF;
}

/* ── Debossed Inset LCD Corridor Meter Screen ────────────────────────────── */
.debossed-screen {
  border-radius: 12px;
  border: 1px solid var(--well-border);
  padding: 15px;
  background: var(--well);
  box-shadow: var(--debossed);
}

.meter-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.meter-eyebrow {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--muted);
}

.meter-value {
  font-size: 21px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
  line-height: 1.2;
  margin-top: 2px;
}

.meter-value-lg {
  font-size: 30px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
  line-height: 1.1;
}

.meter-delta {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}

.meter-sparkline {
  width: 120px;
  height: 44px;
  flex-shrink: 0;
}

.spark-baseline {
  stroke: var(--hairline);
  stroke-width: 1;
}

.spark-bar {
  fill: var(--spark-idle);
  transition: height 0.3s ease, y 0.3s ease;
}

.spark-bar.active {
  fill: var(--accent);
}

.meter-divider {
  height: 1px;
  background: var(--hairline);
  margin: 12px 0 10px;
}

.meter-tabs-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 9px;
}

.meter-tabs {
  display: inline-flex;
  gap: 6px;
}

.meter-tab {
  padding: 4px 10px;
  border-radius: 6px;
  border: 1px solid transparent;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--muted);
}

.meter-tab.active {
  background: var(--face);
  border-color: var(--hairline);
  box-shadow: var(--raised-sm);
  color: var(--ink);
}

.meter-sub-tag {
  font-size: 10.5px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
}

.corridor-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.corridor-list li.empty {
  padding: 12px 8px;
  text-align: center;
  font-size: 12.5px;
  color: var(--muted);
}

.corridor-row {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 8px 10px;
  border-radius: 7px;
  border: 1px solid var(--hairline);
  background: rgba(242, 245, 249, 0.58);
  font-size: 12px;
}

.row-main {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.row-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 11px;
  color: var(--muted);
  padding-left: 1px;
}

@media (min-width: 640px) {
  .corridor-row {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
  }
  .row-main { flex: 1 1 auto; }
  .row-meta { flex: 0 0 auto; gap: 12px; }
}

[data-theme="night"] .corridor-row {
  background: rgba(35, 44, 57, 0.62);
}

.corridor-row[data-level="CRITICAL"],
.corridor-row[data-level="WARN"] {
  background: var(--face);
  border-color: var(--accent-glow);
  box-shadow: var(--raised-sm);
}

.row-no {
  flex: 0 0 auto;
  font-size: 11.5px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}

.row-name {
  flex: 1 1 auto;
  min-width: 0;
  font-weight: 700;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.row-tag {
  flex: 0 0 auto;
  padding: 2px 6px;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 9.5px;
  font-weight: 600;
  background: var(--well);
  color: var(--muted);
}

.row-tag.tag-live {
  background: var(--accent-soft);
  color: var(--accent-deep);
}

[data-theme="night"] .row-tag.tag-live { color: var(--accent-hi); }

.row-dir {
  font-size: 10.5px;
  font-weight: 600;
  color: var(--muted);
}

.row-dist, .row-eta {
  font-size: 11px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
  text-align: right;
}

.log-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 8px;
}

/* ── Sticky Raised Bottom Dock with Machined Center FAB ──────────────────── */
.bottom-dock {
  position: sticky;
  bottom: 0;
  z-index: 40;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  align-items: center;
  padding: 8px 10px calc(10px + env(safe-area-inset-bottom, 0px));
  background: var(--face);
  border-top: 1px solid var(--hairline);
  border-radius: 12px 12px 0 0;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.85),
    0 -3px 12px -4px rgba(20, 30, 44, 0.18);
}

[data-theme="night"] .bottom-dock {
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    0 -4px 16px -4px rgba(0, 0, 0, 0.56);
}

.nav-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  color: var(--muted);
  padding: 3px 2px;
  position: relative;
}

.nav-lbl {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.03em;
}

.nav-pilot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: transparent;
  margin-top: 1px;
}

.nav-btn.active {
  color: var(--ink);
}

.nav-btn.active .nav-pilot {
  background: var(--accent);
}

/* Physical Convex Center FAB (Voice Gang Diary) */
.nav-btn.nav-fab {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  border: 1px solid var(--hairline);
  margin: -20px auto 0;
  background: var(--face);
  box-shadow:
    inset 0 1px 1px rgba(255, 255, 255, 0.88),
    inset 0 -2px 4px rgba(20, 30, 44, 0.14),
    0 4px 10px rgba(20, 30, 44, 0.24);
  color: var(--ink);
  transition: transform 0.12s ease;
}

[data-theme="night"] .nav-btn.nav-fab {
  box-shadow:
    inset 0 1px 1px rgba(255, 255, 255, 0.10),
    inset 0 -2px 5px rgba(0, 0, 0, 0.45),
    0 6px 14px rgba(0, 0, 0, 0.54);
}

.nav-btn.nav-fab:active {
  transform: scale(0.95);
}

.nav-btn.nav-fab.active {
  border-color: rgba(255, 255, 255, 0.22);
  background: linear-gradient(180deg, var(--accent-hi), var(--accent));
  color: #FFFFFF;
  box-shadow:
    inset 0 1px 1px rgba(255, 255, 255, 0.35),
    0 4px 12px var(--accent-glow);
}

/* ── Secondary Screens (Defect, Diary, Weather, Manual) ──────────────────── */
.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.page-title {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--ink);
  line-height: 1.15;
}

.page-sub {
  font-size: 12.5px;
  color: var(--muted);
  margin-top: 2px;
}

.pill-action,
.pill-mini {
  padding: 6px 11px;
  border-radius: 7px;
  border: 1px solid var(--hairline);
  background: var(--face);
  box-shadow: var(--raised-sm);
  font-size: 11.5px;
  font-weight: 700;
  color: var(--ink);
  white-space: nowrap;
}

.pill-action:active,
.pill-mini:active {
  background: var(--well);
  box-shadow: var(--pressed);
}

.text-link {
  font-size: 12px;
  font-weight: 700;
  color: var(--accent-deep);
}
[data-theme="night"] .text-link { color: var(--accent-hi); }

.debossed-box {
  margin-top: 10px;
  padding: 12px 13px;
  border-radius: 9px;
  border: 1px solid var(--well-border);
  background: var(--well);
  box-shadow: var(--debossed);
}

.debossed-box.action-highlight {
  border-left: 3px solid var(--accent);
}

.body-copy {
  font-size: 13.5px;
  color: var(--ink);
  margin-top: 5px;
  line-height: 1.5;
}

.muted-note {
  font-size: 12px;
  color: var(--muted);
}

.empty-copy {
  text-align: center;
  padding: 20px 10px;
  font-size: 13.5px;
  color: var(--muted);
}

/* Inputs & Selects inside debossed wells */
.hw-input {
  width: 100%;
  min-width: 0;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--well-border);
  background: var(--well);
  box-shadow: var(--debossed);
  color: var(--ink);
  font-size: 13.5px;
  line-height: 1.4;
}

.hw-input::placeholder { color: var(--muted); }
.hw-input:focus {
  outline: none;
  border-color: var(--accent);
}

.field-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-top: 10px;
}

.field-group label {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--muted);
}

/* Capture Zone (Defect Inspector) */
.capture-zone {
  border-radius: 10px;
  border: 1px solid var(--well-border);
  background: var(--well);
  box-shadow: var(--debossed);
  min-height: 162px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: 18px;
  text-align: center;
}

.capture-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.capture-title {
  font-family: var(--font-display);
  font-size: 15.5px;
  font-weight: 700;
  color: var(--ink);
}

.capture-hint {
  font-size: 12.5px;
  color: var(--muted);
  max-width: 280px;
}

.image-preview {
  width: 100%;
  max-height: 260px;
  object-fit: cover;
  border-radius: 8px;
}

.capture-btn-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.result-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 12px;
}

.kv-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.kv-well {
  padding: 9px 11px;
  border-radius: 8px;
  border: 1px solid var(--well-border);
  background: var(--well);
  box-shadow: var(--debossed);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.kv-well span {
  font-family: var(--font-mono);
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--muted);
}

.kv-well strong {
  font-size: 13px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}

/* Defect/Manual Filter Chips & Segmented Controls */
.list-head-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 4px;
}

.inline-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.chip-filter-row {
  display: flex;
  gap: 7px;
  overflow-x: auto;
  padding: 2px 0 4px;
  scrollbar-width: none;
}
.chip-filter-row::-webkit-scrollbar { display: none; }

.filter-chip {
  padding: 6px 11px;
  border-radius: 7px;
  border: 1px solid var(--hairline);
  background: var(--face);
  box-shadow: var(--raised-sm);
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  white-space: nowrap;
}

.filter-chip.active {
  background: var(--well);
  box-shadow: var(--pressed);
  border-color: var(--well-border);
  color: var(--ink);
}

.seg-well {
  display: inline-flex;
  padding: 3px;
  border-radius: 8px;
  border: 1px solid var(--well-border);
  background: var(--well);
  box-shadow: var(--debossed);
  gap: 3px;
}

.seg-opt {
  padding: 4px 9px;
  border-radius: 6px;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--muted);
}

.seg-opt.active {
  background: var(--face);
  box-shadow: var(--raised-sm);
  color: var(--ink);
}

/* Attendance Stepper & Phrase Chips (Gang Diary) */
.att-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.stepper-group {
  display: flex;
  align-items: center;
  gap: 7px;
}

.att-input {
  width: 48px;
  height: 36px;
  text-align: center;
  border-radius: 8px;
  border: 1px solid var(--hairline);
  background: var(--face);
  box-shadow: var(--raised-sm);
  font-size: 14.5px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}

.phrase-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.phrase-chip,
.chip-btn {
  padding: 5px 10px;
  border-radius: 6px;
  border: 1px solid var(--hairline);
  background: var(--face);
  box-shadow: var(--raised-sm);
  font-size: 11.5px;
  font-weight: 700;
  color: var(--muted);
}

.phrase-chip:active,
.chip-btn:active {
  background: var(--well);
  box-shadow: var(--pressed);
  color: var(--ink);
}

.diary-line {
  font-size: 13px;
  line-height: 1.5;
  margin-bottom: 5px;
}

.diary-line.te-note {
  font-family: var(--font-te);
  font-size: 12.5px;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--hairline);
}

/* Weather Thermal Hero */
.thermal-hero {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.thermal-big-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
}

.weather-glyph {
  display: inline-flex;
  color: var(--muted);
}

.thermal-right {
  text-align: right;
}

.metric-tile {
  padding: 13px 15px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.metric-label {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.metric-val {
  font-size: 19px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}

/* Manual Search & Rules Grid */
.search-row {
  display: flex;
  align-items: center;
  gap: 9px;
}

.manual-body {
  font-size: 13.5px;
  line-height: 1.6;
  color: var(--ink);
}

.rules-grid {
  display: grid;
  grid-template-columns: repeat(1, minmax(0, 1fr));
  gap: 9px;
}

/* Dynamic Sub-Module Cards (defect-report.js, gang-diary.js, weather-alert.js, pw-manual.js) */
.records-stack {
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.history-item,
.saved-diary-item,
.risk-card,
.rule-card {
  background: var(--face);
  border: 1px solid var(--hairline);
  border-radius: 10px;
  padding: 13px 14px;
  box-shadow: var(--raised);
  text-align: left;
  width: 100%;
}

.history-item {
  display: flex;
  align-items: center;
  gap: 11px;
}

.hi-lead {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: 1px solid var(--well-border);
  background: var(--well);
  box-shadow: var(--debossed);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.hi-body { flex: 1; min-width: 0; }
.hi-title { font-family: var(--font-display); font-size: 14.5px; font-weight: 700; color: var(--ink); }
.hi-sub, .hi-meta, .sdi-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.hi-actions { display: flex; gap: 6px; flex-shrink: 0; align-items: center; }

.icon-btn-sm {
  height: 30px;
  padding: 0 9px;
  border-radius: 6px;
  border: 1px solid var(--well-border);
  background: var(--well);
  box-shadow: var(--debossed);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  color: var(--ink);
}

.icon-btn-danger { color: var(--danger); }

.status-pill,
.rc-tag,
.defect-type-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  border-radius: 5px;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  background: var(--well);
  color: var(--ink);
  max-width: 100%;
}

.status-pill.st-open {
  background: rgba(200, 30, 30, 0.12);
  color: var(--danger);
  border: 1px solid rgba(200, 30, 30, 0.28);
}

.status-pill.st-reported {
  background: var(--accent-soft);
  color: var(--accent-deep);
  border: 1px solid rgba(229, 72, 31, 0.28);
}

.status-pill.st-fixed {
  background: var(--well);
  box-shadow: var(--debossed);
  color: var(--muted);
}

.status-pill.sev-critical,
.status-pill.sev-high,
.rc-tag.tag-emergency,
.rc-tag.rc-tag-emergency {
  background: rgba(200, 30, 30, 0.12);
  color: var(--danger);
  border: 1px solid rgba(200, 30, 30, 0.28);
}

.rc-tag.rc-tag-safety {
  background: var(--accent-soft);
  color: var(--accent-deep);
  border: 1px solid rgba(229, 72, 31, 0.28);
}

.rc-tag.rc-tag-gauge {
  background: var(--well);
  box-shadow: var(--debossed);
  color: var(--ink);
  border: 1px solid var(--hairline);
}

.defect-type-badge.sev-critical {
  background: var(--well);
  box-shadow: var(--debossed);
  color: var(--danger);
  border: 1px solid var(--danger-glow);
}

.defect-type-badge.sev-high {
  background: var(--accent-soft);
  color: var(--accent-deep);
  border: 1px solid rgba(229, 72, 31, 0.30);
}

.defect-type-badge.sev-medium {
  background: var(--well);
  box-shadow: var(--debossed);
  color: var(--ink);
  border: 1px solid var(--hairline);
}

.defect-type-badge.sev-low,
.defect-type-badge.sev-info {
  background: var(--well);
  box-shadow: var(--debossed);
  color: var(--muted);
}

[data-theme="night"] .status-pill.st-reported,
[data-theme="night"] .status-pill.sev-high,
[data-theme="night"] .rc-tag.rc-tag-safety,
[data-theme="night"] .defect-type-badge.sev-high {
  color: var(--accent-hi);
}

[data-theme="night"] .status-pill.st-open,
[data-theme="night"] .status-pill.sev-critical,
[data-theme="night"] .rc-tag.tag-emergency,
[data-theme="night"] .rc-tag.rc-tag-emergency,
[data-theme="night"] .defect-type-badge.sev-critical {
  background: rgba(239, 68, 68, 0.18);
  color: var(--danger);
}

.saved-diary-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 6px;
}

.saved-diary-body { font-size: 13.5px; color: var(--ink); line-height: 1.5; }
.saved-diary-te { font-family: var(--font-te); font-size: 12.5px; color: var(--muted); margin-top: 6px; }

.risk-card {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.risk-content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.risk-card.risk-high {
  border-left: 3px solid var(--danger);
}

.risk-card.risk-medium {
  border-left: 3px solid var(--accent);
}

#rail-thermal-bar[data-state="danger"] {
  background: var(--danger);
  box-shadow: 0 0 8px var(--danger-glow);
}

#rail-thermal-status[data-state="danger"] {
  color: var(--danger);
  font-weight: 700;
}

#rail-thermal-status[data-state="warn"] {
  color: var(--accent-deep);
  font-weight: 700;
}

[data-theme="night"] #rail-thermal-status[data-state="warn"] {
  color: var(--accent-hi);
}

.risk-icon {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: 1px solid var(--well-border);
  background: var(--well);
  box-shadow: var(--debossed);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--ink);
}
.risk-card.risk-high .risk-icon, .risk-card.risk-medium .risk-icon { color: var(--accent); }

.risk-title { font-family: var(--font-display); font-size: 14.5px; font-weight: 700; color: var(--ink); }
.risk-desc { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.risk-action { font-size: 12.5px; font-weight: 700; color: var(--ink); margin-top: 6px; }
.risk-ref { font-family: var(--font-mono); font-size: 10.5px; color: var(--muted); margin-top: 4px; }

.rule-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: transform 0.1s ease;
}
.rule-card:active {
  background: var(--well);
  box-shadow: var(--pressed);
}
.rc-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.rc-title { font-family: var(--font-display); font-size: 14.5px; font-weight: 700; color: var(--ink); }
.rc-preview { font-size: 12.5px; color: var(--muted); line-height: 1.45; }
.rc-category { font-family: var(--font-mono); font-size: 10px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }

.empty-state {
  text-align: center;
  padding: 20px 14px;
  border-radius: 10px;
  border: 1px solid var(--well-border);
  background: var(--well);
  box-shadow: var(--debossed);
}
.es-title { font-weight: 700; color: var(--ink); font-size: 14px; }
.es-sub { font-size: 12.5px; color: var(--muted); margin-top: 4px; }

/* ── Modals (SOS & Settings) ─────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: var(--modal-scrim);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 16px;
}

.modal-sheet {
  width: 100%;
  max-width: 500px;
  max-height: 88dvh;
  background: var(--face);
  border: 1px solid var(--hairline);
  border-radius: 12px;
  box-shadow: var(--raised);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow: hidden;
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--hairline);
}

.modal-head h2 {
  font-family: var(--font-display);
  font-size: 19px;
  font-weight: 700;
  color: var(--ink);
}

.modal-scroll {
  overflow-y: auto;
  padding-right: 4px;
}

.modal-scroll .sec-micro-label {
  margin-top: 14px;
  margin-bottom: 2px;
}

.sos-steps {
  padding-left: 18px;
  margin-top: 8px;
  font-size: 13px;
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.sos-dials {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 9px;
}

.sos-link {
  display: flex;
  flex-direction: column;
  padding: 11px 13px;
  border-radius: 8px;
  background: var(--ink);
  color: var(--on-ink);
  text-decoration: none;
}

.sos-link strong {
  font-family: var(--font-mono);
  font-size: 17px;
  font-variant-numeric: tabular-nums;
}

.sos-link span {
  font-size: 11px;
  opacity: 0.82;
}

.two-col-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.three-col-fields {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.pw-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.adv-details {
  margin-top: 14px;
  padding: 11px 13px;
  border-radius: 9px;
  border: 1px solid var(--well-border);
  background: var(--well);
  box-shadow: var(--debossed);
}

.adv-details summary {
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
  color: var(--ink);
}

.attribution-note {
  margin-top: 14px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--muted);
  text-align: center;
}

/* ── Analyzing Spinner & Toast ───────────────────────────────────────────── */
.analyzing-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: var(--modal-scrim);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.analyzing-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 24px 32px;
  text-align: center;
  max-width: 340px;
}

.analyzing-text {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.3;
}

.analyzing-sub {
  font-size: 12.5px;
  color: var(--muted);
  line-height: 1.4;
}

.analyzing-sub:empty {
  display: none;
}

.spinner {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 3px solid var(--well);
  border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.toast {
  position: fixed;
  left: 50%;
  bottom: 84px;
  transform: translate(-50%, 14px);
  z-index: 110;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  width: max-content;
  max-width: calc(100vw - 28px);
  padding: 9px 14px;
  border-radius: 8px;
  border: 1px solid var(--hairline);
  background: var(--ink);
  color: var(--on-ink);
  font-size: 12.5px;
  font-weight: 700;
  box-shadow: 0 8px 20px rgba(18, 25, 36, 0.28);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* ── Responsive Desktop Widescreen Hardware Console (>= 860px) ───────────── */
@media (min-width: 860px) {
  .app-shell {
    max-width: 960px;
    padding: 0 20px;
  }

  .top-bar {
    padding: 12px 22px;
    border-radius: 0 0 12px 12px;
    border: 1px solid var(--hairline);
    border-top: none;
  }

  .main-content {
    padding: 12px 4px 72px;
  }

  .screen {
    gap: 11px;
  }

  .console-grid {
    display: grid;
    grid-template-columns: 368px minmax(0, 1fr);
    gap: 16px;
    align-items: start;
  }

  .console-col-primary,
  .console-col-secondary {
    gap: 9px;
  }

  .hw-card {
    padding: 12px 14px;
  }

  .dial-card {
    padding: 13px 14px;
    gap: 10px;
  }

  .metal-dial {
    width: 212px;
    height: 212px;
  }

  .dial-readout {
    padding: 0 4px;
    max-width: 124px;
  }

  .dial-num { font-size: 42px; }
  .dial-num.num-word { font-size: 30px; }
  .dial-caption { font-size: 8.2px; max-width: 100%; }

  .inst-grid {
    gap: 9px;
  }

  .inst-tile {
    padding: 10px 12px;
    gap: 7px;
  }

  .guard-row {
    padding: 10px 14px;
  }

  .knurl-slider-wrap {
    margin-top: 9px;
  }

  .debossed-screen {
    padding: 11px 14px;
  }

  .meter-divider {
    margin: 9px 0 8px;
  }

  .meter-tabs-row {
    margin-bottom: 6px;
  }

  .corridor-list {
    max-height: 76px;
    overflow-y: auto;
    padding-right: 2px;
  }

  .rules-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .bottom-dock {
    max-width: 460px;
    width: 100%;
    margin: 0 auto 8px;
    padding: 6px 12px 7px;
    border: 1px solid var(--hairline);
    border-radius: 10px;
    bottom: 6px;
  }

  .bottom-dock .nav-btn.nav-fab {
    width: 44px;
    height: 44px;
    margin: -14px auto 0;
  }

  .modal-overlay {
    align-items: center;
  }
}

/* Compact 360px phones */
@media (max-width: 375px) {
  .brand-tag { display: none; }
  .main-content { padding: 12px 10px 88px; }
  .metal-dial { width: 210px; height: 210px; }
  .dial-num { font-size: 44px; }
  .dial-num.num-word { font-size: 34px; }
  .meter-value-lg { font-size: 26px; }
  .corridor-row { padding: 7px 8px; font-size: 11.5px; }
  .history-item { flex-wrap: wrap; }
  .hi-actions { margin-left: auto; }
}

.desktop-only-label { display: none; }
@media (min-width: 860px) {
  .desktop-only-label { display: block; }
}
.page-head > div:first-child { min-width: 0; flex: 1; }
