:root {
    /* Color System - Default (Dark Mode) */
    --bg-body: #0f172a;
    --bg-card: #1e293b;
    --bg-card-hover: #334155;
    
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --text-accent: #2F6FFC;

    /* Blue palette (base #2F6FFC) */
    --blue-light: #5a8afd;
    --blue-lighter: #8ab0fe;
    --blue-alpha-05: rgba(47, 111, 252, 0.05);
    --blue-alpha-10: rgba(47, 111, 252, 0.1);
    --blue-alpha-20: rgba(47, 111, 252, 0.2);
    --blue-alpha-25: rgba(47, 111, 252, 0.25);

    --border-color: rgba(255, 255, 255, 0.1);
    --shadow-card: 0 10px 15px -3px rgba(0, 0, 0, 0.3), 0 4px 6px -4px rgba(0, 0, 0, 0.2);
    
    --accent-wash: #1dbd88;
    --accent-no-wash: #dc4a41;
    --wash-glow: rgba(29, 189, 136, 0.25);
    --no-wash-glow: rgba(220, 74, 65, 0.2);

    /* Spacing & Layout */
    --radius-lg: 24px;
    --radius-md: 16px;
    --radius-sm: 12px;
    
    --space-xs: 6px;
    --space-sm: 12px;
    --space-md: 24px;
    --space-lg: 32px;
    --space-xl: 48px;

    /* Transitions */
    --transition-fast: 0.2s ease;
    --transition-smooth: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

body.light-mode {
    /* Light Mode (Reference Style) */
    --bg-body: #f3f4f6;
    --bg-card: #ffffff;
    --bg-card-hover: #f9fafb;
    
    --text-main: #111827;
    --text-muted: #6b7280;
    --text-accent: #2560e0;

    --border-color: rgba(0, 0, 0, 0.05);
    --shadow-card: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
    
    --accent-wash: #1dbd88;
    --accent-no-wash: #dc4a41;
    --wash-glow: rgba(29, 189, 136, 0.2);
    --no-wash-glow: rgba(220, 74, 65, 0.15);
}

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

body {
    font-family: 'Open Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-body);
    color: var(--text-main);
    line-height: 1.5;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    padding: var(--space-md);
    transition: background-color var(--transition-smooth), color var(--transition-smooth);
}

/* Main Layout */
.app-container {
    width: 100%;
    max-width: 1000px;
    display: flex;
    flex-direction: column;
    gap: var(--space-lg);
}

#main-content {
    display: flex;
    flex-direction: column;
    gap: var(--space-lg);
}

/* Shared Card Styles (modern cards with subtle depth) */
.glass-panel {
    background-color: var(--bg-card);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-card);
    border: 1px solid var(--border-color);
    padding: var(--space-xl);
    transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

/* Header – Hybrid Desktop/Mobile Layout */
.location-header {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: calc(var(--space-sm) * 1.2);
    background: var(--bg-card);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-card);
    width: 100%;
    border: 1px solid var(--border-color);
    box-sizing: border-box;
}

.location-wrapper {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    flex: 1;
    min-width: 0;
    position: relative;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 4px;
}

.header-actions button {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: var(--space-xs);
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    font-size: 0.9rem;
}

.header-actions button:hover {
    background-color: var(--bg-body);
    color: var(--text-main);
}

/* Input with icon inside */
.location-wrapper.input-with-icon {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    background: var(--bg-body);
    transition: border-color var(--transition-fast);
}

.location-wrapper.input-with-icon:focus-within {
    border-color: var(--text-accent);
    box-shadow: 0 0 0 2px var(--blue-alpha-20);
}

.location-icon {
    color: var(--text-muted);
    font-size: 1rem;
    flex-shrink: 0;
}

/* Reusable text input (header location + modal + start flow) */
.text-input {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    background: var(--bg-body);
    color: var(--text-main);
    font-family: inherit;
    font-size: 1rem;
    outline: none;
    transition: border-color var(--transition-fast);
}

.text-input:focus {
    border-color: var(--text-accent);
    box-shadow: 0 0 0 2px var(--blue-alpha-20);
}

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

.location-input {
    width: 100%;
    min-width: 120px;
    font-size: 0.875rem;
}

/* When inside input-with-icon wrapper: no own border, blend into wrapper */
.location-wrapper.input-with-icon .location-input {
    padding: 0;
    border: none;
    background: transparent;
    box-shadow: none;
}

.location-wrapper.input-with-icon .location-input:focus {
    box-shadow: none;
}

/* Mobile: Icons ABOVE the bar */
@media (max-width: 640px) {
    .location-header {
        flex-direction: column-reverse;
        align-items: stretch;
        gap: 8px;
        background: transparent;
        border: none;
        box-shadow: none;
        padding: 0;
    }

    .header-actions {
        justify-content: flex-end;
    }

    .location-wrapper.input-with-icon {
        background: var(--bg-card);
        border: 1px solid var(--border-color);
        box-shadow: var(--shadow-card);
    }
}

