:root {
  --encre: #14213d; --encre-2: #3d4a66; --gris: #6b7690; --ligne: #dfe4ef; --fond: #f3f5fa; --blanc: #fff;
  --accent: #0f9d8a; --accent-f: #0b7d6e; --A: #2a5db0; --A-f: #e3eefc; --B: #c79a00; --B-f: #fff4cc;
  --danger: #c0182b; --rayon: 16px; --ombre: 0 6px 24px rgba(20, 33, 61, .08);
  --haut: env(safe-area-inset-top, 0px); --bas: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--encre); background: var(--fond); font-size: 16px; line-height: 1.45; overscroll-behavior: none; }
button { font: inherit; color: inherit; cursor: pointer; }
input, textarea, select { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.petit { font-size: .84rem; color: var(--gris); }
.centre { text-align: center; }
.erreur { color: var(--danger); min-height: 1.2em; font-size: .9rem; margin: .4rem 0; }

/* Boutons */
.btn { border: 0; border-radius: 12px; padding: .85rem 1.1rem; font-weight: 600; font-size: 1rem; }
.btn-principal { background: var(--accent); color: #fff; width: 100%; box-shadow: 0 4px 14px rgba(15, 157, 138, .3); }
.btn-principal:active { background: var(--accent-f); }
.btn-leger { background: var(--blanc); border: 1px solid var(--ligne); }
.btn-danger { background: #fff0f1; color: var(--danger); border: 1px solid #f5c6cc; }
.btn-A { background: var(--A); color: #fff; width: 100%; } .btn-B { background: var(--B); color: #fff; width: 100%; }
.btn:disabled { opacity: .55; }
.lien { background: none; border: 0; color: var(--gris); text-decoration: underline; font-size: .85rem; padding: 0; }
.icone-btn { background: none; border: 0; width: 42px; height: 42px; display: grid; place-items: center; border-radius: 50%; padding: 0; }
.icone-btn svg { width: 24px; height: 24px; fill: currentColor; stroke: currentColor; }
.icone-btn.rond { background: var(--blanc); border: 1px solid var(--ligne); flex: none; }

/* Accueil */
#accueil { min-height: 100%; padding: calc(var(--haut) + 28px) 22px calc(var(--bas) + 28px);
  background: linear-gradient(180deg, #14213d 0, #1f3a6b 320px, var(--fond) 320px); max-width: 520px; margin: 0 auto; }
.accueil-haut { text-align: center; color: #fff; }
.accueil-haut .logo { width: 64px; height: 64px; border-radius: 16px; }
.accueil-haut h1 { margin: .4rem 0 .2rem; font-size: 1.8rem; letter-spacing: -.02em; }
.accroche { margin: 0 auto; max-width: 340px; opacity: .85; }
#avatar-accueil { width: 170px; height: 170px; margin: 18px auto -6px; }
.accueil-actions { background: var(--blanc); border-radius: 22px; padding: 22px; box-shadow: var(--ombre); }
.champ-code { display: block; margin-bottom: 12px; }
.champ-code span { display: block; font-size: .85rem; color: var(--gris); margin-bottom: 4px; }
.champ-code input { width: 100%; padding: .8rem; border: 1px solid var(--ligne); border-radius: 12px; font-size: 1.1rem; letter-spacing: .15em; text-transform: uppercase; }
.atouts { list-style: none; padding: 0; margin: 18px 0 8px; display: grid; gap: 8px; }
.atouts li { padding-left: 26px; position: relative; font-size: .95rem; }
.atouts li::before { content: ""; position: absolute; left: 4px; top: .45em; width: 12px; height: 7px; border-left: 3px solid var(--accent); border-bottom: 3px solid var(--accent); transform: rotate(-45deg); }

/* Application */
#app { height: 100%; display: flex; flex-direction: column; max-width: 720px; margin: 0 auto; background: var(--fond); }
.barre { display: flex; align-items: center; gap: 10px; padding: calc(var(--haut) + 8px) 12px 8px; background: var(--encre); color: #fff; }
.barre-titre { display: flex; align-items: center; gap: 8px; font-weight: 700; }
.barre-titre img { border-radius: 7px; }
.progression { flex: 1; display: flex; align-items: center; gap: 8px; font-size: .8rem; }
.progression-barre { flex: 1; height: 7px; background: rgba(255, 255, 255, .2); border-radius: 9px; overflow: hidden; }
#progression-remplie { height: 100%; width: 0; background: var(--accent); transition: width .6s ease; border-radius: 9px; }
#btn-voix { color: #fff; }
#btn-voix svg .ondes, #btn-voix svg .barre-muet { stroke: #fff; }
#btn-voix[aria-pressed="true"] .barre-muet { display: none; }
#btn-voix[aria-pressed="false"] .ondes { display: none; }
.bandeau-urgence { display: flex; align-items: center; justify-content: center; gap: 8px; background: #fff0f1; color: var(--danger);
  font-size: .85rem; padding: 6px; text-decoration: none; border-bottom: 1px solid #f5c6cc; }
.bandeau-urgence svg { width: 16px; height: 16px; fill: currentColor; }
main { flex: 1; min-height: 0; position: relative; }
.vue { display: none; height: 100%; overflow-y: auto; padding: 14px 14px 24px; -webkit-overflow-scrolling: touch; }
.vue.actif { display: block; }
#vue-assistant.actif { display: flex; flex-direction: column; padding: 0; overflow: hidden; }

/* Onglets */
.onglets { display: grid; grid-template-columns: repeat(4, 1fr); background: var(--blanc); border-top: 1px solid var(--ligne); padding-bottom: var(--bas); }
.onglets button { background: none; border: 0; padding: 8px 0 7px; font-size: .72rem; color: var(--gris); display: flex; flex-direction: column; align-items: center; gap: 2px; position: relative; }
.onglets svg { width: 23px; height: 23px; fill: currentColor; }
.onglets button.actif { color: var(--accent); font-weight: 600; }
.pastille { position: absolute; top: 4px; left: calc(50% + 6px); background: var(--accent); color: #fff; font-size: .65rem; border-radius: 9px; padding: 0 5px; min-width: 16px; }

/* Scene de l'assistant */
.scene { display: flex; align-items: center; gap: 12px; padding: 10px 14px; background: linear-gradient(180deg, #fff, #f3f5fa); border-bottom: 1px solid var(--ligne); }
#avatar { width: 92px; height: 92px; flex: none; transition: width .3s, height .3s; }
.scene.grand #avatar { width: 150px; height: 150px; }
.scene.grand { justify-content: center; flex-direction: column; gap: 2px; }
.nom-assistant { font-weight: 700; font-size: 1.05rem; }
#etat-assistant { display: block; font-weight: 400; font-size: .85rem; color: var(--gris); }

.alix { width: 100%; height: 100%; overflow: visible; }
.alix .halo { fill: none; stroke: var(--accent); stroke-width: 3; opacity: 0; transform-origin: 100px 100px; }
.alix.ecoute .halo { animation: halo 1.6s ease-out infinite; }
.alix.ecoute .halo2 { animation-delay: .8s; }
@keyframes halo { 0% { opacity: .7; transform: scale(.96); } 100% { opacity: 0; transform: scale(1.12); } }
.alix .tete { transform-origin: 100px 130px; transition: transform .5s; }
.alix.ecoute .tete { transform: rotate(-4deg); }
.alix.reflechit .tete { transform: rotate(3deg) translateY(-1px); }
.alix.parle .tete { animation: hoche 2.4s ease-in-out infinite; }
@keyframes hoche { 0%, 100% { transform: rotate(0); } 30% { transform: rotate(1.5deg); } 70% { transform: rotate(-1.5deg); } }
.alix.repos .corps, .alix.repos .tete { animation: respire 4s ease-in-out infinite; }
@keyframes respire { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(1.5px); } }
.alix .sourcils path { fill: none; stroke: #2a1c14; stroke-width: 3; stroke-linecap: round; transition: transform .4s; }
.alix.ecoute .sourcils path { transform: translateY(-2px); }
.alix .paupieres rect { transition: height .07s; }
.alix .iris { transition: transform .5s; }
.alix .levres-ouvertes, .alix .levres-fermees { transition: opacity .08s; }
.alix .bulle-reflexion { opacity: 0; transition: opacity .3s; }
.alix.reflechit .bulle-reflexion { opacity: 1; }
.alix .pt { fill: var(--accent); animation: point 1.2s infinite; }
.alix .pt:nth-child(3) { animation-delay: .2s; } .alix .pt:nth-child(4) { animation-delay: .4s; }
@keyframes point { 0%, 60%, 100% { opacity: .25; } 30% { opacity: 1; } }

/* Fil de discussion */
.fil { flex: 1; overflow-y: auto; padding: 14px 12px 8px; display: flex; flex-direction: column; gap: 10px; -webkit-overflow-scrolling: touch; }
.msg { max-width: 86%; padding: .65rem .85rem; border-radius: 18px; white-space: pre-wrap; word-wrap: break-word; animation: entre .25s ease-out; }
@keyframes entre { from { opacity: 0; transform: translateY(6px); } }
.msg.assistant { background: var(--blanc); border: 1px solid var(--ligne); border-bottom-left-radius: 6px; align-self: flex-start; }
.msg.user { background: var(--encre); color: #fff; border-bottom-right-radius: 6px; align-self: flex-end; }
.msg .heure { display: block; font-size: .68rem; opacity: .55; margin-top: 3px; }
.msg .vignettes { display: flex; gap: 6px; margin-bottom: 6px; flex-wrap: wrap; }
.msg .vignettes img { width: 64px; height: 64px; object-fit: cover; border-radius: 10px; }
.msg .relire { background: none; border: 0; padding: 0; margin-left: 6px; color: var(--accent); font-size: .78rem; text-decoration: underline; }
.maj-champs { align-self: flex-start; font-size: .78rem; color: var(--accent-f); background: #e3f6f2; border-radius: 10px; padding: 4px 10px; }
.demande-photo { align-self: flex-start; display: flex; align-items: center; gap: 8px; background: var(--blanc); border: 2px dashed var(--accent); color: var(--accent-f);
  border-radius: 14px; padding: .6rem .9rem; font-weight: 600; }
.demande-photo svg { width: 22px; height: 22px; fill: currentColor; }
.choix { display: flex; flex-wrap: wrap; gap: 8px; align-self: stretch; padding: 2px 0 4px; }
.choix-btn { background: var(--blanc); border: 2px solid var(--accent); color: var(--accent-f); border-radius: 22px; padding: 10px 16px;
  font-size: .98rem; font-weight: 600; text-align: left; line-height: 1.25; box-shadow: 0 2px 8px rgba(15, 157, 138, .15); }
.choix-btn:first-child { background: var(--accent); color: #fff; }
.choix-btn:active { transform: scale(.97); }
.ecrit { align-self: flex-start; color: var(--gris); font-size: .85rem; font-style: italic; }

/* Composeur */
.composeur { display: flex; align-items: flex-end; gap: 8px; padding: 8px 10px 10px; background: var(--blanc); border-top: 1px solid var(--ligne); }
#saisie { flex: 1; resize: none; border: 1px solid var(--ligne); border-radius: 22px; padding: .6rem .9rem; max-height: 140px; background: var(--fond); outline: none; min-height: 44px; }
#saisie:focus { border-color: var(--accent); background: #fff; }
.micro { flex: none; width: 56px; height: 56px; border-radius: 50%; border: 0; background: var(--accent); color: #fff; display: grid; place-items: center; box-shadow: 0 4px 14px rgba(15, 157, 138, .35); position: relative; }
.micro svg { width: 28px; height: 28px; fill: currentColor; }
.micro.ecoute { background: var(--danger); box-shadow: 0 0 0 0 rgba(192, 24, 43, .5); animation: pulse 1.3s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(192, 24, 43, .45); } 100% { box-shadow: 0 0 0 16px rgba(192, 24, 43, 0); } }
.micro:disabled { background: #a9b3c7; box-shadow: none; }

/* Formulaire */
.segments { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; background: #e6eaf3; padding: 4px; border-radius: 12px; margin-bottom: 12px; position: sticky; top: 0; z-index: 2; }
.segments button { border: 0; background: none; padding: .5rem .2rem; border-radius: 9px; font-size: .85rem; font-weight: 600; color: var(--encre-2); }
.segments button.actif { background: var(--blanc); box-shadow: 0 1px 4px rgba(0, 0, 0, .08); color: var(--encre); }
.segments .seg-A.actif { color: var(--A); } .segments .seg-B.actif { color: var(--B); }
.section { background: var(--blanc); border-radius: var(--rayon); padding: 12px 14px; margin-bottom: 12px; box-shadow: var(--ombre); }
.section.A { border-top: 4px solid var(--A); } .section.B { border-top: 4px solid var(--B); }
.section h3 { margin: 0 0 8px; font-size: .95rem; }
.champ { display: block; margin-bottom: 10px; }
.champ > span { display: block; font-size: .78rem; color: var(--gris); margin-bottom: 3px; }
.champ input, .champ textarea { width: 100%; padding: .6rem .7rem; border: 1px solid var(--ligne); border-radius: 10px; background: var(--fond); outline: none; }
.champ textarea { min-height: 84px; resize: vertical; }
.champ input:focus, .champ textarea:focus { border-color: var(--accent); background: #fff; }
.champ.flash input, .champ.flash textarea { animation: flash 2s ease-out; }
@keyframes flash { 0% { background: #c9f1e9; border-color: var(--accent); } 100% { background: var(--fond); } }
.ouinon { display: flex; gap: 6px; }
.ouinon button { flex: 1; border: 1px solid var(--ligne); background: var(--fond); border-radius: 10px; padding: .5rem; font-weight: 600; }
.ouinon button.choisi { background: var(--encre); color: #fff; border-color: var(--encre); }
.circ { display: flex; align-items: flex-start; gap: 10px; padding: 8px 4px; border-bottom: 1px solid var(--ligne); font-size: .92rem; }
.circ:last-child { border-bottom: 0; }
.circ input { width: 22px; height: 22px; flex: none; margin: 0; accent-color: var(--accent); }
.circ b { width: 20px; flex: none; color: var(--gris); }
.choc { display: flex; gap: 14px; align-items: center; }
.choc svg { width: 150px; height: 180px; flex: none; }
.choc .zone { fill: rgba(15, 157, 138, .08); stroke: rgba(15, 157, 138, .35); stroke-dasharray: 3 3; cursor: pointer; }
.choc .zone.choisie { fill: rgba(192, 24, 43, .25); stroke: var(--danger); stroke-dasharray: 0; }
.choc-legende { font-size: .9rem; }

/* Croquis */
.zone-croquis .outils { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.stylo { border: 2px solid var(--ligne); background: var(--blanc); border-radius: 10px; padding: .4rem .8rem; font-weight: 700; color: var(--c); }
.stylo.actif { border-color: var(--c); background: color-mix(in srgb, var(--c) 12%, white); }
.zone-croquis .btn-leger { padding: .4rem .7rem; font-size: .88rem; }
#croquis { width: 100%; aspect-ratio: 4 / 3; background: #fff; border-radius: 12px; border: 1px solid var(--ligne); touch-action: none; display: block; margin-bottom: 10px;
  background-image: linear-gradient(#eef1f7 1px, transparent 1px), linear-gradient(90deg, #eef1f7 1px, transparent 1px); background-size: 25px 25px; }

/* Photos */
.galerie { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; margin: 10px 0 14px; }
.photo { background: var(--blanc); border-radius: 14px; overflow: hidden; box-shadow: var(--ombre); position: relative; }
.photo img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; display: block; }
.photo .legende { padding: 6px 8px; font-size: .78rem; }
.photo .lue { color: var(--accent-f); font-size: .7rem; display: block; }
.photo .suppr { position: absolute; top: 6px; right: 6px; width: 30px; height: 30px; border-radius: 50%; border: 0; background: rgba(0, 0, 0, .55); color: #fff; font-size: 18px; line-height: 1; }
.vide-galerie { grid-column: 1 / -1; text-align: center; color: var(--gris); padding: 30px 10px; background: var(--blanc); border-radius: 14px; }

/* Signer */
.carte { background: var(--blanc); border-radius: var(--rayon); padding: 14px; margin-bottom: 12px; box-shadow: var(--ombre); }
.carte h3 { margin: 0 0 6px; font-size: 1rem; }
.pads { display: grid; gap: 14px; }
@media (min-width: 640px) { .pads { grid-template-columns: 1fr 1fr; } }
.pad { border-radius: 12px; padding: 10px; } .pad-A { background: var(--A-f); } .pad-B { background: var(--B-f); }
.pad-tete { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.pad canvas { width: 100%; aspect-ratio: 5 / 2; background: #fff; border-radius: 10px; touch-action: none; display: block; margin-bottom: 8px; border: 1px dashed #b9c3d8; }
.signe { text-align: center; font-weight: 700; color: var(--accent-f); padding: .5rem; }
.actions-pdf { display: flex; flex-wrap: wrap; gap: 8px; }
.actions-pdf .btn { flex: 1 1 140px; width: auto; }
.manque { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.manque span { background: #fff4e5; color: #8a5a00; border-radius: 8px; padding: 2px 8px; font-size: .78rem; }
.ok-tout { color: var(--accent-f); font-weight: 600; }

/* Feuille photo */
.feuille { position: fixed; inset: 0; z-index: 50; display: flex; align-items: flex-end; justify-content: center; }
.feuille-fond { position: absolute; inset: 0; background: rgba(20, 33, 61, .45); animation: fondu .2s; }
@keyframes fondu { from { opacity: 0; } }
.feuille-contenu { position: relative; background: var(--blanc); width: 100%; max-width: 560px; border-radius: 22px 22px 0 0; padding: 10px 16px calc(var(--bas) + 16px); animation: monte .25s ease-out; max-height: 88vh; overflow-y: auto; }
@keyframes monte { from { transform: translateY(100%); } }
.feuille-poignee { width: 42px; height: 5px; border-radius: 3px; background: var(--ligne); margin: 0 auto 10px; }
.feuille h3 { margin: 0 0 10px; }
.types-photo { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 12px; }
.types-photo button { border: 1px solid var(--ligne); background: var(--fond); border-radius: 12px; padding: .7rem .6rem; text-align: left; font-size: .88rem; font-weight: 600; }
.types-photo button.A { border-left: 5px solid var(--A); } .types-photo button.B { border-left: 5px solid var(--B); }
.types-photo button.suggere { border-color: var(--accent); background: #e3f6f2; }
.types-photo .galerie-choix { grid-column: 1 / -1; display: flex; align-items: center; gap: 8px; font-size: .88rem; color: var(--encre-2); }

.toast { position: fixed; left: 50%; bottom: calc(var(--bas) + 86px); transform: translate(-50%, 20px); background: var(--encre); color: #fff; padding: .6rem 1rem; border-radius: 12px;
  font-size: .9rem; opacity: 0; pointer-events: none; transition: all .25s; z-index: 60; max-width: 90vw; text-align: center; }
.toast.visible { opacity: 1; transform: translate(-50%, 0); }
@media (min-width: 760px) { body { background: #e6eaf3; } #app { box-shadow: 0 0 40px rgba(0, 0, 0, .08); } }
.scene.grand .scene-texte { text-align: center; }
