:root {
  --z2ai-primary: #8b5cf6;
  --z2ai-primary-dark: #6d28d9;
  --z2ai-primary-light: #a78bfa;
  --z2ai-accent: #22d3ee;
  --z2ai-bg: #0f0f1a;
  --z2ai-surface: rgba(255, 255, 255, 0.04);
  --z2ai-glass: rgba(15, 15, 30, 0.85);
  --z2ai-border: rgba(139, 92, 246, 0.15);
  --z2ai-text: #f0f0f5;
  --z2ai-text-dim: rgba(255, 255, 255, 0.5);
  --z2ai-radius: 20px;
}

.z2-ai-toggle {
  position: fixed;
  bottom: 24px;
  left: 24px;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--z2ai-primary) 0%, var(--z2ai-primary-dark) 100%);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 20px rgba(139, 92, 246, 0.4), inset 0 1px 0 rgba(255,255,255,0.15);
  z-index: 9998;
  transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  overflow: visible;
}
.z2-ai-toggle::before {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 2px solid rgba(139, 92, 246, 0.25);
  animation: z2AiPing 2.5s cubic-bezier(0, 0, 0.2, 1) infinite;
}
.z2-ai-toggle:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 30px rgba(139, 92, 246, 0.55);
}
.z2-ai-toggle:hover::before {
  animation: none;
  opacity: 0;
}
.z2-ai-toggle:active {
  transform: scale(0.95);
}
.z2-ai-toggle .z2-ai-bot {
  position: relative;
  width: 32px;
  height: 32px;
  animation: z2AiBotFloat 3s ease-in-out infinite;
}
.z2-ai-toggle .z2-ai-bot-head {
  width: 28px;
  height: 22px;
  background: #fff;
  border-radius: 9px;
  position: absolute;
  top: 5px;
  left: 2px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
}
.z2-ai-toggle .z2-ai-bot-eye {
  width: 5px;
  height: 5px;
  background: var(--z2ai-primary-dark);
  border-radius: 50%;
  animation: z2AiBotBlink 4s ease-in-out infinite;
}
.z2-ai-toggle .z2-ai-bot-eye:first-child {
  animation-delay: 0.1s;
}
.z2-ai-toggle .z2-ai-bot-antenna {
  width: 2px;
  height: 7px;
  background: #fff;
  border-radius: 2px;
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  animation: z2AiAntennaWiggle 3s ease-in-out infinite;
  transform-origin: bottom center;
}
.z2-ai-toggle .z2-ai-bot-antenna::after {
  content: '';
  position: absolute;
  top: -4px;
  left: 50%;
  transform: translateX(-50%);
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--z2ai-accent);
  box-shadow: 0 0 8px rgba(34, 211, 238, 0.6);
  animation: z2AiGlow 2s ease-in-out infinite;
}
.z2-ai-toggle .z2-ai-bot-mouth {
  width: 10px;
  height: 3px;
  border-bottom: 2px solid var(--z2ai-primary-dark);
  border-radius: 0 0 8px 8px;
  position: absolute;
  top: 19px;
  left: 11px;
}
.z2-ai-toggle .z2-ai-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #22c55e;
  border: 2.5px solid var(--z2ai-bg);
  box-shadow: 0 0 6px rgba(34, 197, 94, 0.5);
}

@keyframes z2AiBotFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-2px); }
}
@keyframes z2AiBotBlink {
  0%, 42%, 46%, 100% { transform: scaleY(1); }
  44% { transform: scaleY(0.1); }
}
@keyframes z2AiAntennaWiggle {
  0%, 100% { transform: translateX(-50%) rotate(0deg); }
  25% { transform: translateX(-50%) rotate(6deg); }
  75% { transform: translateX(-50%) rotate(-6deg); }
}
@keyframes z2AiGlow {
  0%, 100% { box-shadow: 0 0 4px rgba(34, 211, 238, 0.3); }
  50% { box-shadow: 0 0 12px rgba(34, 211, 238, 0.7); }
}
@keyframes z2AiPing {
  0% { transform: scale(1); opacity: 0.5; }
  75%, 100% { transform: scale(1.6); opacity: 0; }
}

.z2-ai-panel {
  position: fixed;
  bottom: 24px;
  left: 24px;
  width: 400px;
  max-width: calc(100vw - 48px);
  height: 560px;
  max-height: calc(100vh - 100px);
  border-radius: var(--z2ai-radius);
  background: #111827;
  background: var(--z2ai-glass);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid var(--z2ai-border);
  box-shadow:
    0 24px 80px rgba(0, 0, 0, 0.5),
    0 0 0 1px rgba(139, 92, 246, 0.08),
    inset 0 1px 0 rgba(255, 255, 255, 0.05);
  z-index: 9999;
  display: none;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(20px) scale(0.95);
  transition: opacity 0.35s cubic-bezier(0.16, 1, 0.3, 1), transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}
