:root {
    --bg: #f2f5fb;
    --surface: rgba(255, 255, 255, 0.95);
    --accent: #0F66B0;
    --accent-soft: #3388ff;
    --accent-warm: #ff8800;
    --text: #083b6f;
    --muted: #5a6e8c;
    --shadow: 0 18px 45px rgba(0, 0, 0, 0.12);
}

html,
body {
    margin: 0;
    padding: 0;
    min-height: 100%;
    overflow: hidden;
    background: linear-gradient(180deg, #eef5fb 0%, #f8fbff 100%);
    color: var(--text);
    font-family: 'Inter', 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

#map {
    width: 100%;
    height: 100vh;
    overflow: hidden;
    box-shadow: 0 24px 60px rgba(15, 86, 149, 0.14);
    border: 1px solid rgba(15, 102, 176, 0.12);
    background: #eef4fb;

    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;

    /* Verhindert das Standard-Kontextmenü (Rechtsklick-Menü) auf vielen mobilen Browsern */
    -webkit-touch-callout: none;

    /* Verhindert das blaue Aufblitzen beim Tippen auf Android */
    -webkit-tap-highlight-color: transparent;
    touch-action: pan-x pan-y pinch-zoom;
}

/* Schwebender Tiefen-Tooltip */
.depth-hover-popup .leaflet-popup-content-wrapper {
    background: rgba(255, 255, 255, 0.88) !important;
    color: #083b6f !important;
    border-radius: 20px !important;
    padding: 6px 12px !important;
    border: 1px solid rgba(15, 102, 176, 0.14) !important;
    box-shadow: 0 18px 40px rgba(15, 102, 176, 0.16) !important;
    backdrop-filter: blur(18px) !important;
}

.depth-hover-popup .leaflet-popup-content {
    margin: 0 !important;
    font-size: 14px !important;
    font-weight: 700 !important;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Den kleinen Pfeil unten auf Glass-Style abstimmen */
.depth-hover-popup .leaflet-popup-tip {
    position: absolute !important;
    left: 50% !important;
    transform: translateX(-50%) !important;
    top: 11px !important;
    width: 0 !important;
    height: 0 !important;
    border-left: 6px solid transparent !important;
    border-right: 6px solid transparent !important;
    border-top: 12px solid rgba(15, 102, 176, 0.95) !important;
    background: none !important;
    box-shadow: none !important;
    pointer-events: none !important;
}

.leaflet-bottom.leaflet-right .map-watermark {
    position: absolute !important;
    right: 60px !important;
    bottom: 20px !important;
    background: none !important;
    /* Hintergrund entfernen */
    box-shadow: none !important;
    /* Schatten entfernen */
    pointer-events: none;
    /* Verhindert, dass das Logo Klicks abfängt */
}


/* Hover-Effekt für den Container (optional) */
.leaflet-bottom.leaflet-right .map-watermark:hover {
    background-color: rgba(255, 255, 255, 0.8);
}

.map-watermark {
    position: fixed !important;
    /* Nutzt das gesamte Browserfenster zur Positionierung */
    left: 50% !important;
    bottom: 15px !important;
    /* Abstand zum unteren Rand */
    transform: translateX(-50%) !important;
    /* Exakt mittig ausrichten */
    z-index: 1100 !important;
    /* Sicherstellen, dass es über der Karte liegt */
    pointer-events: none !important;
    /* WICHTIG: Erlaubt Klicks durch das Logo hindurch auf die Karte */
    margin: 0 !important;
    display: block !important;
    background: none !important;
    box-shadow: none !important;
}

.leaflet-control.map-watermark {
    float: none !important;
    clear: both !important;
}

.map-watermark img {
    opacity: 0.6;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2));
    max-width: 80vw;
    /* Verhindert, dass das Logo auf kleinen Screens überläuft */
}

