* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg: #0a0e17;
    --bg-card: #111827;
    --bg-card-soft: rgba(17, 24, 39, 0.76);
    --text: #e5e7eb;
    --text-dim: #6b7280;
    --accent: #3b82f6;
    --accent-soft: rgba(59, 130, 246, 0.18);
    --green: #22c55e;
    --yellow: #eab308;
    --orange: #f97316;
    --red: #ef4444;
    --border: #1f2937;
    --radius: 16px;
    --shadow-soft: 0 24px 48px rgba(0, 0, 0, 0.28);
    --forecast: #a855f7;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    display: flex;
    justify-content: center;
}

.container {
    width: 100%;
    max-width: 480px;
    padding: 24px 16px;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

/* Header */
header {
    text-align: center;
    padding: 16px 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

h1 {
    font-size: 2rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.title-mark {
    color: var(--accent);
    display: inline-block;
    margin-left: 2px;
    transform: translateY(-1px) rotate(-10deg);
    transform-origin: 50% 70%;
}

.subtitle {
    color: var(--text-dim);
    font-size: 0.875rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.location-form {
    width: min(100%, 320px);
}

.zip-row {
    display: flex;
    gap: 10px;
}

#zip-input {
    flex: 1;
    min-width: 0;
    padding: 11px 12px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: rgba(17, 24, 39, 0.92);
    color: var(--text);
    font: inherit;
    text-align: center;
    letter-spacing: 0.08em;
}

#zip-input::placeholder {
    color: var(--text-dim);
    letter-spacing: 0;
}

#zip-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

#zip-submit {
    border: 1px solid transparent;
    border-radius: 999px;
    padding: 11px 18px;
    background: linear-gradient(135deg, var(--accent), #2563eb);
    color: #fff;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

#zip-submit:hover {
    transform: translateY(-1px);
    box-shadow: 0 8px 18px rgba(37, 99, 235, 0.25);
}

#zip-submit:focus-visible {
    outline: 2px solid rgba(59, 130, 246, 0.45);
    outline-offset: 2px;
}

.zip-status {
    min-height: 1.1em;
    margin-top: 8px;
    font-size: 0.75rem;
    color: var(--text-dim);
}

.zip-status.error {
    color: var(--red);
}

.zip-status.success {
    color: var(--accent);
}

/* Loading spinner */
.loading-spinner {
    display: inline-block;
    width: 12px;
    height: 12px;
    border: 2px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* Loading dots */
.loading-dots::after {
    content: '';
    animation: dots 1.5s steps(4, end) infinite;
}

@keyframes dots {
    0%   { content: ''; }
    25%  { content: '.'; }
    50%  { content: '..'; }
    75%  { content: '...'; }
    100% { content: ''; }
}

/* Forecast card */
.forecast-card {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 24px 22px;
    background: linear-gradient(180deg, rgba(18, 24, 38, 0.98), rgba(14, 19, 30, 0.98));
    border-radius: var(--radius);
    border: 1px solid rgba(59, 130, 246, 0.14);
    min-height: 132px;
    justify-content: center;
    box-shadow: var(--shadow-soft);
}

.forecast-card.rain {
    border-color: rgba(34, 197, 94, 0.28);
    box-shadow:
        var(--shadow-soft),
        0 0 0 1px rgba(34, 197, 94, 0.1) inset;
}

.forecast-card.dry {
    border-color: rgba(96, 165, 250, 0.24);
    box-shadow:
        var(--shadow-soft),
        0 0 0 1px rgba(96, 165, 250, 0.08) inset;
}

.forecast-headline {
    font-size: 1.95rem;
    line-height: 1.02;
    letter-spacing: -0.04em;
    font-weight: 700;
    min-height: 2.05em;
    max-width: 12ch;
}

.forecast-detail {
    min-height: 1.3em;
    color: var(--text-dim);
    font-size: 0.94rem;
    max-width: 30ch;
}

.forecast-card.loading .forecast-headline,
.forecast-card.loading .forecast-detail {
    color: var(--text-dim);
}

.forecast-card.loading .forecast-headline {
    display: inline-flex;
    align-items: center;
}

.forecast-card.rain .forecast-headline {
    color: #f8fafc;
}

.forecast-card.dry .forecast-headline {
    color: #dbeafe;
}

/* Map */
.radar-shell {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.radar-gate {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 20px 18px 18px;
    background: linear-gradient(180deg, rgba(18, 24, 38, 0.98), rgba(13, 18, 29, 0.98));
    border: 1px solid rgba(59, 130, 246, 0.18);
    border-radius: var(--radius);
    box-shadow: var(--shadow-soft);
}

.radar-gate-title {
    font-size: 1.02rem;
    font-weight: 600;
    letter-spacing: -0.01em;
}

.radar-gate-copy {
    color: var(--text-dim);
    font-size: 0.9rem;
    line-height: 1.5;
    max-width: 34ch;
}

.radar-gate-button,
.tl-load-btn {
    align-self: flex-start;
    border: 1px solid rgba(96, 165, 250, 0.28);
    border-radius: 999px;
    padding: 10px 16px;
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.16), rgba(37, 99, 235, 0.3));
    color: var(--text);
    font: inherit;
    font-weight: 600;
    cursor: pointer;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
    transition: transform 0.18s ease, background 0.18s ease, border-color 0.18s ease;
}

.radar-gate-button:hover,
.tl-load-btn:hover {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.22), rgba(37, 99, 235, 0.36));
    border-color: rgba(96, 165, 250, 0.42);
    transform: translateY(-1px);
}

