:root {
  --encre: #1f2a2e;
  --encre-douce: #55636a;
  --fond: #faf8f5;
  --carte: #ffffff;
  --trait: #e4dfd8;
  --accent: #2f6b62;
  --accent-clair: #e3efec;
  --alerte: #b2453a;
  --alerte-clair: #f8e6e3;
  --avertissement: #8a6a1f;
  --avertissement-clair: #fbf2dc;
  --largeur-coulisses: 370px;
  --rayon: 12px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--encre);
  background: var(--fond);
}

* { box-sizing: border-box; }

body { margin: 0; line-height: 1.55; }

h1, h2 { line-height: 1.25; }

a { color: var(--accent); }

.invisible {
  position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}

.bandeau {
  position: sticky; top: 0; z-index: 30;
  display: flex; flex-wrap: wrap; gap: 6px 18px; align-items: center; justify-content: space-between;
  padding: 9px 18px;
  background: var(--avertissement-clair);
  border-bottom: 1px solid #ecdcae;
  font-size: 0.9rem;
}
.bandeau-texte { margin: 0; }
.bandeau-liens a { font-weight: 600; white-space: nowrap; }

.mise-en-page { display: flex; align-items: flex-start; }

.vente {
  flex: 1; min-width: 0;
  max-width: 860px; margin: 0 auto;
  padding: 28px 28px 220px;
}
.vente section { margin-bottom: 30px; }
.hero { padding: 26px 0 8px; }
.surtitre { color: var(--accent); font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; font-size: 0.8rem; margin: 0; }
.hero h1 { font-size: clamp(1.7rem, 4vw, 2.4rem); margin: 6px 0 10px; }
.chapeau { font-size: 1.15rem; color: var(--encre-douce); max-width: 620px; }
.cta-ligne { display: flex; flex-wrap: wrap; align-items: center; gap: 14px; }
.mention { color: var(--encre-douce); font-size: 0.92rem; }
.liste li { margin-bottom: 6px; }
.note-demo { background: var(--carte); border: 1px dashed var(--trait); border-radius: var(--rayon); padding: 4px 18px; color: var(--encre-douce); font-size: 0.93rem; }

.bouton {
  font: inherit; font-weight: 600;
  border: 0; border-radius: 999px;
  background: var(--accent); color: #fff;
  padding: 10px 20px; cursor: pointer;
}
.bouton:hover { filter: brightness(1.08); }
.bouton:disabled { opacity: 0.55; cursor: wait; }
.bouton.secondaire { background: var(--accent-clair); color: var(--accent); }
.bouton.petit { padding: 7px 14px; font-size: 0.88rem; }
.lien-bouton { font: inherit; font-size: 0.85rem; background: none; border: 0; color: var(--encre-douce); cursor: pointer; text-decoration: underline; padding: 4px; }

