.avcb4-agent {
  --avcb4-primary: #111318;
  --avcb4-accent: #e1262f;
  --avcb4-text: #171b25;
  --avcb4-muted: #747b8b;
  --avcb4-line: #e7e9ee;
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 999999;
  max-width: calc(100vw - 24px);
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  color: var(--avcb4-text);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.avcb4-agent,
.avcb4-agent *,
.avcb4-agent *::before,
.avcb4-agent *::after {
  box-sizing: border-box;
}

.avcb4-agent * {
  max-width: 100%;
}

/* Premium launcher */
.avcb4-launcher {
  width: 224px;
  max-width: calc(100vw - 28px);
  min-height: 66px;
  padding: 9px 12px 9px 9px;
  border: 1px solid rgba(255,255,255,.13);
  border-radius: 20px;
  background: linear-gradient(135deg, #0b0c10 0%, var(--avcb4-primary) 62%, #2c1115 100%);
  color: #fff;
  display: flex;
  align-items: center;
  gap: 11px;
  cursor: pointer;
  box-shadow: 0 22px 56px rgba(8,12,20,.28), 0 8px 18px rgba(8,12,20,.18);
  position: relative;
  overflow: hidden;
  isolation: isolate;
  transition: transform .2s ease, box-shadow .2s ease;
}
.avcb4-launcher::before {
  content: "";
  position: absolute;
  width: 90px;
  height: 150px;
  left: -120px;
  top: -42px;
  transform: rotate(20deg);
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.13), transparent);
  transition: left .55s ease;
  pointer-events: none;
}
.avcb4-launcher::after {
  content: "AI";
  position: absolute;
  top: 8px;
  right: 9px;
  z-index: -1;
  font-size: 9px;
  font-weight: 900;
  letter-spacing: .08em;
  color: rgba(255,255,255,.08);
}
.avcb4-launcher:hover { transform: translateY(-3px); box-shadow: 0 28px 68px rgba(8,12,20,.32), 0 10px 22px rgba(8,12,20,.2); }
.avcb4-launcher:hover::before { left: 260px; }
.avcb4-launcher:focus-visible { outline: 3px solid rgba(225,38,47,.28); outline-offset: 3px; }
.avcb4-launcher-icon {
  width: 48px;
  height: 48px;
  flex: 0 0 48px;
  border-radius: 15px;
  display: grid;
  place-items: center;
  background: linear-gradient(145deg, rgba(255,255,255,.16), rgba(255,255,255,.07));
  border: 1px solid rgba(255,255,255,.14);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.08);
  position: relative;
}
.avcb4-launcher-icon svg { width: 24px; height: 24px; fill: currentColor; }
.avcb4-live-dot {
  position: absolute;
  right: -1px;
  bottom: -1px;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: #39d98a;
  border: 3px solid #111318;
  animation: avcb4Pulse 2.2s infinite;
}
@keyframes avcb4Pulse { 0% { box-shadow: 0 0 0 0 rgba(57,217,138,.42); } 70% { box-shadow: 0 0 0 8px rgba(57,217,138,0); } 100% { box-shadow: 0 0 0 0 rgba(57,217,138,0); } }
.avcb4-launcher-copy { display: flex; flex: 1 1 auto; min-width: 0; flex-direction: column; text-align: left; }
.avcb4-launcher-copy strong { font-size: 14px; line-height: 1.2; font-weight: 760; letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.avcb4-launcher-copy small { margin-top: 4px; font-size: 10.5px; line-height: 1.2; color: rgba(255,255,255,.7); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.avcb4-launcher-arrow { flex: 0 0 22px; width: 22px; height: 22px; display: grid; place-items: center; opacity: .65; transition: transform .2s ease; }
.avcb4-open .avcb4-launcher-arrow { transform: rotate(180deg); }

/* Panel: overflow-x is deliberately disabled in V4 */
.avcb4-panel {
  position: absolute;
  right: 0;
  bottom: 78px;
  width: 430px;
  max-width: calc(100vw - 28px);
  height: min(700px, calc(100vh - 118px));
  min-height: 510px;
  border: 1px solid rgba(20,25,38,.09);
  border-radius: 25px;
  background: #fff;
  overflow-x: hidden !important;
  overflow-y: hidden !important;
  overscroll-behavior-x: none;
  touch-action: pan-y;
  box-shadow: 0 36px 96px rgba(13,17,28,.25), 0 10px 30px rgba(13,17,28,.1);
  transform-origin: bottom right;
}
.avcb4-panel:not([hidden]) { display: flex; flex-direction: column; animation: avcb4PanelIn .2s cubic-bezier(.2,.8,.2,1); }
@keyframes avcb4PanelIn { from { opacity: 0; transform: translateY(12px) scale(.975); } to { opacity: 1; transform: translateY(0) scale(1); } }

.avcb4-header {
  flex: 0 0 auto;
  min-height: 80px;
  padding: 14px 14px 14px 16px;
  background: linear-gradient(135deg, #0b0c10, var(--avcb4-primary) 70%, #261216);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  position: relative;
  overflow: hidden;
}
.avcb4-header::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 2px; background: linear-gradient(90deg, var(--avcb4-accent), transparent 72%); }
.avcb4-brand { min-width: 0; display: flex; align-items: center; gap: 11px; overflow: hidden; }
.avcb4-avatar { display: inline-grid; place-items: center; overflow: hidden; background: #fff; color: var(--avcb4-primary); font-weight: 850; letter-spacing: -.04em; border: 1px solid rgba(255,255,255,.4); }
.avcb4-avatar img, .avcb4-message-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.avcb4-avatar-large { width: 46px; height: 46px; flex: 0 0 46px; border-radius: 14px; }
.avcb4-brand-copy { display: flex; flex-direction: column; min-width: 0; overflow: hidden; }
.avcb4-brand-copy strong { font-size: 15px; line-height: 1.2; font-weight: 760; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.avcb4-brand-copy small { display: flex; align-items: center; gap: 6px; min-width: 0; margin-top: 5px; font-size: 10.5px; color: rgba(255,255,255,.72); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.avcb4-status-dot { width: 7px; height: 7px; flex: 0 0 7px; border-radius: 50%; background: #39d98a; box-shadow: 0 0 0 3px rgba(57,217,138,.12); }
.avcb4-header-actions { flex: 0 0 auto; display: flex; gap: 5px; }
.avcb4-new-chat, .avcb4-close {
  width: 36px;
  height: 36px;
  padding: 0;
  border: 0;
  border-radius: 11px;
  background: rgba(255,255,255,.08);
  color: #fff;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: background .18s ease, transform .18s ease;
}
.avcb4-new-chat:hover, .avcb4-close:hover { background: rgba(255,255,255,.15); transform: translateY(-1px); }
.avcb4-new-chat svg, .avcb4-close svg { width: 19px; height: 19px; fill: currentColor; }

/* Sales tools */
.avcb4-tools {
  flex: 0 0 auto;
  padding: 10px 12px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 7px;
  background: #fff;
  border-bottom: 1px solid var(--avcb4-line);
  overflow: hidden;
}
.avcb4-tool {
  min-width: 0;
  min-height: 42px;
  padding: 7px 5px;
  border: 1px solid #e2e5eb;
  border-radius: 12px;
  background: #fafbfc;
  color: #333947;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  font: inherit;
  font-size: 10.5px;
  font-weight: 740;
  line-height: 1.1;
  cursor: pointer;
  white-space: normal;
  overflow-wrap: anywhere;
  transition: transform .18s ease, border-color .18s ease, background .18s ease;
}
.avcb4-tool svg { width: 15px; height: 15px; flex: 0 0 15px; fill: currentColor; }
.avcb4-tool:hover { transform: translateY(-1px); border-color: #cfd4dd; background: #fff; }
.avcb4-tool-accent { border-color: rgba(225,38,47,.18); background: rgba(225,38,47,.055); color: var(--avcb4-accent); }

/* Quick questions: WRAP, never horizontal scroll */
.avcb4-quick-wrap { flex: 0 0 auto; padding: 10px 12px; background: #fff; border-bottom: 1px solid var(--avcb4-line); overflow: hidden; }
.avcb4-quick-label { display: block; margin: 0 0 7px; font-size: 9px; font-weight: 800; color: #9a9fac; letter-spacing: .08em; text-transform: uppercase; }
.avcb4-quick-actions { width: 100%; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; overflow: hidden !important; }
.avcb4-quick {
  width: 100%;
  min-width: 0;
  min-height: 36px;
  padding: 7px 9px;
  border: 1px solid #e3e6ec;
  border-radius: 11px;
  background: #fafbfc;
  color: #343a47;
  font: inherit;
  font-size: 10.5px;
  font-weight: 660;
  line-height: 1.2;
  text-align: left;
  white-space: normal;
  overflow-wrap: anywhere;
  cursor: pointer;
  transition: border-color .18s ease, background .18s ease, transform .18s ease;
}
.avcb4-quick:hover { border-color: rgba(225,38,47,.34); background: #fff; transform: translateY(-1px); }
.avcb4-quick-compact { padding-top: 7px; padding-bottom: 7px; }
.avcb4-quick-compact .avcb4-quick-label { display: none; }
.avcb4-quick-compact .avcb4-quick-actions { display: flex; flex-wrap: wrap; gap: 5px; overflow: hidden !important; }
.avcb4-quick-compact .avcb4-quick { width: auto; max-width: 48%; flex: 1 1 44%; min-height: 30px; border-radius: 999px; padding: 6px 8px; text-align: center; }

.avcb4-messages {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
  width: 100%;
  padding: 16px 14px 12px;
  overflow-y: auto;
  overflow-x: hidden !important;
  overscroll-behavior: contain;
  overscroll-behavior-x: none;
  touch-action: pan-y;
  background: radial-gradient(circle at 100% 0, rgba(225,38,47,.035), transparent 32%), linear-gradient(180deg, #f8f9fb, #f3f5f8);
  scrollbar-width: thin;
  scrollbar-color: #cfd3dc transparent;
}
.avcb4-messages::-webkit-scrollbar { width: 6px; height: 0; }
.avcb4-messages::-webkit-scrollbar-thumb { background: #cfd3dc; border-radius: 999px; }
.avcb4-message { width: 100%; min-width: 0; display: flex; align-items: flex-end; gap: 8px; margin: 0 0 14px; overflow: visible; }
.avcb4-message.avcb4-user { justify-content: flex-end; }
.avcb4-message-avatar { width: 28px; height: 28px; flex: 0 0 28px; border-radius: 9px; display: grid; place-items: center; overflow: hidden; background: var(--avcb4-primary); color: #fff; font-size: 9px; font-weight: 850; box-shadow: 0 3px 10px rgba(13,17,28,.12); }
.avcb4-message-stack { min-width: 0; width: auto; max-width: min(86%, 345px); display: flex; flex-direction: column; align-items: flex-start; overflow: hidden; }
.avcb4-user .avcb4-message-stack { align-items: flex-end; }
.avcb4-bubble {
  min-width: 0;
  width: fit-content;
  max-width: 100%;
  padding: 11px 13px;
  border: 1px solid #e3e6ec;
  border-radius: 16px 16px 16px 5px;
  background: #fff;
  color: #202633;
  box-shadow: 0 3px 12px rgba(18,24,38,.045);
  font-size: 13px;
  line-height: 1.52;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
  overflow-x: hidden;
}
.avcb4-user .avcb4-bubble { border: 0; border-radius: 16px 16px 5px 16px; background: linear-gradient(135deg, #0b0c10, var(--avcb4-primary)); color: #fff; box-shadow: 0 8px 20px rgba(13,17,28,.13); }
.avcb4-bubble a { color: var(--avcb4-accent); text-decoration: underline; text-underline-offset: 2px; overflow-wrap: anywhere; word-break: break-all; }
.avcb4-user .avcb4-bubble a { color: #fff; }

.avcb4-typing { display: flex; align-items: center; gap: 4px; min-width: 52px; min-height: 39px; }
.avcb4-typing span { width: 6px; height: 6px; border-radius: 50%; background: #a6acb9; animation: avcb4Typing 1.2s infinite ease-in-out; }
.avcb4-typing span:nth-child(2) { animation-delay: .14s; }
.avcb4-typing span:nth-child(3) { animation-delay: .28s; }
@keyframes avcb4Typing { 0%,60%,100% { transform: translateY(0); opacity: .5; } 30% { transform: translateY(-4px); opacity: 1; } }

.avcb4-sources { width: 100%; min-width: 0; margin-top: 7px; display: grid; gap: 6px; overflow: hidden; }
.avcb4-sources-label { margin: 1px 2px 0; font-size: 9px; color: #9298a6; font-weight: 800; text-transform: uppercase; letter-spacing: .065em; }
.avcb4-source-card { width: 100%; min-width: 0; min-height: 50px; padding: 9px 10px; display: flex; align-items: center; justify-content: space-between; gap: 8px; border: 1px solid #e0e4ea; border-radius: 12px; background: rgba(255,255,255,.94); color: #202633 !important; text-decoration: none !important; box-shadow: 0 2px 8px rgba(18,24,38,.035); overflow: hidden; transition: border-color .18s ease, transform .18s ease, box-shadow .18s ease; }
.avcb4-source-card:hover { border-color: rgba(225,38,47,.3); transform: translateY(-1px); box-shadow: 0 5px 13px rgba(18,24,38,.06); }
.avcb4-source-copy { min-width: 0; flex: 1 1 auto; display: flex; flex-direction: column; overflow: hidden; }
.avcb4-source-copy small { color: var(--avcb4-accent); font-size: 8.5px; font-weight: 850; text-transform: uppercase; letter-spacing: .06em; }
.avcb4-source-copy strong { margin-top: 3px; font-size: 11px; line-height: 1.3; white-space: normal; overflow-wrap: anywhere; word-break: break-word; }
.avcb4-source-arrow { flex: 0 0 25px; width: 25px; height: 25px; border-radius: 8px; display: grid; place-items: center; background: #f1f2f5; color: #656c7b; font-size: 12px; }

.avcb4-followups { width: 100%; min-width: 0; display: flex; flex-wrap: wrap; gap: 5px; margin-top: 7px; overflow: hidden; }
.avcb4-followup { max-width: 100%; min-width: 0; border: 1px solid #dce0e7; border-radius: 999px; background: #fff; color: #4b5261; padding: 6px 9px; font: inherit; font-size: 10px; line-height: 1.2; white-space: normal; overflow-wrap: anywhere; cursor: pointer; transition: border-color .18s ease, color .18s ease; }
.avcb4-followup:hover { border-color: var(--avcb4-accent); color: var(--avcb4-accent); }

/* Lead / quotation card */
.avcb4-lead-stack { width: 100%; max-width: calc(100% - 36px); }
.avcb4-lead-card { width: 100%; min-width: 0; padding: 13px; border: 1px solid #dfe3e9; border-radius: 16px 16px 16px 5px; background: #fff; box-shadow: 0 7px 22px rgba(18,24,38,.07); overflow: hidden; }
.avcb4-lead-heading { margin-bottom: 10px; }
.avcb4-lead-heading strong { display: block; font-size: 13px; color: #1d2230; }
.avcb4-lead-heading small { display: block; margin-top: 3px; font-size: 9.5px; color: #8a909e; line-height: 1.35; }
.avcb4-lead-grid { width: 100%; min-width: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; }
.avcb4-lead-field { min-width: 0; display: block; margin-bottom: 7px; }
.avcb4-lead-field > span { display: block; margin: 0 0 4px 1px; font-size: 9px; font-weight: 750; color: #676f7f; }
.avcb4-lead-field input, .avcb4-lead-field textarea {
  width: 100% !important;
  min-width: 0 !important;
  max-width: 100% !important;
  min-height: 36px;
  margin: 0 !important;
  padding: 8px 9px !important;
  border: 1px solid #dfe3e9 !important;
  border-radius: 10px !important;
  background: #f8f9fb !important;
  color: #202633 !important;
  font: inherit !important;
  font-size: 11px !important;
  line-height: 1.3 !important;
  outline: none !important;
  box-shadow: none !important;
  resize: vertical;
  overflow-x: hidden !important;
}
.avcb4-lead-field input:focus, .avcb4-lead-field textarea:focus { border-color: rgba(225,38,47,.45) !important; background: #fff !important; }
.avcb4-consent { min-width: 0; display: flex; align-items: flex-start; gap: 7px; margin: 3px 0 9px; font-size: 9px; line-height: 1.35; color: #6d7482; }
.avcb4-consent input { flex: 0 0 auto; margin-top: 1px; }
.avcb4-consent span { min-width: 0; overflow-wrap: anywhere; }
.avcb4-honeypot { position: absolute !important; left: -99999px !important; width: 1px !important; height: 1px !important; opacity: 0 !important; pointer-events: none !important; }
.avcb4-lead-error { margin: 0 0 8px; padding: 7px 8px; border-radius: 9px; background: #fff3f3; color: #9c252b; font-size: 9.5px; line-height: 1.35; overflow-wrap: anywhere; }
.avcb4-lead-actions { display: flex; justify-content: flex-end; gap: 7px; }
.avcb4-lead-cancel, .avcb4-lead-submit { min-height: 36px; padding: 7px 10px; border-radius: 10px; font: inherit; font-size: 10.5px; font-weight: 750; cursor: pointer; }
.avcb4-lead-cancel { border: 1px solid #dfe3e9; background: #fff; color: #5d6574; }
.avcb4-lead-submit { border: 0; background: var(--avcb4-accent); color: #fff; box-shadow: 0 6px 14px rgba(225,38,47,.2); }
.avcb4-lead-submit:disabled { opacity: .55; cursor: wait; }
.avcb4-inline-whatsapp { display: inline-flex; max-width: 100%; padding: 9px 11px; border: 1px solid #cfe6da; border-radius: 11px; background: #f4fbf7; color: #157448 !important; font-size: 11px; font-weight: 750; text-decoration: none !important; overflow-wrap: anywhere; }

.avcb4-footer { flex: 0 0 auto; width: 100%; min-width: 0; padding: 9px 11px 10px; background: #fff; border-top: 1px solid var(--avcb4-line); overflow: hidden; }
.avcb4-whatsapp { width: 100%; min-height: 36px; margin: 0 0 7px; border: 1px solid #dfe3e9; border-radius: 11px; background: #fbfcfd; color: #176e47 !important; display: flex; align-items: center; justify-content: center; gap: 7px; font-size: 10.5px; font-weight: 740; text-decoration: none !important; transition: background .18s ease, border-color .18s ease; }
.avcb4-whatsapp:hover { background: #f4fbf7; border-color: #cde8d8; }
.avcb4-whatsapp svg { width: 16px; height: 16px; fill: #1f9d62; }
.avcb4-form { width: 100%; min-width: 0; display: flex; align-items: flex-end; gap: 7px; overflow: hidden; }
.avcb4-input { flex: 1 1 auto; width: 1%; min-width: 0 !important; max-width: 100% !important; min-height: 44px; max-height: 112px; resize: none; overflow-y: auto; overflow-x: hidden !important; border: 1px solid #dce0e7 !important; border-radius: 14px !important; background: #f8f9fb !important; color: #202633 !important; padding: 11px 12px !important; font: inherit !important; font-size: 12.5px !important; line-height: 1.4 !important; outline: none !important; box-shadow: none !important; }
.avcb4-input::placeholder { color: #9aa0ad; }
.avcb4-input:focus { border-color: rgba(225,38,47,.4) !important; background: #fff !important; box-shadow: 0 0 0 3px rgba(225,38,47,.07) !important; }
.avcb4-send { width: 44px; height: 44px; flex: 0 0 44px; padding: 0; border: 0; border-radius: 14px; background: linear-gradient(135deg, var(--avcb4-accent), #a80e1b); color: #fff; display: grid; place-items: center; cursor: pointer; box-shadow: 0 8px 18px rgba(225,38,47,.22); transition: transform .18s ease, box-shadow .18s ease, opacity .18s ease; }
.avcb4-send:hover { transform: translateY(-1px); box-shadow: 0 10px 22px rgba(225,38,47,.28); }
.avcb4-send:disabled { opacity: .45; cursor: wait; transform: none; box-shadow: none; }
.avcb4-send svg { width: 19px; height: 19px; fill: currentColor; }
.avcb4-note { margin-top: 6px; text-align: center; font-size: 8.5px; line-height: 1.3; color: #9a9fad; overflow-wrap: anywhere; }

@media (max-width: 600px) {
  .avcb4-agent { right: 12px; bottom: calc(12px + env(safe-area-inset-bottom)); max-width: calc(100vw - 24px); }
  .avcb4-launcher { width: 62px; min-height: 62px; height: 62px; padding: 7px; border-radius: 19px; }
  .avcb4-launcher-icon { width: 48px; height: 48px; flex-basis: 48px; }
  .avcb4-launcher-copy, .avcb4-launcher-arrow { display: none; }
  .avcb4-panel {
    position: fixed;
    left: 8px;
    right: 8px;
    bottom: calc(82px + env(safe-area-inset-bottom));
    width: auto;
    max-width: none;
    height: min(78svh, 680px);
    min-height: 470px;
    border-radius: 22px;
    transform-origin: bottom center;
  }
  .avcb4-header { min-height: 72px; padding: 11px 11px 11px 13px; }
  .avcb4-tools { padding: 8px 9px; gap: 5px; }
  .avcb4-tool { min-height: 39px; font-size: 9.5px; }
  .avcb4-quick-wrap { padding: 8px 9px; }
  .avcb4-quick { font-size: 9.5px; }
  .avcb4-messages { padding-left: 10px; padding-right: 10px; }
  .avcb4-message-stack { max-width: 87%; }
  .avcb4-lead-stack { max-width: calc(100% - 34px); }
}

@media (max-width: 390px) {
  .avcb4-brand-copy small { font-size: 9px; }
  .avcb4-avatar-large { width: 41px; height: 41px; flex-basis: 41px; }
  .avcb4-new-chat, .avcb4-close { width: 32px; height: 32px; }
  .avcb4-tools { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .avcb4-tool svg { display: none; }
  .avcb4-quick-actions { grid-template-columns: 1fr 1fr; }
  .avcb4-quick-compact .avcb4-quick { flex-basis: 47%; max-width: 48%; }
  .avcb4-lead-grid { grid-template-columns: 1fr; gap: 0; }
  .avcb4-message-stack { max-width: 89%; }
}

@media (max-width: 340px) {
  .avcb4-panel { left: 5px; right: 5px; }
  .avcb4-brand-copy small { display: none; }
  .avcb4-quick-actions { grid-template-columns: 1fr; }
  .avcb4-quick-compact .avcb4-quick { flex: 1 1 100%; max-width: 100%; }
}

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