:root {
    font-family: Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
    color: #12213f;
    --page-a: #dff4ff;
    --page-b: #f5f9ff;
    --glow: rgba(77, 177, 255, .35);
    --card: rgba(255, 255, 255, .9);
    --metric: rgba(246, 249, 253, .9);
    --muted: #64748b;
    --accent: #1f5eff;
    --border: rgba(255, 255, 255, .65);
    --shadow: rgba(29, 49, 92, .12);
}

* { box-sizing: border-box; }

body {
    min-height: 100vh;
    margin: 0;
    color: #12213f;
    background:
        radial-gradient(circle at 82% 6%, var(--glow), transparent 34rem),
        linear-gradient(145deg, var(--page-a), var(--page-b));
    background-attachment: fixed;
    transition: background 700ms ease, color 500ms ease;
}

body[data-theme="day"] {
    --page-a: #cdefff;
    --page-b: #f7fbff;
    --glow: rgba(255, 224, 104, .52);
    --accent: #1768d5;
}

body[data-theme="afternoon"] {
    --page-a: #ffd5a5;
    --page-b: #f6e3ee;
    --glow: rgba(255, 103, 72, .36);
    --accent: #b84d24;
    --shadow: rgba(94, 43, 40, .16);
}

body[data-theme="night"] {
    color: #f4f7ff;
    --page-a: #07142e;
    --page-b: #18264a;
    --glow: rgba(93, 111, 255, .3);
    --card: rgba(15, 29, 57, .88);
    --metric: rgba(255, 255, 255, .075);
    --muted: #b7c3db;
    --accent: #91adff;
    --border: rgba(255, 255, 255, .1);
    --shadow: rgba(0, 0, 0, .3);
}

.app { max-width: 760px; margin: auto; padding: 24px; }
.top { display: flex; justify-content: space-between; align-items: center; gap: 16px; }
.top strong { font-size: 1.12rem; }
.muted { color: var(--muted); }

.badge,
.period {
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 999px;
    color: var(--accent);
    background: var(--card);
    font-size: 13px;
    white-space: nowrap;
    backdrop-filter: blur(12px);
}

.card {
    margin: 18px 0;
    padding: 24px;
    border: 1px solid var(--border);
    border-radius: 24px;
    background: var(--card);
    box-shadow: 0 16px 42px var(--shadow);
    backdrop-filter: blur(16px);
}

