/* ==================== CSS Variables ==================== */
:root {
    --bg-primary: #1a1a2e;
    --bg-secondary: #16213e;
    --bg-card: #0f3460;
    --text-primary: #eaeaea;
    --text-secondary: #a0a0a0;
    --accent: #6D9886;
    --accent-hover: #5a8070;
    --border: #2a2a4a;
    --input-bg: #1e2a4a;
    --shadow: rgba(0, 0, 0, 0.3);
    --glass: rgba(15, 52, 96, 0.6);
    --glass-border: rgba(109, 152, 134, 0.3);
}

[data-theme="light"] {
    --bg-primary: #f0f2f5;
    --bg-secondary: #ffffff;
    --bg-card: #ffffff;
    --text-primary: #1a1a2e;
    --text-secondary: #666666;
    --accent: #6D9886;
    --accent-hover: #5a8070;
    --border: #e0e0e0;
    --input-bg: #f5f5f5;
    --shadow: rgba(0, 0, 0, 0.1);
    --glass: rgba(255, 255, 255, 0.8);
    --glass-border: rgba(109, 152, 134, 0.4);
}

/* ==================== Reset & Base ==================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Rubik', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    transition: background 0.3s ease, color 0.3s ease;
    overflow-x: hidden;
}

main {
    position: relative;
    z-index: 1;
}

/* ==================== Header ==================== */
.header {
    background: var(--bg-secondary);
    border-bottom: 2px solid var(--accent);
    width: 100%;
    box-sizing: border-box;
    position: sticky;
    top: 0;
    z-index: 1000;
}

.header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px 10px;
}

.header h1 {
    font-size: 1.6em;
    color: var(--text-primary);
    margin: 0;
}

.header p {
    font-size: 0.9em;
    color: var(--text-secondary);
    margin: 2px 0 0;
}

/* ==================== Hero ==================== */
.hero {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 40px 20px 30px;
    transition: opacity 0.3s ease, max-height 0.4s ease, padding 0.3s ease, margin 0.3s ease;
    max-height: 500px;
    overflow: hidden;
    opacity: 1;
}

.header.compact .hero {
    opacity: 0;
    max-height: 0;
    padding: 0 20px;
    margin: 0;
    pointer-events: none;
}

.hero-logo {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    margin-bottom: 16px;
    border: 3px solid var(--accent);
    box-shadow: 0 4px 20px var(--shadow);
}

.hero-title {
    font-size: 1.8em;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.hero-desc {
    font-size: 0.95em;
    color: var(--text-secondary);
    max-width: 520px;
    line-height: 1.6;
    margin-bottom: 28px;
}

.hero-tools {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    justify-content: center;
}

.hero-tool-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 18px 24px;
    background: var(--glass);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    cursor: pointer;
    transition: transform 0.2s ease, border-color 0.2s ease, background 0.2s ease;
    min-width: 120px;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.hero-tool-card:hover {
    transform: translateY(-3px);
    border-color: var(--accent);
    background: var(--bg-card);
}

.hero-tool-icon {
    font-size: 1.8em;
    color: var(--accent);
}

.hero-tool-card span {
    font-size: 0.9em;
    font-weight: 600;
    color: var(--text-primary);
}

/* ==================== Theme Toggle ==================== */
.theme-toggle {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2em;
    color: var(--text-primary);
    transition: background 0.3s ease, transform 0.2s ease;
    flex-shrink: 0;
}

.theme-toggle:hover {
    transform: scale(1.1);
    background: var(--accent);
    color: white;
}

.theme-icon-dark {
    display: none;
}

[data-theme="light"] .theme-icon-light {
    display: none;
}

[data-theme="light"] .theme-icon-dark {
    display: inline;
}

/* ==================== Tab Bar ==================== */
.tab-bar {
    display: flex;
    gap: 0;
    padding: 0 20px;
}

.tab-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 10px 20px;
    font-family: 'Rubik', sans-serif;
    font-size: 0.95em;
    cursor: pointer;
    border-bottom: 3px solid transparent;
    transition: color 0.2s ease, border-color 0.2s ease;
}

.tab-btn:hover {
    color: var(--text-primary);
}

.tab-btn.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
    font-weight: 700;
}

/* ==================== Tab Panels ==================== */
.tab-panel {
    display: none;
    width: 100%;
}

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

