:root {
  color-scheme: light dark;
  --fond: #f2f4f8;
  --surface: #ffffff;
  --texte: #111827;
  --sec: #586272;
  --trait: #e2e6ed;
  --accent: #1d4ed8;
  --accent-doux: #e6edfd;
  --direct: #0b7a45;
  --direct-doux: #dff5e9;
  --rouge: #b42318;
  --rouge-doux: #fdecea;
  --rayon: 14px;
  --onglets: 62px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --fond: #0e131b;
    --surface: #18202c;
    --texte: #eef1f6;
    --sec: #a2acbb;
    --trait: #2a3442;
    --accent: #8db1ff;
    --accent-doux: #1f2f50;
    --direct: #4fd694;
    --direct-doux: #123626;
    --rouge: #ff9b92;
    --rouge-doux: #43201d;
  }
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  background: var(--fond);
  color: var(--texte);
  line-height: 1.45;
  padding-bottom: calc(var(--onglets) + env(safe-area-inset-bottom) + 18px);
}
a { color: var(--accent); text-decoration: none; }
small { font-size: .82rem; color: var(--sec); }
ol { list-style: none; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

/* En-tête et onglets */
.entete {
  position: sticky; top: 0; z-index: 1000;
  display: flex; align-items: center; justify-content: space-between;
  min-height: 54px;
  padding: calc(env(safe-area-inset-top) + 8px) 16px 8px;
  background: var(--surface);
  border-bottom: 1px solid var(--trait);
}
.marque { display: flex; align-items: center; gap: .55rem; font-weight: 750; font-size: 1.05rem; color: var(--texte); }
.marque__pastille { width: 12px; height: 12px; border-radius: 4px; background: var(--accent); }
.onglets {
  position: fixed; inset: auto 0 0 0; z-index: 1000;
  display: grid; grid-template-columns: repeat(4, 1fr);
  height: calc(var(--onglets) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--surface);
  border-top: 1px solid var(--trait);
}
.onglets a {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  font-size: .74rem; font-weight: 600; color: var(--sec);
}
.onglets a[aria-current] { color: var(--accent); }
.onglets svg { width: 23px; height: 23px; }

/* Mise en page */
.page { max-width: 640px; margin: 0 auto; padding: 18px 16px; }
h1 { font-size: 1.55rem; line-height: 1.2; letter-spacing: -.01em; }
h2 { font-size: .92rem; font-weight: 700; margin: 26px 0 10px; color: var(--sec); }
.intro { color: var(--sec); font-size: .92rem; margin: -4px 0 10px; }
.alerte { background: var(--rouge-doux); color: var(--rouge); font-size: .9rem; font-weight: 600; padding: 10px 16px; text-align: center; }

/* Accueil */
.hero p { color: var(--sec); margin-top: 4px; }
.champ { display: block; margin-top: 16px; }
input[type="search"] {
  width: 100%; height: 50px; padding: 0 16px;
  font: inherit; font-size: 1.02rem; color: var(--texte);
  background: var(--surface);
  border: 1.5px solid var(--trait); border-radius: var(--rayon);
}
input[type="search"]:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-doux); }
.bouton svg { width: 1.3em; height: 1.3em; flex: none; }
.bouton {
  display: flex; align-items: center; justify-content: center; gap: .5rem;
  width: 100%; height: 48px; margin-top: 10px;
  font: inherit; font-weight: 650; color: var(--accent);
  background: var(--accent-doux); border: 0; border-radius: var(--rayon); cursor: pointer;
}
.message { font-size: .9rem; color: var(--sec); margin-top: 10px; }
.message:empty { display: none; }

/* Listes */
.liste, .departs { background: var(--surface); border: 1px solid var(--trait); border-radius: var(--rayon); overflow: hidden; }
.ligne-liste {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  min-height: 60px; padding: 10px 14px; color: var(--texte);
}
.liste > * + * { border-top: 1px solid var(--trait); }
.ligne-liste__texte { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.ligne-liste__texte strong { font-weight: 650; }
.lien-plein { display: block; padding: 14px; text-align: center; font-weight: 650; }

/* Badges de ligne */
.badges { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 4px; max-width: 52%; }
.badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 26px; height: 26px; padding: 0 6px;
  font-size: .82rem; font-weight: 750; font-variant-numeric: tabular-nums;
  background: var(--c); color: var(--t);
  border-radius: 50%;
}
.badge--car { border-radius: 6px; }
.badge--grand { min-width: 42px; height: 42px; font-size: 1.1rem; flex: none; }

