/*
 * 浅梦博客 · AI 助手样式
 * 由原 custom.css 拆分而来，仅负责 AI 助手界面；配色在文件末尾与站点主题同步。
 */

/* AI按钮 */
#ai-assistant-btn {
  position: fixed;
  right: 28px;
  bottom: 120px;
  z-index: 99999;

  width: 58px;
  height: 58px;

  border-radius: 50%;
  border: none;

  background:
    linear-gradient(
      135deg,
      var(--tech-blue),
      var(--tech-purple)
    );

  color: white;

  font-size: 18px;
  font-weight: 700;

  display: flex;
  align-items: center;
  justify-content: center;

  cursor: pointer;

  box-shadow:
    0 10px 30px rgba(101,182,255,0.35),
    0 0 18px rgba(179,136,255,0.25);

  transition: all 0.25s ease;
}

#ai-assistant-btn:hover {
  transform:
    translateY(-4px)
    scale(1.05);
}

/* AI聊天面板 */
#ai-assistant-panel {

  position: fixed;

  right: 28px;
  bottom: 190px;

  width: 360px;
  height: 520px;

  z-index: 99999;

  border-radius: 24px;

  overflow: hidden;

  background:
    rgba(255,255,255,0.82);

  backdrop-filter: blur(18px);

  border:
    1px solid rgba(101,182,255,0.22);

  box-shadow:
    0 18px 40px rgba(101,182,255,0.22),
    0 0 22px rgba(179,136,255,0.18);

  display: flex;
  flex-direction: column;

  opacity: 0;

  transform:
    translateY(18px)
    scale(0.96);

  pointer-events: none;

  transition: all 0.25s ease;
}

#ai-assistant-panel.show {

  opacity: 1;

  transform:
    translateY(0)
    scale(1);

  pointer-events: auto;
}

/* 顶栏 */
.ai-panel-header {

  padding: 14px 16px;

  background:
    linear-gradient(
      135deg,
      rgba(101,182,255,0.18),
      rgba(179,136,255,0.18)
    );

  display: flex;
  align-items: center;
  justify-content: space-between;

  font-weight: 700;
}

#ai-panel-close {

  border: none;

  background: transparent;

  font-size: 24px;

  cursor: pointer;
}

/* 消息区域 */
#ai-panel-messages {

  flex: 1;

  padding: 16px;

  overflow-y: auto;
}

/* 消息气泡 */
.ai-msg {

  max-width: 82%;

  padding: 10px 14px;

  margin-bottom: 14px;

  border-radius: 16px;

  line-height: 1.7;

  white-space: pre-wrap;

  font-size: 14px;
}

/* AI消息 */
.ai-msg-bot {

  background:
    rgba(101,182,255,0.12);

  border:
    1px solid rgba(101,182,255,0.18);

  color: #243244;
}

/* 用户消息 */
.ai-msg-user {

  margin-left: auto;

  background:
    linear-gradient(
      135deg,
      var(--tech-blue),
      var(--tech-purple)
    );

  color: white;
}

/* 输入区域 */
.ai-panel-input-wrap {

  display: flex;

  gap: 8px;

  padding: 12px;

  background:
    rgba(255,255,255,0.55);
}

#ai-panel-input {

  flex: 1;

  border-radius: 999px;

  border:
    1px solid rgba(101,182,255,0.22);

  padding: 10px 14px;

  outline: none;

  background:
    rgba(255,255,255,0.8);

  min-width: 0;
  max-height: 96px;
  resize: none;
  font: inherit;
  line-height: 1.5;
  overflow-y: auto;
}

#ai-panel-send {

  border: none;

  border-radius: 999px;

  padding: 0 16px;

  background:
    linear-gradient(
      135deg,
      var(--tech-blue),
      var(--tech-purple)
    );

  color: white;

  cursor: pointer;
}

#ai-panel-send:disabled,
#ai-summary-btn:disabled,
#ai-panel-input:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

