@layer pm-map {
    .pm-container {
        position: relative;
        isolation: isolate;
        width: 100%;
        height: 600px;
        overflow: hidden;
        border-radius: 12px;
        box-sizing: border-box;
    }

    #pm-map {
        position: absolute;
        inset: 0;
        width: 100%;
        height: 100%;
        z-index: 1;
    }

    #pm-filters {
        position: absolute;
        top: 12px;
        left: 12px;
        z-index: 2;
        display: flex;
        flex-direction: column;
        gap: 2px;
        max-height: calc(100% - 24px);
        overflow-y: auto;
        overflow-x: hidden;
        background: rgba(255, 255, 255, 0.96);
        backdrop-filter: blur(6px);
        -webkit-backdrop-filter: blur(6px);
        border-radius: 10px;
        padding: 6px;
        box-shadow: 0 2px 14px rgba(0, 0, 0, 0.16);
        min-width: 148px;
        scrollbar-width: thin;
        scrollbar-color: #c5cee0 transparent;
    }

    #pm-filters:empty {
        display: none;
    }

    #pm-filters:not(.expanded) .pm-filter-btn:not(.active) {
        display: none;
    }

    #pm-filters:not(.expanded) {
        cursor: pointer;
    }

    .pm-filter-btn {
        display: block;
        width: 100%;
        padding: 8px 12px;
        background: transparent;
        border: none;
        border-radius: 6px;
        color: #333;
        font-family: Roboto, sans-serif;
        font-size: 13px;
        font-weight: 500;
        text-align: left;
        cursor: pointer;
        white-space: nowrap;
        transition:
            background 0.15s,
            color 0.15s;
    }

    .pm-filter-btn:hover {
        background: #f0f3fb;
        color: #3d5a9e;
    }

    .pm-filter-btn.active {
        background: #3d5a9e;
        color: #fff;
    }

    .pm-balloon {
        width: 240px;
        font-family: Roboto, sans-serif;
        overflow: hidden;
        box-sizing: border-box;
    }

    .pm-balloon img {
        display: block;
        width: calc(100% - 24px);
        height: 140px;
        object-fit: cover;
        border-radius: 6px;
        margin: 12px 12px 0;
    }

    .pm-balloon-body {
        padding: 12px;
    }

    .pm-balloon-title {
        font-weight: 700;
        font-size: 14px;
        color: #1a1a1a;
        margin-bottom: 6px;
        line-height: 1.3;
    }

    .pm-balloon-tech-label {
        display: inline;
        font-size: 10px;
        font-weight: 700;
        letter-spacing: 0.08em;
        text-transform: uppercase;
        color: #aaa;
        margin-right: 6px;
    }

    .pm-balloon-tag {
        display: inline-block;
        padding: 2px 8px;
        background: #f0f3fb;
        color: #3d5a9e;
        font-size: 11px;
        border-radius: 3px;
        margin-bottom: 10px;
    }

    .pm-balloon-spacer {
        margin-bottom: 10px;
    }

    .pm-balloon-btn {
        display: block;
        text-align: center;
        padding: 8px;
        background: #3d5a9e;
        color: #fff;
        text-decoration: none;
        border-radius: 4px;
        font-size: 13px;
        font-weight: 500;
        letter-spacing: 0.3px;
        transition: background 0.15s;
    }

    .pm-balloon-btn:hover {
        background: #2d4a8e;
    }

    /* ── Switcher nav ───────────────────────────────────────── */

    .pm-switcher-nav {
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 8px;
        padding: 8px 12px 12px;
        border-top: 1px solid #eee;
    }

    .pm-switcher-btn {
        width: 28px;
        height: 28px;
        display: flex;
        align-items: center;
        justify-content: center;
        background: none;
        border: 1px solid #ddd;
        border-radius: 4px;
        font-size: 18px;
        color: #3d5a9e;
        cursor: pointer;
        transition: background 0.15s;
        padding: 0;
    }

    .pm-switcher-btn:hover:not(:disabled) {
        background: #f0f3fb;
    }

    .pm-switcher-btn:disabled {
        color: #ccc;
        border-color: #eee;
        cursor: default;
    }

    .pm-switcher-count {
        font-size: 12px;
        color: #888;
        font-family: Roboto, sans-serif;
        min-width: 36px;
        text-align: center;
    }

    @media (max-width: 1024px) {
        .pm-container {
            height: 500px;
        }
    }

    @media (max-width: 640px) {
        .pm-container {
            height: 25dvh;
            min-height: 220px;
            border-radius: 8px;
        }

        #pm-filters {
            flex-direction: row;
            flex-wrap: nowrap;
            top: auto;
            bottom: 12px;
            left: 8px;
            right: 8px;
            max-height: none;
            min-width: unset;
            overflow-x: auto;
            overflow-y: hidden;
            padding: 6px 8px;
            scrollbar-width: none;
        }

        #pm-filters::-webkit-scrollbar {
            display: none;
        }

        .pm-filter-btn {
            flex-shrink: 0;
            width: auto;
            font-size: 12px;
            padding: 6px 10px;
        }

        #pm-filters:not(.expanded) .pm-filter-btn:not(.active) {
            display: block;
        }

        #pm-filters:not(.expanded) {
            cursor: default;
        }

        #pm-filters:not(.expanded) .pm-filter-btn.active::after {
            content: none;
        }
    }
}

