/* ===================== 主题变量 ===================== */
:root {
  --radius: 14px;
  --radius-sm: 10px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  --mono: "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
}

.theme-dark {
  --bg: #0f1115;
  --bg-elev: #161a21;
  --bg-elev-2: #1d232c;
  --bg-hover: #232a34;
  --border: #262d38;
  --border-soft: #1e242d;
  --text: #e6e9ef;
  --text-dim: #98a2b3;
  --text-faint: #667085;
  --accent: #4f8cff;
  --accent-soft: rgba(79, 140, 255, 0.14);
  --accent-text: #ffffff;
  --user-bubble: #2b5fd9;
  --user-text: #ffffff;
  --ai-bubble: #181d25;
  --danger: #ff5c5c;
  --danger-soft: rgba(255, 92, 92, 0.12);
  --ok: #2ecc8f;
  --code-bg: #10141a;
  --shadow: 0 8px 30px rgba(0, 0, 0, 0.45);
  --scrollbar: #2a323d;
}

.theme-light {
  --bg: #f7f8fa;
  --bg-elev: #ffffff;
  --bg-elev-2: #f0f2f5;
  --bg-hover: #e9edf2;
  --border: #e2e6ec;
  --border-soft: #edf0f4;
  --text: #14181f;
  --text-dim: #5b6675;
  --text-faint: #8a94a3;
  --accent: #2563eb;
  --accent-soft: rgba(37, 99, 235, 0.1);
  --accent-text: #ffffff;
  --user-bubble: #2563eb;
  --user-text: #ffffff;
  --ai-bubble: #ffffff;
  --danger: #e5484d;
  --danger-soft: rgba(229, 72, 77, 0.1);
  --ok: #12a66f;
  --code-bg: #f2f4f7;
  --shadow: 0 8px 30px rgba(16, 24, 40, 0.12);
  --scrollbar: #c9d0da;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0; padding: 0; height: 100%; overflow: hidden;
  background: var(--bg); color: var(--text);
  font-family: var(--font);
  font-size: 15px; line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
button { cursor: pointer; border: none; background: none; }
input, textarea, select { outline: none; }

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-thumb { background: var(--scrollbar); border-radius: 3px; }
::-webkit-scrollbar-track { background: transparent; }

/* ===================== 侧边栏 ===================== */
.sidebar-mask {
  position: fixed; inset: 0; background: rgba(0, 0, 0, 0.5);
  opacity: 0; pointer-events: none; transition: opacity .25s; z-index: 40;
  backdrop-filter: blur(2px);
}
.sidebar-mask.show { opacity: 1; pointer-events: auto; }

.sidebar {
  position: fixed; top: 0; left: 0; bottom: 0; width: 280px; max-width: 84vw;
  background: var(--bg-elev); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; z-index: 50;
  transform: translateX(-102%); transition: transform .28s cubic-bezier(.4,0,.2,1);
  padding-top: env(safe-area-inset-top);
}
.sidebar.open { transform: translateX(0); }

.sidebar-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 14px 10px;
}
.brand { display: flex; align-items: center; gap: 8px; font-size: 17px; font-weight: 600; }
.brand-logo { color: var(--accent); font-size: 20px; }
.brand-name b { color: var(--accent); font-weight: 700; }

.icon-btn {
  width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center;
  color: var(--text-dim); font-size: 16px; transition: background .15s, color .15s;
  flex-shrink: 0;
}
.icon-btn:hover, .icon-btn:active { background: var(--bg-hover); color: var(--text); }

.new-chat-btn {
  margin: 4px 12px 10px; padding: 10px 14px; border-radius: var(--radius);
  background: var(--accent); color: var(--accent-text);
  font-weight: 600; font-size: 14px; display: flex; align-items: center; gap: 8px;
  justify-content: center; box-shadow: 0 4px 14px rgba(79, 140, 255, 0.25);
  transition: filter .15s, transform .1s;
}
.new-chat-btn:active { transform: scale(.98); }
.new-chat-btn:hover { filter: brightness(1.08); }
.new-chat-btn .plus { font-size: 17px; }

.sidebar-search { padding: 0 12px 8px; }
.sidebar-search input {
  width: 100%; padding: 8px 12px; border-radius: 9px; font-size: 13px;
  background: var(--bg-elev-2); border: 1px solid var(--border-soft);
  color: var(--text);
}
.sidebar-search input::placeholder { color: var(--text-faint); }

