:root {
  --vert: #59733f;
  --vert-clair: #8fa86e;
  --terracotta: #bf5e3b;
  --ocre: #d9a918;
  --rouge: #a6243c;
  --bleu: #4b93bf;
  --gris: #9aa0a6;
  --fond: #f4efe1;
  --texte: #33291f;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  font-family: "Mulish", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: var(--texte);
}

body {
  display: flex;
  height: 100vh;
}

#panneau {
  width: 340px;
  flex-shrink: 0;
  padding: 24px;
  background: var(--fond);
  overflow-y: auto;
  border-right: 1px solid #e2ddd0;
}

.marque {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}
.embleme {
  width: 60px;
  height: 60px;
  flex-shrink: 0;
}
.marque-texte { min-width: 0; }

.logo-titre { margin: 0 0 6px; }
.logo-titre svg { width: 100%; max-width: 270px; height: auto; display: block; }

.proto {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #fff;
  background: var(--terracotta);
  padding: 2px 7px;
  border-radius: 999px;
  vertical-align: middle;
}

.sous-titre {
  font-family: "Fraunces", Georgia, serif;
  font-size: 14px;
  color: #8a6f4f;
  font-style: italic;
  margin: 2px 0 0;
}

label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 14px;
}

input[type="text"] {
  width: 100%;
  margin-top: 5px;
  padding: 10px 12px;
  border: 1px solid #d6d0c2;
  border-radius: 9px;
  font-size: 14px;
  font-weight: 400;
}

.champ { margin-bottom: 14px; }

.etiquette {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 5px;
}

.saisie-adresse {
  position: relative;
  display: flex;
  gap: 6px;
}

.saisie-adresse input { flex: 1; margin-top: 0; }

#btn-position, #ajouter-ville {
  width: auto;
  flex-shrink: 0;
  padding: 0 12px;
  background: #fff;
  color: inherit;
  border: 1px solid #d6d0c2;
  border-radius: 9px;
  font-size: 17px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s;
}
#btn-position:hover, #ajouter-ville:hover { background: #f0ede4; }

/* Étapes "passer par" façon Google Maps : lien d'ajout + champs éditables */
.lien-ajout {
  width: auto;
  margin: 0 0 18px;
  padding: 4px 0;
  background: none;
  color: var(--vert);
  font-size: 13px;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
}
.lien-ajout:hover { background: none; text-decoration: underline; }

