#map {
    height: 600px;
    width: 100%;
}

@media (max-width: 768px) {
    #map {
        height: clamp(320px, 66.67vh, 640px);
    }

    /* 1. Weiße Box ebenfalls in der Höhe deckeln */
    .leaflet-popup-content-wrapper {
        width: auto !important;
        max-width: calc(100vw - 32px);
        max-height: 40vh !important;
    }

    /* 2. Scrollen erzwingen und Text einpassen */
    .leaflet-popup-content,
    .leaflet-popup-scrolled {
        width: 240px !important;
        max-height: calc(40vh - 24px) !important;
        overflow-y: auto !important;             /* Schaltet das Scrollen wieder ein */
        -webkit-overflow-scrolling: touch;       /* Flüssiges Scrollen auf Smartphones */
        margin: 12px 14px;
        font-size: 0.85rem;
        line-height: 1.45;
        white-space: normal;
        overflow-wrap: break-word;
    }
}

.info.legend {
    background: white;
    padding: 8px 12px;
    border-radius: 5px;
    box-shadow: 0 0 15px rgba(0, 0, 0, 0.2);
    color: #333;
    font-family: Arial, sans-serif;
    font-size: 14px;
}

.legend-toggle {
    min-height: 36px;
    padding: 0;
    border: 0;
    background: transparent;
    color: inherit;
    font: inherit;
    font-weight: bold;
    text-align: left;
    cursor: pointer;
}

.legend-toggle:focus-visible {
    outline: 2px solid #2563eb;
    outline-offset: 2px;
}

.legend-items {
    display: grid;
    gap: 4px;
    line-height: 24px;
}

.legend-items[hidden] {
    display: none;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
}

.legend-swatch {
    width: 14px;
    height: 14px;
    flex: 0 0 14px;
    border: 1px solid #00000040;
    border-radius: 50%;
}

@media (max-width: 768px) {
    .info.legend {
        padding: 4px 10px;
    }

    .legend-toggle {
        min-height: 40px;
    }
}
