/* ==========================================================================
   Routenplaner – Oberfläche
   Aufbau: Tokens · Grundlagen · Bausteine · Layout · Bereiche
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Tokens
   -------------------------------------------------------------------------- */
:root {
  --bg:            #f4f4f1;
  --surface:       #ffffff;
  --surface-2:     #f7f7f4;
  --surface-3:     #ecece7;
  --border:        #e3e2dc;
  --border-strong: #cfcec6;
  --text:          #1a1c19;
  --text-muted:    #71736c;
  --text-faint:    #9b9d95;

  --accent:        #2f6f4e;
  --accent-hover:  #255840;
  --accent-soft:   #e7f0ea;
  --accent-text:   #ffffff;
  --danger:        #c0442c;
  --danger-soft:   #fbeae6;

  --route:         #2f6f4e;
  --route-halo:    rgba(0, 0, 0, .35);

  --radius:    10px;
  --radius-sm: 7px;
  --radius-lg: 16px;
  --shadow:    0 1px 2px rgba(20, 22, 18, .06), 0 4px 14px rgba(20, 22, 18, .07);
  --shadow-lg: 0 8px 40px rgba(20, 22, 18, .18);

  --sidebar-w: 358px;
  --header-h:  54px;
  --profil-h:  158px;
  --griff-h:   52px;   /* Griff des Blatts auf schmalen Bildschirmen */

  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

:root[data-theme='dark'] {
  --bg:            #101215;
  --surface:       #191c20;
  --surface-2:     #202429;
  --surface-3:     #2a2f35;
  --border:        #2b3037;
  --border-strong: #3b424a;
  --text:          #e9ebe8;
  --text-muted:    #969b96;
  --text-faint:    #6d726d;

  --accent:        #58a67c;
  --accent-hover:  #6cba90;
  --accent-soft:   #1d2e26;
  --accent-text:   #0d1a13;
  --danger:        #e0705a;
  --danger-soft:   #33201c;

  --route:         #6cba90;
  --route-halo:    rgba(0, 0, 0, .55);

  --shadow:    0 1px 2px rgba(0, 0, 0, .4), 0 4px 14px rgba(0, 0, 0, .35);
  --shadow-lg: 0 8px 40px rgba(0, 0, 0, .55);
}

/* --------------------------------------------------------------------------
   2. Grundlagen
   -------------------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  height: 100dvh;   /* iPhone/iPad: ohne die ein- und ausfahrende Safari-Leiste */
  overflow: hidden;
  -webkit-text-size-adjust: 100%;
  font-family: var(--font);
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
body { display: flex; flex-direction: column; }

input, textarea, select, button { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: none; touch-action: manipulation; }
a { color: var(--accent); }

::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border: 3px solid transparent; background-clip: content-box; border-radius: 8px; }
::-webkit-scrollbar-thumb:hover { background-color: var(--text-faint); background-clip: content-box; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.versteckt { display: none !important; }

/* --------------------------------------------------------------------------
   3. Bausteine
   -------------------------------------------------------------------------- */

/* Knöpfe ---------------------------------------------------------------- */
.knopf {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 0 14px; height: 36px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text);
  font-size: 13px; font-weight: 500; white-space: nowrap;
  transition: background .12s, border-color .12s, color .12s;
}
.knopf:hover:not(:disabled) { background: var(--surface-2); border-color: var(--border-strong); }
.knopf:disabled { opacity: .45; cursor: not-allowed; }
.knopf svg { width: 16px; height: 16px; flex-shrink: 0; }

.knopf--haupt { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 600; }
.knopf--haupt:hover:not(:disabled) { background: var(--accent-hover); border-color: var(--accent-hover); }
.knopf--still { border-color: transparent; background: transparent; color: var(--text-muted); }
.knopf--still:hover:not(:disabled) { background: var(--surface-3); color: var(--text); }
.knopf--gefahr { color: var(--danger); }
.knopf--gefahr:hover:not(:disabled) { background: var(--danger-soft); border-color: var(--danger); }
.knopf--breit { width: 100%; }
.knopf--klein { height: 30px; padding: 0 10px; font-size: 12px; }
.knopf--symbol { width: 36px; padding: 0; }