#project-selector {
    position: fixed;
    /* Fixiert über der Karte */
    top: 0;
    left: 0;
    width: 100%;
    height: 100dvh;
    /* Nutzt die echte Handy-Displayhöhe (Dynamic Viewport) */
    background: radial-gradient(circle at top left, rgba(15, 102, 176, 0.24), transparent 28%),
        radial-gradient(circle at bottom right, rgba(51, 136, 255, 0.2), transparent 22%),
        rgba(14, 24, 44, 0.96);
    z-index: 9999;

    /* SCROLL-LOGIK */
    display: flex;
    justify-content: center;
    align-items: flex-start !important;
    /* WICHTIG: Nicht 'center', sonst ist der Header oben weg! */
    overflow-y: auto !important;
    /* Erzwingt Scrollbarkeit */
    -webkit-overflow-scrolling: touch;
    /* Weiches Scrollen für iPhones */
    padding: 40px 0;
    /* Abstand oben/unten für Mobile-Browserleisten */
}

.selector-content {
    width: min(1100px, calc(100% - 40px));
    margin-top: 20px;
    /* Startet mit Abstand zum oberen Rand */
    padding-bottom: 80px;
    /* Puffer unten, damit das letzte Projekt nicht klebt */
}

.selector-panel {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.16);
    box-shadow: 0 32px 90px rgba(0, 0, 0, 0.2);
    backdrop-filter: blur(28px) saturate(140%);
    border-radius: 36px;
    padding: 32px;
}

.selector-header {
    text-align: left;
    max-width: 680px;
    margin-bottom: 26px;
}

.selector-header span {
    display: inline-block;
    margin-bottom: 12px;
    color: var(--accent-soft);
    font-weight: 700;
    letter-spacing: 0.16em;
    text-transform: uppercase;
}

.selector-header h1 {
    margin: 0;
    font-size: clamp(2.2rem, 3vw, 3.5rem);
    line-height: 1.05;
    letter-spacing: -0.04em;
    color: #ffffff;
}

.selector-header p {
    margin: 14px 0 0;
    max-width: 620px;
    color: rgba(255, 255, 255, 0.82);
    font-size: 1rem;
    line-height: 1.8;
}

.project-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
}

.project-grid button.project-card {
    padding: 28px 24px;
    /* Behält dein ursprüngliches Karten-Padding */
    width: 100%;
    text-transform: none;
    /* Deaktiviert Uppercase für den Projekttitel */
    background: rgba(255, 255, 255, 0.10);
    /* Glass-Optik beibehalten */
}

.project-card {
    min-height: 140px;
    background: rgba(255, 255, 255, 0.10);
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 28px;
    padding: 28px 24px;
    text-align: left;
    color: white;
    cursor: pointer;
    transition: transform 0.24s ease, background 0.24s ease, box-shadow 0.24s ease, border-color 0.24s ease;
    box-shadow: 0 24px 56px rgba(0, 0, 0, 0.18);
    display: grid;
    grid-template-rows: auto 1fr;
}

.project-card:hover {
    transform: translateY(-4px);
    background: rgba(255, 255, 255, 0.18);
    border-color: rgba(255, 255, 255, 0.28);
}

.project-card h2 {
    margin: 0;
    font-size: 1.35rem;
    color: #ffffff;
    line-height: 1.2;
}

.project-card-badge {
    align-self: end;
    display: inline-flex;
    margin-top: 18px;
    padding: 12px 18px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.16);
    color: rgba(255, 255, 255, 0.95);
    font-weight: 700;
    font-size: 0.95rem;
    letter-spacing: 0.04em;
}

.selector-footer {
    margin-top: 22px;
    text-align: left;
}

#project-selector-note {
    color: rgba(255, 255, 255, 0.74);
    font-size: 0.95rem;
}

.project-grid button {
    padding: 16px 34px;
    font-size: 18px;
    cursor: pointer;
    background: linear-gradient(135deg, rgba(15, 102, 176, 0.18), rgba(51, 136, 255, 0.24));
    color: #07355d;
    border: 1px solid rgba(255, 255, 255, 0.55);
    border-radius: 22px;
    transition: transform 0.18s ease, background 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
    box-shadow: 0 22px 45px rgba(15, 102, 176, 0.14);
    backdrop-filter: blur(14px);
    font-weight: 700;
    letter-spacing: 0.02em;
    text-transform: uppercase;
}

