:root {
    --nm-bg-900: #040712;
    --nm-bg-800: #0b1021;
    --nm-surface: rgba(12, 17, 33, 0.86);
    --nm-surface-strong: rgba(14, 20, 36, 0.92);
    --nm-border: rgba(255, 255, 255, 0.08);
    --nm-border-strong: rgba(126, 241, 255, 0.25);
    --nm-text: #e6eeff;
    --nm-muted: #9eb0d3;
    --nm-accent: #7ef1ff;
    --nm-accent-2: #ffad66;
    --nm-shadow: 0 20px 80px rgba(0, 0, 0, 0.45);
    --nm-blur: blur(16px);
}

* {
    box-sizing: border-box;
}

html, body, #map {
    height: 100%;
    width: 100%;
}

body {
    margin: 0;
    background: radial-gradient(circle at 18% 20%, rgba(70, 107, 255, 0.05), transparent 24%), radial-gradient(circle at 80% 0%, rgba(255, 173, 102, 0.06), transparent 22%), var(--nm-bg-900);
    color: var(--nm-text);
    font-family: 'Space Grotesk', 'Manrope', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    letter-spacing: 0.01em;
    line-height: 1.6;
}

#map {
    position: fixed;
    inset: 0;
    z-index: 1;
}

sup {
    vertical-align: baseline;
    position: relative;
    top: -0.4em;
}

a {
    color: var(--nm-accent);
}

/* Contributor editing */
.nm-contrib-row { margin-top: 6px; }
.nm-loc-contrib {
    cursor: pointer;
    text-decoration: underline;
    text-decoration-color: rgba(126, 241, 255, 0.6);
}

p {
    margin: 0 0 8px;
}

ul, ol {
    display: inline-block;
    text-align: left;
    padding-left: 16px;
}

/* --- New overlay shell --- */
.nm-overlay {
    position: fixed;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 18px;
    pointer-events: none;
    z-index: 500;
    overflow-y: auto;
}

.nm-overlay--hidden {
    display: none;
}

.nm-panel {
    pointer-events: auto;
    width: min(92vw, 640px);
    max-width: 640px;
    max-height: 88vh;
    background: linear-gradient(135deg, rgba(12, 18, 35, 0.92), rgba(9, 14, 27, 0.9));
    border: 1px solid var(--nm-border);
    border-radius: 18px;
    box-shadow: var(--nm-shadow);
    backdrop-filter: var(--nm-blur);
    padding: 18px 20px 16px;
    position: relative;
    overflow: hidden;
}

.nm-panel::before {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    background: radial-gradient(circle at 12% 16%, rgba(126, 241, 255, 0.16), transparent 30%), radial-gradient(circle at 82% 8%, rgba(255, 173, 102, 0.12), transparent 30%);
}

.nm-panel__header {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 8px;
}

.nm-close {
    position: absolute;
    top: 12px;
    right: 12px;
    border: 1px solid var(--nm-border);
    background: rgba(255, 255, 255, 0.06);
    color: var(--nm-text);
    border-radius: 12px;
    width: 36px;
    height: 36px;
    cursor: pointer;
    font-size: 20px;
    line-height: 1;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
    transition: all 0.2s ease;
}

.nm-close:hover {
    border-color: var(--nm-border-strong);
    color: var(--nm-accent);
    transform: translateY(-1px);
}

.nm-badge {
    padding: 6px 10px;
    background: rgba(126, 241, 255, 0.14);
    color: var(--nm-accent);
    border: 1px solid var(--nm-border-strong);
    border-radius: 999px;
    font-weight: 600;
    font-size: 13px;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.nm-title {
    margin: 6px 0;
    font-size: clamp(24px, 3vw, 32px);
    letter-spacing: -0.02em;
}

.nm-subtitle {
    color: var(--nm-muted);
    font-size: 15px;
    margin: 0 0 12px;
    max-width: 720px;
}

.nm-welcome {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--nm-border);
    border-radius: 14px;
    padding: 12px 14px;
    margin: 0 0 12px;
    color: var(--nm-muted);
}

.nm-welcome p {
    margin: 0 0 8px;
}

.nm-welcome__grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 10px;
    margin-top: 6px;
}

.nm-welcome__grid div {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--nm-border);
    border-radius: 10px;
    padding: 10px;
    color: var(--nm-text);
    font-size: 13px;
}

.nm-welcome__grid a {
    color: var(--nm-accent);
    font-weight: 600;
    text-decoration: none;
}

