.zl-district-map {
    margin-block-end: 24px;
    --map-ink: var(--zl-ui-ink, #182c39);
    --map-muted: var(--zl-ui-muted, #526874);
    --map-line: var(--zl-ui-line, #dbe5eb);
    --map-surface: var(--zl-ui-surface, #fff);
    --map-soft: var(--zl-ui-soft, #f3f7fa);
    --map-accent: var(--zl-ui-accent, #15679a);
    --map-hover: var(--zl-ui-hover, #eaf3f9);
}

.zl-district-map > .zl-district-map__frame {
    display: flex;
    flex-direction: column;
    height: auto;
    border-color: var(--map-line);
    border-radius: 14px;
    background: var(--map-surface);
    color: var(--map-ink);
}

.zl-district-map__frame:is(:fullscreen, .maplibregl-pseudo-fullscreen) {
    height: 100%;
    border: 0;
    border-radius: 0;
}

.zl-district-map__toolbar {
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    min-height: 62px;
    padding: 7px max(15px, env(safe-area-inset-right)) 7px max(17px, env(safe-area-inset-left));
    border-bottom: 1px solid var(--map-line);
}

.zl-district-map__frame:is(:fullscreen, .maplibregl-pseudo-fullscreen) .zl-district-map__toolbar {
    padding-top: max(7px, env(safe-area-inset-top));
}

.zl-district-map__toolbar h2 {
    margin: 0;
    font-size: clamp(15px, 1.45vw, 19px);
    font-weight: 650;
    line-height: 1.2;
    color: var(--map-ink);
}

.zl-district-map__count {
    display: block;
    margin-top: 3px;
    color: var(--map-muted);
    font-size: 12px;
    line-height: 1.25;
}

.zl-district-map__count:empty { display: none; }

.zl-district-map__toolbar .zl-district-map__basemap {
    display: flex;
    flex: 0 0 auto;
    position: static;
    padding: 3px;
    border: 1px solid var(--map-line);
    border-radius: 8px;
    background: var(--map-soft);
    box-shadow: none;
}

.zl-district-map__toolbar .zl-district-map__basemap button {
    min-height: 36px;
    padding: 5px 10px;
    background: transparent;
    color: var(--map-muted);
    font-size: 12px;
    font-weight: 550;
}

.zl-district-map__toolbar .zl-district-map__basemap button[aria-pressed="true"] {
    background: var(--map-surface);
    color: var(--map-accent);
    box-shadow: 0 1px 3px #122d3e21;
}

.zl-district-map__workspace {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr);
    height: clamp(290px, 34vh, 350px);
    min-height: 0;
}

.zl-district-map__workspace:has(.zl-district-map__panel) {
    grid-template-columns: minmax(0, 1fr) clamp(264px, 26%, 344px);
}

.zl-district-map__frame:is(:fullscreen, .maplibregl-pseudo-fullscreen) .zl-district-map__workspace {
    flex: 1 1 auto;
    height: auto;
}

.zl-district-map__frame:is(:fullscreen, .maplibregl-pseudo-fullscreen) .zl-district-map__workspace:not(:has(.has-selection)) {
    grid-template-columns: minmax(0, 1fr);
}

.zl-district-map__frame:is(:fullscreen, .maplibregl-pseudo-fullscreen) .zl-district-map__panel:not(.has-selection) {
    display: none;
}

.zl-district-map__surface {
    position: relative;
    min-height: 0;
    min-width: 0;
    isolation: isolate;
    background: #e2ebe8;
}

.zl-district-map__surface .maplibregl-ctrl-top-right {
    display: flex;
    gap: 6px;
    top: 10px;
    right: max(10px, env(safe-area-inset-right));
}

.zl-district-map__surface .maplibregl-ctrl-top-right .maplibregl-ctrl-group {
    display: flex;
    margin: 0;
    border-color: #c2d0d4;
    border-radius: 8px;
    box-shadow: 0 2px 7px #102b4329;
}

.zl-district-map__surface .maplibregl-ctrl-top-right .maplibregl-ctrl-group button + button {
    border-top: 0;
    border-left: 1px solid #dbe5e7;
}

.zl-district-map__surface .maplibregl-ctrl-bottom-right {
    right: max(0px, env(safe-area-inset-right));
}

.zl-district-map__surface .maplibregl-ctrl-attrib {
    font-size: 10px;
}

.zl-district-map__map-actions {
    position: absolute;
    z-index: 2;
    bottom: max(10px, env(safe-area-inset-bottom));
    left: max(10px, env(safe-area-inset-left));
    display: flex;
    align-items: center;
    gap: 7px;
}

.zl-district-map__legend {
    display: none;
    align-items: center;
    gap: 6px;
    padding: 4px 7px;
    border: 1px solid #c2d0d4;
    border-radius: 5px;
    background: #fff;
    color: #36505c;
    font-size: 10px;
    line-height: 1.25;
    pointer-events: none;
}

.zl-district-map__legend::before {
    content: '';
    width: 8px;
    height: 8px;
    border: 1px solid #82601b;
    border-radius: 50%;
    background: #ffd456;
}

@media (min-width: 768px) {
    .zl-district-map.has-clusters .zl-district-map__legend { display: flex; }
}

.zl-district-map__overview {
    min-height: 40px;
    padding: 4px 11px;
    border: 1px solid #c2d0d4;
    border-radius: 8px;
    background: #fff;
    color: #223c49;
    box-shadow: 0 2px 7px #102b4329;
    font: inherit;
    font-size: 12px;
    font-weight: 650;
}

.zl-district-map__overview span {
    margin-right: 3px;
    font-size: 16px;
    line-height: 1;
    vertical-align: -1px;
}

.zl-district-map__overview:disabled { display: none; }

.zl-district-map__cluster.maplibregl-marker {
    display: grid;
    place-items: center;
    min-width: 31px;
    height: 31px;
    padding: 0 7px;
    border: 1px solid #82601b;
    border-radius: 22px;
    background: #ffd456;
    color: #302008;
    box-shadow: 0 0 0 2px #ffffffd9, 0 2px 8px #35290745;
    font: 700 12px/1 system-ui, sans-serif;
    white-space: nowrap;
    cursor: pointer;
}

.zl-district-map__cluster.maplibregl-marker:hover {
    background: #ffe794;
    z-index: 1;
}

.zl-district-map__panel {
    overflow: auto;
    overscroll-behavior: contain;
    min-width: 0;
    min-height: 0;
    border-left: 1px solid var(--map-line);
    background: var(--map-surface);
    scrollbar-width: thin;
}

.zl-district-map :is([data-map-browse], [data-map-preview], [data-map-preview] img)[hidden] {
    display: none;
}

.zl-district-map__browse > h3 {
    position: sticky;
    z-index: 1;
    top: 0;
    margin: 0;
    padding: 13px 15px 10px;
    border-bottom: 1px solid var(--map-line);
    background: var(--map-surface);
    color: var(--map-muted);
    font-size: 12px;
    font-weight: 650;
    line-height: 1.3;
}

.zl-district-map__options {
    padding: 3px 8px 8px;
}

.zl-district-map__options button {
    position: relative;
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    min-height: 48px;
    padding: 8px 28px 8px 8px;
    border: 0;
    border-bottom: 1px solid var(--map-line);
    background: transparent;
    color: var(--map-ink);
    font: inherit;
    text-align: left;
    cursor: pointer;
}

.zl-district-map__options button[aria-pressed] {
    min-height: 40px;
    padding-block: 5px;
}

.zl-district-map__options button::after {
    content: '';
    position: absolute;
    top: calc(50% - 3.5px);
    right: 10px;
    width: 7px;
    height: 7px;
    transform: rotate(-45deg);
    border-right: 1.5px solid var(--map-muted);
    border-bottom: 1.5px solid var(--map-muted);
}

.zl-district-map__options button:hover,
.zl-district-map__options button[aria-pressed="true"] {
    border-radius: 6px;
    background: var(--map-hover);
}

.zl-district-map__options button > span { min-width: 0; }

.zl-district-map__options img {
    flex: 0 0 42px;
    width: 42px;
    height: 40px;
    object-fit: cover;
    border-radius: 5px;
    background: var(--map-soft);
}

.zl-district-map__options strong {
    display: -webkit-box;
    overflow: hidden;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    font-size: 13px;
    font-weight: 650;
    line-height: 1.3;
}

.zl-district-map__options small {
    display: block;
    margin-top: 3px;
    color: var(--map-muted);
    font-size: 11px;
    line-height: 1.2;
}

.zl-district-map__picker { display: none; }

.zl-district-map__preview {
    padding: 10px 14px 15px;
}

.zl-district-map__preview-top {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    min-height: 34px;
    margin: -3px 0 4px;
}

.zl-district-map__preview-top button {
    min-height: 38px;
    padding: 4px 9px;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: var(--map-accent);
    font: inherit;
    font-size: 12px;
}

.zl-district-map__preview-top button:hover { background: var(--map-soft); }

.zl-district-map__preview img {
    display: block;
    width: 100%;
    height: 90px;
    object-fit: cover;
    border-radius: 7px;
    background: var(--map-soft);
}

.zl-district-map__preview h3 {
    margin: 5px 0 6px;
    color: var(--map-ink);
    font-size: 16px;
    line-height: 1.3;
}

.zl-district-map__preview :is([data-preview-place], [data-preview-facts], [data-preview-cad]) {
    display: block;
    color: var(--map-muted);
    font-size: 12px;
    line-height: 1.35;
}

.zl-district-map__preview [data-preview-place] { margin-top: 8px; }

.zl-district-map__preview [data-preview-cad] { margin-top: 5px; }

.zl-district-map__preview :is([data-preview-place], [data-preview-facts], [data-preview-cad], [data-preview-related]):empty {
    display: none;
}

.zl-district-map__preview :is([data-preview-link], [data-preview-related] a) {
    display: block;
    margin-top: 8px;
    padding: 5px 0;
    color: var(--map-accent);
    font-size: 13px;
    font-weight: 650;
    text-decoration: underline;
    text-underline-offset: 3px;
}

.zl-district-map__status a {
    display: block;
    margin-top: 6px;
    color: #12517b;
    text-decoration: underline;
    pointer-events: auto;
}

.zl-district-map__status a[hidden] { display: none; }

.zl-district-map :is(button, select, a):focus-visible {
    outline: 2px solid var(--map-accent) !important;
    outline-offset: -3px;
}

@media (max-width: 767px) {
    .zl-district-map__toolbar {
        min-height: 54px;
        padding-inline: max(10px, env(safe-area-inset-left)) max(8px, env(safe-area-inset-right));
    }

    .zl-district-map__toolbar .zl-district-map__basemap button {
        min-height: 34px;
        padding-inline: 8px;
    }

    .zl-district-map__workspace,
    .zl-district-map__workspace:has(.zl-district-map__panel) {
        display: flex;
        flex-direction: column;
        height: auto;
    }

    .zl-district-map__surface {
        flex: 1 1 auto;
        min-height: clamp(184px, 33svh, 235px);
    }

    .zl-district-map__canvas {
        position: absolute;
        inset: 0;
    }

    .zl-district-map__workspace:not(:has(.zl-district-map__panel)) .zl-district-map__surface {
        min-height: 230px;
    }

    .zl-district-map__panel {
        flex: 0 0 auto;
        max-height: 225px;
        border-top: 1px solid var(--map-line);
        border-left: 0;
    }

    .zl-district-map__options,
    .zl-district-map__browse > h3 {
        display: none;
    }

    .zl-district-map__picker {
        display: block;
        width: 100%;
        min-height: 43px;
        padding: 0 12px;
        border: 0;
        border-radius: 0;
        background: var(--map-surface);
        color: var(--map-ink);
        font: inherit;
        font-size: 13px;
    }

    .zl-district-map__preview {
        display: grid;
        grid-template-columns: minmax(0, 1fr) 84px;
        align-items: start;
        gap: 3px 10px;
        padding: 7px 11px 10px;
        scroll-margin-block-end: calc(134px + env(safe-area-inset-bottom));
    }

    .zl-district-map__preview-top {
        grid-column: 1 / -1;
        margin-bottom: 0;
    }

    .zl-district-map__preview img {
        grid-column: 2;
        grid-row: 2;
        height: 72px;
    }

    .zl-district-map__preview h3 { font-size: 14px; }

    .zl-district-map__preview [data-preview-place] { margin-top: 0; }

    .zl-district-map__preview [data-preview-related] { grid-column: 1 / -1; }
}
