/* Tree map (templates/index.html); colours and glass effect: theme.css */
/* overscroll-behavior: none/contain - verhindert das browsereigene "Pull-to-Refresh" (nach unten ziehen
   am oberen Bildschirmrand lädt sonst die Seite neu, siehe Chat) - kollidiert sonst mit dem Ziehen am
   Sheet-Handle nach unten, siehe sheet-handle touch-action:none weiter unten für die zweite Absicherung */
html { overscroll-behavior: none; }
html, body { margin: 0; height: 100%; }
#map { position: absolute; inset: 0; }

/* ---- Hinweis "Tippe auf einen Baum" (einmalig, s. Chat) ---- */
.tap-hint { position: fixed; top: 38%; left: 50%; transform: translateX(-50%); z-index: 4; max-width: calc(100vw - 32px);
            background: rgba(0, 0, 0, .82); color: var(--ink); border: 1px solid var(--glass-border);
            border-radius: 999px; padding: 9px 18px; font-size: 13px; display: flex; align-items: center; gap: 8px;
            box-shadow: var(--shadow); pointer-events: none; transition: opacity .4s ease; white-space: nowrap; }
.tap-hint[hidden] { display: none; }   /* [hidden] vs .tap-hint: gleiche Spezifität, s. Chat/.table-view */
.tap-hint.fade { opacity: 0; }
.tap-hint .hand { font-size: 18px; display: inline-block; animation: tap-hint-bounce 1.1s ease-in-out infinite; }
@keyframes tap-hint-bounce { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(5px); } }
@media (prefers-reduced-motion: reduce) { .tap-hint .hand { animation: none; } }
@media (max-width: 600px) { .tap-hint { top: 30%; font-size: 12px; white-space: normal; text-align: center; } }

/* ---- Umschalter Karte/Tabelle (s. Chat) ---- */
.view-switch { position: fixed; top: 12px; left: 50%; transform: translateX(-50%); z-index: 7;
               display: flex; background: rgba(0, 0, 0, .82); border: 1px solid var(--glass-border);
               border-radius: 999px; box-shadow: var(--shadow); padding: 3px; gap: 2px; }
/* [hidden] vs .view-switch: gleiche Spezifität, s. Chat/.table-view - sonst bliebe der Umschalter im
   Vollbild trotz hidden sichtbar */
.view-switch[hidden] { display: none; }
.view-switch button { border: 0; background: none; color: var(--muted); font: inherit; font-size: 12px;
                      font-weight: 600; padding: 7px 16px; border-radius: 999px; cursor: pointer; }
.view-switch button.active { background: var(--accent-mid); color: var(--ink); }

/* ---- Hinweis "Neue Version verfügbar" (s. Chat): erscheint schon auf der Ladeseite (Foto), sobald
   map.js lädt - z-index muss daher über #loading (20) liegen, sonst unsichtbar darunter verdeckt. */
.update-banner { position: fixed; inset: 0; z-index: 21; display: flex; align-items: center; justify-content: center;
                 padding: 16px; background: rgba(2, 12, 7, .72); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); }
/* [hidden] vs .update-banner: gleiche Spezifität, s. Chat/.table-view - sonst bliebe der Hinweis immer sichtbar */
.update-banner[hidden] { display: none; }
.update-box { max-width: 360px; text-align: center; color: var(--ink); padding: 28px 24px; border-radius: var(--radius);
              background: var(--glass-strong); border: 1px solid var(--glass-border); box-shadow: var(--shadow); }
.update-icon { font-size: 40px; margin-bottom: 6px; }
.update-app { font-size: 13px; letter-spacing: .04em; color: var(--muted); margin-bottom: 10px; }
.update-box h2 { margin: 0 0 4px; font-size: 20px; }
.update-version { font-size: 13px; font-weight: 600; color: var(--accent); margin-bottom: 12px; }
.update-version:empty { display: none; }
.update-box p { margin: 0 0 18px; font-size: 14px; color: var(--muted); line-height: 1.45; }
.update-box button { border: 0; background: var(--accent-strong); color: #fff; font: inherit; font-weight: 600;
                     font-size: 15px; padding: 10px 28px; border-radius: 999px; cursor: pointer; }
.update-box button:hover { filter: brightness(1.1); }

/* ---- Tabellenansicht (zweite Ansicht statt Karte, s. Chat) ---- */
.table-view { position: fixed; inset: 0; z-index: 3; display: flex; flex-direction: column;
              background: #03140b; padding-top: 56px; }   /* Platz für .view-switch oben */
/* [hidden] und .table-view haben dieselbe CSS-Spezifität - ohne diese Regel gewinnt die spätere
   (.table-view mit display:flex) und das hidden-Attribut wird wirkungslos (s. Chat: Tabelle lag
   immer sichtbar über der Karte) */
.table-view[hidden] { display: none; }
.table-toolbar { flex: none; display: flex; flex-wrap: wrap; align-items: center; gap: 14px;
                 padding: 10px 16px; border-bottom: 1px solid var(--glass-border); font-size: 13px; }
.table-toolbar-label { color: var(--muted); }
.table-toolbar label { display: flex; align-items: center; gap: 6px; cursor: pointer; }
.table-scroll { flex: 1 1 auto; overflow: auto; -webkit-overflow-scrolling: touch; }
#tree-table { width: 100%; border-collapse: collapse; font-size: 13px; white-space: nowrap; }
#tree-table thead th { position: sticky; top: 0; background: #03140b; text-align: left; font-weight: 600;
                       padding: 10px 14px; border-bottom: 1px solid var(--glass-border); cursor: pointer;
                       user-select: none; z-index: 1; }
