:root {
  --bg: #f3f5f8;
  --karte: #ffffff;
  --text: #18202b;
  --text2: #5d6b7c;
  --linie: #e3e8ee;
  --akzent: #2f6fed;
  --akzent-text: #ffffff;
  --akzent-hell: #e8f0ff;
  --gefahr: #d64545;
  --gefahr-hell: #fdeceb;
  --warn: #c77a05;
  --warn-hell: #fff3dc;
  --ok: #1f9d63;
  --schatten: 0 1px 2px rgba(16, 24, 40, .06), 0 4px 14px rgba(16, 24, 40, .05);
  --radius: 18px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d1117;
    --karte: #161b22;
    --text: #e8edf3;
    --text2: #98a5b5;
    --linie: #262e38;
    --akzent: #5b93ff;
    --akzent-text: #0b1220;
    --akzent-hell: #1b2a47;
    --gefahr: #ff7a7a;
    --gefahr-hell: #3a1d1f;
    --warn: #f0b04a;
    --warn-hell: #3a2b0e;
    --ok: #4cc38a;
    --schatten: 0 1px 2px rgba(0, 0, 0, .4);
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior: none;
}
#app { height: 100%; }
h1, h2, h3, p { margin: 0; }
button { font: inherit; color: inherit; cursor: pointer; }
.zahl { font-variant-numeric: tabular-nums; }
.icon { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.versteckt { display: none !important; }

/* ---------- Schale ---------- */
.schale { display: grid; grid-template-rows: auto 1fr auto; height: 100vh; height: 100dvh; }
.seitenleiste { display: none; }
.kopfblock { background: var(--bg); }
.kopf {
  display: flex; align-items: center; gap: 8px;
  padding: calc(env(safe-area-inset-top) + 10px) 16px 8px;
  background: var(--bg);
}
.kopf h1 { flex: 1; font-size: 28px; line-height: 34px; font-weight: 700; letter-spacing: -.02em; }
.kopf.unter h1 { font-size: 20px; text-align: center; padding-right: 44px; }
.icon-btn {
  width: 44px; height: 44px; border: 0; border-radius: 22px; background: transparent;
  display: grid; place-items: center; color: var(--text);
}
.icon-btn:active { background: var(--linie); }
.haupt { overflow-y: auto; -webkit-overflow-scrolling: touch; }
.inhalt { max-width: 760px; margin: 0 auto; padding: 4px 16px 32px; display: grid; gap: 14px; }
.leiste {
  display: grid; grid-template-columns: repeat(5, 1fr);
  padding: 6px 4px calc(env(safe-area-inset-bottom) + 6px);
  background: color-mix(in srgb, var(--karte) 88%, transparent);
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  border-top: 1px solid var(--linie);
}
.leiste button, .seitenleiste .nav button {
  border: 0; background: transparent; color: var(--text2);
  display: grid; justify-items: center; gap: 2px; padding: 6px 0; font-size: 11px; font-weight: 600; min-height: 48px;
}
.leiste button.aktiv { color: var(--akzent); }
.banner { background: var(--warn-hell); color: var(--warn); padding: 8px 16px; font-size: 14px; text-align: center; font-weight: 600; }

@media (min-width: 900px) {
  .schale { grid-template-columns: 250px 1fr; grid-template-rows: auto 1fr; }
  .kopfblock { grid-column: 2; }
  .haupt { grid-column: 2; }
  .leiste { display: none; }
  .seitenleiste {
    display: flex; flex-direction: column; grid-row: 1 / 3; padding: calc(env(safe-area-inset-top) + 18px) 14px 18px;
    background: var(--karte); border-right: 1px solid var(--linie); gap: 18px;
  }
  .marke { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 18px; padding: 0 8px; }
  .marke img { width: 34px; height: 34px; border-radius: 9px; }
  .seitenleiste .nav { display: grid; gap: 4px; }
  .seitenleiste .nav button {
    grid-auto-flow: column; justify-content: start; align-items: center; gap: 12px; font-size: 16px; padding: 10px 12px;
    border-radius: 12px; min-height: 44px;
  }
  .seitenleiste .nav button.aktiv { background: var(--akzent-hell); color: var(--akzent); }
  .seitenleiste .unten { margin-top: auto; }
  .kopf { padding-top: 22px; padding-left: 28px; padding-right: 28px; }
  .inhalt { padding: 4px 28px 40px; }
  .kopf .zahnrad { display: none; }
}

/* ---------- Karten und Zeilen ---------- */
.karte { background: var(--karte); border-radius: var(--radius); box-shadow: var(--schatten); overflow: hidden; }
.karte-kopf { display: flex; align-items: baseline; gap: 8px; padding: 14px 16px 6px; }
.karte-kopf h2 { font-size: 15px; font-weight: 700; letter-spacing: .01em; flex: 1; }
.karte-kopf .zahl { color: var(--text2); font-size: 14px; }
.leer { padding: 6px 16px 16px; color: var(--text2); font-size: 15px; }
.zeile {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; min-height: 56px; padding: 10px 16px;
  border: 0; border-top: 1px solid var(--linie); background: transparent;
}
.karte-kopf + .zeile { border-top: 0; }
button.zeile:active { background: var(--akzent-hell); }
.zeile .mitte { flex: 1; min-width: 0; }
.zeile .titel { font-weight: 600; overflow-wrap: anywhere; }
.zeile .sub { color: var(--text2); font-size: 14px; overflow-wrap: anywhere; }
.zeile .rechts { color: var(--text2); font-size: 14px; text-align: right; white-space: nowrap; }
.zeile .rechts.warn { color: var(--warn); font-weight: 600; }
.zeile .rechts.rot { color: var(--gefahr); font-weight: 600; }
.punkte { display: flex; gap: 4px; flex: none; min-width: 28px; }
.punkt { width: 12px; height: 12px; border-radius: 50%; background: var(--text2); flex: none; }
.pille { width: 8px; align-self: stretch; border-radius: 4px; flex: none; }
.chip { display: inline-block; font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 99px; background: var(--akzent-hell); color: var(--akzent); }
.chip.warn { background: var(--warn-hell); color: var(--warn); }
.chip.rot { background: var(--gefahr-hell); color: var(--gefahr); }
.chip.ok { background: var(--akzent-hell); color: var(--ok); }
.hero { background: linear-gradient(135deg, #3f7df0, #1e52c4); color: #fff; border-radius: var(--radius); padding: 18px 18px 20px; display: grid; gap: 4px; }
.hero .klein { opacity: .85; font-size: 14px; font-weight: 600; }
.hero .klein.kw { margin-top: -2px; }
.hero h2 { font-size: 26px; line-height: 31px; letter-spacing: -.02em; }
.hero .personen { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.hero .person { display: inline-flex; align-items: center; gap: 6px; background: rgba(255, 255, 255, .18); border-radius: 99px; padding: 3px 10px 3px 6px; font-size: 13px; font-weight: 600; }
.hero .person i { width: 10px; height: 10px; border-radius: 50%; display: block; border: 2px solid #fff; }
.hinweis { padding: 14px 16px; background: var(--akzent-hell); border-radius: var(--radius); color: var(--text); font-size: 15px; }
.platzhalter { padding: 28px 20px; text-align: center; display: grid; gap: 8px; justify-items: center; }
.platzhalter .icon { width: 40px; height: 40px; color: var(--akzent); }
.platzhalter h2 { font-size: 20px; }
.platzhalter p { color: var(--text2); max-width: 420px; }
.gruppe-titel { font-size: 13px; font-weight: 700; color: var(--text2); text-transform: uppercase; letter-spacing: .06em; padding: 6px 6px 0; }

/* ---------- Knöpfe und Felder ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; padding: 0 18px;
  border: 0; border-radius: 14px; background: var(--akzent-hell); color: var(--akzent); font-weight: 700; font-size: 16px;
}
.btn.primaer { background: var(--akzent); color: var(--akzent-text); }
.btn.gefahr { background: var(--gefahr-hell); color: var(--gefahr); }
.btn.voll { width: 100%; }
.btn:disabled { opacity: .45; cursor: default; }
.link { border: 0; background: transparent; color: var(--akzent); font-weight: 600; padding: 12px; min-height: 44px; }
.feld { display: grid; gap: 6px; }
.feld > label, .feld > .label { font-size: 13px; font-weight: 700; color: var(--text2); }
input[type=text], input[type=password], input[type=number], select {
  width: 100%; min-height: 48px; padding: 0 14px; font: inherit; font-size: 16px; color: var(--text);
  background: var(--bg); border: 1.5px solid var(--linie); border-radius: 12px; outline: none;
}
input:focus, select:focus { border-color: var(--akzent); }
.fehler { color: var(--gefahr); font-size: 14px; font-weight: 600; min-height: 20px; }
.farben { display: flex; gap: 10px; flex-wrap: wrap; }
.farben button { width: 40px; height: 40px; border-radius: 50%; border: 3px solid transparent; padding: 0; box-shadow: inset 0 0 0 2px var(--karte); }
.farben button.gewaehlt { border-color: var(--text); }
.schalter { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 44px; }
.schalter input { width: 24px; height: 24px; accent-color: var(--akzent); }
.filter { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
code, .befehl { font: 13px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; }
.befehl { display: block; padding: 12px; background: var(--bg); border-radius: 12px; overflow-x: auto; user-select: all; -webkit-user-select: all; white-space: pre; border: 1px solid var(--linie); }

/* ---------- Sperrbildschirm und Einrichtung ---------- */
.mitte-seite { min-height: 100%; display: grid; align-content: center; justify-items: center; gap: 18px; padding: calc(env(safe-area-inset-top) + 24px) 20px calc(env(safe-area-inset-bottom) + 16px); }
.sperre { width: 100%; max-width: 320px; display: grid; justify-items: center; gap: 14px; }
.sperre img { width: 76px; height: 76px; border-radius: 20px; box-shadow: var(--schatten); }
.sperre h1 { font-size: 24px; letter-spacing: -.02em; }
.sperre .frage { color: var(--text2); }
.punkte-pin { display: flex; gap: 16px; padding: 6px 0; }
.punkte-pin .dot { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--text2); transition: background .1s; }
.punkte-pin .dot.voll { background: var(--akzent); border-color: var(--akzent); }
.punkte-pin.wackeln { animation: wackeln .35s; }
@keyframes wackeln { 20% { transform: translateX(-9px); } 40% { transform: translateX(9px); } 60% { transform: translateX(-6px); } 80% { transform: translateX(6px); } }
.tasten { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; width: 100%; }
.tasten button {
  height: 66px; border: 0; border-radius: 18px; background: var(--karte); box-shadow: var(--schatten);
  font-size: 28px; font-weight: 500; font-variant-numeric: tabular-nums;
}
.tasten button:active { background: var(--akzent-hell); }
.tasten button.klein { font-size: 15px; font-weight: 700; color: var(--text2); background: transparent; box-shadow: none; }
.tasten button.ok { background: var(--akzent); color: var(--akzent-text); font-size: 18px; font-weight: 700; }
.tasten button:disabled { opacity: .35; }
.einrichtung { width: 100%; max-width: 520px; display: grid; gap: 14px; }
.einrichtung .karte { padding: 18px; display: grid; gap: 12px; }
.einrichtung h1 { font-size: 24px; letter-spacing: -.02em; }
.einrichtung p { color: var(--text2); }
.vollseite { height: 100%; overflow-y: auto; }
.vollseite .kopf.unter { position: sticky; top: 0; z-index: 2; }

/* ---------- Blatt (Eingabe von unten) ---------- */
.blatt-hg { position: fixed; inset: 0; z-index: 50; background: rgba(8, 12, 18, .45); display: flex; align-items: flex-end; justify-content: center; opacity: 0; transition: opacity .18s; }
.blatt-hg.offen { opacity: 1; }
.blatt {
  width: 100%; max-width: 560px; max-height: 92%; overflow-y: auto; background: var(--karte); border-radius: 22px 22px 0 0;
  padding: 0 18px calc(env(safe-area-inset-bottom) + 18px); transform: translateY(40px); transition: transform .2s;
}
.blatt-hg.offen .blatt { transform: none; }
.blatt-kopf { display: flex; align-items: center; justify-content: space-between; padding: 10px 0 6px; position: sticky; top: 0; background: var(--karte); }
.blatt-kopf h2 { font-size: 20px; }
.blatt-koerper { display: grid; gap: 14px; padding-top: 6px; }
.blatt-knoepfe { display: grid; gap: 10px; }
@media (min-width: 700px) {
  .blatt-hg { align-items: center; }
  .blatt { border-radius: 22px; max-height: 86%; }
}
.hinweis-toast {
  position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 84px); transform: translateX(-50%); z-index: 80;
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 99px; font-size: 14px; font-weight: 600; max-width: 90%;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .25);
}
.plus-knopf {
  position: fixed; right: 18px; bottom: calc(env(safe-area-inset-bottom) + 76px); z-index: 10; width: 58px; height: 58px; border-radius: 29px;
  border: 0; background: var(--akzent); color: var(--akzent-text); display: grid; place-items: center; box-shadow: 0 6px 18px rgba(31, 82, 196, .4);
}
.plus-knopf .icon { width: 28px; height: 28px; stroke-width: 2.2; }
@media (min-width: 900px) { .plus-knopf { bottom: 28px; right: 32px; } }
.laedt { min-height: 100%; display: grid; place-items: center; color: var(--text2); }
.formular { padding: 18px; display: grid; gap: 12px; }
.erklaerung { color: var(--text2); }
.zeile.zeile-label { cursor: pointer; }
