/* =============================================================================
   AURYVO Business — Sophystia, fenêtre de conversation.
   Nouvelle identité (01/12) : grand panneau blanc très arrondi posé sur la toile, ombre large, sans filet ; vos messages en
   bulle bleue, ses propositions en cartes blanches, saisie en pilule, envoi en rond noir. Feuille à tirer sur téléphone.
   ============================================================================= */
.sp { --sp-r: 28px; position: fixed; top: 14px; right: 14px; bottom: 14px; width: min(440px, calc(100vw - 28px)); z-index: 70;
  display: flex; flex-direction: column; overflow: hidden; border-radius: var(--sp-r);
  background: color-mix(in srgb, var(--card) 96%, transparent); -webkit-backdrop-filter: blur(28px) saturate(1.6); backdrop-filter: blur(28px) saturate(1.6);
  box-shadow: var(--sh-float);
  opacity: 0; transform: translateX(22px) scale(.985); transform-origin: right center;
  transition: transform .5s var(--spring, cubic-bezier(.34, 1.36, .5, 1)), opacity .25s; }
.sp.on { opacity: 1; transform: none; }
.sp.sortie { opacity: 0; transform: translateX(22px) scale(.985); transition-duration: .22s; }
.sp.depot { box-shadow: var(--sh-float), 0 0 0 2px var(--accent); }
.sp-poignee { display: none; }

