.schat {
  --sc-ink: #15123a; --sc-ultra: #3b2bff; --sc-ultra-2: #2a1de0; --sc-lilac: #c9c2ff; --sc-fog: #f3f4f8;
  --sc-mint: #23c48e; --sc-line: #e3e4ee; --sc-muted: #5c5a78; --sc-paper: #ffffff;
  position: fixed; right: 20px; bottom: 20px; z-index: 2147483000;
  font: 15px/1.45 "Onest Variable", "Onest", system-ui, -apple-system, "Segoe UI", sans-serif; color: var(--sc-ink);
  -webkit-font-smoothing: antialiased;
}
.schat *, .schat *::before, .schat *::after { box-sizing: border-box; }
.schat [hidden] { display: none !important; }
.schat button { font: inherit; cursor: pointer; }
.schat svg { width: 100%; height: 100%; display: block; }

/* Launcher */
.schat-launcher {
  position: relative; display: flex; align-items: center; gap: 10px; height: 56px; padding: 0 22px 0 18px;
  border: 0; border-radius: 28px; background: var(--sc-ultra); color: #fff; font-weight: 600; font-size: 16px;
  box-shadow: 0 14px 34px -10px rgba(59, 43, 255, .65), 0 2px 6px rgba(21, 18, 58, .18);
  transition: transform .2s cubic-bezier(.2, .8, .2, 1), background-color .2s, padding .25s, border-radius .25s;
  margin-left: auto;
}
.schat-launcher:hover { background: var(--sc-ultra-2); transform: translateY(-2px); }
.schat-launcher:active { transform: translateY(0) scale(.97); }
.schat-launcher:focus-visible, .schat button:focus-visible, .schat a:focus-visible, .schat input:focus-visible, .schat textarea:focus-visible {
  outline: 3px solid var(--sc-lilac); outline-offset: 2px;
}
.schat-launcher-ico { width: 24px; height: 24px; }
.schat-ico-x { display: none; }
.schat.is-open .schat-ico-x { display: block; }
.schat.is-open .schat-ico-chat, .schat.is-open .schat-launcher-text { display: none; }
.schat.is-open .schat-launcher { padding: 0 16px; }
.schat-launcher::after {
  content: ""; position: absolute; top: 10px; left: 34px; width: 10px; height: 10px; border-radius: 50%;
  background: var(--sc-mint); box-shadow: 0 0 0 2px var(--sc-ultra); opacity: 0; transition: opacity .2s;
}
.schat[data-presence="online"] .schat-launcher::after { opacity: 1; }
.schat.is-open .schat-launcher::after { display: none; }
.schat-badge {
  position: absolute; top: -6px; right: -4px; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 11px;
  background: var(--sc-mint); color: #06281b; font-size: 12px; font-weight: 700; line-height: 22px; text-align: center;
  display: none; box-shadow: 0 0 0 3px #fff;
}
.schat.has-unread .schat-badge { display: block; }

