* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --font-size: 16px;
    --font-weight-medium: 500;
    --font-weight-normal: 400;
    --text-base: 1rem;
    --text-lg: 1.125rem;
    --text-xl: 1.25rem;
    --text-2xl: 1.5rem;
    --background: #f7f8ff;
    --surface: rgba(255, 255, 255, 0.95);
    --foreground: #030213;
    --muted: #f5f5f7;
    --muted-foreground: #717182;
    --border: rgba(3, 2, 19, 0.1);
    --accent: #e9ebef;
    --primary: #030213;
    --primary-foreground: #ffffff;
    --shadow-color: rgba(15, 23, 42, 0.25);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: var(--background);
    color: var(--foreground);
    font-size: var(--font-size);
    line-height: 1.5;
    overflow: hidden;
}

h1 {
    font-size: var(--text-2xl);
    font-weight: var(--font-weight-medium);
    line-height: 1.5;
}

h2 {
    font-size: var(--text-xl);
    font-weight: var(--font-weight-medium);
    line-height: 1.5;
}

h3 {
    font-size: var(--text-lg);
    font-weight: var(--font-weight-medium);
    line-height: 1.5;
}

h4,
label,
button {
    font-size: var(--text-base);
    font-weight: var(--font-weight-medium);
    line-height: 1.5;
}

p,
input {
    font-size: var(--text-base);
    font-weight: var(--font-weight-normal);
    line-height: 1.5;
}

#app {
    width: 100vw;
    height: 100vh;
    position: relative;
}

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

#loading {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(247, 248, 255, 0.9);
    z-index: 1000;
}

.loader {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    position: relative;
    animation: loader-rotate 1s linear infinite;
    margin: 0 auto 1rem;
}

.loader::before,
.loader::after {
    content: '';
    box-sizing: border-box;
    position: absolute;
    inset: 0;
    border-radius: 50%;
    border: 2.5px solid #ffffff;
    animation: loader-prix-clip 2s linear infinite;
}

