#codequest-ai-assistant {
  position: fixed;
  right: 22px;
  bottom: 18px;
  z-index: 2147483000;
  width: 560px;
  height: 138px;
  color: #eef8ff;
  font-family: "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
  pointer-events: none;
}

#codequest-ai-assistant * {
  box-sizing: border-box;
}

.cq-ai-avatar {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 126px;
  height: 126px;
  border: 0;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 52%, #fff4bd 0 48%, #1268d6 49% 70%, transparent 71%);
  box-shadow: 0 16px 28px rgba(7, 17, 32, 0.28), 0 0 0 5px rgba(255, 244, 189, 0.48);
  cursor: pointer;
  pointer-events: auto;
  touch-action: manipulation;
}

.cq-ai-avatar::before {
  content: "";
  position: absolute;
  left: 14px;
  top: 8px;
  width: 98px;
  height: 106px;
  background: url("../assets/owl-mentor.png") center bottom / contain no-repeat;
  filter: drop-shadow(0 7px 0 rgba(23, 32, 51, 0.16));
}

.cq-ai-avatar::after {
  content: "智能体";
  position: absolute;
  left: 19px;
  bottom: -4px;
  width: 88px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  color: #102033;
  background: #f5c35b;
  font-size: 14px;
  font-weight: 900;
  box-shadow: 0 5px 0 rgba(113, 63, 18, 0.24);
}

.cq-ai-status {
  position: absolute;
  right: 102px;
  bottom: 14px;
  max-width: 286px;
  min-height: 40px;
  padding: 9px 12px;
  border: 1px solid rgba(16, 52, 92, 0.18);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.96);
  color: #111827;
  font-size: 14px;
  line-height: 1.32;
  font-weight: 800;
  box-shadow: 0 12px 32px rgba(14, 31, 53, 0.12);
  pointer-events: none;
}

.cq-ai-panel {
  position: absolute;
  right: 136px;
  bottom: 96px;
  width: 540px;
  max-height: 548px;
  display: none;
  flex-direction: column;
  border: 1px solid rgba(162, 197, 233, 0.24);
  border-radius: 8px;
  overflow: hidden;
  background: rgba(7, 17, 32, 0.98);
  box-shadow: 0 24px 56px rgba(7, 17, 32, 0.42);
  pointer-events: auto;
  touch-action: auto;
}

#codequest-ai-assistant.open .cq-ai-panel {
  display: flex;
}

.cq-ai-panel header {
  min-height: 62px;
  padding: 11px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: linear-gradient(90deg, #0a356d, #1268d6);
  border-bottom: 1px solid rgba(255, 255, 255, 0.15);
}

.cq-ai-title {
  color: #ffffff;
  font-size: 20px;
  font-weight: 900;
}

.cq-ai-context {
  max-width: 390px;
  margin-top: 3px;
  color: #d8efff;
  font-size: 13px;
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cq-ai-close {
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 50%;
  background: #f5c35b;
  color: #102033;
  font-weight: 900;
  cursor: pointer;
}

.cq-ai-log {
  min-height: 220px;
  max-height: 320px;
  padding: 14px;
  overflow: auto;
  background: #081524;
  user-select: text;
}

.cq-ai-line {
  margin: 0 0 11px;
  padding: 11px 12px;
  border-radius: 8px;
  font-size: 15px;
  line-height: 1.55;
  font-weight: 700;
  white-space: normal;
}

.cq-ai-line.user {
  margin-left: 42px;
  color: #fff5d2;
  background: rgba(245, 195, 91, 0.18);
  border: 1px solid rgba(245, 195, 91, 0.24);
}

.cq-ai-line.assistant {
  margin-right: 36px;
  color: #e9f8ff;
  background: rgba(18, 104, 214, 0.2);
  border: 1px solid rgba(111, 203, 255, 0.18);
}

.cq-ai-speaker {
  font-weight: 900;
}

.cq-ai-line p {
  margin: 0 0 8px;
}

.cq-ai-line p:last-child {
  margin-bottom: 0;
}

.cq-ai-line ul {
  margin: 6px 0 8px 18px;
  padding: 0;
}

.cq-ai-line li {
  margin: 3px 0;
}

.cq-ai-line code {
  padding: 1px 5px;
  border-radius: 5px;
  color: #102033;
  background: #e0f2fe;
  font-family: Consolas, "Microsoft YaHei", monospace;
  font-weight: 900;
}

.cq-ai-line pre {
  margin: 8px 0;
  padding: 10px;
  border-radius: 8px;
  overflow: auto;
  background: #07111f;
  border: 1px solid rgba(111, 203, 255, 0.2);
}

.cq-ai-line pre code {
  padding: 0;
  color: #dff8ff;
  background: transparent;
  white-space: pre;
}

.cq-ai-controls {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 8px;
  padding: 12px;
  background: #0b1b2d;
}

.cq-ai-input {
  min-width: 0;
  height: 42px;
  border: 1px solid rgba(151, 201, 240, 0.42);
  border-radius: 8px;
  padding: 0 12px;
  color: #0c1727;
  background: #f8fbff;
  font-size: 15px;
  font-weight: 800;
  outline: none;
}

.cq-ai-action {
  height: 42px;
  border: 0;
  border-radius: 8px;
  padding: 0 14px;
  color: #ffffff;
  background: #1268d6;
  font-size: 14px;
  font-weight: 900;
  cursor: pointer;
}

.cq-ai-action.secondary {
  background: #365b7e;
}

.cq-ai-action.listening {
  background: #e04f3a;
}

.cq-ai-quick {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  padding: 0 12px 12px;
  background: #0b1b2d;
}

.cq-ai-quick button {
  min-height: 30px;
  border: 1px solid rgba(245, 195, 91, 0.28);
  border-radius: 999px;
  color: #ffe4a3;
  background: rgba(245, 195, 91, 0.12);
  padding: 0 12px;
  font-size: 12px;
  font-weight: 850;
  cursor: pointer;
}

#codequest-ai-assistant.thinking .cq-ai-avatar,
#codequest-ai-assistant.speaking .cq-ai-avatar,
#codequest-ai-assistant.listening .cq-ai-avatar {
  animation: cqAiPulse 0.8s ease-in-out infinite alternate;
}

#codequest-ai-assistant.speaking .cq-ai-avatar::before {
  animation: cqAiTalk 0.22s ease-in-out infinite alternate;
}

@keyframes cqAiPulse {
  from { transform: translateY(0); filter: brightness(1); }
  to { transform: translateY(-5px); filter: brightness(1.12); }
}

@keyframes cqAiTalk {
  from { transform: translateY(0) scale(1); }
  to { transform: translateY(-2px) scale(1.03); }
}

@media (max-width: 760px) {
  #codequest-ai-assistant {
    right: 12px;
    bottom: 12px;
    width: min(360px, calc(100vw - 24px));
    height: 116px;
  }

  .cq-ai-avatar {
    width: 104px;
    height: 104px;
  }

  .cq-ai-avatar::before {
    left: 12px;
    top: 8px;
    width: 80px;
    height: 84px;
  }

  .cq-ai-avatar::after {
    left: 12px;
    width: 80px;
  }

  .cq-ai-status {
    right: 84px;
    width: min(300px, calc(100vw - 136px));
    max-width: calc(100vw - 136px);
    font-size: 13px;
  }

  .cq-ai-panel {
    right: 0;
    bottom: 116px;
    width: 100%;
    max-height: min(620px, calc(100vh - 138px));
  }

  .cq-ai-controls {
    grid-template-columns: 1fr;
  }

  .cq-ai-action {
    width: 100%;
  }
}
