:root {
  --ai-widget-primary: #38bdf8;
  --ai-widget-primary-dark: #0f3b66;
  --ai-widget-accent: #67e8f9;
  --ai-widget-ink: #eaf6ff;
  --ai-widget-muted: #94a3b8;
  --ai-widget-line: rgba(125, 211, 252, 0.24);
  --ai-widget-bg: #07111f;
  --ai-widget-soft: #0d1b2f;
  --ai-widget-shadow: 0 24px 70px rgba(2, 6, 23, 0.46);
}

.ai-human-widget,
.ai-human-widget * {
  box-sizing: border-box;
}

.ai-human-widget {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 2147483000;
  font-family:
    Inter, "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
  color: var(--ai-widget-ink);
}

.ai-human-presence {
  position: absolute;
  right: 0;
  bottom: 58px;
  width: 216px;
  height: 270px;
  border: 0;
  border-radius: 8px;
  padding: 0;
  background: transparent;
  cursor: pointer;
  filter: drop-shadow(0 22px 32px rgba(2, 6, 23, 0.38));
  transform-origin: right bottom;
  transition:
    opacity 180ms ease,
    transform 180ms ease,
    filter 180ms ease;
  animation: aiPresenceDrift 5.6s ease-in-out infinite;
}

.ai-human-presence:hover {
  filter:
    drop-shadow(0 24px 36px rgba(2, 6, 23, 0.42))
    drop-shadow(0 0 24px rgba(56, 189, 248, 0.18));
  transform: translateY(-5px) scale(1.02);
  animation-play-state: paused;
}

.ai-human-presence-frame {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 216px;
  height: 270px;
  overflow: visible;
  border: 0;
  border-radius: 8px;
  background: transparent;
  box-shadow: none;
}

.ai-human-presence-image {
  position: absolute;
  left: 50%;
  bottom: 0;
  width: auto;
  height: 270px;
  max-width: none;
  transform: translateX(-50%);
  user-select: none;
  pointer-events: none;
  filter:
    drop-shadow(0 24px 26px rgba(2, 6, 23, 0.38))
    drop-shadow(0 0 22px rgba(56, 189, 248, 0.24));
  transform-origin: center bottom;
  animation: aiPresenceBreath 4.8s ease-in-out infinite;
}

.ai-human-presence-bubble {
  position: absolute;
  right: 154px;
  bottom: 190px;
  width: 214px;
  border: 1px solid rgba(125, 211, 252, 0.32);
  border-radius: 8px;
  padding: 11px 13px;
  background: rgba(7, 17, 31, 0.82);
  box-shadow: 0 18px 38px rgba(2, 6, 23, 0.28);
  color: #dff7ff;
  font-size: 13px;
  line-height: 1.55;
  text-align: left;
  backdrop-filter: blur(14px);
  animation: aiPresenceBubble 4.8s ease-in-out infinite;
}

.ai-human-presence-bubble strong {
  display: block;
  margin-bottom: 4px;
  color: #ffffff;
  font-size: 13px;
}

.ai-human-size {
  position: absolute;
  right: 8px;
  bottom: 286px;
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 1px solid rgba(221, 249, 255, 0.34);
  border-radius: 999px;
  background: rgba(32, 58, 79, 0.78);
  color: #dff7ff;
  box-shadow:
    0 14px 30px rgba(2, 6, 23, 0.28),
    inset 0 1px 0 rgba(255, 255, 255, 0.14);
  cursor: pointer;
  overflow: hidden;
  backdrop-filter: blur(14px);
  transition:
    transform 180ms ease,
    border-color 180ms ease,
    background 180ms ease,
    box-shadow 180ms ease;
}

.ai-human-size::before {
  content: "";
  position: absolute;
  inset: 4px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: inherit;
  pointer-events: none;
}

.ai-human-size::after {
  display: none;
}

