:root {
  --bg:           #F1F5F9;
  --bg-2:         #EAF2F7;
  --ink:          #1E293B;
  --ink-2:        #2F4F65;
  --muted:        #64748B;
  --line:         #CBD5E1;
  --card:         #FFFFFF;
  --card-border:  #E2E8F0;
  --accent:       #F5783C;
  --accent-soft:  #FBB78E;

  /* Filled in by JS when a scenario / trigger is active */
  --accent-active:      var(--accent);
  --accent-active-soft: rgba(245, 120, 60, 0.18);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ───── Top bar ───── */
.topbar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 16px 28px;
  background: var(--ink);
  color: white;
}
.brand { display: flex; align-items: baseline; gap: 8px; font-weight: 700; letter-spacing: 0.3px; }
.brand-25   { color: var(--accent); font-size: 18px; }
.brand-sep  { color: var(--muted); }
.brand-lynx { font-size: 18px; }
.title { text-align: center; }
.eyebrow {
  font-size: 11px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--accent-soft);
}
.title h1 { font-size: 15px; font-weight: 500; margin: 4px 0 0; color: white; }
.meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  font-size: 11px;
  color: rgba(255,255,255,0.55);
  text-align: right;
}
.meta-sub { color: rgba(255,255,255,0.55); }

/* ───── Failover knop (header) ───── */
.failover-btn {
  appearance: none;
  border: 1px solid rgba(239, 68, 68, 0.45);
  background: rgba(239, 68, 68, 0.10);
  color: #FCA5A5;
  padding: 6px 12px 6px 10px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.2px;
  cursor: pointer;
  transition: background 180ms, color 180ms, border-color 180ms, transform 180ms;
}
.failover-btn:hover {
  background: rgba(239, 68, 68, 0.20);
  border-color: rgba(239, 68, 68, 0.75);
  color: #FECACA;
  transform: translateY(-1px);
}
.failover-btn-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: #EF4444;
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.25);
  animation: failover-btn-dot-pulse 2.2s ease-in-out infinite;
}
@keyframes failover-btn-dot-pulse {
  0%, 100% { box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.25); }
  50%      { box-shadow: 0 0 0 6px rgba(239, 68, 68, 0.05); }
}
.failover-btn[aria-pressed="true"] {
  background: rgba(16, 185, 129, 0.12);
  border-color: rgba(16, 185, 129, 0.55);
  color: #6EE7B7;
}
.failover-btn[aria-pressed="true"] .failover-btn-dot {
  background: #10B981;
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.25);
  animation: none;
}

/* ───── Stage (3-col) ───── */
.stage {
  flex: 1;
  display: grid;
  grid-template-columns: 280px 1fr 280px;
  gap: 0;
  padding: 36px 28px 20px;
  position: relative;
}
.col          { position: relative; z-index: 1; display: flex; flex-direction: column; }
.col-canvas   { min-height: 520px; }
.col-title {
  font-size: 11px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
  margin: 0 0 18px 4px;
}
.col-outputs .col-title { text-align: right; margin-right: 4px; }

/* Kaartlijst vult de kolom en centreert de zichtbare kaarten verticaal
   (uitgelijnd met de hub in het midden). */
.card-list {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 14px;
}

/* Reveal-model: trigger- en output-kaarten zijn verborgen tot een scenario
   actief is. De choreografie gebeurt in JS:
   - is-placed = kaart neemt ruimte in maar is onzichtbaar (zodat de lijn er
                 al naartoe getekend kan worden);
   - is-shown  = kaart vervaagt zichtbaar in (wanneer de lijn aankomt). */
