#adsmash-chatbot-root {
  --adsmash-chat-color: #5468ff;
  --adsmash-chat-color-2: #7b8cff;
  --adsmash-chat-color-3: #3d4fe0;
  --adsmash-surface: #0b0b0f;
  --adsmash-surface-2: #14141a;
  --adsmash-border: rgba(255, 255, 255, 0.1);
  --adsmash-text: #f5f5f7;
  --adsmash-muted: #9a9aa3;
  --adsmash-safe-right: max(16px, env(safe-area-inset-right));
  --adsmash-safe-bottom: max(16px, env(safe-area-inset-bottom));
  position: fixed;
  right: var(--adsmash-safe-right);
  bottom: var(--adsmash-safe-bottom);
  z-index: 2147483000;
  font-family: Inter, "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

#adsmash-chatbot-toggle {
  position: relative;
  width: 62px;
  height: 62px;
  border: 0;
  border-radius: 50%;
  padding: 0;
  overflow: hidden;
  cursor: pointer;
  color: #fff;
  background:
    radial-gradient(circle at 30% 25%, rgba(255, 255, 255, 0.55), transparent 38%),
    linear-gradient(160deg, var(--adsmash-chat-color-2) 0%, var(--adsmash-chat-color) 48%, var(--adsmash-chat-color-3) 100%);
  box-shadow:
    0 16px 30px rgba(84, 104, 255, 0.42),
    0 6px 12px rgba(0, 0, 0, 0.35),
    inset 0 2px 2px rgba(255, 255, 255, 0.55),
    inset 0 -7px 12px rgba(0, 0, 0, 0.28);
  transition: transform 0.18s ease, box-shadow 0.18s ease;
  animation: adsmash-float 2.8s ease-in-out infinite;
}

#adsmash-chatbot-toggle::before {
  content: "";
  position: absolute;
  inset: -5px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(84, 104, 255, 0.4), transparent 68%);
  z-index: -1;
  pointer-events: none;
  animation: adsmash-pulse 2.5s ease-out infinite;
}

#adsmash-chatbot-toggle:hover,
#adsmash-chatbot-toggle:focus-visible {
  transform: translateY(-2px) scale(1.04);
  outline: none;
}

#adsmash-chatbot-toggle:active {
  transform: translateY(1px) scale(0.97);
}

#adsmash-chatbot-toggle .adsmash-chatbot-icon {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
}

#adsmash-chatbot-toggle .adsmash-chatbot-icon svg {
  width: 28px;
  height: 28px;
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.22));
}

/* Never show a second icon under the bubble */
#adsmash-chatbot-toggle .adsmash-chatbot-toggle-close,
#adsmash-chatbot-root.is-open #adsmash-chatbot-toggle {
  display: none !important;
}

#adsmash-chatbot-panel {
  position: absolute;
  right: 0;
  bottom: 78px;
  width: min(380px, calc(100vw - 28px));
  height: min(560px, calc(100dvh - 110px));
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-radius: 22px;
  border: 1px solid var(--adsmash-border);
  background:
    linear-gradient(180deg, rgba(84, 104, 255, 0.12), transparent 24%),
    var(--adsmash-surface);
  color: var(--adsmash-text);
  box-shadow:
    0 28px 60px rgba(0, 0, 0, 0.55),
    0 2px 0 rgba(255, 255, 255, 0.06) inset;
  transform-origin: bottom right;
  animation: adsmash-pop 0.22s ease-out;
}

#adsmash-chatbot-panel[hidden] {
  display: none !important;
}

.adsmash-chatbot-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 14px 14px 16px;
  background: linear-gradient(135deg, #1a1f3d 0%, #12121a 60%, #0b0b0f 100%);
  border-bottom: 1px solid var(--adsmash-border);
  flex: 0 0 auto;
}

.adsmash-chatbot-header-main {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.adsmash-chatbot-avatar {
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  color: #fff;
  background:
    radial-gradient(circle at 30% 25%, rgba(255, 255, 255, 0.45), transparent 42%),
    linear-gradient(145deg, var(--adsmash-chat-color-2), var(--adsmash-chat-color));
  box-shadow:
    0 8px 16px rgba(84, 104, 255, 0.35),
    inset 0 1px 1px rgba(255, 255, 255, 0.45);
}

.adsmash-chatbot-avatar svg {
  width: 22px;
  height: 22px;
}

.adsmash-chatbot-header strong {
  display: block;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.2;
}

.adsmash-chatbot-header span {
  display: block;
  margin-top: 3px;
  font-size: 11px;
  color: var(--adsmash-muted);
}

.adsmash-chatbot-online {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.adsmash-chatbot-online::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.18);
}

#adsmash-chatbot-close {
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}

#adsmash-chatbot-messages {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding: 16px;
  background:
    radial-gradient(circle at top right, rgba(84, 104, 255, 0.1), transparent 40%),
    var(--adsmash-surface-2);
}

.adsmash-msg {
  max-width: 88%;
  margin-bottom: 10px;
  padding: 11px 13px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.18);
}

.adsmash-msg--bot {
  background: #232330;
  border: 1px solid var(--adsmash-border);
  color: #f3f3f3;
  border-bottom-left-radius: 5px;
}

