:root {
    color-scheme: light;
    --ink: #172033;
    --muted: #667085;
    --line: rgba(23, 32, 51, 0.12);
    --panel: rgba(255, 255, 255, 0.76);
    --accent: #0f9f8f;
    --accent-dark: #08786d;
    --shadow: 0 22px 70px rgba(15, 23, 42, 0.18);
    --map-water: #aad3df;
}

* {
    box-sizing: border-box;
}

html,
body,
.map-shell,
#map {
    width: 100%;
    height: 100%;
    margin: 0;
}

body {
    overflow: hidden;
    color: var(--ink);
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Inter, sans-serif;
    background: #eef1f4;
}

.map-shell {
    position: relative;
}

#map {
    z-index: 1;
    background: rgba(193, 223, 228, 1);
}

.leaflet-container,
.leaflet-map-pane,
.leaflet-tile-pane {
    background: var(--map-water);
}

.leaflet-tile-pane {
    filter: saturate(0.82) brightness(1.05) sepia(0.08);
}

.topbar {
    position: fixed;
    z-index: 600;
    top: max(14px, env(safe-area-inset-top));
    left: max(14px, env(safe-area-inset-left));
    display: flex;
    align-items: center;
    gap: 12px;
    max-width: calc(100vw - 28px);
    padding: 9px 12px 9px 9px;
    border: 1px solid rgba(255, 255, 255, 0.68);
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.72);
    box-shadow: 0 18px 48px rgba(15, 23, 42, 0.15);
    backdrop-filter: blur(22px) saturate(1.35);
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    color: var(--ink);
    font-size: 14px;
    font-weight: 750;
    text-decoration: none;
}

.brand-mark {
    width: 22px;
    height: 22px;
    border: 6px solid var(--accent);
    border-radius: 999px 999px 999px 2px;
    transform: rotate(-45deg);
    background: #fff;
    box-shadow: inset 0 0 0 3px #fff;
}

.brand-icon {
    display: block;
    width: 28px;
    height: 28px;
    border-radius: 9px;
    box-shadow: 0 6px 18px rgba(15, 159, 143, 0.22);
}

.status {
    overflow: hidden;
    max-width: 42vw;
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.filter-toggle {
    display: none;
    align-items: center;
    gap: 7px;
    min-height: 32px;
    min-width: 0;
    padding: 0 10px;
    border: 1px solid rgba(255, 255, 255, 0.72);
    border-radius: 999px;
    color: var(--ink);
    font: inherit;
    font-size: 12px;
    font-weight: 760;
    background: rgba(255, 255, 255, 0.62);
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.1);
    cursor: pointer;
}

.map-share-toggle {
    display: inline-grid;
    width: 32px;
    height: 32px;
    flex: 0 0 32px;
    place-items: center;
    border: 1px solid rgba(255, 255, 255, 0.72);
    border-radius: 999px;
    color: var(--ink);
    background: rgba(255, 255, 255, 0.62);
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.1);
    cursor: pointer;
}

.map-share-toggle:hover,
.map-share-toggle.is-copied {
    color: #fff;
    background: rgba(8, 120, 109, 0.86);
}

.map-share-toggle .fa-link {
    font-size: 14px;
    line-height: 1;
}

.filter-toggle-icon {
    position: relative;
    width: 14px;
    height: 10px;
    border-top: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
}

.filter-toggle-icon::after {
    content: "";
    position: absolute;
    top: 2px;
    left: 0;
    width: 14px;
    border-top: 2px solid currentColor;
}

.legend {
    position: fixed;
    z-index: 620;
    top: max(72px, calc(env(safe-area-inset-top) + 72px));
    left: max(14px, env(safe-area-inset-left));
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-width: calc(100vw - 28px);
    padding: 8px;
    border: 1px solid rgba(255, 255, 255, 0.68);
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.68);
    box-shadow: 0 18px 48px rgba(15, 23, 42, 0.13);
    backdrop-filter: blur(22px) saturate(1.35);
}

.legend-item {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 30px;
    padding: 0 9px 0 7px;
    border: 0;
    border-radius: 12px;
    color: #344054;
    font: inherit;
    font-size: 12px;
    font-weight: 720;
    background: transparent;
    cursor: pointer;
    white-space: nowrap;
}

