/* Groma — feuille unique. Écrite pour la tablette, l'outil de terrain réel ;
   les paliers descendants la rendent utilisable jusqu'au petit smartphone. */

/* Police des titres, de la marque et des boutons. Embarquée dans le dépôt et
   précachée par le service worker : une police distante disparaîtrait hors
   réseau. Licence SIL OFL, texte dans fonts/OFL.txt. Le texte courant reste en
   police système, les coordonnées en chasse fixe. */
@font-face {
  font-family: "Bricolage Grotesque";
  src: url("../fonts/bricolage-grotesque-latin.woff2") format("woff2");
  font-weight: 500 800;
  font-style: normal;
  font-display: swap;
}

/* Monde « carte topo » : papier crème parcouru de courbes de niveau, encre
   marine, jaune soleil pour l'action. Le clair reste le thème par défaut, parce
   que l'outil sert dehors et que les reflets écrasent un écran sombre. Les
   contours épais et les reliefs pleins ne sont pas qu'un style : ils restent
   visibles au soleil, là où un filet gris de 1 px disparaît.
   Le sombre est choisi dans Configuration ou laissé à l'appareil. */
:root {
  color-scheme: light;
  --accent: #0ea5e9;
  --fond: #fff8ef;
  --fond-2: #ffffff;
  --fond-3: #fff0dc;
  --encre: #1b1340;
  --bord: #eadcc6;
  --bord-champ: #1b1340;
  --texte: #1b1340;
  --texte-faible: #5b5480;
  --survol: #fff3c4;
  --soleil: #ffd84d;
  --sur-couleur: #0f0b26;
  --bande: #1b1340;
  --bande-2: #2c2163;
  --bande-texte: #d6cff7;
  --courbes: #ffd2a1;
  --danger: #c42b1c;
  --succes: #137a3a;
  --alerte: #8a5300;
  --alerte-fond: #fff4d1;
  --voile: rgba(27, 19, 64, 0.55);
  --relief: 0 4px 0 var(--encre);
  --relief-petit: 0 3px 0 var(--encre);
  --rayon: 18px;
  --gouttiere: 16px;
  --police-titres: "Bricolage Grotesque", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --police-chiffres: ui-monospace, "SF Mono", "Roboto Mono", Menlo, Consolas, monospace;

  /* Les couleurs de filière sont vives : en texte sur papier clair, le vert et
     le bleu ciel tombent sous 3:1. Mélangées à la couleur du texte, elles
     foncent ici et s'éclaircissent en sombre, sans seconde palette à tenir à
     jour dans config.js. En aplat, elles portent toujours --sur-couleur. */
  --accent-texte: color-mix(in oklab, var(--accent) 58%, var(--texte));
}

/* Le thème sombre est déclaré deux fois : une pour l'appareil réglé en sombre,
   une pour le choix explicite. Pas de nesting CSS : les tablettes de terrain
   ont parfois quelques années de retard de navigateur. */
@media (prefers-color-scheme: dark) {
  :root[data-theme="auto"] {
    color-scheme: dark;
    --fond: #120c2e;
    --fond-2: #1e1650;
    --fond-3: #281e63;
    --encre: #05030f;
    --bord: #3a2f80;
    --bord-champ: #8f84d6;
    --texte: #f5f1ff;
    --texte-faible: #c2b9ef;
    --survol: #2f2470;
    --bande: #0b0720;
    --bande-2: #241a5a;
    --bande-texte: #c9c1f2;
    --courbes: #241b5c;
    --danger: #ff8a7a;
    --succes: #5ee38f;
    --alerte: #ffd25e;
    --alerte-fond: #2d2350;
    --voile: rgba(5, 3, 15, 0.75);
  }
}

:root[data-theme="sombre"] {
  color-scheme: dark;
  --fond: #120c2e;
  --fond-2: #1e1650;
  --fond-3: #281e63;
  --encre: #05030f;
  --bord: #3a2f80;
  --bord-champ: #8f84d6;
  --texte: #f5f1ff;
  --texte-faible: #c2b9ef;
  --survol: #2f2470;
  --bande: #0b0720;
  --bande-2: #241a5a;
  --bande-texte: #c9c1f2;
  --courbes: #241b5c;
  --danger: #ff8a7a;
  --succes: #5ee38f;
  --alerte: #ffd25e;
  --alerte-fond: #2d2350;
  --voile: rgba(5, 3, 15, 0.75);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  color: var(--texte);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

/* Encoches et barres système. `viewport-fit=cover` étend la page sous elles :
   sans ces marges, l'en-tête passe sous l'heure et la batterie sur iPhone, et
   la dernière ligne sous la barre de gestes. `env()` vaut zéro partout
   ailleurs — aucun effet sur un écran sans encoche. */
html { background: var(--fond); }

/* Courbes de niveau en fond : un masque SVG peint à la couleur --courbes, pour
   que le motif suive le thème sans seconde image. Le fond reste sur <html> :
   posé sur <body>, il recouvrirait ce calque placé en dessous du contenu. */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background: var(--courbes);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='440' height='320'%3E%3Cg fill='none' stroke='%23000' stroke-width='1.6'%3E%3Cpath d='M-20 60 C80 10 160 110 260 60 S420 20 470 70'/%3E%3Cpath d='M-20 100 C80 50 160 150 260 100 S420 60 470 110'/%3E%3Cpath d='M-20 140 C90 90 170 190 270 140 S420 100 470 150'/%3E%3Cpath d='M-20 220 C70 170 170 270 270 220 S420 180 470 230'/%3E%3Cpath d='M-20 260 C70 210 170 310 270 260 S420 220 470 270'/%3E%3C/g%3E%3C/svg%3E") 0 0 / 440px 320px repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='440' height='320'%3E%3Cg fill='none' stroke='%23000' stroke-width='1.6'%3E%3Cpath d='M-20 60 C80 10 160 110 260 60 S420 20 470 70'/%3E%3Cpath d='M-20 100 C80 50 160 150 260 100 S420 60 470 110'/%3E%3Cpath d='M-20 140 C90 90 170 190 270 140 S420 100 470 150'/%3E%3Cpath d='M-20 220 C70 170 170 270 270 220 S420 180 470 230'/%3E%3Cpath d='M-20 260 C70 210 170 310 270 260 S420 220 470 270'/%3E%3C/g%3E%3C/svg%3E") 0 0 / 440px 320px repeat;
}