#tree-table thead th::after { content: ""; display: inline-block; width: 12px; margin-left: 4px; color: var(--muted); }
#tree-table thead th[aria-sort="ascending"]::after { content: "▲"; font-size: 9px; }
#tree-table thead th[aria-sort="descending"]::after { content: "▼"; font-size: 9px; }
#tree-table tbody td { padding: 8px 14px; border-bottom: 1px solid rgba(255,255,255,.06); }
/* Zeile klickbar (s. Chat): öffnet den Baum-Details-Slider wie ein Klick auf der Karte */
#tree-table tbody tr { cursor: pointer; }
#tree-table tbody tr:hover { background: var(--accent-soft); }
#tree-table tbody tr:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
#tree-table td.num, #tree-table th[data-sort="age"], #tree-table th[data-sort="height"],
#tree-table th[data-sort="girth"] { text-align: right; }
/* Zahlenspalten-Kopfzeilen dürfen umbrechen (s. Chat: "Stammumfang" als ein Wort zog sonst die ganze
   Spalte in die Breite, obwohl die Werte selbst kurz sind) - die Werte (td) bleiben einzeilig. */
#tree-table th[data-sort="age"], #tree-table th[data-sort="height"], #tree-table th[data-sort="girth"] {
  white-space: normal; max-width: 70px;
}
/* Name- und Standort-Spalte: schmaler und bei Bedarf zweizeilig statt die Tabelle in die Breite zu
   ziehen (s. Chat) - max-width allein reicht bei table-layout:auto nicht (die Spalte wird trotzdem am
   längsten Inhalt bemessen), daher zusätzlich eine feste width als Obergrenze. */
#tree-table th.col-name, #tree-table td.col-name,
#tree-table th[data-col="location"], #tree-table td[data-col="location"] {
  width: 110px; max-width: 110px; white-space: normal; overflow-wrap: break-word; line-height: 1.25;
}
.table-loading { display: flex; align-items: center; justify-content: center; gap: 8px;
                 text-align: center; color: var(--muted); padding: 24px !important; }
.table-loading .spinner { width: 13px; height: 13px; border: 2px solid var(--glass-border); border-top-color: var(--accent);
                          border-radius: 50%; animation: popup-spin .8s linear infinite; flex: none; }
/* ---- Paging (s. Chat): zeigt immer nur eine Seite der Tabelle im DOM, Umblättern sortiert nicht neu ---- */
.table-pager { flex: none; display: flex; align-items: center; justify-content: center; gap: 14px;
               padding: 10px 16px; border-top: 1px solid var(--glass-border); font-size: 13px; color: var(--muted); }
/* [hidden] vs .table-pager: gleiche Spezifität, s. Chat/.table-view - sonst bliebe die Leiste immer sichtbar */
.table-pager[hidden] { display: none; }
.table-pager button { border: 1px solid var(--glass-border); background: rgba(255,255,255,.06); color: var(--ink);
                      font: inherit; font-size: 16px; line-height: 1; width: 32px; height: 32px; border-radius: 8px;
                      cursor: pointer; }
