:root {
  --bg-main: #060913;
  --bg-card: #0d1322;
  --bg-glass: rgba(13, 19, 34, 0.94);
  --bg-surface: #121a2d;
  --bg-deep: #040711;
  --border: #1a2640;
  --border-glow: rgba(56, 189, 248, 0.4);
  --accent: #38bdf8;
  --accent-glow: rgba(56, 189, 248, 0.35);
  --gold: #fbbf24;
  --gold-glow: rgba(251, 191, 36, 0.4);
  --success: #10b981;
  --success-glow: rgba(16, 185, 129, 0.4);
  --danger: #ef4444;
  --text: #f8fafc;
  --text-dim: #94a3b8;
  --text-muted: #64748b;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --room-fill: rgba(15, 23, 42, 0.82);
  --outdoor-fill: rgba(45, 68, 54, 0.45);
  --outdoor-stroke: #4b6b57;
  --room-hover: rgba(30, 41, 59, 0.95);
  --room-stroke: #334155;
  --wall-stroke: #64748b;
  --window-stroke: #38bdf8;
  --door-stroke: #fbbf24;
  --opening-stroke: #64748b;
  --label-halo: rgba(6, 9, 19, 0.85);
  --pin-ring: #f8fafc;
  --pin-off: #475569;
  --graph-node-fill: #0b1120;
  --graph-node-hover: #1e293b;
  --graph-edge-passage: #38bdf8;
  --graph-edge-opening: #22c55e;
  --graph-edge-abuts: #64748b;
  --grid-line: rgba(56, 189, 248, 0.08);
  --grid-border: rgba(56, 189, 248, 0.25);
}

html[data-theme="light"] {
  --bg-main: #f1f5f9;
  --bg-card: #ffffff;
  --bg-glass: rgba(255, 255, 255, 0.95);
  --bg-surface: #e2e8f0;
  --bg-deep: #cbd5e1;
  --border: #cbd5e1;
  --border-glow: rgba(2, 132, 199, 0.3);
  --accent: #0284c7;
  --accent-glow: rgba(2, 132, 199, 0.25);
  --gold: #d97706;
  --gold-glow: rgba(217, 119, 6, 0.3);
  --success: #059669;
  --success-glow: rgba(5, 150, 105, 0.3);
  --danger: #dc2626;
  --text: #0f172a;
  --text-dim: #475569;
  --text-muted: #94a3b8;
  --room-fill: rgba(241, 245, 249, 0.85);
  --outdoor-fill: rgba(220, 235, 222, 0.75);
  --outdoor-stroke: #7ca085;
  --room-hover: rgba(226, 232, 240, 0.95);
  --room-stroke: #94a3b8;
  --wall-stroke: #475569;
  --window-stroke: #0284c7;
  --door-stroke: #d97706;
  --opening-stroke: #94a3b8;
  --label-halo: rgba(255, 255, 255, 0.9);
  --pin-ring: #0f172a;
  --pin-off: #94a3b8;
  --graph-node-fill: #ffffff;
  --graph-node-hover: #e2e8f0;
  --graph-edge-passage: #0284c7;
  --graph-edge-opening: #059669;
  --graph-edge-abuts: #94a3b8;
  --grid-line: rgba(2, 132, 199, 0.08);
  --grid-border: rgba(2, 132, 199, 0.25);
}

html[data-theme="blueprint"] {
  --bg-main: #0a192f;
  --bg-card: #0f2744;
  --bg-glass: rgba(15, 39, 68, 0.95);
  --bg-surface: #14355a;
  --bg-deep: #071324;
  --border: #1e4976;
  --border-glow: rgba(56, 189, 248, 0.45);
  --accent: #38bdf8;
  --accent-glow: rgba(56, 189, 248, 0.4);
  --gold: #facc15;
  --gold-glow: rgba(250, 204, 21, 0.4);
  --success: #34d399;
  --success-glow: rgba(52, 211, 153, 0.4);
  --danger: #f87171;
  --text: #f0f9ff;
  --text-dim: #93c5fd;
  --text-muted: #60a5fa;
  --font: "Courier New", Courier, monospace;
  --room-fill: rgba(10, 25, 47, 0.88);
  --outdoor-fill: rgba(20, 50, 40, 0.85);
  --outdoor-stroke: #3f7a63;
  --room-hover: rgba(20, 53, 90, 0.95);
  --room-stroke: #38bdf8;
  --wall-stroke: #7dd3fc;
  --window-stroke: #38bdf8;
  --door-stroke: #facc15;
  --opening-stroke: #38bdf8;
  --label-halo: rgba(10, 25, 47, 0.9);
  --pin-ring: #ffffff;
  --pin-off: #475569;
  --graph-node-fill: #0f2744;
  --graph-node-hover: #14355a;
  --graph-edge-passage: #38bdf8;
  --graph-edge-opening: #34d399;
  --graph-edge-abuts: #60a5fa;
  --grid-line: rgba(56, 189, 248, 0.15);
  --grid-border: rgba(56, 189, 248, 0.4);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  width: 100vw;
  max-width: 100vw;
  height: 100dvh;
  max-height: 100dvh;
  overflow: hidden;
  position: fixed;
  inset: 0;
  background: var(--bg-main);
  color: var(--text);
  font-family: var(--font);
  overscroll-behavior: none;
  -webkit-user-select: none;
  user-select: none;
  display: flex;
  flex-direction: column;
}