.knopf-reihe { display: flex; gap: 6px; }
.knopf-reihe > .knopf { flex: 1; min-width: 0; }

/* Felder ---------------------------------------------------------------- */
.feld {
  width: 100%; height: 36px; padding: 0 11px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text); font-size: 13px;
  transition: border-color .12s, box-shadow .12s;
}
textarea.feld { height: auto; padding: 9px 11px; resize: vertical; line-height: 1.5; }
select.feld { cursor: pointer; appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%), linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: calc(100% - 15px) 15px, calc(100% - 10px) 15px;
  background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; padding-right: 28px; }
.feld:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.feld::placeholder { color: var(--text-faint); }

.feld-gruppe { display: flex; flex-direction: column; gap: 5px; }
.feld-gruppe > label { font-size: 11px; font-weight: 500; color: var(--text-muted); }

input[type='range'] {
  width: 100%; height: 4px; appearance: none; border-radius: 4px;
  background: var(--surface-3); cursor: pointer;
}
input[type='range']::-webkit-slider-thumb {
  appearance: none; width: 15px; height: 15px; border-radius: 50%;
  background: var(--accent); border: 2px solid var(--surface); box-shadow: var(--shadow);
}

/* Segmentierte Umschalter ------------------------------------------------ */
.umschalter {
  display: flex; padding: 3px; gap: 2px;
  background: var(--surface-3); border-radius: var(--radius-sm);
}
.umschalter button {
  flex: 1; padding: 6px 10px; border-radius: 5px;
  font-size: 12px; font-weight: 500; color: var(--text-muted);
  transition: background .12s, color .12s;
}
.umschalter button:hover { color: var(--text); }
.umschalter button[aria-pressed='true'] { background: var(--surface); color: var(--text); font-weight: 600; box-shadow: 0 1px 2px rgba(0,0,0,.08); }

/* Karten / Chips --------------------------------------------------------- */
.chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 9px; border-radius: 20px;
  background: var(--surface-3); color: var(--text-muted);
  font-size: 11px; font-weight: 500;
}

/* --------------------------------------------------------------------------
   4. Kopfzeile
   -------------------------------------------------------------------------- */
#kopf {
  display: flex; align-items: center; gap: 18px;
  flex-shrink: 0; height: var(--header-h);
  padding: 0 max(16px, env(safe-area-inset-right)) 0 max(16px, env(safe-area-inset-left));
  background: var(--surface); border-bottom: 1px solid var(--border);
  z-index: 800;
}
#marke { display: flex; align-items: center; gap: 9px; font-size: 15px; font-weight: 700; letter-spacing: -.2px; }
#marke svg { width: 24px; height: 24px; color: var(--accent); }

#ansicht-tabs { display: flex; gap: 2px; }
#ansicht-tabs button {
  display: flex; align-items: center; gap: 7px;
  padding: 7px 14px; border-radius: var(--radius-sm);
  font-size: 13px; font-weight: 500; color: var(--text-muted);
  transition: background .12s, color .12s;
}
#ansicht-tabs button:hover { background: var(--surface-2); color: var(--text); }
#ansicht-tabs button[aria-pressed='true'] { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
#ansicht-tabs svg { width: 16px; height: 16px; }

#kopf-rechts { margin-left: auto; display: flex; align-items: center; gap: 8px; }
#kopf-stat { font-size: 12px; color: var(--text-muted); }
#key-warnung {
  display: flex; align-items: center; gap: 6px;
  padding: 5px 10px; border-radius: 20px;
  background: var(--danger-soft); color: var(--danger);
  font-size: 11px; font-weight: 600;
}

/* --------------------------------------------------------------------------
   5. Grundgerüst
   -------------------------------------------------------------------------- */
