/* Lichterketten — smart-home control surface.
   Mobile first (360 px and up), one token set, dark and light theme. No build step. */

[hidden] { display: none !important; }

@font-face {
  font-family: "InterVariable";
  src: url("/static/fonts/InterVariable.woff2") format("woff2-variations");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

:root {
  color-scheme: dark;

  /* map (Karte) scenery */
  --map-ground: #10141a;
  --map-lawn: rgba(61, 220, 151, 0.10);
  --map-drive: #1d222b;
  --map-terrace: #232933;
  --map-roof-s: #5a4630;
  --map-roof-gable: #6b4a33;
  --map-shed: #4a3a33;
  --map-ridge: rgba(255, 255, 255, 0.22);
  --map-edge: rgba(255, 255, 255, 0.22);

  --font: "InterVariable", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  /* type scale (1rem = 16px) */
  --fs-2xs: 0.6875rem;
  --fs-xs: 0.75rem;
  --fs-sm: 0.8125rem;
  --fs-md: 0.9375rem;
  --fs-base: 1rem;
  --fs-lg: 1.0625rem;
  --fs-xl: 1.25rem;
  --fs-2xl: 1.75rem;
  --fs-3xl: 2.25rem;

  /* spacing */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 20px;
  --sp-6: 24px;
  --sp-7: 32px;
  --sp-8: 40px;

  /* radius */
  --r-sm: 10px;
  --r-md: 12px;
  --r-lg: 16px;
  --r-xl: 20px;
  --r-pill: 999px;

  /* dark palette */
  --bg: #0a0c10;
  --surface: #14171e;
  --surface-2: #1b1f29;
  --surface-3: #242a36;
  --border: rgba(255, 255, 255, 0.075);
  --border-strong: rgba(255, 255, 255, 0.18);
  --track: rgba(255, 255, 255, 0.12);
  --text: #f3f5f9;
  --text-dim: #a3adbd;
  --text-faint: #828d9e;
  --accent: #ffb340;
  --accent-soft: #f5a623;
  --accent-ink: #1b1204;
  --accent-text: #ffc46b;
  --glow-rgb: 255, 179, 64;
  --glow-a: 0.20;
  --green: #3ddc97;
  --green-text: #63e8b1;
  --red: #ff7b72;
  --red-text: #ff9c95;
  --focus: #8ecbff;
  --shadow-card: 0 1px 0 rgba(255, 255, 255, 0.04), 0 10px 26px rgba(0, 0, 0, 0.32);
  --shadow-pop: 0 16px 40px rgba(0, 0, 0, 0.5);

  /* safe areas + chrome */
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --tabbar-h: 72px;
  --motion: 180ms cubic-bezier(0.2, 0.7, 0.3, 1);
}

@media (prefers-color-scheme: light) {
  :root {
    color-scheme: light;
    --bg: #f4f5f7;
    --surface: #ffffff;
    --surface-2: #f0f2f5;
    --surface-3: #e3e7ed;
    --border: rgba(17, 24, 39, 0.08);
    --border-strong: rgba(17, 24, 39, 0.2);
    --track: rgba(17, 24, 39, 0.12);
    --text: #101521;
    --text-dim: #566173;
    --text-faint: #5f6c7f;
    --accent: #f5a623;
    --accent-soft: #e2910d;
    --accent-ink: #1b1204;
    --accent-text: #8a5200;
    --glow-rgb: 245, 166, 35;
    --glow-a: 0.19;
    --green: #0f9d63;
    --green-text: #0a6b44;
    --red: #d32029;
    --red-text: #a3111a;
    --focus: #0b5cad;
    --shadow-card: 0 1px 2px rgba(16, 21, 33, 0.04), 0 10px 26px rgba(16, 21, 33, 0.08);
    --shadow-pop: 0 16px 40px rgba(16, 21, 33, 0.16);
    --map-ground: #e6e9ee;
    --map-lawn: rgba(15, 157, 99, 0.13);
    --map-drive: #cfd4dc;
    --map-terrace: #dadee5;
    --map-roof-s: #d9b98c;
    --map-roof-gable: #cf9d72;
    --map-shed: #bda699;
    --map-ridge: rgba(16, 21, 33, 0.28);
    --map-edge: rgba(16, 21, 33, 0.3);
  }
}

*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  font-size: 16px;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 400 var(--fs-base) / 1.5 var(--font);
  font-feature-settings: "cv05" 1, "ss01" 1;
  overflow-wrap: anywhere;
  min-height: 100dvh;
}

h1, h2, h3, p, ol, ul, fieldset { margin: 0; padding: 0; }
h1 { font-size: var(--fs-2xl); line-height: 1.15; letter-spacing: -0.022em; font-weight: 700; }
h2 { font-size: var(--fs-xl); line-height: 1.25; letter-spacing: -0.014em; font-weight: 650; }
h3 { font-size: var(--fs-lg); line-height: 1.3; font-weight: 600; }
button, input, select, textarea { font-family: inherit; }

svg.icon { width: 24px; height: 24px; flex: 0 0 auto; }

:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.skip {
  position: absolute;
  top: -64px; left: 16px;
  z-index: 100;
  padding: 10px 16px;
  border-radius: var(--r-md);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  color: var(--text);
  text-decoration: none;
}
.skip:focus { top: 12px; }

/* ── brand + status ─────────────────────────────────────────────────── */

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  color: var(--text);
  text-decoration: none;
  font-size: var(--fs-lg);
  font-weight: 650;
  letter-spacing: -0.015em;
}
.brand-mark {
  display: grid;
  place-items: center;
  width: 30px; height: 30px;
  border-radius: 10px;
  background: linear-gradient(150deg, rgba(var(--glow-rgb), 0.95), rgba(var(--glow-rgb), 0.55));
  color: var(--accent-ink);
  box-shadow: 0 4px 14px rgba(var(--glow-rgb), 0.28);
}
.brand-mark svg { width: 18px; height: 18px; }

.status-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 32px;
  padding: 0 12px;
  border-radius: var(--r-pill);
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-size: var(--fs-sm);
  font-weight: 550;
  white-space: nowrap;
}
.status-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--red);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--red) 18%, transparent);
}
.status-dot.connected { background: var(--green); box-shadow: 0 0 0 3px color-mix(in srgb, var(--green) 18%, transparent); }
.brand .badge {
  padding: 1px 8px;
  border-radius: var(--r-pill);
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-size: var(--fs-2xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.task-badge {
  padding: 1px 8px;
  border-radius: var(--r-pill);
  color: var(--accent-text);
  background: color-mix(in srgb, var(--accent) 14%, transparent);
  font-size: var(--fs-2xs);
  font-weight: 600;
}

/* ── shell: mobile app bar + tab bar, desktop side nav ──────────────── */

.shell { min-height: 100dvh; }

.appbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  padding: calc(10px + var(--safe-t)) calc(var(--sp-4) + var(--safe-r)) 6px calc(var(--sp-4) + var(--safe-l));
}

.bulkbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: 10px calc(var(--sp-4) + var(--safe-r)) 10px calc(var(--sp-4) + var(--safe-l));
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(18px) saturate(1.15);
  -webkit-backdrop-filter: blur(18px) saturate(1.15);
}
.bulk-actions {
  display: flex;
  flex: 1;
  gap: 8px;
}
.bulk-btn {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 50px;
  padding: 0 var(--sp-4);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  font-size: var(--fs-md);
  font-weight: 600;
  cursor: pointer;
  touch-action: manipulation;
  transition: background var(--motion), color var(--motion), border-color var(--motion), transform var(--motion);
}
.bulk-btn:active { transform: scale(0.985); }
.bulk-btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
  box-shadow: 0 6px 18px rgba(var(--glow-rgb), 0.22);
}
.bulk-btn:disabled,
.bulk-btn.primary:disabled {
  background: var(--surface-2);
  border-color: var(--border);
  color: var(--text-faint);
  box-shadow: none;
  cursor: not-allowed;
}
.bulk-btn[aria-busy="true"] { opacity: 0.65; cursor: progress; }

