/**
 * AI 秘书（2026-08-25）：全部选择器前缀 #assistant-root，零泄漏到现有页面。
 * 复用全站 design-tokens 变量（--color-primary 等）。
 */

/* ===== 悬浮按钮 ===== */
#assistant-root .ast-fab {
  position: fixed;
  right: 18px;
  bottom: 84px;                 /* 手机端抬过 bottom-nav */
  z-index: 900;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: none;
  background: var(--color-primary-gradient, #2563eb);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 18px rgba(37, 99, 235, .38);
  cursor: pointer;
  transition: transform .15s ease, box-shadow .15s ease;
}
#assistant-root .ast-fab:hover { transform: scale(1.07); }
#assistant-root .ast-fab .ast-fab-badge {
  position: absolute;
  top: -2px; right: -2px;
  background: var(--color-danger, #dc2626);
  color: #fff;
  font-size: 11px;
  line-height: 1;
  padding: 3px 6px;
  border-radius: 10px;
  display: none;
}
#assistant-root .ast-fab .ast-fab-badge.show { display: block; }
@media (min-width: 769px) {
  #assistant-root .ast-fab { bottom: 28px; right: 28px; width: 58px; height: 58px; }
}

/* ===== 抽屉 ===== */
#assistant-root .ast-drawer {
  position: fixed;
  z-index: 1000;
  background: var(--color-bg-page, #f1f5f9);
  display: none;
  flex-direction: column;
  box-shadow: 0 -8px 40px rgba(15, 23, 42, .18);
}
#assistant-root .ast-drawer.open { display: flex; }
/* 超大对话框（豆包式，2026-08-25 定稿主界面）：手机整屏，电脑居中大窗 */
@media (max-width: 768px) {
  #assistant-root .ast-drawer {
    left: 0; right: 0; bottom: 0;
    height: 100dvh;
    border-radius: 0;
  }
}
@media (min-width: 769px) {
  #assistant-root .ast-drawer {
    left: 50%;
    transform: translateX(-50%);
    top: 4vh;
    width: min(1100px, 94vw);
    height: 92vh;
    border-radius: 18px;
    border: 1px solid var(--color-border-light, #e2e8f0);
    box-shadow: 0 24px 80px rgba(15, 23, 42, .28);
  }
}
/* 内容列宽（豆包式居中可读列） */
#assistant-root .ast-body,
#assistant-root .ast-inputbar,
#assistant-root .ast-chips,
#assistant-root .ast-head {
  width: 100%;
  max-width: 800px;
  margin: 0 auto;
}
#assistant-root .ast-bubble { font-size: 15px; line-height: 1.65; }