#buehne { display: flex; flex: 1; min-height: 0; }

#seitenleiste {
  display: flex; flex-direction: column;
  width: var(--sidebar-w); flex-shrink: 0;
  background: var(--surface); border-right: 1px solid var(--border);
  z-index: 700;
}
#seitenleiste-inhalt { flex: 1; overflow-y: auto; overscroll-behavior: contain; }

.block { padding: 16px; border-bottom: 1px solid var(--border); }
.block:last-child { border-bottom: none; }
.block > * + * { margin-top: 10px; }

.block-titel {
  display: flex; align-items: center; gap: 8px;
  font-size: 11px; font-weight: 600; letter-spacing: .07em; text-transform: uppercase;
  color: var(--text-faint);
}
.block-titel .zahl { margin-left: auto; font-weight: 500; letter-spacing: 0; text-transform: none; font-size: 11px; }

.leer-hinweis {
  padding: 16px 12px; text-align: center;
  font-size: 12px; line-height: 1.55; color: var(--text-faint);
  background: var(--surface-2); border-radius: var(--radius-sm);
}

/* --------------------------------------------------------------------------
   6. Planer – Ortssuche
   -------------------------------------------------------------------------- */
#suche-huelle { position: relative; }
#suche-treffer {
  position: absolute; top: calc(100% + 4px); left: 0; right: 0; z-index: 50;
  max-height: 260px; overflow-y: auto; padding: 4px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-lg);
}
#suche-treffer button {
  display: block; width: 100%; padding: 8px 10px; text-align: left;
  border-radius: var(--radius-sm); font-size: 13px;
}
#suche-treffer button:hover, #suche-treffer button.aktiv { background: var(--surface-2); }
#suche-treffer .ort-detail { display: block; font-size: 11px; color: var(--text-muted); margin-top: 1px; }

/* --------------------------------------------------------------------------
   7. Planer – Aktivität
   -------------------------------------------------------------------------- */
#aktivitaeten { display: grid; grid-template-columns: repeat(3, 1fr); gap: 5px; }
.aktivitaet {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 11px 4px 9px; border-radius: var(--radius-sm);
  border: 1px solid transparent; background: var(--surface-2);
  font-size: 11px; font-weight: 500; color: var(--text-muted);
  transition: background .12s, color .12s, border-color .12s;
}
.aktivitaet svg { width: 21px; height: 21px; }
.aktivitaet:hover { background: var(--surface-3); color: var(--text); }
.aktivitaet[aria-pressed='true'] {
  background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 600;
}

/* --------------------------------------------------------------------------
   8. Planer – Wegpunkte
   -------------------------------------------------------------------------- */
#wegpunkte { display: flex; flex-direction: column; gap: 4px; }
.wegpunkt {
  display: flex; align-items: center; gap: 8px;
  padding: 4px 4px 4px 2px; border-radius: var(--radius-sm);
  background: var(--surface-2); font-size: 13px;
  transition: background .12s, opacity .12s;
}
.wegpunkt .griff {
  flex-shrink: 0; width: 22px; align-self: stretch; display: grid; place-items: center;
  color: var(--text-faint); font-size: 14px; cursor: grab; touch-action: none; user-select: none;
}
.wegpunkt:hover { background: var(--surface-3); }
.wegpunkt.zieht { opacity: .4; }
.wegpunkt.ziel-oben { box-shadow: inset 0 2px 0 var(--accent); }
.wegpunkt.ziel-unten { box-shadow: inset 0 -2px 0 var(--accent); }
.wegpunkt .marke {
  display: grid; place-items: center; flex-shrink: 0;
  width: 21px; height: 21px; border-radius: 6px;
  font-size: 10px; font-weight: 700; color: #fff;
}
.wegpunkt .bezeichnung { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  text-align: left; padding: 4px 0; }
.wegpunkt .weg {
  flex-shrink: 0; width: 28px; height: 28px; border-radius: 6px;
  display: grid; place-items: center; color: var(--text-faint); font-size: 15px; line-height: 1;
}
.wegpunkt .weg:hover { background: var(--danger-soft); color: var(--danger); }

