/**
 * 基石智能体 · 对话 UI（scoped to #aiChatModal / .ai-chat-float-btn）
 * 色彩跟随 data-theme 与 --ds-ai-panel-* / --ds-brand 令牌，避免硬编码粉/白。
 */
#aiChatModal,
.ai-chat-float-btn {
  --ai-accent: var(--ds-brand);
  --ai-accent-deep: var(--ds-ai-panel-accent, var(--ds-brand));
  --ai-accent-soft: color-mix(in srgb, var(--ds-brand) 8%, transparent);
  --ai-surface: var(--ds-neutral-surface);
  --ai-surface-deep: var(--ds-neutral-surface-sunken);
  --ai-surface-glass: var(--ds-neutral-surface);
  --ai-line: color-mix(in srgb, var(--ds-border) 88%, transparent);
  --ai-input-shadow: 0 2px 8px -2px color-mix(in srgb, var(--ds-text) 16%, transparent);
  --ai-input-shadow-focus: 0 2px 12px -2px color-mix(in srgb, var(--ds-text) 22%, transparent);
  --ai-highlight: color-mix(in srgb, var(--ds-text) 5%, transparent);
  --ai-composer-max: 680px;
  /* 端部弧半径 = ai-pill-arc-r；发送钮圆心 = 弧心 */
  --ai-pill-height: 64px;
  --ai-pill-arc-r: calc(var(--ai-pill-height) / 2);
  --ai-send-size: 36px;
  --ai-pill-cap-pad: calc(var(--ai-pill-arc-r) - var(--ai-send-size) / 2);
}

/* ── 悬浮入口 ── */
.ai-chat-float-btn {
  position: fixed;
  right: 18px;
  bottom: 20px;
  z-index: 1500;
  border-radius: 9999px;
  padding: 8px 16px 8px 8px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: linear-gradient(
    135deg,
    color-mix(in srgb, var(--ds-brand) 12%, var(--ai-surface)),
    var(--ai-surface)
  );
  border: 1px solid color-mix(in srgb, var(--ds-brand) 35%, var(--ds-border));
  color: var(--ds-text);
  box-shadow:
    0 0 0 1px color-mix(in srgb, var(--ds-brand) 15%, transparent),
    0 8px 28px color-mix(in srgb, var(--ds-brand) 25%, transparent);
  transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
  animation: aiFloatPulse 3s ease-in-out infinite;
}

@keyframes aiFloatPulse {
  0%, 100% { box-shadow: 0 0 0 1px color-mix(in srgb, var(--ds-brand) 15%, transparent), 0 8px 28px color-mix(in srgb, var(--ds-brand) 22%, transparent); }
  50% { box-shadow: 0 0 0 1px color-mix(in srgb, var(--ds-brand) 35%, transparent), 0 10px 36px color-mix(in srgb, var(--ds-brand) 38%, transparent); }
}

.ai-chat-float-btn:hover {
  border-color: color-mix(in srgb, var(--ai-accent) 45%, var(--ds-border));
  box-shadow: 0 0 24px color-mix(in srgb, var(--ai-accent-deep) 28%, transparent);
  transform: translateY(-1px);
  color: var(--ds-text);
}

/* ── 弹层（遮罩 + 主窗口生命周期） ── */
.ai-chat-modal {
  z-index: 1600;
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: rgba(0, 0, 0, 0);
  backdrop-filter: blur(0);
  -webkit-backdrop-filter: blur(0);
  animation: none !important;
  transition:
    background-color 200ms ease-out,
    backdrop-filter 200ms ease-out,
    -webkit-backdrop-filter 200ms ease-out;
}

.ai-chat-modal.hidden {
  display: none !important;
}

/* 覆盖 app.css 全局 .modal-content（max-width:480px / overflow-y:auto） */
#aiChatModal > .modal-content.ai-chat-modal__panel {
  width: min(96vw, 1040px);
  max-width: min(96vw, 1040px);
  overflow: hidden;
  overflow-y: hidden;
  box-sizing: border-box;
}

#aiChatModal > .modal-content.ai-chat-modal__panel.ai-chat-modal--sidebar-open {
  width: min(96vw, 1120px);
  max-width: min(96vw, 1120px);
}