.ai-human-size:hover {
  transform: translateY(-2px);
  border-color: rgba(125, 211, 252, 0.58);
  background: rgba(42, 76, 100, 0.86);
  box-shadow:
    0 16px 34px rgba(2, 6, 23, 0.32),
    0 0 18px rgba(56, 189, 248, 0.16),
    inset 0 1px 0 rgba(255, 255, 255, 0.18);
}

.ai-human-widget.is-mini .ai-human-launcher {
  animation: aiLauncherPulse 3.4s ease-in-out infinite;
}

.ai-human-size svg {
  position: relative;
  z-index: 1;
  width: 16px;
  height: 16px;
  filter: none;
}

.ai-human-launcher {
  position: relative;
  display: inline-grid;
  width: 58px;
  height: 58px;
  place-items: center;
  border: 1px solid rgba(103, 232, 249, 0.72);
  border-radius: 50%;
  padding: 0;
  color: #fff;
  background:
    radial-gradient(circle at 50% 50%, rgba(56, 189, 248, 0.26), transparent 48%),
    rgba(2, 8, 23, 0.78);
  box-shadow:
    0 12px 34px rgba(2, 6, 23, 0.36),
    0 0 0 6px rgba(56, 189, 248, 0.1),
    inset 0 0 18px rgba(103, 232, 249, 0.18);
  backdrop-filter: blur(14px);
  cursor: pointer;
  overflow: hidden;
  transition:
    transform 180ms ease,
    box-shadow 180ms ease;
}

.ai-human-widget:not(.is-mini) .ai-human-launcher {
  opacity: 0;
  pointer-events: none;
  transform: scale(0.78);
}

.ai-human-widget.is-mini .ai-human-presence {
  opacity: 0;
  pointer-events: none;
  transform: translateY(12px) scale(0.66);
}

.ai-human-widget.is-mini .ai-human-size {
  bottom: 68px;
}

.ai-human-launcher::after {
  content: "";
  position: absolute;
  right: 5px;
  bottom: 5px;
  width: 11px;
  height: 11px;
  border: 2px solid #07111f;
  border-radius: 50%;
  background: #22c55e;
  box-shadow:
    0 0 0 4px rgba(34, 197, 94, 0.14),
    0 0 14px rgba(34, 197, 94, 0.72);
}

.ai-human-launcher:hover {
  transform: translateY(-2px);
  box-shadow:
    0 16px 42px rgba(56, 189, 248, 0.26),
    0 0 0 7px rgba(34, 211, 238, 0.14),
    inset 0 0 22px rgba(103, 232, 249, 0.22);
}

.ai-human-launcher-avatar {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: #0f172a;
  object-fit: cover;
  object-position: top center;
}

.ai-human-launcher-label {
  display: none;
}

.ai-human-launcher-label strong {
  font-size: 14px;
  line-height: 1.1;
  white-space: nowrap;
}

.ai-human-launcher-label span {
  color: rgba(255, 255, 255, 0.82);
  font-size: 12px;
  white-space: nowrap;
}

.ai-human-panel {
  position: absolute;
  right: 0;
  bottom: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  width: min(392px, calc(100vw - 28px));
  height: min(660px, calc(100vh - 92px));
  overflow: hidden;
  overscroll-behavior: contain;
  border: 1px solid rgba(125, 211, 252, 0.34);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(13, 27, 47, 0.98), rgba(7, 17, 31, 0.98)),
    var(--ai-widget-bg);
  box-shadow:
    var(--ai-widget-shadow),
    0 0 0 1px rgba(255, 255, 255, 0.04) inset,
    0 0 42px rgba(56, 189, 248, 0.18);
  opacity: 0;
  pointer-events: none;
  transform: translateY(16px) scale(0.98);
  transition:
    opacity 180ms ease,
    transform 180ms ease;
}

.ai-human-widget.is-open .ai-human-panel {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0) scale(1);
}

.ai-human-widget.is-open .ai-human-launcher {
  opacity: 0;
  pointer-events: none;
}