/* ==================== QR Converter (existing) ==================== */
.container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: calc(100vh - 120px);
    padding: 20px;
}

.frame {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 30px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 4px 20px var(--shadow);
    width: 100%;
    max-width: 420px;
    min-height: 420px;
}

.frame img {
    margin-top: 40px;
    margin-bottom: 20px;
    cursor: pointer;
    max-width: 200px;
}

.textbox {
    padding: 12px 15px;
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--input-bg);
    color: var(--text-primary);
    font-family: 'Rubik', sans-serif;
    font-size: 0.95em;
    outline: none;
    transition: border-color 0.2s ease;
}

.textbox:focus {
    border-color: var(--accent);
}

.textbox::placeholder {
    color: var(--text-secondary);
}

.submit-btn {
    background: var(--accent);
    color: white;
    padding: 12px 28px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    margin-top: 20px;
    font-family: 'Rubik', sans-serif;
    font-size: 1em;
    font-weight: 700;
    transition: background 0.2s ease, transform 0.1s ease;
}

.submit-btn:hover {
    background: var(--accent-hover);
}

.submit-btn:active {
    transform: scale(0.98);
}

/* ==================== Weather Container ==================== */
.weather-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* ==================== Desktop Two-Column Grid ==================== */
.weather-grid {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

@media (min-width: 901px) {
    .weather-grid {
        display: grid;
        grid-template-columns: 420px 1fr;
        gap: 28px;
        align-items: start;
    }

    .weather-col-left {
        position: sticky;
        top: 100px;
        display: flex;
        flex-direction: column;
        gap: 4px;
    }

    .weather-col-left #weather-map {
        height: 420px;
    }

    .weather-col-right {
        display: flex;
        flex-direction: column;
        gap: 20px;
        min-width: 0;
    }

    .weather-col-right .section-label {
        margin-top: 4px;
    }

    .weather-col-right #current-weather {
        order: -1;
    }

    .weather-card {
        margin-bottom: 0;
    }
}

@media (min-width: 901px) {
    .weather-container {
        max-width: 1100px;
    }
}

/* ==================== Search ==================== */
.search-container {
    margin-bottom: 16px;
}

.search-box {
    position: relative;
    display: flex;
    align-items: center;
    width: 100%;
}

.search-icon {
    position: absolute;
    left: 14px;
    color: var(--text-secondary);
    font-size: 1.1em;
    pointer-events: none;
}

.search-input {
    width: 100%;
    padding: 12px 15px 12px 42px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--input-bg);
    color: var(--text-primary);
    font-family: 'Rubik', sans-serif;
    font-size: 0.95em;
    outline: none;
    transition: border-color 0.2s ease;
}

.search-input:focus {
    border-color: var(--accent);
}

.search-input::placeholder {
    color: var(--text-secondary);
}

.search-results {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    margin-top: 4px;
    max-height: 240px;
    overflow-y: auto;
    z-index: 50;
    box-shadow: 0 8px 24px var(--shadow);
}

.search-result {
    padding: 10px 15px;
    cursor: pointer;
    color: var(--text-primary);
    font-size: 0.9em;
    border-bottom: 1px solid var(--border);
    transition: background 0.15s ease;
}

.search-result:last-child {
    border-bottom: none;
}

.search-result:hover {
    background: var(--accent);
    color: white;
}

/* ==================== City Selector ==================== */
/* ==================== Map ==================== */
.map-wrapper {
    margin-bottom: 8px;
    border-radius: 14px;
    overflow: hidden;
    border: 1px solid var(--border);
    box-shadow: 0 4px 16px var(--shadow);
    position: relative;
    z-index: 1;
    min-width: 0;
}

#weather-map {
    height: 320px;
    width: 100%;
    background: var(--bg-card);
}

.leaflet-container {
    z-index: 1;
}

.map-legend {
    position: absolute;
    bottom: 12px;
    right: 12px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px 10px;
    z-index: 500;
    font-size: 0.65em;
    box-shadow: 0 2px 8px var(--shadow);
    max-width: 130px;
    line-height: 1.6;
}

.map-legend-title {
    font-weight: 700;
    font-size: 0.85em;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.map-legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 2px 0;
    color: var(--text-primary);
}

.map-legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.map-legend-divider {
    border: none;
    border-top: 1px solid var(--border);
    margin: 4px 0;
}