.table-pager button:disabled { opacity: .35; cursor: default; }
.table-pager button:not(:disabled):hover { background: var(--accent-soft); }
/* Spalten-Sichtbarkeit: eine Klasse pro ausgeblendeter Spalte auf .table-view, trifft th+td zugleich */
.table-view.hide-location [data-col="location"], .table-view.hide-age [data-col="age"],
.table-view.hide-height [data-col="height"], .table-view.hide-girth [data-col="girth"] { display: none; }
/* ---- Ansicht "In der Nähe" (dritter Reiter, s. Chat): Karten pro Baum, sortiert nach Entfernung u.a. ---- */
.nearby-view { position: fixed; inset: 0; z-index: 3; display: flex; flex-direction: column;
               background: #03140b; padding-top: 56px; }
.nearby-view[hidden] { display: none; }   /* [hidden] vs .nearby-view: gleiche Spezifität, s. Chat/.table-view */
.nearby-toolbar { flex: none; display: flex; flex-wrap: wrap; align-items: center; gap: 10px 18px;
                  padding: 10px 16px; border-bottom: 1px solid var(--glass-border); font-size: 13px; }
.nearby-group { display: flex; align-items: center; gap: 6px; }
.nearby-label { color: var(--muted); }
.nearby-radius { flex: 1 1 220px; max-width: 360px; }
.nearby-radius input[type=range] { flex: 1; min-width: 80px; accent-color: var(--accent); }
.nearby-radius-value { flex: none; min-width: 52px; text-align: right; font-weight: 600; color: var(--accent); }
.nearby-toolbar select { font: inherit; color: var(--ink); background: rgba(255,255,255,.06);
                         border: 1px solid var(--glass-border); border-radius: 8px; padding: 5px 8px; }
.nearby-toolbar select option { color: #000; }
.nearby-scroll { flex: 1 1 auto; overflow: auto; -webkit-overflow-scrolling: touch; padding: 12px 16px 24px; }
.nearby-hint { max-width: 420px; margin: 40px auto; text-align: center; color: var(--muted); line-height: 1.45; }
.nearby-hint[hidden] { display: none; }
.nearby-hint-icon { font-size: 40px; margin-bottom: 8px; }
.nearby-hint strong, .nearby-hint em { color: var(--ink); }
.nearby-hint button, .nearby-more { border: 1px solid var(--glass-border); background: var(--accent-soft); color: var(--ink);
                                    font: inherit; padding: 9px 16px; border-radius: 10px; cursor: pointer; margin-top: 10px; }
.nearby-more { display: block; margin: 14px auto 0; }
.nearby-more[hidden] { display: none; }
.nearby-hint button:hover, .nearby-more:hover { filter: brightness(1.15); }
.nearby-status { color: var(--muted); font-size: 13px; margin: 0 0 10px; }
.nearby-status[hidden] { display: none; }
.nearby-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 8px; }
.nearby-card { display: flex; align-items: stretch; background: rgba(255,255,255,.05); border: 1px solid var(--glass-border);
               border-radius: 12px; overflow: hidden; }
.nearby-card:hover { background: var(--accent-soft); }
.nearby-open { flex: 1; min-width: 0; display: flex; align-items: center; padding: 8px 12px; text-align: left;
               font: inherit; color: var(--ink); background: none; border: 0; cursor: pointer; }
.nearby-open:focus-visible, .nearby-map:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.nearby-map { flex: none; width: 66px; display: flex; flex-direction: column; align-items: center; justify-content: center;
              gap: 1px; padding: 6px 4px; color: var(--accent); font: inherit;
              background: none; border: 0; border-right: 1px solid var(--glass-border); cursor: pointer; }
.nearby-map:hover { background: var(--accent-mid); }
.nearby-dist { text-align: center; font-size: 17px; font-weight: 700; color: var(--accent); line-height: 1.1; }
.nearby-dist small { font-size: 11px; font-weight: 400; color: var(--muted); margin-left: 2px; }
.nearby-main { min-width: 0; flex: 1; display: block; }
.nearby-name { display: block; font-weight: 600; overflow-wrap: anywhere; }
.nearby-species { display: block; font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }
.nearby-facts { display: block; margin-top: 2px; font-size: 12px; color: var(--muted); }
.nearby-facts span + span::before { content: " · "; }
.nearby-lost { color: var(--danger); }
@media (max-width: 600px) {
  .nearby-view { padding-top: 50px; }
  .nearby-list { grid-template-columns: 1fr; }
  .nearby-toolbar { padding: 8px 12px; gap: 8px 12px; }
  .nearby-scroll { padding: 10px 12px 24px; }
}
@media (max-width: 600px) {
  .table-view { padding-top: 50px; }
  .view-switch button { padding: 6px 13px; font-size: 11px; }
  #tree-table { font-size: 12px; }
  #tree-table thead th, #tree-table tbody td { padding: 7px 10px; }
}

/* ---- bottom sheet ("Bäume" overlay + marker details, see map.js) ---- */
/* fixed to the bottom, centred with a max-width on wide screens (so it doesn't stretch edge-to-edge on
   desktop), full-width on narrow ones since 100% of the viewport is already narrow there - one rule set
   covers every screen size, no separate mobile block needed. Floats OVER the fullscreen map (#map stays
   position:absolute;inset:0, completely unaffected) - height is driven by map.js (drag handle, clamped
   to [sheet min, 25% of the viewport height]), not by content, so .sheet-body scrolls internally. */
.sheet { position: fixed; left: 50%; bottom: 0; transform: translateX(-50%); width: 100%; max-width: 640px;
         z-index: 5; display: flex; flex-direction: column; border-radius: 16px 16px 0 0; overflow: hidden;
         box-shadow: 0 -10px 30px rgba(0,0,0,.35); transition: height .18s ease;
         background: rgba(0, 0, 0, .88);   /* schwarzer statt grünlicher Glas-Hintergrund, s. Chat */
         /* kein Weichzeichner mehr (von .glass geerbt) - bei fast deckendem Schwarz kaum sichtbar, aber
            dauerhaft über der WebGL-Karte sehr teuer zu rendern (s. Chat: Speicherproblem auf altem iOS) */
         -webkit-backdrop-filter: none; backdrop-filter: none; }
.sheet[hidden] { display: none; }   /* [hidden] vs .sheet: gleiche Spezifität, s. Chat/.table-view */
.sheet.dragging { transition: none; }   /* no easing while the finger/pointer is actively moving it */
.sheet-handle { flex: none; display: flex; align-items: center; justify-content: center; height: 22px;
                cursor: grab; touch-action: none; }   /* touch-action:none: the drag itself scrolls nothing */
.sheet-handle::before { content: ""; width: 42px; height: 5px; border-radius: 3px; background: var(--glass-border); }
.sheet-handle:active { cursor: grabbing; }
.sheet-handle:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.sheet-header { flex: none; display: flex; align-items: center; gap: 4px; padding: 0 16px 8px; }
.sheet-header h1 { display: flex; align-items: center; gap: 8px; font-size: 17px; font-weight: 650;
                   letter-spacing: .2px; margin: 0; flex: 1; min-width: 0; }
.sheet-header h1 svg { width: 22px; height: 22px; flex: none; }
.sheet-header h1 .t { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sheet-back { display: none; flex: none; align-items: center; justify-content: center; width: 40px; height: 40px;
              margin-left: -8px; border: 0; background: none; color: var(--ink); font-size: 22px;
              border-radius: 10px; }
.sheet-back:hover, .sheet-back:active { background: var(--accent-soft); }
.sheet.details .sheet-back { display: flex; }
/* "Zur Karte"-Button unterhalb des Titels (s. Chat) - nur sichtbar, wenn Baum-Details aus der
   Tabellenansicht heraus geöffnet wurden (map.js: syncToMapButton), nicht wenn man schon auf der Karte ist */
.sheet-to-map { display: block; flex: none; margin: 0 16px 10px; padding: 9px 14px; border: 1px solid var(--glass-border);
               border-radius: 10px; background: var(--accent-mid); color: var(--ink); font: inherit; font-size: 13px;
               font-weight: 600; text-align: center; cursor: pointer; }
.sheet-to-map:hover { filter: brightness(1.1); }
.sheet-to-map[hidden] { display: none; }   /* [hidden] vs .sheet-to-map: gleiche Spezifität, s. Chat/.table-view */
.sheet-body { flex: 1 1 auto; overflow: auto; padding: 0 16px 16px; -webkit-overflow-scrolling: touch; }
/* only one of filters / marker details shows at a time (map.js toggles ".details" on .sheet) */
.sheet.details #sheet-filters { display: none; }
.sheet:not(.details) #sheet-details { display: none; }
#sheet-details .popup { padding: 0; }   /* no extra inset needed - .sheet-body already has its own padding */
.section { border-top: 1px solid var(--glass-border); margin-top: 10px; padding-top: 10px; }
.legend div { display: flex; align-items: center; gap: 8px; margin: 3px 0; }
.legend-box summary { cursor: pointer; font-weight: 600; font-size: 13px; margin-bottom: 4px; list-style: none;
                      display: flex; align-items: center; gap: 8px; padding: 6px 0; }
.legend-box summary::-webkit-details-marker { display: none; }
/* Aufklapp-Dreieck: immer am Ende der Zeile (bei "Parks..."/"Waldmonitor" rechts von Checkbox + Text, bei
   "Filter nach Baumarten" dort, wo früher der Hinweistext stand) - text-align:center zentriert das Zeichen
   exakt in seiner Box, sonst dreht es beim Aufklappen sichtbar aussermittig (s. Chat) */
.legend-box summary::after { content: "▸"; display: inline-block; flex: none; width: 28px; font-size: 22px;
                             text-align: center; color: var(--muted); transition: transform .15s; margin-left: auto; }
.legend-box[open] summary::after { transform: rotate(90deg); }
.legend-box summary input[type=checkbox] { flex: none; }
.legend-box summary .muted { font-weight: 400; font-size: 12px; }
.legend-box { margin: 8px 0; }
.subhead { font-weight: 600; font-size: 13px; margin: 0 0 6px; }
.legend .grp { display: flex; align-items: center; gap: 6px; margin: 1px 0; padding: 2px 4px; border-radius: 7px; cursor: pointer; }
.legend .grp:hover { background: var(--accent-soft); }
.legend .grp.active, .legend .spl li.active { background: var(--accent-mid); box-shadow: inset 2px 0 0 var(--accent); }
.legend .grp .lbl { flex: 1; }
.legend .grp a.stammblatt { flex: none; color: var(--muted); text-decoration: none; font-size: 12px;
                            padding: 0 2px; border-radius: 50%; }
.legend .grp a.stammblatt:hover { color: var(--accent); background: var(--accent-soft); }
.legend .n { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.legend .exp { border: 0; background: none; color: var(--muted); cursor: pointer; font: inherit; font-size: 15px;
               width: 20px; padding: 0; }
.legend .exp:hover { color: var(--ink); }
.legend .exp[aria-expanded="true"] { transform: rotate(90deg); }
.legend .exp:disabled { visibility: hidden; }
.legend .spl { list-style: none; margin: 0 0 4px 38px; padding: 0; font-size: 12px; max-height: 180px; overflow: auto; }
.legend .spl li { display: flex; justify-content: space-between; gap: 8px; padding: 1px 6px; border-radius: 6px; cursor: pointer; }
.legend .spl li:hover { background: var(--accent-soft); }
.legend a, .overlay a { color: var(--ink); text-decoration: none; border-bottom: 1px dotted var(--muted); }
.legend a:hover { border-bottom-style: solid; color: var(--accent); }
.dot { width: 12px; height: 12px; border-radius: 50%; display: inline-block; flex: none;
       border: 1.5px solid rgba(255,255,255,.85); box-shadow: 0 0 0 1px rgba(0,0,0,.35); }
#stats { color: var(--muted); font-size: 12px; }
.muted { color: var(--muted); }
.sheet .statslink { font-size: 12px; margin-top: 4px; }
input[type=checkbox] { width: 15px; height: 15px; }
.overlay { font-size: 13px; }
.overlay label { display: flex; align-items: center; gap: 8px; margin: 4px 0; cursor: pointer; }
.toggle-row { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.toggle-row label { margin: 4px 0; }
.overlay .opacity { color: var(--muted); margin: 4px 0 4px 23px; font-size: 12px; }
.overlay .opacity input { width: 110px; }
.overlay .src { color: var(--muted); font-size: 12px; margin-left: 23px; }
#species-legend, #parks-legend { list-style: none; margin: 2px 0 6px 23px; padding: 0; font-size: 12px; }
#species-legend li, #parks-legend li { display: flex; align-items: center; gap: 8px; margin: 2px 0; }
#species-legend .sq, #parks-legend .sq { width: 12px; height: 12px; border-radius: 3px; flex: none;
                                         box-shadow: 0 0 0 1px rgba(0,0,0,.35); }
#parktrees-legend { color: var(--muted); margin: 0 0 6px 23px; font-size: 12px; }
/* ---- raster layers of the treetile server ("Baumarten (DLR)", "Kronenhöhe (DLR)" ...): built by map.js into
   #raster-layers, one .legend-box per layer like the Waldmonitor - plus a slider for the year ---- */
.overlay .raster-box .opacity { display: grid; grid-template-columns: 62px 110px auto; justify-content: start;
                                align-items: center; gap: 8px; cursor: default; }
.raster-box .opacity output { font-variant-numeric: tabular-nums; }
.raster-box .opacity output.pending { opacity: .5; }   /* the chosen year is still loading */
.raster-legend { list-style: none; margin: 4px 0 6px 23px; padding: 0; font-size: 12px;
                 display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.raster-legend li { display: flex; align-items: center; gap: 8px; margin: 2px 0; min-width: 0; }
.raster-legend .sq { width: 12px; height: 12px; border-radius: 3px; flex: none; box-shadow: 0 0 0 1px rgba(0,0,0,.35); }
.raster-ramp { height: 10px; max-width: 240px; margin: 8px 0 2px 23px; border-radius: 3px; box-shadow: 0 0 0 1px rgba(0,0,0,.35); }
.raster-ramp-labels { display: flex; justify-content: space-between; max-width: 240px; margin: 0 0 6px 23px;
                      color: var(--muted); font-size: 12px; }

/* ---- species filter (search + chips, inside .legend-box, above the colour-group legend) ---- */
.speciesfilter { position: relative; margin: 2px 0 10px; }
#species-search { width: 100%; box-sizing: border-box; }
#species-list { position: absolute; z-index: 5; left: 0; right: 0; max-height: 260px; overflow: auto;
                margin: 4px 0 0; padding: 4px; list-style: none; background: var(--glass-sheen), var(--glass-strong);
                border: 1px solid var(--glass-border); border-radius: 12px; box-shadow: var(--shadow);
                -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur); }
#species-list li { padding: 4px 8px; border-radius: 7px; cursor: pointer; display: flex;
                   justify-content: space-between; gap: 8px; }
#species-list li:hover, #species-list li.active { background: var(--accent-soft); }
#species-list .n { color: var(--muted); font-variant-numeric: tabular-nums; }
#species-chips { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 4px; }
#species-chips span { background: linear-gradient(180deg, rgba(160,255,195,.22), rgba(34,169,90,.14)); border: 1px solid var(--glass-border);
                      box-shadow: inset 0 1px 0 rgba(230,255,240,.25);
                      border-radius: 999px; padding: 1px 4px 1px 9px; font-size: 12px; }
