html, body {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    background: #05050d;
    overflow: hidden;
    font-family: -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}

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

#map {
    position: absolute;
    inset: 0;
    background: #05050d;
}

/* Leaflet's default attribution/zoom controls aren't used - custom ones replace them */
.leaflet-control-container {
    display: none;
}

/* ---- day/night + timezone canvas overlays ---- */
.overlay-canvas {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 450; /* above tile panes, below markers */
}

/* ---- sidebar layer-toggle buttons: float directly over the map, no panel ---- */
#sidebar {
    position: absolute;
    top: 0;
    right: 0;
    max-height: 100vh;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    scrollbar-width: none;
}
#sidebar::-webkit-scrollbar {
    display: none;
}

.sidebar-btn {
    width: 48px;
    height: 48px;
    flex-shrink: 0;
    border: none;
    background: transparent;
    padding: 0;
    cursor: pointer;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
}

#settings-btn {
    position: absolute;
    right: 12px;
    bottom: 58px;
    z-index: 1000;
}

/* ---- zoom buttons, bottom-center ---- */
#zoom-controls {
    position: absolute;
    left: 50%;
    bottom: 30px;
    transform: translateX(-50%);
    z-index: 1000;
    display: flex;
    gap: 14px;
}

.zoom-btn {
    width: 40px;
    height: 40px;
    border-radius: 20px;
    background: rgba(18, 18, 26, 0.7);
    border: 1px solid rgba(255, 255, 255, 0.24);
    color: #fff;
    font-size: 20px;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}
.zoom-btn:hover { background: rgba(45, 45, 60, 0.82); }
.zoom-btn:active { background: rgba(65, 65, 85, 0.9); }

/* ---- generic marker popup box (cities, aircraft, earthquakes, storms, locations) ---- */
.map-popup {
    position: absolute;
    z-index: 900;
    background: rgba(18, 18, 26, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 6px;
    padding: 8px 12px;
    color: #fff;
    pointer-events: auto;
    cursor: pointer;
    white-space: nowrap;
}
.map-popup .title {
    font-size: 15px;
    font-weight: bold;
    color: #fff;
}
.map-popup .line {
    font-size: 14px;
    color: rgb(200, 210, 255);
    margin-top: 2px;
}

/* ---- timezone labels ---- */
.tz-label {
    position: absolute;
    z-index: 460;
    background: rgba(10, 10, 16, 0.6);
    color: rgba(255, 255, 255, 0.9);
    font-size: 12px;
    font-weight: bold;
    padding: 2px 4px;
    border-radius: 3px;
    top: 4px;
    transform: translateX(-50%);
    pointer-events: none;
    white-space: nowrap;
}
.tz-label.utc {
    color: rgb(255, 90, 90);
}

/* ---- moon badge, top-center ---- */
#moon-badge {
    position: absolute;
    top: 16px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 900;
    background: rgba(10, 10, 16, 0.7);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 6px;
    padding: 10px 14px;
    display: none;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    color: #fff;
}
#moon-badge.visible { display: flex; }
#moon-badge img {
    width: 40px;
    height: 40px;
}
#moon-badge .header {
    font-size: 12px;
    font-weight: bold;
    color: rgb(170, 185, 220);
}
#moon-badge .title {
    font-size: 14px;
    font-weight: bold;
    display: none;
}
#moon-badge .detail {
    font-size: 13px;
    color: rgb(200, 210, 255);
    display: none;
}
#moon-badge.expanded .title,
#moon-badge.expanded .detail {
    display: block;
}

/* ---- sub-lunar point marker ---- */
.sublunar-icon {
    width: 30px;
    height: 30px;
}
.sublunar-label {
    position: absolute;
    background: rgba(10, 10, 16, 0.6);
    color: rgb(255, 255, 200);
    font-size: 12px;
    font-weight: bold;
    padding: 2px 4px;
    border-radius: 3px;
    white-space: nowrap;
    pointer-events: none;
}

/* ---- attribution ---- */
#attribution {
    position: absolute;
    right: 0;
    bottom: 0;
    z-index: 1000;
    background: rgba(0, 0, 0, 0.55);
    color: rgba(255, 255, 255, 0.85);
    font-size: 11px;
    padding: 3px 6px;
    pointer-events: none;
}

/* ---- generic Leaflet popup skin (city/aircraft/earthquake/storm/location) ---- */
.leaflet-popup-content-wrapper {
    background: rgba(18, 18, 26, 0.85);
    color: #fff;
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.2);
}
.leaflet-popup-tip { background: rgba(18, 18, 26, 0.85); }
.leaflet-popup-content { margin: 10px 14px; }
.leaflet-popup-content .title { font-size: 15px; font-weight: bold; color: #fff; }
.leaflet-popup-content .line { font-size: 14px; color: rgb(200, 210, 255); margin-top: 3px; }
.leaflet-popup-content .line a { color: rgb(140, 180, 255); }
.leaflet-popup-content .line a:hover { color: rgb(180, 210, 255); }

/* ---- add-location dialog ---- */
.dialog-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
}
.dialog {
    background: #1a1a24;
    color: #fff;
    border-radius: 8px;
    padding: 20px 24px;
    width: 420px;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}
.dialog h2 { margin: 0 0 12px; font-size: 18px; }
.dialog-label { margin: 14px 0 6px; font-weight: bold; font-size: 13px; color: rgba(255, 255, 255, 0.8); }
.dialog-row { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.dialog-row input[type="text"] { flex: 1; }
.dialog input[type="text"], .dialog input[type="password"], .dialog select {
    background: #2a2a36;
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 4px;
    padding: 6px 8px;
    font-size: 13px;
    width: 100%;
    box-sizing: border-box;
}
.dialog select { height: 90px; }
.dialog button {
    background: #3a3a4a;
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 4px;
    padding: 6px 12px;
    font-size: 13px;
    cursor: pointer;
    white-space: nowrap;
}
.dialog button:hover { background: #45455a; }
.dialog button:disabled { opacity: 0.4; cursor: default; }
.dialog-status { font-size: 12px; color: rgba(255, 255, 255, 0.7); min-height: 16px; margin-bottom: 4px; }
.dialog-checkbox { display: block; margin: 8px 0; font-size: 13px; }
.dialog-btn-full { width: 100%; margin-top: 10px; padding: 8px; }
.dialog-existing-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    font-size: 13px;
}
.dialog-existing-row span { flex: 1; }
.dialog-empty { color: rgba(255, 255, 255, 0.5); font-size: 13px; }