.conv-list { flex: 1; overflow-y: auto; padding: 4px 8px 8px; }
.conv-item {
  display: flex; align-items: center; gap: 8px; padding: 9px 10px;
  border-radius: var(--radius-sm); cursor: pointer; margin-bottom: 2px;
  transition: background .15s;
}
.conv-item:hover { background: var(--bg-hover); }
.conv-item.active { background: var(--accent-soft); }
.conv-item.active .conv-title { color: var(--accent); }
.conv-icon { font-size: 13px; color: var(--text-faint); flex-shrink: 0; }
.conv-body { flex: 1; min-width: 0; }
.conv-title {
  font-size: 13.5px; font-weight: 500; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
}
.conv-meta { font-size: 11px; color: var(--text-faint); margin-top: 1px; }
.conv-del {
  opacity: 0; width: 24px; height: 24px; border-radius: 6px; color: var(--text-faint);
  display: grid; place-items: center; font-size: 13px; flex-shrink: 0;
}
.conv-item:hover .conv-del { opacity: 1; }
.conv-del:hover { background: var(--danger-soft); color: var(--danger); }

.sidebar-foot {
  display: flex; gap: 6px; padding: 8px 10px; border-top: 1px solid var(--border-soft);
}
.foot-btn {
  flex: 1; padding: 7px 4px; border-radius: 8px; font-size: 11.5px;
  color: var(--text-dim); display: flex; flex-direction: column;
  align-items: center; gap: 3px; transition: background .15s;
}
.foot-btn span { font-size: 15px; }
.foot-btn:hover { background: var(--bg-hover); color: var(--text); }
.foot-btn.danger:hover { background: var(--danger-soft); color: var(--danger); }
.sidebar-ver {
  text-align: center; font-size: 10.5px; color: var(--text-faint);
  padding: 0 0 calc(8px + env(safe-area-inset-bottom));
}

/* ===================== 主区域 ===================== */
.main {
  height: 100%; display: flex; flex-direction: column;
  padding-top: env(safe-area-inset-top);
}

