:root {
  --rot: #c8102e;
  --rot-dunkel: #a10d25;
  --bg: #f2f2f7;
  --karte: #ffffff;
  --text: #1c1c1e;
  --muted: #6b6b72;
  --linie: #dcdce1;
  --feld: #ffffff;
  --uebung: #c8102e;
  --uebung-bg: #fde8eb;
  --fest: #b25e00;
  --fest-bg: #fff0dc;
  --allg: #2559a8;
  --allg-bg: #e3edfb;
  --schatten: 0 1px 2px rgba(0, 0, 0, .06), 0 2px 8px rgba(0, 0, 0, .05);
  --tabbar: 58px;
  --gruen: #1f8a3b;
  --gruen-bg: #e3f5e8;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --rot: #ff4d5e;
    --rot-dunkel: #e03a4b;
    --bg: #000000;
    --karte: #1c1c1e;
    --text: #f2f2f7;
    --muted: #9a9aa2;
    --linie: #38383c;
    --feld: #2c2c2e;
    --uebung: #ff6b7a;
    --uebung-bg: #3a1a1f;
    --fest: #ffb35c;
    --fest-bg: #3a2a14;
    --allg: #7fb0ff;
    --allg-bg: #172640;
    --schatten: none;
    --gruen: #4cd471;
    --gruen-bg: #143a20;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 17px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
  min-height: 100vh;
}