/* ================= HEADER HUD ================= */
header.hud-bar {
  height: 48px;
  flex-shrink: 0;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  z-index: 50;
  gap: 8px;
}

.brand-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}
.brand-icon {
  width: 28px;
  height: 28px;
  background: linear-gradient(135deg, var(--accent), #818cf8);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  color: #060913;
  font-size: 14px;
  box-shadow: 0 0 8px var(--accent-glow);
}
.status-pill {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 4px 9px;
  border-radius: 9999px;
  background: rgba(16, 185, 129, 0.15);
  color: var(--success);
  border: 1px solid rgba(16, 185, 129, 0.35);
  display: flex;
  align-items: center;
  gap: 5px;
}
.status-pill.dim {
  background: rgba(148, 163, 184, 0.1);
  color: var(--text-muted);
  border-color: var(--border);
}

.view-segment {
  display: flex;
  background: var(--bg-deep);
  padding: 3px;
  border-radius: 8px;
  border: 1px solid var(--border);
  gap: 3px;
}
.segment-btn {
  background: transparent;
  border: none;
  color: var(--text-dim);
  padding: 6px 12px;
  min-height: 34px;
  border-radius: 6px;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s ease;
  display: flex;
  align-items: center;
  gap: 4px;
}
.segment-btn.active {
  background: var(--accent);
  color: var(--bg-deep);
  box-shadow: 0 0 8px var(--accent-glow);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}
.icon-btn {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  color: var(--text);
  width: 38px;
  height: 38px;
  border-radius: 9px;
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.12s ease;
}
.icon-btn:active {
  transform: scale(0.92);
}
.icon-btn.active {
  background: var(--accent);
  color: var(--bg-deep);
  border-color: var(--accent);
}

/* ================= QUICK ACTION & FILTER STRIP ================= */
.quick-strip {
  height: 44px;
  flex-shrink: 0;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 10px;
  gap: 6px;
  overflow-x: auto;
  white-space: nowrap;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  z-index: 45;
}
.quick-strip::-webkit-scrollbar {
  display: none;
}

.strip-label {
  font-size: 0.65rem;
  font-weight: 800;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-right: 2px;
}

#room-quick-chips {
  display: flex;
  align-items: center;
  gap: 5px;
}

.chip {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-size: 0.74rem;
  font-weight: 700;
  padding: 9px 13px;
  min-height: 36px;
  border-radius: 8px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: all 0.12s ease;
  flex-shrink: 0;
}
.chip:active {
  transform: scale(0.94);
}
.chip.active {
  background: var(--accent);
  color: var(--bg-deep);
  border-color: var(--accent);
  font-weight: 800;
}

/* ================= ROOMS MENU OVERLAY ================= */
.rooms-menu {
  position: fixed;
  top: 88px;
  left: 8px;
  right: 8px;
  max-width: 500px;
  max-height: 50dvh;
  overflow-y: auto;
  background: var(--bg-card);
  border: 1px solid var(--border-glow);
  border-radius: 10px;
  padding: 10px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.65);
  z-index: 95;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.rooms-menu[hidden] {
  display: none;
}
.rooms-menu-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 6px;
}
.room-card-btn {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 8px;
  text-align: left;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 2px;
  transition: all 0.15s ease;
}
.room-card-btn:hover {
  background: var(--room-hover);
  border-color: var(--accent);
}
.room-card-btn.active {
  background: var(--accent);
  color: var(--bg-deep);
  border-color: var(--accent);
}
.room-card-btn.active .room-card-sub {
  color: var(--bg-deep);
  opacity: 0.85;
}
.room-card-title {
  font-size: 0.7rem;
  font-weight: 700;
}
.room-card-sub {
  font-size: 0.6rem;
  color: var(--text-muted);
}

/* ================= CENTRAL STAGE ================= */
main.stage {
  flex: 1;
  position: relative;
  overflow: hidden;
  background: radial-gradient(circle at center, var(--bg-surface) 0%, var(--bg-deep) 100%);
}

.view-panel {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
}
.view-panel.active {
  display: flex;
}

svg#floorplan-svg, svg#graph-svg {
  width: 100%;
  height: 100%;
  display: block;
}

/* SVG 2D Styles */
.svg-room {
  fill: var(--room-fill);
  stroke: var(--room-stroke);
  stroke-width: 0.35;
  cursor: pointer;
  transition: fill 0.15s ease, stroke 0.15s ease;
}
.svg-room:hover {
  fill: var(--room-hover);
}
.svg-room.has-power {
  fill: rgba(251, 191, 36, 0.09);
  stroke: rgba(251, 191, 36, 0.45);
}
.svg-room.has-power:hover {
  fill: rgba(251, 191, 36, 0.16);
}
.svg-room.focused {
  fill: rgba(56, 189, 248, 0.14);
  stroke: var(--accent);
  stroke-width: 0.65;
}
.svg-room.focused.has-power {
  fill: rgba(56, 189, 248, 0.18);
  stroke: var(--accent);
  stroke-width: 0.7;
}
.svg-room.dimmed {
  opacity: 0.14;
}
.svg-room.outdoor {
  fill: var(--outdoor-fill);
  stroke: var(--outdoor-stroke);
}
.svg-room.outdoor:hover {
  fill: var(--room-hover);
}
.svg-room.no-devices {
  opacity: 0.5;
}
.svg-device {
  font-size: 2.15px;
  text-anchor: middle;
  cursor: pointer;
}
.svg-device.off {
  opacity: 0.5;
}
.svg-device.offline {
  opacity: 0.4;
  filter: grayscale(1);
}
.svg-device-count {
  font-size: 1.05px;
  font-weight: 800;
  fill: var(--text-dim);
  text-anchor: start;
}