body {
  padding-bottom: calc(40px + env(safe-area-inset-bottom));
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}

/* ---------- En-tête ---------- */

.barre-haute {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--bande);
  /* Le fond monte sous la barre d'état plutôt que de s'arrêter net : la zone
     système reste dans la continuité de l'application. */
  padding-top: env(safe-area-inset-top);
}

.entete {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px var(--gouttiere);
}

/* La marque reprend le logo de l'icône : épingle à mire sur un carrefour,
   posée en pastille claire sur la bande d'encre. */
.entete h1 {
  display: flex;
  align-items: center;
  gap: 9px;
  font-family: var(--police-titres);
  font-size: 1.4rem;
  margin: 0;
  letter-spacing: -0.02em;
  font-weight: 800;
  color: var(--soleil);
}

.marque {
  width: 36px;
  height: 36px;
  flex: 0 0 auto;
  border-radius: 10px;
  box-shadow: 0 0 0 2px var(--encre), 0 3px 0 2px rgba(0, 0, 0, 0.35);
}

/* Sur la bande d'encre, sombre dans les deux thèmes : les pastilles ont des
   couleurs fixes, lisibles sur ce fond-là. */
.badge-fichier {
  font-family: var(--police-titres);
  font-size: 0.78rem;
  font-weight: 800;
  color: var(--bande-texte);
  background: var(--bande-2);
  border-radius: 999px;
  padding: 5px 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 45vw;
}

