#ah-chat-bubble {
  position: fixed;
  bottom: 28px;
  right: 28px;
  z-index: 9990;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  border: 1px solid rgba(79, 110, 247, 0.35);
  background: linear-gradient(135deg, #4f6ef7 0%, #7c5cfa 100%);
  box-shadow: 0 8px 32px rgba(79, 110, 247, 0.45), 0 2px 8px rgba(0,0,0,0.5);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s cubic-bezier(.34,1.56,.64,1), box-shadow 0.2s ease;
  outline: none;
  padding: 0;
}

#ah-chat-bubble:hover {
  transform: scale(1.08);
  box-shadow: 0 12px 40px rgba(79, 110, 247, 0.6), 0 2px 8px rgba(0,0,0,0.5);
}

#ah-chat-bubble.ah-active {
  transform: scale(0.95) rotate(5deg);
}

.ah-bubble-icon svg {
  width: 26px;
  height: 26px;
  color: #fff;
  display: block;
}

.ah-bubble-ping {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #e05252;
  border: 2px solid #0a0b0f;
  display: none;
  z-index: 1;
}

.ah-bubble-ping.ah-ping-active {
  display: block;
  animation: ah-ping-pulse 1.4s ease-in-out infinite;
}

@keyframes ah-ping-pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50%       { transform: scale(1.3); opacity: 0.7; }
}

#ah-chat-win {
  position: fixed;
  bottom: 100px;
  right: 28px;
  z-index: 9991;
  width: 380px;
  max-width: calc(100vw - 40px);
  height: 560px;
  max-height: calc(100vh - 120px);
  border-radius: 20px;
  background: #131620;
  border: 1px solid rgba(255,255,255,0.08);
  box-shadow:
    0 24px 64px rgba(0,0,0,0.7),
    0 0 0 1px rgba(79,110,247,0.12),
    inset 0 1px 0 rgba(255,255,255,0.06);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(18px) scale(0.96);
  pointer-events: none;
  transition:
    opacity 0.28s cubic-bezier(.4,0,.2,1),
    transform 0.28s cubic-bezier(.34,1.56,.64,1);
  font-family: "Inter", system-ui, sans-serif;
}

#ah-chat-win.ah-open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: all;
}

.ah-chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: linear-gradient(135deg, rgba(79,110,247,0.15) 0%, rgba(124,92,250,0.1) 100%);
  border-bottom: 1px solid rgba(255,255,255,0.07);
  backdrop-filter: blur(10px);
  flex-shrink: 0;
}

.ah-chat-header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.ah-chat-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: linear-gradient(135deg, #4f6ef7, #7c5cfa);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(79,110,247,0.4);
}

.ah-chat-avatar svg {
  width: 20px;
  height: 20px;
  color: #fff;
}

.ah-chat-header-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.ah-chat-header-name {
  font-size: 14px;
  font-weight: 600;
  color: #e8eaf0;
  letter-spacing: -0.01em;
}

.ah-chat-header-status {
  font-size: 11px;
  color: #8b91a8;
  display: flex;
  align-items: center;
  gap: 5px;
}

.ah-status-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #4ade80;
  box-shadow: 0 0 6px rgba(74,222,128,0.6);
  animation: ah-status-pulse 2.5s ease-in-out infinite;
}

.ah-status-dot.ah-status-human {
  background: #4f6ef7;
  box-shadow: 0 0 6px rgba(79,110,247,0.6);
}

@keyframes ah-status-pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.5; }
}

.ah-chat-close {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.08);
  background: rgba(255,255,255,0.05);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: #8b91a8;
  transition: background 0.15s, color 0.15s;
  padding: 0;
  flex-shrink: 0;
}

.ah-chat-close:hover {
  background: rgba(255,255,255,0.1);
  color: #e8eaf0;
}

.ah-chat-close svg { width: 14px; height: 14px; }

.ah-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
}

.ah-chat-messages::-webkit-scrollbar { width: 4px; }
.ah-chat-messages::-webkit-scrollbar-track { background: transparent; }
.ah-chat-messages::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.1);
  border-radius: 4px;
}