.ai-human-widget.is-open .ai-human-presence,
.ai-human-widget.is-open .ai-human-size {
  opacity: 0;
  pointer-events: none;
}

.ai-human-hero {
  position: relative;
  min-height: 206px;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 60%, rgba(56, 189, 248, 0.34), transparent 34%),
    radial-gradient(circle at 18% 22%, rgba(14, 165, 233, 0.42), transparent 28%),
    linear-gradient(135deg, rgba(2, 6, 23, 0.72), rgba(8, 47, 73, 0.92)),
    #06101f;
}

.ai-human-hero::before,
.ai-human-hero::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.ai-human-hero::before {
  background:
    linear-gradient(rgba(125, 211, 252, 0.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(125, 211, 252, 0.08) 1px, transparent 1px);
  background-size: 28px 28px;
  mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.72), transparent 82%);
}

.ai-human-hero::after {
  background:
    linear-gradient(90deg, transparent 0 12%, rgba(103, 232, 249, 0.36) 50%, transparent 88%),
    linear-gradient(180deg, transparent, rgba(103, 232, 249, 0.12), transparent);
  height: 1px;
  top: auto;
  bottom: 0;
}

.ai-human-topbar {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 14px 0;
}

.ai-human-title {
  min-width: 0;
}

.ai-human-title strong,
.ai-human-title span {
  display: block;
}

.ai-human-title strong {
  color: #f8fbff;
  font-size: 15px;
  line-height: 1.2;
}

.ai-human-title span {
  margin-top: 3px;
  color: rgba(186, 230, 253, 0.76);
  font-size: 12px;
}

.ai-human-close {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 1px solid rgba(125, 211, 252, 0.32);
  border-radius: 50%;
  background: rgba(8, 47, 73, 0.46);
  color: #dff7ff;
  cursor: pointer;
}

.ai-human-close svg {
  width: 18px;
  height: 18px;
}

.ai-human-avatar-stage {
  position: absolute;
  inset: 56px 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ai-human-avatar {
  width: 136px;
  height: 136px;
  border: 1px solid rgba(103, 232, 249, 0.82);
  border-radius: 50%;
  background: #0f172a;
  object-fit: cover;
  object-position: center center;
  box-shadow:
    0 18px 38px rgba(2, 6, 23, 0.46),
    0 0 0 7px rgba(56, 189, 248, 0.16),
    0 0 30px rgba(103, 232, 249, 0.34);
  transform-origin: center center;
  animation: aiHumanIdle 3.6s ease-in-out infinite;
}

.ai-human-speaking .ai-human-avatar {
  animation: aiHumanTalk 680ms ease-in-out infinite;
}

.ai-human-status {
  position: absolute;
  right: 14px;
  bottom: 12px;
  display: flex;
  align-items: center;
  gap: 7px;
  border-radius: 999px;
  padding: 6px 10px;
  border: 1px solid rgba(125, 211, 252, 0.26);
  background: rgba(2, 8, 23, 0.52);
  color: #dff7ff;
  font-size: 12px;
  font-weight: 700;
  backdrop-filter: blur(10px);
}

.ai-human-status::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 0 4px rgba(34, 197, 94, 0.16);
}

.ai-human-messages {
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  touch-action: pan-y;
  scrollbar-color: rgba(103, 232, 249, 0.32) rgba(15, 34, 55, 0.18);
  scrollbar-width: thin;
  padding: 16px 14px;
  background:
    radial-gradient(circle at 20% 0%, rgba(56, 189, 248, 0.08), transparent 36%),
    #07111f;
}

.ai-human-messages::-webkit-scrollbar {
  width: 8px;
}

.ai-human-messages::-webkit-scrollbar-track {
  background: rgba(15, 34, 55, 0.18);
  border-radius: 999px;
}

.ai-human-messages::-webkit-scrollbar-thumb {
  border: 2px solid rgba(15, 34, 55, 0.18);
  border-radius: 999px;
  background:
    linear-gradient(180deg, rgba(103, 232, 249, 0.42), rgba(167, 139, 250, 0.34));
}