.ai-chat-modal.ai-chat-modal--open {
  background-color: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.ai-chat-modal.ai-chat-modal--leaving {
  background-color: rgba(0, 0, 0, 0);
  backdrop-filter: blur(0);
  -webkit-backdrop-filter: blur(0);
  transition:
    background-color 220ms cubic-bezier(0.16, 1, 0.3, 1),
    backdrop-filter 220ms cubic-bezier(0.16, 1, 0.3, 1),
    -webkit-backdrop-filter 220ms cubic-bezier(0.16, 1, 0.3, 1);
}

.ai-chat-modal .ai-chat-modal__panel {
  opacity: 0;
  transform: scale(0.96) translateY(15px);
  animation: none !important;
  transition:
    opacity 300ms cubic-bezier(0.34, 1.56, 0.64, 1),
    transform 300ms cubic-bezier(0.34, 1.56, 0.64, 1);
  pointer-events: auto;
}

.ai-chat-modal.ai-chat-modal--open .ai-chat-modal__panel {
  opacity: 1;
  transform: scale(1) translateY(0);
}

.ai-chat-modal.ai-chat-modal--leaving .ai-chat-modal__panel {
  opacity: 0;
  transform: scale(0.96) translateY(15px);
  transition:
    opacity 220ms cubic-bezier(0.16, 1, 0.3, 1),
    transform 220ms cubic-bezier(0.16, 1, 0.3, 1);
}

/* 输入区内部：比主窗口延迟 100ms 淡入上移（landing 首屏用独立序列） */
.ai-chat-modal:not(.ai-chat-modal--open) .ai-chat-body:not(.ai-chat-body--landing) .ai-chat-composer__pill,
.ai-chat-modal.ai-chat-modal--leaving .ai-chat-composer__pill {
  opacity: 0;
  transform: translateY(8px);
  animation: none;
}

.ai-chat-modal.ai-chat-modal--open:not(.ai-chat-modal--leaving) .ai-chat-body:not(.ai-chat-body--landing) .ai-chat-composer__pill {
  animation: aiChatComposerInnerIn 200ms ease-out 100ms forwards;
}

@keyframes aiChatComposerInnerIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.ai-chat-modal__panel > .ai-chat-header,
.ai-chat-modal__panel > .ai-chat-body,
.ai-chat-modal__panel > .ai-chat-shell {
  position: relative;
  z-index: 1;
}

.ai-chat-shell {
  display: flex;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  align-self: stretch;
}

.ai-chat-shell__main {
  flex: 1;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.ai-chat-sidebar {
  flex-shrink: 0;
  width: 272px;
  min-width: 272px;
  border-right: 1px solid var(--ai-line);
  background: color-mix(in srgb, var(--ai-surface) 96%, var(--ds-neutral-surface-sunken));
  display: flex;
  flex-direction: column;
  min-height: 0;
  align-self: stretch;
  max-height: 100%;
  box-sizing: border-box;
  overflow: hidden;
}

.ai-chat-sidebar.hidden {
  display: none !important;
}

.ai-chat-modal__panel.ai-chat-modal--sidebar-open {
  max-width: 1120px;
}

.ai-chat-sidebar__head {
  flex-shrink: 0;
  padding: 14px 14px 10px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ds-text);
  border-bottom: 1px solid var(--ai-line);
  box-sizing: border-box;
}

.ai-chat-sidebar__search-wrap {
  flex-shrink: 0;
  padding: 8px 10px;
  border-bottom: 1px solid var(--ai-line);
  box-sizing: border-box;
}

.ai-chat-sidebar__search {
  width: 100%;
  box-sizing: border-box;
  height: 32px;
  border: 1px solid var(--ai-line);
  border-radius: 8px;
  padding: 0 10px;
  font-size: 12px;
  font-family: inherit;
  background: var(--ai-surface);
  color: var(--ds-text);
}

.ai-chat-sidebar__search:focus {
  outline: none;
  border-color: color-mix(in srgb, var(--ai-accent) 40%, var(--ai-line));
}

.ai-chat-streaming-bubble {
  font-size: 14px;
  line-height: 1.65;
  color: var(--ds-text);
  padding: 12px 14px;
  border-radius: 14px;
  background: color-mix(in srgb, var(--ai-accent-soft) 55%, var(--ai-surface));
  border: 1px solid var(--ai-line);
  min-height: 2.5em;
  white-space: pre-wrap;
  word-break: break-word;
}

.ai-chat-row--streaming .ai-chat-streaming-bubble:empty::after {
  content: '…';
  color: var(--ds-text-muted);
}

.ai-chat-row--streaming .ai-chat-streaming-bubble:not(:empty)::after {
  content: '▍';
  display: inline-block;
  margin-left: 2px;
  color: var(--ai-accent);
  animation: ai-chat-stream-cursor 1s step-end infinite;
  vertical-align: baseline;
}

@keyframes ai-chat-stream-cursor {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.15;
  }
}

.ai-chat-sidebar__pane {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 8px 10px 10px;
  min-height: 0;
  -webkit-overflow-scrolling: touch;
  box-sizing: border-box;
  width: 100%;
}

.ai-chat-sidebar__empty {
  padding: 24px 12px;
  text-align: center;
  font-size: 12px;
  color: var(--ds-text-muted);
  line-height: 1.6;
}

.ai-chat-sidebar__item {
  display: block;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  text-align: left;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 10px 10px 8px;
  margin: 0 0 6px;
  background: var(--ai-surface);
  cursor: pointer;
  font-family: inherit;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.ai-chat-sidebar__item:hover {
  border-color: var(--ai-line);
  background: color-mix(in srgb, var(--ai-accent-soft) 40%, var(--ai-surface));
}

.ai-chat-sidebar__item--active {
  border-color: color-mix(in srgb, var(--ai-accent) 35%, var(--ai-line));
  background: var(--ai-accent-soft);
}

.ai-chat-sidebar__item-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--ds-text);
  line-height: 1.35;
  margin: 0 0 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ai-chat-sidebar__item-preview {
  font-size: 12px;
  line-height: 1.45;
  color: var(--ds-text-secondary);
  margin: 0 0 6px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.ai-chat-sidebar__item-meta {
  font-size: 11px;
  color: var(--ds-text-muted);
  line-height: 1.3;
}

.ai-chat-sidebar__item-actions {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
  margin-top: 6px;
}

.ai-chat-sidebar__mini-btn {
  height: 26px;
  padding: 0 8px;
  font-size: 11px;
  border-radius: 6px;
  border: 1px solid var(--ai-line);
  background: var(--ai-surface);
  color: var(--ds-text-secondary);
  cursor: pointer;
  font-family: inherit;
  box-sizing: border-box;
  max-width: 100%;
}

.ai-chat-sidebar__mini-btn:hover {
  color: var(--ds-danger-emphasis);
  border-color: color-mix(in srgb, var(--ds-danger) 35%, var(--ai-line));
}

.ai-chat-modal__panel {
  max-width: 1040px;
  width: min(96vw, 1040px);
  height: min(88vh, 900px);
  max-height: min(88vh, 900px);
  border-radius: 20px;
  overflow: hidden;
  border: 1px solid color-mix(in srgb, var(--ds-border) 55%, transparent);
  background: var(--ai-surface);
  display: flex;
  flex-direction: column;
  box-shadow: 0 8px 32px color-mix(in srgb, var(--ds-text) 8%, transparent);
  position: relative;
  isolation: isolate;
}

.ai-chat-modal__panel.ai-chat-modal--landing {
  background: var(--ai-surface);
  box-shadow: 0 8px 32px color-mix(in srgb, var(--ds-text) 6%, transparent);
}

.ai-chat-modal__panel::before,
.ai-chat-modal__panel::after {
  content: none;
  display: none;
}

@keyframes aiGridDrift {
  0% { transform: translate3d(0, 0, 0); }
  100% { transform: translate3d(28px, 28px, 0); }
}

@keyframes aiScanSweep {
  0%, 100% { transform: translateY(-30%); opacity: 0; }
  45% { opacity: 0.65; }
  55% { opacity: 0.65; }
  100% { transform: translateY(30%); opacity: 0; }
}

.ai-chat-modal__panel > .ai-chat-header,
.ai-chat-modal__panel > .ai-chat-body {
  position: relative;
  z-index: 1;
}

.ai-chat-modal__panel > .ai-chat-landing__backdrop {
  position: absolute;
  inset: 0;
  z-index: 0;
}

/* ── 顶栏 ── */
.ai-chat-modal--landing .ai-chat-header {
  background: transparent;
  backdrop-filter: none;
  border-bottom: none;
}

.ai-chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 20px;
  background: var(--ai-surface);
  border-bottom: none;
  flex-shrink: 0;
  position: relative;
}