.ai-privacy-note {
  margin: 0;
  padding: 0 16px 12px;
  color: #607086;
  font-size: 11px;
  line-height: 1.5;
  text-align: center;
}

.ai-title {
  line-height: 1.25;
}

.ai-status {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
  color: #607086;
  font-size: 11px;
  font-weight: 500;
}

.ai-status > span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #27ae60;
  box-shadow: 0 0 0 3px rgba(39,174,96,0.12);
}

.ai-status.is-thinking > span {
  background: var(--tech-blue);
  box-shadow: 0 0 0 3px rgba(101,182,255,0.16);
  animation: ai-status-pulse 1.2s ease-in-out infinite;
}

.ai-header-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

#ai-clear-btn {
  padding: 5px 8px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #607086;
  font-size: 12px;
  cursor: pointer;
}

#ai-clear-btn:hover {
  background: rgba(101,182,255,0.1);
}

.ai-msg.is-loading .ai-msg-text::after {
  display: inline-block;
  width: 1.5em;
  overflow: hidden;
  vertical-align: bottom;
  content: '···';
  animation: ai-loading-dots 1.1s steps(4, end) infinite;
}

.ai-msg.is-error {
  border-color: rgba(220,53,69,0.25) !important;
  background: rgba(220,53,69,0.06) !important;
}

.ai-sources {
  display: grid;
  gap: 6px;
  width: min(290px, 76vw);
  margin-top: 10px;
  padding-top: 9px;
  border-top: 1px solid rgba(101,182,255,0.16);
}

.ai-sources-label {
  color: #607086;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.ai-source-link {
  display: block;
  padding: 7px 9px;
  border: 1px solid rgba(101,182,255,0.16);
  border-radius: 10px;
  background: rgba(255,255,255,0.46);
  color: #315b9d !important;
  font-size: 11px;
  line-height: 1.45;
  text-decoration: none !important;
  overflow-wrap: anywhere;
}

.ai-source-link:hover {
  border-color: rgba(101,182,255,0.38);
  transform: translateY(-1px);
}

.ai-retry-btn {
  display: block;
  margin-top: 9px;
  padding: 5px 10px;
  border: 1px solid rgba(101,182,255,0.3);
  border-radius: 999px;
  background: transparent;
  color: #315b9d;
  font-size: 12px;
  cursor: pointer;
}

#ai-panel-send.is-stop {
  background: linear-gradient(135deg, #e66a78, #cc3f55);
}

@keyframes ai-status-pulse {
  50% { opacity: 0.45; transform: scale(0.78); }
}

@keyframes ai-loading-dots {
  0% { width: 0; }
  100% { width: 1.5em; }
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

#ai-assistant button:focus-visible,
#ai-panel-input:focus-visible,
.docs-item:focus-visible,
.report-card:focus-visible,
.essay-card:focus-visible {
  outline: 3px solid #2563eb;
  outline-offset: 3px;
}

/* 深色模式 */
[data-theme="dark"] #ai-assistant-panel {

  background:
    rgba(18,26,48,0.9);

  color: #dbe7ff;
}

[data-theme="dark"] .ai-msg-bot {

  color: #dbe7ff;

  background:
    rgba(101,182,255,0.12);
}

[data-theme="dark"] .ai-panel-input-wrap {

  background:
    rgba(18,26,48,0.7);
}

[data-theme="dark"] #ai-panel-input {

  background:
    rgba(10,16,32,0.8);

  color: white;
}

[data-theme="dark"] .ai-privacy-note {
  color: #aebbd4;
}

[data-theme="dark"] .ai-status,
[data-theme="dark"] #ai-clear-btn,
[data-theme="dark"] .ai-sources-label {
  color: #aebbd4;
}

[data-theme="dark"] .ai-source-link {
  background: rgba(10,16,32,0.48);
  color: #a9cbff !important;
}