#species-chips button { border: 0; background: none; cursor: pointer; font: inherit; color: var(--muted); }
#species-chips button:hover { color: var(--ink); }
#filter-info { color: var(--muted); margin-top: 3px; font-size: 12px; }

/* ---- Mapbox controls and popups in glass ---- */
.mapboxgl-ctrl-group, .mapboxgl-ctrl-geocoder {
  background: rgba(0, 0, 0, .82) !important; border: 1px solid var(--glass-border); box-shadow: var(--shadow) !important;
  /* kein Weichzeichner mehr - bei fast deckendem Schwarz kaum sichtbar, aber dauerhaft über der
     WebGL-Karte teuer (s. Chat: Speicherproblem auf altem iOS) */
  -webkit-backdrop-filter: none !important; backdrop-filter: none !important; border-radius: 12px !important; }
.mapboxgl-ctrl-group button + button { border-top: 1px solid var(--glass-border); }
/* Browser-eigener Fokus-/Aktiv-Hintergrund des <button> (nicht von Mapbox gesetzt) bleibt sonst nach dem
   Klick als heller/weißer Fleck stehen, z.B. beim Vollbild-Button (s. Chat) - eigener, dezenter Zustand
   statt des Browser-Standards, Fokus bleibt per outline trotzdem sichtbar (Tastaturbedienung). */