.nm-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 12px;
}

.nm-button {
    border: 1px solid var(--nm-border);
    background: rgba(255, 255, 255, 0.04);
    color: var(--nm-text);
    padding: 9px 14px;
    border-radius: 12px;
    font-weight: 600;
    letter-spacing: 0.01em;
    cursor: pointer;
    transition: all 0.2s ease;
}

.nm-button:hover {
    transform: translateY(-1px);
    border-color: var(--nm-border-strong);
    color: var(--nm-accent);
}

.nm-button--primary {
    background: linear-gradient(135deg, #7ef1ff, #6cc0ff);
    color: #041024;
    border-color: transparent;
    box-shadow: 0 10px 24px rgba(126, 241, 255, 0.35);
}

.nm-button--primary:hover {
    box-shadow: 0 14px 32px rgba(126, 241, 255, 0.45);
}

.nm-button--ghost {
    background: rgba(255, 255, 255, 0.06);
}

.nm-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 4px;
}

.nm-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 11px;
    border-radius: 12px;
    border: 1px solid var(--nm-border-strong);
    background: rgba(255, 255, 255, 0.04);
    color: var(--nm-text);
    font-size: 13px;
}

.nm-chip--muted {
    border-color: var(--nm-border);
    color: var(--nm-muted);
}

.nm-inline-cards {
    pointer-events: none;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 12px;
    width: 100%;
    max-width: 980px;
}

.nm-card {
    pointer-events: auto;
    flex: 1 1 240px;
    max-width: 360px;
    background: var(--nm-surface);
    border: 1px solid var(--nm-border);
    border-radius: 14px;
    padding: 12px 14px;
    box-shadow: var(--nm-shadow);
    backdrop-filter: var(--nm-blur);
}

.nm-card__label {
    font-weight: 700;
    font-size: 14px;
    letter-spacing: 0.01em;
    color: var(--nm-accent);
    margin: 0 0 6px;
}

.nm-card__body {
    margin: 0;
    color: var(--nm-muted);
    font-size: 14px;
    line-height: 1.5;
}

.nm-profile {
    position: fixed;
    top: 14px;
    right: 14px;
    z-index: 600;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

.nm-profile__trigger {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 1px solid var(--nm-border-strong);
    background: rgba(255, 255, 255, 0.06);
    color: var(--nm-text);
    display: grid;
    place-items: center;
    cursor: pointer;
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.35);
}

.nm-profile__menu {
    margin-top: 8px;
    background: rgba(4, 7, 18, 0.9);
    border: 1px solid var(--nm-border);
    border-radius: 12px;
    padding: 12px;
    min-width: 220px;
    box-shadow: 0 18px 48px rgba(0, 0, 0, 0.45);
    display: none;
}

.nm-profile__menu.open {
    display: block;
}

.nm-profile__meta {
    margin-bottom: 10px;
}

.nm-profile__name {
    font-weight: 700;
}

.nm-profile__email {
    color: var(--nm-muted);
    font-size: 13px;
}

.nm-profile__action {
    width: 100%;
    padding: 10px;
    border-radius: 10px;
    border: 1px solid var(--nm-border);
    background: rgba(255, 255, 255, 0.06);
    color: var(--nm-text);
    cursor: pointer;
}

@media (max-width: 900px) {
    .nm-panel {
        width: clamp(260px, 92vw, 620px);
    }

    .nm-inline-cards {
        width: min(98vw, 980px);
    }
}

@media (max-width: 640px) {
    .nm-overlay {
        align-items: center;
        padding: 12px 10px;
        overflow-y: auto;
    }

    .nm-panel {
        padding: 14px;
        width: min(96vw, 420px);
        max-width: 420px;
        max-height: 86vh;
        margin: 0 auto 10px;
        overflow-y: auto;
    }

    .nm-inline-cards {
        flex-wrap: nowrap;
        justify-content: flex-start;
        width: 100%;
        max-width: 100%;
        gap: 10px;
        overflow-x: auto;
        overflow-y: visible;
        padding: 0 4px 8px;
        scroll-snap-type: x mandatory;
        -webkit-overflow-scrolling: touch;
    }
    .nm-inline-cards::-webkit-scrollbar {
        height: 8px;
    }
    .nm-inline-cards::-webkit-scrollbar-thumb {
        background: rgba(255,255,255,0.25);
        border-radius: 10px;
    }
    .nm-card {
        flex: 0 0 280px;
        max-width: 300px;
        border-radius: 12px;
        padding: 10px 12px;
        box-shadow: 0 10px 30px rgba(0,0,0,0.3);
        scroll-snap-align: start;
    }
    .nm-actions {
        flex-direction: column;
        gap: 8px;
    }
    .nm-button {
        width: 100%;
        justify-content: center;
    }
    .nm-title {
        font-size: 20px;
        line-height: 1.3;
    }
    .nm-subtitle {
        font-size: 14px;
        line-height: 1.4;
    }
    /* Move profile trigger away from the close button */
    .nm-profile {
        top: auto;
        bottom: 16px;
        right: 14px;
    }
}

