:root {
    --bg-primary: #0f1923;
    --bg-card: rgba(255,255,255,0.06);
    --bg-card-hover: rgba(255,255,255,0.10);
    --text-primary: #ffffff;
    --text-secondary: rgba(255,255,255,0.6);
    --text-tertiary: rgba(255,255,255,0.4);
    --accent: #5b9cf6;
    --accent-glow: rgba(91,156,246,0.25);
    --border: rgba(255,255,255,0.07);
    --danger: #f65b5b;
    --radius-sm: 12px;
    --radius-md: 16px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    transition: background 1s ease;
}

#fx-canvas, #fx-canvas-front {
    position: fixed; inset: 0;
    width: 100%; height: 100%;
    pointer-events: none;
}
#fx-canvas { z-index: 0; }
#fx-canvas-front { z-index: 2; }
.lightning-flash {
    position: fixed; inset: 0;
    background: rgba(255,255,255,0.12);
    pointer-events: none; z-index: 0;
    opacity: 0;
    transition: opacity 0.05s;
}
.lightning-flash.on { opacity: 1; }

.app {
    position: relative; z-index: 1;
    max-width: 960px;
    margin: 0 auto;
    padding: 20px 24px 40px;
    min-height: 100vh;
}

.header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 16px;
}
.logo { font-size: 1.3em; font-weight: 700; letter-spacing: -0.5px; display: flex; align-items: center; gap: 4px; }
.logo img { width: 28px; height: 28px; }
.h-precip img, .day-precip img { width: 14px; height: 14px; display: inline; vertical-align: -2px; }
.unit-toggle {
    display: flex; background: var(--bg-card); border-radius: 10px;
    border: 1px solid var(--border); overflow: hidden;
}
.unit-toggle button {
    padding: 7px 13px; border: none; background: transparent;
    color: var(--text-secondary); font-family: inherit;
    font-size: 0.82em; font-weight: 600; cursor: pointer; transition: all 0.2s;
}
.unit-toggle button.active { background: var(--accent); color: #fff; }

.search-container { display: flex; gap: 8px; margin-bottom: 14px; }
.search-input-wrap { flex: 1; position: relative; }
.search-input-wrap svg {
    position: absolute; left: 14px; top: 50%;
    transform: translateY(-50%); width: 16px; height: 16px; color: var(--text-tertiary);
}
.search-input-wrap input {
    width: 100%; padding: 12px 12px 12px 40px;
    border: 1px solid var(--border); border-radius: var(--radius-sm);
    background: var(--bg-card); color: var(--text-primary);
    font-family: inherit; font-size: 0.9em; outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.search-input-wrap input::placeholder { color: var(--text-tertiary); }
.search-input-wrap input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }
.search-btn, .geo-btn {
    padding: 12px 16px; border: 1px solid var(--border); border-radius: var(--radius-sm);
    background: var(--bg-card); color: var(--text-primary); font-family: inherit;
    cursor: pointer; transition: all 0.2s; display: flex; align-items: center; justify-content: center;
}
.search-btn:hover, .geo-btn:hover { background: var(--bg-card-hover); border-color: var(--accent); }
.search-btn svg, .geo-btn svg { width: 16px; height: 16px; }

.notification {
    padding: 10px 14px; border-radius: var(--radius-sm);
    background: rgba(246,91,91,0.12); border: 1px solid rgba(246,91,91,0.25);
    color: var(--danger); font-size: 0.85em; margin-bottom: 14px;
    display: none; animation: slideDown 0.3s ease;
}
@keyframes slideDown { from { opacity:0; transform:translateY(-6px); } to { opacity:1; transform:translateY(0); } }

.welcome { text-align: center; padding: 80px 20px; }
.welcome-icon { margin-bottom: 16px; animation: float 3s ease-in-out infinite; display: flex; justify-content: center; }
.welcome-icon img { width: 80px; height: 80px; }
@keyframes float { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-10px); } }
.welcome h2 { font-size: 1.4em; font-weight: 700; margin-bottom: 8px; }
.welcome p { color: var(--text-secondary); font-size: 0.9em; line-height: 1.6; max-width: 380px; margin: 0 auto; }

