/* ── Thèmes : clair par défaut, sombre selon l'appareil ou le bouton ── */
:root {
  --fond: #f4ecda;
  --fond-chat: #faf5ea;
  --carte: #ffffff;
  --carte-2: #f7efdb;
  --texte: #2b2113;
  --doux: #7a6c50;
  --or: #9c6f0c;
  --or-clair: #e2c27a;
  --or-pale: #f3e6c4;
  --bleu: #3f78b0;
  --bord: #e6d7b4;
  --ombre: 0 1px 2px rgba(122, 85, 7, .05), 0 6px 18px rgba(122, 85, 7, .08);
  --verre: rgba(250, 245, 234, .82);
  color-scheme: light;
}
:root[data-theme="dark"] {
  --fond: #0f0d09; --fond-chat: #15120c; --carte: #1f1a12; --carte-2: #27211a; --texte: #f3e9d2;
  --doux: #ad9f80; --or: #e2c27a; --or-clair: #c9a24a; --or-pale: #2d2516; --bleu: #8fb7e0;
  --bord: #33291b; --ombre: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.35);
  --verre: rgba(21, 18, 12, .82); color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --fond: #0f0d09; --fond-chat: #15120c; --carte: #1f1a12; --carte-2: #27211a; --texte: #f3e9d2;
    --doux: #ad9f80; --or: #e2c27a; --or-clair: #c9a24a; --or-pale: #2d2516; --bleu: #8fb7e0;
    --bord: #33291b; --ombre: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.35);
    --verre: rgba(21, 18, 12, .82); color-scheme: dark;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  font-family: Inter, system-ui, sans-serif; color: var(--texte); background: var(--fond);
  -webkit-font-smoothing: antialiased; overflow: hidden;
  transition: background-color .35s ease, color .35s ease;
}
button, textarea { font: inherit; color: inherit; }
button { -webkit-user-select: none; user-select: none; }

/* ── Squelette : colonne (ordinateur) + conversation plein écran ── */
.app { height: 100dvh; display: grid; grid-template-columns: 1fr; }
.cote { display: none; }
.chat { display: flex; flex-direction: column; min-width: 0; height: 100dvh; background: var(--fond-chat); transition: background-color .35s ease; }

