#cw-wrapper {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.4;
}

/* ── Toggle button ── */
#cw-toggle {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: #1a1a2e;
  color: #ffffff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.28);
  transition: transform 0.15s ease, background 0.15s ease;
}

#cw-toggle:hover {
  transform: scale(1.07);
  background: #16213e;
}

#cw-toggle svg {
  width: 26px;
  height: 26px;
  pointer-events: none;
}

/* ── Chat panel ── */
#cw-panel {
  position: absolute;
  bottom: 68px;
  right: 0;
  width: 340px;
  background: #ffffff;
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.18);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: cw-slide-in 0.18s ease;
}

#cw-panel[hidden] {
  display: none;
}

@keyframes cw-slide-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Header ── */
#cw-header {
  background: #1a1a2e;
  color: #ffffff;
  padding: 13px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

#cw-title {
  font-weight: 600;
  font-size: 15px;
}

#cw-close {
  background: none;
  border: none;
  color: #ffffff;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  padding: 0 2px;
  opacity: 0.75;
  transition: opacity 0.1s;
}

#cw-close:hover {
  opacity: 1;
}

/* ── Message list ── */
#cw-messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px 14px 10px;
  display: flex;
  flex-direction: column;
  gap: 9px;
  min-height: 200px;
  max-height: 320px;
}

.cw-msg {
  max-width: 82%;
  padding: 9px 12px;
  border-radius: 10px;
  word-break: break-word;
  white-space: pre-wrap;
  font-size: 14px;
}

.cw-msg--customer {
  background: #1a1a2e;
  color: #ffffff;
  align-self: flex-end;
  border-bottom-right-radius: 3px;
}

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

.cw-msg--bot a {
  color: #1a1a2e;
  text-decoration: underline;
}

.cw-msg--bot a:hover {
  opacity: 0.75;
}

.cw-msg--error {
  background: #fde8e8;
  color: #c0392b;
  align-self: flex-start;
  border-bottom-left-radius: 3px;
}

/* ── Typing indicator ── */
.cw-msg--typing {
  padding: 11px 14px;
}

.cw-msg--typing span {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #999;
  margin: 0 2px;
  vertical-align: middle;
  animation: cw-bounce 1.2s infinite ease-in-out;
}

.cw-msg--typing span:nth-child(2) { animation-delay: 0.2s; }
.cw-msg--typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes cw-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30%           { transform: translateY(-5px); opacity: 1; }
}

/* ── Input area ── */
#cw-input-area {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid #ebebeb;
  background: #ffffff;
  flex-shrink: 0;
}

#cw-input {
  flex: 1;
  border: 1px solid #d0d0d8;
  border-radius: 8px;
  padding: 8px 11px;
  font-size: 14px;
  font-family: inherit;
  resize: none;
  outline: none;
  line-height: 1.45;
  max-height: 120px;
  transition: border-color 0.15s;
}

#cw-input:focus {
  border-color: #1a1a2e;
}

#cw-send {
  background: #1a1a2e;
  color: #ffffff;
  border: none;
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 14px;
  font-family: inherit;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s;
  flex-shrink: 0;
}

#cw-send:hover:not(:disabled) {
  background: #16213e;
}

#cw-send:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* ── Mobile ── */
@media (max-width: 400px) {
  #cw-wrapper {
    bottom: 16px;
    right: 16px;
  }

  #cw-panel {
    width: calc(100vw - 32px);
    right: -8px;
  }
}
