:root {
  --bg: #1B1F3B;
  --bg-2: #252A4D;
  --flaeche: #2E3460;
  --flaeche-hoch: #3A4175;
  --linie: rgba(255, 255, 255, 0.12);
  --text: #F4F5FB;
  --text-2: #B9BDDA;
  --akzent: #F5B84A;
  --auf-hell: #1B1F3B;
  --gefahr: #F87171;
  --gut: #4ADE80;
  --r-s: 10px;
  --r-m: 18px;
  --r-l: 28px;
  --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px; --sp-5: 24px; --sp-6: 36px;
  --tap: 48px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background: radial-gradient(1200px 600px at 50% -200px, #343B78 0%, var(--bg) 60%);
  background-color: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.4;
  -webkit-tap-highlight-color: transparent;
}
main {
  max-width: 720px;
  margin: 0 auto;
  padding: max(var(--sp-5), env(safe-area-inset-top)) var(--sp-4) calc(var(--sp-6) + env(safe-area-inset-bottom));
}
h1 { font-size: 28px; margin: 0 0 var(--sp-2); font-weight: 800; letter-spacing: -0.02em; }
h2 { font-size: 18px; margin: var(--sp-5) 0 var(--sp-3); font-weight: 700; }
p { margin: 0 0 var(--sp-3); color: var(--text-2); }
.mitte { text-align: center; }
.klein { font-size: 13px; color: var(--text-2); }

button { font: inherit; color: inherit; cursor: pointer; }
.knopf {
  min-height: var(--tap); padding: 0 var(--sp-5); border-radius: 999px; border: 1px solid var(--linie);
  background: var(--flaeche); font-weight: 600;
}
.knopf:active { transform: scale(0.97); }
.knopf.haupt { background: var(--akzent); color: var(--auf-hell); border-color: transparent; }
.knopf.gefahr { color: var(--gefahr); }
.knopf.klein-k { min-height: 36px; padding: 0 var(--sp-4); font-size: 14px; }
.knopf:disabled { opacity: 0.5; cursor: default; }
.zeile { display: flex; gap: var(--sp-2); flex-wrap: wrap; align-items: center; }

/* Kopf */
.kopf { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--sp-5); }
.kopf .gruss { font-size: 15px; color: var(--text-2); }
.kopf h1 { margin: 0; }

/* Profile */
.profile { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: var(--sp-4); margin-top: var(--sp-5); }
.profil {
  display: flex; flex-direction: column; align-items: center; gap: var(--sp-2);
  background: none; border: 0; padding: var(--sp-3); border-radius: var(--r-m);
}
.profil:active .avatar { transform: scale(0.94); }
.avatar {
  width: 88px; height: 88px; border-radius: 50%; display: grid; place-items: center;
  font-size: 38px; font-weight: 800; color: var(--auf-hell); transition: transform .15s;
  box-shadow: 0 6px 0 rgba(0, 0, 0, 0.25);
}
.avatar.klein-a { width: 44px; height: 44px; font-size: 19px; box-shadow: none; }
.avatar img { width: 80%; height: 80%; display: block; object-fit: contain; }
.avatar { overflow: hidden; }
.avatar-raster { display: grid; grid-template-columns: repeat(auto-fill, minmax(60px, 1fr)); gap: var(--sp-1); margin: var(--sp-2) 0 var(--sp-4); max-height: 52vh; overflow-y: auto; }
.avatar-wahl { background: none; border: 3px solid transparent; border-radius: 50%; padding: 3px; aspect-ratio: 1; display: grid; place-items: center; }
.avatar-wahl.an { border-color: var(--text); }
.avatar-wahl .avatar { width: 100%; height: 100%; font-size: 24px; box-shadow: none; }
.avatar-knopf { background: none; border: 0; padding: 0; border-radius: 50%; }
.profil-name { font-weight: 700; font-size: 16px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.profil-name.gross { font-size: 20px; }
.geraete-zeile { margin-top: var(--sp-6); text-align: center; }

/* PIN */
.pin-kopf { display: flex; flex-direction: column; align-items: center; gap: var(--sp-3); margin-top: var(--sp-4); }
.punkte { display: flex; gap: var(--sp-3); justify-content: center; margin: var(--sp-4) 0; }
.punkt { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--text-2); }
.punkt.voll { background: var(--akzent); border-color: var(--akzent); }
.punkte.wackeln { animation: wackeln .35s; }
@keyframes wackeln { 25% { transform: translateX(-8px); } 75% { transform: translateX(8px); } }
.tasten { display: grid; grid-template-columns: repeat(3, 76px); gap: var(--sp-3); justify-content: center; }
.taste {
  height: 76px; border-radius: 50%; border: 0; background: var(--flaeche);
  font-size: 28px; font-weight: 600; box-shadow: 0 4px 0 rgba(0, 0, 0, 0.25);
}
.taste:active { transform: translateY(2px); box-shadow: 0 2px 0 rgba(0, 0, 0, 0.25); }
.taste.leer { visibility: hidden; }
.taste.weg { background: transparent; box-shadow: none; font-size: 20px; }
.meldung { min-height: 22px; text-align: center; color: var(--gefahr); font-size: 14px; }

