/* Zuhause — dunkles Glas-Design. Akzentfarbe kommt aus dem Telegram-Theme. */

:root {
  --akzent: var(--tg-theme-button-color, #3d9bff);
  --akzent-text: var(--tg-theme-button-text-color, #fff);
  --text: #eef2f8;
  --text-2: #a5afc0;
  --text-3: #6f7a8c;
  --glas: rgba(255, 255, 255, 0.06);
  --glas-2: rgba(255, 255, 255, 0.10);
  --rand: rgba(255, 255, 255, 0.09);
  --gruen: #3ddc97;
  --gelb: #ffc857;
  --rot: #ff5d6c;
  --radius: 20px;
  --unten: max(env(safe-area-inset-bottom), var(--tg-safe-area-inset-bottom, 0px));
  color-scheme: dark;
}

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

html, body {
  margin: 0;
  min-height: 100%;
  background: #0b0f17;
  color: var(--text);
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

#hintergrund {
  position: fixed; inset: 0; z-index: -1;
  background:
    radial-gradient(60% 45% at 15% 0%, rgba(61, 155, 255, 0.28), transparent 70%),
    radial-gradient(55% 40% at 100% 30%, rgba(155, 92, 255, 0.20), transparent 70%),
    radial-gradient(60% 45% at 30% 100%, rgba(61, 220, 151, 0.12), transparent 70%),
    #0b0f17;
}

#kopf { padding: 18px 16px 6px; }
#kopf h1 { margin: 0; font-size: 26px; font-weight: 700; letter-spacing: -0.02em; }
#kopf .unter { color: var(--text-2); font-size: 14px; margin-top: 2px; }

main { padding: 8px 16px calc(96px + var(--unten)); max-width: 720px; margin: 0 auto; }
.laden { color: var(--text-3); text-align: center; padding: 40px 0; }

/* ── Glas-Karten ── */
.karte {
  background: var(--glas);
  border: 1px solid var(--rand);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 12px;
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
}
.karte h2 { margin: 0 0 10px; font-size: 15px; font-weight: 600; color: var(--text-2); display: flex; justify-content: space-between; align-items: center; }
.karte h2 .zahl { font-weight: 500; color: var(--text-3); font-size: 13px; }
.abschnitt { margin: 18px 4px 8px; font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-3); }

.raster { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-bottom: 12px; }
.raster .karte { margin: 0; }
.kachel .wert { font-size: 26px; font-weight: 700; letter-spacing: -0.02em; }
.kachel .wert small { font-size: 15px; font-weight: 500; color: var(--text-2); }
.kachel .titel { font-size: 13px; color: var(--text-2); margin-bottom: 4px; }
.kachel .fuss { font-size: 13px; color: var(--text-3); margin-top: 2px; }
.kachel.breit { grid-column: 1 / -1; }
.kachel.alarm { border-color: rgba(255, 93, 108, 0.6); background: rgba(255, 93, 108, 0.14); }

/* ── Hinweise ── */
.hinweis {
  display: flex; gap: 10px; align-items: center;
  padding: 12px 14px; border-radius: 16px; margin-bottom: 10px;
  font-size: 15px; font-weight: 500;
  border: 1px solid var(--rand);
}
.hinweis.gelb { background: rgba(255, 200, 87, 0.13); border-color: rgba(255, 200, 87, 0.4); }
.hinweis.rot { background: rgba(255, 93, 108, 0.15); border-color: rgba(255, 93, 108, 0.5); }
.hinweis.gruen { background: rgba(61, 220, 151, 0.12); border-color: rgba(61, 220, 151, 0.4); }
.hinweis.blau { background: rgba(61, 155, 255, 0.13); border-color: rgba(61, 155, 255, 0.4); }
.hinweis .sym { font-size: 20px; }

/* ── Knöpfe ── */
button {
  font: inherit; color: inherit; border: 0; cursor: pointer;
  min-height: 48px; border-radius: 14px; padding: 0 16px;
  background: var(--glas-2); border: 1px solid var(--rand);
  font-weight: 600; transition: transform .08s, background .15s, opacity .15s;
}
button:active { transform: scale(0.97); }
button:disabled { opacity: 0.35; cursor: default; transform: none; }
button.haupt { background: var(--akzent); color: var(--akzent-text); border-color: transparent; }
button.gefahr { background: rgba(255, 93, 108, 0.18); border-color: rgba(255, 93, 108, 0.45); color: #ffd6da; }
button.breit { width: 100%; }
button.ok { background: rgba(61, 220, 151, 0.25); border-color: rgba(61, 220, 151, 0.5); }

/* ── Licht ── */
.licht { display: grid; grid-template-columns: 1fr auto; gap: 8px 12px; align-items: center; padding: 10px 0; border-top: 1px solid var(--rand); }
.licht:first-of-type { border-top: 0; padding-top: 0; }
.licht .name { font-weight: 600; }
.licht .name small { display: block; font-weight: 400; color: var(--text-3); font-size: 13px; }
.licht input[type=range] { grid-column: 1 / -1; }

.schalter {
  width: 58px; min-height: 34px; height: 34px; padding: 0; border-radius: 999px; position: relative;
  background: rgba(255, 255, 255, 0.12);
}
.schalter::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 26px; height: 26px; border-radius: 50%;
  background: #fff; transition: transform .18s;
}
.schalter.an { background: var(--gelb); border-color: transparent; }
.schalter.an::after { transform: translateX(24px); }

input[type=range] {
  -webkit-appearance: none; appearance: none; width: 100%; height: 34px; background: transparent; margin: 0;
}
input[type=range]::-webkit-slider-runnable-track { height: 10px; border-radius: 999px; background: linear-gradient(90deg, var(--gelb) var(--p, 0%), rgba(255, 255, 255, 0.12) var(--p, 0%)); }
input[type=range]::-moz-range-track { height: 10px; border-radius: 999px; background: rgba(255, 255, 255, 0.12); }
input[type=range]::-moz-range-progress { height: 10px; border-radius: 999px; background: var(--gelb); }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 28px; height: 28px; margin-top: -9px; border-radius: 50%; background: #fff; box-shadow: 0 2px 8px rgba(0, 0, 0, .4); }
input[type=range]::-moz-range-thumb { width: 28px; height: 28px; border: 0; border-radius: 50%; background: #fff; }
input[type=range].aus::-webkit-slider-runnable-track { background: rgba(255, 255, 255, 0.12); }

/* ── Szenen ── */
.szenen { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.szenen button { min-height: 64px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; }
.szenen button .sym { font-size: 22px; }
.szenen button .txt { font-size: 14px; }

/* ── Rollos ── */
.rollo { padding: 10px 0; border-top: 1px solid var(--rand); }
.rollo:first-of-type { border-top: 0; padding-top: 0; }
.rollo .zeile { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 6px; }
.rollo .name { font-weight: 600; }
.rollo .stand { color: var(--text-2); font-size: 14px; }
.balken { height: 6px; border-radius: 999px; background: rgba(255, 255, 255, 0.1); overflow: hidden; margin-bottom: 10px; }
.balken div { height: 100%; background: var(--akzent); border-radius: 999px; transition: width .4s; }
.knoepfe { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.knoepfe button { font-size: 20px; }

/* ── Kino ── */
.kino { display: grid; gap: 10px; }
.kino button { min-height: 60px; font-size: 17px; }
.beamer { display: flex; align-items: center; gap: 14px; }
.beamer .sym { font-size: 34px; }
.beamer .wert { font-size: 20px; font-weight: 700; }

/* ── Termine ── */
.termin { display: grid; grid-template-columns: 56px 1fr; gap: 10px; padding: 8px 0; border-top: 1px solid var(--rand); }
.termin:first-of-type { border-top: 0; padding-top: 0; }
.termin .zeit { color: var(--akzent); font-weight: 600; font-variant-numeric: tabular-nums; }
.termin .titel { font-weight: 500; overflow-wrap: anywhere; }
.termin .kal { font-size: 13px; color: var(--text-3); }
.tag { font-size: 13px; color: var(--text-2); font-weight: 600; margin: 10px 0 4px; }
.tag:first-child { margin-top: 0; }
.leer { color: var(--text-3); font-size: 14px; }

/* ── WLAN ── */
.qr { display: flex; justify-content: center; padding: 10px; background: #fff; border-radius: 16px; margin-bottom: 12px; }
.qr img { width: 240px; max-width: 100%; height: auto; image-rendering: pixelated; }

/* ── Server ── */
.bots { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.bot { background: var(--glas); border: 1px solid var(--rand); border-radius: 16px; padding: 10px 12px; min-width: 0; }
.bot .kopfzeile { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.bot .kopfzeile span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bot .details { color: var(--text-3); font-size: 13px; margin-top: 4px; }
.bot.fehler { border-color: rgba(255, 93, 108, 0.6); background: rgba(255, 93, 108, 0.12); }
.punkt { width: 10px; height: 10px; border-radius: 50%; background: var(--gruen); flex: none; box-shadow: 0 0 10px var(--gruen); }
.punkt.rot { background: var(--rot); box-shadow: 0 0 10px var(--rot); }
.werte { display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; font-size: 15px; }
.werte span:nth-child(even) { font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; }
.werte .warn { color: var(--gelb); }

/* ── Untere Leiste ── */
#leiste {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: flex; justify-content: space-around;
  padding: 8px 6px calc(8px + var(--unten));
  background: rgba(14, 19, 28, 0.78);
  border-top: 1px solid var(--rand);
  backdrop-filter: blur(22px) saturate(160%);
  -webkit-backdrop-filter: blur(22px) saturate(160%);
}
#leiste:empty { display: none; }
#leiste button {
  flex: 1; min-width: 0; min-height: 52px; padding: 4px 0; border: 0; background: none; border-radius: 12px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: var(--text-3); font-size: 11px; font-weight: 600;
}
#leiste button .sym { font-size: 21px; filter: grayscale(1); opacity: .7; transition: filter .15s, opacity .15s; }
#leiste button.aktiv { color: var(--text); background: var(--glas-2); }
#leiste button.aktiv .sym { filter: none; opacity: 1; }

/* ── Meldung ── */
#meldung {
  position: fixed; left: 16px; right: 16px; bottom: calc(84px + var(--unten)); z-index: 20;
  margin: 0 auto; max-width: 480px;
  padding: 12px 16px; border-radius: 14px;
  background: rgba(30, 38, 52, 0.95); border: 1px solid var(--rand);
  font-weight: 500; text-align: center;
  opacity: 0; transform: translateY(10px); pointer-events: none; transition: opacity .2s, transform .2s;
}
#meldung.zeigen { opacity: 1; transform: none; }
#meldung.fehler { background: rgba(120, 30, 40, 0.95); }

@media (min-width: 560px) {
  .szenen { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .bots { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