.radar-gate-button:disabled,
.tl-load-btn:disabled {
    opacity: 0.6;
    cursor: wait;
    transform: none;
}

.map-section {
    border-radius: var(--radius);
    overflow: hidden;
    border: 1px solid rgba(59, 130, 246, 0.14);
    position: relative;
    background: linear-gradient(180deg, rgba(17, 23, 35, 0.98), rgba(11, 16, 26, 0.98));
    box-shadow: var(--shadow-soft);
}

#map {
    height: 350px;
    width: 100%;
    background: linear-gradient(180deg, rgba(16, 22, 34, 0.98), rgba(10, 14, 23, 0.98));
}

/* Leaflet dark tiles */
.leaflet-tile-pane {
    filter: brightness(0.7) contrast(1.1) saturate(0.3);
}

.leaflet-control-attribution {
    background: rgba(10, 14, 23, 0.8) !important;
    color: var(--text-dim) !important;
    font-size: 10px !important;
}

.leaflet-control-attribution a {
    color: var(--text-dim) !important;
}

/* Forecast badge */
.map-badge {
    position: absolute;
    top: 14px;
    right: 14px;
    z-index: 1000;
    background: linear-gradient(135deg, rgba(168, 85, 247, 0.92), rgba(124, 58, 237, 0.92));
    color: #fff;
    font-size: 0.625rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    padding: 5px 10px;
    border-radius: 999px;
    text-transform: uppercase;
    box-shadow: 0 10px 24px rgba(88, 28, 135, 0.28);
}

/* Timeline panel */
.timeline-panel {
    background: linear-gradient(180deg, rgba(10, 14, 23, 0.9), rgba(8, 12, 20, 0.98));
    backdrop-filter: blur(14px);
    padding: 14px 14px 12px;
    border-top: 1px solid rgba(59, 130, 246, 0.12);
}

.timeline-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 8px;
}

.timeline-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.tl-btn {
    background: linear-gradient(180deg, rgba(24, 33, 52, 0.94), rgba(13, 19, 32, 0.94));
    border: 1px solid rgba(96, 165, 250, 0.18);
    color: var(--text);
    cursor: pointer;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    transition: transform 0.18s ease, background 0.18s ease, border-color 0.18s ease;
}

.tl-btn:hover {
    background: linear-gradient(180deg, rgba(32, 44, 69, 0.96), rgba(17, 24, 39, 0.96));
    border-color: rgba(96, 165, 250, 0.32);
    transform: translateY(-1px);
}

.tl-load-btn {
    padding-inline: 14px;
    white-space: nowrap;
}

.tl-time {
    font-size: 0.9rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    min-width: 58px;
    color: #f3f4f6;
}

.tl-label {
    font-size: 0.625rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    padding: 4px 8px;
    border-radius: 999px;
    text-transform: uppercase;
}

.tl-label.observed {
    background: var(--accent);
    color: #fff;
}

.tl-label.forecast {
    background: var(--forecast);
    color: #fff;
}

.tl-label.now {
    background: var(--green);
    color: #000;
}

/* Timeline track */
.timeline-track {
    position: relative;
    height: 30px;
    cursor: pointer;
    touch-action: none;
    display: flex;
    align-items: center;
    padding: 0 2px;
}

.tl-past {
    height: 6px;
    background: linear-gradient(90deg, rgba(37, 99, 235, 0.68), rgba(96, 165, 250, 0.78));
    border-radius: 999px 0 0 999px;
    opacity: 0.95;
}

.tl-now-marker {
    width: 3px;
    height: 18px;
    background: var(--green);
    flex-shrink: 0;
    border-radius: 999px;
    box-shadow: 0 0 12px rgba(34, 197, 94, 0.6);
}

.tl-future {
    height: 6px;
    background: linear-gradient(90deg, rgba(168, 85, 247, 0.65), rgba(124, 58, 237, 0.78));
    border-radius: 0 999px 999px 0;
    opacity: 0.9;
}

.tl-thumb {
    position: absolute;
    width: 18px;
    height: 18px;
    background: linear-gradient(180deg, #f8fafc, #cbd5e1);
    border: 3px solid rgba(8, 12, 20, 0.96);
    border-radius: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    pointer-events: none;
    box-shadow:
        0 0 0 2px rgba(255,255,255,0.08),
        0 12px 22px rgba(2, 6, 23, 0.35);
    transition: left 0.15s ease;
}

.timeline-labels {
    display: flex;
    justify-content: space-between;
    font-size: 0.68rem;
    color: var(--text-dim);
    margin-top: 8px;
    padding: 0 4px;
}

/* Footer */
footer {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    color: var(--text-dim);
    padding: 0 4px;
}

/* Error state */
.error-message {
    text-align: center;
    padding: 20px;
    color: var(--text-dim);
    font-size: 0.875rem;
    background: var(--bg-card);
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

/* Responsive */
@media (min-width: 640px) {
    .container {
        padding: 40px 16px;
    }

    h1 {
        font-size: 2.5rem;
    }

    #map {
        height: 420px;
    }
}

@media (max-width: 420px) {
    .zip-row {
        flex-direction: column;
    }

    #zip-submit {
        width: 100%;
    }

    .timeline-top {
        flex-wrap: wrap;
    }

    .timeline-actions {
        width: 100%;
        justify-content: space-between;
    }

    .tl-load-btn {
        flex: 1;
        justify-self: stretch;
        text-align: center;
    }
}
