/* FAQ Chat Widget — everything is scoped under .cmchat */
.cmchat{--cm-primary:#1f5eff;--cm-navy:#07163a;--cm-accent:#5ad1ff;--cm-bg:#fff;--cm-soft:#f2f5fc;--cm-text:#0f1b3d;--cm-muted:#5b678a;--cm-line:#e2e8f5;--cm-font:inherit;
position:fixed;right:20px;bottom:20px;right:max(20px,env(safe-area-inset-right));bottom:max(20px,env(safe-area-inset-bottom));z-index:2147483000;font-family:var(--cm-font);font-size:15px;line-height:1.45;color:var(--cm-text);-webkit-font-smoothing:antialiased}
.cmchat *,.cmchat *::before,.cmchat *::after{box-sizing:border-box}
.cmchat button,.cmchat textarea,.cmchat input{font:inherit;color:inherit;margin:0}
.cmchat button{cursor:pointer;border:0;background:none;padding:0}
.cmchat [hidden]{display:none!important}
.cmchat :focus-visible{outline:3px solid var(--cm-accent);outline-offset:2px}
.cmchat svg{display:block;width:100%;height:100%}

/* Launcher */
.cmchat .cmchat-launcher{position:relative;display:block;width:58px;height:58px;margin-left:auto;border-radius:50%;background:linear-gradient(135deg,var(--cm-primary),var(--cm-navy));color:#fff;box-shadow:0 10px 28px rgba(7,22,58,.35);transition:transform .2s}
.cmchat .cmchat-launcher:hover{transform:scale(1.06)}
.cmchat .cmchat-launcher .cmchat-ico{position:absolute;inset:16px;transition:opacity .2s,transform .25s}
.cmchat .cmchat-launcher .cmchat-ico-x{opacity:0;transform:rotate(-80deg) scale(.6)}
.cmchat[data-state="open"] .cmchat-launcher .cmchat-ico-chat{opacity:0;transform:rotate(80deg) scale(.6)}
.cmchat[data-state="open"] .cmchat-launcher .cmchat-ico-x{opacity:1;transform:none}
.cmchat .cmchat-badge{position:absolute;top:-2px;right:-2px;min-width:18px;height:18px;padding:0 5px;border-radius:9px;background:#ff4d4f;color:#fff;font-size:11px;font-weight:700;line-height:18px;text-align:center}

/* Teaser */
.cmchat .cmchat-teaser{position:absolute;right:0;bottom:72px;width:min(300px,calc(100vw - 40px));display:flex;gap:10px;align-items:flex-start;padding:12px 34px 12px 12px;background:var(--cm-bg);border-radius:18px;box-shadow:0 12px 32px rgba(7,22,58,.22);animation:cmchat-pop .35s ease both}
.cmchat .cmchat-teaser::after{content:"";position:absolute;right:22px;bottom:-6px;width:14px;height:14px;background:var(--cm-bg);transform:rotate(45deg);border-radius:3px}
.cmchat .cmchat-teaser-t{display:flex;flex-direction:column;font-size:14px}
.cmchat .cmchat-teaser-t strong{font-weight:700}
.cmchat .cmchat-teaser-x{position:absolute;top:8px;right:8px;width:22px;height:22px;padding:4px;border-radius:50%;color:var(--cm-muted)}
.cmchat .cmchat-teaser-x:hover{background:var(--cm-soft)}
.cmchat[data-state="open"] .cmchat-teaser{display:none}

.cmchat .cmchat-av{width:36px;height:36px;border-radius:50%;object-fit:contain;padding:3px;flex:none;background:#fff}

/* Panel */
.cmchat .cmchat-panel{position:absolute;right:0;bottom:72px;width:380px;height:min(640px,calc(100dvh - 110px));display:flex;flex-direction:column;background:var(--cm-bg);border-radius:24px;overflow:hidden;box-shadow:0 24px 60px rgba(7,22,58,.3);transform-origin:bottom right;opacity:0;visibility:hidden;transform:translateY(14px) scale(.96);transition:opacity .22s,transform .22s,visibility 0s .22s}
.cmchat[data-state="open"] .cmchat-panel{opacity:1;visibility:visible;transform:none;transition:opacity .22s,transform .22s}

.cmchat .cmchat-head{display:flex;align-items:center;gap:12px;padding:14px 12px 14px 16px;color:#fff;background:linear-gradient(135deg,var(--cm-navy),var(--cm-primary))}
.cmchat .cmchat-avwrap{position:relative;flex:none}
.cmchat .cmchat-avwrap .cmchat-av{width:42px;height:42px;border:2px solid rgba(255,255,255,.35)}
.cmchat .cmchat-dot{position:absolute;right:0;bottom:0;width:11px;height:11px;border-radius:50%;background:#2ecc71;border:2px solid var(--cm-navy)}
.cmchat .cmchat-id{flex:1;min-width:0;display:flex;flex-direction:column}
.cmchat .cmchat-id strong{font-size:16px;font-weight:700}
.cmchat .cmchat-id span{font-size:12px;opacity:.85;line-height:1.3}
.cmchat .cmchat-ib{width:34px;height:34px;padding:8px;border-radius:50%;color:#fff;flex:none}
.cmchat .cmchat-ib:hover{background:rgba(255,255,255,.16)}

/* Log */
.cmchat .cmchat-log{flex:1;overflow-y:auto;padding:16px;display:flex;flex-direction:column;gap:10px;background:var(--cm-soft);overscroll-behavior:contain}
.cmchat .cmchat-row{display:flex;gap:8px;align-items:flex-end;animation:cmchat-in .25s ease both}
.cmchat .cmchat-row.user{justify-content:flex-end}
.cmchat .cmchat-row .cmchat-av{width:26px;height:26px}
.cmchat .cmchat-bub{max-width:80%;padding:10px 14px;border-radius:18px;background:var(--cm-bg);border:1px solid var(--cm-line);border-bottom-left-radius:6px;overflow-wrap:anywhere;white-space:pre-wrap}
.cmchat .cmchat-row.user .cmchat-bub{background:var(--cm-primary);border-color:var(--cm-primary);color:#fff;border-radius:18px;border-bottom-right-radius:6px}
.cmchat .cmchat-bub a{color:var(--cm-primary);text-decoration:underline}
.cmchat .cmchat-bub a.cmchat-cta{display:block;margin-top:8px;padding:9px 14px;border-radius:999px;background:var(--cm-primary);color:#fff;text-align:center;text-decoration:none;font-weight:600;white-space:normal}
.cmchat .cmchat-bub a.cmchat-cta:hover{background:var(--cm-navy)}
.cmchat .cmchat-typing{display:inline-flex;gap:4px;padding:14px}
.cmchat .cmchat-typing i{width:7px;height:7px;border-radius:50%;background:var(--cm-muted);opacity:.5;animation:cmchat-dot 1s infinite}
.cmchat .cmchat-typing i:nth-child(2){animation-delay:.15s}
.cmchat .cmchat-typing i:nth-child(3){animation-delay:.3s}

/* Chips */
.cmchat .cmchat-chips{display:flex;flex-wrap:wrap;gap:6px;padding:10px 14px;background:var(--cm-soft);border-top:1px solid var(--cm-line);max-height:128px;overflow-y:auto}
.cmchat .cmchat-chip{padding:7px 12px;border-radius:999px;background:var(--cm-bg);border:1px solid var(--cm-line);color:var(--cm-primary);font-size:13px;font-weight:500;transition:background .15s,border-color .15s}
.cmchat .cmchat-chip:hover{border-color:var(--cm-primary);background:#eef3ff}
.cmchat .cmchat-chip.hl{background:var(--cm-primary);border-color:var(--cm-primary);color:#fff}
.cmchat .cmchat-chip.hl:hover{background:var(--cm-navy)}
.cmchat .cmchat-chip.ghost{color:var(--cm-muted)}

/* Composer */
.cmchat .cmchat-composer{display:flex;align-items:flex-end;gap:8px;padding:10px 12px;background:var(--cm-bg);border-top:1px solid var(--cm-line)}
.cmchat .cmchat-composer textarea{flex:1;resize:none;border:1px solid var(--cm-line);border-radius:18px;padding:10px 14px;line-height:1.4;max-height:96px;background:var(--cm-soft);outline:none}
.cmchat .cmchat-composer textarea:focus-visible{border-color:var(--cm-primary);outline:2px solid var(--cm-accent);outline-offset:0}
.cmchat .cmchat-send{width:42px;height:42px;flex:none;padding:11px;border-radius:50%;background:var(--cm-primary);color:#fff;transition:background .15s,opacity .15s}
.cmchat .cmchat-send:hover:not(:disabled){background:var(--cm-navy)}
.cmchat .cmchat-send:disabled{opacity:.4;cursor:not-allowed}
.cmchat .cmchat-hp{position:absolute;left:-9999px;width:1px;height:1px;overflow:hidden}

/* Footer */
.cmchat .cmchat-foot{display:flex;justify-content:space-between;gap:10px;padding:8px 16px 10px;font-size:11px;color:var(--cm-muted);background:var(--cm-bg)}
.cmchat .cmchat-foot a{color:var(--cm-muted);text-decoration:underline;flex:none}

@keyframes cmchat-in{from{opacity:0;transform:translateY(8px)}to{opacity:1;transform:none}}
@keyframes cmchat-pop{from{opacity:0;transform:translateY(10px) scale(.96)}to{opacity:1;transform:none}}
@keyframes cmchat-dot{0%,60%,100%{transform:translateY(0);opacity:.4}30%{transform:translateY(-4px);opacity:1}}

/* Mobile: full-screen sheet that follows the on-screen keyboard (height set by JS via --cm-vh / --cm-vt) */
@media (max-width:519px){
.cmchat{right:12px;bottom:12px;right:max(12px,env(safe-area-inset-right));bottom:max(12px,env(safe-area-inset-bottom))}
.cmchat[data-state="open"] .cmchat-launcher{display:none}
.cmchat .cmchat-panel{position:fixed;left:0;right:0;top:var(--cm-vt,0px);bottom:auto;width:auto;height:var(--cm-vh,100dvh);max-height:none;border-radius:0;transform:translateY(24px)}
.cmchat[data-state="open"] .cmchat-panel{transform:none}
.cmchat .cmchat-head{padding-top:max(14px,env(safe-area-inset-top))}
.cmchat .cmchat-ib{width:42px;height:42px;padding:10px}
.cmchat .cmchat-chips{max-height:104px;flex:none}
.cmchat .cmchat-composer{padding-bottom:max(10px,env(safe-area-inset-bottom))}
.cmchat .cmchat-composer textarea{font-size:16px}
.cmchat .cmchat-foot{padding-bottom:max(10px,env(safe-area-inset-bottom))}
.cmchat[data-kb="1"] .cmchat-chips,.cmchat[data-kb="1"] .cmchat-foot{display:none}
.cmchat[data-kb="1"] .cmchat-composer{padding-bottom:10px}
.cmchat .cmchat-teaser{right:0}
}

@media (prefers-reduced-motion:reduce){
.cmchat *,.cmchat *::before,.cmchat *::after{animation:none!important;transition:none!important}
}
