:root {
  color-scheme: light;
  --bg: #f5f7fa;
  --panel: #ffffff;
  --panel-2: #eef1f5;
  --line: #dde3ea;
  --text: #1a2129;
  --muted: #5b6774;
  --accent: #1f7fb8;
  --accent-soft: #e4f2fa;
  --forecast: #b8720f;
  --forecast-soft: #fbeed9;
  --danger: #c23b34;
  --success: #2f9e5b;
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #10161d;
  --panel: #18212a;
  --panel-2: #202c37;
  --line: #334250;
  --text: #edf3f7;
  --muted: #9eabb6;
  --accent: #59c2e8;
  --accent-soft: #1c3a49;
  --forecast: #f0bd55;
  --forecast-soft: #3a2f18;
  --danger: #ef807d;
  --success: #54c783;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--text); font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
button, input { font: inherit; }
body { overflow: hidden; }

.app { height: 100vh; display: grid; grid-template-rows: auto auto minmax(0, 1fr); }

.topbar { min-height: 60px; padding: 10px 20px; display: flex; align-items: center; justify-content: space-between; gap: 16px; background: var(--panel); border-bottom: 1px solid var(--line); z-index: 1000; }
.eyebrow { margin: 0 0 2px; color: var(--accent); font-size: 10px; font-weight: 800; letter-spacing: 1.3px; }
h1 { margin: 0; font-size: 19px; line-height: 1.1; font-weight: 700; }
.topbar-actions { display: flex; align-items: center; gap: 12px; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--success); box-shadow: 0 0 0 3px color-mix(in srgb, var(--success) 18%, transparent); }
.status-dot.offline { background: var(--danger); box-shadow: 0 0 0 3px color-mix(in srgb, var(--danger) 18%, transparent); }
.theme-toggle { width: 36px; height: 36px; border-radius: 999px; border: 1px solid var(--line); background: var(--panel-2); color: var(--text); cursor: pointer; font-size: 16px; display: flex; align-items: center; justify-content: center; }
.theme-toggle:hover, .theme-toggle:focus-visible { border-color: var(--accent); outline: none; }

