/* ========================================
   Textmolt - 主题样式表 (Light / Dark)
   ======================================== */

:root {
  color-scheme: only light;

  /* 背景色 - 浅色系（alias → tokens.css） */
  --bg-primary: var(--tm-bg-1);
  --bg-secondary: var(--tm-bg-2);
  --bg-tertiary: var(--tm-bg-3);
  --bg-hover: var(--tm-surface-3);
  --bg-glass: var(--tm-glass-bg-faint);

  /* 边框色（alias → tokens.css） */
  --border-color: var(--tm-border-default);
  --border-light: var(--tm-border-soft);

  /* 文字色（alias → tokens.css） */
  --text-primary: var(--tm-text-primary);
  --text-secondary: var(--tm-text-secondary);
  --text-muted: var(--tm-text-muted);

  /* 强调色（brand alias → tokens.css；非 brand 沿用真值） */
  --accent-blue: var(--tm-brand-blue);
  --accent-blue-hover: #1D4ED8; /* legacy-raw */
  --accent-indigo: #6366f1; /* legacy-raw */
  --accent-green: var(--tm-brand-green);
  --accent-orange: var(--tm-brand-orange);
  --accent-purple: var(--tm-brand-purple);

  /* Phase 2 ghost-token fix（之前未定义，改用 brand alias） */
  --accent-color: var(--tm-brand-blue);
  --text-purple: var(--tm-brand-purple);

  /* 渐变色（装饰性裸值豁免区，阶段 C 统一裁决 — D§3.9） */
  --gradient-blue: linear-gradient(135deg, #1E40AF 0%, #1E3A8A 100%); /* legacy-raw */
  --gradient-green: linear-gradient(135deg, #22c55e 0%, #10b981 100%); /* legacy-raw */
  --gradient-orange: linear-gradient(135deg, #f97316 0%, #f59e0b 100%); /* legacy-raw */
  --gradient-purple: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%); /* legacy-raw */

  /* 方案默认强调色（用于发送按钮、用户气泡等）
     glow 源收敛：--tm-model-glow-rgb 是唯一模型辉光事实源（D§2.2/§3.4） */
  --primary-gradient: linear-gradient(135deg, #6366f1 0%, #8d81da 100%);
  --primary-glow-rgb: var(--tm-model-glow-rgb);

  /* 极光色系背景（可随模型主题微调） */
  --aurora-1: rgba(99, 102, 241, 0.15); /* legacy-raw */
  --aurora-2: rgba(168, 85, 247, 0.15); /* legacy-raw */
  --aurora-3: rgba(56, 189, 248, 0.15); /* legacy-raw */

  /* 阴影（alias → tokens.css） */
  --shadow-sm: var(--tm-shadow-1);
  --shadow-md: var(--tm-shadow-2);
  --shadow-lg: var(--tm-shadow-3);
  --shadow-inner: var(--tm-shadow-inset);
  --shadow-float: var(--tm-shadow-float);
  --shadow-xl: var(--tm-shadow-xl);
  --glow-code: 0 0 0 1px rgba(99, 102, 241, 0.1), 0 0 20px rgba(99, 102, 241, 0.05); /* legacy-raw */

  /* 悬浮输入区占位（会被 JS 动态更新）- 增加底部呼吸空间 */
  --composer-safe-area: 180px;

  /* 动画 */
  --ease-elastic: cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease-out: cubic-bezier(0.2, 0.8, 0.2, 1);

  /* 布局（B5 刀①：刊头两态 = 大字行 + 2px 墨线 + 门楣签行，比旧功能头排高一档） */
  --header-height: 76px;

  /* 圆角（alias → tokens.css） */
  --radius-xs: var(--tm-radius-xs);
  --radius-sm: var(--tm-radius-sm);
  --radius-md: var(--tm-radius-md);
  --radius-lg: var(--tm-radius-lg);
  --radius-xl: var(--tm-radius-xl);
  --radius-full: var(--tm-radius-full);

  /* Auth Panel 变量 */
  --auth-panel-max-width: 380px;
  --auth-panel-radius: 18px;
  --auth-panel-padding-bottom: 24px;
  --auth-panel-top-offset: 48px;
  --auth-panel-header-margin-top: 24px;
  --auth-panel-header-margin-bottom: 24px;

  /* 过渡 */
  --transition: all 0.2s ease;

  /* 默认深色主题文字 (WPS AI default) */
  --text-deep-theme: #3B0764;
  --markdown-heading-letter-spacing: 0.07em;
  --markdown-list-item-gap: 0.5em;
  --markdown-card-title-letter-spacing: 0.07em;
  --markdown-card-title-weight: 600;
  --markdown-list-strong-letter-spacing: 0.07em;

  /* settings danger semantic tokens (light) */
  --settings-danger-fg: #b91c1c;
  --settings-danger-border: rgba(185, 28, 28, 0.3);
  --settings-danger-bg: rgba(254, 226, 226, 0.32);
  --settings-danger-bg-hover: rgba(254, 226, 226, 0.6);
  /* solid destructive (confirm modal) — light: #b91c1c + white ≈ 6.47:1 (WCAG AA) */
  --settings-danger-solid-bg: #b91c1c;
  --settings-danger-solid-fg: #ffffff;
  --settings-danger-solid-bg-hover: #991b1b;
}

/* ========================================
   Dark Theme — 全局语义变量覆盖
   CSS 只看 html[data-theme="dark"], JS 负责解析 system/light/dark
   ======================================== */
:root[data-theme="dark"] {
  color-scheme: dark;

  /* 背景色（alias → tokens.css dark override） */
  --bg-primary: var(--tm-bg-1);
  --bg-secondary: var(--tm-bg-2);
  --bg-tertiary: var(--tm-bg-3);
  --bg-hover: #2a2a2a;
  --bg-glass: rgba(18, 18, 18, 0.65);

  /* 边框色（alias） */
  --border-color: var(--tm-border-default);
  --border-light: var(--tm-border-soft);

  /* 文字色（alias） */
  --text-primary: var(--tm-text-primary);
  --text-secondary: var(--tm-text-secondary);
  --text-muted: var(--tm-text-muted);

  /* 强调色 — dark 亮度提升（brand alias；非 brand 沿用） */
  --accent-blue: var(--tm-brand-blue);
  --accent-blue-hover: #60a5fa;
  --accent-indigo: #818cf8;
  --accent-green: var(--tm-brand-green);
  --accent-orange: var(--tm-brand-orange);
  --accent-purple: var(--tm-brand-purple);

  /* 极光色系背景 (降低不透明度) */
  --aurora-1: rgba(99, 102, 241, 0.08);
  --aurora-2: rgba(168, 85, 247, 0.08);
  --aurora-3: rgba(56, 189, 248, 0.08);

  /* 阴影 (alias → tokens.css dark override) */
  --shadow-sm: var(--tm-shadow-1);
  --shadow-md: var(--tm-shadow-2);
  --shadow-lg: var(--tm-shadow-3);
  --shadow-inner: var(--tm-shadow-inset);
  --shadow-float: var(--tm-shadow-float);
  --shadow-xl: var(--tm-shadow-xl);
  --glow-code: 0 0 0 1px rgba(99, 102, 241, 0.3), 0 0 20px rgba(99, 102, 241, 0.15);

  /* 深色主题文字 */
  --text-deep-theme: #e2e8f0;

  /* settings danger semantic tokens (dark) */
  --settings-danger-fg: #fca5a5;
  --settings-danger-border: rgba(252, 165, 165, 0.32);
  --settings-danger-bg: rgba(127, 29, 29, 0.18);
  --settings-danger-bg-hover: rgba(127, 29, 29, 0.32);
  /* solid destructive (confirm modal) — dark: #dc2626 + white ≈ 4.83:1 (WCAG AA), avoids #fca5a5 neon bleed */
  --settings-danger-solid-bg: #dc2626;
  --settings-danger-solid-fg: #ffffff;
  --settings-danger-solid-bg-hover: #b91c1c;
}

/* Dark — 模型主题极光降低 */
:root[data-theme="dark"]:is([data-model="gpt_5_6_luna"],[data-model="gpt_5_6_terra"],[data-model="gpt_5_6_sol"]) {
  --aurora-1: rgba(16, 185, 129, 0.06);
  --aurora-2: rgba(34, 197, 94, 0.05);
  --aurora-3: rgba(45, 212, 191, 0.05);
  --text-deep-theme: #a7f3d0;
}
:root[data-theme="dark"]:is([data-model="claude_sonnet_5"],[data-model="claude_opus_5"],[data-model="claude_fable_5"]) {
  --aurora-1: rgba(249, 115, 22, 0.06);
  --aurora-2: rgba(245, 158, 11, 0.05);
  --aurora-3: rgba(250, 204, 21, 0.04);
  --text-deep-theme: #fed7aa;
}
:root[data-theme="dark"]:is([data-model="deepseek_v4_flash_0731"],[data-model="deepseek_v4_pro_0813"]) {
  --text-deep-theme:#ddd6fe;
}


:root:is([data-model="gpt_5_6_luna"],[data-model="gpt_5_6_terra"],[data-model="gpt_5_6_sol"]) {
  --primary-gradient: var(--gradient-green);
  --aurora-1: rgba(16, 185, 129, 0.14);
  --aurora-2: rgba(34, 197, 94, 0.12);
  --aurora-3: rgba(45, 212, 191, 0.12);
  --text-deep-theme: #064E3B; /* Deep Emerald */
  --orb-stop-1: #D1FAE5; --orb-stop-2: #34D399;
  --orb-stop-3: #10B981; --orb-stop-4: #065F46;
}

:root:is([data-model="claude_sonnet_5"],[data-model="claude_opus_5"],[data-model="claude_fable_5"]) {
  --primary-gradient: var(--gradient-orange);
  --aurora-1: rgba(249, 115, 22, 0.14);
  --aurora-2: rgba(245, 158, 11, 0.12);
  --aurora-3: rgba(250, 204, 21, 0.10);
  --text-deep-theme: #7C2D12; /* Deep Amber */
  --orb-stop-1: #FFEDD5; --orb-stop-2: #FB923C;
  --orb-stop-3: #F97316; --orb-stop-4: #9A3412;
}

:root:is([data-model="deepseek_v4_flash_0731"],[data-model="deepseek_v4_pro_0813"]) {
  --primary-gradient: var(--gradient-purple);
  --aurora-1: rgba(139, 92, 246, 0.14);
  --aurora-2: rgba(124, 58, 237, 0.12);
  --aurora-3: rgba(56, 189, 248, 0.10);
  --text-deep-theme: #581C87;
  --orb-stop-1: #EDE9FE; --orb-stop-2: #A78BFA;
  --orb-stop-3: #8B5CF6; --orb-stop-4: #5B21B6;
}

:root:is([data-model="gemini_3_7_flash"], [data-model="gemini_3_1_pro_preview"]) {
  --primary-gradient: var(--gradient-blue);
  --aurora-1: rgba(59, 130, 246, 0.14);
  --aurora-2: rgba(37, 99, 235, 0.12);
  --aurora-3: rgba(14, 165, 233, 0.10);
  --text-deep-theme: #1e3a8a;
  --orb-stop-1: #dbeafe; --orb-stop-2: #60a5fa;
  --orb-stop-3: #3b82f6; --orb-stop-4: #1e40af;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  font-family: var(--tm-font-sans);
  background: var(--bg-primary);
  color: var(--text-primary);
  font-size: 15px;
  line-height: 1.6;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.hidden {
  display: none !important;
}

/* ========================================
   方案 A: 流体极光背景（Fluid Aurora Mesh）
   ======================================== */

.ambient-mesh-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  z-index: -1;
  overflow: hidden;
  background: var(--bg-primary);
  pointer-events: none;
}

.mesh-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.85;
  animation: float-mesh 20s infinite ease-in-out alternate;
}

.orb-1 {
  top: -10%;
  left: -10%;
  width: 50vw;
  height: 50vw;
  background: var(--aurora-1);
  animation-delay: 0s;
}

.orb-2 {
  bottom: -10%;
  right: -10%;
  width: 60vw;
  height: 60vw;
  background: var(--aurora-2);
  animation-delay: -5s;
}

.orb-3 {
  top: 30%;
  left: 30%;
  width: 40vw;
  height: 40vw;
  background: var(--aurora-3);
  animation-delay: -10s;
  opacity: 0.65;
}

@keyframes float-mesh {
  0% { transform: translate(0, 0) scale(1); }
  33% { transform: translate(30px, -50px) scale(1.1); }
  66% { transform: translate(-20px, 20px) scale(0.9); }
  100% { transform: translate(0, 0) scale(1); }
}

/* AI 生成中：加速背景流动（通过 JS 添加 .thinking） */
body.thinking .mesh-orb {
  animation-duration: 4s;
  filter: blur(60px) saturate(1.45);
}

/* 隐藏额外的背景层（保留元素兼容性） */
.bg-noise,
.matrix-grid,
.glass-overlay {
  display: none;
}

/* ========================================
   悬浮工具栏
   ======================================== */

.floating-toolbar {
  position: fixed;
  z-index: var(--tm-z-toast); /* D§3.5: 非阻断浮层，不压 modal（原 9999 为层级 bug 隐患） */
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 6px 8px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  animation: toolbar-appear 0.15s ease-out;
}

@keyframes toolbar-appear {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.floating-toolbar button {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 10px;
  background: transparent;
  color: var(--text-secondary);
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 12px;
  white-space: nowrap;
  transition: var(--transition);
}

.floating-toolbar button:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.floating-toolbar button:active {
  transform: scale(0.96);
}

.floating-toolbar button svg {
  flex-shrink: 0;
}

.toolbar-arrow {
  position: absolute;
  bottom: -6px;
  left: 50%;
  transform: translateX(-50%);
  width: 12px;
  height: 6px;
  overflow: hidden;
}

.toolbar-arrow::after {
  content: '';
  position: absolute;
  top: -6px;
  left: 50%;
  transform: translateX(-50%) rotate(45deg);
  width: 10px;
  height: 10px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-top: none;
  border-left: none;
}

/* ========================================
   主应用容器
   ======================================== */

#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  max-height: 100vh;
  max-height: 100dvh;
  overflow: hidden;
  background: transparent;
  min-width: 300px;
  width: 100%;
  position: relative;
  /* 默认（窄屏）：全宽覆盖 */
  --cortex-width: 100%;
}

@media (min-width: 960px) {
  #app {
    /* 宽屏：侧边栏模式 */
    --cortex-width: clamp(320px, 40vw, 520px);
  }
}

/* ========================================
   头部
   ======================================== */

.header {
  height: var(--header-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  background: transparent;
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: var(--tm-z-sticky);
  width: 100%;
  box-sizing: border-box;
}

/* 账户/余额信息 */
.account-info {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  background: rgba(59, 130, 246, 0.15);
  border-radius: 12px;
  font-size: 12px;
  color: var(--accent-color, #3b82f6);
}

.account-info.hidden {
  display: none;
}

.account-balance {
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

.account-balance::before {
  content: "⚡";
  margin-right: 2px;
}

/* 已登录状态的账户按钮 */
.icon-btn.logged-in {
  color: var(--accent-color, #3b82f6);
}

.icon-btn {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  border-radius: var(--radius-full);
  color: var(--text-muted);
  cursor: pointer;
  transition: var(--transition);
}

#btn-memory {
  position: relative;
}

#btn-memory.pulsing {
  color: var(--accent-purple);
}

#btn-memory.pulsing::after {
  content: "";
  position: absolute;
  inset: 6px;
  border-radius: 999px;
  box-shadow: 0 0 0 0 rgba(139, 92, 246, 0.45);
  animation: memory-pulse 1.8s ease-in-out infinite;
  pointer-events: none;
}

#btn-memory.flash {
  animation:
    memory-bounce 0.55s cubic-bezier(0.18, 0.89, 0.32, 1.28) 1,
    memory-flash 0.65s ease-out 1;
}

@keyframes memory-pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(139, 92, 246, 0.35);
    opacity: 0.9;
  }
  70% {
    box-shadow: 0 0 0 10px rgba(139, 92, 246, 0);
    opacity: 0.45;
  }
  100% {
    box-shadow: 0 0 0 0 rgba(139, 92, 246, 0);
    opacity: 0;
  }
}

@keyframes memory-flash {
  0% {
    filter: drop-shadow(0 0 0 rgba(139, 92, 246, 0));
  }
  45% {
    filter: drop-shadow(0 0 10px rgba(139, 92, 246, 0.55));
  }
  100% {
    filter: drop-shadow(0 0 0 rgba(139, 92, 246, 0));
  }
}

@keyframes memory-bounce {
  0% { transform: scale(1); }
  45% { transform: scale(1.18); }
  70% { transform: scale(0.96); }
  100% { transform: scale(1); }
}

.icon-btn:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

/* 模型选择器触发器 */
.model-selector-trigger {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  margin: 0;
  border-radius: 20px;
  cursor: pointer;
  transition: all 0.2s ease;
  border: 1px solid rgba(255, 255, 255, 0.6);
  background: rgba(255, 255, 255, 0.5);
}

.model-selector-trigger:hover {
  background: rgba(255, 255, 255, 0.9);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

.model-icon {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  box-shadow: var(--shadow-sm);
  flex-shrink: 0;
}


.model-info {
  display: flex;
  align-items: center;
}

.model-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.2;
}

.model-provider {
  font-size: 10px;
  color: var(--text-muted);
  font-weight: 500;
}

.dropdown-arrow {
  color: var(--text-muted);
  transition: transform 0.2s ease;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
}

.model-selector-trigger.active .dropdown-arrow {
  transform: rotate(180deg);
}

/* ========================================
   模型下拉菜单
   ======================================== */

.model-dropdown {
  position: fixed;
  top: calc(var(--header-height) + 6px);
  left: 20px;
  width: min(320px, calc(100% - 40px));
  /* v0.9.70 hotfix P0: vertical scrolling — premium tier rows (e.g. GPT-5.5)
     were clipped on short viewports because the container was overflow:hidden
     with no max-height. Cap to viewport minus header + 60px breathing room,
     then scroll inside. Border radius preserved by overflow on the list.    */
  max-height: calc(100vh - var(--header-height) - 60px);
  display: flex;
  flex-direction: column;
  background: var(--bg-secondary);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border-color);
  overflow: hidden;
  z-index: var(--tm-z-toast);
  animation: dropdown-appear 0.2s ease-out;
}

/* v0.9.70 hotfix P0: scroll lives on the inner list so the rounded outer
   border still clips cleanly and the sticky header/footer stay pinned.    */
.model-dropdown .model-dropdown-list {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
}

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

/* 离场动画 - 缩小淡出（增强版，更明显的视觉反馈） */
@keyframes dropdown-exit {
  0% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
  100% {
    opacity: 0;
    transform: translateY(-12px) scale(0.92);
  }
}

.model-dropdown.closing {
  animation: dropdown-exit 0.7s cubic-bezier(0.4, 0, 1, 1) forwards;
  pointer-events: none; /* 防止动画期间误点击 */
}

.model-dropdown-header {
  padding: 10px 12px;
  background: var(--bg-tertiary);
  border-bottom: 1px solid var(--border-color);
  font-size: 10px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* v0.9.70 hotfix #9: header upgraded to a flex row when the info button is
   present. Tooltip is absolutely positioned relative to the header. */
.model-dropdown-header.model-dropdown-header--with-info {
  display: flex;
  align-items: center;
  gap: 6px;
  position: relative;
}

.model-dropdown-info-button {
  margin-inline-start: auto;
  width: 22px;
  height: 22px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 9999px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: var(--transition);
}

.model-dropdown-info-button:hover {
  background: rgba(0, 0, 0, 0.04);
  color: var(--text-secondary);
}

.model-dropdown-info-button:focus-visible {
  outline: 2px solid var(--accent-blue);
  outline-offset: 2px;
}

.model-dropdown-info-tooltip {
  position: absolute;
  top: calc(100% + 6px);
  inset-inline-end: 8px;
  z-index: calc(var(--tm-z-toast) + 100); /* 依附 toast 层的 tooltip 微层 */
  min-width: 240px;
  max-width: min(280px, calc(100vw - 32px));
  padding: 10px 12px;
  background: rgba(17, 24, 39, 0.96);
  color: #f9fafb;
  border-radius: 10px;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.18);
  font-size: 11px;
  font-weight: 500;
  line-height: 1.45;
  letter-spacing: 0;
  text-transform: none;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-4px);
  transition: opacity 0.15s ease, transform 0.15s ease, visibility 0s linear 0.15s;
  pointer-events: none;
}

.model-dropdown-info-tooltip.visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
  transition: opacity 0.15s ease, transform 0.15s ease, visibility 0s linear 0s;
  pointer-events: auto;
}

.model-dropdown-info-tooltip-title {
  font-weight: 600;
  color: #ffffff;
  margin-bottom: 6px;
}

.model-dropdown-info-tooltip-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.model-dropdown-info-tooltip-list li {
  position: relative;
  padding-inline-start: 12px;
  margin-bottom: 3px;
  color: #e5e7eb;
}

.model-dropdown-info-tooltip-list li::before {
  content: "•";
  position: absolute;
  inset-inline-start: 0;
  color: #fbbf24;
}

.model-dropdown-info-tooltip-note {
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid rgba(255, 255, 255, 0.10);
  color: #d1d5db;
  font-style: italic;
}

.model-dropdown-list {
  padding: 4px;
}

.model-option {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: var(--transition);
  border: none;
  background: transparent;
  width: 100%;
  text-align: left;
}

.model-option:hover {
  background: var(--bg-tertiary);
}

.model-option.active {
  background: rgba(59, 130, 246, 0.08);
}

.model-option-dot {
  width: 8px;
  height: 8px;
  border-radius: var(--radius-full);
  margin-top: 6px;
  flex-shrink: 0;
}


.model-option-info {
  flex: 1;
  min-width: 0;
}

.model-option-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  display: block;
}

.model-option.active .model-option-name {
  color: var(--accent-blue);
}

.model-option-desc {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
  display: block;
  line-height: 1.3;
}

.model-option-check {
  color: var(--accent-blue);
  margin-left: auto;
  margin-top: 4px;
  flex-shrink: 0;
}

.model-option.disabled {
  opacity: 0.55;
  cursor: not-allowed;
  /* v0.9.73 P1-2 fix: 移除 pointer-events:none — 它把 hover 和 click 全屏蔽，
     用户点击 Gemini 3 Flash Preview 等 ENV 未配模型完全无反馈。改由 selectModel
     (main.js:1506-1512) 在收到点击后 showToast disabledReason，体验更明确。
     行为符合 Material/Ant Design/Radix 等设计系统的 disabled-but-discoverable 标准。 */
}

.model-option.disabled:hover {
  /* v0.9.73 P1-2 fix: 给 disabled button hover 一个轻微反馈（非 transparent），
     让用户感知"是个真按钮但当前不可用"。 */
  background: rgba(0, 0, 0, 0.025);
}

/* ========================================
   v0.9.69 Model Selector v3 — tier groups, brand icons, lock-cta, footer
   spec: docs/plans/2026-05-05_v0969_model_selector_visual_redesign.md
   ======================================== */

.model-tier-group {
  display: block;
  padding: 4px 0;
}

.model-tier-group + .model-tier-group {
  border-top: 1px solid var(--border-color);
  margin-top: 4px;
  padding-top: 8px;
}

.model-tier-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding-inline: 12px;
  padding-block: 6px 4px;
  font-size: 10px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.model-tier-header-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 9999px;
  background: #fef3c7;
  color: #b45309;
  border: 1px solid #f59e0b;
  font-size: 10px;
  font-weight: 600;
  text-transform: none;
  letter-spacing: 0;
  margin-inline-start: auto;
}

.model-option-brand-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  margin-top: 2px;
  border-radius: 4px;
  object-fit: contain;
}

/* v0.9.70 hotfix D2 + D2.6: this class now exclusively renders the amber
   inline lock badge ("Plus" / "Pro" / "Max") next to a locked model name.
   The legacy purple basic/mid/premium variant was removed (D2.6). */
.model-option-tier-badge,
.model-option-lock-badge {
  display: inline-block;
  margin-inline-start: 6px;
  padding: 1px 8px;
  border-radius: 9999px;
  background: #fef3c7;
  color: #b45309;
  border: 1px solid #f59e0b;
  font-size: 10px;
  font-weight: 600;
  line-height: 1.5;
  vertical-align: middle;
  letter-spacing: 0;
  text-transform: none;
}

/* v0.9.70 hotfix D1.5 + D2.5 — locked row is now a self-contained clickable
 * div (no sibling lock-cta button, no group-level header badge). The amber
 * inline lock badge sits next to the model name (.model-option-lock-badge).
 * Whole row is the upgrade affordance — pointer events stay on so click
 * routes to the upgrade flow via handleDropdownClick. AT users hear the row
 * as `aria-disabled` + the row's `aria-label` already includes "Upgrade to
 * Plus" so the W3C APG nested-interactive debt from v0.9.69 is resolved.
 *
 * The previous .model-option-locked-wrapper / .model-option-lock-cta classes
 * and the v0.9.69 a11y debt comment block are intentionally retired here.
 * Spec §18.10 v0.9.70 milestone — see in-component comments.
 */