.col-triggers .card,
.col-outputs .card { display: none; }
.col-triggers .card.is-placed,
.col-outputs .card.is-placed {
  display: flex;
  opacity: 0;
}
.col-triggers .card.is-shown,
.col-outputs .card.is-shown {
  animation: card-reveal 480ms cubic-bezier(0.34, 1.4, 0.64, 1) forwards;
}
@keyframes card-reveal {
  from { opacity: 0; transform: translateY(12px) scale(0.96); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ───── Cards ───── */
.card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 12px;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: 0 1px 2px rgba(15,23,42,0.04), 0 6px 14px rgba(15,23,42,0.04);
  cursor: pointer;
  transition:
    transform 180ms ease,
    border-color 180ms ease,
    box-shadow 180ms ease,
    opacity 180ms ease;
  position: relative;
  user-select: none;
}
.card:hover { transform: translateY(-1px); border-color: var(--accent-soft); }
.card .icon {
  width: 40px; height: 40px;
  border-radius: 10px;
  background: var(--bg-2);
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
  color: var(--ink-2);
  flex-shrink: 0;
  transition: background 180ms ease, color 180ms ease;
}
.card .text  { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.card .label { font-size: 14px; font-weight: 600; color: var(--ink); }
.card .kind  { font-size: 11px; color: var(--muted); margin-top: 2px; letter-spacing: 0.2px; }

/* Productfoto (bv. oproeppeer) in plaats van een emoji-icoon */
.card-has-img .icon {
  background: transparent;
  width: 44px;
  height: 60px;
  border-radius: 0;
}
.icon-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  -webkit-user-drag: none;
  filter: drop-shadow(0 4px 8px rgba(15, 23, 42, 0.18));
}

/* ───── Beeld-trigger (kale productfoto, geen kader/tekst) ───── */
.col-triggers .card-trigger-visual {
  align-self: center;          /* krimp tot de fotobreedte, gecentreerd */
  width: auto;
  background: transparent;
  border: none;
  box-shadow: none;
  padding: 0;
  cursor: pointer;
}
.col-triggers .card-trigger-visual:hover { transform: translateY(-2px); }
.col-triggers .card-trigger-visual.is-active {
  background: transparent;
  border: none;
  box-shadow: none;
}
/* Kamer-stack: origineel toestel (boven) + wall module (onder) */
.room-stack {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}
.room-device { position: relative; }
.room-device-card {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 11px 15px 11px 11px;
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 13px;
  box-shadow: 0 1px 2px rgba(15,23,42,0.04), 0 8px 18px rgba(15,23,42,0.08);
}
.device-icon {
  width: 40px; height: 40px;
  border-radius: 10px;
  background: var(--bg-2);
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; color: var(--ink-2);
  flex-shrink: 0;
}
.device-text { display: flex; flex-direction: column; line-height: 1.2; }
.device-label { font-size: 13.5px; font-weight: 700; color: var(--ink); white-space: nowrap; }
.device-sub { font-size: 11px; color: var(--muted); margin-top: 2px; }
.room-device-img { width: 92px; }
.device-img {
  width: 100%; height: auto; display: block;
  -webkit-user-drag: none;
  filter: drop-shadow(0 10px 20px rgba(15, 23, 42, 0.22));
}
.trigger-visual {
  position: relative;
  width: 118px;
}
.trigger-img {
  position: relative;
  z-index: 1;                    /* boven de glow-laag */
  width: 100%;
  height: auto;
  display: block;
  -webkit-user-drag: none;
  filter: drop-shadow(0 14px 26px rgba(15, 23, 42, 0.26));
}

/* Glow-laag onder de trigger-knop (patiëntzijde licht op bij de druk).
   Deelt de ring-grootte met de kamerlamp via de .frame-*-klassen hieronder. */
.trigger-glow {
  position: absolute;
  left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  opacity: 0;
  z-index: 0;
  transition: opacity 340ms ease;
}
.col-triggers .card-trigger-visual { overflow: visible; }
.trigger-visual.is-lit .trigger-glow { opacity: 0.9; }

/* Virtuele klik op de (rode) knop — ripple + press-dot, loopt zolang actief */
.trigger-tap {
  position: absolute;
  width: 40px; height: 40px;
  transform: translate(-50%, -50%);
  pointer-events: none;
  z-index: 2;
}
.trigger-tap::before {           /* uitdijende ring */
  content: '';
  position: absolute; inset: 0;
  border-radius: 50%;
  border: 2.5px solid rgba(255, 255, 255, 0.95);
  animation: tap-ripple 1.8s ease-out infinite;
}
.trigger-tap::after {            /* indruk-stip ("vinger") */
  content: '';
  position: absolute; left: 50%; top: 50%;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 0 8px rgba(255,255,255,0.7);
  transform: translate(-50%, -50%);
  animation: tap-press 1.8s ease-in-out infinite;
}
@keyframes tap-ripple {
  0%   { transform: scale(0.35); opacity: 0; }
  18%  { opacity: 0.9; }
  100% { transform: scale(1.9); opacity: 0; }
}
@keyframes tap-press {
  0%, 100% { transform: translate(-50%, -50%) scale(1);   opacity: 0.55; }
  12%      { transform: translate(-50%, -50%) scale(0.65); opacity: 1; }
  34%      { transform: translate(-50%, -50%) scale(1);   opacity: 0.55; }
}

/* ───── MIFARE-toegangskaart (badge = aanwezig) ───── */
.mifare-card {
  position: absolute;
  left: 50%; top: 100%;
  width: 96px; height: 60px;
  transform: translate(6px, 14px) rotate(-7deg);   /* rustpositie: rechtsonder de knop */
  transform-origin: center center;
  border: none;
  border-radius: 10px;
  background: linear-gradient(155deg, #ffffff 0%, #eaeff5 58%, #dbe3ec 100%);
  box-shadow: 0 12px 24px rgba(15, 23, 42, 0.22), inset 0 1px 0 rgba(255,255,255,0.9);
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  z-index: 4;
  padding: 0;
  transition: transform 600ms cubic-bezier(.34, 1.1, .4, 1),
              opacity 320ms ease, box-shadow 300ms ease;
}
/* Contactloos-symbool (geen chip op de voorkant) */
.mifare-wave { position: absolute; right: 11px; top: 11px; color: #2563eb; opacity: 0.9; }
.mifare-name {
  position: absolute; left: 12px; bottom: 11px;
  font-size: 11px; font-weight: 800; letter-spacing: 1.8px; color: #334155;
}
.mifare-hint {
  position: absolute; left: 50%; top: 100%;
  transform: translate(-50%, 100px);
  white-space: nowrap;
  font-size: 11px; font-weight: 700; color: #475569;
  background: #ffffff;
  border: 1px solid rgba(15, 23, 42, 0.10);
  border-radius: 999px;
  padding: 3px 11px;
  box-shadow: 0 6px 14px rgba(15, 23, 42, 0.12);
  opacity: 0;
  pointer-events: none;
  transition: opacity 300ms ease;
}
/* Kaart verschijnt zodra de oproep gereveald is */
.trigger-visual.show-badge .mifare-card { opacity: 1; pointer-events: auto; }
.trigger-visual.show-badge:not(.is-present) .mifare-card { animation: mifare-invite 1.7s ease-in-out infinite; }
.trigger-visual.show-badge:not(.is-present) .mifare-hint { opacity: 1; }
@keyframes mifare-invite {
  0%, 100% { transform: translate(6px, 14px) rotate(-7deg); }
  50%      { transform: translate(6px, 6px) rotate(-7deg); }
}
.trigger-visual.show-badge .mifare-card:hover { transform: translate(6px, 6px) rotate(-7deg) scale(1.04); }
/* Aanwezig: geen verschuiving meer — de klik volstaat voor de statuswijziging.
   De kaart blijft op haar plaats (en klikbaar om te resetten), de pulse stopt. */
.trigger-visual.is-present .mifare-card {
  animation: none;
}

/* Output cards mirror to the right */
.col-outputs .card { flex-direction: row-reverse; text-align: right; }
.col-outputs .card .text { align-items: flex-end; }
.col-outputs .card-phone {
  flex-direction: column;
  text-align: left;
  padding: 0;
  overflow: visible;
  border: none;
  background: transparent;
  box-shadow: none;
  width: 220px;
  align-self: flex-end;
}
.col-outputs .card-phone:hover { transform: none; border: none; }

/* ───── Smartphone mockup ───── */

/* Teal palette van de LynX app */
:root {
  --phone-teal:       #CFEDE7;
  --phone-teal-dark:  #1E8E7E;
  --phone-teal-text:  #0F766E;
}

.phone {
  width: 100%;
  background: #0F172A;
  border-radius: 28px;
  padding: 8px 7px 9px;
  position: relative;
  box-shadow:
    inset 0 0 0 1px rgba(255,255,255,0.05),
    0 22px 40px rgba(15, 23, 42, 0.22);
}
.phone-notch {
  position: absolute;
  top: 4px; left: 50%;
  transform: translateX(-50%);
  width: 48px; height: 5px;
  background: #1E293B;
  border-radius: 0 0 6px 6px;
  z-index: 2;
}
.phone-screen {
  background: var(--phone-teal);
  border-radius: 20px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 380px;
}

/* Status-bar */
.phone-statusbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 12px 4px;
  background: var(--phone-teal);
  font-size: 8px;
  color: var(--phone-teal-text);
  font-weight: 700;
  letter-spacing: 0.3px;
}
.phone-sb-time { color: #064E3B; }
.phone-sb-icons { display: flex; gap: 5px; align-items: center; }
.phone-sb-bars { letter-spacing: -1px; }

/* App-header — donker navy */
.phone-app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: #1E293B;
  color: white;
}
.phone-app-menu, .phone-app-more {
  font-size: 12px;
  opacity: 0.7;
  width: 16px;
  text-align: center;
}
.phone-app-title {
  display: flex; flex-direction: column;
  align-items: center; line-height: 1.1;
}
.phone-app-brand {
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 0.4px;
}
.phone-app-sub {
  font-size: 7.5px;
  color: var(--accent-soft);
  letter-spacing: 1.4px;
  text-transform: uppercase;
  margin-top: 1px;
}

/* Profile-bar */
.phone-profile {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: rgba(255,255,255,0.65);
  border-bottom: 1px solid rgba(15, 118, 110, 0.10);
}
.phone-profile-avatar {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: #CBD5E1;
  color: white;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.4px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 0 0 2px rgba(255,255,255,0.7);
}
.phone-profile-avatar-idle {
  background: #1E293B;
  color: var(--accent-soft);
  font-size: 8px;
}
.phone-profile-text {
  display: flex; flex-direction: column;
  line-height: 1.15; min-width: 0; flex: 1;
}
.phone-profile-role {
  font-size: 8.5px;
  color: var(--phone-teal-text);
  letter-spacing: 0.5px;
  text-transform: uppercase;
  font-weight: 700;
}
.phone-profile-name {
  font-size: 11px;
  color: var(--ink);
  font-weight: 600;
  margin-top: 1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.phone-profile-status {
  font-size: 8px;
  color: #10B981;
  font-weight: 700;
  letter-spacing: 0.4px;
}
.phone-profile-status-idle { color: var(--muted); }

/* Tabs */
.phone-tabs {
  display: flex;
  background: rgba(255,255,255,0.55);
  border-bottom: 1px solid rgba(15, 118, 110, 0.10);
}
.phone-tab {
  flex: 1;
  text-align: center;
  padding: 8px 4px 7px;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: rgba(15, 118, 110, 0.55);
  position: relative;
}
.phone-tab.is-active {
  color: var(--phone-teal-text);
}
.phone-tab.is-active::after {
  content: '';
  position: absolute;
  left: 22%; right: 22%; bottom: 0;
  height: 2px;
  background: var(--phone-teal-dark);
  border-radius: 2px 2px 0 0;
}

/* Alarm-area */
.phone-alarm-area {
  flex: 1;
  padding: 10px 10px 12px;
  background: var(--phone-teal);
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 170px;
}

/* Idle */
.phone-idle {
  flex: 1;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  text-align: center;
  padding: 14px 6px;
  color: var(--phone-teal-text);
}
.phone-idle-icon {
  font-size: 26px;
  opacity: 0.45;
  margin-bottom: 6px;
}
.phone-idle-title {
  font-size: 11px;
  font-weight: 700;
  color: #134E4A;
}
.phone-idle-text {
  font-size: 9px;
  margin-top: 3px;
  line-height: 1.4;
  opacity: 0.85;
}

/* Alarm-card — bovenste kleurblok + onderste teal-sectie */
.phone-alarm {
  position: relative;
  border-radius: 10px;
  overflow: hidden;
  background: white;
  box-shadow: 0 6px 14px color-mix(in srgb, var(--alarm-color) 28%, transparent);
  animation: alarm-in 280ms cubic-bezier(0.34, 1.56, 0.64, 1);
}
.phone-alarm-top {
  background: var(--alarm-color);
  color: white;
  padding: 9px 12px 11px;
}
.phone-alarm-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 3px;
}
.phone-alarm-icon { font-size: 14px; }
.phone-alarm-time {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: rgba(255,255,255,0.9);
  font-variant-numeric: tabular-nums;
}
.phone-alarm-title {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.2px;
  line-height: 1.2;
}
.phone-alarm-location {
  font-size: 10px;
  margin-top: 2px;
  color: rgba(255,255,255,0.85);
  letter-spacing: 0.2px;
}
.phone-alarm-bottom {
  padding: 8px 12px 10px;
  background: white;
  display: flex; flex-direction: column;
  gap: 8px;
}
.phone-timer {
  display: flex; align-items: center; gap: 8px;
}
.phone-timer-track {
  flex: 1;
  height: 3px;
  border-radius: 2px;
  background: rgba(15, 118, 110, 0.18);
  position: relative;
}
.phone-timer-dot {
  position: absolute;
  top: 50%; left: 6%;
  transform: translate(-50%, -50%);
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--phone-teal-dark);
  box-shadow: 0 0 0 3px rgba(30, 142, 126, 0.18);
}
.phone-timer-label {
  font-size: 9px;
  font-weight: 700;
  color: var(--phone-teal-text);
  letter-spacing: 0.3px;
  font-variant-numeric: tabular-nums;
}
.phone-action-link {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--alarm-color);
  font-family: inherit;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  padding: 0;
  margin-left: auto;
  align-self: flex-end;
  cursor: pointer;
  transition: opacity 160ms;
}
.phone-action-link:hover { opacity: 0.7; }

