/* INVYONE Stage-2 — SCADA Dark Theme */

:root {
  --bg: #050a18;
  --bg-elevated: #081326;
  --bg-darker: #030814;
  --stroke: #aaaaaa;
  --stroke-strong: #ffffff;
  --flow: #5af9ff;
  --active: #7cff3a;
  --warning: #ff8a3a;
  --alarm: #ff4f9a;
  --idle: #2a3f5a;
  --text: #ffffff;
  --text-muted: #cfd3d8;
  --text-dim: #8590a3;
  --selected: #ffd66b;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font-family: 'Segoe UI', Tahoma, Arial, sans-serif; overflow: hidden; }
body { display: flex; flex-direction: column; }

/* ===== TOP BAR ===== */
.topbar {
  display: flex; align-items: center; gap: 16px;
  padding: 8px 16px; height: 50px;
  background: linear-gradient(180deg, #0b1a35, #050a18);
  border-bottom: 1px solid var(--stroke);
  flex-shrink: 0;
}
.topbar h1 { margin: 0; font-size: 18px; color: var(--flow); letter-spacing: 1px; font-weight: 600; }
.topbar .subtitle { font-size: 11px; color: var(--text-muted); }
.topbar .spacer { flex: 1; }
.topbar .mode-display {
  padding: 4px 12px; background: var(--bg-elevated); border: 1px solid var(--stroke);
  font-family: Consolas, monospace; font-size: 14px; color: var(--active);
}
.topbar .mode-display .label { color: var(--text-muted); margin-right: 8px; font-size: 11px; }
.topbar .clock { font-family: Consolas, monospace; font-size: 14px; color: var(--text); }

/* ===== MAIN LAYOUT ===== */
.main {
  display: flex; flex: 1; min-height: 0;
}
.scene-wrap {
  flex: 1; min-width: 0; position: relative;
  background: radial-gradient(ellipse at center, #0a1628 0%, #050a18 100%);
  display: flex; align-items: center; justify-content: center;
}
.scene-wrap svg { width: 100%; height: 100%; }

.sidebar {
  width: 380px; flex-shrink: 0;
  background: var(--bg-elevated);
  border-left: 1px solid var(--stroke);
  display: flex; flex-direction: column;
  overflow: hidden;
}
.sidebar-section { border-bottom: 1px solid #1a2a45; padding: 12px; }
.sidebar-section h2 { margin: 0 0 8px 0; font-size: 11px; color: var(--text-muted); letter-spacing: 1.5px; text-transform: uppercase; }

/* ===== MODE BUTTONS ===== */
.modes { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.modes button {
  padding: 8px 4px; font-size: 11px; font-weight: 600;
  background: var(--bg-darker); color: var(--text-muted);
  border: 1px solid var(--stroke); cursor: pointer; transition: all .15s;
}
.modes button:hover { background: #11203a; color: var(--text); }
.modes button.active { background: var(--active); color: #000; border-color: var(--active); }

.controls-row { display: flex; gap: 6px; margin-top: 8px; }
.controls-row button {
  flex: 1; padding: 6px; font-size: 11px;
  background: var(--bg-darker); color: var(--text); border: 1px solid var(--stroke); cursor: pointer;
}
.controls-row button:hover { background: #11203a; }
.controls-row button.danger { color: var(--alarm); border-color: var(--alarm); }
.controls-row button.warn { color: var(--warning); border-color: var(--warning); }

.global-slider { display: flex; align-items: center; gap: 8px; margin-top: 8px; font-size: 11px; color: var(--text-muted); }
.global-slider input { flex: 1; }

/* ===== INSPECTOR ===== */
.inspector { flex: 1; padding: 12px; overflow-y: auto; }
.inspector h3 { margin: 0 0 12px 0; font-size: 14px; color: var(--flow); }
.inspector .row { display: flex; justify-content: space-between; padding: 4px 0; font-size: 12px; border-bottom: 1px dashed #1a2a45; }
.inspector .row span { color: var(--text-muted); }
.inspector .row b { color: var(--text); font-family: Consolas, monospace; }
.inspector .row b.on { color: var(--active); }
.inspector .row b.off { color: var(--idle); }
.inspector input[type="range"] { width: 100%; margin: 8px 0; accent-color: var(--flow); }
.inspector .actions { margin-top: 12px; display: flex; gap: 6px; }
.inspector .actions button {
  flex: 1; padding: 8px; font-size: 12px; font-weight: 600;
  background: var(--bg-darker); color: var(--text); border: 1px solid var(--stroke); cursor: pointer;
}
.inspector .actions button:hover { background: #11203a; }
.inspector .alarm-tag { padding: 2px 6px; border-radius: 2px; font-size: 10px; }
.inspector .alarm-tag.hh, .inspector .alarm-tag.ll, .inspector .alarm-tag.hi, .inspector .alarm-tag.lo { background: var(--alarm); color: #000; }
.inspector .alarm-tag.hl, .inspector .alarm-tag.lh { background: var(--warning); color: #000; }
.inspector .muted { color: var(--text-dim); font-size: 11px; }
.inspector .muted.small { font-size: 10px; margin-top: 8px; }
.inspector .inspector-empty { color: var(--text-dim); font-size: 12px; }
.inspector .inspector-empty .hint { margin: 12px 0 0 16px; padding: 0; }
.inspector .inspector-empty .hint li { margin: 4px 0; }

/* ===== EVENT LOG ===== */
.eventlog-wrap {
  height: 160px; flex-shrink: 0;
  background: var(--bg-darker);
  border-top: 1px solid var(--stroke);
  padding: 8px 12px; display: flex; flex-direction: column;
}
.eventlog-wrap h2 { margin: 0 0 6px 0; font-size: 11px; color: var(--text-muted); letter-spacing: 1.5px; }
#event-log {
  flex: 1; overflow-y: auto; font-family: Consolas, 'Courier New', monospace; font-size: 11px;
}
.event-line { padding: 1px 0; }
.event-line.event-info { color: var(--text-muted); }
.event-line.event-warn { color: var(--warning); }
.event-line.event-alarm { color: var(--alarm); font-weight: 600; }

/* ============================================================
   SVG COMPONENT STATES
   ============================================================ */

/* Component base */
.comp { cursor: pointer; }
.comp:not(.comp-pipe):not(.comp-panel):not(.comp-tile) { transition: filter .15s; }
.comp:not(.comp-pipe):not(.comp-panel):hover { filter: drop-shadow(0 0 4px var(--flow)) brightness(1.15); }
.comp.selected { outline: 2px dashed var(--selected); }
.comp .comp-label { fill: var(--text); font-family: Arial, sans-serif; }

/* Tank text */
.tank-text { fill: var(--text); font-family: Consolas, monospace; }
.tank-shell { /* metal frame */ }

/* Tank alarm pulse on level-bg */
@keyframes pulse-alarm {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.55; }
}
.comp.comp-tank.alarm-hh [id$="-level-bg"],
.comp.comp-tank.alarm-ll [id$="-level-bg"] { animation: pulse-alarm 0.8s infinite; }
.comp.comp-tank.alarm-hl [id$="-level-bg"],
.comp.comp-tank.alarm-lh [id$="-level-bg"] { animation: pulse-alarm 1.4s infinite; }

/* PUMP impeller spin (running) */
@keyframes spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}
.pump-impeller, .blower-fan {
  transform-box: fill-box;
  transform-origin: center;
}
.comp.comp-pump.running .pump-impeller,
.comp.comp-pump.running .blower-fan { animation: spin 0.8s linear infinite; }
.comp.comp-pump.running .pump-led      { fill: var(--active); }
.comp.comp-pump:not(.running) .pump-led { fill: var(--idle); }

/* VALVE handle rotation */
.valve-handle {
  transform-box: fill-box;
  transform-origin: center;
  transition: transform .25s;
}
.comp.comp-valve.closed .valve-handle { transform: rotate(90deg); }

/* FLOW lines — wave highlight on top of pipe body fluid (no visible dashes when idle) */
.flow {
  opacity: 0;
  stroke-dasharray: 12 28;
  stroke-width: 1.8;
  transition: opacity 0.4s;
}
.flow.active {
  opacity: 0.9;
  animation: flow-march 1.4s linear infinite;
}
.flow.blocked {
  stroke: var(--alarm) !important;
  opacity: 0.95;
  animation: flow-blink 0.6s linear infinite;
}
@keyframes flow-march {
  from { stroke-dashoffset: 0; }
  to   { stroke-dashoffset: -40; }
}
@keyframes flow-blink {
  0%, 100% { opacity: 0.4; }
  50%      { opacity: 1; }
}

/* Pipe fluid fill — uses fixed large dasharray (3000 covers the longest path).
   Idle: dashoffset = 3000 → fully hidden. Active: 0 → revealed.
   No JS measurement needed; CSS does it all. */
.pipe-fluid {
  pointer-events: none;
  stroke-dasharray: 3000;
  stroke-dashoffset: 3000;
  transition: stroke-dashoffset 1.2s linear;
}
.comp-pipe.active .pipe-fluid {
  stroke-dashoffset: 0 !important;
}
/* CHEM dosing lines — green fluid (chemical, not raw water) */
#pipe-p-chem-uf-fluid,
#pipe-p-chemuf-out-fluid {
  stroke: #7cff3a !important;
}
#pipe-p-chem-uf-flow,
#pipe-p-chemuf-out-flow {
  stroke: #7cff3a !important;
}
/* CIP cleaning lines — magenta */
#pipe-p-cip-ro-fluid,
#pipe-p-ciptank-pump-fluid {
  stroke: #ff4f9a !important;
}
#pipe-p-cip-ro-flow,
#pipe-p-ciptank-pump-flow {
  stroke: #ff4f9a !important;
}
/* Hide dash on filter internal flow when idle (no point-line look) */
.filter-internal-flow {
  opacity: 0;
  stroke-dasharray: 6 12;
  stroke-width: 1.5;
}
.comp-filter.active .filter-internal-flow {
  opacity: 0.9;
  animation: flow-march 1.0s linear infinite;
}
/* Membrane internal downflow — wave-style */
.membrane-flow {
  opacity: 0;
  stroke-dasharray: 8 16;
  stroke-width: 1.6;
}
.comp-module.active .membrane-flow {
  opacity: 0.85;
  animation: flow-march 1.2s linear infinite;
}

/* Module fluid level — solid color shift when active (no pulse) */
.comp-module .cell-fluid, .comp-module .cartridge-fluid {
  transition: opacity .35s, fill .25s;
  opacity: 0.30;
}
.comp-module.active .cell-fluid,
.comp-module.active .cartridge-fluid {
  opacity: 0.85;
}
/* Module manifold flow lines on active — slightly brighter, no glow noise */
.comp-module.active .module-flow {
  stroke-width: 2.6;
}
/* Manifold pipe — static metal, no glow */
.manifold-header { /* no transition / filter — keep it calm */ }
.comp-module .cell-fiber { opacity: 0.45; }
.tmp-readout, .mode-readout { pointer-events: none; }
.comp-module.active .tmp-readout text:last-child { fill: #7cff3a; }

/* UF inlet valve indicators — static, no transition glow */
.cell-inlet-valve { opacity: 0.85; }
.cell-outlet-stub { opacity: 0.7; }

/* BACKWASH mode — reverse-flow color (cyan → orange) on UF system */
.comp-module.mode-backwash .cell-fluid     { fill: #ff8a3a !important; }
.comp-module.mode-backwash .membrane-flow  { stroke: #ff8a3a !important; }
.comp-module.mode-backwash .module-flow    { stroke: #ff8a3a !important; }
.comp-module.mode-backwash .cell-inlet-valve circle { stroke: #ff8a3a !important; }
.comp-module.mode-backwash .cell-inlet-valve line:last-of-type { stroke: #ff8a3a !important; }
.comp-module.mode-backwash .manifold-header { filter: drop-shadow(0 0 4px #ff8a3a) !important; }

/* CIP mode — chemical-clean magenta */
.comp-module.mode-cip .cell-fluid    { fill: #ff4f9a !important; }
.comp-module.mode-cip .membrane-flow { stroke: #ff4f9a !important; }
.comp-module.mode-cip .module-flow   { stroke: #ff4f9a !important; }

/* Filter cartridge: housing fills with fluid + internal dash flow when feed pump is running */
.filter-element       { transition: fill .35s, stroke .25s; }
.filter-fluid         { transition: opacity .35s; }
.filter-housing-fluid { transition: opacity .35s; }
.filter-core-flow     { transition: opacity .25s; }
.filter-arrow         { transition: opacity .25s, fill .25s; }

.comp-filter:hover .filter-element { stroke: #5af9ff; }

/* ACTIVE state — visible fluid + flowing dashes inside */
.comp-filter.active .filter-housing-bg    { fill: #0a2438; }
.comp-filter.active .filter-housing-fluid { opacity: 0.22; }
.comp-filter.active .filter-element       { fill: #1a4a5a; stroke: #5af9ff; }
.comp-filter.active .filter-fluid         { opacity: 0.55; }
.comp-filter.active .filter-core-flow     { opacity: 1; animation: flow-march 0.5s linear infinite; }
.comp-filter.active .filter-arrow         { opacity: 1; fill: #7cff3a; }
/* MBR aeration: when AIR BLOWER drives MBR, tank shell pulses cyan */
@keyframes aerationGlow {
  0%, 100% { stroke: #fff;     filter: none; }
  50%      { stroke: #5af9ff;  filter: drop-shadow(0 0 6px #5af9ff); }
}
.comp-tank-mbr.aerating .tank-shell {
  animation: aerationGlow 2s ease-in-out infinite;
}

/* MBR aeration bubbles — rise from bottom of liquid, fade out near surface */
.mbr-bubbles .bubble {
  transform-box: fill-box;
  transform-origin: center;
}
@keyframes bubbleRise {
  0%   { transform: translateY(0px);    opacity: 0; }
  10%  { opacity: 0.85; }
  85%  { opacity: 0.85; }
  100% { transform: translateY(-110px); opacity: 0; }
}
.comp-tank-mbr.aerating .mbr-bubbles .bubble {
  animation: bubbleRise 2.4s ease-in infinite;
}

/* Sensor alarm */
.comp-sensor { transition: filter .15s; }
.comp-sensor.alarm rect { fill: #2a0a14 !important; stroke: var(--alarm) !important; }
.comp-sensor.alarm .sensor-value { fill: var(--alarm) !important; }
.comp-sensor.alarm { animation: pulse-alarm 0.8s infinite; }

/* Sensor */
.sensor-label { fill: var(--text-muted); }
.sensor-value { fill: var(--text); font-family: Consolas, monospace; }
.sensor-unit  { fill: var(--text-dim); }

/* Gauge */
.gauge-readout { fill: var(--text); font-family: Consolas, monospace; }
.gauge-title   { fill: var(--text); }
.gauge-unit    { fill: var(--text-muted); }
.gauge-needle  { transition: transform .25s ease-out; }
/* needle rotation driven by SVG transform attribute via JS — rotate(angle 40 40) */

/* Tile */
.tile-label { fill: var(--text-muted); }
.tile-value { fill: var(--active); font-family: Consolas, monospace; font-weight: bold; }
.tile-unit  { fill: var(--text-muted); }
.comp-tile.alarm rect { fill: #2a0a14 !important; stroke: var(--alarm) !important; }
.comp-tile.alarm .tile-value { fill: var(--alarm) !important; }

/* LED */
.led-status { transition: fill .15s; }

/* Panel frame label */
.panel-label { fill: var(--warning); font-family: Arial; font-weight: 600; }

/* Cartridge */
.cartridge { transition: opacity .2s; }
.cartridge.isolated { opacity: 0.3; }
.cartridge.isolated .cartridge-shell { stroke: var(--alarm) !important; stroke-dasharray: 3 2; }
.cartridge.isolated .cartridge-fluid { opacity: 0.05 !important; }

/* Selected outline */
.comp.selected > rect:first-of-type,
.comp.selected > circle:first-of-type {
  stroke: var(--selected) !important;
  stroke-width: 2 !important;
}

/* Scrollbar */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--bg-darker); }
::-webkit-scrollbar-thumb { background: #2a3f5a; border-radius: 0; }
::-webkit-scrollbar-thumb:hover { background: #3a5278; }

/* ============================================================
   EMERGENCY SCENARIO — 경고시스템 시연 영역
   ============================================================ */

/* 경고 버튼 (사이드바) — voice-btn 과 동일 패턴, 핑크 액센트 */
.controls-row button.emergency {
  position: relative; overflow: hidden;
  display: flex; align-items: center; gap: 10px;
  width: 100%;
  padding: 11px 14px;
  background: linear-gradient(135deg, rgba(255,79,154,0.10), rgba(255,79,154,0.02) 60%, transparent);
  color: #ff8eb6;
  border: 1px solid rgba(255,79,154,0.50);
  border-radius: 6px;
  font-size: 12px; font-weight: 700;
  letter-spacing: 0.12em;
  text-shadow: none;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, color 0.2s, box-shadow 0.2s;
  box-shadow:
    inset 0 0 12px rgba(255,79,154,0.10),
    0 0 8px rgba(255,79,154,0.20);
}
.controls-row button.emergency::before {
  content: ""; position: absolute;
  top: 0; left: 8%; right: 8%; height: 1px;
  background: linear-gradient(90deg, transparent, #ff4f9a, transparent);
  opacity: 0.7;
}
.controls-row button.emergency:hover {
  background: linear-gradient(135deg, rgba(255,79,154,0.22), rgba(255,79,154,0.08) 60%, transparent);
  border-color: #ff4f9a; color: #fff;
  box-shadow:
    inset 0 0 18px rgba(255,79,154,0.20),
    0 0 18px rgba(255,79,154,0.45);
}
.controls-row button.emergency .ico {
  width: 16px; height: 16px; flex-shrink: 0;
  filter: drop-shadow(0 0 4px rgba(255,79,154,0.6));
}
.controls-row button.emergency .lbl { flex: 1; text-align: left; }
.controls-row button.emergency .dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: #ff4f9a;
  box-shadow: 0 0 6px rgba(255,79,154,0.7);
  flex-shrink: 0;
}

/* 다중 경고 — 같은 톤이지만 주황 액센트 (정적) */
.controls-row button.emergency.multi {
  background: linear-gradient(135deg, rgba(255,79,154,0.10), rgba(255,138,58,0.10) 60%, transparent);
  color: #ffb380;
  border-color: rgba(255,138,58,0.55);
  box-shadow:
    inset 0 0 14px rgba(255,138,58,0.14),
    0 0 10px rgba(255,138,58,0.28);
}
.controls-row button.emergency.multi::before {
  background: linear-gradient(90deg, transparent, #ff8a3a, transparent);
  opacity: 1;
}
.controls-row button.emergency.multi:hover {
  background: linear-gradient(135deg, rgba(255,79,154,0.22), rgba(255,138,58,0.18) 60%, transparent);
  border-color: #ff8a3a; color: #fff;
  box-shadow:
    inset 0 0 22px rgba(255,138,58,0.22),
    0 0 22px rgba(255,138,58,0.55);
}
.controls-row button.emergency.multi .ico {
  filter: drop-shadow(0 0 5px rgba(255,138,58,0.75));
}
.controls-row button.emergency.multi .dot {
  background: #ff8a3a;
  box-shadow: 0 0 8px rgba(255,138,58,0.8);
}

/* 다중 경고 — 메인 모달 바로 아래 가로 stack, 메인 모달 톤의 mini-modal 카드 */
.alarm-list-dock {
  position: fixed;
  top: calc(50% + 31vh + 14px); /* 메인 모달(with-multi: max-height 62vh) 의 bottom + gap */
  bottom: auto;
  left: calc(50% - 732px); /* 메인 모달과 좌측 정렬 */
  transform: none;
  width: 960px;
  max-width: calc(100vw - 48px);
  height: auto;
  background: transparent;
  border: none;
  z-index: 103;
  display: none;
  flex-direction: row;
  gap: 14px;
  font-family: Consolas, monospace;
  box-shadow: none;
}
.alarm-list-dock.show { display: flex; }
.alarm-list-dock > header { display: none; }
#alarm-list-rows {
  display: flex;
  flex-direction: row;
  gap: 14px;
  width: 100%;
  align-items: stretch;
}

/* mini-modal — 메인 emergency-modal 의 컴팩트 버전 */
.alarm-mini-modal {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, #081326 0%, #050a18 100%);
  border: 1px solid #2a3f5a;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.5);
  font-family: Consolas, monospace;
}
.alarm-mini-modal.severity-high   { border-left: 4px solid #ff8a3a; }
.alarm-mini-modal.severity-medium { border-left: 3px solid #ffd400; }

/* head */
.alarm-mini-modal .mini-head {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px;
  background: #0d1a2e;
  border-bottom: 1px solid #2a3f5a;
}
.alarm-mini-modal .mini-head-left { display: flex; gap: 6px; align-items: center; }
.alarm-mini-modal .mini-severity {
  padding: 2px 8px;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 1.5px;
  color: #fff;
}
.alarm-mini-modal .mini-severity.severity-high   { background: #ff8a3a; color: #000; }
.alarm-mini-modal .mini-severity.severity-medium { background: #ffd400; color: #000; }
.alarm-mini-modal .mini-code {
  padding: 2px 6px;
  border: 1px solid #3a5278;
  font-size: 10px;
  color: #cfd3d8;
}
.alarm-mini-modal .mini-title {
  flex: 1;
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.alarm-mini-modal .mini-close {
  background: transparent;
  border: none;
  color: #ff8eb6;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  padding: 0 4px;
}
.alarm-mini-modal .mini-close:hover { color: #fff; }

/* location bar — 메인 모달 .modal-location 톤 */
.alarm-mini-modal .mini-location {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 12px;
  background: #0a1628;
  border-bottom: 1px solid #1a2a44;
  font-size: 11px;
  color: var(--text-muted);
}
.alarm-mini-modal .mini-location .mini-loc-icon { color: #ff4f9a; }
.alarm-mini-modal .mini-location b { color: #fff; font-weight: 700; font-family: Consolas, monospace; }
.alarm-mini-modal .mini-location .mini-loc-time { margin-left: auto; color: #5af9ff; font-size: 10px; }

/* body — 알람 상세 */
.alarm-mini-modal .mini-message {
  flex: 1;
  min-height: 0;
  padding: 10px 12px;
  border-bottom: 1px solid #2a3f5a;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.alarm-mini-modal .mini-msg-label {
  font-size: 10px;
  color: #ff8eb6;
  font-weight: 700;
  margin-bottom: 4px;
  letter-spacing: 0.5px;
  flex-shrink: 0;
}
.alarm-mini-modal .mini-msg-text {
  font-size: 12px;
  color: #fff;
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 0;
}
.alarm-mini-modal.severity-medium .mini-msg-text { color: #cfd3d8; }

/* footer */
.alarm-mini-modal .mini-foot {
  display: flex;
  gap: 8px;
  padding: 8px 12px;
  background: var(--bg-darker);
}
.alarm-mini-modal .mini-btn {
  padding: 6px 12px;
  background: var(--bg-darker);
  border: 1px solid var(--stroke);
  font-size: 11px;
  font-family: inherit;
  font-weight: 700;
  letter-spacing: 0.5px;
  cursor: pointer;
}
.alarm-mini-modal .mini-btn-skip { color: var(--text-muted); }
.alarm-mini-modal .mini-btn-skip:hover { color: var(--text); border-color: #fff; }
.alarm-mini-modal .mini-btn-ack {
  margin-left: auto;
  background: var(--active);
  color: #000;
  border-color: var(--active);
}
.alarm-mini-modal .mini-btn-ack:hover { background: #5fff20; }
@keyframes emergencyPulse {
  0%   { box-shadow: 0 0 0 0 rgba(255, 79, 154, 0.6); }
  70%  { box-shadow: 0 0 0 12px rgba(255, 79, 154, 0); }
  100% { box-shadow: 0 0 0 0 rgba(255, 79, 154, 0); }
}

/* P&ID 안의 시나리오 타겟 강조 — 빨간 정적 glow */
.comp.scenario-target { filter: drop-shadow(0 0 6px rgba(220,28,46,0.95)); }
.comp.scenario-flash { /* brightness 깜빡임 제거 — ⚠ 핀의 ring pulse 가 알람 식별 담당 */ }

/* P&ID 알람 핀 — severity 별 시각 위계 */
.scenario-alarm-pin .pin-ring-1,
.scenario-alarm-pin .pin-ring-2,
.scenario-alarm-pin .pin-core {
  transform-box: fill-box;
  transform-origin: center;
}
@keyframes pinRingPulse {
  0%   { transform: scale(0.85); opacity: 0.7; }
  100% { transform: scale(1.9); opacity: 0; }
}
@keyframes pinCoreBeat {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.08); }
}
/* CRITICAL — 가장 강조: ring pulse 두 개 stagger + core beat */
.scenario-alarm-pin.severity-critical .pin-ring-1 { animation: pinRingPulse 1.6s ease-out infinite; }
.scenario-alarm-pin.severity-critical .pin-ring-2 { animation: pinRingPulse 1.6s ease-out 0.8s infinite; }
.scenario-alarm-pin.severity-critical .pin-core   { animation: pinCoreBeat 1.1s ease-in-out infinite; }
/* HIGH — 보조: ring 한 개만 약하게 pulse, core 정적 */
.scenario-alarm-pin.severity-high .pin-ring-1 { animation: pinRingPulse 2.4s ease-out infinite; }
.scenario-alarm-pin.severity-high .pin-ring-2 { display: none; }
/* MEDIUM — 가장 약함: 모두 정적 */
.scenario-alarm-pin.severity-medium .pin-ring-1,
.scenario-alarm-pin.severity-medium .pin-ring-2 { display: none; }

/* hazard 점선 inner 박스 — 천천히 march */
@keyframes hazardMarch {
  from { stroke-dashoffset: 0; }
  to   { stroke-dashoffset: -14; }
}
.scenario-alarm-rect-inner { animation: hazardMarch 1.2s linear infinite; }

/* ============= 전체 화면 CRITICAL 이펙트 (절제) ============= */
body.critical-alarm::before {
  content: "";
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  pointer-events: none;
  z-index: 90; /* 모달(102), 맵(101) 아래 */
  box-shadow: inset 0 0 140px 30px rgba(220, 28, 46, 0.22);
  border: 2px solid rgba(220, 28, 46, 0.65);
  animation: criticalVignette 1.8s ease-in-out infinite;
  transition: right 0.6s cubic-bezier(0.22, 1, 0.36, 1);
}
/* 맵 panel 이 열려있으면 vignette 자체 숨김 (모달 + 맵 둘 다 떠있으면 위험 알림은 모달 + 핀으로 충분) */
body.critical-alarm.map-open::before { display: none; }
@keyframes criticalVignette {
  0%, 100% {
    box-shadow: inset 0 0 130px 25px rgba(220, 28, 46, 0.18);
    border-color: rgba(220, 28, 46, 0.55);
  }
  50% {
    box-shadow: inset 0 0 170px 40px rgba(220, 28, 46, 0.32);
    border-color: rgba(220, 28, 46, 0.85);
  }
}
/* (z-index 우선순위는 .map-panel 정의 위치(아래)에서 직접 박음 — cascade override 방지) */

/* 상단 알람 배너 */
.alarm-banner {
  position: fixed;
  top: 50px;
  left: 0; right: 0;
  background: linear-gradient(90deg, #3a0e1e 0%, #8a3258 50%, #3a0e1e 100%);
  background-size: 200% 100%;
  padding: 11px 24px;
  border-bottom: 1px solid #5a3548;
  border-top: 1px solid rgba(255,255,255,0.08);
  color: #fff;
  align-items: center; gap: 14px;
  font-family: Consolas, monospace;
  z-index: 105; /* 모달(100) 위, 핸드폰(110) 아래 */
  display: none;
  pointer-events: none;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.45);
}
/* 맵 모달이 가운데 정렬 별도 모달이라 배너는 fullscreen 유지 (right shift 제거) */
.alarm-banner.with-map { right: 0; }
.alarm-banner.show {
  display: flex;
  pointer-events: auto;
  animation: bannerScroll 8s linear infinite;
}
@keyframes bannerScroll {
  0%   { background-position: 200% 0; }
  100% { background-position: 0% 0; }
}
.alarm-banner-icon {
  font-size: 22px;
  animation: pinIconBlink 0.55s infinite;
  text-shadow: 0 0 8px #fff;
}
.alarm-banner-severity {
  background: #fff; color: #ff1f6a;
  padding: 4px 11px; font-weight: 800; font-size: 11px;
  letter-spacing: 2px;
  box-shadow: 0 0 8px rgba(255,255,255,0.5);
}
.alarm-banner-code {
  font-size: 12px; padding: 4px 10px;
  background: rgba(0,0,0,0.35);
  border: 1px solid rgba(255,255,255,0.6);
  letter-spacing: 0.5px;
}
.alarm-banner-msg {
  flex: 1;
  font-size: 13px;
  font-weight: 600;
  text-shadow: 0 0 4px rgba(0,0,0,0.5);
  letter-spacing: 0.3px;
}
.alarm-banner-loc {
  display: flex; gap: 8px; align-items: center;
  background: rgba(0,0,0,0.4);
  padding: 6px 12px;
  border: 1px solid rgba(255,255,255,0.5);
  font-size: 12px;
}
.alarm-banner-loc .loc-pin {
  font-size: 14px;
  animation: locPinBounce 1.2s ease-in-out infinite;
}
@keyframes locPinBounce {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-3px); }
}
.alarm-banner-loc b { color: #fff; font-weight: 700; }

/* 모달 — 위치 표시 행 */
.modal-location {
  display: flex; gap: 12px; align-items: center;
  padding: 10px 18px;
  background: rgba(255, 79, 154, 0.10);
  border-bottom: 1px solid rgba(255, 79, 154, 0.3);
  font-size: 12px;
}
.modal-location .loc-icon {
  font-size: 16px;
  animation: locPinBounce 1.2s ease-in-out infinite;
}
.modal-location .loc-text { color: var(--text-muted); }
.modal-location .loc-text b { color: #fff; font-family: Consolas, monospace; font-weight: 700; }
.modal-location .loc-pointer {
  margin-left: auto;
  font-size: 11px;
  color: #ff8eb6;
  font-style: italic;
  animation: pinIconBlink 1.2s ease-in-out infinite;
}

/* ============================================================
   회사 맵 패널 (우측 슬라이드 인)
   ============================================================ */
.map-panel {
  position: fixed;
  top: 50%;
  left: calc(50% + 252px);
  width: 480px;
  max-height: 84vh;
  height: auto;
  background: linear-gradient(180deg, #081326 0%, #050a18 100%);
  border: 1px solid #2a3f5a;
  display: none;
  flex-direction: column;
  transform: translateY(-50%);
  z-index: 103; /* 메인 모달 backdrop(102) 위 — 나란히 sibling 모달 */
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.5);
  box-shadow: -8px 0 32px rgba(90, 249, 255, 0.15);
}
.map-panel.open { display: flex; }

.map-panel-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 18px;
  background: #0d1a2e;
  border-bottom: 1px solid #2a3f5a;
  flex-shrink: 0;
}
.map-panel-title { color: #fff; font-size: 13px; font-weight: 700; letter-spacing: 1px; }
.map-panel-status { color: #cfd3d8; font-size: 10px; font-family: Consolas, monospace; }
.map-panel-status::before { content: "● "; }

.map-panel-body { flex: 1; min-height: 0; padding: 10px; }
.map-svg { width: 100%; height: 100%; }

.map-panel-foot {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 16px;
  background: var(--bg-darker);
  border-top: 1px solid #3a5278;
  flex-shrink: 0;
  font-size: 12px;
  color: var(--text-muted);
}
.map-status-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: #7cff3a;
  box-shadow: 0 0 6px #7cff3a;
  animation: pulse-alarm 1.5s infinite;
}

/* 맵 — 알람 핀 깜빡임 */
@keyframes alarmPinPulse {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.18); }
}
#map-alarm-pin.active {
  opacity: 1 !important;
  animation: alarmPinPulse 0.9s ease-in-out infinite;
  transform-origin: center;
  transform-box: fill-box;
}

/* 맵 — 경로 fade in */
#map-route.active {
  opacity: 1 !important;
  animation: dashMarch 0.8s linear infinite;
}
@keyframes dashMarch {
  from { stroke-dashoffset: 0; }
  to   { stroke-dashoffset: -20; }
}

/* 맵 — 담당자 이동 (transform transition) */
#map-officer { transition: transform 6s linear; }
#map-officer.moving > circle { animation: pulse-alarm 0.6s infinite; }

/* 도착 강조 */
.map-building.alarm-target rect {
  stroke: #ff4f9a !important;
  stroke-width: 2.5 !important;
  animation: pulse-alarm 1s infinite;
}

/* ============================================================
   핸드폰 알림 (우상단 fixed)
   ============================================================ */
.phone-notify {
  position: fixed;
  top: 70px;
  right: 30px;
  width: 280px;
  z-index: 110;
  display: none;
  pointer-events: none;
}
.phone-notify.show { display: block; pointer-events: auto; }
.phone-notify.shake .phone-frame { animation: phoneShake 0.4s ease-in-out 0s 8; }
@keyframes phoneShake {
  0%, 100% { transform: translateX(0) rotate(0); }
  25%      { transform: translateX(-3px) rotate(-1deg); }
  75%      { transform: translateX(3px) rotate(1deg); }
}

.phone-frame {
  background: #050a18;
  border: 3px solid #2a3f5a;
  border-radius: 28px;
  padding: 22px 8px 14px 8px;
  position: relative;
  box-shadow: 0 8px 32px rgba(0,0,0,0.6);
}
.phone-notch {
  position: absolute; top: 6px; left: 50%; transform: translateX(-50%);
  width: 80px; height: 14px; border-radius: 8px;
  background: #2a3f5a;
}
.phone-screen {
  background: #0a1628; border-radius: 18px;
  padding: 14px 10px;
  min-height: 200px;
  display: flex; flex-direction: column; gap: 12px;
}
.phone-time {
  text-align: center; color: #fff;
  font-family: Consolas, monospace;
  font-size: 22px; font-weight: 300;
  letter-spacing: 1px;
}

.phone-card {
  background: rgba(255, 79, 154, 0.12);
  border: 1px solid #ff4f9a;
  border-radius: 12px;
  padding: 10px 12px;
  backdrop-filter: blur(8px);
}
.phone-card-head {
  display: flex; align-items: center; gap: 6px;
  font-size: 10px; color: var(--text-muted);
  margin-bottom: 6px;
}
.phone-app-icon { font-size: 12px; }
.phone-app-name { font-weight: 700; color: #ff4f9a; }
.phone-time-dim { margin-left: auto; color: var(--text-dim); }
.phone-card-title {
  color: #fff; font-weight: 700; font-size: 13px; margin-bottom: 4px;
}
.phone-card-msg {
  color: var(--text-muted); font-size: 11px;
  line-height: 1.4; margin-bottom: 10px;
  white-space: pre-wrap;
}
.phone-card-actions {
  display: flex; gap: 6px;
}
.phone-btn {
  flex: 1; padding: 6px; font-size: 11px;
  border-radius: 6px; cursor: pointer;
  background: rgba(255,255,255,0.08); color: #fff;
  border: 1px solid rgba(255,255,255,0.2);
}
.phone-btn-confirm {
  background: #ff4f9a; border-color: #ff4f9a; color: #fff; font-weight: 700;
}
.phone-btn-confirm.tapped {
  background: #5a102c; transform: scale(0.95);
}
.phone-btn-confirm.highlight {
  animation: phoneTapHint 0.5s ease-in-out 4;
}
@keyframes phoneTapHint {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255,79,154,0.7); }
  50%      { box-shadow: 0 0 0 8px rgba(255,79,154,0); }
}

/* ============================================================
   모달 (CCTV + 담당자)
   ============================================================ */
.emergency-modal-backdrop {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(2, 6, 16, 0.88);
  backdrop-filter: blur(5px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 102; /* critical-alarm(90) + map-panel(101) 위 */
}
.emergency-modal-backdrop.show { display: flex; }
/* 맵 + 다중 카드 떠있으면 메인+맵 위쪽 정렬 (높이 65vh), 하단 22vh 에 보조 카드 stack */
.emergency-modal-backdrop.with-map .emergency-modal {
  position: fixed;
  top: 50%;
  left: calc(50% - 732px);
  transform: translateY(-50%);
  width: 960px;
  max-width: none;
  max-height: 70vh;
  height: auto;
}
/* 다중 경고 — 모달 + dock 을 .emergency-stack 으로 묶어서 viewport 안에서 자동 분할
   (어떤 해상도/줌에서도 dock 이 viewport 밖으로 잘리지 않도록 robust 하게) */
.emergency-stack {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 960px;
  max-width: calc(100vw - 48px);
  max-height: calc(100vh - 80px);
  display: flex;
  flex-direction: column;
  gap: 14px;
  z-index: 103;
}
.emergency-modal-backdrop.with-multi.with-map .emergency-stack {
  left: calc(50% - 732px);
  transform: translateY(-50%);
}
.emergency-modal-backdrop.with-multi .emergency-modal,
.emergency-modal-backdrop.with-multi.with-map .emergency-modal {
  position: static;
  top: auto;
  left: auto;
  transform: none;
  width: 100%;
  max-width: none;
  max-height: none;
  height: auto;
  flex: 1 1 auto;
  min-height: 0;
}
.emergency-modal-backdrop.with-multi .alarm-list-dock {
  position: static;
  top: auto;
  left: auto;
  transform: none;
  width: 100%;
  max-width: none;
  max-height: 32vh;
  flex: 0 0 auto;
}
.emergency-modal {
  width: min(960px, 92vw);
  max-height: 88vh;
  background: linear-gradient(180deg, #081326 0%, #050a18 100%);
  border: 1px solid #2a3f5a;
  box-shadow: 0 8px 28px rgba(0,0,0,0.5);
  display: flex; flex-direction: column;
}

.modal-head {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 18px;
  background: #0d1a2e;
  border-bottom: 1px solid #2a3f5a;
}
.modal-head-left { display: flex; gap: 8px; align-items: center; }
.modal-severity {
  background: #b8466e; color: #fff;
  padding: 3px 10px; font-size: 11px; font-weight: 700;
  letter-spacing: 1.5px;
}
.modal-code {
  font-family: Consolas, monospace; color: #cfd3d8;
  font-size: 11px; padding: 3px 8px; border: 1px solid #3a5278;
}
.modal-head-title { flex: 1; color: #fff; font-size: 16px; font-weight: 700; }
.modal-close {
  background: transparent; border: none; color: #ff8eb6;
  font-size: 24px; cursor: pointer; padding: 0 8px;
}
.modal-close:hover { color: #fff; }

.modal-body {
  display: grid; grid-template-columns: 1.4fr 1fr;
  gap: 16px; padding: 16px;
  flex: 1; min-height: 0;
}

/* CCTV 영역 (좌) */
.modal-cctv {
  display: flex; flex-direction: column; gap: 6px;
  background: #000; border: 1px solid #2a3f5a;
}
.cctv-bar {
  display: flex; gap: 12px; align-items: center;
  padding: 6px 10px; font-size: 10px;
  background: #0a1628; color: var(--text-muted);
  font-family: Consolas, monospace;
}
.cctv-rec {
  color: #d05880; font-weight: 700;
}
.cctv-cam { flex: 1; color: #5af9ff; }
.cctv-time { color: var(--text); }

.cctv-screen {
  position: relative;
  flex: 1; min-height: 280px;
  background: #0a0a0a;
  overflow: hidden;
}
.cctv-noise {
  position: absolute; inset: 0;
  background:
    repeating-linear-gradient(0deg, rgba(255,255,255,0.04) 0 1px, transparent 1px 3px),
    repeating-linear-gradient(90deg, rgba(255,255,255,0.02) 0 1px, transparent 1px 4px);
  pointer-events: none;
  animation: cctvNoise 0.15s steps(4) infinite;
}
@keyframes cctvNoise {
  0%   { transform: translateY(0); }
  100% { transform: translateY(2px); }
}
.cctv-scanline {
  position: absolute; left: 0; right: 0; height: 30px;
  background: linear-gradient(180deg, transparent, rgba(90,249,255,0.08), transparent);
  pointer-events: none;
  animation: cctvScan 4s linear infinite;
}
@keyframes cctvScan {
  0%   { top: -30px; }
  100% { top: 100%; }
}
.cctv-placeholder {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  flex-direction: column;
  color: #5a7898;
}
.cctv-video {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  z-index: 0;
  opacity: 0;
  transition: opacity 0.45s ease;
  transform: translateZ(0);
}
.cctv-video.active { opacity: 1; }
.cctv-target-box {
  position: absolute; top: 30%; left: 30%;
  width: 40%; height: 40%;
  border: 1px dashed rgba(255,158,184,0.55);
}
.cctv-alert-icon {
  position: absolute; top: 10px; right: 10px;
  display: flex; gap: 6px; align-items: center;
  padding: 4px 9px;
  background: rgba(184,70,110,0.85);
  color: #fff;
  font-size: 11px; font-weight: 700;
  font-family: Consolas, monospace;
  letter-spacing: 1px;
  border-radius: 2px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.5);
  z-index: 5;
}
.cctv-alert-icon svg { display: block; }
.cctv-target-label {
  position: absolute; top: -20px; left: 0;
  background: rgba(184,70,110,0.85); color: #fff;
  padding: 2px 8px; font-size: 10px; font-weight: 700;
  font-family: Consolas, monospace;
}
.cctv-fake-pump {
  font-size: 80px;
  color: #2a3f5a;
  filter: drop-shadow(0 0 8px rgba(255,79,154,0.4));
  animation: spin 1.4s linear infinite;
}
.cctv-overlay-text {
  position: absolute; bottom: 14px;
  font-size: 10px; color: var(--text-dim);
  font-family: Consolas, monospace;
  letter-spacing: 1px;
}

.cctv-meta {
  display: flex; gap: 12px;
  padding: 6px 10px; font-size: 10px;
  background: #0a1628; color: var(--text-muted);
  font-family: Consolas, monospace;
}
.cctv-live { margin-left: auto; color: #d05880; }

/* 담당자 영역 (우) */
.modal-officer {
  display: flex; flex-direction: column; gap: 12px;
  background: rgba(11, 26, 53, 0.6);
  border: 1px solid #2a3f5a;
  padding: 14px;
}
.officer-head {
  font-size: 11px; color: #5af9ff; font-weight: 700;
  letter-spacing: 1.5px; text-transform: uppercase;
  border-bottom: 1px solid #2a3f5a; padding-bottom: 6px;
}
.officer-card {
  display: flex; gap: 12px; align-items: center;
}
.officer-avatar {
  width: 60px; height: 60px;
  background: linear-gradient(135deg, #5af9ff, #11203a);
  color: #000;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; font-weight: 700;
  border: 2px solid #5af9ff;
  border-radius: 50%;
  flex-shrink: 0;
  font-family: Arial, sans-serif;
  overflow: hidden;
}
.officer-avatar img {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
}
.officer-info { flex: 1; }
.officer-name { font-size: 16px; font-weight: 700; color: #fff; }
.officer-title { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.officer-role { font-size: 10px; color: var(--warning); margin-top: 4px; }

.officer-contact {
  display: flex; flex-direction: column; gap: 4px;
  font-size: 12px;
  background: var(--bg-darker);
  padding: 10px;
  border: 1px solid #1a2a45;
}
.officer-row { display: flex; justify-content: space-between; padding: 3px 0; }
.officer-row span { color: var(--text-muted); }
.officer-row b { color: #fff; font-family: Consolas, monospace; font-size: 11px; }
.officer-status { color: var(--warning) !important; }
.officer-status.delivered { color: #5af9ff !important; }
.officer-status.responding { color: var(--warning) !important; }
.officer-status.arrived   { color: var(--active) !important; }

.officer-action {
  margin-top: auto;
  padding: 12px;
  background: #1a2a45;
  color: #fff;
  border: 1px solid #3a5278;
  font-size: 13px; font-weight: 600;
  letter-spacing: 1px;
  cursor: pointer;
  display: flex; gap: 8px; align-items: center; justify-content: center;
  transition: background 0.2s, border-color 0.2s;
}
.officer-action:hover { background: #243553; border-color: #5af9ff; }
.dispatch-icon { font-size: 16px; }

/* 모달 알람 메시지 (하단) */
.modal-alarm-message {
  margin: 0 16px 12px;
  padding: 12px;
  background: rgba(20, 30, 50, 0.5);
  border-left: 2px solid rgba(184,70,110,0.7);
}
.alarm-msg-label {
  font-size: 10px; font-weight: 700;
  color: #d05880; letter-spacing: 1.5px;
  margin-bottom: 4px;
}
.alarm-msg-text {
  font-size: 12px; color: var(--text);
  white-space: pre-wrap; line-height: 1.5;
}

/* 모달 푸터 */
.modal-foot {
  display: flex; gap: 8px; padding: 10px 16px;
  border-top: 1px solid #2a3f5a;
  background: var(--bg-darker);
}
.modal-btn {
  padding: 10px 16px; font-size: 12px; font-weight: 700;
  cursor: pointer; letter-spacing: 1px;
  background: var(--bg-darker); color: var(--text);
  border: 1px solid var(--stroke);
}
.modal-btn-skip { color: var(--text-muted); }
.modal-btn-skip:hover { color: var(--text); border-color: #fff; }
.modal-btn-ack {
  margin-left: auto;
  background: var(--idle); color: var(--text-dim); border-color: var(--idle);
}
.modal-btn-ack:enabled {
  background: var(--active); color: #000; border-color: var(--active);
  animation: pulse-alarm 1.2s infinite;
}
.modal-btn-ack:enabled:hover { background: #5fff20; }
.modal-btn-ack:disabled { cursor: not-allowed; }

/* ============================================================
 * 음성 컨트롤 (voice.js)
 * SCADA 톤 — 청록 액센트 + 글로우 + 상단 라이트 라인
 * ============================================================ */
.voice-wrap{margin-top:10px; display:flex; flex-direction:column; gap:4px}
.voice-btn{
  position:relative; overflow:hidden;
  display:flex; align-items:center; gap:10px;
  width:100%;
  padding:11px 14px;
  background:linear-gradient(135deg, rgba(90,249,255,0.08), rgba(90,249,255,0.02) 60%, transparent);
  color:#5af9ff;
  border:1px solid rgba(90,249,255,0.45);
  border-radius:6px;
  cursor:pointer;
  font-size:12px; font-weight:700;
  letter-spacing:0.12em;
  transition:background 0.2s, border-color 0.2s, color 0.2s, box-shadow 0.2s;
  box-shadow:inset 0 0 12px rgba(90,249,255,0.08), 0 0 8px rgba(90,249,255,0.18);
}
.voice-btn::before{
  content:""; position:absolute;
  top:0; left:8%; right:8%; height:1px;
  background:linear-gradient(90deg, transparent, #5af9ff, transparent);
  opacity:0.7;
}
.voice-btn:hover:not(:disabled){
  background:linear-gradient(135deg, rgba(90,249,255,0.18), rgba(90,249,255,0.06) 60%, transparent);
  border-color:#5af9ff; color:#fff;
  box-shadow:inset 0 0 18px rgba(90,249,255,0.18), 0 0 18px rgba(90,249,255,0.4);
}
.voice-btn:disabled{opacity:0.35; cursor:not-allowed; box-shadow:none}
.voice-btn:disabled::before{display:none}

.voice-icon{
  width:16px; height:16px; flex-shrink:0;
  filter:drop-shadow(0 0 4px rgba(90,249,255,0.5));
}
.voice-label{flex:1; text-align:left}
.voice-status-dot{
  width:7px; height:7px; border-radius:50%;
  background:#5af9ff; opacity:0.4;
  box-shadow:0 0 6px rgba(90,249,255,0.6);
  flex-shrink:0;
}

/* listening 상태 — 빨강/주황 위험톤 + 강한 펄스 */
.voice-btn.listening{
  background:linear-gradient(135deg, rgba(255,45,107,0.28), rgba(255,138,58,0.18) 60%, transparent);
  color:#fff; border-color:#ff8a3a;
  animation:voice-pulse 1.2s ease-in-out infinite;
}
.voice-btn.listening::before{
  background:linear-gradient(90deg, transparent, #ff2d6b, transparent);
  opacity:1;
}
.voice-btn.listening .voice-icon{
  filter:drop-shadow(0 0 6px rgba(255,45,107,0.8));
}
.voice-btn.listening .voice-status-dot{
  background:#ff2d6b; opacity:1;
  box-shadow:0 0 10px rgba(255,45,107,0.9);
  animation:voice-dot-pulse 0.9s ease-in-out infinite;
}
@keyframes voice-pulse{
  0%,100%{box-shadow:inset 0 0 18px rgba(255,138,58,0.22), 0 0 14px rgba(255,138,58,0.5)}
  50%    {box-shadow:inset 0 0 24px rgba(255,45,107,0.4),  0 0 28px rgba(255,45,107,0.85)}
}
@keyframes voice-dot-pulse{
  0%,100%{transform:scale(1);   opacity:1}
  50%    {transform:scale(1.4); opacity:0.6}
}

.voice-transcript{
  font-size:11px; color:#5af9ff; min-height:14px;
  padding:3px 6px; font-style:italic;
  font-variant-numeric:tabular-nums;
  letter-spacing:0.02em;
}

/* 매칭된 컴포넌트 청록 펄스 (1.4s) */
.voice-flash{animation:voice-flash 1.4s ease-out 1}
@keyframes voice-flash{
  0%   {filter:drop-shadow(0 0 0 #5af9ff)}
  25%  {filter:drop-shadow(0 0 18px #5af9ff)}
  60%  {filter:drop-shadow(0 0 8px  #5af9ff)}
  100% {filter:drop-shadow(0 0 0 #5af9ff)}
}