.main {
  max-width: 1120px;
  margin: 0 auto;
  padding: 6px calc(var(--sp-4) + var(--safe-r)) calc(var(--tabbar-h) + var(--safe-b) + 28px) calc(var(--sp-4) + var(--safe-l));
}

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--sp-2) var(--sp-3);
  margin: 10px 2px 14px;
}
.section-meta {
  font-size: var(--fs-sm);
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.cards { display: grid; gap: 14px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 640px) {
  .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .bulkbar { justify-content: flex-end; }
  .bulk-actions { flex: 0 0 auto; }
  .bulk-btn { flex: 0 0 auto; min-width: 132px; }
}

/* ── area cards ─────────────────────────────────────────────────────── */

.area-card {
  --lvl: 0;
  --pct: 0;
  --fill: var(--border-strong);
  position: relative;
  padding: 18px 18px 12px;
  border-radius: var(--r-lg);
  border: 1px solid var(--border);
  background:
    radial-gradient(130% 105% at 84% -12%,
      rgba(var(--glow-rgb), calc(var(--lvl) * var(--glow-a))),
      rgba(var(--glow-rgb), 0) 62%),
    var(--surface);
  box-shadow: var(--shadow-card);
  transition: background var(--motion), border-color var(--motion), box-shadow var(--motion);
}
.area-card[data-on="true"] {
  --fill: var(--accent);
  border-color: rgba(var(--glow-rgb), calc(0.14 + var(--lvl) * 0.42));
  box-shadow:
    0 0 calc(var(--lvl) * 34px) rgba(var(--glow-rgb), calc(var(--lvl) * 0.13)),
    var(--shadow-card);
}

.area-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--sp-3); }
.area-name { font-size: var(--fs-lg); font-weight: 600; letter-spacing: -0.012em; line-height: 1.3; }
.area-meta { margin-top: 2px; font-size: var(--fs-sm); color: var(--text-dim); font-variant-numeric: tabular-nums; }

.area-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-2);
  margin-top: 2px;
}
.area-state {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: var(--fs-sm);
  font-weight: 550;
  color: var(--text-dim);
}
.area-state .status-dot { width: 7px; height: 7px; box-shadow: none; background: var(--border-strong); }
.area-card[data-on="true"] .area-state { color: var(--accent-text); }
.area-card[data-on="true"] .area-state .status-dot { background: var(--accent); box-shadow: 0 0 8px rgba(var(--glow-rgb), 0.7); }

.area-level {
  font-size: var(--fs-md);
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  letter-spacing: -0.01em;
}
.area-level .unit { margin-left: 2px; font-size: var(--fs-xs); font-weight: 550; color: var(--text-dim); }
.area-card[data-on="false"] .area-level { color: var(--text-faint); }

/* combined "Haus" group */
.area-group { display: grid; gap: 12px; grid-column: 1 / -1; }
.area-group-head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px 10px;
  padding: 0 2px;
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--text-dim);
}
.area-group-head svg { width: 17px; height: 17px; color: var(--accent-text); }
.area-group-head .rule { flex: 1; min-width: 16px; height: 1px; background: var(--border); }
.area-group-grid { display: grid; gap: 14px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 640px) { .area-group-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.area-group-grid > .area-card.combo { grid-column: 1 / -1; }

.area-card.combo {
  background:
    radial-gradient(130% 105% at 84% -12%,
      rgba(var(--glow-rgb), calc(var(--lvl) * var(--glow-a) * 1.3)),
      rgba(var(--glow-rgb), 0) 64%),
    color-mix(in srgb, var(--surface) 93%, var(--accent));
  border-color: rgba(var(--glow-rgb), calc(0.18 + var(--lvl) * 0.4));
}

/* not yet provisioned */
.area-card[data-available="false"] {
  --lvl: 0 !important;
  background: var(--surface-2);
  border-style: dashed;
  box-shadow: none;
}
.area-card[data-available="false"] .area-name { color: var(--text-dim); }
.area-card[data-available="false"] .area-state { color: var(--text-faint); }
.area-card[data-available="false"] .area-level { color: var(--text-faint); }
.area-lock {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px 10px;
  margin-top: 4px;
  font-size: var(--fs-xs);
  color: var(--text-dim);
}
.area-lock a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding-right: 4px;
  color: var(--accent-text);
  font-weight: 600;
  text-decoration: none;
}
.area-lock a:hover { text-decoration: underline; }

/* pending */
.area-card.is-pending { border-color: var(--accent); }
.area-pending {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: var(--fs-xs);
  color: var(--text-dim);
}
.area-pending[hidden] { display: none; }
.spinner {
  width: 13px;
  height: 13px;
  border-radius: 50%;
  border: 2px solid var(--border-strong);
  border-top-color: var(--accent);
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* custom toggle */
.toggle {
  position: relative;
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  min-width: 64px;
  flex: 0 0 auto;
  cursor: pointer;
}
.toggle input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}
.toggle-track {
  position: relative;
  width: 56px;
  height: 32px;
  border-radius: var(--r-pill);
  background: var(--surface-3);
  box-shadow: inset 0 0 0 1px var(--border);
  transition: background var(--motion), box-shadow var(--motion);
}
.toggle-thumb {
  position: absolute;
  top: 3px; left: 3px;
  width: 26px; height: 26px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.28);
  transition: transform var(--motion);
}
.toggle input:checked + .toggle-track {
  background: linear-gradient(180deg, var(--accent), var(--accent-soft));
  box-shadow: 0 4px 14px rgba(var(--glow-rgb), 0.32);
}
.toggle input:checked + .toggle-track .toggle-thumb { transform: translateX(24px); }
.toggle input:focus-visible + .toggle-track { outline: 3px solid var(--focus); outline-offset: 3px; }
.toggle input:disabled + .toggle-track { opacity: 0.45; }

/* custom range */
.area-slider { margin: 12px 0 4px; }
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 44px;
  margin: 0;
  background: transparent;
  cursor: pointer;
  touch-action: none;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 6px;
  border-radius: var(--r-pill);
  background: linear-gradient(to right,
    var(--fill, var(--accent)) calc(var(--pct, 0) * 1%),
    var(--track) calc(var(--pct, 0) * 1%));
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 24px;
  height: 24px;
  margin-top: -9px;
  border-radius: 50%;
  border: 2px solid var(--surface);
  background: #fff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.32);
}
input[type="range"]::-moz-range-track {
  height: 6px;
  border-radius: var(--r-pill);
  background: var(--track);
}
input[type="range"]::-moz-range-progress {
  height: 6px;
  border-radius: var(--r-pill);
  background: var(--fill, var(--accent));
}
input[type="range"]::-moz-range-thumb {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid var(--surface);
  background: #fff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.32);
}
input[type="range"]:focus-visible { outline: 3px solid var(--focus); outline-offset: 4px; border-radius: var(--r-pill); }
input[type="range"]:disabled { opacity: 0.45; cursor: not-allowed; }

/* ── tab bar (mobile) ───────────────────────────────────────────────── */

.tabbar {
  position: fixed;
  inset: auto 0 0 0;
  z-index: 40;
  display: flex;
  gap: 2px;
  padding: 6px calc(8px + var(--safe-r)) calc(6px + var(--safe-b)) calc(8px + var(--safe-l));
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: blur(20px) saturate(1.2);
  -webkit-backdrop-filter: blur(20px) saturate(1.2);
  border-top: 1px solid var(--border);
}
.tab {
  flex: 1;
  display: grid;
  justify-items: center;
  gap: 3px;
  min-height: 52px;
  padding: 6px 2px 4px;
  border-radius: var(--r-md);
  color: var(--text-faint);
  text-decoration: none;
  font-size: var(--fs-2xs);
  font-weight: 600;
  letter-spacing: 0.005em;
  transition: color var(--motion), background var(--motion);
}
.tab[aria-current="page"] { color: var(--accent-text); }
.tab[aria-current="page"] svg { stroke-width: 2.1; }
.tabbar .tab:active { background: var(--surface-2); }

/* ── sidebar (desktop) ──────────────────────────────────────────────── */

.sidebar { display: none; }

/* ── desktop ────────────────────────────────────────────────────────── */

@media (min-width: 900px) {
  .appbar { display: none; }
  .tabbar { display: none; }

  .sidebar {
    display: flex;
    flex-direction: column;
    gap: 4px;
    position: fixed;
    inset: 0 auto 0 0;
    width: 248px;
    padding: calc(24px + var(--safe-t)) 16px 20px 16px;
    border-right: 1px solid var(--border);
    background: var(--surface);
  }
  .sidebar .brand { padding: 0 6px; margin-bottom: 20px; }
  .side-nav { display: grid; gap: 4px; }
  .side-nav .tab {
    display: flex;
    align-items: center;
    justify-items: start;
    gap: 12px;
    min-height: 44px;
    padding: 0 12px;
    border-radius: var(--r-md);
    font-size: var(--fs-md);
    font-weight: 550;
  }
  .side-nav .tab:hover { background: var(--surface-2); color: var(--text); }
  .side-nav .tab[aria-current="page"] {
    background: color-mix(in srgb, var(--accent) 13%, transparent);
    color: var(--accent-text);
  }
  .sidebar-foot { margin-top: auto; padding: 0 6px; display: grid; gap: 10px; justify-items: start; }
  .sidebar-foot .logout { margin: 0; }

  .main {
    margin-left: 248px;
    max-width: none;
    padding: 28px 36px 40px calc(36px + var(--safe-l));
  }
  .main-inner { max-width: 1080px; margin: 0 auto; }

  .bulkbar {
    position: static;
    background: none;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    padding: 0;
    margin: 0 0 8px;
    justify-content: flex-end;
  }
  .bulk-actions { flex: 0 0 auto; gap: 8px; }
  .bulk-btn { flex: 0 0 auto; min-width: 132px; min-height: 46px; }
  .section-head { margin-top: 8px; }
  .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
}