.loader::before {
    border-color: color-mix(in srgb, var(--primary, #030213) 88%, #ffffff 12%);
    opacity: 0.85;
}

.loader::after {
    border-color: color-mix(in srgb, var(--primary, #030213) 40%, var(--surface, #ffffff) 60%);
    animation:
        loader-prix-clip 2s linear infinite,
        loader-rotate 0.5s linear infinite reverse;
    inset: 6px;
    border-width: 2.5px;
}

@keyframes loader-rotate {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@keyframes loader-prix-clip {
    0%   { clip-path: polygon(50% 50%, 0 0, 0 0, 0 0, 0 0, 0 0); }
    25%  { clip-path: polygon(50% 50%, 0 0, 100% 0, 100% 0, 100% 0, 100% 0); }
    50%  { clip-path: polygon(50% 50%, 0 0, 100% 0, 100% 100%, 100% 100%, 100% 100%); }
    75%  { clip-path: polygon(50% 50%, 0 0, 100% 0, 100% 100%, 0 100%, 0 100%); }
    100% { clip-path: polygon(50% 50%, 0 0, 100% 0, 100% 100%, 0 100%, 0 0); }
}

#loading p {
    color: var(--muted-foreground);
}

#loading button {
    padding: 0.75rem 1.25rem;
    background: var(--primary);
    border: none;
    color: var(--primary-foreground);
    border-radius: 0.75rem;
    font-weight: var(--font-weight-medium);
    cursor: pointer;
    transition: opacity 0.2s ease;
}

#loading button:hover {
    opacity: 0.9;
}

/* Floating search */
#search-form.map-search,
.map-search {
    position: absolute;
    top: 0.85rem;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    width: min(90vw, 640px);
    padding: 0.45rem 0.6rem;
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid rgba(3, 2, 19, 0.12);
    border-radius: 0.8rem;
    box-shadow: 0 14px 30px -24px rgba(3, 2, 19, 0.45);
    pointer-events: auto;
    z-index: 650;
}

@supports (backdrop-filter: blur(12px)) {
    .map-search {
        backdrop-filter: blur(12px);
    }
}

.map-search.has-active-search {
    border-color: rgba(3, 2, 19, 0.24);
    box-shadow: 0 20px 36px -24px rgba(3, 2, 19, 0.55);
}

.search-field {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.32rem 0.45rem;
    border-radius: 0.7rem;
    border: 1px solid rgba(3, 2, 19, 0.08);
    background: rgba(3, 2, 19, 0.05);
    min-height: 42px;
    min-width: 0;
}

.map-search {
    position: absolute;
    top: 0.85rem;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: min(90vw, 720px);
    padding: 0.45rem 0.7rem;
    background: rgba(255, 255, 255, 0.96);
    border: 1px solid rgba(3, 2, 19, 0.1);
    border-radius: 0.9rem;
    box-shadow: 0 14px 36px -26px rgba(3, 2, 19, 0.5);
    pointer-events: auto;
    z-index: 650;
}

@supports (backdrop-filter: blur(12px)) {
    .map-search {
        backdrop-filter: blur(12px);
    }
}

.map-search.has-active-search {
    border-color: rgba(3, 2, 19, 0.22);
    box-shadow: 0 20px 40px -26px rgba(3, 2, 19, 0.55);
}

.search-tags {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.35rem;
    max-width: 100%;
    flex: 1 1 auto;
    min-width: 0;
}

.search-tag {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.2rem 0.55rem;
    border-radius: 999px;
    border: 1px solid rgba(3, 2, 19, 0.12);
    background: rgba(255, 255, 255, 0.94);
    color: rgba(3, 2, 19, 0.78);
    font-size: 0.82rem;
    font-weight: var(--font-weight-medium);
    letter-spacing: -0.005em;
    max-width: 100%;
    box-shadow: 0 8px 16px -14px rgba(3, 2, 19, 0.4);
}

.search-tag-label {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 160px;
}

.search-tag-remove {
    border: none;
    background: rgba(3, 2, 19, 0.12);
    color: rgba(3, 2, 19, 0.7);
    width: 1rem;
    height: 1rem;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background-color 0.15s ease, color 0.15s ease;
    flex-shrink: 0;
}

.search-tag-remove:hover,
.search-tag-remove:focus-visible {
    background: rgba(3, 2, 19, 0.18);
    color: var(--primary);
    outline: none;
}

.search-tag-remove i {
    font-size: 0.7rem;
    line-height: 1;
}

.search-input {
    flex: 1 1 160px;
    min-width: 140px;
    border: none;
    background: transparent;
    color: var(--foreground);
    font-size: 0.92rem;
    line-height: 1.45;
    padding: 0.16rem 0.3rem;
}

.search-input::placeholder {
    color: rgba(3, 2, 19, 0.45);
}

.search-input:focus {
    outline: none;
}

.search-actions {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.search-action {
    border: none;
    background: rgba(3, 2, 19, 0.08);
    color: var(--foreground);
    width: 2.1rem;
    height: 2.1rem;
    border-radius: 0.65rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.15s ease, background-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
    box-shadow: 0 10px 22px -18px rgba(3, 2, 19, 0.35);
}

.search-action:hover,
.search-action:focus-visible {
    transform: translateY(-1px);
    background: rgba(3, 2, 19, 0.16);
    color: var(--primary);
    outline: none;
}

.search-action:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    transform: none;
}

.search-action i {
    font-size: 1.05rem;
}

@media (max-width: 768px) {
    .map-search {
        top: 1rem;
        width: calc(100% - 1.5rem);
        padding: 0.6rem 0.8rem;
    }

    .search-field {
        width: 100%;
        gap: 0.45rem;
        min-height: 48px;
    }
}

#controls {
    position: absolute;
    bottom: 1rem;
    left: 1rem;
    right: 1rem;
    z-index: 1000;
    pointer-events: none;
}

.control-panel {
    background: var(--surface);
    backdrop-filter: blur(10px);
    border-radius: 0.75rem;
    box-shadow: 0 10px 25px -8px var(--shadow-color);
    border: 1px solid var(--border);
    padding: 1rem;
    pointer-events: auto;
    margin-bottom: 1rem;
}

.header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.25rem;
}

.header h1 {
    font-size: 1.125rem;
    font-weight: 500;
    color: var(--foreground);
    margin: 0;
}