.project-grid button:hover {
    background: linear-gradient(135deg, rgba(15, 102, 176, 0.28), rgba(51, 136, 255, 0.36));
    color: white;
    transform: translateY(-2px);
    border-color: rgba(255, 255, 255, 0.85);
    box-shadow: 0 24px 50px rgba(15, 102, 176, 0.18);
}

/* Verhindert Standard-Leaflet-Styles für das Icon-Div */
.custom-depth-marker {
    background: none !important;
    border: none !important;
}

/* Container, der alles nach oben verschiebt, damit die Linie auf dem Punkt steht */
.depth-pin-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    transform: translate(-50%, -100%);
    /* Zentriert horizontal, schiebt Basis auf den Klickpunkt */
}

/* Die kleine Box mit der Zahl - Glas-Design für Pins */
.depth-pin-box {
    background: rgba(255, 255, 255, 0.88);
    border: 1px solid rgba(15, 102, 176, 0.16);
    border-radius: 18px;
    padding: 6px 12px;
    font-size: 13px;
    font-weight: 700;
    color: #083b6f;
    box-shadow: 0 14px 32px rgba(15, 102, 176, 0.14);
    white-space: nowrap;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 52px;
    backdrop-filter: blur(12px);
}

/* Die Spitze unterhalb des Markers */
.depth-pin-line {
    width: 0;
    height: 0;
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-top: 12px solid rgba(15, 102, 176, 0.95);
    margin-top: -2px;
}

.depth-pin-box:hover {
    background: rgba(243, 247, 255, 0.95);
    border-color: #bb1f1f;
}

/* Layer-Box modernisieren */
.leaflet-control-layers {
    background: rgba(255, 255, 255, 0.96) !important;
    border: 1px solid rgba(15, 102, 176, 0.12) !important;
    box-shadow: 0 18px 40px rgba(15, 102, 176, 0.12) !important;
    border-radius: 22px !important;
    padding: 16px !important;
    min-width: 210px;
    margin-top: 20px;
    font-family: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

.leaflet-control-layers-expanded {
    background: transparent !important;
    backdrop-filter: blur(16px);
    color: #083b6f;
    padding: 16px !important;
}

.leaflet-control-layers-list label {
    display: block;
    margin-bottom: 8px;
    cursor: pointer;
    transition: background-color 0.2s, color 0.2s, border-color 0.2s;
    padding: 8px 10px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid rgba(15, 102, 176, 0.1);
    color: var(--text);
}

.leaflet-control-layers-list label:hover {
    background: rgba(51, 136, 255, 0.12);
    color: var(--accent);
    border-color: rgba(51, 136, 255, 0.25);
}

/* Den Projekttitel massiv aufwerten */
.map-title {
    position: absolute !important;
    top: 10px !important;
    left: 10px !important;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.78), rgba(255, 255, 255, 0.58)) !important;
    padding: 18px 26px !important;
    border-radius: 24px !important;
    font-family: 'Inter', 'Segoe UI', sans-serif !important;
    color: rgba(8, 59, 111, 0.95) !important;
    font-size: 24px !important;
    font-weight: 800 !important;
    text-transform: uppercase !important;
    box-shadow: 0 28px 70px rgba(15, 102, 176, 0.16) !important;
    backdrop-filter: blur(24px) saturate(140%) !important;
    z-index: 1000 !important;
    border-left: 6px solid var(--accent) !important;
    letter-spacing: 0.14em !important;
    border: 1px solid rgba(255, 255, 255, 0.7) !important;
}

/* Die Zoom-Box komplett verändern */
.leaflet-control-zoom {
    border: none !important;
    margin-right: 15px !important;
    margin-bottom: 10px !important;
    /* Abstand zum Leaflet-Text darunter */
}

.leaflet-control-attribution {
    margin: 0 !important;
    /* Wir fügen manuell 5px hinzu, falls env() 0 zurückgibt, 
           damit es in Safari nicht "klebt" */
    padding: 2px 10px 5px 10px !important;
    font-size: 10px !important;
    background: rgba(255, 255, 255, 0.6) !important;
    border-radius: 8px 0 0 0 !important;
}

.leaflet-bar {
    display: flex !important;
    flex-direction: column !important;
    gap: 2px !important;
}