.mapboxgl-ctrl-group button { background-color: transparent !important; outline: none; }
.mapboxgl-ctrl-group button:hover, .mapboxgl-ctrl-group button:active { background-color: rgba(255,255,255,.08) !important; }
.mapboxgl-ctrl-group button:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.mapboxgl-ctrl-group button .mapboxgl-ctrl-icon { filter: invert(1) brightness(1.6) hue-rotate(90deg); }
/* Vollbild-Icon etwas kleiner als die übrigen (Standard füllt den ganzen 29x29-Button, wirkt wuchtig) -
   nur background-size verkleinert, Button selbst bleibt gleich groß (Klickfläche unverändert) */
.mapboxgl-ctrl-fullscreen .mapboxgl-ctrl-icon, .mapboxgl-ctrl-shrink .mapboxgl-ctrl-icon { background-size: 16px 16px; }
/* Control-Container oben links (Ortssuche + GPS): Mapbox setzt z-index 2 - darunter lag die aufgeklappte
   Ortssuche samt Vorschlagsliste hinter dem fixierten Umschalter Karte/Tabelle (.view-switch, z-index 7).
   8 = knapp darüber; bleibt unter Update-Hinweis (21) und Ladebildschirm (20). Das Sheet (z-index 5) ist auf
   25% der Viewport-Höhe begrenzt und erreicht diese Ecke nie, die Überlagerung dort ist also unkritisch. */
