:root {
  --fond: #f4f6f4;
  --surface: #ffffff;
  --surface-2: #f0f3f0;
  --texte: #16211a;
  --texte-2: #57635b;
  --bord: #dde3de;
  --vert: #15803d;
  --vert-fonce: #116632;
  --vert-pale: #e3f3e8;
  --rouge: #c62828;
  --rouge-pale: #fbe7e7;
  --gris: #5b6470;
  --gris-pale: #eceef1;
  --gris-btn: #5b6470;
  --bleu: #1d4ed8;
  --bleu-pale: #e5ecfc;
  --ombre: 0 1px 2px rgba(16, 33, 22, .06), 0 4px 16px rgba(16, 33, 22, .06);
  --rayon: 14px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --fond: #0f1411;
    --surface: #171e19;
    --surface-2: #1f2822;
    --texte: #e7ede8;
    --texte-2: #9daaa1;
    --bord: #2c3830;
    --vert: #22a355;
    --vert-fonce: #1b8a47;
    --vert-pale: #16301f;
    --rouge: #ef5350;
    --rouge-pale: #3a1a1a;
    --gris: #a3adb8;
    --gris-pale: #252b31;
    --gris-btn: #4b5563;
    --bleu: #7aa2ff;
    --bleu-pale: #1b2540;
    --ombre: 0 1px 2px rgba(0, 0, 0, .4);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--fond);
  color: var(--texte);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  min-height: 100vh;
}

[hidden] { display: none !important; }

h1, h2, h3 { line-height: 1.25; margin: 0; }