.map-popup {
    font-family: 'Rubik', sans-serif;
    text-align: center;
    min-width: 140px;
}

.map-popup-city {
    font-weight: 700;
    font-size: 0.95em;
    margin-bottom: 4px;
}

.map-popup-temp {
    font-size: 1.5em;
    font-weight: 700;
    color: #6D9886;
    line-height: 1.2;
}

.map-popup-desc {
    font-size: 0.8em;
    color: #666;
    margin-top: 2px;
}

.leaflet-popup-content-wrapper {
    border-radius: 10px !important;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15) !important;
}

.leaflet-popup-tip {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15) !important;
}

.custom-marker {
    background: var(--accent);
    border: 2px solid white;
    border-radius: 50%;
    width: 14px !important;
    height: 14px !important;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

.rainfall-icon {
    background: none !important;
    border: none !important;
}

.rainfall-marker {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 14px;
    box-shadow: 0 0 8px rgba(0, 0, 0, 0.3);
    opacity: 0.85;
}

/* ==================== Weather Card ==================== */
.weather-card {
    background: var(--glass);
    border: 1px solid var(--glass-border);
    border-radius: 14px;
    padding: 24px;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    box-shadow: 0 4px 16px var(--shadow);
    margin-bottom: 24px;
    min-width: 0;
    box-sizing: border-box;
}

.weather-card-header {
    margin-bottom: 16px;
}

.weather-location {
    font-size: 1.3em;
    font-weight: 700;
    color: var(--text-primary);
}

.weather-desc {
    font-size: 0.9em;
    color: var(--text-secondary);
    margin-top: 2px;
}

.weather-card-main {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 20px;
}

.weather-icon-large {
    font-size: 3.5em;
    color: var(--accent);
    line-height: 1;
}

.weather-temp {
    font-size: 3em;
    font-weight: 700;
    line-height: 1;
}

.weather-card-details {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    border-top: 1px solid var(--border);
    padding-top: 16px;
}

.weather-detail {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.weather-detail-label {
    font-size: 0.75em;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.weather-detail-value {
    font-size: 0.95em;
    font-weight: 700;
    color: var(--text-primary);
}

/* ==================== Section Label ==================== */
.section-label {
    font-size: 0.85em;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 10px;
}

/* ==================== Hourly Forecast ==================== */
.hourly-scroll {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 12px;
    margin-bottom: 24px;
    min-width: 0;
    scrollbar-width: thin;
    scrollbar-color: var(--accent) transparent;
}

.hourly-scroll::-webkit-scrollbar {
    height: 6px;
}

.hourly-scroll::-webkit-scrollbar-track {
    background: transparent;
}

.hourly-scroll::-webkit-scrollbar-thumb {
    background: var(--accent);
    border-radius: 3px;
}

.hourly-card {
    flex: 0 0 72px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 12px 8px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    text-align: center;
    transition: border-color 0.2s ease;
}

.hourly-card:first-child {
    border-color: var(--accent);
    background: var(--glass);
}

.hourly-time {
    font-size: 0.75em;
    font-weight: 700;
    color: var(--text-secondary);
}

.hourly-card:first-child .hourly-time {
    color: var(--accent);
}

.hourly-icon {
    font-size: 1.4em;
    color: var(--accent);
}

.hourly-temp {
    font-size: 0.95em;
    font-weight: 700;
    color: var(--text-primary);
}

.hourly-rain {
    font-size: 0.7em;
    color: var(--text-secondary);
}

.hourly-rain .wi-raindrop {
    font-size: 0.9em;
    color: #5b9bd5;
}

.weather-loading,
.weather-error {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-secondary);
    font-size: 0.95em;
}

.section-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 24px 16px;
    color: var(--text-secondary);
    font-size: 0.85em;
}

.section-loading-spinner {
    width: 18px;
    height: 18px;
    border: 2px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    flex-shrink: 0;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.weather-error {
    color: #e74c3c;
}

.section-error {
    text-align: center;
    padding: 20px 16px;
    color: #e74c3c;
    font-size: 0.85em;
}

.section-empty {
    text-align: center;
    padding: 20px 16px;
    color: var(--text-secondary);
    font-size: 0.85em;
}

/* ==================== PAGASA Alert Banner ==================== */
.alert-banner {
    background: linear-gradient(135deg, #e74c3c, #c0392b);
    color: white;
    padding: 12px 20px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.9em;
    font-weight: 700;
    animation: alert-pulse 2s ease-in-out infinite;
}

.alert-banner-icon {
    font-size: 1.3em;
}

.alert-banner-close {
    margin-left: auto;
    background: rgba(255,255,255,0.2);
    border: none;
    color: white;
    font-size: 1.2em;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s ease;
    flex-shrink: 0;
}

.alert-banner-close:hover {
    background: rgba(255,255,255,0.35);
}

@keyframes alert-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.85; }
}

/* ==================== PAGASA Warnings List ==================== */
.alert-filters {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}

.alert-filter-input {
    flex: 1;
    padding: 8px 12px;
    background: var(--input-bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-primary);
    font-family: 'Rubik', sans-serif;
    font-size: 0.85em;
    outline: none;
    transition: border-color 0.2s ease;
}

.alert-filter-input:focus {
    border-color: var(--accent);
}

.alert-filter-input::placeholder {
    color: var(--text-secondary);
}

.alert-filter-select {
    padding: 8px 12px;
    background: var(--input-bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-primary);
    font-family: 'Rubik', sans-serif;
    font-size: 0.85em;
    outline: none;
    cursor: pointer;
    min-width: 120px;
}

.alert-filter-select:focus {
    border-color: var(--accent);
}

.alerts-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-bottom: 30px;
}