/* --------------------------------------------------------------------------
   9. Planer – Abschnitte
   -------------------------------------------------------------------------- */
#auswahl-box { padding: 11px; background: var(--surface-2); border-radius: var(--radius-sm); }
#auswahl-box > * + * { margin-top: 9px; }
#auswahl-bereich { display: flex; align-items: center; gap: 7px; font-size: 12px; color: var(--text-muted); }
#auswahl-bereich input { width: 66px; height: 30px; text-align: center; font-size: 12px; }

.sterne { display: flex; gap: 3px; }
.sterne button { font-size: 20px; line-height: 1; color: var(--border-strong); transition: color .1s, transform .1s; }
.sterne button:hover { transform: scale(1.12); }
.sterne button.gefuellt { color: #e8a33d; }

.abschnitt {
  display: flex; align-items: center; gap: 9px;
  padding: 8px 10px; border-radius: var(--radius-sm);
  background: var(--surface-2); font-size: 12px; cursor: pointer;
}
.abschnitt:hover { background: var(--surface-3); }
.abschnitt .punkt { width: 8px; height: 8px; border-radius: 3px; flex-shrink: 0; }
.abschnitt .text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.abschnitt .text small { color: var(--text-muted); }
.abschnitt .weg { flex-shrink: 0; width: 24px; height: 24px; display: grid; place-items: center;
  border-radius: 6px; color: var(--text-faint); font-size: 14px; line-height: 1; }
.abschnitt .weg:hover { color: var(--danger); }

/* Legende ---------------------------------------------------------------- */
#legende { display: flex; flex-wrap: wrap; gap: 4px 10px; }
#legende span { display: flex; align-items: center; gap: 5px; font-size: 11px; color: var(--text-muted); }
#legende i { width: 10px; height: 4px; border-radius: 2px; }

/* --------------------------------------------------------------------------
   10. Kartenbereich
   -------------------------------------------------------------------------- */
#karten-bereich { position: relative; flex: 1; min-width: 0; display: flex; flex-direction: column; }
#karte { flex: 1; min-height: 0; background: var(--surface-3); }

#kennzahlen {
  position: absolute; top: 14px; left: 50%; transform: translateX(-50%);
  display: none; align-items: center; gap: 2px; z-index: 620;
  padding: 8px 6px; border-radius: 100px;
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow);
  white-space: nowrap;
}
#kennzahlen.sichtbar { display: flex; }
#kennzahlen .wert { display: flex; align-items: baseline; gap: 4px; padding: 0 12px; font-size: 14px; font-weight: 600; }
#kennzahlen .wert + .wert { border-left: 1px solid var(--border); }
#kennzahlen .wert small { font-size: 11px; font-weight: 500; color: var(--text-muted); }

#rechnet {
  position: absolute; top: 0; left: 0; right: 0; height: 2px; z-index: 630;
  overflow: hidden; display: none;
}
#rechnet.sichtbar { display: block; }
#rechnet::after {
  content: ''; position: absolute; inset: 0; width: 40%;
  background: var(--accent); animation: laufen 1.1s ease-in-out infinite;
}
@keyframes laufen { 0% { left: -40%; } 100% { left: 100%; } }

/* --------------------------------------------------------------------------
   11. Höhenprofil
   -------------------------------------------------------------------------- */
#profil {
  flex-shrink: 0; height: calc(var(--profil-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  display: flex; flex-direction: column;
  background: var(--surface); border-top: 1px solid var(--border);
  transition: height .18s ease;
}
#profil.zu { height: calc(38px + env(safe-area-inset-bottom)); }
#profil.zu #profil-koerper { display: none; }

#profil-kopf {
  display: flex; align-items: center; gap: 10px;
  height: 38px; padding: 0 14px; flex-shrink: 0;
}
#profil-kopf .titel { font-size: 12px; font-weight: 600; }
#profil-kopf .hinweis { font-size: 11px; color: var(--text-faint); }
#profil-kopf .rechts { margin-left: auto; display: flex; align-items: center; gap: 6px; }

