.cp-chat-widget {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 140;
  font-family: var(--font, "Inter", system-ui, sans-serif);
}

.cp-chat-toggle {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 12px 18px;
  color: #ffffff;
  background: var(--accent, #d62828);
  border: 0;
  border-radius: 999px;
  box-shadow: 0 10px 26px rgba(214, 40, 40, 0.32);
  font-size: 14px;
  font-weight: 600;
  transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

.cp-chat-toggle:hover {
  background: var(--accent-hover, #b91c1c);
  transform: translateY(-1px);
  box-shadow: 0 14px 30px rgba(214, 40, 40, 0.38);
}

.cp-chat-toggle svg {
  width: 20px;
  height: 20px;
}

.cp-chat-widget.is-open .cp-chat-toggle {
  opacity: 0;
  pointer-events: none;
  transform: scale(0.9);
}

.cp-chat-panel {
  position: absolute;
  right: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  width: min(370px, calc(100vw - 32px));
  height: min(560px, calc(100vh - 110px));
  background: #ffffff;
  border: 1px solid var(--line, #e5e7eb);
  border-radius: 14px;
  box-shadow: 0 24px 60px rgba(31, 35, 40, 0.2);
  overflow: hidden;
  animation: cpChatIn 0.2s ease;
}

@keyframes cpChatIn {
  from {
    opacity: 0;
    transform: translateY(14px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.cp-chat-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 16px;
  color: #ffffff;
  background: linear-gradient(135deg, #d62828, #9f1239);
}

.cp-chat-identity {
  display: flex;
  align-items: center;
  gap: 11px;
}

.cp-chat-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  background: rgba(255, 255, 255, 0.16);
  border-radius: 50%;
}

.cp-chat-mark svg {
  width: 21px;
  height: 21px;
}

.cp-chat-identity strong {
  display: block;
  font-size: 14px;
  line-height: 1.3;
}

.cp-chat-identity span {
  display: block;
  margin-top: 2px;
  color: rgba(255, 255, 255, 0.82);
  font-size: 11.5px;
  line-height: 1.4;
}

.cp-chat-close {
  display: inline-flex;
  padding: 5px;
  color: #ffffff;
  background: transparent;
  border: 0;
  border-radius: 6px;
  opacity: 0.85;
}

.cp-chat-close:hover {
  background: rgba(255, 255, 255, 0.14);
  opacity: 1;
}

.cp-chat-close svg {
  width: 18px;
  height: 18px;
}

.cp-chat-messages {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 16px;
  overflow-y: auto;
  background: var(--bg-soft, #f7f7f8);
}

.cp-chat-bubble {
  max-width: 86%;
  padding: 10px 13px;
  border-radius: 12px;
  font-size: 13.5px;
  line-height: 1.55;
  word-break: break-word;
}

.cp-chat-bubble.assistant {
  align-self: flex-start;
  background: #ffffff;
  border: 1px solid var(--line, #e5e7eb);
  border-bottom-left-radius: 4px;
  color: var(--ink, #1f2328);
}

.cp-chat-bubble.user {
  align-self: flex-end;
  background: var(--accent, #d62828);
  border-bottom-right-radius: 4px;
  color: #ffffff;
}

.cp-chat-action {
  display: inline-flex;
  margin-top: 9px;
  padding: 6px 11px;
  color: var(--accent, #d62828);
  background: var(--accent-soft, #fef2f2);
  border-radius: 6px;
  font-size: 12.5px;
  font-weight: 600;
}

.cp-chat-action:hover {
  background: #fde2e2;
  color: var(--accent-hover, #b91c1c);
}

.cp-chat-typing {
  display: inline-flex;
  gap: 4px;
  padding: 13px;
}

.cp-chat-typing span {
  width: 6px;
  height: 6px;
  background: #c3c7cd;
  border-radius: 50%;
  animation: cpChatDot 1s infinite ease-in-out;
}

.cp-chat-typing span:nth-child(2) {
  animation-delay: 0.15s;
}

.cp-chat-typing span:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes cpChatDot {
  0%, 80%, 100% {
    transform: translateY(0);
    opacity: 0.5;
  }
  40% {
    transform: translateY(-4px);
    opacity: 1;
  }
}

.cp-chat-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0 14px 10px;
  background: var(--bg-soft, #f7f7f8);
}

.cp-chat-suggestions:empty {
  display: none;
}

.cp-chat-chip {
  padding: 6px 10px;
  color: var(--ink, #1f2328);
  background: #ffffff;
  border: 1px solid var(--line-strong, #d1d5db);
  border-radius: 999px;
  font-size: 11.5px;
  line-height: 1.3;
  transition: border-color 0.15s ease, color 0.15s ease;
}

.cp-chat-chip:hover {
  border-color: var(--accent, #d62828);
  color: var(--accent, #d62828);
}

.cp-chat-form {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  background: #ffffff;
  border-top: 1px solid var(--line, #e5e7eb);
}

.cp-chat-form input {
  flex: 1;
  min-width: 0;
  padding: 10px 12px;
  background: var(--bg-soft, #f7f7f8);
  border: 1px solid var(--line, #e5e7eb);
  border-radius: 999px;
  font-size: 13px;
}

.cp-chat-form input:focus {
  outline: none;
  border-color: var(--accent, #d62828);
  background: #ffffff;
}

.cp-chat-form button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  color: #ffffff;
  background: var(--accent, #d62828);
  border: 0;
  border-radius: 50%;
}

.cp-chat-form button:hover {
  background: var(--accent-hover, #b91c1c);
}

.cp-chat-form button:disabled {
  opacity: 0.6;
  cursor: default;
}

.cp-chat-form button svg {
  width: 17px;
  height: 17px;
}

.cp-chat-note {
  margin: 0;
  padding: 0 14px 10px;
  color: var(--muted, #6b7280);
  background: #ffffff;
  font-size: 10.5px;
  text-align: center;
}

@media (max-width: 640px) {
  .cp-chat-widget {
    right: 14px;
    bottom: 14px;
    left: 14px;
  }

  .cp-chat-toggle {
    margin-left: auto;
  }

  .cp-chat-toggle-label {
    display: none;
  }

  .cp-chat-toggle {
    width: 54px;
    height: 54px;
    padding: 0;
    justify-content: center;
    border-radius: 50%;
  }

  .cp-chat-panel {
    position: fixed;
    right: 14px;
    bottom: 14px;
    left: 14px;
    width: auto;
    height: min(78vh, 560px);
  }
}
