*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --bg: #f0f4f8; --surface: #ffffff; --surface2: #f7f9fb;
  --border: rgba(0,0,0,0.08); --text: #1a202c; --muted: #718096;
  --accent: #2563eb; --radius: 16px; --shadow: 0 2px 12px rgba(0,0,0,0.07);
  --font-display: 'Bebas Neue', sans-serif; --font-body: 'DM Sans', sans-serif;
  --col-green: #dcfce7; --col-yellow: #fef9c3; --col-red: #fca5a5;
  --col-green-light: #f0fdf4; --col-yellow-light: #fefce8; --col-red-light: #fee2e2;
  --col-green-border: #86efac; --col-yellow-border: #fde047; --col-red-border: #fca5a5;
  --col-green-text: #166534; --col-yellow-text: #854d0e; --col-red-text: #991b1b;
}
body { background: var(--bg); color: var(--text); font-family: var(--font-body); min-height: 100vh; display: flex; flex-direction: column; align-items: center; }
body::before { content: ''; position: fixed; inset: 0; background: radial-gradient(ellipse 70% 40% at 10% 0%, rgba(37,99,235,0.05) 0%, transparent 60%), radial-gradient(ellipse 50% 50% at 90% 100%, rgba(22,163,74,0.04) 0%, transparent 60%); pointer-events: none; z-index: 0; }
.container { width: 100%; max-width: 560px; padding: 0 12px 60px; position: relative; z-index: 1; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
header { margin-left: -12px; margin-right: -12px; }

/* Header */
header {
  text-align: left;
  padding: 20px 20px 16px;
  margin-bottom: 8px;
  background: #ffffff;
  border-bottom: 1px solid #e2e8f0;
  border-radius: 0 0 16px 16px;
  position: relative;
  overflow: hidden;
  box-shadow: 0 2px 12px rgba(0,0,0,0.06);
}
header::before {
  content: none;
}
.header-inner {
  position: relative;
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 16px;
}
.header-icon-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
}
.header-logo {
  height: 100px;
  width: auto;
}
.header-brand {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.header-wordmark {
  font-family: var(--font-display);
  font-size: clamp(48px, 10vw, 64px);
  line-height: 1;
  letter-spacing: 2px;
  color: #5e6166;
  white-space: nowrap;
}
.header-wordmark .wtr-green { color: #a7d638; }
.header-sub {
  font-size: 10px;
  color: #94a3b8;
  letter-spacing: 2px;
  text-transform: uppercase;
  font-weight: 500;
}
.header-loc {
  display: none;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 3px;
  font-size: 11px;
  font-weight: 600;
  color: #334155;
  max-width: 120px;
  overflow: hidden;
}
.header-loc.visible { display: flex; }

/* Cards */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; margin-bottom: 12px; box-shadow: var(--shadow); animation: fadeUp 0.35s ease both; }
@keyframes fadeUp { from { opacity:0; transform:translateY(12px); } to { opacity:1; transform:translateY(0); } }
.section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.section-label { font-size: 11px; text-transform: uppercase; letter-spacing: 1.4px; color: var(--muted); font-weight: 600; }
#status-msg { font-size: 14px; color: var(--muted); line-height: 1.6; }

/* Autocomplete */
.city-form { position: relative; margin-top: 12px; }
.city-input { width: 100%; background: var(--surface2); border: 1.5px solid var(--border); border-radius: 10px; padding: 11px 15px; color: var(--text); font-family: var(--font-body); font-size: 15px; outline: none; transition: border-color 0.2s; }
.city-input:focus { border-color: var(--accent); }
.city-input::placeholder { color: #a0aec0; }
.ac-dropdown { position: absolute; top: calc(100% + 5px); left: 0; right: 0; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; z-index: 200; box-shadow: 0 8px 32px rgba(0,0,0,0.12); display: none; }
.ac-dropdown.open { display: block; }
.ac-item { padding: 10px 15px; cursor: pointer; border-bottom: 1px solid var(--border); transition: background 0.1s; display: flex; flex-direction: column; gap: 1px; }
.ac-item:last-child { border-bottom: none; }
.ac-item:hover, .ac-item.active { background: #eff6ff; }
.ac-city { font-size: 14px; font-weight: 500; }
.ac-region { font-size: 12px; color: var(--muted); }
.ac-empty { padding: 13px 15px; font-size: 13px; color: var(--muted); text-align: center; }

/* Loading spinner */
#loading-spinner { display: none; flex-direction: column; align-items: center; justify-content: center; gap: 14px; padding: 48px 0; }
#loading-spinner.visible { display: flex; }
.spinner-ring { width: 40px; height: 40px; border: 3px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.75s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.spinner-text { font-size: 13px; color: var(--muted); }

/* Map */
#weather-strip { display: none; }
.map-card { padding: 0; overflow: hidden; border-radius: var(--radius); border: 1px solid var(--border); box-shadow: var(--shadow); margin-bottom: 12px; animation: fadeUp 0.35s ease both; }
.map-container { position: relative; width: 100%; height: 220px; overflow: hidden; cursor: pointer; transition: height 0.35s ease; background: #e8eef4; }
.map-container.expanded { height: 420px; cursor: pointer; }
#map-canvas { display: block; width: 100%; height: 100%; }
.map-overlay-center { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); z-index: 20; pointer-events: none; display: flex; flex-direction: column; align-items: center; gap: 5px; }
.map-overlay-pill { background: rgba(255,255,255,0.96); border-radius: 20px; padding: 5px 13px; font-size: 13px; font-weight: 700; box-shadow: 0 2px 10px rgba(0,0,0,0.18); white-space: nowrap; display: flex; align-items: center; gap: 6px; }
.overlay-green  { color: var(--col-green-text); }
.overlay-yellow { color: var(--col-yellow-text); }
.overlay-red    { color: var(--col-red-text); }
.map-expand-hint { position: absolute; bottom: 10px; left: 50%; transform: translateX(-50%); z-index: 20; background: rgba(255,255,255,0.88); border-radius: 20px; padding: 3px 12px; font-size: 11px; color: var(--muted); font-weight: 500; box-shadow: 0 1px 6px rgba(0,0,0,0.1); pointer-events: none; transition: opacity 0.3s; }
.map-hint-collapsed { display: block; }
.map-hint-expanded  { display: none; }
.map-container.expanded .map-hint-collapsed { display: none; }
.map-container.expanded .map-hint-expanded  { display: block; }
.map-credit { position: absolute; bottom: 4px; right: 8px; font-size: 10px; color: rgba(0,0,0,0.35); z-index: 15; pointer-events: none; }
.retry-link { font-size: 12px; color: var(--accent); background: none; border: none; cursor: pointer; font-family: var(--font-body); text-decoration: underline; padding: 0; }

/* Forecast grids */
.forecast-outer { overflow-x: auto; overflow-y: visible; scrollbar-width: none; padding-bottom: 14px; }
.forecast-outer::-webkit-scrollbar { display: none; }
.forecast-grid { display: flex; min-width: max-content; }
.forecast-labels { display: flex; flex-direction: column; flex: 0 0 90px; position: sticky; left: 0; z-index: 5; background: var(--surface); border-right: 1px solid rgba(0,0,0,0.08); }
.forecast-label-cell { height: 36px; display: flex; align-items: center; padding: 0 4px 0 0; font-size: 11px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.7px; border-bottom: 1px solid var(--border); }
.forecast-label-cell.hdr { height: 32px; padding-right: 8px; }
.forecast-label-cell:last-child { border-bottom: none; }
.forecast-cols { display: flex; flex: 1; }
.forecast-col { flex: 1; min-width: 0; display: flex; flex-direction: column; border-left: 1px solid rgba(0,0,0,0.06); background: var(--card); }
.forecast-col:first-child { border-left: none; }
.forecast-col.col-green  .forecast-cell.hdr { background: var(--col-green); }
.forecast-col.col-yellow .forecast-cell.hdr { background: var(--col-yellow); }
.forecast-col.col-red    .forecast-cell.hdr { background: var(--col-red); }
.forecast-col.col-now    { box-shadow: inset 0 0 0 2px rgba(37,99,235,0.4); }
.forecast-col.col-selected { box-shadow: inset 0 0 0 2px rgba(37,99,235,0.7); filter: brightness(0.93); cursor: pointer; position: relative; overflow: visible; }
.forecast-col.col-selected::after {
  content: '';
  position: absolute;
  bottom: -14px;
  left: 0;
  width: 100%;
  height: 14px;
  background: rgba(37,99,235,0.45);
  clip-path: polygon(0 0, 100% 0, 50% 100%);
  z-index: 2;
}
.forecast-col { cursor: pointer; transition: filter 0.15s; }
.forecast-col:hover { filter: brightness(0.96); }
.forecast-cell { height: 36px; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 500; border-bottom: 1px solid rgba(0,0,0,0.05); padding: 0 3px; white-space: nowrap; }
.forecast-cell:last-child { border-bottom: none; }
.forecast-cell.hdr { height: 36px; font-size: 11px; font-weight: 700; color: var(--text); }
.forecast-col.col-now .forecast-cell.hdr { color: var(--accent); }
.forecast-label-cell.hdr { height: 36px; }
.val-good { color: var(--col-green-text); background: var(--col-green-light); }
.val-warn { color: var(--col-yellow-text); background: var(--col-yellow-light); }
.val-bad  { color: var(--col-red-text); background: var(--col-red-light); font-weight: 650; }

#hourly-temp-label { cursor: pointer; user-select: none; color: var(--accent); }
#hourly-temp-label:hover { opacity: 0.75; }

/* Legend */
.legend { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.legend-item { display: flex; align-items: center; gap: 4px; font-size: 11px; color: var(--muted); }
.legend-dot { width: 9px; height: 9px; border-radius: 3px; flex-shrink: 0; }

/* Score */
.score-wrap { display: flex; flex-direction: column; align-items: center; padding: 16px 0 8px; }
.score-ring { width: 110px; height: 110px; position: relative; margin-bottom: 12px; }
.score-ring svg { transform: rotate(-90deg); }
.score-ring .track { fill: none; stroke: #e2e8f0; stroke-width: 8; }
.score-ring .fill  { fill: none; stroke-width: 8; stroke-linecap: round; transition: stroke-dashoffset 1s ease, stroke 0.5s; }
#section-score, #weekly-score-section, #section-tips { transition: opacity 0.15s ease; }
.score-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.score-num { font-family: var(--font-display); font-size: 40px; line-height: 1; }
.score-sub { font-size: 10px; color: var(--muted); letter-spacing: 1px; text-transform: uppercase; }
.condition-badge { font-family: var(--font-display); font-size: 20px; letter-spacing: 3px; margin-bottom: 4px; }
.condition-sub { font-size: 13px; color: var(--muted); text-align: center; max-width: 340px; line-height: 1.5; }

/* Tips */
.tip-list { list-style: none; display: flex; flex-direction: column; gap: 9px; }
.tip-list li { display: flex; gap: 10px; align-items: flex-start; font-size: 13px; line-height: 1.5; }
.tip-list li span:first-child { font-size: 17px; flex-shrink: 0; margin-top: 1px; }

.pulse { animation: pulse 1.5s ease-in-out infinite; }
@keyframes pulse { 0%,100% { opacity:1; } 50% { opacity:0.35; } }