.alert-region-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.alert-region-label {
    font-size: 0.75em;
    font-weight: 700;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 4px 0;
    border-bottom: 1px solid var(--border);
}

.alert-item {
    display: block;
    padding: 14px 16px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-left: 4px solid var(--accent);
    border-radius: 10px;
    text-decoration: none;
    color: var(--text-primary);
    transition: border-color 0.2s ease, transform 0.1s ease;
    cursor: pointer;
}

.alert-item:hover {
    border-color: var(--accent);
    transform: translateY(-1px);
}

.alert-severity-extreme {
    border-left-color: #e74c3c;
}

.alert-severity-severe {
    border-left-color: #e67e22;
}

.alert-severity-high {
    border-left-color: #f39c12;
}

.alert-severity-moderate {
    border-left-color: #3498db;
}

.alert-severity-low {
    border-left-color: #2ecc71;
}

.alert-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
}

.alert-badges {
    display: flex;
    gap: 6px;
    align-items: center;
}

.alert-signal-badge {
    font-size: 0.65em;
    font-weight: 800;
    padding: 2px 8px;
    border-radius: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    background: rgba(231, 76, 60, 0.2);
    color: #e74c3c;
}

.alert-signal-badge.signal-1 {
    background: rgba(46, 204, 113, 0.2);
    color: #27ae60;
}

.alert-signal-badge.signal-2 {
    background: rgba(243, 156, 18, 0.2);
    color: #f39c12;
}

.alert-signal-badge.signal-3 {
    background: rgba(230, 126, 34, 0.2);
    color: #e67e22;
}

.alert-signal-badge.signal-4 {
    background: rgba(192, 57, 43, 0.2);
    color: #c0392b;
}

.alert-signal-badge.signal-5 {
    background: rgba(142, 68, 173, 0.2);
    color: #8e44ad;
}