@media (max-width: 480px) {
    .nm-panel {
        border-radius: 12px;
        width: min(96vw, 380px);
    }
    .nm-title {
        font-size: 18px;
    }
    .nm-subtitle {
        font-size: 13px;
    }
    .nm-inline-cards {
        gap: 8px;
    }
    .nm-card {
        padding: 10px 12px;
        flex-basis: 260px;
    }
}

/* --- Leaflet UI polish --- */
.leaflet-container {
    font-family: 'Manrope', system-ui, sans-serif;
    color: var(--nm-text);
}

.leaflet-control {
    border: 1px solid var(--nm-border);
    border-radius: 12px;
    background: var(--nm-surface);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
    backdrop-filter: var(--nm-blur);
    overflow: hidden;
}

.leaflet-bar a, .leaflet-bar a:hover {
    background: transparent;
    color: var(--nm-text);
    border-bottom: 1px solid var(--nm-border);
}

.leaflet-bar a:last-child {
    border-bottom: none;
}

.leaflet-control-layers {
    padding: 6px 8px;
    background: rgba(4, 7, 18, 0.6);
    border: 1px solid var(--nm-border-strong);
}

.leaflet-control-layers-toggle {
    width: 34px;
    height: 34px;
    background-color: rgba(255, 255, 255, 0.08);
    border-radius: 10px;
    border: 1px solid var(--nm-border);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}

.leaflet-control-layers-expanded {
    background: rgba(4, 7, 18, 0.7);
    border: 1px solid var(--nm-border-strong);
    color: var(--nm-text);
}

/* Logo control: keep the background fully transparent */
.leaflet-bottom.leaflet-right .leaflet-control {
    background: transparent;
    border: none;
    box-shadow: none;
    backdrop-filter: none;
}

.leaflet-control .logo {
    background: transparent;
    padding: 0;
    margin: 0;
    overflow: visible;
    display: inline-flex;
    align-items: center;
    justify-content: flex-start;
    padding-left: 4px;
}

.leaflet-control .logo img {
    display: block;
    background: transparent;
    max-width: none;
    height: auto;
}

.leaflet-control-layers-list label {
    color: var(--nm-text);
    font-size: 13px;
}

.leaflet-popup-content-wrapper, .leaflet-popup-tip {
    background: var(--nm-surface-strong);
    color: var(--nm-text);
    border: 1px solid var(--nm-border);
    box-shadow: var(--nm-shadow);
    backdrop-filter: blur(14px);
}

.leaflet-popup-content {
    margin: 16px 18px 14px;
    line-height: 1.45;
    font-size: 14px;
    min-height: 1px;
    width: 100%;
    overflow-y: auto;
    max-height: 60vh;
}

.leaflet-popup-content-wrapper img {
    position: relative;
    margin: 6px auto 10px;
    width: 100%;
    height: auto;
    max-height: 320px;
    object-fit: contain;
    border-radius: 12px;
    border: 1px solid var(--nm-border);
}

.leaflet-popup-content-wrapper a {
    color: var(--nm-accent);
    text-decoration: none;
    font-weight: 600;
}

.leaflet-control-container .leaflet-top,
.leaflet-control-container .leaflet-bottom {
    z-index: 450;
}

.leaflet-control-search,
.leaflet-control-geocoder {
    position: fixed !important;
    right: 70px !important;
    left: auto !important;
    top: 16px !important;
    z-index: 700;
    display: block !important;
}

/* --- Carousel inside popups --- */
.carousel {
    position: relative;
}

.carousel-slide {
    display: none;
}

.carousel-slide.active {
    display: block;
}

.carousel-dots {
    display: flex;
    justify-content: center;
    gap: 6px;
    margin-top: 8px;
}