@media (min-width: 1280px) {
  .main { padding-left: calc(48px + var(--safe-l)); padding-right: 48px; }
  .cards { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

/* ── effects panel ──────────────────────────────────────────────────── */

.effects { margin-top: 18px; }
.effect-modes { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-bottom: 16px; }
.effect-modes .chip { padding: 0 8px; }
.fx-controls { display: grid; gap: 14px 20px; grid-template-columns: minmax(0, 1fr); }
.fx-field { display: grid; gap: 4px; align-content: start; }
@media (min-width: 700px) { .fx-controls { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.fx-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }
.fx-actions .btn { flex: 1 1 160px; }

/* ── setup page ─────────────────────────────────────────────────────── */

.setup-list { display: grid; gap: 10px; }
.setup-option {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 14px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface-2);
}
.setup-option[data-active="true"] {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 9%, var(--surface));
}
.setup-option .setup-name { font-weight: 600; }
.setup-option .setup-meta { font-size: var(--fs-xs); color: var(--text-dim); }

.area-rows { list-style: none; display: grid; gap: 8px; }
.area-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 6px 12px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface-2);
}
.area-row .area-row-name { font-weight: 550; }
.area-row .area-row-meta { font-size: var(--fs-xs); color: var(--text-dim); font-variant-numeric: tabular-nums; }
.area-row[data-available="false"] .area-row-name { color: var(--text-dim); }
.state-pill {
  padding: 2px 10px;
  border-radius: var(--r-pill);
  border: 1px solid var(--border-strong);
  font-size: var(--fs-2xs);
  font-weight: 600;
  color: var(--text-dim);
}
.state-pill.on { border-color: var(--accent); color: var(--accent-text); }
.state-pill.offline { border-color: var(--red); color: var(--red-text); }

/* ── banners, feedback, toast ───────────────────────────────────────── */

.banner {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 0 0 14px;
  padding: 12px 16px;
  border-radius: var(--r-md);
  border: 1px solid var(--red);
  background: color-mix(in srgb, var(--red) 14%, var(--surface));
  color: var(--red-text);
  font-size: var(--fs-md);
  font-weight: 550;
}
.banner[hidden] { display: none; }
.banner-warn {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, var(--surface));
  color: var(--accent-text);
}

.feedback {
  margin: 0 0 12px;
  font-size: var(--fs-sm);
  color: var(--text-dim);
  min-height: 0;
}
.feedback:empty { display: none; }
.feedback.error { color: var(--red-text); }
.feedback.ok { color: var(--green-text); }

.toast {
  position: fixed;
  left: calc(16px + var(--safe-l));
  right: calc(16px + var(--safe-r));
  bottom: calc(var(--tabbar-h) + var(--safe-b) + 14px);
  z-index: 60;
  padding: 14px 16px;
  border-radius: var(--r-md);
  border: 1px solid var(--red);
  background: color-mix(in srgb, var(--surface) 88%, var(--red));
  color: var(--text);
  box-shadow: var(--shadow-pop);
  font-size: var(--fs-md);
  font-weight: 550;
}
.toast[hidden] { display: none; }
@media (min-width: 900px) {
  .toast { left: auto; right: 32px; bottom: 28px; max-width: 380px; }
}

/* ── generic buttons / forms ────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  min-width: 44px;
  padding: 0 18px;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  font-size: var(--fs-md);
  font-weight: 600;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  touch-action: manipulation;
  transition: background var(--motion), border-color var(--motion), transform var(--motion), opacity var(--motion);
}
.btn:hover { border-color: var(--text-faint); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }
.btn[aria-busy="true"] { opacity: 0.65; cursor: progress; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-on { background: color-mix(in srgb, var(--green) 14%, var(--surface-2)); border-color: var(--green); color: var(--green-text); }
.btn-off { background: color-mix(in srgb, var(--red) 14%, var(--surface-2)); border-color: var(--red); color: var(--red-text); }
.btn-block { width: 100%; margin-top: var(--sp-4); min-height: 48px; }
.btn-sm { min-height: 44px; padding: 0 12px; font-size: var(--fs-sm); border-radius: var(--r-sm); }
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; }
.btn-row .btn { flex: 1 1 140px; }

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 18px;
  box-shadow: var(--shadow-card);
}
.panel + .panel { margin-top: 14px; }
.panel-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 4px 12px;
  margin-bottom: 14px;
}
.hint { font-size: var(--fs-sm); color: var(--text-dim); }
.hint.small { font-size: var(--fs-xs); margin-top: 10px; }
.hint b { color: var(--accent-text); font-variant-numeric: tabular-nums; }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field-label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: var(--fs-sm);
  font-weight: 550;
  color: var(--text-dim);
}
.field-label b { color: var(--accent-text); font-variant-numeric: tabular-nums; }

select,
input[type="number"],
input[type="text"],
input[type="password"] {
  width: 100%;
  min-height: 48px;
  padding: 0 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  background: var(--surface-2);
  color: var(--text);
  font-size: 16px;
}
select:focus-visible,
input[type="number"]:focus-visible,
input[type="text"]:focus-visible,
input[type="password"]:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

.row-2 { display: grid; gap: 12px; grid-template-columns: minmax(0, 1fr); }
.row-2 > * { min-width: 0; }
.row-2 > .check { align-self: end; min-height: var(--tap); }
@media (min-width: 520px) { .row-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

.inline { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.inline input[type="number"] { width: 5.5em; }
.inline select { width: auto; min-width: 6em; }

.check {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  font-size: var(--fs-md);
  cursor: pointer;
}
.check input { width: 22px; height: 22px; accent-color: var(--accent); flex: 0 0 auto; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 16px;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-pill);
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  font-size: var(--fs-md);
  font-weight: 550;
  cursor: pointer;
  transition: background var(--motion), color var(--motion), border-color var(--motion);
}
.chip input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.chip[aria-pressed="true"], .chip:has(input:checked) {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}
.chip:has(input:focus-visible) { outline: 3px solid var(--focus); outline-offset: 2px; }

.segmented {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 4px;
  min-width: 0;
  border-radius: var(--r-md);
  background: var(--surface-2);
  border: 1px solid var(--border);
}
.segmented .chip { flex: 1 1 auto; min-width: max-content; border: 0; background: transparent; border-radius: var(--r-sm); }
.segmented .chip[aria-pressed="true"], .segmented .chip:has(input:checked) { background: var(--accent); }

/* ── collapsibles ───────────────────────────────────────────────────── */

.sec { padding: 0; overflow: hidden; }
.sec > summary {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 56px;
  padding: 14px 18px;
  font-size: var(--fs-lg);
  font-weight: 600;
  cursor: pointer;
  list-style: none;
}
.sec > summary::-webkit-details-marker { display: none; }
.sec > summary::after {
  content: "";
  width: 9px; height: 9px;
  margin-left: auto;
  border-right: 2px solid var(--text-dim);
  border-bottom: 2px solid var(--text-dim);
  transform: rotate(45deg) translateY(-2px);
  transition: transform var(--motion);
}
.sec[open] > summary::after { transform: rotate(225deg) translateY(-2px); }
.sec > summary:hover { background: var(--surface-2); }
.sec > .sec-body { padding: 0 18px 18px; }

/* ── log / advanced ─────────────────────────────────────────────────── */

.log {
  list-style: none;
  max-height: 320px;
  overflow: auto;
  font: var(--fs-xs) / 1.55 var(--mono);
  color: var(--text-dim);
}
.log li { padding: 5px 0; border-bottom: 1px solid var(--border); }
.log li:last-child { border-bottom: 0; }