.svg-room-label {
  fill: var(--text);
  font-size: 1.25px;
  font-weight: 800;
  text-anchor: middle;
  pointer-events: auto;
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: 0.05px;
  paint-order: stroke fill;
  stroke: var(--label-halo);
  stroke-width: 0.5px;
  stroke-linejoin: round;
}
.svg-room-label.dimmed {
  opacity: 0.45;
}
.svg-room-badge {
  font-size: 0.78px;
  font-weight: 700;
  text-anchor: middle;
  pointer-events: none;
  paint-order: stroke fill;
  stroke: var(--label-halo);
  stroke-width: 0.35px;
  stroke-linejoin: round;
}
.svg-room-badge.on {
  fill: var(--gold);
}
.svg-room-badge.off {
  fill: var(--text-muted);
}
.svg-room-badge.dimmed {
  opacity: 0.4;
}
.svg-room-area {
  fill: var(--text-dim);
  font-size: 0.72px;
  font-weight: 600;
  text-anchor: middle;
  pointer-events: none;
  paint-order: stroke fill;
  stroke: var(--label-halo);
  stroke-width: 0.3px;
  stroke-linejoin: round;
}
.svg-room-area.dimmed {
  opacity: 0.4;
}

.svg-wall {
  stroke: var(--wall-stroke);
  stroke-width: 0.7;
  stroke-linecap: round;
}
.svg-window {
  stroke: var(--window-stroke);
  stroke-width: 0.7;
  stroke-linecap: round;
}
.svg-door-leaf {
  stroke: var(--door-stroke);
  stroke-width: 0.8;
  stroke-linecap: round;
}
.svg-opening {
  stroke: var(--opening-stroke);
  stroke-width: 0.5;
  stroke-dasharray: 1.2 0.8;
}

.device-pin {
  cursor: pointer;
  transition: transform 0.12s cubic-bezier(0.16, 1, 0.3, 1);
}
.device-pin:active {
  transform: scale(1.3);
}
.pin-glow {
  opacity: 0.6;
  filter: blur(0.4px);
  animation: pulseGlow 2.2s infinite alternate ease-in-out;
}
@keyframes pulseGlow {
  0% { opacity: 0.35; r: 1.4; }
  100% { opacity: 0.85; r: 1.9; }
}
.pin-off {
  fill: var(--pin-off);
}
.pin-selection-ring {
  stroke: var(--gold);
  stroke-width: 0.35;
  stroke-dasharray: 0.6 0.4;
  fill: none;
  display: none;
}
.device-pin.selected .pin-selection-ring,
.device-pin.multi-selected .pin-selection-ring {
  display: block;
}

.svg-glyph {
  font-size: 1.15px;
  text-anchor: middle;
  dominant-baseline: central;
  pointer-events: none;
}

.svg-device-label {
  fill: var(--text);
  font-size: 0.95px;
  font-weight: 700;
  text-anchor: middle;
  pointer-events: none;
  paint-order: stroke fill;
  stroke: var(--label-halo);
  stroke-width: 0.35px;
  stroke-linejoin: round;
}

/* ================= GRAPH VIEW ================= */
.graph-node circle {
  fill: var(--graph-node-fill);
  stroke: var(--accent);
  stroke-width: 0.85;
  cursor: pointer;
  transition: all 0.15s ease;
}
.graph-node:hover circle {
  fill: var(--graph-node-hover);
  stroke: var(--gold);
}
.graph-node.dimmed {
  opacity: 0.25;
}
.graph-node.outdoor circle {
  fill: var(--outdoor-fill);
  stroke: var(--outdoor-stroke);
}
.graph-node.no-devices {
  opacity: 0.5;
}
.graph-label-txt {
  fill: var(--text);
  font-size: 1.9px;
  font-weight: 700;
  text-anchor: middle;
  pointer-events: none;
  paint-order: stroke fill;
  stroke: var(--label-halo);
  stroke-width: 0.55px;
}
.graph-pin-count {
  fill: var(--gold);
  font-size: 1.8px;
  font-weight: 800;
  text-anchor: middle;
  pointer-events: none;
  paint-order: stroke fill;
  stroke: var(--label-halo);
  stroke-width: 0.45px;
}
.graph-edge {
  stroke: var(--accent);
  stroke-width: 0.65;
  opacity: 0.55;
  stroke-linecap: round;
}
.graph-edge.doorway {
  stroke: var(--door-stroke);
  stroke-dasharray: 1.1 1.1;
  stroke-width: 0.75;
}
.graph-edge.passage {
  stroke: var(--graph-edge-passage);
  stroke-width: 0.75;
}
.graph-edge.opening {
  stroke: var(--graph-edge-opening);
  stroke-dasharray: 1.2 0.8;
  stroke-width: 0.65;
}
.graph-edge.abuts {
  stroke: var(--graph-edge-abuts);
  stroke-dasharray: 0.8 0.8;
  stroke-width: 0.45;
  opacity: 0.35;
}
.graph-edge.shared_window {
  stroke: var(--window-stroke);
  stroke-dasharray: 0.9 0.5;
}
.graph-device-pin {
  cursor: pointer;
}

