/* ============================================================
 * 四六级备考平台 · AI 学习助手悬浮窗（左下角）
 * ============================================================ */
#cet-ai-agent * { box-sizing: border-box; }
#cet-ai-agent {
  position: fixed;
  left: 22px;
  bottom: 26px;
  z-index: 9997;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}
#cet-ai-btn {
  width: 58px; height: 58px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  background: linear-gradient(135deg, #2F9B7D, #1B7A5E);
  color: #fff;
  box-shadow: 0 6px 20px rgba(37, 99, 235, .35);
  display: flex; align-items: center; justify-content: center;
  transition: transform .2s ease, box-shadow .2s ease;
  position: relative;
}
#cet-ai-btn:hover { transform: scale(1.06); box-shadow: 0 8px 26px rgba(37, 99, 235, .45); }
#cet-ai-btn svg { width: 26px; height: 26px; display: block; }
#cet-ai-badge {
  position: absolute; top: -2px; right: -2px;
  background: #F43F5E; color: #fff; font-size: 10px; font-weight: 700;
  min-width: 18px; height: 18px; border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  padding: 0 4px;
}
#cet-ai-panel {
  position: fixed;
  left: 22px; bottom: 94px;
  width: 372px; max-width: calc(100vw - 44px);
  height: min(560px, calc(100vh - 130px));
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 12px 48px rgba(15, 23, 42, .18);
  border: 1px solid rgba(15, 23, 42, .08);
  display: flex; flex-direction: column;
  overflow: hidden;
  transform-origin: left bottom;
  opacity: 0; transform: scale(.9) translateY(12px);
  pointer-events: none;
  transition: opacity .22s ease, transform .22s ease;
}
#cet-ai-agent.open #cet-ai-panel { opacity: 1; transform: scale(1) translateY(0); pointer-events: auto; }
#cet-ai-head {
  background: linear-gradient(135deg, #2F9B7D, #1B7A5E);
  color: #fff; padding: 13px 16px 11px;
  display: flex; align-items: center; gap: 10px;
  flex: none;
}
#cet-ai-head .ai-avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: rgba(255, 255, 255, .22);
  display: flex; align-items: center; justify-content: center;
  font-size: 17px; flex: none;
}
#cet-ai-head .ai-titles { flex: 1; min-width: 0; }
#cet-ai-head .ai-title { font-size: 14.5px; font-weight: 700; line-height: 1.3; }
#cet-ai-head .ai-sub { font-size: 11px; opacity: .85; line-height: 1.2; }
#cet-ai-head .ai-sub.busy {
  opacity: 1;
  color: #D9F2E7;
  font-weight: 600;
  animation: cet-ai-pulse 1.2s ease-in-out infinite;
}
#cet-ai-new {
  background: rgba(255,255,255,.16); color: #fff; border: none;
  border-radius: 8px; font-size: 11.5px; padding: 5px 9px;
  cursor: pointer; flex: none;
}
#cet-ai-new:hover { background: rgba(255,255,255,.26); }
#cet-ai-close {
  background: transparent; border: none; color: #fff; cursor: pointer;
  font-size: 18px; line-height: 1; padding: 2px 4px; opacity: .8; flex: none;
}
#cet-ai-close:hover { opacity: 1; }
#cet-ai-body {
  flex: 1; overflow-y: auto; padding: 14px 14px 6px;
  background: #F8FAFC;
  display: flex; flex-direction: column; gap: 10px;
  scroll-behavior: smooth;
}
.cet-ai-msg { display: flex; gap: 8px; max-width: 100%; }
.cet-ai-msg.user { flex-direction: row-reverse; }
.cet-ai-msg .bubble {
  max-width: 82%;
  padding: 9px 12px;
  border-radius: 14px;
  font-size: 13.5px; line-height: 1.65;
  word-break: break-word; white-space: pre-wrap;
}
.cet-ai-msg.bot .bubble {
  background: #fff; color: #1E293B;
  border: 1px solid rgba(15, 23, 42, .06);
  border-top-left-radius: 4px;
  box-shadow: 0 1px 3px rgba(15, 23, 42, .04);
}
.cet-ai-msg.user .bubble {
  background: #1B7A5E; color: #fff;
  border-top-right-radius: 4px;
}
.cet-ai-msg .bubble b, .cet-ai-msg .bubble strong { font-weight: 700; }
.cet-ai-msg .bubble code {
  background: rgba(15,23,42,.07); border-radius: 4px;
  padding: 1px 5px; font-size: 12px; font-family: ui-monospace, Consolas, monospace;
}
.cet-ai-msg.user .bubble code { background: rgba(255,255,255,.2); }
#cet-ai-typing {
  display: none;
  align-items: center;
  gap: 6px;
  align-self: flex-start;
  width: fit-content;
  background: linear-gradient(135deg, #EAF6F0, #F4FBF7);
  border: 1px solid rgba(27, 122, 94, .28);
  border-radius: 14px;
  border-top-left-radius: 4px;
  padding: 9px 14px;
  box-shadow: 0 1px 5px rgba(27, 122, 94, .10), 0 0 0 1px rgba(47, 155, 125, .04);
}
#cet-ai-typing i {
  font-style: normal;
  font-size: 13px;
  font-weight: 600;
  color: #155C47;
  letter-spacing: .2px;
  animation: cet-ai-pulse 1.4s ease-in-out infinite;
}
#cet-ai-typing span {
  width: 6px; height: 6px; border-radius: 50%;
  background: #2F9B7D; animation: cet-ai-blink 1.2s infinite;
  box-shadow: 0 0 4px rgba(47, 155, 125, .55);
}
#cet-ai-typing span:nth-child(2) { animation-delay: .2s; }
#cet-ai-typing span:nth-child(3) { animation-delay: .4s; }
@keyframes cet-ai-blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }
@keyframes cet-ai-pulse { 0%, 100% { opacity: .62; } 50% { opacity: 1; } }
#cet-ai-chips {
  display: flex; gap: 6px; padding: 8px 14px 2px;
  overflow-x: auto; flex: none; background: #F8FAFC;
  scrollbar-width: none;
}
#cet-ai-chips::-webkit-scrollbar { display: none; }
.cet-ai-chip {
  flex: none; font-size: 11.5px; color: #155C47;
  background: #fff; border: 1px solid #BFDBFE;
  border-radius: 14px; padding: 5px 11px; cursor: pointer;
  transition: background .15s ease;
}
.cet-ai-chip:hover { background: #EFF6FF; }
#cet-ai-inputbar {
  flex: none; display: flex; gap: 8px;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom, 0px));
  background: #fff; border-top: 1px solid rgba(15, 23, 42, .06);
}
#cet-ai-input {
  flex: 1; border: 1px solid #CBD5E1; border-radius: 20px;
  padding: 9px 14px; font-size: 13.5px; outline: none;
  font-family: inherit; background: #F8FAFC; color: #1E293B;
  resize: none; height: 38px; max-height: 96px; line-height: 1.4;
}
#cet-ai-input:focus { border-color: #1B7A5E; background: #fff; }
#cet-ai-send {
  flex: none; width: 38px; height: 38px; border-radius: 50%;
  border: none; background: #1B7A5E; color: #fff; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