.adv-grid { display: grid; gap: 12px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 700px) { .adv-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.adv-block {
  display: grid;
  gap: 8px;
  align-content: start;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface-2);
  min-width: 0;
}
.adv-block > .field-label { margin: 0; }
.adv-out {
  margin-top: 14px;
  padding: 12px;
  min-height: 60px;
  max-height: 240px;
  overflow: auto;
  border-radius: var(--r-sm);
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-dim);
  font: var(--fs-xs) / 1.5 var(--mono);
  white-space: pre-wrap;
}

/* ── single bulb page ───────────────────────────────────────────────── */

.big-level {
  font-size: var(--fs-3xl);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.03em;
  line-height: 1.1;
}
.big-level .unit { margin-left: 2px; font-size: var(--fs-xl); font-weight: 550; color: var(--text-dim); }
.quick-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.quick-row .btn { flex: 1 1 0; min-width: 0; padding: 0 8px; }
.adv-block h3 { font-size: var(--fs-md); font-weight: 600; letter-spacing: 0; }

/* ── auth ───────────────────────────────────────────────────────────── */

.auth {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: calc(20px + var(--safe-t)) calc(16px + var(--safe-r)) calc(20px + var(--safe-b)) calc(16px + var(--safe-l));
}
.auth-card {
  width: 100%;
  max-width: 400px;
  padding: 28px 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-pop);
}
.auth-card .brand { margin-bottom: 22px; }
.auth-title { font-size: var(--fs-xl); margin-bottom: 4px; }
.auth-sub { color: var(--text-dim); font-size: var(--fs-sm); margin-bottom: 20px; }

/* ── admin ──────────────────────────────────────────────────────────── */

.user-list { list-style: none; display: grid; gap: 10px; }
.user-row {
  display: grid;
  gap: 8px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface-2);
}
.user-row-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; }
.user-name { font-weight: 600; }
.user-meta { font-size: var(--fs-xs); color: var(--text-dim); }
.role-tag {
  padding: 1px 9px;
  border-radius: var(--r-pill);
  border: 1px solid var(--border-strong);
  font-size: var(--fs-2xs);
  font-weight: 600;
  color: var(--text-dim);
}
.role-tag.admin { border-color: var(--accent); color: var(--accent-text); }
.user-manage > summary {
  min-height: 44px;
  display: flex;
  align-items: center;
  font-size: var(--fs-sm);
  font-weight: 550;
  color: var(--accent-text);
  cursor: pointer;
  list-style: none;
}
.user-manage > summary::-webkit-details-marker { display: none; }
.user-manage > summary::after {
  content: "";
  width: 8px; height: 8px;
  margin-left: auto;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg);
}
.user-manage[open] > summary::after { transform: rotate(225deg); }
.manage-body { display: grid; gap: 12px; padding: 6px 0; }

@media (max-width: 400px) {
  .main { padding-left: 12px; padding-right: 12px; }
  .area-card { padding: 16px 14px 10px; }
  h1 { font-size: var(--fs-xl); }
  .bulk-btn { font-size: var(--fs-sm); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

/* ── gateway-locked: nothing is operable, nothing looks warm ─────────── */

body[data-gateway="off"] .area-card,
body[data-gateway="unknown"] .area-card {
  --lvl: 0 !important;
  --fill: var(--border-strong) !important;
  background: var(--surface);
  border-color: var(--border);
  box-shadow: none;
  opacity: 0.62;
}
body[data-gateway="off"] .toggle input:checked + .toggle-track,
body[data-gateway="unknown"] .toggle input:checked + .toggle-track {
  background: var(--surface-3);
  box-shadow: inset 0 0 0 1px var(--border);
}
body[data-gateway="off"] .fx-controls input,
body[data-gateway="unknown"] .fx-controls input { --fill: var(--surface-3); }
body[data-gateway="off"] .area-state,
body[data-gateway="unknown"] .area-state,
body[data-gateway="off"] .area-level,
body[data-gateway="unknown"] .area-level { color: var(--text-faint); }
body[data-gateway="off"] .area-state .status-dot,
body[data-gateway="unknown"] .area-state .status-dot {
  background: var(--border-strong);
  box-shadow: none;
}

.area-row-group {
  background: transparent;
  border-style: dashed;
  box-shadow: none;
}
.area-row-group .area-row-name { display: inline-flex; align-items: center; gap: 8px; }
.area-row-group svg { width: 17px; height: 17px; color: var(--accent-text); }
body[data-gateway="off"] .effect-modes .chip:has(input:checked),
body[data-gateway="unknown"] .effect-modes .chip:has(input:checked),
body[data-gateway="off"] .effect-modes .chip[aria-pressed="true"],
body[data-gateway="unknown"] .effect-modes .chip[aria-pressed="true"] {
  background: var(--surface-3);
  border-color: var(--border-strong);
  color: var(--text-faint);
}
body[data-gateway="off"] .fx-controls b,
body[data-gateway="unknown"] .fx-controls b { color: var(--text-faint); }
.btn-primary:disabled {
  background: var(--surface-2);
  border-color: var(--border);
  color: var(--text-faint);
}

/* ── scenes ─────────────────────────────────────────────────────────── */

.scene-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 16px;
}
.scene {
  display: grid;
  justify-items: center;
  gap: 2px;
  min-height: 64px;
  padding: 8px 4px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  cursor: pointer;
  touch-action: manipulation;
  transition: background var(--motion), border-color var(--motion), transform var(--motion);
}
.scene:hover { border-color: var(--border-strong); }
.scene:active { transform: scale(0.98); }
.scene:disabled { opacity: 0.55; cursor: not-allowed; }
.scene-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 1px solid var(--accent);
  background: transparent;
}
.scene[data-scene="100"] .scene-dot { background: var(--accent); box-shadow: 0 0 8px rgba(var(--glow-rgb), 0.5); }
.scene[data-scene="35"] .scene-dot { background: color-mix(in srgb, var(--accent) 65%, transparent); }
.scene[data-scene="5"] .scene-dot { background: color-mix(in srgb, var(--accent) 35%, transparent); }
.scene-name { font-size: var(--fs-sm); font-weight: 600; }
.scene-sub { font-size: var(--fs-2xs); color: var(--text-faint); font-variant-numeric: tabular-nums; }

/* area name opens the sheet */
.area-name-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 44px;
  margin-left: -4px;
  padding: 0 4px;
  border: 0;
  border-radius: var(--r-sm);
  background: none;
  color: var(--text);
  font: inherit;
  font-weight: 600;
  letter-spacing: -0.012em;
  text-align: left;
  cursor: pointer;
}
.area-name-btn svg { width: 16px; height: 16px; color: var(--text-faint); }
.area-name-btn:hover svg { color: var(--accent-text); }
.area-name-btn:disabled { cursor: not-allowed; color: var(--text-dim); }

/* ── area sheet ─────────────────────────────────────────────────────── */

.sheet {
  width: min(540px, calc(100vw - 24px));
  max-height: min(82dvh, 760px);
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-pop);
}
.sheet::backdrop { background: rgba(4, 6, 10, 0.62); }
.sheet-head {
  position: sticky;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.sheet-head h2 { font-size: var(--fs-lg); }
.sheet-body {
  display: grid;
  gap: 10px;
  padding: 14px 18px calc(18px + var(--safe-b));
  overflow: auto;
  max-height: calc(82dvh - 66px);
}
.bulb-row {
  display: grid;
  gap: 4px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface-2);
}
.bulb-row.is-pending { border-color: var(--accent); }
.bulb-row-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.bulb-name { font-weight: 600; }
.bulb-level { justify-self: end; font-size: var(--fs-xs); color: var(--text-dim); font-variant-numeric: tabular-nums; }
.bulb-row-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 2px; }
.bulb-row-actions .hint { flex: 1 1 120px; }

/* ── bulb settings page ─────────────────────────────────────────────── */

.settings-list { display: grid; gap: 12px; }
.setting {
  display: grid;
  gap: 6px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface-2);
}
.setting-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 12px; }
.setting h3 { font-size: var(--fs-md); }
.setting .setting-desc { font-size: var(--fs-sm); color: var(--text-dim); }
.setting-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.setting-controls input[type="number"] { width: 6em; }
.setting-controls select { width: auto; min-width: 8em; }
.detail-list { display: grid; gap: 6px; margin-top: 10px; }
.detail-list div { display: flex; justify-content: space-between; gap: 12px; font-size: var(--fs-sm); }
.detail-list dt { color: var(--text-dim); }
.detail-list dd { margin: 0; font-variant-numeric: tabular-nums; }
.settings-empty { color: var(--text-dim); font-size: var(--fs-sm); }