.ah-msg {
  display: flex;
  gap: 8px;
  max-width: 100%;
  animation: ah-msg-in 0.22s cubic-bezier(.4,0,.2,1);
}

@keyframes ah-msg-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.ah-msg-user {
  justify-content: flex-end;
}

.ah-msg-user .ah-msg-bubble {
  background: linear-gradient(135deg, #4f6ef7 0%, #7c5cfa 100%);
  color: #fff;
  border-radius: 18px 18px 4px 18px;
  box-shadow: 0 4px 16px rgba(79,110,247,0.3);
  font-size: 13.5px;
  line-height: 1.55;
  max-width: 78%;
  padding: 10px 14px;
}

.ah-msg-ai {
  align-items: flex-start;
}

.ah-msg-ai .ah-msg-bubble {
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.08);
  color: #e8eaf0;
  border-radius: 18px 18px 18px 4px;
  font-size: 13.5px;
  line-height: 1.6;
  max-width: 82%;
  padding: 10px 14px;
}

.ah-msg-ai .ah-msg-bubble a {
  color: #7b93ff;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.ah-msg-staff {
  align-items: flex-start;
}

.ah-msg-staff .ah-msg-bubble {
  background: rgba(79,110,247,0.08);
  border: 1px solid rgba(79,110,247,0.2);
  color: #e8eaf0;
  border-radius: 18px 18px 18px 4px;
  font-size: 13.5px;
  line-height: 1.6;
  max-width: 82%;
  padding: 10px 14px;
}

.ah-msg-content {
  display: flex;
  flex-direction: column;
  gap: 3px;
  max-width: 82%;
}

.ah-msg-author {
  font-size: 11px;
  color: #8b91a8;
  display: flex;
  align-items: center;
  gap: 5px;
  padding-left: 2px;
}

.ah-msg-badge {
  font-size: 9px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: linear-gradient(135deg, #4f6ef7, #7c5cfa);
  color: #fff;
  padding: 1px 5px;
  border-radius: 99px;
}

.ah-msg-avatar-wrap { flex-shrink: 0; }

.ah-msg-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}

.ah-msg-avatar-ai {
  background: linear-gradient(135deg, #4f6ef7, #7c5cfa);
  font-size: 9px;
  letter-spacing: 0.02em;
}

.ah-msg-avatar-staff {
  background: transparent !important;
  border: 1px solid rgba(79,110,247,0.3);
  overflow: hidden;
  padding: 0;
  display: flex !important;
  align-items: center;
  justify-content: center;
}

.ah-msg-avatar-staff img {
  width: 100% !important;
  height: 100% !important;
  object-fit: cover !important;
  display: block !important;
}

.ah-msg-system {
  text-align: center;
  font-size: 11.5px;
  color: #555d7a;
  padding: 4px 0;
  font-style: italic;
}

.ah-msg-bubble-escalate p {
  margin: 0 0 10px;
}

.ah-escalate-btns {
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin-top: 4px;
}

.ah-btn-human,
.ah-btn-close-chat {
  width: 100%;
  padding: 9px 12px;
  border-radius: 10px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
  text-align: center;
  border: none;
}

.ah-btn-human {
  background: linear-gradient(135deg, #4f6ef7 0%, #7c5cfa 100%);
  color: #fff;
  box-shadow: 0 4px 14px rgba(79,110,247,0.35);
}

.ah-btn-human:hover {
  box-shadow: 0 6px 20px rgba(79,110,247,0.5);
  transform: translateY(-1px);
}

.ah-btn-close-chat {
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.1) !important;
  color: #8b91a8;
}

.ah-btn-close-chat:hover {
  background: rgba(255,255,255,0.09);
  color: #e8eaf0;
}

.ah-typing-indicator .ah-msg-bubble {
  padding: 12px 16px;
  display: flex;
  gap: 4px;
  align-items: center;
}

.ah-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #8b91a8;
  animation: ah-bounce 1.2s infinite ease-in-out;
  display: inline-block;
}

