#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%, rgba(255, 247, 173, 0.94) 0 48%, rgba(79, 70, 229, 0.86) 49% 70%, transparent 71%);
  box-shadow: 0 14px 24px rgba(5, 12, 28, 0.38), 0 0 0 5px rgba(255, 247, 173, 0.42);
  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.18));
}

.cq-ai-avatar::after {
  content: "导师";
  position: absolute;
  left: 22px;
  bottom: -4px;
  width: 82px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  color: #172033;
  background: #ffd36a;
  font-size: 15px;
  font-weight: 900;
  box-shadow: 0 5px 0 rgba(113, 63, 18, 0.28);
}

.cq-ai-status {
  position: absolute;
  right: 102px;
  bottom: 14px;
  max-width: 260px;
  min-height: 38px;
  padding: 9px 12px;
  border: 3px solid rgba(23, 32, 51, 0.72);
  border-radius: 12px;
  background: rgba(255, 253, 247, 0.94);
  color: #172033;
  font-size: 15px;
  line-height: 1.25;
  font-weight: 900;
  pointer-events: none;
}

.cq-ai-panel {
  position: absolute;
  right: 136px;
  bottom: 96px;
  width: 520px;
  max-height: 510px;
  display: none;
  flex-direction: column;
  border: 4px solid #172033;
  border-radius: 8px;
  overflow: hidden;
  background: rgba(11, 24, 43, 0.98);
  box-shadow: 0 18px 44px rgba(5, 12, 28, 0.42);
  pointer-events: auto;
  touch-action: auto;
}

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

.cq-ai-panel header {
  min-height: 58px;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: #12345b;
  border-bottom: 3px solid rgba(255,255,255,0.12);
}

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

.cq-ai-context {
  max-width: 360px;
  color: #cfefff;
  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: #f4b844;
  color: #172033;
  font-weight: 900;
  cursor: pointer;
}

.cq-ai-log {
  min-height: 180px;
  max-height: 286px;
  padding: 12px;
  overflow: auto;
  background: rgba(2, 8, 18, 0.6);
  user-select: text;
}

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

.cq-ai-line.user {
  margin-left: 42px;
  color: #fff5d2;
  background: rgba(246, 184, 68, 0.2);
  border: 1px solid rgba(255, 211, 106, 0.22);
}

.cq-ai-line.assistant {
  margin-right: 36px;
  color: #e9f8ff;
  background: rgba(69, 142, 199, 0.22);
  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 h4 {
  margin: 8px 0 6px;
  color: #ffdf7a;
  font-size: 16px;
}

.cq-ai-line code {
  padding: 1px 5px;
  border-radius: 5px;
  color: #172033;
  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: #0b182b;
}

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

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

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

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

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

.cq-ai-quick button {
  min-height: 30px;
  border: 1px solid rgba(255, 211, 106, 0.28);
  border-radius: 999px;
  color: #ffe4a3;
  background: rgba(255, 211, 106, 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); }
}