.tabs { display: flex; gap: 4px; padding: 8px 20px 0; background: var(--panel); border-bottom: 1px solid var(--line); }
.tab { padding: 10px 16px; border: none; background: none; color: var(--muted); font-size: 13px; font-weight: 600; cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.tab:hover:not(.active) { color: var(--text); }

.tab-panel { min-height: 0; overflow-y: auto; }

/* ---------- Previsao diaria (estilo AccuWeather, minimalista) ---------- */
.forecast-location-row { max-width: 720px; margin: 0 auto; padding: 12px 16px 0; display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.forecast-location { margin: 0; color: var(--muted); font-size: 12.5px; }
.forecast-location strong { color: var(--text); font-weight: 700; }
.city-select { padding: 6px 10px; border-radius: 7px; border: 1px solid var(--line); background: var(--panel-2); color: var(--text); font-size: 12.5px; max-width: 100%; }
.city-select:focus-visible { outline: none; border-color: var(--accent); }
.city-select optgroup { font-weight: 700; color: var(--text); }
.city-select option { font-weight: 400; color: var(--text); }
.forecast-legend { max-width: 720px; margin: 0 auto; padding: 8px 16px 0; display: flex; flex-wrap: wrap; gap: 6px 18px; }
.forecast-legend-item { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 11px; }
.forecast-legend .drop { color: var(--accent); font-size: 11px; }
.legend-bar { position: relative; display: inline-block; width: 34px; height: 4px; border-radius: 999px; background: var(--panel-2); }
.legend-bar-fill { position: absolute; inset: 0 30% 0 15%; border-radius: 999px; background: linear-gradient(90deg, var(--accent-soft), var(--accent)); }
.daily-list { display: flex; flex-direction: column; max-width: 720px; margin: 0 auto; padding: 10px 16px 24px; }
.day-block { border-bottom: 1px solid var(--line); }
.day-block:first-child { border-top: 1px solid var(--line); }

.day-row {
  width: 100%;
  display: grid;
  grid-template-columns: 68px 30px 46px 1fr 18px;
  align-items: center;
  gap: 12px;
  padding: 12px 6px;
  border: none;
  background: none;
  color: var(--text);
  text-align: left;
  cursor: pointer;
}
.day-row:hover { background: var(--panel-2); }
.day-row .day-name-wrap { display: flex; flex-direction: column; line-height: 1.3; }
.day-row .day-name { font-weight: 700; font-size: 13px; text-transform: capitalize; }
.day-row .day-date { color: var(--muted); font-size: 11px; }
.day-icon { font-size: 20px; text-align: center; }
.day-precip { display: flex; flex-direction: column; align-items: flex-start; gap: 1px; color: var(--accent); font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums; }
.day-precip-pct { display: flex; align-items: center; gap: 4px; }
.day-precip .drop { font-size: 11px; }
.day-precip.is-zero { color: var(--muted); font-weight: 400; }
.day-precip-mm { font-size: 10px; color: var(--forecast); font-weight: 600; }

.temp-range { display: flex; align-items: center; gap: 8px; }
.temp-min, .temp-max { font-size: 13px; font-variant-numeric: tabular-nums; color: var(--muted); flex: 0 0 auto; }
.temp-max { color: var(--text); font-weight: 600; }
.temp-bar-track { position: relative; flex: 1; height: 4px; border-radius: 999px; background: var(--panel-2); }
.temp-bar-fill { position: absolute; top: 0; bottom: 0; border-radius: 999px; background: linear-gradient(90deg, var(--accent-soft), var(--accent)); }

.chevron { color: var(--muted); font-size: 12px; transition: transform .15s; justify-self: end; }
.day-row[aria-expanded="true"] .chevron { transform: rotate(180deg); }

.hour-strip-wrap { overflow: hidden; max-height: 0; transition: max-height .2s ease; }
.hour-strip-wrap.open { max-height: 220px; }
.hour-strip { display: flex; gap: 2px; overflow-x: auto; padding: 4px 6px 16px; }
.hour-chip { flex: 0 0 66px; display: flex; flex-direction: column; align-items: center; gap: 5px; padding: 9px 4px; border-radius: 8px; }
.hour-chip.is-now { background: var(--accent-soft); }
.hour-time { font-size: 12px; color: var(--muted); }
.hour-icon { font-size: 19px; }
.hour-temp { font-size: 14.5px; font-weight: 600; font-variant-numeric: tabular-nums; }
.hour-precip { font-size: 12px; color: var(--accent); font-variant-numeric: tabular-nums; }
.hour-precip.is-zero { color: var(--muted); }
.hour-mm { font-size: 11px; color: var(--forecast); font-variant-numeric: tabular-nums; }

.note { max-width: 720px; margin: 0 auto; padding: 8px 22px 0; color: var(--muted); font-size: 11px; }
.message { margin: 8px 0 0; font-size: 13px; padding: 0 22px; }
.error { color: var(--danger); }

/* ---------- Radar (aba separada) ---------- */
#tab-radar:not([hidden]) { display: grid; grid-template-rows: minmax(0, 1fr) auto; }
.map-panel { min-height: 0; position: relative; background: #27323a; }
#map { width: 100%; height: 100%; background: #27323a; }
.leaflet-container { background: #27323a; font-family: inherit; }
.leaflet-control-zoom a { background: var(--panel); color: var(--text); border-color: var(--line); }
.leaflet-control-attribution { background: color-mix(in srgb, var(--panel) 85%, transparent) !important; color: var(--muted); }
.leaflet-control-attribution a { color: var(--accent); }
.map-caption { position: absolute; right: 14px; top: 14px; z-index: 500; max-width: calc(100% - 70px); padding: 8px 10px; background: rgba(16,22,29,.84); border: 1px solid rgba(255,255,255,.12); border-radius: 5px; color: #dbe6ec; font-size: 12px; pointer-events: none; }
.legend { position: absolute; z-index: 500; right: 14px; bottom: 14px; max-width: calc(100% - 28px); padding: 10px 12px 9px; background: rgba(16,22,29,.9); border: 1px solid rgba(255,255,255,.13); border-radius: 5px; }
.legend-title { margin: 0 0 7px; color: #9eabb6; font-size: 10px; text-transform: uppercase; letter-spacing: .8px; }
.legend-items { display: flex; gap: 10px; flex-wrap: wrap; }
.legend-item { display: grid; grid-template-columns: 12px auto; column-gap: 5px; align-items: center; font-size: 11px; color: #edf3f7; }
.legend-swatch { width: 12px; height: 12px; border-radius: 2px; }
.legend-value { color: #9eabb6; font-size: 10px; }

.timeline-panel { padding: 13px 20px 15px; background: var(--panel); border-top: 1px solid var(--line); z-index: 1000; }
.time-readout { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 10px; }
.frame-kind { display: block; color: var(--forecast); font-size: 11px; font-weight: 750; text-transform: uppercase; letter-spacing: .7px; }
.frame-kind.observed { color: var(--accent); }
#frame-time { display: block; margin-top: 2px; font-size: 21px; line-height: 1; }
.frame-date { color: var(--muted); font-size: 12px; }
.timeline-controls { display: flex; align-items: center; gap: 9px; }
.icon-button { width: 38px; height: 38px; flex: 0 0 38px; padding: 0; border: 1px solid var(--line); border-radius: 5px; background: var(--panel-2); color: var(--text); cursor: pointer; font-size: 22px; line-height: 1; }
.icon-button:hover, .icon-button:focus-visible { border-color: var(--accent); color: var(--accent); outline: none; }
.icon-button.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-size: 14px; }
.icon-button.primary:hover, .icon-button.primary:focus-visible { filter: brightness(1.1); }
.slider-wrap { position: relative; min-width: 0; flex: 1; height: 38px; display: flex; align-items: center; }
input[type="range"] { position: relative; z-index: 2; width: 100%; accent-color: var(--accent); cursor: pointer; }
.forecast-band { position: absolute; z-index: 1; height: 6px; top: 16px; border-radius: 3px; background: repeating-linear-gradient(135deg, color-mix(in srgb, var(--forecast) 72%, transparent) 0 4px, color-mix(in srgb, var(--forecast) 22%, transparent) 4px 8px); pointer-events: none; }
.opacity-control { width: 84px; display: flex; align-items: center; gap: 5px; color: var(--muted); font-size: 16px; }
.opacity-control input { width: 62px; accent-color: var(--accent); }
.timeline-labels { display: flex; justify-content: space-between; padding: 1px 0 0 152px; color: var(--muted); font-size: 10px; }
.timeline-labels .forecast-label { color: var(--forecast); }

@media (max-width: 560px) {
  .topbar { min-height: 54px; padding: 8px 14px; }
  h1 { font-size: 16px; }
  .tabs { padding: 6px 14px 0; }
  .day-row { grid-template-columns: 56px 26px 40px 1fr 14px; gap: 8px; padding: 10px 4px; }
  .map-caption { right: 9px; top: 9px; max-width: calc(100% - 65px); font-size: 10px; }
  .legend { right: 9px; bottom: 9px; padding: 8px; }
  .legend-items { gap: 6px 8px; }
  .legend-item { font-size: 10px; }
  .timeline-panel { padding: 10px 12px 12px; }
  .timeline-controls { gap: 6px; }
  .icon-button { width: 42px; height: 42px; flex-basis: 42px; }
  .timeline-labels { padding-left: 150px; }
}
