:root {
  --chat-ink: #19243b;
  --chat-line: #edf0f5;
  --chat-brand: #6158d9;
  --chat-shadow: 0 24px 80px rgba(28, 37, 69, .22), 0 4px 18px rgba(28, 37, 69, .1);
}

.chat-launcher-wrap { position: relative; z-index: 1100; }
body.chat-open .go-top { z-index: 1040; }
.chat-launcher {
  position: fixed;
  right: 10px;
  bottom: 10px;
  z-index: 1100;
  display: inline-flex;
  min-height: 58px;
  align-items: center;
  gap: 10px;
  padding: 7px 18px 7px 8px;
  border: 0;
  border-radius: 999px;
  color: #fff;
  background: linear-gradient(135deg, #7469ef 0%, #554bd0 100%);
  box-shadow: 0 12px 30px rgba(83, 73, 205, .34), inset 0 1px 0 rgba(255,255,255,.24);
  font: inherit;
  font-size: .94rem;
  font-weight: 700;
  letter-spacing: .01em;
  transition: transform .2s ease, box-shadow .2s ease, opacity .2s ease;
}
.chat-launcher:hover { color: #fff; transform: translateY(-3px); box-shadow: 0 16px 34px rgba(83,73,205,.42); }
.chat-launcher:focus-visible, .chat-icon-button:focus-visible, .chat-prompt:focus-visible, .chat-send-button:focus-visible {
  outline: 3px solid rgba(104, 94, 226, .35);
  outline-offset: 3px;
}
.chat-launcher-icon { display: grid; width: 43px; height: 43px; place-items: center; border-radius: 50%; background: rgba(255,255,255,.18); font-size: 1.3rem; }
.chat-launcher-label { padding-right: 3px; }
.chat-launcher-spark { margin-left: -4px; color: #c5c0ff; font-size: .78rem; }
.chat-launcher[aria-expanded="true"] { opacity: 0; pointer-events: none; transform: translateY(10px) scale(.92); }

.chat-window {
  position: fixed;
  right: 26px;
  bottom: 24px;
  z-index: 1100;
  display: flex;
  width: min(540px, calc(100vw - 40px));
  height: min(650px, calc(100vh - 140px));
  min-height: 430px;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,.76);
  border-radius: 22px;
  color: var(--chat-ink);
  background: #fff;
  box-shadow: var(--chat-shadow);
  animation: chat-window-in .22s ease-out both;
}
.chat-window[hidden] { display: none; }
@keyframes chat-window-in { from { opacity: 0; transform: translateY(14px) scale(.985); } to { opacity: 1; transform: translateY(0) scale(1); } }

.chat-header {
  display: flex;
  min-height: 72px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 20px;
  color: #fff;
  background: radial-gradient(circle at 80% -40%, rgba(188,180,255,.55), transparent 38%),
              linear-gradient(112deg, #6258dc 0%, #5148c9 58%, #4842b9 100%);
}
.chat-brand { display: flex; min-width: 0; flex: 1; align-items: center; gap: 11px; }
.chat-brand-mark { display: grid; width: 41px; height: 41px; flex: 0 0 41px; place-items: center; border: 1px solid rgba(255,255,255,.23); border-radius: 14px; background: rgba(255,255,255,.16); font-size: 1.3rem; }
.chat-brand-copy { display: grid; min-width: 0; gap: 2px; }
.chat-brand-copy strong { font-size: 1.08rem; line-height: 1.15; }
.chat-brand-copy span { color: rgba(255,255,255,.75); font-size: .82rem; }
.chat-brand-copy strong, .chat-brand-copy span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-header-actions { display: flex; flex-shrink: 0; align-items: center; gap: 6px; }
.chat-icon-button { display: inline-grid; width: 37px; height: 37px; flex: 0 0 auto; place-items: center; border: 0; border-radius: 11px; color: inherit; background: transparent; font-size: 1.15rem; transition: background .16s ease, transform .16s ease; }
.chat-header .chat-icon-button { color: rgba(255,255,255,.9); }
.chat-header .chat-icon-button[hidden] { display: none; }
.chat-header .chat-icon-button:disabled { cursor: wait; opacity: .5; }
.chat-icon-button:hover { background: rgba(255,255,255,.14); }
.chat-clear:hover { color: #ffe1df; }
.chat-header .chat-whatsapp { box-sizing: border-box; border: 1px solid rgba(255,255,255,.65); color: #117847; background: #e4fff0; box-shadow: 0 3px 10px rgba(16,39,34,.14); text-decoration: none; font-size: 1.35rem; }
.chat-header .chat-whatsapp:not(:disabled):hover { color: #086337; background: #fff; transform: translateY(-1px); }
.chat-whatsapp:focus-visible { outline: 3px solid #fff; outline-offset: 3px; }
.chat-header .chat-whatsapp:disabled { cursor: not-allowed; border-color: rgba(255,255,255,.2); color: rgba(255,255,255,.65); background: rgba(255,255,255,.1); box-shadow: none; }
.chat-close:hover { color: #fff; transform: rotate(90deg); }
.chat-preview-banner { display: flex; min-height: 36px; align-items: center; gap: 7px; padding: 6px 16px; border-bottom: 1px solid #f1e5c5; color: #8a6a24; background: #fffaf0; font-size: .76rem; }
.chat-preview-banner i { flex: 0 0 auto; font-size: .9rem; }

.chat-thread { display: flex; min-height: 0; flex: 1; flex-direction: column; }
.chat-thread-header { display: flex; min-height: 70px; align-items: center; gap: 11px; padding: 0 19px; border-bottom: 1px solid #f0f1f5; }
.chat-thread-avatar { display: grid; width: 39px; height: 39px; flex: 0 0 auto; place-items: center; border-radius: 13px; font-size: 1rem; }
.chat-avatar-assistant { color: #fff; background: linear-gradient(145deg, #8479ef, #574dcb); box-shadow: 0 5px 12px rgba(91,80,205,.2); }
.chat-thread-title { flex: 1; min-width: 0; }
.chat-thread-title h2 { overflow: hidden; margin: 0 0 3px; color: #263149; font-size: .95rem; font-weight: 760; text-overflow: ellipsis; white-space: nowrap; }
.chat-thread-title span { display: block; overflow: hidden; color: #929aab; font-size: .75rem; text-overflow: ellipsis; white-space: nowrap; }
.chat-readonly-pill { display: inline-flex; align-items: center; gap: 5px; padding: 6px 9px; border: 1px solid #e7e5fb; border-radius: 999px; color: #6259c9; background: #f8f7ff; font-size: .7rem; font-weight: 700; white-space: nowrap; }

.chat-messages { display: flex; min-height: 0; flex: 1; flex-direction: column; gap: 12px; overflow: auto; padding: 22px; background: radial-gradient(ellipse at 50% 100%, #fafaff 0%, #fff 72%); scrollbar-color: #d9dce6 transparent; scrollbar-width: thin; }
.chat-history-loading { display: flex; min-height: 100%; align-items: center; justify-content: center; gap: 9px; color: #8992a5; font-size: .82rem; }
.chat-history-loading[hidden] { display: none; }
.chat-history-spinner { width: 17px; height: 17px; border: 2px solid #e6e4f7; border-top-color: #655bdd; border-radius: 50%; animation: chat-status-spin .8s linear infinite; }
.chat-load-older { align-self: center; padding: 6px 11px; border: 1px solid #e8e6fb; border-radius: 999px; color: #6259c9; background: #fff; font: inherit; font-size: .76rem; }
.chat-load-older[hidden] { display: none; }
.chat-load-older:disabled { cursor: wait; opacity: .6; }
.chat-message { display: grid; max-width: 86%; gap: 5px; padding: 10px 13px; border: 1px solid #eceef5; border-radius: 15px; background: #fff; box-shadow: 0 3px 10px rgba(28,37,69,.04); }
.chat-message p { margin: 0; color: #313c54; font-size: .88rem; line-height: 1.5; white-space: pre-wrap; overflow-wrap: anywhere; }
.chat-message time { color: #929aab; font-size: .68rem; }
.chat-message-user { align-self: flex-end; border-color: #e4e1ff; background: #f7f6ff; }
.chat-message-assistant { align-self: flex-start; }
.chat-support-card { display: grid; gap: 9px; margin-top: 5px; padding: 12px; border: 1px solid #e2defe; border-radius: 13px; background: linear-gradient(145deg, #fbfaff, #f4f2ff); }
.chat-support-heading { display: flex; align-items: center; gap: 8px; color: #393568; font-size: .84rem; }
.chat-support-heading > i { display: grid; width: 29px; height: 29px; flex: 0 0 auto; place-items: center; border-radius: 9px; color: #655bdd; background: #e9e6ff; font-size: 1rem; }
.chat-support-description, .chat-support-unavailable { margin: 0; color: #777f92; font-size: .76rem; line-height: 1.45; }
.chat-support-actions { display: grid; gap: 7px; }
.chat-support-link { display: flex; min-width: 0; align-items: center; gap: 7px; padding: 8px 9px; border: 1px solid #e6e7ef; border-radius: 10px; color: #3f4860; background: #fff; font-size: .74rem; font-weight: 700; text-decoration: none; transition: border-color .15s ease, transform .15s ease, box-shadow .15s ease; }
.chat-support-link:hover { transform: translateY(-1px); border-color: #c8c3f6; color: #5048b5; box-shadow: 0 4px 12px rgba(58,52,135,.08); }
.chat-support-link > i { flex: 0 0 auto; color: #655bdd; font-size: 1.08rem; }
.chat-support-whatsapp > i { color: #22a866; }
.chat-support-content { display: flex; min-width: 0; flex-direction: column; gap: 3px; }
.chat-support-detail { color: #667086; font-size: .76rem; font-weight: 500; overflow-wrap: anywhere; }
.chat-support-link:focus-visible { outline: 2px solid #655bdd; outline-offset: 3px; }
.chat-message-status { display: flex; min-height: 16px; align-items: center; gap: 5px; color: #929aab; font-size: .68rem; }
.chat-message-status-sending i { animation: chat-status-spin .9s linear infinite; }
.chat-message-status-sent { color: #5a9a7a; }
.chat-message-status-failed, .chat-message-status-cancelled { color: #bc6d65; }
.chat-retry-button { padding: 0; border: 0; color: #6259c9; background: transparent; font: inherit; font-weight: 700; text-decoration: underline; cursor: pointer; }
.chat-typing { min-width: 58px; min-height: 39px; align-items: center; justify-items: center; padding: 10px 15px; }
.chat-typing-dots { display: inline-flex; align-items: center; gap: 4px; }
.chat-typing-dots span { width: 6px; height: 6px; border-radius: 50%; background: #8178dc; animation: chat-typing-bounce 1.1s ease-in-out infinite; }
.chat-typing-dots span:nth-child(2) { animation-delay: .14s; }
.chat-typing-dots span:nth-child(3) { animation-delay: .28s; }
@keyframes chat-status-spin { to { transform: rotate(360deg); } }
@keyframes chat-typing-bounce { 0%, 60%, 100% { transform: translateY(0); opacity: .45; } 30% { transform: translateY(-5px); opacity: 1; } }
.chat-assistant-intro { align-self: center; max-width: 430px; margin: auto auto 8px; text-align: center; }
.chat-assistant-orb { display: grid; width: 60px; height: 60px; margin: 0 auto 13px; place-items: center; border: 1px solid #e7e4ff; border-radius: 19px; color: #655bdd; background: radial-gradient(circle at 35% 25%, #fff, #efedff 72%); box-shadow: 0 7px 20px rgba(92,82,203,.12); font-size: 1.5rem; }
.chat-assistant-greeting { display: block; margin-bottom: 5px; color: #837bd5; font-size: .9rem; font-weight: 700; }
.chat-assistant-intro h3 { margin: 0 0 8px; color: #303b53; font-size: 1.32rem; font-weight: 760; letter-spacing: -.02em; }
.chat-assistant-intro p { max-width: 390px; margin: 0 auto; color: #8992a5; font-size: .96rem; line-height: 1.6; }
.chat-prompt-grid { display: grid; width: min(100%, 430px); align-self: center; gap: 9px; margin: 0 auto auto; }
.chat-prompt { display: flex; min-height: 62px; align-items: center; gap: 12px; padding: 9px 13px; border: 1px solid #eceef5; border-radius: 14px; text-align: left; color: #655bdd; background: rgba(255,255,255,.92); transition: border-color .16s ease, background .16s ease, transform .16s ease, box-shadow .16s ease; }
.chat-prompt:hover { transform: translateY(-1px); border-color: #d8d4fb; background: #fbfaff; box-shadow: 0 5px 15px rgba(40,45,90,.06); }
.chat-prompt > i:first-child { display: grid; width: 38px; height: 38px; flex: 0 0 auto; place-items: center; border-radius: 12px; background: #f0efff; font-size: 1.1rem; }
.chat-prompt > span { display: grid; flex: 1; gap: 2px; }
.chat-prompt strong { color: #3d4860; font-size: .88rem; font-weight: 740; }
.chat-prompt small { color: #929aab; font-size: .78rem; }
.chat-prompt .chat-prompt-arrow { color: #a6a1e6; font-size: .9rem; }

.chat-composer { position: relative; padding: 8px 15px 10px; border-top: 1px solid #f0f1f5; background: #fff; }
.chat-scroll-bottom { position: absolute; right: 20px; bottom: calc(100% + 12px); z-index: 2; display: grid; width: 44px; height: 44px; padding: 0; place-items: center; border: 1px solid #dedaf9; border-radius: 50%; color: #5b50ce; background: #fff; box-shadow: 0 5px 18px rgba(67,55,151,.2); font-size: 1.4rem; cursor: pointer; transition: transform .16s ease, background .16s ease, box-shadow .16s ease; }
.chat-scroll-bottom[hidden] { display: none; }
.chat-scroll-bottom:hover { transform: translateY(2px); background: #f6f4ff; box-shadow: 0 6px 20px rgba(67,55,151,.28); }
.chat-scroll-bottom:focus-visible { outline: 3px solid rgba(104,94,226,.5); outline-offset: 3px; }
.chat-composer-box { padding: 6px 10px 4px; border: 1px solid #e9ebf2; border-radius: 14px; background: #fcfcfe; transition: border-color .16s ease, box-shadow .16s ease; }
.chat-composer-box:focus-within { border-color: #b9b4f1; background: #fff; box-shadow: 0 0 0 3px rgba(97,88,217,.07); }
.chat-composer textarea { display: block; box-sizing: border-box; width: 100%; min-width: 0; min-height: 30px; max-height: 105px; resize: none; border: 0; outline: 0; color: #313c54; background: transparent; font: inherit; font-size: .98rem; line-height: 1.45; }
.chat-composer textarea::placeholder { color: #a9afbd; }
.chat-composer-tools { position: relative; z-index: 1; display: flex; min-height: 31px; align-items: center; justify-content: flex-end; gap: 8px; }
.chat-composer-actions { display: flex; align-items: center; gap: 8px; }
.chat-character-count { color: #a1a8b5; font-size: .68rem; }
.chat-send-button { display: grid; width: 31px; height: 31px; place-items: center; border: 0; border-radius: 10px; color: #fff; background: linear-gradient(135deg, #7268e6, #554bc9); box-shadow: 0 4px 9px rgba(85,75,201,.2); font-size: .9rem; transition: transform .15s ease, opacity .15s ease; }
.chat-send-button:not(:disabled):hover { transform: translateY(-1px); }
.chat-send-button:disabled { cursor: not-allowed; opacity: .42; box-shadow: none; }
.chat-toast { position: fixed; right: 28px; bottom: 130px; z-index: 1110; display: grid; grid-template-columns: 38px minmax(0, 1fr) 28px; align-items: start; gap: 12px; box-sizing: border-box; width: min(420px, calc(100vw - 32px)); max-height: min(360px, calc(100dvh - 180px)); overflow-y: auto; padding: 16px; border: 1px solid #f1dce1; border-radius: 18px; color: #313c54; background: linear-gradient(135deg, #fff7f9, #fff 55%); box-shadow: 0 18px 50px rgba(28,37,69,.18), 0 3px 10px rgba(28,37,69,.06); animation: chat-toast-enter .2s ease-out; }
.chat-toast[hidden] { display: none; }
.chat-toast-icon { display: grid; width: 38px; height: 38px; place-items: center; border: 1px solid #f5d8e0; border-radius: 12px; color: #b74764; background: #fceaf0; font-size: 1.3rem; }
.chat-toast-content { min-width: 0; padding-top: 2px; }
.chat-toast-content strong { display: block; margin-bottom: 5px; color: #873d53; font-size: .92rem; line-height: 1.35; }
.chat-toast-content p { margin: 0; color: #505b70; font-size: .86rem; line-height: 1.55; white-space: pre-wrap; overflow-wrap: anywhere; }
.chat-toast-close { display: grid; width: 28px; height: 28px; padding: 0; place-items: center; border: 0; border-radius: 8px; color: #7d8194; background: transparent; font-size: 1.15rem; cursor: pointer; transition: background .15s ease, color .15s ease; }
.chat-toast-close:hover { color: #873d53; background: #f8e9ee; }
.chat-toast-close:focus-visible { outline: 2px solid #655bdd; outline-offset: 2px; }
.chat-toast[data-type="success"] { border-color: #d8eade; background: linear-gradient(135deg, #f2fbf5, #fff 55%); }
.chat-toast[data-type="success"] .chat-toast-icon { border-color: #d4eadb; color: #348055; background: #e6f5eb; }
.chat-toast[data-type="success"] .chat-toast-content strong { color: #348055; }
@keyframes chat-toast-enter { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

@media (max-width: 680px) {
  .chat-launcher { right: 16px; bottom: 16px; }
  .chat-window { top: 0; right: 0; bottom: 0; width: 100vw; height: 100dvh; min-height: 0; border: 0; border-radius: 0; }
  .chat-header { min-height: 67px; padding: 0 15px; }
  .chat-preview-banner { min-height: 40px; font-size: .7rem; }
  .chat-thread-header { min-height: 62px; padding: 0 14px; }
  .chat-messages { padding: 17px 14px; }
  .chat-assistant-intro { margin-top: auto; }
  .chat-composer { padding: 8px 11px max(10px, env(safe-area-inset-bottom)); }
  .chat-toast { right: 12px; bottom: calc(120px + env(safe-area-inset-bottom)); width: calc(100vw - 24px); gap: 10px; padding: 14px; }
}

@media (prefers-reduced-motion: reduce) {
  .chat-window, .chat-launcher, .chat-icon-button, .chat-send-button, .chat-prompt, .chat-scroll-bottom,
  .chat-message-status-sending i, .chat-typing-dots span, .chat-history-spinner, .chat-toast, .chat-toast-close { animation: none; transition: none; }
}
