/* ============================================================
   Lumina Chat · 主题样式
   设计参考：
   - LobeHub Design System (semantic tokens / dark surface stack)
     https://github.com/CLOUDDOMEALPINEAPEX/lobehub/blob/canary/DESIGN.dark.md
   - celestia-ui (violet/cyan glassmorphism)
     https://github.com/jasl/celestia-ui
   - ChatGPT-Next-Web / ai-chat-ui（布局与交互）
   ============================================================ */

/* ---------- 1. 设计 token ---------- */
:root {
  --font-sans: "Geist", -apple-system, BlinkMacSystemFont, "Segoe UI Variable Display",
    "Segoe UI", Roboto, "Helvetica Neue", Arial, "HarmonyOS Sans SC", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei UI", "Microsoft YaHei", ui-sans-serif, system-ui, sans-serif;
  --font-mono: "Geist Mono", ui-monospace, SFMono-Regular, "SF Mono", Menlo,
    "Cascadia Code", Consolas, "HarmonyOS Sans SC", monospace;

  /* spacing scale 4 / 8 / 12 / 16 / 20 / 24 / 32 */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 20px;
  --sp-6: 24px;
  --sp-8: 32px;

  /* radius */
  --radius-xs: 4px;
  --radius-sm: 6px;
  --radius: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-full: 999px;

  /* control heights */
  --ctl-sm: 28px;
  --ctl: 36px;
  --ctl-lg: 40px;

  /* 配色主题 token（由 [data-accent] 提供；默认 = DSH 黑白） */
  --accent: #e8e8e8;
  --accent-2: #b9b9b9;
  --accent-rgb: 232, 232, 232;
  --accent2-rgb: 185, 185, 185;
  --grad: linear-gradient(135deg, #f5f5f5 0%, #c4c4c4 100%);
  --grad-alt: linear-gradient(135deg, #c4c4c4 0%, #f5f5f5 100%);
  --grad-soft: linear-gradient(135deg, rgba(232, 232, 232, 0.18), rgba(185, 185, 185, 0.12));
  --on-grad: #101010; /* 渐变表面上的文字颜色 */

  --shadow-1: 0 3px 1px -1px rgba(26, 26, 26, 0.06);
  --shadow-2: 0 8px 16px -4px rgba(0, 0, 0, 0.2);
  --shadow-3: 0 20px 20px -8px rgba(0, 0, 0, 0.24);

  --sidebar-w: 272px;
  --topbar-h: 60px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

/* 深色主题：画布纯黑 → 容器 → 抬高层，越"高"越亮 */
[data-theme="dark"] {
  --bg: #000000;
  --bg-container: #0d0d0d;
  --bg-secondary: #070707;
  --bg-elevated: #1a1a1a;
  --bg-spotlight: #2d2d2d;
  --text: #ffffff;
  --text-2: #aaaaaa;
  --text-3: #6f6f6f;
  --text-4: #555555;
  --border: rgba(255, 255, 255, 0.16);
  --border-2: rgba(255, 255, 255, 0.1);
  --code-border: rgba(255, 255, 255, 0.26); /* 代码块边框：比常规描边更深一档 */
  --fill-1: rgba(255, 255, 255, 0.16);
  --fill-2: rgba(255, 255, 255, 0.1);
  --fill-3: rgba(255, 255, 255, 0.06);
  --fill-4: rgba(255, 255, 255, 0.02);
  --user-bubble: rgba(var(--accent-rgb), 0.16);
  --glow-1: rgba(var(--accent-rgb), 0.16);
  --glow-2: rgba(var(--accent2-rgb), 0.1);
  --backdrop: rgba(0, 0, 0, 0.6);
  color-scheme: dark;
}

/* 浅色主题：层级反转——越"高"越白 */
[data-theme="light"] {
  --bg: #f2f3f5;
  --bg-container: #ffffff;
  --bg-secondary: #fafafa;
  --bg-elevated: #ffffff;
  --bg-spotlight: #f5f5f6;
  --text: #181820;
  --text-2: #5f6570;
  --text-3: #9aa0a8;
  --text-4: #b8bdc4;
  --border: rgba(20, 20, 32, 0.12);
  --border-2: rgba(20, 20, 32, 0.08);
  --code-border: rgba(20, 20, 32, 0.26); /* 代码块边框：比常规描边更深一档 */
  --fill-1: rgba(20, 20, 32, 0.12);
  --fill-2: rgba(20, 20, 32, 0.08);
  --fill-3: rgba(20, 20, 32, 0.05);
  --fill-4: rgba(20, 20, 32, 0.02);
  --user-bubble: rgba(var(--accent-rgb), 0.1);
  --glow-1: rgba(var(--accent-rgb), 0.1);
  --glow-2: rgba(var(--accent2-rgb), 0.08);
  --backdrop: rgba(24, 24, 32, 0.32);
  --shadow-2: 0 8px 16px -4px rgba(20, 20, 32, 0.08);
  --shadow-3: 0 20px 30px -10px rgba(20, 20, 32, 0.14);
  color-scheme: light;
}

/* ---------- 1.5 配色主题（多彩 / 黑白，与明暗模式正交） ---------- */
/* DSH 风格黑白：单色渐变、无彩色，深色下白按钮黑字，浅色下黑按钮白字 */
[data-accent="mono"] {
  --accent: #e8e8e8;
  --accent-2: #b9b9b9;
  --accent-rgb: 232, 232, 232;
  --accent2-rgb: 185, 185, 185;
  --grad: linear-gradient(135deg, #f5f5f5 0%, #c4c4c4 100%);
  --grad-alt: linear-gradient(135deg, #c4c4c4 0%, #f5f5f5 100%);
  --grad-soft: linear-gradient(135deg, rgba(232, 232, 232, 0.18), rgba(185, 185, 185, 0.12));
  --on-grad: #101010;
}
[data-theme="light"][data-accent="mono"] {
  /* DSH Harness 浅色风格：浅灰按钮面 + 柔和长春花蓝点缀 */
  --accent: #7f95ee;
  --accent-2: #a5b4fc;
  --accent-rgb: 127, 149, 238;
  --accent2-rgb: 165, 180, 252;
  --grad: linear-gradient(135deg, #e9ebef 0%, #d8dce2 100%);
  --grad-alt: linear-gradient(135deg, #d8dce2 0%, #e9ebef 100%);
  --grad-soft: linear-gradient(135deg, rgba(127, 149, 238, 0.12), rgba(165, 180, 252, 0.08));
  --on-grad: #1c2128;
}
/* DSH 风格按钮：主按钮=柔和长春花蓝；新建对话=白底细描边（同 DSH「新会话」） */
[data-theme="light"][data-accent="mono"] .btn-primary {
  background: linear-gradient(135deg, #aebbf8 0%, #93a6f4 100%);
  color: #1d2433;
  box-shadow: none;
}
[data-theme="light"][data-accent="mono"] .btn-primary:hover {
  filter: brightness(1.03);
}
[data-theme="light"][data-accent="mono"] .new-chat-btn {
  background: var(--bg-container);
  color: var(--text);
  border: 1px solid var(--border);
  box-shadow: none;
}
[data-theme="light"][data-accent="mono"] .new-chat-btn:hover {
  background: var(--fill-3);
  filter: none;
}
[data-theme="light"][data-accent="mono"] .new-chat-btn kbd {
  background: var(--fill-3);
  border-color: var(--border-2);
  color: var(--text-3);
}
/* 深色模式：同样走 DSH 调（深灰按钮面，主按钮长春花蓝，不再出现白块） */
[data-theme="dark"][data-accent="mono"] {
  --accent: #8fa4f2;
  --accent-2: #a5b4fc;
  --accent-rgb: 143, 164, 242;
  --accent2-rgb: 165, 180, 252;
  --grad: linear-gradient(135deg, #2c313a 0%, #23272e 100%);
  --grad-alt: linear-gradient(135deg, #23272e 0%, #2c313a 100%);
  --grad-soft: linear-gradient(135deg, rgba(143, 164, 242, 0.16), rgba(165, 180, 252, 0.1));
  --on-grad: #e9ecf2;
}
[data-theme="dark"][data-accent="mono"] .btn-primary {
  background: linear-gradient(135deg, #aebbf8 0%, #93a6f4 100%);
  color: #1d2433;
  box-shadow: none;
}
[data-theme="dark"][data-accent="mono"] .btn-primary:hover { filter: brightness(1.05); }
[data-theme="dark"][data-accent="mono"] .new-chat-btn {
  background: var(--bg-elevated);
  color: var(--text);
  border: 1px solid var(--border);
  box-shadow: none;
}
[data-theme="dark"][data-accent="mono"] .new-chat-btn:hover {
  background: var(--fill-3);
  filter: none;
}
[data-theme="dark"][data-accent="mono"] .new-chat-btn kbd {
  background: var(--fill-3);
  border-color: var(--border-2);
  color: var(--text-3);
}
[data-accent="aurora"] {
  --accent: #7c5cff;
  --accent-2: #26c6ff;
  --accent-rgb: 124, 92, 255;
  --accent2-rgb: 38, 198, 255;
  --grad: linear-gradient(135deg, #7c5cff 0%, #5a7dff 48%, #26c6ff 100%);
  --grad-alt: linear-gradient(135deg, #26c6ff 0%, #4f7dff 60%, #7c5cff 100%);
  --grad-soft: linear-gradient(135deg, rgba(var(--accent-rgb), 0.18), rgba(var(--accent2-rgb), 0.12));
  --on-grad: #ffffff;
}
[data-accent="ocean"] {
  --accent: #2f7cf6;
  --accent-2: #22d3ee;
  --accent-rgb: 47, 124, 246;
  --accent2-rgb: 34, 211, 238;
  --grad: linear-gradient(135deg, #2f7cf6 0%, #22a3ee 55%, #22d3ee 100%);
  --grad-alt: linear-gradient(135deg, #22d3ee 0%, #22a3ee 45%, #2f7cf6 100%);
  --grad-soft: linear-gradient(135deg, rgba(47, 124, 246, 0.18), rgba(34, 211, 238, 0.12));
  --on-grad: #ffffff;
}
[data-accent="forest"] {
  --accent: #16b981;
  --accent-2: #7ee6c2;
  --accent-rgb: 22, 185, 129;
  --accent2-rgb: 126, 230, 194;
  --grad: linear-gradient(135deg, #16b981 0%, #2dd4a7 55%, #7ee6c2 100%);
  --grad-alt: linear-gradient(135deg, #7ee6c2 0%, #2dd4a7 45%, #16b981 100%);
  --grad-soft: linear-gradient(135deg, rgba(22, 185, 129, 0.18), rgba(126, 230, 194, 0.12));
  --on-grad: #052e22;
}
[data-accent="sunset"] {
  --accent: #f59e0b;
  --accent-2: #f97316;
  --accent-rgb: 245, 158, 11;
  --accent2-rgb: 249, 115, 22;
  --grad: linear-gradient(135deg, #fbbf24 0%, #f97316 55%, #ea580c 100%);
  --grad-alt: linear-gradient(135deg, #ea580c 0%, #f97316 45%, #fbbf24 100%);
  --grad-soft: linear-gradient(135deg, rgba(245, 158, 11, 0.18), rgba(234, 88, 12, 0.12));
  --on-grad: #431407;
}
[data-accent="sakura"] {
  --accent: #db2777;
  --accent-2: #f472b6;
  --accent-rgb: 219, 39, 119;
  --accent2-rgb: 244, 114, 182;
  --grad: linear-gradient(135deg, #db2777 0%, #e84393 55%, #f472b6 100%);
  --grad-alt: linear-gradient(135deg, #f472b6 0%, #e84393 45%, #db2777 100%);
  --grad-soft: linear-gradient(135deg, rgba(219, 39, 119, 0.18), rgba(244, 114, 182, 0.12));
  --on-grad: #ffffff;
}

/* ---------- 2. 基础 ---------- */
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.667;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
h1, h2, h3, h4 { margin: 0; font-weight: 600; }
p { margin: 0; }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: none; background: none; padding: 0; }
/* 作者样式（如 .btn-ghost{display:inline-flex}）会盖掉 UA 的 [hidden]，必须显式兜底 */
[hidden] { display: none !important; }
svg {
  width: 18px; height: 18px;
  fill: none; stroke: currentColor; stroke-width: 1.8;
  stroke-linecap: round; stroke-linejoin: round;
}
kbd {
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 2px 6px;
  border-radius: var(--radius-xs);
  border: 1px solid var(--border-2);
  background: var(--fill-3);
  color: var(--text-3);
}
::selection { background: rgba(var(--accent-rgb), 0.35); color: inherit; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: var(--fill-2); border-radius: var(--radius-full); }
::-webkit-scrollbar-thumb:hover { background: var(--fill-1); }
::-webkit-scrollbar-track { background: transparent; }

/* ---------- 3. 布局 ---------- */
.app {
  display: flex;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  background:
    radial-gradient(900px 480px at 82% -12%, var(--glow-1), transparent 62%),
    radial-gradient(760px 420px at 8% 110%, var(--glow-2), transparent 60%),
    var(--bg);
}

/* ---------- 4. 侧边栏 ---------- */
.sidebar {
  width: var(--sidebar-w);
  flex: none;
  display: flex;
  flex-direction: column;
  background: color-mix(in srgb, var(--bg-container) 86%, transparent);
  backdrop-filter: blur(20px) saturate(140%);
  -webkit-backdrop-filter: blur(20px) saturate(140%);
  border-right: 1px solid var(--border-2);
  padding: var(--sp-4);
  gap: var(--sp-3);
}
.sidebar-head { display: flex; align-items: center; justify-content: space-between; }
.brand { display: flex; align-items: center; gap: var(--sp-3); }
.brand-mark {
  position: relative;
  width: 38px; height: 38px;
  border-radius: var(--radius-lg);
  background: var(--grad);
  flex: none;
}
.brand-mark i {
  position: absolute; top: 50%;
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--on-grad);
  transform: translateY(-50%);
}
.brand-mark i:first-child { left: 8px; }
.brand-mark i:last-child { right: 8px; opacity: 0.72; }
.brand-text h1 {
  font-size: 15px;
  letter-spacing: 0.2px;
  color: var(--accent);
}
.brand-text p { font-size: 11px; color: var(--text-3); line-height: 1.3; }

.new-chat-btn {
  display: flex; align-items: center; gap: var(--sp-2);
  height: var(--ctl-lg);
  padding: 0 var(--sp-4);
  border-radius: var(--radius-lg);
  background: var(--grad);
  color: var(--on-grad);
  font-weight: 600;
  white-space: nowrap;
  box-shadow: 0 6px 16px -12px rgba(var(--accent-rgb), 0.55);
  transition: filter 0.18s;
}
.new-chat-btn:hover { filter: brightness(1.06); }
.new-chat-btn:active { filter: brightness(0.95); }
.new-chat-btn kbd {
  margin-left: auto;
  background: color-mix(in srgb, var(--on-grad) 16%, transparent);
  border-color: color-mix(in srgb, var(--on-grad) 28%, transparent);
  color: color-mix(in srgb, var(--on-grad) 92%, transparent);
}

.search-box {
  display: flex; align-items: center; gap: var(--sp-2);
  height: var(--ctl);
  padding: 0 var(--sp-3);
  border-radius: var(--radius-full);
  background: var(--fill-3);
  border: none;
  color: var(--text-3);
  transition: box-shadow 0.18s, background 0.18s;
}
.search-box:focus-within { background: var(--fill-3); box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 25%, transparent); }
.search-box svg { width: 15px; height: 15px; flex: none; }
.search-box input {
  flex: 1; min-width: 0;
  border: none; outline: none; background: none;
  font-size: 13px;
}
.search-box input::placeholder { color: var(--text-3); }
.search-box input::-webkit-search-cancel-button { display: none; }

.conv-list {
  flex: 1;
  overflow-y: auto;
  margin: 0 calc(var(--sp-2) * -1);
  padding: 0 var(--sp-2) var(--sp-2);
  display: flex; flex-direction: column; gap: 2px;
}
.conv-group-label {
  font-size: 11px; font-weight: 600;
  color: var(--text-3);
  text-transform: uppercase; letter-spacing: 0.6px;
  padding: var(--sp-3) var(--sp-2) var(--sp-1);
}
.conv-item {
  position: relative;
  display: flex; align-items: center; gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--radius);
  color: var(--text-2);
  cursor: pointer;
  border: 1px solid transparent;
  transition: background 0.15s, color 0.15s;
}
.conv-item:hover { background: var(--fill-3); color: var(--text); }
.conv-item.active {
  background: var(--grad-soft);
  border-color: color-mix(in srgb, var(--accent) 34%, transparent);
  color: var(--text);
}
.conv-item .dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--fill-1); flex: none;
}
.conv-item.active .dot { background: var(--accent); box-shadow: 0 0 8px var(--accent); }
.conv-item .conv-name {
  flex: 1; min-width: 0;
  font-size: 13px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.conv-item .conv-actions {
  display: none; align-items: center; gap: 2px;
}
.conv-item:hover .conv-actions { display: flex; }
.conv-item .conv-actions button {
  display: grid; place-items: center;
  width: 22px; height: 22px;
  border-radius: var(--radius-xs);
  color: var(--text-3);
}
.conv-item .conv-actions button:hover { background: var(--fill-2); color: var(--text); }
.conv-item .conv-actions svg { width: 13px; height: 13px; }
.conv-empty {
  padding: var(--sp-6) var(--sp-3);
  text-align: center;
  color: var(--text-3);
  font-size: 12.5px;
}

/* 会话筛选条（全部 / 文件夹 / 已归档） */
.filter-chips {
  display: flex; flex-wrap: wrap; gap: 6px;
  padding: var(--sp-1) 2px var(--sp-2);
}
.filter-chip {
  height: 24px;
  padding: 0 10px;
  border-radius: var(--radius-full);
  border: none;
  background: var(--fill-3);
  color: var(--text-3);
  font-size: 11px;
  transition: background 0.14s, color 0.14s;
}
.filter-chip:hover { color: var(--text); background: var(--fill-2); }
.filter-chip.active {
  color: var(--on-grad);
  background: var(--grad);
}
.filter-chip-add { width: 24px; padding: 0; }

/* 文件夹选择列表 */
.folder-list { display: flex; flex-direction: column; gap: var(--sp-2); }
.folder-item { display: flex; align-items: center; gap: var(--sp-2); }
.folder-item.active .folder-pick {
  color: var(--text);
  background: var(--fill-2);
}
.folder-pick {
  flex: 1;
  height: var(--ctl);
  padding: 0 var(--sp-3);
  border-radius: var(--radius);
  border: none;
  background: var(--fill-3);
  color: var(--text-2);
  text-align: left;
  font-size: 13px;
}
.folder-pick:hover { background: var(--fill-2); color: var(--text); }
.folder-del {
  width: var(--ctl); height: var(--ctl);
  display: grid; place-items: center;
  border-radius: var(--radius);
  color: var(--text-3);
}
.folder-del:hover { background: rgba(244, 65, 108, 0.12); color: #f4416c; }

/* 数据备份 / WebDAV */
.data-actions {
  display: flex; flex-wrap: wrap; gap: var(--sp-2);
  margin-top: var(--sp-2);
}
.data-actions .btn-outline,
.data-actions .btn-ghost {
  flex: none;
}
.dav-row { display: flex; gap: var(--sp-2); }
.dav-row input { flex: 1; min-width: 0; }
.prompt-admin > button { align-self: flex-start; }

.sidebar-foot {
  display: flex; align-items: center; gap: var(--sp-2);
  padding-top: var(--sp-3);
  border-top: 1px solid var(--border-2);
}
.foot-btn {
  display: flex; align-items: center; gap: var(--sp-2);
  height: var(--ctl);
  padding: 0 var(--sp-3);
  border-radius: var(--radius);
  color: var(--text-2);
  font-size: 13px;
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s;
}
.foot-btn > span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.foot-btn:hover { background: var(--fill-3); color: var(--text); }
.foot-btn svg { width: 16px; height: 16px; flex: none; }
.foot-btn em {
  font-style: normal;
  margin-left: auto;
  font-size: 11px;
  flex: none;
  min-width: 18px; height: 18px;
  display: grid; place-items: center;
  padding: 0 5px;
  border-radius: var(--radius-full);
  background: var(--fill-3);
  color: var(--text-3);
}
.foot-btn em.has-data {
  background: var(--grad);
  color: var(--on-grad);
}

.icon-btn {
  display: grid; place-items: center;
  width: var(--ctl); height: var(--ctl);
  border-radius: var(--radius);
  color: var(--text-2);
  background: var(--fill-3);
  transition: background 0.15s, color 0.15s, transform 0.15s;
}
.icon-btn:hover { background: var(--fill-2); color: var(--text); }
.icon-btn:active { transform: scale(0.94); }
.ic-sun { display: none; }
[data-theme="light"] .ic-sun { display: block; }
[data-theme="light"] .ic-moon { display: none; }

/* ---------- 5. 主区域 ---------- */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  height: var(--topbar-h);
  flex: none;
  display: flex; align-items: center; gap: var(--sp-3);
  padding: 0 var(--sp-5);
  border-bottom: 1px solid var(--border-2);
  background: color-mix(in srgb, var(--bg-container) 72%, transparent);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}
.topbar-title { flex: 1; min-width: 0; }
.topbar-title h2 {
  font-size: 15px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.topbar-title p {
  font-size: 11.5px; color: var(--text-3);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.topbar-actions { display: flex; align-items: center; gap: var(--sp-2); }
.topbar-actions > * { flex: none; } /* 按钮不被标题挤压变形，宁可让标题省略 */

/* 助手形象入口 & 头像（方形按钮） */
.assistant-btn {
  display: grid; place-items: center;
  width: var(--ctl); height: var(--ctl);
  padding: 0;
  border-radius: var(--radius);
  border: none;
  background: var(--fill-3);
  transition: background 0.15s, transform 0.15s;
}
.assistant-btn:hover { background: var(--fill-2); }
.assistant-btn:active { transform: scale(0.96); }
.assistant-avatar {
  width: 30px; height: 30px;
  display: grid; place-items: center;
  border-radius: 10px;
  overflow: hidden;
  background: var(--grad);
  color: var(--on-grad);
  font-size: 13px; font-weight: 600;
}
.assistant-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }

.avatar-editor {
  display: flex; align-items: center; gap: var(--sp-4);
  padding: var(--sp-4);
  margin-bottom: var(--sp-4);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-2);
  background: var(--fill-4);
}
.avatar-preview {
  width: 72px; height: 72px; flex: none;
  display: grid; place-items: center;
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--grad);
  color: var(--on-grad);
  font-size: 26px; font-weight: 600;
}
.avatar-preview img { width: 100%; height: 100%; object-fit: cover; display: block; }
.avatar-actions { display: flex; flex-wrap: wrap; gap: var(--sp-2); }
.avatar-editor .avatar-hint { margin: var(--sp-2) 0 0; } /* 提高优先级，避免被 .field-hint 的负边距覆盖 */

/* 设置弹窗里的助手形象入口行 */
.assistant-row {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-3);
  margin-bottom: var(--sp-5);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-2);
  background: var(--grad-soft);
}
.assistant-row-info { display: flex; align-items: center; gap: var(--sp-3); flex: 1; min-width: 0; }
.assistant-row-info strong {
  display: block; font-size: 13.5px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.assistant-row-info p { font-size: 11.5px; color: var(--text-3); }
.assistant-row .assistant-avatar { width: 38px; height: 38px; border-radius: var(--radius); flex: none; }
.assistant-row .assistant-avatar-user {
  background: var(--grad-alt); /* 与助手头像相反的渐变方向，区分"我"与助手 */
}
.identity-segmented { margin-bottom: var(--sp-4); }

.model-picker { position: relative; }
.model-btn {
  display: flex; align-items: center; gap: var(--sp-2);
  height: var(--ctl);
  max-width: 260px;
  padding: 0 var(--sp-3);
  border-radius: var(--radius-full);
  border: none;
  background: var(--fill-3);
  font-size: 12.5px;
  transition: background 0.15s;
}
.model-btn:hover { background: var(--fill-2); }
.model-btn .model-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--grad);
  flex: none;
}
.model-btn .model-name {
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  font-family: var(--font-mono); font-size: 12px;
}
.model-btn svg { width: 14px; height: 14px; color: var(--text-3); flex: none; }

.dropdown {
  position: absolute; top: calc(100% + 8px); right: 0;
  width: 344px; max-height: 480px;
  overflow-y: auto;
  padding: var(--sp-3);
  border-radius: var(--radius-lg);
  background: var(--bg-elevated);
  border: 1px solid var(--border-2);
  box-shadow: var(--shadow-3);
  z-index: 60;
  animation: pop 0.16s var(--ease);
}
.dropdown-group + .dropdown-group { margin-top: var(--sp-3); }
.dropdown-label {
  font-size: 11px; font-weight: 600;
  color: var(--text-3);
  letter-spacing: 0.4px;
  padding: var(--sp-1) var(--sp-2) var(--sp-2);
}
.dropdown-item {
  display: flex; align-items: center; gap: var(--sp-3);
  width: 100%;
  min-height: 38px;
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--radius);
  font-family: var(--font-mono); font-size: 12px;
  color: var(--text-2);
  text-align: left;
  transition: background 0.14s, color 0.14s;
}
.dropdown-item + .dropdown-item { margin-top: 2px; }

/* 输入框组合式下拉：锚在模型席下方，向上弹出 */
.dropdown-up {
  top: auto;
  bottom: calc(100% + 10px);
  left: 0;
  right: auto;
}
/* 模型席与工具行其它胶囊同高 */
.composer-tools .model-btn {
  height: var(--ctl-sm);
  padding: 0 var(--sp-2) 0 var(--sp-1);
}
.composer-tools .model-btn .model-name { max-width: 148px; }
.dropdown-item:hover { background: var(--fill-3); color: var(--text); }
.dropdown-item.active { background: var(--grad-soft); color: var(--text); }
.dropdown-item .check { margin-left: auto; color: var(--accent); display: none; }
.dropdown-item.active .check { display: block; }
.dropdown-item .check svg { width: 14px; height: 14px; }
.dropdown-empty {
  padding: var(--sp-5) var(--sp-3);
  text-align: center;
  color: var(--text-3);
  font-size: 12.5px;
}
.dropdown-empty .btn-outline { margin-top: var(--sp-3); }

/* DSH 风格两级菜单：根面板菜单行（标签 + 当前值 + 箭头） */
.menu-row {
  display: flex; align-items: center; gap: var(--sp-3);
  width: 100%;
  min-height: 42px;
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 13px;
  text-align: left;
  transition: background 0.14s;
}
.menu-row:hover { background: var(--fill-3); }
.menu-row-label { flex: none; color: var(--text-2); }
.menu-row-value {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 12px;
  max-width: 58%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.menu-row svg { width: 15px; height: 15px; color: var(--text-3); flex: none; }
.menu-row-back {
  min-height: 36px;
  margin-bottom: var(--sp-1);
  color: var(--text-2);
  font-size: 12.5px;
}
.menu-row-back svg { width: 14px; height: 14px; }
.menu-row-back .menu-row-label { color: inherit; }

/* ---------- 6. 消息区 ---------- */
.chat-scroll { flex: 1; overflow-y: auto; overflow-x: hidden; scroll-behavior: smooth; }
.chat-inner { max-width: 880px; margin: 0 auto; padding: var(--sp-6) var(--sp-6) var(--sp-8); }
.messages { display: flex; flex-direction: column; gap: var(--sp-6); }

.msg { display: flex; gap: var(--sp-3); animation: rise 0.22s var(--ease); }
.msg-avatar {
  width: 32px; height: 32px; flex: none;
  display: grid; place-items: center;
  border-radius: var(--radius);
  font-size: 13px; font-weight: 600;
  margin-top: 2px;
  overflow: hidden;
}
.msg-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.msg.assistant .msg-avatar { background: var(--grad); color: var(--on-grad); }
.msg.assistant .msg-avatar img { box-shadow: none; }
.msg.user .msg-avatar { background: var(--fill-3); color: var(--text-2); border: 1px solid var(--border-2); }
.msg-body { flex: 1; min-width: 0; }
.msg-meta {
  display: flex; align-items: center; gap: var(--sp-2);
  margin-bottom: var(--sp-1);
}
.msg-role { font-size: 12.5px; font-weight: 600; }
.msg-time { font-size: 11px; color: var(--text-3); }
.stopped-note { font-size: 12.5px; color: var(--text-3); font-style: italic; }

/* 思考过程（推理模型 reasoning_content） */
.think-block {
  margin: 0 0 var(--sp-3);
  border-radius: var(--radius);
  border: 1px dashed var(--border);
  background: var(--fill-4);
  overflow: hidden;
}
.think-head {
  display: flex; align-items: center; gap: var(--sp-2);
  padding: 6px var(--sp-3);
  cursor: pointer;
  list-style: none;
  user-select: none;
  font-size: 11.5px;
  color: var(--text-3);
}
.think-head::-webkit-details-marker { display: none; }
.think-block[open] .think-head { border-bottom: 1px dashed var(--border-2); }
.think-chev {
  width: 12px; height: 12px; flex: none;
  transition: transform 0.18s var(--ease);
}
.think-block[open] .think-chev { transform: rotate(90deg); }
.think-title { font-weight: 600; }
.think-meta {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--text-4);
}
.think-body {
  padding: var(--sp-2) var(--sp-3) var(--sp-3);
  font-size: 12.5px;
  line-height: 1.75;
  color: var(--text-3);
}
.think-body.md > *:first-child { margin-top: 0 !important; }
.think-body.md > *:last-child { margin-bottom: 0 !important; }
.think-body.md pre { font-size: 11.5px; }

/* Token 用量条（≈ 估算值，位于标题栏） */
.usage-meter {
  display: flex; align-items: center; gap: var(--sp-2);
  margin-right: var(--sp-1);
}
.usage-bar {
  width: 64px; height: 4px;
  border-radius: var(--radius-full);
  background: var(--fill-2);
  overflow: hidden;
}
.usage-bar i {
  display: block;
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: var(--grad);
  transition: width 0.25s, background 0.25s;
}
.usage-text {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--text-3);
  white-space: nowrap;
}
.usage-meter.warn .usage-bar i { background: #f59e0b; }
.usage-meter.warn .usage-text { color: #f59e0b; }
.usage-meter.crit .usage-bar i { background: #ef4444; }
.usage-meter.crit .usage-text { color: #ef4444; }
@media (max-width: 900px) {
  .usage-text { display: none; } /* 小屏只保留进度条 */
}

/* 语音输入 */
.chip-mic {
  color: var(--text-3);
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.chip-mic.listening {
  color: #ef4444;
  border-color: rgba(239, 68, 68, 0.55);
  background: rgba(239, 68, 68, 0.12);
  animation: mic-pulse 1.2s ease-in-out infinite;
}
@keyframes mic-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.35); }
  50% { box-shadow: 0 0 0 6px rgba(239, 68, 68, 0); }
}

/* 图片附件 */
.attach-strip {
  display: flex; flex-wrap: wrap; gap: var(--sp-2);
  padding-bottom: var(--sp-2);
}
.attach-thumb {
  position: relative;
  width: 64px; height: 64px;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border-2);
}
.attach-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.attach-thumb button {
  position: absolute; top: 2px; right: 2px;
  width: 18px; height: 18px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  font-size: 11px;
  line-height: 1;
}
.msg-images {
  display: flex; flex-wrap: wrap; gap: var(--sp-2);
  margin-bottom: var(--sp-2);
}
.msg-images img {
  max-width: 220px;
  max-height: 220px;
  border-radius: var(--radius);
  border: 1px solid var(--border-2);
  object-fit: cover;
}

/* 模型能力标记 */
.model-row {
  display: flex; align-items: center; gap: var(--sp-1);
}
.model-row .dropdown-item { flex: 1; min-width: 0; }
.cap-tags { display: flex; gap: 3px; flex: none; padding-right: 2px; }
.cap-tag {
  width: 18px; height: 18px;
  display: grid; place-items: center;
  border-radius: var(--radius-xs);
  font-size: 10px;
  line-height: 1;
  color: var(--text-4);
  background: var(--fill-3);
  transition: background 0.14s, color 0.14s;
}
.cap-tag.on {
  color: var(--on-grad);
  background: var(--grad);
}
.cap-tag:hover { background: var(--fill-2); color: var(--text); }
.cap-tag.on:hover { filter: brightness(1.1); }

/* Prompt 模板（/ 唤起）与快捷键面板 */
.slash-menu {
  position: absolute;
  bottom: calc(100% + 10px);
  left: var(--sp-4);
  right: auto;
  top: auto;
  width: min(380px, calc(100% - 32px));
  max-height: 260px;
  z-index: 70;
}
.slash-item {
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
}
.slash-item strong { font-family: var(--font-mono); font-size: 12px; color: var(--text); }
.slash-item span {
  font-size: 11px;
  color: var(--text-3);
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.prompt-admin { display: flex; flex-direction: column; gap: var(--sp-2); }
.prompt-list {
  margin-top: var(--sp-2);
  display: flex; flex-direction: column; gap: var(--sp-2);
  max-height: 180px;
  overflow-y: auto;
}
.prompt-item {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--radius);
  border: 1px solid var(--border-2);
  background: var(--fill-4);
}
.prompt-item-main { flex: 1; min-width: 0; }
.prompt-item-main strong { font-size: 12.5px; }
.prompt-item-main p {
  font-size: 11px;
  color: var(--text-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.prompt-empty { font-size: 12px; color: var(--text-3); padding: var(--sp-2); }
.keys-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--sp-3); }
.keys-list li { display: flex; align-items: center; gap: var(--sp-4); font-size: 13px; color: var(--text-2); }
.keys-list kbd { min-width: 76px; text-align: center; }

/* 字号与密度 */
[data-fontsize="small"] .msg-content,
[data-fontsize="small"] .composer textarea { font-size: 13px; }
[data-fontsize="large"] .msg-content,
[data-fontsize="large"] .composer textarea { font-size: 16.5px; }
[data-density="compact"] .messages { gap: var(--sp-4); }
[data-density="compact"] .chat-inner { padding-top: var(--sp-4); padding-bottom: var(--sp-4); }
[data-density="loose"] .messages { gap: var(--sp-8); }

/* 消息编辑器（编辑重发） */
.msg-editor {
  margin-top: 2px;
  padding: var(--sp-3);
  border-radius: var(--radius-lg);
  border: 1px solid color-mix(in srgb, var(--accent) 45%, transparent);
  background: var(--fill-4);
}
.msg-editor-input {
  width: 100%;
  min-height: 76px;
  resize: vertical;
  border: none;
  border-radius: var(--radius);
  background: var(--fill-3);
  color: var(--text);
  padding: var(--sp-2) var(--sp-3);
  font-size: 14px;
  line-height: 1.6;
  outline: none;
  font-family: inherit;
}
.msg-editor-input:focus {
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 25%, transparent);
}
.msg-editor-actions { display: flex; gap: var(--sp-2); margin-top: var(--sp-2); }
.msg-editor-actions .btn-primary,
.msg-editor-actions .btn-ghost { height: 32px; }

/* 回答分支版本切换 */
.variant-count {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-3);
  padding: 0 2px;
}
.msg-actions [data-action="msg-prev"],
.msg-actions [data-action="msg-next"] {
  font-family: var(--font-mono);
  font-size: 15px;
  line-height: 1;
  padding: 0 var(--sp-2);
}
.msg-content { font-size: 14.5px; word-wrap: break-word; overflow-wrap: anywhere; }
.msg.user .msg-content {
  display: inline-block;
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--radius-lg);
  background: var(--user-bubble);
  border: none;
  white-space: pre-wrap;
}
.msg-actions {
  display: flex; align-items: center; gap: var(--sp-1);
  margin-top: var(--sp-2);
  opacity: 0;
  transition: opacity 0.16s;
}
.msg:hover .msg-actions { opacity: 1; }
.msg-actions button {
  display: inline-flex; align-items: center; gap: 4px;
  height: 26px; padding: 0 var(--sp-2);
  border-radius: var(--radius-sm);
  color: var(--text-3);
  font-size: 11.5px;
}
.msg-actions button:hover { background: var(--fill-3); color: var(--text); }
.msg-actions svg { width: 13px; height: 13px; }

.typing {
  display: inline-flex; gap: 5px; padding: 6px 0;
}
.typing i {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--accent);
  animation: blink 1.2s infinite ease-in-out;
}
.typing i:nth-child(2) { animation-delay: 0.16s; background: #5a7dff; }
.typing i:nth-child(3) { animation-delay: 0.32s; background: var(--accent-2); }

.msg-error {
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--radius);
  border: 1px solid color-mix(in srgb, #f4416c 45%, transparent);
  background: rgba(244, 65, 108, 0.1);
  color: #ff8aa6;
  font-size: 13px;
  white-space: pre-wrap;
}
[data-theme="light"] .msg-error { color: #c2264e; }

.cursor-blink::after {
  content: "";
  display: inline-block;
  width: 8px; height: 1.05em;
  margin-left: 2px;
  vertical-align: text-bottom;
  background: var(--grad);
  border-radius: 2px;
  animation: blink 0.9s steps(2, start) infinite;
}

/* ---------- 7. 空状态 ---------- */
.empty-state { padding: var(--sp-8) 0; }
.hero {
  text-align: center;
  padding: var(--sp-8) var(--sp-5) var(--sp-6);
}
.hero-badge {
  display: inline-flex; align-items: center; gap: 6px;
  height: 26px; padding: 0 var(--sp-3);
  border-radius: var(--radius-full);
  background: var(--grad-soft);
  border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent);
  color: var(--text-2);
  font-size: 11.5px;
}
.hero h2 {
  margin-top: var(--sp-4);
  font-size: 26px; line-height: 1.3;
  letter-spacing: -0.3px;
}
.hero h2 .grad {
  color: var(--accent);
}
.hero p {
  margin: var(--sp-3) auto 0;
  max-width: 460px;
  color: var(--text-2);
  font-size: 13.5px;
}
.hero-actions {
  margin-top: var(--sp-5);
  display: flex; justify-content: center; gap: var(--sp-3); flex-wrap: wrap;
}
.suggest-grid {
  margin-top: var(--sp-8);
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: var(--sp-3);
}
.suggest-card {
  padding: var(--sp-4);
  text-align: left;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-2);
  background: var(--fill-4);
  transition: transform 0.16s var(--ease), border-color 0.16s, background 0.16s;
}
.suggest-card:hover {
  border-color: transparent;
  background: var(--grad-soft);
}
.suggest-card strong { display: block; font-size: 13px; margin-bottom: 2px; }
.suggest-card span { font-size: 12px; color: var(--text-3); }

/* ---------- 8. 输入区 ---------- */
.composer-area {
  flex: none;
  padding: 0 var(--sp-6) var(--sp-4);
}
.composer {
  max-width: 880px;
  margin: 0 auto;
  border-radius: var(--radius-xl);
  border: 1px solid var(--border-2);
  background: color-mix(in srgb, var(--bg-container) 88%, transparent);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  box-shadow: var(--shadow-1);
  padding: var(--sp-3) var(--sp-4) var(--sp-2);
  transition: border-color 0.18s, box-shadow 0.18s;
}
.composer:focus-within {
  border-color: color-mix(in srgb, var(--accent) 55%, transparent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 14%, transparent), var(--shadow-2);
}
.composer textarea {
  width: 100%;
  border: none; outline: none; background: none;
  resize: none;
  font-size: 14.5px; line-height: 1.6;
  max-height: 220px;
  padding: var(--sp-1) 0;
}
.composer textarea::placeholder { color: var(--text-3); }
.composer-bar {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--sp-3);
  margin-top: var(--sp-2);
}
.composer-tools { display: flex; gap: var(--sp-2); flex-wrap: wrap; }
.chip-btn {
  display: inline-flex; align-items: center; gap: 5px;
  height: var(--ctl-sm);
  padding: 0 var(--sp-3);
  border-radius: var(--radius-full);
  border: none;
  background: var(--fill-3);
  color: var(--text-3);
  font-size: 11.5px;
  transition: color 0.15s, background 0.15s;
}
.chip-btn:hover { color: var(--text); background: var(--fill-2); }
.chip-btn svg { width: 13px; height: 13px; }
.composer-send { display: flex; align-items: center; gap: var(--sp-2); flex: none; }

.btn-primary, .btn-outline, .btn-ghost, .btn-danger {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: var(--ctl);
  padding: 0 var(--sp-4);
  border-radius: var(--radius);
  font-size: 13px; font-weight: 500;
  white-space: nowrap;   /* 防中文被压成竖排 */
  flex: none;            /* 不参与压缩，宁可让别的元素让位 */
  transition: filter 0.15s, background 0.15s, transform 0.15s, border-color 0.15s;
}
.btn-primary {
  background: var(--grad);
  color: var(--on-grad);
  box-shadow: 0 5px 14px -10px rgba(var(--accent-rgb), 0.55);
}
.btn-primary:hover { filter: brightness(1.06); }
.btn-primary:active { transform: translateY(1px); }
.btn-primary svg { width: 15px; height: 15px; }
.btn-outline {
  border: none;
  background: var(--fill-2);
  color: var(--text);
}
.btn-outline:hover { background: var(--fill-1); }
.btn-outline svg { width: 15px; height: 15px; }
.btn-ghost { color: var(--text-2); background: var(--fill-3); }
.btn-ghost:hover { background: var(--fill-2); color: var(--text); }
.btn-ghost svg { width: 15px; height: 15px; }
.btn-danger {
  border: none;
  color: #f4416c;
  background: rgba(244, 65, 108, 0.1);
}
.btn-danger:hover { background: rgba(244, 65, 108, 0.17); }
.btn-primary:disabled, .btn-outline:disabled, .btn-ghost:disabled {
  opacity: 0.5; cursor: not-allowed; filter: none;
}
/* 发送/停止合并按钮：生成中切换为红色停止态 */
[data-theme] .btn-primary.is-stop {
  background: rgba(244, 65, 108, 0.14);
  color: #f4416c;
  box-shadow: none;
}
[data-theme] .btn-primary.is-stop:hover {
  filter: none;
  background: rgba(244, 65, 108, 0.22);
}
[data-theme] .btn-primary.is-stop:active {
  transform: none;
}
.composer-hint {
  max-width: 880px;
  margin: var(--sp-2) auto 0;
  text-align: center;
  font-size: 11px;
  color: var(--text-4);
}

/* ---------- 9. 弹窗 ---------- */
.modal-backdrop {
  position: fixed; inset: 0;
  display: grid; place-items: center;
  padding: var(--sp-5);
  background: var(--backdrop);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 100;
  animation: fade 0.18s var(--ease);
}
.modal-backdrop[hidden] { display: none; }
/* 弹窗叠层：后打开的浮在上面（模型选择 > 助手形象 > 其它） */
#modalModels { z-index: 120; }
/* 从设置弹窗里打开助手形象时，助手弹窗浮在设置之上 */
#modalAssistant { z-index: 110; }
/* HTML 预览浮在最上 */
#modalPreview { z-index: 130; }
.modal-preview { max-width: 880px; }
.modal-head-actions { display: flex; align-items: center; gap: var(--sp-2); }
.preview-body {
  padding: 0;
  background: var(--bg-secondary);
}
#previewFrame {
  display: block;
  width: 100%;
  height: min(62vh, 560px);
  border: none;
  background: #ffffff;
}

/* Mermaid 图表 */
.mermaid-host {
  margin: 0.9em 0 0.35em;
  padding: var(--sp-3);
  border-radius: var(--radius);
  border: 1px solid var(--border-2);
  background: var(--bg-container);
  overflow-x: auto;
  text-align: center;
}
.mermaid-host svg { max-width: 100%; height: auto; }
.mermaid-host.mermaid-error { color: var(--text-3); font-size: 12px; }

/* KaTeX 公式 */
.md .katex-display { margin: 0.8em 0; overflow-x: auto; overflow-y: hidden; }
.md .katex { font-size: 1.05em; }
.modal {
  width: 100%; max-width: 520px;
  max-height: min(86vh, 780px);
  display: flex; flex-direction: column;
  border-radius: var(--radius-xl);
  background: var(--bg-elevated);
  border: 1px solid var(--border-2);
  box-shadow: var(--shadow-3);
  animation: pop 0.2s var(--ease);
  overflow: hidden;
}
.modal-lg { max-width: 720px; }
.modal-sm { max-width: 420px; }
.confirm-message {
  font-size: 13.5px;
  line-height: 1.75;
  color: var(--text-2);
  white-space: pre-wrap;
  word-break: break-word;
}
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--sp-5) var(--sp-5) var(--sp-3);
}
.modal-head h3 { font-size: 16px; }
.modal-body {
  padding: 0 var(--sp-5) var(--sp-5);
  overflow-y: auto;
}
.modal-foot {
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3);
  padding: var(--sp-4) var(--sp-5);
  border-top: 1px solid var(--border-2);
  background: var(--bg-secondary);
}
.modal-foot-right { display: flex; gap: var(--sp-2); margin-left: auto; }

.field { display: block; margin-bottom: var(--sp-4); }
.field > span {
  display: flex; align-items: center; gap: 6px;
  font-size: 12.5px; font-weight: 500;
  color: var(--text-2);
  margin-bottom: var(--sp-2);
}
.field > span em { font-style: normal; color: #f4416c; }
.field > span b { margin-left: auto; color: var(--accent); font-family: var(--font-mono); }
.field input[type="text"], .field input[type="url"], .field input[type="password"],
.field input[type="search"], .field textarea, .input-group input {
  width: 100%;
  height: var(--ctl-lg);
  padding: 0 var(--sp-3);
  border-radius: var(--radius);
  border: none;
  background: var(--fill-3);
  outline: none;
  font-size: 13.5px;
  transition: background 0.16s, box-shadow 0.16s;
}
.field textarea { height: auto; padding: var(--sp-3); resize: vertical; line-height: 1.6; }
.field input:focus, .field textarea:focus, .input-group input:focus {
  background: var(--fill-3);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 25%, transparent);
}
.field input::placeholder, .field textarea::placeholder { color: var(--text-3); }
.field select {
  width: 100%;
  height: var(--ctl-lg);
  padding: 0 var(--sp-3);
  border-radius: var(--radius);
  border: none;
  background: var(--fill-3);
  color: var(--text);
  outline: none;
  font-size: 13.5px;
}
.field select:focus {
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 25%, transparent);
}
.field-hint {
  font-size: 11.5px;
  color: var(--text-3);
  margin: var(--sp-2) 0 var(--sp-4);
  line-height: 1.6;
}
.field-hint code {
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 1px 5px;
  border-radius: var(--radius-xs);
  background: var(--fill-3);
}
.field-inline {
  display: flex; align-items: center; gap: var(--sp-2);
}
.field-inline input { width: 16px; height: 16px; accent-color: var(--accent); }
.field-inline span { margin: 0; font-size: 13px; color: var(--text-2); }
.input-group { display: flex; gap: var(--sp-2); }
.input-group input { flex: 1; min-width: 0; }
.input-group .btn-ghost {
  border: 1px solid var(--border-2);
  height: var(--ctl-lg);
  padding: 0 var(--sp-3);
}

.segmented {
  display: inline-flex;
  padding: 3px;
  gap: 2px;
  border-radius: var(--radius);
  background: var(--fill-4);
  border: 1px solid var(--border-2);
}
.segmented button {
  height: 30px; padding: 0 var(--sp-4);
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  color: var(--text-2);
  transition: background 0.15s, color 0.15s;
}
.segmented button:hover { color: var(--text); }
.segmented button.active {
  background: var(--grad);
  color: var(--on-grad);
}

/* 设置弹窗 Tab 标签 */
.settings-tabs {
  display: flex;
  gap: var(--sp-1);
  padding: 3px;
  margin-bottom: var(--sp-5);
  border-radius: var(--radius);
  border: 1px solid var(--border-2);
  background: var(--fill-4);
  overflow-x: auto;
}
.settings-tabs button {
  flex: 1;
  min-width: 64px;
  height: 32px;
  padding: 0 var(--sp-3);
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  color: var(--text-2);
  white-space: nowrap;
  transition: background 0.15s, color 0.15s;
}
.settings-tabs button:hover { color: var(--text); background: var(--fill-3); }
.settings-tabs button.active {
  background: var(--grad);
  color: var(--on-grad);
}
.tab-panel { animation: fade 0.16s var(--ease); }

/* 主题配色选择器 */
.accent-swatches {
  display: flex; flex-wrap: wrap; gap: var(--sp-2);
}
.swatch {
  display: inline-flex; align-items: center; gap: var(--sp-2);
  height: var(--ctl-lg);
  padding: 0 var(--sp-3);
  border-radius: var(--radius);
  border: none;
  background: var(--fill-3);
  font-size: 12.5px;
  color: var(--text-2);
  transition: background 0.15s, color 0.15s;
}
.swatch i {
  width: 18px; height: 18px;
  border-radius: 50%;
  box-shadow: inset 0 0 0 1px rgba(128, 128, 128, 0.35);
  flex: none;
}
.swatch:hover { background: var(--fill-2); color: var(--text); }
.swatch.active {
  color: var(--text);
  background: transparent;
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 35%, transparent);
}