/* ---------- en-tête ---------- */
.sp-tete { position: relative; display: flex; align-items: center; gap: 12px; padding: 16px 14px 14px 18px; }
.sp-tete::after { content: ""; position: absolute; left: 18px; right: 18px; bottom: 0; height: 1px; background: var(--line); }
.sp-portrait { position: relative; width: 46px; height: 46px; flex-shrink: 0; }
.sp-portrait img { width: 100%; height: 100%; border-radius: 50%; display: block; box-shadow: 0 0 0 2px var(--card), 0 0 0 3.5px color-mix(in srgb, var(--accent) 45%, transparent); }
.sp-portrait::before { content: ""; position: absolute; inset: -5px; border-radius: 50%; opacity: 0;
  background: conic-gradient(from 0deg, transparent 0 40%, var(--accent) 70%, transparent 100%);
  -webkit-mask: radial-gradient(closest-side, transparent 86%, #000 88%); mask: radial-gradient(closest-side, transparent 86%, #000 88%); transition: opacity .3s; }
.sp.pense .sp-portrait::before { opacity: .9; animation: sp-tourne 1.1s linear infinite; }
.sp-etat { position: absolute; right: 0; bottom: 1px; width: 12px; height: 12px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 2.5px var(--card); }
.sp-qui { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.sp-qui b { font: 700 18px/1.1 var(--display); letter-spacing: -.02em; }
.sp-qui small { display: flex; align-items: center; flex-wrap: wrap; gap: 0 6px; min-width: 0; font-size: 12.5px; color: var(--ink-3); }
.sp-ou { overflow-wrap: anywhere; }
.sp-ou:not(:empty)::before { content: "·"; margin-right: 6px; }
.sp-btn { width: 36px; height: 36px; border-radius: 50%; border: 0; background: var(--card-3); color: var(--ink-2); display: grid; place-items: center; cursor: pointer;
  transition: background .2s, color .2s, transform .35s var(--spring, ease); }
.sp-btn:hover { background: var(--line-2); color: var(--ink); }
.sp-btn:active { transform: scale(.9); }

/* ---------- fil ---------- */
.sp-fil { flex: 1; overflow-y: auto; padding: 20px 18px 12px; display: flex; flex-direction: column; gap: 18px; overscroll-behavior: contain; scroll-behavior: smooth;
  -webkit-mask: linear-gradient(transparent, #000 14px, #000 calc(100% - 10px), transparent); mask: linear-gradient(transparent, #000 14px, #000 calc(100% - 10px), transparent); }
.sp-msg { display: flex; flex-direction: column; gap: 6px; animation: sp-arrive .5s var(--spring, cubic-bezier(.34, 1.36, .5, 1)) both; }
.sp-msg.ancien { animation: none; }
.sp-msg.moi { align-items: flex-end; }
.sp-msg.moi .sp-corps { max-width: 86%; padding: 11px 16px; border-radius: 22px 22px 6px 22px; background: var(--black); color: var(--on-black);
  font-size: 14.5px; line-height: 1.45; box-shadow: 0 10px 24px -16px rgba(0, 113, 227, .6); overflow-wrap: anywhere; }
.sp-sig { display: flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 700; color: var(--ink-2); }
.sp-sig img { width: 22px; height: 22px; border-radius: 50%; }
.sp-heure { font-size: 11px; font-weight: 500; color: var(--ink-3); }
.sp-msg.moi .sp-heure { margin-right: 6px; }
.sp-msg.soph .sp-corps { min-width: 0; font-size: 14.5px; line-height: 1.6; color: var(--ink); padding-left: 30px; }
.sp-texte p { margin: 0 0 8px; }
.sp-texte p:last-child { margin-bottom: 0; }
.sp-texte ul, .sp-texte ol { margin: 6px 0 8px; padding-left: 20px; }
.sp-extrait { margin: 10px 0; padding: 10px 14px; border-radius: 16px; background: var(--card-2); color: var(--ink-2); font-size: 13px; line-height: 1.5; }
.sp-extrait b { color: var(--ink); }
.sp-donnees { margin: 12px 0 4px; border-radius: 18px; overflow: hidden; background: var(--card-2); }
.sp-ligne { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 11px 14px; color: var(--ink); text-decoration: none; font-size: 13.5px;
  box-shadow: inset 0 -1px 0 var(--line); transition: background .2s; }
a.sp-ligne:hover { background: var(--card-3); }
.sp-ligne:last-child { box-shadow: none; }
.sp-ligne > span:first-child { min-width: 0; }
.sp-ligne b { font-weight: 600; }
.sp-ligne small { display: block; color: var(--ink-3); font-size: 12px; }
.sp-ligne .num { font-weight: 700; white-space: nowrap; }
.sp-ligne.total { font-weight: 700; background: var(--black); color: var(--on-black); box-shadow: none; }

/* cartes d'action : ce que Sophystia propose de faire */
.sp-carte { position: relative; margin: 12px 0 4px; padding: 16px 16px 14px; border-radius: var(--r-lg, 22px); background: var(--card); box-shadow: 0 0 0 1px var(--line), var(--sh-card); }
.sp-carte::before { content: "Proposition"; display: block; margin-bottom: 6px; font-size: 10.5px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); }
.sp-carte-t { font-weight: 700; font-size: 15px; letter-spacing: -.01em; display: flex; align-items: center; gap: 8px; }
.sp-carte-x { font-size: 13px; color: var(--ink-2); margin-top: 4px; line-height: 1.5; }
.sp-carte-a { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 14px; }
.sp-carte-a .btn { border-radius: var(--pill); }
.sp-carte-a .btn-primary { padding-left: 16px; padding-right: 18px; }
.sp-carte.ok { box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent) 35%, transparent); background: color-mix(in srgb, var(--accent) 5%, var(--card)); }
.sp-carte.ok::before { content: "Fait"; color: var(--accent); }
.sp-carte.ok .sp-carte-t svg { color: var(--accent); }
.sp-carte.off { opacity: .55; box-shadow: 0 0 0 1px var(--line); }
.sp-carte.off::before { content: "Mise de côté"; }
.sp-sources { display: flex; gap: 8px; align-items: flex-start; margin-top: 12px; font-size: 12px; color: var(--ink-3); }
.sp-sources a { color: var(--accent); text-decoration: none; }
.sp-sources a:hover { text-decoration: underline; text-underline-offset: 2px; }
.sp-liens, .sp-suite { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.sp-lien { display: inline-flex; align-items: center; height: 32px; padding: 0 14px; border-radius: var(--pill); background: var(--card); color: var(--ink); box-shadow: inset 0 0 0 1px var(--line-2);
  font-size: 13px; font-weight: 600; text-decoration: none; transition: background .2s, transform .3s var(--spring, ease); }
.sp-lien:hover { background: var(--card-2); }
.sp-lien:active { transform: scale(.96); }

/* « Je m'en souviendrai » : ce qu'elle vient de retenir, avec « Oublier » à portée de main (nouvelle identité : accent bleu) */
.sp { --sp-accent: var(--accent); }
a.sp-btn { text-decoration: none; }
.sp-retenu { display: flex; align-items: center; gap: 10px; margin-top: 12px; padding: 8px 8px 8px 12px; border-radius: 16px;
  background: color-mix(in srgb, var(--sp-accent) 8%, var(--card)); color: var(--ink-2); font-size: 12.5px; line-height: 1.4;
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--sp-accent) 22%, transparent); }
.sp-retenu > svg { flex-shrink: 0; color: var(--sp-accent); }
.sp-retenu > span { flex: 1; min-width: 0; overflow-wrap: anywhere; color: var(--ink); }
.sp-retenu small { display: block; font-size: 11px; font-weight: 700; letter-spacing: .02em; color: var(--sp-accent); }
.sp-retenu.oublie > span { color: var(--ink-3); }
.sp-retenu.oublie small { color: var(--ink-3); }
.sp-retenu.oublie { background: var(--card-2); box-shadow: none; color: var(--ink-3); }
.sp-retenu.oublie > svg { color: var(--ink-3); }
.sp-oublier { flex-shrink: 0; height: 28px; padding: 0 12px; border: 0; border-radius: var(--pill); background: var(--card); color: var(--ink);
  font: 600 12px var(--text, inherit); cursor: pointer; box-shadow: 0 0 0 1px var(--line-2); transition: background .2s, transform .3s var(--spring, ease); }
.sp-oublier:hover { background: var(--card-2); }
.sp-oublier:active { transform: scale(.95); }

/* Sophystia réfléchit */
.sp-reflechit { display: inline-flex; align-items: center; gap: 10px; padding: 10px 14px; border-radius: 18px; background: var(--card-2); color: var(--ink-2); font-size: 13px; }
.sp-points { display: inline-flex; gap: 4px; }
.sp-points i { width: 6px; height: 6px; border-radius: 50%; background: var(--ink-2); animation: sp-point 1.2s infinite ease-in-out; }
.sp-points i:nth-child(2) { animation-delay: .15s; } .sp-points i:nth-child(3) { animation-delay: .3s; }

/* ---------- accueil (conversation vide) ---------- */
.sp-accueil { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 18px 6px 4px; animation: sp-arrive .6s var(--spring, ease) both; }
.sp-accueil-portrait { position: relative; width: 84px; height: 84px; margin-bottom: 14px; }
.sp-accueil-portrait img { width: 100%; height: 100%; border-radius: 50%; display: block; box-shadow: 0 18px 40px -18px rgba(11, 95, 214, .55); }
.sp-accueil-portrait::after { content: ""; position: absolute; inset: -7px; border-radius: 50%; box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent) 35%, transparent); animation: sp-souffle 3.2s ease-in-out infinite; }
.sp-accueil h2 { margin: 0; font: 700 26px/1.1 var(--display); letter-spacing: -.03em; }
.sp-accueil p { margin: 8px 0 0; max-width: 320px; font-size: 14px; line-height: 1.55; color: var(--ink-2); }
.sp-idees { width: 100%; display: flex; flex-direction: column; gap: 8px; margin-top: 22px; text-align: left; }
.sp-idees:empty { display: none; }
.sp-idees-t { font-size: 12px; font-weight: 600; letter-spacing: 0; text-transform: none; color: var(--ink-3); margin: 0 4px 2px; }
.sp-idee { display: flex; align-items: center; gap: 12px; width: 100%; padding: 13px 14px 13px 18px; border: 0; border-radius: var(--pill); background: var(--card-2); color: var(--ink);
  font: 600 14px/1.35 var(--text); text-align: left; cursor: pointer; transition: background .2s, transform .35s var(--spring, ease);
  animation: sp-arrive .55s var(--spring, ease) both; }
