/* Jekaidi — dunkles Mobil-UI. Jede Ansicht ist exakt bildschirmhoch:
   nichts muss gescrollt werden. Größen skalieren mit dvh, damit auch
   kleine Telefone (iPhone SE) alles auf einen Blick zeigen. */
:root {
  --bg: #0b1020;
  --bg2: #121a33;
  --card: #171f3a;
  --line: #26315c;
  --text: #eef2ff;
  --dim: #93a0c9;
  --ok: #2dd4a0;
  --warn: #f5b942;
  --bad: #ff5468;
  --accent: #5b8cff;
  --radius: 16px;
}
* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  /* Kein Double-Tap-Zoom, keine Zoom-Gesten — App, nicht Webseite. */
  touch-action: manipulation;
  -webkit-touch-callout: none;
}
/* Nichts scrollt: html/body sind fest, und auch der innere Container
   clippt nur — jede Ansicht ist so kompakt, dass sie ganz hineinpasst. */
html, body {
  height: 100%;
  overflow: hidden;
  position: fixed;
  inset: 0;
  width: 100%;
  overscroll-behavior: none;
}
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, "SF Pro Text", system-ui, Segoe UI, Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.4;
  -webkit-user-select: none;
  user-select: none;
}
#scroller {
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
.view {
  display: none;
  height: 100%;
  min-height: 0;
  overflow: hidden;
  flex-direction: column;
  padding: clamp(8px, 1.6dvh, 16px) 16px;
  gap: clamp(6px, 1.3dvh, 12px);
  max-width: 560px;
  margin: 0 auto;
}
.view.active { display: flex; }
h1 { font-size: clamp(1.25rem, 2.8dvh, 1.6rem); margin: 0; letter-spacing: .01em; }
h2 { font-size: .82rem; margin: 0; color: var(--dim); font-weight: 600; text-transform: uppercase; letter-spacing: .08em; }
p { margin: 0; color: var(--dim); }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: clamp(10px, 1.6dvh, 15px); }
.spacer { flex: 1; }

button {
  font: inherit; border: 0; border-radius: 14px; padding: 12px 16px;
  background: var(--accent); color: #fff; font-weight: 650; cursor: pointer;
  touch-action: manipulation;
}
button:active { transform: scale(.985); }
button.secondary { background: var(--bg2); color: var(--text); border: 1px solid var(--line); }
button.danger { background: var(--bad); }
button.ok { background: var(--ok); color: #04241a; }
button.big { font-size: clamp(1.05rem, 2.2dvh, 1.3rem); padding: clamp(12px, 2.2dvh, 19px); border-radius: 18px; width: 100%; flex: none; }
button:disabled { opacity: .45; }
input[type=text] {
  font: inherit; width: 100%; padding: clamp(10px, 1.6dvh, 13px) 13px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--bg2); color: var(--text);
  -webkit-user-select: text; user-select: text;
}
.row { display: flex; gap: 10px; align-items: center; }
.col { display: flex; flex-direction: column; gap: clamp(6px, 1.2dvh, 10px); }
.small { font-size: .85rem; }
.mono { font-variant-numeric: tabular-nums; }

/* Installations-Anleitung */
.install-step { display: flex; gap: 10px; align-items: flex-start; }
.install-step .num {
  background: var(--accent); color: #fff; width: 26px; height: 26px; flex: none;
  border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: .9rem;
}
.install-step p { font-size: .95rem; }

/* Raum-Liste: der flexible Bereich der Zentrale. Passt normalerweise ganz
   auf den Schirm; nur bei ungewöhnlich vielen Räumen scrollt sie intern
   (Notventil, damit kein Raum unerreichbar wird). */
#room-list { flex: 1 1 auto; min-height: 0; overflow-y: auto; overflow-x: hidden; overscroll-behavior: none; }
.link-actions { display: flex; gap: 6px; }
.link-actions button { padding: 7px 4px; font-size: .82rem; flex: 1; }