.topbar {
  display: flex; align-items: center; gap: 6px; padding: 8px 10px;
  border-bottom: 1px solid var(--border-soft); background: var(--bg);
  flex-shrink: 0; z-index: 10;
}
.topbar-title {
  flex: 1; font-size: 15px; font-weight: 600; text-align: center;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.topbar-actions { display: flex; align-items: center; gap: 2px; }
.model-badge {
  font-size: 10.5px; padding: 3px 8px; border-radius: 20px;
  background: var(--bg-elev-2); color: var(--text-dim);
  border: 1px solid var(--border-soft); max-width: 110px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.chat-scroll {
  flex: 1; overflow-y: auto; overflow-x: hidden; position: relative;
  scroll-behavior: smooth; -webkit-overflow-scrolling: touch;
}
.messages { padding: 16px 12px 8px; max-width: 860px; margin: 0 auto; }

/* 空状态 */
.empty-state {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; padding: 24px; text-align: center;
  pointer-events: none; opacity: 1; transition: opacity .2s;
}
.empty-state.hide { opacity: 0; pointer-events: none; }
.empty-logo { font-size: 44px; color: var(--accent); margin-bottom: 12px; opacity: .85; }
.empty-state h1 { font-size: 22px; margin: 0 0 8px; font-weight: 600; }
.empty-state p { color: var(--text-dim); font-size: 13px; margin: 0 0 22px; line-height: 1.7; }
.quick-prompts {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
  max-width: 460px; width: 100%; pointer-events: auto;
}
.quick-prompts button {
  padding: 11px 12px; border-radius: var(--radius-sm); font-size: 12.5px;
  background: var(--bg-elev); border: 1px solid var(--border-soft);
  color: var(--text-dim); text-align: left; line-height: 1.4;
  transition: all .15s;
}
.quick-prompts button:hover {
  border-color: var(--accent); color: var(--text); background: var(--accent-soft);
}

/* ===================== 消息气泡 ===================== */
.msg { display: flex; margin-bottom: 16px; gap: 9px; animation: fadeUp .25s ease; }
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}
.msg.user { flex-direction: row-reverse; }

.avatar {
  width: 28px; height: 28px; border-radius: 9px; flex-shrink: 0;
  display: grid; place-items: center; font-size: 13px; font-weight: 600;
  margin-top: 2px;
}
.msg.user .avatar { background: var(--user-bubble); color: #fff; }
.msg.assistant .avatar { background: var(--accent-soft); color: var(--accent); }

.bubble-wrap { max-width: min(82%, 680px); min-width: 0; display: flex; flex-direction: column; }
.msg.user .bubble-wrap { align-items: flex-end; }

.bubble {
  padding: 10px 14px; border-radius: var(--radius); font-size: 14.5px;
  word-wrap: break-word; overflow-wrap: anywhere; position: relative;
}
.msg.user .bubble {
  background: var(--user-bubble); color: var(--user-text);
  border-bottom-right-radius: 5px;
}
.msg.assistant .bubble {
  background: var(--ai-bubble); color: var(--text);
  border: 1px solid var(--border-soft); border-bottom-left-radius: 5px;
}
.msg.error .bubble {
  background: var(--danger-soft); color: var(--danger);
  border: 1px solid rgba(255, 92, 92, .3);
}

.msg-actions {
  display: flex; gap: 2px; margin-top: 4px; opacity: 0;
  transition: opacity .15s; padding: 0 2px;
}
.msg:hover .msg-actions, .msg-actions.show { opacity: 1; }
.msg-act {
  width: 26px; height: 26px; border-radius: 7px; display: grid; place-items: center;
  color: var(--text-faint); font-size: 12px;
}
.msg-act:hover { background: var(--bg-hover); color: var(--text); }
.msg-meta { font-size: 10.5px; color: var(--text-faint); margin-top: 3px; padding: 0 3px; }

/* 加载动画 */
.typing { display: inline-flex; gap: 4px; align-items: center; height: 20px; }
.typing i {
  width: 6px; height: 6px; border-radius: 50%; background: var(--text-faint);
  animation: blink 1.3s infinite ease-in-out both;
}
.typing i:nth-child(2) { animation-delay: .18s; }
.typing i:nth-child(3) { animation-delay: .36s; }
@keyframes blink {
  0%, 80%, 100% { opacity: .25; transform: scale(.85); }
  40% { opacity: 1; transform: scale(1); }
}

/* 光标 */
.cursor-blink::after {
  content: "▍"; color: var(--accent); animation: cb 1s steps(2) infinite;
  margin-left: 1px;
}
@keyframes cb { 50% { opacity: 0; } }

/* ===================== Markdown ===================== */
.bubble p { margin: 0 0 .7em; }
.bubble p:last-child { margin-bottom: 0; }
.bubble h1, .bubble h2, .bubble h3, .bubble h4 {
  margin: 1em 0 .5em; line-height: 1.35; font-weight: 650;
}
.bubble h1 { font-size: 1.35em; }
.bubble h2 { font-size: 1.22em; }
.bubble h3 { font-size: 1.1em; }
.bubble h4 { font-size: 1em; }
.bubble > *:first-child { margin-top: 0; }
.bubble ul, .bubble ol { margin: .4em 0 .8em; padding-left: 1.4em; }
.bubble li { margin: .22em 0; }
.bubble li > p { margin: 0; }
.bubble a { color: var(--accent); text-decoration: none; border-bottom: 1px solid var(--accent-soft); }
.bubble a:hover { text-decoration: underline; }
.bubble hr { border: none; border-top: 1px solid var(--border); margin: 1em 0; }
.bubble img { max-width: 100%; border-radius: 8px; margin: .4em 0; }

.bubble blockquote {
  margin: .6em 0; padding: .3em 0 .3em 12px;
  border-left: 3px solid var(--border); color: var(--text-dim);
}
.msg.user .bubble blockquote { border-color: rgba(255,255,255,.4); color: rgba(255,255,255,.85); }

.bubble code {
  font-family: var(--mono); font-size: .88em;
  background: var(--bg-elev-2); padding: .12em .38em; border-radius: 4px;
}
.msg.user .bubble code { background: rgba(255,255,255,.18); }

.code-block {
  margin: .7em 0; border-radius: var(--radius-sm); overflow: hidden;
  background: var(--code-bg); border: 1px solid var(--border-soft);
}
.code-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 5px 10px; font-size: 11px; color: var(--text-faint);
  background: var(--bg-elev-2); border-bottom: 1px solid var(--border-soft);
}
.copy-code {
  font-size: 11px; color: var(--text-dim); padding: 2px 8px; border-radius: 5px;
}
.copy-code:hover { background: var(--bg-hover); color: var(--text); }
.code-block pre {
  margin: 0; padding: 10px 12px; overflow-x: auto;
  font-family: var(--mono); font-size: 12.5px; line-height: 1.55;
  color: var(--text);
}
.code-block pre code { background: none; padding: 0; font-size: inherit; }

.bubble table {
  border-collapse: collapse; margin: .7em 0; font-size: .92em;
  display: block; overflow-x: auto; max-width: 100%;
}
.bubble th, .bubble td { border: 1px solid var(--border); padding: 6px 10px; text-align: left; }
.bubble th { background: var(--bg-elev-2); font-weight: 600; }

/* ===================== 输入区 ===================== */
.composer-wrap {
  flex-shrink: 0; padding: 6px 12px calc(8px + env(safe-area-inset-bottom));
  background: var(--bg); max-width: 860px; margin: 0 auto; width: 100%;
}
.composer {
  background: var(--bg-elev); border: 1px solid var(--border);
  border-radius: 18px; padding: 8px 8px 6px 14px;
  transition: border-color .15s, box-shadow .15s;
}
.composer:focus-within {
  border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft);
}
#input {
  width: 100%; border: none; background: none; resize: none;
  padding: 4px 0; max-height: 160px; line-height: 1.5; font-size: 15px;
  color: var(--text);
}
#input::placeholder { color: var(--text-faint); }

