body.mer-map-page {
    margin: 0;
    background: #f5f7fb;
    color: #172638;
}

.mer-map-page #mer_mobile_main_sidebar,
.mer-map-page #mer_mobile_user_sidebar {
    position: fixed;
    top: 0;
    right: 0;
    width: min(360px, 80vw);
    height: 100vh;
    max-height: 100vh;
    transform: translateX(100%);
    z-index: 10600;
    display: block;
    overflow-y: auto;
    visibility: hidden;
    pointer-events: none;
    background: #111111;
    border-left: 1px solid rgba(255, 255, 255, 0.08);
}

.mer-map-page #mer_mobile_main_sidebar.visible,
.mer-map-page #mer_mobile_user_sidebar.visible,
.mer-map-page #mer_mobile_main_sidebar.animating,
.mer-map-page #mer_mobile_user_sidebar.animating {
    transform: translateX(0);
    visibility: visible;
    pointer-events: auto;
}

.mer-map-page-container {
    width: 100% !important;
    max-width: none !important;
    margin: 0 auto;
}

.mer-map-first-segment > .ui.aligned.stackable.grid.container {
    width: min(1760px, calc(100vw - 24px)) !important;
    max-width: none !important;
}

.mer-map-page-section {
    padding: 28px 20px 40px;
}

.mer-map-page-container {
    padding-top: 0;
}

.mer-map-breadcrumb {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0 0 18px;
    color: #5b6b7f;
    font-size: 0.92rem;
}

.mer-map-breadcrumb a {
    color: #0f4c81;
    text-decoration: none;
}

.mer-map-breadcrumb a:hover,
.mer-map-breadcrumb a:focus {
    text-decoration: underline;
}

/* Map page shell */
.mer-map-page-layout {
    padding: 10px 0 20px 0;
}

.mer-map-page-hero {
    max-width: 820px;
}

.mer-map-page-hero h1 {
    margin: 0 0 6px 0;
    font-size: 1.6rem;
}

.mer-map-page-hero p {
    margin: 0 0 14px 0;
    color: #4b5563;
}

/* Map wrapper */
.mer-map-breakout {
    width: 100%;
}

#mer-map-root {
    --mer-map-sheet-offset: 0px;
    --mer-map-desktop-sidebar-offset: 0px;
    position: relative;
    width: 100%;
    height: 80vh;
    min-height: 660px;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    overflow: hidden;
    background: #fff;
}

/* Sidebar (Desktop) */
.mer-map-sidebar {
    position: absolute;
    top: 14px;
    left: 14px;
    bottom: 14px;
    width: min(300px, calc(100% - 28px));
    max-width: calc(100% - 28px);
    background: rgba(255, 255, 255, 0.97);
    border: 1px solid #d8e1eb;
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 3;
    box-shadow: 0 18px 44px rgba(15, 23, 42, 0.16);
    backdrop-filter: blur(10px);
}

.mer-map-sidebar-header {
    padding: 12px 12px 10px;
    border-bottom: 1px solid #e8edf3;
    background: linear-gradient(180deg, rgba(249, 251, 254, 0.96) 0%, rgba(243, 247, 252, 0.96) 100%);
}

.mer-map-sidebar-title-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.mer-map-sidebar-title-row h2 {
    margin: 0;
}

.mer-map-sheet-toggle {
    display: inline-flex;
    border: 1px solid #b9c5d8;
    border-radius: 999px;
    background: #fff;
    color: #1f3d5b;
    padding: 7px 11px;
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.01em;
}

.mer-map-mobile-hint {
    display: none;
    margin: 8px 0 0;
    color: #4d6179;
    font-size: 0.85rem;
    line-height: 1.35;
}

.mer-map-toggle-container {
    display: flex;
    margin-bottom: 5px;
    background: #e5e7eb;
    border-radius: 8px;
    padding: 3px;
    gap: 3px;
}

.mer-map-toggle {
    flex: 1;
    border: none;
    background: transparent;
    padding: 9px 8px;
    font-size: 0.88rem;
    line-height: 1.15;
    cursor: pointer;
    border-radius: 6px;
    color: #526178;
    font-weight: 700;
}

.mer-map-toggle.active {
    background: #fff;
    color: #142d47;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.mer-map-legend {
    margin-top: 8px;
    color: #6b7280;
    font-size: 0.82rem;
    line-height: 1.35;
}

.mer-venue-list {
    flex: 1;
    overflow-y: auto;
    padding: 0;
}

/* Venue Item */
.mer-venue-item {
    padding: 13px 14px;
    border-bottom: 1px solid #eef0f3;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s, box-shadow 0.2s, transform 0.2s;
}

