.settings-toggle-btn {
    position: absolute;
    bottom: 335px;
    right: 15px;
    z-index: 2001;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    color: #0284c7;
    border: 1px solid rgba(255, 255, 255, 0.6);
    width: 42px;
    height: 42px;
    border-radius: 50%;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    transition: all 0.2s ease;
}

.settings-toggle-btn:hover {
    background: rgba(255, 255, 255, 0.95);
    transform: scale(1.05);
}

.settings-toggle-btn.active {
    background: #0284c7;
    color: #ffffff;
}

.settings-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 100001;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.settings-overlay.show {
    opacity: 1;
    visibility: visible;
}

.settings-modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.9);
    background: rgba(255, 255, 255, 0.75);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    width: 90%;
    max-width: 350px;
    border-radius: 20px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    z-index: 100002;
    font-family: 'Sarabun', sans-serif;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-sizing: border-box;
    border: 1px solid rgba(255, 255, 255, 0.8);
    overflow: hidden;
}

.settings-modal.show {
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
    visibility: visible;
}

.settings-modal-header {
    padding: 12px 16px;
    background: linear-gradient(135deg, rgba(2, 132, 199, 0.9), rgba(3, 105, 161, 0.9));
    backdrop-filter: blur(10px);
    color: white;
    font-size: 15px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: space-between;
    letter-spacing: 0.3px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}

.settings-close-btn {
    background: rgba(255, 255, 255, 0.15);
    border: none;
    color: white;
    font-size: 16px;
    cursor: pointer;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background 0.2s;
}

.settings-close-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

.settings-modal-content {
    padding: 14px;
    font-size: 13px;
    max-height: calc(85dvh - 54px);
    box-sizing: border-box;
    overflow-y: auto;
    background: rgba(248, 250, 252, 0.5);
}

.settings-section-title {
    font-size: 11.5px;
    font-weight: 700;
    color: #475569;
    text-transform: uppercase;
    margin-bottom: 8px;
    letter-spacing: 0.8px;
    display: flex;
    align-items: center;
}

.settings-section-title::after {
    content: "";
    flex: 1;
    height: 1px;
    background: rgba(226, 232, 240, 0.8);
    margin-left: 10px;
}

.settings-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 9px 12px;
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border-radius: 12px;
    margin-bottom: 6px;
    border: 1px solid rgba(255, 255, 255, 0.9);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.02);
    transition: all 0.2s ease;
}

.settings-item:hover {
    background: rgba(255, 255, 255, 0.95);
    border-color: rgba(2, 132, 199, 0.3);
    box-shadow: 0 6px 12px -2px rgba(0, 0, 0, 0.05);
}

.settings-lightning-period {
    flex-wrap: wrap;
    gap: 6px;
}

.settings-select {
    width: 100%;
    padding: 7px 10px;
    min-height: 36px;
    box-sizing: border-box;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    background: #fff;
    color: #0f172a;
    font: inherit;
}

.settings-select:focus-visible {
    outline: 2px solid #0284c7;
    outline-offset: 2px;
}

.settings-item:last-child {
    margin-bottom: 0;
}

.settings-item.notification-disabled {
    opacity: 0.5;
    box-shadow: none;
}

.settings-item.notification-disabled .slider {
    cursor: not-allowed;
}

.settings-label {
    display: flex;
    flex-direction: column;
    padding-right: 10px;
}

.settings-name {
    font-weight: 600;
    color: #0f172a;
    font-size: 13.5px;
}

.settings-desc {
    font-size: 11.5px;
    color: #64748b;
    margin-top: 2px;
}

.unit-switch-container {
    display: flex;
    align-items: center;
}

.unit-label {
    font-size: 12px;
    font-weight: bold;
    color: #94a3b8;
    transition: color 0.2s;
}

.unit-label.active {
    color: #0284c7;
}

.switch {
    position: relative;
    display: inline-block;
    width: 40px;
    height: 22px;
    flex-shrink: 0;
}

