.ca-chatbot {
  --ca-forest: #1b3c53;
  --ca-forest-deep: #102b3e;
  --ca-emerald: #b75e44;
  --ca-gold: #d7a645;
  --ca-mint: #f3f2e7;
  --ca-paper: #fffdfa;
  --ca-ink: #1b3c53;
  --ca-muted: #63737d;
  position: fixed;
  z-index: 9998;
  right: 24px;
  bottom: 96px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ca-ink);
}

.ca-chatbot *,
.ca-chatbot *::before,
.ca-chatbot *::after {
  box-sizing: border-box;
}

.ca-chatbot button,
.ca-chatbot textarea {
  font: inherit;
}

.ca-chatbot__launcher {
  display: flex;
  min-height: 58px;
  align-items: center;
  gap: 10px;
  padding: 7px 17px 7px 8px;
  border: 4px solid #fff;
  border-radius: 999px;
  background: var(--ca-forest);
  color: #fff;
  box-shadow: 0 15px 38px rgba(16, 43, 62, .28);
  cursor: pointer;
  transition: transform .2s ease, background .2s ease, box-shadow .2s ease;
}

.ca-chatbot__launcher:hover,
.ca-chatbot__launcher:focus-visible {
  background: var(--ca-emerald);
  box-shadow: 0 18px 44px rgba(16, 43, 62, .34);
  outline: none;
  transform: translateY(-2px);
}

.ca-chatbot__launcher-icon {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 50%;
  background: var(--ca-gold);
  color: var(--ca-forest-deep);
}

.ca-chatbot__launcher-icon svg {
  width: 22px;
  height: 22px;
  fill: currentColor;
}

.ca-chatbot__launcher-text {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .01em;
  white-space: nowrap;
}

.ca-chatbot__panel {
  position: absolute;
  right: 0;
  bottom: 72px;
  display: flex;
  width: min(390px, calc(100vw - 32px));
  max-height: min(620px, calc(100vh - 190px));
  min-height: 480px;
  overflow: hidden;
  flex-direction: column;
  border: 1px solid rgba(27, 60, 83, .12);
  border-radius: 26px;
  background: var(--ca-paper);
  box-shadow: 0 28px 80px rgba(16, 43, 62, .25);
  transform-origin: right bottom;
  animation: ca-chatbot-in .22s ease-out;
}

.ca-chatbot__panel[hidden] {
  display: none;
}