.mer-venue-item:hover {
    background: #f0f7ff;
}

.mer-venue-item.active {
    background: linear-gradient(180deg, #eef6ff 0%, #e4f0ff 100%);
    border-left: 4px solid #0056b3;
    padding-left: 10px;
    box-shadow: inset 0 0 0 1px rgba(0, 86, 179, 0.12);
}

.mer-venue-name {
    font-weight: 700;
    font-size: 1rem;
    margin-bottom: 4px;
    color: #22313f;
}

.mer-venue-location {
    font-size: 0.9rem;
    color: #516173;
    margin-bottom: 4px;
}

.mer-venue-geo {
    font-size: 0.9rem;
    color: #516173;
    margin-bottom: 4px;
}

.mer-map-popup-subtle {
    color: #64748b;
}

.mer-venue-meta {
    font-size: 0.84rem;
    color: #6b7280;
}

.mer-venue-count-badge,
.mer-venue-future-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 24px;
    padding: 2px 7px;
    border-radius: 999px;
    font-size: 0.75rem;
    margin-left: 6px;
    font-weight: 700;
    vertical-align: middle;
}

.mer-venue-count-badge {
    background: #0056b3;
    color: #fff;
}

.mer-venue-future-badge {
    background: #f1ecf7;
    color: #5c3d88;
}

/* Map Container */
#mer-map-container {
    position: relative;
    width: 100%;
    height: 100%;
    background: #e5e3df;
}

.mer-map-footer {
    background: #10263c;
    color: #d9e4ef;
    margin-top: 36px;
}

.mer-map-footer__inner {
    max-width: 1180px;
    margin: 0 auto;
    padding: 24px 20px 32px;
    display: grid;
    grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr);
    gap: 24px;
}

.mer-map-footer h2 {
    margin: 0 0 8px;
    font-size: 1rem;
    color: #fff;
}

.mer-map-footer p {
    margin: 0 0 6px;
    line-height: 1.5;
}

.mer-map-footer__links {
    display: grid;
    gap: 10px;
    align-content: start;
}

.mer-map-footer__links a {
    color: #d9e4ef;
    text-decoration: none;
}

.mer-map-footer__links a:hover,
.mer-map-footer__links a:focus {
    color: #fff;
    text-decoration: underline;
}

/* Premium-ish popup styling without changing the map's overall look */
#mer-map-root .mapboxgl-popup-content {
    border-radius: 12px;
    padding: 12px 12px 10px;
    box-shadow: 0 18px 50px rgba(15, 23, 42, 0.20);
    border: 1px solid rgba(15, 23, 42, 0.08);
}

#mer-map-root .mapboxgl-popup-close-button {
    width: 28px;
    height: 28px;
    border-radius: 8px;
    line-height: 26px;
    font-size: 20px;
    color: #2b3a4a;
}

.mer-map-popup-title {
    font-weight: 800;
    font-size: 0.98rem;
    color: #0f172a;
    margin: 0 0 4px;
}

.mer-map-popup-sub {
    color: #475569;
    font-size: 0.88rem;
    line-height: 1.25;
    margin: 0 0 8px;
}

.mer-map-popup-sep {
    margin: 0 6px;
    color: #94a3b8;
}

.mer-map-popup-meta small {
    color: #64748b;
}

.mer-map-popup-cta {
    margin-top: 10px;
}

.mer-map-popup-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 12px;
    border-radius: 10px;
    background: #0056b3;
    color: #ffffff;
    font-weight: 800;
    letter-spacing: 0.01em;
    text-decoration: none;
}

.mer-map-popup-link:hover {
    background: #004a99;
    color: #ffffff;
}

.mer-map-popup-list {
    margin: 8px 0 0;
    padding-left: 16px;
}

/* Keep map controls visible above mobile bottom sheet */
#mer-map-root .mapboxgl-ctrl-bottom-left,
#mer-map-root .mapboxgl-ctrl-bottom-right {
    bottom: calc(var(--mer-map-sheet-offset) + env(safe-area-inset-bottom));
    transition: bottom 0.28s ease;
}

/* Mobile Handle (Hidden on Desktop) */
.mer-map-mobile-handle {
    display: none;
}

/* Filter controls (desktop + mobile baseline) */
.mer-map-filters {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 8px;
}

.mer-map-tools {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
    padding: 8px;
    border: 1px solid #dbe3ed;
    border-radius: 12px;
    background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
}

.mer-map-search--enhanced {
    position: relative;
}

