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

:root {
    --panel-bg: #ffffff;
    --panel-border: #e5e7eb;
    --panel-shadow: 0 18px 40px rgba(15, 23, 42, 0.1);
    --surface-muted: #f6f6f6;
    --text-dark: #111827;
    --text-muted: #6b7280;
    --accent: #111827;
    --chip-bg: #f5f5f5;
    --chip-border: #e5e7eb;
}

body {
    font-family: 'Arial', sans-serif;
    background: linear-gradient(135deg, #e0eafc 0%, #cfdef3 100%);
    min-height: 100vh;
    width: 100vw;
    overflow: hidden;
}

#map {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    width: 100vw;
    border: none;
    z-index: 1;
}

.control-panel {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 360px;
    min-width: 360px;
    max-width: 360px;
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    border-radius: 16px;
    padding: 16px;
    box-shadow: var(--panel-shadow);
    z-index: 1000;
    max-height: calc(100vh - 40px);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    gap: 16px;
    transition: transform 0.35s ease, box-shadow 0.35s ease;
}

.panel-toggle {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    border: 1px solid var(--panel-border);
    background: var(--surface-muted);
    color: var(--text-dark);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease;
    font-size: 18px;
}

.panel-toggle:focus-visible {
    outline: 2px solid rgba(11, 37, 69, 0.45);
    outline-offset: 2px;
}

.panel-toggle:hover {
    background: var(--text-dark);
    color: #fff;
}

.panel-toggle .toggle-icon {
    display: inline-block;
    transition: transform 0.25s ease;
}

.panel-handle {
    display: none;
    position: absolute;
    top: -14px;
    left: 50%;
    transform: translateX(-50%);
    width: 100px;
    height: 28px;
    z-index: 1000;
    cursor: grab;
}
.panel-handle:active { cursor: grabbing; }
.panel-handle .handle-bar {
    width: 56px;
    height: 6px;
    background: rgba(0,0,0,0.12);
    border-radius: 999px;
    margin: 8px auto 0 auto;
    box-shadow: 0 2px 6px rgba(0,0,0,0.08) inset;
}

.panel-shell {
    display: flex;
    flex-direction: column;
    gap: 16px;
    height: 100%;
}

.panel-content {
    display: flex;
    flex-direction: column;
    gap: 16px;
    flex: 1;
}