#pm-sheet {
    display: none;
}

.yandex__link__to_map {
    margin-left: 0 !important;
    margin-top: 25px;
}

@media (max-width: 640px) {
    #pm-sheet {
        display: flex;
        align-items: flex-end;
        position: fixed;
        inset: 0;
        z-index: 100000;
        background: rgba(0, 0, 0, 0.45);
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.25s ease;
    }

    #pm-sheet.open {
        opacity: 1;
        pointer-events: auto;
    }

    .pm-sheet-inner {
        width: 100%;
        background: #fff;
        border-radius: 16px 16px 0 0;
        box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.18);
        transform: translateY(100%);
        transition: transform 0.3s ease;
        position: relative;
        padding-top: 48px;
    }

    #pm-sheet.open .pm-sheet-inner {
        transform: translateY(0);
    }

    .pm-sheet-inner::before {
        content: "";
        display: block;
        position: absolute;
        top: 10px;
        left: 50%;
        transform: translateX(-50%);
        width: 36px;
        height: 4px;
        border-radius: 2px;
        background: #ddd;
    }

    .pm-sheet-close {
        position: absolute;
        top: 0;
        right: 0;
        width: 48px;
        height: 48px;
        display: flex;
        align-items: center;
        justify-content: center;
        background: none;
        border: none;
        font-size: 18px;
        color: #888;
        cursor: pointer;
    }

    #pm-sheet .pm-balloon {
        width: 100%;
    }

    #pm-sheet .pm-balloon img {
        width: calc(100% - 24px);
        height: 160px;
    }
}

#pm-filters {
    padding: 6px;
}
.pm-filter-btn {
    padding: 8px 12px;
}
.pm-balloon-body {
    padding: 12px;
}
.pm-balloon-tag {
    padding: 2px 8px;
}
.pm-balloon-btn {
    padding: 8px;
}
.pm-balloon img {
    margin: 12px 12px 0;
}
.pm-switcher-nav {
    padding: 8px 12px 12px;
}
.pm-switcher-btn {
    padding: 0;
}

@media (max-width: 640px) {
    #pm-filters {
        padding: 6px 8px;
    }
    .pm-filter-btn {
        padding: 6px 10px;
    }
}

[class*="-balloon__close"] {
    display: none !important;
}

[class*="-balloon__close"] + [class*="-balloon__content"] {
    margin-right: 0 !important;
    padding-right: 0 !important;
}

[class*="-balloon__content"] {
    padding: 0 !important;
}

.pm-margin {
    margin-top: 2rem !important;
    margin-bottom: 2rem !important;
}