.ai-chat-header__main,
.ai-chat-header__actions {
  position: relative;
  z-index: 1;
}

.ai-chat-header__title {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--ds-text);
}

.ai-chat-modal--landing .ai-chat-header__title {
  font-weight: 500;
}

@keyframes aiTitleShimmer {
  0%, 100% { background-position: 0% center; }
  50% { background-position: 100% center; }
}

.ai-chat-header__status-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
}

.ai-chat-header__status {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  font-size: 12px;
  color: var(--ds-text-secondary);
}

.ai-chat-model-badge {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  border: 1px solid var(--ai-line);
  background: var(--ai-accent-soft);
  color: color-mix(in srgb, var(--ai-accent) 70%, var(--ds-text));
}

.ai-chat-model-badge--model {
  color: var(--ds-text);
}

.ai-chat-model-badge--warning {
  color: var(--ds-warning-emphasis);
  background: var(--ds-warning-muted);
  border-color: color-mix(in srgb, var(--ds-warning) 35%, white);
}

.ai-chat-model-badge--muted {
  color: var(--ds-text-muted);
}

.ai-chat-model-badge.hidden {
  display: none;
}

.ai-chat-status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ds-success);
  box-shadow: 0 0 8px color-mix(in srgb, var(--ds-success) 55%, transparent);
  flex-shrink: 0;
  animation: aiStatusPulse 2.8s ease-in-out infinite;
}

@keyframes aiStatusPulse {
  0%, 100% { opacity: 0.65; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.15); }
}

.ai-chat-header__actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-shrink: 0;
}

.ai-chat-header__btn {
  height: 34px;
  border-radius: 10px;
  padding: 0 12px;
  font-size: 12px;
  font-weight: 600;
  border: 1px solid transparent;
  background: color-mix(in srgb, var(--ai-surface-deep) 80%, transparent);
  color: var(--ds-text-secondary);
}

.ai-chat-header__btn:hover {
  background: var(--ai-accent-soft);
  color: var(--ds-text);
  border-color: var(--ai-line);
}

.ai-chat-header .modal-close {
  margin-left: 4px;
}

/* ── 主体 ── */
.ai-chat-body {
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1;
  background: transparent;
  position: relative;
}

/* ── 首屏炫酷背景（铺满整窗，避免与顶栏分界） ── */
.ai-chat-landing__backdrop {
  pointer-events: none;
  overflow: hidden;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.55s ease, visibility 0.55s ease;
}

.ai-chat-landing__backdrop:not(.hidden) {
  opacity: 1;
  visibility: visible;
}

