:root {
  /* Palettes gris foncé quel que soit le thème du système, comme les apps (cl26.11.09). */
  color-scheme: dark;
  --encre: #f2f2f4;
  --gris: #a1a1a6;
  --fond: rgba(38, 38, 42, .88);
  --trait: rgba(255, 255, 255, .14);
  --accent: #4cb8d8;
  --danger: #ff6b5e;
  --ombre: 0 3px 10px rgba(0, 0, 0, .35);
  --bord: 12px;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #dfe3e8; }
body { font: 14px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", Arial, sans-serif; color: var(--encre); }
#carte { position: absolute; inset: 0; }

/* Pastilles « matière » de l'app : fond translucide, coins de 14, ombre. */
.pastille {
  background: var(--fond); backdrop-filter: blur(14px) saturate(1.4); -webkit-backdrop-filter: blur(14px) saturate(1.4);
  border: 1px solid rgba(255, 255, 255, .12); border-radius: 14px; box-shadow: var(--ombre);
}
.pastille button, .bouton {
  font: inherit; color: inherit; background: transparent; border: 0; border-radius: 9px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; white-space: nowrap;
}
.pastille button:hover, .bouton:hover { background: rgba(127, 127, 127, .16); }
.pastille button.actif { color: var(--accent); }
button:focus-visible, input:focus-visible, .bouton:focus-within { outline: 2px solid var(--accent); outline-offset: 1px; }
/* Symboles SF de l'app (icones.svg, tirés de SF Pro) ; .on = variante pleine, montrée à l'état actif (cl26.11.11). */
.ic { width: 24px; height: 24px; fill: currentColor; }
.ic .on, .actif .ic .off, .rouge .ic .off { display: none; }
.actif .ic .on, .rouge .ic .on { display: inline; }
hr { border: 0; border-top: 1px solid var(--trait); width: 28px; margin: 2px auto; }

.gauche { position: absolute; z-index: 3; top: var(--bord); left: var(--bord); display: flex; flex-direction: column; gap: 8px; align-items: flex-start; width: min(340px, calc(100% - 90px)); }
.recherche { position: relative; width: 100%; }
#recherche::placeholder { color: var(--gris); }
#recherche {
  width: 100%; font: inherit; color: var(--encre); background: var(--fond); border: 1px solid rgba(255, 255, 255, .12);
  border-radius: 12px; padding: 9px 12px; box-shadow: var(--ombre); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
}
#resultats {
  position: absolute; top: 100%; left: 0; right: 0; margin: 4px 0 0; padding: 4px 0; list-style: none; z-index: 5;
  background: var(--fond); backdrop-filter: blur(14px); border-radius: 12px; box-shadow: var(--ombre); max-height: 50vh; overflow: auto;
}
#resultats li { padding: 7px 12px; cursor: pointer; }
#resultats li small { color: var(--gris); display: block; }
#resultats li:hover, #resultats li.choisi { background: rgba(127, 127, 127, .16); }