.location-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.eyebrow { color: var(--muted); font-size: 12px; font-weight: 800; letter-spacing: .09em; text-transform: uppercase; }
.location { margin: 4px 0 18px; font-size: clamp(1.25rem, 4vw, 1.7rem); line-height: 1.15; }
.location-accuracy { display: block; margin: -14px 0 18px; }
.temp { font-size: 64px; font-weight: 800; letter-spacing: -4px; }
.weather-summary { display: grid; grid-template-columns: 1fr minmax(190px, .72fr); align-items: center; gap: 18px; margin-bottom: 20px; }
.weather-summary h2 { margin-bottom: 0; }
.weather-visual { min-height: 190px; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 18px; border: 1px solid var(--border); border-radius: 22px; background: linear-gradient(145deg, #dff3ff, #fff4c7); text-align: center; box-shadow: inset 0 1px 0 #fff9; }
.weather-visual[data-kind="hot"] { background: linear-gradient(145deg, #ffe0a3, #ff9b71); color: #68270f; }
.weather-visual[data-kind="very-hot"] { background: linear-gradient(145deg, #ffba72, #f15a4f); color: #fff; }
.weather-visual[data-kind="cool"] { background: linear-gradient(145deg, #dff5ff, #c8dbf5); color: #183d64; }
.weather-visual[data-kind="cold"] { background: linear-gradient(145deg, #dff8ff, #9ac5ec); color: #11304e; }
.weather-visual[data-kind="rain"] { background: linear-gradient(145deg, #b6cce5, #637ba2); color: #fff; }
.weather-visual[data-kind="storm"] { background: linear-gradient(145deg, #6f7597, #2d3154); color: #fff; }
.weather-visual[data-kind="cloudy"] { background: linear-gradient(145deg, #e8edf3, #bdc7d5); color: #344258; }
.weather-visual-icon { display: block; font-size: 4.8rem; line-height: 1; filter: drop-shadow(0 8px 12px #0002); }
.weather-visual strong { margin-top: 10px; font-size: 1.15rem; }
.weather-visual small { margin-top: 4px; opacity: .85; }
.grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.metric { padding: 14px; border-radius: 16px; background: var(--metric); }
.actions { display: flex; gap: 10px; flex-wrap: wrap; }

button {
    padding: 12px 16px;
    border: 0;
    border-radius: 14px;
    color: white;
    background: var(--accent);
    font-weight: 700;
    cursor: pointer;
}

button.secondary { color: inherit; background: var(--card); }
button:disabled { cursor: not-allowed; opacity: .55; }
.action-status { min-height: 1.25rem; margin: 8px 2px 0; font-size: .86rem; }
.hour { display: grid; grid-template-columns: 1.3fr 1fr 1fr; gap: 8px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.map-credit { margin: 10px 0 32px; font-size: 11px; text-align: center; }
.map-credit a { color: var(--muted); }

.weather-advice { display: flex; gap: 14px; align-items: center; margin: 18px 0; padding: 16px 18px; border: 1px solid var(--border); border-radius: 18px; background: var(--card); box-shadow: 0 12px 30px var(--shadow); }
.place-search { position: relative; margin: 20px 0 12px; padding: 16px; border: 1px solid var(--border); border-radius: 18px; background: var(--card); box-shadow: 0 12px 30px var(--shadow); }
.place-search label { display: block; margin-bottom: 8px; font-size: .82rem; font-weight: 800; }
.search-row { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 8px; }
.search-row input { min-width: 0; padding: 12px 14px; border: 1px solid var(--border); border-radius: 12px; color: inherit; background: var(--metric); font: inherit; outline: none; }
.search-row input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent); }
.place-results { position: absolute; z-index: 20; top: calc(100% - 8px); left: 16px; right: 16px; padding: 8px; border: 1px solid var(--border); border-radius: 14px; background: var(--card); box-shadow: 0 18px 42px var(--shadow); backdrop-filter: blur(18px); }
.place-option { display: block; width: 100%; padding: 11px 12px; color: inherit; background: transparent; text-align: left; }
.place-option:hover, .place-option:focus { background: var(--metric); }
.place-option strong, .place-option small { display: block; }
.place-option small { margin-top: 3px; color: var(--muted); font-weight: 400; }
.weather-advice[data-level="rain"] { background: linear-gradient(135deg, rgba(39, 99, 235, .92), rgba(62, 55, 183, .92)); color: white; }
.weather-advice[data-level="watch"] { background: linear-gradient(135deg, rgba(255, 190, 78, .92), rgba(255, 137, 65, .92)); color: #49230e; }
.advice-icon { font-size: 2rem; }
.weather-advice p { margin: 3px 0 0; font-size: .9rem; }
.section-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.section-head h2 { margin: 4px 0 14px; }
.metric small { display: block; margin-top: -10px; min-height: 1rem; }

#hours { display: flex; gap: 10px; padding: 4px 0 10px; overflow-x: auto; scroll-snap-type: x proximity; }
.hour { min-width: 170px; display: flex; flex-direction: column; gap: 7px; padding: 13px; border: 1px solid var(--border); border-radius: 15px; background: var(--metric); scroll-snap-align: start; }
.hour-weather { font-size: 1.45rem; }
.hour-rain { color: var(--accent); font-size: .82rem; }

.radar-map { position: relative; height: 340px; overflow: hidden; border-radius: 18px; background: #b9d5e8; isolation: isolate; }
.map-layer { position: absolute; inset: 0; transform-origin: 50% 50%; transition: transform .2s ease; }
.map-layer img { position: absolute; width: 256px; height: 256px; max-width: none; }
.radar-layer { z-index: 2; opacity: .72; }
.map-marker { position: absolute; z-index: 4; left: 50%; top: 50%; width: 17px; height: 17px; margin: -8px; border: 3px solid white; border-radius: 50%; background: #ed2f42; box-shadow: 0 1px 8px #0008; }
.map-empty { position: absolute; z-index: 5; inset: auto 14px 14px; padding: 8px 10px; border-radius: 10px; color: #fff; background: #12213fcc; font-size: .8rem; text-align: center; }
.radar-time { color: var(--muted); font-size: .8rem; }
.radar-actions, .radar-zoom { display: flex; align-items: center; gap: 8px; }
.radar-actions { justify-content: flex-end; flex-wrap: wrap; }
.radar-zoom { justify-content: center; margin-top: 10px; }
.radar-zoom output { min-width: 52px; text-align: center; font-weight: 700; }
.radar-map.is-expanded { position: fixed; z-index: 1000; inset: 12px; width: auto; height: auto; border-radius: 20px; box-shadow: 0 20px 70px #0009; }
body.radar-expanded { overflow: hidden; }
body.radar-expanded .radar-actions { position: fixed; z-index: 1002; top: 24px; right: 24px; }
body.radar-expanded #radarExpand { color: #fff; background: #17233f; }
.radar-legend { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 10px; color: var(--muted); font-size: .76rem; }
.radar-legend span { display: inline-flex; align-items: center; gap: 5px; }
.radar-legend i { width: 13px; height: 13px; border-radius: 4px; }
.radar-legend .rain-light { background: #35a7ff; }
.radar-legend .rain-medium { background: #ffd23f; }
.radar-legend .rain-heavy { background: #ef3340; }
.radar-legend strong { margin-left: auto; color: inherit; }
.radar-legend strong[data-state="ok"] { color: #237a48; }
.radar-legend strong[data-state="error"] { color: #b43b32; }
.radar-controls { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 8px; margin-top: 12px; }
.radar-controls input { width: 100%; accent-color: var(--accent); }
button.tiny { padding: 7px 12px; border-radius: 10px; }
button.text-button { color: var(--accent); background: transparent; }

.daily-table { overflow-x: auto; }
.day-row { min-width: 760px; display: grid; grid-template-columns: 1.15fr 1.35fr .8fr 1.35fr 1.1fr .55fr; align-items: center; gap: 8px; padding: 11px 8px; border-bottom: 1px solid var(--border); }
.day-row.today { border-radius: 12px; background: var(--metric); font-weight: 700; }
.day-date small, .history-row small { display: block; color: var(--muted); font-weight: 400; }
.history { display: grid; gap: 8px; }
.history-row { display: grid; grid-template-columns: 1.5fr .7fr 1fr; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 13px; background: var(--metric); }

@media (max-width: 520px) {
    .app { padding: 16px; }
    .top { align-items: flex-start; }
    .badge { max-width: 48%; overflow: hidden; text-overflow: ellipsis; }
    .temp { font-size: 54px; }
    .grid { grid-template-columns: 1fr; }
    .weather-summary { grid-template-columns: 1fr; }
    .weather-visual { min-height: 155px; }
    .radar-map { height: 280px; }
    .radar-map.is-expanded { inset: 6px; height: auto; border-radius: 14px; }
    .history-row { grid-template-columns: 1fr auto; }
    .history-row .history-condition { grid-column: 1 / -1; }
    .search-row { grid-template-columns: 1fr auto; }
    .search-row input { grid-column: 1 / -1; }
}
