.listing-thumbnail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(64px, 1fr));
    gap: 0.5rem;
    align-items: stretch;
    padding: 0;
    background: transparent;
}

.listing-gallery-thumb {
    width: 100%;
    height: 100%;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    overflow: hidden;
    background: #f8fafc;
    padding: 0;
    cursor: pointer;
    transition: opacity 0.2s ease, transform 0.2s ease, border-color 0.2s ease;
}

.listing-gallery-thumb:hover,
.listing-gallery-thumb:focus-visible {
    transform: translateY(-1px);
    border-color: #cbd5e1;
    opacity: 0.96;
}

.listing-gallery-thumb img {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
}

.listing-gallery-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.86);
    display: none;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    z-index: 5000;
    padding: 1.5rem;
}

.listing-gallery-overlay.is-open {
    display: flex;
}

body.gallery-open .leaflet-control-container,
body.gallery-open .leaflet-control,
body.gallery-open .leaflet-top,
body.gallery-open .leaflet-bottom {
    z-index: 0 !important;
}

.listing-gallery-overlay img {
    max-width: 92vw;
    max-height: 82vh;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(15, 23, 42, 0.35);
    background: #fff;
}

.listing-gallery-overlay-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    width: 42px;
    height: 42px;
    border: none;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
    font-size: 1.6rem;
    cursor: pointer;
}

.listing-gallery-nav {
    width: 42px;
    height: 42px;
    border: 1px solid rgba(255, 255, 255, 0.5);
    border-radius: 999px;
    background: rgba(15, 23, 42, 0.38);
    color: #fff;
    font-size: 1.2rem;
    cursor: pointer;
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 2;
}

.listing-gallery-nav.listing-gallery-prev {
    left: max(0.75rem, env(safe-area-inset-left));
}

.listing-gallery-nav.listing-gallery-next {
    right: max(0.75rem, env(safe-area-inset-right));
}

@media (max-width: 640px) {
    .listing-thumbnail-grid {
        grid-template-columns: repeat(auto-fit, minmax(68px, 1fr));
        gap: 0.55rem;
    }

    .listing-gallery-overlay {
        padding: max(0.75rem, env(safe-area-inset-top)) max(0.75rem, env(safe-area-inset-right)) max(0.75rem, env(safe-area-inset-bottom)) max(0.75rem, env(safe-area-inset-left));
        gap: 0;
    }

    .listing-gallery-overlay-close {
        top: max(0.75rem, env(safe-area-inset-top));
        right: max(0.75rem, env(safe-area-inset-right));
    }

    .listing-gallery-nav {
        width: 38px;
        height: 38px;
    }
}