#profil-koerper { position: relative; flex: 1; min-height: 0; }
#profil-leinwand { display: block; width: 100%; height: 100%; touch-action: none; }
#profil-fadenkreuz {
  position: absolute; top: 0; bottom: 0; width: 1px;
  background: var(--text); opacity: .35; pointer-events: none; display: none;
}
#profil-tipp {
  position: absolute; top: 8px; z-index: 5; display: none;
  padding: 5px 9px; border-radius: var(--radius-sm);
  background: var(--text); color: var(--bg);
  font-size: 11px; font-weight: 500; white-space: nowrap; pointer-events: none;
}
#profil-leer {
  position: absolute; inset: 0; display: grid; place-items: center;
  font-size: 12px; color: var(--text-faint);
}

/* --------------------------------------------------------------------------
   12. Bibliothek
   -------------------------------------------------------------------------- */
#bibliothek { flex: 1; min-width: 0; overflow-y: auto; padding: 18px; background: var(--bg); }
#bib-kopf { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
#bib-kopf h2 { font-size: 17px; font-weight: 700; }
#bib-anzahl { font-size: 12px; color: var(--text-muted); }

#bib-gitter { display: grid; grid-template-columns: repeat(auto-fill, minmax(232px, 1fr)); gap: 12px; }

.tour {
  display: flex; flex-direction: column; overflow: hidden; text-align: left;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  transition: border-color .12s, transform .12s, box-shadow .12s;
}
@media (hover: hover) {
  .tour:hover { border-color: var(--border-strong); transform: translateY(-2px); box-shadow: var(--shadow); }
}
.tour .vorschau { height: 116px; background: var(--surface-2); border-bottom: 1px solid var(--border); position: relative; }
.tour .vorschau svg { display: block; width: 100%; height: 100%; }
.tour .stern-marke { position: absolute; top: 7px; right: 8px; font-size: 13px; color: #e8a33d; }
.tour .inhalt { padding: 10px 12px 12px; }
.tour .name { font-size: 13px; font-weight: 600; line-height: 1.35; margin-bottom: 6px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.tour .zahlen { display: flex; flex-wrap: wrap; gap: 4px 10px; font-size: 11px; color: var(--text-muted); }
.tour .zahlen b { font-weight: 600; color: var(--text); }

#bib-leer { display: grid; place-items: center; gap: 10px; padding: 70px 20px; text-align: center; color: var(--text-muted); }
#bib-leer svg { width: 42px; height: 42px; color: var(--text-faint); }

/* Detailtafel ------------------------------------------------------------ */
#tafel {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 900;
  width: min(460px, 100vw); transform: translateX(102%);
  display: flex; flex-direction: column;
  background: var(--surface); border-left: 1px solid var(--border);
  box-shadow: var(--shadow-lg); transition: transform .22s ease;
}
#tafel.offen { transform: none; }
/* eigene Ebene: sonst liegen die Kartenebenen ueber dem Schliessen-Knopf */
#tafel-karte { position: relative; z-index: 0; height: 210px; flex-shrink: 0; background: var(--surface-2); }
#tafel-zu {
  position: absolute; top: max(12px, env(safe-area-inset-top)); right: 14px; z-index: 10;
  width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center;
  background: var(--surface); box-shadow: var(--shadow); font-size: 15px;
}
#tafel-koerper { flex: 1; overflow-y: auto; padding: 16px; }
#tafel-koerper > * + * { margin-top: 14px; }
#tafel-titel { font-size: 19px; font-weight: 700; line-height: 1.25; }
#tafel-zahlen { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
#tafel-zahlen .kachel { padding: 10px 12px; background: var(--surface-2); border-radius: var(--radius-sm); }
#tafel-zahlen .kachel .label { font-size: 10px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-faint); }
#tafel-zahlen .kachel .wert { font-size: 17px; font-weight: 700; margin-top: 2px; }
#tafel-text { font-size: 13px; line-height: 1.6; color: var(--text-muted); white-space: pre-wrap; }
#tafel-marken { display: flex; flex-wrap: wrap; gap: 5px; }
#tafel-fuss { display: flex; gap: 6px; padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--border); flex-shrink: 0; }