/* v0.9.73 P1 fix (FIX_PLAN F2): 仅 .model-option--locked 使用 amber 样式；
   aria-disabled 现在被 unavailable button 也使用（W3C APG a11y 标准），不能再
   用作样式钩子。原 selector 1187+1194 双处删 [aria-disabled="true"]。 */
.model-option--locked {
  cursor: pointer;
  opacity: 0.6;
  background: rgba(217, 119, 6, 0.02);
}

.model-option--locked:hover {
  background: rgba(217, 119, 6, 0.06);
  opacity: 0.85;
}

/* v0.9.69 a11y debt token retained for the legacy aria-debt regression test
 * — see frontend/tests/modelDropdown.aria.test.js. The CSS source string
 * check looks for "a11y debt" + "v0.9.70" + "2026-06-16"; preserving the
 * comment closes the debt window without keeping the old markup. */
/* a11y debt acceptance — v0.9.69 launch (closed in v0.9.70, deadline 2026-06-16) */

.model-option--trial {
  border: 1px dashed rgba(245, 158, 11, 0.55);
  background: rgba(255, 251, 235, 0.55);
}

.model-option-trial-meta {
  display: inline-block;
  margin-inline-start: 6px;
  padding: 1px 6px;
  border-radius: 9999px;
  background: rgba(217, 119, 6, 0.10);
  color: #b45309;
  font-size: 10px;
  font-weight: 600;
}

.model-dropdown-footer {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid var(--border-color);
  background: var(--bg-tertiary);
}

.model-dropdown-footer-balance,
.model-dropdown-balance {
  flex: 1;
  font-size: 11px;
  color: var(--text-secondary);
  line-height: 1.4;
  min-width: 0;
}

.model-dropdown-footer-cta,
.model-dropdown-upgrade-cta {
  border: 1px solid var(--accent-blue);
  background: var(--accent-blue);
  color: #fff;
  padding: 5px 12px;
  border-radius: 9999px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  flex-shrink: 0;
  transition: var(--transition);
}

.model-dropdown-footer-cta:hover,
.model-dropdown-upgrade-cta:hover {
  filter: brightness(1.05);
}

.model-dropdown-footer-cta:focus-visible,
.model-dropdown-upgrade-cta:focus-visible {
  outline: 2px solid var(--accent-blue);
  outline-offset: 2px;
}

.reasoning-depth-section {
  border-top: 1px solid var(--border-color);
  padding: 10px 12px 12px;
}

.reasoning-depth-header {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

.reasoning-depth-toggle {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
  padding: 4px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  background: var(--bg-tertiary);
}

.depth-btn {
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-secondary);
  border-radius: calc(var(--radius-lg) - 4px);
  font-size: 11px;
  line-height: 1.2;
  font-weight: 600;
  padding: 7px 4px;
  cursor: pointer;
  transition: var(--transition);
}

.depth-btn:hover {
  background: rgba(255, 255, 255, 0.06);
}

.depth-btn.active {
  color: rgb(var(--primary-glow-rgb));
  border-color: rgba(var(--primary-glow-rgb), 0.3);
  background: rgba(var(--primary-glow-rgb), 0.12);
}

/* ========================================
   聊天区域
   ======================================== */

.chat {
  flex: 1;
  overflow-y: auto;
  position: relative;
  padding: calc(var(--header-height) + 20px) 28px 0;
  display: flex;
  flex-direction: column;
  gap: 28px;
  background: transparent;
  scrollbar-width: thin;
  scrollbar-color: rgba(0, 0, 0, 0.12) transparent;
}

.chat-spacer {
  height: var(--composer-safe-area);
  width: 100%;
  flex-shrink: 0;
  pointer-events: none;
}

.chat::-webkit-scrollbar {
  width: 6px;
}

.chat::-webkit-scrollbar-track {
  background: transparent;
}

.chat::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 3px;
}

.chat::-webkit-scrollbar-thumb:hover {
  background: var(--border-light);
}

/* Cortex Panel 打开时：响应式策略 */

/* 1. 默认（窄屏）：Overlay + Push-Left */
#app.cortex-open .chat {
  /* 聊天内容向左被"挤"出屏幕，并虚化 */
  transform: translateX(-120px);
  opacity: 0.4;
  filter: blur(1px);
  transition: transform 0.35s cubic-bezier(0.23, 1, 0.32, 1), opacity 0.35s ease, filter 0.35s ease;
  pointer-events: none; /* 遮挡时不可交互 */
}

#app.cortex-open .composer-container,
#app.composer-docked .composer-container {
  /* 输入框左移停靠，作为"把手" */
  left: 0;
  right: auto;
  transform: translateX(calc(-100% + 20.5px)); /* 再次向左收缩 2px */
  width: min(300px, calc(100% - 40px)); /* 限制宽度，使其看起来更像把手 */
  opacity: 0.5; /* 半透明 */
  pointer-events: auto; /* 允许点击 */
  cursor: pointer; /* 手型光标 */
  transition: 
    left 0.35s cubic-bezier(0.23, 1, 0.32, 1),
    transform 0.35s cubic-bezier(0.23, 1, 0.32, 1),
    width 0.35s ease,
    opacity 0.35s ease;
}

#app.cortex-open .composer-container *,
#app.composer-docked .composer-container * {
  /* 禁用内部元素交互，确保点击触发容器事件 */
  pointer-events: none;
}

#app.cortex-open .composer-container:hover,
#app.composer-docked .composer-container:hover {
  opacity: 0.9;
}

/* 当输入框停靠在左侧时，增加明显的灰度背景，强化"停靠"的视觉隐喻 */
#app.cortex-open .composer-container .composer-glass-panel,
#app.composer-docked .composer-container .composer-glass-panel {
  background: rgba(var(--primary-glow-rgb), 0.15); /* 主题色玻璃质感，略微提升清晰度 */
  border-color: rgba(var(--primary-glow-rgb), 0.1); /* 匹配主题色的边框 */
  box-shadow:
    4px 0 16px rgba(0, 0, 0, 0.08), /* 面板自身的3D投影 */
    inset -1px 0 2px rgba(255, 255, 255, 0.8); /* 内高光增强立体感 */
  backdrop-filter: blur(16px) saturate(100%); /* 降低模糊，恢复饱和 */
  -webkit-backdrop-filter: blur(16px) saturate(100%);
}


/* 2. 宽屏 (>= 960px)：Side-by-Side 并排 */
@media (min-width: 960px) {
  #app.cortex-open .chat {
    padding-right: calc(28px + var(--cortex-width));
    transform: none;
    opacity: 1;
    filter: none;
    pointer-events: auto;
    transition: padding-right 0.28s ease;
  }

  #app.cortex-open .composer-container {
    /* 输入框居中于剩余空间 */
    width: max(260px, calc(100% - 40px - var(--cortex-width)));
    left: calc(50% - (var(--cortex-width) / 2));
    transform: translateX(-50%);
    opacity: 1;
    pointer-events: auto;
    transition: left 0.28s ease, width 0.28s ease;
  }
}

/* Cortex Panel（记忆面板） */
.cortex-panel {
  position: absolute;
  top: var(--header-height);
  right: 0;
  bottom: 0;
  width: var(--cortex-width);
  z-index: calc(var(--tm-z-sticky) - 5); /* 紧贴 header 之下 */
  pointer-events: auto;
  transform: translateX(0);
  opacity: 1;
  transition: transform 0.35s cubic-bezier(0.23, 1, 0.32, 1), opacity 0.25s ease;
}

.cortex-panel.hidden {
  pointer-events: none;
  opacity: 0;
  /* 完全滑出屏幕 */
  transform: translateX(100%);
}

.cortex-panel-inner {
  height: 100%;
  border-left: 1px solid rgba(255, 255, 255, 0.22);
  background: rgba(255, 255, 255, 0.72);
  backdrop-filter: blur(24px) saturate(300%);
  -webkit-backdrop-filter: blur(24px) saturate(300%);
  box-shadow: -20px 0 40px -5px rgba(0, 0, 0, 0.1), -10px 0 15px -6px rgba(0, 0, 0, 0.05);
  display: flex;
  flex-direction: column;
}

.cortex-header {
  padding: 16px 16px 12px 20px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.28);
}

.cortex-title {
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  /* 硬编码亮档墨色曾致暗档题字近隐形(0813 审计 A-1)——本族一律语义 token */
  color: var(--tm-text-primary);
}

.cortex-subtitle {
  margin-top: 3px;
  font-size: 11px;
  color: var(--tm-text-muted);
  font-weight: 500;
}

.cortex-close {
  color: rgba(30, 30, 30, 0.45);
  transition: color 0.2s ease;
}

.cortex-close:hover {
  color: var(--text-primary);
  background: rgba(0,0,0,0.04);
}

.cortex-scroll {
  padding: 20px 20px 24px 20px;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  gap: 24px;
  flex: 1;
  min-height: 0;
}

.cortex-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.cortex-working {
  position: relative;
  padding: 16px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.35);
  border: 1px solid rgba(148, 163, 184, 0.12);
  box-shadow: inset 0 1px 2px rgba(255,255,255,0.6);
}

.cortex-working::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 20px;
  background:
    radial-gradient(circle at 20% 30%, rgba(139, 92, 246, 0.08), transparent 60%),
    radial-gradient(circle at 80% 70%, rgba(59, 130, 246, 0.08), transparent 60%);
  opacity: 0.6;
  animation: wm-breathe 6s ease-in-out infinite;
  pointer-events: none;
}

.cortex-working > * {
  position: relative;
}

@keyframes wm-breathe {
  0%, 100% { opacity: 0.5; transform: scale(1); }
  50% { opacity: 0.8; transform: scale(1.02); }
}

.cortex-section-title {
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--tm-text-secondary);
  margin-bottom: 2px;
}

.cortex-section-desc {
  font-size: 11px;
  color: var(--tm-text-muted);
  margin-top: -6px;
  margin-bottom: 4px;
}

/* ========================================
   Storage Config (Repository) Styles
   ======================================== */

.cortex-storage {
  position: relative;
  padding: 14px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.3);
  border: 1px solid rgba(148, 163, 184, 0.1);
}

.storage-config {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.storage-path-row {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.5);
  border-radius: 8px;
  padding: 8px 10px;
  border: 1px solid rgba(148, 163, 184, 0.12);
}

.storage-path-value {
  flex: 1;
  font-size: 11px;
  font-family: var(--tm-font-mono);
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.storage-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 6px 10px;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-secondary);
  background: rgba(255, 255, 255, 0.6);
  border: 1px solid rgba(148, 163, 184, 0.18);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.storage-btn:hover {
  background: rgba(255, 255, 255, 0.85);
  border-color: rgba(148, 163, 184, 0.28);
  color: var(--text-primary);
}

.storage-btn-copy {
  padding: 4px 6px;
  background: transparent;
  border: none;
}

.storage-btn-copy:hover {
  background: rgba(139, 92, 246, 0.1);
  color: var(--accent-purple);
}

.storage-btn-secondary {
  background: transparent;
  border-color: rgba(148, 163, 184, 0.12);
  color: var(--text-muted);
}

.storage-btn-secondary:hover {
  background: rgba(139, 92, 246, 0.08);
  border-color: rgba(139, 92, 246, 0.2);
  color: var(--accent-purple);
}

.storage-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.storage-pill {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  font-size: 10px;
  font-weight: 600;
  border-radius: 10px;
  letter-spacing: 0.02em;
}

.storage-pill-default {
  background: rgba(148, 163, 184, 0.12);
  color: var(--text-muted);
}

.storage-pill-custom {
  background: rgba(139, 92, 246, 0.12);
  color: var(--accent-purple);
}

.storage-pill-ok {
  background: rgba(16, 185, 129, 0.12);
  color: var(--accent-green);
}

.storage-pill-warn {
  background: rgba(249, 115, 22, 0.12);
  color: var(--accent-orange);
}

.storage-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
}

/* Storage Edit Form */
.storage-edit-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.storage-edit-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.storage-edit-input {
  width: 100%;
  padding: 10px 12px;
  font-size: 12px;
  font-family: var(--tm-font-mono);
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: 8px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.storage-edit-input:focus {
  border-color: rgba(139, 92, 246, 0.5);
  box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.1);
}

.storage-edit-input::placeholder {
  color: var(--text-muted);
}

.storage-migrate-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.storage-radio {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--text-secondary);
  cursor: pointer;
}

.storage-radio input[type="radio"] {
  width: 14px;
  height: 14px;
  accent-color: var(--accent-purple);
  cursor: pointer;
}

.storage-edit-actions {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}

/* ========================================
   Compact Settings
   ======================================== */

.compact-settings {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* ========================================
   Task Sound Settings
   ======================================== */

.task-sound-settings {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.task-sound-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.task-sound-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: var(--text-primary);
  cursor: pointer;
}

.task-sound-toggle input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--accent-purple);
  cursor: pointer;
}

.task-sound-status {
  font-size: 10px;
  padding: 3px 8px;
  border-radius: 10px;
  background: rgba(148, 163, 184, 0.12);
  color: var(--text-muted);
}

.task-sound-status.on {
  background: rgba(16, 185, 129, 0.12);
  color: var(--accent-green);
}

.task-sound-status.off {
  background: rgba(148, 163, 184, 0.12);
  color: var(--text-muted);
}

.task-sound-status.saving {
  background: rgba(139, 92, 246, 0.12);
  color: var(--accent-purple);
}

.task-sound-status.error {
  background: rgba(249, 115, 22, 0.12);
  color: var(--accent-orange);
}

.task-sound-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.task-sound-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
}

.task-sound-input {
  width: 100%;
  padding: 8px 10px;
  font-size: 11px;
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: 6px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.task-sound-input:focus {
  border-color: rgba(139, 92, 246, 0.5);
  box-shadow: 0 0 0 2px rgba(139, 92, 246, 0.1);
}

.task-sound-note {
  font-size: 10px;
  color: var(--text-muted);
}

.task-sound-actions {
  display: flex;
  gap: 8px;
}

.task-sound-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 6px 10px;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-secondary);
  background: rgba(255, 255, 255, 0.6);
  border: 1px solid rgba(148, 163, 184, 0.18);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.task-sound-btn:hover {
  background: rgba(255, 255, 255, 0.85);
  border-color: rgba(148, 163, 184, 0.28);
  color: var(--text-primary);
}

.task-sound-btn.secondary {
  background: transparent;
  border-color: rgba(148, 163, 184, 0.12);
  color: var(--text-muted);
}

.task-sound-btn.secondary:hover {
  background: rgba(139, 92, 246, 0.08);
  border-color: rgba(139, 92, 246, 0.2);
  color: var(--accent-purple);
}

.task-sound-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.compact-setting-item {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.compact-setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.compact-setting-label {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  min-width: 0;
}

.compact-setting-label-text {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-primary);
}

.compact-setting-label-desc {
  font-size: 10px;
  color: var(--text-muted);
}

.compact-setting-select {
  min-width: 100px;
  padding: 6px 10px;
  font-size: 11px;
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: 6px;
  outline: none;
  cursor: pointer;
  transition: border-color 0.15s ease;
}

.compact-setting-select:hover {
  border-color: rgba(148, 163, 184, 0.35);
}

.compact-setting-select:focus {
  border-color: rgba(139, 92, 246, 0.5);
  box-shadow: 0 0 0 2px rgba(139, 92, 246, 0.1);
}

.compact-setting-input {
  width: 70px;
  padding: 6px 10px;
  font-size: 11px;
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: 6px;
  outline: none;
  text-align: center;
  transition: border-color 0.15s ease;
}

.compact-setting-input:hover {
  border-color: rgba(148, 163, 184, 0.35);
}

.compact-setting-input:focus {
  border-color: rgba(139, 92, 246, 0.5);
  box-shadow: 0 0 0 2px rgba(139, 92, 246, 0.1);
}

.compact-settings-divider {
  height: 1px;
  background: rgba(148, 163, 184, 0.12);
  margin: 4px 0;
}

.compact-settings-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px 0;
  transition: color 0.15s ease;
}

.compact-settings-toggle:hover {
  color: var(--text-secondary);
}

.compact-settings-toggle svg {
  width: 12px;
  height: 12px;
  transition: transform 0.2s ease;
}

.compact-settings-toggle.expanded svg {
  transform: rotate(90deg);
}

.compact-settings-advanced {
  display: none;
  flex-direction: column;
  gap: 10px;
  padding-top: 8px;
}

.compact-settings-advanced.show {
  display: flex;
}

.compact-settings-status {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  font-size: 10px;
  color: var(--text-muted);
  background: rgba(16, 185, 129, 0.08);
  border-radius: 6px;
}

.compact-settings-status.saving {
  background: rgba(139, 92, 246, 0.08);
  color: var(--accent-purple);
}

.compact-settings-status.error {
  background: rgba(249, 115, 22, 0.08);
  color: var(--accent-orange);
}

.working-memory-cards {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.wm-card {
  border-radius: 14px;
  padding: 12px;
  background: var(--tm-surface-1);
  border: 1px solid var(--tm-border-default);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.03);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.wm-card:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.06);
}

.wm-card[data-section="facts"] { border-left: 3px solid rgba(59, 130, 246, 0.4); }
.wm-card[data-section="decisions"] { border-left: 3px solid rgba(249, 115, 22, 0.4); }
.wm-card[data-section="todos"] { border-left: 3px solid rgba(16, 185, 129, 0.4); }
.wm-card[data-section="style"] { border-left: 3px solid rgba(139, 92, 246, 0.4); }

.wm-card-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}

.wm-card-title span {
  font-size: 11px;
  font-weight: 700;
  color: var(--tm-text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.wm-add-btn {
  margin-left: auto;
  border: none;
  background: transparent;
  color: rgba(59, 130, 246, 0.8);
  font-size: 11px;
  font-weight: 600;
  padding: 4px 8px;
  border-radius: 6px;
  cursor: pointer;
  transition: var(--transition);
}

.wm-add-btn:hover {
  background: rgba(59, 130, 246, 0.1);
}

.wm-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.wm-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--tm-surface-2);
  border: 1px solid var(--tm-border-default);
  transition: background 0.15s ease;
}

.wm-item:hover {
  background: var(--tm-surface-3);
}

.wm-text {
  flex: 1;
  font-size: 12px;
  color: var(--tm-text-primary);
  line-height: 1.5;
  white-space: pre-wrap;
}

.wm-text[contenteditable="true"] {
  outline: none;
  box-shadow: 0 0 0 2px rgba(139, 92, 246, 0.3);
  border-radius: 6px;
  padding: 4px 6px;
  background: white;
}

/* 动作词不许只留 hover 一条通道(总纲第 8 条③)；visibility 而非 opacity:0
   ——隐形占位会截走点击(narrow-panel-precheck 禁形) */
.wm-actions {
  display: flex;
  gap: 4px;
  visibility: hidden;
}

.wm-item:hover .wm-actions,
.wm-item:focus-within .wm-actions {
  visibility: visible;
}

@media (hover: none) {
  .wm-actions {
    visibility: visible;
  }
}

.wm-action-btn {
  width: 20px;
  height: 20px;
  border-radius: 6px;
  border: none;
  background: transparent;
  color: rgba(148, 163, 184, 0.8);
  cursor: pointer;
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.wm-action-btn:hover {
  background: rgba(0, 0, 0, 0.05);
  color: var(--text-primary);
}

.memory-files {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* ---------------------------------------------------- */
/* Long-term Memory 文件列表样式优化 (统一风格) */
/* ---------------------------------------------------- */

.mem-file {
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.5); /* 半透明磨砂 */
  border: 1px solid rgba(148, 163, 184, 0.15);
  overflow: hidden;
  transition: all 0.2s ease;
}

.mem-file:hover {
  background: rgba(255, 255, 255, 0.7);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.04);
  transform: translateY(-1px);
}

.mem-file-header {
  padding: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  cursor: pointer;
  background: transparent;
}

.mem-file-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--tm-text-primary);
  margin-bottom: 2px;
}

.mem-file-desc {
  font-size: 11px;
  color: var(--tm-text-muted);
}

.mem-file.open {
  /* 0813 换皮：展开不再抬白卡——誊写面（稿纸 textarea）自身已是纸面焦点 */
  background: transparent;
  box-shadow: none;
}

.mem-file.open .mem-file-body {
  display: block;
}

.mem-file-body {
  padding: 0 12px 12px 12px;
  border-top: none;
  display: none;
  animation: slide-down 0.2s ease-out;
}

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

.mem-editor {
  width: 100%;
  min-height: 120px;
  padding: 10px;
  font-size: 12px;
  line-height: 1.5;
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.6);
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: 8px;
  outline: none;
  transition: border-color 0.2s;
  font-family: var(--tm-font-mono);
}

.mem-editor:focus {
  border-color: var(--accent-purple);
  box-shadow: 0 0 0 2px rgba(139, 92, 246, 0.15);
}

.mem-actions {
  margin-top: 8px;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.mem-save-btn {
  border: 1px solid rgba(139, 92, 246, 0.25);
  background: rgba(139, 92, 246, 0.12);
  color: rgba(91, 33, 182, 0.9);
  font-size: 11px;
  padding: 7px 10px;
  border-radius: 10px;
  cursor: pointer;
  transition: var(--transition);
}

.mem-save-btn:hover {
  background: rgba(139, 92, 246, 0.18);
}

/* ========================================
   消息样式
   ======================================== */

.message {
  display: flex;
  gap: 16px;
  width: 100%;
  max-width: 800px;
  margin: 0 auto;
  opacity: 0;
  transform: translateY(20px);
  animation: slide-in-up 0.4s var(--ease-out) forwards;
}

.message.compacted {
  opacity: 0.22 !important;
  filter: blur(0.3px) saturate(0.9);
  transform: translateY(0) scale(0.985);
  transition: opacity 0.4s ease, filter 0.4s ease, transform 0.4s ease;
}

@keyframes slide-in-up {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.message-user {
  justify-content: flex-end;
}

.message-system {
  justify-content: center;
  align-items: center;
  gap: 12px;
  padding: 8px 0;
}

.message-model-switch {
  justify-content: center;
  padding: 8px 0;
}

.message-context-switch {
  justify-content: center;
  padding: 10px 0;
}

.baton-pass-card {
  width: min(520px, 92%);
  border-radius: 16px;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.65);
  border: 1px solid rgba(148, 163, 184, 0.2);
  backdrop-filter: blur(16px) saturate(180%);
  -webkit-backdrop-filter: blur(16px) saturate(180%);
  box-shadow: 
    0 20px 25px -5px rgba(0, 0, 0, 0.08), 
    0 8px 10px -6px rgba(0, 0, 0, 0.05),
    inset 0 1px 0 rgba(255, 255, 255, 0.4);
}

.baton-pass-top {
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 44px;
}

.baton-model {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.5);
}

.baton-model svg {
  width: 18px;
  height: 18px;
}

.baton-from {
  opacity: 0.6;
  filter: grayscale(0.4) saturate(0.8);
}

.baton-flow {
  flex: 1;
  height: 6px;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.12);
  position: relative;
  overflow: hidden;
}

.baton-flow-bar {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0) 0%,
    rgba(var(--primary-glow-rgb), 0.4) 20%,
    rgba(var(--primary-glow-rgb), 0.9) 50%,
    rgba(var(--primary-glow-rgb), 0.4) 80%,
    rgba(255, 255, 255, 0) 100%
  );
  transform: translateX(-100%);
  animation: baton-flow 1.2s cubic-bezier(0.4, 0, 0.2, 1) infinite;
  width: 60%;
}

@keyframes baton-flow {
  0% { left: 0; transform: translateX(-150%); }
  100% { left: 100%; transform: translateX(50%); }
}

.baton-pass-text {
  margin-top: 8px;
  font-size: 11px;
  color: rgba(30, 30, 30, 0.65);
  text-align: center;
  font-weight: 500;
}

.baton-pass-tags {
  margin-top: 8px;
  display: flex;
  justify-content: center;
  gap: 6px;
  flex-wrap: wrap;
}

.baton-tag {
  display: inline-flex;
  align-items: center;
  height: 20px;
  padding: 0 8px;
  border-radius: 6px;
  font-size: 10px;
  font-weight: 600;
  color: rgba(30, 30, 30, 0.75);
  background: rgba(255, 255, 255, 0.6);
  border: 1px solid rgba(148, 163, 184, 0.2);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
}

/* Baton Pass 淡出动画 */
.baton-pass-fade-out {
  animation: batonPassFadeOut 0.4s ease-out forwards;
}

@keyframes batonPassFadeOut {
  0% {
    opacity: 1;
    transform: translateY(0);
  }
  100% {
    opacity: 0;
    transform: translateY(-8px);
  }
}

/* 头像 */
.message-avatar {
  flex-shrink: 0;
}

.avatar-icon {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-color);
  overflow: visible;
  background: var(--bg-secondary);
  color: var(--text-deep-theme, #1a1a2e);
}

