:root {
  --nuit: #14213D;      /* panneau, texte fort */
  --encre: #1F2937;
  --gris: #6B7280;
  --trait: #E5E7EB;
  --fond: #FFFFFF;
  --voile: #F5F6F8;
  --trace: #1D4ED8;     /* fil d'Ariane */
  --balise: #FFCC00;    /* prochain arret : jaune de signalisation */
  --passe: #15803D;
  --cs: #EAB308;
  --om: #4B5563;
  --bio: #92400E;
  --h-peek: 232px;
  font-family: "Atkinson Hyperlegible", system-ui, sans-serif;
  color: var(--encre);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--fond); overflow: hidden; }
button { font: inherit; color: inherit; cursor: pointer; }
button:focus-visible, a:focus-visible { outline: 3px solid var(--trace); outline-offset: 2px; }
button svg, a svg { width: 22px; height: 22px; flex: none; }

.app { position: fixed; inset: 0; }
.carte { position: absolute; inset: 0; z-index: 1; }

/* ---------- Panneau : feuille du bas sur mobile ---------- */
.panneau {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 900;
  height: var(--h-peek); max-height: calc(100% - 64px);
  display: flex; flex-direction: column;
  background: var(--fond); border-radius: 16px 16px 0 0;
  box-shadow: 0 -6px 24px rgba(20, 33, 61, .18);
  transition: height .28s ease;
}
.panneau.ouvert { height: 78%; }
.poignee { flex: none; border: 0; background: none; padding: 10px 0 4px; width: 100%; }
.poignee span { display: block; margin: 0 auto; width: 44px; height: 5px; border-radius: 3px; background: #CBD5E1; }

.entete { flex: none; display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 0 16px 8px; }
.entete h1 { margin: 0; min-width: 0; font-size: 15px; font-weight: 700; color: var(--gris); line-height: 1.25; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.entete h1 br { display: none; }
.entete h1 span { color: var(--gris); font-weight: 400; }
.entete h1 span::before { content: " · "; }
.compteur { margin: 0; font-size: 15px; color: var(--encre); white-space: nowrap; }
.compteur b { font-size: 18px; }

.contenu { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: 0 16px calc(16px + env(safe-area-inset-bottom)); }

/* ---------- Grand ecran : colonne a gauche ---------- */
@media (min-width: 900px) {
  :root { --l-panneau: 400px; }
  .panneau { top: 0; right: auto; width: var(--l-panneau); height: auto !important; max-height: none; border-radius: 0; box-shadow: 4px 0 20px rgba(20, 33, 61, .12); }
  .poignee { display: none; }
  .entete { flex-direction: column; align-items: flex-start; padding: 20px 20px 12px; gap: 6px; background: var(--nuit); }
  .entete h1 { font-size: 22px; color: #fff; white-space: normal; }
  .entete h1 br { display: inline; }
  .entete h1 span { color: rgba(255,255,255,.75); font-weight: 400; font-size: 17px; }
  .entete h1 span::before { content: none; }
  .compteur { color: #fff; }
  .contenu { padding: 16px 20px 24px; }
  .carte { left: var(--l-panneau); }
  .outils-carte { bottom: 24px !important; }
}

/* ---------- Outils carte ---------- */
.outils-carte { position: absolute; right: 16px; z-index: 800; display: flex; flex-direction: column; gap: 10px; bottom: calc(var(--h-panneau, 232px) + 16px); transition: bottom .28s ease; }
.rond { width: 50px; height: 50px; border-radius: 50%; border: 0; background: var(--fond); color: var(--nuit); box-shadow: 0 2px 10px rgba(20,33,61,.25); display: grid; place-items: center; }
.rond.actif { background: var(--trace); color: #fff; }
.leaflet-top.leaflet-right { top: 8px; }

/* ---------- Marqueurs ---------- */
.pav { display: grid; place-items: center; border-radius: 50%; font-weight: 700; background: #fff; color: var(--trace); border: 2.5px solid var(--trace); box-shadow: 0 1px 3px rgba(0,0,0,.3); width: 100%; height: 100%; font-size: 13px; }
.pav.point { border-width: 3px; }
.pav.passe { background: var(--passe); border-color: #fff; color: #fff; }
.pav.selection { outline: 4px solid rgba(29, 78, 216, .35); }
.pav.prochain { background: var(--balise); color: #000; border: 3px solid #000; font-size: 17px; }
.depot { display: grid; place-items: center; width: 100%; height: 100%; border-radius: 6px; background: var(--nuit); color: #fff; font-weight: 700; font-size: 12px; }
.moi { width: 100%; height: 100%; border-radius: 50%; background: #2563EB; border: 3px solid #fff; box-shadow: 0 0 0 6px rgba(37,99,235,.25); }

/* ---------- Contenu : elements communs ---------- */
.resume { margin: 0 0 12px; color: var(--gris); font-size: 15px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 50px; padding: 0 16px; border-radius: 12px; border: 2px solid var(--nuit); background: var(--fond); color: var(--nuit); font-weight: 700; font-size: 16px; text-decoration: none; }
.btn.principal { background: var(--nuit); color: #fff; }
.btn.signal { background: var(--balise); border-color: #000; color: #000; }
.btn.large { width: 100%; }
.btn.carre { width: 50px; padding: 0; }
.btn.discret { border-color: var(--trait); color: var(--encre); font-weight: 400; }
.actions { display: grid; grid-template-columns: 1fr auto auto; gap: 8px; margin: 12px 0; }

.onglets { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; margin: 14px 0 8px; background: var(--voile); border-radius: 12px; }
.onglets button { border: 0; background: none; min-height: 40px; border-radius: 9px; font-size: 15px; color: var(--gris); }
.onglets button[aria-pressed="true"] { background: var(--fond); color: var(--nuit); font-weight: 700; box-shadow: 0 1px 3px rgba(0,0,0,.12); }

/* Liste des PAV : c'est une sequence, d'ou la numerotation */
.liste { list-style: none; margin: 0; padding: 0; }
.liste li + li { border-top: 1px solid var(--trait); }
.ligne { display: grid; grid-template-columns: 34px 1fr auto; align-items: center; gap: 12px; width: 100%; padding: 10px 2px; border: 0; background: none; text-align: left; min-height: 56px; }
.ligne .n { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; border: 2.5px solid var(--trace); color: var(--trace); font-weight: 700; font-size: 14px; }
.ligne .n.passe { background: var(--passe); border-color: var(--passe); color: #fff; }
.ligne .n.prochain { background: var(--balise); border-color: #000; color: #000; }
.ligne .t { font-size: 16px; font-weight: 700; display: block; line-height: 1.25; }
.ligne .s { font-size: 14px; color: var(--gris); display: block; }
.ligne .d { font-size: 14px; color: var(--gris); white-space: nowrap; }
.ligne.passe .t { color: var(--gris); font-weight: 400; }

/* Fiche d'un PAV */
.retour { display: inline-flex; align-items: center; gap: 4px; border: 0; background: none; color: var(--trace); font-weight: 700; padding: 6px 0; font-size: 15px; }
.fiche-titre { display: flex; align-items: flex-start; gap: 12px; margin: 6px 0 4px; }
.fiche-titre .n { flex: none; display: grid; place-items: center; width: 42px; height: 42px; border-radius: 50%; border: 2.5px solid var(--trace); color: var(--trace); font-weight: 700; font-size: 18px; }
.fiche-titre .n.prochain { background: var(--balise); border-color: #000; color: #000; }
.fiche-titre .n.passe { background: var(--passe); border-color: var(--passe); color: #fff; }
.fiche-titre h2 { margin: 0; font-size: 21px; line-height: 1.2; }
.fiche-titre p { margin: 2px 0 0; font-size: 15px; color: var(--gris); }
.adresse { margin: 8px 0 2px; font-size: 16px; }
.note { margin: 2px 0; font-size: 15px; color: #B45309; }
.conteneurs { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 4px; padding: 0; list-style: none; }
.conteneurs li { display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px 5px 8px; border-radius: 8px; background: var(--voile); font-size: 14px; font-weight: 700; }
.conteneurs i { width: 10px; height: 10px; border-radius: 2px; }
.conteneurs i.CS { background: var(--cs); } .conteneurs i.OM { background: var(--om); } .conteneurs i.BIO { background: var(--bio); }

/* Mode tournee */
.bandeau { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 2px 0 6px; }
.bandeau p { margin: 0; font-size: 15px; color: var(--gris); }
.bandeau p.ici { color: #B45309; font-weight: 700; }
.ensuite { margin: 18px 0 4px; font-size: 15px; font-weight: 700; color: var(--gris); }
.fin { text-align: left; padding: 6px 0; }
.fin h2 { margin: 0 0 6px; font-size: 22px; }

.toast { position: fixed; left: 50%; top: 16px; transform: translateX(-50%); z-index: 1100; background: var(--nuit); color: #fff; padding: 12px 18px; border-radius: 12px; font-size: 15px; max-width: calc(100vw - 32px); box-shadow: 0 4px 16px rgba(0,0,0,.25); }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
