.lw-ai-chatbot {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 9999;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  --lw-panel-bg: #ffffff;
  --lw-header-bg: #f9fafb;
  --lw-header-text: #111827;
  --lw-fab-bg: #111827;
  --lw-fab-text: #ffffff;
  --lw-send-bg: #111827;
  --lw-send-text: #ffffff;
  --lw-bubble-fade: .35s;
}

.lw-ai-fab {
  background: var(--lw-fab-bg);
  color: var(--lw-fab-text);
  border-radius: 999px;
  border: 0;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, .2);
  cursor: pointer;
  transition: transform .2s ease, box-shadow .2s ease, background .2s ease;
}

.lw-ai-fab:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 28px rgba(0, 0, 0, .26);
}

.lw-ai-fab-icon {
  width: 20px;
  height: 20px;
  fill: currentColor;
  opacity: .9;
}

.lw-ai-panel {
  position: fixed;
  right: 16px;
  bottom: 76px;
  width: 360px;
  max-height: 65vh;
  background: var(--lw-panel-bg);
  border-radius: 14px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, .22);
  display: none;
  overflow: hidden;
  border: 1px solid rgba(17, 24, 39, .08);
  color: #111827;
}

.lw-ai-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  background: var(--lw-header-bg);
  border-bottom: 1px solid rgba(17, 24, 39, .08);
  color: var(--lw-header-text);
  gap: 12px;
}

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

.lw-ai-header strong {
  color: inherit;
  font-size: 15px;
}

.lw-ai-sub {
  display: block;
  color: rgba(107, 114, 128, .95);
  font-size: 12px;
  margin-top: 2px;
}

.lw-ai-header-copy {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.lw-ai-header-copy strong,
.lw-ai-header-copy .lw-ai-sub {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lw-ai-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  overflow: hidden;
  background: rgba(148, 163, 184, .25);
  flex-shrink: 0;
}

.lw-ai-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.lw-ai-close {
  background: transparent;
  border: 0;
  font-size: 20px;
  cursor: pointer;
  color: var(--lw-header-text);
  opacity: .7;
  transition: opacity .2s ease;
}

.lw-ai-close:hover {
  opacity: 1;
}

.lw-ai-suggestions {
  padding: 8px 12px 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  border-top: 1px solid rgba(17, 24, 39, .05);
  background: var(--lw-panel-bg);
}

.lw-ai-suggestion-btn {
  border: 1px solid rgba(17, 24, 39, .12);
  background: rgba(17, 24, 39, .04);
  color: #111827;
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 13px;
  cursor: pointer;
  transition: background .2s ease, border-color .2s ease, color .2s ease, transform .2s ease;
}

.lw-ai-suggestion-btn:hover {
  background: rgba(17, 24, 39, .08);
  border-color: rgba(17, 24, 39, .2);
  transform: translateY(-1px);
}

.lw-ai-messages {
  padding: 12px;
  overflow-y: auto;
  max-height: calc(65vh - 120px);
}

.lw-ai-msg {
  margin: 8px 0;
  line-height: 1.35;
  font-size: 14px;
}

.lw-ai-msg.user {
  text-align: right;
}

.lw-ai-bubble {
  display: inline-block;
  padding: 8px 10px;
  border-radius: 12px;
  max-width: 80%;
  white-space: pre-wrap;
  overflow-wrap: break-word;
}

.lw-ai-msg.bot .lw-ai-bubble ul {
  list-style: disc;
  margin: 6px 0;
  padding-left: 20px;
}

.lw-ai-msg.bot .lw-ai-bubble ol {
  list-style: decimal;
  margin: 6px 0;
  padding-left: 20px;
}

.lw-ai-msg.bot .lw-ai-bubble li + li {
  margin-top: 4px;
}

.lw-ai-msg.user .lw-ai-bubble {
  background: var(--lw-user-bg, #111827);
  color: var(--lw-user-text, #ffffff);
  border-bottom-right-radius: 4px;
}

.lw-ai-msg.bot .lw-ai-bubble {
  background: var(--lw-bot-bg, #f3f4f6);
  color: var(--lw-bot-text, #111827);
  border-bottom-left-radius: 4px;
}

.lw-ai-bubble--stream,
.lw-ai-bubble--streaming {
  transition: opacity .2s ease;
}

.lw-ai-form {
  display: flex;
  gap: 8px;
  padding: 10px;
  border-top: 1px solid rgba(17, 24, 39, .08);
}

.lw-ai-form input {
  flex: 1;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid #d1d5db;
  font-size: 14px;
}

.lw-ai-form button {
  background: var(--lw-send-bg);
  color: var(--lw-send-text);
  border: 0;
  border-radius: 10px;
  padding: 0 12px;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  position: relative;
  transition: transform .2s ease, box-shadow .2s ease, background .2s ease;
}

.lw-ai-form button:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 18px rgba(0, 0, 0, .18);
}

.lw-ai-send-body {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: opacity .2s ease;
}

.lw-ai-send-label {
  font-size: 14px;
  font-weight: 600;
}

.lw-ai-send-icon {
  font-size: 18px;
  line-height: 1;
}

.lw-ai-form button.is-busy {
  cursor: wait;
}

.lw-ai-form button.is-busy .lw-ai-send-body {
  opacity: 0;
}

.lw-ai-form button.is-busy::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 16px;
  height: 16px;
  margin: -8px 0 0 -8px;
  border-radius: 50%;
  border: 2px solid currentColor;
  border-top-color: transparent;
  animation: lwAiSpin .8s linear infinite;
}

.lw-ai-form button:disabled {
  pointer-events: none;
  opacity: .75;
}

.lw-ai-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  background: var(--lw-header-bg);
  border-top: 1px solid rgba(17, 24, 39, .08);
  font-size: 12px;
  color: rgba(107, 114, 128, .95);
}

.lw-ai-reset {
  background: transparent;
  border: 0;
  color: #ef4444;
  cursor: pointer;
}

.lw-ai-reset:hover {
  text-decoration: underline;
}

.lw-ai-typing {
  font-size: 12px;
  color: #6b7280;
  margin: 0 0 6px 4px;
}

.lw-ai-typing--dots {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.lw-ai-typing--dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  opacity: .35;
  animation: lwAiDot 1s ease-in-out infinite;
}

.lw-ai-typing--dots span:nth-child(2) {
  animation-delay: .15s;
}

.lw-ai-typing--dots span:nth-child(3) {
  animation-delay: .3s;
}

.lw-ai-bubble--anim {
  animation: lwAiBubbleIn var(--lw-bubble-fade, .35s) ease both;
}

@keyframes lwAiSpin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

@keyframes lwAiDot {
  0%, 80%, 100% { opacity: .35; transform: scale(1); }
  40% { opacity: 1; transform: scale(1.35); }
}

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

@media (max-width: 480px) {
  .lw-ai-panel {
    width: calc(100vw - 24px);
    right: 12px;
    bottom: 90px;
  }
}