/* Hero Section (Verdict) */
.verdict-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: var(--space-md);
    position: relative;
    overflow: hidden;
    padding: var(--space-xl) var(--space-lg);
    border-radius: var(--radius-md);
    background: linear-gradient(145deg, var(--bg-card) 0%, rgba(30, 41, 59, 0.95) 100%);
}

body.light-mode .verdict-section {
    background: linear-gradient(145deg, var(--bg-card) 0%, rgba(255, 255, 255, 0.98) 100%);
}

.verdict-section::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    padding: 1px;
    background: linear-gradient(135deg, var(--border-color) 0%, transparent 50%, var(--border-color) 100%);
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    pointer-events: none;
}

.verdict-section .subtitle {
    font-size: 0.875rem;
    letter-spacing: 0.05em;
    color: var(--text-main);
    font-weight: 600;
    line-height: 1.5;
}

.verdict-main-line {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-md);
    margin: var(--space-sm) 0 var(--space-md) 0;
    animation: verdictPop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes verdictPop {
    from {
        opacity: 0;
        transform: scale(0.92);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.verdict-text {
    font-size: 4.2rem;
    font-weight: 800;
    line-height: 1.1;
    letter-spacing: -0.02em;
    text-shadow: 0 2px 20px rgba(0, 0, 0, 0.15);
}

body.light-mode .verdict-text {
    text-shadow: 0 1px 10px rgba(0, 0, 0, 0.06);
}

.verdict-text.wash {
    color: var(--accent-wash);
}

.verdict-section:has(.verdict-text.wash) .verdict-main-line {
    text-shadow: 0 0 40px var(--wash-glow);
}

.verdict-text.no-wash {
    color: var(--accent-no-wash);
}

.verdict-section:has(.verdict-text.no-wash) .verdict-main-line {
    text-shadow: 0 0 40px var(--no-wash-glow);
}

.reason-text {
    font-size: 0.875rem;
    color: var(--text-muted);
    max-width: 600px;
    line-height: 1.6;
}

.reason-text strong {
    color: var(--text-main);
    font-weight: 600;
}

/* Forecast Section */
.forecast-section {
    display: flex;
    flex-direction: column;
    gap: var(--space-lg);
}

.forecast-section .subtitle {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-main);
    margin-left: 0; /* Aligned with grid */
}

.forecast-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 8px;
}

/* Forecast Card */
.forecast-card {
    background-color: var(--bg-card);
    border-radius: var(--radius-md);
    padding: var(--space-md);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-sm);
    box-shadow: var(--shadow-card);
    border: 1px solid var(--border-color);
    min-height: 180px;
    position: relative;
}

.forecast-card .fc-temp {
    margin-top: auto; /* Push temp to bottom */
}

/* Highlight "Algorithm" days (first 3 days) */
.forecast-card.in-algorithm {
    background: linear-gradient(to bottom right, var(--bg-card), var(--blue-alpha-05));
}

.forecast-card.is-raining {
    background-color: var(--blue-alpha-10);
    border-color: var(--blue-alpha-20);
}

.fc-day {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text-main);
    text-transform: capitalize;
}

.fc-algorithm-badge {
    position: absolute;
    top: var(--space-sm);
    right: var(--space-sm);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    color: var(--text-accent);
    background: var(--blue-alpha-10);
    border-radius: 50%;
    font-size: 0.75rem;
    cursor: help;
}

.fc-algorithm-badge i {
    font-size: 0.875rem;
}

.fc-icon {
    font-size: 2rem;
    color: var(--text-muted);
    margin: var(--space-sm) 0;
}

.is-raining .fc-icon {
    color: var(--text-accent);
}

.fc-precip {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-accent);
    display: flex;
    align-items: center;
    gap: 4px;
}

.fc-temp {
    display: flex;
    gap: var(--space-sm);
    font-size: 1rem;
}

.fc-temp-max {
    font-weight: 700;
    color: var(--text-main);
}

.fc-temp-min {
    font-weight: 400;
    color: var(--text-muted);
}

/* Loader – same-size box for all pre-verdict steps (initial, loading, manual, error) */
#loader {
    width: 100%;
    min-height: 520px;
    box-sizing: border-box;
}

.centered-panel {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 520px;
    text-align: center;
    gap: var(--space-lg);
    margin: auto;
}

#loader .loader-icon--error {
    color: var(--accent-no-wash);
    animation: none;
    transform: scale(1);
}

#loader .loader-refresh-btn {
    margin-top: var(--space-md);
}

.loader-actions {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-sm);
    width: 100%;
    max-width: 300px;
}

