#avw-fab {
  position: fixed;
  right: 24px;
  bottom: 24px;
  width: 64px;
  height: 64px;
  border: none;
  cursor: pointer;
  z-index: 9999;
  padding: 0;
  overflow: visible;
  box-shadow: none;
  transition: transform 0.2s ease;
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
}

#avw-fab:hover {
  transform: scale(1.08);
}

#avw-fab img {
  position: relative;
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

#avw-fab.active img {
  display: none;
}

#avw-fab.active::after {
  content: '\2715';
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
  color: #fff;
  font-size: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
}

#avw-panel {
  display: none;
  position: fixed;
  right: 24px;
  bottom: 100px;
  width: 368px;
  max-height: 540px;
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid rgba(124, 58, 237, 0.14);
  border-radius: 20px;
  z-index: 9998;
  box-shadow: 0 18px 48px rgba(76, 29, 149, 0.22);
  overflow: hidden;
  font-family: "Segoe UI", "Helvetica Neue", sans-serif;
  flex-direction: column;
  backdrop-filter: blur(20px);
}

[data-theme="dark"] #avw-panel {
  background: rgba(22, 15, 38, 0.95);
  border-color: rgba(196, 181, 253, 0.12);
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.45);
}

#avw-panel.show {
  display: flex;
  animation: avwSlideUp 0.25s ease-out;
}

@keyframes avwSlideUp {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.avw-header {
  background: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 48%, #6d28d9 100%);
  color: white;
  padding: 15px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

[data-theme="dark"] .avw-header {
  background: linear-gradient(135deg, #7c3aed 0%, #6d28d9 48%, #4c1d95 100%);
}

.avw-header-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.avw-header-logo-wrap {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.16);
  display: flex;
  align-items: center;
  justify-content: center;
}

.avw-header-logo-wrap img {
  width: 28px;
  height: 28px;
  object-fit: contain;
  display: block;
}

.avw-header-text h3 {
  margin: 0;
  font-size: 0.98rem;
  line-height: 1.2;
}

.avw-header-text p {
  margin: 2px 0 0;
  font-size: 0.76rem;
  color: rgba(255, 255, 255, 0.82);
}

.avw-header-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.avw-timer {
  font-size: 0.74rem;
  font-variant-numeric: tabular-nums;
  color: rgba(255, 255, 255, 0.85);
}

#avw-mic-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  display: none;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

#avw-mic-btn.on {
  background: rgba(255, 255, 255, 0.2);
  color: white;
}

#avw-mic-btn.off {
  background: rgba(239, 68, 68, 0.18);
  color: #fee2e2;
}

.avw-body {
  padding: 22px 20px;
  text-align: center;
}

.avw-body p {
  margin: 0 0 16px;
  color: #6b6480;
  font-size: 0.9rem;
}

[data-theme="dark"] .avw-body p {
  color: #b8afcf;
}

#avw-turnstile {
  display: flex;
  justify-content: center;
  margin-bottom: 16px;
}

#avw-call-btn {
  width: 100%;
  border: none;
  border-radius: 999px;
  cursor: pointer;
  padding: 13px 18px;
  color: white;
  font-weight: 700;
  background: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 48%, #6d28d9 100%);
}

#avw-call-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.avw-connecting {
  display: none;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 24px;
  color: #7c3aed;
  font-size: 0.92rem;
}

[data-theme="dark"] .avw-connecting {
  color: #c4b5fd;
}

.avw-connecting.show {
  display: flex;
}

.avw-spinner {
  width: 20px;
  height: 20px;
  border: 2px solid rgba(124, 58, 237, 0.16);
  border-top-color: #7c3aed;
  border-radius: 50%;
  animation: avwSpin 0.8s linear infinite;
}

@keyframes avwSpin {
  to {
    transform: rotate(360deg);
  }
}

#avw-chat {
  display: none;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

#avw-chat.show {
  display: flex;
}

#avw-messages {
  flex: 1;
  min-height: 0;
  max-height: 320px;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background:
    radial-gradient(circle at top left, rgba(139, 92, 246, 0.06), transparent 30%),
    transparent;
}

.avw-msg {
  max-width: 86%;
  padding: 9px 12px;
  border-radius: 14px;
  font-size: 0.86rem;
  line-height: 1.42;
  word-wrap: break-word;
}

.avw-msg.ai {
  align-self: flex-start;
  background: rgba(124, 58, 237, 0.1);
  color: #1f1537;
  border-bottom-left-radius: 5px;
}

.avw-msg.user {
  align-self: flex-end;
  background: rgba(139, 92, 246, 0.16);
  color: #1f1537;
  border-bottom-right-radius: 5px;
}

.avw-msg.system {
  align-self: center;
  color: #7b728f;
  font-size: 0.75rem;
  font-style: italic;
  padding: 4px 8px;
}

[data-theme="dark"] .avw-msg.ai {
  background: rgba(124, 58, 237, 0.18);
  color: #f5f3ff;
}

[data-theme="dark"] .avw-msg.user {
  background: rgba(168, 85, 247, 0.22);
  color: #f5f3ff;
}

[data-theme="dark"] .avw-msg.system {
  color: #b8afcf;
}

.avw-msg-label {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 2px;
  color: #7c3aed;
}

[data-theme="dark"] .avw-msg-label {
  color: #d8b4fe;
}

.avw-msg.streaming::after {
  content: '\25CF';
  animation: avwBlink 1s infinite;
  margin-left: 4px;
  color: #8b5cf6;
}

@keyframes avwBlink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

.avw-input-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid rgba(124, 58, 237, 0.12);
}

#avw-text-input {
  flex: 1;
  border-radius: 999px;
  border: 1px solid rgba(124, 58, 237, 0.16);
  background: rgba(124, 58, 237, 0.04);
  color: #1f1537;
  padding: 10px 14px;
  outline: none;
  font-size: 0.86rem;
}

[data-theme="dark"] #avw-text-input {
  background: rgba(124, 58, 237, 0.12);
  color: #f5f3ff;
  border-color: rgba(196, 181, 253, 0.14);
}

#avw-send-btn {
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  color: white;
  background: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 48%, #6d28d9 100%);
}

#avw-controls-bar {
  display: flex;
  justify-content: center;
  gap: 8px;
  padding: 10px 12px 14px;
  border-top: 1px solid rgba(124, 58, 237, 0.12);
}

#avw-stop-btn,
#avw-end-btn {
  border: none;
  border-radius: 999px;
  cursor: pointer;
  color: white;
  font-weight: 700;
  padding: 8px 18px;
}

#avw-stop-btn {
  background: #f59e0b;
}

#avw-end-btn {
  background: #ef4444;
}

@media (max-width: 420px) {
  #avw-panel {
    left: 10px;
    right: 10px;
    width: auto;
    bottom: 92px;
    max-height: 72vh;
  }

  #avw-fab {
    right: 16px;
    bottom: 16px;
  }
}