.alert-rainfall-badge {
    font-size: 0.65em;
    font-weight: 800;
    padding: 2px 8px;
    border-radius: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.alert-rainfall-badge.rainfall-yellow {
    background: rgba(241, 196, 15, 0.2);
    color: #f1c40f;
}

.alert-rainfall-badge.rainfall-orange {
    background: rgba(230, 126, 34, 0.2);
    color: #e67e22;
}

.alert-rainfall-badge.rainfall-red {
    background: rgba(231, 76, 60, 0.2);
    color: #e74c3c;
}

.alert-type {
    font-size: 0.75em;
    font-weight: 700;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.alert-severity {
    font-size: 0.7em;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 10px;
    text-transform: uppercase;
}

.alert-severity-extreme {
    background: rgba(231, 76, 60, 0.15);
    color: #e74c3c;
}

.alert-severity-severe {
    background: rgba(230, 126, 34, 0.15);
    color: #e67e22;
}

.alert-severity-high {
    background: rgba(243, 156, 18, 0.15);
    color: #f39c12;
}

.alert-severity-moderate {
    background: rgba(52, 152, 219, 0.15);
    color: #3498db;
}

.alert-severity-low {
    background: rgba(46, 204, 113, 0.15);
    color: #2ecc71;
}

.alert-title {
    font-size: 0.9em;
    font-weight: 700;
    line-height: 1.4;
    margin-bottom: 4px;
}

.alert-meta {
    font-size: 0.75em;
    color: var(--text-secondary);
}

.alerts-empty {
    text-align: center;
    padding: 20px;
    color: var(--text-secondary);
    font-size: 0.9em;
}

/* ==================== Responsive ==================== */
@media (max-width: 900px) {
    .weather-container {
        padding: 15px;
    }

    .weather-grid {
        display: flex;
        flex-direction: column;
        gap: 20px;
    }

    .weather-col-left {
        position: static;
    }

    .weather-card {
        padding: 18px;
        margin-bottom: 0;
    }

    .weather-card-main {
        gap: 12px;
    }

    .weather-icon-large {
        font-size: 2.8em;
    }

    .weather-temp {
        font-size: 2.4em;
    }

    #weather-map {
        height: 280px;
    }

    .map-legend {
        font-size: 0.6em;
        padding: 6px 8px;
    }

    .map-wrapper {
        margin-bottom: 8px;
    }
}

@media (max-width: 600px) {
    .header-top {
        padding: 12px 15px 8px;
    }

    .header h1 {
        font-size: 1.3em;
    }

    .header p {
        font-size: 0.8em;
    }

    .tab-btn {
        padding: 8px 14px;
        font-size: 0.85em;
    }

    .hero {
        padding: 28px 15px 20px;
    }

    .hero-logo {
        width: 80px;
        height: 80px;
    }

    .hero-title {
        font-size: 1.4em;
    }

    .hero-desc {
        font-size: 0.85em;
    }

    .hero-tools {
        gap: 10px;
    }

    .hero-tool-card {
        padding: 14px 18px;
        min-width: 100px;
    }

    .hero-tool-icon {
        font-size: 1.5em;
    }

    .hero-tool-card span {
        font-size: 0.8em;
    }

    .weather-container {
        padding: 12px;
    }

    .weather-card {
        padding: 16px;
    }

    .weather-card-main {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .weather-icon-large {
        font-size: 2.5em;
    }

    .weather-temp {
        font-size: 2.2em;
    }

    .weather-card-details {
        grid-template-columns: repeat(3, 1fr);
        gap: 8px;
    }

    .weather-detail-label {
        font-size: 0.7em;
    }

    .weather-detail-value {
        font-size: 0.85em;
    }

    .hourly-card {
        flex: 0 0 64px;
        padding: 10px 6px;
    }

    .container {
        min-height: calc(100vh - 130px);
        padding: 15px;
    }

    .frame {
        min-height: 380px;
        padding: 20px;
    }

    #weather-map {
        height: 220px;
    }

    .map-legend {
        font-size: 0.6em;
        padding: 5px 7px;
        bottom: 8px;
        right: 8px;
        max-width: 120px;
    }

    .alert-banner {
        font-size: 0.8em;
        padding: 10px 14px;
    }

    .alert-region-label {
        font-size: 0.7em;
    }

    .alert-item {
        padding: 10px 12px;
    }

    .alert-title {
        font-size: 0.82em;
    }

    .alert-filters {
        flex-direction: column;
        gap: 6px;
    }

    .alert-filter-select {
        min-width: 100%;
    }

    .section-loading {
        padding: 16px 12px;
        font-size: 0.8em;
    }
}

@media (max-width: 380px) {
    .weather-card-details {
        grid-template-columns: 1fr;
        gap: 6px;
    }

    .weather-detail {
        flex-direction: row;
        justify-content: space-between;
    }

    #weather-map {
        height: 200px;
    }

    .hourly-card {
        flex: 0 0 58px;
        padding: 8px 4px;
    }

    .hourly-temp {
        font-size: 0.9em;
    }
}

/* ==================== CAP Alert Detail (Inline) ==================== */
.cap-detail {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 10px;
    margin-top: 8px;
    overflow: hidden;
    animation: capSlideIn 0.2s ease;
}