.z2-ai-panel.open {
  display: flex;
  opacity: 1;
  transform: translateY(0) scale(1);
}
.z2-ai-panel.z2-ai-animating {
  display: flex;
}

.z2-ai-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 18px;
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.12) 0%, rgba(34, 211, 238, 0.06) 100%);
  border-bottom: 1px solid rgba(139, 92, 246, 0.12);
  position: relative;
  overflow: hidden;
}
.z2-ai-header::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(139, 92, 246, 0.3), rgba(34, 211, 238, 0.2), transparent);
}
.z2-ai-header-icon {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--z2ai-primary), var(--z2ai-primary-dark));
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(139, 92, 246, 0.3);
  position: relative;
}
.z2-ai-header-icon::after {
  content: '';
  position: absolute;
  bottom: -2px;
  right: -2px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #22c55e;
  border: 2px solid var(--z2ai-bg);
  box-shadow: 0 0 6px rgba(34, 197, 94, 0.4);
}
.z2-ai-header-icon svg {
  width: 20px;
  height: 20px;
  fill: #fff;
}
.z2-ai-header-info {
  flex: 1;
  min-width: 0;
}
.z2-ai-header-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--z2ai-text);
  line-height: 1.2;
  letter-spacing: -0.01em;
}
.z2-ai-header-sub {
  font-size: 12px;
  color: var(--z2ai-text-dim);
  line-height: 1.3;
  margin-top: 1px;
}
.z2-ai-header-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}
.z2-ai-clear,
.z2-ai-close {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  border: none;
  background: rgba(255, 255, 255, 0.06);
  color: rgba(255, 255, 255, 0.5);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  transition: all 0.2s;
  flex-shrink: 0;
}
.z2-ai-clear:hover,
.z2-ai-close:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}
.z2-ai-clear svg,
.z2-ai-close svg {
  width: 16px;
  height: 16px;
  fill: currentColor;
}

.z2-ai-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 16px 8px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
}
.z2-ai-messages::-webkit-scrollbar { width: 4px; }
.z2-ai-messages::-webkit-scrollbar-track { background: transparent; }
.z2-ai-messages::-webkit-scrollbar-thumb { background: rgba(139, 92, 246, 0.2); border-radius: 4px; }
.z2-ai-messages::-webkit-scrollbar-thumb:hover { background: rgba(139, 92, 246, 0.4); }

.z2-ai-welcome {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 20px 10px 10px;
  text-align: center;
  gap: 14px;
}
.z2-ai-welcome-icon {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.15), rgba(34, 211, 238, 0.08));
  border: 1px solid rgba(139, 92, 246, 0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
}
.z2-ai-welcome-text h3 {
  font-size: 16px;
  font-weight: 700;
  color: var(--z2ai-text);
  margin: 0 0 4px;
}
.z2-ai-welcome-text p {
  font-size: 13px;
  color: var(--z2ai-text-dim);
  margin: 0;
  line-height: 1.5;
}
.z2-ai-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
  margin-top: 4px;
}
.z2-ai-suggestion {
  padding: 7px 14px;
  border-radius: 20px;
  border: 1px solid rgba(139, 92, 246, 0.2);
  background: rgba(139, 92, 246, 0.06);
  color: var(--z2ai-primary-light);
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}
.z2-ai-suggestion:hover {
  background: rgba(139, 92, 246, 0.15);
  border-color: rgba(139, 92, 246, 0.35);
  color: #fff;
  transform: translateY(-1px);
}