.ai-chat-landing__mesh {
  position: absolute;
  left: 50%;
  top: 44%;
  width: 130%;
  height: 72%;
  transform: translate(-50%, -50%);
  background:
    radial-gradient(ellipse 40% 36% at 26% 44%, color-mix(in srgb, var(--ds-info) 34%, transparent), transparent 68%),
    radial-gradient(ellipse 36% 34% at 74% 50%, color-mix(in srgb, var(--ai-accent-deep) 30%, transparent), transparent 66%),
    radial-gradient(ellipse 42% 38% at 50% 64%, color-mix(in srgb, #8b5cf6 16%, transparent), transparent 70%);
  filter: blur(52px);
  animation: aiMeshBreathe 11s ease-in-out infinite;
}

.ai-chat-landing__mesh-spin {
  position: absolute;
  left: 50%;
  top: 46%;
  width: 88%;
  height: 52%;
  transform: translate(-50%, -50%);
  background: conic-gradient(
    from 140deg at 50% 50%,
    transparent 0deg,
    color-mix(in srgb, var(--ds-info) 24%, transparent) 72deg,
    color-mix(in srgb, var(--ai-accent-deep) 20%, transparent) 148deg,
    color-mix(in srgb, #7c3aed 14%, transparent) 220deg,
    transparent 300deg
  );
  filter: blur(60px);
  opacity: 0.7;
  animation: aiMeshSpin 20s linear infinite;
}

@keyframes aiMeshBreathe {
  0%, 100% {
    transform: translate(-50%, -50%) scale(1);
    opacity: 0.82;
  }
  50% {
    transform: translate(-50%, -46%) scale(1.1);
    opacity: 1;
  }
}

@keyframes aiMeshSpin {
  from { transform: translate(-50%, -50%) rotate(0deg); }
  to { transform: translate(-50%, -50%) rotate(360deg); }
}

.ai-chat-body--booting .ai-chat-messages,
.ai-chat-body--booting .ai-chat-composer,
.ai-chat-body--booting .ai-chat-landing__greet {
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.28s ease 0.08s;
}

.ai-chat-body:not(.ai-chat-body--booting) .ai-chat-messages,
.ai-chat-body:not(.ai-chat-body--booting) .ai-chat-composer {
  opacity: 1;
  visibility: visible;
  transition: opacity 0.28s ease;
}

/* ── 接入启动屏 ── */
.ai-chat-boot {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  background: color-mix(in srgb, var(--ai-surface) 55%, transparent);
  backdrop-filter: blur(16px) saturate(1.1);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.4s ease, visibility 0.4s ease;
}

.ai-chat-boot.ai-chat-boot--active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.ai-chat-boot.ai-chat-boot--leaving {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.ai-chat-boot.hidden {
  display: none !important;
}

.ai-chat-boot__grid {
  position: absolute;
  inset: 0;
  opacity: 0.35;
  background-image:
    linear-gradient(color-mix(in srgb, var(--ds-brand) 12%, transparent) 1px, transparent 1px),
    linear-gradient(90deg, color-mix(in srgb, var(--ds-brand) 12%, transparent) 1px, transparent 1px);
  background-size: 32px 32px;
  animation: aiGridDrift 18s linear infinite;
}

.ai-chat-boot__scan {
  position: absolute;
  inset: -50% 0;
  background: linear-gradient(
    180deg,
    transparent,
    color-mix(in srgb, var(--ds-brand) 14%, transparent),
    transparent
  );
  animation: aiScanSweep 3.2s ease-in-out infinite;
}

.ai-chat-boot__inner {
  position: relative;
  z-index: 1;
  text-align: center;
  padding: 24px;
}

.ai-chat-boot__hero {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  width: 140px;
  height: 140px;
  margin: 0 auto 24px;
}

.ai-chat-boot__hero .ai-chat-welcome-hero {
  width: 140px;
  height: 140px;
  margin: 0;
}

.ai-chat-boot__text {
  margin: 0;
  font-size: 14px;
  color: var(--ds-text-secondary);
  letter-spacing: 0.06em;
  animation: aiBootTextPulse 1.6s ease-in-out infinite;
}

@keyframes aiBootTextPulse {
  0%, 100% { opacity: 0.55; }
  50% { opacity: 1; }
}

/* 基石对话打开时，单据预览须叠在对话层之上 */
body.ai-chat-open > .modal.approval-doc-detail-overlay,
body.ai-chat-open > #oaDetailModal:not(.hidden) {
  z-index: 1800 !important;
}

.ai-chat-messages {
  flex: 1;
  overflow: auto;
  padding: 24px 24px 12px;
  min-height: 0;
  background: transparent;
}

.ai-chat-messages--has-thread {
  background: transparent;
}

/* ── Gemini 式首屏：输入框弹出 → 光晕扩散 → 问候语 ── */
.ai-chat-landing__greet {
  position: relative;
  z-index: 2;
  margin: 0 0 28px;
  padding: 0 8px;
  font-size: clamp(26px, 3vw, 32px);
  font-weight: 400;
  line-height: 1.4;
  color: var(--ds-text);
  letter-spacing: -0.02em;
  text-align: center;
  white-space: nowrap;
  opacity: 0;
  animation: aiLandingGreetFade 320ms cubic-bezier(0.16, 1, 0.3, 1) 0.72s forwards;
}

.ai-chat-landing__greet.hidden {
  display: none !important;
}

.ai-chat-quick-prompts {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin: 0 0 10px;
  padding: 0 12px;
}

.ai-chat-quick-prompts.hidden {
  display: none;
}

.ai-chat-quick-prompt {
  appearance: none;
  border: 1px solid color-mix(in srgb, var(--color-primary, #2563eb) 28%, transparent);
  background: color-mix(in srgb, var(--color-primary, #2563eb) 8%, #fff);
  color: var(--color-primary, #2563eb);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 0.8125rem;
  line-height: 1.2;
  cursor: pointer;
}

.ai-chat-quick-prompt:active {
  transform: scale(0.98);
}

@keyframes aiLandingGreetFade {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.ai-chat-body--landing {
  justify-content: flex-start;
  align-items: stretch;
}

.ai-chat-body--landing .ai-chat-messages {
  flex: 0 0 0;
  min-height: 0;
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  padding: 0;
  pointer-events: none;
}

.ai-chat-body--landing .ai-chat-composer {
  position: absolute;
  left: 0;
  right: 0;
  top: 44%;
  bottom: auto;
  transform: translateY(-50%);
  flex-shrink: 0;
  border-top: none;
  background: transparent;
  backdrop-filter: none;
  padding: 0 20px 12px;
  z-index: 2;
  transition:
    top 0.55s cubic-bezier(0.16, 1, 0.3, 1),
    bottom 0.55s cubic-bezier(0.16, 1, 0.3, 1),
    transform 0.55s cubic-bezier(0.16, 1, 0.3, 1),
    padding 0.55s cubic-bezier(0.16, 1, 0.3, 1),
    background 0.35s ease,
    border-color 0.35s ease;
}

.ai-chat-body--landing .ai-chat-status-line {
  opacity: 0;
  min-height: 0;
  margin: 0;
}

.ai-chat-body:not(.ai-chat-body--landing) .ai-chat-composer {
  position: relative;
  top: auto;
  bottom: auto;
  transform: none;
  transition:
    bottom 0.55s cubic-bezier(0.16, 1, 0.3, 1),
    transform 0.55s cubic-bezier(0.16, 1, 0.3, 1),
    padding 0.55s cubic-bezier(0.16, 1, 0.3, 1),
    background 0.35s ease,
    border-color 0.35s ease;
}

.ai-chat-composer__stage {
  position: relative;
  width: 100%;
  max-width: var(--ai-composer-max);
  margin: 0 auto;
}

.ai-chat-composer__glow {
  position: absolute;
  left: 50%;
  top: 62%;
  width: 115%;
  min-width: 280px;
  height: 200px;
  margin: 0;
  transform: translate(-50%, -50%) scale(0.3);
  transform-origin: center center;
  pointer-events: none;
  z-index: 0;
  opacity: 0;
  border-radius: 50%;
  background:
    radial-gradient(ellipse 70% 55% at 42% 52%, color-mix(in srgb, var(--ds-info) 22%, transparent), transparent 72%),
    radial-gradient(ellipse 65% 50% at 58% 48%, color-mix(in srgb, var(--ai-accent-deep) 18%, transparent), transparent 70%),
    radial-gradient(ellipse 80% 60% at 50% 55%, color-mix(in srgb, #8b5cf6 12%, transparent), transparent 75%);
  filter: blur(40px);
  animation: aiComposerGlowRadiate 900ms cubic-bezier(0.16, 1, 0.3, 1) 0.34s forwards,
    aiComposerGlowPulse 8s ease-in-out 1.2s infinite;
}

@keyframes aiComposerGlowPulse {
  0%, 100% { opacity: 0.75; filter: blur(40px); }
  50% { opacity: 0.95; filter: blur(44px); }
}

.ai-chat-composer__glow.hidden {
  visibility: hidden;
  opacity: 0;
  animation: none;
  pointer-events: none;
}

.ai-chat-body--landing .ai-chat-composer__glow:not(.hidden) {
  visibility: visible;
}

@keyframes aiComposerGlowRadiate {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.35);
  }
  45% {
    opacity: 0.7;
  }
  100% {
    opacity: 0.85;
    transform: translate(-50%, -50%) scale(1);
  }
}

.ai-chat-composer__pill {
  opacity: 1;
  transform: none;
}

.ai-chat-body--landing .ai-chat-composer__pill {
  opacity: 0;
  transform: scale(0.95) translateY(10px);
  animation: aiComposerPillPop 320ms cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes aiComposerPillPop {
  from {
    opacity: 0;
    transform: scale(0.95) translateY(10px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

/* ── 空状态（遗留 welcome 块，新会话不再渲染） ── */
.ai-chat-welcome {
  position: relative;
  min-height: 280px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 24px 16px;
}

.ai-chat-welcome__inner {
  position: relative;
  z-index: 1;
  max-width: 480px;
  text-align: center;
}

.ai-chat-welcome-hero {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  width: 140px;
  height: 140px;
  margin: 0 auto;
}

.ai-chat-welcome__desc {
  margin: 36px 0 0;
  font-size: 15px;
  line-height: 1.75;
  color: var(--ds-text);
  letter-spacing: 0.01em;
}

.ai-chat-welcome-orb {
  position: relative;
  z-index: 1;
  width: 88px;
  height: 88px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ai-chat-welcome-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 1px solid color-mix(in srgb, var(--ai-accent) 30%, transparent);
  box-shadow: 0 0 18px color-mix(in srgb, var(--ai-accent-deep) 12%, transparent);
  animation: aiWelcomeRingSpin 24s linear infinite;
}

.ai-chat-welcome-ring--a {
  inset: -6px;
  border-color: color-mix(in srgb, var(--ai-accent-deep) 42%, transparent);
  animation-duration: 18s;
  opacity: 0.88;
}

.ai-chat-welcome-ring--b {
  inset: -14px;
  opacity: 0.5;
  animation-duration: 26s;
  animation-direction: reverse;
  border-style: dashed;
  border-color: color-mix(in srgb, var(--ai-accent-deep) 24%, transparent);
}

.ai-chat-welcome-ring--c {
  inset: -22px;
  opacity: 0.32;
  animation-duration: 34s;
  border-color: color-mix(in srgb, var(--ds-info) 35%, transparent);
}

@keyframes aiWelcomeRingSpin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.ai-chat-welcome-beam {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 200px;
  height: 2px;
  margin: -1px -100px;
  transform-origin: center center;
  pointer-events: none;
  z-index: 0;
  background: linear-gradient(
    90deg,
    transparent,
    color-mix(in srgb, var(--ai-accent-deep) 65%, transparent),
    transparent
  );
  opacity: 0.48;
  filter: blur(1px);
  animation: aiWelcomeBeam 9s ease-in-out infinite;
}

@keyframes aiWelcomeBeam {
  0%, 100% {
    transform: rotate(0deg) scaleX(0.55);
    opacity: 0.22;
  }
  50% {
    transform: rotate(180deg) scaleX(1);
    opacity: 0.58;
  }
}

.ai-chat-avatar--hero {
  box-shadow:
    0 0 0 1px color-mix(in srgb, var(--ai-accent-deep) 12%, transparent),
    0 0 16px color-mix(in srgb, var(--ai-accent-deep) 14%, transparent);
  animation: none;
}

@keyframes aiHeroPulse {
  0%, 100% {
    box-shadow:
      0 0 0 1px color-mix(in srgb, var(--ai-accent-deep) 18%, transparent),
      0 0 22px color-mix(in srgb, var(--ai-accent-deep) 22%, transparent);
  }
  50% {
    box-shadow:
      0 0 0 1px color-mix(in srgb, var(--ai-accent-deep) 30%, transparent),
      0 0 36px color-mix(in srgb, var(--ai-accent-deep) 34%, transparent);
  }
}

.ai-chat-avatar {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  border-radius: 30%;
  background: linear-gradient(
    145deg,
    color-mix(in srgb, var(--ds-brand) 82%, white),
    var(--ds-brand)
  );
  color: var(--ds-on-brand, #fff);
  font-weight: 800;
  line-height: 1;
  box-shadow: 0 4px 16px color-mix(in srgb, var(--ds-brand) 28%, transparent);
  border: 1px solid color-mix(in srgb, var(--ds-brand) 35%, white);
}

.ai-chat-avatar-glow {
  position: absolute;
  inset: -3px;
  border-radius: inherit;
  background: var(--ds-brand);
  opacity: 0.22;
  filter: blur(7px);
  z-index: -1;
}

.ai-chat-avatar--lg {
  width: 52px;
  height: 52px;
  border-radius: 18px;
}

.ai-chat-avatar--lg .ai-chat-avatar__icon {
  font-size: 22px;
}

.ai-chat-avatar--sm {
  width: 28px;
  height: 28px;
  border-radius: 10px;
}

.ai-chat-avatar--sm .ai-chat-avatar__icon {
  font-size: 13px;
}

.ai-chat-avatar--xs {
  width: 26px;
  height: 26px;
  border-radius: 9px;
}

.ai-chat-avatar--xs .ai-chat-avatar__icon {
  font-size: 12px;
}

.ai-chat-avatar__icon {
  color: #fff;
  line-height: 1;
}

.ai-chat-avatar--hero .ai-chat-avatar__icon {
  animation: aiCubeConnect 2.4s ease-in-out infinite;
  filter: drop-shadow(0 0 6px color-mix(in srgb, white 40%, transparent));
}

.ai-chat-avatar--thinking-pulse .ai-chat-avatar__icon {
  animation: aiCubeThink 1.1s ease-in-out infinite;
}

.ai-chat-boot__avatar .ai-chat-avatar__icon {
  animation: aiCubeConnect 1.8s ease-in-out infinite;
}

@keyframes aiCubeConnect {
  0%, 100% { transform: rotate(-10deg) scale(1); filter: brightness(1); }
  50% { transform: rotate(10deg) scale(1.08); filter: brightness(1.15); }
}

@keyframes aiCubeThink {
  0%, 100% { transform: rotate(0deg) scale(1); opacity: 0.92; }
  25% { transform: rotate(-14deg) scale(1.06); opacity: 1; }
  75% { transform: rotate(14deg) scale(1.06); opacity: 1; }
}

.ai-chat-row--answer-reveal .ai-chat-assistant-bubble,
.ai-chat-row--answer-reveal .ai-answer-card:first-of-type {
  animation: aiAnswerReveal 0.65s ease-out;
}

@keyframes aiAnswerReveal {
  0% {
    box-shadow: 0 0 0 0 color-mix(in srgb, var(--ds-brand) 0%, transparent);
    border-color: color-mix(in srgb, var(--ds-brand) 22%, var(--ds-border));
  }
  35% {
    box-shadow: 0 0 22px color-mix(in srgb, var(--ds-brand) 32%, transparent);
    border-color: color-mix(in srgb, var(--ds-brand) 55%, var(--ds-border));
  }
  100% {
    box-shadow: none;
  }
}

.ai-chat-welcome__title {
  margin: 16px 0 0;
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--ds-text);
}

.ai-evidence-fold {
  margin-top: 10px;
  border-radius: 10px;
  border: 1px solid var(--ai-line);
  background: color-mix(in srgb, var(--ai-surface-deep) 50%, transparent);
}

.ai-evidence-fold__summary {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  cursor: pointer;
  list-style: none;
  user-select: none;
}

.ai-evidence-fold__summary::-webkit-details-marker {
  display: none;
}

.ai-evidence-fold__label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: var(--ds-text-secondary);
}

.ai-evidence-fold__meta {
  font-size: 11px;
  color: var(--ds-text-muted);
}

.ai-evidence-fold__chevron {
  margin-left: auto;
  font-size: 10px;
  color: var(--ds-text-muted);
  transition: transform 0.2s ease;
}

.ai-evidence-fold[open] .ai-evidence-fold__chevron {
  transform: rotate(180deg);
}

.ai-evidence-fold__body {
  padding: 0 12px 12px;
  line-height: 1.75;
  font-size: 13px;
  border-top: 1px solid color-mix(in srgb, var(--ai-line) 70%, transparent);
  padding-top: 10px;
  margin-top: 0;
}

.ai-evidence-fold[open] .ai-evidence-fold__body {
  animation: aiEvidenceReveal 0.2s ease-out;
}

@keyframes aiEvidenceReveal {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

.ai-chat-understanding {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 10px;
  padding: 8px 12px;
  border-radius: 10px;
  background: color-mix(in srgb, var(--ai-accent) 6%, transparent);
  border: 1px solid color-mix(in srgb, var(--ai-accent) 18%, var(--ai-line));
  max-width: 100%;
}

.ai-chat-understanding__label {
  flex: none;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: color-mix(in srgb, var(--ai-accent) 70%, var(--ds-text-secondary));
}

.ai-chat-understanding__text {
  font-size: 13px;
  line-height: 1.5;
  color: var(--ds-text-secondary);
}

.ai-chat-source-footer {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
  flex-wrap: wrap;
}

.ai-chat-source-badge {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 8px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  background: color-mix(in srgb, var(--ai-accent) 10%, transparent);
  color: color-mix(in srgb, var(--ai-accent) 75%, var(--ds-text));
  border: 1px solid color-mix(in srgb, var(--ai-accent) 22%, var(--ai-line));
}

.ai-chat-source-meta {
  font-size: 11px;
  color: var(--ds-text-muted);
}

.ai-chat-model-badge--accent {
  background: color-mix(in srgb, var(--ai-accent) 12%, transparent);
  color: color-mix(in srgb, var(--ai-accent) 80%, var(--ds-text));
  border-color: color-mix(in srgb, var(--ai-accent) 30%, var(--ai-line));
}

.ai-chat-thinking__text {
  font-size: 14px;
  color: var(--ds-text-secondary);
}

#aiChatModal .ai-answer-card--info {
  border-left-color: color-mix(in srgb, var(--ai-accent) 45%, var(--ai-line));
  background: color-mix(in srgb, var(--ai-accent) 5%, transparent);
}

.ai-chat-footnote {
  margin: 8px 0 0;
  padding: 0;
  font-size: 0.6875rem;
  line-height: 1.45;
  letter-spacing: 0.02em;
  color: color-mix(in srgb, var(--ds-text-muted, #94a3b8) 88%, var(--ds-text, #475569));
  opacity: 0.78;
}

/* ── 消息行 ── */
.ai-chat-row {
  margin-bottom: 20px;
}

.ai-chat-row--assistant {
  margin-bottom: 24px;
}

.ai-chat-row__inner {
  max-width: 820px;
  margin: 0 auto;
  width: 100%;
}

.ai-chat-row__inner--user {
  display: flex;
  justify-content: flex-end;
}

.ai-chat-assistant-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.ai-chat-assistant-label {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--ds-text-secondary);
}

.ai-chat-user-bubble {
  max-width: min(78%, 680px);
  background: var(--ds-neutral-surface-sunken);
  color: var(--ds-text);
  border-radius: 18px 18px 4px 18px;
  padding: 12px 16px;
  font-size: 14px;
  line-height: 1.75;
  white-space: normal;
  border: 1px solid var(--ai-line);
}

.ai-chat-assistant-bubble {
  max-width: 100%;
  background: var(--ai-surface);
  color: var(--ds-text);
  border: 1px solid var(--ai-line);
  border-radius: 4px 18px 18px 18px;
  padding: 16px 18px;
  font-size: 15px;
  line-height: 1.85;
  white-space: normal;
  box-shadow: none;
}

.ai-chat-doc-link {
  display: inline;
  margin: 0 1px;
  padding: 0 6px;
  height: auto;
  border: none;
  border-radius: 6px;
  background: var(--ai-accent-soft);
  color: color-mix(in srgb, var(--ai-accent) 75%, var(--ds-text));
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.92em;
  font-weight: 600;
  line-height: 1.6;
  cursor: pointer;
  vertical-align: baseline;
  transition: background 0.15s ease, box-shadow 0.15s ease, color 0.15s ease;
}

.ai-chat-doc-link:hover {
  background: color-mix(in srgb, var(--ai-accent) 28%, transparent);
  box-shadow: 0 0 12px color-mix(in srgb, var(--ai-accent) 35%, transparent);
  color: var(--ds-text);
}

.ai-chat-provider {
  font-size: 11px;
  color: var(--ds-text-muted);
  margin-top: 10px;
}

/* ── 回答卡片（扁平） ── */
#aiChatModal .ai-answer-card {
  border: none;
  border-radius: 12px;
  background: color-mix(in srgb, var(--ai-surface-deep) 55%, transparent);
  padding: 12px 14px;
  margin-top: 8px;
  border-left: 2px solid var(--ai-line);
  box-shadow: none;
}

#aiChatModal .ai-answer-card:first-of-type {
  margin-top: 0;
}

#aiChatModal .ai-answer-card-title {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ds-text-muted);
  margin-bottom: 6px;
}

.ai-answer-card__body {
  white-space: normal;
  line-height: 1.8;
  font-size: 14px;
  color: var(--ds-text);
}

.ai-answer-card__body--muted {
  font-size: 13px;
  color: var(--ds-text-secondary);
}

#aiChatModal .ai-answer-card--evidence {
  border-left-color: color-mix(in srgb, var(--ai-accent) 55%, white);
}

#aiChatModal .ai-answer-card--action {
  border-left-color: color-mix(in srgb, var(--ds-info) 55%, white);
}

#aiChatModal .ai-answer-card--learning {
  border-left-color: var(--ds-border-strong);
}

#aiChatModal .ai-answer-card--uncertain {
  border-left-color: color-mix(in srgb, var(--ds-warning) 55%, white);
  background: color-mix(in srgb, var(--ds-warning-muted) 60%, transparent);
}

#aiChatModal .ai-answer-card--uncertain .ai-answer-card__body {
  color: var(--ds-warning-emphasis);
}

/* ── 反馈操作 ── */
.ai-chat-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 12px;
  flex-wrap: wrap;
}

.ai-chat-action-btn {
  height: 30px;
  border-radius: 8px;
  padding: 0 12px;
  font-size: 12px;
  font-weight: 600;
  border: 1px solid transparent;
  background: color-mix(in srgb, var(--ai-surface-deep) 70%, transparent);
  color: var(--ds-text-secondary);
  cursor: pointer;
  font-family: inherit;
}

.ai-chat-action-btn:hover {
  background: var(--ai-accent-soft);
  color: var(--ds-text);
  border-color: var(--ai-line);
}

/* ── 思考中 ── */
.ai-chat-thinking {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 10px 14px;
  border-radius: 12px;
  background: var(--ds-neutral-surface-sunken);
  color: var(--ds-text-secondary);
  font-size: 14px;
  font-weight: 400;
  border: 1px solid var(--ai-line);
  position: relative;
}

.ai-chat-thinking::after {
  content: none;
  display: none;
}

@keyframes aiThinkSweep {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

.ai-chat-thinking-dots {
  display: inline-flex;
  gap: 5px;
  align-items: center;
}

.ai-chat-thinking-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--ds-text-muted);
  animation: aiThinkingPulse 1.2s infinite ease-in-out;
}

.ai-chat-thinking-dot:nth-child(2) {
  animation-delay: 0.15s;
}

.ai-chat-thinking-dot:nth-child(3) {
  animation-delay: 0.3s;
}

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

/* ── 错误 ── */
.ai-chat-error-box {
  white-space: normal;
  line-height: 1.85;
  font-size: 15px;
  color: var(--ds-danger-emphasis);
  background: var(--ds-danger-muted);
  border-radius: 14px;
  padding: 14px 16px;
  border-left: 2px solid var(--ds-danger);
}

.ai-chat-error-hint {
  font-size: 12px;
  color: var(--ds-danger-emphasis);
  opacity: 0.85;
  margin-top: 10px;
}

.ai-chat-error-actions {
  margin-top: 12px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.ai-chat-error-retry-btn {
  min-height: 36px;
}

.ai-chat-avatar--error {
  background: var(--ds-danger);
  color: #fff;
}

.ai-chat-assistant-label--error {
  color: var(--ds-danger-emphasis);
}

/* ── Composer ── */
.ai-chat-composer {
  flex-shrink: 0;
  padding: 12px 20px 14px;
  border-top: none;
  background: var(--ai-surface);
  z-index: 5;
  position: relative;
}

.ai-chat-operating-summary-link {
  display: block;
  width: 100%;
  box-sizing: border-box;
  margin: 7px 0 0;
  padding: 0 var(--ai-pill-cap-pad, 18px);
  appearance: none;
  border: none;
  background: transparent;
  text-align: left;
  font-size: 0.6875rem;
  line-height: 1.35;
  letter-spacing: 0.03em;
  font-weight: 400;
  color: color-mix(in srgb, var(--ds-text-muted, #94a3b8) 88%, var(--ds-text, #334155));
  opacity: 0.72;
  cursor: pointer;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
  transition: opacity 0.18s ease, color 0.18s ease;
}

.ai-chat-operating-summary-link:hover,
.ai-chat-operating-summary-link:focus-visible {
  opacity: 0.92;
  color: color-mix(in srgb, var(--ds-text-muted, #94a3b8) 70%, var(--ds-text, #475569));
  text-decoration: none;
  outline: none;
}

.ai-chat-operating-summary-link:active {
  opacity: 1;
}

.ai-chat-operating-summary-link.hidden {
  display: none;
}

.ai-chat-composer__rail {
  position: relative;
  z-index: 1;
  max-width: 100%;
  margin: 0 auto;
  padding: 0;
  border: none;
  background: transparent;
  backdrop-filter: none;
  box-shadow: none;
}

#aiChatModal .ai-chat-composer__pill {
  display: flex;
  align-items: center;
  gap: 0;
  box-sizing: border-box;
  height: var(--ai-pill-height);
  min-height: var(--ai-pill-height);
  padding: 0;
  padding-left: var(--ai-pill-cap-pad);
  padding-right: var(--ai-pill-cap-pad);
  border-radius: var(--ai-pill-arc-r);
  border: none;
  background: var(--ai-surface);
  box-shadow: var(--ai-input-shadow);
  transition: box-shadow 0.2s ease, padding-right 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}

#aiChatModal .ai-chat-composer__pill--send-visible {
  padding-right: 0;
}

#aiChatModal .ai-chat-composer__pill:focus-within {
  box-shadow: var(--ai-input-shadow-focus);
}

#aiChatModal .ai-chat-input {
  display: block;
  flex: 1;
  min-width: 0;
  width: 100%;
  resize: none;
  min-height: 24px;
  max-height: 120px;
  border: none;
  box-shadow: none;
  padding: 4px 0;
  margin: 0;
  background: transparent;
  font-size: 16px;
  line-height: 24px;
  color: var(--ds-text);
  font-family: inherit;
  overflow-y: auto;
  field-sizing: content;
}

.ai-chat-input:focus {
  outline: none;
}

.ai-chat-input::placeholder {
  color: var(--ds-text-muted);
}

#aiChatModal .ai-chat-send-btn {
  width: var(--ai-send-size);
  height: var(--ai-send-size);
  min-width: var(--ai-send-size);
  border-radius: 50%;
  padding: 0;
  margin: 0;
  font-weight: 600;
  flex-shrink: 0;
  border: none;
  outline: none;
  box-shadow: none;
  color: var(--ds-on-brand, #fff);
  background: var(--ds-brand);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition:
    background-color 0.15s ease,
    transform 0.22s cubic-bezier(0.34, 1.56, 0.64, 1),
    opacity 0.2s ease,
    width 0.22s cubic-bezier(0.16, 1, 0.3, 1),
    min-width 0.22s cubic-bezier(0.16, 1, 0.3, 1),
    margin 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}

#aiChatModal .ai-chat-send-btn:not(.ai-chat-send-btn--idle-hidden) {
  margin: var(--ai-pill-cap-pad);
  margin-left: 10px;
}

#aiChatModal .ai-chat-send-btn--idle-hidden {
  opacity: 0;
  width: 0;
  min-width: 0;
  margin: 0;
  padding: 0;
  pointer-events: none;
  overflow: hidden;
  transform: scale(0.5);
}

#aiChatModal .ai-chat-send-btn:not(.ai-chat-send-btn--idle-hidden) {
  opacity: 1;
  transform: scale(1);
}

#aiChatModal .ai-chat-send-btn__icon {
  display: block;
  width: 18px;
  height: 18px;
  flex: none;
}

