:root {
  --bg: #f4f6f7;
  --flaeche: #ffffff;
  --flaeche-2: #eef1f3;
  --rand: #dfe4e8;
  --text: #16232b;
  --text-schwach: #5d6f7a;
  --primaer: #0d7a6f;
  --primaer-hell: #e2f2ef;
  --primaer-text: #ffffff;
  --warnung: #b06a00;
  --warnung-hell: #fdf1dd;
  --gefahr: #b3261e;
  --gefahr-hell: #fbe6e4;
  --info-hell: #e6eefb;
  --schatten: 0 1px 2px rgba(16, 32, 40, .07), 0 6px 20px rgba(16, 32, 40, .06);
  --radius: 16px;
  --sicher-oben: env(safe-area-inset-top, 0px);
  --sicher-unten: env(safe-area-inset-bottom, 0px);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1518;
    --flaeche: #182126;
    --flaeche-2: #212c32;
    --rand: #2c383f;
    --text: #e8eef0;
    --text-schwach: #9aacb5;
    --primaer: #3fbfae;
    --primaer-hell: #143733;
    --primaer-text: #05221f;
    --warnung: #e6a94b;
    --warnung-hell: #33280f;
    --gefahr: #f2857c;
    --gefahr-hell: #3a1b18;
    --info-hell: #182739;
    --schatten: 0 1px 2px rgba(0, 0, 0, .4), 0 6px 20px rgba(0, 0, 0, .3);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  overscroll-behavior-y: none;
}
h1, h2, h3 { line-height: 1.25; margin: 0 0 .4em; }
h1 { font-size: 1.45rem; letter-spacing: -.01em; }
h2 { font-size: 1.1rem; }
h3 { font-size: .95rem; }
a { color: var(--primaer); }
button, input, select, textarea { font: inherit; color: inherit; }

/* ------------------------------------------------------------- Anmeldeseiten */
.auth-huelle {
  min-height: 100dvh;
  display: flex; align-items: center; justify-content: center;
  padding: 24px 18px calc(24px + var(--sicher-unten));
}
.auth-karte {
  width: 100%; max-width: 400px;
  background: var(--flaeche); border: 1px solid var(--rand);
  border-radius: 22px; padding: 28px 24px; box-shadow: var(--schatten);
}
.marke { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; }
.marke svg { width: 40px; height: 40px; flex: none; }
.marke-text { font-weight: 650; font-size: 1.15rem; letter-spacing: -.01em; }
.marke-unter { font-size: .8rem; color: var(--text-schwach); font-weight: 400; }

label { display: block; font-size: .82rem; font-weight: 600; margin: 14px 0 5px; }
input[type=text], input[type=password], input[type=number], input[type=date],
input[type=search], select, textarea {
  width: 100%; padding: 12px 14px;
  background: var(--flaeche-2); border: 1px solid var(--rand);
  border-radius: 12px; outline: none;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--primaer); box-shadow: 0 0 0 3px var(--primaer-hell);
}
textarea { min-height: 80px; resize: vertical; }
.code-eingabe {
  font-size: 1.7rem; letter-spacing: .35em; text-align: center; font-variant-numeric: tabular-nums;
}

.knopf {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; padding: 13px 18px; margin-top: 18px;
  background: var(--primaer); color: var(--primaer-text);
  border: none; border-radius: 12px; font-weight: 600; cursor: pointer;
  min-height: 48px;
}
.knopf:active { transform: translateY(1px); }
.knopf[disabled] { opacity: .55; cursor: progress; }
.knopf.sekundaer { background: var(--flaeche-2); color: var(--text); border: 1px solid var(--rand); }
.knopf.gefahr { background: var(--gefahr-hell); color: var(--gefahr); border: 1px solid transparent; }
.knopf.schmal { width: auto; margin-top: 0; padding: 9px 14px; min-height: 40px; font-size: .88rem; }

.meldung { padding: 11px 14px; border-radius: 12px; font-size: .88rem; margin-bottom: 4px; }
.meldung.fehler { background: var(--gefahr-hell); color: var(--gefahr); }
.meldung.info { background: var(--info-hell); }
.meldung.ok { background: var(--primaer-hell); color: var(--primaer); }
.meldung.warnung { background: var(--warnung-hell); color: var(--warnung); }
.hinweis { font-size: .82rem; color: var(--text-schwach); margin-top: 10px; }