.setting-controls { align-items: flex-end; }
.ctl {
  display: grid;
  gap: 4px;
  min-width: 6em;
  font-size: var(--fs-sm);
  font-weight: 550;
  color: var(--text-dim);
}
.ctl input, .ctl select { width: 100%; }
.ctl .hint { font-size: var(--fs-2xs); }
.ctl-actions { display: flex; gap: 8px; align-items: center; }

/* ── setting rows: load / save feedback ─────────────────────────────── */

.setting-state {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 18px;
  font-size: var(--fs-xs);
  color: var(--text-dim);
}
.setting-state.ok { color: var(--green-text); }
.setting-state.error { color: var(--red-text); }
.setting-state svg { width: 15px; height: 15px; }
.setting-state .spinner { width: 14px; height: 14px; }
.setting[data-state="error"] { border-color: var(--red); }

.setting details.advanced {
  margin-top: 6px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}
.setting details.advanced > summary {
  display: flex;
  align-items: center;
  min-height: 44px;
  font-size: var(--fs-sm);
  font-weight: 550;
  color: var(--text-dim);
  cursor: pointer;
  list-style: none;
}
.setting details.advanced > summary::-webkit-details-marker { display: none; }
.setting details.advanced > summary::after {
  content: "";
  width: 8px;
  height: 8px;
  margin-left: auto;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg);
}
.setting details.advanced[open] > summary::after { transform: rotate(225deg); }
.advanced-body { display: flex; flex-wrap: wrap; gap: 10px; padding-top: 6px; }

.setting-value {
  font-size: var(--fs-sm);
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}
.ctl.wide { flex: 1 1 12em; }

.head-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 8px 12px;
}
.head-actions form { margin: 0; }
@media (max-width: 520px) {
  .account-head { align-items: flex-start; }
}

@media (min-width: 900px) {
  .settings-list { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }
}

.setting-controls .segmented {
  flex: 1 1 100%;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}
.setting-controls .segmented .chip {
  min-width: 0;
  padding: 0 4px;
  white-space: nowrap;
}
.range-grid {
  flex: 1 1 100%;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 12px;
}
@media (min-width: 700px) {
  .range-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
.range-grid .ctl { min-width: 0; }

@media print {
  .settings-list { break-inside: auto; }
  .setting { break-inside: avoid; }
}

/* Einrichtung: Suchen, Einrichten, Umziehen, Entfernen */
.setup-devices { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.setup-empty { margin: 4px 0 0; }
.setup-device {
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 12px 14px;
  display: grid;
  gap: 10px;
  background: var(--surface-2);
}
.setup-device-head { display: grid; gap: 2px; }
.setup-device-name {
  display: flex;
  align-items: baseline;
  gap: 6px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.setup-device-signal { color: var(--text-dim); font-weight: 550; }
.setup-device-dot { color: var(--text-faint); }
.setup-device-id {
  font-family: var(--mono);
  font-size: var(--fs-2xs);
  color: var(--text-faint);
  font-variant-numeric: tabular-nums;
}
.setup-device-form { display: flex; flex-wrap: nowrap; gap: 8px; align-items: center; }
.setup-device-form .segmented { flex: 1 1 auto; min-width: 0; overflow: hidden; }
.setup-device-form .stepper { flex: 0 0 auto; }
.setup-device-form .chip { padding: 0 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.setup-device-preview { margin: 0; font-size: var(--fs-sm); color: var(--text-dim); }
.setup-device-note { margin: 0; color: var(--red-text); }

/* stepper */
.stepper {
  display: inline-flex;
  align-items: center;
  gap: 0;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-pill);
  background: var(--surface);
  overflow: hidden;
}
.stepper-btn {
  width: 44px;
  min-height: 44px;
  border: 0;
  background: transparent;
  color: var(--text);
  font-size: var(--fs-lg);
  line-height: 1;
  cursor: pointer;
}
.stepper-btn:hover { background: var(--surface-3); }
.stepper-btn:focus-visible { outline: 3px solid var(--focus); outline-offset: -3px; }
.stepper-input {
  width: 46px;
  min-height: 44px;
  border: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-variant-numeric: tabular-nums;
  text-align: center;
  -moz-appearance: textfield;
}
.stepper-input::-webkit-outer-spin-button,
.stepper-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.stepper-input:focus-visible { outline: 3px solid var(--focus); outline-offset: -3px; }

/* step checklist */
.setup-checklist { list-style: none; margin: 2px 0 0; padding: 0; display: grid; gap: 6px; }
.step { display: flex; align-items: center; gap: 10px; font-size: var(--fs-sm); }
.step-text { min-width: 0; }
.step-icon {
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: inline-grid;
  place-items: center;
  font-size: var(--fs-2xs);
  line-height: 1;
}
.step-done .step-icon { color: var(--green-text); }
.step-done .step-icon::before { content: "✓"; }
.step-failed .step-icon { color: var(--red-text); }
.step-failed .step-icon::before { content: "!"; font-weight: 700; }
.step-todo { color: var(--text-faint); }
.step-todo .step-icon { border: 1px solid var(--border-strong); }
.step-running .step-icon {
  border: 2px solid var(--border-strong);
  border-top-color: var(--accent);
  animation: step-spin 800ms linear infinite;
}
.step-summary { color: var(--red-text); font-weight: 550; }
@keyframes step-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .step-running .step-icon { animation-duration: 2.4s; }
}

.row-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.btn.danger { border-color: var(--red); color: var(--red-text); }

/* bulb settings: live state block at the top */
.bulb-live {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  margin-bottom: 12px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface-2);
}
.bulb-live input[type="range"] { flex: 1 1 140px; min-width: 0; }
.bulb-live .bulb-level {
  font-variant-numeric: tabular-nums;
  font-size: var(--fs-sm);
  color: var(--text-dim);
  min-width: 44px;
  text-align: right;
}

/* effects: Von/Bis range reuses .range-grid from the bulb settings */
.fx-range { grid-column: 1 / -1; }

/* area sheet: link to the group settings page */
.sheet-head-main { display: grid; gap: 2px; min-width: 0; }
.sheet-link { font-size: var(--fs-sm); color: var(--accent-text, var(--accent)); text-decoration: none; }
.sheet-link:hover, .sheet-link:focus-visible { text-decoration: underline; }
.sheet-link[hidden] { display: none; }

/* group settings page */
.group-progress { display: grid; gap: 8px; }
.group-bar { height: 6px; border-radius: var(--r-pill); background: var(--surface-3); overflow: hidden; }
.group-bar > span { display: block; height: 100%; width: 0; background: var(--accent); transition: width .3s; }
.group-summary { font-size: var(--fs-sm); color: var(--text-dim); }
.group-summary.mixed { color: var(--amber-text, var(--text)); font-weight: 600; }
.group-failed { display: grid; gap: 8px; }
.group-failed ul { margin: 0; padding-left: 18px; }

/* ── schedules (Zeitpläne) ──────────────────────────────────────────── */

.sched-editor { margin-bottom: 18px; }
.sched-editor .chips[role="group"], .sched-editor .chips[role="radiogroup"] { gap: 8px; }
.sched-days .chip { min-width: 48px; padding: 0 10px; }
.sched-presets { margin-top: 4px; }
.chip-sm { min-height: 36px; font-size: var(--fs-sm); padding: 0 12px; }
.sched-editor input[type="time"] { max-width: 180px; }
.sched-offset-input { width: 64px; }
.sched-list { list-style: none; margin: 0 0 18px; padding: 0; display: grid; gap: 12px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 900px) { .sched-list { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.sched-card.is-off { opacity: 0.7; }
.sched-card.panel + .sched-card.panel { margin-top: 0; }
.sched-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.sched-title { min-width: 0; display: grid; gap: 2px; }
.sched-title h2 { font-size: var(--fs-lg); overflow-wrap: anywhere; }
.sched-action { margin: 10px 0 2px; font-size: var(--fs-md); }
.sched-next { margin: 0 0 12px; font-size: var(--fs-sm); color: var(--accent-text); }
.sched-card.is-off .sched-next { color: var(--text-dim); }
.sched-loc { align-items: end; }
.sched-log { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.sched-log-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 2px 12px;
  padding: 8px 0;
  border-top: 1px solid var(--border);
  font-size: var(--fs-sm);
}
.sched-log-row:first-child { border-top: 0; }
.sched-log-time { color: var(--text-dim); font-variant-numeric: tabular-nums; }
.sched-log-name { font-weight: 600; overflow-wrap: anywhere; }
.sched-log-action { grid-column: 2; color: var(--text-dim); }
.sched-log-status { grid-row: 1; grid-column: 3; color: var(--green-text); }
.sched-log-row.is-error .sched-log-status { color: var(--red-text); }
@media (max-width: 520px) {
  .sched-log-row { grid-template-columns: minmax(0, 1fr) auto; }
  .sched-log-time { grid-column: 1; }
  .sched-log-name { grid-column: 1; }
  .sched-log-action { grid-column: 1; }
  .sched-log-status { grid-row: 1; grid-column: 2; }
}
.sched-editor[hidden], .sched-editor [hidden], #sched-empty[hidden], #sched-log-empty[hidden] { display: none !important; }

/* ── dual range: one track, two knobs (Effekte, bulb brightness range) ── */
.dr { position: relative; height: 44px; padding: 0 22px; touch-action: none; user-select: none; -webkit-user-select: none; cursor: pointer; }
.dr-track { position: relative; height: 100%; touch-action: none; }
.dr-rail { position: absolute; left: 0; right: 0; top: 50%; height: 6px; margin-top: -3px; border-radius: var(--r-pill); background: var(--track); }
.dr-fill { position: absolute; top: 0; bottom: 0; border-radius: var(--r-pill); background: var(--fill, var(--accent)); }
.dr-knob {
  position: absolute;
  top: 0;
  width: 44px;
  height: 44px;
  margin-left: -22px;
  touch-action: none;
  outline: none;
}
.dr-knob::after {
  content: "";
  position: absolute;
  left: 10px;
  top: 10px;
  width: 24px;
  height: 24px;
  box-sizing: border-box;
  border-radius: 50%;
  border: 2px solid var(--surface);
  background: #fff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.32);
}
.dr-knob:focus-visible::after { outline: 3px solid var(--focus); outline-offset: 3px; }
.dr.is-disabled { opacity: 0.45; cursor: not-allowed; }
body[data-gateway="off"] .dr, body[data-gateway="unknown"] .dr { --fill: var(--surface-3); }
.fx-range .dr, .setting-controls .dr { flex: 1 1 100%; width: 100%; box-sizing: border-box; }

/* ── map (Karte) ─────────────────────────────────────────────────────── */

.view-switch { margin-left: auto; flex: 0 1 190px; min-width: 150px; }
.view-switch .chip { min-height: 36px; }
.cards[hidden], .map-panel[hidden] { display: none; }

.map-panel { display: grid; gap: var(--sp-3); }
.map-toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--sp-2); }
.map-zoom, .map-edit { display: flex; gap: var(--sp-2); }
.map-btn { min-width: 44px; font-size: var(--fs-xl); line-height: 1; }
.map-frame {
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--map-ground);
  box-shadow: var(--shadow-card);
  overflow: hidden;
}
.map-panel.is-editing .map-frame { border-color: var(--accent); }
.map-svg { display: block; width: 100%; height: auto; touch-action: none; user-select: none; -webkit-user-select: none; cursor: grab; }
.map-svg:active { cursor: grabbing; }

