:root {
    --bg: #f4f6f8;
    --bar-bg: #1e2a38;
    --bar-text: #ffffff;
    --bar-subtext: #a9b7c6;
    --panel-bg: #ffffff;
    --panel-text: #1e2a38;
    --panel-border: #d8dee4;
    --btn-bg: #ffffff;
    --btn-bg-active: #2ecc71;
    --btn-text: #1e2a38;
    --btn-text-active: #ffffff;
    --btn-border: #d8dee4;
}

body.dark-theme {
    --bg: #10161f;
    --bar-bg: #0b1119;
    --bar-text: #eef2f6;
    --bar-subtext: #7c8ba1;
    --panel-bg: #1a2331;
    --panel-text: #eef2f6;
    --panel-border: #2c3a4d;
    --btn-bg: #1a2331;
    --btn-bg-active: #2ecc71;
    --btn-text: #eef2f6;
    --btn-text-active: #0b1119;
    --btn-border: #2c3a4d;
}

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    height: 100dvh; /* accounts for mobile browsers' address bar showing/hiding */
    overflow: hidden;
    font-family: -apple-system, Segoe UI, Roboto, Arial, sans-serif;
    background: var(--bg);
    transition: background 0.2s ease;
}

body {
    display: flex;
    flex-direction: column;
}

#status-bar {
    display: flex;
    flex: 0 0 auto;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: var(--bar-bg);
    color: var(--bar-text);
    font-size: 14px;
    transition: background 0.2s ease, color 0.2s ease;
}

#status-bar-title {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    font-weight: 600;
    font-size: 16px;
    letter-spacing: 0.2px;
}
#status-bar-title span {
    overflow-wrap: anywhere;
}

#app-logo {
    height: 32px;
    width: auto;
    display: block;
    flex-shrink: 0;
}

#status-bar-right {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 14px;
}

#last-checked {
    color: var(--bar-subtext);
    font-size: 12px;
}

#status-text {
    color: #ff9b8a;
    font-size: 12px;
    font-weight: 600;
}
#status-text:empty {
    display: none;
}

#refresh-interval-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--bar-subtext);
}

#refresh-interval {
    background: var(--btn-bg);
    color: var(--btn-text);
    border: 1px solid var(--btn-border);
    border-radius: 6px;
    padding: 6px 8px;
    min-height: 32px;
    font-size: 12px;
    cursor: pointer;
}

#theme-toggle {
    border: 1px solid var(--btn-border);
    background: transparent;
    color: var(--bar-text);
    border-radius: 6px;
    width: 38px;
    height: 38px;
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}
#theme-toggle:hover {
    background: rgba(255, 255, 255, 0.08);
}

#left-controls {
    /* Positioned by Google Maps itself (map.controls[LEFT_TOP]) — see
       app.js. Starts hidden so there's no flash of it sitting in the
       normal page flow before JS moves it into the map's control layer. */
    display: none;
    margin: 10px;
    flex-direction: column;
    gap: 8px;
}

.control-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    min-height: 40px;
    background: var(--btn-bg);
    color: var(--btn-text);
    border: 1px solid var(--btn-border);
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.15);
    transition: background 0.15s ease, color 0.15s ease;
}
.control-btn:hover {
    filter: brightness(1.05);
}
.control-btn[aria-pressed="true"] {
    background: var(--btn-bg-active);
    color: var(--btn-text-active);
    border-color: var(--btn-bg-active);
}
.control-icon {
    font-size: 15px;
}

#right-controls {
    /* Positioned by Google Maps itself (map.controls[RIGHT_TOP]) — see
       app.js. Starts hidden so there's no flash of it sitting in the
       normal page flow before JS moves it into the map's control layer. */
    display: none;
    margin: 10px;
}

#legend-panel {
    background: var(--btn-bg);
    color: var(--btn-text);
    border: 1px solid var(--btn-border);
    border-radius: 8px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.15);
    min-width: 150px;
    overflow: hidden;
}