/* ================= 3D ISOMETRIC VIEW ================= */
.iso-container {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  perspective: 1100px;
  overflow: hidden;
}
.iso-stage {
  position: relative;
  width: 360px;
  height: 400px;
  transform-style: preserve-3d;
  transform: scale(0.85) rotateX(58deg) rotateZ(-38deg);
  transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}
.iso-grid {
  position: absolute;
  inset: -120px;
  background-image:
    linear-gradient(to right, var(--grid-line) 1px, transparent 1px),
    linear-gradient(to bottom, var(--grid-line) 1px, transparent 1px);
  background-size: 24px 24px;
  border: 1px solid var(--grid-border);
  transform: translateZ(-4px);
  pointer-events: none;
}
.iso-room-box {
  position: absolute;
  background: var(--room-fill);
  border: 1.5px solid var(--accent);
  border-radius: 4px;
  transform-style: preserve-3d;
  cursor: pointer;
  box-shadow: -2px 2px 0 var(--border), -4px 4px 0 var(--border), -6px 6px 14px rgba(0, 0, 0, 0.45);
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}
.iso-room-box:hover {
  background: var(--room-hover);
  border-color: var(--gold);
  transform: translateZ(4px);
}
.iso-room-box.has-power {
  background: rgba(251, 191, 36, 0.12);
  border-color: var(--gold);
  box-shadow: -2px 2px 0 var(--border), -4px 4px 0 var(--border), 0 0 20px rgba(251, 191, 36, 0.25);
}
.iso-room-box.outdoor {
  background: var(--outdoor-fill);
  border-color: var(--outdoor-stroke);
}
.iso-room-box.no-devices {
  opacity: 0.55;
}
.iso-room-box.focused {
  border-color: var(--accent);
  border-width: 2px;
  transform: translateZ(8px);
}
.iso-room-title {
  position: absolute;
  top: 3px;
  left: 4px;
  right: 4px;
  font-size: 7px;
  font-weight: 800;
  color: var(--accent);
  text-transform: uppercase;
  pointer-events: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.iso-floor-spot {
  position: absolute;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  background: radial-gradient(circle, rgba(251, 191, 36, 0.45) 0%, rgba(251, 191, 36, 0) 70%);
  pointer-events: none;
}
.iso-device-beacon {
  position: absolute;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  transform-style: preserve-3d;
  transform: translate(-50%, -50%) translateZ(var(--beacon-z, 22px));
  background: var(--bg-surface);
  border: 1.5px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 7px;
  cursor: pointer;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.5);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  z-index: 10;
}
.iso-device-beacon:hover {
  transform: translate(-50%, -50%) translateZ(calc(var(--beacon-z, 22px) + 6px)) scale(1.2);
  border-color: var(--gold);
}
.iso-device-beacon.on {
  border-color: var(--gold);
  box-shadow: 0 0 12px var(--gold), 0 4px 8px rgba(0, 0, 0, 0.4);
}
.iso-device-beacon.dance {
  border-color: transparent;
  box-shadow: 0 0 14px rgba(251, 191, 36, 0.55), 0 4px 8px rgba(0, 0, 0, 0.4);
}
.iso-device-beacon.offline {
  opacity: 0.4;
  filter: grayscale(1);
}
.iso-device-count {
  position: absolute;
  top: -5px;
  right: -7px;
  font-size: 5.5px;
  font-weight: 800;
  color: var(--text-dim);
  pointer-events: none;
}

/* ================= TOOLTIP CARD ================= */
.pin-tip {
  position: absolute;
  z-index: 75;
  background: var(--bg-card);
  border: 1px solid var(--border-glow);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 0.72rem;
  line-height: 1.35;
  color: var(--text);
  white-space: pre-line;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.55);
  pointer-events: none;
  opacity: 0;
  transform: translate(-50%, -135%);
  transition: opacity 0.18s ease;
  max-width: 250px;
}
.pin-tip.show {
  opacity: 1;
}

/* ================= BOTTOM CONTROL DECK ================= */
footer.bottom-deck {
  flex-shrink: 0;
  background: var(--bg-glass);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
  z-index: 60;
  display: flex;
  flex-direction: column;
}

.deck-summary {
  min-height: 52px;
  display: flex;
  flex-direction: column;
  padding: 8px 14px 10px 14px;
  gap: 8px;
}
.summary-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 38px;
}
.deck-room-control {
  display: none;
  flex-direction: column;
  padding: 8px 14px 12px 14px;
  gap: 8px;
}
.deck-room-control.open {
  display: flex;
}

.room-control-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 40px;
}

.room-control-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.room-control-title {
  font-size: 0.84rem;
  font-weight: 800;
  color: var(--accent);
  display: flex;
  align-items: center;
  gap: 6px;
}
.room-control-sub {
  font-size: 0.68rem;
  color: var(--text-muted);
}

.summary-info {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-dim);
  display: flex;
  align-items: center;
  gap: 8px;
}

.quick-deck-btn {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 0.78rem;
  font-weight: 700;
  padding: 8px 14px;
  min-height: 40px;
  border-radius: 9px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: all 0.12s ease;
  white-space: nowrap;
}
.quick-deck-btn:active {
  transform: scale(0.95);
}
.quick-deck-btn.accent {
  background: var(--accent);
  color: var(--bg-deep);
  border-color: var(--accent);
}