.ai-chat-send-btn i {
  font-size: 14px;
  line-height: 1;
  font-weight: 400;
}

#aiChatModal .ai-chat-send-btn.ai-chat-send-btn--stop {
  border-radius: 50%;
  background: color-mix(in srgb, var(--ds-text) 8%, var(--ds-neutral-surface-sunken));
  color: var(--ds-text);
}

#aiChatModal .ai-chat-send-btn.ai-chat-send-btn--stop:not(:disabled):hover {
  background: color-mix(in srgb, var(--ds-text) 12%, var(--ds-neutral-surface-sunken));
  transform: none;
  color: var(--ds-text);
}

#aiChatModal .ai-chat-send-btn:not(:disabled):not(.ai-chat-send-btn--stop):hover {
  box-shadow: none;
  color: #fff;
}

#aiChatModal .ai-chat-send-btn:not(.ai-chat-send-btn--idle-hidden):not(:disabled):not(.ai-chat-send-btn--stop):hover {
  transform: scale(1.04);
}

#aiChatModal .ai-chat-send-btn__stop {
  display: block;
  width: 10px;
  height: 10px;
  border-radius: 2px;
  background: var(--ds-text);
  flex: none;
}

#aiChatModal .ai-chat-send-btn:focus-visible {
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--ds-brand) 32%, transparent);
}