.z2-ai-msg {
  max-width: 82%;
  padding: 10px 14px;
  font-size: 13.5px;
  line-height: 1.55;
  word-wrap: break-word;
  animation: z2AiMsgIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes z2AiMsgIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
.z2-ai-msg a {
  color: var(--z2ai-accent);
  text-decoration: none;
  border-bottom: 1px solid rgba(34, 211, 238, 0.3);
  transition: border-color 0.2s;
  word-break: break-all;
}
.z2-ai-msg a:hover {
  border-color: var(--z2ai-accent);
}
.z2-ai-msg-user {
  align-self: flex-end;
  background: linear-gradient(135deg, var(--z2ai-primary), var(--z2ai-primary-dark));
  color: #fff;
  border-radius: 18px 18px 6px 18px;
  box-shadow: 0 2px 8px rgba(139, 92, 246, 0.25);
}
.z2-ai-msg-user a {
  color: #fff;
  border-bottom-color: rgba(255, 255, 255, 0.4);
}
.z2-ai-msg-assistant {
  align-self: flex-start;
  background: rgba(255, 255, 255, 0.05);
  color: rgba(255, 255, 255, 0.88);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 18px 18px 18px 6px;
}
.z2-ai-msg-assistant ul, .z2-ai-msg-assistant ol {
  padding-left: 16px;
  margin: 6px 0;
}
.z2-ai-msg-assistant li {
  margin-bottom: 3px;
}
.z2-ai-msg-assistant strong {
  color: var(--z2ai-primary-light);
  font-weight: 600;
}
.z2-ai-msg-assistant code {
  background: rgba(139, 92, 246, 0.12);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 12px;
  color: var(--z2ai-accent);
}

.z2-ai-typing {
  align-self: flex-start;
  padding: 12px 18px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 18px 18px 18px 6px;
  display: none;
  gap: 5px;
  align-items: center;
}
.z2-ai-typing.show { display: flex; }
.z2-ai-typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--z2ai-primary-light);
  animation: z2AiDot 1.4s ease-in-out infinite;
}
.z2-ai-typing span:nth-child(2) { animation-delay: 0.2s; }
.z2-ai-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes z2AiDot {
  0%, 80%, 100% { opacity: 0.25; transform: scale(0.7); }
  40% { opacity: 1; transform: scale(1); }
}

.z2-ai-input-area {
  padding: 14px 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  display: flex;
  gap: 10px;
  align-items: flex-end;
  background: rgba(0, 0, 0, 0.15);
}
.z2-ai-input {
  flex: 1;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  padding: 10px 14px;
  color: var(--z2ai-text);
  font-size: 13.5px;
  resize: none;
  min-height: 20px;
  max-height: 80px;
  outline: none;
  font-family: inherit;
  line-height: 1.45;
  transition: border-color 0.2s, background 0.2s;
}
.z2-ai-input::placeholder { color: rgba(255, 255, 255, 0.3); }
.z2-ai-input:focus {
  border-color: rgba(139, 92, 246, 0.4);
  background: rgba(255, 255, 255, 0.08);
}
.z2-ai-send {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  border: none;
  background: linear-gradient(135deg, var(--z2ai-primary), var(--z2ai-primary-dark));
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.2s;
  box-shadow: 0 2px 8px rgba(139, 92, 246, 0.3);
}
.z2-ai-send:hover {
  box-shadow: 0 4px 16px rgba(139, 92, 246, 0.45);
  transform: translateY(-1px);
}
.z2-ai-send:active {
  transform: translateY(0) scale(0.95);
}
.z2-ai-send:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
}
.z2-ai-send svg { width: 18px; height: 18px; fill: #fff; }

.z2-ai-footer {
  padding: 8px 16px 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border-top: 1px solid rgba(255, 255, 255, 0.04);
}
.z2-ai-footer span {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.3);
}
.z2-ai-footer a {
  font-size: 11px;
  color: rgba(139, 92, 246, 0.5);
  text-decoration: none;
  transition: color 0.2s;
}
.z2-ai-footer a:hover {
  color: var(--z2ai-primary-light);
}
.z2-ai-footer svg {
  width: 12px;
  height: 12px;
  fill: rgba(139, 92, 246, 0.4);
}

@media (max-width: 480px) {
  .z2-ai-panel {
    bottom: 0;
    left: 0;
    width: 100vw;
    max-width: 100vw;
    height: 100dvh;
    max-height: 100dvh;
    border-radius: 0;
  }
  .z2-ai-toggle {
    bottom: 16px;
    left: 16px;
    width: 52px;
    height: 52px;
  }
  .z2-ai-toggle .z2-ai-bot {
    width: 26px;
    height: 26px;
  }
  .z2-ai-toggle .z2-ai-bot-head {
    width: 24px;
    height: 18px;
    top: 4px;
  }
  .z2-ai-toggle .z2-ai-bot-eye {
    width: 4px;
    height: 4px;
  }
  .z2-ai-toggle .z2-ai-bot-mouth {
    top: 16px;
    left: 9px;
    width: 8px;
  }
  .z2-ai-welcome-icon {
    width: 48px;
    height: 48px;
    font-size: 24px;
  }
}

.z2-ai-cursor {
  display: inline-block;
  width: 2px;
  height: 1em;
  background: var(--z2ai-primary-light);
  margin-left: 2px;
  vertical-align: text-bottom;
  animation: z2AiCursorBlink 0.8s step-end infinite;
}

@keyframes z2AiCursorBlink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

.z2-ai-msg-streaming {
  min-height: 24px;
}
