.zp-ai,
.zp-ai * {
  box-sizing: border-box;
}

.zp-ai {
  --zp-ai-primary: #409eff;
  --zp-ai-primary-dark: #1e78d7;
  --zp-ai-ink: #172033;
  --zp-ai-muted: #64748b;
  --zp-ai-line: #dce6f2;
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 90;
  font-family: Inter, "Microsoft YaHei", "PingFang SC", system-ui, -apple-system, sans-serif;
}

.zp-ai__launcher {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 54px;
  padding: 0 18px;
  border: 0;
  border-radius: 999px;
  background: linear-gradient(135deg, #409eff, #1e78d7);
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 12px 32px rgba(30, 120, 215, 0.34);
  transition: transform 160ms ease, box-shadow 160ms ease;
}

.zp-ai__launcher:hover {
  transform: translateY(-2px);
  box-shadow: 0 16px 38px rgba(30, 120, 215, 0.4);
}

.zp-ai__launcher:focus-visible,
.zp-ai button:focus-visible,
.zp-ai textarea:focus-visible {
  outline: 3px solid rgba(64, 158, 255, 0.32);
  outline-offset: 2px;
}

.zp-ai__launcher-icon {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.18);
  font-size: 19px;
}

.zp-ai__panel {
  position: absolute;
  right: 0;
  bottom: 68px;
  display: flex;
  width: min(390px, calc(100vw - 28px));
  height: min(620px, calc(100vh - 118px));
  min-height: 460px;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid rgba(148, 163, 184, 0.32);
  border-radius: 18px;
  background: #fff;
  color: var(--zp-ai-ink);
  box-shadow: 0 24px 70px rgba(15, 34, 64, 0.24);
  transform-origin: right bottom;
  animation: zp-ai-in 180ms ease-out;
}

.zp-ai__panel[hidden] {
  display: none;
}

@keyframes zp-ai-in {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.98);
  }
}

.zp-ai__header {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 15px 16px;
  background: linear-gradient(135deg, #0b2f5b, #164f8c);
  color: #fff;
}

.zp-ai__avatar {
  display: grid;
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 13px;
  background: linear-gradient(145deg, #63b3ff, #409eff);
  font-size: 22px;
}

.zp-ai__identity {
  min-width: 0;
  flex: 1;
}

.zp-ai__title {
  margin: 0;
  font-size: 16px;
  font-weight: 800;
  line-height: 1.35;
}

.zp-ai__status {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 3px;
  color: #cfe7ff;
  font-size: 12px;
}

.zp-ai__status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #5ee394;
  box-shadow: 0 0 0 3px rgba(94, 227, 148, 0.16);
}

.zp-ai__header-actions {
  display: flex;
  gap: 4px;
}

.zp-ai__icon-button {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: inherit;
  cursor: pointer;
  font-size: 18px;
}

.zp-ai__icon-button:hover {
  background: rgba(255, 255, 255, 0.12);
}

.zp-ai__messages {
  flex: 1;
  overflow-y: auto;
  padding: 17px 15px 12px;
  background:
    radial-gradient(circle at 100% 0, rgba(64, 158, 255, 0.08), transparent 32%),
    #f7f9fc;
  scroll-behavior: smooth;
}

.zp-ai__message {
  display: flex;
  margin: 0 0 13px;
}

.zp-ai__message--user {
  justify-content: flex-end;
}

.zp-ai__message--human .zp-ai__bubble {
  border-color: #93c5fd;
  background: #eff6ff;
  color: #123a63;
}

.zp-ai__message--system {
  justify-content: center;
}

.zp-ai__message--system .zp-ai__bubble {
  max-width: 94%;
  border: 0;
  background: transparent;
  color: #64748b;
  font-size: 12px;
  text-align: center;
  box-shadow: none;
}

.zp-ai__bubble {
  max-width: 86%;
  padding: 10px 12px;
  border: 1px solid var(--zp-ai-line);
  border-radius: 5px 15px 15px 15px;
  background: #fff;
  color: #273449;
  font-size: 14px;
  line-height: 1.65;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
  box-shadow: 0 3px 12px rgba(31, 58, 92, 0.06);
}

.zp-ai__message--user .zp-ai__bubble {
  border-color: var(--zp-ai-primary);
  border-radius: 15px 5px 15px 15px;
  background: var(--zp-ai-primary);
  color: #fff;
}

.zp-ai__typing {
  display: inline-flex;
  gap: 4px;
  align-items: center;
  min-width: 52px;
}

.zp-ai__typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #8aa1ba;
  animation: zp-ai-typing 1.1s infinite ease-in-out;
}

.zp-ai__typing span:nth-child(2) {
  animation-delay: 140ms;
}

