/* Alarmanlage. Ein Screen. Radius-System: Pill (Interaktives), 28px (Flaechen). */
:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --text: #121316;
  --muted: #5a5e66;
  --track: rgb(255 255 255 / .62);
  --track-edge: rgb(255 255 255 / .8);
  --hair: rgb(18 19 22 / .08);
  --accent: #0b7a54;          /* Emerald, einziger Akzent */
  --accent-ink: #ffffff;
  --away: #25272c;            /* Graphit fuer "scharf" */
  --away-ink: #ffffff;
  --alert: #c8302f;           /* nur fuer Alarm */
  --shadow: 0 1px 0 rgb(255 255 255 / .7) inset, 0 14px 40px -18px rgb(18 24 40 / .35);
  --font: system-ui, -apple-system, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  --ease: cubic-bezier(.16, 1, .3, 1);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d0e10; --surface: #17181b; --text: #f2f3f5; --muted: #a0a4ad;
    --track: rgb(40 42 48 / .6); --track-edge: rgb(255 255 255 / .09);
    --hair: rgb(255 255 255 / .09);
    --accent: #2fbf8a; --accent-ink: #06231a;
    --away: #e9eaed; --away-ink: #16171a;
    --alert: #ff6b66;
    --shadow: 0 1px 0 rgb(255 255 255 / .06) inset, 0 18px 50px -20px rgb(0 0 0 / .8);
  }
}
@media (prefers-reduced-transparency: reduce) { :root { --track: var(--surface); } }

* { box-sizing: border-box; margin: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  min-height: 100dvh; background: var(--bg); color: var(--text);
  font: 400 1rem/1.5 var(--font); -webkit-font-smoothing: antialiased;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
.page {
  min-height: 100dvh; max-width: 30rem; margin: 0 auto; padding: 1.25rem 1.5rem 2rem;
  display: grid; grid-template-rows: auto 1fr auto; gap: 1.5rem;
}
.topbar { display: flex; justify-content: space-between; align-items: center; min-height: 3rem; }
.who { color: var(--muted); font-size: .9375rem; }
.icon-btn {
  width: 3rem; height: 3rem; border-radius: 999px; border: 0; background: transparent; color: var(--muted);
  display: grid; place-items: center; cursor: pointer; transition: transform 100ms ease-out, background-color .2s;
}
.icon-btn svg { width: 1.5rem; height: 1.5rem; }
.icon-btn:active { transform: scale(.94); background: var(--hair); }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }

/* Status */
.status { align-self: center; display: grid; gap: .75rem; justify-items: start; padding-bottom: 2rem; }
.hero-icon {
  position: relative; width: 7rem; height: 7rem; border-radius: 999px; margin-bottom: 1rem;
  background: var(--surface); color: var(--text); box-shadow: var(--shadow);
  transition: background-color .5s var(--ease), color .5s var(--ease);
}
.hero-icon .glyph, .hero-icon > svg {
  position: absolute; inset: 0; display: grid; place-items: center;
  opacity: 0; transform: scale(.7); transition: opacity .35s var(--ease), transform .5s var(--ease);
}
.glyph svg { width: 3.25rem; height: 3.25rem; }
.hero-icon--idle > svg { opacity: 1; transform: none; inset: 0; width: 3.25rem; height: 3.25rem; margin: auto; }
.ring { position: absolute; inset: -.5rem; border-radius: 999px; border: 2px solid currentColor; opacity: 0; }
.display { font-size: clamp(2.5rem, 11vw, 3.5rem); line-height: 1.05; letter-spacing: -.035em; font-weight: 700; }
.lead { color: var(--muted); font-size: 1.125rem; max-width: 24rem; letter-spacing: -.005em; }
.error { color: var(--alert); font-weight: 600; max-width: 24rem; }

#app[data-state="home"] .hero-icon { background: var(--accent); color: var(--accent-ink); }
#app[data-state="home"] .g-home,
#app[data-state="away"] .g-away,
#app[data-state="arming"] .g-arming,
#app[data-state="pending"] .g-warn,
#app[data-state="triggered"] .g-warn,
#app[data-state="offline"] .g-offline { opacity: 1; transform: none; }
#app[data-state="away"] .hero-icon { background: var(--away); color: var(--away-ink); }
#app[data-state="arming"] .hero-icon { background: var(--surface); color: var(--text); }
#app[data-state="pending"] .hero-icon, #app[data-state="triggered"] .hero-icon { background: var(--alert); color: #fff; }
#app[data-state="offline"] .hero-icon { color: var(--muted); }
#app[data-state="arming"] .ring { animation: pulse 1.8s var(--ease) infinite; }
#app[data-state="triggered"] .ring { animation: pulse 1.1s var(--ease) infinite; }
@keyframes pulse { 0% { opacity: .55; transform: scale(.94); } 100% { opacity: 0; transform: scale(1.18); } }

/* Skeleton: gleiche Form wie das Hero */
#app[data-state="loading"] .hero-icon { background: var(--hair); box-shadow: none; }
#app[data-state="loading"] .display, #app[data-state="loading"] .lead {
  color: transparent; background: var(--hair); border-radius: 999px; width: 60%; min-height: 1.2em; animation: shimmer 1.6s ease-in-out infinite;
}
#app[data-state="loading"] .lead { width: 40%; }
@keyframes shimmer { 50% { opacity: .5; } }

/* Schalter */
.control { display: grid; gap: .875rem; }
.switch {
  --pad: 6px;
  position: relative; display: grid; grid-template-columns: 1fr 1fr; height: 4.5rem; padding: var(--pad);
  border-radius: 999px; background: var(--track); border: 1px solid var(--track-edge);
  backdrop-filter: blur(24px) saturate(180%); -webkit-backdrop-filter: blur(24px) saturate(180%);
  box-shadow: var(--shadow); touch-action: pan-y; user-select: none; -webkit-user-select: none;
}
.thumb {
  position: absolute; top: var(--pad); bottom: var(--pad); left: var(--pad); width: calc((100% - 2 * var(--pad)) / 2);
  border-radius: 999px; background: var(--accent); will-change: transform;
  box-shadow: 0 6px 18px -8px rgb(0 0 0 / .45); transition: background-color .35s var(--ease);
  touch-action: none; cursor: grab;
}
.thumb:active { cursor: grabbing; }
.switch[data-side="away"] .thumb { background: var(--away); }
.seg {
  position: relative; z-index: 1; border: 0; background: transparent; font: 600 1.0625rem/1 var(--font);
  letter-spacing: -.01em; color: var(--muted); border-radius: 999px; cursor: pointer; min-height: 56px;
  transition: color .25s var(--ease); touch-action: none;
}
.switch[data-side="home"] .seg[data-target="home"] { color: var(--accent-ink); }
.switch[data-side="away"] .seg[data-target="away"] { color: var(--away-ink); }
.switch[aria-busy="true"] .thumb { opacity: .9; }
.hint { color: var(--muted); font-size: .875rem; text-align: center; }
#app[data-state="loading"] .switch, #app[data-state="offline"] .switch { opacity: .55; pointer-events: none; }

/* Login */
.page--login { grid-template-rows: 1fr; align-content: center; }
.login { display: grid; gap: .875rem; justify-items: start; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; min-height: 3.5rem; padding: 0 1.75rem; margin-top: 1rem;
  border-radius: 999px; background: var(--accent); color: var(--accent-ink); font-weight: 600; font-size: 1.0625rem;
  text-decoration: none; white-space: nowrap; transition: transform 100ms ease-out;
}
.btn:active { transform: scale(.97); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition-duration: .01ms !important; }
  .hero-icon .glyph { transform: none; }
}
