:root {
  --bleu: #0b4f9c;
  --bleu-fonce: #08386b;
  --bleu-clair: #083b72;
  --orange: #ef6c00;
  --fond: #f4f8fc;
  --texte: #1b365d;
  --surface: #ffffff;
  --bordure: #d7e7f9;
  --meta: #5a6f8a;
  --badge: #d32f2f;
  --entete-sous: #cddff3;
  --safe-haut: env(safe-area-inset-top, 0px);
  --safe-bas: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  background: var(--fond);
  color: var(--texte);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
body {
  padding-top: var(--safe-haut);
}
button, input, textarea, select { font: inherit; }
a { color: var(--bleu); }

#pda_racine {
  height: 100%;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#pda_entete {
  flex-shrink: 0;
  background: var(--surface);
}
.pda-logo {
  display: block;
  width: 100%;
  height: auto;
}
.pda-bandeau-commune {
  margin: 10px 12px 8px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 12px;
  color: #fff;
  background: linear-gradient(180deg, var(--bleu) 0%, var(--bleu-clair) 100%);
  border: 1px solid rgba(255,255,255,0.24);
}
.pda-bandeau-commune img {
  width: 48px;
  height: 48px;
  object-fit: contain;
  border-radius: 8px;
  background: rgba(255,255,255,0.12);
}
.pda-bandeau-commune .libelle {
  font-weight: 700;
  font-size: 0.95rem;
}
.pda-bandeau-commune .sous {
  color: var(--entete-sous);
  font-size: 0.75rem;
}
.pda-titre-ecran {
  margin: 0 12px 8px;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--bleu);
}

#pda_contenu {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 0 0 calc(64px + var(--safe-bas));
  -webkit-overflow-scrolling: touch;
}
#pda_contenu.fil-accoup {
  padding: 0 0 calc(64px + var(--safe-bas));
  overflow-y: scroll;
  scroll-snap-type: y mandatory;
  overscroll-behavior-y: contain;
}
#pda_contenu.fil-accoup .fil-carte {
  scroll-snap-align: start;
  scroll-snap-stop: always;
  margin: 0 0 2px;
  padding: 0;
  background: var(--fond);
}
#pda_contenu.fil-accoup .fil-carte:last-child {
  margin-bottom: 0;
}
#pda_contenu.fil-accoup .fil-carte .pda-carte {
  margin: 0;
  border-radius: 0;
  box-shadow: none;
  padding: 8px 10px;
}
.pda-page {
  padding: 0 16px 24px;
}
.pda-page.fil-carte {
  padding: 0;
}

.pda-champ {
  width: 100%;
  margin: 8px 0;
  padding: 12px 14px;
  border: 1px solid var(--bordure);
  border-radius: 8px;
  background: var(--surface);
  color: var(--texte);
}
.pda-btn {
  display: block;
  width: 100%;
  margin: 8px 0;
  padding: 12px 14px;
  border-radius: 8px;
  border: 1px solid var(--bleu);
  background: var(--bleu);
  color: #fff;
  font-weight: 600;
}
.pda-btn.secondaire {
  background: var(--surface);
  color: var(--bleu);
}
.pda-btn.texte {
  background: transparent;
  border: none;
  color: var(--bleu);
}
.pda-btn:disabled { opacity: 0.55; }
.pda-msg { color: var(--orange); font-size: 0.85rem; margin: 8px 0; }
.pda-msg.ok { color: var(--bleu); }

.pda-carte {
  background: var(--surface);
  border-radius: 12px;
  padding: 12px;
  margin: 10px 0;
  box-shadow: 0 1px 4px rgba(11,79,156,0.08);
}
.pda-carte.mise-en-avant {
  outline: 2px solid #c92a2a;
}
.pda-meta { font-size: 0.75rem; color: var(--meta); }
.pda-auteur { font-weight: 700; color: var(--bleu); text-decoration: underline; }
.pda-galerie img {
  width: 100%;
  max-height: 280px;
  object-fit: cover;
  border-radius: 8px;
  margin-top: 8px;
  cursor: pointer;
}

#pda_zoom {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: rgba(0, 0, 0, 0.88);
  display: flex;
  align-items: center;
  justify-content: center;
}
#pda_zoom[hidden] {
  display: none !important;
}
.pda-zoom-scene {
  width: 100%;
  height: 100%;
  overflow: hidden;
  touch-action: none;
  display: flex;
  align-items: center;
  justify-content: center;
}
#pda_zoom_img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  transform-origin: center center;
  user-select: none;
  -webkit-user-drag: none;
}
.pda-zoom-fermer {
  position: absolute;
  top: calc(8px + env(safe-area-inset-top, 0px));
  right: 8px;
  z-index: 81;
  width: 44px;
  height: 44px;
  border: none;
  border-radius: 22px;
  background: rgba(0, 0, 0, 0.45);
  color: #fff;
  font-size: 28px;
  line-height: 1;
}
.pda-ligne-action {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}
.pda-ligne-action button {
  flex: 1;
  min-width: 72px;
  padding: 8px;
  border-radius: 8px;
  border: 1px solid var(--bordure);
  background: var(--surface);
  color: var(--texte);
}

#pda_barre {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  background: var(--surface);
  border-top: 1px solid var(--bordure);
  padding-bottom: var(--safe-bas);
  z-index: 20;
}
#pda_barre[hidden] { display: none; }
.pda-onglet {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 8px 2px 6px;
  border: none;
  background: none;
  color: var(--meta);
  font-size: 0.68rem;
}
.pda-onglet.actif { color: var(--bleu); font-weight: 700; }
.pda-onglet .icone { font-size: 1.25rem; line-height: 1; }
.pda-badge {
  background: var(--badge);
  color: #fff;
  border-radius: 999px;
  padding: 0 5px;
  font-size: 0.65rem;
  min-width: 16px;
  text-align: center;
}

.pda-install {
  margin: 8px 12px;
  padding: 12px;
  border-radius: 10px;
  background: #fff3e0;
  color: var(--texte);
  font-size: 0.9rem;
  line-height: 1.35;
}
.pda-install[hidden] { display: none !important; }
.pda-install-titre {
  font-weight: 700;
  margin: 0 0 8px;
}
.pda-install-etape {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin: 6px 0;
}
.pda-install-etape span.num {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--bleu);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}
.pda-install-icone {
  display: inline-flex;
  vertical-align: middle;
  margin: 0 2px;
}
.pda-install-fermer {
  margin-top: 8px;
  width: auto;
  display: inline-block;
  padding: 6px 12px;
  font-size: 0.8rem;
}
.pda-splash {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
  gap: 16px;
}
.pda-liste-commune button.ligne {
  display: block;
  width: 100%;
  text-align: left;
  padding: 12px;
  margin: 0;
  border: none;
  border-bottom: 1px solid var(--bordure);
  background: var(--surface);
  color: var(--texte);
}
.pda-liste-commune button.ligne.actif {
  background: var(--bordure);
  font-weight: 700;
}
#pda_carte_osm { height: 70vh; width: 100%; border-radius: 8px; }

.pda-etape-barre {
  height: 4px;
  background: var(--bordure);
  border-radius: 4px;
  margin: 8px 0 16px;
}
.pda-etape-barre span {
  display: block;
  height: 100%;
  background: var(--bleu);
  border-radius: 4px;
}
.pda-select-type {
  width: 100%;
  padding: 12px;
  border-radius: 10px;
  border: 1px solid var(--bordure);
  background: #f0f4f8;
}

@media (display-mode: fullscreen), (display-mode: standalone) {
  .pda-install { display: none; }
}