.map-ground { fill: var(--map-ground); }
.map-wall { fill: none; stroke: var(--map-edge); stroke-width: 1.5; }
.map-roof { fill: var(--map-roof-s); stroke: var(--map-edge); stroke-width: 1.5; }
.map-roof-gable { fill: var(--map-roof-gable); stroke: var(--map-edge); stroke-width: 1.5; stroke-linejoin: miter; }
.map-shed { fill: var(--map-shed); stroke: var(--map-edge); stroke-width: 1.5; }
.map-ridge { fill: none; stroke: var(--map-ridge); stroke-width: 1.5; }
.map-testbox { fill: var(--surface-2); stroke: var(--border-strong); stroke-width: 1.5; stroke-dasharray: 4 3; }
.map-north line { stroke: var(--text-dim); stroke-width: 1.5; }
.map-north polygon { fill: var(--text-dim); }
.map-north-text { font: 600 13px / 1 var(--font); fill: var(--text-dim); }

.map-line { fill: none; stroke: var(--text-faint); stroke-width: 1.5; stroke-dasharray: 2 3; opacity: 0.8; }
.map-line.is-unset { opacity: 0.45; }
.map-line-hit { fill: none; stroke: transparent; stroke-width: 16; stroke-linecap: round; stroke-linejoin: round; cursor: pointer; }

.map-label {
  font: 600 16px / 1 var(--font);
  fill: var(--text);
  paint-order: stroke;
  stroke: var(--map-ground);
  stroke-width: 4px;
  stroke-linejoin: round;
  cursor: pointer;
  outline: none;
}
.map-label[data-on="true"] { fill: var(--accent-text); }
.map-label.is-unset { fill: var(--text-dim); }
.map-label:hover { text-decoration: underline; }
.map-label:focus-visible { fill: var(--focus); text-decoration: underline; }

.map-bulb { --lvl: 0; cursor: pointer; outline: none; }
.map-halo { fill: rgba(var(--glow-rgb), calc(var(--lvl) * 0.5)); pointer-events: none; }
.map-ring { fill: none; stroke: var(--focus); stroke-width: 2; opacity: 0; pointer-events: none; }
.map-core { fill: var(--surface-3); stroke: var(--text-faint); stroke-width: 1.2; pointer-events: none; }
.map-hit { fill: transparent; }
.map-bulb[data-on="true"] .map-core { fill: var(--accent); stroke: rgba(var(--glow-rgb), 0.9); }
.map-bulb.is-unset .map-core { fill: transparent; stroke-dasharray: 2 1.6; stroke: var(--text-dim); }
.map-bulb.is-inactive { opacity: 0.55; }
.map-bulb:focus-visible .map-ring, .map-bulb.is-dragging .map-ring { opacity: 1; }
.map-panel.is-editing .map-bulb { cursor: move; }
.map-panel.is-editing .map-label, .map-panel.is-editing .map-line-hit { pointer-events: none; }

body[data-gateway="off"] .map-halo,
body[data-gateway="unknown"] .map-halo { fill: transparent; }

/* display:grid would otherwise beat the hidden attribute on these boxes */
.group-progress[hidden], .group-failed[hidden], #group-retry[hidden], #group-busy[hidden] { display: none; }

/* map: area picked from the Einrichtung page */
.map-bulb.is-hl .map-ring { opacity: 1; stroke-width: 3; }
.map-label.is-hl { fill: var(--accent-text); font-weight: 700; text-decoration: underline; }

/* Einrichtung: clickable area rows and the area detail */
.area-row-btn {
  width: 100%;
  text-align: left;
  font: inherit;
  color: inherit;
  cursor: pointer;
  min-height: 56px;
}
.area-row-btn:hover { border-color: var(--border-strong); background: var(--surface-3); }
.area-row-btn:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.area-row-end { display: inline-flex; align-items: center; gap: 8px; }
.area-row-end svg { width: 18px; height: 18px; color: var(--text-dim); }
.detail-links { display: flex; flex-wrap: wrap; gap: 8px; }
.detail-bulbs { display: grid; gap: 10px; }
.detail-bulb { display: grid; gap: 8px; padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface-2); }
.detail-bulb-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 12px; }
.detail-bulb-name { font-weight: 600; }
.detail-bulb-meta { font-size: var(--fs-xs); color: var(--text-dim); font-variant-numeric: tabular-nums; }
.detail-bulb-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.detail-bulb .setup-device-form { display: grid; gap: 8px; }