/* 手机端 */
@media screen and (max-width: 600px) {

  #page-header.post-bg #post-info {
    max-width: 100vw;
  }

  #post-info .post-title {
    display: block;
    overflow: visible;
    max-width: 100%;
    font-size: clamp(1.55rem, 7vw, 2rem);
    line-height: 1.35;
    word-break: break-word;
    overflow-wrap: anywhere;
    -webkit-line-clamp: unset;
  }

  #ai-assistant-panel {

    width: calc(100vw - 32px);

    right: 16px;

    bottom: 160px;

    height: min(480px, calc(100dvh - 190px));
  }

  #ai-assistant-btn {

    right: 18px;
  }
}

/* AI 面板快捷按钮 */
.ai-panel-actions {
  padding: 10px 12px;
  background: rgba(255,255,255,0.45);
  border-bottom: 1px solid rgba(101,182,255,0.14);
}

#ai-summary-btn {
  width: 100%;
  border: none;
  border-radius: 999px;
  padding: 9px 14px;
  cursor: pointer;
  color: #fff;
  font-weight: 700;
  background: linear-gradient(135deg, var(--tech-blue), var(--tech-purple));
  box-shadow: 0 6px 18px rgba(101,182,255,0.22);
}

#ai-summary-btn:hover {
  transform: translateY(-2px);
}

[data-theme="dark"] .ai-panel-actions {
  background: rgba(18,26,48,0.72);
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* AI Assistant v3 — spacious, focused chat surface */
#ai-assistant {
  --ai-accent: #665cf6;
  --ai-accent-strong: #5548e8;
  --ai-ink: #172033;
  --ai-muted: #778197;
  --ai-line: rgba(83, 95, 125, 0.14);
  --ai-surface: rgba(250, 251, 255, 0.96);
  --ai-card: rgba(255, 255, 255, 0.92);
  font-family: inherit;
}

#ai-assistant-btn {
  right: 30px;
  bottom: 30px;
  width: 58px;
  height: 58px;
  gap: 2px;
  border: 1px solid rgba(255, 255, 255, 0.5);
  background: linear-gradient(145deg, #746cf8 0%, #5d4de8 100%);
  box-shadow: 0 14px 34px rgba(74, 62, 211, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.28);
}

#ai-assistant-btn:hover {
  transform: translateY(-3px) scale(1.035);
  box-shadow: 0 18px 40px rgba(74, 62, 211, 0.34), inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

.ai-launcher-mark {
  font-size: 14px;
  transform: translateY(-7px);
}

.ai-launcher-label {
  margin-left: -7px;
  font-size: 13px;
  letter-spacing: -0.02em;
  transform: translateY(5px);
}

#ai-assistant-panel {
  right: 28px;
  bottom: 104px;
  width: min(460px, calc(100vw - 48px));
  height: min(720px, calc(100dvh - 132px));
  border: 1px solid rgba(106, 96, 224, 0.18);
  border-radius: 26px;
  background: var(--ai-surface);
  box-shadow: 0 30px 80px rgba(30, 36, 62, 0.2), 0 8px 24px rgba(83, 70, 200, 0.1);
  backdrop-filter: blur(28px) saturate(1.25);
  -webkit-backdrop-filter: blur(28px) saturate(1.25);
  transform: translateY(14px) scale(0.975);
  transform-origin: right bottom;
}

#ai-assistant-panel.show {
  transform: translateY(0) scale(1);
}

.ai-panel-header {
  min-height: 76px;
  padding: 15px 17px 14px 18px;
  border-bottom: 1px solid var(--ai-line);
  background: linear-gradient(135deg, rgba(245, 247, 255, 0.98), rgba(246, 243, 255, 0.96));
  font-weight: inherit;
}

.ai-brand {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
}