/* 点选按钮（ask_user） */
#assistant-root .ast-choices {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
}
#assistant-root .ast-choice-btn {
  border: 1.5px solid var(--color-primary, #2563eb);
  background: var(--color-primary-050, #f8faff);
  color: var(--color-primary-dark, #1d4ed8);
  border-radius: 10px;
  padding: 8px 16px;
  font-size: 14px;
  cursor: pointer;
  transition: all .12s ease;
  -webkit-tap-highlight-color: transparent;
}
#assistant-root .ast-choice-btn:active { transform: scale(.97); }
#assistant-root .ast-choice-btn.picked {
  background: var(--color-primary-gradient, #2563eb);
  color: #fff;
}
#assistant-root .ast-choice-btn:disabled { opacity: .55; cursor: default; }
#assistant-root .ast-attach { background: var(--color-bg-card, #fff); border: 1px solid var(--color-border-light, #e2e8f0); color: var(--color-text-secondary, #475569); }

/* ===== 快捷指令条（主入口加速器） ===== */
#assistant-root .ast-chips {
  flex: 0 0 auto;
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 8px 12px;
  background: var(--color-bg-card, #fff);
  border-top: 1px solid var(--color-border-light, #e2e8f0);
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
#assistant-root .ast-chips::-webkit-scrollbar { display: none; }
#assistant-root .ast-chip {
  flex: 0 0 auto;
  border: 1px solid var(--color-border-light, #e2e8f0);
  background: var(--color-primary-050, #f8faff);
  color: var(--color-primary-dark, #1d4ed8);
  font-size: 12.5px;
  border-radius: 16px;
  padding: 6px 12px;
  cursor: pointer;
  white-space: nowrap;
  transition: background .12s ease;
  -webkit-tap-highlight-color: transparent;
}
#assistant-root .ast-chip:active { background: var(--color-primary-light, #eff6ff); }

/* ===== 头部 ===== */
#assistant-root .ast-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  background: var(--color-bg-card, #fff);
  border-bottom: 1px solid var(--color-border-light, #e2e8f0);
  flex: 0 0 auto;
}
#assistant-root .ast-head-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  color: var(--color-text-primary, #0f172a);
  font-size: 1rem;
  flex: 1;
}
#assistant-root .ast-head-title .ast-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--color-success, #16a34a);
}
#assistant-root .ast-icon-btn {
  border: 1px solid var(--color-border-light, #e2e8f0);
  background: var(--color-bg-card, #fff);
  border-radius: 8px;
  padding: 6px 8px;
  cursor: pointer;
  color: var(--color-text-secondary, #475569);
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
}
#assistant-root .ast-icon-btn.on {
  color: var(--color-primary, #2563eb);
  border-color: var(--color-primary, #2563eb);
  background: var(--color-primary-light, #eff6ff);
}

/* ===== 消息区 ===== */
#assistant-root .ast-body {
  flex: 1;
  overflow-y: auto;
  padding: 14px 12px 8px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
#assistant-root .ast-msg { max-width: 92%; display: flex; flex-direction: column; gap: 4px; }
#assistant-root .ast-msg.user { align-self: flex-end; align-items: flex-end; }
#assistant-root .ast-msg.ai { align-self: flex-start; align-items: flex-start; }
#assistant-root .ast-bubble {
  padding: 9px 12px;
  border-radius: 12px;
  font-size: var(--font-sm, .875rem);
  line-height: 1.55;
  word-break: break-word;
  white-space: pre-wrap;
}
#assistant-root .ast-msg.user .ast-bubble {
  background: var(--color-primary-gradient, #2563eb);
  color: #fff;
  border-bottom-right-radius: 4px;
}
#assistant-root .ast-msg.ai .ast-bubble {
  background: var(--color-bg-card, #fff);
  color: var(--color-text-primary, #0f172a);
  border: 1px solid var(--color-border-light, #e2e8f0);
  border-bottom-left-radius: 4px;
}
#assistant-root .ast-bubble strong { font-weight: 700; }

/* 工具轨迹 chips */
#assistant-root .ast-trace {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
#assistant-root .ast-trace-chip {
  font-size: 11px;
  color: var(--color-text-secondary, #475569);
  background: rgba(37, 99, 235, .08);
  border-radius: 8px;
  padding: 2px 7px;
}
#assistant-root .ast-trace-chip.bad { color: var(--color-danger, #dc2626); background: rgba(220,38,38,.08); }

/* 打字中 */
#assistant-root .ast-typing .ast-bubble { display: flex; gap: 4px; align-items: center; }
#assistant-root .ast-typing .ast-dot-b {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--color-text-secondary, #94a3b8);
  animation: ast-bounce 1.2s infinite;
}
#assistant-root .ast-typing .ast-dot-b:nth-child(2) { animation-delay: .18s; }
#assistant-root .ast-typing .ast-dot-b:nth-child(3) { animation-delay: .36s; }
@keyframes ast-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: .5; }
  30% { transform: translateY(-5px); opacity: 1; }
}

/* ===== 待执行卡片 ===== */
#assistant-root .ast-card {
  align-self: stretch;
  background: var(--color-bg-card, #fff);
  border: 1.5px solid var(--color-primary, #2563eb);
  border-radius: 12px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
#assistant-root .ast-card-title {
  font-weight: 700;
  color: var(--color-primary-dark, #1d4ed8);
  font-size: var(--font-sm, .875rem);
  display: flex;
  align-items: center;
  gap: 6px;
}
#assistant-root .ast-card-lines {
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 13px;
  color: var(--color-text-primary, #0f172a);
}
#assistant-root .ast-card-lines div { line-height: 1.45; }
#assistant-root .ast-card-actions { display: flex; gap: 8px; }
#assistant-root .ast-card-actions button {
  flex: 1;
  border: none;
  border-radius: 8px;
  padding: 8px 0;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
#assistant-root .ast-card-exec { background: var(--color-primary-gradient, #2563eb); color: #fff; }
#assistant-root .ast-card-cancel { background: #fff; color: var(--color-text-secondary, #475569); border: 1px solid var(--color-border-light, #e2e8f0) !important; }
#assistant-root .ast-card.done { border-color: var(--color-success, #16a34a); }
#assistant-root .ast-card.dead { border-color: var(--color-border-light, #e2e8f0); opacity: .7; }
#assistant-root .ast-card-note { font-size: 11px; color: var(--color-text-secondary, #475569); }

/* ===== 输入区 ===== */
#assistant-root .ast-inputbar {
  flex: 0 0 auto;
  display: flex;
  gap: 8px;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom, 0));
  background: var(--color-bg-card, #fff);
  border-top: 1px solid var(--color-border-light, #e2e8f0);
  align-items: flex-end;
}
#assistant-root .ast-input {
  flex: 1;
  border: 1px solid var(--color-border-light, #e2e8f0);
  border-radius: 10px;
  padding: 9px 12px;
  font-size: 14px;
  resize: none;
  min-height: 38px;
  max-height: 110px;
  font-family: inherit;
  outline: none;
  line-height: 1.4;
}
#assistant-root .ast-input:focus { border-color: var(--color-primary, #2563eb); }
#assistant-root .ast-mic,
#assistant-root .ast-send {
  width: 40px; height: 40px;
  border-radius: 10px;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
}
#assistant-root .ast-send { background: var(--color-primary-gradient, #2563eb); color: #fff; }
#assistant-root .ast-send:disabled { opacity: .5; cursor: default; }
#assistant-root .ast-mic {
  background: var(--color-primary-light, #eff6ff);
  color: var(--color-primary, #2563eb);
}
#assistant-root .ast-mic.listening {
  background: var(--color-danger, #dc2626);
  color: #fff;
  animation: ast-pulse 1.1s infinite;
}
#assistant-root .ast-mic.hidden { display: none; }
@keyframes ast-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(220, 38, 38, .45); }
  55% { box-shadow: 0 0 0 9px rgba(220, 38, 38, 0); }
}

/* 遮罩（手机） */
#assistant-root .ast-mask {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, .35);
  z-index: 999;
  display: none;
}
#assistant-root .ast-mask.show { display: block; }

/* ===== 通话模式（豆包式免提对话） ===== */
#assistant-root .ast-call {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: none;
  background: linear-gradient(160deg, #0f2138 0%, #12305c 55%, #0d1b33 100%);
  color: #eaf2ff;
}
#assistant-root .ast-call.open { display: flex; }
#assistant-root .ast-call-inner {
  margin: auto;
  width: min(92vw, 460px);
  max-height: 96vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 20px 14px calc(24px + env(safe-area-inset-bottom, 0px));
}
#assistant-root .ast-call-title {
  font-size: 15px;
  letter-spacing: 2px;
  color: rgba(234, 242, 255, .85);
  display: flex;
  align-items: center;
  gap: 8px;
}
#assistant-root .ast-call-title::before {
  content: '';
  width: 8px; height: 8px;
  border-radius: 50%;
  background: #34d399;
  animation: ast-breathe 2s infinite;
}
@keyframes ast-breathe { 0%, 100% { opacity: .5; } 50% { opacity: 1; } }

#assistant-root .ast-call-orb {
  position: relative;
  width: 116px; height: 116px;
  border-radius: 50%;
  border: none;
  background: radial-gradient(circle at 32% 28%, #4f8ef7, #1d4ed8 70%);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 10px 34px rgba(37, 99, 235, .5);
  transition: transform .12s ease;
  -webkit-tap-highlight-color: transparent;
}
#assistant-root .ast-call-orb:active { transform: scale(.92); }
#assistant-root .ast-call-rings {
  position: absolute;
  inset: -14px;
  border-radius: 50%;
  border: 2px solid rgba(79, 142, 247, .5);
  opacity: 0;
  pointer-events: none;
}
#assistant-root .ast-call.st-listening .ast-call-rings {
  animation: ast-ring 1.6s infinite;
}
#assistant-root .ast-call.st-listening .ast-call-rings::after {
  content: '';
  position: absolute;
  inset: 16px;
  border-radius: 50%;
  border: 2px solid rgba(79, 142, 247, .35);
  animation: ast-ring 1.6s infinite .4s;
}
@keyframes ast-ring {
  0% { transform: scale(.82); opacity: .9; }
  100% { transform: scale(1.18); opacity: 0; }
}

