html, body {
    margin: 0;
    padding: 0;
    height: 100%;
}
#map {
    width: 100%;
    height: 100vh;
}
/* --- Tile Switcher --- */
.tile-switcher {
    position: fixed;
    top: 16px;
    right: 16px;
    z-index: 1100;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px 6px 10px;
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(0, 0, 0, 0.10);
    border-radius: 10px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
}
.tile-icon {
    flex-shrink: 0;
    color: #888;
}
#tile-select {
    border: none;
    outline: none;
    background: transparent;
    font-size: 13px;
    font-family: inherit;
    color: #333;
    cursor: pointer;
    padding: 2px 0;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%23999'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0 center;
    padding-right: 16px;
}
#tile-select:hover {
    color: #3b82f6;
}

/* --- Legend Panel --- */
.legend {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 1000;
    width: 220px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
    font-size: 13px;
    color: #333;
    background: rgba(245, 245, 245, 0.94);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(0, 0, 0, 0.10);
    border-radius: 14px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.10), 0 1px 3px rgba(0, 0, 0, 0.06);
    overflow: hidden;
}
.legend-head {
    padding: 14px 16px 10px;
    border-bottom: 1px solid #eee;
}
.legend-title {
    font-size: 15px;
    font-weight: 800;
    color: #1a1a1a;
    letter-spacing: 0.01em;
}
.legend-sub {
    font-size: 11px;
    color: #999;
    margin-top: 1px;
}
.legend-categories {
    padding: 10px 16px;
    border-bottom: 1px solid #eee;
}
.legend-cat {
    display: flex;
    align-items: center;
    padding: 3px 0;
}
.legend-dot {
    flex-shrink: 0;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-right: 10px;
}
.legend-label {
    flex: 1;
    font-size: 12px;
    color: #555;
}
.legend-count {
    font-size: 12px;
    font-weight: 700;
    color: #1a1a1a;
    font-variant-numeric: tabular-nums;
}
.legend-stats {
    padding: 10px 16px;
    border-bottom: 1px solid #eee;
}
.legend-stat {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 2px 0;
}
.legend-stat-label {
    font-size: 11px;
    color: #888;
}
.legend-stat-value {
    font-size: 12px;
    font-weight: 700;
    color: #1a1a1a;
    font-variant-numeric: tabular-nums;
}
.legend-stat-divider {
    height: 1px;
    background: #f0f0f0;
    margin: 6px 0;
}
.legend-links {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
}
.legend-links a {
    font-size: 11px;
    color: #888;
    text-decoration: none;
    transition: color 0.15s;
}
.legend-links a:hover {
    color: #3b82f6;
}
.legend-link-sep {
    width: 1px;
    height: 12px;
    background: #ddd;
}
/* --- Popup Card --- */
.pp-popup .leaflet-popup-content-wrapper {
    border-radius: 12px;
    padding: 0;
    box-shadow: 0 6px 28px rgba(0,0,0,0.15);
    overflow: hidden;
}
.pp-popup .leaflet-popup-content {
    margin: 0;
    min-width: 220px;
}
.pp-popup .leaflet-popup-tip {
    box-shadow: 0 3px 8px rgba(0,0,0,0.1);
}
.pp {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
    font-size: 13px;
    color: #333;
}
.pp-head {
    padding: 14px 16px 10px;
    border-bottom: 1px solid #eee;
}
.pp-icao {
    display: block;
    font-size: 18px;
    font-weight: 800;
    letter-spacing: 0.08em;
    font-family: "SF Mono", "Cascadia Code", "Consolas", monospace;
    margin-bottom: 2px;
}
.pp-name {
    display: block;
    font-size: 13px;
    color: #666;
    line-height: 1.3;
}
.pp-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    padding: 8px 16px;
    border-bottom: 1px solid #eee;
}
.pp-badge {
    display: inline-block;
    font-size: 11px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 20px;
    white-space: nowrap;
}
.badge-tile {
    background: #f0f4ff;
    color: #4a6fa5;
    font-family: "SF Mono", "Cascadia Code", "Consolas", monospace;
    letter-spacing: 0.03em;
}
.badge-ortho {
    background: #ecfdf5;
    color: #047857;
}
.badge-rwy {
    background: #fefce8;
    color: #a16207;
}
.pp-archives {
    padding: 8px 16px 12px;
}
.pp-arch {
    padding: 6px 0;
}
.pp-arch + .pp-arch {
    border-top: 1px solid #f3f3f3;
}
.pp-dir {
    font-size: 12px;
    font-weight: 500;
    color: #1a1a1a;
    word-break: break-word;
    line-height: 1.35;
    margin-bottom: 4px;
}
.pp-arch-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 5px;
}
.pp-source {
    font-size: 11px;
    color: #888;
    font-weight: 500;
}
.pp-tag {
    display: inline-block;
    font-size: 10px;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.tag-xp12 {
    background: #dcfce7;
    color: #166534;
}
.tag-flat {
    background: #ede9fe;
    color: #5b21b6;
}
.tag-2d {
    background: #ffedd5;
    color: #c2410c;
}

/* --- Map Marker Icon (from DB icon_html) --- */
.legend-marker {
    display: inline-block;
    width: 20px;
    height: 20px;
    line-height: 20px;
    text-align: center;
    border-radius: 50%;
    font-weight: bold;
    font-size: 12px;
}
.custom-div-icon {
    background: transparent;
    border: none;
}

/* --- ICAO Search Box --- */
.search-container {
    position: fixed;
    top: 16px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1100;
    width: 340px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
}
.search-box {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(0, 0, 0, 0.12);
    border-radius: 12px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.10), 0 1px 3px rgba(0, 0, 0, 0.06);
    transition: box-shadow 0.2s, border-color 0.2s;
}
.search-box:focus-within {
    border-color: rgba(59, 130, 246, 0.5);
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.12), 0 0 0 3px rgba(59, 130, 246, 0.15);
}
.search-icon {
    flex-shrink: 0;
    color: #999;
}
.search-box:focus-within .search-icon {
    color: #3b82f6;
}
#icao-search {
    flex: 1;
    border: none;
    outline: none;
    background: transparent;
    font-size: 14px;
    color: #1a1a1a;
    letter-spacing: 0.02em;
}
#icao-search::placeholder {
    color: #aaa;
}
.search-hint {
    flex-shrink: 0;
    font-family: inherit;
    font-size: 11px;
    color: #bbb;
    background: rgba(0, 0, 0, 0.05);
    padding: 2px 6px;
    border-radius: 4px;
    border: 1px solid rgba(0, 0, 0, 0.08);
    min-width: 18px;
    text-align: center;
}

/* --- Search Results Dropdown --- */
.search-results {
    display: none;
    list-style: none;
    margin: 6px 0 0 0;
    padding: 6px 0;
    background: rgba(255, 255, 255, 0.96);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(0, 0, 0, 0.10);
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.14);
    max-height: 360px;
    overflow-y: auto;
}
.search-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 14px;
    cursor: pointer;
    transition: background 0.1s;
}
.search-item:hover,
.search-active {
    background: rgba(59, 130, 246, 0.08);
}
.search-cat {
    flex-shrink: 0;
    width: 8px;
    height: 8px;
    border-radius: 50%;
}
.search-icao {
    flex-shrink: 0;
    font-weight: 700;
    font-size: 14px;
    color: #1a1a1a;
    letter-spacing: 0.04em;
    min-width: 48px;
}
.search-name {
    font-size: 13px;
    color: #666;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.search-empty {
    padding: 12px 14px;
    color: #999;
    font-size: 13px;
    text-align: center;
}
.search-results mark {
    background: rgba(59, 130, 246, 0.18);
    color: inherit;
    border-radius: 2px;
    padding: 0 1px;
}