@keyframes capSlideIn {
    from { opacity: 0; max-height: 0; }
    to { opacity: 1; max-height: 2000px; }
}

.cap-detail-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-card);
}

.cap-detail-title {
    font-size: 0.85em;
    font-weight: 700;
    color: var(--text-primary);
    flex: 1;
    margin-right: 10px;
}

.cap-detail-close {
    background: none;
    border: none;
    font-size: 1.2em;
    color: var(--text-secondary);
    cursor: pointer;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    flex-shrink: 0;
    transition: background 0.15s ease;
}

.cap-detail-close:hover {
    background: rgba(231, 76, 60, 0.15);
    color: #e74c3c;
}

.cap-detail-body {
    padding: 16px;
    overflow-y: auto;
}

.cap-loading {
    text-align: center;
    color: var(--text-secondary);
    padding: 30px 0;
}

.cap-meta-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-bottom: 16px;
}

.cap-meta-item {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px;
    text-align: center;
}

.cap-meta-item-label {
    font-size: 0.65em;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    margin-bottom: 4px;
}

.cap-meta-item-value {
    font-size: 0.85em;
    font-weight: 700;
}

.cap-meta-item-value.urgency-immediate { color: #e74c3c; }
.cap-meta-item-value.urgency-expected { color: #e67e22; }
.cap-meta-item-value.severity-extreme { color: #e74c3c; }
.cap-meta-item-value.severity-severe { color: #e67e22; }
.cap-meta-item-value.severity-moderate { color: #f1c40f; }
.cap-meta-item-value.severity-minor { color: #2ecc71; }
.cap-meta-item-value.certainty-observed { color: #e74c3c; }
.cap-meta-item-value.certainty-likely { color: #e67e22; }
.cap-meta-item-value.certainty-possible { color: #3498db; }

.cap-field {
    margin-bottom: 14px;
}

.cap-field-label {
    font-size: 0.7em;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.cap-field-value {
    font-size: 0.9em;
    color: var(--text-primary);
    line-height: 1.5;
}

.cap-area-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 14px;
}

.cap-area-tag {
    font-size: 0.75em;
    font-weight: 600;
    padding: 3px 10px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 20px;
    color: var(--text-primary);
}

.cap-instruction-box {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-left: 4px solid var(--accent);
    border-radius: 8px;
    padding: 14px;
    margin-bottom: 14px;
}

.cap-section-divider {
    border: none;
    border-top: 1px solid var(--border);
    margin: 14px 0;
}

.cap-raw-toggle {
    display: inline-block;
    font-size: 0.75em;
    color: var(--accent);
    cursor: pointer;
    border: none;
    background: none;
    padding: 0;
    margin-top: 6px;
    text-decoration: underline;
}

.cap-raw-toggle:hover {
    color: var(--accent-hover);
}

.cap-raw-xml {
    display: none;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px;
    margin-top: 8px;
    font-family: monospace;
    font-size: 0.75em;
    white-space: pre-wrap;
    word-break: break-all;
    max-height: 300px;
    overflow-y: auto;
    color: var(--text-secondary);
}

.cap-raw-xml.visible {
    display: block;
}

@media (max-width: 600px) {
    .cap-meta-grid {
        grid-template-columns: 1fr;
    }

    .cap-meta-item-value {
        font-size: 0.8em;
    }

    .cap-field-value {
        font-size: 0.85em;
    }

    .cap-area-tag {
        font-size: 0.7em;
    }
}

/* ==================== Media Converter ==================== */
.converter-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: calc(100vh - 120px);
    padding: 20px;
}

.converter-card {
    background: var(--glass);
    border: 1px solid var(--glass-border);
    border-radius: 14px;
    padding: 30px;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    box-shadow: 0 4px 20px var(--shadow);
    width: 100%;
    max-width: 460px;
}

.converter-title {
    font-size: 1.4em;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 6px;
    text-align: center;
}

.converter-subtitle {
    font-size: 0.9em;
    color: var(--text-secondary);
    margin-bottom: 24px;
    text-align: center;
}

/* Input Sections */
.converter-file-drop {
    border: 2px dashed var(--border);
    border-radius: 12px;
    padding: 40px 20px;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.2s ease, background 0.2s ease;
}

.converter-file-drop:hover,
.converter-file-drop.dragover {
    border-color: var(--accent);
    background: rgba(109, 152, 134, 0.1);
}

.converter-file-icon {
    font-size: 2.5em;
    color: var(--accent);
    margin-bottom: 12px;
    display: block;
}

.converter-file-text {
    font-size: 0.95em;
    color: var(--text-primary);
    margin-bottom: 6px;
}

.converter-file-hint {
    font-size: 0.8em;
    color: var(--text-secondary);
}

.converter-file-info {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: var(--input-bg);
    border: 1px solid var(--border);
    border-radius: 10px;
}

.converter-file-details {
    display: flex;
    flex-direction: column;
    gap: 2px;
    overflow: hidden;
}

.converter-file-details span:first-child {
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.converter-file-details span:last-child {
    font-size: 0.8em;
    color: var(--text-secondary);
}

.converter-file-remove {
    background: none;
    border: none;
    font-size: 1.4em;
    color: var(--text-secondary);
    cursor: pointer;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    transition: background 0.15s ease, color 0.15s ease;
    flex-shrink: 0;
}

.converter-file-remove:hover {
    background: rgba(231, 76, 60, 0.15);
    color: #e74c3c;
}

/* Format Selection */
.converter-format-section {
    margin-bottom: 24px;
}

.converter-format-group {
    margin-bottom: 12px;
}

.converter-label {
    display: block;
    font-size: 0.8em;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 10px;
}

.converter-format-tabs {
    display: flex;
    gap: 0;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--border);
}

.converter-format-tab {
    flex: 1;
    padding: 10px 16px;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-family: 'Rubik', sans-serif;
    font-size: 0.85em;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease;
}

.converter-format-tab:hover {
    background: var(--input-bg);
}

.converter-format-tab.active {
    background: var(--accent);
    color: white;
}

.converter-format-options {
    display: flex;
    gap: 10px;
}

.converter-select {
    flex: 1;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--input-bg);
    color: var(--text-primary);
    font-family: 'Rubik', sans-serif;
    font-size: 0.9em;
    outline: none;
    cursor: pointer;
    transition: border-color 0.2s ease;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%23a0a0a0' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10l-5 5z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

.converter-select:focus {
    border-color: var(--accent);
}

/* Convert Button */
.converter-btn {
    width: 100%;
    padding: 14px 24px;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 10px;
    font-family: 'Rubik', sans-serif;
    font-size: 1em;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: background 0.2s ease, transform 0.1s ease;
}

.converter-btn:hover {
    background: var(--accent-hover);
}

.converter-btn:active {
    transform: scale(0.98);
}

.converter-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.converter-btn-icon {
    font-size: 1.1em;
}

/* Progress */
.converter-progress {
    margin-top: 20px;
    text-align: center;
}

.converter-progress-bar {
    width: 100%;
    height: 6px;
    background: var(--border);
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 10px;
}

.converter-progress-fill {
    width: 0%;
    height: 100%;
    background: var(--accent);
    border-radius: 3px;
    transition: width 0.3s ease;
}

.converter-progress-text {
    font-size: 0.85em;
    color: var(--text-secondary);
}

/* Download */
.converter-download {
    margin-top: 20px;
    text-align: center;
}

.converter-download-btn {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 14px 28px;
    background: var(--accent);
    color: white;
    text-decoration: none;
    border-radius: 10px;
    font-family: 'Rubik', sans-serif;
    font-size: 1em;
    font-weight: 700;
    transition: background 0.2s ease, transform 0.1s ease;
}

.converter-download-btn:hover {
    background: var(--accent-hover);
    transform: scale(1.02);
}

.converter-download-info {
    font-size: 0.8em;
    color: var(--text-secondary);
    margin-top: 10px;
}

/* Error */
.converter-error {
    margin-top: 16px;
    padding: 12px 16px;
    background: rgba(231, 76, 60, 0.1);
    border: 1px solid rgba(231, 76, 60, 0.3);
    border-radius: 10px;
    color: #e74c3c;
    font-size: 0.9em;
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Responsive */
@media (max-width: 600px) {
    .converter-container {
        padding: 15px;
    }

    .converter-card {
        padding: 20px;
    }

    .converter-title {
        font-size: 1.2em;
    }

    .converter-file-drop {
        padding: 30px 15px;
    }

    .converter-format-options {
        flex-direction: column;
    }
}