/* Kacheln */
.kacheln { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: var(--sp-4); }
.kachel {
  display: flex; flex-direction: column; align-items: flex-start; justify-content: space-between; gap: var(--sp-5);
  min-height: 150px; padding: var(--sp-4); border-radius: var(--r-l); text-decoration: none;
  color: var(--auf-hell); font-weight: 800; font-size: 18px;
  box-shadow: 0 6px 0 rgba(0, 0, 0, 0.25); transition: transform .15s;
}
.kachel:active { transform: translateY(3px); box-shadow: 0 3px 0 rgba(0, 0, 0, 0.25); }
.kachel .zeichen { width: 56px; height: 56px; border-radius: 16px; background: rgba(27, 31, 59, 0.14); display: grid; place-items: center; }
.leer-hinweis { padding: var(--sp-6) var(--sp-4); text-align: center; color: var(--text-2); border: 1px dashed var(--linie); border-radius: var(--r-l); }

/* Blatt (Menü, Formulare) */
.huelle { position: fixed; inset: 0; background: rgba(8, 10, 28, 0.6); display: flex; align-items: flex-end; justify-content: center; z-index: 10; }
.blatt {
  width: 100%; max-width: 560px; max-height: 90vh; overflow: auto; background: var(--bg-2);
  border-radius: var(--r-l) var(--r-l) 0 0; padding: var(--sp-5) var(--sp-4) calc(var(--sp-5) + env(safe-area-inset-bottom));
}
.blatt h2 { margin-top: 0; }
.menue { display: flex; flex-direction: column; gap: var(--sp-2); }
.menue button { text-align: left; min-height: var(--tap); padding: 0 var(--sp-4); border-radius: var(--r-s); border: 0; background: var(--flaeche); font-weight: 600; }
.menue button.gefahr { color: var(--gefahr); }

/* Verwaltung */
.reiter { display: flex; gap: var(--sp-2); margin-bottom: var(--sp-4); }
.reiter button { flex: 1; min-height: 42px; border-radius: 999px; border: 1px solid var(--linie); background: none; font-weight: 600; }
.reiter button.aktiv { background: var(--text); color: var(--auf-hell); border-color: transparent; }
.karte { background: var(--flaeche); border-radius: var(--r-m); padding: var(--sp-4); margin-bottom: var(--sp-3); }
.karte-kopf { display: flex; align-items: center; gap: var(--sp-3); margin-bottom: var(--sp-3); }
.karte-kopf .titel { font-weight: 700; }
.karte-kopf .rest { flex: 1; min-width: 0; }
.marke { display: inline-block; font-size: 12px; padding: 2px 8px; border-radius: 999px; background: var(--flaeche-hoch); color: var(--text-2); }
.marke.warn { background: rgba(248, 113, 113, 0.2); color: var(--gefahr); }
.chips { display: flex; flex-wrap: wrap; gap: var(--sp-2); margin-bottom: var(--sp-3); }
.chip { min-height: 36px; padding: 0 var(--sp-3); border-radius: 999px; border: 1px solid var(--linie); background: none; font-size: 14px; }
.chip.an { background: var(--akzent); color: var(--auf-hell); border-color: transparent; font-weight: 600; }