.toggle-btn {
    background: rgba(3, 2, 19, 0.08);
    border: 1px solid var(--border);
    cursor: pointer;
    padding: 0.4rem;
    border-radius: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary);
    box-shadow: 0 4px 12px -8px var(--shadow-color);
    transition: background-color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
}

.toggle-btn:hover {
    background: rgba(3, 2, 19, 0.16);
    transform: translateY(-1px);
    box-shadow: 0 6px 16px -10px var(--shadow-color);
}

.toggle-btn svg {
    transition: transform 0.3s ease;
}

.toggle-btn:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

.collapsed .toggle-btn svg {
    transform: rotate(180deg);
}

.header p {
    font-size: 0.875rem;
    color: var(--muted-foreground);
    margin: 0;
}

#expanded-controls {
    transition: all 0.3s ease;
    overflow: hidden;
}

.collapsed #expanded-controls {
    max-height: 0;
    opacity: 0;
    padding-top: 0;
    padding-bottom: 0;
    margin: 0;
}

.filters {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 0.75rem;
    margin-top: 1rem;
}

.filter-btn {
    background: var(--muted);
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    padding: 0.75rem 0.85rem;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.875rem;
    font-weight: var(--font-weight-medium);
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 0.75rem;
    width: 100%;
    color: inherit;
    text-align: left;
    appearance: none;
}

.filter-btn:hover {
    background: var(--accent);
}

.filter-btn:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

.filter-btn.active {
    border-color: var(--primary);
    background: var(--primary);
    color: var(--primary-foreground);
    box-shadow: 0 6px 18px -6px var(--shadow-color);
}


.filter-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    flex: 1;
    min-width: 0;
}

.filter-label {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
}

.filter-badge {
    background: rgba(3, 2, 19, 0.08);
    color: var(--foreground);
    border-radius: 999px;
    padding: 0.15rem 0.55rem;
    font-size: 0.75rem;
    font-weight: var(--font-weight-medium);
    line-height: 1.2;
    min-width: 2.25rem;
    text-align: center;
}

.filter-btn.active .filter-badge {
    background: rgba(255, 255, 255, 0.2);
    color: var(--primary-foreground);
}

.filter-icon {
    flex-shrink: 0;
    width: 1.5rem;
    height: 1.5rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: currentColor;
    font-size: 1.1rem;
}

.filter-icon i,
.filter-icon svg {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    fill: currentColor;
}

.filter-btn[data-type="all"] .filter-icon {
    color: #0EA5E9;
}

.filter-btn[data-type="cultural"] .filter-icon {
    color: #DC2626;
}

.filter-btn[data-type="natural"] .filter-icon {
    color: #16A34A;
}

.filter-btn[data-type="mixed"] .filter-icon {
    color: #F97316;
}

.filter-btn.active .filter-icon {
    color: currentColor;
}

.slider-container {
    margin-top: 1rem;
    position: relative;
    padding-top: 2rem;
}

.slider-label {
    display: flex;
    justify-content: space-between;
    font-size: 0.875rem;
    color: var(--muted-foreground);
    margin-bottom: 0.35rem;
}

.slider {
    width: 100%;
    height: 0.5rem;
    border-radius: 9999px;
    background: var(--accent);
    outline: none;
    -webkit-appearance: none;
    appearance: none;
}

.slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 1.4rem;
    height: 1.4rem;
    border-radius: 50%;
    background: var(--primary);
    cursor: pointer;
    border: none;
}

.slider-bubble {
    position: absolute;
    top: 0;
    left: 0;
    transform: translateX(-50%);
    background: rgba(255, 255, 255, 0.92);
    color: var(--foreground);
    padding: 0.15rem 0.5rem;
    border: 1px solid rgba(3, 2, 19, 0.08);
    border-radius: 9999px;
    font-size: 0.7rem;
    font-family: monospace;
    font-weight: var(--font-weight-medium);
    pointer-events: none;
    white-space: nowrap;
    box-shadow: 0 4px 10px -12px var(--shadow-color);
    opacity: 0.85;
}