.panel-stat-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.stat-chip {
    border-radius: 14px;
    padding: 12px;
    border: 1px solid var(--chip-border);
    background: var(--chip-bg);
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.stat-chip span {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.stat-chip strong {
    font-size: 1.1rem;
    color: var(--text-dark);
}

.panel-body {
    border-radius: 12px;
    padding: 16px;
    border: 1px solid var(--panel-border);
    background: #fff;
    display: flex;
    flex-direction: column;
    gap: 16px;
    min-height: 0;
    flex: 1;
}

.panel-scroll {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding-right: 0;
}

.panel-scroll::-webkit-scrollbar {
    width: 6px;
}

.panel-scroll::-webkit-scrollbar-thumb {
    background: rgba(11, 37, 69, 0.25);
    border-radius: 999px;
}

@media (max-width: 768px) {
    .panel-stat-grid {
        grid-template-columns: 1fr 1fr;
    }
}

@media (max-width: 520px) {
    .panel-stat-grid {
        grid-template-columns: 1fr;
    }
}

.tab-nav {
    display: flex;
    align-items: center;
    gap: 6px;
    border-radius: 999px;
    padding: 6px;
    background: var(--surface-muted);
    border: 1px solid var(--panel-border);
    overflow: hidden;
    justify-content: center;
}

.tab-btn {
    flex: 0 0 auto;
    border: none;
    background: transparent;
    border-radius: 999px;
    min-width: 44px;
    width: 44px;
    height: 44px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease, padding 0.2s ease;
}

.tab-btn .icon {
    display: inline-flex;
}

.tab-btn .label {
    white-space: nowrap;
    max-width: 0;
    opacity: 0;
    margin-left: 0;
    overflow: hidden;
    transition: max-width 0.2s ease, opacity 0.2s ease, margin-left 0.2s ease;
}

.tab-btn.active {
    background: var(--text-dark);
    color: #fff;
    padding: 0 14px;
    width: auto;
}

.tab-btn.active .label {
    max-width: 140px;
    opacity: 1;
    margin-left: 4px;
}

.tab-btn:hover {
    background: rgba(17, 24, 39, 0.08);
    color: var(--text-dark);
}

.tab-content {
    flex: 1;
    min-height: 100%;
}

.tab-pane {
    display: none;
}

.tab-pane.active {
    display: block;
}

.panel-mode-label {
    display: block;
    margin: 18px 0 8px 0;
    font-weight: 600;
    color: #0b2545;
}

.panel-mode-select {
    width: 100%;
    padding: 6px 8px;
    border-radius: 8px;
    border: 1px solid rgba(0, 0, 0, 0.12);
    background: rgba(255, 255, 255, 0.92);
    font-size: 0.92em;
}

.toggle-btn {
    background: #111827;
    color: #fff;
    border: none;
    padding: 6px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85em;
    transition: background 0.3s ease;
}
@media (max-width: 600px) {
    .control-panel {
        position: fixed;
        top: unset;
        bottom: 0;
        left: 0;
        right: 0;
        min-width: unset;
        max-width: unset;
        width: 100vw;
        max-height: 60vh;
        border-radius: 20px 20px 0 0;
        padding: 0;
        transform: translateY(calc(100% - 58px));
        transition: transform 0.36s cubic-bezier(0.22, 1, 0.36, 1), box-shadow 0.2s;
        z-index: 1001;
    }
    .control-panel.open {
        transform: translateY(0);
        box-shadow: 0 -10px 40px rgba(11,37,69,0.18);
    }
    .panel-handle {
        display: block;
        padding-top: 12px;
        padding-bottom: 12px;
    }
    .panel-handle::before {
        content: none;
    }
    .tab-nav {
        border-radius: 0;
        border-left: none;
        border-right: none;
        padding: 12px 20px;
        width: 100%;
        box-sizing: border-box;
        margin: 0;
    }
    .tab-btn {
        min-width: 88px;
    }
    .panel-content {
        padding: 0 20px 20px 20px;
    }
    .tab-content {
        padding: 0;
    }
    #map {
        position: fixed;
        top: 0;
        left: 0;
        height: 100vh !important;
        width: 100vw !important;
        z-index: 1;
    }
}

.toggle-btn:hover {
    background: #000;
}

@media (min-width: 601px) {
    .control-panel.collapsed {
        transform: translateX(calc(100% - 64px));
        box-shadow: none;
    }

    .control-panel.collapsed .tab-nav,
    .control-panel.collapsed .tab-content,
    .control-panel.collapsed .flight-controls,
    .control-panel.collapsed .stats-content,
    .control-panel.collapsed .panel-body,
    .control-panel.collapsed .panel-stat-grid,
    .control-panel.collapsed .panel-scroll {
        opacity: 0;
        pointer-events: none;
        user-select: none;
    }

    .control-panel.collapsed .panel-toggle .toggle-icon {
        transform: rotate(180deg);
    }
}

.flight-controls {
    margin-bottom: 20px;
    flex: 1;
    overflow-y: auto;
}

.flight-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.flight-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px;
    border-radius: 6px;
    transition: background 0.2s;
}

.flight-item:hover {
    background: #f3f3f3;
}

.flight-item input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
}

.flight-item label {
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9em;
    color: #333;
    flex: 1;
}