.mer-map-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.mer-map-search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1rem;
    line-height: 1;
    font-weight: 700;
    color: #4f6988;
    pointer-events: none;
}

.mer-map-search input[type="search"] {
    width: 100%;
    border: 1px solid #ccd8e6;
    border-radius: 11px;
    padding: 10px 40px 10px 36px;
    font-size: 0.9rem;
    color: #0f172a;
    background: #ffffff;
    box-shadow: inset 0 1px 1px rgba(15, 23, 42, 0.04);
}

.mer-map-search input[type="search"]:focus {
    outline: none;
    border-color: #2f73b4;
    box-shadow: 0 0 0 3px rgba(0, 86, 179, 0.14);
}

.mer-map-search-clear {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    width: 24px;
    height: 24px;
    border: 1px solid #c8d2df;
    border-radius: 999px;
    background: #fff;
    color: #48607f;
    font-size: 0.95rem;
    line-height: 1;
    font-weight: 700;
    cursor: pointer;
}

.mer-map-search-clear:hover {
    background: #eef5ff;
    color: #1d456f;
}

.mer-map-toolrow {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    gap: 8px;
}

.mer-map-filter-pill {
    border: 1px solid #b9c8db;
    border-radius: 999px;
    background: #fff;
    color: #25486d;
    padding: 8px 12px;
    font-size: 0.76rem;
    font-weight: 800;
    letter-spacing: 0.01em;
    cursor: pointer;
    text-align: center;
}

.mer-map-filter-pill.is-active {
    border-color: #0056b3;
    background: #eaf3ff;
    color: #003f87;
}

.mer-map-reset-btn {
    border: 1px solid #b9c5d8;
    border-radius: 999px;
    background: #fff;
    color: #1f3d5b;
    padding: 8px 12px;
    font-size: 0.76rem;
    font-weight: 800;
    letter-spacing: 0.01em;
    cursor: pointer;
    white-space: nowrap;
}

.mer-map-reset-btn:hover {
    background: #f4f8ff;
}

/* Mobile Styles */
@media (max-width: 768px) {
    .mer-map-page-layout {
        padding: 0 0 16px;
    }

    .mer-map-page-hero {
        padding: 0 16px 12px;
    }

    #mer-map-root {
        --mer-map-sheet-peek: 100px;
        --mer-map-sheet-height: min(78%, 620px);
        height: clamp(900px, 125dvh, 1400px);
        min-height: 900px;
        width: 100vw;
        margin-left: calc(50% - 50vw);
        margin-right: calc(50% - 50vw);
        border-left: none;
        border-right: none;
        border-radius: 0;
    }

    .mer-map-sidebar {
        position: absolute;
        top: auto;
        right: auto;
        bottom: 0;
        left: 0;
        width: 100%;
        max-width: none;
        height: var(--mer-map-sheet-height);
        border-right: none;
        border-top: 1px solid #d9e0e7;
        border-radius: 14px 14px 0 0;
        box-shadow: 0 -10px 30px rgba(17, 24, 39, 0.2);
        transform: translate3d(0, 0, 0);
        transition: transform 0.28s ease;
        will-change: transform;
    }

    .mer-map-sidebar.is-collapsed {
        transform: translate3d(0, calc(100% - var(--mer-map-sheet-peek)), 0);
    }

    .mer-map-sidebar-header {
        padding: 10px 12px 8px;
        position: sticky;
        top: 0;
        z-index: 2;
        background: rgba(249, 249, 249, 0.96);
        border-bottom: 1px solid #e7edf3;
        box-shadow: 0 2px 10px rgba(15, 23, 42, 0.08);
        backdrop-filter: saturate(1.06) blur(4px);
    }

    .mer-map-sheet-toggle {
        display: inline-flex;
        align-items: center;
        min-height: 38px;
    }

    .mer-map-mobile-hint {
        display: block;
        margin-top: 6px;
        color: #6b7280;
        font-size: 0.78rem;
        line-height: 1.3;
    }

.mer-map-filters {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 8px;
}

.mer-map-tools {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
}

.mer-map-search--enhanced {
    position: relative;
}

.mer-map-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.mer-map-search-icon {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.7rem;
    line-height: 1;
    font-weight: 800;
    color: #5a6d86;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    pointer-events: none;
}

.mer-map-search input[type="search"] {
    width: 100%;
    border: 1px solid #d6dee8;
    border-radius: 12px;
    padding: 11px 70px 11px 68px;
    font-size: 0.92rem;
    color: #0f172a;
    background: #ffffff;
    box-shadow: inset 0 1px 1px rgba(15, 23, 42, 0.04);
}

