.cardy-widget {
  position: fixed;
  left: 22px;
  bottom: 22px;
  z-index: 9999;
  font-family: inherit;
}

.cardy-widget-toggle {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  height: 56px;
  border: 0;
  border-radius: 999px;
  padding: 6px 18px 6px 6px;
  color: #ffffff;
  background: #2b50ba;
  box-shadow: 0 16px 36px rgba(43, 80, 186, .28);
  font-size: 15px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  transition: transform .18s ease, box-shadow .18s ease, background .18s ease;
}

.cardy-widget-toggle:hover,
.cardy-widget-toggle:focus {
  background: #2445a3;
  box-shadow: 0 18px 42px rgba(43, 80, 186, .34);
  transform: translateY(-1px);
}

.cardy-widget-toggle-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  object-fit: cover;
  background: #ffffff;
  border: 2px solid rgba(255, 255, 255, .9);
}

.cardy-widget-panel {
  position: absolute;
  left: 0;
  bottom: 72px;
  width: min(380px, calc(100vw - 28px));
  height: min(620px, calc(100dvh - 120px));
  min-height: 460px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: #ffffff;
  border: 1px solid #e8edf5;
  border-radius: 18px;
  box-shadow: 0 22px 60px rgba(15, 23, 42, .18);
}

.cardy-widget-panel[hidden] {
  display: none;
}

.cardy-widget-header {
  min-height: 76px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  background: #ffffff;
  border-bottom: 1px solid #e9eef5;
  flex-shrink: 0;
}

.cardy-widget-title {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
}

.cardy-widget-avatar {
  width: 46px;
  height: 46px;
  border-radius: 13px;
  object-fit: cover;
  box-shadow: 0 8px 18px rgba(43, 80, 186, .16);
  flex-shrink: 0;
}

.cardy-widget-title h2 {
  margin: 0;
  color: #172033;
  font-size: 18px;
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: 0;
}

.cardy-widget-title p {
  margin: 4px 0 0;
  color: #667085;
  font-size: 12px;
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cardy-widget-close {
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #e3e8f0;
  border-radius: 10px;
  color: #667085;
  background: #f8fafc;
  cursor: pointer;
  flex-shrink: 0;
}

.cardy-widget-close:hover,
.cardy-widget-close:focus {
  color: #172033;
  background: #eef2f7;
}

.cardy-widget-messages {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow-y: auto;
  padding: 16px;
  background: linear-gradient(180deg, #f8fafc 0%, #f5f7fb 100%);
  scroll-behavior: smooth;
}

.cardy-widget-message {
  display: flex;
  width: 100%;
  min-width: 0;
}

.cardy-widget-message-assistant {
  justify-content: flex-start;
}

.cardy-widget-message-user {
  justify-content: flex-end;
}

.cardy-widget-bubble {
  max-width: 82%;
  padding: 11px 13px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.45;
  white-space: pre-line;
  overflow-wrap: anywhere;
  word-break: normal;
}

.cardy-widget-message-assistant .cardy-widget-bubble {
  color: #1f2937;
  background: #ffffff;
  border: 1px solid #e7ecf3;
  border-bottom-left-radius: 6px;
}

.cardy-widget-message-user .cardy-widget-bubble {
  color: #ffffff;
  background: #2b50ba;
  border: 1px solid #2b50ba;
  border-bottom-right-radius: 6px;
  box-shadow: 0 8px 18px rgba(43, 80, 186, .16);
}

.cardy-widget-typing .cardy-widget-bubble {
  width: 62px;
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
}

.cardy-widget-typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #8b95a5;
  animation: cardyTypingDot 1.1s infinite ease-in-out;
}

.cardy-widget-typing span:nth-child(2) {
  animation-delay: .14s;
}

.cardy-widget-typing span:nth-child(3) {
  animation-delay: .28s;
}

@keyframes cardyTypingDot {
  0%, 80%, 100% {
    opacity: .35;
    transform: translateY(0);
  }
  40% {
    opacity: 1;
    transform: translateY(-3px);
  }
}

.cardy-widget-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 46px;
  align-items: center;
  gap: 9px;
  padding: 12px;
  background: #ffffff;
  border-top: 1px solid #e9eef5;
  flex-shrink: 0;
}

.cardy-widget-input {
  width: 100%;
  height: 46px;
  min-height: 46px;
  max-height: 46px;
  resize: none;
  overflow: hidden;
  border: 1px solid #d9e1ec;
  border-radius: 12px;
  padding: 0 13px;
  color: #172033;
  background: #fbfcff;
  font: inherit;
  font-size: 14px;
  line-height: 44px;
  outline: none;
}

.cardy-widget-input::placeholder {
  color: #98a2b3;
}

.cardy-widget-input:focus {
  border-color: #2b50ba;
  background: #ffffff;
  box-shadow: 0 0 0 3px rgba(43, 80, 186, .11);
}

.cardy-widget-send {
  width: 46px;
  height: 46px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 12px;
  color: #ffffff;
  background: #2b50ba;
  cursor: pointer;
  box-shadow: 0 8px 18px rgba(43, 80, 186, .18);
}

.cardy-widget-send:hover,
.cardy-widget-send:focus {
  background: #2445a3;
}

.cardy-widget-send:disabled,
.cardy-widget-input:disabled {
  cursor: not-allowed;
  opacity: .72;
}

@media (max-width: 576px) {
  .cardy-widget {
    right: 14px;
    bottom: 14px;
  }

  .cardy-widget-toggle {
    height: 54px;
    padding-right: 14px;
  }

  .cardy-widget-toggle-text {
    display: none;
  }

  .cardy-widget-toggle-avatar {
    width: 42px;
    height: 42px;
  }

  .cardy-widget-panel {
    position: fixed;
    left: 10px;
    bottom: 78px;
    width: calc(100vw - 20px);
    height: min(610px, calc(100dvh - 96px));
    min-height: 390px;
    border-radius: 16px;
  }

  .cardy-widget-title p {
    max-width: 210px;
  }

  .cardy-widget-bubble {
    max-width: 90%;
  }
}
