:root {
  --assistant-left-gap: 24px;
  --assistant-bottom-gap: 116px;
  --assistant-z-index: 9999;
  --assistant-cyan: #64d6d2;
  --assistant-blue: #38bdf8;
  --assistant-amber: #d8a24f;
  --assistant-bg: rgba(8, 16, 23, 0.9);
  --assistant-panel: rgba(15, 23, 42, 0.85);
  --assistant-line: rgba(34, 211, 238, 0.75);
  --assistant-soft-line: rgba(34, 211, 238, 0.18);
  --assistant-text: #e7f4f4;
  --assistant-muted: #7e939a;
}

.ai-assistant {
  position: fixed;
  left: var(--assistant-left-gap);
  bottom: var(--assistant-bottom-gap);
  width: 96px;
  height: 96px;
  z-index: var(--assistant-z-index);
  pointer-events: none;
  color: var(--assistant-text);
  font-family: "SF Pro Display", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
}

.ai-chick-trigger,
.ai-panel {
  pointer-events: auto;
}

.ai-chick-tip {
  position: absolute;
  left: 50%;
  top: -27px;
  z-index: 8;
  width: max-content;
  max-width: 180px;
  transform: translate(-50%, 0);
  pointer-events: none;
  padding: 2px 6px;
  border: 1px solid rgba(100, 214, 210, 0.22);
  background: rgba(5, 14, 19, 0.44);
  color: #9ffbf2;
  box-shadow: 0 0 18px rgba(34, 211, 238, 0.1);
  text-shadow:
    0 0 6px rgba(100, 214, 210, 0.7),
    0 0 12px rgba(56, 189, 248, 0.34);
  font-family: "Silkscreen", "Press Start 2P", "Pixelify Sans", "Courier New", ui-monospace, SFMono-Regular, monospace;
  font-size: 9px;
  line-height: 1.25;
  letter-spacing: 0.08em;
  white-space: nowrap;
  opacity: 0.82;
  text-rendering: geometricPrecision;
  -webkit-font-smoothing: none;
  font-smooth: never;
  animation: aiChickTipFloat 3.8s ease-in-out infinite;
}

.ai-chick-trigger {
  position: relative;
  width: 96px;
  height: 96px;
  border: 0;
  padding: 0;
  background: transparent;
  cursor: pointer;
  display: grid;
  place-items: center;
  transform: translateZ(0);
  animation: aiChickFloat 4.8s ease-in-out infinite;
}

.ai-chick-trigger:focus-visible {
  outline: 2px solid var(--assistant-cyan);
  outline-offset: 5px;
}

.ai-chick-media {
  position: absolute;
  z-index: 2;
  width: 100%;
  height: 100%;
  object-fit: contain;
  opacity: 0;
  filter:
    drop-shadow(0 0 8px rgba(34, 211, 238, 0.25))
    drop-shadow(0 0 18px rgba(56, 189, 248, 0.18));
  transform: translateZ(0);
  transition: opacity 180ms ease, transform 180ms ease, filter 180ms ease;
}

.ai-chick-media[data-ready="true"] {
  opacity: 1;
}

.ai-chick-fallback {
  position: absolute;
  z-index: 1;
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter:
    drop-shadow(0 0 8px rgba(34, 211, 238, 0.24))
    drop-shadow(0 0 18px rgba(216, 162, 79, 0.12));
  transform: translateZ(0);
  transition: transform 180ms ease, filter 180ms ease;
}

.ai-chick-trigger:hover .ai-chick-media,
.ai-chick-trigger:hover .ai-chick-fallback,
.ai-assistant.is-panel-open .ai-chick-media,
.ai-assistant.is-panel-open .ai-chick-fallback {
  transform: translateY(-2px) scale(1.035);
  filter:
    drop-shadow(0 0 10px rgba(34, 211, 238, 0.34))
    drop-shadow(0 0 24px rgba(216, 162, 79, 0.16));
}

