#dwars-chatbot-root {
  --dwars-chat-purple: #4b2a7f;
  --dwars-chat-purple-dark: #35205a;
  --dwars-chat-bg: #ffffff;
  --dwars-chat-border: #e4e0eb;
  position: relative;
  z-index: 1090;
}

.dwars-chat-toggle {
  position: fixed;
  right: 22px;
  bottom: 22px;
  width: 62px;
  height: 62px;
  border-radius: 50%;
  border: 0;
  background: var(--dwars-chat-purple);
  color: #fff;
  box-shadow: 0 14px 38px rgba(35, 22, 57, .28);
  font-size: 1.55rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform .15s ease, box-shadow .15s ease;
}

.dwars-chat-toggle:hover,
.dwars-chat-toggle:focus-visible {
  transform: translateY(-2px);
  box-shadow: 0 17px 42px rgba(35, 22, 57, .34);
}

.dwars-chat-toggle-label {
  position: absolute;
  right: 72px;
  white-space: nowrap;
  background: #fff;
  color: #302a38;
  border: 1px solid var(--dwars-chat-border);
  border-radius: 999px;
  padding: .45rem .75rem;
  font-size: .8rem;
  font-weight: 700;
  box-shadow: 0 6px 20px rgba(35, 22, 57, .12);
}