.ai-human-messages::-webkit-scrollbar-thumb:hover {
  background:
    linear-gradient(180deg, rgba(126, 244, 255, 0.56), rgba(196, 181, 253, 0.46));
}

.ai-human-message {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  width: 100%;
  min-width: 0;
  font-size: 14px;
  line-height: 1.65;
}

.ai-human-message.bot {
  justify-content: flex-start;
}

.ai-human-message.user {
  justify-content: flex-start;
  flex-direction: row-reverse;
}

.ai-human-message-avatar {
  flex: 0 0 auto;
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  margin-top: 2px;
  overflow: hidden;
  border: 1px solid rgba(125, 211, 252, 0.26);
  border-radius: 50%;
  background: rgba(15, 34, 55, 0.86);
  color: #dff7ff;
  font-size: 12px;
  font-weight: 700;
  box-shadow: 0 8px 18px rgba(2, 6, 23, 0.2);
}

.ai-human-message-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top center;
}

.ai-human-message.user .ai-human-message-avatar {
  border-color: rgba(147, 197, 253, 0.42);
  background: linear-gradient(135deg, #67e8f9, #93c5fd);
  color: #031421;
}

.ai-human-message-bubble {
  position: relative;
  max-width: min(78%, 284px);
  min-width: 0;
  border-radius: 8px;
  padding: 10px 12px;
  overflow-wrap: anywhere;
  word-break: break-word;
  white-space: pre-wrap;
}

.ai-human-message.bot .ai-human-message-bubble {
  border: 1px solid var(--ai-widget-line);
  background: rgba(15, 34, 55, 0.72);
  color: #f8fbff;
  box-shadow: 0 10px 24px rgba(2, 6, 23, 0.2);
}

.ai-human-message.user .ai-human-message-bubble {
  color: #031421;
  background: linear-gradient(135deg, #67e8f9, #93c5fd);
}

.ai-human-message.ai-human-typing .ai-human-message-bubble {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: rgba(248, 251, 255, 0.82);
}

.ai-human-typing-label {
  font-size: 13px;
}

.ai-human-typing-dots {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding-top: 2px;
}

.ai-human-typing-dots i {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: rgba(103, 232, 249, 0.74);
  animation: aiHumanTyping 920ms ease-in-out infinite;
}

.ai-human-typing-dots i:nth-child(2) {
  animation-delay: 130ms;
}

.ai-human-typing-dots i:nth-child(3) {
  animation-delay: 260ms;
}

.ai-human-quick {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 14px 12px;
  background: #07111f;
}

.ai-human-chip {
  border: 1px solid rgba(125, 211, 252, 0.28);
  border-radius: 999px;
  padding: 7px 10px;
  background: rgba(15, 34, 55, 0.76);
  color: #dff7ff;
  font-size: 12px;
  cursor: pointer;
}

.ai-human-chip:hover {
  border-color: rgba(103, 232, 249, 0.68);
  color: #ffffff;
  box-shadow: 0 0 18px rgba(56, 189, 248, 0.16);
}

.ai-human-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 42px;
  gap: 8px;
  border-top: 1px solid var(--ai-widget-line);
  padding: 12px;
  background: rgba(5, 13, 25, 0.98);
}

.ai-human-input {
  width: 100%;
  height: 42px;
  border: 1px solid rgba(125, 211, 252, 0.34);
  border-radius: 8px;
  padding: 0 12px;
  color: #f8fbff;
  background: rgba(15, 34, 55, 0.72);
  font: inherit;
  outline: none;
}

.ai-human-input:focus {
  border-color: var(--ai-widget-primary);
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.16);
}