.ah-dot:nth-child(1) { animation-delay: 0s; }
.ah-dot:nth-child(2) { animation-delay: 0.2s; }
.ah-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes ah-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
  30%            { transform: translateY(-5px); opacity: 1; }
}

.ah-chat-input-area {
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 10px 14px 12px;
  border-top: 1px solid rgba(255,255,255,0.06);
  background: rgba(10,11,15,0.6);
  flex-shrink: 0;
  backdrop-filter: blur(10px);
}

#ah-chat-input {
  flex: 1;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 12px;
  color: #e8eaf0;
  font-family: "Inter", system-ui, sans-serif;
  font-size: 13.5px;
  line-height: 1.5;
  padding: 9px 13px;
  resize: none;
  outline: none;
  transition: border-color 0.15s, background 0.15s;
  min-height: 38px;
  max-height: 120px;
}

#ah-chat-input::placeholder { color: #555d7a; }

#ah-chat-input:focus {
  border-color: rgba(79,110,247,0.4);
  background: rgba(79,110,247,0.05);
}

#ah-chat-input:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

#ah-chat-send {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, #4f6ef7 0%, #7c5cfa 100%);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform 0.15s, box-shadow 0.15s, opacity 0.15s;
  box-shadow: 0 4px 14px rgba(79,110,247,0.35);
  padding: 0;
}

#ah-chat-send:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 20px rgba(79,110,247,0.5);
}

#ah-chat-send:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}

#ah-chat-send svg { width: 16px; height: 16px; }

.ah-chat-closed-banner {
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 16px 20px;
  border-top: 1px solid rgba(255,255,255,0.06);
  background: rgba(10,11,15,0.6);
  flex-shrink: 0;
  text-align: center;
}

.ah-chat-closed-banner p {
  font-size: 13px;
  color: #8b91a8;
  margin: 0;
}

#ah-new-conv {
  background: linear-gradient(135deg, #4f6ef7 0%, #7c5cfa 100%);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 8px 20px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: box-shadow 0.15s, transform 0.15s;
  box-shadow: 0 4px 14px rgba(79,110,247,0.35);
}

#ah-new-conv:hover {
  box-shadow: 0 6px 20px rgba(79,110,247,0.5);
  transform: translateY(-1px);
}

.ah-msg-bubble strong { color: #fff; font-weight: 600; }
.ah-msg-bubble em     { color: #b0b8d4; font-style: italic; }

@media (max-width: 480px) {
  #ah-chat-win {
    bottom: 0;
    right: 0;
    width: 100vw;
    max-width: 100vw;
    height: 100dvh;
    max-height: 100dvh;
    border-radius: 0;
  }

  #ah-chat-bubble {
    bottom: 20px;
    right: 16px;
  }
}

.ah-notif-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 20px;
  height: 20px;
  border-radius: 99px;
  background: #e05252;
  border: 2px solid #0a0b0f;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  font-family: "Inter", system-ui, sans-serif;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  z-index: 2;
  animation: ah-badge-pop 0.25s cubic-bezier(.34,1.56,.64,1);
  line-height: 1;
}

@keyframes ah-badge-pop {
  from { transform: scale(0.4); opacity: 0; }
  to   { transform: scale(1);   opacity: 1; }
}

.ah-input-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  width: 100%;
}

.ah-btn-human-bubble {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  padding: 7px 12px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 600;
  font-family: "Inter", system-ui, sans-serif;
  cursor: pointer;
  border: 1px solid rgba(79, 110, 247, 0.3);
  background: rgba(79, 110, 247, 0.08);
  color: #7b93ff;
  transition: all 0.18s ease;
  margin-top: 6px;
  letter-spacing: 0.01em;
}

.ah-btn-human-bubble:hover {
  background: rgba(79, 110, 247, 0.18);
  border-color: rgba(79, 110, 247, 0.55);
  color: #a4b8ff;
  transform: translateY(-1px);
}

.ah-btn-human-bubble:active {
  transform: translateY(0);
  background: rgba(79, 110, 247, 0.22);
}

.ah-btn-human-bubble svg {
  flex-shrink: 0;
  opacity: 0.85;
}