.coulisses {
  width: var(--largeur-coulisses); flex-shrink: 0;
  position: sticky; top: 42px;
  height: calc(100vh - 42px); overflow-y: auto;
  background: #f1f4f3; border-left: 1px solid var(--trait);
  padding: 14px 16px 30px;
  font-size: 0.88rem;
}
.coulisses.pulse .etat-courant { animation: pulse 0.7s ease-out; }
@keyframes pulse { from { box-shadow: 0 0 0 4px rgba(47, 107, 98, 0.35); } to { box-shadow: 0 0 0 0 rgba(47, 107, 98, 0); } }
.coulisses-entete { display: flex; align-items: center; justify-content: space-between; }
.coulisses-entete h2 { font-size: 1.05rem; margin: 0; }
.bloc { background: var(--carte); border: 1px solid var(--trait); border-radius: var(--rayon); padding: 10px 12px; margin-top: 12px; }
.etiquette { margin: 0 0 6px; font-size: 0.74rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--encre-douce); font-weight: 700; }
.sous-etiquette { margin: 8px 0 2px; font-weight: 600; }
.etat-courant {
  display: inline-block; margin: 0;
  font-family: ui-monospace, "SFMono-Regular", Menlo, monospace; font-size: 1.25rem; font-weight: 700;
  background: var(--accent-clair); color: var(--accent);
  padding: 4px 12px; border-radius: 8px;
}
.etat-courant.alerte { background: var(--alerte-clair); color: var(--alerte); }
.etat-courant.fin { background: #dcefdc; color: #2c6a2c; }
.dernier-tour { margin: 6px 0 8px; color: var(--encre-douce); }
.frise { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 4px; }
.etape { font-family: ui-monospace, Menlo, monospace; font-size: 0.72rem; border: 1px solid var(--trait); border-radius: 6px; padding: 2px 6px; color: var(--encre-douce); display: flex; flex-direction: column; }
.etape.fait { background: #eef3f2; }
.etape.courant { border-color: var(--accent); color: var(--accent); background: var(--accent-clair); font-weight: 700; }
.etape.deja_renseigne { border-style: dashed; border-color: var(--accent); }
.etape-statut { font-family: system-ui, sans-serif; font-size: 0.66rem; }
.transverses { margin: 8px 0 0; color: var(--encre-douce); }
.pastille { font-family: ui-monospace, Menlo, monospace; font-size: 0.72rem; border: 1px solid var(--trait); border-radius: 6px; padding: 1px 6px; }
.pastille.active { background: var(--avertissement-clair); border-color: var(--avertissement); color: var(--avertissement); font-weight: 700; }
#pastille-alerte.active { background: var(--alerte-clair); border-color: var(--alerte); color: var(--alerte); }

.champs { margin: 0; display: grid; grid-template-columns: 118px 1fr; gap: 5px 8px; }
.champs dt { color: var(--encre-douce); }
.champs dd { margin: 0; display: flex; flex-wrap: wrap; gap: 4px; }
.puce { background: var(--accent-clair); color: var(--accent); border-radius: 6px; padding: 0 7px; }
.vide { color: #a0a8ab; }

.analyse-liste { margin: 0; display: grid; grid-template-columns: 118px 1fr; gap: 3px 8px; }
.analyse-liste dt { color: var(--encre-douce); }
.analyse-liste dd { margin: 0; }
.garde-fous { margin: 2px 0 0; padding-left: 18px; color: var(--avertissement); }

.journal { list-style: none; margin: 0; padding: 0; max-height: 300px; overflow-y: auto; }
.journal li { border-bottom: 1px solid var(--trait); padding: 6px 0; }
.journal li:last-child { border-bottom: 0; }
.transition { margin: 0; font-weight: 600; }
.etat-mini { font-family: ui-monospace, Menlo, monospace; font-size: 0.78rem; }
.etat-mini.alerte { color: var(--alerte); }
.raison { margin: 2px 0 0; color: var(--encre-douce); }

.scenarios { display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px; }
.bouton-scenario {
  font: inherit; text-align: left; cursor: pointer;
  background: #fff; border: 1px solid var(--trait); border-radius: 8px; padding: 7px 10px;
}
.bouton-scenario:hover { border-color: var(--accent); }
.bouton-scenario.alerte { border-left: 4px solid var(--alerte); }
.bouton-scenario:not(.alerte) { border-left: 4px solid var(--accent); }

.ouvrir-coulisses {
  display: none; position: fixed; top: 54px; right: 10px; z-index: 25;
  font: inherit; font-size: 0.85rem; font-weight: 600;
  background: var(--encre); color: #fff; border: 0; border-radius: 999px; padding: 6px 14px; cursor: pointer;
}
body.coulisses-masquees .coulisses { display: none; }
body.coulisses-masquees .ouvrir-coulisses { display: block; }

.widget {
  position: fixed; z-index: 20;
  right: calc(var(--largeur-coulisses) + 18px); bottom: 16px;
  width: 380px; height: min(620px, calc(100vh - 80px));
  display: flex; flex-direction: column;
  background: var(--carte); border: 1px solid var(--trait); border-radius: 16px;
  box-shadow: 0 12px 40px rgba(31, 42, 46, 0.18);
  overflow: hidden;
}
body.coulisses-masquees .widget { right: 16px; }
.widget.reduit { display: none; }
.widget-entete { display: flex; align-items: center; gap: 10px; padding: 10px 12px; background: var(--accent); color: #fff; }
.widget-entete p { margin: 0; }
.widget-nom { font-weight: 700; }
.widget-sous-titre { font-size: 0.78rem; opacity: 0.85; }
.widget-reduire { margin-left: auto; color: #fff; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: #fff; color: var(--accent); display: grid; place-items: center; font-weight: 700; }
.fil { flex: 1; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 8px; background: #fbfaf8; }
.message { max-width: 88%; padding: 8px 12px; border-radius: 14px; white-space: pre-line; overflow-wrap: anywhere; font-size: 0.94rem; }
.de-claire { align-self: flex-start; background: #fff; border: 1px solid var(--trait); border-bottom-left-radius: 4px; }
.du-visiteur { align-self: flex-end; background: var(--accent); color: #fff; border-bottom-right-radius: 4px; }
.message.info { align-self: center; background: var(--avertissement-clair); color: var(--avertissement); font-size: 0.85rem; }
.saisie-en-cours { display: flex; gap: 4px; padding: 12px 14px; }
.saisie-en-cours span { width: 7px; height: 7px; border-radius: 50%; background: #9fb0ad; animation: rebond 1s infinite; }
.saisie-en-cours span:nth-child(2) { animation-delay: 0.15s; }
.saisie-en-cours span:nth-child(3) { animation-delay: 0.3s; }
@keyframes rebond { 0%, 60%, 100% { transform: translateY(0); } 30% { transform: translateY(-4px); } }
.saisie { display: flex; gap: 8px; padding: 10px; border-top: 1px solid var(--trait); }
.saisie textarea { flex: 1; resize: none; font: inherit; font-size: 0.94rem; border: 1px solid var(--trait); border-radius: 10px; padding: 8px 10px; }
.saisie textarea:focus, .formulaire-contact input:focus, .formulaire-contact select:focus { outline: 2px solid var(--accent); outline-offset: 0; }
.widget-mention { margin: 0; padding: 0 12px 8px; font-size: 0.75rem; color: var(--encre-douce); }

.bulle {
  position: fixed; z-index: 20; right: calc(var(--largeur-coulisses) + 18px); bottom: 16px;
  font: inherit; font-weight: 700;
  background: var(--accent); color: #fff; border: 0; border-radius: 999px; padding: 12px 22px;
  box-shadow: 0 8px 24px rgba(31, 42, 46, 0.25); cursor: pointer;
}
body.coulisses-masquees .bulle { right: 16px; }
.bulle.cachee { display: none; }

.formulaire-contact {
  align-self: stretch; background: #fff; border: 1px solid var(--accent); border-radius: 12px; padding: 12px;
  display: flex; flex-direction: column; gap: 4px; font-size: 0.9rem;
}
.formulaire-titre { margin: 0 0 4px; font-weight: 700; color: var(--accent); }
.formulaire-contact label { display: flex; flex-direction: column; gap: 2px; }
.formulaire-contact input:not([type="checkbox"]), .formulaire-contact select { font: inherit; border: 1px solid var(--trait); border-radius: 8px; padding: 6px 8px; background: #fff; }
.formulaire-contact .case { flex-direction: row; align-items: flex-start; gap: 8px; font-size: 0.84rem; margin-top: 6px; }
.formulaire-contact .case input { margin-top: 4px; }
.erreur { margin: 0; color: var(--alerte); font-size: 0.8rem; min-height: 0; }
.erreur:empty { display: none; }
.mention-demo { margin: 4px 0; font-size: 0.76rem; color: var(--encre-douce); }

@media (max-width: 1250px) {
  :root { --largeur-coulisses: 330px; }
  .widget { width: 340px; }
}

@media (max-width: 900px) {
  .coulisses {
    position: fixed; z-index: 40; top: 0; right: 0; bottom: 0;
    width: min(100%, 420px); height: auto;
    box-shadow: -8px 0 30px rgba(31, 42, 46, 0.2);
  }
  .widget, body.coulisses-masquees .widget {
    right: 0; left: 0; bottom: 0; width: 100%; max-width: 100vw;
    height: min(62vh, 520px); height: min(62dvh, 520px);
    border-radius: 16px 16px 0 0;
    padding-bottom: env(safe-area-inset-bottom);
  }
  .widget-entete > div { min-width: 0; }
  .widget-reduire { flex-shrink: 0; }
  .saisie textarea { min-width: 0; }
  .saisie .bouton { flex-shrink: 0; padding: 10px 14px; }
  .bulle, body.coulisses-masquees .bulle { right: 14px; }
  .vente { padding: 18px 16px 66vh; }
  .bandeau { position: static; padding: 9px 14px; }
  .bandeau-texte { overflow-wrap: anywhere; }
  .bandeau-liens a { white-space: normal; overflow-wrap: anywhere; }
  .ouvrir-coulisses, body.coulisses-masquees .ouvrir-coulisses {
    top: auto; right: 10px;
    bottom: calc(min(62vh, 520px) + 10px);
    bottom: calc(min(62dvh, 520px) + 10px);
  }
  body:has(.widget.reduit) .ouvrir-coulisses { bottom: 76px; }
}