/* 2FA setup: QR on an opaque white tile so it scans in dark mode too */
.twofa-qr[hidden] { display: none; }
.twofa-qr { display: block; width: 216px; height: 216px; max-width: 100%;
  background: #fff; border-radius: 8px; image-rendering: pixelated; margin: 8px 0; }

/* ═══ effect engine: playback, programmer, setup, bulk setup ════════════ */

.head-actions .btn[aria-pressed="true"] { border-color: var(--accent); color: var(--accent-text); }
.ex-blackout[aria-pressed="true"] { background: var(--red); border-color: var(--red); color: #fff; }

/* radio-load meter (budget, programmer, bulk intake) */
.ex-meter {
  height: 12px;
  border-radius: var(--r-pill);
  background: var(--track);
  overflow: hidden;
}
.ex-meter-fill {
  height: 100%;
  width: 0;
  border-radius: var(--r-pill);
  background: var(--green);
  transition: width var(--motion), background var(--motion);
}
.ex-meter[data-level="warn"] .ex-meter-fill { background: var(--accent); }
.ex-meter[data-level="high"] .ex-meter-fill { background: var(--red); }
.ex-meterbar .hint { font-variant-numeric: tabular-nums; }
.ex-budget-row { margin-top: 10px; }
.ex-budget-row input { width: 5.5em; min-height: 44px; }

.pg-warnings { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 4px; }
.pg-warnings[hidden] { display: none; }
.pg-warnings li {
  padding: 6px 10px;
  border-radius: var(--r-sm);
  border: 1px solid var(--accent);
  background: color-mix(in srgb, var(--accent) 10%, var(--surface));
  color: var(--accent-text);
  font-size: var(--fs-sm);
}

/* speed masters */
.ex-speeds { display: grid; gap: 12px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.ex-sm {
  display: grid;
  gap: 8px;
  padding: 10px;
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface-2);
}
.ex-sm-head { display: flex; align-items: baseline; justify-content: space-between; }
.ex-sm-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.ex-sm-row .btn { min-width: 44px; padding: 0 10px; }
.ex-sm .stepper { max-width: 100%; }
.ex-sm .stepper-btn { width: 36px; min-width: 36px; height: 38px; padding: 0; }
.ex-sm .stepper-input { width: 54px; min-width: 0; height: 38px; padding: 0 4px; }
@media (min-width: 900px) { .ex-speeds { grid-template-columns: repeat(4, minmax(0, 1fr)); } }

/* executor bank: 2 columns on mobile, 4 at 600px, 8 (16 executors) on desktop */
.ex-bank { display: grid; gap: 10px; grid-template-columns: repeat(2, minmax(0, 1fr)); margin-top: 14px; }
.ex.ex-extra { display: none; }
.ex {
  display: grid;
  grid-template-rows: auto auto auto 1fr auto auto auto;
  gap: 6px;
  justify-items: center;
  min-width: 0;
  overflow: hidden;
  padding: 8px 4px 10px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
  box-shadow: var(--shadow-card);
}
.ex.is-empty { opacity: 0.55; box-shadow: none; }
.ex[data-status="running"] { border-color: var(--green); }
.ex[data-status="paused"] { border-color: var(--accent); }
.ex[data-status="error"] { border-color: var(--red); }
.ex-head { display: flex; align-items: center; gap: 4px; min-width: 0; max-width: 100%; box-sizing: border-box; }
.ex-num {
  flex: 0 0 auto;
  min-width: 22px;
  padding: 0 4px;
  border-radius: var(--r-pill);
  background: var(--surface-3);
  font-size: var(--fs-xs);
  font-weight: 700;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.ex-name {
  font-size: var(--fs-xs);
  font-weight: 650;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ex-sub { max-width: 100%; font-size: var(--fs-2xs); color: var(--text-dim); text-align: center; overflow: hidden; text-overflow: ellipsis; white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; min-height: 1em; }
.ex-state { font-size: var(--fs-2xs); font-weight: 650; color: var(--text-dim); text-align: center; max-width: 100%; overflow-wrap: anywhere; line-height: 1.15; }
.ex[data-status="running"] .ex-state { color: var(--green-text); }
.ex[data-status="error"] .ex-state { color: var(--red-text); }
.ex[data-status="unarmed"] .ex-state { color: var(--accent-text); }
.ex-cues {
  display: flex;
  flex-direction: column;
  gap: 2px;
  width: 100%;
  padding: 3px 4px;
  border-radius: var(--r-sm);
  background: var(--surface-2);
  box-sizing: border-box;
  font-size: var(--fs-2xs);
  line-height: 1.2;
}
.ex-cue {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 1px 4px;
  border-radius: 3px;
  color: var(--text-dim);
  min-width: 0;
}
.ex-cue.is-active {
  background: color-mix(in srgb, var(--green) 18%, transparent);
  color: var(--green-text);
  font-weight: 700;
  border-left: 2px solid var(--green);
}
.ex-cue.is-next {
  color: var(--text);
  border-left: 2px solid var(--accent);
}
.ex-cue-mark { flex: 0 0 auto; width: 1.1em; text-align: center; }
.ex-cue-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ex-fader {
  display: grid;
  grid-template-rows: 124px auto;
  align-items: center;
  justify-items: center;
  align-content: center;
  gap: 4px;
  width: 100%;
}
.ex-out {
  min-width: 3ch;
  white-space: nowrap;
  text-align: right;
  font-size: var(--fs-xs);
  font-variant-numeric: tabular-nums;
  color: var(--text-dim);
}
.ex-fader .ex-out { text-align: center; }
input[type="range"].ex-range {
  -webkit-appearance: none;
  appearance: none;
  writing-mode: horizontal-tb;
  direction: ltr;
  width: 112px;
  height: 36px;
  margin: 0;
  padding: 0;
  background: transparent;
  transform: rotate(-90deg);
  transform-origin: center center;
  cursor: pointer;
  touch-action: none;
}
input[type="range"].ex-range::-webkit-slider-runnable-track {
  width: 100%;
  height: 8px;
  border-radius: var(--r-pill);
  background: linear-gradient(to right,
    var(--fill, var(--accent)) calc(var(--pct, 0) * 1%),
    var(--track) calc(var(--pct, 0) * 1%));
}
input[type="range"].ex-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 28px;
  margin-top: -10px;
  margin-left: 0;
  border-radius: 6px;
  border: 2px solid var(--surface);
  background: #fff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
}
input[type="range"].ex-range::-moz-range-track {
  width: 100%;
  height: 8px;
  border-radius: var(--r-pill);
  background: var(--track);
}
input[type="range"].ex-range::-moz-range-progress {
  height: 8px;
  border-radius: var(--r-pill);
  background: var(--fill, var(--accent));
}
input[type="range"].ex-range::-moz-range-thumb {
  width: 18px;
  height: 28px;
  border-radius: 6px;
  border: 2px solid var(--surface);
  background: #fff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
}
.ex-btns { display: grid; gap: 6px; width: 100%; min-width: 0; max-width: 100%; box-sizing: border-box; padding: 0 4px; }
.ex-btns .btn { min-width: 0; max-width: 100%; width: 100%; box-sizing: border-box; padding: 0 4px; font-size: var(--fs-sm); }
.ex-go[aria-pressed="true"] { background: var(--green); border-color: var(--green); color: #04150d; }
.ex-flash:active { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.ex-arm { width: calc(100% - 8px); min-width: 0; max-width: 100%; box-sizing: border-box; padding: 4px; font-size: var(--fs-2xs); white-space: normal; line-height: 1.15; }
.ex-arm[hidden], .ex-arm-bar[hidden] { display: none; }
.ex-arm-bar { width: calc(100% - 12px); height: 6px; border-radius: var(--r-pill); background: var(--track); overflow: hidden; }
.ex-arm-fill { height: 100%; width: 0; background: var(--accent); transition: width var(--motion); }
.ex-bank-note { margin-top: 10px; margin-bottom: 14px; }
.fx-legacy { margin-top: 18px; }

@media (min-width: 600px) {
  .ex-bank { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

@media (min-width: 960px) {
  .ex-bank { grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 10px; }
  .ex.ex-extra { display: grid; }
  .ex { padding: 10px 6px 12px; }
  .ex-range { height: 150px; }
  .ex-bank-note { display: none; }
}

#twofa-setup { display: grid; gap: 10px; margin-bottom: 10px; }
#twofa-setup[hidden], .btn[hidden] { display: none; }

/* Simulator Mode bar */
.sim-bar {
  margin-bottom: 12px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface-2);
}
.sim-bar.is-active {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 8%, var(--surface-2));
}
.sim-bar-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.sim-presets { display: flex; flex-wrap: wrap; gap: 6px; }
.sim-bar[hidden], #fx-sim-map-panel[hidden] { display: none; }

/* programmer sheet */
.sheet-wide { width: min(1080px, calc(100vw - 24px)); max-height: min(92dvh, 940px); }
.sheet-wide .sheet-body { max-height: calc(92dvh - 66px); }
.pg-grid { display: grid; gap: 14px; grid-template-columns: minmax(0, 1fr); }
.pg-grid .segmented { flex-wrap: wrap; border-radius: var(--r-md); gap: 4px; }
.pg-grid .segmented .chip { flex: 1 1 auto; min-width: max-content; min-height: 38px; padding: 4px 10px; font-size: var(--fs-sm); text-align: center; border-radius: var(--r-sm); }
.pg-preview { display: grid; gap: 8px; padding: 6px 0 8px; background: var(--surface); }
.pg-meter-wrap { display: grid; gap: 4px; }
.pg-controls { display: grid; gap: 10px; align-content: start; min-width: 0; }
.pg-sec { border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface-2); }
.pg-sec > summary { padding: 12px 14px; font-weight: 650; cursor: pointer; min-height: 44px; display: flex; align-items: center; }
.pg-sec > summary:focus-visible { outline: 3px solid var(--focus); outline-offset: -3px; border-radius: var(--r-md); }
.pg-sec-body { display: grid; gap: 4px; padding: 0 14px 12px; }
.pg-sec .field { margin-bottom: 8px; }
.pg-speed-row { display: flex; align-items: center; gap: 10px; margin: 8px 0; }
.pg-groups .chip { min-height: 40px; padding: 0 12px; font-size: var(--fs-sm); }
.pg-map-slot .fxmap-frame { max-height: 240px; }
@media (min-width: 900px) {
  .pg-grid { grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); align-items: start; }
  .pg-preview { position: sticky; top: var(--s-2, 8px); z-index: 2; align-self: start; }
  .pg-map-slot .fxmap-frame { max-height: none; }
}

/* the bulb map used by the effect pages */
.fxmap { display: grid; gap: var(--sp-2); }
.fxmap-frame { touch-action: none; }
.fxmap-svg { cursor: crosshair; }
.fxmap-hint { text-align: right; }
.fxmap-bulb { --lvl: 0; cursor: pointer; }
.fxmap-halo { fill: rgba(var(--glow-rgb), calc(var(--lvl) * 0.55)); pointer-events: none; }
.fxmap-core { fill: var(--surface-3); stroke: var(--text-faint); stroke-width: 1.2; pointer-events: none; }
.fxmap-bulb.is-on .fxmap-core { fill: rgba(var(--glow-rgb), calc(0.35 + var(--lvl) * 0.65)); stroke: rgba(var(--glow-rgb), 0.95); }
.fxmap-ring { fill: none; stroke: var(--focus); stroke-width: 1.8; opacity: 0; pointer-events: none; }
.fxmap-hit { fill: transparent; }
.fxmap-bulb.is-selected .fxmap-ring { opacity: 1; }
.fxmap.is-dimmed .fxmap-bulb:not(.is-selected) { opacity: 0.32; }
.fxmap-bulb.is-unset .fxmap-core { stroke-dasharray: 2 1.6; stroke: var(--text-dim); }
.fxmap-bulb.is-free .fxmap-core { fill: transparent; stroke: var(--accent); stroke-width: 1.8; }
.fxmap-bulb.is-free .fxmap-ring { opacity: 1; stroke: var(--accent); stroke-dasharray: 2 2; }
.fxmap-bulb.is-taken { opacity: 0.4; }
.fxmap-bulb.is-hl .fxmap-ring { opacity: 1; stroke: var(--accent); stroke-width: 3; }
.fxmap-num { font: 700 8px / 1 var(--font); fill: var(--text); paint-order: stroke; stroke: var(--map-ground); stroke-width: 2.4px; pointer-events: none; }
.fxmap-origin circle { fill: none; stroke: var(--accent); stroke-width: 1.6; }
.fxmap-origin path { stroke: var(--accent); stroke-width: 1.6; }
body[data-gateway="off"] .fxmap-halo, body[data-gateway="unknown"] .fxmap-halo { fill: rgba(var(--glow-rgb), calc(var(--lvl) * 0.55)); }

/* Einrichtung: groups, presets, effects, executors */
.fxs-tabs { margin-bottom: 14px; max-width: 640px; }
.fxs-tabs .chip { min-height: 38px; padding: 4px 10px; font-size: var(--fs-sm); text-align: center; }
.fxs-layout { display: grid; gap: 14px; grid-template-columns: minmax(0, 1fr); align-items: start; }
.fxs-side[hidden] { display: none; }
@media (min-width: 900px) { .fxs-layout { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } .fxs-side { position: sticky; top: 16px; align-self: start; } }
.fxs-list { list-style: none; margin: 0 0 12px; padding: 0; display: grid; gap: 8px; }
.fxs-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 12px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface-2);
}
.fxs-row-main { display: grid; gap: 2px; min-width: 0; }
.fxs-row-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.fxs-editor { display: grid; gap: 4px; padding-top: 10px; border-top: 1px solid var(--border); }
.fxs-editor[hidden], .fxs-items[hidden] { display: none; }
.fxs-members { list-style: none; margin: 0 0 12px; padding: 0; display: grid; gap: 6px; }
.fxs-member {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 6px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--surface-2);
}
.fxs-member.is-dragging { opacity: 0.55; border-color: var(--accent); }
.fxs-member.is-drop { box-shadow: 0 -3px 0 var(--accent); }
.fxs-handle {
  flex: 0 0 auto;
  width: 44px;
  min-height: 44px;
  border: 0;
  background: transparent;
  color: var(--text-dim);
  font-size: var(--fs-xl);
  cursor: grab;
  touch-action: none;
}
.fxs-handle:focus-visible { outline: 3px solid var(--focus); outline-offset: -3px; }
.fxs-order { flex: 0 0 auto; min-width: 2ch; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--accent-text); text-align: right; }
.fxs-member-name { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fxs-mini { min-width: 34px; padding: 0 8px; }
.fxs-items { display: grid; gap: 8px; margin: 8px 0; }
.fxs-item { display: grid; gap: 8px; align-items: center; padding: 8px; border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface-2); }
.fxs-item > * { min-width: 0; }
.fxs-item-preset { grid-template-columns: minmax(0, 1fr) auto; }
.fxs-item-preset .fxs-item-level { grid-column: 1 / -1; }
.fxs-item-cue { grid-template-columns: auto minmax(80px, auto) minmax(0, 1fr) auto; }
.fxs-item-cue .fxs-mini { grid-column: 4; grid-row: 1; }
.fxs-item-cue .stepper { grid-column: 1 / -1; justify-self: start; }
@media (min-width: 640px) {
  .fxs-item-preset { grid-template-columns: minmax(0, 1fr) minmax(140px, 1fr) auto; }
  .fxs-item-preset .fxs-item-level { grid-column: auto; }
  .fxs-item-cue { grid-template-columns: auto minmax(90px, auto) minmax(0, 1fr) auto auto; }
  .fxs-item-cue .fxs-mini { grid-column: auto; grid-row: auto; }
  .fxs-item-cue .stepper { grid-column: auto; }
}
.fxs-item-level { display: flex; align-items: center; gap: 6px; min-width: 0; }