/* --------------------------------------------------------------------------
   13. Dialog
   -------------------------------------------------------------------------- */
.hintergrund {
  position: fixed; inset: 0; z-index: 1000;
  display: none; align-items: center; justify-content: center; padding: 20px;
  background: rgba(16, 18, 15, .5); backdrop-filter: blur(2px);
}
.hintergrund.offen { display: flex; }
.dialog {
  width: 100%; max-width: 440px; max-height: 88vh; overflow-y: auto;
  background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
}
.dialog-kopf { display: flex; align-items: center; gap: 10px; padding: 16px 18px 0; }
.dialog-kopf h3 { font-size: 16px; font-weight: 700; }
.dialog-kopf button { margin-left: auto; color: var(--text-faint); font-size: 16px; }
.dialog-koerper { padding: 16px 18px; }
.dialog-koerper > * + * { margin-top: 12px; }
.dialog-fuss { display: flex; justify-content: flex-end; gap: 8px; padding: 0 18px 18px; }
.paar { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

#ablage {
  padding: 24px 16px; text-align: center;
  border: 1.5px dashed var(--border-strong); border-radius: var(--radius);
  font-size: 13px; color: var(--text-muted); cursor: pointer;
  transition: border-color .12s, background .12s, color .12s;
}
#ablage:hover, #ablage.bereit { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
#ablage-liste { font-size: 12px; color: var(--text-muted); }

/* Geräte verknüpfen */
#geraete-qr { display: grid; justify-items: center; gap: 6px; text-align: center; }
#geraete-qr svg { width: 210px; height: 210px; border-radius: var(--radius-sm); }
#geraete-qr .code { font-size: 22px; font-weight: 700; letter-spacing: .12em; }
#geraete-qr small { color: var(--text-muted); }
#geraete-liste { display: flex; flex-direction: column; gap: 4px; }
#ablage-liste div { padding: 2px 0; }

/* --------------------------------------------------------------------------
   14. Meldungen
   -------------------------------------------------------------------------- */