.mapboxgl-ctrl-top-left { z-index: 8; }
.mapboxgl-ctrl-geocoder { min-width: 250px; font-family: inherit; }
.mapboxgl-ctrl-geocoder input { color: var(--ink) !important; background: transparent !important; }
.mapboxgl-ctrl-geocoder input::placeholder { color: var(--muted); }
.mapboxgl-ctrl-geocoder--icon { fill: var(--muted); }
.mapboxgl-ctrl-geocoder .suggestions { background: var(--glass-strong); border: 1px solid var(--glass-border);
                                       -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur); }
.mapboxgl-ctrl-geocoder .suggestions > li > a { color: var(--ink); }
.mapboxgl-ctrl-geocoder .suggestions > .active > a,
.mapboxgl-ctrl-geocoder .suggestions > li > a:hover { background: var(--accent-soft); color: var(--ink) !important; }
/* the plugin colours title and address of the (first) active result dark - keep them light */
.mapboxgl-ctrl-geocoder .suggestions a, .mapboxgl-ctrl-geocoder--suggestion-title,
.mapboxgl-ctrl-geocoder--suggestion-address { color: var(--ink) !important; }
.mapboxgl-ctrl-geocoder--suggestion-address { opacity: .75; }
/* collapsed search (icon-only on every screen size, see collapsed:true in map.js): the plugin's own icon
   keeps a fixed "left" offset meant for the full-width box, so once collapsed to a small square it sits
   off-centre - recentre it */
.mapboxgl-ctrl-geocoder.mapboxgl-ctrl-geocoder--collapsed .mapboxgl-ctrl-geocoder--icon-search {
  left: 50% !important; transform: translateX(-50%); }
/* aufgeklappt (Textfeld sichtbar): die Lupe (Plugin-Standard) ausblenden statt sie neben dem Text stehen zu
   lassen - das Eingabefeld bekommt dafür einen normalen linken Innenabstand statt des für das Icon reservierten */
.mapboxgl-ctrl-geocoder:not(.mapboxgl-ctrl-geocoder--collapsed) .mapboxgl-ctrl-geocoder--icon-search { display: none; }
.mapboxgl-ctrl-geocoder:not(.mapboxgl-ctrl-geocoder--collapsed) .mapboxgl-ctrl-geocoder--input { padding-left: 12px; }

/* "Karte" style switcher: its own control (top-right, with zoom), replacing the old <select> in the panel.
   The <select> itself stays the clickable element but its closed-state text is hidden (like the search
   box above) and a small "layers" icon (Feather icons, MIT) is shown centred on top instead - pointer-events:
   none on the icon lets clicks fall through to the select beneath it. */
.map-style-ctrl { position: relative; }
.map-style-ctrl select { display: block; width: 29px; height: 29px; padding: 0 3px; border: 0; background: transparent;
  color: transparent; font-size: 15px; text-align: center; text-align-last: center; cursor: pointer;
  -webkit-appearance: none; appearance: none; }
.map-style-ctrl select option { background: #062014; color: var(--ink); text-align: left; }
.map-style-ctrl .map-style-icon { position: absolute; inset: 0; margin: auto; width: 17px; height: 17px;
  color: var(--ink); pointer-events: none; }
.mapboxgl-ctrl-attrib.mapboxgl-compact, .mapboxgl-ctrl-attrib { background: rgba(3,20,11,.7); color: var(--muted); }
.mapboxgl-ctrl-attrib a { color: var(--ink); }
.mapboxgl-popup { max-width: calc(100vw - 16px) !important; }   /* never wider than the screen (phones) */
.mapboxgl-popup-content { background: var(--glass-sheen), var(--glass-tint), var(--glass-strong); color: var(--ink); border: 1px solid var(--glass-border);
                          border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px;
                          -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur);
                          max-width: min(330px, calc(100vw - 24px)); max-height: 60vh; overflow: auto; }
.mapboxgl-popup-tip { display: none; }
.mapboxgl-popup-close-button { color: var(--muted); font-size: 18px; padding: 2px 8px; }
.mapboxgl-popup-close-button:hover { background: transparent; color: var(--ink); }
.popup h3 { margin: 0 0 2px; font-size: 16px; }
.popup .lost { display: inline-block; margin: -2px 0 8px; padding: 2px 10px; border-radius: 999px; font-size: 12px;
               letter-spacing: .3px; color: #f0e6dc; background: linear-gradient(180deg, rgba(90, 70, 60, .55), rgba(40, 28, 22, .7));
               border: 1px solid rgba(220, 190, 170, .3); box-shadow: inset 0 1px 0 rgba(255, 240, 230, .18); }
.popup .sub { color: var(--muted); font-style: italic; margin-bottom: 8px; }
.popup table { border-collapse: collapse; }
.popup td { padding: 2px 10px 2px 0; vertical-align: top; }
.popup td:first-child { color: var(--muted); white-space: nowrap; }
.popup .links { margin-top: 8px; display: flex; flex-wrap: wrap; gap: 6px; }
.popup .links a { color: var(--ink); text-decoration: none; background: linear-gradient(180deg, rgba(160,255,195,.20), rgba(34,169,90,.12));
                  box-shadow: inset 0 1px 0 rgba(230,255,240,.25);
                  border: 1px solid var(--glass-border); border-radius: 999px; padding: 1px 9px; font-size: 12px; }