@keyframes ca-chatbot-in {
  from { opacity: 0; transform: translateY(12px) scale(.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.ca-chatbot__header {
  display: flex;
  min-height: 82px;
  align-items: center;
  gap: 12px;
  padding: 16px 16px 16px 18px;
  background: linear-gradient(135deg, var(--ca-forest-deep), var(--ca-forest));
  color: #fff;
}

.ca-chatbot__avatar {
  display: block;
  width: 48px;
  height: 48px;
  flex: 0 0 auto;
  overflow: hidden;
  border: 2px solid var(--ca-gold);
  border-radius: 50%;
  background: #fff;
}

.ca-chatbot__avatar img {
  width: 100%;
  height: 100%;
  max-width: none;
  object-fit: cover;
  object-position: center;
}

.ca-chatbot__identity {
  min-width: 0;
  flex: 1;
}

.ca-chatbot__identity strong {
  display: block;
  overflow: hidden;
  margin-bottom: 3px;
  font-size: 14px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ca-chatbot__identity > span {
  display: flex;
  align-items: center;
  gap: 6px;
  color: #e2d8c1;
  font-size: 11px;
}

.ca-chatbot__identity i {
  width: 8px;
  height: 8px;
  border: 2px solid rgba(255, 255, 255, .55);
  border-radius: 50%;
  background: #d7a645;
}

.ca-chatbot__close {
  display: grid;
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, .1);
  color: #fff;
  font-size: 25px;
  line-height: 1;
  cursor: pointer;
}

.ca-chatbot__close:hover,
.ca-chatbot__close:focus-visible {
  background: rgba(255, 255, 255, .2);
  outline: 2px solid rgba(255, 255, 255, .5);
}

.ca-chatbot__messages {
  flex: 1;
  min-height: 230px;
  overflow-y: auto;
  padding: 20px 16px 10px;
  background:
    radial-gradient(circle at top right, rgba(215, 166, 69, .09), transparent 32%),
    #faf8f2;
  scrollbar-color: rgba(27, 60, 83, .2) transparent;
  scrollbar-width: thin;
}

.ca-chatbot__message {
  display: flex;
  margin-bottom: 12px;
}

.ca-chatbot__message--user {
  justify-content: flex-end;
}

.ca-chatbot__bubble {
  max-width: 84%;
  padding: 11px 13px;
  border: 1px solid rgba(27, 60, 83, .1);
  border-radius: 6px 17px 17px 17px;
  background: #fff;
  box-shadow: 0 6px 18px rgba(27, 60, 83, .06);
  color: var(--ca-ink);
  font-size: 13px;
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.ca-chatbot__message--user .ca-chatbot__bubble {
  border-color: var(--ca-forest);
  border-radius: 17px 6px 17px 17px;
  background: var(--ca-forest);
  color: #fff;
}

.ca-chatbot__message--typing .ca-chatbot__bubble {
  color: var(--ca-muted);
  font-style: italic;
}

.ca-chatbot__message--typing .ca-chatbot__bubble::after {
  display: inline-block;
  width: 1.1em;
  content: "…";
  animation: ca-chatbot-pulse 1s infinite;
}

.ca-chatbot__message--error .ca-chatbot__bubble {
  border-color: rgba(165, 65, 45, .22);
  background: #fff7f4;
  color: #8f3424;
}

@keyframes ca-chatbot-pulse {
  50% { opacity: .35; }
}

.ca-chatbot__quick {
  display: flex;
  overflow-x: auto;
  flex: 0 0 auto;
  gap: 7px;
  padding: 9px 14px 11px;
  border-top: 1px solid rgba(27, 60, 83, .08);
  background: #faf8f2;
  scrollbar-width: none;
}

.ca-chatbot__quick:empty {
  display: none;
}

.ca-chatbot__quick::-webkit-scrollbar {
  display: none;
}

.ca-chatbot__quick button {
  flex: 0 0 auto;
  padding: 7px 10px;
  border: 1px solid rgba(183, 94, 68, .25);
  border-radius: 999px;
  background: #fff;
  color: var(--ca-emerald);
  font-size: 10px;
  font-weight: 750;
  cursor: pointer;
}

.ca-chatbot__quick button:hover,
.ca-chatbot__quick button:focus-visible {
  border-color: var(--ca-emerald);
  background: var(--ca-mint);
  outline: none;
}

.ca-chatbot__form {
  display: flex;
  flex: 0 0 auto;
  align-items: flex-end;
  gap: 9px;
  padding: 12px;
  border-top: 1px solid rgba(27, 60, 83, .1);
  background: #fff;
}

.ca-chatbot__form textarea {
  min-height: 46px;
  max-height: 112px;
  flex: 1;
  resize: none;
  padding: 12px 13px;
  border: 1px solid rgba(27, 60, 83, .17);
  border-radius: 15px;
  background: #fffdfa;
  color: var(--ca-ink);
  font-size: 13px;
  line-height: 1.45;
}

.ca-chatbot__form textarea:focus {
  border-color: var(--ca-emerald);
  box-shadow: 0 0 0 3px rgba(183, 94, 68, .1);
  outline: none;
}

.ca-chatbot__form button {
  min-height: 46px;
  padding: 0 14px;
  border: 0;
  border-radius: 14px;
  background: var(--ca-gold);
  color: var(--ca-forest-deep);
  font-size: 11px;
  font-weight: 850;
  cursor: pointer;
}

.ca-chatbot__form button:hover,
.ca-chatbot__form button:focus-visible {
  filter: brightness(.95);
  outline: 3px solid rgba(215, 166, 69, .24);
}

.ca-chatbot__form button:disabled,
.ca-chatbot__form textarea:disabled,
.ca-chatbot__quick button:disabled {
  cursor: wait;
  opacity: .6;
}

.ca-chatbot__footer {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 0 14px 11px;
  background: #fff;
  color: var(--ca-muted);
  font-size: 9px;
  line-height: 1.3;
}

.ca-chatbot__footer span {
  max-width: 58%;
}

.ca-chatbot__footer a {
  color: var(--ca-emerald);
  font-weight: 800;
  text-decoration: none;
}

.ca-chatbot__footer a:hover,
.ca-chatbot__footer a:focus-visible {
  text-decoration: underline;
}

@media (max-width: 600px) {
  .ca-chatbot {
    right: 16px;
    bottom: 92px;
  }

  .ca-chatbot__launcher {
    min-height: 54px;
    padding-right: 12px;
  }

  .ca-chatbot__launcher-icon {
    width: 36px;
    height: 36px;
  }

  .ca-chatbot__launcher-text {
    max-width: 135px;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .ca-chatbot__panel {
    position: fixed;
    right: 10px;
    bottom: 158px;
    left: 10px;
    width: auto;
    max-height: calc(100dvh - 176px);
    min-height: min(500px, calc(100dvh - 176px));
    border-radius: 22px;
  }
}

@media (max-height: 650px) {
  .ca-chatbot__panel {
    min-height: 0;
    max-height: calc(100dvh - 170px);
  }

  .ca-chatbot__header {
    min-height: 68px;
    padding-top: 10px;
    padding-bottom: 10px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .ca-chatbot__panel,
  .ca-chatbot__launcher,
  .ca-chatbot__message--typing .ca-chatbot__bubble::after {
    animation: none;
    transition: none;
  }
}