.ai-chick-glow {
  position: absolute;
  inset: 18% 18% 10% 18%;
  border-radius: 999px;
  background: radial-gradient(
    ellipse at center,
    rgba(34, 211, 238, 0.22) 0%,
    rgba(34, 211, 238, 0.08) 45%,
    rgba(34, 211, 238, 0) 75%
  );
  z-index: -1;
  pointer-events: none;
  animation: aiChickGlow 2.8s ease-in-out infinite;
}

.ai-status-chip {
  display: none;
}

.ai-assistant[data-state="thinking"] .ai-status-chip {
  color: var(--assistant-amber);
  border-color: rgba(216, 162, 79, 0.52);
}

.ai-assistant[data-state="thinking"] .ai-chick-trigger {
  animation-duration: 2.4s;
}

.ai-assistant[data-state="thinking"] .ai-chick-glow {
  background: radial-gradient(
    ellipse at center,
    rgba(216, 162, 79, 0.22) 0%,
    rgba(34, 211, 238, 0.12) 48%,
    rgba(34, 211, 238, 0) 75%
  );
}

.ai-panel {
  position: absolute;
  left: 112px;
  bottom: 12px;
  width: 420px;
  height: 540px;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--assistant-line);
  border-radius: 16px;
  background: var(--assistant-panel);
  backdrop-filter: blur(18px);
  box-shadow:
    0 0 0 1px rgba(34, 211, 238, 0.08) inset,
    0 12px 40px rgba(2, 6, 23, 0.55),
    0 0 28px rgba(34, 211, 238, 0.12);
  overflow: hidden;
  transform-origin: left bottom;
  transition:
    opacity 180ms ease,
    transform 220ms cubic-bezier(.22, 1, .36, 1),
    visibility 180ms ease;
}

.ai-panel:before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(rgba(100, 214, 210, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(100, 214, 210, 0.035) 1px, transparent 1px);
  background-size: 28px 28px;
  mask-image: linear-gradient(180deg, #000 0%, rgba(0, 0, 0, 0.76) 52%, transparent 100%);
}

.ai-panel.is-hidden {
  opacity: 0;
  visibility: hidden;
  transform: translateY(12px) scale(0.98);
}

.ai-panel:not(.is-hidden) {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

.ai-panel-header {
  position: relative;
  z-index: 1;
  height: 54px;
  padding: 0 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--assistant-soft-line);
  background: linear-gradient(180deg, rgba(30, 41, 59, 0.68), rgba(15, 23, 42, 0.38));
}

.ai-panel-title-wrap {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 9px;
}

.ai-panel-dot {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: var(--assistant-cyan);
  box-shadow: 0 0 0 5px rgba(100, 214, 210, 0.08), 0 0 16px rgba(100, 214, 210, 0.42);
}

.ai-panel-title-group {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.ai-panel-title {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: #e9fbfb;
}

.ai-panel-subtitle {
  color: #6f858d;
  font: 8px ui-monospace, SFMono-Regular, monospace;
  letter-spacing: 0.15em;
}

.ai-panel-close {
  width: 32px;
  height: 32px;
  border: 1px solid rgba(100, 214, 210, 0.22);
  background: rgba(8, 17, 24, 0.55);
  color: #92a8ae;
  cursor: pointer;
  line-height: 1;
  transition: 160ms ease;
}

.ai-panel-close:hover {
  border-color: rgba(100, 214, 210, 0.7);
  color: var(--assistant-cyan);
}

.ai-message-list {
  position: relative;
  z-index: 1;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 16px 14px 14px;
  display: flex;
  flex-direction: column;
  gap: 11px;
  scrollbar-gutter: stable;
}

.ai-message-list::-webkit-scrollbar {
  width: 8px;
}

.ai-message-list::-webkit-scrollbar-thumb {
  background: rgba(100, 214, 210, 0.22);
  border: 2px solid rgba(8, 16, 23, 0.72);
}

.ai-msg {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.ai-msg-user {
  justify-content: flex-end;
}

.ai-msg-bubble {
  max-width: 82%;
  padding: 10px 11px;
  border: 1px solid rgba(100, 214, 210, 0.2);
  background: rgba(10, 22, 30, 0.72);
  color: #dbe8e9;
  font-size: 12px;
  line-height: 1.65;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.018);
}

.ai-msg-assistant .ai-msg-bubble {
  border-left-color: rgba(100, 214, 210, 0.72);
}

.ai-msg-user .ai-msg-bubble {
  color: #f4fbfb;
  border-color: rgba(216, 162, 79, 0.34);
  background: linear-gradient(180deg, rgba(41, 33, 19, 0.78), rgba(17, 28, 33, 0.72));
}

.ai-msg-system .ai-msg-bubble {
  max-width: 100%;
  color: #91aab0;
  border-style: dashed;
  font: 10px/1.55 ui-monospace, SFMono-Regular, monospace;
  letter-spacing: 0.04em;
}

.ai-typing {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--assistant-amber);
  font: 9px ui-monospace, SFMono-Regular, monospace;
  letter-spacing: 0.12em;
}

.ai-typing i {
  width: 4px;
  height: 4px;
  border-radius: 999px;
  background: currentColor;
  animation: aiTyping 900ms ease-in-out infinite;
}

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

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

.ai-panel-footer {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 72px;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid var(--assistant-soft-line);
  background: rgba(7, 14, 21, 0.76);
}

.ai-input {
  width: 100%;
  min-height: 46px;
  max-height: 96px;
  resize: none;
  border: 1px solid rgba(100, 214, 210, 0.24);
  background: rgba(4, 10, 15, 0.72);
  color: #edf7f7;
  padding: 10px 11px;
  font: 12px/1.45 "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
}

.ai-input::placeholder {
  color: #5f757d;
}

.ai-input:focus {
  outline: 0;
  border-color: rgba(100, 214, 210, 0.72);
  box-shadow: 0 0 0 1px rgba(100, 214, 210, 0.1), 0 0 18px rgba(34, 211, 238, 0.08);
}

.ai-send-btn {
  border: 1px solid rgba(100, 214, 210, 0.42);
  background: linear-gradient(180deg, rgba(18, 43, 48, 0.95), rgba(10, 25, 31, 0.95));
  color: var(--assistant-cyan);
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  transition: 160ms ease;
}

.ai-send-btn:hover:not(:disabled) {
  border-color: rgba(100, 214, 210, 0.82);
  background: linear-gradient(180deg, rgba(24, 57, 61, 0.98), rgba(12, 31, 37, 0.98));
}

.ai-send-btn:disabled,
.ai-input:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

@keyframes aiChickFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-5px); }
}