/* WhatsApp quick button above the launcher */
.schat-wa { position: absolute; right: 2px; bottom: 70px; display: grid; place-items: center; width: 52px; height: 52px; padding: 13px; border-radius: 16px; background: #25d366; color: #fff; box-shadow: 0 12px 28px -10px rgba(37, 211, 102, .8); transition: transform .2s cubic-bezier(.2, .8, .2, 1); }
.schat-wa:hover { transform: translateY(-2px) scale(1.05); color: #fff; }
.schat.is-open .schat-wa { opacity: 0; pointer-events: none; }
/* the greeting sits above the WhatsApp button so both stay visible */
.schat.has-invite .schat-invite { bottom: 134px; }

/* Invite bubble */
.schat-invite {
  position: absolute; right: 0; bottom: 70px; width: 320px; display: none; padding: 14px;
  background: var(--sc-paper); border-radius: 18px 18px 6px 18px; box-shadow: 0 20px 50px -12px rgba(21, 18, 58, .35);
  animation: schat-pop .35s cubic-bezier(.2, .9, .3, 1.2);
}
.schat.has-invite .schat-invite { display: block; }
.schat.is-open .schat-invite { display: none; }
.schat-invite-body { display: flex; gap: 10px; align-items: center; width: 100%; padding: 0 30px 10px 0; border: 0; background: none; text-align: left; color: var(--sc-ink); }
.schat-invite-who { display: flex; flex-direction: column; line-height: 1.2; }
.schat-invite-who small { color: #0b8a5e; font-size: 12px; font-weight: 600; }
.schat-invite .schat-dot { box-shadow: 0 0 0 3px #fff; background: var(--sc-mint); }
.schat-invite-msg { padding: 12px 14px; border-radius: 16px 16px 16px 6px; background: var(--sc-fog); cursor: pointer; }
.schat-invite-text { margin: 0; font-weight: 650; font-size: 15.5px; }
.schat-invite-sub { margin: 4px 0 0; font-size: 13.5px; color: var(--sc-muted); }
.schat-invite-typing { display: none; gap: 4px; padding: 4px 0; }
.schat-invite-typing i { width: 7px; height: 7px; border-radius: 50%; background: #a9a6c9; animation: schat-dot 1.2s infinite ease-in-out; }
.schat-invite-typing i:nth-child(2) { animation-delay: .15s; } .schat-invite-typing i:nth-child(3) { animation-delay: .3s; }
.schat.is-typing .schat-invite-typing { display: flex; }
.schat.is-typing .schat-invite-text, .schat.is-typing .schat-invite-sub, .schat.is-typing .schat-invite-chips { display: none; }
.schat-invite-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.schat-invite-chips .schat-chip { padding: 7px 11px; font-size: 13px; }
.schat-invite-x { position: absolute; top: 10px; right: 10px; width: 28px; height: 28px; padding: 6px; border: 0; border-radius: 50%; background: var(--sc-fog); color: var(--sc-muted); }

/* Panel */
.schat-panel {
  position: absolute; right: 0; bottom: 72px; width: 384px; height: min(600px, calc(100vh - 110px));
  display: flex; flex-direction: column; overflow: hidden;
  background: var(--sc-fog); border-radius: 22px; box-shadow: 0 30px 80px -20px rgba(21, 18, 58, .5), 0 0 0 1px rgba(21, 18, 58, .06);
  opacity: 0; transform: translateY(14px) scale(.98); transform-origin: bottom right; pointer-events: none; visibility: hidden;
  transition: opacity .22s ease, transform .28s cubic-bezier(.2, .9, .3, 1), visibility 0s linear .28s;
}
.schat.is-open .schat-panel { opacity: 1; transform: none; pointer-events: auto; visibility: visible; transition-delay: 0s; }

.schat-head {
  display: flex; align-items: center; gap: 12px; padding: 16px 12px 16px 16px;
  background: var(--sc-ink); color: #fff;
  background-image: radial-gradient(420px 160px at 100% 0%, rgba(59, 43, 255, .9), transparent 70%);
}
.schat-avatar {
  position: relative; flex: none; width: 42px; height: 42px; border-radius: 14px; display: grid; place-items: center;
  background: var(--sc-ultra); color: #fff; font: 700 20px/1 "Unbounded Variable", "Unbounded", system-ui, sans-serif;
}
.schat-avatar--img { background: #fff; box-shadow: inset 0 0 0 1px rgba(21, 18, 58, .08); }
.schat-avatar--img img { width: 74%; height: 74%; object-fit: contain; display: block; }
.schat-avatar--sm { width: 36px; height: 36px; font-size: 17px; border-radius: 12px; }
.schat-dot { position: absolute; right: -3px; bottom: -3px; width: 13px; height: 13px; border-radius: 50%; background: #9a98b5; box-shadow: 0 0 0 3px var(--sc-ink); }
.schat[data-presence="online"] .schat-dot, .schat[data-presence="hours"] .schat-dot { background: var(--sc-mint); }
.schat-head-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.schat-head-text strong { font-size: 16px; font-weight: 650; }
.schat-status-text { font-size: 13px; color: #cfcce8; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.schat-head-links { display: flex; gap: 2px; }
.schat-hl { display: grid; place-items: center; width: 38px; height: 38px; padding: 9px; border: 0; border-radius: 12px; background: transparent; color: #fff; text-decoration: none; transition: background-color .15s; }
.schat-hl:hover { background: rgba(255, 255, 255, .12); }

.schat button, .schat a { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
.schat-list { flex: 1; overflow-y: auto; padding: 18px 14px 8px; display: flex; flex-direction: column; gap: 10px; overscroll-behavior: contain; scroll-behavior: smooth; }
.schat-msg { display: flex; flex-direction: column; max-width: 84%; }
.schat-msg--them { align-self: flex-start; }
.schat-msg--me { align-self: flex-end; align-items: flex-end; }
.schat-msg--sys { align-self: center; max-width: 92%; }
.schat-bubble { padding: 10px 14px; border-radius: 18px; white-space: pre-wrap; word-wrap: break-word; overflow-wrap: anywhere; }
.schat-msg--them .schat-bubble { background: var(--sc-paper); border-bottom-left-radius: 6px; box-shadow: 0 1px 2px rgba(21, 18, 58, .06); }
.schat-msg--me .schat-bubble { background: var(--sc-ultra); color: #fff; border-bottom-right-radius: 6px; }
.schat-msg--sys .schat-bubble { background: transparent; color: var(--sc-muted); font-size: 13px; text-align: center; padding: 4px 8px; }
.schat-msg--me .schat-bubble a { color: #fff; }
.schat-bubble a { color: var(--sc-ultra); }
.schat-msg.is-pending .schat-bubble { opacity: .65; }
.schat-meta { font-size: 11.5px; color: var(--sc-muted); margin: 4px 6px 0; }

.schat-typing { display: none; gap: 4px; margin: 0 14px 6px; padding: 10px 14px; width: max-content; background: var(--sc-paper); border-radius: 18px 18px 18px 6px; }
.schat-typing.is-on { display: flex; }
.schat-typing i { width: 7px; height: 7px; border-radius: 50%; background: #a9a6c9; animation: schat-dot 1.2s infinite ease-in-out; }
.schat-typing i:nth-child(2) { animation-delay: .15s; } .schat-typing i:nth-child(3) { animation-delay: .3s; }

.schat-quick { display: flex; flex-wrap: wrap; gap: 8px; padding: 4px 14px 10px; justify-content: flex-end; }
.schat-chip { padding: 9px 14px; border: 1.5px solid var(--sc-ultra); border-radius: 18px; background: #fff; color: var(--sc-ultra); font-size: 14px; font-weight: 550; line-height: 1.2; transition: background-color .15s, color .15s; }
.schat-chip:hover { background: var(--sc-ultra); color: #fff; }

.schat-card { align-self: stretch; background: #fff; border-radius: 18px; padding: 14px; border: 1.5px dashed var(--sc-lilac); }
.schat-card-title { margin: 0 0 10px; font-size: 14px; font-weight: 600; }
.schat-card-row { display: grid; grid-template-columns: 1fr 1.3fr; gap: 8px; }
.schat-card input { width: 100%; min-height: 44px; padding: 10px 12px; border: 1px solid var(--sc-line); border-radius: 12px; font: inherit; color: var(--sc-ink); background: var(--sc-fog); }
.schat-card-err { margin: 6px 0 0; color: #b42318; font-size: 13px; }
.schat-card-err:empty { display: none; }
.schat-card-btn { margin-top: 10px; width: 100%; min-height: 44px; border: 0; border-radius: 12px; background: var(--sc-ink); color: #fff; font-weight: 600; }
.schat-card-btn:disabled { opacity: .6; }

.schat-error { margin: 0 14px; color: #b42318; font-size: 13px; }
.schat-error:empty { display: none; }
.schat-form { display: flex; align-items: flex-end; gap: 8px; margin: 8px 12px 0; padding: 6px 6px 6px 14px; background: #fff; border-radius: 20px; box-shadow: 0 0 0 1px var(--sc-line); }
.schat-form:focus-within { box-shadow: 0 0 0 2px var(--sc-ultra); }
.schat-input { flex: 1; min-height: 40px; max-height: 120px; padding: 9px 0; border: 0; outline: 0; resize: none; background: none; font: inherit; color: var(--sc-ink); }
.schat-input:focus-visible { outline: none; }
.schat-send { flex: none; width: 42px; height: 42px; padding: 10px; border: 0; border-radius: 14px; background: var(--sc-ultra); color: #fff; transition: background-color .15s, transform .15s; }
.schat-send:hover { background: var(--sc-ultra-2); }
.schat-send:active { transform: scale(.94); }
.schat-hp { position: absolute !important; left: -9999px !important; width: 1px; height: 1px; opacity: 0; }
.schat-foot { padding: 8px 16px 12px; font-size: 11.5px; color: var(--sc-muted); text-align: center; }
.schat-foot a { color: inherit; }

@keyframes schat-pop { from { opacity: 0; transform: translateY(10px) scale(.96); } to { opacity: 1; transform: none; } }
@keyframes schat-dot { 0%, 80%, 100% { transform: translateY(0); opacity: .5; } 40% { transform: translateY(-4px); opacity: 1; } }

@media (max-width: 520px) {
  .schat { right: 14px; bottom: 14px; }
  .schat-launcher-text { display: none; }
  .schat-launcher { width: 58px; height: 58px; padding: 0; justify-content: center; border-radius: 20px; }
  .schat.is-open .schat-launcher { display: none; }
  .schat-launcher::after { left: auto; right: 10px; }
  .schat-panel { position: fixed; inset: 0; width: auto; height: 100%; height: 100dvh; border-radius: 0; transform: translateY(24px); }
  .schat-head { padding-top: max(16px, env(safe-area-inset-top)); }
  .schat-foot { padding-bottom: max(12px, env(safe-area-inset-bottom)); }
  .schat-input { font-size: 16px; } /* no iOS zoom */
  .schat-card input { font-size: 16px; }
  .schat-invite { width: calc(100vw - 28px); bottom: 72px; }
  .schat.has-invite .schat-invite { bottom: 132px; }
  .schat-wa { width: 50px; height: 50px; bottom: 70px; right: 4px; }
  .schat-invite { padding: 10px 12px; border-radius: 16px 16px 6px 16px; }
  .schat-invite-body { padding-bottom: 6px; }
  .schat-invite .schat-avatar--sm { width: 30px; height: 30px; font-size: 14px; border-radius: 10px; }
  .schat-invite-msg { padding: 8px 12px; }
  .schat-invite-text { font-size: 14.5px; }
  .schat-invite-sub { display: none; }
  .schat-invite-chips { margin-top: 8px; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .schat-invite-chips .schat-chip { flex: none; padding: 6px 10px; font-size: 12.5px; }
}

/* Mobile: compact bubble beside the buttons, never covers the page */
@media (max-width: 520px) {
  .schat-invite, .schat.has-invite .schat-invite { right: 70px; bottom: 4px; width: min(250px, calc(100vw - 104px)); padding: 0; border-radius: 18px 18px 6px 18px; background: transparent; box-shadow: none; }
  .schat-invite-body, .schat-invite-chips, .schat-invite-sub { display: none !important; }
  .schat-invite-msg { position: relative; padding: 12px 34px 12px 14px; border-radius: 18px 18px 6px 18px; background: var(--sc-paper); box-shadow: 0 14px 34px -10px rgba(21, 18, 58, .35), 0 0 0 1px rgba(21, 18, 58, .06); }
  .schat-invite-text { font-size: 14px; line-height: 1.35; }
  .schat-invite-x { top: 6px; right: 6px; width: 24px; height: 24px; padding: 5px; }
}
@media (prefers-reduced-motion: reduce) {
  .schat *, .schat-panel, .schat-launcher { transition: none !important; animation: none !important; }
}