.legend-item:hover,
.legend-item.is-active {
    color: var(--ink);
    background: rgba(255, 255, 255, 0.78);
}

.legend-icon {
    display: grid;
    width: 18px;
    height: 18px;
    flex: 0 0 18px;
    place-items: center;
    border: 1px solid rgba(255, 255, 255, 0.88);
    border-radius: 999px;
    color: #fff;
    font-size: 8px;
    line-height: 1;
    background: var(--marker-color, var(--accent));
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.16);
}

.legend-icon .fa-solid {
    opacity: 0.82;
}

.legend-count {
    margin-left: auto;
    color: #667085;
    font-size: 11px;
    font-weight: 760;
}

.place-card {
    position: fixed;
    z-index: 700;
    right: max(18px, env(safe-area-inset-right));
    bottom: max(18px, env(safe-area-inset-bottom));
    width: min(390px, calc(100vw - 36px));
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.72);
    border-radius: 22px;
    background: var(--panel);
    box-shadow: var(--shadow);
    opacity: 0;
    pointer-events: none;
    transform: translateY(14px);
    transition: opacity 160ms ease, transform 160ms ease;
    backdrop-filter: blur(26px) saturate(1.28);
}

.place-card.is-open {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
}

.icon-button {
    position: absolute;
    z-index: 2;
    top: 10px;
    right: 10px;
    display: grid;
    width: 34px;
    height: 34px;
    place-items: center;
    border: 0;
    border-radius: 999px;
    color: #fff;
    font-size: 26px;
    line-height: 1;
    background: rgba(17, 24, 39, 0.72);
    cursor: pointer;
}

.icon-button:hover {
    background: rgba(17, 24, 39, 0.9);
}

.place-image {
    width: 100%;
    aspect-ratio: 16 / 9;
    background: linear-gradient(135deg, #d7e8e4, #f2e7cf 48%, #d9d0be);
    background-position: center;
    background-size: cover;
}

.place-image.is-empty::after {
    content: "";
    display: block;
    width: 100%;
    height: 100%;
    background:
        linear-gradient(120deg, rgba(255,255,255,0.36), rgba(255,255,255,0) 38%),
        repeating-linear-gradient(135deg, rgba(17,24,39,0.055) 0 1px, transparent 1px 14px);
}

.place-body {
    padding: 18px 18px 20px;
}

.place-kind {
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    margin-bottom: 10px;
    padding: 0 9px;
    border-radius: 999px;
    color: #fff;
    font-size: 11px;
    font-weight: 780;
    letter-spacing: 0.02em;
    background: var(--accent);
}

.place-body h1 {
    margin: 0 34px 8px 0;
    color: var(--ink);
    font-size: 21px;
    line-height: 1.14;
    letter-spacing: 0;
}

.place-body p {
    display: -webkit-box;
    overflow: hidden;
    margin: 0 0 16px;
    color: #344054;
    font-size: 14px;
    line-height: 1.48;
    white-space: pre-line;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 5;
}

.place-body p.is-airport-codes {
    display: block;
    white-space: normal;
    -webkit-line-clamp: initial;
}

.airport-code-row {
    display: block;
}

.airport-code-row + .airport-code-row {
    margin-top: 4px;
}

.place-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.place-actions [hidden] {
    display: none !important;
}

.read-link,
.share-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
    padding: 0 15px;
    border: 1px solid rgba(255, 255, 255, 0.72);
    border-radius: 14px;
    color: var(--accent-dark);
    font-size: 14px;
    font-weight: 760;
    text-decoration: none;
    background: rgba(255, 255, 255, 0.58);
    box-shadow: 0 12px 34px rgba(15, 23, 42, 0.12);
    backdrop-filter: blur(18px) saturate(1.28);
}

.share-link {
    appearance: none;
    cursor: pointer;
}

.read-link:hover,
.share-link:hover {
    color: #fff;
    background: rgba(8, 120, 109, 0.86);
}