/* Massen-Einrichtung */
.bk-steps { display: flex; flex-wrap: wrap; gap: 8px; list-style: none; margin: 0 0 14px; padding: 0; counter-reset: bk; }
.bk-manual .inline { flex-wrap: wrap; gap: 8px; }
.bk-steps li {
  flex: 1;
  counter-increment: bk;
  padding: 8px 10px;
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  background: var(--surface-2);
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--text-dim);
}
.bk-steps li::before { content: counter(bk) ". "; }
.bk-steps li[aria-current="step"] { border-color: var(--accent); color: var(--accent-text); }
.bk-steps li.is-done { color: var(--green-text); }
.bk-list { list-style: none; margin: 12px 0; padding: 0; display: grid; gap: 6px; }
.bk-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 10px; padding: 8px 12px; border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface-2); }
.bk-row[data-state="failed"] { border-color: var(--red); }
.bk-row[data-state="configured"] { border-color: color-mix(in srgb, var(--green) 55%, var(--border)); }
.bk-row-main { display: grid; gap: 2px; min-width: 0; }
.bk-state { font-size: var(--fs-sm); font-weight: 600; }
.bk-row[data-state="failed"] .bk-state { color: var(--red-text); }
.bk-row[data-state="configured"] .bk-state { color: var(--green-text); }
.bk-mode { max-width: 360px; margin-bottom: 10px; }
.bk-place-grid { display: grid; gap: 14px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 900px) { .bk-place-grid { grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); align-items: start; } }
.bk-side { display: grid; gap: 10px; align-content: start; }
.bk-current { padding: 12px; border-radius: var(--r-md); border: 1px solid var(--accent); background: color-mix(in srgb, var(--accent) 9%, var(--surface)); font-weight: 600; }
.bk-current:empty { display: none; }
.bk-walk-q { font-size: var(--fs-lg); font-weight: 650; margin: 0 0 8px; }
.bk-manual[hidden], .bk-walk[hidden] { display: none; }
.bk-unassigned .btn[aria-pressed="true"] { border-color: var(--accent); }

/* Fix 9A: CSP-safe spacing rules (no inline style="..." in templates) */
.section-head p + h1,
#group-title,
#bulb-title { margin-top: 14px; }
#group-panel > .setting-desc { margin-bottom: 14px; }
#group-list { margin-top: 14px; }
.group-refresh-row,
#group-panel > p:last-child { margin-top: 16px; }
.detail-links { margin-top: 14px; }
#twofa-uri { word-break: break-all; }

/* Fix 9C: Active state for Synchron button */
#ex-sync[aria-pressed="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}