.etape-champ { margin-bottom: 10px; }
.etape-champ.en-deplacement { opacity: 0.45; }
.poignee {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  padding: 0 4px;
  color: #b9b3a5;
  font-size: 16px;
  cursor: grab;
  user-select: none;
}
.poignee:active { cursor: grabbing; }
.retirer-etape {
  width: auto;
  flex-shrink: 0;
  padding: 0 12px;
  background: #fff;
  color: #b06a28;
  border: 1px solid #d6d0c2;
  border-radius: 9px;
  font-size: 15px;
  cursor: pointer;
}
.retirer-etape:hover { background: #f0ede4; }

.suggestions {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  margin: 4px 0 0;
  padding: 0;
  list-style: none;
  background: #fff;
  border: 1px solid #d6d0c2;
  border-radius: 9px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.12);
  z-index: 1000;
  overflow: hidden;
}
.suggestions:empty { display: none; }
.suggestions li {
  padding: 9px 12px;
  font-size: 13px;
  cursor: pointer;
}
.suggestions li:hover { background: #f0ede4; }

.bloc-eviter {
  background: #fff;
  border: 1px solid #e2ddd0;
  border-radius: 11px;
  padding: 14px;
  margin-bottom: 18px;
}

.case {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.case input { width: auto; }

.bloc-eviter small {
  display: block;
  color: #8a8a8a;
  font-weight: 400;
  margin-top: 6px;
  font-size: 11px;
}

.puces-villes {
  list-style: none;
  margin: 10px 0 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.puces-villes:empty { margin: 0; }

.puce-ville {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #eef5f0;
  border: 1px solid #cfe3d7;
  color: var(--vert);
  border-radius: 999px;
  padding: 4px 6px 4px 11px;
  font-size: 12px;
  font-weight: 600;
}

.puce-ville .retirer {
  width: 18px;
  height: 18px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #cfe3d7;
  color: var(--vert);
  border: none;
  border-radius: 999px;
  font-size: 11px;
  line-height: 1;
  cursor: pointer;
  transition: background .15s;
}
.puce-ville .retirer:hover { background: var(--vert); color: #fff; }

.bloc-population, .bloc-agglos, .bloc-nature, .bloc-stations, .bloc-boucle {
  background: #fff;
  border: 1px solid #e2ddd0;
  border-radius: 11px;
  padding: 14px;
  margin-bottom: 18px;
}
.bloc-nature small, .bloc-stations small, .bloc-boucle small {
  display: block;
  color: #8a8a8a;
  font-weight: 400;
  margin-top: 6px;
  font-size: 11px;
}
.score-nature {
  margin-top: 8px;
  font-size: 13px;
  color: var(--vert);
  background: #eef5f0;
  border-radius: 8px;
  padding: 6px 9px;
}
.score-nature strong { font-size: 15px; }

.marqueur-poi {
  font-size: 17px;
  text-align: center;
  line-height: 26px;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35);
}
.popup-station { width: 180px; }
.popup-station > strong { font-size: 13px; display: block; margin-bottom: 6px; }
.popup-station .prix { font-size: 12px; margin-bottom: 8px; }
.prix-ligne { display: flex; justify-content: space-between; padding: 1px 0; color: #444; }
.popup-station .passer-station { width: 100%; padding: 7px; font-size: 12px; }

.marqueur-meteo {
  font-size: 17px;
  text-align: center;
  line-height: 22px;
  text-shadow: 0 0 3px #fff, 0 0 4px #fff, 0 0 4px #fff;
}
.meteo-resume {
  margin-top: 9px;
  font-size: 13px;
  background: #eef3f7;
  border: 1px solid #d8e3ec;
  border-radius: 8px;
  padding: 7px 9px;
  color: #34506a;
}
.cout-resume {
  margin-top: 9px;
  font-size: 14px;
  font-weight: 600;
  background: #fbf3e6;
  border: 1px solid #efd9b0;
  border-radius: 8px;
  padding: 7px 9px;
  color: #8a5a1a;
}
.cout-resume .cout-detail { font-size: 11px; font-weight: 400; color: #a07a4a; }

#installer-pwa {
  width: 100%;
  margin-bottom: 14px;
  padding: 12px;
  background: var(--terracotta);
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}

#export-gpx {
  width: 100%;
  margin-top: 8px;
  padding: 11px;
  background: #fff;
  color: var(--vert);
  border: 1px solid var(--vert);
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s;
}
#export-gpx:hover { background: #eef5f0; }

#nav-btn {
  width: 100%;
  margin-top: 8px;
  padding: 14px;
  background: var(--bleu);
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
}
#nav-btn:hover { filter: brightness(0.95); }

#nav-overlay {
  position: fixed;
  inset: 0;
  z-index: 2000;
  pointer-events: none;
}
.nav-bas {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: #fff;
  border-radius: 16px 16px 0 0;
  box-shadow: 0 -4px 22px rgba(0, 0, 0, 0.18);
  padding: 14px 16px;
  padding-bottom: max(14px, env(safe-area-inset-bottom));
  pointer-events: auto;
}
.nav-ligne1 {
  display: flex;
  align-items: center;
  gap: 14px;
}
.nav-fleche {
  flex-shrink: 0;
  width: 58px;
  height: 58px;
  background: var(--vert);
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.nav-fleche svg { width: 46px; height: 46px; display: block; }
.nav-instr { min-width: 0; }
#nav-distance {
  font-family: "Fraunces", serif;
  font-size: 27px;
  font-weight: 700;
  line-height: 1;
  color: var(--texte);
}
#nav-texte { font-size: 15px; margin-top: 3px; color: #555; }
.nav-ligne2 {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 12px;
  padding-top: 11px;
  border-top: 1px solid #eee;
}
#nav-reste { font-size: 16px; font-weight: 700; color: var(--vert); }
#nav-stop {
  background: var(--rouge);
  color: #fff;
  border: none;
  border-radius: 999px;
  padding: 10px 22px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
}
.me-marker svg {
  width: 34px;
  height: 34px;
  display: block;
  transform-origin: center;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.45));
  transition: transform 0.2s;
}
.bloc-agglos small {
  display: block;
  color: #8a8a8a;
  font-weight: 400;
  margin-top: 6px;
  font-size: 11px;
}

