:root {
  --encre: #1d2433;
  --doux: #5b6475;
  --fond: #ffffff;
  --ombre: 0 2px 10px rgba(20, 28, 45, .18);
  --vert: #1f9d55;
  --orange: #d9822b;
  --rouge: #c8372d;
  --haut: env(safe-area-inset-top, 0px);
  --bas: env(safe-area-inset-bottom, 0px);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--encre);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; }
[hidden] { display: none !important; } /* sinon un display: flex l'emporte et l'élément reste visible */
#carte { position: fixed; inset: 0; background: #e9ece8; }
.leaflet-tile-pane { filter: saturate(.5) brightness(1.04); }

/* --- bandeau --- */
.bandeau {
  position: fixed; z-index: 1000; top: calc(10px + var(--haut)); left: 10px; right: 10px;
  display: flex; align-items: center; gap: 10px; pointer-events: none;
}
.titre {
  pointer-events: auto; background: var(--fond); border-radius: 14px; box-shadow: var(--ombre);
  padding: 8px 14px 9px; min-width: 0;
}
h1 { font-size: 17px; margin: 0; letter-spacing: -.01em; }
.etat { margin: 2px 0 0; font-size: 13px; color: var(--doux); display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.voyant { width: 8px; height: 8px; border-radius: 50%; background: #aab; flex: none; }
.etat.direct .voyant { background: var(--vert); box-shadow: 0 0 0 0 rgba(31,157,85,.5); animation: pouls 2s infinite; }
.etat.retard .voyant { background: var(--orange); }
.etat.panne .voyant { background: var(--rouge); }
@keyframes pouls { 70% { box-shadow: 0 0 0 7px rgba(31,157,85,0); } 100% { box-shadow: 0 0 0 0 rgba(31,157,85,0); } }

.rond {
  pointer-events: auto; width: 40px; height: 40px; border-radius: 50%; border: 0; background: var(--fond);
  box-shadow: var(--ombre); color: var(--encre); font: 700 17px/1 Georgia, serif; cursor: pointer; flex: none;
  display: grid; place-items: center;
}
.rond:focus-visible, .puce:focus-visible { outline: 3px solid #3b82f6; outline-offset: 2px; }
.bandeau .rond { margin-left: auto; }
.moi { position: fixed; z-index: 1000; right: 10px; bottom: calc(78px + var(--bas)); width: 46px; height: 46px; }
.moi svg { width: 24px; height: 24px; fill: var(--encre); stroke: var(--encre); stroke-width: 2; stroke-linecap: round; }
.moi.actif svg { fill: #2563eb; stroke: #2563eb; }

.info {
  position: fixed; z-index: 1001; top: calc(70px + var(--haut)); left: 10px; right: 10px; max-width: 430px;
  background: var(--fond); border-radius: 14px; box-shadow: var(--ombre); padding: 4px 16px 10px; font-size: 14px; line-height: 1.45;
}
.info h2 { font-size: 15px; margin: 12px 0 4px; }
.info { max-height: calc(100vh - 160px - var(--haut) - var(--bas)); overflow-y: auto; overscroll-behavior: contain; padding-top: 0; }
/* en-tête collé en haut du panneau : la croix reste visible quand on fait défiler */
.info-tete { position: sticky; top: 0; z-index: 1; display: flex; align-items: center; gap: 10px; background: var(--fond); margin: 0 -16px 0; padding: 10px 10px 6px 16px; }
.info-tete h2 { margin: 0; flex: 1; }
.info-tete .rond { box-shadow: none; background: #eef0f3; width: 36px; height: 36px; font: 400 22px/1 system-ui, sans-serif; }
.suggestion { display: grid; gap: 5px; margin: 6px 0 4px; }
.suggestion label { font-size: 13px; font-weight: 600; }
.suggestion label small { font-weight: 400; color: var(--doux); }
.suggestion textarea, .suggestion input { font: 15px/1.35 system-ui, sans-serif; color: var(--encre); border: 1px solid #c9ced8; border-radius: 9px; padding: 8px 10px; width: 100%; background: #fff; }
.suggestion textarea { resize: vertical; min-height: 84px; }
.suggestion textarea:focus, .suggestion input:focus { outline: 2px solid #3b82f6; outline-offset: 0; border-color: transparent; }
.suggestion button { justify-self: start; margin-top: 4px; border: 0; border-radius: 9px; padding: 9px 18px; background: var(--encre); color: #fff; font: 600 14px system-ui, sans-serif; cursor: pointer; }
.suggestion button:disabled { opacity: .5; cursor: wait; }
.suggestion .pot { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.sugg-etat { margin: 2px 0 0; font-size: 13px; min-height: 1em; color: var(--doux); }
.sugg-etat.ok { color: var(--vert); font-weight: 600; }
.sugg-etat.erreur { color: var(--rouge); }
.info p { margin: 8px 0; }
.info .source { color: var(--doux); font-size: 12px; }
.exemple { display: inline-block; width: 14px; height: 14px; border-radius: 50%; border: 2px dashed #555; opacity: .6; vertical-align: -2px; }

/* --- puces des lignes --- */
.lignes {
  position: fixed; z-index: 1000; left: 0; right: 0; bottom: 0; padding: 0 0 calc(10px + var(--bas));
  pointer-events: none;
}
.defile {
  display: flex; gap: 6px; overflow-x: auto; padding: 4px 10px; pointer-events: auto; scrollbar-width: none;
  scroll-snap-type: x proximity;
}
.defile::-webkit-scrollbar { display: none; }
.puce {
  flex: none; border: 0; cursor: pointer; border-radius: 10px; min-width: 44px; height: 40px; padding: 0 11px;
  font: 700 15px/1 system-ui, sans-serif; background: var(--c); color: var(--t); box-shadow: var(--ombre);
  display: inline-flex; align-items: center; gap: 6px; scroll-snap-align: start; transition: opacity .15s, transform .15s;
}
.puce small { font-weight: 600; font-size: 12px; opacity: .8; }
.puce.toutes { background: var(--fond); color: var(--encre); font-size: 14px; }
.filtre .puce:not(.choisie):not(.toutes) { opacity: .4; }
.puce.choisie { transform: translateY(-3px); box-shadow: 0 0 0 2px var(--fond), 0 0 0 4px var(--c), var(--ombre); }
.filtre .puce.toutes { opacity: .85; }
.puce.vide:not(.choisie) { opacity: .45; box-shadow: none; outline: 1px solid rgba(0, 0, 0, .12); outline-offset: -1px; }

/* --- marqueurs de bus --- */
.bus .pastille {
  position: absolute; left: 0; top: 0; width: 30px; height: 30px; border-radius: 50%;
  background: var(--c); color: var(--t); border: 2px solid #fff; box-shadow: 0 1px 4px rgba(0,0,0,.35);
  display: grid; place-items: center; font: 800 12px/1 system-ui, sans-serif; letter-spacing: -.03em;
}
.bus .pastille.long { font-size: 10px; }
.bus .cap { position: absolute; left: 0; top: 0; width: 30px; height: 30px; transition: transform .8s; }
.bus .cap::before {
  content: ""; position: absolute; left: 50%; top: -7px; margin-left: -6px;
  border: 6px solid transparent; border-bottom: 8px solid var(--c); border-top: 0; filter: drop-shadow(0 -1px 0 #fff);
}
.bus.arret .cap { opacity: 0; }
.bus.theo .pastille { opacity: .55; border-style: dashed; border-color: #333; }
.bus.theo .cap { opacity: .4; }
.leaflet-marker-icon.bus { transition: transform 1s linear; }
.sans-transition .leaflet-marker-icon.bus { transition: none; }
.sans-transition .leaflet-zoom-anim .leaflet-marker-icon.bus { transition: transform .25s cubic-bezier(0, 0, .25, 1); }
.bus.choisi .pastille { box-shadow: 0 0 0 3px var(--c), 0 2px 8px rgba(0,0,0,.4); }

/* --- bulle d'un bus --- */
.leaflet-popup-content-wrapper { border-radius: 12px; }
.leaflet-popup-content { margin: 12px 14px; font-size: 14px; line-height: 1.4; min-width: 200px; }
.bulle .tete { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 15px; margin-bottom: 6px; }
.bulle .badge { background: var(--c); color: var(--t); border-radius: 7px; padding: 3px 7px; font-size: 13px; }
.bulle .statut { font-weight: 600; margin: 4px 0; }
.bulle .statut.ok { color: var(--vert); }
.bulle .statut.tard { color: var(--rouge); }
.bulle .statut.tot { color: var(--orange); }
.bulle .statut.theo { color: var(--doux); }
.bulle p { margin: 3px 0; }
.bulle .note { color: var(--doux); font-size: 12px; margin-top: 8px; }

.arret-carte { font-size: 13px; }
.leaflet-control-attribution { font-size: 10px; }
.leaflet-bottom.leaflet-right { bottom: calc(56px + var(--bas)); }
.leaflet-control-zoom { display: none; }
.leaflet-top.leaflet-right { top: calc(62px + var(--haut)); }
@media (hover: hover) and (pointer: fine) {
  .leaflet-control-zoom { display: block; }
}
@media (prefers-reduced-motion: reduce) {
  .leaflet-marker-icon.bus, .bus .cap, .puce { transition: none; }
  .etat.direct .voyant { animation: none; }
}

/* --- étiquettes des arrêts : 2 prochains passages --- */
.leaflet-tooltip.etiquette {
  padding: 3px 7px 4px; border: 0; border-radius: 8px; box-shadow: 0 1px 5px rgba(20, 28, 45, .28);
  font: 11px/1.35 system-ui, sans-serif; color: var(--encre); white-space: nowrap;
}
.leaflet-tooltip-bottom.etiquette::before { border-bottom-color: #fff; }
.etiquette .et-nom { font-weight: 700; max-width: 170px; overflow: hidden; text-overflow: ellipsis; }
.et-l { display: flex; align-items: center; gap: 4px; }
.et-d { color: var(--doux); max-width: 120px; overflow: hidden; text-overflow: ellipsis; }
.fl { flex: none; width: 11px; height: 11px; margin-right: 2px; fill: var(--encre); overflow: visible; display: inline-grid; place-items: center; line-height: 1; }
.bulle-arret .fl { width: 14px; height: 14px; }
.choix .fl { width: 13px; height: 13px; margin-right: -1px; }
.et-t { margin-left: auto; padding-left: 4px; }
.et-b { background: var(--c); color: var(--t); border-radius: 4px; padding: 0 4px; font-weight: 800; font-size: 10px; line-height: 15px; }
.et-v { color: var(--doux); font-style: italic; }
.rt { font-weight: 700; color: var(--encre); }
.th { color: #8b93a3; font-style: italic; }
.bulle-arret .et-l { font-size: 13px; gap: 6px; margin: 5px 0; }
.bulle-arret .et-d { max-width: 150px; }
.bulle-arret .et-b { font-size: 12px; line-height: 19px; padding: 0 6px; border-radius: 6px; }
.bulle-arret small { color: var(--doux); font-weight: 400; font-style: normal; }

/* --- fiche horaire de la journée --- */
.leaflet-tooltip.etiquette.leaflet-interactive { cursor: pointer; }
.bulle-arret .et-l[data-fiche] { cursor: pointer; border-radius: 6px; margin: 2px -4px; padding: 3px 4px; }
.bulle-arret .et-l[data-fiche]:hover { background: #f1f3f6; }
.bulle-arret .et-l[data-fiche]::after { content: "›"; color: var(--doux); font-size: 16px; margin-left: 2px; }
.fiche {
  position: fixed; z-index: 1100; left: 0; right: 0; bottom: 0; height: 62vh; background: var(--fond);
  border-radius: 16px 16px 0 0; box-shadow: 0 -4px 24px rgba(20, 28, 45, .25); display: flex; flex-direction: column;
  padding-bottom: var(--bas);
}
@media (min-width: 760px) {
  .fiche { left: auto; top: 0; width: 430px; height: auto; border-radius: 0; box-shadow: -4px 0 24px rgba(20, 28, 45, .2); }
}
.fiche-tete { display: flex; align-items: flex-start; gap: 10px; padding: 14px 14px 4px; }
.fiche-titres { min-width: 0; flex: 1; }
.fiche-tete h2 { font-size: 17px; margin: 0; }
.fiche-tete .rond { box-shadow: none; background: #eef0f3; width: 36px; height: 36px; font: 400 22px/1 system-ui, sans-serif; }
.fiche-jour { display: flex; align-items: center; gap: 8px; color: var(--doux); font-size: 14px; margin-top: 5px; }
.fiche-jour button { border: 0; background: #eef0f3; color: var(--encre); border-radius: 8px; width: 32px; height: 28px; font-size: 18px; line-height: 1; cursor: pointer; }
#fiche-date { min-width: 9.5em; text-align: center; }
.fiche-autres { display: flex; align-items: center; gap: 8px; padding: 6px 14px 0; font-size: 13px; color: var(--doux); cursor: pointer; flex: none; user-select: none; }
.fiche-autres input { width: 18px; height: 18px; margin: 0; accent-color: var(--encre); cursor: pointer; }
.fiche-choix { padding: 8px 14px 10px; flex: none; max-height: 30vh; overflow-y: auto; }
.choix-lignes { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 8px; }
.choix-ligne { border: 2px solid transparent; background: none; padding: 1px; border-radius: 9px; cursor: pointer; line-height: 0; }
.choix-ligne .et-b { display: inline-block; min-width: 34px; text-align: center; font-size: 13px; line-height: 24px; padding: 0 7px; border-radius: 7px; }
.choix-ligne[aria-pressed="true"] { border-color: var(--encre); }
.choix-sens { display: flex; gap: 6px; }
.choix {
  flex: 1 1 0; min-width: 0; border: 1px solid #d5d9e0; background: var(--fond); color: var(--encre); border-radius: 9px; padding: 6px 9px 6px 6px;
  display: flex; gap: 6px; align-items: center; white-space: nowrap; font: 13px system-ui, sans-serif; cursor: pointer; text-align: left;
}
.choix-dest { overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.choix[aria-pressed="true"] { border-color: var(--encre); box-shadow: inset 0 0 0 1px var(--encre); font-weight: 600; }
.choix .et-b { font-size: 12px; line-height: 19px; padding: 0 6px; border-radius: 6px; }
.fiche-corps { overflow-y: auto; padding: 0 14px 16px; overscroll-behavior: contain; }
.fiche-resume { padding: 0 14px; flex: none; }
.prochain-depart { font-size: 14px; margin: 0 0 8px; }
.grille { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; }
.grille th { text-align: right; padding: 5px 10px 5px 0; width: 3.2em; color: var(--doux); font-weight: 600; vertical-align: top; border-top: 1px solid #eef0f3; white-space: nowrap; }
.grille td { padding: 3px 0; border-top: 1px solid #eef0f3; }
.grille tr.heure-en-cours th { color: var(--encre); }
.m { display: inline-block; min-width: 2.55em; padding: 2px 3px; margin: 1px; border-radius: 6px; text-align: center; font-size: 14px; }
.m.passe { color: #b3b9c4; }
.m.prochain { background: var(--c); color: var(--t); font-weight: 700; }
.m.annule { text-decoration: line-through; color: var(--rouge); }
.m sup { font-size: 9px; margin-left: 1px; font-weight: 700; }
.m sup.retard { color: var(--rouge); }
.m sup.avance { color: var(--orange); }
.m.prochain sup { color: inherit; }
.legende { font-size: 12px; color: var(--doux); margin-top: 12px; line-height: 1.55; }
.legende b { color: var(--encre); }
.fiche-vide { color: var(--doux); font-style: italic; padding: 20px 0; }