.ai-brand-mark {
  display: grid;
  flex: 0 0 40px;
  width: 40px;
  height: 40px;
  place-items: center;
  border-radius: 13px;
  background: linear-gradient(145deg, #756df8, #5a4be5);
  box-shadow: 0 8px 20px rgba(89, 74, 224, 0.24);
  color: #fff;
  font-size: 18px;
}

.ai-title {
  color: var(--ai-ink);
  font-size: 16px;
  font-weight: 760;
  letter-spacing: -0.015em;
}

.ai-status {
  gap: 7px;
  margin-top: 4px;
  color: var(--ai-muted);
  font-size: 11.5px;
}

.ai-status > .ai-status-dot {
  width: 7px;
  height: 7px;
  background: #36b878;
  box-shadow: 0 0 0 3px rgba(54, 184, 120, 0.11);
}

.ai-status > .ai-status-text {
  width: auto;
  height: auto;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.ai-header-actions {
  gap: 5px;
}

#ai-clear-btn,
#ai-panel-close.ai-icon-btn {
  height: 34px;
  border: 1px solid transparent;
  border-radius: 11px;
  background: transparent;
  color: #6e778b;
  transition: background 0.18s ease, border-color 0.18s ease, color 0.18s ease;
}

#ai-clear-btn {
  padding: 0 9px;
  font-size: 12px;
}

#ai-panel-close.ai-icon-btn {
  display: grid;
  width: 34px;
  padding: 0;
  place-items: center;
  font-size: 22px;
  line-height: 1;
}

#ai-clear-btn:hover,
#ai-panel-close.ai-icon-btn:hover {
  border-color: var(--ai-line);
  background: rgba(103, 93, 238, 0.07);
  color: var(--ai-ink);
}

.ai-panel-actions {
  display: flex;
  flex: 0 0 auto;
  gap: 8px;
  padding: 11px 18px;
  overflow-x: auto;
  border-bottom: 1px solid var(--ai-line);
  background: rgba(255, 255, 255, 0.68);
  scrollbar-width: none;
}

.ai-panel-actions::-webkit-scrollbar {
  display: none;
}

#ai-summary-btn.ai-quick-action,
.ai-quick-action {
  display: inline-flex;
  flex: 0 0 auto;
  width: auto;
  min-height: 34px;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  border: 1px solid rgba(101, 91, 235, 0.16);
  border-radius: 999px;
  background: #fff;
  box-shadow: none;
  color: #5550bd;
  font-size: 12px;
  font-weight: 650;
  white-space: nowrap;
  cursor: pointer;
  transition: border-color 0.18s ease, background 0.18s ease, transform 0.18s ease;
}

#ai-summary-btn.ai-quick-action {
  border-color: transparent;
  background: linear-gradient(135deg, #6f66f4, #5b4ce5) !important;
  color: #fff !important;
}

#ai-summary-btn.ai-quick-action:hover,
.ai-quick-action:hover {
  border-color: rgba(101, 91, 235, 0.32);
  background: #f6f5ff;
  transform: translateY(-1px);
}

#ai-summary-btn[hidden],
.ai-quick-action[hidden] {
  display: none;
}

#ai-panel-messages {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  padding: 20px 18px 8px;
  overflow-x: hidden;
  overflow-y: auto;
  background:
    radial-gradient(circle at 100% 0, rgba(118, 108, 248, 0.06), transparent 33%),
    #f7f8fc;
  scrollbar-color: rgba(109, 104, 157, 0.28) transparent;
  scrollbar-width: thin;
}

#ai-panel-messages::-webkit-scrollbar {
  width: 6px;
}

#ai-panel-messages::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: rgba(109, 104, 157, 0.25);
}

.ai-msg {
  position: relative;
  flex: 0 0 auto;
  max-width: 92%;
  margin-bottom: 16px;
  padding: 13px 15px;
  border-radius: 18px;
  font-size: 14px;
  line-height: 1.72;
  overflow-wrap: anywhere;
}

.ai-msg-bot {
  align-self: flex-start;
  border: 1px solid rgba(69, 82, 112, 0.1);
  border-radius: 7px 18px 18px 18px;
  background: var(--ai-card);
  box-shadow: 0 5px 16px rgba(33, 43, 70, 0.055);
  color: #293246;
}