.badge-fichier[data-etat="lie"] { color: #0b3d1d; background: #3ee07a; }
.badge-fichier[data-etat="absent"] { color: #2a0d05; background: #ff6b4a; }
.badge-fichier[data-etat="neutre"] { color: var(--bande-texte); background: var(--bande-2); }

/* ---------- Onglets ---------- */

/* Des pastilles sur la bande d'encre : chaque filière garde un liseré de sa
   couleur, l'onglet actif en prend l'aplat. */
/* Autant de colonnes que d'onglets : une filière ajoutée dans config.js trouve
   sa place sans retoucher la feuille. */
.onglets {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(0, 1fr);
  gap: 8px;
  padding: 0 var(--gouttiere) 10px;
}

/* Chaque onglet porte une teinte pâle de sa filière ; l'onglet ouvert prend
   l'aplat vif et un socle de la même couleur, plus sombre, qui le fait
   ressortir. Un simple liseré sous les autres se lisait comme un second état,
   pas comme la couleur de la filière. */
.onglet {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  appearance: none;
  border: 0;
  border-radius: 14px;
  background: var(--bande-2);
  background: color-mix(in oklab, var(--couleur-onglet, var(--accent)) 30%, var(--bande-2));
  color: #f3f0ff;
  font: inherit;
  font-family: var(--police-titres);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  padding: 11px 4px;
  min-height: 44px;
  cursor: pointer;
  box-shadow: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Sélecteurs à :not(:disabled) : sans eux, le survol générique des boutons,
   plus spécifique, remplaçait la couleur de l'onglet sous le doigt. */
.onglet:hover:not(:disabled) {
  background: color-mix(in oklab, var(--couleur-onglet, var(--accent)) 45%, var(--bande-2));
  color: #ffffff;
}

.onglet[aria-selected="true"],
.onglet[aria-selected="true"]:hover:not(:disabled) {
  background: var(--couleur-onglet, var(--accent));
  color: var(--sur-couleur);
  box-shadow: 0 4px 0 color-mix(in oklab, var(--couleur-onglet, var(--accent)) 55%, #000);
  transform: translateY(-2px);
}

.onglet:active:not(:disabled) { transform: none; box-shadow: none; }

.onglet-picto { display: inline-flex; flex: 0 0 auto; }
.onglet-long, .onglet-court { overflow: hidden; text-overflow: ellipsis; }

/* Trois paliers : nom complet sur tablette large, nom court en dessous (cinq
   colonnes, « ASSAINISSEMENT » ne tient plus à 1024 px moins les gouttières),
   picto seul au téléphone. */
.onglet-court { display: none; }

@media (max-width: 1100px) {
  .onglet-long { display: none; }
  .onglet-court { display: inline; }
}

@media (max-width: 600px) {
  .onglets { gap: 6px; }
  .onglet { padding: 10px 2px; }
  .onglet-court { display: none; }
  .onglet-picto svg { width: 24px; height: 24px; }
}

/* ---------- Titre de l'onglet ouvert ---------- */

/* Pastille de la couleur de filière portant le picto, puis le nom complet. */
.vue-titre {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 4px 0 2px;
  font-family: var(--police-titres);
  font-size: 1.45rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.15;
  color: var(--texte);
}

.vue-titre-picto {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  border: 2px solid var(--encre);
  background: var(--accent);
  color: var(--sur-couleur);
  box-shadow: var(--relief-petit);
}

/* ---------- Structure ---------- */

main { padding: var(--gouttiere); max-width: 1080px; margin: 0 auto; }

.vue[hidden] { display: none; }

.bloc {
  background: var(--fond-2);
  border: 2px solid var(--encre);
  border-radius: var(--rayon);
  box-shadow: var(--relief);
  padding: 14px;
  margin-bottom: 18px;
}

/* La liste des relevés n'a pas de cadre : chaque relevé est déjà une fiche. */
.bloc--registre {
  background: transparent;
  border: 0;
  box-shadow: none;
  padding: 0;
}

/* Titres en casse normale et à la couleur du texte : les petites capitales
   grises étaient le texte le moins lisible de l'écran, au soleil surtout. */
.bloc > h2,
.bloc-titre h2 {
  margin: 0 0 12px;
  font-family: var(--police-titres);
  font-size: 1.2rem;
  letter-spacing: -0.02em;
  color: var(--texte);
  font-weight: 800;
}

.bloc-titre {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 12px;
}

.bloc-titre h2 { margin: 0; }

/* ---------- Formulaire ---------- */

.grille {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

@media (min-width: 620px) {
  .grille { grid-template-columns: 1fr 1fr; }
  .champ--large { grid-column: 1 / -1; }
}

.champ { display: flex; flex-direction: column; gap: 5px; }

.champ label {
  font-size: 0.75rem;
  color: var(--texte-faible);
  letter-spacing: 0.04em;
}

.champ label .requis { color: var(--accent-texte); }

input, select, textarea {
  font: inherit;
  font-size: 0.95rem;
  color: var(--texte);
  background: var(--fond-2);
  border: 2px solid var(--bord-champ);
  border-radius: 12px;
  padding: 9px 12px;
  width: 100%;
  min-height: 44px; /* cible tactile confortable avec des gants */
}

input::placeholder, textarea::placeholder { color: var(--texte-faible); opacity: 1; }

textarea { min-height: 80px; resize: vertical; }

input[type="checkbox"] { accent-color: var(--accent); }

input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  border-color: var(--accent);
}

input[aria-invalid="true"], select[aria-invalid="true"] { border-color: var(--danger); }

/* ---------- Boutons ---------- */

.actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }

/* Un bouton est une pièce en relief : il s'enfonce à l'appui. Au doigt et
   avec des gants, c'est le seul retour qu'on sent avant que l'écran change. */
button {
  font: inherit;
  font-weight: 700;
  border-radius: 12px;
  border: 2px solid var(--encre);
  background: var(--fond-2);
  color: var(--texte);
  padding: 11px 16px;
  min-height: 46px;
  cursor: pointer;
  box-shadow: var(--relief-petit);
  transition: transform 0.08s ease-out, box-shadow 0.08s ease-out;
}

button:hover:not(:disabled) { background: var(--survol); }
button:active:not(:disabled) { transform: translateY(2px); box-shadow: 0 1px 0 var(--encre); }
button:disabled { opacity: 0.45; cursor: not-allowed; box-shadow: none; }

/* Un halo net au clavier seulement : au doigt, il resterait collé au bouton
   après chaque appui. */
button:focus-visible, a:focus-visible, summary:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
}

/* Jaune soleil pour l'action, dans tous les onglets : la couleur dit « ici on
   agit », la filière se lit déjà à l'onglet. */
.btn-primaire {
  font-family: var(--police-titres);
  font-weight: 800;
  background: var(--soleil);
  color: var(--sur-couleur);
}

.btn-primaire:hover:not(:disabled) { background: #ffe27a; }

.btn-danger { color: var(--danger); }
.btn-plein { flex: 1 1 100%; }

/* ---------- Acquisition GPS ---------- */

/* L'acquisition n'a plus de bouton : elle part à l'ouverture de la fenêtre de
   mesure. Seule la jauge dit que la série tourne encore. */
.progression {
  height: 10px;
  background: var(--fond-2);
  border: 2px solid var(--encre);
  border-radius: 999px;
  overflow: hidden;
  margin-top: 10px;
}

.progression[hidden] { display: none; }

/* Avance par mise à l'échelle, pas par largeur : un tic toutes les 200 ms
   pendant toute la mesure ne doit pas relancer la mise en page de la fenêtre. */
.progression-barre {
  height: 100%;
  width: 100%;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: left center;
  transition: transform 0.2s linear;
}

@media (prefers-reduced-motion: reduce) {
  .progression-barre { transition: none; }
}

/* ---------- Position ---------- */

.position {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-top: 12px;
}

@media (min-width: 620px) { .position { grid-template-columns: repeat(4, 1fr); } }

.position dt {
  font-size: 0.68rem;
  color: var(--texte-faible);
  text-transform: uppercase;
  letter-spacing: 0.07em;
}

.position dd {
  margin: 2px 0 0;
  font-family: var(--police-chiffres);
  font-variant-numeric: tabular-nums;
  font-size: 0.92rem;
}

.position .vide { color: var(--texte-faible); }

/* Le message d'acquisition et le bouton de détail partagent une ligne : le
   message est ce qu'on lit, le bouton ce qu'on ouvre rarement. */
.ligne-etat {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.ligne-etat .etat-gps { flex: 1 1 auto; }

.btn-details {
  flex: 0 0 auto;
  width: 38px;
  min-height: 38px;
  padding: 0;
  margin-top: 10px;
  font-size: 1rem;
  line-height: 1;
}

.etat-gps:empty + .btn-details { margin-top: 0; }

/* Consultation seule, par-dessus la fenêtre de mesure : elle tient à son contenu
   au lieu d'occuper toute la hauteur. */
.modale-fenetre--details { max-width: 460px; }
.modale-fenetre--details:focus { outline: none; }
.modale-fenetre--details .position { margin-bottom: 0; }

.etat-gps { font-size: 0.82rem; margin: 10px 0 0; min-height: 1.2em; }

/* Sans message, la réserve de place laisse un trou dans le bloc. */
.etat-gps:empty { min-height: 0; margin: 0; }
.etat-gps[data-niveau="erreur"] { color: var(--danger); }
.etat-gps[data-niveau="alerte"] { color: var(--alerte); }
.etat-gps[data-niveau="ok"] { color: var(--succes); }

/* ---------- Liste des points ---------- */

.compteur {
  font-size: 0.75rem;
  color: var(--texte-faible);
  font-variant-numeric: tabular-nums;
}

/* Chaque relevé est une fiche posée sur la carte, comme une étiquette de
   terrain ; la liste qui les porte n'a pas de cadre (.bloc--registre). */
.liste { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 14px; }

.point {
  background: var(--fond-2);
  border: 2px solid var(--encre);
  border-radius: var(--rayon);
  box-shadow: var(--relief);
  padding: 12px 14px;
}

.point-entete {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.point-ref {
  font-family: var(--police-titres);
  font-weight: 800;
  font-size: 1.05rem;
  letter-spacing: -0.01em;
  color: var(--accent-texte);
  flex: 1;
}
.point-date { font-size: 0.7rem; color: var(--texte-faible); white-space: nowrap; }
.point-detail { font-size: 0.8rem; color: var(--texte-faible); margin-top: 4px; word-break: break-word; }
.point-coord {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px 10px;
  font-size: 0.75rem;
  font-variant-numeric: tabular-nums;
  margin-top: 6px;
}

/* Cible tactile : un lien de 14 px de haut est inutilisable au doigt. */
.lien-carte {
  color: var(--accent-texte);
  font-family: var(--police-chiffres);
  font-weight: 600;
  text-decoration: none;
  background: color-mix(in oklab, var(--accent) 14%, var(--fond-2));
  border: 2px solid var(--accent);
  border-radius: 10px;
  padding: 8px 10px;
  min-height: 36px;
  display: inline-flex;
  align-items: center;
}

.lien-carte:hover, .lien-carte:focus-visible { text-decoration: underline; }

.point-precision { color: var(--texte-faible); font-family: var(--police-chiffres); font-weight: 700; }

/* Aplat vert fixe : la pastille se lit de la même façon dans les deux thèmes. */
.point-methode {
  color: #0b3d1d;
  background: #3ee07a;
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 0.72rem;
  font-weight: 800;
}

.point-actions { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.point-actions button { padding: 7px 12px; min-height: 38px; font-size: 0.8rem; }

.vide-message {
  color: var(--texte-faible);
  font-size: 0.85rem;
  text-align: center;
  padding: 18px 0;
}

/* ---------- Fichiers (un par filière) ---------- */

.fichiers { display: flex; flex-direction: column; gap: 10px; margin: 12px 0; }

/* Le dossier de travail passe avant les fichiers un par un : c'est le choix
   qu'on fait une fois, le reste est du réglage fin. */
.dossier-travail {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 14px;
  margin: 10px 0 4px;
}

.dossier-travail .note { flex: 1 1 220px; margin: 0; }

.fichier {
  border: 2px solid var(--bord);
  border-radius: 14px;
  padding: 10px 12px;
  background: var(--fond);
}

/* Une pastille porte la couleur de filière ; le libellé reste au contraste du
   texte, ce que le vert ou le bleu ciel n'atteignent pas sur fond clair. */
.fichier-filiere::before,
.cat-nom::before,
.stat-label::before {
  content: "";
  display: inline-block;
  width: 10px;
  height: 10px;
  margin-right: 6px;
  border-radius: 50%;
  background: var(--couleur-filiere, var(--texte-faible));
  vertical-align: 0.05em;
}

/* Le libellé de filière passe à la ligne plutôt que de déborder de la carte :
   « ASSAINISSEMENT » à côté de assainissement.geojson ne tient pas à 400 px. */
.fichier-entete {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: baseline;
  gap: 2px 10px;
}

.fichier-nom { min-width: 0; overflow-wrap: anywhere; }

.fichier-nom { font-weight: 600; font-size: 0.9rem; font-family: ui-monospace, "SFMono-Regular", Menlo, monospace; }

.fichier-filiere {
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  white-space: nowrap;
  color: var(--texte-faible);
}

.fichier .note { margin: 6px 0 0; }
.fichier .actions { margin-top: 10px; gap: 8px; }

.btn-compact { padding: 7px 12px; min-height: 36px; font-size: 0.78rem; font-weight: 500; }

/* ---------- Configuration ---------- */

.changelog { margin: 6px 0 12px; padding-left: 1.2em; font-size: 0.9rem; }
.changelog li + li { margin-top: 4px; }
.historique { margin-top: 12px; }

/* Bandeau de mise à jour : posé en bas, au-dessus de la marge d'encoche. */
.bandeau-maj {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  z-index: 60;
  background: var(--encre);
  color: var(--fond);
  border-radius: 14px;
  padding: 12px 14px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}
.bandeau-maj p { margin: 0 0 8px; font-weight: 600; }
.bandeau-maj .actions { display: flex; flex-wrap: wrap; gap: 8px; }
.historique summary { cursor: pointer; font-weight: 600; min-height: 44px; display: flex; align-items: center; }

.note {
  font-size: 0.78rem;
  color: var(--texte-faible);
  line-height: 1.5;
  margin: 10px 0 0;
}

.stats { display: flex; flex-wrap: wrap; gap: 10px; }

.stat {
  flex: 1 1 120px;
  border: 2px solid var(--bord);
  border-radius: 14px;
  padding: 10px 12px;
  background: var(--fond);
}

.stat-valeur { font-family: var(--police-titres); font-size: 1.7rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.stat-label { font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--texte-faible); }

.case { display: flex; align-items: center; gap: 10px; min-height: 44px; }
.case input { width: 22px; min-height: 22px; height: 22px; flex: 0 0 auto; }

.case label {
  font-size: 0.88rem;
  color: var(--texte);
  flex: 1;
  padding: 11px 0;
  cursor: pointer;
}

/* ---------- Barre de recherche ---------- */

/* Collée sous les onglets : on cherche un relevé déjà pris sans remonter la page. */
.barre-recherche {
  position: sticky;
  top: var(--h-barre, 0px);
  z-index: 15;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0 12px;
  margin-bottom: 2px;
  background: var(--fond);
}

.barre-recherche input {
  min-height: 50px;
  font-size: 1rem;
  border-color: var(--encre);
  border-radius: 999px;
  padding-left: 18px;
}

.barre-recherche .compteur {
  white-space: nowrap;
  font-size: 0.78rem;
}

.bloc-soustitre {
  font-size: 0.72rem;
  color: var(--texte-faible);
  text-align: right;
}

/* ---------- Créer une mesure ---------- */

/* Première chose à l'écran, pleine largeur : c'est l'action de l'onglet. */
.btn-creer {
  width: 100%;
  min-height: 62px;
  font-size: 1.25rem;
  letter-spacing: -0.01em;
  border-width: 3px;
  border-radius: 20px;
  box-shadow: 0 5px 0 var(--encre);
  margin-top: 16px;
}

.btn-creer:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 2px 0 var(--encre); }

/* ---------- Relevés encore dans le seul navigateur ---------- */

/* En haut de l'onglet, avant le bouton de création : ce qui menace le travail
   déjà fait passe avant l'invitation à en faire davantage. Ton d'alerte, pas de
   danger — rien n'est perdu, il y a seulement quelque chose à mettre à l'abri. */
.alerte-sauvegarde {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 14px;
  margin-top: 14px;
  padding: 12px 14px;
  border: 2px solid var(--encre);
  border-radius: 16px;
  box-shadow: var(--relief-petit);
  background: var(--alerte-fond);
}

.alerte-sauvegarde[hidden] { display: none; }

/* Proposition, pas avertissement : rien n'est en danger, on offre un réglage.
   Le ton d'alerte reste réservé à ce qui est réellement cassé — accès expiré
   ou fichier disparu — pour qu'il garde sa valeur d'avertissement. */
.alerte-liaison[data-etat="absent"] {
  border-color: var(--bord);
  background: var(--fond-2);
}

.alerte-liaison[data-etat="absent"] .alerte-texte strong { color: var(--accent-texte); }

.alerte-texte {
  flex: 1 1 200px;
  margin: 0;
  font-size: 0.86rem;
  line-height: 1.45;
  color: var(--texte);
}

.alerte-texte strong { color: var(--alerte); }

/* Le bouton ne se comprime jamais sous la cible tactile : en dessous de
   200 px de texte disponible, il prend sa propre ligne. */
.alerte-sauvegarde button { flex: 0 0 auto; }

/* ---------- Fenêtre de mesure ---------- */

/* Sous la carte d'ajustement, qui s'ouvre par-dessus. Sélecteur doublé à
   dessein : `.modale` porte z-index 60 plus bas dans la feuille et gagnerait
   à spécificité égale. */
.modale.modale-mesure { z-index: 50; }

.modale-fenetre--mesure { max-width: 680px; }

/* La fenêtre reçoit le focus à l'ouverture : pas de halo pour autant, ce n'est
   pas une cible cliquable. */
.modale-fenetre--mesure:focus { outline: none; }

/* Le fond ne se ferme pas au clic : la règle est dans app.js, le curseur le dit. */
.modale-mesure .modale-fond { cursor: default; }

/* Une fenêtre ouverte fige la page derrière : sinon le doigt fait défiler la
   liste au lieu de la carte ou du formulaire. */
body[data-modale] { overflow: hidden; }

/* ---------- Favoris ---------- */

.favoris {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
}

.favoris[hidden] { display: none; }

.favoris-titre {
  font-size: 0.72rem;
  color: var(--texte-faible);
  letter-spacing: 0.04em;
  margin-right: 2px;
}

.favori {
  font-size: 0.82rem;
  padding: 8px 14px;
  min-height: 40px;
  border-radius: 999px;
  border-color: var(--accent);
  color: var(--accent-texte);
  background: color-mix(in oklab, var(--accent) 12%, var(--fond-2));
  box-shadow: none;
}

.point-etoile {
  padding: 0;
  width: 40px;
  min-height: 40px;
  font-size: 1.1rem;
  line-height: 1;
  font-size: 1.35rem;
  border-color: transparent;
  background: transparent;
  box-shadow: none;
  color: var(--texte-faible);
  flex-shrink: 0;
}

/* Orange vif fixe : l'étoile se lit sur la fiche blanche comme sur la violette. */
.point-etoile--actif { color: #ff9f1c; }
.point-etoile:hover:not(:disabled) { background: var(--survol); color: #ff9f1c; }

.zone-position {
  padding-bottom: 14px;
  margin-bottom: 14px;
  border-bottom: 2px dashed var(--bord);
}

/* ---------- Cascade type / modèle / détail ---------- */

/* Les trois listes liées sont l'identification de l'ouvrage : elles se lisent
   d'un bloc, détachées des champs métier qui suivent. */
.cascade {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  padding: 12px;
  margin-bottom: 14px;
  background: color-mix(in oklab, var(--accent) 12%, var(--fond-2));
  border: 2px solid var(--encre);
  border-radius: 16px;
}

.cascade select { background: var(--fond-2); }
.cascade .champ label { color: var(--texte); font-weight: 700; }
.cascade select:disabled { opacity: 0.5; }

/* ---------- Note de terrain ---------- */

/* Deux lignes suffisent au constat qu'on tape debout ; la poignée reste là pour
   les cas bavards. Plus haut, la note repousse la liste hors de l'écran. */
.champ-note { margin-bottom: 4px; }
.champ-note textarea { min-height: 62px; }

/* ---------- Catalogue de matériel ---------- */

.catalogue { display: flex; flex-direction: column; gap: 10px; margin: 12px 0; }

.cat-filiere {
  border: 2px solid var(--bord);
  border-radius: 14px;
  background: var(--fond);
}

.cat-filiere > summary {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  padding: 13px 14px;
  min-height: 48px;
  cursor: pointer;
  list-style: none;
}

.cat-filiere > summary::-webkit-details-marker { display: none; }

.cat-nom {
  font-weight: 600;
  font-size: 0.8rem;
  letter-spacing: 0.08em;
  color: var(--texte);
}

.cat-compte { font-size: 0.74rem; color: var(--texte-faible); }

.cat-ajout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  padding: 0 14px 12px;
}

.cat-table-hote {
  max-height: 340px;
  overflow-y: auto;
  border-top: 1px solid var(--bord);
}

.cat-table { width: 100%; border-collapse: collapse; font-size: 0.82rem; }

.cat-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--fond-2);
  text-align: left;
  font-size: 0.64rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--texte-faible);
  font-weight: 600;
  padding: 8px 10px;
}

.cat-table td { padding: 7px 10px; border-top: 1px solid var(--bord); }

/* Le type n'est écrit qu'au changement : la colonne devient lisible au survol vertical. */
.cat-rupture td { border-top-color: var(--texte-faible); }
.cat-table .cat-type { font-weight: 600; white-space: nowrap; }
.cat-table .cat-detail { color: var(--texte-faible); }
.cat-vide { color: var(--texte-faible); text-align: center; padding: 16px 10px; }

.cat-suppr {
  width: 38px;
  min-height: 38px;
  padding: 0;
  font-size: 0.8rem;
  line-height: 1;
  color: var(--danger);
  border-color: transparent;
  background: transparent;
  box-shadow: none;
}

.cat-suppr:hover { border-color: var(--danger); }


/* ---------- Modale carte ---------- */

/* Une fenêtre couvre tout l'écran, encoche comprise : sans ces marges, son
   titre et sa croix de fermeture tombent sous la barre d'état. */
.modale {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  padding-top: calc(12px + env(safe-area-inset-top));
  padding-bottom: calc(12px + env(safe-area-inset-bottom));
  padding-left: calc(12px + env(safe-area-inset-left));
  padding-right: calc(12px + env(safe-area-inset-right));
}

.modale[hidden] { display: none; }

.modale-fond {
  position: absolute;
  inset: 0;
  background: var(--voile);
}

.modale-fenetre {
  position: relative;
  width: 100%;
  max-width: 560px;
  /* Relatif au conteneur, déjà rétréci par les marges d'encoche. Une hauteur en
     `vh` les ignorerait et déborderait sous la barre système. */
  max-height: 100%;
  overflow-y: auto;
  background: var(--fond-2);
  border: 3px solid var(--encre);
  border-radius: 22px;
  padding: 14px;
  box-shadow: 0 6px 0 var(--encre);
}

.modale-entete {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 10px;
  margin-bottom: 12px;
}

.modale-entete h2 {
  margin: 0;
  flex: 1;
  font-family: var(--police-titres);
  font-size: 1.35rem;
  letter-spacing: -0.02em;
  color: var(--texte);
  font-weight: 800;
}

.modale-fermer {
  padding: 0;
  width: 38px;
  min-height: 38px;
  font-size: 1rem;
  line-height: 1;
}

/* ---------- Carte ---------- */

/* Les voiles posés sur la carte restent sombres dans les deux thèmes : ils se
   lisent sur la photo aérienne, qui ne change pas avec le thème. */
.carte {
  position: relative;
  height: clamp(220px, 44vh, 400px);
  overflow: hidden;
  border: 3px solid var(--encre);
  border-radius: 18px;
  box-shadow: var(--relief);
  background: var(--fond-3);
  cursor: grab;
  touch-action: none; /* sans quoi le défilement de la page capte le geste */
  user-select: none;
}

.carte--glisse { cursor: grabbing; }

.carte-couche { position: absolute; inset: 0; }

.carte-tuile {
  position: absolute;
  width: 256px;
  height: 256px;
  pointer-events: none;
  -webkit-user-drag: none;
}

.carte-marqueur {
  position: absolute;
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.carte-marqueur--gps {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #38bdf8;
  border: 2px solid #f8fafc;
  box-shadow: 0 0 0 1px rgba(2, 8, 20, 0.7);
}

/* Le cercle de précision prend la couleur de la filière : on sait d'un coup
   d'œil dans quel onglet on relève. */
.carte-marqueur--precision {
  border-radius: 50%;
  background: rgba(56, 189, 248, 0.18);
  background: color-mix(in oklab, var(--accent) 22%, transparent);
  border: 3px solid var(--accent);
}

/* Le repère ne bouge jamais : c'est la carte qui se déplace dessous. */
.carte-croix {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 46px;
  height: 46px;
  transform: translate(-50%, -50%);
  pointer-events: none;
  z-index: 3;
}

.carte-croix::before,
.carte-croix::after {
  content: "";
  position: absolute;
  background: #f8fafc;
  box-shadow: 0 0 3px rgba(0, 0, 0, 0.9);
}

.carte-croix::before { left: 50%; top: 0; width: 2px; height: 100%; margin-left: -1px; }
.carte-croix::after { top: 50%; left: 0; height: 2px; width: 100%; margin-top: -1px; }

/* En haut, pas au centre : le message ne doit pas masquer le repère. */
.carte-message {
  position: absolute;
  left: 10px;
  right: 10px;
  top: 10px;
  margin: 0;
  text-align: center;
  font-size: 0.82rem;
  color: #fbbf24;
  background: rgba(11, 15, 20, 0.88);
  border-radius: 8px;
  padding: 10px;
  z-index: 4;
  pointer-events: none;
}

.carte-message:empty { display: none; }

/* Dans la fenêtre de mesure, la carte partage la hauteur avec le formulaire :
   elle occupe le haut de l'écran sans repousser la cascade hors de vue. */
.carte--mesure { height: clamp(190px, 34vh, 320px); }

/* Tant qu'aucun fixe n'est arrivé, le viseur ne désigne rien : on masque la
   carte plutôt que de laisser croire que la croix est déjà posée. */
.carte-attente {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(11, 15, 20, 0.82);
  color: #c9d3df;
  font-size: 0.86rem;
  letter-spacing: 0.04em;
}

.carte-attente[hidden] { display: none; }

/* Libellé en toutes lettres : le glyphe ⌖ manque à certaines polices Android,
   et le message d'échec du GPS renvoie à ce bouton. */
.carte-zoom .carte-gps {
  width: auto;
  padding: 0 12px;
  font-size: 0.78rem;
  font-weight: 600;
  white-space: nowrap;
}

/* Mention de licence : visible en permanence, jamais masquée par un geste. */
.carte-attribution {
  position: absolute;
  right: 0;
  bottom: 0;
  margin: 0;
  padding: 3px 7px;
  font-size: 0.65rem;
  color: #e6edf5;
  background: rgba(11, 15, 20, 0.78);
  border-top-left-radius: 6px;
  pointer-events: none;
  z-index: 3;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.carte-attribution:empty { display: none; }

.carte-barre {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 10px;
}

/* Un seul fond actif à la fois : un sélecteur segmenté le montre d'un coup
   d'œil, là où trois boutons à bord coloré se confondaient avec le survol. */
.carte-fonds {
  display: flex;
  gap: 3px;
  padding: 3px;
  border: 2px solid var(--encre);
  border-radius: 14px;
  background: var(--fond-2);
  box-shadow: var(--relief-petit);
}

.carte-fond {
  padding: 7px 11px;
  min-height: 36px;
  font-size: 0.78rem;
  font-weight: 700;
  border-color: transparent;
  border-radius: 10px;
  background: transparent;
  box-shadow: none;
  color: var(--texte-faible);
}

.carte-fond:active:not(:disabled) { transform: none; box-shadow: none; }

.carte-fond--actif,
.carte-fond--actif:hover:not(:disabled) {
  background: var(--accent);
  color: var(--sur-couleur);
  font-weight: 800;
}

.carte-zoom { display: flex; align-items: center; gap: 6px; }

.carte-zoom button {
  width: 40px;
  padding: 0;
  min-height: 40px;
  font-size: 1.15rem;
  line-height: 1;
}

.carte-echelle {
  font-size: 0.72rem;
  color: var(--texte-faible);
  font-variant-numeric: tabular-nums;
  min-width: 64px;
  text-align: center;
}

.carte-infos {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px 14px;
  margin: 12px 0 0;
  font-size: 0.82rem;
  font-variant-numeric: tabular-nums;
}

.carte-coord {
  font-family: var(--police-chiffres);
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: -0.01em;
}
.carte-ecart { color: var(--texte-faible); }
.carte-ecart.ecart-fort { color: var(--alerte); }
.carte-echelle { margin-left: auto; }

/* Sur sa propre ligne sous le titre : coincée entre le titre et la croix,
   elle écrase l'un et l'autre. */
.modale-aide {
  order: 3;
  flex-basis: 100%;
  margin: 0;
  font-size: 0.78rem;
  color: var(--texte-faible);
}

/* ---------- Fonds de carte (configuration) ---------- */

.fonds { display: flex; flex-direction: column; gap: 10px; margin: 12px 0; }

.fond {
  border: 2px solid var(--bord);
  border-radius: 14px;
  padding: 11px 12px;
  background: var(--fond);
}

.fond--invalide { border-color: var(--danger); }

.fond-probleme { color: var(--danger); margin-top: 8px; }

.fond .actions { margin-top: 10px; }

.champ-url {
  font-family: ui-monospace, "SFMono-Regular", Menlo, monospace;
  font-size: 0.78rem;
  min-height: 62px;
  word-break: break-all;
}

/* ---------- Toast ---------- */

/* Inversé par rapport à la page dans les deux thèmes : le message se détache
   sans couleur de fond à choisir. La pastille dit le type. */
#toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%) translateY(140%);
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--texte);
  color: var(--fond-2);
  border: 2px solid var(--encre);
  border-radius: 14px;
  padding: 12px 16px;
  font-size: 0.88rem;
  font-weight: 700;
  max-width: calc(100vw - 32px);
  transition: transform 0.24s cubic-bezier(0.22, 1, 0.36, 1);
  z-index: 50;
  box-shadow: var(--relief);
}

#toast::before {
  content: "";
  flex: 0 0 auto;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
}

#toast:empty { visibility: hidden; }
#toast[data-visible="true"] { transform: translateX(-50%) translateY(0); }
/* Couleurs vives fixes : la pastille se lit sur le fond inversé du message,
   pas sur la page. */
#toast[data-type="erreur"]::before { background: #ef4444; }
#toast[data-type="succes"]::before { background: #22c55e; }

@media (prefers-reduced-motion: reduce) {
  #toast { transition: none; }
}

/* ---------- Tablette : la cible principale ---------- */

@media (min-width: 768px) {
  :root { --gouttiere: 22px; }

  .entete h1 { font-size: 1.2rem; }
  .onglet { font-size: 0.82rem; padding: 14px 8px; }

  .bloc { padding: 18px 20px; margin-bottom: 18px; }

  /* Trois listes côte à côte : la cascade se lit en une ligne, gauche à droite. */
  .cascade { grid-template-columns: repeat(3, 1fr); padding: 14px; }

  input, select, textarea { min-height: 48px; font-size: 1rem; }
  button { min-height: 48px; }

  .cat-ajout { grid-template-columns: 1fr 1fr 1fr auto; align-items: end; }
  .cat-table-hote { max-height: 420px; }

  .carte { height: clamp(320px, 52vh, 560px); }
  .carte--mesure { height: clamp(240px, 38vh, 400px); }
  .modale-fenetre { max-width: 720px; padding: 20px; }
  .btn-creer { min-height: 60px; }

  .point { padding: 14px 16px; }
  .fichiers { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
}

/* ---------- Petits smartphones ---------- */

/* Sous 400 px, le toast centré se replie en colonne étroite : bandeau pleine largeur. */
@media (max-width: 480px) {
  #toast {
    left: 12px;
    right: 12px;
    bottom: 12px;
    max-width: none;
    transform: translateY(160%);
  }

  #toast[data-visible="true"] { transform: translateY(0); }
}

/* Paysage sur petit écran : 96 px de barres fixes sur 320 px de haut, c'est trop. */
@media (max-height: 480px) and (orientation: landscape) {
  /* L'en-tête glisse hors écran, les onglets restent collés en haut.
     --h-entete est mesuré par app.js : la hauteur change avec la largeur. */
  .barre-haute { top: calc(-1 * var(--h-entete, 40px)); }

  /* L'en-tête sort de l'écran : la barre de recherche remonte d'autant. */
  .barre-recherche { top: calc(var(--h-barre, 0px) - var(--h-entete, 40px)); }

  .entete { padding: 6px var(--gouttiere); }
  .entete h1 { font-size: 0.85rem; }

  .onglets { padding-bottom: 6px; }
  .onglet { padding: 7px 4px; min-height: 36px; }

  main { padding-top: 10px; }
  .bloc { padding: 10px 12px; margin-bottom: 10px; }
  textarea { min-height: 56px; }

  /* Écran couché : la carte doit laisser voir la cascade sans tout faire défiler. */
  .carte--mesure { height: clamp(150px, 44vh, 210px); }
}

/* iPhone SE, Galaxy Fold replié : chaque pixel de largeur compte. */
@media (max-width: 360px) {
  :root { --gouttiere: 10px; }

  .entete { padding: 10px var(--gouttiere); }
  .entete h1 { font-size: 0.95rem; letter-spacing: 0.1em; }
  .badge-fichier { max-width: 40vw; font-size: 0.66rem; padding: 3px 8px; }

  .bloc { padding: 11px; }
  .position { gap: 8px; }
  .position dt { font-size: 0.62rem; letter-spacing: 0.04em; }
  .position dd { font-size: 0.88rem; }

  .fichier { padding: 9px 10px; }
  .fichier-nom { font-size: 0.82rem; }
  .fichier-filiere { font-size: 0.6rem; }
  .fichier-entete { flex-direction: column; align-items: flex-start; gap: 2px; }

  /* Les boutons compacts passent sur deux colonnes plutôt que de déborder. */
  .fichier .actions { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
  .fichier .actions button { width: 100%; }
  .fichier .actions button:last-child { grid-column: 1 / -1; }

  /* Les quatre côtés sont réécrits : un `padding` raccourci effacerait les
     marges d'encoche posées plus haut. */
  .modale {
    padding: 8px;
    padding-top: calc(8px + env(safe-area-inset-top));
    padding-bottom: calc(8px + env(safe-area-inset-bottom));
    padding-left: calc(8px + env(safe-area-inset-left));
    padding-right: calc(8px + env(safe-area-inset-right));
  }
  .modale-fenetre { padding: 11px; }
  .carte { height: clamp(200px, 40vh, 320px); }
  .carte--mesure { height: clamp(170px, 30vh, 260px); }
  .carte-barre { gap: 8px; }
  /* Le sélecteur segmenté passe sur deux lignes plutôt que de déborder : à
     280 px, les trois libellés ne tiennent pas côte à côte. */
  .carte-fonds { flex-wrap: wrap; }
  .carte-fond { flex: 1 1 auto; padding: 7px 8px; font-size: 0.72rem; }
  .carte-echelle { margin-left: 0; }

  .stat { flex-basis: calc(50% - 5px); padding: 9px 10px; }
  .stat-valeur { font-size: 1.3rem; }

  .point-actions button { padding: 7px 9px; font-size: 0.74rem; }
}