/* Anruf-Ansicht: beide Statusbanner nebeneinander statt untereinander */
.banner-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; flex: none; }
.status-banner {
  border-radius: var(--radius); padding: clamp(8px, 1.4dvh, 14px) 10px; text-align: center;
  font-weight: 800; transition: background .2s, border-color .2s;
  border: 2px solid var(--line); background: var(--bg2); min-width: 0;
}
.status-banner .headline { font-size: .78rem; font-weight: 700; }
.status-banner .detail { font-size: clamp(1.3rem, 3dvh, 1.9rem); font-variant-numeric: tabular-nums; line-height: 1.2; overflow-wrap: break-word; }
.status-banner .sub { font-weight: 500; font-size: .68rem; color: var(--dim); margin-top: 2px; }
.status-banner.state-ok   { border-color: var(--ok);   background: #0e2a20; }
.status-banner.state-ok .detail { color: var(--ok); }
.status-banner.state-warn { border-color: var(--warn); background: #2f2410; }
.status-banner.state-warn .detail { color: var(--warn); }
.status-banner.state-bad  { border-color: var(--bad);  background: #34121a; }
.status-banner.state-bad .detail { color: var(--bad); }
.status-banner.state-idle { opacity: .7; }

/* Live-Waveform (Funktionsbeweis: da läuft wirklich Audio) */
.wave {
  width: 100%;
  height: clamp(36px, 6.5dvh, 72px);
  flex: none;
  display: block;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 12px;
}
.wave.small { height: clamp(28px, 5dvh, 56px); }

/* Raum-Karten: Anrufer erscheinen live IN ihrer Raum-Karte */
.room-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; display: flex; flex-direction: column; gap: 8px; flex: none; }
.room-card.ringing { border-color: var(--ok); animation: pulse 2.2s ease-in-out infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 6px rgba(45, 212, 160, .12); } }
.room-card .room-id { font-weight: 700; font-size: .98rem; letter-spacing: .02em; }
.room-card .room-id .uuid-rest { color: var(--dim); font-weight: 400; font-size: .74rem; }
.caller-box {
  border: 2px solid var(--ok); border-radius: 14px; padding: 10px;
  background: linear-gradient(160deg, #12301f, #10241c);
  display: flex; flex-direction: column; gap: 8px;
}
.caller-box.stale { border-color: var(--bad); background: #2b1218; }
.caller-box .live-line { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.caller-box .hb-ms { font-size: 1.4rem; font-weight: 800; font-variant-numeric: tabular-nums; color: var(--ok); }
.caller-box.stale .hb-ms { color: var(--bad); }
.caller-box .hb-label { font-size: .72rem; color: var(--dim); text-transform: uppercase; letter-spacing: .06em; }

.meter { height: 8px; border-radius: 4px; background: var(--bg); overflow: hidden; }
.meter > div { height: 100%; width: 0%; background: var(--ok); border-radius: 4px; transition: width .06s linear; }
.meter.small { height: 6px; }

.stats-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 6px; text-align: center; }
.stat .value { font-size: clamp(.95rem, 2dvh, 1.2rem); font-weight: 750; font-variant-numeric: tabular-nums; }
.stat .name { font-size: .58rem; color: var(--dim); text-transform: uppercase; letter-spacing: .05em; }

.toggles { flex: none; }
.toggles label { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: clamp(4px, .9dvh, 9px) 0; border-bottom: 1px solid var(--line); font-size: .92rem; }
.toggles label:last-child { border-bottom: 0; }
.toggles input { width: 21px; height: 21px; accent-color: var(--accent); }

/* Aussetzer-Protokoll füllt den Rest der Anruf-Ansicht. Neueste Einträge
   stehen oben (prepend), Älteres wird unten schlicht abgeschnitten —
   die Zusammenfassung gibt es ohnehin auf der Ende-Seite. */
.outage-card { flex: 1 1 40px; min-height: 0; overflow: hidden; }
#outage-log { display: flex; flex-direction: column; gap: 4px; flex: 1 1 0; min-height: 0; overflow: hidden; }
#outage-log .entry { font-size: .82rem; color: var(--dim); font-variant-numeric: tabular-nums; flex: none; }
#outage-log .entry b { color: var(--bad); }

/* Benachrichtigungs-Zeile in der Zentrale */
.push-card { display: flex; align-items: center; gap: 12px; flex: none; }
.push-card > div { flex: 1; min-width: 0; }
.push-card h2 { margin-bottom: 2px; }
.push-card .small { font-size: .78rem; }
.push-card button { flex: none; }

.toast {
  position: fixed; left: 16px; right: 16px; bottom: calc(20px + env(safe-area-inset-bottom));
  background: var(--ok); color: #04241a; font-weight: 700; padding: 14px 16px;
  border-radius: 14px; text-align: center; z-index: 40;
  transform: translateY(140%); transition: transform .25s ease; max-width: 528px; margin: 0 auto;
}
.toast.show { transform: translateY(0); }
.toast.warn { background: var(--warn); color: #241a04; }
.toast.bad { background: var(--bad); color: #fff; }

.wait-timer { font-size: clamp(2.2rem, 7dvh, 3.4rem); font-weight: 800; text-align: center; font-variant-numeric: tabular-nums; }
.presence { display: flex; align-items: center; gap: 8px; justify-content: center; color: var(--dim); }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--warn); }
.dot.on { background: var(--ok); }

dialog {
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--card);
  color: var(--text); padding: 20px; max-width: 90vw;
}
dialog::backdrop { background: rgba(0, 0, 0, .6); }
dialog img { width: min(70vw, 55dvh, 320px); height: auto; background: #fff; border-radius: 12px; padding: 10px; }

.error-box { border: 2px solid var(--bad); border-radius: var(--radius); padding: 16px; background: #34121a; }