.zp-ai__typing span:nth-child(3) {
  animation-delay: 280ms;
}

@keyframes zp-ai-typing {
  0%,
  60%,
  100% {
    transform: translateY(0);
    opacity: 0.45;
  }
  30% {
    transform: translateY(-4px);
    opacity: 1;
  }
}

.zp-ai__suggestions {
  display: flex;
  gap: 7px;
  margin: 2px 0 14px;
  padding-left: 1px;
  overflow-x: auto;
  scrollbar-width: thin;
}

.zp-ai__suggestion {
  flex: 0 0 auto;
  padding: 7px 10px;
  border: 1px solid #b8d8fa;
  border-radius: 999px;
  background: #fff;
  color: #2469ad;
  font-size: 12px;
  cursor: pointer;
}

.zp-ai__suggestion:hover {
  border-color: var(--zp-ai-primary);
  background: #edf7ff;
}

.zp-ai__composer {
  border-top: 1px solid var(--zp-ai-line);
  background: #fff;
  padding: 11px 12px 10px;
}

.zp-ai__handoff-button {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: center;
  gap: 7px;
  margin-bottom: 9px;
  padding: 8px 12px;
  border: 1px solid #b8d8fa;
  border-radius: 10px;
  background: #f3f8ff;
  color: #2469ad;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
}

.zp-ai__handoff-button:hover {
  border-color: var(--zp-ai-primary);
  background: #eaf4ff;
}

.zp-ai__handoff-form {
  display: grid;
  gap: 8px;
}

.zp-ai__handoff-form[hidden],
.zp-ai__form[hidden],
.zp-ai__handoff-button[hidden] {
  display: none;
}

.zp-ai__handoff-title {
  color: #172033;
  font-size: 14px;
  font-weight: 900;
}

.zp-ai__handoff-note {
  margin: 0 0 2px;
  color: #64748b;
  font-size: 11px;
  line-height: 1.5;
}

.zp-ai__handoff-form input {
  width: 100%;
  min-height: 38px;
  border: 1px solid #cfdceb;
  border-radius: 9px;
  background: #f8fafc;
  color: #172033;
  font: inherit;
  font-size: 13px;
  padding: 8px 10px;
}

.zp-ai__handoff-form input:focus {
  border-color: var(--zp-ai-primary);
  background: #fff;
  outline: none;
}

.zp-ai__handoff-actions {
  display: grid;
  grid-template-columns: 1fr 1.5fr;
  gap: 8px;
}

.zp-ai__handoff-actions button {
  min-height: 38px;
  border-radius: 9px;
  font-weight: 800;
  cursor: pointer;
}

.zp-ai__handoff-cancel {
  border: 1px solid #cfdceb;
  background: #fff;
  color: #475569;
}

.zp-ai__handoff-submit {
  border: 1px solid var(--zp-ai-primary);
  background: var(--zp-ai-primary);
  color: #fff;
}

.zp-ai__handoff-submit:disabled {
  cursor: wait;
  opacity: 0.62;
}

.zp-ai__honeypot {
  position: absolute !important;
  left: -10000px !important;
  width: 1px !important;
  height: 1px !important;
  opacity: 0 !important;
  pointer-events: none !important;
}

.zp-ai__form {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}

.zp-ai__input {
  width: 100%;
  min-height: 42px;
  max-height: 112px;
  resize: none;
  border: 1px solid #cfdceb;
  border-radius: 12px;
  background: #f8fafc;
  color: var(--zp-ai-ink);
  font: inherit;
  font-size: 14px;
  line-height: 1.45;
  padding: 10px 11px;
}

.zp-ai__input:focus {
  border-color: var(--zp-ai-primary);
  background: #fff;
  outline: none;
}

.zp-ai__send {
  display: grid;
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  place-items: center;
  border: 0;
  border-radius: 12px;
  background: var(--zp-ai-primary);
  color: #fff;
  cursor: pointer;
  font-size: 19px;
}

.zp-ai__send:hover {
  background: var(--zp-ai-primary-dark);
}

.zp-ai__send:disabled,
.zp-ai__input:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

.zp-ai__privacy {
  margin: 7px 2px 0;
  color: var(--zp-ai-muted);
  font-size: 10px;
  line-height: 1.45;
  text-align: center;
}

@media (max-width: 540px) {
  .zp-ai {
    right: 12px;
    bottom: 12px;
  }

  .zp-ai__launcher {
    min-height: 50px;
    padding: 0 14px;
  }

  .zp-ai__panel {
    position: fixed;
    inset: 10px 10px 72px;
    width: auto;
    height: auto;
    min-height: 0;
    border-radius: 16px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .zp-ai__panel,
  .zp-ai__typing span,
  .zp-ai__launcher {
    animation: none;
    transition: none;
  }
}
