/* KRESTYA : assistant de discussion. Thème clair par défaut, sombre via html[data-theme="dark"]. */
#kc-root{--kc-bg:#fff;--kc-bg2:#F1F4F9;--kc-tx:#334155;--kc-hd:#0B1226;--kc-mu:#64748b;--kc-ln:rgba(15,23,42,.12);--kc-ac:#1F5BFF;--kc-ac2:#1749D6;--kc-on:#fff;--kc-bot:#EDF1F8;--kc-sh:rgba(15,23,42,.22);
 font-family:"Plus Jakarta Sans",system-ui,-apple-system,"Segoe UI",sans-serif;font-size:15px;line-height:1.5;color:var(--kc-tx)}
:root[data-theme="dark"] #kc-root{--kc-bg:#0F1730;--kc-bg2:#0A0F1E;--kc-tx:#C9D3EA;--kc-hd:#fff;--kc-mu:#8593B5;--kc-ln:rgba(255,255,255,.12);--kc-ac:#3B7BFF;--kc-ac2:#2F66E0;--kc-bot:#1A2447;--kc-sh:rgba(0,0,0,.6)}
#kc-root *,#kc-root *::before,#kc-root *::after{box-sizing:border-box}
:where(#kc-root) button{font:inherit;color:inherit;cursor:pointer;border:0;background:none;padding:0}
#kc-root :focus-visible{outline:2px solid var(--kc-ac);outline-offset:2px;border-radius:8px}
.kc-i{width:20px;height:20px;fill:none;stroke:currentColor;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;display:block}

/* bouton flottant */
#kc-fab{position:fixed;right:20px;bottom:max(20px,env(safe-area-inset-bottom,0px));z-index:80;display:inline-flex;align-items:center;gap:10px;height:52px;padding:0 20px 0 16px;border-radius:999px;background:var(--kc-ac)!important;color:var(--kc-on)!important;font-weight:700;font-size:15px;box-shadow:0 8px 24px var(--kc-sh);transition:transform .15s,background .15s}
#kc-fab:hover{background:var(--kc-ac2)!important;transform:translateY(-2px)}
#kc-root.open #kc-fab{display:none}
#kc-root[data-ctx="dashboard"] #kc-fab{bottom:max(92px,env(safe-area-inset-bottom,0px))}

/* panneau : pleine hauteur, collé à droite */
#kc-panel{position:fixed;top:0;right:0;bottom:0;z-index:130;width:min(440px,100vw);height:100vh;height:100dvh;display:flex;flex-direction:column;background:var(--kc-bg);border-left:1px solid var(--kc-ln);box-shadow:-12px 0 40px var(--kc-sh);animation:kc-in .22s ease-out}
#kc-panel[hidden]{display:none}
@keyframes kc-in{from{transform:translateX(24px);opacity:0}to{transform:none;opacity:1}}
@media(prefers-reduced-motion:reduce){#kc-panel{animation:none}#kc-fab{transition:none}}

.kc-h{flex:none;display:flex;align-items:center;gap:12px;padding:14px 14px 14px 18px;border-bottom:1px solid var(--kc-ln);background:var(--kc-bg)}
.kc-lg{height:32px;width:auto;flex:none}.kc-lgd{display:none}
:root[data-theme="dark"] .kc-lgl{display:none}:root[data-theme="dark"] .kc-lgd{display:block}
.kc-tt{flex:1;min-width:0}.kc-tt b{display:block;color:var(--kc-hd);font-size:16px;font-weight:800;line-height:1.2}.kc-tt small{display:block;color:var(--kc-mu);font-size:12.5px}
.kc-ib{flex:none;width:38px;height:38px;border-radius:10px;display:grid;place-items:center;color:var(--kc-mu)}
.kc-ib:hover{background:var(--kc-bg2);color:var(--kc-hd)}

.kc-m{flex:1;min-height:0;overflow-y:auto;padding:18px;display:flex;flex-direction:column;gap:10px;background:var(--kc-bg2);overscroll-behavior:contain}
.kc-b{max-width:88%;padding:10px 14px;border-radius:16px;overflow-wrap:anywhere;word-break:break-word;font-size:14.5px}
.kc-b.a{align-self:flex-start;background:var(--kc-bot);color:var(--kc-hd);border-bottom-left-radius:5px}
.kc-b.u{align-self:flex-end;background:var(--kc-ac);color:var(--kc-on);border-bottom-right-radius:5px}
.kc-b.err{border:1px solid rgba(239,68,68,.45)}
.kc-b ul{margin:6px 0;padding-left:20px}.kc-b li{margin:2px 0}
.kc-b a{color:inherit;text-decoration:underline;text-underline-offset:2px;font-weight:600}
.kc-act{display:flex;flex-direction:column;gap:8px;margin-top:10px}
.kc-act .kc-btn{display:block;text-align:center;text-decoration:none;font-weight:700;font-size:14px;padding:10px 14px;border-radius:12px;background:var(--kc-ac);color:var(--kc-on)}
.kc-act .kc-btn.alt{background:transparent;color:var(--kc-hd);border:1px solid var(--kc-ln)}
.kc-ty{display:flex;gap:5px;align-items:center;padding:14px 16px}
.kc-ty i{width:7px;height:7px;border-radius:50%;background:var(--kc-mu);animation:kc-b 1.2s infinite ease-in-out}.kc-ty i:nth-child(2){animation-delay:.15s}.kc-ty i:nth-child(3){animation-delay:.3s}
@keyframes kc-b{0%,60%,100%{opacity:.3;transform:none}30%{opacity:1;transform:translateY(-3px)}}
@media(prefers-reduced-motion:reduce){.kc-ty i{animation:none;opacity:.7}}

.kc-c{flex:none;display:flex;flex-wrap:wrap;gap:8px;padding:10px 18px;background:var(--kc-bg2);border-top:1px solid var(--kc-ln)}
.kc-c[hidden]{display:none}
.kc-chip{padding:8px 13px;border-radius:999px;border:1px solid var(--kc-ln);background:var(--kc-bg);color:var(--kc-hd);font-size:13.5px;font-weight:600;text-align:left;transition:.15s}
.kc-chip:hover{border-color:var(--kc-ac);color:var(--kc-ac)}

.kc-f{flex:none;padding:12px 14px calc(10px + env(safe-area-inset-bottom,0px));background:var(--kc-bg);border-top:1px solid var(--kc-ln)}
.kc-box{display:flex;align-items:flex-end;gap:6px;background:var(--kc-bg2);border:1px solid var(--kc-ln);border-radius:16px;padding:6px 6px 6px 14px}
.kc-box:focus-within{border-color:var(--kc-ac)}
#kc-ta{flex:1;min-width:0;resize:none;border:0;outline:0;background:transparent;color:var(--kc-hd);font:inherit;font-size:16px;line-height:1.4;padding:8px 0;max-height:140px}
#kc-ta::placeholder{color:var(--kc-mu)}
.kc-mic[hidden]{display:none}
.kc-mic.on{background:rgba(239,68,68,.15);color:#ef4444;animation:kc-p 1.4s infinite}
@keyframes kc-p{50%{box-shadow:0 0 0 6px rgba(239,68,68,.12)}}
@media(prefers-reduced-motion:reduce){.kc-mic.on{animation:none}}
.kc-send{flex:none;width:40px;height:40px;border-radius:12px;display:grid;place-items:center;background:var(--kc-ac)!important;color:var(--kc-on)!important}
.kc-send:hover{background:var(--kc-ac2)!important}.kc-send:disabled{opacity:.45;cursor:default}
.kc-n{margin:8px 4px 0;min-height:16px;font-size:12px;color:var(--kc-mu);text-align:center}

/* mobile : plein écran */
@media(max-width:640px){
 #kc-panel{width:100vw;border-left:0;box-shadow:none;animation:none}
 #kc-fab{right:14px;height:48px;padding:0 16px 0 14px}
 #kc-root[data-ctx="dashboard"] #kc-fab{bottom:max(88px,env(safe-area-inset-bottom,0px))}
 .kc-m{padding:14px}.kc-c{padding:10px 14px}.kc-b{max-width:92%}
}
html.kc-lock,html.kc-lock body{overflow:hidden}
#kc-root #kc-ta:focus-visible{outline:0}

/* v2 : sur le tableau de bord, le bouton d'aide se place au-dessus de la zone de saisie (hauteur mesurée par chat.js dans --kc-lift) */
#kc-root[data-ctx="dashboard"] #kc-fab{bottom:max(92px,calc(var(--kc-lift,0px) + 16px))}
@media(max-width:640px){#kc-root[data-ctx="dashboard"] #kc-fab{bottom:max(88px,calc(var(--kc-lift,0px) + 16px))}}

/* v3 : sur le tableau de bord, bouton d'aide compact (icône seule) ; le site public garde le bouton avec texte */
#kc-root[data-ctx="dashboard"] #kc-fab{width:48px;height:48px;padding:0;gap:0;justify-content:center;right:20px}
#kc-root[data-ctx="dashboard"] #kc-fab .kc-fl{position:absolute;width:1px;height:1px;margin:-1px;padding:0;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}
@media(max-width:640px){#kc-root[data-ctx="dashboard"] #kc-fab{width:46px;height:46px;padding:0;right:14px}}

/* v4 : le site public stylise tous les <header> (sticky, flou, animation) : on l'annule pour l'entête du chat, comme sur le tableau de bord */
#kc-root .kc-h{position:relative;top:auto;z-index:auto;animation:none;backdrop-filter:none;-webkit-backdrop-filter:none;margin:0;min-height:0;height:auto;padding:14px 14px 14px 18px;background:var(--kc-bg);border-bottom:1px solid var(--kc-ln)}