.popup .links a:hover { background: var(--accent-mid); }
/* footer: a divider, then one labelled row per group (Quelle(n) / Foto(s) / Wikipedia+Stammblatt) */
.popup hr.popup-divider { border: none; border-top: 1px solid var(--glass-border); margin: 10px 0 8px; }
.popup .popup-group { margin: 8px 0; }
.popup .popup-group .lbl { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 4px; }
.popup .popup-group .links { margin-top: 0; }
.popup-loading { display: flex; align-items: center; gap: 8px; padding: 2px 4px; color: var(--muted); font-size: 13px; }
.popup-loading .spinner { width: 13px; height: 13px; border: 2px solid var(--glass-border); border-top-color: var(--accent);
                          border-radius: 50%; animation: popup-spin .8s linear infinite; flex: none; }
@keyframes popup-spin { to { transform: rotate(360deg); } }

/* ---- no token ---- */
#notoken { position: absolute; inset: 0; display: grid; place-items: center; padding: 16px; text-align: center; }

/* ---- loading screen: mystical photo (static/loading.*, optional static/loading_mobile.* for mobile), mist, "Karte öffnen" ---- */
#loading { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; overflow: hidden;
           grid-template-rows: 1fr auto auto;
           background: radial-gradient(ellipse at 50% 35%, #0f3a24, #020c06 75%); transition: opacity .9s ease; }
#loading.hidden { opacity: 0; pointer-events: none; }
/* seen in this session already (see templates/index.html): short loading screen without button and boxes,
   closes by itself as soon as the map is drawn */
html.intro-seen #loading .channels, html.intro-seen #loading .about-link, html.intro-seen #open-map { display: none !important; }
html.intro-seen #loading { transition-duration: .5s; }
#loading .photo { position: absolute; inset: -4%; background: var(--loading-image) center / cover no-repeat;
                  filter: saturate(.95) brightness(.95); animation: drift 40s ease-in-out infinite alternate; }
/* static/loading_mobile.* (optional, hochkant zugeschnitten): ersetzt nur unterhalb des Mobile-Breakpoints
   das Hintergrundbild; Desktop bleibt unverändert bei --loading-image. */
@media (max-width: 600px) {
  #loading.has-image-mobile .photo { background-image: var(--loading-image-mobile); }
}
#loading .veil { position: absolute; inset: 0;
                 background: radial-gradient(ellipse at 50% 45%, rgba(4,24,13,0), rgba(1,10,5,.5) 85%),
                             linear-gradient(180deg, rgba(6,40,20,.12), rgba(1,12,6,.36)); }
#loading .mist { position: absolute; inset: -20%; pointer-events: none; mix-blend-mode: screen; opacity: .2;
                 background: radial-gradient(ellipse 45% 18% at 30% 70%, rgba(200,235,210,.35), transparent 70%),
                             radial-gradient(ellipse 40% 14% at 70% 60%, rgba(200,235,210,.28), transparent 70%);
                 filter: blur(18px); animation: mist 28s ease-in-out infinite alternate; }
#loading .mist.m2 { opacity: .14; animation-duration: 36s; animation-direction: alternate-reverse; }
#loading .inner { position: relative; display: flex; flex-direction: column; align-items: center; gap: 14px;
                  text-align: center; padding: 0 16px; }
#loading .inner::before { content: ""; position: absolute; inset: -40px -80px; z-index: -1; border-radius: 50%;
                          background: radial-gradient(ellipse, rgba(4,16,10,.5), transparent 70%); filter: blur(10px); }
#loading h2 { margin: 0; font-size: clamp(24px, 4.5vw, 44px); font-weight: 300; letter-spacing: 2px;
              color: #eef7ef; text-shadow: 0 2px 4px rgba(0,0,0,.5), 0 2px 24px rgba(0,0,0,.6); }
#loading-text { font-size: 15px; letter-spacing: .4px; color: var(--ink); text-shadow: 0 1px 6px rgba(0,0,0,.7); }
#loading .bar { width: 200px; height: 2px; border-radius: 2px; background: rgba(255,255,255,.14); overflow: hidden; }
#loading .bar::after { content: ""; display: block; width: 40%; height: 100%;
                       background: linear-gradient(90deg, transparent, var(--accent), transparent);
                       animation: slide 1.6s ease-in-out infinite; }
#loading.ready .bar, #loading.error .bar { display: none; }
#loading.error #loading-text { color: var(--danger); }
#open-map { margin-top: 6px; padding: 11px 30px; font: inherit; font-size: 16px; letter-spacing: .6px; }   /* look: .btn-glow */
/* channel boxes below "Karte öffnen" (enabled channels from /channels, counts from /stats) */
/* grid row 2 = bottom of the screen; row 1 (title, button) stays centred in the space above */
#loading .channels { position: relative; align-self: end; margin: 0 16px 10px; padding: 2px 0;   /* no outer frame */
                     max-width: min(1080px, calc(100vw - 32px)); box-sizing: border-box; }
#loading .channels:empty { display: none; }
#loading .ch-row { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: thin;
                   scroll-snap-type: x proximity; }