.adsmash-msg--user {
  margin-left: auto;
  color: #fff;
  background: linear-gradient(145deg, var(--adsmash-chat-color-2), var(--adsmash-chat-color));
  border-bottom-right-radius: 5px;
  box-shadow:
    0 8px 18px rgba(84, 104, 255, 0.28),
    inset 0 1px 0 rgba(255, 255, 255, 0.25);
}

.adsmash-msg--typing {
  opacity: 0.75;
  font-style: italic;
}

.adsmash-chatbot-composer,
.adsmash-chatbot-lead {
  display: flex;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid var(--adsmash-border);
  background: #0d0d12;
  flex: 0 0 auto;
}

.adsmash-chatbot-composer {
  align-items: center;
}

.adsmash-chatbot-composer input {
  flex: 1;
  min-width: 0;
  min-height: 44px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  padding: 10px 14px;
  font-size: 16px;
  color: #fff;
  background: #1a1a22;
  outline: none;
}

.adsmash-chatbot-composer input::placeholder {
  color: #888;
}

.adsmash-chatbot-composer input:focus {
  border-color: rgba(84, 104, 255, 0.7);
  box-shadow: 0 0 0 3px rgba(84, 104, 255, 0.18);
}

.adsmash-chatbot-composer button,
.adsmash-chatbot-lead button {
  border: 0;
  border-radius: 999px;
  min-height: 44px;
  padding: 10px 14px;
  background: linear-gradient(145deg, var(--adsmash-chat-color-2), var(--adsmash-chat-color));
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  box-shadow:
    0 8px 16px rgba(84, 104, 255, 0.28),
    inset 0 1px 0 rgba(255, 255, 255, 0.28);
}

#adsmash-chatbot-lead-open {
  background: #22222c;
  color: #fff;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.adsmash-chatbot-lead {
  flex-direction: column;
}

.adsmash-chatbot-lead[hidden],
.adsmash-chatbot-composer[hidden] {
  display: none !important;
}

.adsmash-chatbot-lead-title {
  margin: 0 0 4px;
  font-size: 13px;
  font-weight: 700;
  color: #fff;
}

.adsmash-chatbot-lead input,
.adsmash-chatbot-lead textarea {
  width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  padding: 12px;
  font-size: 16px;
  font-family: inherit;
  color: #fff;
  background: #1a1a22;
  box-sizing: border-box;
}

.adsmash-chatbot-lead-actions {
  display: flex;
  gap: 8px;
}

.adsmash-chatbot-lead-actions button {
  flex: 1;
}

.adsmash-chatbot-lead-actions button[type="button"] {
  background: #22222c;
  color: #fff;
  box-shadow: none;
}

.adsmash-chatbot-lead-status {
  margin: 0;
  font-size: 13px;
  color: var(--adsmash-muted);
}

.adsmash-chatbot-credit {
  margin: 0;
  padding: 0 12px 10px;
  font-size: 10px;
  color: #666;
  text-align: center;
  background: #0d0d12;
  flex: 0 0 auto;
}

@keyframes adsmash-float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}

@keyframes adsmash-pulse {
  0% { transform: scale(0.92); opacity: 0.7; }
  70% { transform: scale(1.25); opacity: 0; }
  100% { transform: scale(1.25); opacity: 0; }
}

@keyframes adsmash-pop {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Mobile: full usable area + keyboard-safe layout */
@media (max-width: 640px) {
  #adsmash-chatbot-root {
    right: max(14px, env(safe-area-inset-right));
    bottom: max(14px, env(safe-area-inset-bottom));
  }

  #adsmash-chatbot-toggle {
    width: 58px;
    height: 58px;
  }

  #adsmash-chatbot-panel {
    position: fixed;
    left: max(10px, env(safe-area-inset-left));
    right: max(10px, env(safe-area-inset-right));
    top: max(10px, env(safe-area-inset-top));
    bottom: calc(78px + env(safe-area-inset-bottom));
    width: auto;
    height: auto;
    border-radius: 18px;
  }

  /* When open, panel fills visual viewport (JS sets --vv* vars) */
  #adsmash-chatbot-root.is-open #adsmash-chatbot-panel {
    left: max(8px, env(safe-area-inset-left));
    right: max(8px, env(safe-area-inset-right));
    top: var(--adsmash-vv-top, max(8px, env(safe-area-inset-top)));
    bottom: var(--adsmash-vv-bottom, 8px);
    width: auto;
    height: auto;
    max-height: none;
    border-radius: 16px;
  }

  #adsmash-chatbot-root.is-open.is-typing #adsmash-chatbot-panel {
    border-radius: 14px;
  }

  .adsmash-chatbot-composer {
    padding-bottom: 12px;
  }

  .adsmash-msg {
    font-size: 15px;
  }

  /* Slimmer chrome while typing so input + text stay visible */
  #adsmash-chatbot-root.is-typing .adsmash-chatbot-credit {
    display: none;
  }

  #adsmash-chatbot-root.is-typing .adsmash-chatbot-header {
    padding: 10px 12px;
  }

  #adsmash-chatbot-root.is-typing .adsmash-chatbot-avatar {
    width: 34px;
    height: 34px;
    border-radius: 10px;
  }
}

@media (prefers-reduced-motion: reduce) {
  #adsmash-chatbot-toggle,
  #adsmash-chatbot-toggle::before,
  #adsmash-chatbot-panel {
    animation: none !important;
  }
}
