:root {
  --bg: #0b1e33;
  --bg-card: #142c47;
  --text: #eaf2fa;
  --muted: #93a9c2;
  --accent: #4fa3d1;
  --vert: #35c46a;
  --bleu: #4fa3d1;
  --jaune: #e8d84a;
  --orange: #f2a93b;
  --rouge: #e5544d;
  --radius: 14px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: linear-gradient(180deg, var(--bg) 0%, #081522 100%);
  color: var(--text);
  padding-bottom: 40px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px 10px;
}
.topbar h1 { margin: 0; font-size: 1.4rem; }
.subtitle { color: var(--muted); font-size: 0.85rem; }
.topbar-actions { display: flex; gap: 10px; }

#refresh-btn, .connect-btn {
  background: var(--bg-card);
  border: none;
  color: var(--text);
  font-size: 1.3rem;
  width: 44px; height: 44px;
  border-radius: 50%;
  cursor: pointer;
}
.connect-btn.connected { box-shadow: 0 0 0 2px var(--vert); }

.mode-switch-wrap {
  max-width: 640px;
  margin: 0 auto;
  padding: 0 16px 4px;
}
.spot-select {
  width: 100%;
  background: var(--bg-card);
  color: var(--text);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 999px;
  padding: 12px 16px;
  font-size: 0.95rem;
  font-weight: 600;
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%2393a9c2'><path d='M7 10l5 5 5-5z'/></svg>");
  background-repeat: no-repeat;
  background-position: right 14px center;
  background-size: 20px;
}
.mode-status {
  color: var(--muted);
  font-size: 0.8rem;
  margin: 8px 2px 0;
}
.mode-status.error { color: var(--rouge); }
.mode-status.hidden { display: none; }

.lake-only.hidden-mode { display: none; }

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 50;
}
.modal.hidden { display: none; }

.modal-content {
  background: var(--bg-card);
  width: 100%;
  max-width: 640px;
  border-radius: 18px 18px 0 0;
  padding: 20px;
  max-height: 85vh;
  overflow-y: auto;
}
@media (min-width: 700px) {
  .modal { align-items: center; }
  .modal-content { border-radius: 18px; }
}

.modal-header { display: flex; justify-content: space-between; align-items: center; }
.modal-header h2 { margin: 0; font-size: 1.1rem; }
.modal-close {
  background: none; border: none; color: var(--text);
  font-size: 1.2rem; cursor: pointer;
}

.modal-intro { color: var(--muted); font-size: 0.85rem; line-height: 1.5; }
.modal-intro a { color: var(--accent); }

.token-block {
  border-top: 1px solid rgba(255,255,255,0.08);
  padding-top: 14px;
  margin-top: 14px;
}
.token-block label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 8px;
}
.badge-status {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 10px;
  background: var(--muted);
  color: #0b1e33;
}
.badge-status.ok { background: var(--vert); }
.badge-status.error { background: var(--rouge); color: #fff; }

.token-row { display: flex; gap: 8px; }
.token-row input {
  flex: 1;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.15);
  background: #0b1e33;
  color: var(--text);
  font-size: 0.9rem;
}
.btn-primary {
  background: var(--accent);
  border: none;
  color: #fff;
  padding: 0 14px;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  font-size: 0.85rem;
  white-space: nowrap;
}
.btn-primary:disabled { opacity: 0.6; cursor: default; }

.token-msg { font-size: 0.8rem; margin: 8px 0 0; min-height: 1em; }
.token-msg.ok { color: var(--vert); }
.token-msg.error { color: var(--rouge); }
.token-note { color: var(--muted); font-size: 0.75rem; margin-top: 6px; }

main {
  max-width: 640px;
  margin: 0 auto;
  padding: 0 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: 0 4px 14px rgba(0,0,0,0.25);
}
.card h2 { margin: 0 0 12px; font-size: 1rem; color: var(--muted); font-weight: 600; }

.current-card { display: flex; flex-direction: column; gap: 14px; }
.current-main { display: flex; align-items: center; gap: 16px; }