.ai-msg-bot::before {
  display: block;
  margin-bottom: 6px;
  color: #665cf6;
  content: '✦  浅梦 AI';
  font-size: 10.5px;
  font-weight: 750;
  letter-spacing: 0.025em;
}

.ai-msg-text p {
  margin: 0 0 0.72em;
}

.ai-msg-text p:last-child,
.ai-msg-text ul:last-child,
.ai-msg-text ol:last-child {
  margin-bottom: 0;
}

.ai-msg-text .ai-answer-heading {
  margin-top: 0.95em;
  color: #20283a;
  font-size: 1.03em;
  font-weight: 750;
}

.ai-msg-text ul,
.ai-msg-text ol {
  margin: 0.35em 0 0.78em;
  padding-left: 1.35em;
}

.ai-msg-text li {
  margin: 0.28em 0;
  padding-left: 0.12em;
}

.ai-msg-text strong {
  color: #252d42;
  font-weight: 750;
}

.ai-msg-text code {
  padding: 0.12em 0.35em;
  border-radius: 5px;
  background: rgba(99, 91, 229, 0.08);
  color: #574ed0;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 0.9em;
}

.ai-msg-user {
  align-self: flex-end;
  max-width: 84%;
  margin-left: auto;
  border: 0;
  border-radius: 18px 18px 7px 18px;
  background: linear-gradient(140deg, #7067f5, #5a4ce5);
  box-shadow: 0 7px 18px rgba(84, 70, 211, 0.16);
  color: #fff;
}

.ai-msg.is-error {
  border-color: rgba(218, 72, 89, 0.22) !important;
  background: #fff7f8 !important;
}

.ai-sources {
  width: 100%;
  margin-top: 11px;
  padding-top: 10px;
  border-top: 1px solid var(--ai-line);
}

.ai-sources-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: #6661b7;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0;
  list-style: none;
  cursor: pointer;
  user-select: none;
}

.ai-sources-label::-webkit-details-marker {
  display: none;
}

.ai-sources-label::after {
  content: '⌄';
  color: #8b91a2;
  font-size: 15px;
  transition: transform 0.18s ease;
}

.ai-sources[open] .ai-sources-label::after {
  transform: rotate(180deg);
}

.ai-source-list {
  display: grid;
  gap: 7px;
  padding-top: 9px;
}

.ai-source-link {
  display: -webkit-box;
  padding: 8px 10px;
  overflow: hidden;
  border: 1px solid rgba(91, 81, 219, 0.12);
  border-radius: 11px;
  background: #f8f8ff;
  color: #4e56a8 !important;
  font-size: 11.5px;
  line-height: 1.48;
  text-decoration: none !important;
  overflow-wrap: anywhere;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.ai-source-link:hover {
  border-color: rgba(91, 81, 219, 0.28);
  background: #f3f2ff;
  transform: none;
}

.ai-panel-input-wrap {
  display: block;
  flex: 0 0 auto;
  padding: 12px 14px 10px;
  border-top: 1px solid var(--ai-line);
  background: rgba(255, 255, 255, 0.94);
}

.ai-composer {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 5px 5px 5px 14px;
  border: 1px solid rgba(82, 91, 119, 0.17);
  border-radius: 18px;
  background: #fff;
  box-shadow: 0 4px 16px rgba(28, 38, 66, 0.055);
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.ai-composer:focus-within {
  border-color: rgba(101, 91, 235, 0.48);
  box-shadow: 0 0 0 3px rgba(101, 91, 235, 0.09), 0 5px 18px rgba(28, 38, 66, 0.06);
}

#ai-panel-input {
  min-height: 42px;
  max-height: 112px;
  padding: 10px 2px 8px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--ai-ink);
  font-size: 13.5px;
  line-height: 1.55;
  box-shadow: none;
}

#ai-panel-input::placeholder {
  color: #a0a7b6;
}

#ai-panel-input:focus-visible {
  outline: 0;
}

