html, body { height: 100%; }
body { overscroll-behavior: none; }
body.fige { overflow: hidden; }
#appli { min-height: 100%; display: flex; flex-direction: column; }
#onglet {
  flex: 1; width: 100%; max-width: 640px; margin: 0 auto;
  padding: calc(16px + env(safe-area-inset-top)) 16px calc(96px + env(safe-area-inset-bottom));
}
#onglet.entre { animation: entree 0.22s ease; }
@keyframes entree { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
h1.titre-onglet { font-size: 28px; margin: 8px 0 16px; line-height: 1.15; }

/* Barre d'onglets */
#barre {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: grid; grid-template-columns: repeat(5, minmax(0, 1fr));
  background: var(--surface); border-top: 1px solid var(--bord);
  padding: 6px 2px calc(6px + env(safe-area-inset-bottom));
  transition: transform 0.2s ease;
}
#barre.cachee { transform: translateY(110%); }
#barre button {
  border: 0; background: none; display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 6px 0; border-radius: 12px; color: var(--texte-2); font-size: 10.5px; font-weight: 500; letter-spacing: -0.01em; cursor: pointer; min-width: 0;
  transition: color 0.2s ease, background 0.2s ease;
}
#barre button span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#barre button[aria-current="page"] { color: var(--texte); background: var(--surface-2); }
#barre .ic { width: 22px; height: 22px; }