.sp-idee:nth-child(2) { animation-delay: .05s; } .sp-idee:nth-child(3) { animation-delay: .1s; } .sp-idee:nth-child(4) { animation-delay: .15s; }
.sp-idee:hover { background: var(--card-3); }
.sp-idee:active { transform: scale(.975); }
.sp-idee span { flex: 1; }
.sp-idee::after { content: ""; width: 7px; height: 7px; border-right: 1.8px solid var(--ink-3); border-top: 1.8px solid var(--ink-3); transform: rotate(45deg); margin-right: 4px; flex-shrink: 0; }

/* ---------- suggestions et saisie ---------- */
.sp-sugg { display: flex; gap: 8px; padding: 4px 18px 12px; overflow-x: auto; scrollbar-width: none; }
.sp-sugg::-webkit-scrollbar { display: none; }
.sp-sugg:empty { display: none; }
.sp-chip { flex-shrink: 0; border: 0; background: var(--card); color: var(--ink); box-shadow: inset 0 0 0 1px var(--line-2); border-radius: var(--pill); padding: 8px 14px; font: 600 12.5px var(--text, inherit);
  cursor: pointer; white-space: nowrap; transition: background .2s, transform .3s var(--spring, ease); }
.sp-suite .sp-chip { white-space: normal; text-align: left; }
.sp-chip:hover { background: var(--card-2); }
.sp-chip:active { transform: scale(.95); }
.sp-saisie { display: flex; align-items: flex-end; gap: 6px; margin: 0 14px; padding: 6px; border-radius: 26px; background: var(--card);
  box-shadow: 0 0 0 1px var(--line-2), var(--sh-card); transition: box-shadow .25s; }
