:root {
    --nav-h: 60px;
    --safe: #2ecc71;
    --warn: #f1c40f;
    --danger: #e74c3c;
    --theme: var(--safe);
}

[data-status="safe"] { --theme: var(--safe); }
[data-status="warning"] { --theme: var(--warn); }
[data-status="danger"] { --theme: var(--danger); }

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { width: 100%; max-width: 100vw; height: 100%; overflow: hidden; font-family: "Noto Sans TC", sans-serif; background: #d9e9f0; }

#map-container { position: absolute; inset: var(--nav-h) 0 0; width: 100%; max-width: 100vw; overflow: hidden; background: #d9e9f0; }
#drone-map { width: 100%; max-width: 100%; height: 100%; }

#map-status,
#map-error {
    position: absolute;
    top: 50%; left: 50%;
    z-index: 1000;
    transform: translate(-50%, -50%);
    width: min(88%, 390px);
    padding: 16px 20px;
    color: #17313d;
    text-align: center;
    background: rgba(255,255,255,.96);
    border: 1px solid rgba(0,105,148,.18);
    border-radius: 16px;
    box-shadow: 0 12px 35px rgba(20,56,70,.18);
}
#map-status i { margin-right: 7px; color: #078fb3; }
#map-error { display: grid; gap: 7px; }
#map-error[hidden] { display: none; }
#map-error span { color: #617680; font-size: 13px; }
#map-error a { color: #087fa2; font-weight: 900; }