#meldungen {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  z-index: 1500; display: flex; flex-direction: column; gap: 8px; align-items: center;
  pointer-events: none;
}
.meldung {
  padding: 9px 16px; border-radius: 100px;
  background: var(--text); color: var(--bg);
  font-size: 13px; font-weight: 500; box-shadow: var(--shadow-lg);
  animation: einblenden .22s ease;
}
.meldung.fehler { background: var(--danger); color: #fff; }
@keyframes einblenden { from { opacity: 0; transform: translateY(8px); } }

/* --------------------------------------------------------------------------
   15. Leaflet-Anpassungen
   -------------------------------------------------------------------------- */
.leaflet-container { font-family: var(--font); background: var(--surface-3); }
.leaflet-control-attribution {
  background: rgba(255, 255, 255, .72) !important; font-size: 10px !important; color: var(--text-muted) !important;
}
:root[data-theme='dark'] .leaflet-control-attribution { background: rgba(0, 0, 0, .5) !important; }

.leaflet-bar, .leaflet-control-layers {
  border: 1px solid var(--border) !important; border-radius: var(--radius-sm) !important;
  box-shadow: var(--shadow) !important; overflow: hidden; background: var(--surface) !important;
}
.leaflet-bar a, .leaflet-bar a:hover {
  width: 32px !important; height: 32px !important; line-height: 32px !important;
  background: var(--surface) !important; color: var(--text) !important;
  border-bottom: 1px solid var(--border) !important;
}
.leaflet-bar a:hover { background: var(--surface-2) !important; }
.leaflet-bar a.leaflet-disabled { color: var(--text-faint) !important; background: var(--surface-2) !important; }
.leaflet-control-layers-toggle { background-color: var(--surface) !important; }
.leaflet-control-layers-expanded { padding: 8px 12px 8px 8px !important; color: var(--text) !important; font-size: 13px; }
.leaflet-control-layers-selector { margin-right: 6px; }

.karten-knopf {
  display: grid !important; place-items: center;
  width: 32px; height: 32px; font-size: 15px;
  background: var(--surface) !important; color: var(--text) !important; text-decoration: none !important;
}
.karten-knopf.an { background: var(--accent) !important; color: var(--accent-text) !important; }
.karten-knopf.leaflet-disabled { opacity: .45; }

.leaflet-popup-content-wrapper { border-radius: var(--radius) !important; background: var(--surface); color: var(--text); }
.leaflet-popup-tip { background: var(--surface); }
.leaflet-popup-content { margin: 10px 12px !important; font-size: 13px; }
.leaflet-tooltip { border: 1px solid var(--border) !important; background: var(--surface) !important; color: var(--text) !important;
  border-radius: var(--radius-sm) !important; box-shadow: var(--shadow) !important; font-size: 12px; }
.leaflet-tooltip-left::before { border-left-color: var(--border) !important; }
.leaflet-tooltip-right::before { border-right-color: var(--border) !important; }

:root[data-theme='dark'] .leaflet-tile-pane { filter: brightness(.82) saturate(.85); }

.wp-symbol {
  display: grid; place-items: center;
  width: 100%; height: 100%; border-radius: 8px;
  border: 2px solid var(--surface); box-shadow: 0 2px 6px rgba(0, 0, 0, .3);
  color: #fff; font-size: 10px; font-weight: 700; font-family: var(--font);
}

/* Favoriten */
.fav-symbol {
  display: grid; place-items: center;
  width: 28px; height: 28px; border-radius: 50%;
  border: 2px solid #fff; box-shadow: 0 2px 6px rgba(0, 0, 0, .35); color: #fff;
}
.fav-symbol svg { width: 15px; height: 15px; }
.fav-formular, .fav-info { display: flex; flex-direction: column; gap: 8px; }
.fav-info small { color: var(--text-muted); }
.fav-info p { margin: 0; color: var(--text-muted); }
.fav-arten button { padding: 0 4px; }
/* Langer Druck soll einen Favoriten anlegen, nicht das iOS-Kontextmenü öffnen. */
#karte { -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }
/* Sonst lässt Safari in den Popup-Feldern nichts eintippen. */
#karte input, #karte textarea { -webkit-user-select: text; user-select: text; }

/* --------------------------------------------------------------------------
   16. Touch (iPad, iPhone): grössere Tippflächen, keine Zoom-Sprünge
   -------------------------------------------------------------------------- */
#blatt-griff { display: none; }

@media (pointer: coarse) {
  .knopf { height: 44px; }
  .knopf--klein { height: 40px; font-size: 13px; }
  .knopf--symbol { width: 44px; }
  /* unter 16 px zoomt Safari beim Antippen eines Feldes hinein */
  .feld, textarea.feld, select.feld { font-size: 16px; }
  .feld { height: 44px; }
  select.feld { background-position: calc(100% - 15px) 19px, calc(100% - 10px) 19px; }
  #auswahl-bereich input { height: 40px; width: 72px; font-size: 16px; }
  .umschalter button { padding: 10px 6px; font-size: 13px; }
  #ansicht-tabs button { padding: 10px 14px; }
  #suche-treffer button { padding: 12px 10px; }
  .wegpunkt { min-height: 48px; }
  .wegpunkt .griff { width: 34px; font-size: 18px; }
  .wegpunkt .weg { width: 40px; height: 40px; font-size: 17px; }
  .abschnitt { min-height: 46px; padding: 4px 4px 4px 10px; font-size: 13px; }
  .abschnitt .weg { width: 40px; height: 40px; font-size: 16px; }
  .sterne { gap: 8px; }
  .sterne button { font-size: 30px; padding: 2px; }
  input[type='range'] { height: 6px; }
  input[type='range']::-webkit-slider-thumb { width: 26px; height: 26px; }
  #tafel-zu { width: 44px; height: 44px; }
  .leaflet-bar a, .leaflet-bar a:hover, .karten-knopf {
    width: 44px !important; height: 44px !important; line-height: 44px !important; font-size: 19px;
  }
  .leaflet-touch .leaflet-control-layers-toggle { width: 44px; height: 44px; }
  .leaflet-popup-content .knopf--klein { height: 42px; }
}

/* --------------------------------------------------------------------------
   17. Schmale Fenster (iPhone, iPad mini hochkant): Seitenleiste als Blatt
       von unten, die Karte bekommt die ganze Fläche
   -------------------------------------------------------------------------- */
@media (max-width: 820px) {
  :root { --profil-h: 120px; }
  #kopf { gap: 10px; }
  #kopf-stat, #marke span { display: none; }
  #tafel { width: 100vw; }

  #buehne { position: relative; padding-bottom: calc(var(--griff-h) + env(safe-area-inset-bottom)); }
  /* eigene Ebene, damit Kartenknöpfe nicht über dem Blatt liegen */
  #karten-bereich { z-index: 0; }

  #seitenleiste {
    position: absolute; left: 0; right: 0; bottom: 0; z-index: 750;
    width: auto; height: min(65%, 600px);
    border-right: none; border-top: 1px solid var(--border);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    box-shadow: 0 -6px 24px rgba(0, 0, 0, .14);
    transform: translateY(calc(100% - var(--griff-h) - env(safe-area-inset-bottom)));
    transition: transform .25s ease;
  }
  #seitenleiste.offen { transform: none; }
  #seitenleiste-inhalt { padding-bottom: env(safe-area-inset-bottom); }
  #profil { padding-bottom: 0; height: var(--profil-h); }
  #profil.zu { height: 38px; }

  #blatt-griff {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
    flex-shrink: 0; height: var(--griff-h); width: 100%;
    font-size: 13px; font-weight: 600; color: var(--text-muted);
    border-bottom: 1px solid var(--border); touch-action: none;
  }
  #blatt-griff .strich { width: 38px; height: 5px; border-radius: 3px; background: var(--border-strong); }

  /* links oben, rechts bleibt Platz fuer die Kartenknoepfe */
  #kennzahlen { left: 8px; top: 8px; transform: none; padding: 6px 0; max-width: calc(100% - 68px); }
  #kennzahlen .wert { padding: 0 7px; font-size: 12px; }
  #kennzahlen .wert small { display: none; }
  #profil-kopf .hinweis { display: none; }
}

/* Querformat auf dem iPhone: wenig Höhe */
@media (max-height: 500px) {
  :root { --header-h: 44px; --profil-h: 76px; --griff-h: 40px; --sidebar-w: 310px; }
  #seitenleiste { height: 88%; }
  #blatt-griff { flex-direction: row; gap: 10px; }
  #profil-kopf, #profil.zu { height: 32px; }
  /* Kartenknoepfe brechen in eine zweite Spalte um, statt unten abgeschnitten zu werden */
  .leaflet-top.leaflet-right {
    bottom: 0; display: flex; flex-direction: column; flex-wrap: wrap-reverse; align-content: flex-start;
  }
  .leaflet-top.leaflet-right .leaflet-control { margin-top: 6px; }
  #kennzahlen { left: 8px; top: 8px; transform: none; padding: 6px 0; max-width: calc(100% - 120px); overflow: hidden; }
  #kennzahlen .wert { padding: 0 7px; font-size: 12px; }
  #kennzahlen .wert small { display: none; }
}