.switch input { 
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: rgba(203, 213, 225, 0.8);
    transition: .3s;
    border-radius: 22px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .3s;
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

input:checked + .slider {
    background-color: #0284c7;
}

input:checked + .slider:before {
    transform: translateX(18px);
}

#websiteNotifications {
    position: fixed;
    top: clamp(72px, 13vh, 140px);
    left: 50%;
    transform: translateX(-50%);
    width: min(440px, calc(100vw - 32px));
    z-index: 100003;
    display: grid;
    gap: 10px;
    pointer-events: none;
}
.website-notification {
    position: relative;
    padding: 16px 44px 16px 18px;
    border: 1px solid rgba(255,255,255,.7);
    border-left: 4px solid #0284c7;
    border-radius: 16px;
    background: rgba(245, 251, 255, .86);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    color: #102b40;
    font-family: 'Sarabun', sans-serif;
    font-size: 13px;
    line-height: 1.5;
    box-shadow: 0 12px 38px rgba(15,23,42,.25);
    pointer-events: auto;
    animation: notification-enter .35s ease both;
}
.website-notification strong { font-size: 15px; }
.website-notification p { margin: 6px 0 0; }
.website-notification a { display: block; color: inherit; text-decoration: none; }
.website-notification.is-critical { border-left-color: #dc2626; background: rgba(255,245,245,.9); }
.website-notification.is-leaving { animation: notification-exit .3s ease both; }
.notification-critical-icon { display: inline-block; animation: notification-pulse 1s ease-in-out infinite; }
.website-notification button {
    position: absolute;
    top: 7px;
    right: 7px;
    width: 32px;
    height: 32px;
    border: 0;
    border-radius: 50%;
    background: rgba(255,255,255,.65);
    color: #475569;
    font-size: 22px;
    cursor: pointer;
}
@keyframes notification-enter { from { opacity: 0; transform: translateY(-15px) scale(.96); } to { opacity: 1; transform: translateY(0) scale(1); } }
@keyframes notification-exit { to { opacity: 0; transform: translateY(-10px) scale(.97); } }
@keyframes notification-pulse { 50% { opacity: .35; transform: scale(1.12); } }
@media (prefers-reduced-motion: reduce) {
    .website-notification, .notification-critical-icon { animation-duration: .01ms; animation-iteration-count: 1; }
}

#notificationStatus { color:#0369a1; overflow-wrap:anywhere; text-align:center; }
#notificationStatus.notification-error { color:#dc2626; }
#notificationStatus.notification-info { color:#0369a1; }

.notification-actions { margin: 10px 0; }
.notification-actions button { border: 1px solid #0284c7; background: #f0f9ff; color: #0369a1; border-radius: 8px; padding: 8px 12px; font: inherit; cursor: pointer; }
.notification-actions button:disabled { opacity: 0.6; cursor: wait; }

.theme-control { position: absolute; top: 15px; right: 115px; z-index: 1002; }
.theme-control button { width: 42px; height: 42px; border: 0; border-radius: 50%; background: #fff; color: #0284c7; box-shadow: 0 4px 10px #0004; cursor: pointer; font-size: 16px; }
.theme-options { position: absolute; top: 49px; right: 0; display: flex; gap: 5px; padding: 6px; border-radius: 25px; background: #fff; box-shadow: 0 4px 16px #0004; }
.theme-options[hidden] { display: none; }
.theme-options button { width: 36px; height: 36px; box-shadow: none; }
.theme-options button[aria-pressed="true"] { background: #dbeafe; color: #0369a1; }
html[data-theme="dark"] :is(.sidebar, .sidebar-content, .sidebar-footer) { background: #17283a; color: #e2e8f0; }
html[data-theme="dark"] :is(.sidebar-section-title, .sidebar-footer-title) { color: #b9cadd; }
html[data-theme="dark"] .region-btn { background: #293d51; color: #e8f2fa; }
html[data-theme="dark"] .region-btn:is(:hover, .active) { background: #0369a1; color: #fff; }
html[data-theme="dark"] :is(.time-control, #measureBar, .legend-box, .settings-modal-content) { background: #1c3043; color: #e2e8f0; }
html[data-theme="dark"] :is(.time-date, .time-scope, .legend-title, .legend-text, .legend-text b) { color: #d4e2ee; }
html[data-theme="dark"] .settings-modal { background: #1c3043; border-color: #60788c; }
html[data-theme="dark"] .settings-item { background: #2a4055; border-color: #49647b; }
html[data-theme="dark"] :is(.settings-name, .settings-section-title) { color: #f1f5f9; }
html[data-theme="dark"] .settings-desc { color: #c1d4e5; }
html[data-theme="dark"] #notificationStatus.notification-error { color: #ff9a9a; }
html[data-theme="dark"] #notificationStatus.notification-info { color: #7dd3fc; }
html[data-theme="dark"] .settings-select { background: #162a3d; color: #f1f5f9; border-color: #61798d; }
html[data-theme="dark"] :is(.theme-control button, .theme-options, #reloadData, .menu-btn) { background: #263b4e; color: #b5e3ff; }
html[data-theme="dark"] .theme-options button[aria-pressed="true"] { background: #075985; color: #fff; }

html[data-theme="dark"] body :is(.locate-btn, #cloudsToggleBtn, #weatherToggleBtn, #stormToggleBtn, #lightningToggleBtn, #measureBtn, #settingsToggleBtn, #legendToggleBtn) {
    background: #263b4e;
    color: #b5d1e4;
}
html[data-theme="dark"] body :is(#cloudsToggleBtn.active, #weatherToggleBtn.active, #measureBtn[aria-pressed="true"], #settingsToggleBtn.active, #legendToggleBtn.active) {
    color: #7dd3fc;
    outline-color: #38bdf8;
}
html[data-theme="dark"] body #stormToggleBtn.active { color: #ff8b8b; outline-color: #f87171; }
html[data-theme="dark"] #lightningToggleBtn svg[fill="#64748b"] { fill: #b5d1e4; }
html[data-theme="dark"] #lightningToggleBtn svg[fill="#d97706"] { fill: #fbbf24; }
html[data-theme="dark"] .leaflet-control-zoom a { background: #263b4e; color: #e2e8f0; border-color: #49647b; }
html[data-theme="dark"] .leaflet-control-zoom a:hover { background: #35516a; }

html[data-theme="dark"] .base-map-tiles { filter: brightness(.78); }