/* ================= ROOM NAVIGATION TABS ================= */
.room-nav-tabs {
  display: flex;
  align-items: center;
  gap: 6px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 6px;
}
.room-nav-tab {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-size: 0.74rem;
  font-weight: 700;
  padding: 6px 12px;
  min-height: 34px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.12s ease;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.room-nav-tab:hover {
  color: var(--text);
  border-color: var(--accent);
}
.room-nav-tab.active {
  background: var(--accent);
  color: var(--bg-deep);
  border-color: var(--accent);
  box-shadow: 0 0 10px var(--accent-glow);
}

.room-tab-content {
  display: none;
  flex-direction: column;
  gap: 8px;
  max-height: 36dvh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-right: 2px;
}
.room-tab-content.active {
  display: flex;
}

/* ================= FIXTURE CARDS ================= */
.fixture-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: all 0.14s ease;
}
.fixture-card.has-power {
  border-color: rgba(56, 189, 248, 0.4);
}
.fixture-card-hdr {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.fixture-card-info {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
  cursor: pointer;
}
.fixture-glyph-badge {
  font-size: 1.2rem;
  width: 32px;
  height: 32px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.fixture-card-title {
  font-size: 0.84rem;
  font-weight: 800;
  color: var(--text);
  line-height: 1.2;
}
.fixture-card-sub {
  font-size: 0.68rem;
  color: var(--text-muted);
}
.fixture-card-toggle {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-size: 0.80rem;
  font-weight: 800;
  padding: 7px 14px;
  min-height: 38px;
  min-width: 80px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.12s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}
.fixture-card-toggle.on {
  background: linear-gradient(135deg, var(--accent), #818cf8);
  color: #060913;
  border-color: var(--accent);
  box-shadow: 0 0 12px var(--accent-glow);
}

.fixture-card-controls {
  display: flex;
  flex-direction: column;
  gap: 7px;
  padding-top: 6px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}
.fixture-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.fixture-slider-box {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
}
.fixture-slider {
  flex: 1;
  height: 6px;
  -webkit-appearance: none;
  background: var(--bg-deep);
  border-radius: 9999px;
  outline: none;
}
.fixture-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  box-shadow: 0 0 6px var(--accent-glow);
}
.fixture-slider.hue-slider {
  background: linear-gradient(to right, #ff0000 0%, #ffff00 17%, #00ff00 33%, #00ffff 50%, #0000ff 67%, #ff00ff 83%, #ff0000 100%);
}

.fixture-bri-pills, .fixture-kelvin-pills, .fixture-swatches {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}
.fixture-mini-pill {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-size: 0.68rem;
  font-weight: 700;
  padding: 4px 7px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.12s ease;
}
.fixture-mini-pill:hover {
  border-color: var(--accent);
  color: var(--text);
}
.fixture-mini-pill:active {
  transform: scale(0.94);
}
.fixture-swatch-circle {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.2);
  cursor: pointer;
  transition: transform 0.12s ease;
}
.fixture-swatch-circle:hover {
  transform: scale(1.15);
}
.fixture-swatch-circle:active {
  transform: scale(0.9);
}

.fixture-subdevs-accordion {
  margin-top: 4px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  padding-top: 4px;
}
.fixture-subdevs-summary {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px 0;
  outline: none;
}
.fixture-subdevs-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding-top: 4px;
}
.fixture-subdev-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-deep);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 5px 8px;
  gap: 8px;
}
.fixture-subdev-name {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text);
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.fixture-subdev-btn {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-size: 0.68rem;
  font-weight: 800;
  padding: 4px 8px;
  border-radius: 6px;
  cursor: pointer;
}
.fixture-subdev-btn.on {
  background: var(--accent);
  color: var(--bg-deep);
  border-color: var(--accent);
}