.ai-human-send {
  display: inline-grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 8px;
  background: linear-gradient(135deg, #38bdf8, #a78bfa);
  color: #02111f;
  cursor: pointer;
}

.ai-human-send svg {
  width: 18px;
  height: 18px;
}

.ai-human-send:hover {
  background: linear-gradient(135deg, #67e8f9, #c4b5fd);
}

@keyframes aiHumanIdle {
  0%,
  100% {
    transform: translateY(0) rotate(0deg);
  }

  50% {
    transform: translateY(-5px) rotate(0.4deg);
  }
}

@keyframes aiHumanBubbleIn {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes aiHumanBlink {
  0%,
  88%,
  94%,
  100% {
    opacity: 0;
    transform: scaleY(0.1);
  }

  90%,
  92% {
    opacity: 0.96;
    transform: scaleY(1);
  }
}

@keyframes aiHumanWave {
  0%,
  68%,
  100% {
    transform: translateY(0) rotate(0deg);
  }

  73% {
    transform: translateY(-4px) rotate(-2.2deg);
  }

  78% {
    transform: translateY(-2px) rotate(2.1deg);
  }

  83% {
    transform: translateY(-4px) rotate(-1.6deg);
  }

  88% {
    transform: translateY(0) rotate(0deg);
  }
}

@keyframes aiPresenceDrift {
  0%,
  100% {
    transform: translateY(0);
  }

  50% {
    transform: translateY(-6px);
  }
}

@keyframes aiPresenceBreath {
  0%,
  100% {
    transform: translateX(-50%) scale(1);
  }

  50% {
    transform: translateX(-50%) scale(1.018);
  }
}

@keyframes aiPresenceBubble {
  0%,
  100% {
    box-shadow: 0 18px 38px rgba(2, 6, 23, 0.28);
  }

  50% {
    box-shadow:
      0 18px 38px rgba(2, 6, 23, 0.32),
      0 0 20px rgba(56, 189, 248, 0.14);
  }
}

@keyframes aiLauncherPulse {
  0%,
  100% {
    box-shadow:
      0 12px 34px rgba(2, 6, 23, 0.36),
      0 0 0 6px rgba(56, 189, 248, 0.1),
      inset 0 0 18px rgba(103, 232, 249, 0.18);
  }

  50% {
    box-shadow:
      0 14px 38px rgba(56, 189, 248, 0.24),
      0 0 0 8px rgba(56, 189, 248, 0.13),
      inset 0 0 22px rgba(103, 232, 249, 0.22);
  }
}

@media (prefers-reduced-motion: reduce) {
  .ai-human-presence,
  .ai-human-presence-image,
  .ai-human-presence-bubble,
  .ai-human-widget.is-mini .ai-human-launcher {
    animation: none;
  }
}

@keyframes aiHumanTalk {
  0%,
  100% {
    transform: translateY(0) scale(1);
  }

  50% {
    transform: translateY(-3px) scale(1.018);
  }
}

@keyframes aiHumanTyping {
  0%,
  80%,
  100% {
    opacity: 0.32;
    transform: translateY(0);
  }

  40% {
    opacity: 1;
    transform: translateY(-3px);
  }
}

@media (max-width: 520px) {
  .ai-human-widget {
    right: 12px;
    bottom: 12px;
  }

  .ai-human-presence {
    bottom: 58px;
    width: 160px;
    height: 204px;
  }

  .ai-human-presence-frame {
    width: 160px;
    height: 204px;
  }

  .ai-human-presence-image {
    height: 204px;
  }

  .ai-human-presence-bubble {
    display: none;
  }

  .ai-human-size {
    right: 4px;
    bottom: 238px;
  }

  .ai-human-launcher {
    width: 52px;
    height: 52px;
  }

  .ai-human-launcher-avatar {
    width: 46px;
    height: 46px;
  }

  .ai-human-panel {
    right: -7px;
    bottom: 0;
    height: min(632px, calc(100vh - 72px));
  }

  .ai-human-message-bubble {
    max-width: min(76%, 260px);
  }

  .ai-human-launcher-label span {
    display: none;
  }
}
