/* Télérelève terrain — pensé pour le doigt (iPad), clair ou sombre selon l'iPad. */
:root {
  --fond: #f2f3f6; --surface: #fff; --surface-2: #f6f7f9; --bord: #dfe2e8;
  --texte: #1b1f27; --texte-2: #4a5160; --texte-3: #7c8494;
  --accent: #1f5fd1; --accent-doux: #e6eefc; --orange: #c9561c; --vert: #1d8a4e;
  --rayon: 14px; --mono: ui-monospace, "SF Mono", Menlo, monospace;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --fond: #121418; --surface: #1c1f25; --surface-2: #23272e; --bord: #323741;
    --texte: #eceef2; --texte-2: #b5bbc6; --texte-3: #858c99;
    --accent: #6f9bff; --accent-doux: #1f2a40; --orange: #f08a4b; --vert: #4cc489;
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--fond); color: var(--texte); font: 17px/1.4 -apple-system, "SF Pro Text", system-ui, sans-serif; }
button { font: inherit; color: inherit; cursor: pointer; }
input, textarea { font: inherit; font-size: 17px; color: var(--texte); }

#haut {
  position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 10px;
  padding: calc(env(safe-area-inset-top) + 8px) calc(env(safe-area-inset-right) + 14px) 8px calc(env(safe-area-inset-left) + 14px);
  background: color-mix(in srgb, var(--surface) 88%, transparent); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--bord);
}
#titre { flex: 1; font-weight: 700; font-size: 18px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-align: center; }
.haut-bouton { min-height: 44px; padding: 0 14px; border: 1px solid var(--bord); border-radius: 10px; background: var(--surface); font-weight: 600; }
.haut-bouton.principal { background: var(--accent); border-color: var(--accent); color: #fff; }
.haut-bouton.principal.attention { box-shadow: 0 0 0 3px color-mix(in srgb, var(--orange) 45%, transparent); }
#retour[hidden] + #titre { text-align: left; }

#principal { max-width: 980px; margin: 0 auto; padding: 16px calc(env(safe-area-inset-right) + 16px) calc(env(safe-area-inset-bottom) + 40px) calc(env(safe-area-inset-left) + 16px); }
h1 { margin: 0 0 8px; font-size: 26px; }
h2 { margin: 22px 0 8px; font-size: 15px; color: var(--texte-2); text-transform: uppercase; letter-spacing: .03em; }
h2 .code, .code { font-family: var(--mono); color: var(--texte-3); font-weight: 500; }
.aide { color: var(--texte-3); font-size: 14px; }
.vide { color: var(--texte-3); padding: 20px 4px; }

.gros-bouton { min-height: 52px; padding: 0 20px; border: 1px solid var(--bord); border-radius: 12px; background: var(--surface); font-weight: 600; font-size: 17px; }
.gros-bouton.principal { background: var(--accent); border-color: var(--accent); color: #fff; }
.gros-bouton:disabled { opacity: .35; }
.gros-bouton:active, .ligne:active, .site:active { transform: scale(.985); }

.carte-aide { background: var(--surface); border: 1px solid var(--bord); border-radius: var(--rayon); padding: 24px; }
.carte-aide ol { padding-left: 22px; margin: 16px 0 22px; display: grid; gap: 10px; color: var(--texte-2); }

.etat-visite { display: grid; gap: 10px; grid-template-columns: 1fr auto; align-items: center; background: var(--surface); border: 1px solid var(--bord); border-radius: var(--rayon); padding: 14px 16px; }
.etat-visite .bilan { text-align: right; font-size: 15px; color: var(--vert); }
.etat-visite .bilan.attention { color: var(--orange); font-weight: 600; }
@media (max-width: 640px) { .etat-visite { grid-template-columns: 1fr; } .etat-visite .bilan { text-align: left; } }
.sites { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; margin: 16px 0; }
.site { display: grid; gap: 2px; text-align: left; padding: 16px; border: 1px solid var(--bord); border-radius: var(--rayon); background: var(--surface); }
.site .nom { font-weight: 700; font-size: 19px; }
.site .adresse { color: var(--texte-2); font-size: 15px; }
.site .compte { color: var(--texte-3); font-size: 14px; margin-top: 6px; }
.site .compte b { color: var(--orange); }
.actions-bas { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 8px; }

.onglets { display: flex; gap: 8px; margin-bottom: 12px; }
.onglets button { flex: 1; min-height: 48px; border: 1px solid var(--bord); border-radius: 12px; background: var(--surface); font-weight: 600; font-size: 15px; }
.onglets button.actif { background: var(--accent-doux); border-color: var(--accent); color: var(--accent); }
.onglets span { color: var(--texte-3); font-weight: 500; }
#filtre { width: 100%; min-height: 46px; padding: 0 14px; border: 1px solid var(--bord); border-radius: 12px; background: var(--surface); }

.ligne { display: flex; gap: 12px; align-items: center; width: 100%; text-align: left; padding: 8px; margin-bottom: 8px; border: 1px solid var(--bord); border-radius: var(--rayon); background: var(--surface); }
.ligne.barree .t { text-decoration: line-through; color: var(--texte-3); }
.vignette { flex: none; width: 76px; height: 60px; border-radius: 9px; overflow: hidden; background: color-mix(in srgb, var(--c) 14%, var(--surface-2)); display: grid; place-items: center; font-size: 26px; }
.vignette img { width: 100%; height: 100%; object-fit: cover; }
.textes { flex: 1; min-width: 0; display: grid; gap: 2px; }
.textes .t { font-weight: 650; display: flex; gap: 8px; align-items: center; overflow-wrap: anywhere; }
.textes .s { color: var(--texte-2); font-size: 14.5px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.pastille { flex: none; font: 700 13px var(--mono); padding: 2px 7px; border-radius: 999px; background: color-mix(in srgb, var(--c) 18%, var(--surface)); border: 1.5px solid var(--c); }
.marques { flex: none; display: grid; gap: 4px; justify-items: end; font-size: 13px; color: var(--texte-3); }
.modifie { color: var(--orange); font-weight: 700; font-size: 16px; }

.fiche-tete { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; margin-bottom: 14px; }
.etiquette { padding: 4px 10px; border-radius: 999px; font-weight: 600; font-size: 14px; background: color-mix(in srgb, var(--c) 16%, var(--surface)); border: 1px solid color-mix(in srgb, var(--c) 50%, transparent); }
.chemin { color: var(--texte-2); font-size: 15px; }
.barre-plan { color: var(--orange); font-weight: 600; font-size: 14px; }
.boutons-photo { display: flex; gap: 10px; flex-wrap: wrap; }
.boutons-photo .gros-bouton { flex: 1; min-width: 200px; }
.bande-photos { display: flex; gap: 10px; overflow-x: auto; padding: 12px 0; scroll-snap-type: x proximity; -webkit-overflow-scrolling: touch; }
.photo { position: relative; flex: none; scroll-snap-align: start; }
.photo > button { display: block; padding: 0; border: 0; border-radius: 12px; overflow: hidden; background: var(--surface-2); }
.photo img { display: block; height: 190px; min-width: 120px; max-width: 320px; object-fit: cover; }
.photo.nouvelle > button { outline: 3px solid var(--vert); outline-offset: -3px; }
.photo .badge { position: absolute; left: 8px; bottom: 8px; padding: 2px 8px; border-radius: 999px; background: var(--vert); color: #fff; font-size: 12.5px; font-weight: 700; }
.photo .retirer { position: absolute; top: 6px; right: 6px; width: 36px; height: 36px; border: 0; border-radius: 50%; background: rgba(0, 0, 0, .6); color: #fff; font-size: 16px; }

.champs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-top: 6px; }
@media (max-width: 640px) { .champs { grid-template-columns: minmax(0, 1fr); } }
.champ { display: grid; gap: 4px; }
.champ.large { grid-column: 1 / -1; }
.champ .l { font-size: 13.5px; font-weight: 600; color: var(--texte-3); }
.champ .l i { font-style: normal; color: var(--orange); }
.champ input, .champ textarea { width: 100%; min-height: 48px; padding: 11px 12px; border: 1px solid var(--bord); border-radius: 11px; background: var(--surface); resize: vertical; }
.champ textarea { line-height: 1.4; }
.champ input:focus, .champ textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-doux); }
.champ.change input, .champ.change textarea { border-color: var(--orange); }
.voisins { display: flex; justify-content: space-between; gap: 10px; margin-top: 22px; }
.voisins .gros-bouton { flex: 1; }

#visionneuse { position: fixed; inset: 0; z-index: 50; background: #000; touch-action: none; }
.v-scene { position: absolute; inset: 0; display: grid; place-items: center; overflow: hidden; }
.v-scene img { max-width: 100%; max-height: 100%; transform-origin: center; will-change: transform; }
.v-fermer { position: absolute; top: calc(env(safe-area-inset-top) + 12px); right: calc(env(safe-area-inset-right) + 12px); width: 48px; height: 48px; border: 0; border-radius: 50%; background: rgba(255, 255, 255, .2); color: #fff; font-size: 20px; }

#message { position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 24px); transform: translateX(-50%); z-index: 60; max-width: 90vw; padding: 12px 18px; border-radius: 12px; background: #1b1f27; color: #fff; font-weight: 600; box-shadow: 0 8px 30px rgba(0, 0, 0, .3); text-align: center; }
[hidden] { display: none !important; }
