/* ============================================================================
   ui.css —— 全站统一 UI 设计系统（在页面自身样式之后引入，做"统一化 + 打磨"）
   目标：
     1) 统一设计令牌（圆角/阴影/过渡/焦点环），缺省变量自动回退，兼容所有页面；
     2) 统一滚动条、焦点态、选中色等"系统级"观感（深色主题下默认白滚动条极其刺眼）；
     3) 统一按钮/输入框/弹窗/卡片/表格的交互反馈与入场动效；
   原则：只做"视觉打磨"，不改动任何布局结构属性（display / position / 尺寸），
        以免破坏各页面既有排版。
   ========================================================================== */

/* ───────────────────────── 1. 设计令牌（含回退，页面缺啥补啥） ───────────────────────── */
:root {
  /* 页面已有 --bg/--panel/--border/--text/--muted/--accent，这里补齐缺失的层级色 */
  --ui-panel-2: var(--panel-2, var(--bg-elev, color-mix(in srgb, var(--panel, #141a26) 78%, var(--text, #e6edf3) 6%)));
  --ui-input-bg: var(--bg-input, var(--panel, #0e1320));

  /* 字体与排版：统一各页面的默认字形，但不覆盖页面已声明的具体字号 */
  --ui-font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  --ui-font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --ui-leading-tight: 1.25;
  --ui-leading-normal: 1.6;
  --ui-leading-relaxed: 1.75;

  --ui-radius-sm: 8px;
  --ui-radius: var(--radius, 12px);
  --ui-radius-lg: 16px;

  --ui-shadow-1: 0 1px 2px rgba(0, 0, 0, .28);
  --ui-shadow-2: var(--shadow, 0 10px 30px rgba(0, 0, 0, .4));
  --ui-shadow-3: 0 24px 70px rgba(0, 0, 0, .55);

  --ui-ring: 0 0 0 3px rgba(79, 140, 255, .28);
  --ui-accent: var(--accent, #4f8cff);
  --ui-border: var(--border, #232b3a);
  --ui-muted-strong: color-mix(in srgb, var(--muted, #8b97a7) 78%, var(--text, #e6edf3) 22%);
  --ui-accent-soft: color-mix(in srgb, var(--ui-accent) 12%, transparent);
  --ui-accent-border: color-mix(in srgb, var(--ui-accent) 45%, var(--ui-border));

  --ui-trans: .16s cubic-bezier(.4, 0, .2, 1);
  --ui-trans-slow: .24s cubic-bezier(.2, .8, .3, 1);

  /* 液态玻璃：半透明底色、边缘高光、漫反射阴影与流体缓动 */
  --ui-glass-bg: color-mix(in srgb, var(--ui-surface-2, var(--panel, #171a23)) 76%, transparent);
  --ui-glass-bg-strong: color-mix(in srgb, var(--ui-surface-2, var(--panel, #171a23)) 90%, transparent);
  --ui-glass-border: color-mix(in srgb, var(--ui-text, #e6edf3) 14%, var(--ui-border));
  --ui-glass-highlight: linear-gradient(155deg, rgba(255, 255, 255, .14), rgba(255, 255, 255, .035) 42%, transparent 68%);
  --ui-glass-shadow: inset 0 1px 0 rgba(255, 255, 255, .085), 0 18px 48px rgba(0, 0, 0, .26);
  --ui-glass-blur: blur(16px) saturate(140%);
  --ui-glow: color-mix(in srgb, var(--ui-accent) 24%, transparent);
  --ui-ease-liquid: cubic-bezier(.22, .9, .26, 1);
  --ui-trans-liquid: .28s var(--ui-ease-liquid);
}

/* 基础排版：只统一字形/行高/渲染质量，不改任何页面布局尺寸 */
body {
  font-family: var(--ui-font-sans);
  line-height: var(--ui-leading-normal);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
h1, h2, h3, h4 { line-height: var(--ui-leading-tight); letter-spacing: -.01em; }
h1, h2 { text-wrap: balance; }
p { text-wrap: pretty; }

/* 选中文字：跟随主题色，避免系统默认蓝与主题冲突 */
::selection { background: color-mix(in srgb, var(--ui-accent) 34%, transparent); }

/* ───────────────────────── 2. 滚动条（全站统一：细、半透明、悬浮加深） ───────────────────────── */
* { scrollbar-width: thin; scrollbar-color: var(--ui-border) transparent; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--ui-border);
  background-clip: content-box;
  border: 2px solid transparent;
  border-radius: 999px;
}
::-webkit-scrollbar-thumb:hover { background: color-mix(in srgb, var(--muted, #8b97a7) 70%, transparent); background-clip: content-box; }
::-webkit-scrollbar-corner { background: transparent; }

/* ───────────────────────── 3. 焦点态（键盘可达性 + 观感统一） ───────────────────────── */
:focus:not(:focus-visible) { outline: none; }
:focus-visible { outline: 2px solid var(--ui-accent); outline-offset: 2px; }
button:focus-visible, .btn:focus-visible, a.btn:focus-visible, .cbtn:focus-visible {
  outline: none;
  border-color: var(--ui-accent);
  box-shadow: var(--ui-ring);
}
.switch:focus-within .slider, .tool-toggle:focus-visible { box-shadow: var(--ui-ring); }

input, select, textarea {
  font-family: inherit;
  transition: border-color var(--ui-trans), box-shadow var(--ui-trans), background var(--ui-trans);
}
input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: none;
  border-color: var(--ui-accent) !important;
  box-shadow: var(--ui-ring);
}
input::placeholder, textarea::placeholder { color: color-mix(in srgb, var(--muted, #8b97a7) 85%, transparent); }

/* ───────────────────────── 4. 按钮（统一过渡 / 悬浮 / 按下 / 禁用） ───────────────────────── */
button, .btn, a.btn {
  font-family: inherit;
  transition: background var(--ui-trans), border-color var(--ui-trans), color var(--ui-trans),
              transform var(--ui-trans), box-shadow var(--ui-trans), filter var(--ui-trans);
}
button:not(:disabled):not([disabled]):hover, .btn:not(:disabled):hover { filter: brightness(1.09); }
button:not(:disabled):not([disabled]):active, .btn:not(:disabled):active { transform: translateY(1px); filter: brightness(.97); }
button:disabled, .btn:disabled, button[disabled] { opacity: .5; cursor: not-allowed; filter: none; }

.btn.primary, button.primary { box-shadow: var(--ui-shadow-1); }
.btn.primary:not(:disabled):hover, button.primary:not(:disabled):hover {
  box-shadow: 0 8px 20px color-mix(in srgb, var(--ui-accent) 34%, transparent);
}

/* ───────────────────────── 5. 弹窗 / 抽屉：统一背景虚化、圆角阴影、入场动效 ───────────────────────── */
.modal, .modal-overlay {
  -webkit-backdrop-filter: blur(6px) saturate(1.15);
  backdrop-filter: blur(6px) saturate(1.15);
}
/* index.html：<div class="modal" hidden>；显示时去掉 hidden */
.modal:not([hidden]) .modal-box { animation: ui-pop var(--ui-trans-slow); }
/* mobile.html：.modal.open > .sheet（底部抽屉，从下往上） */
.modal.open .sheet { animation: ui-sheet-up var(--ui-trans-slow); }
/* workflow_editor.html / workflow_chat.html：.modal-overlay.visible > .modal-box */
.modal-overlay.visible .modal-box { animation: ui-pop var(--ui-trans-slow); }

@keyframes ui-pop {
  from { opacity: 0; transform: translateY(10px) scale(.985); }
  to   { opacity: 1; transform: none; }
}
@keyframes ui-sheet-up {
  from { transform: translateY(100%); }
  to   { transform: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}

/* 弹窗内标题：统一间距与字重 */
.modal-box > h3:first-child, .sheet > h3:first-child { letter-spacing: .01em; }

/* 标准弹窗三段式（供需要"头/体/脚固定、仅中间滚动"的弹窗使用） */
.ui-dialog { display: flex; flex-direction: column; overflow: hidden; }
.ui-dialog-head { flex: 0 0 auto; }
.ui-dialog-body { flex: 1; min-height: 0; overflow-y: auto; padding-right: 4px; }
.ui-dialog-foot {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 10px;
  padding-top: 14px;
  margin-top: 14px;
  border-top: 1px solid var(--ui-border);
}

/* ───────────────────────── 6. 卡片 / 列表行：统一圆角与悬浮反馈 ───────────────────────── */
.card, .item, .expert-card, .tool-card, .bubble, .test-msg .bubble {
  transition: background var(--ui-trans), border-color var(--ui-trans), box-shadow var(--ui-trans);
}
.item:hover, .expert-card:hover, .tool-card:hover { border-color: color-mix(in srgb, var(--ui-accent) 35%, var(--ui-border)); }
.bubble { box-shadow: var(--ui-shadow-1); }
.msg.user .bubble { border-color: var(--ui-accent-border); }
.bubble pre { box-shadow: inset 0 1px 0 rgba(255, 255, 255, .035); }

/* ───────────────────────── 7. 表格 ───────────────────────── */
table { font-variant-numeric: tabular-nums; }
th { letter-spacing: .02em; }
tbody tr { transition: background var(--ui-trans); }
tbody tr:hover { background: color-mix(in srgb, var(--panel, #141a26) 65%, transparent); }

/* ───────────────────────── 8. 代码块 / 等宽文本 ───────────────────────── */
pre, code, kbd, samp { font-variant-ligatures: none; }
pre {
  border-radius: var(--ui-radius-sm);
  border: 1px solid var(--ui-border);
  background: var(--ui-input-bg);
}

/* ───────────────────────── 9. 徽标 / 标签：统一圆角与内距 ───────────────────────── */
.chip, .pill, .badge, .tag, .expert-tag, .cap {
  border-radius: 999px;
  transition: background var(--ui-trans), color var(--ui-trans), border-color var(--ui-trans);
}

/* ───────────────────────── 10. 主题切换时的整体过渡（避免生硬闪变） ───────────────────────── */
html { color-scheme: dark; }
html[data-theme="light"] { color-scheme: light; }
body { transition: background var(--ui-trans-slow), color var(--ui-trans-slow); }

/* ───────────────────────── 11. 页面级打磨（仅加过渡/悬浮反馈，不改布局） ───────────────────────── */

/* 增强功能中心 / 侧边导航 */
.nav a { transition: background var(--ui-trans), color var(--ui-trans); }

/* 工作流编排器 & 工作流对话：节点模板、标签页、画布节点 */
.node-template {
  transition: background var(--ui-trans), border-color var(--ui-trans), transform var(--ui-trans);
}
.node-template:hover {
  transform: translateX(2px);
  background: color-mix(in srgb, var(--ui-accent) 9%, var(--ui-panel-2));
}
.right-tabs button { transition: color var(--ui-trans), border-color var(--ui-trans), background var(--ui-trans); }
.right-tabs button:hover { background: color-mix(in srgb, var(--ui-accent) 8%, transparent); }
.wf-node { transition: border-color var(--ui-trans), box-shadow var(--ui-trans); }
.wf-node:hover { box-shadow: 0 10px 28px rgba(0, 0, 0, .4); }
.modal-item { transition: background var(--ui-trans); }

/* 移动端：底部抽屉与菜单行 */
.sheet { box-shadow: 0 -18px 50px rgba(0, 0, 0, .5); }
.sheet-row { transition: background var(--ui-trans); }
.sheet-row:active { background: color-mix(in srgb, var(--ui-accent) 12%, transparent); }
.sheet-btn { transition: filter var(--ui-trans), transform var(--ui-trans); }
.sheet-btn:active { transform: translateY(1px); }

/* 分享页：阅读体验 */
.wrap { line-height: 1.8; }

/* 12. 弹窗内容归一化 */
.modal-box { box-shadow: var(--ui-shadow-3); }
.modal-box label { display: block; font-size: 12px; color: var(--muted); margin: 12px 0 5px; }
.modal-box input:not([type="checkbox"]):not([type="radio"]):not([type="file"]) { box-sizing: border-box; padding: 8px 10px; min-height: 36px; }
.modal-box textarea { box-sizing: border-box; padding: 8px 10px; min-height: 72px; }
.modal-box .btn, .modal-box button { min-height: 32px; }
.modal-actions { flex-wrap: wrap; align-items: center; }
.modal-actions .btn, .modal-actions button { min-width: 76px; }

/* 开关：禁止文字被挤成竖排；表格 / 代码块统一观感 */
.switch { flex: 0 0 auto; }
.switch-label { white-space: nowrap; }
.modal-box table { width: 100%; }
.modal-box pre { max-height: 42vh; overflow: auto; }
.modal-box .list { max-height: 46vh; overflow-y: auto; }

/* 13. 下拉菜单 / 欢迎区：降低密集工具栏的视觉噪音，强化首屏层次 */
.ui-menu-btn { font-weight: 600; }
.ui-menu-panel {
  border-radius: var(--ui-radius);
  background: color-mix(in srgb, var(--ui-panel-2) 94%, var(--ui-accent) 6%);
  box-shadow: var(--ui-shadow-2);
}
.ui-menu-panel .btn, .ui-menu-panel a.btn { border-color: transparent; background: transparent; }
.ui-menu-panel .btn:not(:disabled):hover, .ui-menu-panel a.btn:hover {
  border-color: var(--ui-accent-border);
  background: var(--ui-accent-soft);
}
.welcome h1 { letter-spacing: -.02em; }
.welcome p { color: var(--ui-muted-strong); line-height: var(--ui-leading-relaxed); }

/* 14. 首屏推荐卡片：把能力标签变成可操作的入口 */
.prompt-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  max-width: 720px;
  margin: 22px auto 0;
}
.prompt-grid .prompt-card,
.quick-actions .prompt-card {
  width: 100%;
  border: 1px solid var(--ui-border);
  border-radius: var(--ui-radius);
  background: color-mix(in srgb, var(--ui-panel-2) 88%, var(--ui-accent) 12%);
  color: var(--text);
  font: inherit;
  cursor: pointer;
  transition: border-color var(--ui-trans), background var(--ui-trans), transform var(--ui-trans), box-shadow var(--ui-trans);
}
.prompt-grid .prompt-card {
  display: block;
  text-align: left;
  padding: 12px 14px;
}
.prompt-grid .prompt-card:hover,
.quick-actions .prompt-card:hover {
  border-color: var(--ui-accent-border);
  background: color-mix(in srgb, var(--ui-panel-2) 78%, var(--ui-accent) 22%);
  box-shadow: 0 8px 22px color-mix(in srgb, var(--ui-accent) 18%, transparent);
  transform: translateY(-1px);
}
.prompt-grid .prompt-card:active,
.quick-actions .prompt-card:active { transform: translateY(0); }
.prompt-icon { display: block; font-size: 18px; line-height: 1.2; margin-bottom: 6px; }
.prompt-title { display: block; font-size: 14px; font-weight: 600; }
.prompt-desc { display: block; margin-top: 3px; font-size: 12px; line-height: 1.5; color: var(--ui-muted-strong); }
.quick-actions .prompt-card {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 10px 12px;
  text-align: center;
  font-size: 13px;
  line-height: 1.45;
}

/* 15. 聊天阅读体验：Markdown / 工具块 / 代码操作按钮 */
.bubble > :first-child { margin-top: 0; }
.bubble > :last-child { margin-bottom: 0; }
.bubble p,
.bubble ul,
.bubble ol,
.bubble blockquote,
.bubble table,
.bubble pre { margin: .75em 0; }
.bubble h1 { font-size: 1.45em; margin: 1.1em 0 .5em; }
.bubble h2 { font-size: 1.25em; margin: 1em 0 .45em; padding-bottom: .3em; border-bottom: 1px solid var(--ui-border); }
.bubble h3 { font-size: 1.1em; margin: .9em 0 .4em; }
.bubble h4 { font-size: 1em; margin: .8em 0 .35em; color: var(--ui-muted-strong); }
.bubble ul, .bubble ol { padding-left: 1.5em; }
.bubble li + li { margin-top: .35em; }
.bubble blockquote {
  border-left: 3px solid var(--ui-accent);
  border-radius: 0 var(--ui-radius-sm) var(--ui-radius-sm) 0;
  background: var(--ui-accent-soft);
  color: var(--ui-muted-strong);
  padding: .5em .9em;
}
.bubble a { text-decoration-color: var(--ui-accent-border); text-underline-offset: 3px; }
.bubble table { display: block; max-width: 100%; overflow-x: auto; border-radius: var(--ui-radius-sm); }
.bubble th, .bubble td { padding: 7px 10px; }
.bubble th { background: color-mix(in srgb, var(--ui-panel-2) 82%, var(--text) 18%); }
.bubble img { max-width: 100%; border-radius: var(--ui-radius-sm); border: 1px solid var(--ui-border); }
.bubble hr { border: none; border-top: 1px solid var(--ui-border); margin: 1.2em 0; }
.bubble pre { padding: 12px 14px; }
.bubble p code, .bubble li code, .bubble blockquote code {
  border: 1px solid var(--ui-border-soft);
  border-radius: 6px;
  background: var(--ui-accent-soft);
  color: var(--text);
  padding: 1px 5px;
  font-size: .92em;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .08);
}
.tool-block { box-shadow: var(--ui-shadow-1); }
.tool-head { font-weight: 600; letter-spacing: .01em; }
.tool-block.open .tool-head {
  border-radius: var(--ui-radius-sm) var(--ui-radius-sm) 0 0;
  background: var(--ui-accent-soft);
  color: var(--ui-accent);
}
.think-block { line-height: var(--ui-leading-relaxed); }
.copy-btn, .run-btn {
  background: var(--panel) !important;
  color: var(--muted) !important;
  border: 1px solid var(--ui-border) !important;
  border-radius: var(--ui-radius-sm) !important;
  padding: 3px 9px !important;
  font: inherit !important;
  font-size: 12px !important;
  cursor: pointer;
}
.run-btn { color: var(--green) !important; border-color: var(--ui-accent-border) !important; }
.run-output {
  background: var(--ui-input-bg) !important;
  border: 1px solid var(--ui-border) !important;
  border-radius: var(--ui-radius-sm) !important;
  color: var(--text) !important;
  font-size: 12px !important;
}

/* 16. 品牌与一致性：SVG 图标、按钮节奏、亮色主题对比度 */
.ui-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.ui-icon {
  width: 16px; height: 16px; flex: 0 0 auto;
  fill: none; stroke: currentColor; stroke-width: 1.8;
  stroke-linecap: round; stroke-linejoin: round;
}
button.btn, a.btn, .icon-btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 32px; }
html[data-theme="light"] {
  --ui-shadow-1: 0 1px 2px rgba(15, 23, 42, .08);
  --ui-muted-strong: color-mix(in srgb, var(--muted, #66718a) 88%, #111827 12%);
  --ui-accent-soft: color-mix(in srgb, var(--ui-accent) 9%, #ffffff 91%);
  --ui-accent-border: color-mix(in srgb, var(--ui-accent) 38%, #cbd5e1);
}
html[data-theme="light"] .bubble { box-shadow: 0 1px 2px rgba(15, 23, 42, .06); }
html[data-theme="light"] .bubble pre { box-shadow: none; }

/* 17. 高对比度偏好：只增强边界与焦点，不改变主题本身 */
@media (prefers-contrast: more) {
  :root { --ui-border: color-mix(in srgb, var(--border, #232b3a) 65%, var(--text, #e6edf3) 35%); }
  .bubble, .modal-box, .ui-menu-panel, .sheet { border-color: var(--text); }
  :focus-visible { outline-width: 3px; }
}

@media (max-width: 560px) {
  .prompt-grid { grid-template-columns: 1fr; }
}

/* 18. 全站组件质感：把聊天页之外的页面也纳入同一套设计语言 */
:root {
  /* 字号阶梯：组件统一取这些值，页面特殊的 inline style 仍可覆盖 */
  --ui-text-xs: 12px;
  --ui-text-sm: 13px;
  --ui-text-md: 14px;
  --ui-text-lg: 16px;
  --ui-text-xl: 20px;

  --ui-space-1: 4px;
  --ui-space-2: 8px;
  --ui-space-3: 12px;
  --ui-space-4: 16px;
  --ui-space-5: 24px;

  --ui-surface-1: var(--bg, #0f1117);
  --ui-surface-2: var(--bg-elev, var(--panel, #171a23));
  --ui-surface-3: var(--ui-panel-2);
  --ui-border-soft: color-mix(in srgb, var(--ui-border) 72%, transparent);
  --ui-accent-2: var(--accent-2, color-mix(in srgb, var(--ui-accent) 68%, #a78bfa));
  --ui-on-accent: #fff;
  --ui-success: var(--green, #3fb950);
  --ui-warn: #d29922;
  --ui-danger: var(--red, #f85149);
  --ui-gradient: linear-gradient(135deg, var(--ui-accent), var(--ui-accent-2));
}

/* 页面标题与说明文字 */
h1, h2, h3, h4 { font-weight: 650; }
.wrap h1, .page-title { letter-spacing: -.02em; }
.sub, .muted, .hint, .desc, .empty-tip { color: var(--ui-muted-strong); }

/* 卡片 / 面板：统一的表面层级、圆角和阴影 */
.card, .cfg-card, .obs-card, .workflow-card, .graph-card, .panel {
  background: linear-gradient(180deg, color-mix(in srgb, var(--ui-surface-2) 96%, var(--text) 4%), var(--ui-surface-2));
  border: 1px solid var(--ui-border);
  border-radius: var(--ui-radius-lg);
  box-shadow: var(--ui-shadow-1);
  transition: border-color var(--ui-trans), box-shadow var(--ui-trans), background var(--ui-trans);
}
.card:hover, .cfg-card:hover, .obs-card:hover, .workflow-card:hover {
  border-color: var(--ui-accent-border);
  box-shadow: 0 12px 32px color-mix(in srgb, var(--ui-accent) 12%, transparent);
}
.card h2, .card h3, .panel h2, .panel h3 {
  font-size: var(--ui-text-md);
  font-weight: 650;
  letter-spacing: .01em;
}

/* 按钮：统一圆角、字重与按钮节奏 */
button, .btn, a.btn, .icon-btn, .cbtn, .sheet-btn {
  border-radius: var(--ui-radius);
  font-family: inherit;
  font-weight: 500;
}
button.btn, a.btn, .icon-btn, .cbtn, .sheet-btn { min-height: 34px; padding: 8px 12px; }
.btn.primary, button.primary, .sheet-btn:not(.secondary) {
  background: var(--ui-gradient);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 8px 20px color-mix(in srgb, var(--ui-accent) 28%, transparent);
}
button.ghost, .btn.ghost, .sheet-btn.secondary {
  background: var(--ui-surface-3);
  border: 1px solid var(--ui-border);
  color: var(--text);
}

/* 表单：.input 类在多个页面大量使用但此前没有统一样式 */
input.input, select.input, textarea.input,
.model-input, .sheet-select, .cs-trigger {
  background: var(--ui-input-bg);
  border: 1px solid var(--ui-border-soft);
  border-radius: var(--ui-radius);
  color: var(--text);
  font-family: inherit;
  font-size: var(--ui-text-md);
  min-height: 38px;
  padding: 9px 12px;
  transition: border-color var(--ui-trans), box-shadow var(--ui-trans), background var(--ui-trans);
}
input.input:focus, select.input:focus, textarea.input:focus,
.model-input:focus, .sheet-select:focus, .cs-trigger:focus {
  outline: none;
  border-color: var(--ui-accent);
  box-shadow: var(--ui-ring);
}
label { color: var(--ui-muted-strong); font-size: var(--ui-text-xs); font-weight: 500; }
.bar label, .field label { font-weight: 600; letter-spacing: .02em; }

/* 表格：更清晰的斑马纹与表头 */
table { border-radius: var(--ui-radius); overflow: hidden; }
th {
  background: color-mix(in srgb, var(--ui-surface-3) 82%, var(--text) 18%);
  color: var(--ui-muted-strong);
  font-size: var(--ui-text-xs);
  font-weight: 650;
  letter-spacing: .06em;
  text-transform: uppercase;
}
th, td { padding: 10px 12px; }
tbody tr:nth-child(even) { background: color-mix(in srgb, var(--ui-surface-3) 45%, transparent); }

/* 标签 / 徽章 / 状态色 */
.chip, .pill, .badge, .tag, .file-chip, .cfg-badge, .expert-tag, .cap {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border: 1px solid var(--ui-border-soft);
  border-radius: 999px;
  background: var(--ui-surface-3);
  color: var(--ui-muted-strong);
  font-size: var(--ui-text-xs);
  line-height: 1.5;
}
.chip.active, .pill.active, .badge.active, .tag.active {
  border-color: var(--ui-accent-border);
  background: var(--ui-accent-soft);
  color: var(--ui-accent);
}
.pill.h { color: var(--ui-danger); border-color: color-mix(in srgb, var(--ui-danger) 35%, transparent); background: color-mix(in srgb, var(--ui-danger) 12%, transparent); }
.pill.m { color: var(--ui-warn); border-color: color-mix(in srgb, var(--ui-warn) 35%, transparent); background: color-mix(in srgb, var(--ui-warn) 12%, transparent); }
.pill.l { color: var(--ui-success); border-color: color-mix(in srgb, var(--ui-success) 35%, transparent); background: color-mix(in srgb, var(--ui-success) 12%, transparent); }

/* 导航 / 会话列表 / 标签页 */
.nav a, .wf-item, .session-item, .list .item {
  border-radius: var(--ui-radius);
  padding: 9px 12px;
  transition: background var(--ui-trans), color var(--ui-trans), border-color var(--ui-trans);
}
.nav a:hover, .wf-item:hover, .session-item:hover, .list .item:hover {
  background: var(--ui-accent-soft);
  color: var(--text);
}
.nav a.active, .wf-item.active, .session-item.active, .list .item.active {
  border-color: var(--ui-accent-border);
  background: var(--ui-accent-soft);
  color: var(--ui-accent);
}
.session-item .s-title { font-weight: 500; }
.right-tabs button, .tabs button, .tab-btn {
  border-radius: var(--ui-radius-sm) var(--ui-radius-sm) 0 0;
  padding: 9px 14px;
  transition: color var(--ui-trans), background var(--ui-trans), border-color var(--ui-trans);
}
.right-tabs button.active, .tabs button.active, .tab-btn.active {
  border-bottom-color: var(--ui-accent);
  background: var(--ui-accent-soft);
  color: var(--ui-accent);
}

/* 空状态 / Toast / 头像 / 开关 */
.empty-state, .empty-tip, .wf-empty, .tool-empty, .state, .test-empty {
  padding: 28px 18px;
  border: 1px dashed var(--ui-border);
  border-radius: var(--ui-radius-lg);
  background: color-mix(in srgb, var(--ui-surface-3) 45%, transparent);
  color: var(--ui-muted-strong);
  text-align: center;
}
.toast {
  border: 1px solid var(--ui-accent-border);
  border-radius: var(--ui-radius);
  background: var(--ui-surface-3);
  color: var(--text);
  box-shadow: var(--ui-shadow-2);
  padding: 10px 14px;
  animation: ui-pop var(--ui-trans-slow);
}
.avatar, .ava {
  border: 1px solid var(--ui-accent-border);
  background: var(--ui-accent-soft);
  color: var(--ui-accent);
  font-weight: 600;
}
.slider, .tool-toggle {
  border: 1px solid var(--ui-border-soft);
  background: var(--ui-border);
}
.slider::before, .tool-toggle::after { background: #fff; box-shadow: var(--ui-shadow-1); }

/* 工具栏：标签更透气，分隔更柔和 */
.bar, .topbar, .header { border-color: var(--ui-border-soft); }
.bar-group { gap: var(--ui-space-2); }

/* 代码块：全站统一的等宽文本表面 */
pre {
  color: var(--text);
  font-family: var(--ui-font-mono);
  font-size: var(--ui-text-sm);
  line-height: var(--ui-leading-normal);
}

/* ───────────────────────── 19. 液态玻璃：透亮表面 + 边缘高光 + 流体过渡 ───────────────────────── */
/* 只改背景、边框、阴影、滤镜与动效，不改 display / position / 尺寸等布局属性 */
.ui-glass,
.card, .cfg-card, .obs-card, .workflow-card, .graph-card, .panel,
.modal-box, .ui-menu-panel, .toast,
.prompt-grid .prompt-card, .quick-actions .prompt-card,
.empty-state, .empty-tip, .wf-empty, .tool-empty, .state, .test-empty {
  background:
    var(--ui-glass-highlight),
    radial-gradient(130% 100% at 8% -20%, color-mix(in srgb, var(--ui-accent) 14%, transparent), transparent 62%),
    var(--ui-glass-bg-strong);
  background-size: 180% 180%, 160% 160%, auto;
  background-position: 0% 0%, 0% 0%, 0 0;
  border-color: var(--ui-glass-border);
  box-shadow: var(--ui-glass-shadow);
  -webkit-backdrop-filter: var(--ui-glass-blur);
  backdrop-filter: var(--ui-glass-blur);
  transition: background-position var(--ui-trans-liquid), border-color var(--ui-trans),
              box-shadow var(--ui-trans), transform var(--ui-trans);
}
.ui-glass:hover,
.card:hover, .cfg-card:hover, .obs-card:hover, .workflow-card:hover, .graph-card:hover,
.prompt-grid .prompt-card:hover, .quick-actions .prompt-card:hover {
  background-position: 100% 0%, 100% 0%, 0 0;
  border-color: color-mix(in srgb, var(--ui-accent) 52%, var(--ui-border));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .12), 0 18px 44px var(--ui-glow);
}

/* 聊天气泡与工具块：保留玻璃高光，但不加 backdrop-filter，避免长列表掉帧 */
.bubble, .test-msg .bubble, .tool-block {
  background:
    linear-gradient(155deg, rgba(255, 255, 255, .075), transparent 46%),
    radial-gradient(120% 100% at 0% 0%, color-mix(in srgb, var(--ui-accent) 9%, transparent), transparent 58%),
    var(--ui-glass-bg);
  border-color: var(--ui-glass-border);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .07), 0 10px 28px rgba(0, 0, 0, .18);
}
.msg.user .bubble { border-color: var(--ui-accent-border); }

/* 主按钮：让高光随悬停流过，形成“活”的折射感 */
.btn.primary, button.primary, .sheet-btn:not(.secondary) {
  background:
    linear-gradient(115deg, rgba(255, 255, 255, .26), transparent 32%, rgba(255, 255, 255, .16) 68%, transparent),
    var(--ui-gradient);
  background-size: 220% 100%, auto;
  background-position: 0% 0%, 0 0;
  color: var(--ui-on-accent);
  border-color: transparent;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .32), 0 8px 22px color-mix(in srgb, var(--ui-accent) 34%, transparent);
  transition: background-position var(--ui-trans-liquid), transform var(--ui-trans),
              box-shadow var(--ui-trans), filter var(--ui-trans);
}
.btn.primary:not(:disabled):hover,
button.primary:not(:disabled):hover,
.sheet-btn:not(.secondary):not(:disabled):hover {
  background-position: 100% 0%, 0 0;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .4), 0 12px 28px color-mix(in srgb, var(--ui-accent) 44%, transparent);
}
button.ghost, .btn.ghost, .sheet-btn.secondary {
  background: var(--ui-glass-highlight), var(--ui-glass-bg);
  border-color: var(--ui-glass-border);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .06);
}

/* 表单、标签、导航：轻量玻璃化，保持文字对比度 */
input.input, select.input, textarea.input,
.model-input, .sheet-select, .cs-trigger,
.modal-box input:not([type="checkbox"]):not([type="radio"]):not([type="file"]) {
  background: var(--ui-glass-highlight), var(--ui-glass-bg);
  border-color: var(--ui-glass-border);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .06);
}
.chip, .pill, .badge, .tag, .file-chip, .cfg-badge, .expert-tag, .cap {
  background: var(--ui-glass-highlight), var(--ui-glass-bg);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .07);
}
.chip.active, .pill.active, .badge.active, .tag.active,
.nav a.active, .wf-item.active, .session-item.active, .list .item.active,
.right-tabs button.active, .tabs button.active, .tab-btn.active {
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .1), 0 6px 18px color-mix(in srgb, var(--ui-accent) 16%, transparent);
}

/* 弹窗 / Toast：用更顺的曲线承接玻璃层次 */
@keyframes ui-liquid-in {
  from { opacity: 0; transform: translateY(14px) scale(.97); }
  to   { opacity: 1; transform: none; }
}
.modal:not([hidden]) .modal-box,
.modal-overlay.visible .modal-box,
.toast { animation: ui-liquid-in var(--ui-trans-liquid) var(--ui-ease-liquid); }
.modal.open .sheet { animation: ui-sheet-up var(--ui-trans-liquid) var(--ui-ease-liquid); }

/* 浅色主题：用更白的玻璃与更轻的阴影，避免脏灰 */
html[data-theme="light"] {
  --ui-glass-bg: rgba(255, 255, 255, .74);
  --ui-glass-bg-strong: rgba(255, 255, 255, .9);
  --ui-glass-border: rgba(15, 23, 42, .12);
  --ui-glass-highlight: linear-gradient(155deg, rgba(255, 255, 255, .95), rgba(255, 255, 255, .28) 46%, transparent 72%);
  --ui-glass-shadow: inset 0 1px 0 rgba(255, 255, 255, .95), 0 14px 36px rgba(15, 23, 42, .12);
}
html[data-theme="light"] .bubble,
html[data-theme="light"] .test-msg .bubble,
html[data-theme="light"] .tool-block { box-shadow: 0 1px 2px rgba(15, 23, 42, .06); }

/* 高对比度偏好：关掉透明与模糊，保证边界清晰 */
@media (prefers-contrast: more) {
  .ui-glass,
  .card, .cfg-card, .obs-card, .workflow-card, .graph-card, .panel,
  .modal-box, .ui-menu-panel, .toast,
  .prompt-grid .prompt-card, .quick-actions .prompt-card,
  .empty-state, .empty-tip, .wf-empty, .tool-empty, .state, .test-empty,
  .bubble, .test-msg .bubble, .tool-block,
  input.input, select.input, textarea.input, .model-input, .sheet-select, .cs-trigger {
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
    background: var(--ui-surface-2);
    box-shadow: none;
  }
}

/* 减少透明偏好：保留结构层次，关掉模糊与半透明，兼顾低性能设备 */
@media (prefers-reduced-transparency: reduce) {
  .ui-glass,
  .card, .cfg-card, .obs-card, .workflow-card, .graph-card, .panel,
  .modal-box, .ui-menu-panel, .toast,
  .prompt-grid .prompt-card, .quick-actions .prompt-card,
  .empty-state, .empty-tip, .wf-empty, .tool-empty, .state, .test-empty,
  input.input, select.input, textarea.input, .model-input, .sheet-select, .cs-trigger {
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
    background: var(--ui-surface-2);
    border-color: var(--ui-border);
    box-shadow: var(--ui-shadow-1);
  }
}

/* 触屏设备：避免 hover 态被浏览器粘住后持续位移 */
@media (hover: none) {
  .card:hover, .cfg-card:hover, .obs-card:hover, .workflow-card:hover, .graph-card:hover,
  .prompt-grid .prompt-card:hover, .quick-actions .prompt-card:hover { transform: none; }
}

/* ───────────────────────── 20. 走查修正：工具栏可读性与环境光层 ───────────────────────── */
/* 顶栏/工具栏按钮不被 flex 压缩，避免窄屏把文字挤成竖排 */
.header .btn, .header button, .header a.btn,
.topbar .btn, .topbar button, .topbar a.btn,
.bar .btn, .bar button, .bar a.btn {
  flex: 0 0 auto;
  white-space: nowrap;
}
.header h1 { flex: 0 0 auto; white-space: nowrap; }
.header { overflow-x: auto; scrollbar-width: none; }
.header::-webkit-scrollbar { display: none; }
@media (max-width: 820px) {
  .header h1 { font-size: 14px; }
}

/* 窄屏工具栏保留单行横向滚动，只隐藏滚动条，避免首屏被多行工具挤占 */
@media (max-width: 820px) {
  .bar { scrollbar-width: none; }
  .bar::-webkit-scrollbar { height: 0; display: none; }
}

/* 轻微环境光：让 backdrop-filter 有可折射的底色层次 */
body {
  background-image:
    radial-gradient(980px 560px at 8% -6%, color-mix(in srgb, var(--ui-accent) 9%, transparent), transparent 62%),
    radial-gradient(820px 480px at 96% 6%, color-mix(in srgb, var(--ui-accent-2) 8%, transparent), transparent 60%);
  background-repeat: no-repeat;
}
html[data-theme="light"] body {
  background-image:
    radial-gradient(980px 560px at 8% -6%, rgba(79, 140, 255, .10), transparent 62%),
    radial-gradient(820px 480px at 96% 6%, rgba(167, 139, 250, .08), transparent 60%);
}
.chatbox {
  background-image:
    radial-gradient(760px 420px at 50% -8%, color-mix(in srgb, var(--ui-accent) 16%, transparent), transparent 68%),
    radial-gradient(680px 420px at 92% 12%, color-mix(in srgb, var(--ui-accent-2) 12%, transparent), transparent 62%),
    radial-gradient(620px 380px at 4% 46%, color-mix(in srgb, var(--ui-accent) 8%, transparent), transparent 64%);
}

/* ───────────────────────── 21. Apple 风格：系统蓝 + 中性材质 + 连续圆角 ───────────────────────── */
:root {
  --ui-font-sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  --ui-accent: #0a84ff;
  --ui-accent-2: #5e5ce6;
  --ui-on-accent: #fff;
  --ui-gradient: linear-gradient(135deg, #0a84ff, #5e5ce6);
  --ui-border: rgba(255, 255, 255, .12);
  --ui-border-soft: rgba(255, 255, 255, .08);
  --ui-accent-soft: rgba(10, 132, 255, .16);
  --ui-accent-border: rgba(10, 132, 255, .5);
  --ui-glass-bg: rgba(28, 28, 30, .72);
  --ui-glass-bg-strong: rgba(44, 44, 46, .82);
  --ui-glass-border: rgba(255, 255, 255, .14);
  --ui-glass-highlight: linear-gradient(180deg, rgba(255, 255, 255, .10), rgba(255, 255, 255, .02) 42%, transparent 70%);
  --ui-glass-shadow: inset 0 1px 0 rgba(255, 255, 255, .10), 0 12px 40px rgba(0, 0, 0, .42);
  --ui-glass-blur: blur(20px) saturate(180%);
  --ui-ring: 0 0 0 4px rgba(10, 132, 255, .32);
  --ui-radius: 12px;
  --ui-radius-lg: 20px;
  --ui-segment-active: rgba(255, 255, 255, .16);
  --ui-ease-apple: cubic-bezier(.32, .72, 0, 1);
  --ui-trans: .2s var(--ui-ease-apple);
  --ui-trans-slow: .34s var(--ui-ease-apple);
  --ui-trans-liquid: .34s var(--ui-ease-apple);
}

html[data-theme="light"] {
  --ui-border: rgba(0, 0, 0, .10);
  --ui-border-soft: rgba(0, 0, 0, .07);
  --ui-glass-bg: rgba(255, 255, 255, .72);
  --ui-glass-bg-strong: rgba(255, 255, 255, .88);
  --ui-glass-border: rgba(0, 0, 0, .10);
  --ui-glass-highlight: linear-gradient(180deg, rgba(255, 255, 255, .92), rgba(255, 255, 255, .24) 46%, transparent 72%);
  --ui-glass-shadow: inset 0 1px 0 rgba(255, 255, 255, .96), 0 8px 30px rgba(0, 0, 0, .10);
  --ui-segment-active: rgba(255, 255, 255, .96);
}

/* 系统字体与大标题节奏 */
body { letter-spacing: -.01em; }
h1 { font-weight: 700; letter-spacing: -.03em; }
h2 { font-weight: 650; letter-spacing: -.02em; }

/* 毛玻璃工具栏 / 导航栏：细分隔线 + 系统材质 */
.topbar, .bar, .header {
  background: var(--ui-glass-bg-strong);
  border-bottom-color: var(--ui-glass-border);
  -webkit-backdrop-filter: var(--ui-glass-blur);
  backdrop-filter: var(--ui-glass-blur);
}

/* 连续圆角：卡片更圆润，按钮保持克制的系统圆角 */
.card, .cfg-card, .obs-card, .workflow-card, .graph-card, .panel,
.modal-box, .ui-menu-panel, .toast,
.prompt-grid .prompt-card, .quick-actions .prompt-card,
.empty-state, .empty-tip, .wf-empty, .tool-empty, .state, .test-empty {
  border-radius: var(--ui-radius-lg);
}

/* 分段控件：选中项像 iOS 的白色滑块 */
.right-tabs button.active, .tabs button.active, .tab-btn.active {
  border-radius: 999px;
  border-bottom-color: transparent;
  background: var(--ui-segment-active);
  color: var(--text);
  box-shadow: 0 1px 4px rgba(0, 0, 0, .22);
}

/* 系统开关：完整胶囊轨道 + 圆形滑块 */
.slider, .tool-toggle { border-radius: 999px; }
.slider::before, .tool-toggle::after { border-radius: 50%; }

/* ───────────────────────── 22. 配色重做：中性石墨 + Apple 系统蓝 ───────────────────────── */
:root {
  --bg: #0b0c0f;
  --bg-elev: #16171a;
  --panel: #16171a;
  --panel-2: #1d1f22;
  --text: #f5f5f7;
  --muted: #a1a1a6;
  --border: rgba(255, 255, 255, .08);
  --accent: #0a84ff;
  --green: #30d158;
  --yellow: #ffd60a;
  --red: #ff453a;

  --ui-accent: #0a84ff;
  --ui-accent-2: #64d2ff;
  --ui-gradient: linear-gradient(180deg, #0a84ff, #0070e0);
  --ui-border: rgba(255, 255, 255, .08);
  --ui-border-soft: rgba(255, 255, 255, .06);
  --ui-accent-soft: rgba(10, 132, 255, .14);
  --ui-accent-border: rgba(10, 132, 255, .46);
  --ui-glass-bg: rgba(22, 23, 26, .78);
  --ui-glass-bg-strong: rgba(29, 31, 34, .88);
  --ui-glass-border: rgba(255, 255, 255, .10);
  --ui-glass-highlight: linear-gradient(180deg, rgba(255, 255, 255, .08), rgba(255, 255, 255, .015) 44%, transparent 72%);
  --ui-glass-shadow: inset 0 1px 0 rgba(255, 255, 255, .08), 0 12px 38px rgba(0, 0, 0, .38);
  --ui-glass-blur: blur(20px) saturate(160%);
  --ui-success: #30d158;
  --ui-warn: #ffd60a;
  --ui-danger: #ff453a;
  --ui-segment-active: rgba(255, 255, 255, .14);
}

html[data-theme="light"] {
  --bg: #f5f5f7;
  --bg-elev: #ffffff;
  --panel: #ffffff;
  --panel-2: #f2f2f7;
  --text: #1d1d1f;
  --muted: #6e6e73;
  --border: rgba(0, 0, 0, .08);
  --ui-border: rgba(0, 0, 0, .08);
  --ui-border-soft: rgba(0, 0, 0, .06);
  --ui-glass-bg: rgba(255, 255, 255, .78);
  --ui-glass-bg-strong: rgba(255, 255, 255, .92);
  --ui-glass-border: rgba(0, 0, 0, .08);
  --ui-glass-highlight: linear-gradient(180deg, rgba(255, 255, 255, .95), rgba(255, 255, 255, .25) 46%, transparent 72%);
  --ui-glass-shadow: inset 0 1px 0 rgba(255, 255, 255, .98), 0 8px 28px rgba(0, 0, 0, .08);
  --ui-segment-active: rgba(255, 255, 255, .96);
}

body { background-color: var(--bg); color: var(--text); }
body {
  background-image:
    radial-gradient(900px 520px at 12% -8%, rgba(10, 132, 255, .07), transparent 62%),
    radial-gradient(760px 460px at 92% 4%, rgba(100, 210, 255, .05), transparent 60%);
}
html[data-theme="light"] body {
  background-image:
    radial-gradient(900px 520px at 12% -8%, rgba(0, 122, 255, .06), transparent 62%),
    radial-gradient(760px 460px at 92% 4%, rgba(100, 210, 255, .04), transparent 60%);
}
.chatbox {
  background-image:
    radial-gradient(720px 400px at 50% -8%, rgba(10, 132, 255, .10), transparent 68%),
    radial-gradient(620px 380px at 92% 12%, rgba(100, 210, 255, .06), transparent 62%);
}
html[data-theme="light"] .chatbox {
  background-image:
    radial-gradient(720px 400px at 50% -8%, rgba(0, 122, 255, .07), transparent 68%),
    radial-gradient(620px 380px at 92% 12%, rgba(100, 210, 255, .04), transparent 62%);
}

/* ───────────────────────── 23. 微调：真正的分段控件态 ───────────────────────── */
.tabs button, .right-tabs button, .tab-btn {
  background: transparent;
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 7px 14px;
  color: var(--ui-muted-strong);
  font: inherit;
  font-size: var(--ui-text-sm);
}
.tabs button:not(.active):hover,
.right-tabs button:not(.active):hover,
.tab-btn:not(.active):hover {
  background: var(--ui-accent-soft);
  color: var(--text);
}
.tabs button.active, .right-tabs button.active, .tab-btn.active {
  background: var(--ui-segment-active);
  border-color: var(--ui-glass-border);
  color: var(--text);
  box-shadow: 0 1px 4px rgba(0, 0, 0, .22);
}

/* ───────────────────────── 24. 下拉：原生 select 与自定义菜单统一 Apple 质感 ───────────────────────── */
select:not([multiple]) {
  -webkit-appearance: none;
  appearance: none;
  padding-right: 30px;
  background:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M3 4.5 6 7.5 9 4.5' fill='none' stroke='%23A1A1A6' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat right 10px center / 12px 12px,
    var(--ui-glass-highlight) no-repeat 0 0 / 180% 180%,
    var(--ui-glass-bg);
  color: var(--text);
  border: 1px solid var(--ui-glass-border);
  border-radius: var(--ui-radius);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .06);
  transition: border-color var(--ui-trans), box-shadow var(--ui-trans), filter var(--ui-trans);
}
select:not([multiple]):hover { border-color: var(--ui-accent-border); }
select:not([multiple]):focus-visible {
  outline: none;
  border-color: var(--ui-accent);
  box-shadow: var(--ui-ring);
}
select:not([multiple]) { color-scheme: dark; }
html[data-theme="light"] select:not([multiple]) { color-scheme: light; }
select:not([multiple]) option { background: var(--panel-2); color: var(--text); }
select:not([multiple]) option:checked { background: var(--ui-accent); color: #fff; }
select:not([multiple]) optgroup { background: var(--panel); color: var(--muted); font-style: normal; }

/* 自定义下拉面板：毛玻璃卡片 + 整行 hover 反馈 */
.ui-menu-panel {
  width: max-content;
  min-width: 0;
  max-width: min(320px, calc(100vw - 16px));
  border-radius: 16px;
  border: 1px solid var(--ui-glass-border);
  background: color-mix(in srgb, var(--ui-glass-bg-strong) 96%, var(--ui-accent) 4%);
  -webkit-backdrop-filter: var(--ui-glass-blur);
  backdrop-filter: var(--ui-glass-blur);
  box-shadow: 0 20px 56px rgba(0, 0, 0, .5), inset 0 1px 0 rgba(255, 255, 255, .06);
  padding: 8px;
}
.ui-menu-panel .btn, .ui-menu-panel a.btn {
  width: 100%;
  min-height: 38px;
  padding: 9px 12px;
  border-radius: 10px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--ui-muted-strong);
  justify-content: flex-start;
  text-align: left;
  font-size: var(--ui-text-sm);
  font-weight: 500;
  gap: 8px;
  box-shadow: none;
}
.ui-menu-panel .btn + .btn,
.ui-menu-panel .btn + a.btn,
.ui-menu-panel a.btn + .btn,
.ui-menu-panel a.btn + a.btn { margin-top: 2px; }
.ui-menu-panel .btn:not(:disabled):hover,
.ui-menu-panel a.btn:hover {
  background: color-mix(in srgb, var(--ui-accent) 14%, transparent);
  color: var(--text);
  border-color: color-mix(in srgb, var(--ui-accent) 28%, transparent);
  transform: translateX(2px);
}
.ui-menu-panel .btn:not(:disabled):active,
.ui-menu-panel a.btn:active { transform: translateX(1px); }

.ui-menu-panel.floating {
  position: fixed;
  z-index: 200;
  max-width: min(320px, calc(100vw - 16px));
}
/* fixed 面板需要以视口为包含块；工具栏自身保留材质色，但不再创建滤镜包含块 */
.bar { -webkit-backdrop-filter: none; backdrop-filter: none; }

@media (prefers-contrast: more), (prefers-reduced-transparency: reduce) {
  select:not([multiple]), .ui-menu-panel {
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
    background: var(--ui-surface-2);
    border-color: var(--ui-border);
    box-shadow: none;
  }
}

/* ───────────────────────── 25. 顶部 Skill / 模型选择器：紧凑弹出按钮 ───────────────────────── */
:root {
  --ui-icon-skill: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 14 14'%3E%3Cpath d='M7 1.2l1.2 3.4 3.6 1.2-3.6 1.2L7 10.4 5.8 7 2.2 5.8 5.8 4.6 7 1.2z' fill='none' stroke='%23A1A1A6' stroke-width='1.1' stroke-linejoin='round'/%3E%3C/svg%3E");
  --ui-icon-model: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 14 14'%3E%3Crect x='3.5' y='3.5' width='7' height='7' rx='2' fill='none' stroke='%23A1A1A6' stroke-width='1.1'/%3E%3Cpath d='M5.5 1.5v2M8.5 1.5v2M5.5 10.5v2M8.5 10.5v2M1.5 5.5h2M1.5 8.5h2M10.5 5.5h2M10.5 8.5h2' stroke='%23A1A1A6' stroke-width='1.1' stroke-linecap='round'/%3E%3C/svg%3E");
  --ui-icon-agent: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 14 14'%3E%3Crect x='3' y='4.5' width='8' height='6.5' rx='2' fill='none' stroke='%23A1A1A6' stroke-width='1.1'/%3E%3Cpath d='M7 2v2.5' stroke='%23A1A1A6' stroke-width='1.1' stroke-linecap='round'/%3E%3Ccircle cx='7' cy='2' r='1' fill='%23A1A1A6'/%3E%3Ccircle cx='5.5' cy='7.5' r='.8' fill='%23A1A1A6'/%3E%3Ccircle cx='8.5' cy='7.5' r='.8' fill='%23A1A1A6'/%3E%3C/svg%3E");
  --ui-icon-chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M3 4.5 6 7.5 9 4.5' fill='none' stroke='%23A1A1A6' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}
#skillSelect, #modelSelect {
  height: 34px;
  min-height: 34px;
  padding: 6px 28px 6px 30px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.2;
  white-space: nowrap;
  text-overflow: ellipsis;
  background-repeat: no-repeat, no-repeat, no-repeat;
  background-position: left 9px center, right 9px center, 0 0;
  background-size: 14px 14px, 12px 12px, 180% 180%;
  background-color: var(--ui-glass-bg);
}
#skillSelect {
  min-width: 138px;
  max-width: 168px;
  background-image: var(--ui-icon-skill), var(--ui-icon-chevron), var(--ui-glass-highlight);
}
#modelSelect {
  min-width: 156px;
  max-width: 188px;
  background-image: var(--ui-icon-model), var(--ui-icon-chevron), var(--ui-glass-highlight);
}
#modelSelect.missing-key { color: var(--ui-warn); }
#modelSelect.missing-key:focus-visible { border-color: var(--ui-warn); box-shadow: 0 0 0 4px rgba(255, 214, 10, .22); }

/* ───────────────────────── 26. 顶部选择器自定义展开列表 ───────────────────────── */
.apple-select { position: relative; display: inline-flex; vertical-align: middle; width: fit-content; min-width: 0; max-width: 100%; }
.apple-select > select { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.apple-select-trigger {
  width: 100%; max-width: 100%; height: 34px; min-height: 34px;
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 28px 6px 30px;
  border: 1px solid var(--ui-glass-border);
  border-radius: 10px;
  background-color: var(--ui-glass-bg);
  background-repeat: no-repeat, no-repeat, no-repeat;
  background-position: left 9px center, right 9px center, 0 0;
  background-size: 14px 14px, 12px 12px, 180% 180%;
  color: var(--text);
  font-size: 12px; font-weight: 600; line-height: 1.2;
  text-align: left; cursor: pointer;
  transition: border-color var(--ui-trans), box-shadow var(--ui-trans), filter var(--ui-trans);
}
.apple-select.skill .apple-select-trigger { background-image: var(--ui-icon-skill), var(--ui-icon-chevron), var(--ui-glass-highlight); }
.apple-select.model .apple-select-trigger { background-image: var(--ui-icon-model), var(--ui-icon-chevron), var(--ui-glass-highlight); }
.apple-select.agent .apple-select-trigger { background-image: var(--ui-icon-agent), var(--ui-icon-chevron), var(--ui-glass-highlight); }
.apple-select.generic .apple-select-trigger {
  padding-left: 10px;
  background-image: var(--ui-icon-chevron), var(--ui-glass-highlight);
  background-position: right 9px center, 0 0;
  background-size: 12px 12px, 180% 180%;
}
.apple-select.generic .apple-select-menu { min-width: 100%; }
.apple-select-trigger:hover {
  border-color: var(--ui-accent-border);
  background-color: var(--ui-glass-bg);
  background-repeat: no-repeat;
}
.apple-select-trigger:focus-visible { outline: none; border-color: var(--ui-accent); box-shadow: var(--ui-ring); }
.apple-select-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.apple-select-badge {
  flex: 0 0 auto; color: var(--ui-warn); font-size: 10px; font-weight: 600;
  letter-spacing: .02em; display: none;
}
.apple-select.missing-key .apple-select-badge { display: inline; }
.apple-select.missing-key .apple-select-trigger { color: var(--ui-warn); }

.apple-select-menu {
  position: absolute; top: calc(100% + 6px); left: 0; z-index: 200;
  width: max-content; min-width: 100%; max-width: min(320px, calc(100vw - 16px)); max-height: 320px;
  overflow-y: auto; padding: 8px;
  border-radius: 16px; border: 1px solid var(--ui-glass-border);
  background: color-mix(in srgb, var(--ui-glass-bg-strong) 96%, var(--ui-accent) 4%);
  -webkit-backdrop-filter: var(--ui-glass-blur); backdrop-filter: var(--ui-glass-blur);
  box-shadow: 0 20px 56px rgba(0, 0, 0, .5), inset 0 1px 0 rgba(255, 255, 255, .06);
}
.apple-select-menu.floating {
  position: fixed;
  min-width: 0;
  width: max-content;
}
.apple-select-option {
  width: 100%; min-height: 36px; padding: 8px 10px;
  display: flex; align-items: center; gap: 8px;
  border-radius: 10px; border: 1px solid transparent;
  background: transparent; color: var(--ui-muted-strong);
  font-size: 12px; font-weight: 500; text-align: left;
  cursor: pointer; transition: background var(--ui-trans), color var(--ui-trans), border-color var(--ui-trans);
}
.apple-select-option + .apple-select-option { margin-top: 2px; }
.apple-select-option:hover { background: var(--ui-accent-soft); color: var(--text); border-color: color-mix(in srgb, var(--ui-accent) 28%, transparent); }
.apple-select-option.selected { background: var(--ui-segment-active); color: var(--text); border-color: var(--ui-glass-border); }
.apple-select-option[disabled] { opacity: .45; cursor: not-allowed; }
.apple-select-option .check { margin-left: auto; color: var(--ui-accent); opacity: 0; }
.apple-select-option.selected .check { opacity: 1; }
.apple-select-option em { font-style: normal; color: var(--ui-warn); font-size: 10px; }
.apple-select-search {
  width: 100%; margin-bottom: 6px; padding: 7px 10px;
  border: 1px solid var(--ui-glass-border); border-radius: 10px;
  background: var(--ui-glass-bg-strong); color: var(--text);
  font-size: 12px; outline: none;
}
.apple-select-search:focus { border-color: var(--ui-accent); box-shadow: var(--ui-ring); }
.apple-select-search::placeholder { color: var(--ui-muted-strong); }
.apple-select-empty { padding: 8px 10px; color: var(--ui-muted-strong); font-size: 12px; }
.apple-select-option[hidden] { display: none; }