.phone-alarm.is-urgent {
  animation: alarm-in 280ms cubic-bezier(0.34, 1.56, 0.64, 1),
             alarm-urgent-pulse 1.4s ease-in-out 0.3s infinite;
}
@keyframes alarm-in {
  from { transform: translateY(-6px) scale(0.96); opacity: 0; }
  to   { transform: translateY(0)    scale(1);    opacity: 1; }
}
@keyframes alarm-urgent-pulse {
  0%, 100% { box-shadow: 0 6px 14px color-mix(in srgb, var(--alarm-color) 28%, transparent); }
  50%      { box-shadow: 0 6px 14px color-mix(in srgb, var(--alarm-color) 55%, transparent),
                          0 0 0 4px color-mix(in srgb, var(--alarm-color) 20%, transparent); }
}

/* Bottom nav */
.phone-nav {
  display: flex;
  justify-content: space-around;
  align-items: center;
  padding: 7px 6px 9px;
  background: rgba(255,255,255,0.7);
  border-top: 1px solid rgba(15, 118, 110, 0.10);
}
.phone-nav-item {
  display: flex; flex-direction: column;
  align-items: center; gap: 2px;
  font-size: 8px;
  color: rgba(15, 118, 110, 0.55);
  font-weight: 600;
}
.phone-nav-icon { font-size: 12px; }
.phone-nav-item.is-active {
  color: var(--phone-teal-text);
  font-weight: 800;
}