.leaflet-bar a {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    background: white !important;
    color: #083b6f !important;
    border: 1px solid rgba(15, 102, 176, 0.14) !important;
    width: 42px !important;
    height: 42px !important;
    font-size: 20px !important;
    font-weight: 700 !important;
    font-family: 'Inter', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif !important;
    transition: all 0.2s ease !important;
    box-shadow: 0 20px 42px rgba(15, 102, 176, 0.1) !important;
    padding: 0 !important;
    border-radius: 12px !important;
}

.leaflet-bar a:hover {
    background-color: #083b6f !important;
    color: white !important;
}

/* 3. Lösch-Button links unten als schwebender Action-Button */
.clear-depth-btn {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 10px !important;
    background: white !important;
    color: #bb1f1f !important;
    border: 1px solid rgba(255, 68, 68, 0.25) !important;
    padding: 14px 22px !important;
    border-radius: 20px !important;
    cursor: pointer;
    box-shadow: 0 20px 42px rgba(15, 102, 176, 0.14) !important;
    transition: all 0.3s ease !important;
    font-size: 18px !important;
    font-weight: 700 !important;
    margin-bottom: 10px !important;
    margin-left: 10px !important;
    backdrop-filter: blur(14px) !important;
    letter-spacing: 0.01em !important;
}

.clear-depth-btn:hover {
    background: linear-gradient(135deg, rgba(255, 68, 68, 0.26), rgba(255, 136, 136, 0.22)) !important;
    color: white !important;
    transform: translateY(-2px);
    box-shadow: 0 22px 46px rgba(15, 102, 176, 0.2) !important;
}

.clear-depth-btn .button-icon {
    width: 18px !important;
    height: 18px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
}

.clear-depth-btn .button-icon svg {
    width: 18px !important;
    height: 18px !important;
    fill: currentColor !important;
}

/* 4. Layer-Menü rechts oben verfeinern */
/* Der Style ist bereits oben definiert, doppelte Definition entfernt. */

/* Überschrift im Layer-Menü hinzufügen */
.leaflet-control-layers-list::before {
    content: "KARTEN-EBENEN";
    /* Hier kannst du deinen Text ändern */
    display: block;
    text-align: center;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif !important;
    font-size: 18px;
    color: #0F66B0;
    /* Skyability Orange */
    margin-bottom: 10px;
    letter-spacing: 1px;
    border-bottom: 1px solid #eee;
    padding-bottom: 5px;
}

/* Suche diesen Block in deiner style.css oder füge ihn hinzu */
.depth-hover-popup {
    pointer-events: none !important;
    /* Die Maus geht "durch" das Popup durch */
    cursor: pointer !important;
    /* Erzwingt den normalen Cursor auf dem Popup */
}

/* Verhindert, dass die Karte auf "grab" umschaltet, während das Popup aktiv ist */
.leaflet-container.leaflet-crosshair,
.leaflet-container {
    cursor: grab;
    /* Standard für die Karte */
}

/* Normale Maus während der Tiefen-Hover-Anzeige */
.leaflet-container.depth-hover-cursor-default {
    cursor: pointer !important;
}

