:root {
  --bg: #f6f5f2; --flaeche: #fff; --text: #1f2328; --leise: #5f6670; --rand: #dcd9d2;
  --akzent: #2f6f4f; --akzent-text: #fff; --gefahr: #b3261e; --tag: #e6efe9; --tag-text: #24553c;
  --radius: 10px;
}
/* Standard ist hell; dunkel nur per Knopf (Cookie "thema=dunkel"). */
:root { color-scheme: light; }
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #17191c; --flaeche: #202328; --text: #e7e9ec; --leise: #9aa1aa; --rand: #343840;
  --akzent: #5fb58a; --akzent-text: #0f1a14; --gefahr: #f08a82; --tag: #233a2e; --tag-text: #a9dcbf;
}
:root[data-theme="dark"] .meldungen li.error { background: #4a1f1c; color: #f6c9c5; }
* { box-sizing: border-box; }
body { margin: 0; font: 16px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif; background: var(--bg); color: var(--text); }
a { color: var(--akzent); }
main { max-width: 900px; margin: 0 auto; padding: 16px; }
h1 { font-size: 1.5rem; margin: .2rem 0 1rem; }
h2 { font-size: 1.15rem; margin: 1.5rem 0 .6rem; }
.leise { color: var(--leise); font-size: .9rem; }

header.kopf { background: var(--flaeche); border-bottom: 1px solid var(--rand); }
header.kopf .innen { max-width: 900px; margin: 0 auto; padding: 8px 16px; display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; }
header.kopf .marke { font-weight: 700; text-decoration: none; color: var(--text); font-size: 1.1rem; }
header.kopf nav { display: flex; gap: 4px; flex-wrap: wrap; }
header.kopf nav a { text-decoration: none; padding: 6px 10px; border-radius: 8px; color: var(--text); }
header.kopf nav a.aktiv, header.kopf nav a:hover { background: var(--bg); }
header.kopf .rechts { margin-left: auto; display: flex; gap: 8px; align-items: center; }

.knopf, button, input[type=submit] {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 16px; min-height: 44px; border-radius: var(--radius); border: 1px solid var(--akzent);
  background: var(--akzent); color: var(--akzent-text); font: inherit; font-weight: 600; text-decoration: none; cursor: pointer;
}
.knopf.zweit, button.zweit { background: transparent; color: var(--akzent); }
.knopf.gefahr, button.gefahr { background: var(--gefahr); border-color: var(--gefahr); color: #fff; }
.knopf.klein, button.klein { min-height: 34px; padding: 4px 10px; font-size: .9rem; }
.knopfleiste { display: flex; flex-wrap: wrap; gap: 8px; margin: 1rem 0; }

input[type=text], input[type=search], input[type=number], input[type=password], select, textarea {
  width: 100%; padding: 10px 12px; min-height: 44px; font: inherit; color: var(--text);
  background: var(--flaeche); border: 1px solid var(--rand); border-radius: var(--radius);
}
label { display: block; font-weight: 600; margin-bottom: 4px; }
.feld { margin-bottom: 14px; }
.feld .hilfe { color: var(--leise); font-size: .85rem; margin-top: 2px; }
.fehlerbox { background: #fbe4e2; color: #8c1d18; border: 2px solid var(--gefahr); border-radius: var(--radius); padding: 12px 14px; margin-bottom: 14px; }
:root[data-theme="dark"] .fehlerbox { background: #4a1f1c; color: #f6c9c5; }
.feld:has(.errorlist) input, .feld:has(.errorlist) select, .feld:has(.errorlist) textarea { border: 2px solid var(--gefahr); }
.feld .errorlist { font-weight: 600; }
.feld .fehler, .errorlist { color: var(--gefahr); font-size: .9rem; margin: 4px 0 0; padding: 0; list-style: none; }

.karte { background: var(--flaeche); border: 1px solid var(--rand); border-radius: var(--radius); padding: 16px; }
.suche { display: grid; grid-template-columns: 1fr; gap: 8px; margin-bottom: 12px; }
@media (min-width: 640px) { .suche { grid-template-columns: 2fr 1fr auto; } }

ul.liste { list-style: none; padding: 0; margin: 0; background: var(--flaeche); border: 1px solid var(--rand); border-radius: var(--radius); overflow: hidden; }
ul.liste li { border-top: 1px solid var(--rand); }
ul.liste li:first-child { border-top: 0; }
ul.liste a.zeile { display: flex; gap: 12px; align-items: center; padding: 10px 14px; color: inherit; text-decoration: none; }
ul.liste a.zeile:hover { background: var(--bg); }
.zeile .haupt { flex: 1; min-width: 0; }
.zeile .titel { font-weight: 600; overflow-wrap: anywhere; }
.zeile .menge { color: var(--leise); white-space: nowrap; }
.mini { width: 48px; height: 48px; object-fit: cover; border-radius: 8px; flex: none; background: var(--bg); }

.tag { display: inline-block; background: var(--tag); color: var(--tag-text); border-radius: 999px; padding: 1px 10px; font-size: .85rem; text-decoration: none; margin: 2px 2px 0 0; }
.pfad { color: var(--leise); font-size: .9rem; }
.pfad a { color: inherit; }

dl.daten { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0; }
dl.daten dt { color: var(--leise); }
dl.daten dd { margin: 0; overflow-wrap: anywhere; }
.foto-gross { max-width: 100%; max-height: 420px; border-radius: var(--radius); display: block; margin-bottom: 12px; }
.qr { width: 140px; height: 140px; background: #fff; border-radius: 8px; padding: 4px; }

.meldungen { list-style: none; padding: 0; margin: 0 0 12px; }
.meldungen li { padding: 10px 14px; border-radius: var(--radius); background: var(--tag); color: var(--tag-text); margin-bottom: 6px; }
.meldungen li.error { background: #fbe4e2; color: #8c1d18; }

.blaettern { display: flex; gap: 12px; justify-content: center; align-items: center; margin: 16px 0; }
.leer { text-align: center; color: var(--leise); padding: 32px 16px; }
.einzug { display: inline-block; }

/* ---- Ort-Auswahl in Stufen (ortwahl.js) ---- */
.ortwahl-knopf { width: 100%; text-align: left; background: var(--flaeche); color: var(--text); border: 1px solid var(--rand); font-weight: 400; }
.ortwahl-knopf::after { content: " ▾"; color: var(--akzent); }
dialog.ortwahl { width: min(560px, calc(100vw - 32px)); max-height: 85vh; padding: 0; border: 1px solid var(--rand); border-radius: var(--radius); background: var(--bg); color: var(--text); display: none; }
dialog.ortwahl[open] { display: flex; flex-direction: column; }
dialog.ortwahl::backdrop { background: rgb(0 0 0 / .4); }
.ortwahl-kopf { display: flex; gap: 8px; padding: 12px; }
.ortwahl-kopf input { flex: 1; }
.ortwahl-weg { padding: 0 12px; }
.ortwahl-weg:empty { display: none; }
.ortwahl-liste { overflow-y: auto; margin: 8px 0 0; padding: 0 12px 12px; }
.ortwahl-liste li { display: flex; align-items: stretch; gap: 6px; }
.ortwahl-zeile { flex: 1; width: 100%; text-align: left; background: var(--flaeche); color: var(--text); font-weight: 400; border: 1px solid var(--rand); }
.ortwahl-unter { display: block; }
.ortwahl-ok { background: var(--flaeche); color: var(--akzent); border: 1px solid var(--rand); min-width: 48px; }
.ortwahl-zurueck { background: transparent; border-style: dashed; }
.ortwahl-hier button { width: 100%; margin: 4px 0 8px; }
.ortwahl-liste li.gewaehlt .ortwahl-zeile { border-color: var(--akzent); box-shadow: inset 3px 0 0 var(--akzent); }
.ortwahl-leer { padding: 16px; }

/* ---- Orte-Baum (einklappbar) ---- */
.baum, .baum ul { list-style: none; margin: 0; padding: 0; }
.baum ul { padding-left: 20px; }
.baum details > summary { list-style: none; cursor: pointer; }
.baum details > summary::-webkit-details-marker { display: none; }
.baum .pfeil { display: inline-block; width: 1.4em; text-align: center; color: var(--akzent); opacity: .8; transition: transform .15s; }
.baum details[open] > summary .pfeil { transform: rotate(90deg); }
.baum .ohne-pfeil { display: inline-block; width: 1.4em; }
.baum .knoten { display: flex; align-items: center; gap: 4px; }
.baum .knoten .zeile { flex: 1; }
.baum details:not([open]) > summary .direkt, .baum details[open] > summary .gesamt { display: none; }
ul.liste.ortwahl-liste { background: transparent; border: 0; border-radius: 0; display: flex; flex-direction: column; gap: 6px; }
ul.liste.ortwahl-liste li { border-top: 0; }