/* 温度滑条（设置弹窗）——用 id 限定，避免属性选择器泄漏到推理滑条 */
#temperatureRange {
  width: 100%;
  height: 4px;
  appearance: none; -webkit-appearance: none;
  border-radius: var(--radius-full);
  background: var(--fill-2);
  outline: none;
}
#temperatureRange::-webkit-slider-thumb {
  appearance: none; -webkit-appearance: none;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--grad);
  border: 2px solid var(--bg-elevated);
  box-shadow: 0 4px 10px -3px rgba(var(--accent-rgb), 0.9);
  cursor: pointer;
}

.form-status {
  font-size: 12px;
  white-space: pre-wrap;
  color: var(--text-3);
  min-height: 18px;
}
.form-status.ok { color: #7ee787; }
[data-theme="light"] .form-status.ok { color: #1a7f37; }
.form-status.err { color: #ff8aa6; }
[data-theme="light"] .form-status.err { color: #c2264e; }
.form-status.loading { color: var(--text-2); }

/* ---------- 10. 模型选择网格 ---------- */
.picker-toolbar {
  display: flex; align-items: center; gap: var(--sp-3);
  margin-bottom: var(--sp-3);
}
.picker-toolbar .search-box { flex: 1; height: var(--ctl-lg); background: var(--fill-4); }
.picker-actions { display: flex; gap: var(--sp-2); }
.picker-actions .btn-ghost { border: none; }
.picker-meta {
  font-size: 11.5px; color: var(--text-3);
  margin-bottom: var(--sp-3);
}
.model-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: var(--sp-2);
  max-height: 46vh;
  overflow-y: auto;
  padding-right: var(--sp-1);
}
.model-card {
  display: flex; align-items: center; gap: var(--sp-2);
  padding: var(--sp-3);
  border-radius: var(--radius);
  border: 1px solid var(--border-2);
  background: var(--fill-4);
  cursor: pointer;
  transition: border-color 0.14s, background 0.14s, transform 0.14s;
}
.model-card:hover { border-color: var(--border); }
.model-card.checked {
  border-color: color-mix(in srgb, var(--accent) 60%, transparent);
  background: var(--grad-soft);
}
.model-card input {
  width: 15px; height: 15px; flex: none;
  accent-color: var(--accent);
}
.model-card .model-id {
  flex: 1; min-width: 0;
  font-family: var(--font-mono);
  font-size: 11.5px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.model-grid-empty {
  grid-column: 1 / -1;
  padding: var(--sp-8);
  text-align: center;
  color: var(--text-3);
  font-size: 12.5px;
}

/* ---------- 10.5 推理等级滑条（Codex 风格：越往右越"通电"） ---------- */
.model-effort {
  flex: none;
  font-family: var(--font-mono);
  font-size: 10.5px;
  line-height: 1.6;
  padding: 1px 7px;
  border-radius: var(--radius-full);
  background: var(--fill-3);
  color: var(--text-3);
  transition: color 0.2s, background 0.2s;
}

.effort-row {
  position: sticky;
  bottom: var(--sp-2);
  margin-top: var(--sp-4);
  padding: var(--sp-4) var(--sp-4) var(--sp-3);
  background: var(--bg-elevated);
  border: 1px solid var(--border-2);
  border-radius: var(--radius-lg);
  /* 高档位泛紫：内圈紫边 + 外发光，透明度随能量增强 */
  box-shadow:
    inset 0 0 0 1px rgba(147, 51, 234, var(--row-a, 0)),
    0 12px 24px -16px rgba(147, 51, 234, var(--row-a, 0));
  transition: box-shadow 0.25s;
}
.effort-head {
  display: flex; align-items: baseline; justify-content: space-between;
  padding: 0 2px 12px;
}
.effort-label { font-size: 11.5px; font-weight: 600; color: var(--text-3); }
.effort-value {
  font-family: var(--font-mono);
  font-size: 12px; font-weight: 600;
  color: var(--text-2);
}
.effort-desc {
  padding: 12px 2px 2px;
  font-size: 10.5px;
  color: var(--text-3);
}

.effort-track {
  position: relative;
  height: 28px;
  border-radius: var(--radius);          /* 圆角方形，不是胶囊 */
  background: var(--fill-3);
  box-shadow: inset 0 0 0 1px var(--border-2); /* 用内描边，保证内容高=28px 与旋钮等高 */
}
.effort-fill,
.effort-energy {
  position: absolute;
  top: 0; bottom: 0; left: 0;
  /* 与旋钮左缘同一套几何：28px + pct × (100% - 28px)，最高档正好铺满整条 */
  width: calc(28px + var(--pct, 0) * (100% - 28px));
  border-radius: var(--radius);
  pointer-events: none;
}
.effort-fill {
  background: linear-gradient(90deg, #4d93f8 0%, var(--fill-end, #4d93f8) 100%);
}
.effort-energy {
  opacity: var(--energy, 0);
  overflow: hidden;
  background:
    radial-gradient(130% 180% at 18% 50%, rgba(147, 51, 234, 0.55), transparent 62%),
    linear-gradient(90deg, rgba(124, 92, 255, 0.22), rgba(76, 29, 149, 0.78));
}
.effort-energy::after { /* 扫光 */
  content: "";
  position: absolute; inset: 0;
  background: linear-gradient(100deg, transparent 22%, rgba(255, 255, 255, 0.38) 50%, transparent 78%);
  transform: translateX(-110%);
  animation: effort-sweep 2.8s linear infinite;
}
@keyframes effort-sweep { to { transform: translateX(110%); } }

.effort-stars {
  position: absolute;
  top: 0; bottom: 0; left: 0;
  /* 星尘只在已填充区域内漂移，不飘到未点亮的灰轨道上 */
  width: calc(28px + var(--pct, 0) * (100% - 28px));
  overflow: hidden;
  border-radius: var(--radius);
  opacity: var(--star-a, 0);
  pointer-events: none;
}
.effort-star {
  position: absolute;
  left: 100%;
  width: 3px; height: 3px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 6px rgba(216, 204, 255, 0.95);
  transform: scale(var(--b, 1));
  animation-name: effort-drift;
  animation-timing-function: linear;
  animation-iteration-count: infinite;
}
@keyframes effort-drift {
  0% { left: 100%; opacity: 0; }
  8% { opacity: var(--b, 1); }
  88% { opacity: var(--b, 1); }
  100% { left: -6%; opacity: 0; }
}

.effort-input {
  position: absolute; inset: 0;
  width: 100%; height: 28px;
  margin: 0;
  appearance: none; -webkit-appearance: none;
  background: transparent;
  cursor: pointer;
}
.effort-input::-webkit-slider-runnable-track { height: 28px; background: transparent; }
/* 旋钮隐形：星云条本身就是控制器（拖动命中区仍是 28px 全高） */
.effort-input::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 28px; height: 28px;
  border-radius: 7px;
  background: transparent;
  border: none;
  box-shadow: none;
}
.effort-input::-moz-range-track { height: 28px; background: transparent; border: none; }
.effort-input::-moz-range-thumb {
  width: 28px; height: 28px;
  border-radius: 7px;
  background: transparent;
  border: none;
}
.effort-input:focus { outline: none; }
.effort-input:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--accent) 65%, transparent);
  outline-offset: 2px;
  border-radius: var(--radius);
}

/* ---------- 11. 供应商列表 ---------- */
.provider-list { display: flex; flex-direction: column; gap: var(--sp-3); }
.provider-card {
  display: flex; align-items: center; gap: var(--sp-4);
  padding: var(--sp-4);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-2);
  background: var(--fill-4);
}
.provider-logo {
  width: 40px; height: 40px; flex: none;
  display: grid; place-items: center;
  border-radius: var(--radius);
  background: var(--grad);
  color: var(--on-grad); font-weight: 600; font-size: 15px;
}
.provider-info { flex: 1; min-width: 0; }
.provider-info strong { display: block; font-size: 13.5px; }
.provider-info p {
  font-family: var(--font-mono);
  font-size: 11px; color: var(--text-3);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.provider-info .tags { margin-top: 4px; display: flex; gap: 6px; flex-wrap: wrap; }
.tag {
  font-size: 10.5px;
  padding: 1px 8px;
  border-radius: var(--radius-full);
  background: var(--fill-3);
  color: var(--text-3);
}
.provider-actions { display: flex; gap: var(--sp-1); flex: none; }
.provider-actions button {
  display: inline-flex; align-items: center; gap: 4px;
  height: 30px; padding: 0 var(--sp-3);
  border-radius: var(--radius-sm);
  font-size: 11.5px;
  color: var(--text-2);
}
.provider-actions button:hover { background: var(--fill-3); color: var(--text); }
.provider-actions button.danger:hover { background: rgba(244, 65, 108, 0.12); color: #f4416c; }
.provider-actions svg { width: 13px; height: 13px; }
.provider-empty {
  padding: var(--sp-8);
  text-align: center;
  color: var(--text-3);
  font-size: 13px;
}
.danger-zone {
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-4);
  margin-top: var(--sp-5);
  padding: var(--sp-4);
  border-radius: var(--radius-lg);
  border: 1px dashed color-mix(in srgb, #f4416c 45%, transparent);
  background: rgba(244, 65, 108, 0.06);
}
.danger-zone strong { font-size: 13px; }
.danger-zone p { font-size: 11.5px; color: var(--text-3); margin-top: 2px; }

/* ---------- PWA 安装提示 ---------- */
.install-banner {
  position: fixed;
  left: 50%;
  bottom: calc(96px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-2) var(--sp-2) var(--sp-2) var(--sp-4);
  border-radius: var(--radius-full);
  background: var(--bg-elevated);
  border: 1px solid var(--border-2);
  box-shadow: var(--shadow-3);
  z-index: 90;
  animation: rise 0.24s var(--ease);
}
.install-banner > span {
  font-size: 12.5px;
  color: var(--text-2);
  white-space: nowrap;
}
.install-banner .btn-primary {
  height: 30px;
  padding: 0 var(--sp-4);
  border-radius: var(--radius-full);
}
.install-banner .icon-btn { width: 28px; height: 28px; }
@media (max-width: 900px) {
  .install-banner {
    left: var(--sp-3);
    right: var(--sp-3);
    transform: none;
    bottom: calc(120px + env(safe-area-inset-bottom, 0px));
  }
  .install-banner > span { white-space: normal; }
}

/* ---------- 12. Toast ---------- */
.toast-wrap {
  position: fixed; right: var(--sp-5); bottom: var(--sp-5);
  display: flex; flex-direction: column; gap: var(--sp-2);
  z-index: 200;
}
.toast {
  display: flex; align-items: center; gap: var(--sp-2);
  max-width: 380px;
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--radius);
  background: var(--bg-elevated);
  border: 1px solid var(--border-2);
  box-shadow: var(--shadow-3);
  font-size: 12.5px;
  animation: slide-in 0.22s var(--ease);
}
.toast .bar {
  width: 3px; align-self: stretch;
  border-radius: var(--radius-full);
  background: var(--grad);
}
.toast.err .bar { background: #f4416c; }
.toast.out { animation: slide-out 0.22s var(--ease) forwards; }

/* ---------- 13. Markdown ---------- */
.md { line-height: 1.75; }
.md > *:first-child { margin-top: 0 !important; }
.md > *:last-child { margin-bottom: 0 !important; }
.md h1, .md h2, .md h3, .md h4, .md h5, .md h6 {
  margin: 1.2em 0 0.5em;
  line-height: 1.35;
  letter-spacing: -0.2px;
}
.md h1 { font-size: 1.55em; }
.md h2 { font-size: 1.32em; padding-bottom: 0.3em; border-bottom: 1px solid var(--border-2); }
.md h3 { font-size: 1.16em; }
.md h4 { font-size: 1.05em; }
.md p { margin: 0.65em 0; }
.md a {
  color: var(--accent-2);
  text-decoration: none;
  border-bottom: 1px solid color-mix(in srgb, var(--accent-2) 40%, transparent);
}
.md a:hover { border-bottom-color: var(--accent-2); }
.md strong { font-weight: 600; }
.md ul, .md ol { margin: 0.65em 0; padding-left: 1.5em; }
.md li { margin: 0.25em 0; }
.md li::marker { color: var(--text-3); }
.md blockquote {
  margin: 0.9em 0;
  padding: var(--sp-2) var(--sp-4);
  border-left: 3px solid var(--accent);
  background: var(--fill-4);
  border-radius: 0 var(--radius) var(--radius) 0;
  color: var(--text-2);
}
.md hr {
  border: none;
  height: 1px;
  background: var(--border-2);
  margin: 1.4em 0;
}
.md img { max-width: 100%; border-radius: var(--radius); }
.md code {
  font-family: var(--font-mono);
  font-size: 0.875em;
  padding: 0.15em 0.42em;
  border-radius: var(--radius-xs);
  background: var(--fill-3);
  border: 1px solid var(--border-2);
}
.md .table-wrap {
  overflow-x: auto;
  margin: 0.9em 0;
  border: 1px solid var(--border-2);
  border-radius: var(--radius);
}
.md table { border-collapse: collapse; width: 100%; font-size: 0.92em; }
.md th, .md td {
  padding: var(--sp-2) var(--sp-3);
  border-bottom: 1px solid var(--border-2);
  text-align: left;
  white-space: nowrap;
}
.md th { background: var(--fill-3); font-weight: 600; }
.md tr:last-child td { border-bottom: none; }

.code-block {
  margin: 0.9em 0;
  border-radius: var(--radius);
  border: 1px solid var(--code-border);
  background: var(--bg-secondary);
  overflow: hidden;
}
.code-head {
  display: flex; align-items: center; gap: var(--sp-2);
  padding: 6px var(--sp-3);
  background: var(--fill-4);
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  list-style: none;
  user-select: none;
}
.code-head::-webkit-details-marker { display: none; }
.code-block:not([open]) .code-head { border-bottom: none; }
.code-chev {
  width: 13px; height: 13px; flex: none;
  color: var(--text-3);
  transition: transform 0.18s var(--ease);
}
.code-block[open] .code-chev { transform: rotate(90deg); }
.code-lang {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-3);
  text-transform: lowercase;
}
.code-meta { font-size: 11px; color: var(--text-4); }
.code-actions {
  margin-left: auto;
  display: flex; align-items: center; gap: var(--sp-3);
}
.code-toggle { font-size: 11px; color: var(--text-3); }
.code-block .when-open { display: none; }
.code-block[open] .when-open { display: inline; }
.code-block[open] .when-closed { display: none; }
.code-copy {
  display: inline-flex; align-items: center; gap: 4px;
  height: 24px; padding: 0 var(--sp-2);
  border-radius: var(--radius-xs);
  font-size: 11px;
  color: var(--text-3);
  transition: background 0.14s, color 0.14s;
}
.code-copy:hover { background: var(--fill-3); color: var(--text); }
.code-copy svg { width: 12px; height: 12px; }
.code-block pre {
  margin: 0;
  padding: var(--sp-3) var(--sp-4);
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 12.5px;
  line-height: 1.65;
  tab-size: 2;
}
.code-block code { background: none; border: none; padding: 0; font-size: inherit; }
.tok-com { color: var(--text-3); font-style: italic; }
.tok-str { color: #a5d6a7; }
.tok-num { color: #ffcb6b; }
.tok-key { color: #c792ea; }
.tok-fn { color: #82aaff; }
[data-theme="light"] .tok-str { color: #2e7d32; }
[data-theme="light"] .tok-num { color: #b26a00; }
[data-theme="light"] .tok-key { color: #7b1fa2; }
[data-theme="light"] .tok-fn { color: #1565c0; }

/* ---------- 14. 动画 & 响应式 ---------- */
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes pop { from { opacity: 0; transform: scale(0.96) translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes blink { 0%, 80%, 100% { opacity: 0.25; transform: scale(0.85); } 40% { opacity: 1; transform: scale(1); } }
@keyframes slide-in { from { opacity: 0; transform: translateX(16px); } to { opacity: 1; transform: none; } }
@keyframes slide-out { to { opacity: 0; transform: translateX(16px); } }

.sidebar-overlay {
  position: fixed; inset: 0;
  background: var(--backdrop);
  z-index: 40;
  display: none;
}
.only-mobile { display: none; }

@media (max-width: 900px) {
  .only-mobile { display: grid; }
  .sidebar {
    position: fixed; inset: 0 auto 0 0;
    z-index: 50;
    transform: translateX(-100%);
    transition: transform 0.24s var(--ease);
    background: var(--bg-container);
    width: min(84vw, var(--sidebar-w));
    padding-bottom: calc(var(--sp-4) + env(safe-area-inset-bottom, 0px));
  }
  .sidebar.open { transform: none; }
  .sidebar-overlay.show { display: block; }

  .topbar { padding: 0 var(--sp-2) 0 var(--sp-3); gap: var(--sp-2); }
  .topbar-title h2 { font-size: 14px; }
  .topbar-title p { display: none; }           /* 小屏隐藏副标题 */
  .topbar-actions { gap: 2px; }
  .model-btn { max-width: 44vw; padding: 0 var(--sp-2); }
  .model-btn .model-name { font-size: 11px; }
  .composer-tools .model-btn { height: 38px; }  /* 触屏可点区域加大 */
  .icon-btn { width: 34px; height: 34px; }

  .chat-inner { padding: var(--sp-4) var(--sp-3) var(--sp-5); }
  .messages { gap: var(--sp-5); }
  .msg { gap: var(--sp-2); }
  .msg-avatar { width: 28px; height: 28px; font-size: 12px; }
  .msg-content { font-size: 14px; }
  .msg.user .msg-content { padding: var(--sp-2) var(--sp-3); }

  .composer-area {
    padding: 0 var(--sp-3) calc(var(--sp-3) + env(safe-area-inset-bottom, 0px));
  }
  .composer { padding: var(--sp-2) var(--sp-3) var(--sp-2); }
  /* iOS 聚焦缩放规避：输入控件字号 ≥ 16px */
  .composer textarea { font-size: 16px; max-height: 40vh; }
  .composer-tools .chip-btn { display: none; }  /* 小屏隐藏次要胶囊，保留模型选择器 */
  .composer-send .btn-primary,
  .composer-send .btn-ghost { padding: 0 var(--sp-3); } /* 双按钮并排时收窄内距 */
  .composer-hint { display: none; }

  .dropdown-up {
    width: min(344px, calc(100vw - 28px));
    max-height: 44vh;
  }

  .hero { padding: var(--sp-6) var(--sp-2) var(--sp-4); }
  .hero h2 { font-size: 21px; }
  .hero p { font-size: 13px; }
  .suggest-grid { grid-template-columns: 1fr; margin-top: var(--sp-5); }

  /* 弹窗改为底部抽屉 */
  .modal-backdrop { align-items: end; padding: 0; }
  .modal {
    max-width: none;
    max-height: 92dvh;
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }
  .modal-body { padding-bottom: var(--sp-4); }
  .modal-foot { padding-bottom: calc(var(--sp-4) + env(safe-area-inset-bottom, 0px) / 2); }
  .field input[type="text"], .field input[type="url"], .field input[type="password"],
  .field input[type="search"], .field textarea, .input-group input {
    font-size: 16px;
    height: 44px;
  }
  .field textarea { height: auto; }

  .model-grid { grid-template-columns: 1fr 1fr; max-height: 44vh; }
  .model-card { padding: var(--sp-2); }
  .picker-toolbar { flex-wrap: wrap; }
  .picker-toolbar .search-box { min-width: 100%; }

  .provider-card { flex-wrap: wrap; }
  .provider-actions { width: 100%; justify-content: flex-end; }
  .provider-actions button { height: 36px; padding: 0 var(--sp-3); }
  .avatar-editor { flex-direction: column; align-items: flex-start; }
  .danger-zone { flex-direction: column; align-items: stretch; }
  .danger-zone .btn-danger { width: 100%; }

  .toast-wrap { left: var(--sp-3); right: var(--sp-3); bottom: calc(var(--sp-3) + env(safe-area-inset-bottom, 0px)); }
  .toast { max-width: none; }
  .btn-primary, .btn-outline, .btn-ghost, .btn-danger { height: 40px; }
}

/* 触屏设备没有 hover：操作按钮直接常显 */
@media (hover: none) {
  .msg-actions { opacity: 1; }
  .conv-item .conv-actions { display: flex; }
  .conv-item .conv-actions button { width: 28px; height: 28px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