.noscript {
    position: fixed;
    z-index: 900;
    top: 50%;
    left: 50%;
    width: min(420px, calc(100vw - 32px));
    padding: 18px;
    border: 1px solid rgba(255, 255, 255, 0.72);
    border-radius: 18px;
    color: var(--ink);
    font-size: 14px;
    line-height: 1.45;
    background: rgba(255, 255, 255, 0.82);
    box-shadow: var(--shadow);
    transform: translate(-50%, -50%);
    backdrop-filter: blur(22px) saturate(1.28);
}

.leaflet-control-zoom {
    overflow: hidden;
    border: 0 !important;
    border-radius: 16px !important;
    box-shadow: 0 10px 28px rgba(17, 24, 39, 0.16) !important;
}

.leaflet-control-zoom a {
    border-color: var(--line) !important;
    color: var(--ink) !important;
}

.place-marker {
    display: grid;
    width: 30px;
    height: 30px;
    place-items: center;
    border: 3px solid rgba(255, 255, 255, 0.96);
    border-radius: 999px;
    background: var(--marker-color, var(--accent));
    box-shadow:
        0 8px 22px rgba(15, 23, 42, 0.28),
        0 0 0 7px rgba(15, 159, 143, 0.15);
    transition: transform 130ms ease, box-shadow 130ms ease;
}

.place-cluster {
    display: grid;
    width: 100%;
    height: 100%;
    place-items: center;
    border: 4px solid rgba(255, 255, 255, 0.94);
    border-radius: 999px;
    color: #fff;
    font-size: 13px;
    font-weight: 850;
    line-height: 1;
    box-shadow:
        0 12px 30px rgba(15, 23, 42, 0.24),
        0 0 0 8px rgba(93, 118, 140, 0.15);
}

.place-cluster.is-sm {
    background: #2f7dd1;
    box-shadow:
        0 10px 24px rgba(15, 23, 42, 0.22),
        0 0 0 8px rgba(47, 125, 209, 0.13);
}

.place-cluster.is-md {
    background: #0f9f8f;
    font-size: 14px;
    box-shadow:
        0 12px 28px rgba(15, 23, 42, 0.24),
        0 0 0 10px rgba(15, 159, 143, 0.15);
}

.place-cluster.is-lg {
    background: #f59f00;
    font-size: 15px;
    box-shadow:
        0 14px 32px rgba(15, 23, 42, 0.25),
        0 0 0 12px rgba(245, 159, 0, 0.16);
}

.place-cluster.is-xl {
    background: #d9480f;
    font-size: 16px;
    box-shadow:
        0 16px 38px rgba(15, 23, 42, 0.27),
        0 0 0 14px rgba(217, 72, 15, 0.18);
}

.place-marker i {
    color: #fff;
    font-size: 11px;
    line-height: 1;
    opacity: 0.86;
    text-shadow: 0 1px 4px rgba(15, 23, 42, 0.28);
}

.place-marker:hover {
    transform: scale(1.16);
}

@media (max-width: 640px) {
    .topbar {
        right: max(14px, env(safe-area-inset-right));
        gap: 8px;
        justify-content: space-between;
        padding-right: 9px;
    }

    .filter-toggle {
        display: inline-flex;
        max-width: 31vw;
    }

    #filter-toggle-label {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .legend {
        top: max(72px, calc(env(safe-area-inset-top) + 72px));
        right: max(14px, env(safe-area-inset-right));
        bottom: auto;
        display: flex;
        max-height: min(68vh, 520px);
        overflow-y: auto;
        padding: 8px;
        opacity: 0;
        pointer-events: none;
        transform: translateY(-8px) scale(0.98);
        transition: opacity 150ms ease, transform 150ms ease;
    }

    .is-filter-menu-open .legend {
        opacity: 1;
        pointer-events: auto;
        transform: translateY(0) scale(1);
    }

    .legend-item {
        width: 100%;
        min-height: 38px;
        justify-content: flex-start;
    }

    .status {
        max-width: 20vw;
    }

    .place-card {
        right: 0;
        bottom: 0;
        left: 0;
        width: 100%;
        border-right: 0;
        border-bottom: 0;
        border-left: 0;
        border-radius: 8px 8px 0 0;
    }

    .place-image {
        aspect-ratio: 21 / 10;
    }
}