.composer-bar { display: flex; align-items: center; justify-content: space-between; margin-top: 2px; }
.composer-left { display: flex; gap: 5px; align-items: center; }
.chip {
  font-size: 11.5px; padding: 4px 9px; border-radius: 14px;
  background: var(--bg-elev-2); color: var(--text-dim);
  border: 1px solid var(--border-soft); transition: all .15s;
}
.chip:hover { color: var(--text); border-color: var(--border); }
.chip.stop { background: var(--danger-soft); color: var(--danger); border-color: rgba(255,92,92,.3); }

.send-btn {
  width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center;
  background: var(--accent); color: #fff; transition: all .15s; flex-shrink: 0;
}
.send-btn:hover { filter: brightness(1.1); }
.send-btn:active { transform: scale(.93); }
.send-btn:disabled { opacity: .35; cursor: not-allowed; }

.composer-tip {
  text-align: center; font-size: 10.5px; color: var(--text-faint);
  margin-top: 5px; min-height: 13px;
}

.scroll-bottom {
  position: absolute; right: 16px; bottom: 14px; width: 34px; height: 34px;
  border-radius: 50%; background: var(--bg-elev); border: 1px solid var(--border);
  color: var(--text-dim); display: grid; place-items: center; font-size: 15px;
  box-shadow: var(--shadow); opacity: 0; pointer-events: none; transition: opacity .2s;
  z-index: 5;
}
.scroll-bottom.show { opacity: 1; pointer-events: auto; }

/* ===================== 弹层 ===================== */
.sheet-mask {
  position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 60;
  opacity: 0; pointer-events: none; transition: opacity .22s;
}
.sheet-mask.show { opacity: 1; pointer-events: auto; }

.sheet {
  position: fixed; z-index: 61; background: var(--bg-elev);
  left: 0; right: 0; bottom: 0; max-height: 88vh;
  border-radius: 20px 20px 0 0; display: flex; flex-direction: column;
  transform: translateY(102%); transition: transform .3s cubic-bezier(.4,0,.2,1);
  box-shadow: var(--shadow);
}
.sheet.show { transform: translateY(0); }
.sheet.small { max-height: 60vh; }

.sheet-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px 8px; flex-shrink: 0;
}
.sheet-head h2 { margin: 0; font-size: 16.5px; font-weight: 650; }
.sheet-head::before {
  content: ""; position: absolute; top: 6px; left: 50%; transform: translateX(-50%);
  width: 36px; height: 4px; border-radius: 2px; background: var(--border);
}

.sheet-tabs {
  display: flex; gap: 4px; padding: 0 12px 8px; flex-shrink: 0;
  overflow-x: auto; border-bottom: 1px solid var(--border-soft);
}
.tab {
  padding: 7px 14px; border-radius: 8px; font-size: 13px; color: var(--text-dim);
  white-space: nowrap; transition: all .15s;
}
.tab:hover { background: var(--bg-hover); }
.tab.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }

.sheet-body {
  flex: 1; overflow-y: auto; padding: 14px 16px calc(22px + env(safe-area-inset-bottom));
}
.sheet.small .sheet-body { padding-top: 8px; }

.tab-pane { display: none; }
.tab-pane.active { display: block; animation: fadeUp .2s ease; }

