:root {
  --aiw-primary: #2563eb;
  --aiw-primary-h: #1d4ed8;
  --aiw-accent: #7c3aed;
  --aiw-bg: rgba(255, 255, 255, 0.92);
  --aiw-text: #0f172a;
  --aiw-muted: #64748b;
  --aiw-border: rgba(226, 232, 240, 0.8);
  --aiw-shadow: 0 24px 60px -12px rgba(15, 23, 42, 0.35);
}

#cityp-ai-widget {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 99999;
  font-family: inherit;
}

.aiw-toggle {
  position: relative;
  width: 64px;
  height: 64px;
  border: none;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--aiw-primary), var(--aiw-accent));
  color: #fff;
  font-size: 26px;
  cursor: pointer;
  box-shadow: 0 10px 28px -8px rgba(37, 99, 235, 0.5);
  transition: transform 0.2s, box-shadow 0.2s;
}
.aiw-toggle:hover { transform: translateY(-3px) scale(1.05); box-shadow: 0 14px 36px -8px rgba(37, 99, 235, 0.6); }
.aiw-toggle.is-active { transform: scale(0.9); }

.aiw-toggle-pulse {
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  border: 2px solid rgba(37, 99, 235, 0.35);
  animation: aiw-pulse-ring 2s infinite;
  pointer-events: none;
}
@keyframes aiw-pulse-ring {
  0% { transform: scale(1); opacity: 0.6; }
  100% { transform: scale(1.35); opacity: 0; }
}

.aiw-chat {
  position: absolute;
  bottom: 80px;
  right: 0;
  width: 380px;
  max-width: calc(100vw - 32px);
  height: 560px;
  max-height: calc(100vh - 120px);
  display: flex;
  flex-direction: column;
  background: var(--aiw-bg);
  border: 1px solid var(--aiw-border);
  border-radius: 24px;
  box-shadow: var(--aiw-shadow);
  overflow: hidden;
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
  animation: aiw-chat-in 0.25s cubic-bezier(0.2, 0.8, 0.2, 1);
}
@keyframes aiw-chat-in {
  from { opacity: 0; transform: translateY(16px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.aiw-chat[hidden] { display: none; }

.aiw-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 18px;
  background: linear-gradient(135deg, var(--aiw-primary), var(--aiw-accent));
  color: #fff;
}
.aiw-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.2);
  font-size: 20px;
}
.aiw-title { display: flex; flex-direction: column; flex: 1; }
.aiw-title strong { font-size: 15px; font-weight: 700; }
.aiw-title span { font-size: 12px; opacity: 0.85; }
.aiw-close {
  width: 34px;
  height: 34px;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  transition: background 0.15s;
}
.aiw-close:hover { background: rgba(255, 255, 255, 0.3); }

.aiw-messages {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.aiw-message { display: flex; flex-direction: column; max-width: 88%; }
.aiw-message.aiw-user { align-self: flex-end; }
.aiw-message.aiw-bot { align-self: flex-start; }
.aiw-bubble {
  padding: 12px 15px;
  border-radius: 18px;
  font-size: 14px;
  line-height: 1.55;
  word-break: break-word;
}
.aiw-user .aiw-bubble {
  background: var(--aiw-primary);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.aiw-bot .aiw-bubble {
  background: #f1f5f9;
  color: var(--aiw-text);
  border-bottom-left-radius: 4px;
}
.aiw-time {
  font-size: 11px;
  color: var(--aiw-muted);
  margin-top: 4px;
  padding: 0 4px;
}
.aiw-user .aiw-time { text-align: right; }

.aiw-bubble a.aiw-link { color: var(--aiw-primary); text-decoration: underline; font-weight: 600; }
.aiw-bubble a.aiw-link:hover { color: var(--aiw-primary-h); }
.aiw-bubble code {
  background: rgba(15, 23, 42, 0.06);
  padding: 2px 5px;
  border-radius: 5px;
  font-family: monospace;
  font-size: 12px;
}
.aiw-bubble pre {
  background: #0f172a;
  color: #e2e8f0;
  padding: 10px;
  border-radius: 10px;
  overflow-x: auto;
  font-size: 12px;
}

.aiw-typing .aiw-bubble { padding: 16px 14px; }
.aiw-dots { display: inline-flex; gap: 5px; }
.aiw-dots span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--aiw-muted);
  animation: aiw-dot 1.2s infinite ease-in-out;
}
.aiw-dots span:nth-child(2) { animation-delay: 0.15s; }
.aiw-dots span:nth-child(3) { animation-delay: 0.3s; }
@keyframes aiw-dot {
  0%, 80%, 100% { transform: scale(0.7); opacity: 0.5; }
  40% { transform: scale(1); opacity: 1; }
}

.aiw-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 8px 16px;
  border-top: 1px solid var(--aiw-border);
}
.aiw-chip {
  padding: 7px 12px;
  border-radius: 999px;
  border: 1px solid var(--aiw-border);
  background: #fff;
  color: var(--aiw-text);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}
.aiw-chip:hover { border-color: var(--aiw-primary); color: var(--aiw-primary); background: rgba(37, 99, 235, 0.06); }

.aiw-input-wrap {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 12px 14px;
  border-top: 1px solid var(--aiw-border);
  background: #fff;
}
.aiw-input-wrap textarea {
  flex: 1;
  resize: none;
  border: 1px solid var(--aiw-border);
  border-radius: 16px;
  padding: 10px 14px;
  font: inherit;
  font-size: 14px;
  color: var(--aiw-text);
  max-height: 120px;
  outline: none;
  transition: border-color 0.15s;
}
.aiw-input-wrap textarea:focus { border-color: var(--aiw-primary); }
.aiw-send {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border: none;
  border-radius: 50%;
  background: var(--aiw-primary);
  color: #fff;
  font-size: 16px;
  cursor: pointer;
  transition: background 0.15s, transform 0.15s;
  flex: 0 0 auto;
}
.aiw-send:hover { background: var(--aiw-primary-h); transform: translateY(-1px); }
.aiw-send:disabled { opacity: 0.5; cursor: not-allowed; }

@media (max-width: 480px) {
  #cityp-ai-widget { bottom: 18px; right: 18px; }
  .aiw-toggle { width: 56px; height: 56px; font-size: 22px; }
  .aiw-chat {
    width: calc(100vw - 36px);
    right: -8px;
    bottom: 72px;
    height: 480px;
  }
}