.slider-ends {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    color: var(--muted-foreground);
    margin-top: 0.35rem;
    pointer-events: none;
}

.popup-card {
    display: flex;
    flex-direction: column;
    width: min(320px, 72vw);
    max-width: 320px;
    border-radius: 1rem;
    overflow: hidden;
    background: var(--surface);
    border: none;
    box-shadow: 0 24px 46px -28px rgba(15, 23, 42, 0.6);
}

.leaflet-popup-content {
    background: transparent;
}

.popup-media {
    position: relative;
    flex: none;
    width: 100%;
    aspect-ratio: 4 / 3;
    background: #d8dde3;
    overflow: hidden;
}

.popup-media-track {
    width: 100%;
    height: 100%;
    position: relative;
    overflow: hidden;
}

.popup-media-slide {
    position: absolute;
    inset: 0;
    opacity: 0;
    transform: scale(0.975);
    transition: opacity 0.35s ease, transform 0.35s ease;
}

.popup-media-slide img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.popup-media-slide.active {
    opacity: 1;
    transform: scale(1);
    transition: opacity 0.45s ease, transform 0.45s ease;
}

.popup-media-dots {
    position: absolute;
    bottom: 0.7rem;
    left: 50%;
    transform: translateX(-50%);
    display: inline-flex;
    gap: 0.35rem;
    padding: 0.25rem 0.5rem;
    border-radius: 9999px;
    background: rgba(0, 0, 0, 0.38);
    backdrop-filter: blur(4px);
}

.popup-media-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    border: none;
    background: rgba(255, 255, 255, 0.6);
    cursor: pointer;
    padding: 0;
    transition: transform 0.2s ease, background 0.2s ease;
}

.popup-media-dot.active {
    background: #ffffff;
    transform: scale(1.25);
}

.popup-body {
    padding: 0.4rem 0.7rem 0.45rem;
    display: flex;
    flex-direction: column;
    gap: 0.06rem;
}

.popup-body-meta {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    margin-top: 0.22rem;
    margin-bottom: 0.02rem;
}

.popup-country {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.76rem;
    color: var(--muted-foreground);
    white-space: nowrap;
    min-width: 0;
}

.popup-country span:last-child {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
}

.popup-country-flag {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.06rem;
    border-radius: 0.26rem;
    border: 1px solid rgba(3, 2, 19, 0.12);
    box-shadow: 0 2px 6px -4px rgba(15, 23, 42, 0.4);
    background-color: #ffffff;
    line-height: 1;
    overflow: hidden;
}

.popup-country-flag img {
    display: block;
    width: 1.4rem;
    height: 1.05rem;
    object-fit: cover;
    object-position: center;
}

.popup-country-flag--emoji,
.popup-country-flag--fallback {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.4rem;
    height: 1.05rem;
    font-size: 0.72rem;
    font-weight: var(--font-weight-medium);
    letter-spacing: 0.04em;
    color: var(--foreground);
    background: rgba(3, 2, 19, 0.04);
    box-shadow: none;
    padding: 0;
}