.field { display: block; margin-bottom: 16px; }
.field-label { display: block; font-size: 12.5px; font-weight: 600; color: var(--text-dim); margin-bottom: 6px; }
.field-label b { color: var(--accent); font-weight: 600; }
.field input[type="text"], .field input[type="password"], .field select, .field textarea {
  width: 100%; padding: 9px 12px; border-radius: var(--radius-sm);
  background: var(--bg-elev-2); border: 1px solid var(--border);
  color: var(--text); font-size: 14px; transition: border-color .15s;
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--accent); }
.field textarea { resize: vertical; line-height: 1.55; }
.field-hint { display: block; font-size: 11px; color: var(--text-faint); margin-top: 5px; line-height: 1.5; }
.input-row { display: flex; gap: 6px; }
.input-row input { flex: 1; min-width: 0; }
.mini-btn {
  padding: 0 12px; border-radius: var(--radius-sm); background: var(--bg-elev-2);
  border: 1px solid var(--border); color: var(--text-dim); font-size: 12.5px;
  white-space: nowrap; flex-shrink: 0;
}
.mini-btn:hover { color: var(--text); border-color: var(--accent); }

input[type="range"] {
  width: 100%; -webkit-appearance: none; height: 4px; border-radius: 2px;
  background: var(--bg-elev-2); outline: none; margin: 8px 0;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 18px; height: 18px; border-radius: 50%;
  background: var(--accent); cursor: pointer; border: 2px solid var(--bg-elev);
  box-shadow: 0 1px 4px rgba(0,0,0,.3);
}

