:root {
  --bg: #12160f;
  --flaeche: #1b2117;
  --flaeche2: #232b1e;
  --rand: #333d2b;
  --text: #e6ecdd;
  --leise: #9aa78d;
  --gruen: #6f9c57;
  --gruen-dunkel: #2f4f2a;
  --alarm: #e0553f;
  --warn: #dd9a33;
  --info: #6c8fb0;
  --radius: 14px;
}
@media (prefers-color-scheme: light) {
  :root {
    --bg: #f4f6f0;
    --flaeche: #ffffff;
    --flaeche2: #eef1e8;
    --rand: #d7ddcc;
    --text: #1d2318;
    --leise: #64705a;
    --gruen: #40702f;
    --gruen-dunkel: #2f4f2a;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding-bottom: calc(66px + env(safe-area-inset-bottom));
  -webkit-text-size-adjust: 100%;
}
.versteckt { display: none !important; }
.leise { color: var(--leise); }
.klein { font-size: 13px; }
.fehler { color: var(--alarm); min-height: 1.2em; margin: 6px 0 0; font-size: 14px; }

/* --- Kopf --- */
.kopf {
  position: sticky; top: 0; z-index: 50;
  background: var(--gruen-dunkel);
  color: #eef3e6;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  box-shadow: 0 1px 0 rgba(0,0,0,.25);
}
.kopfzeile { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.kopf .leise { color: #c2d3b4; }
.hinweis {
  margin-top: 10px; padding: 8px 10px; border-radius: 10px;
  background: rgba(255,255,255,.12); display: flex; gap: 10px;
  align-items: center; justify-content: space-between; font-size: 14px;
}

/* --- Inhalt --- */
.inhalt { padding: 14px 16px 24px; max-width: 900px; margin: 0 auto; }
h2 { font-size: 19px; margin: 4px 0 12px; }
h3 { font-size: 16px; margin: 20px 0 8px; }

.karte {
  background: var(--flaeche); border: 1px solid var(--rand);
  border-radius: var(--radius); padding: 14px; margin-bottom: 12px;
}

/* --- Filter --- */
.filter { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 6px; margin-bottom: 12px; }
.filter button {
  flex: 0 0 auto; border: 1px solid var(--rand); background: var(--flaeche);
  color: var(--text); border-radius: 999px; padding: 7px 14px; font-size: 14px; cursor: pointer;
}
.filter button[aria-pressed="true"] { background: var(--gruen); border-color: var(--gruen); color: #fff; }

/* --- Meldungen --- */
.meldung {
  display: grid; grid-template-columns: 6px 1fr auto; gap: 12px;
  background: var(--flaeche); border: 1px solid var(--rand);
  border-radius: var(--radius); padding: 0; margin-bottom: 10px; overflow: hidden;
}
.meldung .balken { background: var(--info); }
.meldung.alarm .balken { background: var(--alarm); }
.meldung.warnung .balken { background: var(--warn); }
.meldung .mitte { padding: 12px 0; min-width: 0; }
.meldung .rechts { padding: 12px 12px 12px 0; display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.meldung .titel { font-weight: 600; }
.meldung .geraet { font-size: 14px; color: var(--leise); }
.meldung .text { font-size: 14px; color: var(--leise); margin-top: 4px; white-space: pre-wrap;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.meldung .zeit { font-size: 13px; color: var(--leise); white-space: nowrap; }
.meldung .vorschau { width: 62px; height: 62px; object-fit: cover; border-radius: 10px; cursor: pointer; }
.meldung.ungelesen { border-color: var(--gruen); }

.marke {
  display: inline-block; font-size: 12px; padding: 2px 8px; border-radius: 999px;
  background: var(--flaeche2); color: var(--leise); border: 1px solid var(--rand);
}

/* --- Geräte --- */
.geraet-zeile {
  display: flex; gap: 12px; align-items: center; padding: 12px 0;
  border-bottom: 1px solid var(--rand);
}
.geraet-zeile:last-child { border-bottom: 0; }
.punkt { width: 11px; height: 11px; border-radius: 50%; flex: 0 0 auto; background: var(--gruen); }
.punkt.still { background: var(--alarm); }
.punkt.batterie { background: var(--warn); }
.punkt.neu, .punkt.aus { background: var(--leise); }
.balkenleiste { height: 6px; background: var(--flaeche2); border-radius: 3px; overflow: hidden; width: 60px; }
.balkenleiste i { display: block; height: 100%; background: var(--gruen); }
.balkenleiste.wenig i { background: var(--warn); }

/* --- Karte --- */
#karteBox { height: min(62vh, 520px); border-radius: var(--radius); overflow: hidden; border: 1px solid var(--rand); }
.leaflet-container { background: var(--flaeche2); font: inherit; }

/* --- Galerie --- */
.galerie { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 8px; }
.galerie figure { margin: 0; position: relative; }
.galerie img { width: 100%; aspect-ratio: 4/3; object-fit: cover; border-radius: 10px; display: block; cursor: pointer; }
.galerie figcaption { font-size: 12px; color: var(--leise); margin-top: 3px; }

/* --- Knöpfe und Felder --- */
.knopf {
  border: 1px solid var(--rand); background: var(--flaeche2); color: var(--text);
  border-radius: 10px; padding: 9px 14px; font-size: 15px; cursor: pointer;
}
.knopf.haupt { background: var(--gruen); border-color: var(--gruen); color: #fff; font-weight: 600; }
.knopf.klein { padding: 5px 11px; font-size: 13px; }
.knopf:active { transform: translateY(1px); }
.knopfreihe { display: flex; gap: 8px; flex-wrap: wrap; }

input, select, textarea {
  width: 100%; background: var(--flaeche2); color: var(--text);
  border: 1px solid var(--rand); border-radius: 10px; padding: 9px 11px; font: inherit;
}
label { display: block; font-size: 14px; color: var(--leise); margin-bottom: 10px; }
label input, label select, label textarea { margin-top: 4px; color: var(--text); }

/* --- Anmeldung --- */
.anmeldung { min-height: 100dvh; display: grid; place-items: center; padding: 20px; }
.anmeldebox { width: 100%; max-width: 360px; text-align: center; }
.anmeldebox h1 { font-size: 22px; margin: 10px 0 2px; }
.anmeldebox label { text-align: left; margin-top: 14px; }
.anmeldebox .knopf { width: 100%; margin-top: 16px; }

/* --- Tableiste --- */
.leiste {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 60;
  display: grid; grid-template-columns: repeat(5, 1fr);
  background: var(--flaeche); border-top: 1px solid var(--rand);
  padding-bottom: env(safe-area-inset-bottom);
}
.leiste a {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 9px 0 7px; font-size: 11px; color: var(--leise); text-decoration: none;
}
.leiste a span { font-size: 19px; line-height: 1; }
.leiste a.aktiv { color: var(--gruen); }

/* --- Bildlupe --- */
.lupe {
  position: fixed; inset: 0; z-index: 100; background: rgba(0,0,0,.92);
  display: grid; place-items: center; padding: 16px;
}
.lupe img { max-width: 100%; max-height: 100%; border-radius: 8px; }

.zaehler { display: flex; gap: 10px; margin-bottom: 12px; }
.zaehler div {
  flex: 1; background: var(--flaeche); border: 1px solid var(--rand);
  border-radius: var(--radius); padding: 10px; text-align: center;
}
.zaehler b { display: block; font-size: 22px; }
.zaehler span { font-size: 12px; color: var(--leise); }

pre.roh {
  background: var(--flaeche2); border: 1px solid var(--rand); border-radius: 10px;
  padding: 10px; font-size: 12px; overflow-x: auto; white-space: pre-wrap; max-height: 180px;
}