/* Boussole : anneau gradué qui tourne avec la carte, l'œil au centre. */
.boussole-bloc { padding: 6px; display: flex; align-items: stretch; gap: 4px; }
.boussole-colonne { display: flex; flex-direction: column; align-items: center; gap: 2px; }
/* Curseurs verticaux à droite de la boussole : inclinaison, angle de vue. */
.curseur { display: flex; flex-direction: column; align-items: center; gap: 2px; width: 26px; color: var(--gris); font: 600 10px ui-rounded, -apple-system, sans-serif; font-variant-numeric: tabular-nums; }
.curseur .ic { width: 15px; height: 15px; }
.curseur input { writing-mode: vertical-lr; direction: rtl; width: 18px; flex: 1; min-height: 56px; margin: 0; accent-color: var(--accent); cursor: ns-resize; }
.boussole { width: 60px; height: 60px; border-radius: 50% !important; position: relative; }
.anneau {
  position: absolute; inset: 0; border-radius: 50%; border: 13px solid rgba(127, 127, 127, .26);
  background: radial-gradient(circle, rgba(127, 127, 127, .14) 0 14px, transparent 15px);
}
.nord { position: absolute; top: -12px; left: 50%; transform: translateX(-50%); font: 800 10px ui-rounded, -apple-system, sans-serif; color: #e0352b; }
.boussole.actif .nord { color: var(--accent); }
.boussole .ic { width: 17px; height: 17px; position: relative; }
.tours { display: flex; }
.tours button { width: 32px; height: 28px; }
.tours .ic { width: 18px; height: 18px; }
.demi { width: 30px !important; font: 700 10px ui-rounded, -apple-system, sans-serif; }

.palette { position: absolute; z-index: 3; top: var(--bord); right: var(--bord); display: flex; flex-direction: column; padding: 4px 0; }
.palette button { width: 44px; height: 42px; }

.barre {
  position: absolute; z-index: 3; bottom: 30px; left: 50%; transform: translateX(-50%); display: flex; gap: 6px;
  padding: 6px 8px; border-radius: 999px;
}
.barre button, .barre a { width: 44px; height: 40px; border-radius: 999px; }
.barre a { color: inherit; display: inline-flex; align-items: center; justify-content: center; }
.barre a:hover { background: rgba(127, 127, 127, .16); }
.barre button.rouge { color: #e0352b; }

.menu {
  position: absolute; bottom: 86px; left: 50%; transform: translateX(-50%); padding: 10px 12px; width: 250px;
  display: flex; flex-direction: column; gap: 6px; z-index: 4;
}
.menu strong { font-size: 12px; color: var(--gris); text-transform: uppercase; letter-spacing: .04em; margin-top: 4px; }
.menu label { display: flex; gap: 8px; align-items: center; cursor: pointer; }
#fonds { display: flex; flex-direction: column; }
#fonds button { justify-content: flex-start; padding: 6px 8px; }
#fonds button.actif { color: var(--accent); font-weight: 600; }
.menu summary { cursor: pointer; color: var(--gris); font-size: 13px; margin-top: 4px; }
.raccourcis { margin: 6px 0 0; padding: 0; list-style: none; font-size: 12.5px; display: flex; flex-direction: column; gap: 3px; }
kbd { font: 600 11px -apple-system, sans-serif; border: 1px solid var(--trait); border-radius: 4px; padding: 0 4px; margin-right: 2px; background: rgba(127, 127, 127, .1); }

.panneau {
  position: absolute; left: 50%; transform: translateX(-50%); bottom: 86px; width: min(560px, calc(100% - 24px)); max-height: 55vh;
  display: flex; flex-direction: column; overflow: hidden; z-index: 3;
}
.panneau button, .panneau .bouton { padding: 6px 10px; border: 1px solid var(--trait); }
.panneau-tete, .detail-tete { display: flex; gap: 6px; align-items: center; padding: 10px; flex-wrap: wrap; }
.espace { flex: 1; }
#liste { list-style: none; margin: 0; padding: 0 6px 6px; overflow: auto; max-height: 22vh; }
#liste li { padding: 6px 8px; border-radius: 8px; cursor: pointer; display: flex; gap: 8px; }
#liste li small { color: var(--gris); margin-left: auto; }
#liste li.choisi, #liste li:hover { background: rgba(127, 127, 127, .14); }
#liste:empty::after { content: "Aucun trajet. Importez un fichier GPX ou enregistrez une sortie."; color: var(--gris); padding: 6px 8px; display: block; }
#detail { border-top: 1px solid var(--trait); }
#nom-trace { font: inherit; font-weight: 600; color: inherit; background: transparent; border: 0; min-width: 0; flex: 1 1 140px; }
.danger { color: var(--danger) !important; }
.stats { display: flex; gap: 14px; flex-wrap: wrap; padding: 0 10px 6px; color: var(--gris); }
.stats b { color: var(--encre); font-weight: 600; }
.profil { width: 100%; height: 110px; display: block; cursor: crosshair; }
.profil .aire { fill: rgba(31, 143, 176, .22); stroke: var(--accent); stroke-width: 1.5; vector-effect: non-scaling-stroke; }
.profil .curseur { stroke: var(--encre); stroke-width: 1; vector-effect: non-scaling-stroke; }

.message {
  position: absolute; left: 50%; top: 14px; transform: translateX(-50%); background: var(--fond); backdrop-filter: blur(14px);
  padding: 9px 14px; border-radius: 999px; box-shadow: var(--ombre); max-width: calc(100% - 24px); font-weight: 600; z-index: 6;
}
.photo-pin { width: 44px; height: 44px; border-radius: 8px; border: 2px solid #fff; box-shadow: var(--ombre); background: #ccc center / cover; cursor: pointer; }
.photo-grande { max-width: min(70vw, 520px); max-height: 60vh; display: block; border-radius: 6px; }
.maplibregl-popup-content { padding: 6px; }

@media (max-width: 640px) {
  .gauche { width: calc(100% - 80px); }
  .barre { bottom: 22px; gap: 2px; }
  .menu { bottom: 78px; }
  .panneau { width: 100%; border-radius: 14px 14px 0 0; bottom: 0; max-height: 50vh; }
}
#b-fermer .ic { width: 18px; height: 18px; }