#hud {
    position: fixed;
    top: calc(var(--nav-h) + 15px);
    left: 50%;
    z-index: 9000;
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 90%;
    max-width: 470px;
    padding: 14px 20px;
    pointer-events: none;
    transform: translateX(-50%);
    background: rgba(255,255,255,.95);
    border-left: 8px solid var(--theme);
    border-radius: 16px;
    box-shadow: 0 8px 30px rgba(0,0,0,.15);
    backdrop-filter: blur(10px);
}
.hud-left { display: flex; min-width: 0; flex-direction: column; }
#location-name { overflow: hidden; color: #111; font-size: 17px; font-weight: 900; text-overflow: ellipsis; white-space: nowrap; }
#coord { color: #7f8d94; font-family: monospace; font-size: 11px; }
.hud-right { flex: 0 0 auto; margin-left: 12px; text-align: right; }
.hud-label { color: #68777d; font-size: 10px; font-weight: 800; }
#alt-limit { color: var(--theme); font-size: 27px; font-weight: 900; line-height: 1; }

#rules-overlay { position: fixed; inset: 0; z-index: 20000; display: flex; align-items: center; justify-content: center; overflow-y: auto; padding: 20px; background: rgba(21,42,52,.62); backdrop-filter: blur(3px); }
.rules-card { width: min(520px, 100%); padding: 22px 24px 20px; color: #263d46; background: #fff; border: 1px solid rgba(35,74,91,.12); border-radius: 12px; box-shadow: 0 18px 50px rgba(11,35,46,.28); }
.rules-card h2 { margin: 0 0 10px; color: #202f36; font-size: 18px; }
.source-warning-copy { margin: 0; color: #354d57; font-size: 14px; line-height: 1.75; }
.source-warning-copy a { color: #087fa2; font-weight: 800; overflow-wrap: anywhere; }
.data-notice { margin: 14px 0 0; padding: 10px 12px; background: #eef8fb; border: 1px solid #cfe8ef; border-radius: 9px; }
.data-notice strong { color: #176781; }
.data-notice p { margin: 2px 0 0; color: #566d76; font-size: 12px; line-height: 1.6; }
.flight-limits { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-top: 12px; }
.flight-limit { padding: 10px; border: 1px solid transparent; border-radius: 9px; }
.flight-limit span, .flight-limit strong { display: block; }
.flight-limit span { margin-bottom: 2px; font-size: 11px; font-weight: 800; }
.flight-limit strong { font-size: 13px; line-height: 1.35; }
.flight-limit.is-red { color: #a32929; background: #fff0f0; border-color: #f2c5c5; }
.flight-limit.is-yellow { color: #755900; background: #fff8d9; border-color: #eedc83; }
.flight-limit.is-green { color: #167340; background: #eaf9f0; border-color: #bde5cd; }
.rules-actions { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-top: 16px; }
.consent-check { display: flex; align-items: center; gap: 8px; margin: 0; color: #354d57; font-size: 13px; cursor: pointer; }
.consent-check input { flex: 0 0 auto; width: 17px; height: 17px; margin: 0; accent-color: #1683f3; }
.btn-agree { flex: 0 0 auto; min-width: 82px; padding: 10px 18px; color: #fff; font-weight: 900; cursor: pointer; background: #1683f3; border: 0; border-radius: 7px; }
.btn-agree:disabled { cursor: not-allowed; opacity: .42; }
#footer-info { position: fixed; bottom: 34px; left: 14px; z-index: 8000; max-width: min(560px, calc(100% - 28px)); pointer-events: none; }
.legend-tag { width: fit-content; margin-bottom: 5px; padding: 9px 13px; background: rgba(255,255,255,.96); border-radius: 10px; box-shadow: 0 4px 12px rgba(0,0,0,.12); font-size: 12px; font-weight: 800; }
.source-tag { padding: 5px 8px; color: #273d46; background: rgba(255,255,255,.84); border-radius: 7px; font-size: 10px; font-weight: 700; }

.leaflet-control-zoom { display: none !important; }
.leaflet-control-layers { overflow: hidden; margin-bottom: 104px !important; margin-left: 10px !important; background: rgba(255,255,255,.96) !important; border: 1px solid rgba(19,76,101,.12) !important; border-radius: 14px !important; box-shadow: 0 10px 28px rgba(15,55,75,.2) !important; backdrop-filter: blur(12px); }
.leaflet-control-layers-toggle { position: relative; width: 46px !important; height: 46px !important; background-image: none !important; }
.leaflet-control-layers-toggle::before { position: absolute; inset: 0; display: grid; place-items: center; color: #087fa2; font-family: "Font Awesome 6 Free"; font-size: 20px; font-weight: 900; content: "\f5fd"; }
.leaflet-control-layers-expanded { width: min(230px, calc(100vw - 24px)); max-width: calc(100vw - 24px); padding: 13px !important; }
.leaflet-control-layers-list { margin: 0 !important; }
.leaflet-control-layers-overlays { display: grid; gap: 8px; }
.leaflet-control-layers-overlays::before { display: block; margin: 0 2px 2px; color: #173d50; font-size: 12px; font-weight: 900; letter-spacing: .08em; content: "空域圖層"; }
.leaflet-control-layers label { margin: 0; padding: 9px 10px; background: #f3f8fa; border: 1px solid #dce9ee; border-radius: 10px; cursor: pointer; }
.leaflet-control-layers-overlays label > span { display: flex; align-items: center; gap: 9px; min-height: 24px; color: #314e5b; font-size: 12px; font-weight: 800; line-height: 1.35; white-space: nowrap; }
.leaflet-control-layers-selector { position: relative; flex: 0 0 auto; width: 38px !important; height: 22px !important; margin: 0 !important; appearance: none; cursor: pointer; background: #a9bbc3; border: 0; border-radius: 999px; outline: none; transition: background .2s ease; }
.leaflet-control-layers-selector::after { position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; background: #fff; border-radius: 50%; box-shadow: 0 2px 5px rgba(22,55,68,.28); content: ""; transition: transform .2s ease; }
.leaflet-control-layers-selector:checked::after { transform: translateX(16px); }
.leaflet-control-layers-overlays label:nth-of-type(1) .leaflet-control-layers-selector:checked { background: #ef5350; }
.leaflet-control-layers-overlays label:nth-of-type(2) .leaflet-control-layers-selector:checked { background: #e4b21f; }
.leaflet-control-layers label:has(.leaflet-control-layers-selector:focus-visible) { outline: 3px solid rgba(8,127,162,.22); outline-offset: 2px; }
.leaflet-popup-content-wrapper {
    overflow: hidden;
    padding: 0;
    color: #203844;
    background: #fff;
    border: 1px solid rgba(29,89,116,.16);
    border-radius: 16px;
    box-shadow: 0 14px 36px rgba(16,48,65,.24);
}
.leaflet-popup-content {
    width: min(370px, calc(100vw - 46px)) !important;
    max-height: min(66vh, 560px);
    margin: 0;
    overflow-x: hidden;
    overflow-y: auto;
    line-height: 1.65;
}
.leaflet-popup-tip { background: #fff; box-shadow: none; }
.leaflet-container a.leaflet-popup-close-button {
    top: 9px; right: 9px; z-index: 2;
    display: grid; place-items: center;
    width: 28px; height: 28px; padding: 0;
    color: #61747d; font-size: 20px; font-weight: 400;
    background: #eef4f6; border-radius: 50%;
}
.leaflet-container a.leaflet-popup-close-button:hover { color: #18323e; background: #dfecef; }
.airspace-popup { padding: 17px 18px 18px; }
.airspace-popup__type {
    display: inline-flex; align-items: center; min-height: 27px;
    margin: 0 36px 11px 0; padding: 4px 10px;
    color: #fff; background: linear-gradient(135deg,#ef5350,#c62828);
    border: 1px solid rgba(164,29,29,.14); border-radius: 999px;
    font-size: 11px; font-weight: 900; letter-spacing: .02em;
}
.airspace-popup__type.is-yellow { color: #3b3100; background: linear-gradient(135deg,#ffe46b,#f3bd24); }
.airspace-popup h3 { margin: 0 0 13px; color: #18323e; font-size: 18px; line-height: 1.45; }
.airspace-popup strong { display: inline-block; margin-right: 4px; color: #274957; }
.airspace-popup__details { overflow: hidden; margin-bottom: 10px; background: #f4f8f9; border: 1px solid #e3ecef; border-radius: 11px; }
.airspace-popup__row { display: grid; grid-template-columns: 72px minmax(0, 1fr); gap: 9px; padding: 8px 10px; border-top: 1px solid #e3ecef; font-size: 11.5px; line-height: 1.55; }
.airspace-popup__row:first-child { border-top: 0; }
.airspace-popup__row span { color: #72858d; font-weight: 800; }
.airspace-popup__row b { color: #294752; font-weight: 800; overflow-wrap: anywhere; }
.airspace-popup__section { padding: 10px 0; color: #536a74; border-top: 1px solid #e8eef1; font-size: 12px; line-height: 1.65; }
.airspace-popup__section > strong { display: block; margin-bottom: 5px; }
.airspace-popup__contact { padding: 9px 10px; color: #355461; background: #eef6f8; border-radius: 9px; overflow-wrap: anywhere; }
.airspace-popup__penalty { padding: 10px 0 9px; border-top: 1px solid #e8eef1; }
.penalty-list { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 7px; }
.penalty-chip { display: inline-flex; align-items: center; min-height: 27px; padding: 4px 9px; color: #a52828; background: #fff0f0; border: 1px solid #f2c4c4; border-radius: 999px; font-size: 11px; font-weight: 900; line-height: 1.4; }
.airspace-popup .airspace-popup__notice { margin: 2px 0 0; padding: 9px 10px; color: #6e7f86; background: #f2f7f8; border: 0; border-radius: 9px; font-size: 11px; line-height: 1.55; }
.gps-marker { width: 20px; height: 20px; background: #087fa2; border: 4px solid #fff; border-radius: 50%; box-shadow: 0 0 0 5px rgba(8,127,162,.26), 0 3px 10px rgba(0,0,0,.3); }
.pulse { animation: danger-blink 1s infinite; }
@keyframes danger-blink { 0%,100% { border-left-color: var(--danger); } 50% { border-left-color: #fff; } }

@media (max-width: 560px) {
    .flight-limits { grid-template-columns: 1fr; }
    #hud { top: calc(var(--nav-h) + 10px); width: calc(100% - 18px); min-height: 72px; padding: 15px 17px; }
    #location-name { font-size: 17px; }
    #alt-limit { font-size: 29px; }
    #footer-info { right: 10px; bottom: 30px; left: 10px; }
    .source-tag { max-width: 100%; line-height: 1.45; }
    .leaflet-control-layers { margin-bottom: 104px !important; margin-left: 8px !important; }
    .leaflet-control-layers-expanded { width: min(220px, calc(100vw - 16px)); max-width: calc(100vw - 16px); padding: 11px !important; }
}

@media (prefers-reduced-motion: reduce) {
    .pulse { animation: none; }
}
/* ===== 共用導覽列與地圖層級 ===== */
#navbar-placeholder { position: relative; z-index: 30000; height: var(--nav-h); background: #006994; }
.main-navbar { z-index: 30000 !important; }
.nav-menu { z-index: 30020 !important; }
.menu-overlay { z-index: 30010 !important; }
#sharedNavbarToggle { position: relative; z-index: 2; pointer-events: auto !important; touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
#rules-overlay { z-index: 50000; }





