:root {
  --bg1: #1e3a5f;
  --bg2: #4a7fb5;
  --card: rgba(255, 255, 255, 0.14);
  --card-border: rgba(255, 255, 255, 0.22);
  --text: #fff;
  --muted: rgba(255, 255, 255, 0.72);
  --radius: 18px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { margin: 0; min-height: 100%; }

body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
  background: linear-gradient(160deg, var(--bg1), var(--bg2)) fixed;
  min-height: 100vh;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  transition: background 0.6s;
}

/* Thèmes selon la météo */
.theme-clear-day   { --bg1: #2b7bd6; --bg2: #8cc8f5; }
.theme-clear-night { --bg1: #0b1026; --bg2: #2c3e70; }
.theme-cloudy      { --bg1: #4b5866; --bg2: #8a99a8; }
.theme-rain        { --bg1: #27384a; --bg2: #557089; }
.theme-snow        { --bg1: #6f8aa3; --bg2: #c9d8e6; }
.theme-storm       { --bg1: #1d1f2e; --bg2: #4b4a6b; }
.theme-fog         { --bg1: #6c7680; --bg2: #b3bcc4; }

.muted { color: var(--muted); }

a { color: inherit; }

/* Barre du haut */
.topbar {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  max-width: 1100px;
  margin: 0 auto;
}

.search { position: relative; flex: 1; }

.search input {
  width: 100%;
  padding: 12px 16px;
  border-radius: 999px;
  border: 1px solid var(--card-border);
  background: var(--card);
  color: var(--text);
  font-size: 16px; /* évite le zoom auto sur iOS */
  outline: none;
  backdrop-filter: blur(12px);
}
.search input::placeholder { color: var(--muted); }
.search input:focus { border-color: #fff; }

.suggestions {
  position: absolute;
  top: calc(100% + 6px);
  left: 0; right: 0;
  margin: 0; padding: 6px;
  list-style: none;
  background: rgba(20, 30, 50, 0.96);
  border-radius: 14px;
  z-index: 10;
  box-shadow: 0 10px 30px rgba(0,0,0,.35);
}
.suggestions li {
  padding: 10px 12px;
  border-radius: 10px;
  cursor: pointer;
}
.suggestions li:hover, .suggestions li.active { background: rgba(255,255,255,.12); }
.suggestions small { color: var(--muted); }

.icon-btn {
  flex: none;
  width: 46px; height: 46px;
  border-radius: 50%;
  border: 1px solid var(--card-border);
  background: var(--card);
  color: var(--text);
  font-size: 20px;
  cursor: pointer;
  backdrop-filter: blur(12px);
}
.icon-btn:hover { background: rgba(255,255,255,.25); }

/* Favoris */
.favorites {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 0 16px 8px;
  max-width: 1100px;
  margin: 0 auto;
  scrollbar-width: none;
}
.favorites:empty { display: none; }
.chip {
  flex: none;
  padding: 6px 14px;
  border-radius: 999px;
  border: 1px solid var(--card-border);
  background: var(--card);
  color: var(--text);
  cursor: pointer;
  font-size: 14px;
}
.chip.active { background: rgba(255,255,255,.35); }

/* Bandeaux */
.banner {
  max-width: 1100px;
  margin: 0 auto 8px;
  padding: 8px 16px;
  text-align: center;
  font-size: 14px;
  background: rgba(0,0,0,.25);
}
.banner.error { background: rgba(180, 40, 40, .55); }

/* Mise en page principale */
main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 16px 16px;
  display: grid;
  gap: 16px;
}

.card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 18px;
  backdrop-filter: blur(14px);
  min-width: 0;
}
.card h2 {
  margin: 0 0 12px;
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
}

/* Météo actuelle */
.current-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.current-head h1 { margin: 0; font-size: 26px; }
.current-head p { margin: 4px 0 0; font-size: 13px; }

.current-main { display: flex; align-items: center; gap: 18px; margin: 14px 0 18px; }
.big-icon { font-size: 84px; line-height: 1; }
.big-temp { font-size: 68px; font-weight: 200; line-height: 1; }
#current-desc { font-size: 18px; margin-top: 4px; }

.details {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin: 0;
}
.details div {
  background: rgba(255,255,255,.08);
  border-radius: 12px;
  padding: 10px 12px;
}
.details dt { font-size: 12px; color: var(--muted); }
.details dd { margin: 4px 0 0; font-size: 16px; font-weight: 500; }

/* En-tête de carte avec bascule Graphe / Liste */
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 12px; }
.card-head h2 { margin: 0; }
.seg { display: inline-flex; background: rgba(0,0,0,.18); border-radius: 999px; padding: 3px; }
.seg button {
  border: 0; background: transparent; color: var(--muted);
  padding: 5px 12px; border-radius: 999px; font-size: 13px; cursor: pointer;
}
.seg button[aria-pressed="true"] { background: rgba(255,255,255,.25); color: var(--text); }

/* Graphe horaire */
.hourly-chart { position: relative; }
.hourly-chart svg { display: block; width: 100%; touch-action: pan-y; user-select: none; }
.hourly-chart .axis { fill: var(--muted); font-size: 11px; }
.hourly-chart .panel-label { fill: var(--muted); font-size: 11px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; }
.hourly-chart .grid { stroke: rgba(255,255,255,.15); stroke-width: 1; }
.hourly-chart .value { fill: var(--text); font-size: 12px; font-weight: 600; }
.chart-tip {
  position: absolute; top: 0;
  transform: translateX(-50%);
  background: rgba(15, 25, 45, .92);
  border-radius: 10px;
  padding: 6px 10px;
  font-size: 13px;
  white-space: nowrap;
  pointer-events: none;
  box-shadow: 0 6px 18px rgba(0,0,0,.3);
}

/* Horaire */
.hourly {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 6px;
  scroll-snap-type: x proximity;
}
.hour {
  flex: none;
  width: 64px;
  text-align: center;
  padding: 10px 4px;
  border-radius: 14px;
  scroll-snap-align: start;
}
.hour.now { background: rgba(255,255,255,.18); }
.hour .h-time { font-size: 13px; color: var(--muted); }
.hour .h-icon { font-size: 26px; margin: 6px 0; }
.hour .h-temp { font-size: 17px; font-weight: 500; }
.hour .h-rain { font-size: 11px; color: #9fd3ff; min-height: 14px; }

/* 7 jours */
.daily { list-style: none; margin: 0; padding: 0; }
.day {
  display: grid;
  grid-template-columns: 90px 36px 62px 40px 1fr 40px;
  align-items: center;
  gap: 8px;
  padding: 10px 0;
  border-top: 1px solid rgba(255,255,255,.12);
}
.day:first-child { border-top: none; }
.day .d-name { font-weight: 500; }
.day .d-icon { font-size: 24px; text-align: center; }
.day .d-rain { font-size: 12px; color: #9fd3ff; }
.day .d-min { text-align: right; color: var(--muted); }
.day .d-max { text-align: left; }
.range {
  position: relative;
  height: 6px;
  border-radius: 3px;
  background: rgba(255,255,255,.15);
}
.range span {
  position: absolute;
  top: 0; bottom: 0;
  border-radius: 3px;
  background: linear-gradient(90deg, #7cc4ff, #ffd36b, #ff8a5c);
}

.footer { text-align: center; font-size: 12px; padding: 8px 16px 24px; }

/* Écrans larges : 2 colonnes */
@media (min-width: 900px) {
  main { grid-template-columns: 1fr 1fr; }
  .current { grid-row: span 1; }
  main > section:nth-child(2) { grid-column: 1 / -1; order: 3; }
}

@media (max-width: 420px) {
  .details { grid-template-columns: repeat(2, 1fr); }
  .day { grid-template-columns: 66px 30px 54px 30px 1fr 32px; gap: 6px; }
  .big-icon { font-size: 68px; }
  .big-temp { font-size: 58px; }
}

/* Icônes météo SVG */
.wi { display: block; width: 100%; height: 100%; filter: drop-shadow(0 2px 4px rgba(0,0,0,.18)); }
.big-icon { width: 104px; height: 104px; flex: none; }
.big-icon .wi { filter: drop-shadow(0 4px 10px rgba(0,0,0,.22)); }
.h-icon { width: 36px; height: 36px; margin: 4px auto !important; }
.d-icon { width: 32px; height: 32px; justify-self: center; }
.chart-tip .wi { display: inline-block; width: 20px; height: 20px; vertical-align: -5px; filter: none; }
.drop { display: inline-block; width: 11px; height: 11px; vertical-align: -1px; margin-right: 2px; }
@media (max-width: 420px) { .big-icon { width: 84px; height: 84px; } }

/* Icônes d'interface */
.icon-btn { display: inline-flex; align-items: center; justify-content: center; }
.ui-icon { width: 22px; height: 22px; }
.big-icon .ui-icon { width: 100%; height: 100%; padding: 22%; opacity: .85; }
.spin { animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Infos ajoutées : alerte pluie, sous-lignes, qualité de l'air, pluie en mm */
.rain-alert {
  display: flex; align-items: center; gap: 6px;
  margin: -4px 0 14px;
  padding: 8px 12px;
  border-radius: 12px;
  background: rgba(255,255,255,.08);
  font-size: 14px;
}
.rain-alert:empty { display: none; }
.rain-alert.wet { background: rgba(91, 180, 255, .22); }
.rain-alert .drop { width: 14px; height: 14px; flex: none; }
.details .wide { grid-column: span 2; }
.details .full { grid-column: 1 / -1; }
.details dd small { display: block; font-size: 12px; font-weight: 400; color: var(--muted); margin-top: 2px; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; vertical-align: 0; box-shadow: 0 0 0 2px rgba(255,255,255,.35); }
.day .d-rain { display: flex; flex-direction: column; line-height: 1.25; }
.day .d-rain small { color: var(--muted); font-size: 11px; }
.hour .h-wind { font-size: 11px; color: var(--muted); }
.chart-tip { line-height: 1.5; }

/* Mode mini */
body.mini-mode .topbar,
body.mini-mode .favorites,
body.mini-mode main,
body.mini-mode .footer { display: none; }
.mini-view { max-width: 420px; margin: 24px auto; padding: 0 16px; display: grid; gap: 12px; justify-items: center; }
.mini-view .mini-card { width: 100%; }
.mini-card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 14px 16px;
  backdrop-filter: blur(14px);
}
.mini-top { display: flex; justify-content: space-between; font-size: 14px; }
.mini-city { font-weight: 600; }
.mini-time { color: var(--muted); font-size: 12px; }
.mini-main { display: flex; align-items: center; gap: 10px; margin: 6px 0 8px; }
.mini-icon { width: 56px; height: 56px; flex: none; }
.mini-temp { font-size: 44px; font-weight: 200; line-height: 1; }
.mini-desc { font-size: 14px; }
.mini-desc small { display: block; color: var(--muted); font-size: 12px; }
.mini-alert { display: flex; align-items: center; gap: 4px; font-size: 12px; color: var(--muted); }
.mini-alert.wet { color: #cfe8ff; }
.mini-alert .drop { width: 12px; height: 12px; flex: none; }
.mini-hours { display: grid; grid-template-columns: repeat(5, 1fr); text-align: center; margin-top: 10px; font-size: 12px; }
.mini-hours .wi { width: 26px; height: 26px; margin: 2px auto; }
.mini-h { color: var(--muted); }
.mini-loading { padding: 24px; text-align: center; color: var(--muted); }

/* Fenêtre mini toujours au premier plan (PC) : la carte remplit la fenêtre */
body.pip { padding: 0; min-height: 100vh; }
body.pip .mini-card { border: 0; border-radius: 0; background: transparent; backdrop-filter: none; min-height: 100vh; }