/* Car trips reuse flight-item styles but allow a slightly different color */
.cartrip-item label { color: #0b2545; font-weight: 600; }

.cartrip-item input[type="checkbox"] { width: 16px; height: 16px; cursor: pointer; }

.cartrip-header { margin-top: 10px; font-weight: 700; color: #333; }

.flight-color {
    width: 20px;
    height: 4px;
    border-radius: 2px;
    border: 1px solid #333;
}

.delay {
    color: #e74c3c;
    font-weight: bold;
    font-size: 0.8em;
}

.flight-stats {
    margin-top: 15px;
    padding-top: 10px;
    border-top: 2px solid rgba(102, 126, 234, 0.3);
}

.flight-stats h4 {
    color: #333;
    margin-bottom: 8px;
    font-size: 1.1em;
}

.flight-stats p {
    margin: 5px 0;
    color: #555;
    font-size: 0.9em;
}

@media (max-width: 768px) {
    .flight-panel {
        position: relative;
        top: 0;
        right: 0;
        margin: 20px;
        width: calc(100% - 40px);
        max-height: none;
    }
    
    #map {
        height: 50vh;
    }
}

/* Photo gallery styles */
.filter-select {
    background: #fff;
    border: 1px solid var(--panel-border);
    border-radius: 6px;
    padding: 6px 10px;
    color: #333;
    font-size: 0.9em;
}

.lang-select {
    padding: 6px 8px;
    border-radius: 6px;
    border: 1px solid rgba(0,0,0,0.08);
    background: rgba(255,255,255,0.9);
}


.photo-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    grid-auto-rows: 180px;
    gap: 10px;
    overflow-y: auto;
    min-height: 0;
    align-content: flex-start;
    transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Mobile: make photo gallery horizontally scrollable tiles for easier browsing */
@media (max-width: 600px) {
    .photo-grid {
        display: flex;
        flex-direction: row;
        gap: 10px;
        overflow-x: auto;
        scroll-snap-type: x mandatory;
        padding: 12px 6px;
        max-height: none;
    }
    .photo-item {
        min-width: 70vw;
        max-width: 80vw;
        scroll-snap-align: center;
        height: 240px;
        border-radius: 12px;
    }
    .photo-item img { object-fit: cover; }
}

.photo-item {
    position: relative;
    height: 180px;
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.3s;
    background: rgba(255, 255, 255, 0.1);
    z-index: 0;
    transform-origin: center;
}

.photo-item:hover {
    transform: scale(1.02);
    z-index: 3;
}

.photo-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.photo-item .photo-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.7));
    color: white;
    padding: 8px 6px 6px;
    font-size: 0.75em;
    line-height: 1.2;
}

.photo-item .photo-location {
    font-size: 0.7em;
    opacity: 0.85;
}
.photo-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(180deg, rgba(255,255,255,0.06), rgba(255,255,255,0.04));
    z-index: 2000;
    backdrop-filter: blur(22px) saturate(180%);
    -webkit-backdrop-filter: blur(22px) saturate(180%);
    padding: 24px;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.25s ease;
}

.photo-modal.open {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.modal-content {
    position: relative;
    background: rgba(255, 255, 255, 0.45);
    box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.37);
    backdrop-filter: blur(12px) saturate(180%);
    -webkit-backdrop-filter: blur(12px) saturate(180%);
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.18);
    padding: 24px;
    max-width: min(1100px, 90vw);
    width: 100%;
    max-height: 90vh;
    overflow: hidden;
    display: grid;
    grid-template-columns: minmax(0, 2.5fr) minmax(240px, 1fr);
    gap: 24px;
}

.modal-close {
    position: absolute;
    top: 10px;
    right: 15px;
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #666;
}


.modal-media {
    position: relative;
    padding: 0 56px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.modal-image-stage {
    position: relative;
    /*overflow: hidden;*/
    display: flex;
    justify-content: center;
}

#modalImage {
    max-width: 100%;
    max-height: 70vh;
    width: 100%;
    height: auto;
    border-radius: 8px;
    cursor: zoom-in;
    transition: transform 0.1s ease-out;
    transform-origin: center center;
    box-shadow: 0 12px 32px rgba(0,0,0,0.25);
    -webkit-user-drag: none;
    user-drag: none;
    user-select: none;
    touch-action: none;
}

