/* ==== Wo ist Was - modernes, mobil-optimiertes Layout ==== */
:root {
  --rot: #c62828;
  --rot-dunkel: #8e0000;
  --rot-hell: #ff5f52;
  --gruen: #2e7d32;
  --gruen-hell: #e6f4ea;
  --fehler: #c62828;
  --fehler-hell: #fdecea;
  --grau-900: #1f2426;
  --grau-700: #3c4347;
  --grau-500: #6b7378;
  --grau-300: #cfd6da;
  --grau-100: #eef1f3;
  --grau-50: #f7f9fa;
  --weiss: #ffffff;
  --radius: 14px;
  --radius-s: 10px;
  --schatten: 0 2px 10px rgba(0, 0, 0, 0.08);
  --schatten-gross: 0 8px 30px rgba(0, 0, 0, 0.12);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  font-family: var(--font);
  color: var(--grau-900);
  background: var(--grau-50);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ---- Kopfzeile / App-Bar ---- */
.appbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  padding-top: calc(12px + env(safe-area-inset-top));
  background: linear-gradient(135deg, var(--rot), var(--rot-dunkel));
  color: var(--weiss);
  box-shadow: var(--schatten);
}
.appbar__logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px; height: 38px;
  background: rgba(255, 255, 255, 0.16);
  border-radius: 10px;
  font-size: 20px;
  flex: 0 0 auto;
}
.appbar__titel { display: flex; flex-direction: column; line-height: 1.15; }
.appbar__titel strong { font-size: 1.05rem; }
.appbar__titel span { font-size: 0.72rem; opacity: 0.85; }
.appbar__spacer { flex: 1 1 auto; }
.appbar__rolle {
  font-size: 0.72rem;
  background: rgba(255, 255, 255, 0.18);
  padding: 4px 10px;
  border-radius: 999px;
  white-space: nowrap;
}

/* ---- Navigationsleiste ---- */
.nav {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  background: var(--weiss);
  border-bottom: 1px solid var(--grau-100);
  padding: 6px 10px;
  position: sticky;
  top: 62px;
  z-index: 15;
}
.nav a {
  flex: 0 0 auto;
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--grau-700);
  text-decoration: none;
  white-space: nowrap;
}
.nav a.aktiv { background: var(--rot); color: var(--weiss); }

/* ---- Layout-Container ---- */
.container {
  max-width: 720px;
  margin: 0 auto;
  padding: 18px 16px 96px;
}

/* ---- Karten ---- */
.card {
  background: var(--weiss);
  border-radius: var(--radius);
  box-shadow: var(--schatten);
  padding: 18px;
  margin-bottom: 16px;
}
.card h1, .card h2 { margin-top: 0; }

h1 { font-size: 1.5rem; }
h2 { font-size: 1.2rem; }
.muted { color: var(--grau-500); }
.center { text-align: center; }

/* ---- Kacheln (Dashboard) ---- */
.kacheln {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
}
.kachel {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 18px;
  border-radius: var(--radius);
  background: var(--weiss);
  box-shadow: var(--schatten);
  text-decoration: none;
  color: var(--grau-900);
  border: 1px solid var(--grau-100);
  transition: transform 0.05s ease;
}
.kachel:active { transform: scale(0.98); }
.kachel__icon { font-size: 1.6rem; }
.kachel__titel { font-weight: 700; }
.kachel__text { font-size: 0.82rem; color: var(--grau-500); }
.kachel--rot { background: linear-gradient(135deg, var(--rot), var(--rot-dunkel)); color: var(--weiss); border: none; }
.kachel--rot .kachel__text { color: rgba(255,255,255,0.85); }

.statzahl { font-size: 1.8rem; font-weight: 800; color: var(--rot); }