#aiChatModal .ai-chat-send-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  box-shadow: none;
}

.ai-chat-status-line {
  max-width: var(--ai-composer-max);
  margin: 6px auto 0;
  font-size: 11px;
  color: var(--ds-text-muted);
  min-height: 1.2em;
}

@media (prefers-reduced-motion: reduce) {
  .ai-chat-modal__panel::before,
  .ai-chat-modal__panel::after,
  .ai-chat-header__title,
  .ai-chat-boot__grid,
  .ai-chat-boot__scan,
  .ai-chat-boot__text,
  .ai-chat-float-btn,
  .ai-chat-status-dot,
  .ai-chat-avatar--thinking-pulse .ai-chat-avatar__icon,
  .ai-chat-thinking::after,
  .ai-chat-row--answer-reveal .ai-chat-assistant-bubble,
  .ai-chat-row--answer-reveal .ai-answer-card:first-of-type,
  .ai-chat-composer__glow,
  .ai-chat-landing__mesh,
  .ai-chat-landing__mesh-spin,
  .ai-chat-landing__greet,
  .ai-chat-body--landing .ai-chat-composer__pill {
    animation: none !important;
  }
  .ai-chat-boot,
  .ai-chat-body--booting .ai-chat-messages,
  .ai-chat-body--booting .ai-chat-composer,
  .ai-chat-body:not(.ai-chat-body--booting) .ai-chat-messages,
  .ai-chat-body:not(.ai-chat-body--booting) .ai-chat-composer,
  .ai-chat-body--landing .ai-chat-composer,
  .ai-chat-body:not(.ai-chat-body--landing) .ai-chat-composer,
  .ai-chat-modal,
  .ai-chat-modal .ai-chat-modal__panel,
  .ai-chat-modal.ai-chat-modal--open,
  .ai-chat-modal.ai-chat-modal--leaving {
    animation: none !important;
    transition: none !important;
  }
  .ai-chat-modal.ai-chat-modal--open {
    background-color: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
  }
  .ai-chat-modal.ai-chat-modal--open .ai-chat-modal__panel,
  .ai-chat-modal.ai-chat-modal--open:not(.ai-chat-modal--leaving) .ai-chat-composer__pill {
    opacity: 1;
    transform: none;
  }
  .ai-chat-composer__glow,
  .ai-chat-landing__greet,
  .ai-chat-body--landing .ai-chat-composer__pill {
    opacity: 1;
    transform: none;
  }
}