.carousel-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--nm-border);
    cursor: pointer;
}

.carousel-dot.active {
    background: var(--nm-accent);
}

.nm-list-actions {
    margin-top: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
}

.nm-list-actions button {
    border: 1px solid var(--nm-border);
    background: rgba(255, 255, 255, 0.06);
    color: var(--nm-text);
    border-radius: 10px;
    padding: 8px 12px;
    min-height: 36px;
    font-size: 12px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1.2;
}

.nm-list-actions button:hover {
    border-color: var(--nm-border-strong);
    color: var(--nm-accent);
}

/* --- Lightboxes and full bleed overlays --- */
.lightbox,
[class^=lightbox_],
[class^=large_],
[class^=planner_],
.panobox {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(4, 7, 18, 0.78);
    color: var(--nm-text);
    padding: clamp(12px, 5vw, 32px);
    box-sizing: border-box;
    z-index: 1000;
    backdrop-filter: blur(14px);
}

.lightbox-content,
.large-lightbox-content,
.panobox-content,
#planner-content {
    background: var(--nm-surface-strong);
    padding: clamp(16px, 4vw, 24px);
    border-radius: 16px;
    margin: auto;
    text-align: left;
    font-family: 'Manrope', system-ui, sans-serif;
    overflow-y: auto;
    max-height: calc(100% - 80px);
    max-width: 1100px;
    border: 1px solid var(--nm-border);
    box-shadow: var(--nm-shadow);
}

.panobox-content,
#planner-content {
    text-align: center;
}

.lightbox-content a {
    color: var(--nm-accent);
    text-decoration: none;
    font-weight: 600;
}

.close {
    cursor: pointer;
    color: var(--nm-text);
    float: right;
    font-size: 30px;
    line-height: 1;
    opacity: 0.8;
}

.close:hover {
    opacity: 1;
}

div.list-block-center {
    text-align: center;
}

/* Contributors lightbox */
.nm-contrib {
    max-width: 1080px;
}

.nm-contrib__header {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 16px;
    align-items: center;
    margin-bottom: 12px;
}

.nm-contrib__header img {
    max-width: 200px;
}

.nm-contrib__eyebrow {
    margin: 0 0 4px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 700;
    color: var(--nm-accent);
    font-size: 12px;
}

.nm-contrib__lede {
    margin: 4px 0 0;
    color: var(--nm-muted);
}

.nm-contrib__grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 12px;
    margin: 12px 0;
}

.nm-contrib__card {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--nm-border);
    border-radius: 12px;
    padding: 12px 14px;
}

.nm-contrib__label {
    margin: 0 0 6px;
    font-weight: 700;
    color: var(--nm-accent);
}

.nm-contrib__card ul {
    margin: 0 0 10px;
    padding-left: 18px;
    color: var(--nm-text);
}

.nm-contrib__card li {
    margin-bottom: 4px;
}

.nm-contrib__card a {
    color: var(--nm-accent);
    font-weight: 600;
    text-decoration: none;
}

.nm-contrib__card a:hover {
    text-decoration: underline;
}

.nm-contrib__cta {
    margin-top: 10px;
    padding: 10px;
    border: 1px solid var(--nm-border);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.02);
}

.nm-contrib__cta p {
    margin: 0 0 8px;
    color: var(--nm-muted);
}

.nm-contrib__footer {
    text-align: center;
    color: var(--nm-muted);
    margin-top: 8px;
    font-weight: 600;
}

/* Lists modal */
.nm-modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(4, 7, 18, 0.78);
    backdrop-filter: blur(10px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1200;
}
.nm-modal {
    background: var(--nm-surface-strong);
    border: 1px solid var(--nm-border);
    border-radius: 14px;
    padding: 16px 18px;
    max-width: 420px;
    width: 100%;
    box-shadow: 0 20px 80px rgba(0,0,0,0.45);
    color: var(--nm-text);
}
.nm-modal h3 {
    margin: 0 0 10px;
}
.nm-modal label {
    display: block;
    margin: 8px 0 4px;
    font-weight: 600;
}
.nm-modal select, .nm-modal input {
    width: 100%;
    padding: 8px;
    border-radius: 10px;
    border: 1px solid var(--nm-border);
    background: rgba(255,255,255,0.05);
    color: var(--nm-text);
    margin-bottom: 8px;
}
.nm-modal-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    margin-top: 10px;
}
.nm-modal-actions button {
    border: 1px solid var(--nm-border);
    background: rgba(255,255,255,0.07);
    color: var(--nm-text);
    border-radius: 10px;
    padding: 8px 12px;
    cursor: pointer;
}
.nm-modal-actions .primary {
    background: linear-gradient(135deg, #7ef1ff, #6cc0ff);
    color: #041024;
    border: none;
    box-shadow: 0 10px 24px rgba(126,241,255,0.35);
}

.imageLightbox {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.9);
    box-sizing: border-box;
    z-index: 1000;
    display: grid;
    place-items: center;
    animation: fadeToBlack 0.4s ease;
}

