:root {
  --creme: #fff4e6;
  --peche: #ffe3c2;
  --rose: #ffc6b3;
  --mauve: #f8b4d0;
  --encre: #2b1d3a;
  --encre-douce: #6b5a7b;
  --violet: #7c3aed;
  --violet-fonce: #6228c9;
  --rose-vif: #ec4899;
  --blanc: #fffdfb;
  --ligne: rgba(124, 58, 237, 0.16);
  --ombre: 0 6px 24px rgba(124, 58, 237, 0.12);
  --vert: #1f7a4d;
  --rouge: #b42343;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--encre);
  background: linear-gradient(170deg, var(--creme) 0%, var(--peche) 45%, #ffd6cf 100%) fixed;
  line-height: 1.5;
  font-size: 17px;
}
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--violet); outline-offset: 2px; }
[hidden] { display: none !important; }

/* ---------- page principale ---------- */
.app { display: grid; grid-template-rows: auto auto 1fr auto; height: 100%; max-width: 860px; margin: 0 auto; padding: 0 16px; }
.haut { display: flex; justify-content: flex-end; padding: 10px 0 0; position: relative; }
.menu summary { list-style: none; cursor: pointer; padding: 6px 12px; border-radius: 999px; color: var(--encre-douce); font-size: 15px; }
.menu summary::-webkit-details-marker { display: none; }
.menu[open] summary { background: var(--blanc); box-shadow: var(--ombre); }
.menu .liste { position: absolute; right: 0; top: 44px; z-index: 5; background: var(--blanc); border-radius: 14px; box-shadow: var(--ombre); padding: 6px; min-width: 260px; }
.menu .liste button { display: block; width: 100%; text-align: left; background: none; border: 0; padding: 10px 12px; border-radius: 10px; }
.menu .liste button:hover { background: var(--creme); }
.scene { text-align: center; padding: 0 0 8px; }
.scene img { width: 150px; height: 150px; display: block; margin: 0 auto; }
.etat { margin: 2px 0 0; color: var(--encre-douce); font-size: 15px; min-height: 1.5em; }
.zone { overflow-y: auto; padding: 8px 2px 16px; scroll-behavior: smooth; }
.msg { margin: 10px 0; max-width: 92%; }
.msg.moi { margin-left: auto; background: var(--violet); color: #fff; padding: 10px 16px; border-radius: 20px 20px 6px 20px; white-space: pre-wrap; overflow-wrap: anywhere; width: fit-content; }
.msg.aria { background: var(--blanc); padding: 12px 18px; border-radius: 20px 20px 20px 6px; box-shadow: var(--ombre); overflow-wrap: anywhere; width: fit-content; }
.msg.aria p { margin: 0 0 0.7em; }
.msg.aria p:last-child { margin-bottom: 0; }
.msg.aria code { background: #f3e8ff; padding: 1px 6px; border-radius: 6px; font-size: 0.92em; }
.msg.aria pre { background: #2b1d3a; color: #fdf2f8; padding: 12px 14px; border-radius: 12px; overflow-x: auto; font-size: 0.9em; }
.msg.aria pre code { background: none; padding: 0; }
.msg.aria ul { margin: 0 0 0.7em; padding-left: 1.3em; }
.note { margin: 6px 0; color: var(--encre-douce); font-size: 14px; font-style: italic; }
.note.erreur { color: var(--rouge); font-style: normal; }

/* ---------- cartes de confirmation ---------- */
.carte { background: var(--blanc); border: 2px solid var(--violet); border-radius: 18px; padding: 16px 18px; margin: 14px 0; box-shadow: var(--ombre); max-width: 100%; }
.carte h3 { margin: 0 0 4px; font-size: 14px; letter-spacing: 0.04em; text-transform: uppercase; color: var(--violet); }
.carte .phrase { margin: 0 0 10px; font-size: 18px; font-weight: 600; overflow-wrap: anywhere; }
.carte details { margin: 0 0 12px; color: var(--encre-douce); font-size: 14px; }
.carte details pre { background: var(--creme); padding: 10px; border-radius: 10px; overflow-x: auto; max-height: 220px; color: var(--encre); white-space: pre-wrap; overflow-wrap: anywhere; }
.carte .actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.carte button { border: 0; border-radius: 12px; padding: 10px 22px; font-weight: 600; }
.carte .valider { background: var(--vert); color: #fff; }
.carte .refuser { background: #fff; color: var(--rouge); border: 2px solid var(--rouge); }
.carte .reste { margin-left: auto; color: var(--encre-douce); font-size: 14px; font-variant-numeric: tabular-nums; }
.carte .barre { height: 5px; background: var(--ligne); border-radius: 3px; margin-top: 12px; overflow: hidden; }
.carte .barre i { display: block; height: 100%; width: 100%; background: var(--rose-vif); transform-origin: left; }
.carte.fini { border-color: var(--ligne); opacity: 0.85; }
.carte.fini .actions, .carte.fini .barre { display: none; }
.carte .issue { font-weight: 600; margin: 0; }
.carte .issue.valide { color: var(--vert); }
.carte .issue.refuse, .carte .issue.expire, .carte .issue.annule { color: var(--rouge); }

/* ---------- saisie ---------- */
.saisie { padding: 8px 0 16px; }
.saisie form { display: flex; gap: 10px; align-items: flex-end; background: var(--blanc); border-radius: 22px; padding: 8px 8px 8px 18px; box-shadow: var(--ombre); }
.saisie textarea { flex: 1; border: 0; resize: none; background: transparent; outline: none; max-height: 200px; padding: 8px 0; }
.saisie button { border: 0; border-radius: 16px; padding: 10px 20px; font-weight: 600; background: linear-gradient(135deg, var(--violet), var(--rose-vif)); color: #fff; }
.saisie button:disabled { opacity: 0.45; cursor: default; }
.saisie .stop { background: #fff; color: var(--rouge); border: 2px solid var(--rouge); }
.hors { background: #fff0f3; color: var(--rouge); text-align: center; padding: 6px; border-radius: 12px; font-size: 14px; margin-bottom: 6px; }

/* ---------- connexion et enrolement ---------- */
.centre { min-height: 100%; display: grid; place-items: center; padding: 24px 16px; }
.boite { background: var(--blanc); border-radius: 26px; box-shadow: var(--ombre); padding: 28px 28px 24px; width: min(440px, 100%); text-align: center; }
.boite img.logo { width: 120px; height: 120px; }
.boite h1 { margin: 4px 0 4px; font-size: 26px; }
.boite p { color: var(--encre-douce); margin: 0 0 16px; font-size: 15px; }
.boite label { display: block; text-align: left; font-weight: 600; font-size: 14px; margin: 12px 0 4px; }
.boite input { width: 100%; padding: 12px 14px; border-radius: 12px; border: 2px solid var(--ligne); background: #fff; }
.boite input:focus { border-color: var(--violet); outline: none; }
.boite button.principal { width: 100%; margin-top: 18px; border: 0; border-radius: 14px; padding: 13px; font-weight: 700; color: #fff; background: linear-gradient(135deg, var(--violet), var(--rose-vif)); }
.boite .erreur { color: var(--rouge); min-height: 1.4em; margin: 12px 0 0; font-weight: 600; }
.boite .secret { font-family: ui-monospace, Consolas, monospace; letter-spacing: 0.08em; background: var(--creme); border-radius: 10px; padding: 8px; word-break: break-all; font-size: 15px; }
.boite .espace { margin-top: 18px; }
.boite img.qr { width: 220px; height: 220px; border-radius: 12px; background: #fff; border: 1px solid var(--ligne); }