.sp-saisie:focus-within { box-shadow: 0 0 0 1.5px var(--accent), 0 0 0 5px var(--accent-soft), var(--sh-card); }
.sp-saisie textarea { flex: 1; border: 0; outline: none; resize: none; background: none; font: 15px/1.45 var(--text, inherit); color: var(--ink); padding: 9px 6px; max-height: 150px; }
.sp-saisie textarea::placeholder { color: var(--ink-3); }
.sp-joindre, .sp-envoi { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; cursor: pointer; flex-shrink: 0; border: 0;
  transition: background .2s, color .2s, transform .4s var(--spring, ease), opacity .2s; }
.sp-joindre { color: var(--ink-2); background: var(--card-3); }
.sp-joindre:hover { background: var(--line-2); color: var(--ink); }
.sp-envoi { background: var(--black); color: var(--on-black); }
.sp-envoi:active { transform: scale(.88); }
.sp-saisie.vide .sp-envoi { background: var(--card-3); color: var(--ink-3); transform: scale(.92); }
.sp-pied { text-align: center; font-size: 11px; color: var(--ink-3); padding: 9px 14px 14px; letter-spacing: .01em; }

@keyframes sp-arrive { from { opacity: 0; transform: translateY(12px) scale(.985); } }
@keyframes sp-tourne { to { transform: rotate(360deg); } }
@keyframes sp-point { 0%, 80%, 100% { opacity: .3; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }
@keyframes sp-souffle { 50% { transform: scale(1.06); opacity: .5; } }

/* ---------- téléphone : feuille qu'on tire vers le bas pour fermer ---------- */
@media (max-width: 820px) {
  .sp { --sp-r: 30px; top: auto; left: 0; right: 0; bottom: 0; width: auto; height: calc(100% - env(safe-area-inset-top) - 12px);
    border-radius: var(--sp-r) var(--sp-r) 0 0; padding-bottom: env(safe-area-inset-bottom); z-index: 120;
    transform: translateY(100%); opacity: 1; transform-origin: bottom center; transition: transform .55s var(--ressort-doux, cubic-bezier(.32, .72, 0, 1)); }
  .sp.on { transform: none; }
  .sp.sortie { transform: translateY(100%); opacity: 1; transition-duration: .35s; }
  .sp.tire { transition: none; }
  .sp-poignee { display: block; position: absolute; top: 7px; left: 50%; width: 38px; height: 5px; margin-left: -19px; border-radius: 3px; background: var(--line-2); z-index: 2; }
  .sp-tete { padding-top: 22px; touch-action: none; }
  .sp-saisie textarea { font-size: 16px; }
  .sp-msg.soph .sp-corps { padding-left: 0; }
  html.sp-ouvert body { overflow: hidden; }
}
@media (prefers-reduced-motion: reduce) {
  .sp, .sp-msg, .sp-idee, .sp-accueil { animation: none !important; transition-duration: .01s !important; }
  .sp-accueil-portrait::after, .sp.pense .sp-portrait::before { animation: none; }
}
/* téléphone : « Disponible » puis la page en cours sur sa propre ligne (pas de point orphelin en début de ligne) */
@media (max-width: 820px) {
  .sp-qui small { flex-direction: column; align-items: flex-start; gap: 1px; }
  .sp-ou:not(:empty)::before { content: none; }
}