/* ---------- Barre ---------- */
.barre {
  background: var(--vert);
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 5;
}
.barre-int {
  max-width: 560px;
  margin: 0 auto;
  padding: 10px 16px;
  padding-top: calc(10px + env(safe-area-inset-top));
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.marque { display: flex; align-items: center; gap: 10px; font-weight: 700; letter-spacing: .2px; }
.logo svg { width: 28px; height: 28px; display: block; }
.logo rect { fill: #fff; }
.logo path { stroke: var(--vert); stroke-width: 3.2; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.barre .lien-discret { color: #fff; opacity: .9; }

main { max-width: 560px; margin: 0 auto; padding: 16px 16px 48px; }

/* ---------- Connexion ---------- */
.intro { margin: 8px 2px 18px; }
.intro h1 { font-size: 1.45rem; }
.intro p { margin: 6px 0 0; color: var(--texte-2); }

.carte {
  background: var(--surface);
  border: 1px solid var(--bord);
  border-radius: var(--rayon);
  box-shadow: var(--ombre);
  padding: 18px;
  margin-bottom: 14px;
}

.etape { font-size: 1.02rem; display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.num {
  width: 24px; height: 24px; border-radius: 50%;
  background: var(--vert); color: #fff; font-size: .8rem;
  display: inline-grid; place-items: center; flex: none;
}

.champ { display: block; margin-bottom: 14px; }
.champ > span:first-child { display: block; font-size: .88rem; font-weight: 600; margin-bottom: 5px; }
.champ small { display: block; color: var(--texte-2); font-size: .8rem; margin-top: 5px; }

input {
  width: 100%;
  font: inherit;
  font-size: 1.05rem;
  padding: 11px 12px;
  border: 1px solid var(--bord);
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--texte);
  min-height: 46px;
}
input:focus { outline: 2px solid var(--vert); outline-offset: 1px; background: var(--surface); }

.mdp { display: flex; gap: 8px; }
.mdp input { flex: 1; min-width: 0; letter-spacing: .12em; }
.voir {
  flex: none;
  border: 1px solid var(--bord);
  background: var(--surface);
  color: var(--texte-2);
  border-radius: 10px;
  padding: 0 12px;
  font: inherit;
  font-size: .85rem;
  cursor: pointer;
}

.bienvenue {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--vert-pale);
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 16px;
}
.sur-titre { display: block; font-size: .78rem; color: var(--texte-2); text-transform: uppercase; letter-spacing: .06em; }

.message {
  background: var(--rouge-pale);
  color: var(--rouge);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: .92rem;
  margin: 0 0 14px;
}

.pied { text-align: center; color: var(--texte-2); font-size: .85rem; margin-top: 18px; }

/* ---------- Boutons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%;
  min-height: 48px;
  padding: 10px 16px;
  border-radius: 12px;
  border: 0;
  font: inherit;
  font-weight: 700;
  font-size: 1rem;
  cursor: pointer;
  background: var(--vert);
  color: #fff;
  transition: filter .15s, transform .05s;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-principal:hover:not(:disabled) { background: var(--vert-fonce); }
.btn-second { background: var(--surface-2); color: var(--texte); border: 1px solid var(--bord); }
.btn-texte { background: transparent; color: var(--vert); border: 1px solid var(--bord); font-weight: 600; }

.lien-discret {
  background: none; border: 0; padding: 4px 0;
  color: var(--vert); font: inherit; font-size: .9rem; font-weight: 600;
  cursor: pointer; text-decoration: underline; text-underline-offset: 3px;
}

/* ---------- Séance ---------- */
.entete-ag { margin: 4px 2px 14px; }
.residence { font-size: 1.3rem; font-weight: 750; }
.meta { color: var(--texte-2); font-size: .9rem; }

.onglets {
  display: grid; grid-template-columns: 1fr 1fr; gap: 4px;
  background: var(--surface-2);
  border: 1px solid var(--bord);
  border-radius: 12px;
  padding: 4px;
  margin-bottom: 14px;
}
.onglets button {
  border: 0; background: transparent; color: var(--texte-2);
  font: inherit; font-weight: 600; font-size: .95rem;
  padding: 9px; border-radius: 9px; cursor: pointer;
}
.onglets button[aria-selected="true"] { background: var(--surface); color: var(--texte); box-shadow: var(--ombre); }

.etat-vide { text-align: center; padding: 30px 18px; }
.etat-vide .pastille {
  width: 56px; height: 56px; border-radius: 50%;
  display: grid; place-items: center; margin: 0 auto 12px;
  background: var(--surface-2); font-size: 1.6rem;
}
.etat-vide h2 { font-size: 1.15rem; margin-bottom: 6px; }
.etat-vide p { color: var(--texte-2); margin: 0 0 4px; }
.etat-vide .btn { margin-top: 14px; }

.attente-points { display: inline-flex; gap: 5px; }
.attente-points i {
  width: 8px; height: 8px; border-radius: 50%; background: var(--vert);
  animation: pulse 1.2s infinite ease-in-out;
}
.attente-points i:nth-child(2) { animation-delay: .2s; }
.attente-points i:nth-child(3) { animation-delay: .4s; }
@keyframes pulse { 0%, 80%, 100% { opacity: .25; transform: scale(.8); } 40% { opacity: 1; transform: scale(1); } }
@media (prefers-reduced-motion: reduce) { .attente-points i { animation: none; opacity: .7; } }

.reso-num { font-size: .8rem; font-weight: 700; color: var(--vert); text-transform: uppercase; letter-spacing: .06em; }
.reso-titre { font-size: 1.15rem; margin: 4px 0 10px; }
.puces { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.puce {
  font-size: .8rem; padding: 3px 9px; border-radius: 999px;
  background: var(--surface-2); color: var(--texte-2); border: 1px solid var(--bord);
}

.section-titre {
  display: flex; justify-content: space-between; align-items: baseline;
  font-size: .82rem; font-weight: 700; color: var(--texte-2);
  text-transform: uppercase; letter-spacing: .06em;
  margin: 18px 2px 8px;
}

.voix { list-style: none; margin: 0; padding: 0; }
.voix li + li { margin-top: 8px; }
.voix label {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--bord);
  border-radius: 12px;
  padding: 12px;
  cursor: pointer;
}
.voix label:has(input:checked) { border-color: var(--vert); box-shadow: 0 0 0 1px var(--vert) inset; }
.voix input[type=checkbox] { width: 22px; height: 22px; min-height: 0; accent-color: var(--vert); margin: 0; }
.voix .nom { display: block; font-weight: 600; line-height: 1.3; }
.voix .detail { display: block; font-size: .82rem; color: var(--texte-2); margin-top: 2px; }
.etiquette { font-size: .72rem; font-weight: 700; padding: 1px 7px; border-radius: 6px; background: var(--bleu-pale); color: var(--bleu); margin-left: 4px; vertical-align: 1px; }

.badge {
  font-size: .75rem; font-weight: 700; padding: 4px 8px; border-radius: 8px; white-space: nowrap;
  background: var(--gris-pale); color: var(--gris);
}
.badge.pour { background: var(--vert-pale); color: var(--vert); }
.badge.contre { background: var(--rouge-pale); color: var(--rouge); }
.badge.abst { background: var(--gris-pale); color: var(--gris); }
.badge.attente { background: transparent; color: var(--texte-2); border: 1px dashed var(--bord); font-weight: 600; }

.selection-resume { font-size: .9rem; color: var(--texte-2); margin: 12px 2px 10px; min-height: 1.4em; }

.choix { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
.choix .btn { font-size: .95rem; padding: 10px 6px; min-height: 56px; }
.btn.pour { background: var(--vert); }
.btn.contre { background: var(--rouge); }
.btn.abst { background: var(--gris-btn); }

.actualise {
  display: flex; justify-content: center; align-items: center; gap: 10px;
  color: var(--texte-2); font-size: .82rem; margin-top: 18px;
}

/* ---------- Résultats ---------- */
.resultat {
  background: var(--surface);
  border: 1px solid var(--bord);
  border-radius: 12px;
  margin-bottom: 8px;
  overflow: hidden;
}
.resultat summary {
  list-style: none;
  display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: center;
  padding: 12px 14px; cursor: pointer;
}
.resultat summary::-webkit-details-marker { display: none; }
.resultat .r-titre { font-weight: 600; line-height: 1.35; }
.resultat .r-num { color: var(--texte-2); font-weight: 700; margin-right: 4px; }
.resultat .r-detail { border-top: 1px solid var(--bord); padding: 8px 14px 12px; font-size: .88rem; }
.resultat .r-detail div { display: flex; justify-content: space-between; gap: 10px; padding: 4px 0; }
.resultat .r-detail div + div { border-top: 1px dashed var(--bord); }
.badge.accepte { background: var(--vert-pale); color: var(--vert); }
.badge.refuse { background: var(--rouge-pale); color: var(--rouge); }
.badge.second { background: var(--bleu-pale); color: var(--bleu); }

/* ---------- Dialogues ---------- */
.dialogue {
  border: 0; border-radius: 16px; padding: 20px;
  width: min(440px, calc(100vw - 32px));
  background: var(--surface); color: var(--texte);
  box-shadow: 0 20px 60px rgba(0,0,0,.3);
}
.dialogue::backdrop { background: rgba(10, 20, 14, .55); }
.dialogue h2 { font-size: 1.2rem; margin-bottom: 8px; }
.dialogue p { margin: 0 0 8px; color: var(--texte-2); }
.liste-simple { margin: 0 0 16px; padding-left: 18px; font-size: .92rem; max-height: 30vh; overflow: auto; }
.dialogue-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

.dialogue-large { width: min(720px, calc(100vw - 24px)); height: min(86vh, 900px); padding: 0; display: none; }
.dialogue-large[open] { display: flex; flex-direction: column; }
.dialogue-tete {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  padding: 14px 16px; border-bottom: 1px solid var(--bord);
}
.dialogue-tete h2 { margin: 0; font-size: 1.05rem; }
.fermer { border: 0; background: var(--surface-2); color: var(--texte); width: 36px; height: 36px; border-radius: 50%; font-size: 1rem; cursor: pointer; flex: none; }
#texte-cadre { flex: 1; width: 100%; border: 0; background: #fff; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  background: var(--texte); color: var(--fond);
  padding: 12px 18px; border-radius: 12px;
  font-weight: 600; font-size: .92rem;
  box-shadow: 0 8px 24px rgba(0,0,0,.25);
  max-width: calc(100vw - 32px);
  z-index: 20;
}
.toast.erreur { background: var(--rouge); color: #fff; }

@media (min-width: 600px) {
  main { padding-top: 28px; }
  .intro h1 { font-size: 1.7rem; }
}
