:root {
  --fond: #0f1419;
  --panneau: #141a21;
  --panneau-2: #1b232c;
  --survol: #232d38;
  --trait: #2a343f;
  --texte: #e8edf2;
  --doux: #a3afbb;
  --accent: #6cb6ff;
  --reel: #4fd18b;
  --theo: #c9d2db;
  --rayon: 12px;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--fond); color: var(--texte); overflow: hidden;
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  font-variant-numeric: tabular-nums; -webkit-font-smoothing: antialiased;
}
#carte { position: fixed; inset: 0; }
button {
  font: inherit; color: var(--texte); background: var(--panneau-2); border: 1px solid var(--trait);
  border-radius: 8px; padding: 8px 12px; cursor: pointer; min-height: 40px;
  transition: background-color .15s, border-color .15s, opacity .15s;
}
button:hover { border-color: #3d4a58; background: var(--survol); }
button:focus-visible, a:focus-visible, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
button[disabled] { opacity: .45; cursor: not-allowed; }
a { color: var(--accent); }
h1, h2, h3, h4 { margin: 0; font-weight: 650; letter-spacing: -.01em; }
.ico { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.invisible { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.principal { background: var(--accent); color: #07121d; border-color: var(--accent); font-weight: 650; }
.principal:hover { background: #8cc6ff; border-color: #8cc6ff; }

/* barre du haut */
#haut {
  position: fixed; top: 12px; left: 12px; right: 12px; z-index: 5; display: flex; gap: 10px;
  align-items: flex-start; flex-wrap: wrap; pointer-events: none;
}
#haut > * { pointer-events: auto; }
#marque, #legende, #actions {
  background: color-mix(in srgb, var(--panneau) 94%, transparent); border: 1px solid var(--trait);
  border-radius: var(--rayon); backdrop-filter: blur(8px); box-shadow: 0 4px 18px rgba(0,0,0,.3);
}
#marque { padding: 8px 14px; }
#marque h1 { font-size: 16px; }
#compteur { margin: 2px 0 0; color: var(--doux); font-size: 13px; }
#compteur strong { color: var(--texte); font-size: 15px; }
#legende { list-style: none; margin: 0; padding: 8px 14px; display: flex; gap: 14px; font-size: 13px; align-items: center; min-height: 44px; }
#legende li { display: flex; align-items: center; gap: 6px; }
#actions { padding: 4px; display: flex; gap: 2px; margin-left: auto; margin-right: 52px; }
#actions button { border: 0; background: transparent; display: inline-flex; align-items: center; gap: 7px; min-height: 40px; }
#actions button:hover { background: var(--panneau-2); }
#actions button[aria-pressed="true"], #actions button[aria-expanded="true"] { background: #1d3550; color: #cfe6ff; }
#actions button[aria-pressed="false"] .ico { opacity: .6; }
#actions button[aria-busy="true"] { opacity: .6; cursor: progress; }
.pastille { width: 14px; height: 14px; border-radius: 50%; display: inline-block; flex: none; }
.pastille.reel { background: var(--theo); border: 2px solid #fff; }
.pastille.theo { background: var(--panneau); border: 3px solid var(--theo); }

.trait-tunnel { display: inline-block; width: 22px; height: 0; border-top: 3px dashed #fdc41f; box-shadow: 0 0 6px 2px rgba(253,196,31,.35); flex: none; }
#bt-sous-terre { display: flex; align-items: center; gap: 12px; width: 100%; margin-top: 8px; text-align: left; padding: 10px 12px; }
#bt-sous-terre .libelle { display: flex; flex-direction: column; flex: 1; line-height: 1.3; }
#bt-sous-terre small { color: var(--doux); font-size: 11.5px; }
.interrupteur { width: 38px; height: 22px; border-radius: 11px; background: #3a4552; position: relative; flex: none; transition: background-color .15s; }
.interrupteur::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .15s; }
#bt-sous-terre[aria-checked="true"] .interrupteur { background: var(--accent); }
#bt-sous-terre[aria-checked="true"] .interrupteur::after { transform: translateX(16px); }
#bandeau {
  position: fixed; z-index: 6; left: 50%; transform: translateX(-50%); top: 76px; max-width: min(620px, calc(100% - 24px));
  background: #3a2a12; border: 1px solid #8a6a2a; color: #ffdca0; padding: 8px 10px 8px 14px; border-radius: 10px; font-size: 13px;
  display: flex; gap: 12px; align-items: center;
}
#bandeau[hidden] { display: none; }
#bandeau .petit { min-height: 32px; padding: 4px 10px; background: #5a4318; border-color: #8a6a2a; color: #ffe7bd; white-space: nowrap; }
#bandeau { width: max-content; padding: 2px 4px 2px 12px; gap: 6px; line-height: 1.3; }
#bandeau .texte { flex: 1; min-width: 0; background: none; border: 0; padding: 4px 0; color: inherit; font: inherit; text-align: left; cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#bandeau.ouvert .texte { white-space: normal; max-height: 30vh; overflow-y: auto; }
#bandeau .fermer { flex: none; align-self: flex-start; background: none; border-color: transparent; color: inherit; }

/* écran de démarrage et erreurs */
#demarrage { position: fixed; inset: 0; z-index: 20; display: flex; flex-direction: column; gap: 14px; align-items: center; justify-content: center; background: var(--fond); color: var(--doux); padding: 20px; text-align: center; }
#demarrage[hidden] { display: none; }
.roue { width: 34px; height: 34px; border-radius: 50%; border: 3px solid var(--trait); border-top-color: var(--accent); animation: tourne .9s linear infinite; }
@keyframes tourne { to { transform: rotate(360deg); } }
.erreur { background: #2b1a1d; border: 1px solid #6b3138; color: #ffd2d6; border-radius: 10px; padding: 12px 14px; display: flex; flex-direction: column; gap: 10px; align-items: flex-start; max-width: 420px; }
.erreur p { margin: 0; }
#demarrage .erreur { align-items: center; text-align: center; }

/* panneaux : « Lignes » à gauche, « Ma ligne » à droite ; tiroirs en bas sur téléphone */
#panneau, #detail {
  position: fixed; z-index: 5; top: 76px; bottom: 34px; display: flex; flex-direction: column;
  background: color-mix(in srgb, var(--panneau) 97%, transparent); border: 1px solid var(--trait); border-radius: 14px;
  backdrop-filter: blur(8px); box-shadow: 0 10px 40px rgba(0,0,0,.45); overflow: hidden; transition: transform .25s ease;
}
#panneau { left: 12px; width: 360px; transform: translateX(calc(-100% - 24px)); visibility: hidden; }
#panneau.ouvert { transform: none; visibility: visible; }
#detail { right: 12px; width: 400px; bottom: 96px; }
#detail[hidden] { display: none; }
#detail.replie { bottom: auto; }
#detail.replie #vue-detail > :not(.tete-detail) { display: none; }
#detail.replie .tete-detail { margin-bottom: -10px; }
#poignee, #poignee-detail { display: none; }
.tete-detail .replier .ico { transition: transform .2s; }
#detail.replie .tete-detail .replier .ico { transform: rotate(180deg); }
#vue-liste, #vue-detail { overflow: auto; padding: 14px; flex: 1; overscroll-behavior: contain; }
.tete-detail .titre { flex: 1; }
#vue-liste[hidden], #vue-detail[hidden] { display: none; }
.entete-panneau { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.entete-panneau h2 { font-size: 16px; }
.icone { padding: 0; width: 40px; min-height: 40px; display: inline-flex; align-items: center; justify-content: center; background: transparent; border-color: transparent; }
.champ { position: relative; margin-bottom: 12px; }
.champ .ico { position: absolute; left: 12px; top: 13px; color: var(--doux); pointer-events: none; }
#recherche {
  width: 100%; font: inherit; font-size: 15px; color: var(--texte); background: var(--fond); border: 1px solid var(--trait);
  border-radius: 10px; padding: 11px 12px 11px 38px; min-height: 44px;
}
#recherche::placeholder { color: #7d8996; }
#modes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
#modes button { display: flex; flex-direction: column; align-items: center; gap: 2px; line-height: 1.2; padding: 8px 4px; }
#modes button .ico { width: 22px; height: 22px; margin-bottom: 2px; }
#modes button[aria-pressed="false"] { opacity: .5; }
#modes small { color: var(--doux); font-size: 11.5px; }
.groupe h3, #resultats h3 { font-size: 12px; color: var(--doux); font-weight: 600; margin: 16px 0 8px; }
.rangee {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; background: transparent; border-color: transparent;
  padding: 8px; min-height: 48px; margin-bottom: 2px;
}
.rangee:hover { background: var(--panneau-2); border-color: var(--trait); }
.parcours { color: var(--texte); font-size: 13.5px; line-height: 1.3; display: flex; flex-direction: column; }
.parcours small { color: var(--doux); font-size: 12px; }
.badge { display: inline-flex; align-items: center; justify-content: center; font-weight: 800; padding: 3px 8px; border-radius: 7px; font-size: 14px; min-width: 42px; min-height: 28px; flex: none; }
.badge.grand { font-size: 18px; min-width: 52px; min-height: 36px; border-radius: 9px; }
.puces { display: flex; flex-wrap: wrap; gap: 6px; }
.puce { min-width: 46px; min-height: 40px; padding: 4px 8px; font-weight: 750; font-size: 13px; border-radius: 7px; border: 0; }
.puce:hover { filter: brightness(1.15); }
.discret { color: var(--doux); }
.chargement::before { content: ""; display: inline-block; width: 12px; height: 12px; margin-right: 8px; border-radius: 50%; border: 2px solid var(--trait); border-top-color: var(--accent); animation: tourne .9s linear infinite; vertical-align: -1px; }

/* détail : ligne ou station */
.tete-detail { display: flex; align-items: center; gap: 10px; margin: -4px 0 12px; position: sticky; top: -14px; background: var(--panneau); padding: 6px 0; z-index: 2; }
.tete-detail .retour { margin-left: -8px; }
.tete-detail .titre { min-width: 0; }
.tete-detail h2 { font-size: 17px; }
.tete-detail p { margin: 0; color: var(--doux); font-size: 12.5px; }
.sens { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-bottom: 10px; }
.sens button { display: flex; flex-direction: column; align-items: flex-start; text-align: left; line-height: 1.25; padding: 8px 10px; }
.sens button small { color: var(--doux); font-size: 11px; }
.sens button span { font-weight: 600; font-size: 13px; }
.sens button[aria-pressed="true"] { border-color: var(--accent); background: #16283b; }
.etat { color: var(--doux); font-size: 12.5px; margin: 0 0 6px; }
.legende-passages { display: flex; gap: 14px; font-size: 12px; color: var(--doux); margin: 0 0 8px; }
.legende-passages span::before, .tag::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; vertical-align: 1px; }
.legende-passages .tr::before, .tag.tr::before { background: var(--reel); }
.legende-passages .th::before, .tag.th::before { border: 1.5px dashed var(--theo); width: 6px; height: 6px; }
.legende-passages .sp::before, .tag.sp::before { background: #ff8a8a; border-radius: 1px; height: 2px; width: 10px; vertical-align: 3px; }
.passage.supprime { background: #2b1a1d; border: 1px solid #6b3138; }
.passage.supprime strong { color: #ff9c9c; font-size: 12px; text-decoration: none; }
.passage.supprime small { text-decoration: line-through; }
.passage .retard, .passage .avance { font-weight: 700; }

.schema { --c: #888; position: relative; }
.branche { font-size: 13px; margin: 16px 0 4px; color: var(--texte); }
.branche small { color: var(--doux); font-weight: 400; }
.branche-liste { list-style: none; margin: 0; padding: 0; position: relative; }
.arret { display: grid; grid-template-columns: 52px 1fr auto; align-items: center; height: 52px; position: relative; }
.rail { position: relative; height: 100%; }
.rail::before { content: ""; position: absolute; left: 22px; width: 8px; top: 0; bottom: 0; background: var(--c); }
.arret:first-child .rail::before { top: 50%; }
.arret:last-child .rail::before { bottom: 50%; }
.rail::after { content: ""; position: absolute; left: 18px; top: calc(50% - 8px); width: 16px; height: 16px; border-radius: 50%; background: #fff; border: 3px solid var(--c); box-sizing: border-box; }
.arret.attache { opacity: .55; }
.arret .nom { background: transparent; border-color: transparent; text-align: left; padding: 4px 6px; min-height: 44px; display: flex; flex-direction: column; justify-content: center; gap: 3px; min-width: 0; }
.arret .nom:hover { background: var(--panneau-2); }
.arret .nom > span:first-child { font-size: 13.5px; font-weight: 550; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.corresp { display: flex; gap: 3px; flex-wrap: wrap; }
.mini { font-size: 10px; font-weight: 800; padding: 0 4px; border-radius: 4px; line-height: 15px; min-width: 0; min-height: 0; }
.mini.bus { background: var(--panneau-2); color: var(--doux); font-weight: 600; }
.prochains { display: flex; gap: 4px; justify-content: flex-end; }
.passage { display: inline-flex; flex-direction: column; align-items: center; border-radius: 7px; padding: 3px 7px; line-height: 1.15; min-width: 50px; background: var(--panneau-2); border: 1px dashed #4a5664; }
.passage strong { font-size: 13px; font-weight: 700; }
.passage small { font-size: 10.5px; color: var(--doux); }
.passage.tr { background: #11301f; border: 1px solid #1f6a40; }
.passage.tr strong { color: #7be3a9; }
.aucun { color: #7d8996; font-size: 12px; }
.rames { position: absolute; left: 0; top: 0; width: 52px; height: 100%; pointer-events: none; }
.rame {
  position: absolute; width: 20px; height: 22px; min-height: 0; padding: 0; border-radius: 6px; border: 2px solid #0f1419;
  display: flex; align-items: center; justify-content: center; pointer-events: auto; transform: translateY(-50%);
  transition: top 1s linear; box-shadow: 0 2px 6px rgba(0,0,0,.5);
}
.rame .ico { width: 13px; height: 13px; stroke-width: 3; }
.rame.bas { left: 0; }
.rame.bas .ico { transform: rotate(-90deg); }
.rame.haut { left: 32px; }
.rame.haut .ico { transform: rotate(90deg); }
.rame:not(.tr) { background-image: repeating-linear-gradient(135deg, rgba(0,0,0,.28) 0 3px, transparent 3px 6px); }
.rame.choisie { outline: 2px solid var(--accent); outline-offset: 1px; }
.note { color: var(--doux); font-size: 12px; margin: 12px 0 0; }

.ligne-station { border-top: 1px solid var(--trait); padding: 10px 0; }
.tete-ligne { display: flex; align-items: center; gap: 10px; width: 100%; background: transparent; border-color: transparent; padding: 4px; text-align: left; }
.tete-ligne:hover { background: var(--panneau-2); }
.direction { padding: 6px 4px 2px; }
.vers { margin: 0 0 6px; font-size: 13px; font-weight: 600; }
ul.passages { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 5px; }
ul.passages .autre { font-size: 10px; color: var(--doux); max-width: 90px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* fiche du véhicule */
#fiche {
  position: fixed; z-index: 7; left: 50%; transform: translateX(-50%); bottom: 36px; width: 340px; max-width: calc(100% - 24px);
  background: var(--panneau); border: 1px solid var(--trait); border-radius: 14px; padding: 14px;
  box-shadow: 0 10px 34px rgba(0,0,0,.55);
}
#fiche[hidden] { display: none; }
.actions-suivi { display: flex; gap: 8px; margin-top: 12px; }
.actions-suivi button { flex: 1; min-height: 44px; }
#fiche .dans { display: block; color: var(--accent); font-weight: 650; }
.fin-suivi { margin: 0 0 12px; font-size: 14px; }
.note-courte { color: var(--doux); font-size: 12px; margin: 8px 0 0; }
@media (min-width: 721px) {
  #fiche { left: auto; right: 12px; top: 76px; bottom: auto; transform: none; max-height: calc(100% - 120px); overflow: auto; }
  body.detail-ouvert #fiche { right: 424px; }
}
#fiche .tete { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
#fiche .mode { color: var(--doux); font-size: 12px; }
#fiche .dir { font-size: 15px; font-weight: 650; }
#fiche .fermer { margin-left: auto; align-self: flex-start; margin-top: -6px; margin-right: -6px; }
#fiche dl, #aide dl { margin: 10px 0 0; display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; }
#fiche dt, #aide dt { color: var(--doux); }
#fiche dd, #aide dd { margin: 0; }
#fiche .lien { margin-top: 10px; width: 100%; color: var(--accent); }
.statut { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 99px; font-size: 12px; font-weight: 600; margin-bottom: 6px; }
.statut.reel { background: #12331f; color: var(--reel); border: 1px solid #1f6a40; }
.statut.theo { background: var(--panneau-2); color: var(--theo); border: 1px dashed var(--doux); }
.retard { color: #ffb86b; font-weight: 600; }
.avance, .ponctuel { color: var(--reel); font-weight: 600; }

/* fenêtre d'aide */
#voile { position: fixed; inset: 0; z-index: 10; background: rgba(5,8,11,.7); display: flex; align-items: center; justify-content: center; padding: 12px; }
#voile[hidden] { display: none; }
#aide {
  position: relative; background: var(--panneau); border: 1px solid var(--trait); border-radius: 16px; padding: 22px;
  width: min(700px, 100%); max-height: 100%; overflow: auto;
}
#aide h2 { font-size: 20px; margin-bottom: 12px; padding-right: 56px; }
#aide h3 { font-size: 14px; margin: 16px 0 6px; }
#aide > .icone { position: absolute; top: 12px; right: 12px; }
#aide p, #aide li { color: #c3ccd6; }
#aide li { margin-bottom: 4px; }
#aide .franc { margin: 0 0 12px; padding: 10px 12px; border-left: 3px solid #8a6a2a; background: #2a2316; color: #ffdca0; }
#aide .deux { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 8px; }
#aide .deux > div { background: var(--panneau-2); border-radius: 10px; padding: 12px; }
#aide .deux p { margin: 4px 0; }
.legende-ligne { display: flex; align-items: center; gap: 8px; color: var(--texte) !important; }
#aide ul { padding-left: 18px; margin: 8px 0; }
#aide .petit { font-size: 12px; color: var(--doux); }
.tag { white-space: nowrap; font-weight: 600; }

#credits { position: fixed; z-index: 4; bottom: 0; left: 0; right: 0; padding: 4px 10px; font-size: 11px; color: var(--doux); background: rgba(15,20,25,.85); }
#credits a { color: var(--doux); }

.maplibregl-canvas { outline: none; }
.maplibregl-ctrl-group { background: var(--panneau) !important; border: 1px solid var(--trait); }
.maplibregl-ctrl-group button { background: transparent; border: 0 !important; min-height: 29px; border-radius: 0; }
.maplibregl-ctrl-icon { filter: invert(1); }

@media (max-width: 1100px) and (min-width: 721px) {
  #legende { display: none; }
  #actions button > span { display: none; }
  #bt-aide > span { display: inline !important; }
}

@media (max-width: 720px) {
  #haut { top: 8px; left: 8px; right: 8px; gap: 6px; }
  #marque { flex: 1 1 100%; padding: 6px 12px; }
  #compteur { font-size: 12px; }
  #legende { flex: 1 1 100%; padding: 4px 10px; gap: 10px; font-size: 12px; min-height: 0; justify-content: center; }
  /* une feuille ouverte (ligne, station, fiche) : la barre du haut se réduit pour laisser la carte (au moins 45 % de la hauteur) */
  body.detail-ouvert #compteur, body.detail-ouvert #legende, body:has(#fiche:not([hidden])) #compteur, body:has(#fiche:not([hidden])) #legende { display: none; }
  #actions { width: 100%; margin: 0; }
  #actions button { flex: 1; justify-content: center; font-size: 13px; padding: 6px; }
  #bt-aide > span { font-size: 0; }
  #bt-aide > span::after { content: "Aide"; font-size: 13px; }
  #bandeau { top: 150px; }
  #panneau, #detail {
    top: auto; left: 0; right: 0; bottom: 0; width: auto; height: 62vh; height: 62dvh; border-radius: 16px 16px 0 0; border-bottom: 0;
    visibility: visible; padding-bottom: env(safe-area-inset-bottom);
  }
  #panneau { transform: translateY(calc(100% - 132px)); } /* replié : poignée, titre et recherche restent visibles */
  #panneau.ouvert { transform: none; }
  body.detail-ouvert #panneau { display: none; }
  #panneau { height: 52vh; height: 52dvh; }
  #detail { height: 36vh; height: 36dvh; min-height: 230px; }
  body:has(#fiche:not([hidden])) #detail, body:has(#fiche:not([hidden])) #panneau { display: none; } /* une seule feuille à la fois : la fiche remplace la feuille de la ligne */
  #detail.replie { bottom: 0; transform: translateY(calc(100% - 92px)); }
  #detail.replie #vue-detail > :not(.tete-detail) { display: revert; }
  #poignee, #poignee-detail { display: flex; justify-content: center; align-items: center; width: 100%; min-height: 26px; padding: 8px 0 2px; border: 0; background: transparent; border-radius: 0; flex: none; }
  #poignee span, #poignee-detail span { width: 44px; height: 5px; border-radius: 3px; background: #4a5664; }
  #vue-liste, #vue-detail { padding: 6px 12px 40px; }
  .entete-panneau { margin-bottom: 8px; }
  .tete-detail { top: -6px; }
  .prochains .passage:nth-child(3) { display: none; } /* deux passages par station sur téléphone : le nom reste lisible */
  #fiche { padding: 10px 12px; }
  #fiche .note, #fiche .lien { display: none; } /* téléphone : fiche compacte, la carte reste visible ; la mention « pas un GPS » reste */
  #fiche dl { margin-top: 4px; }
  .actions-suivi { margin-top: 8px; }
  #fiche { left: 8px; right: 8px; bottom: calc(8px + env(safe-area-inset-bottom)); width: auto; max-width: none; transform: none; max-height: 36vh; max-height: 36dvh; overflow: auto; }
  #fiche .mode { display: none; }
  #fiche dl { font-size: 13px; gap: 2px 10px; }
  #fiche .statut { margin-bottom: 2px; }
  #fiche .actions-suivi button { min-height: 40px; }
  #fiche .note-courte { margin-top: 6px; font-size: 11.5px; }
  #fiche .tete { margin-bottom: 4px; }
  #fiche .dir { font-size: 14px; }
  body.detail-ouvert .maplibregl-ctrl-bottom-right { bottom: calc(36dvh + 8px) !important; }
  body.detail-ouvert:has(#detail.replie) .maplibregl-ctrl-bottom-right { bottom: 100px !important; }
  body:has(#fiche:not([hidden])) .maplibregl-ctrl-bottom-right { bottom: calc(36dvh + 8px) !important; }
  body.detail-ouvert #credits { bottom: 36dvh; }
  body.detail-ouvert:has(#detail.replie) #credits { bottom: 92px; }
  body:has(#fiche:not([hidden])) #credits { bottom: 36dvh; }
  #aide .deux { grid-template-columns: 1fr; }
  #aide { padding: 16px; }
  .maplibregl-ctrl-bottom-right { bottom: 140px !important; }
  #credits { bottom: 132px; font-size: 10px; padding: 2px 8px; background: rgba(15,20,25,.7); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation-duration: .01ms !important; }
}

/* accès clavier aux rames : invisibles, sauf celle qui a le focus */
#vehicules-clavier { list-style: none; margin: 0; padding: 0; }
#vehicules-clavier li { position: fixed; z-index: 9; left: 50%; bottom: 44px; transform: translateX(-50%); width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
#vehicules-clavier li:focus-within { width: auto; height: auto; overflow: visible; clip: auto; }

/* filtre « Tout / Temps réel seulement » (barre du haut) */
#legende .filtre { display: flex; gap: 2px; padding: 2px; background: var(--fond); border-radius: 9px; border: 1px solid var(--trait); }
#legende .filtre button { border: 0; background: transparent; min-height: 34px; padding: 4px 10px; display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--doux); border-radius: 7px; }
#legende .filtre button[aria-pressed="true"] { background: #1d3550; color: #e5f1ff; }
#legende .filtre b { font-weight: 700; color: var(--texte); }
#legende .filtre .pastille { width: 11px; height: 11px; }
#actions button#bt-iti[aria-pressed="true"] { background: #1d3550; color: #cfe6ff; }

/* perturbations : liste des lignes, puces de bus, fiche de la ligne */
.petit-texte { font-size: 12px; margin: 10px 0 0; }
.pert-resume:empty { display: none; }
.rangee .motif { color: #ffb86b; font-size: 11.5px; }
.rangee.grave .motif { color: #ff9c9c; }
.rangee.pert { border-left: 3px solid #f0a030; }
.rangee.pert.grave { border-left-color: #ff5a5a; }
.rangee.barre .parcours > :first-child, .rangee.barre > .parcours:not(:has(> span)) { text-decoration: line-through; text-decoration-color: #ff5a5a; }
.puce.pert { position: relative; outline: 2px solid #f0a030; outline-offset: 1px; }
.puce.pert.grave { outline-color: #ff5a5a; }
.puce.barre { text-decoration: line-through; text-decoration-thickness: 2px; }
.alerte-ligne { border-radius: 10px; padding: 10px 12px; margin: 0 0 10px; font-size: 13px; }
.alerte-ligne[hidden] { display: none; }
.alerte-ligne.moyen { background: #2c2213; border: 1px solid #7a5a22; color: #ffdca0; }
.alerte-ligne.grave { background: #2b1a1d; border: 1px solid #6b3138; color: #ffd2d6; }
.alerte-ligne p { margin: 2px 0; }
.alerte-ligne .titre-alerte { display: flex; align-items: center; gap: 8px; }
.alerte-ligne blockquote { margin: 8px 0 0; padding: 6px 10px; border-left: 3px solid currentColor; background: rgba(0,0,0,.2); border-radius: 0 6px 6px 0; }
.alerte-ligne blockquote small { opacity: .8; }

/* itinéraire */
.itin-form { display: flex; flex-direction: column; gap: 10px; }
.lieux { display: grid; grid-template-columns: 1fr 44px; grid-template-rows: auto auto; gap: 8px; align-items: end; }
.lieux .champ-lieu:nth-child(1) { grid-column: 1; grid-row: 1; }
.lieux .champ-lieu:nth-child(2) { grid-column: 1; grid-row: 2; }
.lieux .inverser { grid-column: 2; grid-row: 1 / 3; align-self: center; border: 1px solid var(--trait); }
.champ-lieu { position: relative; display: flex; flex-direction: column; gap: 3px; }
.champ-lieu label, .heure label { font-size: 12px; color: var(--doux); font-weight: 600; }
.champ-lieu input, .heure input {
  width: 100%; background: var(--fond); color: var(--texte); border: 1px solid var(--trait); border-radius: 10px; padding: 10px 12px; min-height: 44px; font: inherit;
}
.champ-lieu:first-child input { border-left: 4px solid #4fd18b; }
.champ-lieu:nth-child(2) input { border-left: 4px solid #ff8a8a; }
.heure input { width: auto; color-scheme: dark; }
.heure { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.heure .petit[aria-pressed="true"] { border-color: var(--accent); background: #16283b; }
.heure .principal { margin-left: auto; }
.suggestions { position: absolute; z-index: 6; top: 100%; left: 0; right: 0; margin: 4px 0 0; padding: 4px; list-style: none; background: var(--panneau-2); border: 1px solid #3d4a58; border-radius: 10px; box-shadow: 0 10px 30px rgba(0,0,0,.5); max-height: 280px; overflow: auto; }
.suggestions[hidden] { display: none; }
.suggestions li { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 10px; border-radius: 7px; cursor: pointer; min-height: 44px; }
.suggestions li:hover, .suggestions li[aria-selected="true"] { background: var(--survol); }
.suggestions .nom { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.suggestions .nom small { color: var(--doux); font-size: 11.5px; }
.suggestions .lignes-arret { display: flex; gap: 3px; flex: none; }
.suggestions .vide { color: var(--doux); cursor: default; }
.itin-res { margin-top: 12px; }
.itin-entete { color: var(--doux); font-size: 12px; margin: 0 0 6px; }
.trajets { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.trajet { width: 100%; text-align: left; display: flex; flex-direction: column; gap: 6px; padding: 10px 12px; background: var(--panneau-2); }
.trajet[aria-pressed="true"] { border-color: var(--accent); background: #16283b; box-shadow: inset 3px 0 0 var(--accent); }
.trajet .horaires { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.trajet .horaires strong { font-size: 16px; }
.trajet .duree { font-weight: 700; color: #cfe6ff; }
.trajet .chaine { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; }
.trajet .chaine .mini { font-size: 12px; line-height: 20px; padding: 0 6px; }
.trajet .fleche { color: var(--doux); }
.trajet .pied { display: inline-flex; align-items: center; gap: 2px; color: var(--doux); font-size: 12px; }
.trajet .pied .ico, .etapes .ico { width: 15px; height: 15px; }
.trajet .meta { display: flex; flex-wrap: wrap; gap: 4px 12px; color: var(--doux); font-size: 12px; }
.avert { display: flex; gap: 6px; align-items: flex-start; margin: 0; color: #ffb86b; font-size: 12px; }
.avert .ico { width: 15px; height: 15px; margin-top: 1px; }
.etapes h3 { font-size: 12px; color: var(--doux); margin: 14px 0 6px; }
.etapes ol { list-style: none; margin: 0; padding: 0; }
.etapes li { padding: 6px 0 8px 14px; border-left: 4px dotted #6b7886; margin-left: 6px; }
.etapes li.e-ligne { border-left: 4px solid var(--c); }
.etapes p { margin: 2px 0; font-size: 13px; }
.etapes .e-tete { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.etapes small { color: var(--doux); font-size: 11.5px; display: block; margin: 2px 0; }
.etapes .retard { color: #ffb86b; font-weight: 700; }
.etapes .avance { color: #8fd9ff; font-weight: 700; }

@media (max-width: 1100px) and (min-width: 721px) {
  #legende { display: flex; }
  #legende li:not(.filtre) { display: none; }
}
@media (max-width: 720px) {
  #legende li:not(.filtre) { display: none; }
  #legende { padding: 3px; }
  #legende .filtre { width: 100%; }
  #legende .filtre button { flex: 1; justify-content: center; font-size: 12px; padding: 4px 6px; }
  #detail.itin { height: 50vh; height: 50dvh; }
  body.detail-ouvert:has(#detail.itin:not(.replie)) .maplibregl-ctrl-bottom-right { bottom: calc(50dvh + 8px) !important; }
  body.detail-ouvert:has(#detail.itin:not(.replie)) #credits { bottom: 50dvh; }
  .heure .principal { flex: 1 1 100%; margin-left: 0; }
}