/* Highlight wanneer de smartphone-card actief is — glow rond het toestel */
.col-outputs .card-phone.is-active .phone {
  box-shadow:
    inset 0 0 0 1px rgba(255,255,255,0.06),
    0 0 0 3px var(--accent-active-soft),
    0 22px 40px var(--accent-active-soft);
}

/* ───── Wall module-video (kamerzijde) ─────
   In rust toont ze frame 0 (geen glow); speelt in loop bij activatie. De video
   heeft een bijna-witte achtergrond — een zachte radiale mask laat de rand
   invloeien zodat het vierkant wegvalt en de glow op de pagina uitwaaiert. */
.wall-video {
  position: relative;
  z-index: 1;
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1;
  height: auto;
  object-fit: cover;
  -webkit-user-drag: none;
  -webkit-mask-image: radial-gradient(circle closest-side, #000 86%, transparent 100%);
          mask-image: radial-gradient(circle closest-side, #000 86%, transparent 100%);
}

/* ───── LynX LED-armatuur (lijnverlichting in de gang) ─────
   Geen kader: enkel de armatuur. Een witte balk die wit oplicht, met in het
   midden de statuskleur die de wall module in de kamer matcht. */
.col-outputs .card-line {
  align-self: flex-end;
  width: auto;
  background: transparent;
  border: none;
  box-shadow: none;
  padding: 0;
}
.col-outputs .card-line:hover { transform: translateY(-2px); }
.col-outputs .card-line.is-active { background: transparent; border: none; box-shadow: none; }

.led-arm {
  position: relative;
  width: 232px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: center;
}
/* gekleurde lichtwaas (de lichtval op muur/vloer) achter de armatuur */
.led-wash {
  position: absolute;
  left: 50%; top: 56%;
  width: 88%; height: 150%;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: radial-gradient(ellipse, var(--led-color) 0%, transparent 68%);
  filter: blur(20px);
  opacity: 0;
  z-index: 0;
  transition: opacity 360ms ease;
}
.led-arm.is-on .led-wash { opacity: 0.6; }

/* de armatuur: een slanke witte balk */
.led-bar {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 20px;
  border-radius: 11px;
  overflow: hidden;            /* klipt de bewegende snake binnen de armatuur */
  background: linear-gradient(180deg, #ffffff 0%, #e9eef4 100%);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.9), 0 3px 8px rgba(15,23,42,0.14);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: box-shadow 320ms ease, background 320ms ease;
}
.led-arm.is-on .led-bar {
  background: linear-gradient(180deg, #ffffff 0%, #f6fafe 100%);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,1),
    0 0 16px rgba(255,255,255,0.95),
    0 0 34px rgba(255,255,255,0.65),
    0 3px 8px rgba(15,23,42,0.10);
}
/* gekleurde kern in het midden = de status */
.led-bar-core {
  width: 34%;
  height: 64%;
  border-radius: 8px;
  background: var(--led-color);
  opacity: 0;
  transition: opacity 320ms ease, box-shadow 320ms ease;
}
.led-arm.is-on .led-bar-core {
  opacity: 1;
  box-shadow: 0 0 8px var(--led-color), 0 0 18px var(--led-color);
}

/* Snake = routebegeleiding (REA): een lichtsegment loopt over de armatuur richting
   de kamer. De statische kern valt dan weg. */
.led-snake {
  position: absolute;
  top: 50%;
  left: -28%;
  width: 24%;
  height: 68%;
  transform: translateY(-50%);
  border-radius: 8px;
  background: var(--led-color);                 /* volledig blauw, geen witte kern */
  box-shadow: 0 0 9px var(--led-color), 0 0 18px var(--led-color);
  opacity: 0;
}
.led-arm.mode-snake .led-bar-core { opacity: 0; }
.led-arm.is-on.mode-snake .led-snake {
  opacity: 1;
  animation: led-snake-run 1.9s linear infinite;
}
/* tweede snake loopt op een halve periode → twee die elkaar achtervolgen */
.led-arm.is-on.mode-snake .led-snake-2 { animation-delay: -0.95s; }
@keyframes led-snake-run {
  /* loopt richting de kamer (van rechts naar links) */
  0%   { left: 104%; }
  100% { left: -28%; }
}

/* Blink = dringend (prio): de gekleurde kern knippert hard aan/uit. De witte
   balk blijft branden. */
.led-arm.is-on.mode-blink .led-bar-core { animation: led-blink 0.66s steps(1, end) infinite; }
.led-arm.is-on.mode-blink .led-wash     { animation: led-blink-wash 0.66s steps(1, end) infinite; }
@keyframes led-blink {
  0%,   49.9% { opacity: 1;    box-shadow: 0 0 9px var(--led-color), 0 0 20px var(--led-color); }
  50%,  100%  { opacity: 0.06; box-shadow: none; }
}
@keyframes led-blink-wash {
  0%,   49.9% { opacity: 0.6; }
  50%,  100%  { opacity: 0.05; }
}

/* Active / dim states */
.card.is-active {
  border-color: var(--accent-active);
  box-shadow:
    0 0 0 3px var(--accent-active-soft),
    0 8px 22px var(--accent-active-soft);
  transform: translateY(-1px);
}
.card.is-active .icon {
  background: var(--accent-active-soft);
  color: var(--accent-active);
}
.card.is-dim { opacity: 0.35; }

/* ───── Hub-anker (onzichtbaar — wires convergeren hierop) ───── */
.hub-anchor {
  position: absolute;
  top: 50%; left: 50%;
  width: 0; height: 0;
  pointer-events: none;
  z-index: 0;
}

/* ───── Hubs (primair + secundair) ───── */
.hub {
  position: absolute;
  top: 50%; left: 50%;
  width: 180px; height: 180px;
  pointer-events: none;
  transition:
    transform 700ms cubic-bezier(0.4, 0.0, 0.2, 1),
    opacity   500ms ease,
    filter    500ms ease;
}

/* Primaire hub: groot, centraal — de "active" positie in normaaltoestand. */
.hub-primary {
  transform: translate(-50%, -50%) scale(1);
  z-index: 3;
}

/* Secundaire hub (standby): kleiner, loodrecht boven het centrum.
   Bewust niet rechtsboven want dan zou hij op het pad van de wires zitten. */
.hub-secondary {
  transform: translate(-50%, -50%) translate(0, -230px) scale(0.55);
  opacity: 0.72;
  filter: saturate(0.85);
  z-index: 2;
}

.hub-inner {
  position: absolute;
  inset: 0;
  display: flex; align-items: center; justify-content: center;
  z-index: 2;
}
.hub-logo-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  user-select: none;
  -webkit-user-drag: none;
  filter: drop-shadow(0 10px 24px rgba(15, 23, 42, 0.18));
  transition: filter 260ms ease;
}

/* Status-badges onder de hubs */
.hub-status-badge {
  position: absolute;
  left: 50%; bottom: -28px;
  transform: translateX(-50%);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 10px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
  white-space: nowrap;
  transition: background 220ms, color 220ms, border-color 220ms;
}
.hub-status-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
}
.hub-status-active {
  background: rgba(16, 185, 129, 0.12);
  color: #047857;
  border: 1px solid rgba(16, 185, 129, 0.35);
}
.hub-status-standby {
  background: rgba(100, 116, 139, 0.08);
  color: var(--muted);
  border: 1px solid rgba(100, 116, 139, 0.30);
}

/* Error-overlay op de primaire hub — alleen zichtbaar tijdens/na failover */
.hub-error-badge {
  position: absolute;
  top: -6px; right: -8px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #EF4444;
  color: white;
  padding: 4px 9px 4px 6px;
  border-radius: 999px;
  font-size: 10px;
  letter-spacing: 0.8px;
  font-weight: 700;
  text-transform: uppercase;
  box-shadow: 0 8px 20px rgba(239, 68, 68, 0.35);
  opacity: 0;
  transform: scale(0.6);
  transition: opacity 260ms ease, transform 260ms cubic-bezier(0.34, 1.56, 0.64, 1);
  pointer-events: none;
  z-index: 4;
}
.hub-error-icon {
  width: 14px; height: 14px;
  border-radius: 50%;
  background: white;
  color: #EF4444;
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 900;
  font-size: 11px;
  line-height: 1;
}
.hub-error-text { white-space: nowrap; }

/* Pulserende ringen — alleen zichtbaar bij actief scenario op de active hub */
.hub-ring {
  position: absolute;
  top: 50%; left: 50%;
  width: 70%; height: 70%;
  border-radius: 50%;
  border: 2px solid var(--accent-active);
  transform: translate(-50%, -50%) scale(1);
  opacity: 0;
  pointer-events: none;
  z-index: 1;
}

/* Standaardstaat: primaire hub pulseert bij active scenario */
.stage:not(.is-failed-over).has-active .hub-primary .hub-ring-1,
.stage.is-failed-over.has-active           .hub-secondary .hub-ring-1 {
  animation: hub-ring-pulse 1.8s ease-out infinite;
}
.stage:not(.is-failed-over).has-active .hub-primary .hub-ring-2,
.stage.is-failed-over.has-active           .hub-secondary .hub-ring-2 {
  animation: hub-ring-pulse 1.8s ease-out infinite;
  animation-delay: 0.9s;
}
.stage:not(.is-failed-over).has-active .hub-primary .hub-inner,
.stage.is-failed-over.has-active           .hub-secondary .hub-inner {
  animation: hub-breathe 1.8s ease-in-out infinite;
}
.stage:not(.is-failed-over).has-active .hub-primary .hub-logo-img,
.stage.is-failed-over.has-active           .hub-secondary .hub-logo-img {
  filter:
    drop-shadow(0 10px 24px rgba(15, 23, 42, 0.18))
    drop-shadow(0 0 18px var(--accent-active-soft));
}

@keyframes hub-ring-pulse {
  0%   { opacity: 0.55; transform: translate(-50%, -50%) scale(1); }
  80%  { opacity: 0;    transform: translate(-50%, -50%) scale(1.55); }
  100% { opacity: 0;    transform: translate(-50%, -50%) scale(1.55); }
}
@keyframes hub-breathe {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.04); }
}

