.cm-chat-launcher {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 2147482500;
  min-height: 58px;
  border: 1px solid rgba(96, 93, 186, 0.16);
  border-radius: 999px;
  background: #ffffff;
  color: #162033;
  box-shadow: 0 18px 48px rgba(23, 32, 55, 0.18), 0 0 0 6px rgba(96, 93, 186, 0.06);
  display: inline-flex;
  align-items: center;
  gap: 11px;
  padding: 8px 16px 8px 9px;
  font: 800 14px/1.1 Manrope, Sora, sans-serif;
  cursor: pointer;
  transition: transform 160ms ease, box-shadow 160ms ease;
}

.cm-chat-launcher:hover {
  transform: translateY(-2px);
  box-shadow: 0 24px 58px rgba(23, 32, 55, 0.22), 0 0 0 7px rgba(96, 93, 186, 0.08);
}

.cm-chat-launcher-logo,
.cm-chat-header-logo {
  width: 40px;
  height: 40px;
  border-radius: 14px;
  object-fit: contain;
  background: #f7f8ff;
  box-shadow: inset 0 0 0 1px rgba(96, 93, 186, 0.1);
}

.cm-chat-launcher span {
  display: grid;
  gap: 2px;
  text-align: left;
}

.cm-chat-launcher strong {
  font-size: 14px;
}

.cm-chat-launcher small {
  color: #6c7590;
  font-size: 11px;
  font-weight: 800;
}

.cm-chat-shell {
  position: fixed;
  right: 22px;
  bottom: 94px;
  z-index: 2147482600;
  width: min(420px, calc(100vw - 28px));
  height: min(680px, calc(100vh - 120px));
  display: none;
  grid-template-rows: auto 1fr auto;
  overflow: hidden;
  border: 1px solid rgba(96, 93, 186, 0.14);
  border-radius: 28px;
  background: #ffffff;
  color: #172033;
  box-shadow: 0 28px 80px rgba(23, 32, 55, 0.26);
  font-family: Manrope, Sora, sans-serif;
}

.cm-chat-shell.open {
  display: grid;
  animation: cm-chat-enter 180ms ease-out both;
}

.cm-chat-topbar {
  min-height: 76px;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  border-bottom: 1px solid #e8ebf5;
  background:
    radial-gradient(circle at 8% 0%, rgba(0, 207, 255, 0.18), transparent 34%),
    linear-gradient(135deg, #ffffff 0%, #f8fbff 100%);
}

.cm-chat-brand {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
}

.cm-chat-title {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.cm-chat-title strong {
  overflow: hidden;
  color: #172033;
  font-size: 15px;
  letter-spacing: -0.01em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cm-chat-title span {
  overflow: hidden;
  color: #6c7590;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cm-chat-close {
  flex: 0 0 auto;
  height: 36px;
  border: 1px solid #e1e5f2;
  border-radius: 999px;
  background: #ffffff;
  color: #4b5672;
  padding: 0 13px;
  font: 800 12px/1 Manrope, sans-serif;
  cursor: pointer;
}

.cm-chat-log {
  overflow: auto;
  padding: 18px 16px;
  display: grid;
  align-content: start;
  gap: 13px;
  background:
    radial-gradient(circle at 14% 8%, rgba(96, 93, 186, 0.08), transparent 32%),
    linear-gradient(180deg, #fbfcff 0%, #f5f7fc 100%);
  scroll-behavior: smooth;
}

.cm-chat-message {
  width: min(330px, 88%);
  white-space: pre-wrap;
  line-height: 1.5;
  font-size: 14px;
  padding: 12px 14px;
  border-radius: 18px;
  animation: cm-message-in 180ms ease-out both;
  box-shadow: 0 10px 28px rgba(23, 32, 55, 0.08);
}

.cm-chat-message.assistant {
  justify-self: start;
  border: 1px solid #e7eaf3;
  border-bottom-left-radius: 6px;
  background: #ffffff;
  color: #202a43;
}

.cm-chat-message.user {
  justify-self: end;
  border-bottom-right-radius: 6px;
  background: linear-gradient(135deg, #605dba, #e668b3);
  color: #ffffff;
}

.cm-chat-bubble-meta {
  margin-bottom: 5px;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.055em;
  text-transform: uppercase;
  opacity: 0.56;
}

.cm-chat-status {
  justify-self: start;
  max-width: 92%;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  border: 1px solid rgba(96, 93, 186, 0.12);
  border-radius: 999px;
  background: #ffffff;
  color: #6c7590;
  padding: 9px 11px;
  font-size: 12px;
  animation: cm-message-in 180ms ease-out both;
  box-shadow: 0 10px 28px rgba(23, 32, 55, 0.06);
}

.cm-chat-typing-dots {
  display: inline-flex;
  gap: 4px;
}

.cm-chat-typing-dots i {
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: #605dba;
  animation: cm-typing-dot 0.9s ease-in-out infinite;
}

.cm-chat-typing-dots i:nth-child(2) {
  animation-delay: 0.12s;
}

.cm-chat-typing-dots i:nth-child(3) {
  animation-delay: 0.24s;
}

.cm-chat-compose {
  padding: 12px 14px 14px;
  border-top: 1px solid #e8ebf5;
  background: #ffffff;
}

.cm-chat-options {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 10px;
}

.cm-chat-option,
.cm-chat-action {
  border: 1px solid rgba(96, 93, 186, 0.2);
  border-radius: 999px;
  background: #f5f3ff;
  color: #4d4aa8;
  padding: 8px 11px;
  font: 900 12px/1.2 Manrope, sans-serif;
  cursor: pointer;
  text-decoration: none;
}

.cm-chat-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 9px;
  align-items: end;
}

.cm-chat-input {
  min-height: 48px;
  max-height: 130px;
  resize: none;
  border: 1px solid #dfe4f1;
  border-radius: 16px;
  background: #f8faff;
  color: #172033;
  outline: none;
  padding: 13px 14px;
  font: 14px/1.4 Manrope, sans-serif;
  transition: border-color 160ms ease, background 160ms ease, box-shadow 160ms ease;
}

.cm-chat-input::placeholder {
  color: #8994ad;
}

.cm-chat-input:focus {
  border-color: rgba(96, 93, 186, 0.55);
  background: #ffffff;
  box-shadow: 0 0 0 4px rgba(96, 93, 186, 0.1);
}

.cm-chat-send {
  min-width: 72px;
  min-height: 48px;
  border: 0;
  border-radius: 16px;
  background: linear-gradient(135deg, #605dba, #e668b3);
  color: #ffffff;
  font: 900 13px/1 Manrope, sans-serif;
  cursor: pointer;
}

.cm-chat-send:disabled,
.cm-chat-option:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

body.cm-chat-locked {
  overflow: hidden;
}

@keyframes cm-chat-enter {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes cm-message-in {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.99);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes cm-typing-dot {
  0%, 80%, 100% {
    opacity: 0.35;
    transform: translateY(0);
  }
  40% {
    opacity: 1;
    transform: translateY(-3px);
  }
}

@media (max-width: 640px) {
  .cm-chat-launcher {
    right: 14px;
    bottom: 14px;
  }

  .cm-chat-shell {
    inset: 0;
    width: auto;
    height: auto;
    border: 0;
    border-radius: 0;
  }

  .cm-chat-topbar {
    min-height: 68px;
    padding-top: max(14px, env(safe-area-inset-top));
  }

  .cm-chat-log {
    padding: 16px 13px;
  }

  .cm-chat-message {
    width: min(360px, 90vw);
  }

  .cm-chat-compose {
    padding-bottom: max(14px, env(safe-area-inset-bottom));
  }
}
