.chatbot-root {
  position: fixed;
  z-index: 60;
  left: 1rem;
  bottom: 1rem;
  font-family: var(--font);
}

.chatbot-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  border: none;
  border-radius: 999px;
  padding: 0.85rem 1.1rem;
  background: linear-gradient(180deg, var(--gold-soft), var(--gold));
  color: #1A1405;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.35);
  transition: transform 160ms ease, filter 160ms ease;
}

.chatbot-toggle:hover {
  filter: brightness(1.05);
}

.chatbot-toggle:active {
  transform: translateY(1px);
}

.chatbot-toggle svg {
  flex-shrink: 0;
}

.chatbot-panel {
  display: none;
  width: min(380px, calc(100vw - 1.5rem));
  height: min(560px, calc(100vh - 6rem));
  margin-bottom: 0.75rem;
  border-radius: 16px;
  border: 1px solid rgba(201, 162, 39, 0.35);
  background: rgba(7, 21, 40, 0.96);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.45);
  overflow: hidden;
  flex-direction: column;
}

.chatbot-root.is-open .chatbot-panel {
  display: flex;
  animation: fadeIn 180ms ease;
}

.chatbot-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.9rem 1rem;
  border-bottom: 1px solid rgba(232, 212, 139, 0.2);
  background: rgba(18, 42, 74, 0.85);
}

.chatbot-header strong {
  display: block;
  color: var(--gold-soft);
  font-size: 0.95rem;
}

.chatbot-header small {
  color: var(--muted);
  font-size: 0.78rem;
}

.chatbot-close {
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 1.3rem;
  line-height: 1;
  cursor: pointer;
  padding: 0.15rem 0.35rem;
}

.chatbot-messages {
  flex: 1;
  overflow-y: auto;
  padding: 0.9rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.chat-bubble {
  max-width: 88%;
  padding: 0.7rem 0.85rem;
  border-radius: 12px;
  font-size: 0.9rem;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
}

.chat-assistant {
  align-self: flex-start;
  background: rgba(18, 42, 74, 0.95);
  border: 1px solid rgba(168, 179, 197, 0.25);
  color: var(--text);
  border-bottom-right-radius: 4px;
}

.chat-user {
  align-self: flex-end;
  background: rgba(201, 162, 39, 0.18);
  border: 1px solid rgba(201, 162, 39, 0.4);
  color: var(--gold-soft);
  border-bottom-left-radius: 4px;
}

.chatbot-form {
  display: flex;
  gap: 0.5rem;
  padding: 0.75rem;
  border-top: 1px solid rgba(232, 212, 139, 0.18);
  background: rgba(7, 21, 40, 0.95);
}

.chatbot-input {
  flex: 1;
  min-width: 0;
  border-radius: 10px;
  border: 1px solid rgba(168, 179, 197, 0.3);
  background: var(--bg-deep);
  color: var(--text);
  font: inherit;
  padding: 0.7rem 0.8rem;
}

.chatbot-send {
  border: none;
  border-radius: 10px;
  background: var(--gold);
  color: #1A1405;
  font: inherit;
  font-weight: 700;
  padding: 0.7rem 0.9rem;
  cursor: pointer;
  min-width: 4.2rem;
}

.chatbot-send:disabled,
.chatbot-input:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

.chatbot-status {
  padding: 0 0.9rem 0.55rem;
  color: var(--muted);
  font-size: 0.75rem;
}

.chatbot-root.has-capture .chatbot-status {
  color: #9BE7C3;
}

.chatbot-root.is-busy .chatbot-toggle {
  opacity: 0.9;
}

@media (max-width: 640px) {
  .chatbot-root {
    left: 0.65rem;
    right: 0.65rem;
    bottom: 0.65rem;
  }

  .chatbot-panel {
    width: 100%;
    height: min(70vh, 560px);
  }

  .chatbot-toggle {
    width: auto;
    max-width: 100%;
    justify-content: center;
    padding: 0.7rem 0.95rem;
    font-size: 0.88rem;
  }

  /* Avoid overlap with request form sticky bar */
  body:has(.submit-bar) .chatbot-root {
    bottom: 5.5rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .chatbot-root.is-open .chatbot-panel {
    animation: none;
  }
}