/* ================= ZONE CARD STYLES ================= */
.zone-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.zone-card.has-power {
  border-color: rgba(56, 189, 248, 0.4);
}
.zone-card-hdr {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.zone-card-info {
  display: flex;
  align-items: center;
  gap: 8px;
}
.zone-card-title {
  font-size: 0.84rem;
  font-weight: 800;
  color: var(--text);
}
.zone-card-sub {
  font-size: 0.68rem;
  color: var(--text-muted);
}
.zone-card-toggle {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-size: 0.80rem;
  font-weight: 800;
  padding: 7px 14px;
  min-height: 38px;
  min-width: 80px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.12s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}
.zone-card-toggle.on {
  background: linear-gradient(135deg, var(--accent), #818cf8);
  color: #060913;
  border-color: var(--accent);
  box-shadow: 0 0 12px var(--accent-glow);
}

.whole-house-carousel-container {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
}
.whole-house-carousel {
  display: flex;
  align-items: center;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
  flex: 1;
  padding: 2px 0;
}
.whole-house-carousel::-webkit-scrollbar {
  display: none;
}
.carousel-room-pill {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 6px 11px;
  min-height: 36px;
  border-radius: 8px;
  cursor: pointer;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  font-size: 0.76rem;
  font-weight: 700;
  transition: all 0.12s ease;
}
.carousel-room-pill:hover {
  border-color: var(--accent);
}
.carousel-room-pill.has-power {
  border-color: rgba(251, 191, 36, 0.45);
  background: rgba(251, 191, 36, 0.08);
}
.carousel-room-pill .carousel-room-dot {
  font-size: 0.65rem;
}
.carousel-room-pill .carousel-room-dot.on {
  color: var(--gold);
}
.carousel-room-pill .carousel-room-dot.off {
  color: var(--text-muted);
}

.drawer-nav-btn {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  color: var(--text);
  width: 30px;
  height: 30px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.76rem;
  cursor: pointer;
  transition: all 0.12s ease;
}
.drawer-nav-btn:active {
  transform: scale(0.92);
}


/* Video mirror combined control */
.mirror-card {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 6px 8px;
  margin-bottom: 6px;
  border: 1px solid var(--border);
  border-radius: 8px;
}
.mirror-card-title {
  font-size: 0.62rem;
  letter-spacing: 0.12em;
  opacity: 0.85;
}
.mirror-comp {
  display: flex;
  justify-content: space-between;
  font-size: 0.72rem;
}
.mirror-comp-state {
  opacity: 0.9;
}
.mirror-card-btn {
  margin-top: 3px;
  padding: 3px 6px;
  font-size: 0.72rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: transparent;
  cursor: pointer;
}
.mirror-card-btn.active {
  border-color: var(--accent);
}

/* Read-only router status card */
.router-card {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 6px 8px;
  margin-bottom: 6px;
  border: 1px solid var(--border);
  border-radius: 8px;
}
.router-card-title {
  font-size: 0.62rem;
  letter-spacing: 0.12em;
  opacity: 0.85;
}
.router-block {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 3px 0;
}
.router-block + .router-block {
  border-top: 1px solid var(--border);
}
.router-comp {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 0.72rem;
}
.router-comp-state {
  opacity: 0.9;
  text-align: right;
}
.router-sub {
  font-size: 0.66rem;
  opacity: 0.75;
}

/* Category separators inside a room's device list. */
.device-category-heading {
  grid-column: 1 / -1;
  margin: 10px 2px 2px;
  font-size: 0.64rem;
  font-weight: 800;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--text-dim);
}
.device-category-heading:first-child {
  margin-top: 0;
}

/* Scope selector: how far one device change reaches. */
.drawer-scope-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 2px 2px 6px;
}
.scope-label {
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-dim);
}
.scope-pills {
  display: flex;
  gap: 4px;
}
.scope-pill {
  border: 1px solid var(--border);
  background: var(--bg-surface);
  color: var(--text-dim);
  border-radius: 999px;
  padding: 2px 10px;
  font-size: 0.68rem;
  font-weight: 700;
  cursor: pointer;
}
.scope-pill.active {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(56, 189, 248, 0.12);
}
/* ================= DEVICE DRAWER (COMPACT 3-ROW LAYOUT) ================= */
.device-drawer {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.22s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  flex-direction: column;
  padding: 0 14px;
  gap: 8px;
}
.device-drawer.open {
  max-height: 32dvh;
  padding: 10px 14px 12px 14px;
  overflow-y: auto;
}

.drawer-row-1 {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.device-meta {
  display: flex;
  align-items: center;
  gap: 10px;
}
.drawer-glyph-badge {
  font-size: 1.25rem;
  width: 32px;
  height: 32px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.device-meta-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.device-title {
  font-size: 0.88rem;
  font-weight: 800;
  color: var(--text);
  line-height: 1.15;
}
.device-sub {
  font-size: 0.68rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 5px;
}

.power-toggle-btn {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-size: 0.84rem;
  font-weight: 800;
  padding: 9px 18px;
  min-height: 44px;
  min-width: 90px;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.12s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}
.power-toggle-btn:active {
  transform: scale(0.94);
}
.power-toggle-btn.on {
  background: linear-gradient(135deg, var(--accent), #818cf8);
  color: #060913;
  border-color: var(--accent);
  box-shadow: 0 0 14px var(--accent-glow);
}

.drawer-row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.control-box {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.control-box-header {
  display: flex;
  justify-content: space-between;
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--text-dim);
}
.control-box-val {
  color: var(--accent);
}
.modality-label {
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-dim);
}
#drawer-modality-rows {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 8px;
}

.slider-input {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 3px;
  background: var(--bg-deep);
  outline: none;
}
.slider-input::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--text);
  cursor: pointer;
  box-shadow: 0 0 6px rgba(0, 0, 0, 0.5);
}

