.bd-chat {
  bottom: max(1rem, env(safe-area-inset-bottom));
  color: #172033;
  font-family: inherit;
  position: fixed;
  right: max(1rem, env(safe-area-inset-right));
  z-index: 1080;
}

.bd-chat-toggle {
  align-items: center;
  background: #123766;
  border: 0;
  border-radius: 999px;
  box-shadow: 0 10px 30px rgba(18, 55, 102, 0.28);
  color: #fff;
  display: inline-flex;
  font-weight: 700;
  gap: 0.55rem;
  min-height: 3rem;
  padding: 0 1.1rem;
}

.bd-chat-toggle:hover,
.bd-chat-toggle:focus-visible {
  background: #0d2b52;
  outline: 3px solid rgba(47, 141, 244, 0.25);
}

.bd-chat-panel {
  background: #fff;
  border: 1px solid rgba(23, 32, 51, 0.12);
  border-radius: 8px;
  bottom: 4rem;
  box-shadow: 0 18px 48px rgba(15, 23, 42, 0.22);
  display: flex;
  flex-direction: column;
  max-height: min(640px, calc(100vh - 6rem));
  overflow: hidden;
  position: absolute;
  right: 0;
  width: min(380px, calc(100vw - 2rem));
}

.bd-chat-header {
  align-items: center;
  background: #f8fafc;
  border-bottom: 1px solid #e5e7eb;
  display: flex;
  justify-content: space-between;
  padding: 0.85rem 0.95rem;
}

.bd-chat-title {
  font-size: 0.98rem;
  font-weight: 800;
}

.bd-chat-subtitle {
  color: #64748b;
  font-size: 0.82rem;
}

.bd-chat-close {
  align-items: center;
  background: transparent;
  border: 0;
  border-radius: 6px;
  color: #475569;
  display: inline-flex;
  height: 2rem;
  justify-content: center;
  width: 2rem;
}

.bd-chat-close:hover,
.bd-chat-close:focus-visible {
  background: #e5e7eb;
  outline: none;
}

.bd-chat-messages {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  gap: 0.7rem;
  min-height: 190px;
  overflow-y: auto;
  padding: 0.9rem;
}

.bd-chat-message {
  display: flex;
  flex-direction: column;
  max-width: 88%;
}

.bd-chat-message--user {
  align-self: flex-end;
}

.bd-chat-message--assistant {
  align-self: flex-start;
}

.bd-chat-bubble {
  border-radius: 8px;
  font-size: 0.92rem;
  line-height: 1.4;
  padding: 0.65rem 0.75rem;
  white-space: pre-wrap;
}

.bd-chat-message--user .bd-chat-bubble {
  background: #123766;
  color: #fff;
}

.bd-chat-message--assistant .bd-chat-bubble {
  background: #eef2f7;
  color: #172033;
}

.bd-chat-sources {
  color: #64748b;
  font-size: 0.76rem;
  margin-top: 0.35rem;
}

.bd-chat-prompts {
  border-top: 1px solid #eef2f7;
  display: flex;
  gap: 0.45rem;
  overflow-x: auto;
  padding: 0.65rem 0.85rem;
}

.bd-chat-prompt {
  background: #fff;
  border: 1px solid #d7dee8;
  border-radius: 999px;
  color: #334155;
  flex: 0 0 auto;
  font-size: 0.78rem;
  padding: 0.35rem 0.6rem;
}

.bd-chat-prompt:hover,
.bd-chat-prompt:focus-visible {
  border-color: #2f8df4;
  outline: none;
}

.bd-chat-form {
  align-items: flex-end;
  border-top: 1px solid #e5e7eb;
  display: flex;
  gap: 0.55rem;
  padding: 0.75rem;
}

.bd-chat-input {
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  flex: 1 1 auto;
  font: inherit;
  line-height: 1.35;
  max-height: 7rem;
  min-height: 2.5rem;
  padding: 0.55rem 0.65rem;
  resize: vertical;
}

.bd-chat-input:focus {
  border-color: #2f8df4;
  box-shadow: 0 0 0 3px rgba(47, 141, 244, 0.16);
  outline: none;
}

.bd-chat-send {
  align-items: center;
  background: #2f8df4;
  border: 0;
  border-radius: 8px;
  color: #fff;
  display: inline-flex;
  flex: 0 0 auto;
  height: 2.5rem;
  justify-content: center;
  width: 2.5rem;
}

.bd-chat-send:disabled {
  cursor: wait;
  opacity: 0.65;
}

@media (max-width: 575.98px) {
  .bd-chat {
    left: 0.75rem;
    right: 0.75rem;
  }

  .bd-chat-toggle {
    justify-content: center;
    width: 100%;
  }

  .bd-chat-panel {
    bottom: 4rem;
    left: 0;
    right: 0;
    width: 100%;
  }
}