#loading .ch { flex: 1 0 168px; min-width: 168px; box-sizing: border-box; scroll-snap-align: start; display: flex; flex-direction: column;
               gap: 4px; padding: 9px 11px; text-align: left; text-decoration: none; color: var(--ink);
               background: var(--glass-sheen), var(--glass-tint), rgba(3,20,11,.42); border: 1px solid var(--glass-border); border-radius: 12px;
               box-shadow: 0 8px 22px rgba(0,0,0,.35), inset 0 1px 0 var(--glass-edge);
               -webkit-backdrop-filter: blur(10px) saturate(160%); backdrop-filter: blur(10px) saturate(160%);
               transition: background .2s, border-color .2s, transform .2s; }
#loading a.ch:hover, #loading a.ch:focus-visible { background: var(--glass-sheen), linear-gradient(180deg, rgba(120,230,160,.22), rgba(20,90,50,.30));
                                                  box-shadow: 0 10px 26px rgba(0,0,0,.4), 0 0 18px var(--accent-glow), inset 0 1px 0 var(--glass-edge); border-color: rgba(160,255,200,.45);
                                                  transform: translateY(-1px); outline: none; }
/* channel name: always two lines high (numbers and dates line up); longer names are cut with "…" */
#loading .ch .nm { display: flex; align-items: flex-start; gap: 7px; font-size: 13px; font-weight: 600; line-height: 1.25;
                   height: 2.5em; }
#loading .ch .nm .dot { margin-top: .2em; }
#loading .ch .nm .t { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2;
                      overflow: hidden; }
#loading .ch .dot { width: 10px; height: 10px; }
#loading .ch .n { font-size: 18px; font-weight: 300; font-variant-numeric: tabular-nums; }
#loading .ch .n small { font-size: 11px; color: var(--muted); margin-left: 3px; }
#loading .ch .when { font-size: 11px; color: var(--muted); white-space: nowrap; }
/* link to the about page, bottom centre (below the channel boxes) */
#loading .about-link { position: relative; margin: 0 0 14px; font-size: 13px; letter-spacing: .3px;
                       color: rgba(230,242,232,.85); text-decoration: none; border-bottom: 1px dotted rgba(230,242,232,.5);
                       text-shadow: 0 1px 6px rgba(0,0,0,.7); }
#loading .about-link:hover, #loading .about-link:focus-visible { color: var(--accent); border-bottom-style: solid; outline: none; }
#loading .credit { position: absolute; right: 12px; bottom: 8px; font-size: 11px; color: rgba(230,242,232,.6); }
@keyframes drift { from { transform: scale(1.02) translate(0, 0); } to { transform: scale(1.1) translate(-1.5%, -1%); } }
@keyframes mist { from { transform: translateX(-6%); } to { transform: translateX(6%); } }
@keyframes slide { from { transform: translateX(-100%); } to { transform: translateX(260%); } }
@media (prefers-reduced-motion: reduce) {
  #loading .photo, #loading .mist, #loading .bar::after { animation: none; }
}

/* search: collapsed to just the icon on every screen size (collapsed:true in map.js) until
   tapped/focused - only then does it need the full width. The plugin only shrinks the outer box, not
   its own input padding/icon, so without this the placeholder text would still render (overflowing
   the tiny icon-sized box); hiding the text while collapsed is what actually makes it look like an icon. */
.mapboxgl-ctrl-geocoder.mapboxgl-ctrl-geocoder--collapsed .mapboxgl-ctrl-geocoder--input,
.mapboxgl-ctrl-geocoder.mapboxgl-ctrl-geocoder--collapsed .mapboxgl-ctrl-geocoder--input::placeholder {
  color: transparent !important; }

@media (max-width: 600px) {
  /* bigger touch targets (fingers, not mouse pointers) */
  .legend .exp { width: 30px; height: 30px; display: inline-flex; align-items: center; justify-content: center; }
  .legend .grp, .legend .spl li { min-height: 30px; align-items: center; }
  .legend .grp a.stammblatt { padding: 6px; margin: -6px; }
  .overlay label { padding: 5px 0; }
  input[type=checkbox] { width: 20px; height: 20px; }
  #species-list li { padding: 8px; }
  #species-chips button { padding: 4px; }

  /* loading screen: narrower cards fit more of the row before it needs to scroll */
  #loading .ch { flex-basis: 148px; min-width: 148px; }
  #loading .ch-row { -webkit-overflow-scrolling: touch; }

  /* map controls (search, zoom, locate): a bit of breathing room between the stacked groups */
  .mapboxgl-ctrl-top-right > .mapboxgl-ctrl, .mapboxgl-ctrl-top-left > .mapboxgl-ctrl {
    margin-top: 10px !important; margin-right: 10px !important; margin-left: 10px !important; }
  .mapboxgl-ctrl-geocoder.mapboxgl-ctrl-geocoder--collapsed { width: 34px; min-width: 34px; }
  .mapboxgl-ctrl-geocoder:not(.mapboxgl-ctrl-geocoder--collapsed) { min-width: 0; width: calc(100vw - 70px); }
  .mapboxgl-ctrl-geocoder .suggestions { max-height: 50vh; overflow-y: auto; }

  /* loading screen: the photo credit (bottom-right corner) would otherwise overlap the "Über das
     Projekt"-link on short/narrow screens - let it flow below the link instead of floating over it */
  #loading .credit { position: static; right: auto; bottom: auto; text-align: center; margin: -6px 0 4px; }
}