:root {
  --zx-bg: #07080c;
  --zx-card: #0e1017;
  --zx-card-soft: rgba(14, 16, 23, 0.72);
  --zx-border: rgba(255, 255, 255, 0.08);
  --zx-border-strong: rgba(99, 102, 241, 0.35);
  --zx-text: #e2e8f0;
  --zx-muted: #94a3b8;
  --zx-cyan: #06b6d4;
  --zx-indigo: #6366f1;
  --zx-purple: #8b5cf6;
  --zx-gradient: linear-gradient(135deg, #06b6d4 0%, #6366f1 55%, #8b5cf6 100%);
  --zx-shadow: 0 20px 50px rgba(0, 0, 0, 0.45);
}

.zx-chat-launcher {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 999;
  border: 0;
  border-radius: 999px;
  padding: 0.9rem 1.35rem;
  color: #fff;
  font: 600 0.92rem/1 Inter, system-ui, -apple-system, sans-serif;
  background: var(--zx-gradient);
  box-shadow: 0 12px 32px rgba(99, 102, 241, 0.35);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  transition: transform .2s ease, box-shadow .2s ease, opacity .2s ease;
}
.zx-chat-launcher:hover { transform: translateY(-2px); box-shadow: 0 16px 38px rgba(99, 102, 241, 0.45); }
.zx-chat-launcher .zx-launcher-dot {
  width: 10px; height: 10px; border-radius: 50%; background: #22d3ee;
  box-shadow: 0 0 0 4px rgba(34, 211, 238, 0.18);
}

.zx-widget {
  position: fixed;
  right: 24px;
  bottom: 90px;
  z-index: 1000;
  width: 390px;
  max-width: calc(100vw - 28px);
  height: 560px;
  max-height: calc(100vh - 115px);
  display: none;
  flex-direction: column;
  overflow: hidden;
  border-radius: 24px;
  border: 1px solid var(--zx-border);
  background: linear-gradient(180deg, rgba(14,16,23,0.96), rgba(7,8,12,0.98));
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  box-shadow: var(--zx-shadow);
}
.zx-widget.open { display: flex; }
#zxChatWidget { display: flex; flex-direction: column; height: 100%; min-height: 0; }

.zx-chat-header {
  padding: 1rem 1.1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  color: #fff;
  background: linear-gradient(135deg, rgba(6,182,212,0.16), rgba(99,102,241,0.22), rgba(139,92,246,0.16));
  border-bottom: 1px solid var(--zx-border);
}
.zx-chat-brand { display: flex; align-items: center; gap: 0.75rem; min-width: 0; }
.zx-chat-avatar {
  width: 40px; height: 40px; flex: 0 0 40px; border-radius: 14px;
  background: var(--zx-gradient); display: grid; place-items: center;
  font: 700 0.95rem/1 'Space Grotesk', Inter, sans-serif; color: #fff;
  box-shadow: 0 8px 20px rgba(99,102,241,0.3);
}
.zx-chat-title { font: 700 0.96rem/1.2 'Space Grotesk', Inter, sans-serif; letter-spacing: -0.01em; }
.zx-chat-sub { font: 500 0.73rem/1.2 Inter, sans-serif; color: #a5b4fc; margin-top: 0.2rem; display: flex; align-items: center; gap: 0.35rem; }
.zx-status-dot { width: 7px; height: 7px; border-radius: 50%; background: #34d399; box-shadow: 0 0 0 3px rgba(52,211,153,0.15); }

.zx-chat-actions { display: flex; align-items: center; gap: 0.35rem; }
.zx-chat-icon-btn {
  width: 34px; height: 34px; border-radius: 10px; border: 1px solid rgba(255,255,255,0.08);
  background: rgba(255,255,255,0.04); color: #cbd5e1; cursor: pointer;
  display: grid; place-items: center; transition: all .2s ease;
}
.zx-chat-icon-btn:hover { background: rgba(99,102,241,0.18); color: #fff; border-color: rgba(99,102,241,0.35); }
.zx-chat-icon-btn svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.zx-byok-bar {
  display: none; padding: 0.75rem 1rem; background: rgba(99,102,241,0.06);
  border-bottom: 1px solid var(--zx-border);
}
.zx-byok-bar.show { display: block; }
.zx-byok-bar label { display:block; font: 600 0.72rem/1.2 Inter, sans-serif; color: #c7d2fe; margin-bottom: 0.4rem; }
.zx-byok-bar input {
  width: 100%; padding: 0.55rem 0.75rem; border-radius: 10px; border: 1px solid rgba(255,255,255,0.1);
  background: rgba(7,8,12,0.7); color: #e2e8f0; font: 500 0.8rem/1.3 Inter, sans-serif; outline: none;
}
.zx-byok-bar input:focus { border-color: rgba(99,102,241,0.5); box-shadow: 0 0 0 3px rgba(99,102,241,0.12); }

.zx-messages {
  flex: 1; overflow-y: auto; padding: 1rem;
  display: flex; flex-direction: column; gap: 0.85rem;
  background:
    linear-gradient(to right, rgba(255,255,255,0.018) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(255,255,255,0.018) 1px, transparent 1px),
    radial-gradient(circle at top right, rgba(99,102,241,0.08), transparent 35%),
    #07080c;
  background-size: 28px 28px, 28px 28px, auto, auto;
}
.zx-messages::-webkit-scrollbar { width: 6px; }
.zx-messages::-webkit-scrollbar-thumb { background: rgba(148,163,184,0.25); border-radius: 999px; }

.zx-msg {
  max-width: 86%; padding: 0.8rem 0.95rem; border-radius: 18px;
  font: 400 0.9rem/1.6 Inter, system-ui, sans-serif; word-wrap: break-word; overflow-wrap: anywhere;
}
.zx-msg-bot {
  align-self: flex-start; color: var(--zx-text);
  background: rgba(14, 16, 23, 0.88); border: 1px solid var(--zx-border);
  border-bottom-left-radius: 6px;
}
.zx-msg-user {
  align-self: flex-end; color: #fff;
  background: linear-gradient(135deg, #4f46e5, #6366f1);
  border-bottom-right-radius: 6px; box-shadow: 0 8px 24px rgba(99,102,241,0.25);
}
.zx-msg-error { border-color: rgba(251, 113, 133, 0.35); background: rgba(127, 29, 29, 0.18); color: #fecdd3; }

.zx-msg-meta { font-size: 0.7rem; color: #64748b; margin-top: 0.35rem; }
.zx-msg-user .zx-msg-meta { color: rgba(255,255,255,0.7); text-align: right; }

/* Typing indicator */
.zx-typing-indicator {
  display: inline-flex; align-items: center; gap: 0.55rem;
  padding: 0.7rem 0.9rem; min-width: 140px;
}
.zx-typing-dots { display: inline-flex; align-items: center; gap: 0.28rem; }
.zx-typing-dots span {
  width: 7px; height: 7px; border-radius: 50%; background: #818cf8;
  animation: zxBounce 1.2s infinite ease-in-out;
}
.zx-typing-dots span:nth-child(2) { animation-delay: .15s; background: #67e8f9; }
.zx-typing-dots span:nth-child(3) { animation-delay: .3s; background: #a78bfa; }
.zx-typing-label { font-size: 0.78rem; color: #94a3b8; font-weight: 500; }
@keyframes zxBounce {
  0%, 80%, 100% { transform: translateY(0); opacity: .45; }
  40% { transform: translateY(-5px); opacity: 1; }
}

/* Typewriter cursor */
.zx-typing .zx-type-body { display: inline; white-space: pre-wrap; word-break: break-word; }
.zx-cursor {
  display: inline-block; width: 2px; height: 1.05em; margin-left: 2px;
  vertical-align: text-bottom; border-radius: 2px;
  background: linear-gradient(180deg, #67e8f9, #818cf8);
  box-shadow: 0 0 8px rgba(99,102,241,0.55);
  animation: zxBlink .85s steps(1, end) infinite;
}
@keyframes zxBlink { 0%, 50% { opacity: 1; } 51%, 100% { opacity: 0; } }

@media (prefers-reduced-motion: reduce) {
  .zx-typing-dots span, .zx-cursor { animation: none !important; }
}

/* Markdown content inside bot bubbles */
.zx-msg-bot p { margin: 0 0 0.65rem; }
.zx-msg-bot p:last-child { margin-bottom: 0; }
.zx-msg-bot strong { color: #f8fafc; font-weight: 600; }
.zx-msg-bot em { color: #cbd5e1; }
.zx-msg-bot a { color: #67e8f9; text-decoration: none; border-bottom: 1px solid rgba(103,232,249,0.3); }
.zx-msg-bot a:hover { color: #a5f3fc; border-bottom-color: rgba(165,243,252,0.6); }
.zx-msg-bot ul, .zx-msg-bot ol { margin: 0.45rem 0 0.7rem 1.2rem; padding: 0; }
.zx-msg-bot li { margin: 0.25rem 0; }
.zx-msg-bot h1, .zx-msg-bot h2, .zx-msg-bot h3, .zx-msg-bot h4 {
  margin: 0.7rem 0 0.45rem; font-family: 'Space Grotesk', Inter, sans-serif; color: #f8fafc; line-height: 1.3;
}
.zx-msg-bot h1 { font-size: 1.05rem; } .zx-msg-bot h2 { font-size: 1rem; }
.zx-msg-bot h3 { font-size: 0.95rem; } .zx-msg-bot h4 { font-size: 0.9rem; }
.zx-msg-bot code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.82em;
  background: rgba(99,102,241,0.12); color: #c7d2fe; padding: 0.12rem 0.35rem; border-radius: 6px;
}
.zx-msg-bot pre {
  margin: 0.6rem 0; padding: 0.75rem; overflow-x: auto; border-radius: 12px;
  background: rgba(2,6,23,0.7); border: 1px solid rgba(255,255,255,0.06);
}
.zx-msg-bot pre code { background: transparent; padding: 0; color: #e2e8f0; font-size: 0.8rem; }
.zx-msg-bot blockquote {
  margin: 0.6rem 0; padding: 0.2rem 0 0.2rem 0.85rem; border-left: 3px solid rgba(99,102,241,0.5); color: #cbd5e1;
}
.zx-msg-bot hr { border: 0; border-top: 1px solid rgba(255,255,255,0.08); margin: 0.75rem 0; }
.zx-msg-bot table { width: 100%; border-collapse: collapse; margin: 0.6rem 0; font-size: 0.82rem; display: block; overflow-x: auto; }
.zx-msg-bot th, .zx-msg-bot td { border: 1px solid rgba(255,255,255,0.08); padding: 0.45rem 0.55rem; text-align: left; vertical-align: top; }
.zx-msg-bot th { background: rgba(99,102,241,0.12); color: #e2e8f0; font-weight: 600; }

/* Suggested question cards - compact swipeable */
.zx-suggest { margin-top: 0.75rem; padding-top: 0.65rem; border-top: 1px solid rgba(255,255,255,0.06); }
.zx-suggest-title {
  display: flex; align-items: center; gap: 0.4rem; margin-bottom: 0.55rem;
  font: 600 0.7rem/1.2 Inter, sans-serif; color: #a5b4fc; letter-spacing: 0.01em;
}
.zx-suggest-title svg { width: 13px; height: 13px; stroke: #67e8f9; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.zx-suggest-grid {
  display: flex; flex-wrap: wrap; gap: 0.45rem;
}
.zx-suggest-card {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0.45rem 0.75rem; border-radius: 999px;
  border: 1px solid rgba(99,102,241,0.25); background: rgba(99,102,241,0.08);
  color: #e2e8f0; cursor: pointer; transition: all .2s ease;
  white-space: normal; text-align: center;
}
.zx-suggest-card:hover { transform: translateY(-1px); border-color: rgba(99,102,241,0.5); background: rgba(99,102,241,0.16); box-shadow: 0 6px 18px rgba(99,102,241,0.12); }
.zx-suggest-card:disabled { opacity: 0.55; cursor: default; transform: none; box-shadow: none; }
.zx-suggest-card.is-active { border-color: rgba(34,211,238,0.5); background: rgba(6,182,212,0.12); color: #fff; }
.zx-suggest-text { font: 500 0.74rem/1.3 Inter, sans-serif; color: inherit; }

.zx-notice {
  display: inline-flex; align-items: center; gap: 0.35rem; margin-top: 0.5rem;
  padding: 0.25rem 0.55rem; border-radius: 999px; font-size: 0.68rem; font-weight: 600;
  color: #a5b4fc; background: rgba(99,102,241,0.12); border: 1px solid rgba(99,102,241,0.2);
}

.zx-input-area {
  display: flex; align-items: center; gap: 0.5rem; padding: 0.85rem;
  background: rgba(14,16,23,0.92); border-top: 1px solid var(--zx-border);
}
.zx-input {
  flex: 1; min-width: 0; padding: 0.72rem 1rem; border-radius: 14px;
  border: 1px solid rgba(255,255,255,0.08); background: rgba(7,8,12,0.75); color: #f8fafc;
  font: 400 0.9rem/1.4 Inter, sans-serif; outline: none; transition: border-color .2s, box-shadow .2s;
}
.zx-input::placeholder { color: #64748b; }
.zx-input:focus { border-color: rgba(99,102,241,0.45); box-shadow: 0 0 0 3px rgba(99,102,241,0.12); }
.zx-send-btn {
  border: 0; border-radius: 14px; padding: 0.72rem 1rem;
  background: var(--zx-gradient); color: #fff; font: 600 0.85rem/1 Inter, sans-serif;
  cursor: pointer; transition: transform .2s, opacity .2s; white-space: nowrap;
}
.zx-send-btn:hover { transform: translateY(-1px); }
.zx-send-btn:disabled { opacity: 0.55; cursor: not-allowed; transform: none; }

.zx-mic-btn {
  width: 42px; height: 42px; flex: 0 0 42px; border-radius: 14px; border: 1px solid rgba(255,255,255,0.08);
  background: rgba(255,255,255,0.03); color: #94a3b8; cursor: pointer; display: grid; place-items: center;
}
.zx-mic-btn:hover { color: #fff; background: rgba(99,102,241,0.15); border-color: rgba(99,102,241,0.3); }
.zx-mic-btn.listening { color: #fb7185; background: rgba(251,113,133,0.12); border-color: rgba(251,113,133,0.35); }
.zx-mic-btn svg, .zx-send-btn svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

@media (max-width: 520px) {
  .zx-widget { right: 12px; bottom: 84px; width: calc(100vw - 24px); height: calc(100vh - 140px); max-height: none; border-radius: 20px; }
  .zx-chat-launcher { right: 16px; bottom: 16px; }
}