:root {
  --grund: #f6f4ef;
  --flaeche: #ffffff;
  --text: #1d2420;
  --text-leise: #4d5752;
  --linie: #d5d2c8;
  --akzent: #1f6f4a;
  --akzent-hell: #e3f1e9;
  --vermietet: #2e9d57;
  --gekuendigt: #e07b00;
  --leer: #ffffff;
  --ueberdacht: #2f6fdf;
  --notfall: #8a3ffc;
  --auswahl: #ffd200;
  --warnung: #fff4d6;
  --warnung-rand: #e0a800;
  --fehler: #b3261e;
  --radius: 14px;
  --schatten: 0 2px 10px rgba(0, 0, 0, .12);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 19px;
  line-height: 1.45;
  color: var(--text);
  background: var(--grund);
  -webkit-text-size-adjust: 100%;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--akzent); }
:focus-visible { outline: 3px solid #0b57d0; outline-offset: 2px; }

.sprunglink { position: absolute; left: -999px; top: 0; background: #fff; padding: 8px 12px; z-index: 9999; }
.sprunglink:focus { left: 8px; }

/* ---------- Kopf und Navigation ---------- */
.kopf {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px; background: var(--akzent); color: #fff;
}
.kopf h1 { font-size: 1.15rem; margin: 0; flex: 1; font-weight: 650; }
.kopf .wer { font-size: .85rem; opacity: .9; }
.kopf form { margin: 0; }
.kopf button { background: rgba(255,255,255,.15); color: #fff; border: 1px solid rgba(255,255,255,.4); border-radius: 10px; padding: 6px 12px; font-size: .85rem; cursor: pointer; }

.navi {
  display: flex; background: var(--flaeche); border-bottom: 1px solid var(--linie);
  overflow-x: auto;
}
.navi button {
  flex: 1; min-width: 92px; border: 0; background: none; padding: 12px 8px; cursor: pointer;
  font-size: 1rem; color: var(--text-leise); border-bottom: 4px solid transparent; white-space: nowrap;
}
.navi button[aria-current="page"] { color: var(--akzent); border-bottom-color: var(--akzent); font-weight: 650; }

@media (max-width: 760px) {
  body { padding-bottom: 72px; }
  .navi { position: fixed; bottom: 0; left: 0; right: 0; z-index: 1500; border-top: 1px solid var(--linie); border-bottom: 0;
          padding-bottom: env(safe-area-inset-bottom); }
  .navi button { border-bottom: 0; border-top: 4px solid transparent; font-size: .9rem; padding: 8px 4px 10px; min-width: 0; }
  .navi button[aria-current="page"] { border-top-color: var(--akzent); }
  .navi .sym { display: block; font-size: 1.35rem; line-height: 1.2; }
}
@media (min-width: 761px) { .navi .sym { margin-right: 6px; } }

main { display: block; }
.seite { display: none; }
.seite.aktiv { display: block; }
.innen { max-width: 980px; margin: 0 auto; padding: 16px; }

/* ---------- Knöpfe, Felder ---------- */
.knopf {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 10px 18px; border-radius: 12px; border: 2px solid var(--akzent);
  background: var(--flaeche); color: var(--akzent); font-weight: 600; cursor: pointer; text-decoration: none;
}
.knopf.haupt { background: var(--akzent); color: #fff; }
.knopf.klein { min-height: 40px; padding: 6px 12px; font-size: .9rem; }
.knopf.gefahr { border-color: var(--fehler); color: var(--fehler); }
.knopf:disabled { opacity: .5; cursor: default; }
.knopfreihe { display: flex; flex-wrap: wrap; gap: 10px; margin: 12px 0; }

label { display: block; font-weight: 600; margin: 12px 0 4px; }
input[type=text], input[type=email], input[type=tel], input[type=number], input[type=date], input[type=password], input[type=search], select, textarea {
  width: 100%; min-height: 48px; padding: 10px 12px; border: 2px solid var(--linie); border-radius: 10px; background: #fff;
}
textarea { min-height: 160px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--akzent); outline: none; box-shadow: 0 0 0 3px rgba(31,111,74,.25); }
.feld-unsicher input, .feld-unsicher select { border-color: var(--warnung-rand); background: var(--warnung); }
.unsicher-hinweis { display: none; color: #7a5400; font-size: .85rem; font-weight: 600; margin-left: 6px; }
.feld-unsicher .unsicher-hinweis { display: inline; }
.feld-erkannt input { border-color: var(--vermietet); }
.raster2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
@media (max-width: 600px) { .raster2 { grid-template-columns: 1fr; } }
.check { display: flex; align-items: center; gap: 10px; font-weight: 600; margin: 12px 0; cursor: pointer; }
.check input { width: 26px; height: 26px; }

.karte-box { background: var(--flaeche); border-radius: var(--radius); box-shadow: var(--schatten); padding: 16px; margin: 12px 0; }
.hinweis { background: var(--warnung); border: 2px solid var(--warnung-rand); border-radius: 12px; padding: 12px 14px; margin: 12px 0; }
.hinweis.gut { background: var(--akzent-hell); border-color: var(--akzent); }
.hinweis.schlecht { background: #fde7e6; border-color: var(--fehler); }
.leise { color: var(--text-leise); font-size: .9rem; }
h2 { font-size: 1.35rem; margin: 8px 0 12px; }
h3 { font-size: 1.1rem; margin: 16px 0 8px; }

/* ---------- Karte ---------- */
.karten-kopf { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; padding: 10px 16px; background: var(--flaeche); border-bottom: 1px solid var(--linie); }
.umschalter { display: inline-flex; border: 3px solid var(--akzent); border-radius: 14px; overflow: hidden; }
.umschalter button {
  border: 0; background: #fff; color: var(--akzent); padding: 10px 20px; font-size: 1.15rem; font-weight: 700; cursor: pointer; min-height: 54px;
}
.umschalter button[aria-pressed="true"] { background: var(--akzent); color: #fff; }
.karten-kopf .rechts { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }

.kartenbereich { position: relative; height: calc(100vh - 210px); min-height: 380px; }
@media (max-width: 760px) { .kartenbereich { height: calc(100vh - 250px); } }
#karte2d, #karte3d { position: absolute; inset: 0; }
#karte2d { background: #dfe8d6; }
#karte3d { background: #eef3f7; touch-action: none; }
#karte3d canvas { display: block; width: 100%; height: 100%; }
.verborgen { display: none !important; }

.legende {
  position: absolute; left: 10px; bottom: 30px; z-index: 600; background: rgba(255,255,255,.94); border-radius: 12px;
  padding: 8px 12px; font-size: .85rem; box-shadow: var(--schatten); max-width: 60%;
}
.legende div { display: flex; align-items: center; gap: 8px; margin: 2px 0; }
.legende .f { width: 22px; height: 16px; border-radius: 4px; border: 2px solid #555; flex: none; }
.legende-zu { position: absolute; left: 10px; bottom: 30px; z-index: 600; }
.quelle3d { position: absolute; right: 6px; bottom: 4px; font-size: .7rem; color: #444; background: rgba(255,255,255,.75); padding: 1px 6px; border-radius: 6px; z-index: 5; }

.nummer-2d { color: #111; font-weight: 800; text-align: center; white-space: nowrap; pointer-events: none;
  text-shadow: 0 0 3px #fff, 0 0 3px #fff, 0 0 2px #fff; line-height: 1; }
.leaflet-container { font-family: inherit; }
.leaflet-control-attribution { font-size: 11px !important; }
.leaflet-touch .leaflet-bar a { width: 44px; height: 44px; line-height: 44px; font-size: 22px; }
.griff { width: 34px; height: 34px; margin: -17px 0 0 -17px; border-radius: 50%; background: #fff; border: 4px solid #0b57d0; box-shadow: var(--schatten);
  display: flex; align-items: center; justify-content: center; font-size: 16px; font-weight: 800; color: #0b57d0; }
.griff.drehen { border-color: #c2410c; color: #c2410c; }

.auswahl-leiste {
  position: absolute; left: 50%; transform: translateX(-50%); top: 10px; z-index: 700;
  background: #222; color: #fff; padding: 8px 10px 8px 16px; border-radius: 14px; display: flex; gap: 10px; align-items: center; box-shadow: var(--schatten);
  max-width: calc(100% - 20px);
}
.auswahl-leiste .knopf { min-height: 40px; }

/* ---------- Platz-Fenster (unten am Handy, rechts am PC) ---------- */
.fenster {
  position: absolute; z-index: 800; background: var(--flaeche); box-shadow: 0 -4px 20px rgba(0,0,0,.2);
  overflow-y: auto; -webkit-overflow-scrolling: touch;
}
@media (max-width: 760px) {
  .fenster { left: 0; right: 0; bottom: 0; max-height: 70%; border-radius: 18px 18px 0 0; padding: 14px 16px 20px; }
}
@media (min-width: 761px) {
  .fenster { top: 10px; right: 10px; bottom: 10px; width: 400px; border-radius: var(--radius); padding: 16px 18px; }
}
.fenster .zu { position: sticky; top: 0; float: right; border: 0; background: #eee; border-radius: 50%; width: 44px; height: 44px; font-size: 22px; cursor: pointer; }
.platz-titel { font-size: 1.6rem; font-weight: 800; margin: 0 0 4px; }
.marke { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: .85rem; font-weight: 700; margin: 2px 4px 2px 0; }
.marke.vermietet { background: #d7f0df; color: #135c2f; }
.marke.gekuendigt { background: #ffe7c7; color: #7a3d00; }
.marke.leer { background: #eee; color: #333; }
.marke.ueberdacht { background: #dde8fb; color: #1a4596; }
.marke.notfall { background: #ece0ff; color: #4d1a9c; }
.marke.offen { background: #fde7e6; color: #8c1d18; }
.marke.bezahlt { background: #d7f0df; color: #135c2f; }
dl.daten { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; margin: 8px 0; }
dl.daten dt { color: var(--text-leise); }
dl.daten dd { margin: 0; font-weight: 600; word-break: break-word; }

/* ---------- Editor ---------- */
.editor-feld { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 4px 10px; margin: 8px 0; }
.editor-feld label { margin: 0; }
.stufer { display: inline-flex; align-items: center; gap: 6px; }
.stufer button { width: 46px; height: 46px; border-radius: 10px; border: 2px solid var(--linie); background: #fff; font-size: 1.4rem; font-weight: 700; cursor: pointer; }
.stufer input { width: 90px; text-align: center; min-height: 46px; }
.editor-feld input[type=range] { grid-column: 1 / -1; width: 100%; height: 34px; }
.gespeichert { font-size: .9rem; color: var(--akzent); font-weight: 600; }

/* ---------- Listen ---------- */
.suche { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.suche input { flex: 1; min-width: 200px; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; margin: 10px 0; }
.chip { border: 2px solid var(--linie); background: #fff; border-radius: 999px; padding: 8px 14px; cursor: pointer; font-size: .95rem; min-height: 44px; }
.chip[aria-pressed="true"] { border-color: var(--akzent); background: var(--akzent-hell); color: var(--akzent); font-weight: 700; }
.eintrag { background: var(--flaeche); border-radius: 12px; box-shadow: var(--schatten); padding: 12px 14px; margin: 10px 0; display: flex; gap: 12px; align-items: flex-start; }
.eintrag .nr { font-size: 1.4rem; font-weight: 800; min-width: 52px; text-align: center; background: var(--grund); border-radius: 10px; padding: 4px 6px; }
.eintrag .haupt { flex: 1; min-width: 0; }
.eintrag .name { font-weight: 700; font-size: 1.1rem; }
.eintrag .aktionen { display: flex; flex-direction: column; gap: 6px; }
.eintrag.auswahlbar { cursor: pointer; }
.eintrag input[type=checkbox] { width: 28px; height: 28px; margin-top: 6px; flex: none; }

/* ---------- Dialog ---------- */
dialog { border: 0; border-radius: var(--radius); padding: 0; width: min(760px, 100vw - 16px); max-height: calc(100vh - 16px); box-shadow: 0 10px 40px rgba(0,0,0,.35); }
dialog::backdrop { background: rgba(0,0,0,.45); }
.dialog-innen { padding: 18px 20px 24px; }
.dialog-kopf { display: flex; align-items: center; gap: 10px; position: sticky; top: 0; background: #fff; padding: 12px 20px; border-bottom: 1px solid var(--linie); z-index: 2; }
.dialog-kopf h2 { flex: 1; margin: 0; }
.ablage { border: 3px dashed var(--akzent); border-radius: var(--radius); padding: 18px; text-align: center; background: var(--akzent-hell); }
.ablage input { display: none; }
.lade { display: inline-block; width: 22px; height: 22px; border: 3px solid var(--akzent); border-top-color: transparent; border-radius: 50%; animation: dreh 1s linear infinite; vertical-align: middle; }
@keyframes dreh { to { transform: rotate(360deg); } }
.mail-vorschau { background: #fff; border: 2px solid var(--linie); border-radius: 12px; padding: 14px; white-space: pre-wrap; }
.meldung { position: fixed; left: 50%; transform: translateX(-50%); bottom: 90px; background: #222; color: #fff; padding: 12px 20px; border-radius: 12px; z-index: 3000; box-shadow: var(--schatten); max-width: calc(100% - 32px); }

/* ---------- Anmeldung ---------- */
.anmelde-box { max-width: 420px; margin: 8vh auto; background: #fff; border-radius: var(--radius); box-shadow: var(--schatten); padding: 24px; }
.anmelde-box h1 { font-size: 1.5rem; margin: 0 0 6px; }

@media print {
  .kopf, .navi, .karten-kopf, .fenster, .legende { display: none !important; }
}
.nummer-wrap { width: 0 !important; height: 0 !important; }
.nummer-2d { transform: translate(-50%, -50%); font-size: var(--nr, 13px); }
.hinweis.auslauf { margin: 0; border-radius: 0; border-width: 0 0 2px; padding: 8px 16px; }
.hinweis.auslauf summary { cursor: pointer; min-height: 32px; }
.hinweis.auslauf .chip { margin: 6px 6px 0 0; }
@media (max-width: 760px) {
  .kopf { padding: 8px 12px; }
  .kopf .wer { display: none; }
  .karten-kopf { padding: 8px 12px; gap: 8px; }
  .umschalter { width: 100%; }
  .umschalter button { flex: 1; padding: 8px 10px; font-size: 1.1rem; min-height: 50px; }
  .karten-kopf .rechts { margin-left: 0; width: 100%; gap: 6px; flex-wrap: nowrap; }
  .karten-kopf .rechts .knopf { flex: 1; font-size: .8rem; min-height: 40px; padding: 4px 6px; text-align: center; }
  .legende { bottom: 22px; font-size: .78rem; padding: 6px 10px; }
}
.legende summary { cursor: pointer; font-weight: 700; min-height: 28px; }
.legende[open] summary { margin-bottom: 4px; }
.nummern-aus .nummer-2d { display: none; }
@media (max-width: 760px) {
  .leaflet-control-attribution { font-size: 9.5px !important; line-height: 1.25; }
  .legende { bottom: 34px; }
}
.fenster { z-index: 1100; }
.auswahl-leiste { z-index: 1050; }
:root { --reserviert: #0097a7; }
.marke.reserviert { background: #d2f1f4; color: #005f69; }
.marke.unbekannt { background: #eee; color: #333; }
.marke.interessent { background: #fff0c2; color: #6b4e00; }
.marke.mieter { background: #d7f0df; color: #135c2f; }
.mail-zeile { cursor: pointer; }
.mail-zeile.ungelesen .name { font-weight: 800; }
.mail-zeile.ungelesen .nr { background: var(--akzent); color: #fff; }
.mailverlauf { list-style: none; padding: 0; margin: 6px 0; }
.mailverlauf li { border-left: 4px solid var(--linie); padding: 6px 10px; margin: 8px 0; background: #fff; border-radius: 0 10px 10px 0; }
.mailverlauf li.aus { border-left-color: var(--akzent); background: var(--akzent-hell); }
.mailverlauf .text { white-space: pre-wrap; font-size: .9rem; margin-top: 4px; }
@media (max-width: 760px) { .navi button { font-size: .78rem; } }