.avatar-icon.user { background: #e2e8f0; color: #64748b; }

/* 金球跳动：用于 AI 思考状态 */
@keyframes orb-bounce {
  0%, 100% {
    transform: translateY(0) scale(1);
    filter: drop-shadow(0 0 0 transparent);
  }
  40% {
    transform: translateY(-3px) scale(1.1);
    filter: drop-shadow(0 0 6px rgba(255, 215, 0, 0.6));
  }
  60% {
    transform: translateY(-1px) scale(1.05);
  }
}

.message-ai.ai-thinking .logo-orb {
  animation: orb-bounce 1.2s ease-in-out infinite;
  transform-box: fill-box;
  transform-origin: center;
  will-change: transform, filter;
}

/* 消息内容 */
.message-content {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-width: min(85%, 520px);
  flex: 1;
  min-width: 0;
}

.message-ai .message-content {
  max-width: min(92%, 760px);
}

.message-user .message-content {
  align-items: flex-end;
}

.message-sender {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  opacity: 0.6;
}

.message-actions {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 2px;
  opacity: 0;
  transform: translateY(-2px);
  pointer-events: none;
  transition: opacity 0.16s ease, transform 0.16s ease;
}

.message:hover .message-actions,
.message:focus-within .message-actions,
.message .message-actions.actions-last,
.message .message-actions.actions-memorized {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.message-action-btn.pin-btn {
  background: transparent;
  border-color: transparent;
  color: rgba(124, 58, 237, 0.92);
}

.message-action-btn.pin-btn:hover {
  background: rgba(255, 255, 255, 0.98);
  border-color: rgba(226, 232, 240, 0.9);
}

.message-action-btn.memory-btn {
  color: rgba(100, 116, 139, 0.82);
  position: relative;
  overflow: visible;
}

.message-action-btn.memory-btn:hover {
  color: rgba(124, 58, 237, 0.92);
}

.message-action-btn.memory-btn .memory-icon .brain-shell {
  fill: transparent;
  transition: fill 0.35s ease, stroke-width 0.35s ease, color 0.35s ease;
}

.message-action-btn.memory-btn .memory-icon .brain-detail {
  opacity: 0.76;
  transition: opacity 0.35s ease, stroke-width 0.35s ease;
}

.message-action-btn.memory-btn.memory-writing {
  animation: memory-absorb-press 0.72s cubic-bezier(0.22, 1, 0.36, 1) 1;
}

.message-action-btn.memory-btn.memory-writing .memory-icon {
  animation: memory-absorb-pulse 0.72s ease-out 1;
}

.message-action-btn.memory-btn.is-memorized {
  color: rgba(124, 58, 237, 0.96);
}

.message-action-btn.memory-btn.is-memorized .memory-icon .brain-shell {
  fill: rgba(139, 92, 246, 0.16);
  stroke-width: 2.2;
}

.message-action-btn.memory-btn.is-memorized .memory-icon .brain-detail {
  stroke-width: 2;
  opacity: 0.92;
}

.message-action-btn.memory-btn.memory-just-saved::after {
  content: "✓";
  position: absolute;
  top: -3px;
  right: -3px;
  width: 12px;
  height: 12px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  font-weight: 700;
  line-height: 1;
  color: rgba(255, 255, 255, 0.98);
  background: rgba(124, 58, 237, 0.96);
  border: 1px solid rgba(255, 255, 255, 0.95);
  box-shadow: 0 4px 12px rgba(124, 58, 237, 0.3);
  animation: memory-check-pop 0.9s ease-out 1 forwards;
}

@keyframes memory-absorb-press {
  0% {
    transform: scale(1);
  }
  20% {
    transform: scale(0.9);
  }
  56% {
    transform: scale(1.07);
  }
  100% {
    transform: scale(1);
  }
}

@keyframes memory-absorb-pulse {
  0% {
    opacity: 0.82;
    filter: none;
  }
  42% {
    opacity: 1;
    filter: drop-shadow(0 0 7px rgba(124, 58, 237, 0.52));
  }
  100% {
    opacity: 1;
    filter: none;
  }
}

@keyframes memory-check-pop {
  0% {
    opacity: 0;
    transform: scale(0.4) translateY(3px);
  }
  35% {
    opacity: 1;
    transform: scale(1.08) translateY(0);
  }
  100% {
    opacity: 0;
    transform: scale(0.82) translateY(-3px);
  }
}

.pin-popover {
  position: fixed;
  z-index: var(--tm-z-modal-top);
  width: min(360px, calc(100vw - 24px));
  border-radius: 14px;
  background: var(--tm-paper-raised);
  border: 1px solid var(--tm-paper-hairline);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  box-shadow: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
  padding: 10px 10px;
  color: var(--tm-paper-ink);
}

.pin-fly {
  position: fixed;
  z-index: calc(var(--tm-z-modal-top) + 1); /* 飞行动画压顶 */
  transform: translate(-50%, -50%) scale(1);
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 650;
  color: rgba(226, 232, 240, 0.92);
  background: rgba(139, 92, 246, 0.26);
  border: 1px solid rgba(139, 92, 246, 0.34);
  backdrop-filter: blur(12px) saturate(160%);
  -webkit-backdrop-filter: blur(12px) saturate(160%);
  box-shadow: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
  pointer-events: none;
  white-space: nowrap;
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  opacity: 0.95;
  transition:
    left 0.55s cubic-bezier(0.22, 1, 0.36, 1),
    top 0.55s cubic-bezier(0.22, 1, 0.36, 1),
    transform 0.55s cubic-bezier(0.22, 1, 0.36, 1),
    opacity 0.55s ease;
}

.pin-fly.flying {
  transform: translate(-50%, -50%) scale(0.12);
  opacity: 0.18;
}

.pin-popover-title {
  font-size: 12px;
  font-weight: 800;
  color: var(--tm-paper-ink);
}

.pin-popover-sub {
  margin-top: 2px;
  font-size: 10px;
  color: var(--tm-paper-ink-2);
}

.pin-popover-row {
  margin-top: 10px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.pin-pill {
  border: 1px solid var(--tm-paper-hairline);
  background: var(--tm-paper-band);
  color: var(--tm-paper-ink-2);
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 11px;
  cursor: pointer;
  transition: var(--transition);
}

.pin-pill.active {
  border-color: var(--tm-ink-purple);
  background: var(--tm-paper-2);
}

.pin-editor {
  margin-top: 10px;
  width: 100%;
  min-height: 84px;
  border-radius: 12px;
  border: 1px solid var(--tm-paper-hairline);
  background: var(--tm-paper-band);
  color: var(--tm-paper-ink);
  padding: 10px 10px;
  font-size: 12px;
  outline: none;
  resize: vertical;
}

.pin-actions {
  margin-top: 10px;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.pin-btn-secondary,
.pin-btn-primary {
  border-radius: 10px;
  padding: 7px 10px;
  font-size: 11px;
  cursor: pointer;
  transition: var(--transition);
  border: 1px solid var(--tm-paper-hairline);
}

.pin-btn-secondary {
  background: var(--tm-paper-band);
  color: var(--tm-paper-ink-2);
}

.pin-btn-primary {
  background: var(--tm-paper-band);
  border-color: var(--tm-ink-purple);
  color: var(--tm-ink-purple-strong);
}

.pin-btn-primary:hover {
  background: var(--tm-paper-2);
}

.message-user .message-actions {
  justify-content: flex-end;
}

.message-action-btn {
  width: 30px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-secondary);
  padding: 0;
  border-radius: 999px;
  cursor: pointer;
  transition: var(--transition);
}

.message-action-btn svg {
  width: 15px;
  height: 15px;
  pointer-events: none;
}

.message-action-btn:hover {
  background: rgba(255, 255, 255, 0.98);
  border-color: rgba(226, 232, 240, 0.9);
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
}

.message-action-btn:focus-visible {
  background: rgba(255, 255, 255, 0.98);
  border-color: rgba(226, 232, 240, 0.9);
  outline: 2px solid rgba(59, 130, 246, 0.35);
  outline-offset: 1px;
}

.message-action-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.message-action-btn.primary {
  background: transparent;
  border-color: transparent;
  color: var(--accent-blue);
}

.message-action-btn.primary:hover {
  background: rgba(255, 255, 255, 0.98);
  border-color: rgba(226, 232, 240, 0.9);
}

/* 消息气泡 */
.message-bubble {
  padding: 12px 18px;
  border-radius: 18px;
  font-size: 15px;
  line-height: 1.6;
  box-shadow: var(--shadow-sm);
  white-space: pre-wrap;
  word-break: break-word;
  width: fit-content;
  max-width: 100%;
  position: relative;
}

.message-ai .message-bubble {
  /* 沉浸式文档助手：AI 回复去气泡化，内容融入背景 */
  background: transparent;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  color: var(--text-secondary);
  border: none;
  border-radius: 0;
  box-shadow: none;
  padding: 2px 2px;
  width: 100%;
}

.message-ai .message-bubble:hover {
  background: transparent;
  box-shadow: none;
}

/* ==========================================================================
   User Message Bubble Themes
   Theme A: Aurora Crystal (Default) - Ultra transparent, high blur (25px)
   Theme B: Classic White - High opacity (80%), medium blur (12px)
   ========================================================================== */

/* Shared Base */
.message-user .message-bubble {
  color: var(--text-deep-theme);
  
  /* Refined Border: Subtle theme-colored reflection */
  border: 1px solid rgba(var(--primary-glow-rgb), 0.2); 
  border-bottom-right-radius: 4px;
  
  /* Critical: Stronger Colored shadow (0.1 -> 0.15) for the "floating" effect */
  box-shadow: 0 4px 14px 0 rgba(var(--primary-glow-rgb), 0.15);
  
  font-weight: 500;
  transition: all 0.4s cubic-bezier(0.25, 0.8, 0.25, 1); /* Smooth Morphing */
}

/* Theme: Aurora (Default) - The "Frozen White Mist" */
body:not([data-bubble-theme="white"]) .message-user .message-bubble {
  /* Restore: Ultra transparent base */
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.03) 0%, rgba(var(--primary-glow-rgb), 0.05) 100%);
  backdrop-filter: blur(25px);
  -webkit-backdrop-filter: blur(25px);
  /* Remove the muddy filter I added */
  filter: none;
}

body:not([data-bubble-theme="white"]) .message-user .message-bubble:hover {
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.08) 0%, rgba(var(--primary-glow-rgb), 0.1) 100%);
  filter: none;
}

/* Theme: Classic White - The "Opaque Porcelain" */
body[data-bubble-theme="white"] .message-user .message-bubble {
  /* Restore: Clean white base */
  background: rgba(255, 255, 255, 0.8);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  filter: none;
}

body[data-bubble-theme="white"] .message-user .message-bubble:hover {
  background: rgba(255, 255, 255, 0.9);
  filter: none;
}

/* Submerged State: Subtle effect that preserves the aurora/glass aesthetic */
/* Aurora Theme: Enhance glow while keeping transparency */
body:not([data-bubble-theme="white"]) .message-user .message-bubble.submerged {
  /* No background change - rely on optical interference */
  color: var(--text-deep-theme); 
  border-color: rgba(var(--primary-glow-rgb), 0.6); /* Even Stronger border */
  box-shadow:
    0 4px 20px rgba(var(--primary-glow-rgb), 0.35), /* Deeper shadow glow */
    inset 0 1px 2px rgba(255, 255, 255, 0.25);
  backdrop-filter: blur(15px);
  -webkit-backdrop-filter: blur(15px);
  filter: none;
}

/* White Theme: Slightly increase opacity when submerged for readability */
body[data-bubble-theme="white"] .message-user .message-bubble.submerged {
  /* No background change */
  color: var(--text-deep-theme);
  border-color: rgba(var(--primary-glow-rgb), 0.5); /* Stronger border */
  box-shadow:
    0 4px 18px rgba(var(--primary-glow-rgb), 0.25), /* Deeper shadow glow */
    inset 0 1px 2px rgba(255, 255, 255, 0.3);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  filter: none;
}

/* ========================================
   方案 C: Cinematic Streaming (电影级流式排版)
   ======================================== */

/* 流动式文字出现效果 - 从模糊到清晰，配合物理弹簧曲线 */
.blur-in-char {
  display: inline-block;
  opacity: 0;
  filter: blur(8px);
  transform: translateY(6px) scale(0.96); 
  /* 物理曲线优化：弹入感 (Spring-in) */
  animation: blur-reveal 0.6s cubic-bezier(0.18, 0.89, 0.32, 1.28) forwards;
  animation-delay: var(--wave-delay, 0ms);
  transform-origin: bottom center;
  will-change: transform, opacity, filter;
}

@keyframes blur-reveal {
  0% {
    opacity: 0;
    filter: blur(8px);
    transform: translateY(6px) scale(0.96);
  }
  60% {
    opacity: 0.8;
    filter: blur(2px);
  }
  100% {
    opacity: 1;
    filter: blur(0);
    transform: translateY(0) scale(1);
  }
}

/* 移除旧的属性选择器写法，直接在上面处理了 */

/* 光标效果 (Active Breathing Caret) */
.typing-cursor::after {
  content: '';
  display: inline-block;
  width: 3px;
  height: 1.3em;
  background: var(--accent-blue);
  margin-left: 3px;
  border-radius: 4px;
  box-shadow: 0 0 8px rgba(var(--primary-glow-rgb), 0.6);
  animation: blink-breathe 1s infinite ease-in-out;
  vertical-align: text-bottom;
  position: relative;
  top: 2px;
}

@keyframes blink-breathe {
  0%, 100% { opacity: 1; transform: scaleY(1); }
  50% { opacity: 0.4; transform: scaleY(0.85); }
}

/* 方案 B: 发送 -> 飞入（Morphing） */
.morphing-bubble {
  position: fixed;
  z-index: var(--tm-z-modal);
  pointer-events: none;
  background: var(--primary-gradient);
  color: #fff;
  border-radius: 18px;
  padding: 12px 18px;
  box-shadow: var(--shadow-float), 0 4px 15px rgba(var(--primary-glow-rgb), 0.28);
  font-weight: 500;
  white-space: pre-wrap;
  overflow: hidden;
}

/* 系统消息 */
.system-divider {
  height: 1px;
  width: 32px;
  background: var(--border-color);
}

.system-text {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
}

/* 模型切换消息 */
.model-switch-badge {
  font-size: 10px;
  font-weight: 700;
  padding: 6px 12px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-full);
  color: var(--text-secondary);
}

/* 模型切换消息颜色 */
.model-switch-badge.text-blue {
  color: #3b82f6;
  background: rgba(59, 130, 246, 0.1);
  border-color: rgba(59, 130, 246, 0.2);
}

.model-switch-badge.text-green {
  color: #10b981;
  background: rgba(16, 185, 129, 0.1);
  border-color: rgba(16, 185, 129, 0.2);
}

.model-switch-badge.text-orange {
  color: #f97316;
  background: rgba(249, 115, 22, 0.1);
  border-color: rgba(249, 115, 22, 0.2);
}

.model-switch-badge.text-purple {
  color: #8b5cf6;
  background: rgba(139, 92, 246, 0.1);
  border-color: rgba(139, 92, 246, 0.2);
}

/* 旧版消息兼容 */
.msg {
  padding: 14px 18px;
  border-radius: var(--radius-xl);
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.7;
  font-size: 15px;
  max-width: min(85%, 520px);
  animation: fade-in 0.3s ease-out;
  box-shadow: var(--shadow-sm);
}

.msg.user {
  align-self: flex-end;
  background: var(--accent-blue);
  color: white;
  border-top-right-radius: 4px;
}

.msg.assistant {
  align-self: flex-start;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  border-top-left-radius: 4px;
}

.msg.meta {
  align-self: center;
  background: transparent;
  color: var(--text-muted);
  font-size: 12px;
  padding: 6px 12px;
  border: 1px dashed var(--border-color);
  border-radius: var(--radius-sm);
  box-shadow: none;
}

.msg.loading {
  display: flex;
  align-items: center;
  gap: 8px;
}

.msg.loading::before {
  content: '';
  width: 8px;
  height: 8px;
  background: var(--accent-blue);
  border-radius: 50%;
  animation: pulse 1s infinite;
}

/* ========================================
   Diff 卡片
   ======================================== */

.diff-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  margin-top: 8px;
  ring: 4px solid var(--bg-tertiary);
}