/* ───── Failover-staten ───── */

/* Korte glitch-fase (~700ms): rode glow + shake + error-badge popt op */
.stage.is-failing .hub-primary {
  animation: hub-glitch 0.7s ease-in-out;
}
.stage.is-failing .hub-primary .hub-logo-img,
.stage.is-failed-over .hub-primary .hub-logo-img {
  filter:
    drop-shadow(0 0 18px rgba(239, 68, 68, 0.55))
    drop-shadow(0 10px 24px rgba(15, 23, 42, 0.18))
    grayscale(0.4);
}
.stage.is-failing .hub-error-badge,
.stage.is-failed-over .hub-error-badge {
  opacity: 1;
  transform: scale(1);
}

@keyframes hub-glitch {
  0%, 100% { transform: translate(-50%, -50%) scale(1); }
  10%      { transform: translate(calc(-50% - 6px), -50%) scale(1.01); }
  20%      { transform: translate(calc(-50% + 6px), calc(-50% - 3px)) scale(0.99); }
  30%      { transform: translate(calc(-50% - 4px), calc(-50% + 3px)) scale(1.01); }
  40%      { transform: translate(calc(-50% + 4px), -50%) scale(0.99); }
  50%      { transform: translate(calc(-50% - 2px), calc(-50% - 2px)) scale(1); }
  60%      { transform: translate(calc(-50% + 2px), calc(-50% + 2px)) scale(1); }
}