.ai-chat-model-badge--accent {
  background: color-mix(in srgb, var(--ai-accent-deep) 12%, transparent);
  color: color-mix(in srgb, var(--ai-accent-deep) 82%, var(--ds-text));
  border-color: color-mix(in srgb, var(--ai-accent-deep) 26%, var(--ai-line));
}

@media (prefers-reduced-motion: reduce) {
  .ai-chat-modal__panel::before,
  .ai-chat-modal__panel::after,
  .ai-chat-welcome-ring,
  .ai-chat-welcome-beam,
  .ai-chat-avatar--hero,
  .ai-chat-float-btn,
  .ai-chat-status-dot,
  .ai-chat-header__title {
    animation: none !important;
  }

  .ai-chat-row--answer-reveal .ai-chat-assistant-bubble,
  .ai-chat-row--answer-reveal .ai-answer-card:first-of-type {
    animation: none !important;
  }
}

@media (max-width: 768px) {
  .ai-chat-shell {
    position: relative;
  }

  .ai-chat-sidebar-backdrop {
    display: none;
    border: none;
    padding: 0;
    margin: 0;
    appearance: none;
    -webkit-appearance: none;
  }

  .ai-chat-sidebar-backdrop:not(.hidden) {
    display: block;
    position: absolute;
    inset: 0;
    z-index: 7;
    background: color-mix(in srgb, var(--ds-text) 32%, transparent);
    cursor: pointer;
  }

  .ai-chat-sidebar:not(.hidden) {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    z-index: 8;
    width: min(88vw, 300px);
    min-width: min(88vw, 300px);
    box-shadow: 4px 0 24px color-mix(in srgb, var(--ds-text) 18%, transparent);
  }

  .ai-chat-modal__panel.ai-chat-modal--sidebar-open .ai-chat-shell__main {
    pointer-events: none;
    user-select: none;
  }

  .ai-chat-modal__panel {
    width: 100%;
    height: 100%;
    max-height: 100vh;
    border-radius: 0;
  }

  .ai-chat-messages {
    padding: 16px 14px 12px;
  }

  .ai-chat-composer {
    padding: 10px 12px 12px;
  }

  .ai-chat-body--landing .ai-chat-composer {
    padding: 0 14px;
  }

  .ai-chat-composer__stage {
    max-width: min(var(--ai-composer-max), 92vw);
  }

  .ai-chat-composer__glow {
    width: 120%;
    height: 160px;
    filter: blur(28px);
  }

  .ai-chat-welcome__title {
    font-size: 22px;
  }

  #aiChatModal .ai-chat-composer__pill {
    padding-left: var(--ai-pill-cap-pad);
  }
}