/* Listes */
.liste { display: flex; flex-direction: column; gap: 8px; }
.ligne {
  display: flex; align-items: center; gap: 12px; width: 100%; min-height: 64px; padding: 10px 14px;
  border: 0; border-radius: var(--rayon); background: var(--surface); box-shadow: var(--ombre);
  color: var(--texte); text-align: left; cursor: pointer; text-decoration: none;
  transition: transform 0.12s ease, background 0.2s ease, opacity 0.2s ease;
}
.ligne:active { transform: scale(0.985); }
.ligne .txt { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.ligne .titre { font-weight: 650; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.ligne .meta { font-size: 14px; color: var(--texte-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ligne > .ic:last-child { color: var(--texte-2); }
.ligne .pastille-ui {
  width: 40px; height: 40px; border-radius: 50%; background: var(--surface-2);
  display: inline-flex; align-items: center; justify-content: center; flex: none;
}
.ligne .avatar { width: 40px; height: 40px; font-size: 15px; }
.mini-icones { display: flex; gap: 2px; flex: none; }
.mini-icones .icr { width: 24px; height: 24px; }
.mini-icones .icr svg, .mini-icones .icr .ic { width: 14px; height: 14px; }
.vide { display: flex; flex-direction: column; align-items: center; gap: 16px; padding: 48px 0; color: var(--texte-2); text-align: center; }
.vide p { margin: 0; }
.entete-liste { display: flex; gap: 8px; margin-bottom: 12px; }
.entete-liste .btn { flex: 1; }
.section { margin: 20px 0 8px; font-size: 14px; font-weight: 700; color: var(--texte-2); }
.recherche { display: block; position: relative; margin-bottom: 12px; }
.recherche .ic { position: absolute; left: 14px; top: 14px; color: var(--texte-2); }
.recherche input {
  width: 100%; min-height: 48px; padding: 12px 14px 12px 44px; border-radius: 12px;
  border: 1px solid var(--bord); background: var(--surface); outline: none;
}
.coche {
  width: 26px; height: 26px; border-radius: 8px; border: 2px solid var(--bord); flex: none;
  display: inline-flex; align-items: center; justify-content: center; transition: background 0.15s ease, border-color 0.15s ease;
}
.coche .ic { width: 16px; height: 16px; opacity: 0; transition: opacity 0.15s ease; }
[aria-checked="true"] .coche { background: var(--accent); border-color: var(--accent); color: var(--sur-accent); }
[aria-checked="true"] .coche .ic { opacity: 1; }
.info { display: flex; flex-direction: column; gap: 2px; padding: 12px 14px; border-radius: var(--rayon); background: var(--surface); box-shadow: var(--ombre); }
.info .etiquette { font-size: 14px; color: var(--texte-2); font-weight: 600; }
.formulaire { display: flex; flex-direction: column; gap: 14px; }
.apercu-lien { font-size: 14px; color: var(--texte-2); display: flex; align-items: center; gap: 8px; min-width: 0; }
.apercu-lien > span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.apercu-lien .btn { min-height: 40px; flex: none; }
.apercu-lien:empty { display: none; }

/* Pages (détails) */
.couche-page {
  position: fixed; inset: 0; z-index: 20; background: var(--fond);
  display: flex; flex-direction: column;
  transform: translateX(100%); transition: transform 0.26s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.couche-page.ouverte { transform: none; }
.couche-page header {
  display: flex; align-items: center; gap: 8px;
  padding: calc(8px + env(safe-area-inset-top)) 8px 8px; max-width: 640px; width: 100%; margin: 0 auto;
}
.couche-page header h2 { margin: 0; font-size: 20px; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.btn-icone { min-height: 44px; width: 44px; padding: 0; border-radius: 50%; flex: none; }
.couche-page .contenu { flex: 1; overflow-y: auto; overscroll-behavior: contain; }
.couche-page .contenu > div { max-width: 640px; margin: 0 auto; padding: 8px 16px 24px; display: flex; flex-direction: column; gap: 12px; }
.actions {
  display: flex; gap: 8px; padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
  background: var(--surface); border-top: 1px solid var(--bord);
}
.actions > div { display: flex; gap: 8px; width: 100%; max-width: 608px; margin: 0 auto; }
.actions .btn:not(.btn-icone) { flex: 1 1 0; }

/* Feuilles du bas */
.couche-feuille { position: fixed; inset: 0; z-index: 30; }
.couche-feuille .voile { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.4); opacity: 0; transition: opacity 0.22s ease; }
.couche-feuille .feuille {
  position: absolute; left: 0; right: 0; bottom: 0; max-height: 88%; margin: 0 auto; max-width: 640px;
  background: var(--surface); border-radius: 20px 20px 0 0; display: flex; flex-direction: column;
  transform: translateY(100%); transition: transform 0.26s cubic-bezier(0.2, 0.8, 0.2, 1);
  padding-bottom: env(safe-area-inset-bottom);
}
.couche-feuille.ouverte .voile { opacity: 1; }
.couche-feuille.ouverte .feuille { transform: none; }
.feuille .poignee { width: 40px; height: 4px; border-radius: 2px; background: var(--bord); margin: 8px auto 0; flex: none; }
.feuille .tete { display: flex; align-items: center; gap: 8px; padding: 8px 8px 4px 16px; }
.feuille .tete h3 { margin: 0; flex: 1; font-size: 18px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.feuille .corps { overflow-y: auto; overscroll-behavior: contain; padding: 8px 16px 16px; display: flex; flex-direction: column; gap: 10px; }
.feuille .choix {
  display: flex; align-items: center; gap: 12px; width: 100%; min-height: 56px; padding: 8px 12px; border: 0; border-radius: 12px;
  background: var(--surface-2); color: var(--texte); font-weight: 600; text-align: left; cursor: pointer;
}
.feuille .choix.danger { color: var(--danger); }
.feuille .choix > span:not(.icr) { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.code-secours {
  font: 700 22px/1.3 ui-monospace, Menlo, Consolas, monospace; letter-spacing: 0.04em; text-align: center;
  padding: 16px; border-radius: 12px; background: var(--surface-2);
}

/* QR code */
.qr-boite { background: #fff; border-radius: 20px; padding: 18px; align-self: center; width: min(100%, 340px); box-shadow: var(--ombre); }
.qr-boite svg { display: block; width: 100%; height: auto; }
.qr-titre { text-align: center; margin: 4px 0 0; font-size: 22px; }
.qr-lien { text-align: center; color: var(--texte-2); font-size: 14px; margin: 0; }
.photo-fiche { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.photo-fiche .avatar { width: 80px; height: 80px; font-size: 28px; }
.photo-fiche .boutons { display: flex; flex-direction: column; gap: 8px; width: 100%; }

#toast {
  position: fixed; left: 50%; bottom: calc(96px + env(safe-area-inset-bottom)); z-index: 40;
  transform: translate(-50%, 10px); opacity: 0; pointer-events: none;
  background: var(--texte); color: var(--fond); padding: 10px 16px; border-radius: 12px; font-weight: 600; font-size: 15px;
  max-width: calc(100% - 32px); transition: opacity 0.2s ease, transform 0.2s ease;
}
#toast.visible { opacity: 1; transform: translate(-50%, 0); }