/* Eindstaat na failover: primaire krimpt + zakt loodrecht onder het centrum,
   secundaire schuift van boven naar centrum. */
.stage.is-failed-over .hub-primary {
  transform: translate(-50%, -50%) translate(0, 230px) scale(0.45);
  opacity: 0.35;
  z-index: 2;
}
.stage.is-failed-over .hub-primary .hub-status-active {
  background: rgba(239, 68, 68, 0.12);
  color: #B91C1C;
  border-color: rgba(239, 68, 68, 0.4);
}
.stage.is-failed-over .hub-primary .hub-status-text::after {
  content: " · uitgevallen";
  font-weight: 600;
}
.stage.is-failed-over .hub-secondary {
  transform: translate(-50%, -50%) scale(1);
  opacity: 1;
  filter: none;
  z-index: 3;
}
.stage.is-failed-over .hub-secondary .hub-status-standby {
  background: rgba(16, 185, 129, 0.12);
  color: #047857;
  border-color: rgba(16, 185, 129, 0.35);
}
.stage.is-failed-over .hub-secondary .hub-status-text {
  /* tekst wisselen via JS — fallback styling */
}

/* ───── Wires (SVG overlay) ───── */
.wires {
  position: absolute;
  inset: 0;
  width: 100%; height: 100%;
  pointer-events: none;
  z-index: 0;
  overflow: visible;
}
.wire {
  fill: none;
  stroke: var(--line);
  stroke-width: 1.4;
  opacity: 0;                /* verborgen tot een trigger/alarm actief is */
  transition:
    stroke 220ms ease,
    stroke-width 220ms ease,
    opacity 260ms ease,
    filter 220ms ease;
}
.wire.is-active {
  stroke: var(--accent-active);
  stroke-width: 2.6;
  opacity: 1;
  filter: drop-shadow(0 0 6px var(--accent-active-soft));
  /* opacity verschijnt iets later → ná de trigger, vóór de outputs settelen */
  transition-delay: 0s, 0s, 0.18s, 0s;
}
.wire.is-dim { opacity: 0; }  /* niet-relevante lijnen blijven onzichtbaar */