label.feld { display: block; margin-bottom: var(--sp-3); font-size: 13px; color: var(--text-2); }
label.feld input, label.feld select {
  display: block; width: 100%; margin-top: var(--sp-1); min-height: var(--tap); padding: 0 var(--sp-3);
  border-radius: var(--r-s); border: 1px solid var(--linie); background: var(--bg); color: var(--text); font: inherit;
}
.farben { display: flex; gap: var(--sp-2); flex-wrap: wrap; margin: var(--sp-1) 0 var(--sp-3); }
.farbe { width: 36px; height: 36px; border-radius: 50%; border: 3px solid transparent; }
.farbe.an { border-color: var(--text); }

#toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%) translateY(120px);
  background: var(--text); color: var(--auf-hell); padding: 10px 18px; border-radius: 999px; font-weight: 600;
  transition: transform .25s; z-index: 20; max-width: 90vw;
}
#toast.sichtbar { transform: translateX(-50%) translateY(0); }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* Android-Apps zum Installieren (unter den Kacheln, nur auf Android) */
.android-apps { margin-top: var(--sp-6); display: flex; flex-direction: column; gap: var(--sp-2); }
.android-apps .abschnitt { margin: 0 0 var(--sp-1); font-size: 13px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-2); }
.apk-zeile { display: flex; align-items: center; gap: var(--sp-3); min-height: var(--tap); padding: var(--sp-3); border-radius: var(--r-m); background: var(--flaeche); border: 1px solid var(--linie); color: var(--text); text-decoration: none; }
.apk-zeile .zeichen { width: 40px; height: 40px; border-radius: var(--r-s); display: grid; place-items: center; flex-shrink: 0; color: var(--auf-hell); }
.apk-text { display: flex; flex-direction: column; gap: 2px; }

/* KI-Guthaben (nur Eltern, unter den Kacheln) */
.guthaben { margin-top: var(--sp-6); display: flex; flex-direction: column; gap: var(--sp-2); }
.guthaben-kopf { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--sp-1); }
.guthaben .abschnitt { margin: 0; font-size: 13px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-2); }
.guthaben-zeile { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); padding: var(--sp-3) var(--sp-4); border-radius: var(--r-m); background: var(--flaeche); border: 1px solid var(--linie); }
.guthaben-zeile .betrag { font-size: 22px; font-weight: 800; white-space: nowrap; color: var(--gut); }
.guthaben-zeile.knapp .betrag { color: var(--gefahr); }
.guthaben .fehler { color: var(--gefahr); }
.guthaben-zeile .apk-text { flex: 1; min-width: 0; }
.guthaben .budget { display: flex; flex-direction: column; gap: 4px; margin-top: var(--sp-2); }
.guthaben .balken { display: block; height: 6px; border-radius: 999px; background: var(--flaeche-hoch); overflow: hidden; }
.guthaben .balken span { display: block; height: 100%; background: var(--gut); border-radius: 999px; }
.guthaben .budget.knapp .balken span { background: var(--gefahr); }
.guthaben-knoepfe { margin-top: var(--sp-2); }
.guthaben-knoepfe a.knopf { display: inline-flex; align-items: center; text-decoration: none; color: var(--text); }
.notfall { margin-top: 18px; }
/* Anfrage läuft: Knopf gedimmt, bis die Antwort da ist */
button.laeuft { opacity: .55; cursor: progress; }
.laden { text-align: center; opacity: .7; margin-top: 40vh; }
/* Anmeldeversuche in Verwaltung → Geräte */
.versuche { margin-top: var(--sp-6); }
.versuche .abschnitt { margin: 0 0 var(--sp-1); font-size: 13px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-2); }
.versuch { padding: var(--sp-2) 0; border-bottom: 1px solid var(--linie); }
.versuch .titel { font-weight: 600; }
.versuch.fehlgeschlagen .titel { color: #F87171; }
.abmelden-knoepfe { justify-content: center; gap: var(--sp-3); margin-top: var(--sp-4); }