/* Page d'un arrêt */
.titre-arret p { color: var(--sec); margin-top: 2px; }
.titre-ligne { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.titre-ligne h1 { font-size: 1.3rem; }
.favori { width: 40px; height: 40px; border: 0; background: none; color: var(--sec); cursor: pointer; display: grid; place-items: center; }
.favori svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linejoin: round; }
.favori[aria-pressed="true"] { color: #d97706; }
.favori[aria-pressed="true"] svg { fill: currentColor; }

.filtres { display: flex; gap: 6px; overflow-x: auto; margin: 14px -16px 0; padding: 2px 16px 4px; scrollbar-width: none; }
.filtres::-webkit-scrollbar { display: none; }
.filtre {
  flex: none; display: inline-flex; align-items: center; justify-content: center;
  min-width: 42px; height: 36px; padding: 0 12px;
  font-size: .88rem; font-weight: 700; color: var(--sec);
  background: var(--surface); border: 1.5px solid var(--trait); border-radius: 18px;
}
.filtre[aria-current] { background: var(--texte); border-color: var(--texte); color: var(--surface); }
.filtre--ligne[aria-current] { background: var(--c); border-color: var(--c); color: var(--t); }

#tableau { margin-top: 14px; }
.departs > li + li { border-top: 1px solid var(--trait); }
.depart {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 12px;
  min-height: 68px; padding: 10px 14px; color: var(--texte);
}
.depart .badge { min-width: 34px; height: 34px; font-size: .95rem; }
.depart__centre { display: flex; flex-direction: column; min-width: 0; }
.depart__centre strong { font-weight: 650; overflow-wrap: anywhere; }
.depart__temps { display: flex; flex-direction: column; align-items: flex-end; white-space: nowrap; }
.depart__temps b { font-size: 1.14rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.depart__temps s { opacity: .7; }
.depart--supprime strong, .depart--supprime b { text-decoration: line-through; color: var(--sec); }
.jour { padding: 8px 14px; font-size: .84rem; font-weight: 700; color: var(--sec); background: var(--fond); }

.etat { color: var(--sec); }
.etat--direct { color: var(--direct); font-weight: 650; }
.etat--supprime { color: var(--rouge); font-weight: 650; }
.etat--direct i {
  display: inline-block; width: 8px; height: 8px; margin-right: 5px; vertical-align: 1px;
  border-radius: 50%; background: var(--direct);
  animation: pouls 1.8s ease-out infinite;
}
@keyframes pouls {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--direct) 60%, transparent); }
  100% { box-shadow: 0 0 0 7px transparent; }
}
@media (prefers-reduced-motion: reduce) { .etat--direct i { animation: none; } }
.vide { padding: 28px 16px; text-align: center; color: var(--sec); background: var(--surface); border: 1px solid var(--trait); border-radius: var(--rayon); }
.note { font-size: .82rem; color: var(--sec); margin-top: 10px; }

/* Trajets */
.trajet { position: relative; background: var(--surface); border: 1px solid var(--trait); border-radius: var(--rayon); padding: 6px 0; }
.trajet li { position: relative; }
.trajet li::before { content: ""; position: absolute; left: 22px; top: 0; bottom: 0; width: 4px; background: var(--c); }
.trajet li:first-child::before { top: 50%; }
.trajet li:last-child::before { bottom: 50%; }
.trajet li::after { content: ""; position: absolute; left: 17px; top: 50%; width: 14px; height: 14px; margin-top: -7px; border-radius: 50%; background: var(--surface); border: 3px solid var(--c); }
.trajet a { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 46px; padding: 8px 14px 8px 46px; color: var(--texte); }
.trajet time { font-variant-numeric: tabular-nums; font-weight: 700; white-space: nowrap; }
.trajet time s { color: var(--sec); font-weight: 400; }
.trajet .passe a { color: var(--sec); }
.trajet .prochain::after { background: var(--c); }
.trajet .prochain a span { font-weight: 700; }

/* Carte */
.plein-ecran { padding-bottom: 0; }
.plein-ecran .page { max-width: none; padding: 0; }
#carte { height: calc(100dvh - 54px - var(--onglets) - env(safe-area-inset-bottom) - env(safe-area-inset-top) - 38px); min-height: 280px; }
.legende {
  display: flex; align-items: center; gap: 6px; height: 38px; padding: 0 14px;
  font-size: .82rem; color: var(--sec); background: var(--surface);
  margin-bottom: calc(var(--onglets) + env(safe-area-inset-bottom));
}
.pastille { display: inline-block; width: 12px; height: 12px; }
.pastille--arret { border-radius: 50%; background: #fff; border: 3px solid var(--accent); margin-right: 2px; }
.pastille--car { border-radius: 3px; background: var(--direct); margin-left: 10px; margin-right: 2px; }
#compte { margin-left: auto; }
.car-marqueur {
  display: flex; align-items: center; justify-content: center;
  width: 36px !important; height: 24px !important; margin: -12px 0 0 -18px !important;
  font-size: 12px; font-weight: 800;
  background: var(--c); color: var(--t);
  border: 2px solid #fff; border-radius: 6px;
  box-shadow: 0 1px 4px rgb(0 0 0 / .4);
}
.leaflet-popup-content { font: inherit; font-size: .92rem; }
.leaflet-popup-content a { font-weight: 650; }

/* À propos */
.texte p { margin-top: 8px; }
.sources { display: grid; gap: 10px; }
.sources div { display: flex; flex-direction: column; gap: 2px; padding: 12px 14px; background: var(--surface); border: 1px solid var(--trait); border-radius: var(--rayon); font-size: .92rem; }