.modal-nav {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: none;
    background: rgba(0, 0, 0, 0.55);
    color: #fff;
    font-size: 1.5rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease;
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
}

.modal-nav-prev {
    left: 8px;
}

.modal-nav-next {
    right: 8px;
}

.modal-nav:hover {
    background: rgba(0, 0, 0, 0.75);
}

.modal-info {
    overflow-y: auto;
    max-height: calc(90vh - 48px);
    padding-right: 6px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.modal-info h3 {
    margin: 0;
    color: #000;
}

.modal-info p {
    margin: 4px 0;
    color: #333;
    font-size: 0.9em;
}

.modal-location-text {
    font-weight: 600;
}

@media (max-width: 900px) {
    .modal-content {
        grid-template-columns: 1fr;
        gap: 16px;
    }
    .modal-info {
        max-height: none;
        padding-right: 0;
    }
}

@media (max-width: 640px) {
    .modal-media {
        padding: 0 36px;
    }
    .modal-nav {
        width: 36px;
        height: 36px;
        font-size: 1.2rem;
    }
}

@keyframes modalDesktopPop {
    from {
        transform: scale(0.92);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

@media (hover: hover) and (pointer: fine) {
    .modal-content.desktop-pop {
        animation: modalDesktopPop 0.35s cubic-bezier(0.22, 1, 0.36, 1);
    }

    /* Make sure the modal content is always centered and not moved by translate offsets */
    .modal-content {
        transform: translate(0, 0);
    }
}

/* Photo Gallery Popup */
.photo-gallery-popup {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    /* match control panel glass look */
    background: linear-gradient(180deg, rgba(255,255,255,0.14), rgba(255,255,255,0.10));
    z-index: 1500;
    backdrop-filter: blur(18px) saturate(170%);
    -webkit-backdrop-filter: blur(18px) saturate(170%);
}

.popup-content {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(255, 255, 255, 0.82);
    box-shadow: 0 12px 48px 0 rgba(11, 37, 69, 0.18);
    backdrop-filter: blur(14px) saturate(180%);
    -webkit-backdrop-filter: blur(14px) saturate(180%);
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.18);
    width: 90vw;
    max-width: 1200px;
    height: 80vh;
    max-height: 800px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* Make photo modal and popup more usable on small phones */
@media (max-width: 420px) {
    .modal-content {
        width: 96vw;
        height: 86vh;
        max-width: 96vw;
        max-height: 86vh;
        border-radius: 14px;
        padding: 16px;
    }

    .modal-media { padding: 0 24px; }

    #modalImage { max-height: 74vh; }

    .popup-content {
        width: 98vw;
        height: 92vh;
        max-width: 98vw;
        max-height: 92vh;
        border-radius: 12px;
    }
}

.popup-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}

.popup-header h2 {
    margin: 0;
    color: #333;
}

.popup-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #666;
}

.popup-controls {
    padding: 15px 20px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

/* Make multi-selects easier to use */
.popup-controls .filter-select[multiple] {
    min-height: 80px;
    max-height: 140px;
    overflow-y: auto;
}

.popup-controls .filter-select {
    flex: 1 1 160px;
    min-width: 140px;
}

#popup-photo-grid {
    flex: 1;
    min-height: 0;
    max-height: none;
    overflow-y: auto;
    padding: 20px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 15px;
}

/* Stats styles */
.stat-group {
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}

.stat-group:last-child {
    border-bottom: none;
}

.stat-group h4 {
    margin: 0 0 10px 0;
    color: #333;
    font-size: 1em;
}

.stat-group p {
    margin: 5px 0;
    color: #555;
    font-size: 0.9em;
}
.city-marker {
    transition: all 0.3s ease;
}

.city-marker:hover {
    transform: scale(1.1);
}

.leaflet-popup-content-wrapper {
    background: rgba(255, 255, 255, 0.95) !important;
    backdrop-filter: blur(10px) !important;
    border-radius: 12px !important;
    border: 1px solid rgba(255, 255, 255, 0.3) !important;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2) !important;
}

