/* Traces — mise en page sobre, claire ou sombre selon le téléphone. */
:root {
  --fond: #f4f5f2;
  --surface: #ffffff;
  --texte: #1b1f1d;
  --texte-2: #5d6560;
  --trait: #e1e4df;
  --accent: #c2255c;          /* boutons, liens, et couleur de la trace (carte + profil) */
  --accent-texte: #ffffff;
  --alerte-fond: #fdecef;
  --alerte-texte: #8a1238;
  --rayon: 14px;
  --ombre: 0 1px 2px rgba(20, 30, 25, .06), 0 4px 16px rgba(20, 30, 25, .05);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --fond: #111413;
    --surface: #1a1e1c;
    --texte: #eef1ee;
    --texte-2: #a3aca6;
    --trait: #2b312e;
    --accent: #f06595;
    --accent-texte: #1a0610;
    --alerte-fond: #3a1220;
    --alerte-texte: #ffc2d4;
    --ombre: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--fond); color: var(--texte);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-variant-numeric: tabular-nums;
}
main { max-width: 960px; margin: 0 auto; padding: 16px 16px calc(32px + env(safe-area-inset-bottom)); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.6rem; line-height: 1.2; margin: 0; letter-spacing: -.01em; }
h2 { font-size: 1rem; margin: 0 0 8px; }

/* En-tête */
.entete {
  display: flex; align-items: center; justify-content: space-between;
  max-width: 960px; margin: 0 auto; padding: calc(12px + env(safe-area-inset-top)) 16px 4px;
}
.marque { display: inline-flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.1rem; color: var(--texte); }
.marque:hover { text-decoration: none; }
.marque.grande { font-size: 1.8rem; justify-content: center; width: 100%; margin-bottom: 8px; }
.pastille {
  width: 14px; height: 14px; border-radius: 50%; background: var(--accent);
  box-shadow: 0 0 0 3px var(--surface), 0 0 0 5px var(--accent);
}
.marque.grande .pastille { width: 18px; height: 18px; }
.lien-discret {
  background: none; border: 0; padding: 8px 4px; font: inherit; font-size: .95rem;
  color: var(--texte-2); cursor: pointer;
}
.lien-discret:hover { color: var(--texte); }