/* ---- Buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 15px 18px;
  border: none;
  border-radius: var(--radius-s);
  font-size: 1rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  text-decoration: none;
  color: var(--weiss);
  background: var(--rot);
  min-height: 52px;
  text-align: center;
}
.btn:active { filter: brightness(0.95); }
.btn--gross { font-size: 1.1rem; padding: 18px; }
.btn--sekundaer { background: var(--grau-100); color: var(--grau-900); }
.btn--umriss { background: transparent; color: var(--rot); border: 2px solid var(--rot); }
.btn--gruen { background: var(--gruen); }
.btn--klein { width: auto; min-height: 40px; padding: 8px 14px; font-size: 0.85rem; }
.btn--gefahr { background: transparent; color: var(--fehler); border: 1px solid var(--grau-300); }
.btn-reihe { display: flex; gap: 10px; flex-wrap: wrap; }
.btn-reihe .btn { width: auto; flex: 1 1 auto; }

/* ---- Auswahl-Buttons (Quiz-Antworten) ---- */
.auswahl { display: grid; gap: 12px; margin-top: 8px; }
.auswahl .btn { background: var(--weiss); color: var(--grau-900); border: 2px solid var(--grau-300); font-weight: 600; }
.auswahl .btn:active { border-color: var(--rot); }
.jn { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.jn .btn { min-height: 64px; font-size: 1.15rem; }
.jn .btn--ja { background: var(--gruen); color: var(--weiss); border: none; }
.jn .btn--nein { background: var(--grau-700); color: var(--weiss); border: none; }

/* ---- Fortschritt / Punktestand ---- */
.quizkopf {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
}
.pill {
  background: var(--grau-100);
  color: var(--grau-700);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 0.82rem;
  font-weight: 700;
}
.pill--rot { background: var(--rot); color: var(--weiss); }

.schritte { display: flex; gap: 6px; margin-bottom: 14px; }
.schritt {
  flex: 1;
  height: 6px;
  border-radius: 999px;
  background: var(--grau-300);
}
.schritt.aktiv { background: var(--rot); }
.schritt.fertig { background: var(--gruen); }

/* ---- Frage-Objekt ---- */
.gegenstand {
  text-align: center;
  padding: 22px 16px;
  border-radius: var(--radius);
  background: var(--grau-50);
  border: 1px dashed var(--grau-300);
  margin-bottom: 16px;
}
.gegenstand .label { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--grau-500); }
.gegenstand .name { font-size: 1.6rem; font-weight: 800; margin-top: 4px; }

/* ---- Feedback ---- */
.feedback {
  border-radius: var(--radius-s);
  padding: 14px 16px;
  margin-bottom: 16px;
  border-left: 5px solid;
}
.feedback--ok { background: var(--gruen-hell); border-color: var(--gruen); }
.feedback--fehler { background: var(--fehler-hell); border-color: var(--fehler); }
.feedback__titel { font-weight: 800; margin-bottom: 2px; }
.hinweis {
  margin-top: 12px;
  background: #fff8e1;
  border-left: 5px solid #f9a825;
  border-radius: var(--radius-s);
  padding: 12px 14px;
  font-size: 0.92rem;
}
.hinweis .label { font-weight: 800; display: block; margin-bottom: 2px; }

/* ---- Meldungen ---- */
.messages { list-style: none; padding: 0; margin: 0 0 14px; }
.messages li {
  padding: 12px 14px;
  border-radius: var(--radius-s);
  margin-bottom: 8px;
  font-size: 0.9rem;
  border-left: 5px solid var(--grau-500);
  background: var(--grau-100);
}
.messages li.success { background: var(--gruen-hell); border-color: var(--gruen); }
.messages li.error { background: var(--fehler-hell); border-color: var(--fehler); }

/* ---- Formulare ---- */
form p, .feld { margin: 0 0 14px; }
label { display: block; font-weight: 600; margin-bottom: 6px; font-size: 0.9rem; }
input[type=text], input[type=password], input[type=email], input[type=number],
select, textarea {
  width: 100%;
  padding: 13px 14px;
  border: 1.5px solid var(--grau-300);
  border-radius: var(--radius-s);
  font-size: 1rem;
  font-family: inherit;
  background: var(--weiss);
  color: var(--grau-900);
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--rot);
  box-shadow: 0 0 0 3px rgba(198, 40, 40, 0.12);
}
.helptext { display: block; font-size: 0.78rem; color: var(--grau-500); margin-top: 4px; }
.errorlist { list-style: none; padding: 0; margin: 6px 0; color: var(--fehler); font-size: 0.85rem; }
ul.errorlist li { background: var(--fehler-hell); padding: 8px 10px; border-radius: 8px; }