.mer-map-search input[type="search"]:focus {
    outline: none;
    border-color: #3f78b4;
    box-shadow: 0 0 0 3px rgba(0, 86, 179, 0.16);
}

.mer-map-search-clear {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    border: 1px solid #c8d2df;
    border-radius: 999px;
    background: #f8fbff;
    color: #28496e;
    height: 28px;
    min-width: 52px;
    padding: 0 10px;
    font-size: 0.74rem;
    font-weight: 800;
    letter-spacing: 0.01em;
    cursor: pointer;
}

.mer-map-search-clear:hover {
    background: #eef5ff;
}

.mer-map-toolrow {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.mer-map-filter-pill {
    border: 1px solid #b9c8db;
    border-radius: 999px;
    background: #fff;
    color: #25486d;
    padding: 8px 12px;
    font-size: 0.78rem;
    font-weight: 800;
    letter-spacing: 0.01em;
    cursor: pointer;
}

.mer-map-filter-pill.is-active {
    border-color: #0056b3;
    background: #eaf3ff;
    color: #003f87;
}

.mer-map-reset-btn {
    border: 1px solid #b9c5d8;
    border-radius: 999px;
    background: #fff;
    color: #1f3d5b;
    padding: 8px 12px;
    font-size: 0.78rem;
    font-weight: 800;
    letter-spacing: 0.01em;
    cursor: pointer;
}

.mer-map-reset-btn:hover {
    background: #f4f8ff;
}

/* Desktop: allow hiding list for a full-width map */
@media (min-width: 769px) {
    .mer-map-sidebar.is-hidden-desktop {
        display: none;
    }

    #mer-map-root .mapboxgl-ctrl-bottom-left,
    #mer-map-root .mapboxgl-ctrl-top-left {
        left: calc(var(--mer-map-desktop-sidebar-offset) + 8px);
        transition: left 0.2s ease;
    }
}

@media (max-width: 768px) {
    .mer-map-toggle {
        min-height: 44px;
        font-size: 0.86rem;
    }

    .mer-map-legend {
        margin-top: 8px;
    }

    .mer-venue-list {
        padding: 8px 8px calc(env(safe-area-inset-bottom) + 10px);
        overscroll-behavior: contain;
    }

    .mer-venue-item {
        padding: 13px 12px;
        margin-bottom: 8px;
        border: 1px solid #e6ebf1;
        border-radius: 10px;
        background: #fff;
    }

    .mer-map-sidebar.is-collapsed .mer-venue-list {
        opacity: 0;
        pointer-events: none;
    }

    .mer-map-sidebar.is-collapsed .mer-map-legend {
        display: none;
    }

    .mer-map-mobile-handle {
        display: block;
        width: 48px;
        height: 5px;
        background: #c8d2dd;
        border-radius: 999px;
        margin: 8px auto 4px;
    }

    #mer-map-container {
        width: 100%;
        height: 100%;
        touch-action: none;
        overscroll-behavior: contain;
    }

    #mer-map-container .mapboxgl-canvas-container,
    #mer-map-container .mapboxgl-canvas {
        touch-action: none !important;
    }

    #mer-map-root .mapboxgl-ctrl-top-right .mapboxgl-ctrl,
    #mer-map-root .mapboxgl-ctrl-top-left .mapboxgl-ctrl {
        margin-top: 8px;
    }

    #mer-map-root .mapboxgl-ctrl-group button {
        width: 36px;
        height: 36px;
    }

    .mer-map-page-section {
        padding: 20px 14px 28px;
    }

    .mer-map-footer__inner {
        grid-template-columns: 1fr;
        gap: 18px;
    }
}

@media (max-width: 1280px) {
}

@media (max-width: 600px) {
    .mer-map-toolrow {
        grid-template-columns: 1fr;
    }

    .mer-map-filter-pill,
    .mer-map-reset-btn {
        width: 100%;
        min-height: 36px;
    }
}

@media (max-width: 1024px) {
    .mer-map-first-segment > .ui.aligned.stackable.grid.container {
        width: calc(100vw - 28px) !important;
    }

    .mer-map-breakout {
        width: 100%;
    }

    #mer-map-root {
        width: 100%;
    }
}

@media (min-width: 1025px) {
    .mer-map-page .mer-mobile-header {
        display: none !important;
    }
}

@media (prefers-reduced-motion: reduce) {
    .mer-map-sidebar,
    #mer-map-root .mapboxgl-ctrl-bottom-left,
    #mer-map-root .mapboxgl-ctrl-bottom-right {
        transition: none;
    }
}