.diff-header {
  padding: 10px 16px;
  background: var(--bg-tertiary);
  border-bottom: 1px solid var(--border-color);
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.diff-body {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.diff-section {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.diff-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
}

.diff-label-new {
  color: #16a34a;
}

.diff-original {
  font-size: 14px;
  color: var(--text-muted);
  text-decoration: line-through;
  text-decoration-color: #f87171;
  text-decoration-thickness: 2px;
}

.diff-suggestion {
  font-size: 14px;
  color: var(--text-primary);
  font-weight: 500;
  background: rgba(34, 197, 94, 0.08);
  padding: 10px 12px;
  margin: -4px -4px 0;
  border-radius: var(--radius-md);
  border: 1px solid rgba(34, 197, 94, 0.2);
}

.diff-actions {
  display: flex;
  border-top: 1px solid var(--border-color);
}

.diff-btn {
  flex: 1;
  padding: 12px;
  font-size: 12px;
  font-weight: 700;
  background: transparent;
  border: none;
  cursor: pointer;
  transition: var(--transition);
}

.diff-btn-cancel {
  color: var(--text-muted);
  border-right: 1px solid var(--border-color);
}

.diff-btn-cancel:hover {
  background: var(--bg-tertiary);
}

.diff-btn-accept {
  color: var(--accent-blue);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.diff-btn-accept:hover {
  background: rgba(59, 130, 246, 0.08);
}

/* ========================================
   插入卡片
   ======================================== */

.insert-card {
  background: var(--bg-secondary);
  border: 1px solid rgba(59, 130, 246, 0.3);
  border-radius: var(--radius-xl);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  margin-top: 8px;
}

.insert-content {
  padding: 16px;
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.6;
}

.insert-btn {
  width: 100%;
  padding: 12px;
  background: rgba(59, 130, 246, 0.08);
  color: var(--accent-blue);
  font-size: 12px;
  font-weight: 700;
  border: none;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.insert-btn:hover {
  background: rgba(59, 130, 246, 0.15);
}

/* ========================================
   打字动画
   ======================================== */

.typing-indicator {
  display: flex;
  gap: 6px;
  padding: 8px 0;
  width: 100%;
  max-width: 800px;
  margin: 0 auto;
  padding-left: 48px;
}

.typing-dot {
  width: 8px;
  height: 8px;
  background: var(--text-muted);
  border-radius: var(--radius-full);
  animation: typing-bounce 1.4s infinite ease-in-out;
}

.typing-dot:nth-child(1) { animation-delay: 0s; }
.typing-dot:nth-child(2) { animation-delay: 0.15s; }
.typing-dot:nth-child(3) { animation-delay: 0.3s; }

@keyframes typing-bounce {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(-6px); }
}

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

@keyframes pulse {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 1; }
}

/* ========================================
   Loading Indicators (Enhanced)
   ======================================== */

/* Thinking 指示器（对标 ChatGPT 思考动画） */
.loading-thinking {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
}

.thinking-orb {
  position: relative;
  width: 24px;
  height: 24px;
}

.thinking-ring {
  position: absolute;
  inset: 0;
  border: 2px solid transparent;
  border-top-color: var(--accent-purple, #c084fc);
  border-radius: 50%;
  animation: thinking-spin 1s linear infinite;
}

.thinking-core {
  position: absolute;
  inset: 6px;
  background: var(--accent-purple, #c084fc);
  border-radius: 50%;
  animation: thinking-pulse 1.5s ease-in-out infinite;
}

.thinking-text {
  font-size: 13px;
  color: var(--text-secondary);
  animation: thinking-fade 2s ease-in-out infinite;
}

@keyframes thinking-spin {
  to { transform: rotate(360deg); }
}

@keyframes thinking-pulse {
  0%, 100% { opacity: 0.4; transform: scale(0.8); }
  50% { opacity: 1; transform: scale(1); }
}

@keyframes thinking-fade {
  0%, 100% { opacity: 0.6; }
  50% { opacity: 1; }
}

/* 进度条加载指示器 */
.loading-progress {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px 16px;
  width: 100%;
}

.progress-bar {
  height: 4px;
  background: var(--bg-tertiary, #f3f4f6);
  border-radius: 2px;
  overflow: hidden;
  position: relative;
}

.progress-bar::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  width: var(--progress, 0%);
  background: var(--accent-purple, #c084fc);
  border-radius: 2px;
  transition: width 0.3s ease;
}

.progress-text {
  font-size: 12px;
  color: var(--text-muted);
}

/* 骨架屏 */
.loading-skeleton {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
}

.skeleton-line {
  height: 12px;
  border-radius: 4px;
  background: linear-gradient(
    90deg,
    var(--bg-tertiary, #f3f4f6) 25%,
    var(--bg-secondary, #f9fafb) 50%,
    var(--bg-tertiary, #f3f4f6) 75%
  );
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.5s infinite;
}

.skeleton-line-long { width: 100%; }
.skeleton-line-medium { width: 75%; }
.skeleton-line-short { width: 50%; }

@keyframes skeleton-shimmer {
  from { background-position: 200% 0; }
  to { background-position: -200% 0; }
}

/* 脉冲点加载指示器 */
.loading-pulse-dots {
  display: flex;
  gap: 4px;
  align-items: center;
  padding: 8px 0;
}

.pulse-dot {
  width: 6px;
  height: 6px;
  background: var(--accent-purple, #c084fc);
  border-radius: 50%;
  animation: pulse-dot-bounce 1.4s infinite ease-in-out;
}

.pulse-dot:nth-child(1) { animation-delay: -0.32s; }
.pulse-dot:nth-child(2) { animation-delay: -0.16s; }
.pulse-dot:nth-child(3) { animation-delay: 0s; }

@keyframes pulse-dot-bounce {
  0%, 80%, 100% {
    transform: scale(0.6);
    opacity: 0.5;
  }
  40% {
    transform: scale(1);
    opacity: 1;
  }
}

/* ========================================
   输入区域 (Morphing & Island)
   ======================================== */

.composer {
  padding: 0;
  background: transparent;
  border-top: none;
  flex-shrink: 0;
}

.composer-container {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  width: calc(100% - 40px);
  max-width: 700px;
  z-index: var(--tm-z-banner);
  display: flex;
  flex-direction: column;
  gap: 8px;
  /* 初始入场动画 */
  animation: composer-float-in 0.8s var(--ease-elastic) backwards;
  animation-delay: 0.2s;
  transition:
    transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1),
    opacity 0.3s ease,
    left 0.28s ease,
    width 0.28s ease;
}

/* ========================================
   Composer Handle (把手) - Top-tier Aesthetics (Jade / Breathing Light)
   ======================================== */

.composer-handle {
  position: absolute;
  top: 50%;
  right: -12px;
  transform: translateY(-50%) translateY(-21px); /* 再次上移 3px */
  width: 24px; /* 增大热区，便于抓取 */
  height: 64px;
  z-index: 10;
  cursor: grab;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s ease, right 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  display: flex;
  align-items: center;
  justify-content: center;
}

#app.cortex-open .composer-handle,
#app.composer-docked .composer-handle {
  opacity: 1;
  pointer-events: auto;
  right: 11px; /* 向左缩 5px */
  box-shadow: none; /* 移除容器阴影，拒绝"穿帮"矩形框，只保留内部晶体 */
  z-index: 20; /* 确保浮在输入框上方 */
}

@media (min-width: 960px) {
  #app.cortex-open .composer-handle {
    opacity: 0;
    pointer-events: none;
  }
}

.handle-luminescence {
  /* 基础形状 */
  width: 1.8px;
  height: 38.4px;
  border-radius: 99px;

  /* 1. 平时状态：陶瓷质感，低调融合 */
  background: rgba(255, 255, 255, 0.4); /* 晶体质感：高透白 */
  box-shadow: 
    inset 0 0 0 0.5px rgba(255, 255, 255, 0.8), /* 锐利边缘 */
    0 1px 3px rgba(0, 0, 0, 0.05); /* 极其微弱的投影，增加实体感 */
  backdrop-filter: blur(2px); /* 微弱的折射感 */
  -webkit-backdrop-filter: blur(2px);

  /* 2. 动画曲线：物理阻尼 (Spring) */
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  position: relative;
  transform: translateX(5px) translateY(-10px); /* 向上再次移动 5px */
}

/* 移除旧版内部发光芯 (Core)，新版靠整体材质 */
.handle-luminescence::after {
  content: none;
}

/* Hover 状态：注入灵魂 (Glow & Expand) */
.composer-handle:hover .handle-luminescence {
  /* 变大尺寸 */
  width: 3.2px; /* 变窄 */
  height: 44.8px; /* 变短 */

  /* 3. 激活颜色：带光感的玉石 */
    background: #ffffff; /* 白热内核：真正的激光中心是白色的 */
    box-shadow: 
      0 0 4px 1px rgb(var(--primary-glow-rgb)), /* 第一层：紧贴的高能光圈 */
      0 0 12px 2px rgba(var(--primary-glow-rgb), 0.8), /* 第二层：主辉光 */
      0 0 25px rgba(var(--primary-glow-rgb), 0.5), /* 第三层：环境散射 */
      inset 0 0 2px rgba(var(--primary-glow-rgb), 0.5); /* 内部：色彩渗透 */}

/* Active 状态：按压反馈 (Pinch) */
.composer-handle:active .handle-luminescence {
  transform: scale(0.95);
  box-shadow: 
    0 0 5px rgba(var(--primary-glow-rgb), 0.6),
    inset 0 0 2px rgba(255, 255, 255, 0.2);
  /* 颜色加深一点点模拟受力 */
  filter: brightness(0.95);
}

/* 磁吸微动 (模拟) */
.composer-handle:hover {
  transform: translateY(-50%) translateX(2px);
}



/* 真·形态变换状态 */
.composer-container.morphing {
  /* 飞出效果：向上位移、缩小、模糊消失 */
  transform: translateX(-50%) translateY(-100px) scale(0.4);
  opacity: 0;
  filter: blur(4px);
  pointer-events: none;
}

.composer-container.resetting {
  /* 归位前置状态：从下方淡入 */
  transform: translateX(-50%) translateY(40px) scale(0.95);
  opacity: 0;
}

/* 正常状态 (Implicit in base class) */
/* transform: translateX(-50%) translateY(0) scale(1); opacity: 1 */

@keyframes composer-float-in {
  from { transform: translateX(-50%) translateY(40px); opacity: 0; }
  to { transform: translateX(-50%) translateY(0); opacity: 1; }
}

/* 消息弹射动画 (配合输入框飞出) */
@keyframes projectile-up {
  0% { opacity: 0; transform: translateY(40px) scale(0.8); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}

.animate-projectile-up {
  animation: projectile-up 0.5s cubic-bezier(0.23, 1, 0.32, 1) forwards;
}

.composer-glass-panel {
  /* Input Box Problem - Refinement: More opaque to block background noise */
  background: rgba(255, 255, 255, 0.8);
  backdrop-filter: blur(20px) saturate(300%);
  -webkit-backdrop-filter: blur(20px) saturate(300%);
  border: 1px solid rgba(255, 255, 255, 0.6); /* Slightly more transparent border */
  border-radius: 24px;
  box-shadow: var(--shadow-float), inset 0 0 0 1px rgba(255, 255, 255, 0.4);
  padding: 6px 6px 0 6px; /* 底部留给能量槽贴合 */
  transition: all 0.3s var(--ease-out);
  overflow: hidden; /* 能量槽贴底自然裁剪出完美弧度 */
}

.composer-glass-panel:focus-within {
  background: rgba(255, 255, 255, 0.9);
  box-shadow:
    0 20px 60px -10px rgba(var(--primary-glow-rgb), 0.3),
    inset 0 0 0 1px rgba(var(--primary-glow-rgb), 0.3);
  transform: translateY(-2px);
}

.composer-glass-panel.full-doc-mode {
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.3), 0 20px 60px -10px rgba(99, 102, 241, 0.2);
  border-color: rgba(99, 102, 241, 0.4);
}

/* 输入区域：左侧控件列 + 输入框横向排列 */
.composer-input-area {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 6px 6px 6px;
}

/* 左侧控件列：scroll 按钮 + "+"按钮纵向排列 */
.composer-left-controls {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

/* 「+」按钮 */
.composer-plus-btn {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: var(--radius-full);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.composer-plus-btn:hover {
  background: rgba(var(--primary-glow-rgb), 0.1);
  color: rgb(var(--primary-glow-rgb));
  border-color: rgba(var(--primary-glow-rgb), 0.3);
}

.composer-input-wrapper {
  display: flex;
  align-items: flex-end;
  flex: 1;
  min-width: 0;
  gap: 4px;
  padding: 6px 8px;
  background: transparent;
  border: none;
  border-radius: 18px;
  box-shadow: none;
}

/* Scroll-to-bottom 按钮：默认隐藏，滚动离开底部时滑入 */
.scroll-status-btn {
  width: 28px;
  height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  color: var(--accent-blue);
  border: 1px solid rgba(59, 130, 246, 0.2);
  border-radius: var(--radius-full);
  cursor: pointer;
  flex-shrink: 0;
  overflow: hidden;
  opacity: 0;
  transform: scale(0.5) translateY(8px);
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  padding: 0;
}

/* 滚动离开底部：按钮出现 */
.scroll-status-btn.scrolled-up {
  height: 28px;
  opacity: 1;
  transform: scale(1) translateY(0);
  background: rgba(59, 130, 246, 0.08);
}

.scroll-status-btn.scrolled-up:hover {
  background: rgba(59, 130, 246, 0.18);
  transform: scale(1.08) translateY(0);
  border-color: rgba(59, 130, 246, 0.35);
}

.composer textarea {
  flex: 1;
  background: transparent;
  color: var(--text-primary);
  border: none;
  outline: none;
  resize: none;
  font-size: 15px;
  line-height: 1.6;
  min-height: 26px;
  max-height: 150px;
  font-family: inherit;
  width: 100%;
}

.composer textarea::placeholder {
  color: var(--text-muted);
}

/* 清空输入按钮 */
.clear-input-btn {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  color: var(--text-muted);
  border: none;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: all 0.2s ease;
  flex-shrink: 0;
  opacity: 0.6;
}

.clear-input-btn:hover {
  background: rgba(0, 0, 0, 0.06);
  color: var(--text-secondary);
  opacity: 1;
}

.clear-input-btn:active {
  transform: scale(0.9);
}

.clear-input-btn.hidden {
  display: none;
}

.send-btn {
  position: relative; /* 为内部 absolute 图标提供定位上下文 */
  width: 0;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--text-muted);
  color: white;
  border: none;
  border-radius: var(--radius-full);
  cursor: not-allowed;
  transition: all 0.3s var(--ease-elastic);
  flex-shrink: 0;
  opacity: 0;
  transform: scale(0.9);
  overflow: hidden;
  padding: 0;
  margin: 0;
}

.send-btn.active {
  background: var(--primary-gradient);
  color: white;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(var(--primary-glow-rgb), 0.4);
  opacity: 1;
  transform: scale(1);
  width: 36px;
  padding: 0;
}

.send-btn:disabled {
  opacity: 0.6;
}

.send-btn.active:hover {
  transform: scale(1.1);
}

.send-btn.active:active {
  transform: scale(0.95);
}

/* 发送/停止图标切换（C3: 2s 排练场参数回调至产品节奏 0.45s，spring 曲线保留） */
.send-btn .icon-send,
.send-btn .icon-stop {
  position: absolute;
  transition: all 0.45s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.send-btn .icon-stop {
  opacity: 0;
  transform: scale(0) rotate(-360deg) translateY(10px);
}

.send-btn .icon-send {
  opacity: 1;
  transform: translate(0, 0) scale(1);
}

/* 流式输出时：显示停止图标 */
.send-btn.streaming .icon-send {
  opacity: 0;
  /* 纸飞机向右上方飞出 */
  transform: translate(12px, -12px) scale(0.5);
}

.send-btn.streaming .icon-stop {
  opacity: 1;
  animation: icon-stop-spin 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) 1 forwards;
}

/* 方块入场动画（C3: 2s×2 → 0.6s×1，中间关键帧同步压缩） */
@keyframes icon-stop-spin {
  0% {
    transform: scale(0) rotate(-360deg) translateY(10px);
    opacity: 0;
  }
  70% {
    transform: scale(1) rotate(0deg) translateY(0);
    opacity: 1;
  }
  100% {
    transform: scale(1) rotate(0deg) translateY(0);
    opacity: 1;
  }
}

/* 停止按钮特殊样式 - 黑色/深灰色 */
.send-btn.streaming {
  background: var(--text-primary); /* 深色背景 #1e293b */
  color: white;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  /* 移除强烈的红色呼吸动画，改为轻微的深色呼吸或无动画 */
  animation: none;
  width: 36px;
  opacity: 1;
}

.send-btn.streaming:hover {
  background: #0f172a; /* 更深的黑色 */
  transform: scale(1.05);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
}

/* 输入框禁用状态 */
.composer-input-wrapper.disabled {
  opacity: 0.7;
  cursor: not-allowed;
  background: rgba(0, 0, 0, 0.02);
}

.composer-input-wrapper.disabled textarea {
  pointer-events: none;
}

/* ========== Quota Block Overlay (充能站) ========== */

/* 输入区被 quota-blocked 时隐藏正常子元素，保留发送按钮 */
.composer-input-area.quota-blocked .composer-left-controls {
  display: none;
}

.composer-input-area.quota-blocked .composer-input-wrapper {
  flex: 0;
  width: auto;
  min-width: 0;
}

.composer-input-area.quota-blocked .composer-input-wrapper textarea,
.composer-input-area.quota-blocked .composer-input-wrapper .clear-input-btn,
.composer-input-area.quota-blocked .composer-input-wrapper .voice-btn {
  display: none;
}

.quota-block-overlay {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 1;
  min-width: 0;
  padding: 10px 8px;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.quota-block-overlay.visible {
  opacity: 1;
  transform: translateY(0);
}

.qb-content {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
}

.qb-icon {
  flex-shrink: 0;
  color: var(--text-muted);
  opacity: 0.5;
}

.qb-icon-bolt {
  width: 28px;
  height: 28px;
}

.qb-text {
  flex: 1;
  min-width: 0;
}

.qb-message {
  margin: 0;
  font-size: 13px;
  line-height: 1.4;
  color: var(--text-secondary);
}

.qb-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.qb-btn {
  padding: 6px 14px;
  border-radius: var(--radius-lg);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.qb-btn-primary {
  background: var(--primary-gradient);
  color: white;
  box-shadow: 0 2px 8px rgba(var(--primary-glow-rgb), 0.3);
}

.qb-btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(var(--primary-glow-rgb), 0.4);
}

.qb-btn-secondary {
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  border: 1px solid var(--border-light);
}

.qb-btn-secondary:hover {
  background: var(--bg-secondary);
  color: var(--text-primary);
}

/* 发送按钮 quota-blocked 状态：完全隐藏 */
.send-btn.quota-blocked {
  width: 0;
  opacity: 0;
  overflow: hidden;
  padding: 0;
  margin: 0;
  pointer-events: none;
}

/* ========== End Quota Block ========== */

/* 语音按钮（输入框内） */
.voice-btn {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  border-radius: var(--radius-full);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s ease;
  flex-shrink: 0;
  position: relative;
  user-select: none;
  -webkit-user-select: none;
  padding: 0;
}

.voice-btn:hover {
  background: rgba(var(--primary-glow-rgb), 0.08);
  color: rgb(var(--primary-glow-rgb));
}

.voice-btn.disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.voice-btn.recording {
  background: rgba(239, 68, 68, 0.15);
  color: #ef4444;
  animation: voice-pulse 1s ease-in-out infinite;
}

.voice-btn.recording .icon-mic-active {
  fill: #ef4444;
}

.voice-btn.processing {
  background: rgba(var(--primary-glow-rgb), 0.1);
  color: rgb(var(--primary-glow-rgb));
}

@keyframes voice-pulse {
  0%, 100% {
    box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4);
  }
  50% {
    box-shadow: 0 0 0 8px rgba(239, 68, 68, 0);
  }
}

@keyframes voice-processing-dots {
  0%, 20% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
  80%, 100% {
    opacity: 1;
  }
}

.token-counter,
.composer-counter {
  margin-left: auto;
  font-size: 11px;
  color: var(--text-muted);
  font-feature-settings: "tnum";
  font-variant-numeric: tabular-nums;
}

.composer-footer {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 12px 10px 12px;
}

.composer-hint,
.composer-status {
  font-size: 10px;
  color: var(--text-muted);
}

.composer-meta {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
}

.composer-counter {
  font-size: 10px;
  color: var(--text-muted);
}

.composer-status {
  display: flex;
  align-items: center;
  gap: 4px;
}

.composer-footer-text {
  text-align: center;
  font-size: 11.5px;
  color: var(--text-muted);
  opacity: 0.7;
}

/* Synapse Status Bar（上下文预算 + 活跃源） */
.synapse-bar {
  padding: 8px 12px 6px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.synapse-bar.hidden {
  display: none;
}

.synapse-gauge {
  height: 3px;
  width: 100%;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(148, 163, 184, 0.12);
  box-shadow: inset 0 0 0 1px rgba(148, 163, 184, 0.08);
}

.synapse-gauge-fill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: var(--accent-blue);
  box-shadow: 0 0 10px rgba(59, 130, 246, 0.25);
  transition: width 0.25s ease, background-color 0.25s ease, box-shadow 0.25s ease;
}

.synapse-gauge-fill.warm {
  background: var(--accent-orange);
  box-shadow: 0 0 10px rgba(249, 115, 22, 0.25);
}

.synapse-gauge-fill.critical {
  background: var(--accent-purple);
  box-shadow: 0 0 12px rgba(139, 92, 246, 0.35);
}

.synapse-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.synapse-sources {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-height: 18px;
}

.synapse-chip {
  display: inline-flex;
  align-items: center;
  height: 18px;
  padding: 0 6px;
  border-radius: 6px;
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.2px;
  color: var(--text-muted);
  background: rgba(148, 163, 184, 0.06);
  border: 1px solid rgba(148, 163, 184, 0.12);
}

.synapse-metrics {
  margin-left: auto;
  font-size: 10px;
  color: var(--text-muted);
  opacity: 0.85;
  font-feature-settings: "tnum";
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* 上下文 Bar */
.composer-context-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  margin-bottom: 4px;
  min-height: 0;
  transition: all 0.3s ease;
  overflow: hidden;
}

.composer-context-bar:not(.hidden) {
  padding-top: 6px;
  animation: slide-down-fade 0.2s ease-out;
}

@keyframes slide-down-fade {
  from { opacity: 0; transform: translateY(-4px); max-height: 0; }
  to { opacity: 1; transform: translateY(0); max-height: 40px; }
}

.context-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 22px;
  padding: 0 8px;
  border-radius: 5px;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.2px;
  white-space: nowrap;
  animation: chip-fade-in 0.3s ease-out forwards;
  /* 默认：安静的灰色调，不抢眼 */
  background: rgba(148, 163, 184, 0.08);
  border: 1px solid rgba(148, 163, 184, 0.15);
  color: var(--text-muted);
  transition: all 0.2s ease;
  cursor: default;
}

.context-chip:hover {
  /* Hover 时高亮为品牌色 */
  background: rgba(var(--primary-glow-rgb), 0.1);
  border-color: rgba(var(--primary-glow-rgb), 0.25);
  color: rgb(var(--primary-glow-rgb));
}

.context-chip:hover svg {
  color: rgb(var(--primary-glow-rgb));
}

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

.context-chip svg {
  width: 12px;
  height: 12px;
  flex-shrink: 0;
}

/* 选区预览文字 */
.context-chip .chip-text {
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-style: italic;
  opacity: 0.9;
}

/* 关闭按钮 */
.context-chip .chip-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  margin-left: 2px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  opacity: 0.6;
  transition: all 0.15s ease;
}

.context-chip .chip-close:hover {
  background: rgba(var(--primary-glow-rgb), 0.15);
  color: rgb(var(--primary-glow-rgb));
  opacity: 1;
}

.context-chip .chip-close:active {
  transform: scale(0.9);
}

/* 选区和全文标签：默认继承基础的灰色调，Hover 时才显示品牌色 */
.context-chip.full-doc,
.context-chip.selection {
  /* 继承基础样式，不再单独设置颜色 */
}

/* 选区标签可点击：导航回文档选中位置 */
.context-chip.selection.selection-interactive {
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
}

.context-chip.selection.selection-interactive * {
  user-select: none;
  -webkit-user-select: none;
}

.context-chip.selection.selection-interactive:focus-visible {
  outline: 2px solid rgba(var(--primary-glow-rgb), 0.45);
  outline-offset: 1px;
}

.context-chip.selection.selection-readonly {
  cursor: default;
}

/* 全文模式 Hover 时用绿色 */
.context-chip.full-doc:hover {
  background: rgba(16, 185, 129, 0.1);
  border-color: rgba(16, 185, 129, 0.25);
  color: #059669;
}

.context-chip.full-doc:hover svg {
  color: #059669;
}

/* ========================================
   选区标签三模式样式
   ======================================== */

/* Mode B: no persistent highlight, inherit default chip style. */

/* Mode C: chip keeps default style; only magnet icon is highlighted. */
.context-chip.selection.mode-c .magnet-glow-icon {
  color: rgb(var(--primary-glow-rgb));
  filter: drop-shadow(0 0 3px rgba(var(--primary-glow-rgb), 0.5));
  animation: magnet-glow 2s ease-in-out infinite;
}

@keyframes magnet-glow {
  0%, 100% {
    filter: drop-shadow(0 0 2px rgba(var(--primary-glow-rgb), 0.3));
  }
  50% {
    filter: drop-shadow(0 0 6px rgba(var(--primary-glow-rgb), 0.7));
  }
}

/* 收集计数徽章 */
.chip-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 16px;
  height: 14px;
  padding: 0 3px;
  border-radius: 7px;
  background: rgb(var(--primary-glow-rgb));
  color: #fff;
  font-size: 9px;
  font-weight: 600;
  line-height: 1;
  margin-left: 2px;
}

/* Mode C 多标签布局 */
.composer-context-bar.mode-c {
  flex-wrap: wrap;
  gap: 4px 6px;
}

/* Mode C "全部清除"按钮 */
.context-chip.selection.clear-all-chip {
  opacity: 0.6;
  border-style: dashed;
}
.context-chip.selection.clear-all-chip:hover {
  opacity: 1;
}

/* ========================================
   响应式
   ======================================== */

@media (max-width: 360px) {
  .floating-toolbar button span {
    display: none;
  }

  .message-content {
    max-width: 90%;
  }

  .voice-btn {
    width: 24px;
    height: 24px;
    flex-shrink: 0;
  }
  .composer-input-area {
    gap: 4px;
  }
  .composer-left-controls {
    gap: 2px;
  }
}

/* ========================================
   加载状态
   ======================================== */

.loading-dots {
  display: inline-flex;
  gap: 4px;
}

.loading-dots span {
  width: 6px;
  height: 6px;
  background: var(--text-secondary);
  border-radius: 50%;
  animation: bounce 1.4s infinite ease-in-out both;
}

.loading-dots span:nth-child(1) { animation-delay: -0.32s; }
.loading-dots span:nth-child(2) { animation-delay: -0.16s; }

@keyframes bounce {
  0%, 80%, 100% { transform: scale(0); }
  40% { transform: scale(1); }
}

/* ========================================
   Markdown 渲染样式
   ======================================== */

.message-bubble.markdown-body {
  white-space: normal;
}

.markdown-body p {
  margin: 0 0 12px 0;
}

.markdown-body p:last-child {
  margin-bottom: 0;
}

.markdown-body strong {
  font-weight: 600;
  color: var(--text-primary);
}

.markdown-body li strong {
  letter-spacing: var(--markdown-list-strong-letter-spacing);
}

.markdown-body em {
  font-style: italic;
}

.markdown-body mark {
  background: rgba(var(--primary-glow-rgb), 0.14);
  color: var(--text-primary);
  padding: 0 4px;
  border-radius: 6px;
}

.markdown-body h1,
.markdown-body h2,
.markdown-body h3,
.markdown-body h4 {
  margin: 16px 0 8px 0;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.4;
}

.markdown-body h1:first-child,
.markdown-body h2:first-child,
.markdown-body h3:first-child,
.markdown-body h4:first-child {
  margin-top: 0;
}

.markdown-body h1 {
  font-size: 1.45em;
  font-weight: 800;
  letter-spacing: -0.02em;
  background: var(--primary-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.markdown-body h2 {
  font-size: 1.25em;
  font-weight: 700;
  letter-spacing: -0.035em;
  background: var(--primary-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}
.markdown-body h3,
.markdown-body h4 {
  letter-spacing: var(--markdown-heading-letter-spacing);
}

.markdown-body h3 {
  font-size: 1.1em;
}

.markdown-body h4 {
  font-size: 1em;
}

/* 列表样式 */
.markdown-body ul,
.markdown-body ol {
  margin: 8px 0;
  padding-left: 24px;
}

.markdown-body li {
  margin: 0 0 var(--markdown-list-item-gap) 0;
  line-height: 1.6;
}

.markdown-body li:last-child {
  margin-bottom: 0;
}

.markdown-body li::marker {
  color: var(--text-muted);
}

.markdown-body ul ul,
.markdown-body ol ol,
.markdown-body ul ol,
.markdown-body ol ul {
  margin: 4px 0;
}

/* 行内代码 */
.markdown-body code:not(pre code) {
  background: var(--bg-tertiary);
  color: #c7254e;
  padding: 2px 6px;
  border-radius: 4px;
  font-family: var(--tm-font-mono);
  font-size: 0.88em;
  border: 1px solid var(--border-color);
}

/* 代码块容器 */
.markdown-body .code-block-wrapper {
  position: relative;
  margin: 20px 0;
  border-radius: 12px;
  overflow: hidden;
  background: #111827;
  border: 1px solid rgba(255, 255, 255, 0.05);
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  transition: all 0.3s ease;
}

.markdown-body .code-block-wrapper:hover {
  box-shadow: var(--glow-code), 0 10px 30px rgba(0, 0, 0, 0.2);
  border-color: rgba(var(--primary-glow-rgb), 0.22);
  transform: translateY(-1px);
}

.markdown-body .code-block-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 16px;
  background: rgba(255, 255, 255, 0.03);
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.markdown-body .code-lang {
  font-size: 11px;
  font-weight: 700;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-family: var(--tm-font-mono);
  display: flex;
  align-items: center;
}

/* Mac 窗口控制点 */
.markdown-body .code-lang::before {
  content: '';
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #ef4444;
  box-shadow: 16px 0 0 #eab308, 32px 0 0 #22c55e;
  margin-right: 48px;
  opacity: 0.85;
  transition: opacity 0.2s;
}

.markdown-body .code-block-wrapper:hover .code-lang::before {
  opacity: 1;
}

.markdown-body .code-copy-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 6px;
  color: rgba(255, 255, 255, 0.6);
  font-size: 11px;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: 'Inter', sans-serif;
}

.markdown-body .code-copy-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.4);
}

.markdown-body .code-copy-btn.copied {
  background: #22c55e;
  border-color: #22c55e;
  color: #fff;
}

.markdown-body .code-copy-btn svg {
  width: 14px;
  height: 14px;
}

.markdown-body pre {
  margin: 0;
  padding: 20px;
  overflow-x: auto;
  background: transparent;
}

.markdown-body pre code {
  font-family: var(--tm-font-mono);
  font-size: 13px;
  line-height: 1.6;
  color: #e5e7eb;
  background: transparent;
  padding: 0;
  border: none;
}

/* 代码高亮主题 (VS Code Dark+) */
.markdown-body pre .hljs-keyword { color: #569cd6; }
.markdown-body pre .hljs-string { color: #ce9178; }
.markdown-body pre .hljs-number { color: #b5cea8; }
.markdown-body pre .hljs-comment { color: #6a9955; font-style: italic; }
.markdown-body pre .hljs-function { color: #dcdcaa; }
.markdown-body pre .hljs-class { color: #4ec9b0; }
.markdown-body pre .hljs-variable { color: #9cdcfe; }
.markdown-body pre .hljs-operator { color: #d4d4d4; }
.markdown-body pre .hljs-punctuation { color: #d4d4d4; }
.markdown-body pre .hljs-property { color: #9cdcfe; }
.markdown-body pre .hljs-attr { color: #9cdcfe; }
.markdown-body pre .hljs-built_in { color: #4ec9b0; }
.markdown-body pre .hljs-title { color: #dcdcaa; }
.markdown-body pre .hljs-params { color: #9cdcfe; }
.markdown-body pre .hljs-literal { color: #569cd6; }
.markdown-body pre .hljs-type { color: #4ec9b0; }
.markdown-body pre .hljs-meta { color: #c586c0; }
.markdown-body pre .hljs-selector-tag { color: #d7ba7d; }
.markdown-body pre .hljs-selector-class { color: #d7ba7d; }
.markdown-body pre .hljs-selector-id { color: #d7ba7d; }
.markdown-body pre .hljs-attribute { color: #9cdcfe; }
.markdown-body pre .hljs-tag { color: #569cd6; }
.markdown-body pre .hljs-name { color: #569cd6; }

/* 引用块 */
.markdown-body blockquote {
  margin: 12px 0;
  padding: 10px 16px;
  /* Aurora Ink Style: Subtle theme tint instead of static blue */
  border-left: 4px solid rgba(var(--primary-glow-rgb), 0.3);
  background: rgba(var(--primary-glow-rgb), 0.05);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  color: var(--text-secondary);
}

.markdown-body blockquote p {
  margin: 0;
}

/* Callout (Notion/Obsidian 风格结构化提示块) */
.markdown-body .callout {
  margin: 12px 0;
  padding: 10px 16px;
  border-left: 4px solid rgba(var(--primary-glow-rgb), 0.3);
  background: rgba(var(--primary-glow-rgb), 0.05);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  color: var(--text-secondary);
}

.markdown-body .callout .callout-title {
  font-weight: 700;
  color: var(--text-primary);
  margin: 0 0 8px 0;
}

.markdown-body .callout-body > :last-child {
  margin-bottom: 0;
}

/* 卡片式信息架构（更像文档排版，不像聊天列表） */
.markdown-body .ia-cards {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 10px 0;
}

.markdown-body .ia-card {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 12px 14px;
  background: transparent;
}

.markdown-body .ia-card-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.markdown-body .ia-card-icon {
  width: 28px;
  height: 28px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border-color);
  background: var(--bg-secondary);
  color: var(--text-secondary);
  flex-shrink: 0;
}

.markdown-body .ia-card-title {
  font-weight: var(--markdown-card-title-weight);
  color: var(--text-primary);
  letter-spacing: var(--markdown-card-title-letter-spacing);
}

.markdown-body .ia-card-body {
  color: var(--text-secondary);
}

.markdown-body .ia-card-body > :last-child {
  margin-bottom: 0;
}

/* 水平分割线 */
.markdown-body hr {
  border: none;
  height: 1px;
  background: var(--border-color);
  margin: 16px 0;
}

/* 表格 */
.markdown-body table {
  width: 100%;
  border-collapse: collapse;
  margin: 12px 0;
  font-size: 14px;
  /* 防止宽表格撑破气泡：允许横向滚动 */
  display: block;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.markdown-body th,
.markdown-body td {
  padding: 10px 12px;
  border: 1px solid var(--border-color);
  text-align: left;
}

.markdown-body th {
  background: var(--bg-tertiary);
  font-weight: 600;
  color: var(--text-primary);
}

.markdown-body tr:nth-child(even) {
  background: var(--bg-tertiary);
}

/* 链接 */
.markdown-body a {
  color: var(--accent-blue);
  text-decoration: none;
}

.markdown-body a:hover {
  text-decoration: underline;
}

/* 图片 */
.markdown-body img {
  max-width: 100%;
  border-radius: var(--radius-sm);
  margin: 8px 0;
}

/* ========================================
   动效可访问性
   ======================================== */

@media (prefers-reduced-motion: reduce) {
  .mesh-orb {
    animation: none;
  }

  body.thinking .mesh-orb {
    animation: none;
  }

  .message {
    animation: none;
    opacity: 1;
    transform: none;
  }

  /* 
  .blur-in-char {
    animation: none;
    opacity: 1;
    filter: none;
    transform: none;
  } 
  */

  .composer-container {
    animation: none;
  }
}

/* ========================================
   右键菜单 (Context Menu)
   ======================================== */
.context-menu {
  position: fixed;
  z-index: var(--tm-z-modal-top); /* 右键菜单压 modal 内容 */
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: 4px;
  min-width: 120px;
  animation: context-menu-appear 0.1s ease-out;
}

@keyframes context-menu-appear {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

.context-menu-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  font-size: 13px;
  color: var(--text-primary);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.1s;
}

.context-menu-item:hover {
  background: var(--bg-tertiary);
}

.context-menu-item svg {
  width: 14px;
  height: 14px;
  color: var(--text-muted);
}

/* ========================================
   Compact Preview Dialog
   ======================================== */

.compact-preview-overlay {
  position: fixed;
  inset: 0;
  z-index: var(--tm-z-modal-top);
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  animation: overlay-fade-in 0.2s ease-out;
}

@keyframes overlay-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

.region-lock-overlay {
  position: fixed;
  inset: 0;
  z-index: calc(var(--tm-z-critical, 10200) + 1); /* B2 归位：合规终态全场最高（压强更卡） */
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: overlay-fade-in 0.2s ease-out;
}

.region-lock-card {
  width: min(420px, 100%);
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  padding: 18px 18px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.region-lock-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
}

.region-lock-message {
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-secondary);
}

.region-lock-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 6px;
}

.region-lock-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 12px;
  border-radius: 10px;
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border-color);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.region-lock-link:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.25);
}

body.region-locked {
  overflow: hidden;
}

/* ========================================
   Auth Panel
   ======================================== */

.auth-panel-overlay {
  position: fixed;
  inset: 0;
  z-index: calc(var(--tm-z-modal-top) + 30); /* modal-top 与 onboarding 间层 */
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  /* 企业稳重风格：轻遮罩 + 极轻品牌渐变，不用重模糊 */
  background:
    linear-gradient(180deg, rgba(30, 64, 175, 0.06) 0%, rgba(30, 64, 175, 0.02) 100%),
    rgba(0, 0, 0, 0.12);
  /* 移除重模糊，保持清晰聚焦 */
  animation: overlay-fade-in 0.2s ease-out;
}

.auth-panel {
  width: min(var(--auth-panel-max-width), 100%);
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--auth-panel-radius);
  box-shadow: var(--shadow-float);
  display: flex;
  flex-direction: column;
  overflow: visible;
  animation: auth-panel-rise 0.25s var(--ease-out);
  --auth-accent: var(--accent-blue);
  --auth-accent-soft: rgba(59, 130, 246, 0.12);
}

@keyframes auth-panel-rise {
  from {
    opacity: 0;
    transform: translateY(14px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.auth-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  padding: 16px 18px 12px;
  background: var(--bg-tertiary);
  border-bottom: 1px solid var(--border-color);
}

.auth-panel-kicker {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

.auth-panel-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  margin-top: 4px;
}

.auth-panel-subtitle {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 4px;
}

.auth-panel-close {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  border: none;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition);
  opacity: 0.08;
}

.auth-panel-close.left {
  position: absolute;
  left: 18px;
  top: 16px;
}

.auth-panel-close:hover,
.auth-panel-close:focus-visible {
  background: rgba(0, 0, 0, 0.08);
  color: var(--text-primary);
  opacity: 1;
}

.auth-panel-body {
  padding: 16px 18px 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.auth-panel-alert {
  padding: 10px 12px;
  border-radius: var(--radius-md);
  font-size: 12px;
  line-height: 1.4;
  background: rgba(59, 130, 246, 0.12);
  color: var(--text-primary);
  border: 1px solid rgba(59, 130, 246, 0.2);
}

.auth-panel-alert.error {
  background: rgba(239, 68, 68, 0.12);
  border-color: rgba(239, 68, 68, 0.25);
  color: #b91c1c;
}

.auth-panel-alert.success {
  background: rgba(16, 185, 129, 0.12);
  border-color: rgba(16, 185, 129, 0.25);
  color: #047857;
}

.auth-panel-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.auth-panel-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.auth-panel-tab {
  padding: 6px 12px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-color);
  background: transparent;
  font-size: 12px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition);
}

.auth-panel-tab.active,
.auth-panel-tab:hover {
  background: var(--auth-accent-soft);
  border-color: rgba(59, 130, 246, 0.4);
  color: var(--text-primary);
}

.auth-panel-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.auth-panel-row {
  display: grid;
  grid-template-columns: 1fr 110px;
  gap: 10px;
}

.auth-panel-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.auth-panel-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
}

.auth-panel-input {
  padding: 10px 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-size: 13px;
  transition: var(--transition);
}

.auth-panel-input:focus {
  outline: none;
  border-color: rgba(59, 130, 246, 0.6);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.12);
}

.auth-panel-input:disabled {
  background: var(--bg-tertiary);
  color: var(--text-muted);
}

.auth-panel-otp-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  color: var(--text-muted);
}

.auth-panel-otp-notes {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.auth-panel-muted {
  color: var(--text-muted);
  font-size: 11px;
}

.auth-panel-link {
  background: none;
  border: none;
  padding: 0;
  color: var(--auth-accent);
  font-size: 11px;
  cursor: pointer;
}

.auth-panel-link[disabled] {
  color: var(--text-muted);
  cursor: not-allowed;
}

/* OTP 输入框包裹容器 - 重新发送按钮在右下角 */
.auth-otp-field-wrapper {
  width: 100%;
}

/* OTP 组件内的垂直栈与分组 */
.auth-otp-stack {
  display: flex;
  flex-direction: column;
  gap: var(--auth-otp-stack-gap);
}

.auth-otp-group {
  display: flex;
  flex-direction: column;
  gap: var(--auth-otp-group-gap);
}

/* 重新发送模块 - 新设计 */
.auth-otp-resend-module {
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: var(--auth-otp-resend-min-height);
  line-height: var(--auth-otp-resend-line-height);
  font-size: 13px;
  opacity: 0;
  transition: opacity 150ms ease-out;
}

/* 鼠标靠近这一行时才显示 */
.auth-otp-resend-module:hover {
  opacity: 1;
}

/* 左侧状态文案 */
.auth-resend-status {
  color: var(--text-muted);
  user-select: none;
}

/* 右侧提示文案（不可点击） */
.auth-resend-hint {
  color: var(--text-muted);
  pointer-events: none;
  user-select: none;
}

/* 右侧链接文案（可点击） */
.auth-resend-link {
  background: none;
  border: none;
  padding: 0;
  margin: 0;
  font-size: 13px;
  color: var(--text-secondary);
  cursor: pointer;
  text-decoration: none;
  transition: text-decoration 150ms ease-out;
}

.auth-resend-link:hover {
  text-decoration: underline;
}

.auth-resend-link[disabled] {
  color: var(--text-muted);
  cursor: not-allowed;
  text-decoration: none;
}

/* 旧版重新发送行（保留兼容） */
.auth-otp-resend-row {
  display: flex;
  justify-content: flex-end;
  margin-top: 8px;
}

.auth-resend-inline {
  font-size: 13px;
  color: var(--accent-blue);
}

.auth-resend-inline[disabled] {
  color: var(--text-muted);
}

.auth-panel-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.auth-panel-btn {
  padding: 8px 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  background: transparent;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}

.auth-panel-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.auth-panel-btn.primary {
  background: var(--auth-accent);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 6px 16px rgba(59, 130, 246, 0.3);
}

.auth-panel-btn.primary:hover {
  filter: brightness(1.05);
}

.auth-panel-btn.ghost {
  background: transparent;
}

.auth-panel-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.auth-panel-footer {
  display: flex;
  justify-content: flex-end;
}

.auth-panel-grid {
  display: grid;
  gap: 10px;
}

.auth-panel-row-item {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.auth-panel-meta {
  font-size: 11px;
  color: var(--text-muted);
}

.auth-panel-value {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
  text-align: right;
}

.auth-panel-balance {
  padding: 10px 12px;
  border-radius: var(--radius-md);
  background: rgba(59, 130, 246, 0.08);
  border: 1px solid rgba(59, 130, 246, 0.15);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.auth-panel-divider {
  height: 1px;
  background: var(--border-color);
}

.auth-identity-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.auth-identity-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  background: var(--bg-tertiary);
}

.auth-identity-main {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.auth-identity-provider {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-secondary);
}

.auth-identity-subject,
.auth-identity-email {
  font-size: 11px;
  color: var(--text-primary);
}

.auth-panel-wechat {
  display: flex;
  gap: 14px;
  align-items: center;
}

.auth-panel-qr {
  width: 120px;
  height: 120px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.auth-panel-qr-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.auth-panel-wechat-text {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.auth-panel-wechat-status {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
}

.auth-panel-wechat-actions {
  display: flex;
  gap: 8px;
}

body.auth-panel-open {
  overflow: hidden;
}

@media (max-width: 520px) {
  .auth-panel-row {
    grid-template-columns: 1fr;
  }

  .auth-panel-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .auth-panel-wechat {
    flex-direction: column;
    align-items: flex-start;
  }

  .auth-panel-qr {
    width: 160px;
    height: 160px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .auth-panel,
  .auth-panel-overlay {
    animation: none;
  }
}

.compact-preview-dialog {
  width: 100%;
  max-width: 480px;
  max-height: 85vh;
  background: var(--tm-paper-raised);
  border: 1px solid var(--tm-paper-hairline);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  display: flex;
  flex-direction: column;
  animation: dialog-slide-up 0.25s ease-out;
  overflow: hidden;
}

@keyframes dialog-slide-up {
  from {
    opacity: 0;
    transform: translateY(20px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.compact-preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--tm-paper-hairline);
  background: var(--tm-paper-band);
}

.compact-preview-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--tm-paper-ink);
  display: flex;
  align-items: center;
  gap: 8px;
}

.compact-preview-title svg {
  color: var(--tm-ink-purple);
}

.compact-preview-close {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--tm-paper-ink-2);
  cursor: pointer;
  transition: var(--transition);
}

.compact-preview-close:hover {
  background: var(--tm-paper-2);
  color: var(--tm-paper-ink);
}

.compact-preview-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.compact-preview-stats {
  display: flex;
  gap: 12px;
  padding: 10px 12px;
  background: var(--tm-paper-band);
  border-radius: var(--radius-md);
}

.compact-stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.compact-stat-label {
  font-size: 11px;
  color: var(--tm-paper-ink-2);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.compact-stat-value {
  font-size: 14px;
  font-weight: 600;
  color: var(--tm-paper-ink);
}

.compact-stat-value.text-green { color: var(--text-green); }
.compact-stat-value.text-orange { color: var(--text-orange); }
.compact-stat-value.text-purple { color: var(--tm-ink-purple); }

.compact-preview-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.compact-preview-section-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--tm-paper-ink-2);
  display: flex;
  align-items: center;
  gap: 6px;
}

.compact-preview-section-title svg {
  width: 14px;
  height: 14px;
  color: var(--tm-paper-ink-2);
}

.compact-summary-textarea {
  width: 100%;
  min-height: 80px;
  max-height: 150px;
  padding: 10px 12px;
  background: var(--tm-paper-raised);
  border: 1px solid var(--tm-paper-hairline);
  border-radius: var(--radius-md);
  color: var(--tm-paper-ink);
  font-size: 13px;
  line-height: 1.5;
  resize: vertical;
  transition: var(--transition);
}

.compact-summary-textarea:focus {
  outline: none;
  border-color: var(--tm-ink-purple);
  box-shadow: 0 0 0 2px rgba(192, 132, 252, 0.15);
}

.compact-memory-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 200px;
  overflow-y: auto;
}

.compact-memory-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 8px 10px;
  background: var(--tm-paper-band);
  border-radius: var(--radius-sm);
  font-size: 12px;
  line-height: 1.4;
}

.compact-memory-section-badge {
  flex-shrink: 0;
  padding: 2px 6px;
  background: var(--tm-paper-raised);
  border: 1px solid var(--tm-paper-hairline);
  border-radius: var(--radius-xs);
  font-size: 10px;
  font-weight: 500;
  color: var(--tm-paper-ink-2);
  text-transform: uppercase;
}

.compact-memory-text {
  color: var(--tm-paper-ink-2);
  flex: 1;
}

.compact-preview-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--tm-paper-hairline);
  background: var(--tm-paper-band);
}

.compact-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 500;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: var(--transition);
}

.compact-btn-cancel {
  background: transparent;
  border: 1px solid var(--tm-paper-hairline);
  color: var(--tm-paper-ink-2);
}

.compact-btn-cancel:hover {
  background: var(--tm-paper-2);
  color: var(--tm-paper-ink);
}

.compact-btn-confirm {
  background: var(--tm-paper-band);
  border: 1px solid var(--tm-ink-purple);
  color: var(--tm-ink-purple-strong);
}

.compact-btn-confirm:hover {
  background: var(--tm-paper-2);
}

.compact-btn-confirm:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ========================================
   Auto Compact Notification Banner
   ======================================== */

.compact-notification-banner {
  position: fixed;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  z-index: var(--tm-z-overlay); /* D§3.5 归并全屏遮罩语义 */
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  animation: banner-slide-down 0.3s ease-out;
  max-width: calc(100% - 24px);
}

@keyframes banner-slide-down {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(-16px);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}

.compact-notification-banner.hiding {
  animation: banner-slide-up 0.2s ease-in forwards;
}

@keyframes banner-slide-up {
  from {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
  to {
    opacity: 0;
    transform: translateX(-50%) translateY(-16px);
  }
}

.banner-icon {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(251, 146, 60, 0.1);
  border-radius: var(--radius-md);
  color: var(--text-orange);
}

.banner-content {
  flex: 1;
  min-width: 0;
}

.banner-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 2px;
}

.banner-desc {
  font-size: 11px;
  color: var(--text-muted);
}

.banner-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.banner-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 500;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
}

.banner-btn-primary {
  background: var(--text-purple);
  border: none;
  color: #fff;
}

.banner-btn-primary:hover {
  background: #8d81da;
}

.banner-btn-secondary {
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
}

.banner-btn-secondary:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.banner-close {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  border-radius: var(--radius-xs);
  color: var(--text-muted);
  cursor: pointer;
  transition: var(--transition);
}

.banner-close:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

/* ========================================
   Inline Banner - 通用内联横幅组件
   用于上下文相关的持久提示 (Layer 2)
   ======================================== */

.inline-banner {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 14px;
  margin: 8px 12px;
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid var(--border-color);
  backdrop-filter: blur(8px);
  opacity: 0;
  transform: translateY(-8px);
  transition: opacity 0.25s cubic-bezier(0.34, 1.56, 0.64, 1),
              transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.inline-banner.visible {
  opacity: 1;
  transform: translateY(0);
}

.inline-banner.hiding {
  animation: inline-banner-out 0.2s ease-in forwards;
}

@keyframes inline-banner-out {
  from {
    opacity: 1;
    transform: translateY(0);
  }
  to {
    opacity: 0;
    transform: translateY(-8px);
  }
}

/* Banner 类型样式 */
.inline-banner.banner-info {
  border-left: 3px solid var(--accent-blue);
  background: rgba(59, 130, 246, 0.05);
}

.inline-banner.banner-warning {
  border-left: 3px solid var(--text-orange);
  background: rgba(251, 146, 60, 0.05);
}

.inline-banner.banner-error {
  border-left: 3px solid var(--accent-red);
  background: rgba(239, 68, 68, 0.05);
}

.inline-banner.banner-success {
  border-left: 3px solid var(--text-green);
  background: rgba(34, 197, 94, 0.05);
}

/* Banner 图标 */
.inline-banner .banner-icon-wrapper {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.inline-banner.banner-info .banner-icon-wrapper {
  color: var(--accent-blue);
}

.inline-banner.banner-warning .banner-icon-wrapper {
  color: var(--text-orange);
}

.inline-banner.banner-error .banner-icon-wrapper {
  color: var(--accent-red);
}

.inline-banner.banner-success .banner-icon-wrapper {
  color: var(--text-green);
}

/* Banner 内容 */
.inline-banner .banner-content {
  flex: 1;
  min-width: 0;
}

.inline-banner .banner-message {
  margin: 0;
  font-size: 13px;
  color: var(--text-primary);
  line-height: 1.5;
}

.inline-banner .banner-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.inline-banner .banner-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 600;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
}

.inline-banner .banner-btn-primary {
  background: var(--text-purple);
  border: none;
  color: #fff;
}

.inline-banner .banner-btn-primary:hover {
  background: #8d81da;
  transform: translateY(-1px);
}

.inline-banner .banner-btn-secondary {
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
}

.inline-banner .banner-btn-secondary:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

/* Banner 关闭按钮 */
.inline-banner .banner-close {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  border-radius: var(--radius-xs);
  color: var(--text-muted);
  cursor: pointer;
  transition: var(--transition);
  margin-left: auto;
}

.inline-banner .banner-close:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

/* 暗色模式适配 */
:root[data-theme="dark"] .inline-banner {
  background: rgba(30, 30, 30, 0.8);
}
:root[data-theme="dark"] .inline-banner.banner-info {
  background: rgba(59, 130, 246, 0.08);
}
:root[data-theme="dark"] .inline-banner.banner-warning {
  background: rgba(251, 146, 60, 0.08);
}
:root[data-theme="dark"] .inline-banner.banner-error {
  background: rgba(239, 68, 68, 0.08);
}
:root[data-theme="dark"] .inline-banner.banner-success {
  background: rgba(34, 197, 94, 0.08);
}

/* ========================================
   Energy Edge - 底部能量槽 (HUD 进度条)
   主题色跟随模型切换
   ======================================== */

/* 主题色 CSS 变量 — 收敛到 --tm-model-* 单一事实源（D§2.2/§3.4）：
   能量槽与气泡辉光自此同色；per-model 判定只存在于 tokens.css */
:root {
  --energy-theme-color: var(--tm-model-accent);
  --energy-theme-rgb: var(--tm-model-accent-rgb);
}

.energy-edge {
  position: relative;
  width: calc(100% + 12px); /* 延伸到 glass-panel 全宽 */
  margin: 0 -6px; /* 抵消父容器 6px 左右 padding */
  padding: 3px 0 0 0;
  min-height: 5px; /* 固定占位，避免显隐造成输入区抖动 */
  cursor: default;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.2s ease, visibility 0.2s ease;
}

/* 仅在 critical 状态下显示可点击的指针样式 */
.energy-edge.critical {
  cursor: pointer;
}

.energy-edge.is-visible {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.energy-edge.hidden {
  display: block !important; /* 覆盖全局 .hidden，保留高度占位 */
  opacity: 0 !important;
  visibility: hidden !important;
  pointer-events: none !important;
}

.energy-edge-wrapper {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ========================================
   Synapse Bar 3.0 - 三层进度条
   L1: 历史 (History) - 深色模型主色
   L2: 输入 (Input) - 浅色模型主色 + 高亮
   L3: 开销 (Overhead) - 灰色
   ======================================== */

.energy-edge-track {
  position: relative;
  display: flex;
  flex: 1;
  height: 2px;
  border-radius: 0; /* 弧度由 glass-panel overflow:hidden 裁剪 */
  overflow: hidden;
  background: rgba(148, 163, 184, 0.08);
  transition: height 0.3s ease;
}

/* 80%+ 时进度条变粗 */
.energy-edge.critical .energy-edge-track {
  height: 3px;
}

/* 三层填充基础样式 */
.energy-fill {
  height: 100%;
  flex-shrink: 0;
  transition: width 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

/* L1: 历史层 - 哑光深沉基底 (沉淀感) */
.energy-fill-history {
  background: var(--energy-theme-color);
  opacity: 1;
  /* 降低亮度与饱和度，使其像是一块坚实的基岩，衬托 L2 */
  filter: brightness(0.65) saturate(0.8);
}

/* L2: 输入层 - 极致高能光谱彩带 (宽波段柔光版) */
.energy-fill-input {
  /* 
     去尖峰设计：
     移除 49%-51% 的极窄光针，改为平滑宽阔的青色漫射区 (35%-65%)
     彻底移除白色停靠点
  */
  background: linear-gradient(
    90deg,
    rgba(var(--energy-theme-rgb), 0.7) 0%,
    rgba(168, 85, 247, 1.0) 25%,        /* 紫色 */
    
    rgba(var(--energy-theme-rgb), 1.0) 40%, /* 过渡蓝 */
    rgba(34, 211, 238, 0.95) 50%,       /* 青色波峰 (宽阔且略微透明，不再刺眼) */
    rgba(var(--energy-theme-rgb), 1.0) 60%, /* 过渡蓝 */
    
    rgba(168, 85, 247, 1.0) 75%,        /* 紫色 */
    rgba(var(--energy-theme-rgb), 0.7) 100%
  );
  
  background-size: 200% 100%;
  opacity: 1;
  
  /* 4秒循环 */
  animation: energy-liquid-flow 4s linear infinite;
  
  /* 保持高色彩饱和度，但光感更均匀 */
  filter: saturate(1.8) brightness(1.2) drop-shadow(0 0 10px rgba(34, 211, 238, 0.5));
  
  transition: all 0.4s cubic-bezier(0.23, 1, 0.32, 1);
}

/* L2 输入时状态 - 辉光爆发 */
.energy-fill-input.typing {
  filter: saturate(1.6) brightness(1.2) drop-shadow(0 0 10px rgba(34, 211, 238, 0.6));
  /* 增加微弱的上下溢出感 */
  transform: scaleY(1.1);
}

@keyframes energy-liquid-flow {
  from { background-position: 200% 0; }
  to { background-position: 0% 0; }
}

/* L2 输入时状态 - 辉光增强 */
.energy-fill-input.typing {
  filter: saturate(1.3) brightness(1.2);
  box-shadow: 0 0 12px rgba(var(--energy-theme-rgb), 0.4);
}

@keyframes input-highlight {
  0% { filter: brightness(1.4) saturate(1.4); }
  50% { filter: brightness(1.8) saturate(1.8); }
  100% { filter: brightness(1.4) saturate(1.4); }
}

/* L3: 开销层 - 灰色 */
.energy-fill-overhead {
  background: #64748b;
  opacity: 0.6;
}

/* L3 呼吸动画 - 总体超50%时触发 */
.energy-edge.breathing .energy-fill-overhead {
  animation: overhead-breathe 2s ease-in-out infinite;
}

@keyframes overhead-breathe {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 0.75; }
}

/* ========================================
   Critical 状态 (80%+) - 所有层变为警示色
   ======================================== */

.energy-edge.critical .energy-fill-history {
  background: linear-gradient(90deg,
    var(--energy-theme-color) 0%,
    var(--accent-orange) 100%
  );
  opacity: 1;
}

.energy-edge.critical .energy-fill-input {
  background: linear-gradient(90deg,
    var(--accent-orange) 0%,
    #ef4444 100%
  );
  opacity: 0.8;
}

.energy-edge.critical .energy-fill-overhead {
  background: linear-gradient(90deg,
    #ef4444 0%,
    #dc2626 100%
  );
  opacity: 0.9;
  animation: critical-breathe 1.5s ease-in-out infinite;
}

@keyframes critical-breathe {
  0%, 100% { opacity: 0.8; }
  50% { opacity: 1; }
}

/* ========================================
   旧版兼容样式（保留以防遗留代码引用）
   ======================================== */

.energy-edge-fill {
  position: relative;
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: var(--energy-theme-color);
  box-shadow:
    0 0 6px rgba(var(--energy-theme-rgb), 0.4),
    0 0 12px rgba(var(--energy-theme-rgb), 0.2);
  transition: width 0.4s cubic-bezier(0.16, 1, 0.3, 1), background 0.3s ease, box-shadow 0.3s ease;
}

/* 流动渐变动画（50%+ 时使用） */
@keyframes energy-flow-warm {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* 50%-80%：动态脉冲，主题色→橙色流动 */
.energy-edge-fill.warm {
  background: linear-gradient(90deg,
    var(--energy-theme-color) 0%,
    rgba(251, 191, 36, 0.9) 40%,
    var(--accent-orange) 70%,
    rgba(251, 191, 36, 0.9) 100%
  );
  background-size: 200% 100%;
  box-shadow:
    0 0 8px rgba(251, 191, 36, 0.5),
    0 0 16px rgba(251, 191, 36, 0.25);
  animation: energy-flow-warm 2s linear infinite, energy-pulse 1.5s ease-in-out infinite;
}

/* 脉冲动效（warm 状态） */
@keyframes energy-pulse {
  0%, 100% {
    opacity: 0.9;
  }
  50% {
    opacity: 1;
  }
}

/* 80%+：临界状态 - 橙色→红色流动 */
.energy-edge-fill.critical {
  background: linear-gradient(90deg,
    var(--accent-orange) 0%,
    rgba(249, 115, 22, 0.95) 25%,
    #ef4444 50%,
    rgba(239, 68, 68, 0.9) 75%,
    var(--accent-orange) 100%
  );
  background-size: 300% 100%;
  box-shadow:
    0 0 10px rgba(239, 68, 68, 0.6),
    0 0 20px rgba(249, 115, 22, 0.3);
  animation: energy-flow-critical 1.5s linear infinite, energy-breathe 1.5s ease-in-out infinite;
}

@keyframes energy-flow-critical {
  0% { background-position: 300% 0; }
  100% { background-position: -300% 0; }
}

/* 呼吸动效（critical 状态） */
@keyframes energy-breathe {
  0%, 100% {
    opacity: 0.85;
    box-shadow:
      0 0 8px rgba(239, 68, 68, 0.5),
      0 0 16px rgba(249, 115, 22, 0.25);
  }
  50% {
    opacity: 1;
    box-shadow:
      0 0 14px rgba(239, 68, 68, 0.7),
      0 0 28px rgba(249, 115, 22, 0.4);
  }
}

/* Hover 效果：发光增强 */
.energy-edge:hover .energy-edge-fill {
  box-shadow:
    0 0 10px rgba(var(--energy-theme-rgb), 0.6),
    0 0 20px rgba(var(--energy-theme-rgb), 0.3);
}

.energy-edge:hover .energy-edge-fill.warm {
  box-shadow:
    0 0 12px rgba(251, 191, 36, 0.7),
    0 0 24px rgba(251, 191, 36, 0.35);
}

.energy-edge:hover .energy-edge-fill.critical {
  box-shadow:
    0 0 16px rgba(239, 68, 68, 0.8),
    0 0 32px rgba(249, 115, 22, 0.5);
}

/* ========================================
   Energy Compact Icon - 压缩触发图标
   80%+ 时显示在进度条右侧
   ======================================== */

.energy-compact-icon {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: 4px;
  color: #ef4444;
  cursor: pointer;
  transition: all 0.2s ease;
  animation: compact-icon-pulse 1.5s ease-in-out infinite;
}

.energy-compact-icon.hidden {
  display: none;
}

.energy-compact-icon:hover {
  background: rgba(239, 68, 68, 0.25);
  border-color: rgba(239, 68, 68, 0.5);
  transform: scale(1.1);
}

.energy-compact-icon:active {
  transform: scale(0.95);
}

@keyframes compact-icon-pulse {
  0%, 100% {
    opacity: 0.9;
    box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.3);
  }
  50% {
    opacity: 1;
    box-shadow: 0 0 8px 2px rgba(239, 68, 68, 0.2);
  }
}

/* ========================================
   Energy Tooltip - Hover 详细信息
   ======================================== */

.energy-tooltip {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  z-index: var(--tm-z-sticky);
  min-width: 160px;
  padding: 10px 12px;
  background: rgba(18, 18, 18, 0.95);
  border: 1px solid rgba(148, 163, 184, 0.15);
  border-radius: var(--radius-md);
  backdrop-filter: blur(12px);
  box-shadow:
    0 8px 24px rgba(0, 0, 0, 0.4),
    0 2px 8px rgba(0, 0, 0, 0.2);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  transform: translateX(-50%) translateY(4px);
}

.energy-edge:hover .energy-tooltip:not(.hidden) {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
  pointer-events: auto;
}

.energy-tooltip.hidden {
  display: none;
}

.energy-tooltip-header {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: rgba(148, 163, 184, 0.8);
  margin-bottom: 6px;
}

.energy-tooltip-divider {
  height: 1px;
  background: rgba(148, 163, 184, 0.15);
  margin-bottom: 8px;
}

.energy-tooltip-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}

.energy-tooltip-row:last-child {
  margin-bottom: 0;
}

.energy-tooltip-label {
  font-size: 11px;
  color: var(--text-muted);
}

.energy-tooltip-value {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-primary);
  font-feature-settings: "tnum";
  font-variant-numeric: tabular-nums;
}

.energy-tooltip-value.text-orange { color: var(--accent-orange); }
.energy-tooltip-value.text-red { color: #ef4444; }

/* ========================================
   Compact Trigger Button - 显性触发按钮
   ======================================== */

.compact-trigger-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  margin-right: 6px;
  font-size: 11px;
  font-weight: 500;
  color: var(--accent-orange);
  background: rgba(249, 115, 22, 0.1);
  border: 1px solid rgba(249, 115, 22, 0.3);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
  animation: compact-btn-pulse 2s ease-in-out infinite;
  white-space: nowrap;
}

.compact-trigger-btn.hidden {
  display: none;
}

.compact-trigger-btn:hover {
  background: rgba(249, 115, 22, 0.2);
  border-color: rgba(249, 115, 22, 0.5);
  transform: scale(1.02);
}

.compact-trigger-btn:active {
  transform: scale(0.98);
}

.compact-trigger-btn svg {
  flex-shrink: 0;
  stroke: currentColor;
}

/* 呼吸动效 */
@keyframes compact-btn-pulse {
  0%, 100% {
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(249, 115, 22, 0.3);
  }
  50% {
    transform: scale(1.03);
    box-shadow: 0 0 8px 2px rgba(249, 115, 22, 0.2);
  }
}

/* Critical 状态：紫色主题 */
.compact-trigger-btn.critical {
  color: var(--accent-purple);
  background: rgba(139, 92, 246, 0.1);
  border-color: rgba(139, 92, 246, 0.3);
  animation: compact-btn-pulse-critical 1.5s ease-in-out infinite;
}

.compact-trigger-btn.critical:hover {
  background: rgba(139, 92, 246, 0.2);
  border-color: rgba(139, 92, 246, 0.5);
}

@keyframes compact-btn-pulse-critical {
  0%, 100% {
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(139, 92, 246, 0.3);
  }
  50% {
    transform: scale(1.05);
    box-shadow: 0 0 12px 3px rgba(139, 92, 246, 0.25);
  }
}

/* ========================================
   Compact Banner Slot - 嵌入式通知横幅
   ======================================== */

.compact-banner-slot {
  width: 100%;
  overflow: hidden;
}

.compact-banner-slot.hidden {
  display: none;
}

/* 嵌入式 Banner 内容 */
.compact-inline-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  margin: 0 8px 8px 8px;
  background: rgba(249, 115, 22, 0.08);
  border: 1px solid rgba(249, 115, 22, 0.2);
  border-radius: var(--radius-md);
  animation: banner-inline-enter 0.3s ease-out;
}

@keyframes banner-inline-enter {
  from {
    opacity: 0;
    transform: translateY(-8px);
    max-height: 0;
    padding: 0 12px;
    margin-bottom: 0;
  }
  to {
    opacity: 1;
    transform: translateY(0);
    max-height: 80px;
    padding: 8px 12px;
    margin-bottom: 8px;
  }
}

.compact-inline-banner.hiding {
  animation: banner-inline-leave 0.2s ease-in forwards;
}

@keyframes banner-inline-leave {
  from {
    opacity: 1;
    transform: translateY(0);
    max-height: 80px;
  }
  to {
    opacity: 0;
    transform: translateY(-8px);
    max-height: 0;
    padding: 0 12px;
    margin-bottom: 0;
  }
}

.inline-banner-icon {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(249, 115, 22, 0.15);
  border-radius: var(--radius-sm);
  color: var(--accent-orange);
}

.inline-banner-content {
  flex: 1;
  min-width: 0;
}

.inline-banner-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 1px;
}

.inline-banner-desc {
  font-size: 10px;
  color: var(--text-muted);
}

.inline-banner-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.inline-banner-btn {
  padding: 4px 8px;
  font-size: 11px;
  font-weight: 500;
  border-radius: var(--radius-xs);
  cursor: pointer;
  transition: var(--transition);
}

.inline-banner-btn-primary {
  background: var(--accent-purple);
  border: none;
  color: #fff;
}

.inline-banner-btn-primary:hover {
  background: #8d81da;
}

.inline-banner-btn-dismiss {
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 4px;
}

.inline-banner-btn-dismiss:hover {
  color: var(--text-primary);
}

/* ========================================
   Auth Panel V2 (GPT Style - Refined Apple Aesthetic)
   ======================================== */

/* 
   Overlay & Layout Strategy 
   Target: Centered Card (Modal) with adaptive height.
   Avoids "dead white space" at bottom by centering the card vertically.
*/
.auth-panel-overlay.mode-full .auth-panel {
  max-width: var(--auth-panel-max-width);
  border-radius: var(--auth-panel-radius);
  padding-bottom: var(--auth-panel-padding-bottom);
}

.auth-panel.mode-centered {
  max-width: var(--auth-panel-max-width);
  border-radius: var(--auth-panel-radius);
  padding-bottom: var(--auth-panel-padding-bottom);
  position: relative;
  margin-top: var(--auth-panel-top-offset);
  overflow: visible;
}

/* Typography Overrides for V2 */

/* Pill Buttons */
.auth-panel-btn.pill {
  border-radius: 999px;
  padding: 12px 24px;
  font-size: 15px;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-weight: 600;
  transition: all 0.2s cubic-bezier(0.25, 0.8, 0.25, 1);
}

.auth-panel-btn.pill:active {
  transform: scale(0.98);
}

.auth-panel-btn.black {
  background: #18181b;
  color: #fff;
  border: 1px solid #18181b;
}

.auth-panel-btn.black:hover {
  background: #27272a;
  border-color: #27272a;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.auth-panel-btn.outline {
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-primary);
}

.auth-panel-btn.outline:hover {
  background: var(--bg-tertiary);
  border-color: var(--border-light);
}

.auth-panel-btn.green {
  background: #10b981;
  color: #fff;
  border: 1px solid #10b981;
}

.auth-panel-btn.green:hover {
  background: #059669;
  border-color: #059669;
}

.auth-panel-btn.full-width {
  width: 100%;
}

/* Options Stack */
.auth-options-stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  max-width: 320px;
  margin: 0 auto;
}

.auth-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 24px 0;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 500;
  width: 100%;
  max-width: 320px;
  margin-left: auto;
  margin-right: auto;
}

.auth-divider::before,
.auth-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border-color);
}

/* Input Styles */
.auth-input-large {
  font-size: 16px;
  padding: 0 16px;
  height: 56px;
  border-radius: 12px;
  background: #fff;
  border: 1px solid #e5e7eb;
  transition: all 0.2s cubic-bezier(0.25, 0.8, 0.25, 1);
}

.auth-input-large:focus {
  border-color: #3b82f6;
  box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.1);
  transform: translateY(-1px);
}

/* Primary Button in Full Mode */
.auth-panel-btn.primary {
  width: 100%;
  height: 52px;
  border-radius: 12px; /* Slightly squarer than pills */
  font-size: 16px;
  font-weight: 600;
}

.auth-panel-btn.primary.pill {
  border-radius: var(--radius-full);
}

/* Hide default header in V2 mode if needed */
.auth-panel.v2 .auth-panel-header {
  border-bottom: none;
  background: transparent;
  padding-bottom: 0;
}

.auth-panel-header.v2-options {
  justify-content: flex-end;
  border-bottom: none;
  background: transparent;
  padding-bottom: 0;
}

/* Tighter form fields in Full Mode */
.auth-panel-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.auth-panel-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 2px;
}

.auth-panel-otp-meta {
  margin-top: 12px;
  justify-content: center;
}


/* ========================================
   Auth Panel - Top Tier Aesthetic Overrides
   ======================================== */

/* 1. Modal Spring Animation */
@keyframes auth-spring-in {
  0% { opacity: 0; transform: scale(0.9) translateY(20px); }
  50% { opacity: 1; transform: scale(1.02) translateY(-5px); }
  100% { opacity: 1; transform: scale(1) translateY(0); }
}

.auth-panel {
  animation: auth-spring-in 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
  /* 企业稳重风格：纯白背景，精致层次感 */
  background: #ffffff;
  /* 两层阴影：小阴影+大阴影 */
  box-shadow:
    0 6px 18px rgba(0, 0, 0, 0.10),
    0 24px 70px rgba(0, 0, 0, 0.12),
    inset 0 0 0 1px rgba(255, 255, 255, 0.70);
  /* 圆角收敛：更像Office插件的成熟组件 */
  border-radius: 18px;
  border: 1px solid rgba(30, 64, 175, 0.08);
  /* 全局字体抗锯齿 - 解决文字模糊问题 */
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

/* Dark/Deep Theme Support for Glass */
:root[data-theme="dark"] .auth-panel {
  background: rgba(30, 30, 30, 0.85);
  border-color: rgba(255, 255, 255, 0.1);
  box-shadow:
    0 25px 50px -12px rgba(0,0,0,0.35),
    inset 0 1px 0 rgba(255,255,255,0.05);
}
:root[data-theme="dark"] .auth-panel-input {
  background: rgba(0, 0, 0, 0.2);
  border-color: rgba(255, 255, 255, 0.1);
  color: #e2e8f0;
}
:root[data-theme="dark"] .auth-panel-input:focus {
  background: rgba(0, 0, 0, 0.3);
}

/* 2. Typography & Emotions */

/* 3. Inputs with "Breathing" Focus & Depth */
.auth-panel-input {
  height: 44px;
  background: rgba(255, 255, 255, 0.5);
  border: 1px solid rgba(148, 163, 184, 0.25);
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.02);
  transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
  font-size: 14px;
}

.auth-panel-input.auth-input-large {
  height: 52px;
  font-size: 14px;
  padding-left: 16px;
}

.auth-panel-input:hover {
  background: rgba(255, 255, 255, 0.7);
  border-color: rgba(148, 163, 184, 0.4);
}

.auth-panel-input:focus {
  background: rgba(255, 255, 255, 0.95);
  border-color: var(--accent-blue);
  box-shadow: 
    0 0 0 4px rgba(59, 130, 246, 0.15),
    inset 0 1px 2px rgba(0,0,0,0.01),
    0 4px 12px rgba(59, 130, 246, 0.08); /* Glow */
  transform: translateY(-1px);
}

/* 4. Elegant Divider */
.auth-divider {
  margin: 20px 0;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 500;
  opacity: 0.8;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.auth-divider::before,
.auth-divider::after {
  content: "";
  height: 1px;
  flex: 1;
  background: linear-gradient(90deg, transparent, rgba(148, 163, 184, 0.3), transparent);
}

/* 5. Buttons: Magnetic & Morphing */
.auth-panel-btn {
  height: 40px;
  font-weight: 600;
  letter-spacing: 0.01em;
  position: relative;
  overflow: hidden;
}

.auth-panel-btn.pill {
  border-radius: 999px;
}

.auth-panel-btn.primary {
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  background: var(--primary-gradient);
  border: none;
  color: white;
}

.auth-panel-btn.primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px -4px rgba(var(--primary-glow-rgb), 0.5);
  filter: brightness(1.05);
}

.auth-panel-btn.primary:active {
  transform: translateY(0);
  box-shadow: 0 4px 12px -2px rgba(var(--primary-glow-rgb), 0.4);
}

.auth-panel-btn.outline {
  background: transparent;
  border: 1px solid rgba(148, 163, 184, 0.3);
  color: var(--text-primary);
  transition: all 0.2s ease;
}

.auth-panel-btn.outline:hover {
  background: rgba(255, 255, 255, 0.6);
  border-color: rgba(148, 163, 184, 0.5);
  transform: translateY(-1px);
}

/* Loading State - Morph to Spinner */
.auth-panel-btn.loading {
  color: transparent !important;
  pointer-events: none;
  cursor: wait;
}

.auth-panel-btn.loading svg {
  opacity: 0;
}

.auth-panel-btn.loading::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 18px;
  height: 18px;
  margin-top: -9px;
  margin-left: -9px;
  border: 2px solid rgba(255,255,255,0.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: auth-spin 0.8s linear infinite;
}

.auth-panel-btn.outline.loading::after {
  border-color: rgba(148, 163, 184, 0.3);
  border-top-color: var(--accent-blue);
}

@keyframes auth-spin {
  to { transform: rotate(360deg); }
}

/* 6. Alert Shake & Polish */
@keyframes auth-shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-4px); }
  40% { transform: translateX(4px); }
  60% { transform: translateX(-2px); }
  80% { transform: translateX(2px); }
}

.auth-panel-alert {
  animation: auth-shake 0.5s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
  border: none;
  background: rgba(59, 130, 246, 0.1);
  color: var(--text-primary);
  border-left: 3px solid var(--accent-blue);
  padding: 12px 16px;
  font-weight: 500;
  display: flex;
  align-items: center;
}

.auth-panel-alert.error {
  background: rgba(239, 68, 68, 0.08);
  border-left-color: #ef4444;
  color: #b91c1c;
}

.auth-panel-alert.info {
  background: rgba(59, 130, 246, 0.08);
  border-left-color: #3b82f6;
  color: #1d4ed8;
}

/* 7. Options Stack Refinement */
.auth-options-stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
}


/* ========================================
   Clean Header & Mascot Styles
   ======================================== */

.auth-panel-header.clean-mode {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  background: transparent;
  border-bottom: none;
  z-index: 10;
  padding: 12px 16px;
  pointer-events: auto;
  justify-content: flex-end; /* Push close button to right */
}

.auth-panel-header.clean-mode .auth-panel-close {
  pointer-events: auto;
  background: transparent;
  border: 1px solid transparent;
  opacity: 0.08;
}

.auth-panel-header.clean-mode .auth-panel-close:hover {
  background: rgba(0, 0, 0, 0.10);
  border-color: rgba(0, 0, 0, 0.04);
  opacity: 1;
}

.auth-mascot {
  width: 64px;
  height: 64px;
  margin: 0 auto;
  display: block;
}

.mascot-head {
  transition: fill 0.3s ease;
}

.mascot-pupil {
  transition: transform 0.15s cubic-bezier(0.2, 0, 0.4, 1);
}

/* ========================================
   Tai Chi Twin Fish Logo Animation
   ======================================== */

.fish-group {
  transform-origin: 50px 50px;
  transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Idle State: Slow, meditative rotation */

/* Active State: Fast, energetic rotation when typing */

@keyframes fish-rotate-idle {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

@keyframes fish-rotate-swim {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

@keyframes fish-idle-pulse {
  0%, 100% { transform: scale(1); opacity: 0.9; }
  50% { transform: scale(1.05); opacity: 1; }
}

/* Enhance Fish Visibility */


/* ========================================
   Badge Logo (The One) - Half-Out Style
   ======================================== */

/* 1. Anchor Point: The Card */
.auth-panel-overlay.mode-full .auth-panel {
  position: relative !important;
  overflow: visible !important; /* Allow logo to protrude */
  margin-top: var(--auth-panel-top-offset); /* Ensure visual space in viewport */
}

/* 2. Z-Index Stack Management
   Keep the header clickable while allowing the logo to float above it.
*/
.auth-panel-overlay.mode-full .auth-panel-body {
  position: relative !important;
  z-index: auto !important;
  overflow: visible !important;
}

/* Reset Intermediates to not clip or offset */

/* 3. The Badge: Classic Centering (Most Robust) */

/* 4. Content Spacing */

/* Animation for the Fish Ring */

/* Interactive Swim Speed */

/* Adjust Header Container */


/* ========================================
   企业稳重风格：内嵌品牌头部
   ======================================== */

/* 品牌头部栏：Logo + 产品名 */
.auth-brand-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 24px 16px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

.auth-brand-logo {
  width: 28px;
  height: 28px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.auth-brand-logo svg {
  width: 100%;
  height: 100%;
}

.auth-brand-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

/* 主色更新为深蓝 #1E40AF */
.auth-brand-logo svg {
  color: #1E40AF;
}

/* 企业风格标题区 */
.auth-enterprise-content {
  padding: 28px 24px 24px;
  text-align: center;
}

.auth-enterprise-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 8px;
  letter-spacing: -0.02em;
}

.auth-enterprise-subtitle {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.5;
  max-width: 280px;
  margin: 0 auto;
}

/* 表单区域 */
.auth-enterprise-form {
  padding: 0 24px 24px;
}

/* Primary按钮使用高级黑色系 - One Plan 品牌色 */
.auth-panel-btn.primary {
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Inter', 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: #111111;
  border: none;
  color: white;
  font-weight: 600;
  font-size: 15px;
  --primary-glow-rgb: 17, 17, 17;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.auth-panel-btn.primary:hover {
  background: #333333;
  box-shadow: 0 8px 20px -4px rgba(0, 0, 0, 0.25);
}

.auth-panel-btn.primary:active {
  background: #1a1a1a;
  transform: translateY(0);
}

/* 输入框样式优化 - 现代极简风格 */
.auth-panel-input {
  font-family: "Segoe UI", Roboto, Helvetica, Arial, sans-serif !important;
  font-size: 14px;
  line-height: 20px;
  font-weight: 400;
  letter-spacing: 0.02em;
  border: 1px solid #E5E7EB;
  background-color: #F9FAFB;
  border-radius: 10px;
  padding: 14px 16px;
  color: #374151;
  transition: all 0.2s ease;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.auth-panel-input::placeholder {
  color: var(--text-muted, #9CA3AF);
  font-weight: 400;
}

.auth-panel-input:hover {
  background-color: var(--bg-tertiary, #F3F4F6);
  border-color: var(--border-light, #D1D5DB);
}

/* B1: focus 边框走语义 token（暗色自动翻转为浅色边框，根修暗色不可见）+ 品牌紫 focus ring */
.auth-panel-input:focus {
  background-color: var(--bg-secondary, #FFFFFF);
  border-color: var(--text-primary, #111111);
  box-shadow:
    0 0 0 3px var(--tm-brand-purple-alpha-08, rgba(85, 69, 182, 0.08)),
    inset 0 1px 2px rgba(0,0,0,0.01);
}

/* ========================================
   居中垂直布局样式
   ======================================== */

.auth-centered-layout {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 40px 24px 24px;
  text-align: center;
}

/* Logo 居中 - 优化尺寸和间距 */
.auth-centered-logo {
  width: 80px;
  height: 80px;
  margin-bottom: 16px;
}

.auth-centered-logo svg,
.auth-centered-logo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* 外部引用 logo 样式 */
.auth-brand-logo {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* App Name 大字加粗黑色 - 无衬线体 + 抗锯齿 */
.auth-centered-appname {
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Inter', 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  font-size: 24px;
  font-weight: 700;
  color: var(--text-primary, #111111);
  letter-spacing: -0.01em;
  margin-bottom: 6px;
  /* 字体抗锯齿 - 解决模糊问题 */
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

/* Login Title 小字灰色 - 拉开层次 */
.auth-centered-title {
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Inter', 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  font-size: 14px;
  font-weight: 400;
  color: var(--text-muted, #9CA3AF);
  margin-bottom: 24px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* 表单居中 */
.auth-centered-form {
  width: 100%;
  max-width: 320px;
}

/* 居中布局下的分隔线和选项 */
.auth-centered-layout .auth-divider {
  width: 100%;
  max-width: 320px;
  margin: 28px 0;
  gap: 16px;
  font-size: 12px;
  color: var(--text-muted, #9CA3AF);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.auth-centered-layout .auth-divider::before,
.auth-centered-layout .auth-divider::after {
  background: linear-gradient(90deg, transparent, var(--border-color, #E5E7EB), transparent);
}

.auth-centered-layout .auth-options-stack {
  width: 100%;
  max-width: 320px;
  gap: 12px;
}
.auth-options-stack .auth-panel-btn {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 13px;
}

/* Sign-in wrap legal footer */
.auth-legal-footer {
  margin-top: 20px;
  text-align: center;
  font-size: 11px;
  line-height: 1.5;
  color: var(--text-muted, #94a3b8);
  max-width: 320px;
}
.auth-legal-link {
  color: var(--text-muted, #94a3b8);
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
  transition: color 0.15s;
}
.auth-legal-link:hover {
  color: var(--text-secondary, #64748b);
}

/* ========================================
   6位OTP验证码输入框组件
   ======================================== */

/* OTP容器 - 双层架构 */
.auth-otp-container {
  position: relative;
  width: 100%;
  max-width: 320px;
}

/* 隐藏的真实输入框 - 处理所有输入逻辑 */
.auth-otp-hidden-input {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  z-index: 2;
  cursor: text;
  font-size: 16px; /* 防止iOS缩放 */
}

/* 展示层 - 6个等距槽位 */
.auth-otp-display {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  pointer-events: none;
}

/* 单个槽位 */
.auth-otp-slot {
  flex: 1;
  max-width: 48px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-primary, #F9FAFB);
  border: 1.5px solid var(--border-color, #E5E7EB);
  border-radius: 10px;
  transition: all 0.15s ease;
}

/* 槽位状态 - 空 */
.auth-otp-slot.empty .auth-otp-char::before {
  content: "–";
  color: var(--border-color, #E5E7EB);
  font-weight: 300;
  font-size: 20px;
}

/* 槽位状态 - 已填充 */
.auth-otp-slot.filled {
  background: var(--bg-secondary, #FFFFFF);
  border-width: 1px;
  border-color: var(--text-secondary, #374151);
}

/* 槽位状态 - 当前激活（光标位置）- 主文本色边框（暗色自动翻转）+ 品牌紫 ring */
.auth-otp-slot.active {
  border-color: var(--text-primary, #111827);
  border-width: 2px;
  background: var(--bg-secondary, #FFFFFF);
  outline: 3px solid var(--tm-brand-purple-alpha-08, rgba(85, 69, 182, 0.08));
  outline-offset: 0;
}

/* 字符样式 */
.auth-otp-char {
  font-family: 'SF Mono', 'Menlo', 'Monaco', 'Consolas', monospace;
  font-size: 24px;
  font-weight: 600;
  color: var(--text-primary, #111111);
  line-height: 1;
}

/* 禁用状态 */
.auth-otp-container.disabled .auth-otp-slot {
  background: var(--bg-tertiary, #F3F4F6);
  border-color: var(--border-color, #E5E7EB);
  cursor: not-allowed;
}

.auth-otp-container.disabled .auth-otp-char {
  color: var(--text-muted, #9CA3AF);
}

.auth-otp-container.disabled .auth-otp-hidden-input {
  cursor: not-allowed;
}

/* 错误状态（status token：danger 面板底随主题自动切换） */
.auth-otp-container.error .auth-otp-slot {
  border-color: var(--tm-status-danger, #EF4444);
  background: var(--tm-status-danger-bg, #FEF2F2);
}

/* OTP组件下方的重新发送模块间距由 auth-otp-group/auth-otp-stack 控制 */

/* 旧版：OTP组件下方的重新发送按钮行（保留兼容） */
.auth-otp-container + .auth-otp-resend-row {
  margin-top: 12px;
}

/* OTP验证按钮 - 未填满时禁用状态 */
.auth-otp-submit-btn.incomplete {
  background: #9CA3AF !important;
  border-color: transparent !important;
  color: #fff !important;
  box-shadow: none !important;
  cursor: not-allowed;
  opacity: 0.7;
}

/* OTP验证按钮 - 跳动动画 */
@keyframes otp-btn-bounce {
  0%, 100% {
    transform: scale(1);
  }
  25% {
    transform: scale(1.05);
  }
  50% {
    transform: scale(0.98);
  }
  75% {
    transform: scale(1.02);
  }
}

.auth-otp-submit-btn.bounce {
  animation: otp-btn-bounce 0.4s ease-out;
}

/* ========================================
   Left Panel (左侧面板：对话历史 + 项目)
   ======================================== */

.left-panel-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.25);
  z-index: var(--tm-z-overlay);
  opacity: 0;
  transition: opacity 0.3s ease;
  -webkit-tap-highlight-color: transparent;
}
.left-panel-overlay.visible { opacity: 1; }
.left-panel-overlay.hidden { display: none; }

.left-panel {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: calc(100% - 48px);
  max-width: 320px;
  z-index: calc(var(--tm-z-overlay) + 1); /* 压过同层遮罩（原 9996/9997 相对序保持） */
  transform: translateX(-100%);
  transition: transform 0.3s cubic-bezier(0.23, 1, 0.32, 1);
}
.left-panel.visible { transform: translateX(0); }
.left-panel.hidden { display: none; }
#lp-settings-view,
#lp-settings-root {
  display: flex;
  flex: 1;
  min-height: 0;
}

.settings-shell {
  --settings-panel-bg: linear-gradient(180deg, rgba(255, 255, 255, 0.86), rgba(248, 250, 252, 0.98));
  --settings-panel-border: rgba(148, 163, 184, 0.18);
  --settings-soft-fill: rgba(241, 245, 249, 0.82);
  --settings-text: var(--text-primary);
  --settings-subtle: rgba(71, 85, 105, 0.82);
  /* v0.9.83 W-1：placeholder/secondary 文本 contrast 提升到 ≥ AA（6.20:1 on white） */
  --settings-muted: #5a6172;
  --settings-chip-bg: rgba(226, 232, 240, 0.72);
  --settings-chip-text: rgba(51, 65, 85, 0.9);
  --settings-chip-active-bg: rgba(99, 102, 241, 0.12);
  --settings-chip-active-border: rgba(99, 102, 241, 0.2);
  --settings-chip-active-text: #3730a3;
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  background:
    radial-gradient(circle at top left, var(--aurora-1), transparent 38%),
    radial-gradient(circle at top right, var(--aurora-2), transparent 34%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.94) 0%, rgba(248, 250, 252, 0.98) 100%);
  color: var(--settings-text);
}

.settings-float-back {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 5;
  /* v0.9.47 PR-A (plan §4): WCAG 2.5.5 Target Size (Enhanced) ≥ 44×44.
     icon 视觉尺寸不变（仍 18px font-size），padding 撑起 hit target。 */
  min-width: 44px;
  min-height: 44px;
  padding: 12px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  background: rgba(241, 245, 249, 0.88);
  color: var(--settings-text);
  cursor: pointer;
  font-size: 18px;
}

.settings-float-back,
.settings-back-inline,
.settings-link-btn,
.settings-text-btn,
.settings-choice,
.settings-row-value,
.settings-primary-btn,
.settings-secondary-btn {
  border: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
}

.settings-shell {
  position: relative;
}

.settings-scroll {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  gap: 16px;
  /* v0.9.84 Δ — 顶部 padding 52px → 8px：AppBar 现在 sticky 在 scroll 外层 shell，
     不再需要为 legacy float-back 预留 52px；< 与子页标题直接贴最上方。
     baseline 80px 兜底（不支持 :has() 的老 WebView 永远安全，不复发 P0-1 遮挡）。 */
  padding: 8px 16px calc(80px + env(safe-area-inset-bottom, 0px));
  overflow-y: auto;
}

/* v0.9.46 conditional reserve — Chromium 105+ / Safari 15.4+ / Firefox 121+ 支持 :has() 时启用
   v0.9.83 S-1/G2：settings-route 内已通过 .lp-user-profile { display:none } 隐藏 footer 控件，
   原 80px reserve 在 settings 子页里不再需要 → padding-bottom 收敛到 12px。
   v0.9.84 Δ：顶部 padding 52px → 8px（理由同上）。 */
@supports selector(:has(*)) {
  .settings-scroll {
    padding: 8px 16px 12px;
  }

  .left-panel.settings-route:has(.lp-user-profile:not(.hidden)) .settings-scroll {
    padding-bottom: 12px;
  }
}

/* v0.9.52 hotfix (Gemini r1 → Issue 1+2+3 合并修复):
   - Issue 1 (idle track 仍可见): track 透明 + thumb background-clip:padding-box → idle 完全隐形
   - Issue 2 (padding 左右不对称): scrollbar-gutter:stable both-edges → content 真正居中
   - Issue 3 (thumb 缺悬浮感): border:2px solid transparent + background-clip:padding-box → thumb 浮在 10px track 中
   保留 v0.9.51 alpha 梯度：idle 透明 / .is-scrolling 0.16 / hover 0.22 / active 0.30 (light)
   暗色平行：0.12 / 0.18 / 0.24
   .is-scrolling class 由 leftPanel.js 的 capture-phase scroll 监听器添加 */
.settings-scroll,
.lp-scroll,
.lp-settings-scroll {
  scrollbar-width: thin;
  scrollbar-color: transparent transparent;
  scrollbar-gutter: stable both-edges;
  transition: scrollbar-color 200ms var(--ease-out);
}

.settings-scroll.is-scrolling,
.lp-scroll.is-scrolling,
.lp-settings-scroll.is-scrolling {
  scrollbar-color: rgba(0, 0, 0, 0.16) transparent;
}

.settings-scroll:hover,
.settings-scroll:focus-within,
.lp-scroll:hover,
.lp-scroll:focus-within,
.lp-settings-scroll:hover,
.lp-settings-scroll:focus-within {
  scrollbar-color: rgba(0, 0, 0, 0.22) transparent;
}

.settings-scroll::-webkit-scrollbar,
.lp-scroll::-webkit-scrollbar,
.lp-settings-scroll::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

.settings-scroll::-webkit-scrollbar-track,
.lp-scroll::-webkit-scrollbar-track,
.lp-settings-scroll::-webkit-scrollbar-track {
  background: transparent;
}

/* v0.9.52: floating thumb — 2px 透明边框 + background-clip:padding-box
   让 background-color 只渲染在 padding 内（visible thumb 6px 浮在 10px track 中） */
.settings-scroll::-webkit-scrollbar-thumb,
.lp-scroll::-webkit-scrollbar-thumb,
.lp-settings-scroll::-webkit-scrollbar-thumb {
  background-color: transparent;
  border: 2px solid transparent;
  background-clip: padding-box;
  border-radius: 5px;
  transition: background-color 200ms var(--ease-out);
}

.settings-scroll.is-scrolling::-webkit-scrollbar-thumb,
.lp-scroll.is-scrolling::-webkit-scrollbar-thumb,
.lp-settings-scroll.is-scrolling::-webkit-scrollbar-thumb {
  background-color: rgba(0, 0, 0, 0.16);
}

.settings-scroll:hover::-webkit-scrollbar-thumb,
.settings-scroll:focus-within::-webkit-scrollbar-thumb,
.lp-scroll:hover::-webkit-scrollbar-thumb,
.lp-scroll:focus-within::-webkit-scrollbar-thumb,
.lp-settings-scroll:hover::-webkit-scrollbar-thumb,
.lp-settings-scroll:focus-within::-webkit-scrollbar-thumb {
  background-color: rgba(0, 0, 0, 0.22);
}

.settings-scroll::-webkit-scrollbar-thumb:hover,
.settings-scroll::-webkit-scrollbar-thumb:active,
.lp-scroll::-webkit-scrollbar-thumb:hover,
.lp-scroll::-webkit-scrollbar-thumb:active,
.lp-settings-scroll::-webkit-scrollbar-thumb:hover,
.lp-settings-scroll::-webkit-scrollbar-thumb:active {
  background-color: rgba(0, 0, 0, 0.30);
}

:root[data-theme="dark"] .settings-scroll.is-scrolling,
:root[data-theme="dark"] .lp-scroll.is-scrolling,
:root[data-theme="dark"] .lp-settings-scroll.is-scrolling {
  scrollbar-color: rgba(255, 255, 255, 0.12) transparent;
}

:root[data-theme="dark"] .settings-scroll:hover,
:root[data-theme="dark"] .settings-scroll:focus-within,
:root[data-theme="dark"] .lp-scroll:hover,
:root[data-theme="dark"] .lp-scroll:focus-within,
:root[data-theme="dark"] .lp-settings-scroll:hover,
:root[data-theme="dark"] .lp-settings-scroll:focus-within {
  scrollbar-color: rgba(255, 255, 255, 0.18) transparent;
}

:root[data-theme="dark"] .settings-scroll.is-scrolling::-webkit-scrollbar-thumb,
:root[data-theme="dark"] .lp-scroll.is-scrolling::-webkit-scrollbar-thumb,
:root[data-theme="dark"] .lp-settings-scroll.is-scrolling::-webkit-scrollbar-thumb {
  background-color: rgba(255, 255, 255, 0.12);
}

:root[data-theme="dark"] .settings-scroll:hover::-webkit-scrollbar-thumb,
:root[data-theme="dark"] .settings-scroll:focus-within::-webkit-scrollbar-thumb,
:root[data-theme="dark"] .lp-scroll:hover::-webkit-scrollbar-thumb,
:root[data-theme="dark"] .lp-scroll:focus-within::-webkit-scrollbar-thumb,
:root[data-theme="dark"] .lp-settings-scroll:hover::-webkit-scrollbar-thumb,
:root[data-theme="dark"] .lp-settings-scroll:focus-within::-webkit-scrollbar-thumb {
  background-color: rgba(255, 255, 255, 0.18);
}

:root[data-theme="dark"] .settings-scroll::-webkit-scrollbar-thumb:hover,
:root[data-theme="dark"] .settings-scroll::-webkit-scrollbar-thumb:active,
:root[data-theme="dark"] .lp-scroll::-webkit-scrollbar-thumb:hover,
:root[data-theme="dark"] .lp-scroll::-webkit-scrollbar-thumb:active,
:root[data-theme="dark"] .lp-settings-scroll::-webkit-scrollbar-thumb:hover,
:root[data-theme="dark"] .lp-settings-scroll::-webkit-scrollbar-thumb:active {
  background-color: rgba(255, 255, 255, 0.24);
}

/* 全局兜底 — 任何未明确自定义滚动条样式的容器，默认 thumb 透明 + hover 显示
   防止 viewport / 二级容器 fallback 到 Windows 原生粗滚动条 */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: transparent;
  border-radius: 4px;
  transition: background 200ms var(--ease-out);
}
:hover > ::-webkit-scrollbar-thumb,
*:hover::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.18);
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 0, 0, 0.32);
}
:root[data-theme="dark"] ::-webkit-scrollbar-thumb {
  background: transparent;
}
:root[data-theme="dark"] *:hover::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.14);
}
:root[data-theme="dark"] ::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.28);
}

.settings-search {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: rgba(0, 0, 0, 0.04);
  border-radius: 10px;
  border: 1px solid rgba(0, 0, 0, 0.06);
  transition: background 0.15s;
}
.settings-search:hover { background: rgba(0, 0, 0, 0.06); }
.settings-search-icon { flex-shrink: 0; opacity: 0.4; }
.settings-search-input {
  flex: 1;
  border: none;
  background: transparent;
  font-size: 13px;
  color: var(--settings-text);
  outline: none;
}
.settings-search-input::placeholder {
  /* v0.9.83 G3：用 token 联动 light/dark；opacity:1 覆盖 Firefox 默认 ~0.54 */
  color: var(--settings-muted);
  opacity: 1;
}

.settings-group,
.settings-inline-panel,
.settings-detail-card {
  border: 1px solid var(--settings-panel-border);
  background: var(--settings-panel-bg);
  border-radius: 18px;
  box-shadow: 0 14px 36px rgba(18, 18, 18, 0.06);
}

.settings-group,
.settings-detail-card {
  padding: 10px 12px;
}

.settings-row {
  width: 100%;
  display: grid;
  grid-template-columns: 28px 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 12px 6px;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
}

.settings-row + .settings-row {
  border-top: 1px solid rgba(226, 232, 240, 0.9);
}

.settings-row-icon {
  width: 28px;
  height: 28px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(241, 245, 249, 0.92);
  color: var(--settings-subtle);
}

.settings-row-icon svg {
  width: 18px;
  height: 18px;
}

.settings-row-copy {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.settings-row-title,
.settings-list-title,
.settings-detail-title,
.settings-subpage-title {
  font-size: 15px;
  font-weight: 600;
}

.settings-row-summary,
.settings-list-desc,
.settings-detail-desc,
.settings-empty,
.settings-version {
  color: var(--settings-subtle);
  font-size: 12px;
  line-height: 1.45;
}

.settings-row-chevron {
  color: var(--settings-muted);
  font-size: 18px;
}

.settings-row-value {
  padding: 4px 0;
  color: var(--settings-text);
  font-size: 13px;
}

.settings-inline-panel {
  margin-top: 8px;
  padding: 12px;
  background: rgba(248, 250, 252, 0.88);
}

.settings-choice-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.settings-choice {
  padding: 10px 14px;
  border-radius: 999px;
  border: 1px solid transparent;
  background: var(--settings-chip-bg);
  color: var(--settings-chip-text);
  font-size: 13px;
}

.settings-choice.active {
  background: var(--settings-chip-active-bg);
  color: var(--settings-chip-active-text);
  box-shadow: inset 0 0 0 1px var(--settings-chip-active-border);
}

/* === v0.9.79 Settings UI Polish — full-width action button alignment (plan §2.4) ===
   Gemini iter3 "global full-width alignment" rule: every action button that occupies
   its own row spans 100% to provide a unified grid + Fitts's Law + remove the
   "island" feeling created by inconsistent widths. */

/* Primary button block variant — full width with centered content + icon gap */
.settings-primary-btn--block {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

/* Secondary button block variant — full width + ellipsis fallback for narrow viewports */
.settings-secondary-btn--block {
  width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Inline icon span inside buttons (used by Manage subscription ↗ icon) */
.settings-btn-icon {
  display: inline-flex;
}
.settings-btn-icon svg {
  display: block;
}

/* Primary action row — vertical stack, primary button occupies its own row */
.settings-action-row--primary {
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
  margin-bottom: 12px;
}

/* Secondary action row — horizontal 50/50 split (Upgrade + Top up). min-width:0
   on flex items prevents long text from breaking the equal split (combined with
   --block ellipsis ensures graceful degradation on narrow viewports). */
.settings-action-row--secondary {
  display: flex;
  flex-direction: row;
  gap: 8px;
}
.settings-action-row--secondary > .settings-secondary-btn--block {
  flex: 1 1 0;
  min-width: 0;
}

/* Full row — single button spans full width (Account "Manage linked identities") */
.settings-action-row--full > .settings-secondary-btn--block {
  width: 100%;
}

/* ============================================================
   v0.9.82a Settings Redesign — UI only refactor (plan v3 §3)
   Adds AppBar, Profile Header, generic list-row, and redesigned
   Subscription / Account / Usage cards. Uses existing settings
   shell tokens (--settings-panel-bg / --settings-subtle /
   --settings-muted / --tm-brand-purple); no new design tokens.
   ============================================================ */

/* AppBar — sticky 48px header with centered title + left back chevron.
   48px back button hits Material 48dp target. Title margin-right offsets
   the back button so the title is visually centered against the panel
   regardless of LTR/RTL. */
.settings-app-bar {
  display: flex;
  align-items: center;
  min-height: 48px;
  /* v0.9.84 Δ：去 border-bottom 分割线，与下方 ProfileHeader/卡片无缝过渡 */
  padding: 8px 8px;
  position: sticky;
  top: 0;
  z-index: 6;
  background: transparent;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
/* v0.9.83 Δ1：不支持 backdrop-filter 的老 WebView 走 light 半透明 fallback */
@supports not ((backdrop-filter: blur(12px)) or (-webkit-backdrop-filter: blur(12px))) {
  .settings-app-bar { background: rgba(255, 255, 255, 0.72); }
}
@supports not ((backdrop-filter: blur(12px)) or (-webkit-backdrop-filter: blur(12px))) {
  :root[data-theme="dark"] .settings-app-bar { background: rgba(15, 23, 42, 0.72); }
}

/* v0.9.84 Δ — 主页 AppBar inline search 变体：< 与 search 同行，search flex:1 占满。 */
.settings-app-bar--with-search {
  gap: 8px;
  padding-right: 16px;
}
.settings-app-bar--with-search .settings-search--inline {
  flex: 1;
  min-width: 0;
}
.settings-app-bar-back {
  min-width: 48px;
  min-height: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 0;
  border-radius: 12px;
  color: var(--settings-text);
  cursor: pointer;
}
.settings-app-bar-back:hover {
  background: rgba(148, 163, 184, 0.12);
}
.settings-app-bar-back:focus-visible {
  outline: 2px solid var(--tm-brand-purple);
  outline-offset: 2px;
}
.settings-app-bar-title {
  flex: 1;
  margin: 0 48px 0 0; /* offset 48px back hit-target so title is centered */
  text-align: center;
  font-size: 17px;
  font-weight: 600;
  color: var(--settings-text);
  min-width: 0;
  overflow-wrap: anywhere;
  word-break: break-word;
}

/* v0.9.83 S-1：settings 子页内隐藏 left-panel footer 的用户信息控件（avatar/gear），
   避免与 settings AppBar 重复出现登录身份；padding reserve 已由 G2 同步收敛 */
.left-panel.settings-route .lp-user-profile { display: none; }

/* v0.9.83 Subscription subpage — Manage 改用 scoped list-row 风格 row
   （不引入通用 -icon/-content/-title/-desc 4 class，只 subscription-scoped）。
   保留原 .settings-subscription-card padding 给主卡。 */
.settings-subscription-card {
  padding: 4px 0;
}
.settings-subscription-manage-row {
  align-items: flex-start;
  padding-top: 12px;
  padding-bottom: 12px;
}
.settings-subscription-manage-text {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  text-align: left;
}
.settings-subscription-manage-title {
  font-size: 15px;
  font-weight: 500;
  color: var(--settings-text);
}
.settings-subscription-manage-desc {
  font-size: 13px;
  color: var(--settings-muted);
}

.settings-subpage {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.settings-back-inline {
  align-self: flex-start;
  /* v0.9.47 PR-A (plan §4): WCAG 2.5.5 Target Size (Enhanced) ≥ 44×44.
     视觉左缘对齐用 margin-left:-4px 抵消 padding。 */
  min-width: 44px;
  min-height: 44px;
  padding: 12px 4px;
  margin-left: -4px;
  color: var(--settings-subtle);
}

.settings-two-col,
.settings-action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.settings-stat-card,
.settings-static-row,
.settings-list-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
}

.settings-two-col .settings-stat-card {
  flex: 1 1 0;
  padding: 14px;
  border-radius: 16px;
  border: 1px solid rgba(226, 232, 240, 0.92);
  background: var(--settings-soft-fill);
}

.settings-stat-value {
  font-size: 22px;
  font-weight: 700;
}

.settings-stat-label,
.settings-detail-meta,
.settings-section-kicker {
  margin-top: 6px;
  font-size: 12px;
  color: var(--settings-muted);
}

.settings-meter {
  margin-top: 12px;
  height: 8px;
  border-radius: 999px;
  background: rgba(226, 232, 240, 0.88);
  overflow: hidden;
}

.settings-meter-fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, rgba(83, 148, 255, 0.85), rgba(112, 255, 199, 0.85));
}

.settings-primary-btn,
.settings-secondary-btn {
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 13px;
  white-space: normal;
  overflow-wrap: break-word;
  line-height: 1.4;
}

.settings-primary-btn {
  background: var(--primary-gradient);
  color: #ffffff;
  box-shadow: 0 12px 28px rgba(var(--primary-glow-rgb), 0.18);
}

.settings-secondary-btn {
  border: 1px solid rgba(203, 213, 225, 0.92);
  background: rgba(241, 245, 249, 0.88);
  color: var(--settings-text);
}

/* destructive solid — used for confirm modal "Sign out" button (Progressive Friction layer 2) */
.settings-primary-btn.settings-danger-solid,
.settings-secondary-btn.settings-danger-solid,
.settings-danger-solid {
  background: var(--settings-danger-solid-bg);
  color: var(--settings-danger-solid-fg);
  border: 1px solid var(--settings-danger-solid-bg);
  box-shadow: 0 8px 20px rgba(185, 28, 28, 0.18);
}
.settings-primary-btn.settings-danger-solid:hover,
.settings-secondary-btn.settings-danger-solid:hover,
.settings-danger-solid:hover {
  background: var(--settings-danger-solid-bg-hover);
  border-color: var(--settings-danger-solid-bg-hover);
  color: var(--settings-danger-solid-fg);
}
.settings-primary-btn.settings-danger-solid:focus-visible,
.settings-secondary-btn.settings-danger-solid:focus-visible,
.settings-danger-solid:focus-visible {
  outline: 2px solid var(--settings-danger-solid-bg);
  outline-offset: 2px;
}

.settings-cap-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.settings-cap-chip {
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(226, 232, 240, 0.96);
  background: rgba(248, 250, 252, 0.96);
  font-size: 12px;
  color: var(--settings-chip-text);
}

.settings-preferences-shell .settings-pane-block + .settings-pane-block,
.settings-preferences-shell .settings-static-row + .settings-pane-block,
.settings-preferences-shell .settings-pane-block + .settings-static-row {
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.settings-overview {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.settings-link-btn,
.settings-text-btn {
  padding: 0;
  color: var(--settings-subtle);
}

.lp-inner {
  display: flex;
  flex-direction: column;
  height: 100%;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(24px) saturate(200%);
  -webkit-backdrop-filter: blur(24px) saturate(200%);
  border-right: 1px solid rgba(0, 0, 0, 0.06);
  box-shadow: 4px 0 24px rgba(0, 0, 0, 0.08);
}

.left-panel.settings-route .lp-inner {
  background:
    radial-gradient(circle at top left, rgba(99, 102, 241, 0.08), transparent 34%),
    radial-gradient(circle at top right, rgba(56, 189, 248, 0.08), transparent 30%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.98) 0%, rgba(248, 250, 252, 0.98) 100%);
  border-right: 0;
  box-shadow: none;
}

/* 搜索栏 */
.lp-search {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 12px 12px 0;
  padding: 8px 12px;
  background: rgba(0, 0, 0, 0.04);
  border-radius: 10px;
  border: 1px solid rgba(0, 0, 0, 0.06);
  cursor: pointer;
  transition: background 0.15s;
}
.lp-search:hover { background: rgba(0, 0, 0, 0.06); }
.lp-search-icon {
  flex-shrink: 0;
  opacity: 0.4;
}
.lp-search-input {
  flex: 1;
  border: none;
  background: transparent;
  font-size: 13px;
  color: var(--text-primary, #1a1a1a);
  outline: none;
  cursor: pointer;
}
.lp-search-input::placeholder {
  color: rgba(0, 0, 0, 0.35);
}

/* 新对话 + 临时会话 行 */
.lp-actions-row {
  display: flex;
  gap: 8px;
  padding: 10px 12px 6px;
}
.lp-action-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 0;
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.8);
  font-size: 13px;
  color: var(--text-primary, #1a1a1a);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.lp-action-btn:hover {
  background: rgba(0, 0, 0, 0.04);
  border-color: rgba(0, 0, 0, 0.12);
}
.lp-action-btn svg {
  opacity: 0.6;
}

/* 可滚动主体 */
.lp-scroll {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 4px 0;
  /* scrollbar-width / scrollbar-color 由 v0.9.51 统一规则驱动（styles.css L8106 起） */
}

/* 区块 */
.lp-section {
  padding: 4px 0;
}
.lp-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px 4px;
}
.lp-section-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: rgba(0, 0, 0, 0.4);
}
.lp-section-actions {
  display: flex;
  gap: 2px;
}
.lp-icon-btn {
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  border-radius: 6px;
  color: rgba(0, 0, 0, 0.4);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.lp-icon-btn:hover {
  background: rgba(0, 0, 0, 0.06);
  color: rgba(0, 0, 0, 0.7);
}

/* 折叠组件 */
.lp-collapsible .lp-collapse-content {
  overflow: hidden;
  max-height: 2000px;
  transition: max-height 0.25s ease;
}
.lp-collapsible.collapsed .lp-collapse-content {
  max-height: 0;
}

.lp-collapse-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  cursor: pointer;
  border-radius: 6px;
  margin: 0 6px;
  transition: background 0.15s;
  user-select: none;
}
.lp-collapse-header:hover {
  background: rgba(0, 0, 0, 0.04);
}
.lp-collapse-arrow {
  font-size: 11px;
  color: rgba(0, 0, 0, 0.35);
  width: 12px;
  text-align: center;
  flex-shrink: 0;
}

/* 项目/文档/对话 行 */
.lp-project-row {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary, #1a1a1a);
}
.lp-doc-row {
  font-size: 12.5px;
  color: rgba(0, 0, 0, 0.7);
  padding-left: 28px !important;
}
.lp-chat-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 14px 5px 44px;
  font-size: 12px;
  color: rgba(0, 0, 0, 0.55);
  cursor: pointer;
  border-radius: 6px;
  margin: 0 6px;
  transition: background 0.15s;
}
.lp-chat-row:hover {
  background: rgba(0, 0, 0, 0.04);
}
.lp-item-icon {
  flex-shrink: 0;
  opacity: 0.5;
}
.lp-item-text {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* 归档区 */
.lp-archive-row {
  font-size: 12.5px;
  color: rgba(0, 0, 0, 0.45);
}

/* 分隔线 */
.lp-divider {
  height: 1px;
  margin: 4px 14px;
  background: rgba(0, 0, 0, 0.06);
}

/* 空状态 */
.lp-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px 16px;
  gap: 8px;
}
.lp-empty-title {
  font-size: 13px;
  font-weight: 500;
  color: rgba(0, 0, 0, 0.5);
}
.lp-empty-desc {
  font-size: 12px;
  color: rgba(0, 0, 0, 0.35);
  text-align: center;
  line-height: 1.4;
}
.lp-empty-hint {
  padding: 8px 14px 8px 32px;
  font-size: 12px;
  color: rgba(0, 0, 0, 0.35);
  font-style: italic;
}

/* ---- 对话历史列表 ---- */
.lp-history-list { padding: 0; }

.lp-group-label {
  padding: 10px 14px 4px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  color: rgba(0, 0, 0, 0.35);
  letter-spacing: 0.03em;
}

.lp-history-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  font-size: 13px;
  color: rgba(0, 0, 0, 0.7);
  cursor: pointer;
  border-radius: 8px;
  margin: 1px 6px;
  transition: background 0.15s;
  position: relative;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.lp-history-row:hover { background: rgba(0, 0, 0, 0.04); }
.lp-history-row.active {
  background: rgba(0, 0, 0, 0.07);
  font-weight: 500;
}

.lp-history-row-title {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lp-history-delete {
  display: none;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border: none;
  background: none;
  color: rgba(0, 0, 0, 0.3);
  cursor: pointer;
  border-radius: 4px;
  flex-shrink: 0;
  padding: 0;
  transition: color 0.15s, background 0.15s;
}
.lp-history-row:hover .lp-history-delete { display: flex; }
.lp-history-delete:hover {
  color: #e53935;
  background: rgba(229, 57, 53, 0.08);
}

.lp-search-no-results {
  padding: 16px 14px;
  font-size: 12px;
  color: rgba(0, 0, 0, 0.35);
  text-align: center;
}

/* 视图切换 */
.lp-view { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.lp-view-hidden { display: none !important; }

/* ---- 设置视图 ---- */
.lp-settings-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  border-bottom: 1px solid rgba(0,0,0,0.06);
}
.lp-settings-back {
  display: flex; align-items: center; gap: 4px;
  background: none; border: none; cursor: pointer;
  font-size: 13px; color: var(--accent-color, #3b82f6);
  padding: 4px 6px; border-radius: 6px;
}
.lp-settings-back:hover { background: rgba(59,130,246,0.08); }
.lp-settings-title {
  font-size: 14px; font-weight: 600; color: rgba(0,0,0,0.8);
  margin-left: auto;
}

/* 设置视图-用户卡 */
.lp-settings-user-card {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 14px; cursor: pointer;
  border-bottom: 1px solid rgba(0,0,0,0.06);
  transition: background 0.15s;
}
.lp-settings-user-card:hover { background: rgba(0,0,0,0.03); }
.lp-settings-user-avatar,
.lp-user-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,0.06); color: rgba(0,0,0,0.4);
  font-size: 14px; font-weight: 600; flex-shrink: 0;
}
.lp-settings-user-avatar.has-initial,
.lp-user-avatar.has-initial {
  background: var(--tm-brand-purple); color: #fff;
}
.lp-settings-user-info {
  flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px;
}
.lp-settings-user-email {
  font-size: 13px; font-weight: 500; color: rgba(0,0,0,0.8);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.lp-settings-user-plan {
  font-size: 11px; color: var(--tm-brand-purple); font-weight: 500;
}
.lp-settings-user-plan.hidden { display: none; }
.lp-settings-chevron { opacity: 0.3; flex-shrink: 0; }

/* 设置项滚动区 */
.lp-settings-scroll {
  flex: 1; overflow-y: auto; padding: 4px 0;
  -webkit-overflow-scrolling: touch;
}
.lp-settings-group { padding: 4px 0; }
.lp-settings-group-label {
  padding: 8px 16px 4px;
  font-size: 11px; font-weight: 600; letter-spacing: 0.5px;
  color: rgba(0,0,0,0.4); text-transform: uppercase;
}
.lp-settings-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 16px; cursor: pointer;
  transition: background 0.15s;
}
.lp-settings-item:hover { background: rgba(0,0,0,0.03); }
.lp-settings-item svg:first-child { opacity: 0.5; flex-shrink: 0; }
.lp-settings-item-label { flex: 1; font-size: 13px; color: rgba(0,0,0,0.75); }
.lp-settings-item-value {
  font-size: 12px; color: rgba(0,0,0,0.4); font-weight: 500;
}
.lp-settings-logout { color: #ef4444; }
.lp-settings-logout .lp-settings-item-label { color: #ef4444; }
.lp-settings-logout svg { stroke: #ef4444; opacity: 0.7; }
.lp-settings-logout.hidden { display: none; }
.lp-settings-version {
  text-align: center; padding: 8px 16px 12px;
  font-size: 11px; color: rgba(0,0,0,0.25);
}
.lp-settings-bottom { border-top: 1px solid rgba(0,0,0,0.06); margin-top: 4px; padding-top: 4px; }

/* ---- 底部用户信息条 ---- */
.lp-footer {
  padding: 8px 12px;
  border-top: 1px solid rgba(0, 0, 0, 0.06);
}
.lp-user-bar {
  display: flex; align-items: center; gap: 8px;
}
.lp-user-login-btn {
  flex: 1; padding: 8px 10px;
  border: none; background: transparent; border-radius: 8px;
  font-size: 13px; color: var(--tm-brand-purple);
  cursor: pointer; text-align: left; font-weight: 500;
  transition: background 0.15s;
}
.lp-user-login-btn:hover { background: rgba(var(--tm-brand-purple-rgb), 0.08); }
.lp-user-login-btn.hidden { display: none; }
.lp-user-profile {
  flex: 1; display: flex; align-items: center; gap: 8px;
  min-width: 0; cursor: pointer; padding: 4px 6px;
  border-radius: 8px; transition: background 0.15s;
}
.lp-user-profile:hover { background: rgba(0,0,0,0.04); }
.lp-user-profile.hidden { display: none; }
.lp-user-email {
  font-size: 12px; color: rgba(0,0,0,0.6);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  flex: 1; min-width: 0;
}
.lp-gear-btn {
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  border: none; background: transparent; border-radius: 8px;
  cursor: pointer; color: rgba(0,0,0,0.4); flex-shrink: 0;
  transition: background 0.15s, color 0.15s;
}
.lp-gear-btn:hover { background: rgba(0,0,0,0.06); color: rgba(0,0,0,0.7); }

/* ========================================
   Billing 视图
   ======================================== */
.lp-billing-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 0;
}
.lp-billing-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 40px 16px;
  font-size: 12px;
  color: rgba(0,0,0,0.4);
}
.lp-billing-state.hidden { display: none; }
.lp-billing-retry-btn {
  padding: 6px 14px;
  border: 1px solid rgba(0,0,0,0.12);
  background: transparent;
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
  color: rgba(0,0,0,0.6);
  transition: background 0.15s;
}
.lp-billing-retry-btn:hover { background: rgba(0,0,0,0.04); }

/* Plan Card */
.lp-billing-plan-free,
.lp-billing-plan-active {
  padding: 14px 16px;
  border-bottom: 1px solid rgba(0,0,0,0.06);
}
.lp-billing-plan-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.3px;
  color: rgba(0,0,0,0.4);
  text-transform: uppercase;
  margin-bottom: 2px;
}
.lp-billing-plan-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary, #1e293b);
}
.lp-billing-plan-desc {
  font-size: 12px;
  color: rgba(0,0,0,0.45);
  margin-top: 4px;
}
.lp-billing-plan-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}
.lp-billing-adjust-btn {
  flex-shrink: 0;
  padding: 5px 12px;
  border: 1px solid rgba(99,102,241,0.3);
  background: rgba(99,102,241,0.06);
  border-radius: 6px;
  font-size: 11px;
  font-weight: 500;
  color: var(--accent-indigo, #6366f1);
  cursor: pointer;
  transition: background 0.15s;
}
.lp-billing-adjust-btn:hover {
  background: rgba(99,102,241,0.12);
}
.lp-billing-plan-details {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-top: 8px;
}
.lp-billing-plan-price {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary, #1e293b);
}
.lp-billing-plan-renew {
  font-size: 11px;
  color: rgba(0,0,0,0.4);
}

/* Invoices Section */
.lp-billing-section-label {
  padding: 12px 16px 6px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.5px;
  color: rgba(0,0,0,0.4);
  text-transform: uppercase;
}
.lp-billing-invoice-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 16px;
  border-bottom: 1px solid rgba(0,0,0,0.04);
  transition: background 0.15s;
}
.lp-billing-invoice-row:hover {
  background: rgba(0,0,0,0.02);
}
.lp-billing-invoice-left,
.lp-billing-invoice-right {
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.lp-billing-invoice-right {
  align-items: flex-end;
}
.lp-billing-invoice-date {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-primary, #1e293b);
}
.lp-billing-invoice-type {
  font-size: 10px;
  color: rgba(0,0,0,0.35);
}
.lp-billing-invoice-amount {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary, #1e293b);
  font-variant-numeric: tabular-nums;
}
.lp-billing-invoice-status {
  font-size: 10px;
  font-weight: 500;
}
.lp-billing-status-paid { color: #10b981; }
.lp-billing-status-pending { color: #f59e0b; }
.lp-billing-status-failed { color: #ef4444; }

/* Empty & Cancel */
.lp-billing-empty {
  padding: 20px 16px;
  text-align: center;
  font-size: 12px;
  color: rgba(0,0,0,0.35);
}
.lp-billing-empty.hidden { display: none; }
.lp-billing-cancel-section {
  padding: 16px;
  margin-top: 8px;
  border-top: 1px solid rgba(0,0,0,0.06);
}
.lp-billing-cancel-section.hidden { display: none; }
.lp-billing-cancel-btn {
  width: 100%;
  padding: 9px;
  border: 1px solid rgba(239,68,68,0.25);
  background: rgba(239,68,68,0.04);
  border-radius: 8px;
  font-size: 12px;
  font-weight: 500;
  color: #ef4444;
  cursor: pointer;
  transition: background 0.15s;
}
.lp-billing-cancel-btn:hover {
  background: rgba(239,68,68,0.1);
}

/* ========================================
   Dark Theme — 组件级硬编码颜色覆盖
   选择器: :root[data-theme="dark"]
   ======================================== */

/* --- Glass Panels (Composer / Cortex；B5 刀① 旧头排族已随组件删除) --- */
:root[data-theme="dark"] .composer-glass-panel {
  background: rgba(30, 30, 30, 0.85);
  border-color: rgba(255, 255, 255, 0.1);
}
/* 旧极光暗补丁已删（0813 记忆面板纸墨换皮）：:root[data-theme] 特异性会
   反杀 memory-paper.css 的纸面栈（lp-inner 同族实证），暗档由 token 承担 */

/* --- Model Selector --- */
:root[data-theme="dark"] .model-selector-trigger {
  border-color: rgba(148, 163, 184, 0.2);
  background: rgba(30, 30, 30, 0.6);
}
:root[data-theme="dark"] .model-selector-trigger:hover {
  background: rgba(30, 30, 30, 0.8);
}

/* --- Message Bubbles --- */
:root[data-theme="dark"] body:not([data-bubble-theme="white"]) .message-user .message-bubble {
  background: rgba(255, 255, 255, 0.06);
}
:root[data-theme="dark"] body:not([data-bubble-theme="white"]) .message-user .message-bubble:hover {
  background: rgba(255, 255, 255, 0.1);
}
:root[data-theme="dark"] body[data-bubble-theme="white"] .message-user .message-bubble {
  background: rgba(30, 30, 30, 0.8);
}
:root[data-theme="dark"] body[data-bubble-theme="white"] .message-user .message-bubble:hover {
  background: rgba(30, 30, 30, 0.9);
}
:root[data-theme="dark"] .message-action-btn.primary:hover {
  background: rgba(18, 18, 18, 0.9);
  border-color: rgba(100, 116, 139, 0.3);
}

/* --- Code Blocks --- */
:root[data-theme="dark"] .markdown-body .code-block-wrapper {
  background: #0a0a0a;
  border-color: rgba(255, 255, 255, 0.08);
}
:root[data-theme="dark"] .markdown-body .code-block-header {
  background: rgba(30, 30, 30, 0.4);
  border-color: rgba(255, 255, 255, 0.08);
}
:root[data-theme="dark"] .markdown-body code:not(pre code) {
  color: #f87171;
  background: rgba(239, 68, 68, 0.1);
}

/* --- Composer Input --- */
:root[data-theme="dark"] .composer-plus-btn {
  border-color: rgba(255, 255, 255, 0.15);
}
:root[data-theme="dark"] .composer-plus-btn:hover {
  background: rgba(255, 255, 255, 0.08);
}

/* --- Scrollbars --- */
:root[data-theme="dark"] .chat {
  scrollbar-color: rgba(100, 116, 139, 0.3) transparent;
}
/* v0.9.51: .lp-scroll dark scrollbar-color 已由 styles.css L8159 起的 .is-scrolling/hover/focus-within 规则统一驱动 */

/* --- Cortex / Memory / Storage --- */
/* .cortex-working 暗补丁已删（同上：纸皮层已置 transparent） */
:root[data-theme="dark"] .mem-file {
  background: rgba(30, 30, 30, 0.6);
}
:root[data-theme="dark"] .mem-file:hover {
  background: rgba(30, 30, 30, 0.7);
}
/* .mem-file.open 暗补丁已删（0813 换皮：展开态透明，暗档由 token 承担） */
/* storage-* 旧暗补丁已删（0813 偏好页纸墨换皮）：:root[data-theme] 特异性
   会反杀 settings-paper 的纸皮层（lp-inner/cortex 同族第四例），暗档由
   token 翻转承担 */

/* --- Markdown highlight --- */
:root[data-theme="dark"] .markdown-body mark {
  background: rgba(var(--primary-glow-rgb), 0.25);
}

/* --- Settings Shell (Left Panel) --- */
/* v0.9.85 Δ：深色卡片 bg 从 rgba(18,18,18) 抬到 rgba(38,38,42)，与 page bg
   gradient rgba(18,18,18,0.94→0.98) 拉开 ~20 单位明度差，避免卡片溶解；
   border opacity 0.12 → 0.18 微强化卡片边界。 */
:root[data-theme="dark"] .settings-shell {
  --settings-panel-bg: linear-gradient(180deg, rgba(38, 38, 42, 0.94), rgba(38, 38, 42, 0.98));
  --settings-panel-border: rgba(148, 163, 184, 0.18);
  --settings-soft-fill: rgba(30, 30, 30, 0.82);
  --settings-text: var(--text-primary);
  --settings-subtle: rgba(203, 213, 225, 0.82);
  /* v0.9.83 W-1：dark placeholder/secondary 文本 contrast 提升 */
  --settings-muted: rgba(203, 213, 225, 0.92);
  --settings-chip-bg: rgba(42, 42, 42, 0.72);
  --settings-chip-text: rgba(203, 213, 225, 0.9);
  --settings-chip-active-bg: rgba(99, 102, 241, 0.2);
  --settings-chip-active-border: rgba(99, 102, 241, 0.35);
  --settings-chip-active-text: #a5b4fc;
  background:
    radial-gradient(circle at top left, var(--aurora-1), transparent 38%),
    radial-gradient(circle at top right, var(--aurora-2), transparent 34%),
    linear-gradient(180deg, rgba(18, 18, 18, 0.94) 0%, rgba(18, 18, 18, 0.98) 100%);
}
:root[data-theme="dark"] .settings-search {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.08);
}
:root[data-theme="dark"] .settings-search:hover {
  background: rgba(255, 255, 255, 0.1);
}
:root[data-theme="dark"] .settings-search-input::placeholder {
  /* v0.9.83 G3：dark 与 light 对称，token 联动 + opacity:1 */
  color: var(--settings-muted);
  opacity: 1;
}
:root[data-theme="dark"] .settings-row + .settings-row {
  border-top-color: rgba(60, 60, 60, 0.5);
}
:root[data-theme="dark"] .settings-row-icon {
  background: rgba(30, 30, 30, 0.92);
}
:root[data-theme="dark"] .settings-inline-panel {
  background: rgba(18, 18, 18, 0.88);
}
:root[data-theme="dark"] .settings-two-col .settings-stat-card {
  border-color: rgba(60, 60, 60, 0.5);
}
:root[data-theme="dark"] .settings-meter {
  background: rgba(42, 42, 42, 0.88);
}
:root[data-theme="dark"] .settings-secondary-btn {
  border-color: rgba(80, 80, 80, 0.5);
  background: rgba(30, 30, 30, 0.88);
}
:root[data-theme="dark"] .settings-cap-chip {
  border-color: rgba(60, 60, 60, 0.6);
  background: rgba(18, 18, 18, 0.96);
}

/* --- Left Panel (lp-*) ---
   旧极光暗档补丁已删：:root[data-theme] 特异性反杀 scrolls/settings-paper 的
   纸面栈，暗档抽屉被换回 0.92 半透玻璃致透底重影(0813 审计 A-5 实证)。
   暗档由纸面 token 翻转承担，此处不得再设 .lp-inner 背景。 */
:root[data-theme="dark"] .lp-search {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.08);
}
:root[data-theme="dark"] .lp-search:hover {
  background: rgba(255, 255, 255, 0.1);
}
:root[data-theme="dark"] .lp-search-input::placeholder {
  color: rgba(255, 255, 255, 0.35);
}
:root[data-theme="dark"] .lp-action-btn {
  border-color: rgba(255, 255, 255, 0.1);
  background: rgba(30, 30, 30, 0.8);
}
:root[data-theme="dark"] .lp-action-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.15);
}
:root[data-theme="dark"] .lp-section-title {
  color: rgba(255, 255, 255, 0.4);
}
:root[data-theme="dark"] .lp-icon-btn {
  color: rgba(255, 255, 255, 0.4);
}
:root[data-theme="dark"] .lp-icon-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.7);
}
:root[data-theme="dark"] .lp-doc-row {
  color: rgba(255, 255, 255, 0.7);
}
:root[data-theme="dark"] .lp-chat-row {
  color: rgba(255, 255, 255, 0.55);
}
:root[data-theme="dark"] .lp-chat-row:hover {
  background: rgba(255, 255, 255, 0.06);
}
:root[data-theme="dark"] .lp-archive-row {
  color: rgba(255, 255, 255, 0.45);
}
:root[data-theme="dark"] .lp-divider {
  background: rgba(255, 255, 255, 0.08);
}
:root[data-theme="dark"] .lp-empty-title {
  color: rgba(255, 255, 255, 0.5);
}
:root[data-theme="dark"] .lp-empty-desc {
  color: rgba(255, 255, 255, 0.35);
}
:root[data-theme="dark"] .lp-empty-hint {
  color: rgba(255, 255, 255, 0.35);
}
:root[data-theme="dark"] .lp-group-label {
  color: rgba(255, 255, 255, 0.35);
}
:root[data-theme="dark"] .lp-history-row {
  color: rgba(255, 255, 255, 0.7);
}
:root[data-theme="dark"] .lp-history-row:hover {
  background: rgba(255, 255, 255, 0.06);
}
:root[data-theme="dark"] .lp-history-row.active {
  background: rgba(255, 255, 255, 0.1);
}
:root[data-theme="dark"] .lp-user-profile:hover {
  background: rgba(255, 255, 255, 0.06);
}
:root[data-theme="dark"] .lp-user-email {
  color: rgba(255, 255, 255, 0.6);
}
:root[data-theme="dark"] .lp-gear-btn {
  color: rgba(255, 255, 255, 0.4);
}
:root[data-theme="dark"] .lp-gear-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.7);
}
:root[data-theme="dark"] .lp-collapse-header:hover {
  background: rgba(255, 255, 255, 0.04);
}

/* v0.9.44 FIX-1 + FIX-2 (plan 2026-04-28 §6):
   Settings 路由内隐藏底部齿轮（导航悖论：已在 settings 还看到入口齿轮）
   + 隐藏底部 Log in 按钮（与 Hub banner CTA 形成双重 Log in 撞车）。
   仅在 .settings-route 下隐藏，回到 chat/list view 时全局入口完整恢复。
   不删 DOM，CSS only，已登录用户的 lp-user-profile 不受影响。 */
.left-panel.settings-route .lp-gear-btn,
.left-panel.settings-route .lp-user-login-btn {
  display: none;
}

/* v0.9.44 PR2 (Codex r5 PASS + Gemini approved): post-login subpage slide-in.
   配合 main.js onAuthenticated 的 400ms cognitive buffer，
   让 Hub anchor → Usage/Account/Security 子页过渡有空间感（避免长瘦视口空间迷失）。
   16px 微移距 + opacity 是顶级 SaaS（Stripe/Linear）使用的高级感参数。
   只命中初次进入子页（template 重渲染），用户主动 back-to-list 后再进入会再触发动画 = OK。 */
.settings-subpage[data-anim-enter] {
  animation: slideInSubpage 250ms cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
}
@keyframes slideInSubpage {
  0% {
    opacity: 0;
    transform: translateX(16px);
  }
  100% {
    opacity: 1;
    transform: translateX(0);
  }
}
@media (prefers-reduced-motion: reduce) {
  .settings-subpage[data-anim-enter] {
    animation: none;
  }
}