.dwars-chat-panel {
  position: fixed;
  right: 22px;
  bottom: 96px;
  width: min(410px, calc(100vw - 32px));
  height: min(660px, calc(100vh - 128px));
  background: var(--dwars-chat-bg);
  border: 1px solid var(--dwars-chat-border);
  border-radius: 20px;
  box-shadow: 0 22px 68px rgba(35, 22, 57, .28);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.dwars-chat-panel[hidden] { display: none !important; }

.dwars-chat-header {
  background: linear-gradient(135deg, var(--dwars-chat-purple), var(--dwars-chat-purple-dark));
  color: #fff;
  padding: 1rem 1rem .9rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.dwars-chat-title { font-weight: 800; line-height: 1.15; }
.dwars-chat-subtitle { font-size: .76rem; opacity: .82; margin-top: .2rem; }
.dwars-chat-close {
  border: 0;
  background: rgba(255,255,255,.14);
  color: #fff;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  font-size: 1.25rem;
  line-height: 1;
}

.dwars-chat-messages {
  flex: 1;
  overflow-y: auto;
  background: #f8f7fa;
  padding: 1rem;
  scroll-behavior: smooth;
}

.dwars-chat-row { display: flex; margin-bottom: .75rem; }
.dwars-chat-row.user { justify-content: flex-end; }
.dwars-chat-row.assistant { justify-content: flex-start; }

.dwars-chat-bubble {
  max-width: 88%;
  padding: .7rem .82rem;
  border-radius: 15px;
  line-height: 1.42;
  font-size: .91rem;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.dwars-chat-row.user .dwars-chat-bubble {
  background: var(--dwars-chat-purple);
  color: #fff;
  border-bottom-right-radius: 5px;
}

.dwars-chat-row.assistant .dwars-chat-bubble {
  background: #fff;
  color: #2f2936;
  border: 1px solid #e7e3ec;
  border-bottom-left-radius: 5px;
}

.dwars-chat-meta {
  font-size: .69rem;
  color: #81798b;
  margin: .22rem .25rem 0;
}

.dwars-chat-actions,
.dwars-chat-sources,
.dwars-chat-quick {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem;
  margin-top: .55rem;
}

.dwars-chat-action,
.dwars-chat-source,
.dwars-chat-chip {
  border-radius: 999px;
  padding: .36rem .64rem;
  font-size: .75rem;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
}

.dwars-chat-action {
  border: 1px solid var(--dwars-chat-purple);
  background: var(--dwars-chat-purple);
  color: #fff;
}

.dwars-chat-action.secondary,
.dwars-chat-source,
.dwars-chat-chip {
  border: 1px solid #d8d0e4;
  background: #fff;
  color: var(--dwars-chat-purple);
}

.dwars-chat-action:disabled { opacity: .55; cursor: wait; }
.dwars-chat-source:hover,
.dwars-chat-chip:hover,
.dwars-chat-action.secondary:hover { background: #f0ebf7; color: var(--dwars-chat-purple-dark); }

.dwars-chat-composer {
  border-top: 1px solid var(--dwars-chat-border);
  padding: .72rem;
  background: #fff;
}

.dwars-chat-form { display: flex; gap: .5rem; align-items: flex-end; }
.dwars-chat-input {
  flex: 1;
  resize: none;
  min-height: 42px;
  max-height: 120px;
  border: 1px solid #d9d4df;
  border-radius: 12px;
  padding: .63rem .72rem;
  line-height: 1.3;
  font-size: .9rem;
  outline: none;
}
.dwars-chat-input:focus { border-color: var(--dwars-chat-purple); box-shadow: 0 0 0 3px rgba(75,42,127,.12); }
.dwars-chat-send {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  border: 0;
  background: var(--dwars-chat-purple);
  color: #fff;
  font-size: 1.05rem;
}
.dwars-chat-send:disabled { opacity: .5; cursor: wait; }
.dwars-chat-note { font-size: .68rem; color: #81798b; margin-top: .42rem; text-align: center; }
.dwars-chat-typing { display: inline-flex; gap: .22rem; align-items: center; }
.dwars-chat-typing span { width: 5px; height: 5px; background: #887d93; border-radius: 50%; animation: dwars-chat-pulse 1.1s infinite ease-in-out; }
.dwars-chat-typing span:nth-child(2) { animation-delay: .15s; }
.dwars-chat-typing span:nth-child(3) { animation-delay: .3s; }
@keyframes dwars-chat-pulse { 0%, 60%, 100% { opacity: .35; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-2px); } }

@media (max-width: 575.98px) {
  .dwars-chat-toggle { right: 16px; bottom: 16px; }
  .dwars-chat-toggle-label { display: none; }
  .dwars-chat-panel {
    inset: 10px 10px 86px 10px;
    width: auto;
    height: auto;
    border-radius: 16px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .dwars-chat-toggle, .dwars-chat-messages { transition: none; scroll-behavior: auto; }
  .dwars-chat-typing span { animation: none; }
}

.dwars-chat-feedback {
  margin-top: .65rem;
  padding: .65rem .7rem;
  border: 1px solid #e1dbe9;
  border-radius: 12px;
  background: #fbfafe;
  max-width: 340px;
}

.dwars-chat-feedback-label {
  display: block;
  font-size: .72rem;
  font-weight: 700;
  color: #62596c;
  margin-bottom: .4rem;
}

.dwars-chat-feedback-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem;
  align-items: center;
}

.dwars-chat-feedback-button {
  border: 1px solid #d7cfe2;
  border-radius: 999px;
  padding: .34rem .58rem;
  background: #fff;
  color: var(--dwars-chat-purple);
  font-size: .72rem;
  font-weight: 700;
  cursor: pointer;
}

.dwars-chat-feedback-button:hover { background: #f0ebf7; }
.dwars-chat-feedback-button.negative { border-color: #e4c8cb; color: #9c3039; }
.dwars-chat-feedback-button.secondary { color: #6e6677; }
.dwars-chat-feedback-button:disabled { opacity: .55; cursor: wait; }
.dwars-chat-feedback-detail { margin-top: .15rem; }
.dwars-chat-feedback-note {
  width: 100%;
  resize: vertical;
  min-height: 72px;
  max-height: 150px;
  border: 1px solid #d9d4df;
  border-radius: 10px;
  padding: .55rem .62rem;
  font: inherit;
  font-size: .78rem;
  margin-bottom: .5rem;
}
.dwars-chat-feedback-note:focus { outline: none; border-color: var(--dwars-chat-purple); box-shadow: 0 0 0 3px rgba(75,42,127,.1); }
.dwars-chat-feedback-thanks { font-size: .73rem; color: #4f6f42; font-weight: 700; }
.dwars-chat-feedback-error { margin-top: .45rem; font-size: .72rem; color: #a12631; }
