.maestra-chat{--mc-accent:#7c55e8;--mc-accent-strong:#6840dc;--mc-accent-soft:#f0eaff;--mc-panel:#fff;--mc-text:#1e2430;--mc-muted:#72798a;--mc-border:#e8e4f3;--mc-user:#7c55e8;--mc-user-text:#fff;--mc-assistant:#f3efff;--mc-assistant-text:#3c315e;position:fixed;right:24px;bottom:24px;z-index:1600;font-family:Inter,ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif;color:var(--mc-text)}
.maestra-chat *, .maestra-chat *::before, .maestra-chat *::after{box-sizing:border-box}
.maestra-chat-toggle{width:58px;height:58px;border:0;border-radius:50%;display:grid;place-items:center;background:linear-gradient(145deg,#7d52ec,#6434e6);color:#fff;font-size:1.25rem;font-weight:850;letter-spacing:.02em;box-shadow:0 16px 36px rgba(79,49,173,.34);cursor:pointer;transition:transform .18s ease,box-shadow .18s ease}
.maestra-chat-toggle:hover,.maestra-chat-toggle:focus-visible{transform:translateY(-2px);box-shadow:0 20px 42px rgba(79,49,173,.4);outline:0}
.maestra-chat.is-open .maestra-chat-toggle{transform:scale(.94)}
.maestra-chat-panel{position:absolute;right:0;bottom:72px;width:min(390px,calc(100vw - 32px));height:min(560px,calc(100vh - 118px));overflow:hidden;background:var(--mc-panel);border:1px solid var(--mc-border);border-radius:22px;box-shadow:0 28px 70px rgba(29,22,58,.24);display:grid;grid-template-rows:auto 1fr auto;transform-origin:bottom right;animation:maestra-panel-in .18s ease-out}
.maestra-chat-panel[hidden]{display:none}
@keyframes maestra-panel-in{from{opacity:0;transform:translateY(10px) scale(.98)}to{opacity:1;transform:none}}
.maestra-chat-head{display:flex;align-items:flex-start;gap:12px;padding:16px 16px 14px;border-bottom:1px solid var(--mc-border);background:linear-gradient(180deg,#fff,#fcfbff)}
.maestra-chat-head-copy{min-width:0;flex:1}.maestra-chat-head strong{display:block;font-size:.98rem;line-height:1.25;color:var(--mc-text)}
.maestra-chat-status{display:flex;align-items:center;gap:7px;margin-top:5px;color:var(--mc-muted);font-size:.73rem}.maestra-chat-status-dot{width:7px;height:7px;border-radius:50%;background:#9aa0ad;box-shadow:0 0 0 3px rgba(154,160,173,.12)}
.maestra-chat[data-status="online"] .maestra-chat-status-dot{background:#36c982;box-shadow:0 0 0 3px rgba(54,201,130,.12)}
.maestra-chat[data-status="setup"] .maestra-chat-status-dot{background:#e6a83d;box-shadow:0 0 0 3px rgba(230,168,61,.14)}
.maestra-chat-head-actions{display:flex;gap:5px}.maestra-chat-icon-button{width:32px;height:32px;border:1px solid transparent;border-radius:10px;background:transparent;color:#6e7483;font:inherit;font-size:1rem;cursor:pointer}.maestra-chat-icon-button:hover,.maestra-chat-icon-button:focus-visible{background:#f5f3fa;color:#302a40;outline:0}
.maestra-chat-messages{min-height:0;overflow-y:auto;padding:16px 14px 18px;scrollbar-width:thin;overscroll-behavior:contain;background:#fff}
.maestra-chat-message{display:flex;margin:0 0 10px}.maestra-chat-message.is-user{justify-content:flex-end}.maestra-chat-bubble{max-width:84%;padding:10px 12px;border-radius:16px;font-size:.88rem;line-height:1.48;white-space:pre-wrap;overflow-wrap:anywhere}
.maestra-chat-message.is-assistant .maestra-chat-bubble{background:var(--mc-assistant);color:var(--mc-assistant-text);border-bottom-left-radius:6px}.maestra-chat-message.is-user .maestra-chat-bubble{background:var(--mc-user);color:var(--mc-user-text);border-bottom-right-radius:6px}
.maestra-chat-message.is-pending .maestra-chat-bubble{color:#82769f;font-size:.8rem}
.maestra-chat-form{display:grid;grid-template-columns:1fr auto;align-items:end;gap:8px;padding:12px;border-top:1px solid var(--mc-border);background:#fff}.maestra-chat-input{display:block;width:100%;min-height:42px;max-height:120px;resize:none;border:1px solid #dfe2ea;border-radius:13px;padding:10px 12px;background:#fafbfc;color:#222936;font:inherit;font-size:.86rem;line-height:1.4;outline:0}.maestra-chat-input:focus{border-color:#a993ef;box-shadow:0 0 0 3px rgba(124,85,232,.11);background:#fff}.maestra-chat-input:disabled{opacity:.66}
.maestra-chat-send{min-height:42px;border:0;border-radius:12px;padding:0 15px;background:linear-gradient(145deg,#8a6aeb,#7551e3);color:#fff;font:inherit;font-size:.82rem;font-weight:760;cursor:pointer;box-shadow:0 8px 18px rgba(100,64,220,.18)}.maestra-chat-send:hover,.maestra-chat-send:focus-visible{background:linear-gradient(145deg,#805fe8,#6941db);outline:0}.maestra-chat-send:disabled{cursor:wait;opacity:.6}
html[data-theme="dark"] .maestra-chat{--mc-panel:#211b2b;--mc-text:#f7f5fc;--mc-muted:#b8b0c7;--mc-border:#3b3348;--mc-assistant:#302642;--mc-assistant-text:#eee9f8}
html[data-theme="dark"] .maestra-chat-head{background:linear-gradient(180deg,#211b2b,#1d1727)}html[data-theme="dark"] .maestra-chat-messages,html[data-theme="dark"] .maestra-chat-form{background:#211b2b}html[data-theme="dark"] .maestra-chat-icon-button{color:#c8c0d6}html[data-theme="dark"] .maestra-chat-icon-button:hover,html[data-theme="dark"] .maestra-chat-icon-button:focus-visible{background:#30283d;color:#fff}html[data-theme="dark"] .maestra-chat-input{background:#18141f;border-color:#40374e;color:#f7f5fc}html[data-theme="dark"] .maestra-chat-input:focus{background:#18141f;border-color:#8e7be8}
@media(max-width:620px){.maestra-chat{right:14px;bottom:14px}.maestra-chat-toggle{width:54px;height:54px}.maestra-chat-panel{position:fixed;left:10px;right:10px;bottom:78px;width:auto;height:min(610px,calc(100vh - 104px));border-radius:20px}.maestra-chat-bubble{max-width:90%}}
@media(prefers-reduced-motion:reduce){.maestra-chat-panel,.maestra-chat-toggle,.maestra-chat-message.is-pending .maestra-chat-bubble{animation:none;transition:none}}
.maestra-chat-message.is-assistant .maestra-chat-bubble{white-space:normal}
.maestra-chat-bubble p{margin:0 0 .62rem}.maestra-chat-bubble p:last-child{margin-bottom:0}
.maestra-chat-bubble h4{margin:.15rem 0 .5rem;font-size:.9rem;line-height:1.35;color:inherit}
.maestra-chat-bubble ul{margin:.35rem 0 .65rem;padding-left:1.15rem}.maestra-chat-bubble li{margin:.22rem 0}
.maestra-chat-bubble a:not(.maestra-chat-action){color:inherit;text-decoration:underline;text-underline-offset:2px}
.maestra-chat-action{display:inline-flex;align-items:center;justify-content:center;margin:.35rem .35rem .1rem 0;padding:.55rem .75rem;border-radius:10px;background:#fff;color:#6044bd!important;border:1px solid #d9cff7;text-decoration:none!important;font-weight:760;font-size:.8rem}
.maestra-chat-action:hover,.maestra-chat-action:focus-visible{background:#f9f7ff;outline:0;border-color:#bba9ef}
.maestra-chat-bubble hr{border:0;border-top:1px solid rgba(91,71,139,.18);margin:.65rem 0}
html[data-theme="dark"] .maestra-chat-action{background:#241d31;border-color:#544568;color:#d7c8ff!important}

/* V2.1 — languette flottante : séparée du bouton Retour en haut. */
.maestra-chat{
  right:0;
  bottom:118px;
}
.maestra-chat-toggle{
  width:auto;
  min-width:132px;
  height:48px;
  padding:0 16px 0 9px;
  border-radius:16px 0 0 16px;
  display:flex;
  align-items:center;
  justify-content:flex-start;
  gap:9px;
  font-size:.86rem;
  letter-spacing:0;
  box-shadow:0 12px 30px rgba(79,49,173,.28);
}
.maestra-chat-toggle-mark{
  width:30px;
  height:30px;
  flex:0 0 30px;
  display:grid;
  place-items:center;
  border-radius:10px;
  background:rgba(255,255,255,.17);
  color:#fff;
  font-size:.9rem;
  font-weight:900;
}
.maestra-chat-toggle-label{
  display:block;
  max-width:150px;
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
  color:#fff;
  font-weight:800;
}
.maestra-chat-toggle:hover,.maestra-chat-toggle:focus-visible{
  transform:translateX(-3px);
}
.maestra-chat.is-open .maestra-chat-toggle{
  transform:translateX(-3px);
}
.maestra-chat-panel{
  right:18px;
  bottom:62px;
  transform-origin:bottom right;
}

@media(max-width:620px){
  .maestra-chat{
    right:0;
    bottom:82px;
  }
  .maestra-chat-toggle{
    min-width:118px;
    height:46px;
    padding:0 13px 0 8px;
    border-radius:15px 0 0 15px;
  }
  .maestra-chat-toggle-mark{
    width:29px;
    height:29px;
    flex-basis:29px;
  }
  .maestra-chat-toggle-label{
    max-width:116px;
  }
  .maestra-chat-panel{
    position:fixed;
    left:10px;
    right:10px;
    bottom:140px;
    width:auto;
    height:min(560px,calc(100vh - 160px));
    border-radius:20px;
  }
}

/* Information fixe sur la nature de Maestra */
.maestra-chat-disclosure{
  margin:0;
  padding:7px 14px 5px;
  border-top:1px solid var(--mc-border);
  background:#fff;
  color:var(--mc-muted);
  font-size:.66rem;
  line-height:1.35;
  text-align:center;
}

html[data-theme="dark"] .maestra-chat-disclosure{
  background:#211b2b;
  color:#b8b0c7;
}

/* V2.2 — identité de Maestra sur chaque réponse + indicateur d'écriture fluide. */
.maestra-chat-message.is-assistant{
  flex-direction:column;
  align-items:flex-start;
}
.maestra-chat-speaker{
  margin:0 0 4px 5px;
  color:#75699a;
  font-size:.68rem;
  font-weight:800;
  letter-spacing:.01em;
}
.maestra-chat-message.is-pending{margin-bottom:12px}
.maestra-chat-typing{
  min-width:52px;
  min-height:34px;
  display:flex;
  align-items:center;
  justify-content:center;
  gap:5px;
  padding:9px 13px;
}
.maestra-chat-typing-dot{
  width:6px;
  height:6px;
  border-radius:50%;
  background:#8d78ca;
  opacity:.38;
  transform:translateY(0);
  animation:maestra-typing-dot 1.05s ease-in-out infinite;
}
.maestra-chat-typing-dot:nth-child(2){animation-delay:.14s}
.maestra-chat-typing-dot:nth-child(3){animation-delay:.28s}
@keyframes maestra-typing-dot{
  0%,60%,100%{opacity:.34;transform:translateY(0)}
  30%{opacity:1;transform:translateY(-4px)}
}
html[data-theme="dark"] .maestra-chat-speaker{color:#b9acd9}
html[data-theme="dark"] .maestra-chat-typing-dot{background:#c1afea}
@media(prefers-reduced-motion:reduce){
  .maestra-chat-typing-dot{animation:none;opacity:.72}
}


/* V2.3 — identification visiteur + indicateur d’écriture réellement perceptible. */
.maestra-chat-message.is-user{
  flex-direction:column;
  align-items:flex-end;
}
.maestra-chat-message.is-user .maestra-chat-speaker{
  margin:0 5px 4px 0;
  color:#7267a0;
}
.maestra-chat-message.is-pending .maestra-chat-bubble{
  background:#eee8ff;
  color:#6d5ca6;
}
.maestra-chat-typing-dot{
  width:7px;
  height:7px;
  background:#6f52c8;
  box-shadow:0 0 0 1px rgba(111,82,200,.08);
}
html[data-theme="dark"] .maestra-chat-message.is-user .maestra-chat-speaker{color:#b9acd9}
html[data-theme="dark"] .maestra-chat-message.is-pending .maestra-chat-bubble{background:#372b4c}


/* V2.6 — respiration douce de la languette Maestra */
.maestra-chat:not(.is-open) .maestra-chat-toggle{
  animation:maestra-launcher-breathe 3.2s ease-in-out infinite;
  transform-origin:right center;
  will-change:transform,box-shadow;
}
.maestra-chat:not(.is-open) .maestra-chat-toggle-mark{
  animation:maestra-mark-breathe 3.2s ease-in-out infinite;
}
.maestra-chat-toggle:hover,
.maestra-chat-toggle:focus-visible{
  animation:none;
  transform:translateX(-3px);
}
.maestra-chat-toggle:hover .maestra-chat-toggle-mark,
.maestra-chat-toggle:focus-visible .maestra-chat-toggle-mark{
  animation:none;
}
.maestra-chat.is-open .maestra-chat-toggle,
.maestra-chat.is-open .maestra-chat-toggle-mark{
  animation:none;
}
@keyframes maestra-launcher-breathe{
  0%,100%{
    transform:translateX(0) scale(1);
    box-shadow:0 12px 30px rgba(79,49,173,.28);
  }
  50%{
    transform:translateX(-3px) scale(1.035);
    box-shadow:0 15px 34px rgba(79,49,173,.36),0 0 0 5px rgba(124,85,232,.07);
  }
}
@keyframes maestra-mark-breathe{
  0%,100%{transform:scale(1);background:rgba(255,255,255,.17)}
  50%{transform:scale(1.09);background:rgba(255,255,255,.25)}
}
@media(prefers-reduced-motion:reduce){
  .maestra-chat-toggle,
  .maestra-chat-toggle-mark{animation:none!important}
}