/* Connexion et installation */
.carte-auth {
  max-width: 380px; margin: 12vh auto 0; background: var(--surface); border-radius: var(--rayon);
  padding: 28px 24px; box-shadow: var(--ombre); border: 1px solid var(--trait);
}
.carte-auth.large { max-width: 460px; margin-top: 4vh; }
.carte-auth h2 { margin-top: 8px; }
.formulaire { display: grid; gap: 14px; margin-top: 12px; }
.formulaire label { display: grid; gap: 6px; font-size: .9rem; color: var(--texte-2); }
input {
  font: inherit; font-size: 1rem; color: var(--texte); background: var(--fond);
  border: 1px solid var(--trait); border-radius: 10px; padding: 11px 12px; width: 100%;
}
input:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }
.bouton {
  font: inherit; font-weight: 600; border: 0; border-radius: 10px; padding: 12px 16px; cursor: pointer;
  background: var(--accent); color: var(--accent-texte); text-align: center; display: inline-block;
}
.bouton:hover { filter: brightness(1.06); text-decoration: none; }
.bouton.secondaire { background: var(--surface); color: var(--texte); border: 1px solid var(--trait); font-weight: 500; }
.alerte { background: var(--alerte-fond); color: var(--alerte-texte); border-radius: 10px; padding: 10px 12px; margin: 12px 0 0; }
.aide { color: var(--texte-2); font-size: .9rem; margin: 0; }
.qr { background: #fff; border-radius: 10px; padding: 10px; width: 220px; margin: 0 auto; }
.qr svg { display: block; width: 100%; height: auto; }
.cle { font-size: .85rem; word-break: break-all; }

/* Accueil */
.resume { color: var(--texte-2); margin: 4px 0 12px; }
.carte {
  height: 46vh; min-height: 260px; border-radius: var(--rayon); overflow: hidden;
  border: 1px solid var(--trait); background: var(--surface);
}
.carte.grande { height: 56vh; min-height: 300px; }
.liste { list-style: none; padding: 0; margin: 16px 0 0; display: grid; gap: 8px; }
.ligne {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  background: var(--surface); border: 1px solid var(--trait); border-radius: var(--rayon);
  padding: 12px 16px; color: var(--texte);
}
.ligne:hover { text-decoration: none; border-color: var(--accent); }
.ligne-titre { display: grid; min-width: 0; }
.ligne-titre strong { font-weight: 600; overflow-wrap: anywhere; }
.ligne-titre small, .ligne-chiffres small { color: var(--texte-2); font-size: .8rem; }
.ligne-chiffres { display: flex; gap: 18px; }
.ligne-chiffres span { display: grid; text-align: right; }
.vide { color: var(--texte-2); text-align: center; margin: 32px 0; }

/* Trace */
.retour { display: inline-block; margin: 4px 0 10px; font-size: .95rem; }
.titre-trace { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.form-titre { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 6px 0; }
.form-titre input { flex: 1 1 240px; width: auto; }
.form-titre[hidden] { display: none; }
.sous-titre { color: var(--texte-2); margin: 4px 0 14px; }
.sous-titre::first-letter { text-transform: uppercase; }
.tuiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; margin-bottom: 14px; }
.tuile {
  background: var(--surface); border: 1px solid var(--trait); border-radius: var(--rayon);
  padding: 12px 14px; display: grid; gap: 2px;
}
.tuile b { font-size: 1.35rem; font-weight: 650; letter-spacing: -.01em; }
.tuile small { color: var(--texte-2); font-size: .85rem; }
.tuile em { color: var(--texte-2); font-style: normal; font-size: .8rem; }
.profil {
  margin-top: 14px; background: var(--surface); border: 1px solid var(--trait);
  border-radius: var(--rayon); padding: 14px 14px 8px;
}
.graphe { position: relative; height: 190px; }
.graphe svg { display: block; width: 100%; height: 100%; overflow: visible; touch-action: pan-y; }
.graphe .axe { fill: var(--texte-2); font-size: 11px; }
.graphe .grille { stroke: var(--trait); stroke-width: 1; }
.graphe .ligne-profil { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.graphe .aire { fill: var(--accent); opacity: .1; }
.graphe .curseur { stroke: var(--texte-2); stroke-width: 1; }
.graphe .point { fill: var(--accent); stroke: var(--surface); stroke-width: 2; }
.bulle {
  position: absolute; top: 0; pointer-events: none; background: var(--texte); color: var(--fond);
  font-size: .8rem; line-height: 1.35; padding: 5px 8px; border-radius: 8px; white-space: nowrap;
  transform: translateX(-50%);
}
.bulle[hidden] { display: none; }
.vide-graphe { color: var(--texte-2); font-size: .9rem; margin: 12px 0; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.note { color: var(--texte-2); font-size: .82rem; margin-top: 14px; }

/* Leaflet : contrôles accordés au thème */
.leaflet-container { font: inherit; background: var(--fond); }
.leaflet-control-layers, .leaflet-bar a { background: var(--surface); color: var(--texte); border-color: var(--trait); }
.leaflet-control-layers-expanded { padding: 8px 10px; font-size: .9rem; }
.leaflet-control-attribution { font-size: 10px; }
.repere-depart, .repere-arrivee { border-radius: 50%; border: 3px solid #fff; box-shadow: 0 0 0 1px rgba(0,0,0,.35); }
.repere-depart { background: #2f9e44; }
.repere-arrivee { background: #1b1f1d; }

@media (max-width: 560px) {
  h1 { font-size: 1.35rem; }
  .ligne-chiffres { width: 100%; justify-content: space-between; }
  .ligne-chiffres span { text-align: left; }
  .tuiles { grid-template-columns: 1fr 1fr; }
  .carte-auth { margin-top: 6vh; }
}