.leaflet-popup-tip {
    background: rgba(255, 255, 255, 0.95) !important;
    backdrop-filter: blur(10px) !important;
}

@media (max-width: 768px) {
    .flight-panel {
        position: relative;
        top: 0;
        right: 0;
        margin: 20px;
        width: calc(100% - 40px);
        max-height: none;
    }
    
    #map {
        height: 50vh;
    }
    
    .header h1 {
        font-size: 2em;
    }
    
    .legend {
        gap: 15px;
    }
}

/* progressive blur */
.wrapper {
    position: relative;
    overflow: hidden;
}

.progressive-blur {
    position: absolute;
    z-index: 7;
    width: 100%;
    height: 100%;
    pointer-events: none;
    inset: auto 0 0 0;
}

.blur {
    background-size: cover;
    position: absolute;
    inset: 0;
}

.progressive-blur>div:nth-child(1) {
    filter: blur(1px);
    mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 0) 69%, rgba(0, 0, 0, 1) 74.16666666666667%, rgba(0, 0, 0, 1) 79.33333333333333%, rgba(0, 0, 0, 0) 84.5%);
    -webkit-mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 0) 69%, rgba(0, 0, 0, 1) 74.16666666666667%, rgba(0, 0, 0, 1) 79.33333333333333%, rgba(0, 0, 0, 0) 84.5%);
    z-index: 1;
}

.progressive-blur>div:nth-child(2) {
    filter: blur(2px);
    mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 0) 74.16666666666667%, rgba(0, 0, 0, 1) 79.33333333333333%, rgba(0, 0, 0, 1) 84.5%, rgba(0, 0, 0, 0) 89.66666666666667%);
    -webkit-mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 0) 74.16666666666667%, rgba(0, 0, 0, 1) 79.33333333333333%, rgba(0, 0, 0, 1) 84.5%, rgba(0, 0, 0, 0) 89.66666666666667%);
    z-index: 2;
}

.progressive-blur>div:nth-child(3) {
    filter: blur(4px);
    mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 0) 79.33333333333333%, rgba(0, 0, 0, 1) 84.5%, rgba(0, 0, 0, 1) 89.66666666666667%, rgba(0, 0, 0, 0) 94.83333333333334%);
    -webkit-mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 0) 79.33333333333333%, rgba(0, 0, 0, 1) 84.5%, rgba(0, 0, 0, 1) 89.66666666666667%, rgba(0, 0, 0, 0) 94.83333333333334%);
    z-index: 3;
}

.progressive-blur>div:nth-child(4) {
    filter: blur(8px);
    mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 0) 84.5%, rgba(0, 0, 0, 1) 89.66666666666667%, rgba(0, 0, 0, 1) 94.83333333333334%, rgba(0, 0, 0, 0) 100%);
    -webkit-mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 0) 84.5%, rgba(0, 0, 0, 1) 89.66666666666667%, rgba(0, 0, 0, 1) 94.83333333333334%, rgba(0, 0, 0, 0) 100%);
    z-index: 4;
}

.progressive-blur>div:nth-child(5) {
    filter: blur(16px);
    mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 0) 89.66666666666667%, rgba(0, 0, 0, 1) 94.83333333333334%, rgba(0, 0, 0, 1) 100%);
    -webkit-mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 0) 89.66666666666667%, rgba(0, 0, 0, 1) 94.83333333333334%, rgba(0, 0, 0, 1) 100%);
    z-index: 5;
}

.progressive-blur>div:nth-child(6) {
    filter: blur(32px);
    mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 0) 94.83333333333334%, rgba(0, 0, 0, 1) 100%);
    -webkit-mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 0) 94.83333333333334%, rgba(0, 0, 0, 1) 100%);
    z-index: 6;
}