#ai-panel-send {
  display: flex;
  flex: 0 0 auto;
  min-width: 82px;
  height: 42px;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 0 13px;
  border-radius: 13px;
  background: linear-gradient(140deg, #7067f5, #594ae3);
  box-shadow: 0 6px 15px rgba(83, 69, 209, 0.2);
  color: #fff;
  font-size: 12.5px;
  font-weight: 700;
}

#ai-panel-send:hover {
  transform: translateY(-1px);
}

.ai-send-icon {
  display: grid;
  width: 20px;
  height: 20px;
  place-items: center;
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.16);
  font-size: 14px;
  line-height: 1;
}

#ai-panel-send.is-stop {
  background: linear-gradient(140deg, #e66a78, #cc3f55);
}

.ai-privacy-note {
  margin: 7px 3px 0;
  padding: 0;
  color: #9299a8;
  font-size: 10.5px;
  line-height: 1.45;
  text-align: center;
}

.ai-retry-btn {
  margin-top: 10px;
  padding: 6px 11px;
  border-color: rgba(101, 91, 235, 0.25);
  color: #5a54bd;
}

[data-theme="dark"] #ai-assistant {
  --ai-ink: #f2f5ff;
  --ai-muted: #a5aec2;
  --ai-line: rgba(171, 181, 211, 0.13);
  --ai-surface: rgba(14, 20, 35, 0.97);
  --ai-card: rgba(28, 37, 57, 0.96);
}

[data-theme="dark"] #ai-assistant-panel {
  background: var(--ai-surface);
  border-color: rgba(134, 123, 255, 0.22);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.42), 0 8px 24px rgba(43, 34, 120, 0.18);
}

[data-theme="dark"] .ai-panel-header {
  background: linear-gradient(135deg, rgba(24, 32, 52, 0.98), rgba(29, 27, 55, 0.98));
}

[data-theme="dark"] .ai-panel-actions,
[data-theme="dark"] .ai-panel-input-wrap {
  background: rgba(18, 25, 42, 0.96);
}

[data-theme="dark"] #ai-panel-messages {
  background: radial-gradient(circle at 100% 0, rgba(118, 108, 248, 0.1), transparent 35%), #111827;
}

[data-theme="dark"] .ai-title,
[data-theme="dark"] #ai-panel-input {
  color: var(--ai-ink);
}

[data-theme="dark"] .ai-msg-bot {
  color: #e2e8f5;
  background: var(--ai-card);
  border-color: rgba(171, 181, 211, 0.1);
}

[data-theme="dark"] .ai-quick-action {
  border-color: rgba(143, 133, 255, 0.2);
  background: rgba(34, 43, 65, 0.9);
  color: #c1bcff;
}

[data-theme="dark"] #ai-summary-btn.ai-quick-action {
  background: linear-gradient(135deg, #786ff7, #6253e8) !important;
  color: #fff !important;
}

[data-theme="dark"] .ai-quick-action:hover,
[data-theme="dark"] .ai-source-link {
  background: rgba(43, 48, 78, 0.94);
  color: #c5c9ff !important;
}

[data-theme="dark"] .ai-composer {
  border-color: rgba(171, 181, 211, 0.16);
  background: rgba(12, 18, 31, 0.9);
}

[data-theme="dark"] #ai-clear-btn,
[data-theme="dark"] #ai-panel-close.ai-icon-btn,
[data-theme="dark"] .ai-status,
[data-theme="dark"] .ai-privacy-note {
  color: #aab3c7;
}