#cet-ai-send:disabled { background: #CBD5E1; cursor: not-allowed; }
#cet-ai-send svg { width: 17px; height: 17px; }
.cet-ai-tip { text-align: center; font-size: 11px; color: #94A3B8; padding: 2px 0; }

@media (max-width: 600px) {
  #cet-ai-panel { left: 10px; bottom: 80px; width: calc(100vw - 20px); max-width: none; height: calc(100vh - 120px); }
  #cet-ai-btn { width: 54px; height: 54px; }
  #cet-ai-agent { left: 14px; bottom: 20px; }
}

/* ===== 暗黑模式适配（2026-10-24）===== */
html[data-theme="dark"] #cet-ai-panel{background:#10231C!important;border-color:#26423A!important;color:#E6F0EB!important}
html[data-theme="dark"] #cet-ai-panel .cet-ai-head{background:#1D3A2E!important;color:#E6F0EB!important}
html[data-theme="dark"] #cet-ai-panel .cet-ai-msg.bot .bubble{background:#1D3A2E!important;color:#E6F0EB!important}
html[data-theme="dark"] #cet-ai-panel .cet-ai-msg.user .bubble{background:#2F9B7D!important;color:#fff!important}
html[data-theme="dark"] #cet-ai-panel input[type="text"],html[data-theme="dark"] #cet-ai-panel textarea{background:#0B1410!important;color:#E6F0EB!important;border-color:#26423A!important}
html[data-theme="dark"] #cet-ai-panel .cet-ai-foot{background:#0B1410!important}
html[data-theme="dark"] #cet-ai-panel .cet-ai-title,html[data-theme="dark"] #cet-ai-panel .cet-ai-status{color:#E6F0EB!important}