.bri-presets-row {
  display: flex;
  gap: 4px;
  margin-top: 2px;
}
.modality-select {
  width: 100%;
  background: var(--bg-deep);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 0.72rem;
  font-weight: 600;
  padding: 4px 6px;
  border-radius: 5px;
  cursor: pointer;
}
.modality-select:focus {
  outline: none;
  border-color: var(--accent);
}
.modality-reset-row {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 4px;
}
.modality-reset {
  background: var(--bg-deep);
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-size: 0.62rem;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 5px;
  cursor: pointer;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.modality-reset:hover {
  border-color: var(--accent);
  color: var(--text);
}
.modality-reset:active {
  transform: scale(0.96);
}
.bri-chip {
  flex: 1;
  background: var(--bg-deep);
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-size: 0.64rem;
  font-weight: 700;
  padding: 3px 0;
  border-radius: 5px;
  text-align: center;
  cursor: pointer;
}
.bri-chip:active {
  transform: scale(0.95);
}
.bri-chip:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.toggle-row {
  display: flex;
  gap: 4px;
  margin-top: 2px;
}
.toggle-btn {
  flex: 1;
  background: var(--bg-deep);
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-size: 0.64rem;
  font-weight: 700;
  padding: 4px 0;
  border-radius: 5px;
  cursor: pointer;
}
.toggle-btn.active {
  background: linear-gradient(135deg, var(--accent), #818cf8);
  color: #060913;
  border-color: var(--accent);
}
.toggle-btn:active {
  transform: scale(0.95);
}
.toggle-btn:hover {
  border-color: var(--accent);
}

.drawer-row-3 {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 8px;
  padding: 2px 0;
}
.kelvin-group {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 4px;
  min-width: 0;
}
.swatch-group {
  display: grid;
  grid-template-columns: repeat(4, 24px);
  grid-auto-rows: 24px;
  gap: 4px;
  align-content: center;
}
.kelvin-pill {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  color: var(--text-dim);
  padding: 4px 2px;
  border-radius: 7px;
  cursor: pointer;
  transition: all 0.12s ease;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  line-height: 1.2;
  min-width: 0;
}
.kelvin-pill .kp-val {
  font-size: 0.64rem;
  font-weight: 800;
  color: var(--text);
  white-space: nowrap;
}
.kelvin-pill .kp-label {
  font-size: 0.52rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
}
.kelvin-pill:active {
  transform: scale(0.95);
}
.kelvin-pill:hover {
  border-color: var(--accent);
}
.kelvin-pill.active {
  border-color: var(--accent);
  background: var(--bg-deep);
}
.preset-color-pill {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid var(--border);
  cursor: pointer;
  transition: transform 0.12s ease;
}
.preset-color-pill:hover {
  transform: scale(1.15);
  border-color: var(--text);
}
.preset-color-pill:active {
  transform: scale(0.92);
}

/* ================= POPOVER MENUS (SCENES / ROOMS / TOOLS) ================= */
.popover {
  position: fixed;
  top: 88px;
  left: 8px;
  max-width: 340px;
  max-height: 60dvh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background: var(--bg-card);
  border: 1px solid var(--border-glow);
  border-radius: 12px;
  padding: 10px;
  box-shadow: 0 10px 34px rgba(0, 0, 0, 0.65);
  z-index: 95;
  display: flex;
  flex-direction: column;
  gap: 7px;
}
.popover[hidden] {
  display: none;
}
.popover-title {
  font-size: 0.64rem;
  font-weight: 800;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0 2px;
}
.tools-popover {
  top: 48px;
  right: 8px;
  left: auto;
  width: 230px;
}
.menu-btn {
  display: flex;
  align-items: center;
  gap: 9px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 9px;
  padding: 11px 12px;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.12s ease;
}
.menu-btn:hover {
  border-color: var(--accent);
}
.menu-btn:active {
  transform: scale(0.96);
}
.menu-btn.active {
  background: var(--accent);
  color: var(--bg-deep);
  border-color: var(--accent);
}
.scene-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 6px;
}
.scene-card {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 9px 10px;
  cursor: pointer;
  font-size: 0.74rem;
  font-weight: 700;
  color: var(--text);
  transition: all 0.12s ease;
}
.scene-card:hover {
  border-color: var(--accent);
}
.scene-card:active {
  transform: scale(0.96);
}
.scene-card.dance-running {
  border-color: #ec4899;
  box-shadow: 0 0 10px rgba(236, 72, 153, 0.4);
}
.dance-state {
  margin-left: auto;
  font-size: 0.6rem;
  font-weight: 800;
  letter-spacing: 0.5px;
  color: var(--text-muted);
}
.scene-card.dance-running .dance-state {
  color: #ec4899;
}
.quick-deck-btn.dance-running {
  border-color: #ec4899;
  color: #ec4899;
  box-shadow: 0 0 8px rgba(236, 72, 153, 0.35);
}
@keyframes dance-busy-pulse {
  0%, 100% { box-shadow: 0 0 6px rgba(245, 158, 11, 0.3); }
  50% { box-shadow: 0 0 14px rgba(245, 158, 11, 0.6); }
}
.scene-card.dance-busy {
  border-color: #f59e0b;
  animation: dance-busy-pulse 1.2s ease-in-out infinite;
}
.scene-card.dance-busy .dance-state {
  color: #f59e0b;
}
.scene-card.dance-failed {
  border-color: #ef4444;
}
.scene-card.dance-failed .dance-state {
  color: #ef4444;
}

/* ================= FLOATING ZOOM CONTROLS ================= */
.zoom-bar {
  position: absolute;
  right: 12px;
  bottom: 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: var(--bg-glass);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 4px;
  z-index: 70;
}
.zoom-btn {
  width: 42px;
  height: 42px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 1.15rem;
  font-weight: 700;
  border-radius: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.12s ease;
}
.zoom-btn:active {
  transform: scale(0.93);
}

/* ================= ROOM / HOUSE DEVICE GRID (EXPANDABLE LIST) ================= */
.deck-device-grid {
  display: none;
}
.deck-device-grid.open {
  display: flex;
  flex-direction: column;
  max-height: 42dvh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 10px 12px;
  gap: 6px;
  background: var(--bg-glass);
  border-top: 1px solid var(--border);
}
.deck-section-label {
  font-size: 0.68rem;
  font-weight: 800;
  color: var(--text-muted);
  text-transform: uppercase;
  padding: 6px 4px 4px 4px;
  flex-shrink: 0;
}
.dev-card {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 14px;
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.12s ease;
}
.dev-card:active {
  background: var(--room-hover);
}
.dev-card-glyph {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: var(--bg-deep);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.15rem;
  flex-shrink: 0;
}
.dev-card-meta {
  flex: 1;
  min-width: 0;
}
.dev-card-name {
  font-size: 0.84rem;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.dev-card-sub {
  font-size: 0.68rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.health-badge {
  display: inline-block;
  margin-left: 6px;
  padding: 0 6px;
  border-radius: 8px;
  font-size: 0.62rem;
  font-weight: 600;
  vertical-align: middle;
  background: rgba(255, 176, 32, 0.18);
  color: #ffb020;
}
.health-badge.health-offline { background: rgba(255, 80, 80, 0.18); color: #ff6b6b; }
.health-badge.health-wedged { background: rgba(255, 176, 32, 0.22); color: #ffb020; }
.health-badge.health-recovering { background: rgba(80, 200, 120, 0.18); color: #4fd18b; }
.dev-power-btn {
  width: 42px;
  height: 42px;
  min-width: 42px;
  border-radius: 10px;
  background: var(--bg-deep);
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-size: 1rem;
  font-weight: 800;
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.12s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}
.dev-power-btn.on {
  background: var(--accent);
  color: var(--bg-deep);
  border-color: var(--accent);
  box-shadow: 0 0 10px var(--accent-glow);
}
.dev-power-btn:active {
  transform: scale(0.92);
}

/* ================= CLUSTERING STYLES ================= */
.cluster-badge-tag {
  background: var(--bg-deep);
  border: 1px solid var(--border-glow);
  color: var(--accent);
  font-size: 0.64rem;
  font-weight: 800;
  padding: 2px 6px;
  border-radius: 6px;
  margin-left: 4px;
}
.verified-badge-tag {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 0.62rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(16, 185, 129, 0.15);
  border: 1px solid var(--success);
  color: var(--success);
  cursor: pointer;
  transition: all 0.12s ease;
}
.verified-badge-tag:hover {
  transform: scale(1.05);
}
.verified-badge-tag.unverified {
  background: rgba(239, 68, 68, 0.15);
  border-color: var(--danger);
  color: var(--danger);
}
.verified-badge-tag.stale {
  background: rgba(251, 191, 36, 0.15);
  border-color: var(--gold);
  color: var(--gold);
}
.cluster-subdevs {
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 10px;
  margin-top: 4px;
}
.cluster-subdevs-title {
  font-size: 0.65rem;
  font-weight: 800;
  color: var(--text-dim);
  text-transform: uppercase;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.cluster-subcard {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-deep);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 8px;
  gap: 8px;
}
.cluster-subcard-info {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}
.cluster-subcard-btn {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-size: 0.68rem;
  font-weight: 800;
  padding: 4px 8px;
  border-radius: 6px;
  cursor: pointer;
}
.cluster-subcard-btn.on {
  background: var(--accent);
  color: var(--bg-deep);
  border-color: var(--accent);
}

.svg-cluster-badge {
  font-size: 0.85px;
  font-weight: 800;
  fill: var(--text);
  paint-order: stroke fill;
  stroke: var(--label-halo);
  stroke-width: 0.4px;
  text-anchor: middle;
  pointer-events: none;
}
.svg-cluster-ring {
  fill: none;
  stroke: var(--accent);
  stroke-width: 0.2px;
  stroke-dasharray: 0.8 0.5;
}

/* ================= CONFIRMATION MODAL ================= */
.confirm-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(6px);
  z-index: 120;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.confirm-backdrop[hidden] {
  display: none;
}
.confirm-dialog {
  background: var(--bg-card);
  border: 2px solid var(--danger);
  border-radius: 14px;
  width: 100%;
  max-width: 440px;
  overflow: hidden;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.85);
  display: flex;
  flex-direction: column;
}
.confirm-hdr {
  padding: 12px 16px;
  background: rgba(239, 68, 68, 0.15);
  border-bottom: 1px solid rgba(239, 68, 68, 0.3);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.confirm-title {
  font-size: 0.92rem;
  font-weight: 800;
  color: #fca5a5;
  display: flex;
  align-items: center;
  gap: 8px;
}
.confirm-body {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.confirm-msg {
  font-size: 0.82rem;
  color: var(--text);
  line-height: 1.45;
}
.confirm-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 4px;
}
.confirm-btn {
  padding: 10px 18px;
  min-height: 42px;
  border-radius: 10px;
  font-size: 0.82rem;
  font-weight: 800;
  cursor: pointer;
  border: 1px solid var(--border);
  transition: all 0.12s ease;
}
.confirm-btn:active {
  transform: scale(0.95);
}
.confirm-btn.cancel {
  background: var(--bg-surface);
  color: var(--text);
}
.confirm-btn.danger {
  background: var(--danger);
  color: #ffffff;
  border-color: var(--danger);
  box-shadow: 0 0 14px rgba(239, 68, 68, 0.45);
}

/* ================= EXPORT MODAL ================= */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  z-index: 100;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 14px;
}
.modal-backdrop.open {
  display: flex;
}
.modal-dialog {
  background: var(--bg-card);
  border: 1px solid var(--border-glow);
  border-radius: 12px;
  width: 100%;
  max-width: 480px;
  overflow: hidden;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.65);
}
.modal-hdr {
  padding: 10px 14px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-body {
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.code-box {
  background: var(--bg-deep);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 10px;
  font-family: monospace;
  font-size: 0.72rem;
  color: var(--accent);
  white-space: pre-wrap;
  max-height: 32dvh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* ================= TOAST ================= */
.toast {
  position: fixed;
  bottom: 54px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--accent);
  color: var(--bg-deep);
  font-weight: 800;
  font-size: 0.74rem;
  padding: 5px 13px;
  border-radius: 9999px;
  box-shadow: 0 4px 16px var(--accent-glow);
  opacity: 0;
  pointer-events: none;
  transition: all 0.22s cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 110;
}
.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}