@media screen and (max-width: 600px) {
  #ai-assistant-btn {
    right: 17px;
    bottom: 18px;
    width: 54px;
    height: 54px;
  }

  #ai-assistant-panel {
    right: 10px;
    bottom: 82px;
    left: 10px;
    width: auto;
    height: min(74dvh, 680px);
    border-radius: 24px;
    transform-origin: center bottom;
  }

  .ai-panel-header {
    min-height: 70px;
    padding: 13px 13px 12px 14px;
  }

  .ai-brand-mark {
    flex-basis: 37px;
    width: 37px;
    height: 37px;
    border-radius: 12px;
  }

  .ai-panel-actions {
    padding: 9px 13px;
  }

  #ai-panel-messages {
    padding: 16px 13px 7px;
  }

  .ai-msg {
    max-width: 94%;
  }

  .ai-panel-input-wrap {
    padding: 10px 10px 8px;
  }

  #ai-panel-send {
    min-width: 44px;
    width: 44px;
    padding: 0;
  }

  .ai-send-label {
    display: none;
  }

  .ai-send-icon {
    background: transparent;
  }
}

/* ===== 以下合并自原 assistant-refinement.css ===== */
/* Consolidated assistant refinements; loaded after the legacy theme overrides. */
#ai-assistant {
  --ai-accent: #5668ec;
  --ai-accent-deep: #4054d1;
  --ai-ink: #1b2740;
  --ai-muted: #69758e;
  --ai-line: rgba(73, 91, 132, 0.15);
  --ai-panel: #f7f9fd;
  --ai-bubble: #fff;
}

#ai-assistant-panel {
  width: min(440px, calc(100vw - 40px));
  height: min(680px, calc(100dvh - 120px));
  border-color: rgba(79, 98, 206, 0.2);
  border-radius: 22px;
  background: #fff;
  box-shadow: 0 24px 72px rgba(23, 35, 71, 0.2), 0 4px 16px rgba(62, 80, 153, 0.08);
  backdrop-filter: blur(22px) saturate(125%);
  -webkit-backdrop-filter: blur(22px) saturate(125%);
}

.ai-panel-header {
  min-height: 72px;
  padding: 13px 16px;
  background: linear-gradient(135deg, #f3f6ff, #f7f5ff);
}

.ai-title { color: var(--ai-ink); }
.ai-status, .ai-privacy-note { color: var(--ai-muted); }

.ai-panel-actions {
  gap: 7px;
  padding: 10px 14px;
  background: #fff;
}

.ai-quick-action {
  min-height: 36px;
  padding: 7px 11px;
  border-color: rgba(82, 99, 207, 0.18);
  color: #4656bf;
  font-size: 12px;
}

#ai-summary-btn.ai-quick-action {
  border: 0;
  background: linear-gradient(135deg, #5268eb, #7763e6) !important;
}

#ai-panel-messages {
  gap: 3px;
  padding: 18px 16px 10px;
  background: #f6f8fc;
  overscroll-behavior: contain;
}

.ai-msg {
  max-width: min(92%, 380px);
  margin-bottom: 12px;
  padding: 13px 15px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.75;
}

.ai-msg-bot {
  border: 1px solid rgba(73, 91, 132, 0.12) !important;
  border-radius: 6px 16px 16px 16px;
  background: #fff !important;
  color: #29364f !important;
  box-shadow: 0 3px 12px rgba(33, 45, 78, 0.045);
}

.ai-msg-user {
  border-radius: 16px 6px 16px 16px;
  background: linear-gradient(135deg, #5369e9, #775fe0) !important;
  color: #fff !important;
}

.ai-sources { width: min(100%, 340px); }
.ai-sources-label { cursor: default; }
.ai-sources-label::after { content: none; }
.ai-sources-more { width: min(100%, 340px); margin: 4px 0 8px; color: var(--ai-muted); font-size: 11px; }
.ai-sources-more > summary { width: fit-content; cursor: pointer; }
.ai-sources-more .ai-source-list { padding-top: 7px; }
.ai-source-link { overflow-wrap: anywhere; }

.ai-panel-input-wrap {
  padding: 11px 14px 8px;
  background: #fff;
  border-top: 1px solid rgba(73, 91, 132, 0.1);
}

.ai-composer {
  border-color: rgba(82, 99, 207, 0.22);
  box-shadow: 0 0 0 3px rgba(82, 99, 207, 0.055);
}

#ai-panel-input { color: var(--ai-ink); }
#ai-panel-input::placeholder { color: #8993a8; }

.ai-privacy-note {
  padding: 7px 4px 1px;
  font-size: 10.5px;
  line-height: 1.45;
}

.ai-panel-backdrop { display: none; }

[data-theme='dark'] #ai-assistant {
  --ai-ink: #e8edf9;
  --ai-muted: #aab5ce;
}

