:root { --rahmenabstand: 4px; }

html, body, .kartenrahmen, #map { width: 100%; height: 100%; margin: 0; }
body {
  box-sizing: border-box;
  height: 100dvh;
  padding: var(--rahmenabstand);
  overflow: hidden;
  background: var(--hintergrund);
}
.kartenrahmen {
  position: relative;
  box-sizing: border-box;

  border: 1px solid var(--linie);

  border-radius: 4px;
  overflow: hidden;
  box-shadow: 0 3px 12px #203e361a;
}
#map { background: var(--karte-papier); font-family: inherit; color: var(--ink); }

@media (max-width: 540px), (max-height: 560px) {
  :root { --rahmenabstand: 2px; }
  .kartenrahmen { border-radius: 3px; }
}

.leaflet-top .leaflet-control { margin-top: 9px; }
.leaflet-left .leaflet-control { margin-left: 14px; }
.leaflet-right .leaflet-control { margin-right: 14px; }
.leaflet-top.leaflet-left .leaflet-control-zoom,
.leaflet-top.leaflet-right .leaflet-control { margin-top: 14px; }
.leaflet-bottom .leaflet-control { margin-bottom: 13px; }
.leaflet-bottom .leaflet-control-attribution { margin: 0; }

.leaflet-touch .leaflet-bar, .leaflet-bar,
.leaflet-touch .leaflet-control-layers, .leaflet-control-layers {
  border: 1px solid var(--border);
  border-radius: 3px;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.leaflet-bar { overflow: hidden; }
.leaflet-bar a, .leaflet-touch .leaflet-bar a {
  width: 35px;
  height: 35px;
  line-height: 35px;
  color: var(--ink);
  background: var(--surface);
  border-bottom-color: var(--border);
}
.leaflet-bar a:hover, .leaflet-bar a:focus-visible { background: var(--weich); }
.leaflet-bar a.leaflet-disabled { color: #777773; background: #f4f4f2; }

.leaflet-control-zoom a { font-size: 21px; font-weight: 600; }
.startknopf svg, .gemeindeknopf svg, .titelblattknopf svg { vertical-align: middle; }
.leaflet-control-layers-toggle, .leaflet-touch .leaflet-control-layers-toggle {
  width: 42px;
  height: 42px;
  background-size: 21px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%232f594d' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m12 3 9 5-9 5-9-5 9-5ZM3 12l9 5 9-5M3 16l9 5 9-5'/%3E%3C/svg%3E");
}
.leaflet-control-layers-expanded { padding: 8px 10px; }
.leaflet-control-layers-expanded label { padding: 3px 0; color: var(--ink); font-size: 13px; }
.leaflet-control-layers-selector { accent-color: var(--accent); }

.kartenlegende {
  box-sizing: border-box;
  width: min(225px, 52vw);
  padding: 11px 13px;
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--border);
  border-radius: 3px;
  box-shadow: var(--shadow);
  font-size: 13px;
}
.legendentitel { margin: 0 0 10px; color: var(--accent); font-family: Georgia, serif; font-size: 20px; line-height: 1.2; font-weight: 400; }
.legendenzeile { display: flex; align-items: center; gap: 8px; margin-top: 4px; }
.legendenzeile svg { flex: 0 0 19px; width: 19px; height: 19px; }

.gemeinde-legende { line-height: 1.3; margin-top: 7px; }
.gemeinde-legende svg { flex-basis: 27px; width: 27px; height: 18px; }
.legendenhintergrund { margin-top: 9px; border-top: 1px solid var(--border); padding-top: 6px; }
.legendenhintergrund span, .legendenhintergrund strong { display: block; }
.legendenhintergrund span { color: var(--muted); font-size: 11px; }
.legendenhintergrund strong { margin-top: 2px; font-size: 13px; }

.massstab-box {
  padding: 6px 9px 7px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 3px;
  box-shadow: var(--shadow);
}
.massstab-box .leaflet-control-scale-line { background: transparent; color: var(--ink); border-color: #666663; }
.leaflet-control-attribution { font-size: 10px; }

.baumsymbol { background: none; border: 0; }
.baumsymbol svg, .kartenlegende svg { display: block; }

.tree-popup-shell .leaflet-popup-content-wrapper, .tree-popup-shell .leaflet-popup-tip { background: var(--surface); color: var(--ink); }
.tree-popup-shell .leaflet-popup-content-wrapper { border-radius: 3px; box-shadow: var(--shadow); }
.tree-popup-shell .leaflet-popup-content { margin: 12px 15px; }

.einzelbaum-popup .leaflet-popup-content { height: auto; overflow: visible; }

.baumpopup {
  box-sizing: border-box;
  width: min(260px, calc(100vw - 84px));
  max-width: 100%;
  overflow-wrap: anywhere;
}
.baumname {
  display: block;
  margin-bottom: 4px;
  padding-right: 11px;
  font-family: Georgia, serif;
  font-size: 22px;
  font-weight: 400;
  line-height: 1.15;
  letter-spacing: -.015em;
}
.baumpopup p { margin: 5px 0; }
.baumpopup .baumtyp {
  display: inline-block;
  padding: 3px 7px;
  border-radius: 3px;
  background: var(--weich);
  color: var(--akzent-dunkel);
  font-size: 11px;
  font-weight: 650;
}
.baumfoto { margin: 8px 0 0; }

.baumfoto img {
  display: block;
  width: 100%;
  height: min(144px, max(48px, calc(100vh - 245px)));
  height: min(144px, max(48px, calc(100dvh - 245px)));
  object-fit: contain;
  background: var(--karte-papier);
  border-radius: 4px;
}

.baumfoto figcaption {
  margin-top: 8px;
  padding-top: 6px;
  border-top: 1px solid var(--border);
  font-size: 10px;
  line-height: 1.45;
  color: var(--muted);
  overflow-wrap: anywhere;
}
.baumfoto figcaption i { font-size: 12px; color: var(--ink); }

.baumfoto .bildzeile {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 2px 8px;
  margin-top: 4px;
}
.baumfoto .bildzeile span, .baumfoto .bildzeile > a { min-width: 0; max-width: 100%; }
.baumfoto a { color: var(--akzent); }

@media (max-width: 480px) {
  .leaflet-top.leaflet-left .leaflet-control-zoom,
  .leaflet-top.leaflet-right .leaflet-control { margin-top: 9px; }
  .leaflet-left .leaflet-control { margin-left: 9px; }
  .leaflet-right .leaflet-control { margin-right: 9px; }
  .leaflet-bottom .leaflet-control-attribution { margin: 0; }
  .kartenlegende { padding: 8px 10px; font-size: 12px; }
  .legendentitel { font-size: 18px; }
  .legendenhintergrund strong { font-size: 12px; }
}

.baumgruppe { background: transparent; border: 0; }
.baumgruppe div {
  width: 100%;
  height: 100%;
  box-sizing: border-box;
  display: grid;
  place-items: center;
  border: 3px solid rgba(255, 255, 255, .85);
  border-radius: 50%;
  color: #fff;
  background: var(--akzent);
  box-shadow: 0 0 4px #0006;
  font: 700 14px/1 system-ui, sans-serif;
}
.baumgruppe:focus-visible { outline: 2px solid var(--akzent-dunkel); outline-offset: 2px; }

.creditsknopf a { font-size: 17px; font-weight: 700; color: var(--accent); }

@media (pointer: coarse) {
  .leaflet-bar a, .leaflet-touch .leaflet-bar a { width: 44px; height: 44px; line-height: 44px; }
  .leaflet-control-layers-toggle, .leaflet-touch .leaflet-control-layers-toggle { width: 44px; height: 44px; }
}

.baumsuche { display: grid; justify-items: end; gap: 7px; }
.baumsuche [hidden] { display: none; }

.suchreset {
  box-sizing: border-box;
  width: min(270px, calc(100vw - 78px));
  min-height: 36px;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 3px;
  background: var(--surface);
  color: var(--accent);
  font: inherit;
  font-weight: 600;
  overflow-wrap: anywhere;
  box-shadow: var(--shadow);
  cursor: pointer;
}
.suchreset:hover { background: var(--weich); }
.suchknopf {
  display: grid;
  place-items: center;
  width: 37px;
  height: 37px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 3px;
  background: var(--surface);
  color: var(--accent);
  box-shadow: var(--shadow);
  cursor: pointer;
}

.suchfeld {
  box-sizing: border-box;
  width: min(270px, calc(100vw - 78px));
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 3px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow);
}
.suchfeld label { display: block; margin-bottom: 5px; font-weight: 700; }
.suchfeld input {
  box-sizing: border-box;
  width: 100%;
  min-height: 34px;
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 5px 7px;
  font: inherit;
}
.suchstatus { margin: 6px 0 0; color: var(--muted); }

.suchtreffer {
  max-height: min(210px, 32vh);
  overflow-y: auto;
  margin: 0;
  padding: 0;
  list-style: none;
}
.suchtreffer button {
  width: 100%;
  min-height: 34px;
  border: 0;
  border-top: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink);
  padding: 5px;
  text-align: left;
  font: inherit;
  cursor: pointer;
}
.suchknopf:hover, .suchtreffer button:hover { background: var(--weich); }
.baumsuche :focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
@media (pointer: coarse) {
  .suchknopf { width: 46px; height: 46px; }
  .suchtreffer button { min-height: 44px; }
  .suchreset { min-height: 44px; }
  .suchfeld input { min-height: 44px; font-size: 16px; }
}

.leaflet-control-attribution { background: var(--surface); color: var(--muted); }
.leaflet-control-attribution a { color: var(--accent); }
.leaflet-container a.leaflet-popup-close-button { color: var(--muted); }

.legendenhinweis { margin: 10px 0 0; color: var(--muted); font-size: 11px; line-height: 1.4; }
.leaflet-cluster-spider-leg { filter: drop-shadow(0 0 1px #fff); }