/* ---- Listen / Tabellen ---- */
.liste { display: grid; gap: 10px; }
.zeile {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--weiss);
  border: 1px solid var(--grau-100);
  border-radius: var(--radius-s);
  padding: 12px 14px;
}
.zeile__haupt { flex: 1 1 auto; min-width: 0; }
.zeile__titel { font-weight: 700; }
.zeile__sub { font-size: 0.82rem; color: var(--grau-500); }
.zeile__aktionen { display: flex; gap: 8px; flex: 0 0 auto; }
.tag {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--grau-100);
  color: var(--grau-700);
}
.tag--admin { background: var(--rot); color: #fff; }
.tag--editor { background: #1565c0; color: #fff; }
.tag--anwender { background: var(--grau-700); color: #fff; }
.tag--inaktiv { background: var(--fehler-hell); color: var(--fehler); }

.inline-form { display: inline; }

/* ---- Login ---- */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: linear-gradient(160deg, var(--rot), var(--rot-dunkel));
}
.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--weiss);
  border-radius: 18px;
  box-shadow: var(--schatten-gross);
  padding: 28px 24px;
}
.login-logo {
  width: 60px; height: 60px;
  margin: 0 auto 12px;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--rot), var(--rot-dunkel));
  color: #fff; font-size: 30px; border-radius: 16px;
}