.loading { display: none; text-align: center; padding: 80px 20px; }
.spinner {
    width: 36px; height: 36px; border: 3px solid var(--border);
    border-top-color: var(--accent); border-radius: 50%;
    animation: spin 0.7s linear infinite; margin: 0 auto 14px;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading p { color: var(--text-secondary); font-size: 0.85em; }

.weather-content { display: none; }
.weather-content.visible { display: block; animation: fadeUp 0.45s ease; }
@keyframes fadeUp { from { opacity:0; transform:translateY(14px); } to { opacity:1; transform:translateY(0); } }

.top-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 16px;
}

.hero-card {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius-md); padding: 28px 24px;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    text-align: center; min-height: 280px;
}
.hero-location { font-size: 0.88em; color: var(--text-secondary); font-weight: 500; margin-bottom: 2px; }
.hero-datetime { font-size: 0.75em; color: var(--text-tertiary); margin-bottom: 14px; }
.hero-icon { line-height: 1; margin-bottom: 6px; filter: drop-shadow(0 4px 16px rgba(0,0,0,0.3)); }
.hero-icon img { width: 80px; height: 80px; }
.hero-temp { font-size: 4em; font-weight: 800; letter-spacing: -3px; line-height: 1; }
.hero-temp .unit { font-size: 0.38em; font-weight: 500; color: var(--text-secondary); vertical-align: super; letter-spacing: 0; }
.hero-feels { font-size: 0.8em; color: var(--text-secondary); margin-top: 4px; }
.hero-status { font-size: 1em; font-weight: 600; margin-top: 6px; }
.hero-minmax { font-size: 0.8em; color: var(--text-secondary); display: flex; gap: 10px; margin-top: 4px; }
.hero-minmax .hi { color: #f6a05b; }
.hero-minmax .lo { color: #5bb8f6; }

.detail-grid {
    display: grid; grid-template-columns: 1fr 1fr; grid-template-rows: repeat(3, 1fr);
    gap: 10px;
}
.detail-card {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius-md); padding: 14px;
    transition: background 0.2s, border-color 0.2s;
}
.detail-card:hover { background: var(--bg-card-hover); border-color: rgba(255,255,255,0.1); }
.detail-card .label {
    font-size: 0.68em; color: var(--text-tertiary); text-transform: uppercase;
    letter-spacing: 0.8px; margin-bottom: 6px; display: flex; align-items: center; gap: 5px;
}
.detail-card .label svg { width: 12px; height: 12px; opacity: 0.5; }
.detail-card .value { font-size: 1.2em; font-weight: 700; }
.detail-card .sub { font-size: 0.72em; color: var(--text-secondary); margin-top: 2px; }

.section-label {
    font-size: 0.7em; font-weight: 600; text-transform: uppercase;
    letter-spacing: 1.2px; color: var(--text-tertiary); margin: 20px 0 8px;
}

.mid-row {
    display: grid;
    grid-template-columns: 260px 1fr;
    gap: 16px;
    align-items: stretch;
}

.sun-card {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius-md); padding: 20px;
}
.sun-card .section-label { margin-top: 0; }
.sun-row { display: flex; align-items: center; justify-content: space-between; margin-top: 12px; }
.sun-item { text-align: center; }
.sun-item .sun-icon { margin-bottom: 4px; display: flex; justify-content: center; }
.sun-item .sun-icon img { width: 32px; height: 32px; }
.sun-item .sun-label { font-size: 0.65em; text-transform: uppercase; letter-spacing: 0.8px; color: var(--text-tertiary); }
.sun-item .sun-time { font-size: 0.95em; font-weight: 700; margin-top: 2px; }
.sun-divider {
    flex: 1; height: 2px; margin: 0 14px;
    background: linear-gradient(90deg, #fbbf24, rgba(255,255,255,0.06) 40%, rgba(255,255,255,0.06) 60%, #5b9cf6);
    border-radius: 1px; position: relative;
}
.sun-divider::after { content: none; }
.sun-marker {
    position: absolute; top: -9px;
    left: var(--sun-progress, 50%); transform: translateX(-50%); transition: left 0.3s;
    color: #fbbf24; line-height: 0;
}
.sun-marker img { width: 20px; height: 20px; }
.sun-daylight { text-align: center; margin-top: 14px; font-size: 0.78em; color: var(--text-secondary); }

.hourly-wrap {
    min-width: 0;
    display: flex;
    flex-direction: column;
}
.hourly-wrap .section-label { margin-top: 0; }
.hourly-scroll {
    display: flex; overflow-x: auto; gap: 6px; padding-bottom: 6px;
    scroll-snap-type: x mandatory; -webkit-overflow-scrolling: touch;
    flex: 1; align-items: stretch;
}
.hourly-scroll::-webkit-scrollbar { height: 3px; }
.hourly-scroll::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.12); border-radius: 3px; }
.hourly-scroll::-webkit-scrollbar-track { background: transparent; }
.hour-card {
    flex-shrink: 0; width: 64px; text-align: center;
    padding: 12px 6px; background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius-sm); scroll-snap-align: start; transition: background 0.2s;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.hour-card:hover { background: var(--bg-card-hover); }