.loader-actions > .action-btn {
    width: 100%;
}

.landing-input-group {
    width: 100%;
}

.divider-text {
    font-size: 1rem;
    font-weight: 400;
    line-height: 1.5;
    color: var(--text-muted);
    letter-spacing: 0.05em;
    margin: 4px 0;
}

/* Flying Weather Icons Animation */
.weather-fly-animation {
    position: relative;
    width: 140px; /* Width of the flight path */
    height: 60px;
    margin: 0 auto var(--space-md); /* Center it */
    overflow: hidden;
    -webkit-mask-image: linear-gradient(to right, transparent, black 20%, black 80%, transparent);
    mask-image: linear-gradient(to right, transparent, black 20%, black 80%, transparent);
}

.weather-fly-animation i {
    position: absolute;
    top: 50%;
    left: -40px; /* Start off-screen left */
    transform: translateY(-50%);
    font-size: 2.5rem;
    color: var(--text-accent);
    opacity: 0;
    animation: flyRight 3s linear infinite;
}

/* Stagger the animations for each icon */
.weather-fly-animation i:nth-child(1) { animation-delay: 0s; }   /* Sun */
.weather-fly-animation i:nth-child(2) { animation-delay: 0.75s; } /* Cloud+Sun */
.weather-fly-animation i:nth-child(3) { animation-delay: 1.5s; }  /* Cloud */
.weather-fly-animation i:nth-child(4) { animation-delay: 2.25s; } /* Cloud+Rain */

@keyframes flyRight {
    0% {
        left: -40px;
        opacity: 0;
        transform: translateY(-50%) scale(0.8);
    }
    10% {
        opacity: 1;
        transform: translateY(-50%) scale(1);
    }
    90% {
        opacity: 1;
        transform: translateY(-50%) scale(1);
    }
    100% {
        left: 100%; /* Fly off to the right */
        opacity: 0;
        transform: translateY(-50%) scale(0.8);
    }
}

.spin-icon {
    font-size: 3rem;
    color: var(--text-accent);
    animation: spin 2s linear infinite;
}

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

/* Footer */
.footer-panel {
    text-align: center;
    padding: var(--space-lg);
    color: var(--text-muted);
    font-size: 0.875rem;
    background: transparent;
    box-shadow: none;
    border: none;
}

.footer-panel a {
    color: var(--text-main);
    text-decoration: none;
    font-weight: 600;
}

.footer-panel a:hover {
    text-decoration: underline;
    color: var(--text-accent);
}

/* Modals */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: var(--space-md);
}

.modal-content {
    background: var(--bg-card);
    padding: var(--space-xl);
    border-radius: var(--radius-sm);
    width: 100%;
    max-width: 500px;
    box-shadow: var(--shadow-card);
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}

.modal-content h2 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-main);
}

.modal-content p {
    color: var(--text-muted);
    line-height: 1.6;
}

/* Inputs & Buttons */
.input-group {
    display: flex;
    gap: var(--space-sm);
}

.input-group .text-input {
    flex: 1;
}

.action-btn {
    padding: 12px 24px;
    border-radius: var(--radius-sm);
    border: none;
    background: var(--text-accent);
    color: #fff;
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    transition: all var(--transition-fast);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.action-btn:hover {
    filter: brightness(1.1);
    transform: translateY(-1px);
}

.action-btn:active {
    transform: translateY(0);
}

.action-btn.secondary-btn {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-main);
}

.action-btn.secondary-btn:hover {
    background: var(--bg-body);
}

/* Loader "Use my location" button: blue gradient, no hover movement */
.loader-actions > .action-btn.secondary-btn {
    padding: 16px 24px;
    font-weight: 400;
    background: linear-gradient(180deg, var(--text-accent) 0%, var(--blue-light) 100%);
    color: #fff;
    border: none;
    transition: none;
}

.loader-actions > .action-btn.secondary-btn:hover,
.loader-actions > .action-btn.secondary-btn:active {
    transform: none;
    background: var(--text-accent);
    filter: none;
}

/* Utilities */
.hidden { display: none !important; }

/* Responsive */
@media (max-width: 640px) {
    body {
        padding: 16px;
    }
    .verdict-text { font-size: 3rem; }
    .forecast-grid {
        display: flex;
        flex-wrap: nowrap;
        gap: 8px;
        overflow-x: auto;
        overflow-y: hidden;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: thin;
        padding-bottom: 8px;
    }
    .forecast-grid::-webkit-scrollbar {
        height: 6px;
    }
    .forecast-grid::-webkit-scrollbar-thumb {
        background: var(--border-color);
        border-radius: 3px;
    }
    .forecast-card {
        flex: 0 0 auto;
        min-width: 140px;
    }
    .location-header { width: 100%; }
}