/* ---- v0.2: Mehrfachauswahl (Checkboxen) ---- */
.check-liste { display: grid; gap: 10px; margin-top: 6px; }
.check-option {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 14px;
  border: 2px solid var(--grau-300);
  border-radius: var(--radius-s);
  background: var(--weiss);
  font-weight: 600;
  cursor: pointer;
  margin: 0;
}
.check-option input { width: 22px; height: 22px; flex: 0 0 auto; accent-color: var(--rot); }
.check-option:has(input:checked) { border-color: var(--rot); background: #fdecec; }

/* ---- v0.2: Feedback teilweise ---- */
.feedback--warn { background: #fff8e1; border-color: #f9a825; }

/* ---- v0.2: Ergebnis-Badge ---- */
.ergebnis-badge {
  display: block;
  text-align: center;
  font-weight: 800;
  font-size: 1.05rem;
  padding: 12px;
  border-radius: var(--radius-s);
}
.ergebnis-badge--ok { background: var(--gruen-hell); color: var(--gruen); }
.ergebnis-badge--warn { background: #fff8e1; color: #b06f00; }
.ergebnis-badge--fehler { background: var(--fehler-hell); color: var(--fehler); }

/* ---- v0.2: Aufloesung ---- */
.aufloesung { margin: 14px 0 4px; }
.aufloesung__zeile {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 10px 0; border-bottom: 1px solid var(--grau-100);
}
.aufloesung__zeile span { color: var(--grau-500); font-size: 0.85rem; }
.aufloesung__zeile strong { text-align: right; }
.mini { display: inline-block; margin-left: 4px; font-weight: 800; }
.mini.ok { color: var(--gruen); }
.mini.warn { color: #b06f00; }
.mini.fehler { color: var(--fehler); }

/* ---- v0.2: Tags/Chips ---- */
.tag--dummy { background: #6a1b9a; color: #fff; }
.chip-liste { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0 12px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--grau-100); color: var(--grau-900);
  border-radius: 999px; padding: 6px 6px 6px 12px; font-size: 0.85rem; font-weight: 600;
}
.chip__x {
  border: none; background: var(--grau-300); color: #fff;
  width: 20px; height: 20px; border-radius: 50%; cursor: pointer;
  font-size: 0.7rem; line-height: 1; display: inline-flex; align-items: center; justify-content: center;
}
.chip__x:hover { background: var(--fehler); }
.add-inline { display: flex; gap: 8px; align-items: center; }
.add-inline input { flex: 1 1 auto; }
.add-inline .btn { flex: 0 0 auto; }

/* ---- v0.2: Diagramm & Quoten-Balken ---- */
.chart-wrap { width: 100%; overflow-x: auto; }
.chart { width: 100%; height: auto; display: block; }
.quote-bar { height: 8px; background: var(--grau-100); border-radius: 999px; overflow: hidden; margin: 6px 0; }
.quote-bar__fill { display: block; height: 100%; border-radius: 999px; }
.quote-bar__fill.gut { background: var(--gruen); }
.quote-bar__fill.mittel { background: #f9a825; }
.quote-bar__fill.schlecht { background: var(--fehler); }

/* ---- v0.3: Ermahnungs-Overlay (3x falsch) ---- */
.ermahnung-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.94);
  padding: 0;
  opacity: 1;
  transition: opacity 0.4s ease;
  animation: ermahnung-auf 0.25s ease;
}
.ermahnung-overlay--weg { opacity: 0; }
.ermahnung-overlay__img {
  width: 100vw;
  height: 100vh;
  max-width: 100vw;
  max-height: 100vh;
  object-fit: contain;
  display: block;
}
@keyframes ermahnung-auf { from { opacity: 0; } to { opacity: 1; } }

/* ---- v0.4: Modal / Kontextfenster (native <dialog>) ---- */
.modal {
  border: none;
  border-radius: 16px;
  padding: 20px;
  max-width: 460px;
  width: 92vw;
  box-shadow: var(--schatten-gross);
  color: var(--grau-900);
  background: var(--weiss);
}
.modal::backdrop { background: rgba(0, 0, 0, 0.5); }
.modal h3 { margin-top: 0; }
.modal__abschnitt { margin-top: 14px; border-top: 1px solid var(--grau-100); padding-top: 12px; }
.modal__liste { margin: 6px 0 0; padding-left: 18px; }
.modal__liste li { margin: 2px 0; }

/* klickbare Chips (Orte/Details) */
.chip--klick {
  cursor: pointer;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  border: 1px solid var(--grau-300);
}
.chip--klick:hover { background: var(--grau-300); }
.chip__count {
  background: var(--rot);
  color: #fff;
  border-radius: 999px;
  font-size: 0.7rem;
  padding: 1px 7px;
  margin-left: 6px;
}

/* ---- v0.5: Dark-Mode-Umschalter ---- */
.appbar__toggle {
  background: rgba(255, 255, 255, 0.16);
  border: none;
  color: #fff;
  width: 34px;
  height: 34px;
  border-radius: 9px;
  font-size: 1rem;
  cursor: pointer;
  flex: 0 0 auto;
  margin-right: 6px;
}
.appbar__toggle:active { filter: brightness(0.9); }

:root[data-theme="dark"] {
  --grau-900: #eceff1;
  --grau-700: #c4cbd0;
  --grau-500: #98a1a7;
  --grau-300: #414b52;
  --grau-100: #2b3238;
  --grau-50: #14181b;
  --weiss: #232a2f;
  --gruen-hell: #16311f;
  --fehler-hell: #3a1d1d;
  --schatten: 0 2px 10px rgba(0, 0, 0, 0.55);
  --schatten-gross: 0 8px 30px rgba(0, 0, 0, 0.6);
}
:root[data-theme="dark"] body { background: var(--grau-50); }
/* Kontrastanpassungen fuer getoente Panels im Dark Mode */
:root[data-theme="dark"] .feedback--ok,
:root[data-theme="dark"] .ergebnis-badge--ok { color: #7fd99a; }
:root[data-theme="dark"] .feedback--fehler,
:root[data-theme="dark"] .ergebnis-badge--fehler { color: #ff8a8a; }
:root[data-theme="dark"] .hinweis,
:root[data-theme="dark"] .feedback--warn,
:root[data-theme="dark"] .ergebnis-badge--warn { background: #34300f; color: #ffe0a0; }
:root[data-theme="dark"] .check-option:has(input:checked) { background: #3a1d1d; }
:root[data-theme="dark"] .messages li.success { color: #7fd99a; }
:root[data-theme="dark"] .messages li.error { color: #ff8a8a; }

/* ---- v1.0: Beladungs-Textfilter ---- */
.beladung-filter {
  width: 100%;
  margin-top: 10px;
  padding: 12px 14px;
  border: 1.5px solid var(--grau-300);
  border-radius: var(--radius-s);
  font-size: 1rem;
  font-family: inherit;
  background: var(--weiss);
  color: var(--grau-900);
}
.beladung-filter:focus {
  outline: none;
  border-color: var(--rot);
  box-shadow: 0 0 0 3px rgba(198, 40, 40, 0.12);
}

/* ---- Divers ---- */
.footer { text-align: center; color: var(--grau-500); font-size: 0.75rem; padding: 8px 0 24px; }
.trenner { height: 1px; background: var(--grau-100); margin: 16px 0; border: none; }
a.textlink { color: var(--rot); font-weight: 600; text-decoration: none; }
.datalist-wrap { position: relative; }