@keyframes aiChickTipFloat {
  0%, 100% { transform: translate(-50%, 0); opacity: 0.76; }
  50% { transform: translate(-50%, -5px); opacity: 1; }
}

@keyframes aiChickGlow {
  0%, 100% { opacity: 0.72; transform: scale(0.96); }
  50% { opacity: 1; transform: scale(1.08); }
}

@keyframes aiTyping {
  0%, 100% { opacity: 0.35; transform: translateY(0); }
  50% { opacity: 1; transform: translateY(-2px); }
}

@media (max-width: 1440px) {
  :root {
    --assistant-right-gap: 320px;
  }
}

@media (max-width: 1100px) {
  :root {
    --assistant-right-gap: 24px;
  }

  .ai-panel {
    right: 0;
    bottom: 112px;
    width: min(420px, calc(100vw - 48px));
    height: min(540px, calc(100dvh - 156px));
    transform-origin: right bottom;
  }
}

@media (max-width: 560px) {
  :root {
    --assistant-right-gap: 16px;
    --assistant-bottom-gap: 16px;
  }

  .ai-chick-trigger {
    width: 82px;
    height: 82px;
  }

  .ai-assistant {
    width: 82px;
    height: 82px;
  }

  .ai-chick-tip {
    top: -26px;
    max-width: 160px;
    font-size: 8px;
  }

  .ai-panel {
    width: calc(100vw - 32px);
    height: min(520px, calc(100dvh - 120px));
  }
}

@media (prefers-reduced-motion: reduce) {
  .ai-chick-trigger,
  .ai-chick-glow,
  .ai-chick-tip,
  .ai-typing i {
    animation: none !important;
  }

  .ai-panel,
  .ai-chick-media,
  .ai-send-btn {
    transition-duration: 0.001ms !important;
  }
}