#legend-toggle {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 10px 12px;
    min-height: 40px;
    background: transparent;
    color: var(--btn-text);
    border: none;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    text-align: left;
}
#legend-toggle:hover {
    filter: brightness(1.05);
}

#legend-body {
    padding: 4px 12px 10px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
#legend-panel.collapsed #legend-body {
    display: none;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
}

.legend-swatch {
    display: inline-block;
    width: 20px;
    height: 4px;
    border-radius: 2px;
    flex-shrink: 0;
}

.legend-icon {
    display: inline-flex;
    width: 20px;
    justify-content: center;
    font-size: 13px;
    flex-shrink: 0;
}

.iw-outage {
    font-size: 13px;
    line-height: 1.4;
    max-width: 220px;
}

#map {
    width: 100%;
    flex: 1 1 auto;
    min-height: 0; /* required for flex children to shrink properly in some browsers */
}

.iw-status {
    font-weight: 600;
}

#radar-attribution {
    position: fixed;
    bottom: calc(4px + env(safe-area-inset-bottom, 0px));
    left: 12px;
    z-index: 5;
    font-size: 10px;
    color: var(--panel-text);
    background: var(--panel-bg);
    padding: 2px 6px;
    border-radius: 4px;
    opacity: 0.85;
    display: none;
}
#radar-attribution.visible {
    display: block;
}

#announcement-overlay {
    position: fixed;
    inset: 0;
    z-index: 50;
    background: rgba(0, 0, 0, 0.5);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 16px;
}
#announcement-overlay.visible {
    display: flex;
}

#announcement-box {
    position: relative;
    max-width: 520px;
    width: 100%;
    max-height: 80vh;
    max-height: 80dvh;
    overflow-y: auto;
    /* Fixed dark styling regardless of light/dark site theme, so the
       white link/text below always has enough contrast to read. */
    background: #1a2331;
    color: #eef2f6;
    border: 1px solid #2c3a4d;
    border-radius: 10px;
    padding: 28px 24px 24px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

#announcement-content {
    font-size: 14px;
    line-height: 1.5;
}
#announcement-content h1,
#announcement-content h2,
#announcement-content h3 {
    margin-top: 0;
}
#announcement-content a {
    color: #ffffff;
    text-decoration: underline;
}
#announcement-content a:visited {
    color: #ffffff;
}
#announcement-content a:hover {
    opacity: 0.85;
}

#announcement-footer {
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid #2c3a4d;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}

#announcement-hide-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: #c9d6e3;
    cursor: pointer;
}
#announcement-hide-label input[type="checkbox"] {
    width: 20px;
    height: 20px;
    cursor: pointer;
    flex-shrink: 0;
}

#announcement-dismiss {
    background: #2ecc71;
    color: #0b1119;
    border-color: #2ecc71;
    white-space: nowrap;
}
#announcement-dismiss:hover {
    filter: brightness(1.08);
}

#announcement-close {
    position: absolute;
    top: 8px;
    right: 8px;
    border: none;
    background: transparent;
    color: #eef2f6;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    padding: 8px 12px;
    min-width: 40px;
    min-height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
}
#announcement-close:hover {
    background: rgba(255, 255, 255, 0.12);
}

@media (max-width: 600px) {
    #status-bar {
        padding: 8px 10px;
    }
    #status-bar-title {
        font-size: 14px;
    }
    #app-logo {
        height: 24px;
    }
    #status-bar-right {
        font-size: 11px;
        gap: 10px;
    }
    #last-checked {
        font-size: 11px;
    }

    /* Google Maps already repositions its own controls responsively —
       these just make our custom panels take up less width so there's
       still map visible between them on narrow phones. */
    #left-controls,
    #right-controls {
        margin: 6px;
    }
    .control-label {
        font-size: 12px;
    }
    #legend-panel {
        min-width: 128px;
    }

    #announcement-box {
        padding: 24px 16px 16px;
    }
    #announcement-footer {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }
    #announcement-dismiss {
        width: 100%;
    }
}