/* 识别中：旋转描边环 */
#assistant-root .ast-call.st-transcribing .ast-call-orb::after {
  content: '';
  position: absolute;
  inset: -10px;
  border-radius: 50%;
  border: 3px solid transparent;
  border-top-color: #7fb0ff;
  border-right-color: rgba(127, 176, 255, .35);
  animation: ast-spin .9s linear infinite;
}
@keyframes ast-spin { to { transform: rotate(360deg); } }

/* 声波音柱：倾听=蓝(活跃)，说话=橙；其余状态隐藏 */
#assistant-root .ast-call-wave {
  display: none;
  align-items: flex-end;
  justify-content: center;
  gap: 5px;
  height: 26px;
}
#assistant-root .ast-call-wave span {
  width: 4px;
  border-radius: 2px;
  background: #7fb0ff;
  height: 8px;
  animation: ast-bar 1s infinite ease-in-out;
}
#assistant-root .ast-call-wave span:nth-child(1) { animation-delay: 0s; }
#assistant-root .ast-call-wave span:nth-child(2) { animation-delay: .15s; }
#assistant-root .ast-call-wave span:nth-child(3) { animation-delay: .3s; }
#assistant-root .ast-call-wave span:nth-child(4) { animation-delay: .1s; }
#assistant-root .ast-call-wave span:nth-child(5) { animation-delay: .25s; }
@keyframes ast-bar {
  0%, 100% { height: 7px; opacity: .6; }
  35% { height: 24px; opacity: 1; }
  70% { height: 12px; opacity: .8; }
}
#assistant-root .ast-call.st-listening .ast-call-wave,
#assistant-root .ast-call.st-speaking .ast-call-wave { display: flex; }
#assistant-root .ast-call.st-speaking .ast-call-wave span { background: #fbbf6e; }