.hour-card.now { background: rgba(91,156,246,0.12); border-color: rgba(91,156,246,0.25); }
.hour-card .h-time { font-size: 0.65em; color: var(--text-secondary); font-weight: 500; margin-bottom: 6px; }
.hour-card .h-icon { margin-bottom: 4px; }
.hour-card .h-icon img { width: 28px; height: 28px; }
.hour-card .h-temp { font-size: 0.82em; font-weight: 700; }
.hour-card .h-precip { font-size: 0.6em; color: var(--accent); margin-top: 3px; font-weight: 500; }

.daily-list { display: flex; flex-direction: column; gap: 5px; }
.daily-row {
    display: grid; grid-template-columns: 1fr auto auto 1fr auto;
    align-items: center; gap: 10px; padding: 12px 14px;
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius-sm); transition: background 0.2s;
}
.daily-row:hover { background: var(--bg-card-hover); }
.daily-row .day-name { font-size: 0.85em; font-weight: 600; }
.daily-row .day-icon { display: flex; align-items: center; }
.daily-row .day-icon img { width: 28px; height: 28px; }
.daily-row .day-precip { font-size: 0.72em; color: var(--accent); font-weight: 500; min-width: 52px; text-align: center; }
.daily-row .temp-bar { width: 80px; height: 4px; background: var(--border); border-radius: 2px; position: relative; overflow: hidden; }
.daily-row .temp-bar .fill { position: absolute; height: 100%; border-radius: 2px; background: linear-gradient(90deg, var(--accent), #f6a05b); }
.daily-row .day-temps { display: flex; align-items: center; gap: 6px; font-size: 0.85em; justify-content: flex-end; }
.daily-row .day-hi { font-weight: 700; }
.daily-row .day-lo { color: var(--text-tertiary); font-weight: 500; }

.footer {
    text-align: center; margin-top: 28px; padding-top: 16px;
    border-top: 1px solid var(--border); color: var(--text-tertiary); font-size: 0.7em;
}

@media (max-width: 700px) {
    .app { padding: 16px 14px 32px; }
    .top-row { grid-template-columns: 1fr; }
    .mid-row { grid-template-columns: 1fr; }
    .hero-card { min-height: auto; padding: 24px 20px; }
    .hero-temp { font-size: 3.4em; }
}
