.ai-chat-widget {
  position: fixed;
  right: 22px;
  bottom: 24px;
  z-index: 80;
  font-family: inherit;
  animation: aiWidgetFloat 3.6s ease-in-out infinite;
}

.ai-chat-toggle {
  min-width: 154px;
  height: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid rgba(42, 122, 255, .24);
  border-radius: 6px;
  color: #fff;
  background:
    radial-gradient(circle at 24% 20%, rgba(255, 255, 255, .35), transparent 28%),
    linear-gradient(135deg, #1559d8, #12b9d7);
  box-shadow: 0 14px 34px rgba(21, 89, 216, .28), 0 0 0 0 rgba(23, 214, 255, .28);
  font-weight: 900;
  cursor: pointer;
  animation: aiTogglePulse 2.8s ease-out infinite;
  position: relative;
  overflow: visible;
  transition: transform .2s ease, box-shadow .2s ease;
}

.ai-chat-toggle:hover,
.ai-chat-toggle:focus-visible {
  transform: translateY(-2px);
  box-shadow: 0 18px 42px rgba(21, 89, 216, .34), 0 0 0 8px rgba(23, 214, 255, .12);
}

.ai-chat-icon {
  width: 30px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  color: #eaffff;
  background: rgba(255, 255, 255, .16);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .28);
  position: relative;
}

.ai-chat-icon::after {
  content: "";
  position: absolute;
  right: 3px;
  top: 4px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #41dfad;
  box-shadow: 0 0 0 3px rgba(65, 223, 173, .18);
  animation: aiStatusBlink 1.8s ease-in-out infinite;
}

.ai-chat-icon svg {
  width: 21px;
  height: 21px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

@keyframes aiWidgetFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-5px); }
}

@keyframes aiTogglePulse {
  0%, 72%, 100% {
    box-shadow: 0 14px 34px rgba(21, 89, 216, .28), 0 0 0 0 rgba(23, 214, 255, .26);
  }
  82% {
    box-shadow: 0 14px 34px rgba(21, 89, 216, .28), 0 0 0 10px rgba(23, 214, 255, 0);
  }
}

@keyframes aiStatusBlink {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: .48; transform: scale(.72); }
}

.ai-chat-panel {
  position: absolute;
  right: 0;
  bottom: 62px;
  width: min(50vw, 820px);
  min-width: 560px;
  height: min(68vh, 640px);
  max-height: calc(100vh - 118px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid #d7e4f6;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 22px 60px rgba(16, 42, 86, .22);
}

.ai-chat-panel[hidden] {
  display: none;
}

.ai-chat-head {
  min-height: 54px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  color: #fff;
  background: linear-gradient(135deg, #0d3f9f, #08a0bd);
}

.ai-chat-close {
  width: 30px;
  height: 30px;
  border: 0;
  color: #fff;
  background: transparent;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
}

.ai-chat-body {
  min-height: 0;
  flex: 1;
  padding: 16px;
}

.ai-chat-messages {
  height: 100%;
  overflow-y: auto;
  display: grid;
  align-content: start;
  gap: 10px;
  padding-right: 2px;
}

.ai-message {
  margin: 0;
  padding: 12px 14px;
  border-radius: 6px;
  color: #29415f;
  background: #f3f8ff;
  line-height: 1.65;
  font-size: 13px;
  font-weight: 700;
  white-space: pre-wrap;
}

.ai-message.is-user {
  justify-self: end;
  max-width: 86%;
  color: #fff;
  background: #1d6fd8;
}

.ai-message.is-loading {
  color: #5a6f8b;
  background: #f7faff;
}

.ai-chat-link {
  justify-self: start;
  display: inline-flex;
  height: 34px;
  align-items: center;
  justify-content: center;
  padding: 0 18px;
  border-radius: 5px;
  color: #fff;
  text-decoration: none;
  background: linear-gradient(135deg, #1559d8, #12b9d7);
  box-shadow: 0 10px 24px rgba(21, 89, 216, .18);
  font-size: 13px;
  font-weight: 900;
}

.ai-signup-card {
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1px solid #cfe0f7;
  border-radius: 6px;
  color: #29415f;
  background: #fff;
  box-shadow: 0 10px 24px rgba(26, 78, 150, .08);
  font-size: 13px;
  font-weight: 700;
}

.ai-signup-card strong {
  color: #174f9f;
  font-size: 15px;
}

.ai-signup-card p {
  margin: 0;
  line-height: 1.65;
}

.ai-signup-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.ai-signup-actions button {
  height: 34px;
  padding: 0 16px;
  border: 1px solid #d9e6f7;
  border-radius: 5px;
  color: #1f4f96;
  background: #fff;
  font-weight: 900;
  cursor: pointer;
}

.ai-signup-actions button:first-child {
  color: #fff;
  border-color: transparent;
  background: linear-gradient(135deg, #1559d8, #12b9d7);
}

.ai-chat-actions {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin: 0;
}

.ai-chat-actions button {
  height: 34px;
  border: 1px solid #d9e6f7;
  border-radius: 4px;
  color: #1f4f96;
  background: #fff;
  font-weight: 800;
  cursor: pointer;
}

.ai-chat-input {
  display: grid;
  grid-template-columns: 1fr 64px;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid #edf2fb;
  background: #fbfdff;
}

.ai-chat-input input,
.ai-chat-input button {
  height: 36px;
  border-radius: 4px;
  border: 1px solid #d9e6f7;
}

.ai-chat-input input {
  min-width: 0;
  padding: 0 10px;
  color: #667085;
  background: #f7faff;
}

.ai-chat-input button {
  color: #fff;
  background: #1d6fd8;
  font-weight: 800;
  cursor: pointer;
}

.ai-chat-input button:disabled {
  opacity: .62;
  cursor: not-allowed;
}

@media (max-width: 760px) {
  .ai-chat-widget {
    right: 14px;
    bottom: 18px;
  }

  .ai-chat-widget.is-open {
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
  }

  .ai-chat-toggle {
    min-width: 52px;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    padding: 0;
  }

  .ai-chat-toggle > span:not(.ai-chat-icon) {
    display: none;
  }

  .ai-chat-toggle .ai-chat-icon {
    width: 34px;
    height: 34px;
  }

  .ai-chat-panel {
    left: 10px;
    right: 10px;
    bottom: 68px;
    width: auto;
    min-width: 0;
    height: min(76vh, 620px);
    max-height: calc(100vh - 88px);
    border-radius: 8px;
  }

  .ai-chat-messages {
    max-height: none;
  }
}
