:root {
  --bg: #f4f6f8;
  --flaeche: #ffffff;
  --text: #1c2630;
  --text-leise: #5b6875;
  --rand: #d6dde3;
  --akzent: #1f5f8b;
  --akzent-text: #ffffff;
  --akzent-hell: #e3eef6;
  --ok: #2e7d4f;
  --warn: #a8670b;
  --fehler: #b3261e;
  --radius: 10px;
  --tipp: 44px; /* Mindesthöhe für Touch-Ziele */
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12171c;
    --flaeche: #1b2229;
    --text: #e6ebef;
    --text-leise: #9aa7b3;
    --rand: #2e3842;
    --akzent: #5ea4d4;
    --akzent-text: #0d1a24;
    --akzent-hell: #1d3445;
    --ok: #6cc394;
    --warn: #e0a54a;
    --fehler: #f08a82;
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", sans-serif;
  padding-bottom: env(safe-area-inset-bottom);
}

a { color: var(--akzent); }

/* Kopfzeile */
.kopf {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  padding: calc(8px + env(safe-area-inset-top)) 16px 8px;
  background: var(--flaeche);
  border-bottom: 1px solid var(--rand);
}
.marke {
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--text);
  text-decoration: none;
}
.hauptnav { display: flex; gap: 4px; flex-wrap: wrap; }
.hauptnav a {
  display: inline-flex;
  align-items: center;
  min-height: var(--tipp);
  padding: 0 14px;
  border-radius: var(--radius);
  color: var(--text);
  text-decoration: none;
}
.hauptnav a[aria-current="page"] { background: var(--akzent-hell); color: var(--akzent); font-weight: 600; }

main { max-width: 960px; margin: 0 auto; padding: 16px; outline: none; }

h1 { font-size: 1.5rem; margin: 8px 0 16px; }
h2 { font-size: 1.15rem; margin: 0 0 12px; }

.karte {
  background: var(--flaeche);
  border: 1px solid var(--rand);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
}
.leise { color: var(--text-leise); }
.klein { font-size: 0.875rem; }

/* Knöpfe */
.knopf {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: var(--tipp);
  padding: 0 16px;
  border: 1px solid var(--akzent);
  border-radius: var(--radius);
  background: var(--akzent);
  color: var(--akzent-text);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  touch-action: manipulation;
}
.knopf:disabled { opacity: 0.5; cursor: not-allowed; }
.knopf-zweit { background: transparent; color: var(--akzent); }
.knopf-hell { background: var(--flaeche); color: var(--akzent); border-color: var(--flaeche); }
.knopf-gefahr { background: transparent; color: var(--fehler); border-color: var(--fehler); }
.knopfreihe { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }

/* Ordner-Zeilen */
.zeile {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 12px 0;
  border-top: 1px solid var(--rand);
}
.zeile:first-of-type { border-top: 0; }
.zeile-text { flex: 1 1 240px; min-width: 0; }
.zeile-text strong { display: block; }

.status { font-size: 0.875rem; font-weight: 600; }
.status-ok { color: var(--ok); }
.status-warn { color: var(--warn); }
.status-fehler { color: var(--fehler); }

.hinweis {
  border-left: 4px solid var(--warn);
  background: var(--flaeche);
  padding: 12px 16px;
  border-radius: 0 var(--radius) var(--radius) 0;
  margin-bottom: 16px;
}

/* Zählerkacheln */
.zaehler {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
}
.zaehler div {
  background: var(--flaeche);
  border: 1px solid var(--rand);
  border-radius: var(--radius);
  padding: 12px;
}
.zaehler b { display: block; font-size: 1.6rem; }

/* Update-Banner */
.banner {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 8px 16px;
  background: var(--akzent);
  color: var(--akzent-text);
}
.banner[hidden] { display: none; }

/* Toasts */
.toasts {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: calc(16px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
  z-index: 20;
}
.toast {
  max-width: 480px;
  padding: 12px 16px;
  border-radius: var(--radius);
  background: var(--text);
  color: var(--bg);
  box-shadow: 0 4px 16px rgb(0 0 0 / 0.2);
}
.toast-fehler { background: var(--fehler); color: #fff; }

/* Dialog */
.dialog {
  border: 1px solid var(--rand);
  border-radius: var(--radius);
  background: var(--flaeche);
  color: var(--text);
  max-width: min(480px, calc(100vw - 32px));
  padding: 20px;
}
.dialog::backdrop { background: rgb(0 0 0 / 0.4); }
.dialog p { margin: 0 0 16px; white-space: pre-line; }
.dialog-knoepfe { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