h1, h2 { margin: 0; line-height: 1.2; }
.muted { color: var(--muted); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4em;
  min-height: 48px; padding: 0 18px;
  border: 0; border-radius: 12px;
  font: inherit; font-weight: 600; text-decoration: none;
  cursor: pointer; touch-action: manipulation;
}
.btn:active { opacity: .75; }
.btn-block { width: 100%; }
.btn-primary { background: var(--rot); color: #fff; }
.btn-secondary { background: var(--feld); color: var(--text); border: 1px solid var(--linie); }
.btn-danger { background: transparent; color: var(--rot); border: 1px solid var(--rot); }
.btn-ghost { background: transparent; color: var(--rot); min-height: 44px; }
.btn[disabled] { opacity: .5; }

/* ---------- Anmeldung ---------- */
.login {
  min-height: 100vh; display: grid; place-items: center;
  padding: max(24px, env(safe-area-inset-top)) 16px max(24px, env(safe-area-inset-bottom));
}
.login-card { width: 100%; max-width: 380px; text-align: center; }
.login-logo { display: block; margin: 0 auto; width: auto; height: 140px; filter: drop-shadow(0 2px 6px rgba(0, 0, 0, .18)); }
.login-card h1 { margin-top: 16px; font-size: 26px; line-height: 1.15; }
.login-card form { text-align: left; margin-top: 24px; display: grid; gap: 14px; }

label { display: grid; gap: 6px; font-size: 15px; font-weight: 600; color: var(--muted); }
input, textarea {
  width: 100%; font: inherit; font-size: 17px; /* ab 16px zoomt iOS nicht hinein */
  color: var(--text); background: var(--feld);
  border: 1px solid var(--linie); border-radius: 12px; padding: 12px 14px;
  -webkit-appearance: none; appearance: none;
}
input[type="datetime-local"], input[type="date"] { min-height: 48px; }
input:focus, textarea:focus { outline: 2px solid var(--rot); outline-offset: 0; border-color: transparent; }
textarea { resize: vertical; }
.fehler { color: var(--rot); margin: 0; font-weight: 600; }

/* ---------- Kopfzeile (Banner + Seitentitel, bleibt beim Scrollen oben) ---------- */
.kopf { position: sticky; top: 0; z-index: 5; }
.banner {
  display: flex; align-items: center; gap: 10px;
  padding: calc(env(safe-area-inset-top) + 6px) max(16px, env(safe-area-inset-right)) 6px max(16px, env(safe-area-inset-left));
  background: #c8102e; color: #fff; /* feste Wappenfarbe, auch im dunklen Modus */
}
.banner img { flex: none; width: 30px; height: 36px; filter: drop-shadow(0 0 1px rgba(255, 255, 255, .8)); }
.banner span {
  min-width: 0; font-size: clamp(14px, 4.4vw, 18px); font-weight: 700; line-height: 1.15; letter-spacing: .01em;
}
.topbar {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 12px;
  padding: 8px max(16px, env(safe-area-inset-right)) 8px max(16px, env(safe-area-inset-left));
  background: color-mix(in srgb, var(--bg) 94%, transparent);
  -webkit-backdrop-filter: saturate(180%) blur(16px); backdrop-filter: saturate(180%) blur(16px);
}
.topbar h1 { font-size: 28px; font-weight: 800; }
.topbar-sub { margin: 2px 0 0; color: var(--muted); font-size: 14px; }

/* ---------- Filter ---------- */
.filter {
  display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none;
  padding: 4px max(16px, env(safe-area-inset-right)) 8px max(16px, env(safe-area-inset-left));
}
.filter::-webkit-scrollbar { display: none; }
.chip {
  flex: none; border: 1px solid var(--linie); background: var(--karte); color: var(--text);
  border-radius: 999px; padding: 8px 14px; font: inherit; font-size: 15px; font-weight: 600;
  min-height: 38px; cursor: pointer;
}
.chip.aktiv { background: var(--text); color: var(--bg); border-color: var(--text); }

.hinweis {
  margin: 4px 16px 8px; padding: 10px 12px; border-radius: 12px;
  background: var(--fest-bg); color: var(--fest); font-size: 14px; font-weight: 600;
}

/* ---------- Liste ---------- */
.liste {
  padding: 0 max(16px, env(safe-area-inset-right)) 8px max(16px, env(safe-area-inset-left));
  max-width: 760px; margin: 0 auto;
}
#vergangene { max-width: 760px; margin: 0 auto 24px; display: flex; }
.monat { margin: 18px 4px 8px; font-size: 15px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.leer { text-align: center; color: var(--muted); padding: 48px 16px; }

.termin {
  display: grid; grid-template-columns: 56px 1fr; gap: 14px; align-items: center;
  width: 100%; text-align: left; font: inherit; color: inherit;
  background: var(--karte); border: 0; border-radius: 16px; padding: 12px 14px;
  margin-bottom: 10px; box-shadow: var(--schatten); cursor: pointer;
  border-left: 5px solid var(--farbe);
}
.termin:active { transform: scale(.99); }
.termin.vorbei { opacity: .55; }
.datum { text-align: center; line-height: 1.1; }
.datum .tag { display: block; font-size: 26px; font-weight: 800; }
.datum .wtag { display: block; font-size: 13px; font-weight: 700; color: var(--farbe); text-transform: uppercase; }
.termin-titel { font-weight: 700; display: block; }
.termin-info { font-size: 15px; color: var(--muted); display: block; margin-top: 2px; }

.art-uebungsdienst { --farbe: var(--uebung); --farbe-bg: var(--uebung-bg); }
.art-fest { --farbe: var(--fest); --farbe-bg: var(--fest-bg); }
.art-allgemein { --farbe: var(--allg); --farbe-bg: var(--allg-bg); }

.badge {
  display: inline-block; padding: 4px 10px; border-radius: 999px;
  background: var(--farbe-bg); color: var(--farbe); font-size: 13px; font-weight: 700;
  justify-self: start;
}

/* ---------- Plus-Knopf ---------- */
.fab {
  position: fixed; z-index: 6;
  right: max(20px, env(safe-area-inset-right)); bottom: calc(env(safe-area-inset-bottom) + var(--tabbar) + 16px);
  width: 60px; height: 60px; border-radius: 50%; border: 0;
  background: var(--rot); color: #fff; font-size: 34px; line-height: 1;
  box-shadow: 0 6px 18px rgba(200, 16, 46, .4); cursor: pointer;
}
.fab:active { transform: scale(.94); }

/* ---------- Bottom-Sheets ---------- */
.sheet {
  border: 0; padding: 0; margin: auto 0 0; width: 100%; max-width: 100%;
  /* oben bleibt immer ein Streifen zum Danebentippen frei – auch unter der Uhrzeit-Leiste der installierten App */
  max-height: calc(100vh - env(safe-area-inset-top) - 56px);
  max-height: calc(100dvh - env(safe-area-inset-top) - 56px);
  overflow-y: auto; overscroll-behavior: contain;
  border-radius: 20px 20px 0 0;
  background: var(--karte); color: var(--text);
}
.sheet::backdrop { background: rgba(0, 0, 0, .4); }
.sheet[open] { animation: hoch .22s ease-out; }
@keyframes hoch { from { transform: translateY(60px); } to { transform: none; } }
@media (min-width: 700px) {
  .sheet { margin: auto; max-width: 560px; border-radius: 20px; max-height: calc(100dvh - 48px); }
}
.sheet-inner {
  display: grid; gap: 14px;
  padding: 0 max(20px, env(safe-area-inset-right)) calc(env(safe-area-inset-bottom) + 16px) max(20px, env(safe-area-inset-left));
}
.sheet-griff { width: 40px; height: 5px; border-radius: 3px; background: var(--linie); outline: none; }
/* Kopf mit Griff und X: bleibt beim Scrollen oben stehen */
.sheet-kopf {
  position: sticky; top: 0; z-index: 3; height: 48px; margin-bottom: -10px;
  display: flex; align-items: center; justify-content: center; background: var(--karte);
}
.sheet-x {
  position: absolute; right: -6px; top: 4px; width: 40px; height: 40px; border: 0; border-radius: 50%;
  display: grid; place-items: center; font: inherit; font-size: 17px; font-weight: 700; line-height: 1;
  background: var(--bg); color: var(--muted); cursor: pointer;
}
.sheet-x:active { transform: scale(.92); }
/* Abbrechen + Speichern: immer sichtbar am unteren Rand des Fensters */
.sheet-aktionen {
  position: sticky; bottom: 0; z-index: 3;
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px;
  padding: 10px 0 calc(env(safe-area-inset-bottom) + 12px);
  background: var(--karte); box-shadow: 0 -1px 0 var(--linie);
}
.sheet-aktionen .btn { padding-left: 8px; padding-right: 8px; }
.sheet-inner:has(.sheet-aktionen) { padding-bottom: 0; }
.sheet h2 { font-size: 24px; }
.d-zeile { margin: 0; font-size: 17px; }
.d-beschreibung { margin: 0; white-space: pre-wrap; color: var(--muted); }
.zeile-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.segment-feld { border: 0; padding: 0; margin: 0; min-width: 0; }
.segment-feld legend { font-size: 15px; font-weight: 600; color: var(--muted); padding: 0; margin-bottom: 6px; }
.segment { display: grid; grid-template-columns: repeat(3, 1fr);
  background: var(--feld); border: 1px solid var(--linie); border-radius: 12px; overflow: hidden; }
.segment label { display: block; position: relative; color: var(--text); font-size: 14px; }
.segment input { position: absolute; opacity: 0; inset: 0; }
.segment span { display: grid; place-items: center; min-height: 44px; padding: 0 4px; text-align: center; }
.segment input:checked + span { background: var(--rot); color: #fff; }
.segment input:focus-visible + span { outline: 2px solid var(--text); outline-offset: -2px; }

.schalter { display: flex; align-items: center; justify-content: space-between; color: var(--text); font-size: 17px; font-weight: 500; }
.schalter input {
  width: 51px; height: 31px; padding: 0; border-radius: 999px; border: 0;
  background: var(--linie); position: relative; cursor: pointer; flex: none; transition: background .2s;
}
.schalter input::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 27px; height: 27px; border-radius: 50%;
  background: #fff; box-shadow: 0 2px 4px rgba(0, 0, 0, .2); transition: transform .2s;
}
.schalter input:checked { background: #34c759; }
.schalter input:checked::after { transform: translateX(20px); }

.zwei-spalten { display: grid; gap: 14px; }
@media (min-width: 520px) { .zwei-spalten { grid-template-columns: 1fr 1fr; } }

/* ---------- Kalender-Abo ---------- */
.abo-leiste {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  width: calc(100% - 32px); max-width: 728px; margin: 4px auto 4px;
  min-height: 48px; padding: 10px 14px; border: 0; border-radius: 14px;
  background: var(--allg-bg); color: var(--allg);
  font: inherit; font-size: 15px; font-weight: 600; text-align: left; cursor: pointer;
}
.abo-leiste span:last-child { font-size: 22px; line-height: 1; }
.klein { margin: 0; font-size: 14px; color: var(--muted); }
.klein a { color: var(--rot); }
.klein ol, ol.klein { margin: 6px 0 0; padding-left: 20px; display: grid; gap: 4px; }
.klein summary { cursor: pointer; color: var(--rot); font-weight: 600; min-height: 32px; display: list-item; }
.abo-block { display: grid; gap: 10px; padding: 14px; border-radius: 14px; background: var(--bg); }
.abo-block h3 { margin: 0; font-size: 17px; }
#abo-adresse { font-size: 13px; font-family: ui-monospace, Menlo, monospace; }

/* =========================================================
   Schritt 2: Reiter unten, Verwaltung, Bereich, Bilder, Dokumente
   ========================================================= */
#app { padding-bottom: calc(var(--tabbar) + env(safe-area-inset-bottom) + 84px); }
.topbar-links { min-width: 0; }
.topbar h1 { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.zurueck {
  display: block; border: 0; background: none; color: var(--rot); font: inherit; font-size: 17px;
  padding: 4px 0; margin: 0 0 2px -2px; cursor: pointer; min-height: 32px;
}

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 7;
  display: flex; justify-content: space-around;
  padding: 6px max(8px, env(safe-area-inset-right)) calc(env(safe-area-inset-bottom) + 4px) max(8px, env(safe-area-inset-left));
  background: color-mix(in srgb, var(--karte) 94%, transparent);
  -webkit-backdrop-filter: saturate(180%) blur(16px); backdrop-filter: saturate(180%) blur(16px);
  border-top: 1px solid var(--linie);
}
.tab {
  flex: 1; max-width: 120px; display: flex; flex-direction: column; align-items: center; gap: 2px;
  min-height: 48px; justify-content: center;
  color: var(--muted); text-decoration: none; font-size: 11px; font-weight: 600;
}
.tab span { font-size: 22px; line-height: 1; filter: grayscale(1); opacity: .7; }
.tab.aktiv { color: var(--rot); }
.tab.aktiv span { filter: none; opacity: 1; }

.seite { padding: 4px max(16px, env(safe-area-inset-right)) 0 max(16px, env(safe-area-inset-left)); max-width: 760px; margin: 0 auto; }
.seite > div { display: grid; gap: 12px; }
.hallo { margin: 4px 0 4px; font-size: 17px; }
.hinweis-info { margin: 0; padding: 10px 12px; border-radius: 12px; background: var(--allg-bg); color: var(--allg); font-size: 14px; font-weight: 600; }

/* ---------- Meldung ---------- */
.meldung {
  position: fixed; left: 50%; transform: translateX(-50%); z-index: 20;
  bottom: calc(env(safe-area-inset-bottom) + var(--tabbar) + 16px);
  max-width: calc(100% - 32px); padding: 12px 16px; border-radius: 14px;
  background: var(--text); color: var(--bg); font-size: 15px; font-weight: 600; box-shadow: 0 6px 20px rgba(0,0,0,.25);
}
.meldung-fehler { background: var(--rot); color: #fff; }

/* ---------- Listen mit Karten ---------- */
.karten-liste { display: grid; gap: 8px; }
.person, .dokument {
  display: flex; align-items: center; gap: 12px; width: 100%;
  background: var(--karte); border: 0; border-radius: 16px; padding: 12px 14px; box-shadow: var(--schatten);
  color: var(--text); text-decoration: none; font: inherit; text-align: left; cursor: pointer; min-height: 60px;
}
.person-text { display: grid; gap: 2px; flex: 1; min-width: 0; }
.person-text b { overflow: hidden; text-overflow: ellipsis; }
.person-text small { color: var(--muted); font-size: 14px; }
.avatar {
  flex: none; width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center;
  background: var(--uebung-bg); color: var(--rot); font-weight: 800; font-size: 15px; text-transform: uppercase;
}
.avatar-kommandant { background: var(--allg-bg); color: var(--allg); }
.avatar-gross { width: 64px; height: 64px; font-size: 22px; }
.person-stand { font-size: 13px; font-weight: 700; color: var(--gruen); white-space: nowrap; }
.pfeil { color: var(--muted); font-size: 22px; flex: none; }
.badge-gesperrt { background: var(--uebung-bg); color: var(--rot); flex: none; }
.person-kopf { display: flex; gap: 14px; align-items: center; background: var(--karte); border-radius: 16px; padding: 14px; box-shadow: var(--schatten); }
.person-kopf h2 { font-size: 22px; }
.person-kopf .badge { margin-top: 6px; }
.notiz { margin: 0; padding: 12px 14px; border-radius: 14px; background: var(--fest-bg); color: var(--text); white-space: pre-wrap; font-size: 15px; }
.formular { display: grid; gap: 14px; }
select {
  width: 100%; font: inherit; font-size: 17px; color: var(--text); background: var(--feld);
  border: 1px solid var(--linie); border-radius: 12px; padding: 12px 14px; min-height: 48px;
}

/* ---------- Persönlicher Bereich ---------- */
.rubrik { background: var(--karte); border-radius: 16px; box-shadow: var(--schatten); overflow: hidden; }
.rubrik summary {
  display: flex; align-items: center; gap: 12px; padding: 14px; cursor: pointer; list-style: none; min-height: 64px;
}
.rubrik summary::-webkit-details-marker { display: none; }
.rubrik summary::after { content: "›"; color: var(--muted); font-size: 22px; transition: transform .2s; }
.rubrik[open] summary::after { transform: rotate(90deg); }
.rubrik-icon { font-size: 28px; flex: none; }
.rubrik-text { display: grid; gap: 3px; flex: 1; min-width: 0; }
.rubrik-text small { color: var(--muted); font-size: 14px; }
.balken { display: block; height: 6px; border-radius: 3px; background: var(--linie); overflow: hidden; }
.balken span { display: block; height: 100%; background: var(--gruen); border-radius: 3px; }
.rubrik-inhalt { display: grid; gap: 6px; padding: 0 10px 12px; }
.eintrag {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; font: inherit; color: var(--text);
  background: var(--bg); border: 0; border-radius: 12px; padding: 10px 12px; cursor: pointer; min-height: 52px;
}
.eintrag-text { display: grid; flex: 1; min-width: 0; }
.eintrag-text small { color: var(--muted); font-size: 13px; }
.stand {
  flex: none; display: inline-block; min-width: 92px; text-align: center;
  padding: 4px 8px; border-radius: 999px; font-size: 13px; font-weight: 700;
}
.stand-offen { background: var(--linie); color: var(--muted); }
.stand-in_arbeit { background: var(--fest-bg); color: var(--fest); }
.stand-bestanden { background: var(--gruen-bg); color: var(--gruen); }
.segment-stand { display: grid; grid-template-columns: repeat(3, 1fr); background: var(--feld); border: 1px solid var(--linie); border-radius: 12px; overflow: hidden; }
.segment-stand button { border: 0; background: none; color: var(--text); font: inherit; font-size: 14px; font-weight: 600; min-height: 44px; cursor: pointer; }
.segment-stand button.aktiv[data-stand="offen"] { background: var(--muted); color: #fff; }
.segment-stand button.aktiv[data-stand="in_arbeit"] { background: var(--fest); color: #fff; }
.segment-stand button.aktiv[data-stand="bestanden"] { background: var(--gruen); color: #fff; }

.datei-raster { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.datei-kachel { position: relative; aspect-ratio: 1; border-radius: 12px; overflow: hidden; background: var(--bg); }
.datei-kachel a { display: grid; place-items: center; width: 100%; height: 100%; color: var(--text); text-decoration: none; text-align: center; }
.datei-kachel img { width: 100%; height: 100%; object-fit: cover; }
.datei-pdf a { align-content: center; gap: 4px; padding: 6px; }
.datei-pdf span { font-size: 32px; }
.datei-pdf small { font-size: 11px; word-break: break-all; line-height: 1.2; }
.datei-weg {
  position: absolute; top: 4px; right: 4px; width: 28px; height: 28px; border-radius: 50%; border: 0;
  background: rgba(0,0,0,.6); color: #fff; font-size: 14px; cursor: pointer;
}
.datei-knopf { position: relative; overflow: hidden; }
.datei-knopf input { position: absolute; inset: 0; opacity: 0; cursor: pointer; font-size: 0; }
.fortschritt { display: grid; gap: 4px; }
.fortschritt::before { content: ""; grid-area: 1 / 1; height: 8px; border-radius: 4px; background: var(--linie); }
.fortschritt span { grid-area: 1 / 1; height: 8px; border-radius: 4px; background: var(--rot); width: 0; transition: width .2s; }
.fortschritt small { color: var(--muted); font-size: 13px; }

/* ---------- Zugangsdaten ---------- */
.zugang { display: grid; gap: 8px; background: var(--bg); border-radius: 14px; padding: 14px; }
.zugang div { display: grid; }
.zugang small { color: var(--muted); font-size: 13px; }
.zugang b { font-family: ui-monospace, Menlo, monospace; font-size: 20px; letter-spacing: .02em; user-select: all; -webkit-user-select: all; }

/* ---------- Bilder ---------- */
.alben { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.album { display: grid; gap: 2px; color: var(--text); text-decoration: none; }
.album-bild { aspect-ratio: 1; border-radius: 14px; overflow: hidden; background: var(--karte); box-shadow: var(--schatten); display: grid; place-items: center; }
.album-bild img { width: 100%; height: 100%; object-fit: cover; }
.album-leer { font-size: 40px; opacity: .5; }
.album b { margin-top: 6px; font-size: 15px; line-height: 1.25; }
.album small { color: var(--muted); font-size: 13px; }
.album-kopf { display: grid; gap: 8px; }
.album-kopf p { margin: 0; }
.raster { display: grid; grid-template-columns: repeat(3, 1fr); gap: 3px; margin: 0 -12px; }
@media (min-width: 600px) { .raster { grid-template-columns: repeat(4, 1fr); margin: 0; } }
.kachel { aspect-ratio: 1; padding: 0; border: 0; background: var(--karte); cursor: pointer; overflow: hidden; }
.kachel img { width: 100%; height: 100%; object-fit: cover; display: block; }

.lightbox {
  border: 0; padding: 0; margin: 0; width: 100vw; height: 100vh; height: 100dvh; max-width: none; max-height: none;
  background: #000; color: #fff;
}
.lightbox::backdrop { background: #000; }
.lb-leiste {
  position: absolute; top: 0; left: 0; right: 0; z-index: 2; display: flex; align-items: center; justify-content: space-between;
  padding: calc(env(safe-area-inset-top) + 6px) max(10px, env(safe-area-inset-right)) 10px max(10px, env(safe-area-inset-left));
  background: linear-gradient(rgba(0,0,0,.7), transparent);
}
.lb-leiste button { width: 48px; height: 48px; border: 0; background: none; color: #fff; font-size: 24px; cursor: pointer; }
.lb-leiste .ansicht-knopf { width: auto; font-size: 16px; background: rgba(0, 0, 0, .55); box-shadow: 0 0 0 1px rgba(255, 255, 255, .35); }

/* ---------- Dateiansicht (PDFs und Bilder in der App, mit Schließen-Knopf) ---------- */
.ansicht {
  border: 0; padding: 0; margin: 0; width: 100vw; height: 100vh; height: 100dvh; max-width: none; max-height: none;
  background: #2c2c2e; color: #fff; overflow: hidden;
}
.ansicht[open] { display: flex; flex-direction: column; }
.ansicht::backdrop { background: #000; }
.ansicht-leiste {
  flex: none; display: flex; align-items: center; gap: 8px; background: #1c1c1e;
  /* unterhalb von Kamera-Aussparung/Uhrzeit, auch im Querformat neben der Aussparung */
  padding: calc(env(safe-area-inset-top) + 6px) max(10px, env(safe-area-inset-right)) 8px max(10px, env(safe-area-inset-left));
}
.ansicht-knopf {
  flex: none; min-height: 44px; padding: 0 16px; border: 0; border-radius: 22px; cursor: pointer;
  background: rgba(255, 255, 255, .18); color: #fff; font: inherit; font-size: 16px; font-weight: 700; white-space: nowrap;
}
.ansicht-knopf:active { background: rgba(255, 255, 255, .3); }
.ansicht-titel { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: center; font-size: 15px; font-weight: 600; }
.ansicht-flaeche {
  flex: 1; min-height: 0; overflow: auto; overscroll-behavior: contain; text-align: center;
  padding: 8px 8px calc(env(safe-area-inset-bottom) + 80px);
}
.ansicht-seite { display: block; margin: 0 auto 10px; background: #fff; box-shadow: 0 2px 10px rgba(0, 0, 0, .5); }
.ansicht-bild { max-width: 100%; display: block; margin: 0 auto; }
.ansicht-bild[style*="width"] { max-width: none; }
.ansicht-info { color: #d1d1d6; padding: 32px 16px; margin: 0; }
.ansicht-zoom {
  position: absolute; right: max(14px, env(safe-area-inset-right)); bottom: calc(env(safe-area-inset-bottom) + 14px);
  display: flex; gap: 10px;
}
.ansicht-zoom button {
  width: 52px; height: 52px; border: 0; border-radius: 50%; cursor: pointer;
  background: rgba(0, 0, 0, .7); color: #fff; font-size: 28px; line-height: 1; box-shadow: 0 1px 6px rgba(0, 0, 0, .4);
}
.ansicht-zoom button:disabled { opacity: .35; }
.lb-leiste span { font-weight: 600; }
.lb-spur {
  display: flex; width: 100%; height: 100%; overflow-x: auto; overflow-y: hidden;
  scroll-snap-type: x mandatory; scrollbar-width: none; overscroll-behavior: contain;
}
.lb-spur::-webkit-scrollbar { display: none; }
.lb-bild { flex: 0 0 100%; height: 100%; margin: 0; scroll-snap-align: center; display: grid; place-items: center; position: relative; }
.lb-bild img { max-width: 100%; max-height: 100%; object-fit: contain; }
.lb-bild figcaption { position: absolute; bottom: calc(env(safe-area-inset-bottom) + 16px); left: 16px; right: 16px; text-align: center; text-shadow: 0 1px 3px #000; }
.lb-pfeil {
  position: absolute; top: 50%; transform: translateY(-50%); width: 48px; height: 64px; border: 0; border-radius: 12px;
  background: rgba(0,0,0,.35); color: #fff; font-size: 36px; cursor: pointer; display: none;
}
.lb-links { left: 8px; } .lb-rechts { right: 8px; }
@media (hover: hover) and (pointer: fine) { .lb-pfeil { display: block; } }

/* ---------- Dokumente ---------- */
.dokument { padding: 0; gap: 0; }
.dokument-link { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0; padding: 12px 14px; color: var(--text); text-decoration: none; min-height: 60px; }
.dokument-icon { font-size: 28px; flex: none; }
.dokument-mehr { flex: none; width: 52px; align-self: stretch; border: 0; border-left: 1px solid var(--linie); background: none; color: var(--muted); font-size: 22px; cursor: pointer; }

/* Unterseiten (mit Zurück-Knopf): kleinere Überschrift, damit Namen nicht abgeschnitten werden */
.zurueck:not([hidden]) + h1 { font-size: 26px; }

/* =========================================================
   Wissenstest
   ========================================================= */
.wt-jahr { display: grid; gap: 12px; background: var(--karte); border-radius: 18px; padding: 16px; box-shadow: var(--schatten); }
.wt-jahr h2 { font-size: 24px; }
.wt-thema { margin: -6px 0 0; font-size: 17px; font-weight: 600; color: var(--rot); }
.wt-archiv { padding: 0; }
.wt-archiv > summary { display: grid; gap: 2px; padding: 14px 16px; cursor: pointer; list-style: none; min-height: 56px; }
.wt-archiv > summary::-webkit-details-marker { display: none; }
.wt-archiv > summary small { color: var(--muted); }
.wt-archiv[open] { padding: 0 16px 16px; }
.wt-archiv[open] > summary { padding: 14px 0 4px; }
.wt-h { margin: 6px 0 0; font-size: 15px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.wt-h small { text-transform: none; letter-spacing: 0; font-weight: 500; }

.medaille {
  position: relative; flex: none; display: inline-grid; place-items: center;
  width: 34px; height: 34px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, color-mix(in srgb, var(--m) 55%, #fff), var(--m) 60%, color-mix(in srgb, var(--m) 70%, #000));
  box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--m) 60%, #000), 0 1px 2px rgba(0,0,0,.2);
  color: #fff; vertical-align: middle;
}
.medaille b { position: relative; font-size: 12px; font-weight: 800; text-shadow: 0 1px 1px rgba(0,0,0,.45); }
.medaille i { position: absolute; inset: 9px; border-radius: 50%; }
.medaille-gross { width: 72px; height: 72px; }
.medaille-gross b { font-size: 24px; }
.medaille-gross i { inset: 18px; }

.wt-stufen { display: flex; flex-wrap: wrap; gap: 10px 14px; }
.wt-stufe { display: grid; justify-items: center; gap: 2px; min-width: 48px; }
.wt-stufe small { font-size: 11px; color: var(--muted); font-weight: 600; }
.wt-mehr summary { cursor: pointer; color: var(--rot); font-weight: 600; min-height: 32px; }
.wt-mehr p { margin: 6px 0 0; color: var(--muted); font-size: 15px; }
.wt-links { display: grid; gap: 6px; }
.wt-links a {
  display: flex; gap: 10px; align-items: center; padding: 10px 12px; border-radius: 12px;
  background: var(--allg-bg); color: var(--allg); text-decoration: none; font-size: 15px; font-weight: 600; min-height: 44px;
}
.wt-eigene { margin: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 10px 12px; border-radius: 12px; background: var(--bg); }
.wt-quiz { display: grid; gap: 8px; }
.wt-quiz-knopf {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 14px; min-height: 58px;
  background: var(--bg); color: var(--text); text-decoration: none; border: 2px solid transparent;
}
.wt-quiz-knopf span:nth-child(2) { display: grid; flex: 1; }
.wt-quiz-knopf small { color: var(--muted); font-size: 13px; }
.wt-quiz-knopf.meins { border-color: var(--rot); }
.wt-quiz-knopf.leer { opacity: .5; }
.wt-quellen { margin-top: 4px; }

.wt-tabelle { display: grid; gap: 8px; }
.wt-zeile { display: grid; gap: 6px; padding: 12px; border-radius: 14px; background: var(--bg); border-left: 4px solid var(--linie); }
.wt-zeile.ok { border-left-color: var(--gruen); }
.wt-felder { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.wt-felder label { gap: 2px; }
.wt-felder small { font-size: 12px; }
.wt-felder select { min-height: 42px; padding: 8px 10px; font-size: 15px; }
.wt-uebung { color: var(--muted); font-size: 13px; }
.wt-ergebnis { font-weight: 700; font-size: 15px; }
.wt-bestanden { color: var(--gruen); }
.wt-nicht_bestanden { color: var(--rot); }

/* ---------- Quiz ---------- */
.quiz { display: grid; gap: 14px; }
.quiz-kopf { display: flex; align-items: center; gap: 10px; font-weight: 600; color: var(--muted); }
.quiz-punkte { margin-left: auto; color: var(--gruen); font-weight: 800; }
.quiz-frage { font-size: 21px; line-height: 1.3; }
.quiz-antworten { display: grid; gap: 10px; }
.quiz-antwort {
  width: 100%; text-align: left; font: inherit; font-size: 17px; color: var(--text);
  background: var(--karte); border: 2px solid var(--linie); border-radius: 14px; padding: 14px 16px; min-height: 56px;
  cursor: pointer; box-shadow: var(--schatten); touch-action: manipulation;
}
.quiz-antwort.gewaehlt { border-color: var(--allg); background: var(--allg-bg); }
.quiz-antwort.richtig { border-color: var(--gruen); background: var(--gruen-bg); color: var(--text); }
.quiz-antwort.richtig::before { content: "✓ "; color: var(--gruen); font-weight: 800; }
.quiz-antwort.falsch { border-color: var(--rot); background: var(--uebung-bg); }
.quiz-antwort.falsch::before { content: "✗ "; color: var(--rot); font-weight: 800; }
.quiz-antwort.neutral { opacity: .55; }
.quiz-antwort:disabled { cursor: default; }
.quiz-rueckmeldung { display: grid; gap: 6px; padding: 14px; border-radius: 14px; }
.quiz-rueckmeldung.ok { background: var(--gruen-bg); color: var(--text); }
.quiz-rueckmeldung.nein { background: var(--uebung-bg); color: var(--text); }
.quiz-rueckmeldung b { font-size: 18px; }
.quiz-rueckmeldung.ok b { color: var(--gruen); }
.quiz-rueckmeldung.nein b { color: var(--rot); }
.quiz-rueckmeldung p { margin: 0; }
.quiz-rueckmeldung a { color: var(--allg); font-weight: 600; }
.quiz-ende { justify-items: center; text-align: center; padding-top: 16px; }
.quiz-ende h2 { font-size: 26px; }
.quiz-prozent { margin: -8px 0 0; font-size: 44px; font-weight: 800; color: var(--rot); }
.avatar-betreuer { background: var(--gruen-bg); color: var(--gruen); }

/* =========================================================
   Stammdaten, Notfallkontakte, Ausbildung, Gesamtübersicht
   ========================================================= */
.karte { display: grid; gap: 10px; background: var(--karte); border-radius: 16px; padding: 14px; box-shadow: var(--schatten); }
.karte-kopf { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 32px; }
.karte-kopf h3 { margin: 0; font-size: 17px; }
.karte-kopf .btn { min-height: 36px; padding: 0 8px; }
.daten { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin: 0; font-size: 16px; }
.daten dt { color: var(--muted); font-size: 14px; padding-top: 2px; }
.daten dd { margin: 0; overflow-wrap: anywhere; }
.daten small { color: var(--muted); }
.tel { color: var(--allg); font-weight: 600; text-decoration: none; }
.notfall { display: grid; grid-template-columns: 1fr auto auto; align-items: center; gap: 8px; padding: 10px 0; border-top: 1px solid var(--linie); }
.notfall:first-of-type { border-top: 0; }
.notfall div { display: grid; min-width: 0; }
.notfall small { color: var(--muted); font-size: 14px; }
.tel-knopf { min-height: 44px; padding: 0 12px; background: var(--gruen); font-size: 15px; white-space: nowrap; }
.notfall .dokument-mehr { width: 44px; min-height: 44px; border-left: 0; }
.plz-ort { display: grid; grid-template-columns: 7.5em 1fr; gap: 10px; }
.meine-daten { display: grid; gap: 10px; }
.meine-daten > summary { cursor: pointer; font-weight: 700; padding: 12px 14px; background: var(--karte); border-radius: 14px; box-shadow: var(--schatten); min-height: 48px; }
.meine-daten[open] > summary { margin-bottom: 10px; }

.ab-stufen { display: grid; grid-template-columns: repeat(6, 1fr); gap: 4px; }
.ab-stufe { display: grid; justify-items: center; gap: 2px; text-align: center; }
.ab-stufe small { font-size: 10px; color: var(--muted); font-weight: 600; line-height: 1.1; }
.ab-stufe b { font-size: 12px; color: var(--muted); }
.ab-stufe.ok b { color: var(--gruen); }
.medaille-aus { filter: grayscale(1); opacity: .35; }
.ab-zeilen p { margin: 0; padding: 6px 0; display: flex; gap: 8px; align-items: baseline; color: var(--muted); }
.ab-zeilen p.ok { color: var(--text); }
.ab-zeilen span { font-weight: 800; width: 1.2em; color: var(--rot); }
.ab-zeilen p.ok span { color: var(--gruen); }
.ab-zeilen small { color: var(--muted); }
.ab-eingabe { display: grid; grid-template-columns: 1fr 9em; gap: 8px; align-items: center; }
.ab-haken { display: flex; align-items: center; gap: 8px; color: var(--text); font-weight: 600; font-size: 15px; }
.ab-haken input { width: 24px; height: 24px; flex: none; -webkit-appearance: auto; appearance: auto; accent-color: var(--gruen); }
.ab-eingabe input[type="number"], .ab-eingabe input[type="date"] { min-height: 44px; padding: 8px 10px; font-size: 16px; }

.ue-steuerung { display: grid; gap: 8px; }
.ue-steuerung select, .ue-steuerung input { min-height: 44px; }
.ue-filter { padding: 0 0 4px; margin: 0 -16px; padding-left: 16px; }
.ue-karte { display: grid; gap: 8px; padding: 12px 14px; border-radius: 16px; background: var(--karte); box-shadow: var(--schatten); color: var(--text); text-decoration: none; }
.ue-kopf { display: grid; }
.ue-kopf small { color: var(--muted); font-size: 13px; }
.ue-stand { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.ue-wt { display: flex; align-items: center; gap: 8px; flex: 1 1 200px; }
.ue-wt > span:last-child { display: grid; line-height: 1.25; }
.ue-wt small { color: var(--muted); font-size: 12px; }
.ue-haken { padding: 4px 10px; border-radius: 999px; font-size: 13px; font-weight: 700; background: var(--uebung-bg); color: var(--rot); }
.ue-haken.ok { background: var(--gruen-bg); color: var(--gruen); }

/* ---------- Datenschutz ---------- */
.fusszeile { text-align: center; margin: 24px 0 0; font-size: 14px; }
.fusszeile a { color: var(--muted); }
#login-datenschutz { margin-top: 16px; font-size: 15px; }
.ds-text h3 { margin: 16px 0 4px; font-size: 16px; }
.ds-text p, .ds-text li { font-size: 15px; line-height: 1.45; }
.ds-text ul { padding-left: 20px; margin: 4px 0; }
.ds-dialog .sheet-inner { padding-top: 20px; }
.pr-eintrag { display: grid; gap: 4px; padding: 10px 12px; border-radius: 12px; background: var(--karte); box-shadow: var(--schatten); border-left: 4px solid var(--linie); }
.pr-angelegt { border-left-color: var(--gruen); }
.pr-geloescht, .pr-anmeldung { border-left-color: var(--rot); }
.pr-konto { border-left-color: var(--allg); }
.pr-kopf { display: flex; justify-content: space-between; gap: 8px; }
.pr-kopf small, .pr-eintrag > small { color: var(--muted); font-size: 13px; }
.pr-eintrag ul { margin: 2px 0 0; padding-left: 18px; font-size: 14px; }
.pr-eintrag s { color: var(--muted); }
