.cw-root {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 999999;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: #1a1a1a;
}

.cw-root *,
.cw-root *::before,
.cw-root *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* Floating button */
.cw-fab {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: #2563eb;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.4);
  transition: background 0.2s, transform 0.2s, box-shadow 0.2s;
}

.cw-fab:hover {
  background: #1d4ed8;
  transform: scale(1.05);
  box-shadow: 0 6px 20px rgba(37, 99, 235, 0.5);
}

.cw-fab svg {
  width: 24px;
  height: 24px;
  fill: #fff;
  transition: transform 0.3s;
}

.cw-fab.cw-open svg {
  transform: rotate(90deg);
}

/* Chat panel */
.cw-panel {
  position: absolute;
  bottom: 72px;
  right: 0;
  width: 380px;
  max-width: calc(100vw - 32px);
  height: 520px;
  max-height: calc(100vh - 120px);
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.18);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(12px) scale(0.95);
  pointer-events: none;
  transition: opacity 0.25s, transform 0.25s;
}

.cw-panel.cw-visible {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* Header */
.cw-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  background: #2563eb;
  color: #fff;
  font-weight: 600;
  font-size: 15px;
}

.cw-header-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #4ade80;
  flex-shrink: 0;
}

.cw-header-spacer {
  flex: 1;
}

.cw-header-close {
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  transition: background 0.15s;
}

.cw-header-close:hover {
  background: rgba(255, 255, 255, 0.15);
}

.cw-header-close svg {
  width: 18px;
  height: 18px;
  fill: #fff;
}

/* Messages */
.cw-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
}

.cw-msg {
  max-width: 80%;
  padding: 10px 14px;
  border-radius: 12px;
  word-wrap: break-word;
}

.cw-msg-user {
  align-self: flex-end;
  background: #2563eb;
  color: #fff;
  border-bottom-right-radius: 4px;
}

.cw-msg-bot {
  align-self: flex-start;
  background: #f1f5f9;
  color: #1a1a1a;
  border-bottom-left-radius: 4px;
}

.cw-msg-bot .cw-md-pre {
  background: #1e293b;
  color: #e2e8f0;
  padding: 12px;
  border-radius: 8px;
  overflow-x: auto;
  margin: 8px 0;
  font-size: 13px;
}

.cw-msg-bot .cw-md-code {
  background: #e2e8f0;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 13px;
}

.cw-msg-bot .cw-md-pre code {
  background: none;
  padding: 0;
}

.cw-msg-bot .cw-md-list {
  margin: 8px 0;
  padding-left: 20px;
}

.cw-msg-bot .cw-md-list li {
  margin: 4px 0;
}

.cw-msg-bot .cw-md-h {
  margin: 12px 0 8px;
  font-weight: 600;
}

.cw-msg-bot a {
  color: #2563eb;
  text-decoration: underline;
}

.cw-msg-bot strong {
  font-weight: 600;
}

.cw-msg-bot em {
  font-style: italic;
}

.cw-msg-bot.cw-typing::after {
  content: '';
  display: inline-block;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: #94a3b8;
  margin-left: 4px;
  animation: cw-blink 1s infinite;
}

@keyframes cw-blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

/* Input area */
.cw-input-area {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid #e2e8f0;
  background: #fff;
}

.cw-input {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  font-size: 14px;
  font-family: inherit;
  outline: none;
  resize: none;
  transition: border-color 0.15s;
  min-height: 42px;
  max-height: 100px;
  line-height: 1.4;
}

.cw-input:focus {
  border-color: #2563eb;
}

.cw-send {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  background: #2563eb;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, opacity 0.15s;
  flex-shrink: 0;
}

.cw-send:hover {
  background: #1d4ed8;
}

.cw-send:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.cw-send svg {
  width: 18px;
  height: 18px;
  fill: #fff;
}

/* Scrollbar */
.cw-messages::-webkit-scrollbar {
  width: 5px;
}

.cw-messages::-webkit-scrollbar-track {
  background: transparent;
}

.cw-messages::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 4px;
}
