:root {
    --bg: #eef2f9;
    --text: #1c2333;
    --text-soft: #5b6478;
    --card-bg: #ffffff;
    --card-border: rgba(28, 35, 51, 0.06);
    --shadow: 0 10px 30px rgba(30, 41, 59, 0.08);
    --accent: #3b6fe0;
    --radius: 18px;
    --day-grad: linear-gradient(135deg, #4f9df7 0%, #3b6fe0 55%, #2f4fb0 100%);
    --night-grad: linear-gradient(135deg, #232a4d 0%, #1b1f3b 55%, #0f1226 100%);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: "Segoe UI", system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); }

/* ---------- Header ---------- */

.site-header {
    background: #fff;
    border-bottom: 1px solid var(--card-border);
    padding: 18px 20px 14px;
    position: sticky;
    top: 0;
    z-index: 20;
}

.header-inner {
    max-width: 900px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap;
}

.logo {
    margin: 0;
    font-size: 1.4rem;
    font-weight: 700;
    white-space: nowrap;
}

.logo-accent { color: var(--accent); }

.search-wrap {
    position: relative;
    flex: 1;
    min-width: 220px;
}

.search-input {
    width: 100%;
    padding: 10px 14px;
    font-size: 1rem;
    border: 1px solid var(--card-border);
    border-radius: 12px;
    background: #f5f7fb;
    outline: none;
    transition: border-color .15s, background .15s;
}

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

.search-results {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    background: #fff;
    border: 1px solid var(--card-border);
    border-radius: 12px;
    box-shadow: var(--shadow);
    max-height: 280px;
    overflow-y: auto;
    z-index: 30;
}

.search-result-item {
    padding: 10px 14px;
    cursor: pointer;
    font-size: .95rem;
}

.search-result-item:hover,
.search-result-item.active {
    background: #eef2f9;
}

.search-result-item .admin1 {
    color: var(--text-soft);
    font-size: .85rem;
}

.search-empty {
    padding: 10px 14px;
    color: var(--text-soft);
    font-size: .9rem;
}

.popular-cities {
    max-width: 900px;
    margin: 12px auto 0;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.chip {
    border: 1px solid var(--card-border);
    background: #f5f7fb;
    color: var(--text);
    padding: 6px 14px;
    border-radius: 999px;
    font-size: .85rem;
    cursor: pointer;
    transition: background .15s, color .15s;
}

.chip:hover, .chip.active {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

/* ---------- Main ---------- */

.container {
    max-width: 900px;
    margin: 24px auto 40px;
    padding: 0 16px;
}

.error-box {
    background: #fff3f2;
    border: 1px solid #ffd7d3;
    color: #a33;
    padding: 16px;
    border-radius: var(--radius);
}

/* ---------- Hero ---------- */

.hero {
    border-radius: var(--radius);
    padding: 26px 28px;
    color: #fff;
    box-shadow: var(--shadow);
    background: var(--day-grad);
    transition: background .3s;
}

.hero.is-night { background: var(--night-grad); }

.hero-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
}

.city-name {
    margin: 0;
    font-size: 1.4rem;
    font-weight: 600;
}

.city-name .admin1 {
    font-weight: 400;
    opacity: .8;
    font-size: 1rem;
}

.badge {
    font-size: .78rem;
    padding: 4px 10px;
    border-radius: 999px;
    background: rgba(255,255,255,.18);
    white-space: nowrap;
}

.hero-main {
    display: flex;
    align-items: center;
    gap: 18px;
    margin-top: 18px;
}

.hero-icon { font-size: 4rem; line-height: 1; }

.hero-temp {
    font-size: 3.6rem;
    font-weight: 300;
    line-height: 1;
}

.hero-desc-wrap { margin-left: 6px; }

.hero-desc { font-size: 1.15rem; font-weight: 500; }

.hero-feels { opacity: .85; font-size: .9rem; margin-top: 4px; }

/* ---------- Details grid ---------- */

.details-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 12px;
    margin-top: 18px;
}

.detail-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 14px;
    padding: 14px 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 4px;
    box-shadow: var(--shadow);
}

.detail-icon { font-size: 1.4rem; }

.detail-label { font-size: .75rem; color: var(--text-soft); }

.detail-value { font-size: 1rem; font-weight: 600; }

/* ---------- Hourly ---------- */

.hourly, .daily {
    margin-top: 26px;
}

.hourly h3, .daily h3 {
    font-size: 1rem;
    color: var(--text-soft);
    margin: 0 0 10px 2px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .03em;
}

.hourly-scroll {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    padding-bottom: 6px;
}

.hour-card {
    flex: 0 0 auto;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 14px;
    padding: 12px 14px;
    text-align: center;
    min-width: 68px;
    box-shadow: var(--shadow);
}

.hour-time { font-size: .78rem; color: var(--text-soft); }
.hour-icon { font-size: 1.6rem; margin: 6px 0; }
.hour-temp { font-weight: 600; }
.hour-precip { font-size: .72rem; color: var(--accent); margin-top: 4px; }

/* ---------- Daily ---------- */

.daily-list {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
}

.day-row {
    display: grid;
    grid-template-columns: 90px 40px 60px 1fr;
    align-items: center;
    padding: 12px 18px;
    gap: 10px;
}

.day-row + .day-row { border-top: 1px solid var(--card-border); }

.day-name { font-weight: 600; font-size: .92rem; }
.day-icon { font-size: 1.4rem; }
.day-precip { font-size: .8rem; color: var(--accent); }

.day-temps {
    display: flex;
    justify-content: flex-end;
    gap: 14px;
    font-weight: 600;
}

.day-temps .min { color: var(--text-soft); font-weight: 400; }

/* ---------- Footer ---------- */

.site-footer {
    max-width: 900px;
    margin: 0 auto 30px;
    padding: 0 16px;
    color: var(--text-soft);
    font-size: .8rem;
    text-align: center;
}

/* ---------- Loading ---------- */

.loading {
    text-align: center;
    padding: 60px 0;
    color: var(--text-soft);
    font-size: 1rem;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #10131f;
        --text: #eef1f8;
        --text-soft: #9aa3b8;
        --card-bg: #1a1f33;
        --card-border: rgba(255,255,255,0.08);
        --shadow: 0 10px 30px rgba(0,0,0,0.35);
    }
    .site-header { background: #151a2b; }
    .search-input { background: #1f2438; color: var(--text); }
    .search-input:focus { background: #232945; }
    .search-results { background: #1a1f33; }
    .search-result-item:hover, .search-result-item.active { background: #232945; }
    .chip { background: #1f2438; color: var(--text); }
}

@media (max-width: 480px) {
    .hero-temp { font-size: 2.8rem; }
    .hero-icon { font-size: 3rem; }
    .day-row { grid-template-columns: 70px 32px 50px 1fr; padding: 10px 14px; }
}