@keyframes fadeToBlack {
    from { background-color: rgba(0, 0, 0, 0); }
    to { background-color: rgba(0, 0, 0, 0.9); }
}

.imagebox-content {
    display: grid;
    place-items: center;
    width: 100%;
    height: 100%;
}

.imagebox-content img {
    width: 100vw;
    height: 100vh;
    object-fit: contain;
    animation: fadeIn 0.6s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

#panorama {
    width: 100%;
    min-height: 60vh;
    height: 70vh;
}

/* --- Legacy helpers kept for compatibility --- */
.two-column-list {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    justify-content: center;
}

.two-column-list li {
    flex: 1 1 calc(50% - 20px);
    list-style-type: none;
}

legend {
    position: relative;
    top: 10px;
    width: 100%;
    text-align: center;
    color: var(--nm-muted);
}

legend > item {
    margin: 0 10px 10px 0;
    float: left;
    border-radius: 10px;
    padding: 8px 10px;
    font-size: 11px;
    font-weight: bold;
    background: var(--nm-surface);
    border: 1px solid var(--nm-border);
}

.axis-grid line {
    stroke: #aaa;
    opacity: 0.25;
}

.attribution-control {
    position: absolute;
    bottom: 10px;
    left: 10px;
    background: var(--nm-surface);
    padding: 8px 10px;
    border: 1px solid var(--nm-border);
    border-radius: 10px;
    z-index: 1000;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
    color: #fff;
}

.attribution-content {
    display: none;
}

.attribution-control.collapsed .attribution-content {
    display: block;
}

.leaflet-control-attribution a {
    color: #dbe8ff;
    font-weight: 600;
}

.leaflet-control-attribution {
    color: #dbe8ff;
}

.leaflet-tooltip.nm-tooltip {
    background: rgba(7, 10, 20, 0.92);
    color: var(--nm-text);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    box-shadow: 0 10px 24px rgba(0,0,0,0.35);
    padding: 6px 10px;
    font-size: 13px;
    font-weight: 600;
}

#details {
    background: var(--nm-surface);
    padding: 10px;
    color: var(--nm-text);
    display: flex;
    width: 800px;
    max-width: 800px;
    box-shadow: 7px -2px 8px -1px rgba(0, 0, 0, 0.7);
    border-bottom-right-radius: 10px;
    border-bottom-left-radius: 10px;
}

#details div {
    display: flex;
    flex-direction: column;
    flex-grow: 1;
}

span {
    font-size: 0.9rem;
    margin-top: 10px;
}

.logo {
    pointer-events: auto;
}

.leaflet-center {
    left: 50%;
    transform: translate(-50%, 0%);
}

/* Image meta captions in carousel */
.nm-img-meta {
    color: var(--nm-muted);
    font-size: 12px;
    margin-top: 4px;
}

/* Add photo button in popups */
.nm-add-photo {
    background: linear-gradient(135deg, rgba(126,241,255,0.15), rgba(126,241,255,0.08));
    color: var(--nm-accent);
    border: 1px solid rgba(126,241,255,0.35);
    border-radius: 12px;
    padding: 8px 12px;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 6px 18px rgba(0,0,0,0.25);
}
.nm-add-photo:hover {
    border-color: rgba(126,241,255,0.6);
    color: #0b1828;
    background: var(--nm-accent);
}

/* Add photo button match list style */
.nm-add-photo {
    border: 1px solid var(--nm-border);
    background: rgba(255, 255, 255, 0.06);
    color: var(--nm-text);
    border-radius: 10px;
    padding: 8px 12px;
    min-height: 36px;
    font-size: 12px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    line-height: 1.2;
}
.nm-add-photo:hover {
    border-color: var(--nm-border-strong);
    color: var(--nm-accent);
}

/* Align list and photo buttons in popup */
.nm-actions-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