/* --- Ultra-Clean Mobile UI Reset --- */
@media (max-width: 1024px) {

    /* 1. TITEL: Kompakter Header oben links */
    .map-title {
        top: 15px !important;
        left: 15px !important;
        padding: 6px 12px !important;
        font-size: 22px !important;
        max-width: 50vw !important;
        /* Blockiert nur die linke Hälfte */
        border-radius: 10px !important;
        border-left: 3px solid var(--accent) !important;
        background: rgba(255, 255, 255, 0.9) !important;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1) !important;
        z-index: 1000 !important;
        pointer-events: none;
        /* Klicks gehen durch den Titel auf die Karte */
    }

    /* 2. LAYER-BUTTON: Ganz nach rechts rücken */
    .leaflet-top.leaflet-right {
        margin-top: 0px !important;
        margin-right: 0px !important;
        z-index: 2000 !important;
    }

    .leaflet-control-layers {
        background: transparent !important;
        border: none !important;
        box-shadow: none !important;
        padding: 0 !important;
        margin-right: 15px !important;
        margin-top: 15px !important;
    }

    .leaflet-control-layers-toggle {
        width: 54px !important;
        height: 54px !important;
        background-color: white !important;
        border-radius: 50% !important;
        box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2) !important;
        margin-left: auto !important;
    }

    /* 3. LÖSCH-BUTTON: Wird zum runden Icon (FAB) unten links */
    .clear-depth-btn {
        position: fixed !important;
        bottom: 15px !important;
        left: 15px !important;
        width: 54px !important;
        height: 54px !important;
        padding: 0 !important;
        border-radius: 50% !important;
        background: white !important;
        border: 2px solid #ff4444 !important;
        display: flex !important;
        align-items: center;
        justify-content: center;
        box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2) !important;
        z-index: 2000 !important;
        margin: 0 !important;
    }

    /* Text "Alle Messpunkte..." auf Mobile verstecken */
    .clear-depth-btn span:not(.button-icon) {
        display: none !important;
    }

    .clear-depth-btn .button-icon svg {
        width: 24px !important;
        height: 24px !important;
        fill: #ff4444 !important;
        margin: 0 !important;
    }

    /* 4. WASSERZEICHEN: Massiv schrumpfen und nach rechts rücken */
    .leaflet-bottom.leaflet-right .map-watermark {
        /* Diese Werte werden durch die obere .map-watermark Regel überschrieben */
        position: absolute !important;
        right: auto !important;
        /* Rechtsbündigkeit aufheben */
    }

    .map-watermark {
        bottom: 30px !important;
        /* Ein Stück höher als auf Desktop */
        transform: translateX(-50%) scale(1) !important;
        /* Deutlich kleiner auf dem Handy */
    }

    .leaflet-control-zoom {
        position: fixed !important;
        /* Abstand vom rechten Rand inkl. Safari-Sicherheitszone */
        right: calc(15px + env(safe-area-inset-right, 0px)) !important;
        /* Abstand von unten, damit sie über dem Leaflet-Text schweben */
        bottom: 15px !important;
        margin: 0 !important;
        border: none !important;
        z-index: 2000 !important;
        /* Gleiche Ebene wie der Lösch-Button */
    }

    /* 5. ZOOM: Etwas kompakter */
    .leaflet-bottom.leaflet-right {
        margin: 0 !important;
        pointer-events: none;
        /* Verhindert, dass der unsichtbare Container Klicks abfängt */
    }

    .leaflet-bar a {
        width: 50px !important;
        height: 50px !important;
        line-height: 50px !important;
        background: white !important;
        backdrop-filter: blur(10px);
        border-radius: 12px !important;
        margin-bottom: 3px !important;
        box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15) !important;
    }

    .leaflet-control-layers-list {
        padding: 16px !important;
    }

    .leaflet-control-attribution {
        position: fixed !important;
        right: 0 !important;
        bottom: 0 !important;
        margin: 0 !important;
        padding: 2px 10px 0px 10px !important;
        background: rgba(255, 255, 255, 0.5) !important;
        font-size: 10px !important;
        pointer-events: auto;
        /* Text bleibt für Klicks/Links aktiv */
    }

    .selector-content {
        width: calc(100% - 30px);
        /* Weniger Rand auf schmalen Handys */
        padding: 10px;
    }

    .selector-panel {
        padding: 20px;
        /* Kompakteres Padding */
        border-radius: 24px;
    }

    .selector-header h1 {
        font-size: 1.8rem;
        /* Titel etwas kleiner */
    }

    .project-grid {
        grid-template-columns: 1fr !important;
        /* Erzwingt eine Spalte bei 4 Projekten */
    }

    .project-card {
        padding: 20px;
        min-height: 120px;
        /* Etwas flacher auf Mobile */
    }

    .selector-panel {
        padding: 24px 16px;
        /* Etwas kompakter auf Handys */
    }
}

/* Erzeugt eine spezielle Ebene für Layer, die multipliziert werden sollen */
.leaflet-multiply-pane {
    mix-blend-mode: multiply;
    z-index: 450;
    /* Liegt über den Standard-Tiles, aber unter Popups */
    pointer-events: none;
    /* Klicks gehen durch die Ebene durch auf die Karte */
}