.popup-chip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.12rem 0.45rem;
    border-radius: 8px;
    font-size: 0.7rem;
    font-weight: var(--font-weight-medium);
    background: color-mix(in srgb, var(--chip-color, #030213) 25%, #ffffff 75%);
    color: var(--chip-color, #030213);
    border: 1px solid color-mix(in srgb, var(--chip-color, #030213) 34%, #ffffff 66%);
    white-space: nowrap;
    margin-left: auto;
}

.popup-chip-overlay {
    position: absolute;
    top: 0.65rem;
    right: 0.65rem;
    pointer-events: none;
    z-index: 3;
}

.popup-heading {
    margin: 0 0 0.24rem;
    font-size: 0.97rem;
    font-weight: var(--font-weight-medium);
    color: var(--foreground);
    line-height: 1.1;
}

.popup-meta-line {
    margin: 0;
    font-size: 0.76rem;
    color: var(--muted-foreground);
    line-height: 1.1;
}

.popup-description {
    margin: 0;
    font-size: 0.82rem;
    color: color-mix(in srgb, var(--foreground) 82%, #6c7082 18%);
    line-height: 1.18;
    word-break: break-word;
}

.popup-body-meta + .popup-meta-line {
    margin-top: 0.08rem;
}

.popup-body-meta + .popup-description {
    margin-top: 0.02rem;
}

.popup-meta-line + .popup-description {
    margin-top: 0.06rem;
}

.popup-link {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.78rem;
    font-weight: var(--font-weight-medium);
    color: var(--primary);
    text-decoration: none;
    margin-top: 0.08rem;
}

.popup-link:hover,
.popup-link:focus {
    text-decoration: underline;
}

/* Essential Leaflet CSS */
.leaflet-pane,
.leaflet-tile,
.leaflet-marker-icon,
.leaflet-marker-shadow,
.leaflet-tile-container,
.leaflet-pane > svg,
.leaflet-pane > canvas,
.leaflet-zoom-box,
.leaflet-image-layer,
.leaflet-layer {
    position: absolute;
    left: 0;
    top: 0;
}

.leaflet-container {
    overflow: hidden;
    touch-action: none;
}

.leaflet-tile,
.leaflet-marker-icon,
.leaflet-marker-shadow {
    user-select: none;
    webkit-user-drag: none;
}

.leaflet-marker-icon,
.leaflet-marker-shadow {
    display: block;
}

.leaflet-control {
    position: relative;
    z-index: 800;
    pointer-events: visiblePainted;
    pointer-events: auto;
}

.leaflet-top,
.leaflet-bottom {
    position: absolute;
    z-index: 1000;
    pointer-events: none;
}

.leaflet-top {
    top: 0;
}

.leaflet-right {
    right: 0;
}

.leaflet-bottom {
    bottom: 0;
}

.leaflet-left {
    left: 0;
}

.leaflet-control {
    float: left;
    clear: both;
}

.leaflet-right .leaflet-control {
    float: right;
}

.leaflet-top .leaflet-control {
    margin-top: 10px;
}

.leaflet-bottom .leaflet-control {
    margin-bottom: 10px;
}

.leaflet-left .leaflet-control {
    margin-left: 10px;
}

.leaflet-right .leaflet-control {
    margin-right: 10px;
}

.leaflet-fade-anim .leaflet-tile {
    will-change: opacity;
}

.leaflet-fade-anim .leaflet-popup {
    opacity: 1;
}

.leaflet-zoom-anim .leaflet-zoom-animated {
    will-change: transform;
}

.leaflet-zoom-anim .leaflet-zoom-animated {
    transition: transform 0.25s cubic-bezier(0,0,0.25,1);
}

.leaflet-pan-anim .leaflet-tile,
.leaflet-pan-anim .leaflet-zoom-anim .leaflet-zoom-animated {
    transition: none;
}

.leaflet-zoom-anim .leaflet-tile {
    transition: none;
}

.leaflet-interactive {
    cursor: pointer;
}

.leaflet-grab {
    cursor: -webkit-grab;
    cursor: -moz-grab;
    cursor: grab;
}

.leaflet-crosshair,
.leaflet-crosshair .leaflet-interactive {
    cursor: crosshair;
}

.leaflet-popup-pane,
.leaflet-control {
    cursor: auto;
}

.leaflet-dragging .leaflet-grab,
.leaflet-dragging .leaflet-grab .leaflet-interactive,
.leaflet-dragging .leaflet-marker-draggable {
    cursor: move;
    cursor: -webkit-grabbing;
    cursor: -moz-grabbing;
    cursor: grabbing;
}

.leaflet-marker-icon,
.leaflet-marker-shadow,
.leaflet-image-layer,
.leaflet-pane > svg path,
.leaflet-tile-container {
    pointer-events: none;
}

.leaflet-marker-icon.leaflet-interactive,
.leaflet-image-layer.leaflet-interactive,
.leaflet-pane > svg path.leaflet-interactive,
svg.leaflet-image-layer.leaflet-interactive path {
    pointer-events: visiblePainted;
    pointer-events: auto;
}

.leaflet-popup {
    position: absolute;
    text-align: center;
    margin-bottom: 34px;
    background: transparent;
    border: none;
    box-shadow: none;
}

.leaflet-popup-content-wrapper {
    position: relative;
    text-align: left;
    border-radius: 0;
    background: transparent;
    border: none;
    box-shadow: none;
    padding: 0;
}

.leaflet-popup-content-wrapper::after {
    content: '';
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    bottom: -14px;
    width: 0;
    height: 0;
    border-left: 12px solid transparent;
    border-right: 12px solid transparent;
    border-top: 14px solid var(--surface);
    filter: drop-shadow(0 16px 28px rgba(15, 23, 42, 0.3));
}

.leaflet-popup-content {
    margin: 0;
    line-height: 1.3;
    font-size: 1rem;
    min-height: 1px;
}

.leaflet-popup-tip-container,
.leaflet-popup-tip {
    display: none !important;
}

.leaflet-container a.leaflet-popup-close-button {
    position: absolute;
    top: 0;
    right: 0;
    border: none;
    text-align: center;
    width: 24px;
    height: 24px;
    font: 16px/24px Tahoma, Verdana, sans-serif;
    color: #757575;
    text-decoration: none;
    background: transparent;
}

.leaflet-container a.leaflet-popup-close-button:hover,
.leaflet-container a.leaflet-popup-close-button:focus {
    color: #585858;
}

.leaflet-popup-scrolled {
    overflow: auto;
}

.leaflet-oldie .leaflet-popup-content-wrapper {
    -ms-zoom: 1;
}

.leaflet-oldie .leaflet-popup-tip {
    width: 24px;
    margin: 0 auto;
    -ms-filter: "progid:DXImageTransform.Microsoft.Matrix(M11=0.70710678, M12=0.70710678, M21=-0.70710678, M22=0.70710678)";
    filter: progid:DXImageTransform.Microsoft.Matrix(M11=0.70710678, M12=0.70710678, M21=-0.70710678, M22=0.70710678);
}

.leaflet-oldie .leaflet-control-zoom,
.leaflet-oldie .leaflet-control-layers,
.leaflet-oldie .leaflet-popup-content-wrapper,
.leaflet-oldie .leaflet-popup-tip {
    border: 1px solid #999;
}

/* Leaflet CSS overrides for better integration */
.custom-heritage-marker {
    background: none !important;
    border: none !important;
}

.tooltip-popup {
    background: var(--surface);
    color: var(--foreground);
    padding: 0.45rem 0.75rem;
    border-radius: 0.65rem;
    border: 1px solid rgba(3, 2, 19, 0.12);
    box-shadow: 0 10px 24px -18px var(--shadow-color);
    font-size: 0.95rem;
    font-weight: var(--font-weight-medium);
    letter-spacing: -0.01em;
    line-height: 1.4;
}

.tooltip-popup::after {
    content: '';
    position: absolute;
    left: 50%;
    bottom: -6px;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-top: 6px solid var(--surface);
}

.tooltip-popup strong {
    font-weight: var(--font-weight-medium);
}

.custom-cluster-marker {
    background: none !important;
    border: none !important;
}

.custom-cluster-marker .cluster-marker {
    width: 48px;
    height: 48px;
    border-radius: 9999px;
    border: 4px solid #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--cluster-color, #0EA5E9);
    background-image: linear-gradient(140deg,
        var(--cluster-color-light, rgba(14, 165, 233, 0.92)),
        var(--cluster-color-dark, rgba(3, 2, 19, 0.85))
    );
    box-shadow:
        0 18px 40px -22px rgba(15, 23, 42, 0.55),
        inset 0 0 0 2px color-mix(in srgb, var(--cluster-color, #0EA5E9) 55%, #ffffff 45%);
    color: #ffffff;
    font-size: 0.95rem;
    font-weight: var(--font-weight-medium);
    letter-spacing: -0.01em;
    transition: transform 0.18s ease-out, box-shadow 0.18s ease-out;
    position: relative;
    overflow: visible;
}

.custom-cluster-marker:hover .cluster-marker,
.custom-cluster-marker:focus-visible .cluster-marker {
    transform: scale(1.06);
    box-shadow:
        0 26px 48px -22px rgba(15, 23, 42, 0.6),
        inset 0 0 0 2px color-mix(in srgb, var(--cluster-color, #0EA5E9) 45%, #ffffff 55%);
}

.cluster-marker-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
}

.custom-cluster-marker .cluster-marker::after {
    content: '';
    position: absolute;
    inset: -10px;
    border-radius: inherit;
    background: radial-gradient(circle,
        color-mix(in srgb, var(--cluster-color, #0EA5E9) 22%, transparent) 0%,
        transparent 68%
    );
    opacity: 0.35;
    transform: scale(0.95);
    transition: opacity 0.2s ease-out, transform 0.2s ease-out;
    pointer-events: none;
    z-index: -1;
}

.custom-cluster-marker:hover .cluster-marker::after,
.custom-cluster-marker:focus-visible .cluster-marker::after {
    opacity: 0.5;
    transform: scale(1.01);
}

.marker-cluster-small,
.marker-cluster-medium,
.marker-cluster-large {
    background: none !important;
}

.heritage-marker {
    transform: scale(1);
    transition: transform 0.18s ease-out;
    width: 42px;
    height: 42px;
    border-radius: 9999px;
    border: 3px solid #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 14px 26px -16px rgba(15, 23, 42, 0.6);
}

.custom-heritage-marker:hover .heritage-marker {
    transform: scale(1.06);
}

.heritage-marker-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    font-size: 1.25rem;
    width: 24px;
    height: 24px;
}

.heritage-marker-icon svg,
.heritage-marker-icon i {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    fill: currentColor;
}

.leaflet-container {
    background: var(--background);
}

.leaflet-popup {
    margin-bottom: 34px;
    background: transparent;
    border: none;
    box-shadow: none;
}

.leaflet-popup-content-wrapper {
    position: relative;
    border-radius: 0;
    box-shadow: none;
    border: none;
    background: transparent;
    padding: 0;
    color: var(--foreground);
}

.leaflet-popup-content-wrapper::after {
    content: '';
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    bottom: -14px;
    width: 0;
    height: 0;
    border-left: 12px solid transparent;
    border-right: 12px solid transparent;
    border-top: 14px solid var(--surface);
    filter: drop-shadow(0 16px 28px rgba(15, 23, 42, 0.3));
}

.leaflet-popup-content {
    margin: 0;
    padding: 0;
    font-size: 0.9rem;
    line-height: 1.5;
    background: transparent;
}

.leaflet-popup-tip-container,
.leaflet-popup-tip {
    display: none !important;
}

.leaflet-container a.leaflet-popup-close-button {
    position: absolute;
    top: 0.35rem;
    right: 0.5rem;
    width: 1.5rem;
    height: 1.5rem;
    border-radius: 9999px;
    border: none;
    background: rgba(3, 2, 19, 0.08);
    color: var(--muted-foreground);
    font-size: 1rem;
    line-height: 1.4rem;
    transition: background-color 0.2s ease, color 0.2s ease;
}

.leaflet-container a.leaflet-popup-close-button:hover,
.leaflet-container a.leaflet-popup-close-button:focus {
    background: rgba(3, 2, 19, 0.16);
    color: var(--foreground);
    outline: none;
}

.leaflet-control-attribution {
    background: rgba(255, 255, 255, 0.85) !important;
    backdrop-filter: blur(8px) !important;
    border-radius: 8px !important;
    margin: 8px !important;
    padding: 4px 10px !important;
    font-size: 11px !important;
    color: var(--muted-foreground) !important;
}

.leaflet-control-zoom {
    border: none !important;
    box-shadow: 0 10px 20px -16px rgba(15, 23, 42, 0.35) !important;
    border-radius: 12px !important;
    overflow: hidden;
    margin: 8px !important;
    backdrop-filter: blur(6px);
}

.leaflet-control-zoom a {
    background: rgba(255, 255, 255, 0.95) !important;
    border: none !important;
    color: var(--foreground) !important;
    font-weight: 600 !important;
    width: 38px !important;
    height: 38px !important;
    line-height: 38px !important;
    transition: background-color 0.2s !important;
}

.leaflet-control-zoom a:hover {
    background: rgba(255, 255, 255, 1) !important;
    color: var(--foreground) !important;
}