#assistant-root .ast-call.st-thinking .ast-call-orb { animation: ast-think 1.2s infinite ease-in-out; }
@keyframes ast-think { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.07); } }
#assistant-root .ast-call.st-speaking .ast-call-orb {
  background: radial-gradient(circle at 32% 28%, #f7a44f, #d97706 70%);
  box-shadow: 0 10px 34px rgba(217, 119, 6, .45);
}
#assistant-root .ast-call.st-transcribing .ast-call-orb {
  background: radial-gradient(circle at 32% 28%, #6ea3f5, #2563eb 70%);
}
#assistant-root .ast-call.st-paused .ast-call-orb { filter: grayscale(.7); }

#assistant-root .ast-call-status {
  font-size: 14px;
  color: rgba(234, 242, 255, .92);
  min-height: 20px;
  font-variant-numeric: tabular-nums;    /* 计时器数字不跳动 */
  letter-spacing: .5px;
}

#assistant-root .ast-call-reply {
  width: 100%;
  max-height: 30vh;
  overflow-y: auto;
  font-size: 14px;
  line-height: 1.6;
  background: rgba(255, 255, 255, .07);
  border-radius: 12px;
  padding: 10px 14px;
  white-space: pre-wrap;
  word-break: break-word;
}
#assistant-root .ast-call-card {
  width: 100%;
  background: rgba(79, 142, 247, .12);
  border: 1px solid rgba(79, 142, 247, .45);
  border-radius: 12px;
  padding: 10px 14px;
  display: none;
  flex-direction: column;
  gap: 4px;
}
#assistant-root .ast-call-card:has(.ast-call-card-title) { display: flex; }
#assistant-root .ast-call-card-title { font-weight: 700; font-size: 14px; color: #9cc3ff; }
#assistant-root .ast-call-card-line { font-size: 13px; line-height: 1.5; }
#assistant-root .ast-call-card-hint { font-size: 12px; color: rgba(234, 242, 255, .65); margin-top: 4px; }

#assistant-root .ast-call-hangup {
  margin-top: 4px;
  border: none;
  border-radius: 24px;
  padding: 10px 38px;
  font-size: 15px;
  background: rgba(220, 38, 38, .92);
  color: #fff;
  cursor: pointer;
}

/* 语音诊断长文本兜底：errMsg无空格ASCII长串不撑破气泡（2026-08-25 溢出修复） */
#assistant-root .ast-bubble { overflow-wrap: anywhere; }
