:root {
  --dw-chat-bg: #ffffff;
  --dw-chat-border: #d7dde3;
  --dw-chat-shadow: rgba(14, 24, 39, 0.18);
  --dw-chat-accent: #2463a6;
  --dw-chat-accent-strong: #1c4c7c;
  --dw-chat-text: #0f1b2d;
  --dw-chat-muted: #5d6b7c;
  --dw-chat-user: #e9f0f9;
  --dw-chat-assistant: #f6f7f9;
}

html[data-theme="dark"],
html.theme--documenter-dark,
html.theme--catppuccin-mocha,
html.theme--catppuccin-macchiato,
html.theme--catppuccin-frappe,
html.dark {
  --dw-chat-bg: #121821;
  --dw-chat-border: #2a3340;
  --dw-chat-shadow: rgba(0, 0, 0, 0.45);
  --dw-chat-accent: #5aa0f0;
  --dw-chat-accent-strong: #7bb3f3;
  --dw-chat-text: #e6eef8;
  --dw-chat-muted: #a2b3c6;
  --dw-chat-user: #1a2432;
  --dw-chat-assistant: #1f2a39;
}

.dw-chat {
  position: static;
  z-index: 2000;
  font-family: inherit;
  color: var(--dw-chat-text);
}

.dw-chat * {
  box-sizing: border-box;
}

.dw-toggle {
  border: 1px solid var(--dw-chat-border);
  background: var(--dw-chat-bg);
  color: var(--dw-chat-text);
  font-weight: 600;
  padding: 0.6rem 1rem;
  border-radius: 999px;
  box-shadow: 0 10px 26px var(--dw-chat-shadow);
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.dw-toggle:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 30px var(--dw-chat-shadow);
  border-color: var(--dw-chat-accent);
}

.dw-chat.dw-floating {
  position: fixed;
  right: 1.25rem;
  bottom: 1.25rem;
}

.dw-panel {
  display: none;
  width: 340px;
  max-width: calc(100vw - 2.5rem);
  height: 420px;
  background: var(--dw-chat-bg);
  border: 1px solid var(--dw-chat-border);
  border-radius: 16px;
  box-shadow: 0 14px 40px var(--dw-chat-shadow);
  overflow: hidden;
}

.dw-chat.dw-open .dw-panel {
  display: flex;
  flex-direction: column;
}

.dw-chat.dw-open .dw-toggle {
  display: none;
}

.dw-chat.dw-embedded .dw-panel,
.dw-chat.dw-inline .dw-panel {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: auto;
  max-width: none;
}

.dw-chat.dw-embedded {
  margin-top: 0.75rem;
}

.docs-sidebar .dw-panel {
  border-radius: 8px;
  box-shadow: none;
}

.docs-sidebar .dw-header {
  padding: 0.6rem 0.75rem;
  background: transparent;
}

.docs-sidebar .dw-messages {
  padding: 0.6rem 0.7rem;
}

.docs-sidebar .dw-input {
  padding: 0.6rem 0.7rem 0.7rem;
}

.docs-sidebar .dw-send {
  font-size: 0.8rem;
  padding: 0.4rem 0.8rem;
}

.dw-chat.dw-embedded .dw-toggle,
.dw-chat.dw-inline .dw-toggle,
.dw-chat.dw-embedded .dw-close,
.dw-chat.dw-inline .dw-close {
  display: none;
}

.dw-chat.dw-embedded .dw-messages,
.dw-chat.dw-inline .dw-messages {
  max-height: 240px;
}

.dw-chat.dw-inline {
  margin: 0 0 1.5rem;
}

.dw-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1rem 0.7rem;
  border-bottom: 1px solid var(--dw-chat-border);
  background: linear-gradient(135deg, rgba(36, 99, 166, 0.08), rgba(36, 99, 166, 0));
  font-weight: 600;
}

.dw-title {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.dw-subtitle {
  font-size: 0.78rem;
  color: var(--dw-chat-muted);
  font-weight: 500;
}

.dw-close {
  border: none;
  background: transparent;
  color: var(--dw-chat-muted);
  font-size: 1.1rem;
  cursor: pointer;
  padding: 0.2rem 0.4rem;
}

.dw-messages {
  flex: 1;
  overflow-y: auto;
  padding: 0.8rem 0.9rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.dw-msg {
  padding: 0.6rem 0.7rem;
  border-radius: 12px;
  font-size: 0.9rem;
  line-height: 1.35;
  white-space: pre-wrap;
}

.dw-msg.dw-user {
  align-self: flex-end;
  background: var(--dw-chat-user);
  border: 1px solid rgba(36, 99, 166, 0.12);
}

.dw-msg.dw-assistant {
  align-self: flex-start;
  background: var(--dw-chat-assistant);
  border: 1px solid rgba(93, 107, 124, 0.2);
}

.dw-input {
  border-top: 1px solid var(--dw-chat-border);
  padding: 0.7rem 0.8rem 0.8rem;
  display: grid;
  gap: 0.5rem;
}

.dw-input textarea {
  width: 100%;
  min-height: 64px;
  max-height: 120px;
  resize: vertical;
  border-radius: 10px;
  border: 1px solid var(--dw-chat-border);
  padding: 0.5rem 0.6rem;
  font-family: inherit;
  font-size: 0.9rem;
  color: var(--dw-chat-text);
  background: transparent;
}

.dw-input textarea:focus {
  outline: 2px solid rgba(36, 99, 166, 0.35);
  border-color: var(--dw-chat-accent);
}

.dw-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.dw-status {
  font-size: 0.75rem;
  color: var(--dw-chat-muted);
}

.dw-send {
  border: none;
  background: var(--dw-chat-accent);
  color: #fff;
  font-weight: 600;
  padding: 0.45rem 0.9rem;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.2s ease;
}

.dw-send:disabled {
  background: #9bb9d8;
  cursor: not-allowed;
}

.dw-send:hover:not(:disabled) {
  background: var(--dw-chat-accent-strong);
  transform: translateY(-1px);
}

@media (max-width: 720px) {
  .dw-chat.dw-floating {
    right: 0.9rem;
    bottom: 0.9rem;
  }

  .dw-chat.dw-floating .dw-panel {
    width: min(94vw, 360px);
    height: 58vh;
  }
}