.switch-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 11px 0; border-bottom: 1px solid var(--border-soft); font-size: 14px;
}
.switch-row:last-child { border-bottom: none; }
.switch-row input[type="checkbox"] {
  -webkit-appearance: none; appearance: none; width: 44px; height: 25px;
  border-radius: 13px; background: var(--bg-elev-2); position: relative;
  cursor: pointer; transition: background .2s; flex-shrink: 0;
  border: 1px solid var(--border);
}
.switch-row input[type="checkbox"]::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 19px; height: 19px;
  border-radius: 50%; background: var(--text-faint); transition: all .2s;
}
.switch-row input[type="checkbox"]:checked { background: var(--accent); border-color: var(--accent); }
.switch-row input[type="checkbox"]:checked::after { left: 21px; background: #fff; }

.seg {
  display: flex; gap: 4px; background: var(--bg-elev-2); padding: 3px;
  border-radius: var(--radius-sm); border: 1px solid var(--border);
}
.seg button {
  flex: 1; padding: 7px 8px; border-radius: 8px; font-size: 12.5px;
  color: var(--text-dim); transition: all .15s;
}
.seg button.active { background: var(--accent); color: #fff; font-weight: 600; }

.preset-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.preset-chips button {
  padding: 6px 12px; border-radius: 16px; font-size: 12.5px;
  background: var(--bg-elev-2); border: 1px solid var(--border-soft);
  color: var(--text-dim); transition: all .15s;
}
.preset-chips button:hover { border-color: var(--accent); color: var(--accent); }

.primary-btn {
  width: 100%; padding: 11px; border-radius: var(--radius-sm);
  background: var(--accent); color: #fff; font-weight: 600; font-size: 14px;
  margin-bottom: 8px; transition: filter .15s;
}
.primary-btn:hover { filter: brightness(1.08); }
.primary-btn:disabled { opacity: .5; cursor: not-allowed; }

.ghost-btn {
  width: 100%; padding: 11px; border-radius: var(--radius-sm);
  background: var(--bg-elev-2); border: 1px solid var(--border);
  color: var(--text); font-size: 13.5px; margin-bottom: 8px; text-align: left;
  transition: all .15s;
}
.ghost-btn:hover { border-color: var(--accent); background: var(--accent-soft); }
.ghost-btn.danger { color: var(--danger); border-color: rgba(255,92,92,.25); }
.ghost-btn.danger:hover { background: var(--danger-soft); }

.test-result { font-size: 12.5px; line-height: 1.6; margin-top: 4px; word-break: break-word; }
.test-result.ok { color: var(--ok); }
.test-result.err { color: var(--danger); }
.test-result .loading { color: var(--text-dim); }

.data-stat {
  padding: 12px 14px; border-radius: var(--radius-sm); background: var(--bg-elev-2);
  font-size: 12.5px; color: var(--text-dim); margin-bottom: 14px; line-height: 1.8;
}

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: 84px; transform: translate(-50%, 12px);
  background: rgba(30, 36, 45, .96); color: #fff; padding: 9px 18px;
  border-radius: 20px; font-size: 13px; z-index: 200;
  opacity: 0; pointer-events: none; transition: all .25s;
  box-shadow: 0 6px 20px rgba(0,0,0,.4); max-width: 82vw; text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* 桌面端 */
@media (min-width: 900px) {
  .sidebar { transform: translateX(0); width: 268px; }
  .sidebar-mask { display: none; }
  .main { margin-left: 268px; }
  #btnOpenSidebar, #btnCloseSidebar { display: none; }
  .sheet {
    left: 50%; right: auto; bottom: auto; top: 50%;
    transform: translate(-50%, -46%); width: 520px; max-height: 84vh;
    border-radius: 16px; opacity: 0; transition: transform .22s, opacity .22s;
  }
  .sheet.show { transform: translate(-50%, -50%); opacity: 1; }
  .sheet-head::before { display: none; }
  .sheet-mask { backdrop-filter: blur(3px); }
  .topbar-title { text-align: left; }
}

/* 诊断信息块 */
.diag {
  margin-top: 10px; padding: 9px 11px; border-radius: 8px;
  background: var(--bg-elev-2); border: 1px solid var(--border-soft);
  font-size: 11.5px; color: var(--text-dim); line-height: 1.7;
  font-family: var(--mono); word-break: break-all;
}

/* ===================== 模型选择面板 ===================== */
.model-pick-tip {
  font-weight: 400; font-size: 11px; color: var(--text-faint); margin-left: 6px;
}
.model-search { margin-bottom: 8px; }
.model-search input {
  width: 100%; padding: 7px 11px; border-radius: 8px; font-size: 12.5px;
  background: var(--bg-elev-2); border: 1px solid var(--border);
  color: var(--text);
}
.model-pick-list {
  max-height: 260px; overflow-y: auto; display: flex; flex-direction: column; gap: 3px;
  padding: 4px; border-radius: var(--radius-sm);
  background: var(--bg-elev-2); border: 1px solid var(--border)
}
.model-pick-item {
  display: flex; align-items: center; gap: 6px; padding: 8px 10px;
  border-radius: 8px; cursor: pointer; font-size: 12.5px;
  font-family: var(--mono); transition: background .12s;
  text-align: left; width: 100%;
}
.model-pick-item:hover { background: var(--bg-hover); }
.model-pick-item.active {
  background: var(--accent-soft); color: var(--accent); font-weight: 600;
}
.model-pick-item .mp-brand {
  width: 16px; height: 16px; border-radius: 4px; flex-shrink: 0;
  display: grid; place-items: center; font-size: 9px; font-weight: 700; color: #fff;
}
.model-pick-item .mp-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.model-pick-item .mp-check { color: var(--accent); font-size: 12px; }
.model-empty { padding: 16px; text-align: center; color: var(--text-faint); font-size: 12px; }

/* ===================== 头像选择 ===================== */
.avatar-picker { display: flex; align-items: center; gap: 14px; margin-bottom: 12px; }
.avatar-preview .avatar {
  width: 52px; height: 52px; border-radius: 15px; font-size: 21px;
}
.avatar-actions { display: flex; flex-direction: column; gap: 6px; flex: 1; }
.avatar-actions .mini-btn { padding: 7px 12px; }

.avatar-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(44px, 1fr)); gap: 7px;
}
.avatar-opt {
  aspect-ratio: 1; border-radius: 11px; display: grid; place-items: center;
  font-size: 18px; cursor: pointer; border: 2px solid transparent;
  transition: transform .12s, border-color .12s; overflow: hidden;
  background: var(--bg-elev-2);
}
.avatar-opt:hover { transform: scale(1.08); border-color: var(--border); }
.avatar-opt.active { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.avatar-opt img { width: 100%; height: 100%; object-fit: cover; }

/* 带图片/渐变/表情的头像渲染 */
.avatar {
  background-size: cover; background-position: center; overflow: hidden;
}
.avatar.is-img { padding: 0; }
.avatar.is-img img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* ===================== AI 品牌头像 ===================== */
.msg.assistant .avatar.ai-avatar {
  color: #fff; font-size: 12px; font-weight: 700;
  letter-spacing: -.3px;
}
.msg.assistant .avatar.ai-avatar svg { width: 15px; height: 15px; }

/* 模型名标签 */
.msg-model-name {
  font-size: 10.5px; color: var(--text-faint); margin-bottom: 3px;
  padding: 0 3px; display: flex; align-items: center; gap: 5px;
  font-family: var(--mono);
}
.msg-model-name .dot {
  width: 5px; height: 5px; border-radius: 50%; background: var(--accent);
  flex-shrink: 0;
}