/* ── Barre du haut ── */
.barre {
  flex: none; display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: max(10px, env(safe-area-inset-top)) 14px 10px;
  background: var(--verre); backdrop-filter: saturate(1.4) blur(16px); -webkit-backdrop-filter: saturate(1.4) blur(16px);
  border-bottom: 1px solid var(--bord);
}
.barre-id { display: flex; align-items: center; gap: 10px; min-width: 0; }
.barre-id img { flex: none; }
.barre-id div { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.barre-id strong { font-size: 16px; }
.barre-id small { font-size: 12px; color: var(--doux); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.barre-actions { display: flex; align-items: center; gap: 8px; flex: none; }
.bouton-rond {
  width: 38px; height: 38px; border-radius: 50%; border: 1px solid var(--bord); background: var(--carte);
  display: grid; place-items: center; cursor: pointer; color: var(--or);
  transition: transform .2s ease, background-color .35s ease, border-color .35s ease;
}
.bouton-rond:active { transform: scale(.92); }
.bouton-rond svg { grid-area: 1 / 1; transition: opacity .3s ease, transform .4s cubic-bezier(.2, .8, .2, 1); }
.ic-soleil { opacity: 0; transform: rotate(-60deg) scale(.6); }
:root[data-theme="dark"] .ic-lune { opacity: 0; transform: rotate(60deg) scale(.6); }
:root[data-theme="dark"] .ic-soleil { opacity: 1; transform: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .ic-lune { opacity: 0; transform: rotate(60deg) scale(.6); }
  :root:not([data-theme="light"]) .ic-soleil { opacity: 1; transform: none; }
}

.bouton-or {
  display: inline-flex; align-items: center; justify-content: center; border: 0; cursor: pointer;
  background: linear-gradient(180deg, #ecce82, #b8892a); color: #2b1d05; font-weight: 700; font-size: 14px;
  padding: 10px 16px; border-radius: 999px; text-decoration: none; white-space: nowrap;
  box-shadow: 0 4px 14px rgba(156, 111, 12, .3), inset 0 1px 0 rgba(255, 255, 255, .45);
  transition: transform .18s ease, box-shadow .25s ease;
}
.bouton-or:hover { box-shadow: 0 6px 20px rgba(156, 111, 12, .4), inset 0 1px 0 rgba(255, 255, 255, .45); }
.bouton-or:active { transform: scale(.96); }
.bouton-or.petit { font-size: 13.5px; padding: 9px 14px; }
.bouton-or.compact { font-size: 13.5px; padding: 9px 13px; }
.bouton-ligne {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1.5px solid var(--bord); background: var(--carte); color: var(--texte); font-weight: 600; font-size: 14px;
  padding: 9px 16px; border-radius: 999px; text-decoration: none; transition: border-color .25s ease, transform .18s ease;
}
.bouton-ligne:hover { border-color: var(--or-clair); }
.bouton-ligne:active { transform: scale(.96); }

/* ── Zone qui défile : stories puis fil ── */
.fil-zone { flex: 1; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }

.stories {
  display: flex; gap: 12px; overflow-x: auto; scroll-snap-type: x proximity;
  padding: 12px 14px 10px; scrollbar-width: none; border-bottom: 1px solid var(--bord);
  background: var(--fond-chat);
}
.stories::-webkit-scrollbar { display: none; }
.story {
  flex: none; width: 66px; background: none; border: 0; padding: 0; cursor: pointer; scroll-snap-align: start; text-align: center;
  animation: monte .5s cubic-bezier(.2, .8, .2, 1) both; animation-delay: calc(80ms + var(--i) * 40ms);
}
.story-anneau {
  position: relative; display: block; width: 62px; height: 62px; margin: 0 auto; border-radius: 50%; padding: 3px;
  background: conic-gradient(from 210deg, #f3d995, #b8892a, #e2c27a, #8fb7e0, #f3d995);
  transition: transform .25s cubic-bezier(.2, .8, .2, 1);
}
.story.vue .story-anneau { background: var(--bord); }
.story:hover .story-anneau { transform: scale(1.05); }
.story:active .story-anneau { transform: scale(.95); }
.story-anneau img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; object-position: 50% 92%; border: 3px solid var(--fond-chat); display: block; background: var(--carte-2); }
.story-num {
  position: absolute; right: -3px; bottom: -3px; min-width: 21px; height: 21px; padding: 0 5px; border-radius: 11px;
  background: var(--or); color: var(--fond-chat); font-size: 11px; font-weight: 800; display: grid; place-items: center; border: 2px solid var(--fond-chat);
}
.story-nom { display: block; margin-top: 6px; font-size: 11px; line-height: 1.2; font-weight: 600; color: var(--texte); }

/* ── Fil de discussion ── */
.fil { display: flex; flex-direction: column; gap: 12px; padding: 16px 14px 20px; max-width: 760px; margin: 0 auto; }
.entre { animation: entre .38s cubic-bezier(.2, .8, .2, 1) both; }
@keyframes entre { from { opacity: 0; transform: translateY(10px) scale(.985); } }
@keyframes monte { from { opacity: 0; transform: translateY(12px); } }
.jour { align-self: center; font-size: 11.5px; color: var(--doux); letter-spacing: .06em; text-transform: uppercase; padding: 2px 0 4px; }
.msg-moi {
  align-self: flex-end; max-width: 84%;
  background: linear-gradient(180deg, #5a8fc4, #3f78b0); color: #fff;
  padding: 10px 14px; border-radius: 18px 18px 5px 18px; line-height: 1.45; font-size: 15.5px;
  white-space: pre-wrap; overflow-wrap: anywhere; box-shadow: 0 4px 14px rgba(63, 120, 176, .22);
}
.msg-celeste { display: flex; gap: 9px; align-items: flex-end; max-width: 100%; }
.msg-celeste > img { width: 30px; height: 28px; flex: none; margin-bottom: 4px; }
.msg-celeste.suite > img { visibility: hidden; }
.bulle {
  background: var(--carte); border: 1px solid var(--bord); border-radius: 18px 18px 18px 5px;
  padding: 11px 14px; line-height: 1.55; font-size: 15.5px; box-shadow: var(--ombre); min-width: 0; max-width: 86%;
  transition: background-color .35s ease, border-color .35s ease;
}
.bulle p { margin: 0 0 8px; }
.bulle p:last-child, .bulle ul:last-child, .bulle ol:last-child { margin-bottom: 0; }
.bulle ul, .bulle ol { margin: 0 0 8px; padding-left: 20px; }
.bulle li { margin: 4px 0; }
.bulle li::marker { color: var(--or); font-weight: 700; }
.bulle a { color: var(--bleu); overflow-wrap: anywhere; text-underline-offset: 2px; }
.bulle.erreur { border-color: #d99a86; }
.bulle.accueil { background: linear-gradient(180deg, var(--carte), var(--carte-2)); }
.source { margin-top: 10px; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 12.5px; color: var(--doux); }
.source span { background: var(--or-pale); color: var(--texte); border: 1px solid var(--bord); padding: 3px 9px; border-radius: 999px; }

/* Réponses rapides sous le message d'accueil */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.fil .chips { padding-left: 39px; margin-top: -2px; }
.chip {
  display: inline-flex; align-items: center; gap: 7px; cursor: pointer;
  background: var(--carte); border: 1.5px solid var(--or-clair); color: var(--texte); border-radius: 999px;
  padding: 8px 13px; font-size: 14px; font-weight: 600; line-height: 1.25; text-align: left;
  animation: monte .45s cubic-bezier(.2, .8, .2, 1) both; animation-delay: calc(300ms + var(--i) * 55ms);
  transition: transform .18s ease, background-color .25s ease, border-color .25s ease;
}
.chip:hover { background: var(--or-pale); }
.chip:active { transform: scale(.96); }
.chip i { font-style: normal; font-size: 16px; }

/* Étape du tuto citée dans une réponse */
.etape-rep {
  margin-top: 12px; display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; cursor: pointer;
  background: var(--carte-2); border: 1px solid var(--bord); border-radius: 14px; padding: 8px 12px 8px 8px;
  transition: transform .2s ease, border-color .25s ease;
}
.etape-rep:hover { border-color: var(--or-clair); }
.etape-rep:active { transform: scale(.98); }
.etape-rep img { width: 44px; height: 60px; border-radius: 9px; object-fit: cover; object-position: 50% 62%; flex: none; }
.etape-rep b { display: block; font-size: 11.5px; color: var(--or); letter-spacing: .08em; text-transform: uppercase; }
.etape-rep span { font-size: 14px; font-weight: 600; }
.etape-rep::after { content: "▶"; margin-left: auto; font-size: 11px; color: var(--or); width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--or-pale); flex: none; }

.points { display: inline-flex; gap: 5px; padding: 5px 2px; }
.points i { width: 7px; height: 7px; border-radius: 50%; background: var(--or-clair); animation: point 1.2s infinite ease-in-out; }
.points i:nth-child(2) { animation-delay: .15s; } .points i:nth-child(3) { animation-delay: .3s; }
@keyframes point { 0%, 60%, 100% { opacity: .35; transform: none; } 30% { opacity: 1; transform: translateY(-4px); } }

/* ── Saisie ── */
.saisie {
  flex: none; background: var(--verre); backdrop-filter: saturate(1.4) blur(16px); -webkit-backdrop-filter: saturate(1.4) blur(16px);
  border-top: 1px solid var(--bord); padding: 8px 12px max(10px, env(safe-area-inset-bottom));
}
#formulaire, .saisie-note { max-width: 760px; margin: 0 auto; }
#formulaire {
  display: flex; align-items: flex-end; gap: 6px;
  background: var(--carte); border: 1.5px solid var(--bord); border-radius: 24px; padding: 5px 5px 5px 6px;
  box-shadow: var(--ombre); transition: border-color .25s ease, box-shadow .25s ease, background-color .35s ease;
}
#formulaire:focus-within { border-color: var(--or-clair); box-shadow: var(--ombre), 0 0 0 4px rgba(226, 194, 122, .18); }
.bouton-idees { flex: none; width: 38px; height: 38px; border-radius: 50%; border: 0; background: var(--or-pale); color: var(--or); display: grid; place-items: center; cursor: pointer; transition: transform .2s ease; }
.bouton-idees:active { transform: scale(.9); }
textarea { flex: 1; border: 0; outline: 0; resize: none; background: transparent; font-size: 16px; line-height: 1.4; padding: 8px 4px; max-height: 140px; }
textarea::placeholder { color: var(--doux); opacity: .8; }
#envoyer {
  flex: none; width: 38px; height: 38px; border-radius: 50%; border: 0; cursor: pointer;
  background: linear-gradient(180deg, #ecce82, #b8892a); color: #2b1d05; display: grid; place-items: center;
  transition: transform .2s cubic-bezier(.2, .8, .2, 1), opacity .25s ease;
}
#envoyer:not(:disabled):active { transform: scale(.9); }
#envoyer:disabled { opacity: .35; cursor: default; transform: scale(.94); }
.saisie-note { display: flex; justify-content: space-between; align-items: center; gap: 10px; font-size: 12px; color: var(--doux); padding: 7px 6px 0; }
.lien-discret { background: none; border: 0; padding: 0; color: var(--or); font-weight: 600; cursor: pointer; font-size: 12px; }

/* ── Feuille d'idées (bas d'écran) ── */
.feuille { position: fixed; inset: 0; z-index: 40; display: flex; align-items: flex-end; justify-content: center; }
.feuille[hidden] { display: none; }
.feuille-fond { position: absolute; inset: 0; background: rgba(8, 6, 3, .45); animation: fondu .25s ease both; }
.feuille-cadre {
  position: relative; width: 100%; max-width: 560px; background: var(--fond-chat); border-radius: 22px 22px 0 0;
  padding: 10px 18px max(22px, env(safe-area-inset-bottom)); box-shadow: 0 -10px 40px rgba(0, 0, 0, .25);
  animation: glisse .35s cubic-bezier(.2, .8, .2, 1) both;
}
@keyframes glisse { from { transform: translateY(40px); opacity: 0; } }
@keyframes fondu { from { opacity: 0; } }
.feuille-poignee { width: 40px; height: 4px; border-radius: 2px; background: var(--bord); margin: 0 auto 14px; }
.feuille h2 { margin: 0 0 12px; font-size: 17px; }
.feuille .chip { animation-delay: calc(60ms + var(--i) * 40ms); }

/* ── Lecteur « stories » ── */
.lecteur { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; }
.lecteur[hidden] { display: none; }
.lecteur-fond { position: absolute; inset: 0; background: rgba(8, 6, 3, .84); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); animation: fondu .3s ease both; }
.lecteur-cadre {
  position: relative; width: min(100vw, calc((100dvh - 120px) * 9 / 16), 440px);
  display: flex; flex-direction: column; gap: 10px; padding: max(12px, env(safe-area-inset-top)) 12px max(12px, env(safe-area-inset-bottom));
  animation: zoom .35s cubic-bezier(.2, .8, .2, 1) both;
}
@keyframes zoom { from { opacity: 0; transform: scale(.94); } }
.progression { display: flex; gap: 4px; padding: 0 2px; }
.progression span { flex: 1; height: 3px; border-radius: 2px; background: rgba(255, 255, 255, .28); overflow: hidden; }
.progression span i { display: block; height: 100%; width: 0; background: #f3d995; }
.progression span.faite i { width: 100%; }
.progression span.active i { animation: avance var(--duree, 6s) linear forwards; }
.lecteur.pause .progression span.active i { animation-play-state: paused; }
@keyframes avance { to { width: 100%; } }
.lecteur-fermer { position: absolute; top: max(24px, calc(env(safe-area-inset-top) + 12px)); right: 18px; z-index: 3; width: 34px; height: 34px; border-radius: 50%; border: 0; background: rgba(0, 0, 0, .45); color: #fff; cursor: pointer; font-size: 15px; }
.lecteur-image { position: relative; border-radius: 18px; overflow: hidden; background: #000; aspect-ratio: 9 / 16; box-shadow: 0 20px 60px rgba(0, 0, 0, .5); }
.lecteur-image img { width: 100%; height: 100%; object-fit: cover; display: block; transition: opacity .25s ease; }
.lecteur-image img.change { opacity: 0; }
.zone { position: absolute; top: 0; bottom: 0; width: 38%; background: none; border: 0; cursor: pointer; }
.zone-prec { left: 0; } .zone-suiv { right: 0; width: 62%; }
.lecteur-bas { display: flex; align-items: center; justify-content: space-between; gap: 10px; color: #fff; font-weight: 600; font-size: 14px; padding: 0 2px; }

/* ── Ordinateur : colonne à gauche, conversation à droite ── */
@media (min-width: 860px) {
  .app { grid-template-columns: 330px minmax(0, 1fr); }
  .cote {
    display: flex; flex-direction: column; height: 100dvh; overflow-y: auto; border-right: 1px solid var(--bord);
    background: radial-gradient(120% 300px at 50% -40px, var(--or-pale), transparent 70%), var(--fond);
    animation: monte .6s cubic-bezier(.2, .8, .2, 1) both;
  }
  .cote-haut { padding: 34px 26px 22px; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 10px; }
  .halo-mascotte { position: relative; display: inline-block; }
  .halo-mascotte::before { content: ""; position: absolute; inset: 18% 10% 4%; border-radius: 50%; background: radial-gradient(closest-side, rgba(226, 194, 122, .5), transparent); filter: blur(8px); z-index: -1; animation: respire 5s ease-in-out infinite; }
  .mascotte { width: 150px; height: auto; display: block; animation: flotte 5s ease-in-out infinite; }
  @keyframes flotte { 50% { transform: translateY(-6px) rotate(-1.5deg); } }
  @keyframes respire { 50% { opacity: .55; transform: scale(.92); } }
  .cote h1 { margin: 4px 0 0; font-size: 30px; letter-spacing: -.02em; font-weight: 800; }
  .cote-haut p { margin: 0 0 8px; color: var(--doux); font-size: 14.5px; line-height: 1.5; }
  .cote-haut p em { font-family: "Playfair Display", serif; font-style: italic; font-weight: 700; color: var(--or); font-size: 16px; }
  .cote-haut .bouton-or, .cote-haut .bouton-ligne { width: 100%; }
  .cote-tuto { padding: 10px 18px 18px; }
  .cote h2 { font-size: 12px; letter-spacing: .14em; text-transform: uppercase; color: var(--or); margin: 10px 8px 10px; font-weight: 700; }
  .tuto-liste { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
  .tuto-liste button {
    display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; cursor: pointer;
    background: none; border: 1px solid transparent; border-radius: 14px; padding: 7px 8px;
    transition: background-color .2s ease, border-color .2s ease, transform .2s ease;
  }
  .tuto-liste button:hover { background: var(--carte); border-color: var(--bord); }
  .tuto-liste button:active { transform: scale(.98); }
  .tuto-liste img { width: 40px; height: 54px; border-radius: 9px; object-fit: cover; object-position: 50% 62%; flex: none; }
  .tuto-liste b { display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: var(--or); color: var(--fond); font-size: 12px; font-weight: 800; flex: none; }
  .tuto-liste span { font-size: 14px; font-weight: 600; }
  .tuto-liste .vue b { background: var(--bord); color: var(--doux); }
  .cote-bas { margin-top: auto; padding: 14px 26px 18px; font-size: 12px; color: var(--doux); text-align: center; }

  .stories { display: none; }
  #inscription-haut { display: none; }
  .barre { padding-top: 12px; }
  .fil { padding: 24px 28px 28px; }
  .bulle { max-width: 78%; }
  .msg-moi { max-width: 70%; }
  .feuille-cadre { border-radius: 22px; margin-bottom: 24px; }
}

@media (max-width: 859px) {
  .cote-haut, .cote-tuto, .cote-bas { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-delay: 0ms !important; transition-duration: .01ms !important; }
}