.bloc-villages {
  background: #fff;
  border: 1px solid #e2ddd0;
  border-radius: 11px;
  padding: 14px;
  margin-bottom: 18px;
}
.bloc-villages small {
  display: block;
  color: #8a8a8a;
  font-weight: 400;
  margin-top: 6px;
  font-size: 11px;
}

.popup-village { text-align: center; width: 215px; }
.popup-village .carrousel { position: relative; margin-bottom: 6px; }
.popup-village .img-principale {
  width: 100%;
  height: 130px;
  object-fit: cover;
  border-radius: 6px;
  display: block;
}
.popup-village .fleche {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 26px;
  height: 26px;
  padding: 0;
  background: rgba(255, 255, 255, 0.85);
  color: #333;
  border: none;
  border-radius: 50%;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}
.popup-village .fleche.prec { left: 5px; }
.popup-village .fleche.suiv { right: 5px; }
.popup-village .fleche:hover { background: #fff; }
.popup-village .compteur {
  position: absolute;
  bottom: 6px;
  right: 6px;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 10px;
}
.popup-village .galerie {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  justify-content: center;
  margin-bottom: 6px;
}
.popup-village .vignette {
  width: 40px;
  height: 40px;
  object-fit: cover;
  border-radius: 4px;
  cursor: pointer;
  border: 2px solid transparent;
}
.popup-village .vignette:hover { border-color: var(--vert); }
.popup-village strong { font-size: 14px; color: var(--vert); }
.popup-village .dep { font-size: 11px; color: #888; }
.popup-village .desc-village {
  font-size: 12px;
  color: #555;
  text-align: left;
  line-height: 1.4;
  margin: 6px 0;
  max-height: 110px;
  overflow-y: auto;
}
.popup-village .passer-village {
  width: 100%;
  margin-top: 6px;
  padding: 8px;
  font-size: 13px;
}
.popup-village .lien-wiki {
  display: inline-block;
  margin-top: 6px;
  font-size: 12px;
  color: var(--vert);
  text-decoration: none;
}
.popup-village .lien-wiki:hover { text-decoration: underline; }

#seuil-population, #dist-boucle {
  width: 100%;
  margin: 12px 0 4px;
  accent-color: var(--vert);
  cursor: pointer;
}
.bloc-route .case { margin-top: 12px; }

.segments {
  display: flex;
  margin: 4px 0 2px;
  border: 1px solid #d6d0c2;
  border-radius: 9px;
  overflow: hidden;
}
.segment {
  width: auto;
  flex: 1;
  padding: 9px 6px;
  background: #fff;
  color: #555;
  border: none;
  border-left: 1px solid #e2ddd0;
  border-radius: 0;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.segment:first-child { border-left: none; }
.segment:hover { background: #f0ede4; }
.segment.actif { background: var(--vert); color: #fff; }

.aide {
  font-size: 11px;
  color: #8a8a8a;
  font-style: italic;
  margin: 8px 0 2px;
}
#seuil-population:disabled { cursor: not-allowed; opacity: 0.45; }

.seuil-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--vert);
}

.bloc-population small {
  display: block;
  color: #8a8a8a;
  font-weight: 400;
  margin-top: 6px;
  font-size: 11px;
}

.communes-auto {
  font-size: 11px;
  color: #b06a28;
  margin-top: 4px;
}

.bloc-route {
  background: #fff;
  border: 1px solid #e2ddd0;
  border-radius: 11px;
  padding: 14px;
  margin-bottom: 18px;
}
.bloc-route .etiquette { margin-bottom: 10px; }
.bloc-route small {
  display: block;
  color: #8a8a8a;
  font-weight: 400;
  margin-top: 2px;
  font-size: 11px;
}

button {
  width: 100%;
  padding: 13px;
  background: var(--vert);
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s;
}

button:hover { background: #346249; }
button:disabled { background: var(--gris); cursor: wait; }

#resultat {
  margin-top: 18px;
  font-size: 13px;
}

.carte-resultat {
  background: #fff;
  border: 1px solid #e2ddd0;
  border-radius: 10px;
  padding: 11px 13px;
  margin-bottom: 9px;
}

.carte-resultat .titre { font-weight: 700; }
.carte-resultat.normale .titre { color: var(--gris); }
.carte-resultat.buissonniere .titre { color: var(--vert); }
.carte-resultat .chiffres { font-size: 13px; color: #555; margin-top: 2px; }
.gain { color: var(--vert); font-weight: 600; }

.legende {
  font-size: 12px;
  color: #666;
  margin-top: 18px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.pastille {
  display: inline-block;
  width: 14px;
  height: 5px;
  border-radius: 3px;
}
.pastille.grise { background: var(--gris); }
.pastille.verte { background: var(--vert); }

.alerte {
  margin-top: 16px;
  font-size: 12px;
  background: #fff4e5;
  border: 1px solid #ffd9a8;
  border-radius: 9px;
  padding: 10px;
}

.alerte code { background: #ffe9cc; padding: 1px 4px; border-radius: 4px; }

/* Sections repliables (accordéon natif <details>) */
.section {
  background: #fff;
  border: 1px solid #e2ddd0;
  border-radius: 11px;
  margin-bottom: 12px;
  overflow: hidden;
}
.section > summary {
  list-style: none;
  cursor: pointer;
  padding: 13px 14px;
  font-size: 14px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: space-between;
  user-select: none;
}
.section > summary::-webkit-details-marker { display: none; }
.section > summary::after {
  content: "▾";
  color: #b9b3a5;
  font-size: 12px;
  transition: transform 0.2s;
}
.section[open] > summary::after { transform: rotate(180deg); }
.section > summary:hover { background: #faf8f2; }
.section-corps { padding: 0 14px 8px; }

/* À l'intérieur d'une section, les blocs deviennent plats (séparés par un filet) */
.section-corps .bloc-eviter,
.section-corps .bloc-agglos,
.section-corps .bloc-population,
.section-corps .bloc-route,
.section-corps .bloc-villages,
.section-corps .bloc-nature,
.section-corps .bloc-stations,
.section-corps .bloc-boucle {
  background: none;
  border: none;
  border-radius: 0;
  padding: 12px 0 0;
  margin: 12px 0 0;
  border-top: 1px solid #f0ece2;
}
.section-corps > *:first-child {
  border-top: none;
  padding-top: 0;
  margin-top: 0;
}

#carte {
  flex: 1;
  height: 100%;
}

@media (max-width: 700px) {
  body { flex-direction: column; }
  #panneau { width: 100%; height: auto; max-height: 56%; padding: 18px; }
  #carte { height: 44%; min-height: 230px; }

  /* Zones tactiles plus généreuses au doigt */
  input[type="text"] { font-size: 16px; padding: 12px 13px; }
  .case { gap: 11px; padding: 3px 0; font-size: 14px; }
  .case input[type="checkbox"] { width: 22px; height: 22px; flex-shrink: 0; }
  .segment { padding: 13px 6px; }
  .section > summary { padding: 16px 14px; font-size: 15px; }
  #calculer { padding: 16px; font-size: 16px; }
  #btn-position, #ajouter-ville, #ajouter-etape { font-size: 19px; padding: 0 14px; }
  .suggestions li { padding: 12px; font-size: 14px; }
}