.qr { display: block; width: 210px; height: 210px; margin: 16px auto 8px; border-radius: 12px; }
.geheim {
  font-family: ui-monospace, monospace; font-size: .82rem; text-align: center;
  background: var(--flaeche-2); padding: 10px; border-radius: 10px; word-break: break-all;
}
.codeliste {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
  font-family: ui-monospace, monospace; margin: 16px 0;
}
.codeliste span { background: var(--flaeche-2); padding: 9px; border-radius: 9px; text-align: center; }

/* -------------------------------------------------------------------- App */
.kopf {
  position: sticky; top: 0; z-index: 20;
  padding: calc(10px + var(--sicher-oben)) 16px 10px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--rand);
}
.kopf-zeile { display: flex; align-items: center; gap: 10px; }
.kopf-zeile h1 { margin: 0; flex: 1; font-size: 1.2rem; }
.inhalt { padding: 14px 16px 120px; max-width: 720px; margin: 0 auto; }

.suchfeld { position: relative; margin-top: 10px; }
.suchfeld input { padding-left: 40px; background: var(--flaeche); }
.suchfeld svg { position: absolute; left: 13px; top: 13px; width: 18px; height: 18px; opacity: .5; }

.chips { display: flex; gap: 8px; overflow-x: auto; padding: 12px 0 2px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; padding: 7px 13px; border-radius: 999px; font-size: .83rem; font-weight: 550;
  background: var(--flaeche); border: 1px solid var(--rand); cursor: pointer; white-space: nowrap;
}
.chip[aria-pressed=true] { background: var(--primaer); color: var(--primaer-text); border-color: transparent; }
.chip .zahl { opacity: .75; margin-left: 4px; }

.kacheln { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 16px; }
.kachel {
  background: var(--flaeche); border: 1px solid var(--rand); border-radius: 14px;
  padding: 12px 10px; text-align: center; cursor: pointer;
}
.kachel .zahl { font-size: 1.4rem; font-weight: 680; display: block; }
.kachel .titel { font-size: .74rem; color: var(--text-schwach); }
.kachel.warn .zahl { color: var(--warnung); }
.kachel.gefahr .zahl { color: var(--gefahr); }

.karte {
  background: var(--flaeche); border: 1px solid var(--rand); border-radius: var(--radius);
  padding: 14px; margin-bottom: 10px; box-shadow: var(--schatten);
}
.med { display: flex; gap: 12px; align-items: flex-start; cursor: pointer; }
.med-bild {
  width: 54px; height: 54px; border-radius: 12px; object-fit: cover; flex: none;
  background: var(--flaeche-2);
}
.med-platzhalter {
  width: 54px; height: 54px; border-radius: 12px; flex: none;
  background: var(--primaer-hell); color: var(--primaer);
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 1.1rem;
}
.med-haupt { flex: 1; min-width: 0; }
.med-name { font-weight: 640; }
.med-unter { font-size: .84rem; color: var(--text-schwach); }
.med-zeile { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 7px; }
.marke-pille {
  font-size: .73rem; padding: 3px 8px; border-radius: 999px;
  background: var(--flaeche-2); color: var(--text-schwach);
}
.marke-pille.warn { background: var(--warnung-hell); color: var(--warnung); }
.marke-pille.gefahr { background: var(--gefahr-hell); color: var(--gefahr); }
.marke-pille.ok { background: var(--primaer-hell); color: var(--primaer); }

.leer { text-align: center; padding: 48px 20px; color: var(--text-schwach); }
.leer svg { width: 54px; height: 54px; opacity: .35; margin-bottom: 10px; }

