.baqaw-widget {
  --baqaw-primary: #1f7a68;
  --baqaw-text: #17211f;
  --baqaw-border: #d8e0dc;
  --baqaw-surface: #ffffff;
  --baqaw-muted: #f2f6f4;
  bottom: 22px;
  color: var(--baqaw-text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  position: fixed;
  right: 22px;
  z-index: 2147483647;
}

.baqaw-toggle {
  align-items: center;
  background: var(--baqaw-primary);
  border: 0;
  border-radius: 999px;
  box-shadow: 0 12px 28px rgba(18, 32, 29, 0.22);
  color: #fff;
  cursor: pointer;
  display: flex;
  font-size: 28px;
  overflow: visible;
  font-weight: 700;
  height: 58px;
  justify-content: center;
  line-height: 1;
  position: relative;
  transition: transform 180ms ease, box-shadow 180ms ease, background-color 180ms ease;
  width: 58px;
}

.baqaw-toggle:hover,
.baqaw-toggle:focus-visible {
  box-shadow: 0 16px 34px rgba(18, 32, 29, 0.28);
  transform: translateY(-2px) scale(1.03);
}

.baqaw-toggle:active {
  transform: translateY(0) scale(0.98);
}

.baqaw-toggle-icon {
  position: relative;
  z-index: 1;
}

.baqaw-toggle-pulse {
  animation: baqaw-pulse 2.4s ease-out infinite;
  border: 2px solid color-mix(in srgb, var(--baqaw-primary) 55%, #fff);
  border-radius: inherit;
  inset: -5px;
  opacity: 0.45;
  position: absolute;
}

.baqaw-widget.is-open .baqaw-toggle-pulse {
  animation: none;
  opacity: 0;
}

.baqaw-panel {
  background: var(--baqaw-surface);
  border: 1px solid var(--baqaw-border);
  border-radius: 8px;
  bottom: 76px;
  box-shadow: 0 18px 48px rgba(18, 32, 29, 0.22);
  display: flex;
  flex-direction: column;
  max-height: min(620px, calc(100vh - 118px));
  opacity: 0;
  overflow: hidden;
  pointer-events: none;
  position: absolute;
  right: 0;
  transform: translateY(12px) scale(0.98);
  transform-origin: bottom right;
  transition: opacity 180ms ease, transform 180ms ease, visibility 180ms ease;
  visibility: hidden;
  width: min(372px, calc(100vw - 32px));
}

.baqaw-widget.is-open .baqaw-panel {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0) scale(1);
  visibility: visible;
}

.baqaw-header {
  align-items: center;
  background: var(--baqaw-primary);
  color: #fff;
  display: flex;
  gap: 12px;
  justify-content: space-between;
  min-height: 52px;
  padding: 12px 14px;
}

.baqaw-header strong {
  flex: 1;
  font-size: 16px;
  font-weight: 700;
  line-height: 1.25;
  min-width: 0;
}

.baqaw-header-actions {
  align-items: center;
  display: flex;
  flex: 0 0 auto;
  gap: 8px;
}

.baqaw-refresh,
.baqaw-close {
  align-items: center;
  background: rgba(255, 255, 255, 0.16);
  border: 0;
  border-radius: 999px;
  color: #fff;
  cursor: pointer;
  display: flex;
  font-size: 18px;
  height: 30px;
  justify-content: center;
  line-height: 1;
  transition: background-color 160ms ease, transform 160ms ease;
  width: 30px;
}

.baqaw-refresh:hover,
.baqaw-close:hover,
.baqaw-refresh:focus-visible,
.baqaw-close:focus-visible {
  background: rgba(255, 255, 255, 0.26);
  transform: translateY(-1px);
}

.baqaw-refresh:active,
.baqaw-close:active {
  transform: translateY(0) scale(0.96);
}

.baqaw-refresh:hover {
  transform: rotate(90deg);
}

.baqaw-messages {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 10px;
  min-height: 260px;
  overflow-y: auto;
  padding: 14px;
}

.baqaw-message {
  border-radius: 8px;
  font-size: 14px;
  line-height: 1.45;
  max-width: 86%;
  padding: 10px 12px;
  white-space: pre-wrap;
  animation: baqaw-message-in 180ms ease both;
}

.baqaw-message-agent {
  align-self: flex-start;
  background: var(--baqaw-muted);
}

.baqaw-message-user {
  align-self: flex-end;
  background: var(--baqaw-primary);
  color: #fff;
}

.baqaw-loading {
  align-items: center;
  display: inline-flex;
  gap: 5px;
  min-height: 38px;
  min-width: 58px;
}

.baqaw-loading span {
  animation: baqaw-typing 1s ease-in-out infinite;
  background: color-mix(in srgb, var(--baqaw-primary) 58%, #71817b);
  border-radius: 999px;
  display: block;
  height: 7px;
  opacity: 0.45;
  width: 7px;
}

.baqaw-loading span:nth-child(2) {
  animation-delay: 120ms;
}

.baqaw-loading span:nth-child(3) {
  animation-delay: 240ms;
}

.baqaw-form {
  border-top: 1px solid var(--baqaw-border);
  display: grid;
  gap: 10px;
  grid-template-columns: 1fr auto;
  padding: 12px;
}

.baqaw-input {
  border: 1px solid var(--baqaw-border);
  border-radius: 8px;
  box-shadow: none;
  color: var(--baqaw-text);
  font: inherit;
  min-height: 46px;
  padding: 10px 11px;
  resize: none;
  transition: border-color 160ms ease, box-shadow 160ms ease, background-color 160ms ease;
  width: 100%;
}

.baqaw-input:focus {
  border-color: var(--baqaw-primary);
  outline: 2px solid color-mix(in srgb, var(--baqaw-primary) 24%, transparent);
}

.baqaw-send {
  align-self: end;
  background: var(--baqaw-primary);
  border: 0;
  border-radius: 8px;
  color: #fff;
  cursor: pointer;
  font: inherit;
  font-weight: 700;
  min-height: 46px;
  padding: 0 16px;
  transition: filter 160ms ease, transform 160ms ease, opacity 160ms ease;
}

.baqaw-send:hover,
.baqaw-send:focus-visible {
  filter: brightness(1.05);
  transform: translateY(-1px);
}

.baqaw-send:active {
  transform: translateY(0) scale(0.98);
}

.baqaw-send:disabled,
.baqaw-input:disabled {
  cursor: wait;
  opacity: 0.7;
}

.baqaw-send:disabled {
  position: relative;
}

.baqaw-send:disabled::after {
  animation: baqaw-spin 760ms linear infinite;
  border: 2px solid rgba(255, 255, 255, 0.48);
  border-top-color: #fff;
  border-radius: 999px;
  content: "";
  display: inline-block;
  height: 12px;
  margin-left: 8px;
  vertical-align: -2px;
  width: 12px;
}

@keyframes baqaw-pulse {
  0% {
    opacity: 0.44;
    transform: scale(0.92);
  }

  70%,
  100% {
    opacity: 0;
    transform: scale(1.35);
  }
}

@keyframes baqaw-message-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes baqaw-typing {
  0%,
  80%,
  100% {
    opacity: 0.35;
    transform: translateY(0);
  }

  40% {
    opacity: 1;
    transform: translateY(-4px);
  }
}

@keyframes baqaw-spin {
  to {
    transform: rotate(360deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  .baqaw-toggle,
  .baqaw-toggle-pulse,
  .baqaw-panel,
  .baqaw-message,
  .baqaw-loading span,
  .baqaw-send:disabled::after {
    animation: none;
    transition: none;
  }
}

@media (max-width: 480px) {
  .baqaw-widget {
    bottom: 14px;
    right: 14px;
  }

  .baqaw-panel {
    bottom: 72px;
    max-height: calc(100vh - 100px);
    width: calc(100vw - 28px);
  }
}