[data-theme='dark'] #ai-assistant-panel,
[data-theme='dark'] .ai-panel-actions,
[data-theme='dark'] .ai-panel-input-wrap {
  background: #141b2e;
}

[data-theme='dark'] .ai-panel-header {
  background: linear-gradient(135deg, #192442, #211e3b);
}

[data-theme='dark'] #ai-panel-messages { background: #10172a; }
[data-theme='dark'] .ai-msg-bot { background: #192238 !important; color: #e1e8f8 !important; }
[data-theme='dark'] .ai-panel-actions { border-color: rgba(173, 184, 220, 0.1); }
[data-theme='dark'] .ai-quick-action { background: #1b2440; color: #c3ccff; }
[data-theme='dark'] .ai-sources-more { color: #b9c2d9; }
[data-theme='dark'] #ai-panel-input { background: #11192b; color: #e8edf9; }

@media (max-width: 600px) {
  .ai-panel-backdrop {
    position: fixed;
    inset: 0;
    z-index: 99997;
    display: block;
    width: 100vw;
    height: 100dvh;
    border: 0;
    background: rgba(8, 14, 31, 0.48);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.22s ease;
  }

  .ai-panel-backdrop.show { opacity: 1; pointer-events: auto; }

  #ai-assistant-btn { z-index: 99999; }

  #ai-assistant-panel {
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 100dvh;
    max-height: 100dvh;
    border-radius: 20px 20px 0 0;
    transform: translateY(18px);
    transform-origin: center bottom;
  }

  #ai-assistant-panel.show { transform: translateY(0); }
  .ai-panel-header { padding-top: max(14px, env(safe-area-inset-top)); }
  #ai-panel-messages { padding: 16px 14px 10px; }
  .ai-msg { max-width: 94%; }
  .ai-panel-input-wrap { padding-bottom: max(9px, env(safe-area-inset-bottom)); }
  .ai-privacy-note { font-size: 10px; }
}

@media (prefers-reduced-motion: reduce) {
  .ai-panel-backdrop { transition: none; }
}

/* ===== 与站点主题（theme.css）同步的配色与入口位置 ===== */
#ai-assistant {
  --ai-accent: var(--qm-primary, #3f51d4);
  --ai-accent-deep: var(--qm-primary-deep, #3141b8);
  --ai-accent-strong: var(--qm-primary-deep, #3141b8);
  --ai-ink: var(--qm-text, #1b2130);
  --ai-muted: var(--qm-text-soft, #5a6274);
  --ai-line: var(--qm-border, rgba(24, 30, 48, 0.09));
}

#ai-assistant-btn {
  right: 76px;
  bottom: 28px;
  width: 50px;
  height: 50px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: linear-gradient(150deg, #4b5be0 0%, #2f3cae 100%);
  box-shadow: 0 10px 26px rgba(40, 52, 160, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.22);
}

#ai-assistant-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 32px rgba(40, 52, 160, 0.36), inset 0 1px 0 rgba(255, 255, 255, 0.25);
}

#ai-assistant-panel {
  border-color: var(--qm-border-strong, rgba(63, 81, 212, 0.18));
  border-radius: 20px;
}

.ai-msg-user,
#ai-panel-send,
#ai-summary-btn.ai-quick-action {
  background: linear-gradient(150deg, #4b5be0 0%, #3343bf 100%) !important;
}

[data-theme='dark'] #ai-assistant-btn {
  border-color: rgba(255, 255, 255, 0.12);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.45);
}

@media screen and (max-width: 768px) {
  #ai-assistant-btn {
    right: 64px;
    bottom: 20px;
    width: 46px;
    height: 46px;
  }
}