/* Untere Navigation */
.navi {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: grid; grid-template-columns: repeat(4, 1fr);
  padding: 6px 8px calc(6px + var(--sicher-unten));
  background: color-mix(in srgb, var(--flaeche) 92%, transparent);
  backdrop-filter: blur(14px); border-top: 1px solid var(--rand);
}
.navi button {
  background: none; border: none; padding: 7px 2px 5px; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  font-size: .68rem; color: var(--text-schwach); font-weight: 550;
}
.navi button svg { width: 23px; height: 23px; }
.navi button[aria-current=page] { color: var(--primaer); }
.navi .abzeichen {
  position: absolute; transform: translate(13px, -4px);
  background: var(--gefahr); color: #fff; font-size: .62rem; font-weight: 700;
  border-radius: 999px; padding: 1px 5px;
}
.scan-knopf {
  position: fixed; right: 18px; bottom: calc(78px + var(--sicher-unten)); z-index: 31;
  width: 60px; height: 60px; border-radius: 50%; border: none;
  background: var(--primaer); color: var(--primaer-text);
  box-shadow: 0 8px 24px rgba(13, 122, 111, .38); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.scan-knopf svg { width: 28px; height: 28px; }

/* Blatt / Dialog */
.blatt-hg {
  position: fixed; inset: 0; z-index: 40; background: rgba(8, 16, 20, .5);
  display: flex; align-items: flex-end; justify-content: center;
  opacity: 0; pointer-events: none; transition: opacity .18s;
}
.blatt-hg.offen { opacity: 1; pointer-events: auto; }
.blatt {
  background: var(--bg); width: 100%; max-width: 720px;
  max-height: 92dvh; overflow-y: auto; border-radius: 22px 22px 0 0;
  padding: 8px 16px calc(24px + var(--sicher-unten));
  transform: translateY(14px); transition: transform .18s;
}
.blatt-hg.offen .blatt { transform: none; }
.griff { width: 40px; height: 4px; border-radius: 99px; background: var(--rand); margin: 8px auto 14px; }
.blatt-kopf { display: flex; align-items: flex-start; gap: 10px; margin-bottom: 10px; }
.blatt-kopf h2 { flex: 1; }
.schliessen {
  background: var(--flaeche-2); border: none; border-radius: 50%;
  width: 34px; height: 34px; cursor: pointer; font-size: 1.1rem; line-height: 1;
}

.feldgruppe { display: grid; gap: 2px; }
.zwei { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.datenzeile {
  display: flex; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--rand);
  font-size: .9rem;
}
.datenzeile:last-child { border-bottom: none; }
.datenzeile .b { color: var(--text-schwach); flex: none; width: 38%; }
.datenzeile .w { flex: 1; word-break: break-word; }

.mengensteuerung { display: flex; align-items: center; gap: 12px; }
.mengensteuerung button {
  width: 42px; height: 42px; border-radius: 12px; border: 1px solid var(--rand);
  background: var(--flaeche); font-size: 1.25rem; cursor: pointer;
}
.mengensteuerung .wert { font-size: 1.25rem; font-weight: 680; min-width: 34px; text-align: center; }

.schalter { display: flex; align-items: center; gap: 12px; padding: 12px 0; }
.schalter input { width: 46px; height: 28px; appearance: none; background: var(--rand);
  border-radius: 999px; position: relative; cursor: pointer; flex: none; transition: background .15s; }
.schalter input::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px;
  background: #fff; border-radius: 50%; transition: transform .15s;
}
.schalter input:checked { background: var(--primaer); }
.schalter input:checked::after { transform: translateX(18px); }
.schalter label { margin: 0; font-weight: 550; }

.toast {
  position: fixed; left: 50%; bottom: calc(96px + var(--sicher-unten)); z-index: 60;
  transform: translate(-50%, 12px); opacity: 0; pointer-events: none;
  background: var(--text); color: var(--bg); padding: 11px 18px; border-radius: 12px;
  font-size: .88rem; max-width: 88vw; text-align: center; transition: all .2s;
}
.toast.zeigen { opacity: 1; transform: translate(-50%, 0); }

.lade { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 36px 0; }
.spinner {
  width: 34px; height: 34px; border: 3px solid var(--rand); border-top-color: var(--primaer);
  border-radius: 50%; animation: dreh .8s linear infinite;
}
@keyframes dreh { to { transform: rotate(360deg); } }

.vorschau { width: 100%; max-height: 220px; object-fit: contain; border-radius: 14px;
  background: var(--flaeche-2); margin-bottom: 12px; }
.quellenband {
  display: flex; gap: 6px; flex-wrap: wrap; font-size: .74rem; color: var(--text-schwach);
  margin-bottom: 10px;
}
.abschnitt-titel {
  font-size: .76rem; text-transform: uppercase; letter-spacing: .06em;
  color: var(--text-schwach); font-weight: 650; margin: 22px 0 8px;
}
.trefferliste button {
  display: block; width: 100%; text-align: left; background: var(--flaeche);
  border: 1px solid var(--rand); border-radius: 12px; padding: 11px 13px;
  margin-bottom: 7px; cursor: pointer;
}
.klein { font-size: .82rem; color: var(--text-schwach); }
.zentriert { text-align: center; }
.verstecken { display: none !important; }