.nav-badge {
  min-width: 90px;
  padding: 10px 14px;
  border-radius: 12px;
  text-align: center;
  font-weight: 700;
  font-size: 0.85rem;
  background: var(--muted);
}
.nav-badge.bleu { background: var(--bleu); }
.nav-badge.vert { background: var(--vert); color: #062b14; }
.nav-badge.jaune { background: var(--jaune); color: #3a2500; }
.nav-badge.orange { background: var(--orange); color: #3a2500; }
.nav-badge.rouge { background: var(--rouge); }
.nav-badge.inconnu { background: var(--muted); color: #0b1e33; }

.storm-current {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 12px;
}
.storm-cape { color: var(--muted); font-size: 0.9rem; }

.current-values { flex: 1; }
.big-value { font-size: 2.4rem; font-weight: 700; }
.big-value small { font-size: 1rem; color: var(--muted); }
.sub-value { color: var(--muted); font-size: 0.9rem; }

.wind-rose-wrap { flex-shrink: 0; }

.mini-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  border-top: 1px solid rgba(255,255,255,0.08);
  padding-top: 14px;
}
.mini-item { font-size: 0.9rem; color: var(--muted); }
.mini-item span { color: var(--text); font-weight: 600; }

.nav-timeline {
  display: flex;
  gap: 3px;
  overflow-x: auto;
  padding-top: 12px;
  padding-bottom: 6px;
}
.nav-timeline .slot {
  min-width: 28px;
  height: 46px;
  border-radius: 6px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  font-size: 0.6rem;
  color: rgba(0,0,0,0.55);
  padding-bottom: 3px;
  flex-shrink: 0;
  position: relative;
}
.nav-timeline .bleu { background: var(--bleu); }
.nav-timeline .vert { background: var(--vert); }
.nav-timeline .jaune { background: var(--jaune); }
.nav-timeline .orange { background: var(--orange); }
.nav-timeline .rouge { background: var(--rouge); color: #fff; }
.nav-timeline .inconnu { background: var(--muted); }

/* Case "maintenant" : liseré + petit repère triangulaire, pour se situer d'un
   coup d'œil dans les 48h affichées (cf. markNowSlot() dans app.js). */
.nav-timeline .slot.now {
  box-shadow: 0 0 0 2px var(--text), 0 0 6px 1px rgba(234, 242, 250, 0.6);
  z-index: 1;
}
.nav-timeline .slot.now::before {
  content: "";
  position: absolute;
  top: -8px;
  left: 50%;
  transform: translateX(-50%);
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 6px solid var(--text);
}

.disclaimer { color: var(--muted); font-size: 0.75rem; margin-top: 10px; }

.map-wrap {
  position: relative;
  width: 100%;
  height: 280px;
  border-radius: 10px;
  overflow: hidden;
}
.map-wrap .map-container {
  width: 100%;
  height: 100%;
  border-radius: 0;
}
/* Carte laissée au plus clair : la lisibilité des traînées de vent vient du
   rendu des particules lui-même (liseré + opacité, cf. app.js), plus besoin
   d'assombrir le fond. Overlay conservé (inerte) au cas où on en aurait
   besoin plus tard pour un autre usage. */
.map-dim-overlay {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: transparent;
  pointer-events: none;
  z-index: 350;
}
.wind-particles-canvas {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  pointer-events: none;
  z-index: 400; /* au-dessus des tuiles Leaflet (z-index Leaflet ~200-650) mais sous les contrôles */
}
/* Leaflet doit voir des couleurs correctes même en thème sombre */
.leaflet-container { background: #0b1e33; }
/* Carte volontairement éclaircie au-delà de son rendu naturel (demande
   explicite) : les traînées de vent restent lisibles via leur propre
   rendu (liseré + opacité), indépendamment de la luminosité du fond. */
.leaflet-tile-pane { filter: brightness(1.35); }

.gauge-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: center;
  margin-top: 6px;
  font-size: 0.75rem;
  color: var(--muted);
}
.gauge-legend .dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  margin-right: 4px;
}
.dot.bleu { background: var(--bleu); }
.dot.vert { background: var(--vert); }
.dot.orange { background: var(--orange); }
.dot.rouge { background: var(--rouge); }
.gust-legend { color: #f2a93b; }

.hourly-table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
#hourly-table {
  border-collapse: collapse;
  font-size: 0.75rem;
  white-space: nowrap;
}
#hourly-table th, #hourly-table td {
  padding: 6px 8px;
  text-align: center;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
#hourly-table th.row-label, #hourly-table td.row-label {
  position: sticky;
  left: 0;
  background: var(--bg-card);
  text-align: left;
  color: var(--muted);
  font-weight: 600;
  z-index: 1;
  padding-right: 14px;
}
#hourly-table thead th {
  color: var(--muted);
  font-weight: 600;
  font-size: 0.7rem;
}
#hourly-table thead th.new-day {
  border-left: 2px solid rgba(255,255,255,0.15);
}
#hourly-table td.new-day {
  border-left: 2px solid rgba(255,255,255,0.15);
}

/* Colonne "maintenant" : repère la même heure que les frises 48h ci-dessus
   (cf. markNowSlot()/nowClassFor() dans app.js). */
#hourly-table th.now-col, #hourly-table td.now-col {
  background: rgba(234, 242, 250, 0.1);
  border-left: 2px solid var(--text);
  border-right: 2px solid var(--text);
}
#hourly-table thead th.now-col {
  color: var(--text);
}
.wind-arrow {
  display: inline-block;
  font-size: 0.9rem;
}
.nav-cell {
  display: inline-block;
  width: 14px;
  height: 14px;
  border-radius: 4px;
}

.alert-banner {
  background: var(--orange);
  color: #3a2500;
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-weight: 600;
}
.alert-banner.rouge { background: var(--rouge); color: #fff; }
.hidden { display: none; }

.footer {
  text-align: center;
  color: var(--muted);
  font-size: 0.75rem;
  margin-top: 10px;
  line-height: 1.5;
}