/* Tijdens een failover/herstel "her-routen" de wires visueel: even stippellijn
   met een vloeiende stroming in de richting van de outputs. Zodra de swap rond
   is, vallen ze terug naar volle lijnen. */
.stage.is-rerouting .wire {
  stroke-dasharray: 8 6;
  animation: wire-flow 0.7s linear infinite;
}
@keyframes wire-flow {
  to { stroke-dashoffset: -14; }
}

/* ───── Scenarios strip ───── */
.scenarios {
  background: white;
  border-top: 1px solid var(--card-border);
  padding: 22px 28px 24px;
}
.scenarios-header {
  display: flex;
  align-items: baseline;
  gap: 18px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.scenarios-header h2 {
  font-size: 13px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
  margin: 0;
}
.scenario-desc {
  margin: 0;
  font-size: 13px;
  color: var(--ink-2);
  line-height: 1.5;
  flex: 1 1 320px;
  min-width: 0;
}
.scenario-desc strong { color: var(--ink); }

.scenario-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.chip {
  --chip-accent: var(--accent);
  appearance: none;
  border: 1px solid var(--card-border);
  background: white;
  color: var(--ink);
  padding: 8px 14px 8px 10px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: border-color 180ms, box-shadow 180ms, background 180ms, color 180ms, transform 180ms;
}
.chip-num {
  width: 20px; height: 20px;
  border-radius: 50%;
  background: var(--bg-2);
  color: var(--ink-2);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 11px;
  font-weight: 700;
  transition: background 180ms, color 180ms;
}
.chip-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--chip-accent);
  flex-shrink: 0;
}
.chip:hover { border-color: var(--chip-accent); transform: translateY(-1px); }
.chip.is-active {
  background: var(--chip-accent);
  color: white;
  border-color: var(--chip-accent);
  box-shadow: 0 6px 16px color-mix(in srgb, var(--chip-accent) 30%, transparent);
}
.chip.is-active .chip-num { background: rgba(255,255,255,0.22); color: white; }
.chip.is-active .chip-dot { background: white; }

/* ───── Footer ───── */
.footer {
  padding: 14px 28px;
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.3px;
  text-align: center;
  background: var(--bg);
}

/* ───── Responsive ───── */
@media (max-width: 900px) {
  .topbar { grid-template-columns: 1fr; gap: 8px; text-align: center; }
  .meta { text-align: center; }
  .stage {
    grid-template-columns: 1fr;
    gap: 20px;
  }
  .col-canvas { min-height: 140px; order: 2; }
  .col-triggers { order: 1; }
  .col-outputs { order: 3; }
  .col-outputs .card { flex-direction: row; text-align: left; }
  .col-outputs .card .text { align-items: flex-start; }
  .col-outputs .col-title { text-align: left; margin-left: 4px; }
  .wires { display: none; }
  .hub { position: relative; top: auto; left: auto; transform: none; margin: 8px auto; }
}
