/* ============ 星空AI · 暗色主题 ============ */
:root {
  --bg: #0a0d14;
  --bg-soft: #0e121c;
  --panel: #121826;
  --panel-2: #1a2133;
  --panel-3: #232c44;
  --border: #1e2740;
  --border-2: #2b3657;
  --text: #e8ebf4;
  --text-dim: #9aa5c0;
  --text-faint: #626e8f;
  --accent: #4d6bfe;
  --accent-2: #8b5cf6;
  --gradient: linear-gradient(135deg, #4d6bfe 0%, #8b5cf6 100%);
  --danger: #f87171;
  --danger-bg: rgba(248, 113, 113, 0.12);
  --success: #34d399;
  --warn: #fbbf24;
  --user-bubble: #1d2a52;
  --code-bg: #0c1018;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
  --sidebar-w: 264px;
  --font: -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", "Noto Sans SC", "Helvetica Neue", sans-serif;
  --mono: "JetBrains Mono", "Cascadia Code", Consolas, "Courier New", monospace;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.65;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}
body::before {
  content: "";
  position: fixed; inset: 0;
  background:
    radial-gradient(900px 500px at 85% -10%, rgba(77, 107, 254, 0.13), transparent 60%),
    radial-gradient(700px 400px at -10% 110%, rgba(139, 92, 246, 0.10), transparent 60%);
  pointer-events: none;
  z-index: 0;
}
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, textarea { font-family: inherit; }

/* ============ 布局 ============ */
#app { display: flex; height: 100vh; position: relative; z-index: 1; }

/* ============ 侧边栏 ============ */
#sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: var(--bg-soft);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  transition: transform .25s ease;
  z-index: 30;
}
.sb-head { padding: 18px 14px 10px; }
.logo { display: flex; align-items: center; gap: 10px; padding: 2px 4px 12px; }
.logo-mark {
  width: 34px; height: 34px; border-radius: 10px;
  background: var(--gradient);
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 18px; color: #fff;
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.4);
}
.logo-mark.big { width: 52px; height: 52px; font-size: 26px; border-radius: 14px; margin: 0 auto 14px; }
.logo-txt { line-height: 1.25; }
.logo-name { font-weight: 700; font-size: 15px; letter-spacing: .3px; }
.logo-sub { font-size: 11.5px; color: var(--text-faint); margin-top: 2px; }

.btn-newchat {
  width: 100%; padding: 10px 12px;
  background: var(--gradient); color: #fff;
  border-radius: var(--radius); font-size: 14px; font-weight: 600;
  display: flex; align-items: center; justify-content: center; gap: 6px;
  transition: opacity .15s, transform .1s;
  box-shadow: 0 6px 18px rgba(99, 102, 241, 0.35);
}
.btn-newchat:hover { opacity: .92; }
.btn-newchat:active { transform: scale(.98); }

/* 对话搜索框 */
.sb-search {
  display: flex; align-items: center; gap: 7px;
  margin: 2px 14px 4px; padding: 7px 11px;
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 10px; color: var(--text-faint);
  transition: border-color .15s;
}
.sb-search:focus-within { border-color: var(--accent); }
.sb-search svg { flex-shrink: 0; opacity: .7; }
.sb-search input {
  flex: 1; min-width: 0; border: none; background: none; outline: none;
  color: var(--text); font-size: 13px;
}
.sb-search input::placeholder { color: var(--text-faint); }

.sb-label { font-size: 11.5px; color: var(--text-faint); padding: 12px 18px 6px; letter-spacing: 1px; }
.conv-list { flex: 1; overflow-y: auto; padding: 2px 10px 10px; }
.conv-list::-webkit-scrollbar, .chat-scroll::-webkit-scrollbar { width: 6px; }
.conv-list::-webkit-scrollbar-thumb, .chat-scroll::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 3px; }
.conv-empty { color: var(--text-faint); font-size: 13px; text-align: center; padding: 24px 10px; }

.conv-item {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 10px; border-radius: var(--radius-sm);
  color: var(--text-dim); font-size: 13.5px;
  cursor: pointer; margin-bottom: 2px; position: relative;
  transition: background .12s;
}
.conv-item:hover { background: var(--panel); color: var(--text); }
.conv-item.active { background: var(--panel-2); color: var(--text); }
.conv-item.active::before {
  content: ""; position: absolute; left: 0; top: 8px; bottom: 8px; width: 3px;
  border-radius: 2px; background: var(--gradient);
}
.conv-item .conv-ico { opacity: .6; font-size: 13px; }
.conv-item .conv-title { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-item .conv-time { font-size: 11px; color: var(--text-faint); white-space: nowrap; }
.conv-ops { display: none; gap: 2px; }
.conv-item:hover .conv-ops { display: flex; }
.conv-ops button {
  width: 22px; height: 22px; border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-faint); font-size: 11px;
}
.conv-ops button:hover { background: var(--panel-3); color: var(--text); }
.conv-ops button.del:hover { color: var(--danger); }
.conv-ops button.confirm-del { color: #fff; background: var(--danger); width: auto; padding: 0 6px; font-size: 11px; }

.sb-foot { padding: 12px 14px; border-top: 1px solid var(--border); }
.status-card {
  display: flex; align-items: center; gap: 8px;
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 8px 10px;
  font-size: 12.5px; color: var(--text-dim);
}
.status-card .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--warn); flex-shrink: 0; animation: pulse 1.6s infinite; }
.status-card .dot.ok { background: var(--success); animation: none; }
.status-card .dot.err { background: var(--danger); animation: none; }
.status-txt { line-height: 1.4; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .35; } }
.foot-actions { display: flex; justify-content: space-between; margin-top: 8px; font-size: 11.5px; color: var(--text-faint); }
.foot-right { display: flex; gap: 12px; align-items: center; }
.link-btn { color: var(--text-faint); font-size: 12px; }
.link-btn:hover { color: var(--danger); }
#btnExportSide:hover { color: var(--accent); }

.sidebar-mask { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 25; }

/* ============ 主区域 ============ */
#main { flex: 1; display: flex; flex-direction: column; min-width: 0; position: relative; }

#topbar {
  height: 56px; min-height: 56px;
  display: flex; align-items: center; gap: 10px;
  padding: 0 16px;
  border-bottom: 1px solid var(--border);
  background: rgba(10, 13, 20, 0.7);
  backdrop-filter: blur(10px);
  z-index: 10;
}
.icon-btn {
  width: 34px; height: 34px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-dim);
}
.icon-btn:hover { background: var(--panel-2); color: var(--text); }
/* 一键清除：危险红色 */
.icon-btn.sbx-clear { color: var(--text-faint); }
.icon-btn.sbx-clear:hover { background: rgba(248, 113, 113, .15); color: var(--danger); }
#btnSidebar { display: none; }
.top-title {
  flex: 1; font-weight: 600; font-size: 14.5px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  min-width: 0;
}
.top-title[contenteditable="true"] {
  outline: 1.5px solid var(--accent); border-radius: 6px;
  padding: 2px 8px; background: var(--panel);
}

/* ============ 聊天区 ============ */
.chat-scroll { flex: 1; overflow-y: auto; overscroll-behavior: contain; }
.chat {
  max-width: 840px; margin: 0 auto;
  padding: 28px 24px 40px;
  display: flex; flex-direction: column; gap: 22px;
}

/* 欢迎页 */
.welcome { text-align: center; padding: 9vh 8px 20px; animation: fadeUp .5s ease; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
.welcome .w-title {
  font-size: 34px; font-weight: 800; letter-spacing: .5px;
  background: var(--gradient);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  margin-bottom: 8px;
}
.welcome .w-sub { color: var(--text-dim); font-size: 14.5px; margin-bottom: 34px; }
.w-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; max-width: 560px; margin: 0 auto; }
.w-card {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px 18px; text-align: left;
  cursor: pointer; transition: border-color .15s, transform .1s, background .15s;
}
.w-card:hover { border-color: var(--accent); background: var(--panel-2); transform: translateY(-2px); }
.w-card .w-emoji { font-size: 22px; }
.w-card .w-name { font-weight: 600; font-size: 14px; margin: 8px 0 4px; }
.w-card .w-desc { font-size: 12.5px; color: var(--text-dim); line-height: 1.5; }

/* 用户消息 */
.msg-user { display: flex; justify-content: flex-end; }
.msg-user .bubble {
  max-width: 76%;
  background: var(--user-bubble);
  border: 1px solid var(--border-2);
  border-radius: 16px 16px 4px 16px;
  padding: 10px 16px;
  font-size: 14.5px;
  white-space: pre-wrap; word-break: break-word;
}
.msg-user .bubble .md-body > *:last-child { margin-bottom: 0; }

/* 助手消息 */
.msg-ai { display: flex; gap: 12px; animation: fadeUp .3s ease; }
.ai-avatar {
  width: 32px; height: 32px; border-radius: 10px; flex-shrink: 0;
  background: var(--gradient);
  display: flex; align-items: center; justify-content: center;
  font-size: 15px; color: #fff; font-weight: 700;
  box-shadow: 0 3px 12px rgba(99, 102, 241, .35);
  margin-top: 2px;
}
.ai-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 10px; }
.ai-meta { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text-faint); }
.ai-meta .ai-name { color: var(--text); font-weight: 600; font-size: 13px; }
.ai-meta .model-tag {
  background: var(--panel-2); border: 1px solid var(--border);
  padding: 1px 8px; border-radius: 20px; font-size: 11px; color: var(--text-dim);
}
.ai-meta .msg-time { }

/* 思考过程 */
.think {
  border: 1px solid var(--border);
  background: var(--bg-soft);
  border-radius: var(--radius);
  overflow: hidden;
}
.think-head {
  display: flex; align-items: center; gap: 7px;
  padding: 8px 14px; font-size: 12.5px; color: var(--text-dim);
  cursor: pointer; user-select: none;
}
.think-head:hover { color: var(--text); }
.think-head .chev { margin-left: auto; transition: transform .2s; color: var(--text-faint); }
.think.open .think-head .chev { transform: rotate(180deg); }
.think-body {
  display: none;
  padding: 0 14px 12px;
  font-size: 13px; line-height: 1.7;
  color: var(--text-dim);
  white-space: pre-wrap; word-break: break-word;
  font-family: var(--mono);
  border-top: 1px dashed var(--border);
}
.think.open .think-body { display: block; padding-top: 10px; }
.think.streaming .think-head .dot-anim::after {
  content: "思考中"; margin-left: 2px;
  animation: blink 1.2s infinite;
}
@keyframes blink { 50% { opacity: .3; } }

/* 工具卡片 */
.tool-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-soft);
  overflow: hidden;
  font-size: 13px;
}
.tool-card .tool-head {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 14px;
}
.tool-card .tool-ico { font-size: 14px; }
.tool-card .tool-name { font-weight: 600; color: var(--text); font-size: 13px; }
.tool-card .tool-args {
  color: var(--text-faint); font-family: var(--mono); font-size: 11.5px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  flex: 1; min-width: 0; margin-left: 4px;
}
.tool-card .tool-status { font-size: 12px; color: var(--text-faint); white-space: nowrap; }
.tool-card .tool-status .spinner {
  display: inline-block; width: 12px; height: 12px; margin-right: 5px;
  border: 2px solid var(--border-2); border-top-color: var(--accent);
  border-radius: 50%; animation: spin .8s linear infinite; vertical-align: -2px;
}
@keyframes spin { to { transform: rotate(360deg); } }
.tool-card.done .tool-status { color: var(--success); }
.tool-card.fail { border-color: rgba(248,113,113,.4); }
.tool-card.fail .tool-status { color: var(--danger); }
.tool-card .tool-result {
  display: none;
  border-top: 1px dashed var(--border);
  padding: 10px 14px;
  font-family: var(--mono); font-size: 12px; color: var(--text-dim);
  white-space: pre-wrap; word-break: break-word;
  max-height: 200px; overflow-y: auto;
  background: var(--code-bg);
}
.tool-card .tool-result.show { display: block; }
.tool-result-toggle {
  color: var(--text-faint); font-size: 12px; margin-left: 6px;
  padding: 2px 6px; border-radius: 6px; cursor: pointer;
}
.tool-result-toggle:hover { background: var(--panel-2); color: var(--text); }

/* 正文 Markdown */
.md-body { font-size: 14.5px; word-break: break-word; min-width: 0; }
.md-body > *:first-child { margin-top: 0; }
.md-body > *:last-child { margin-bottom: 0; }
.md-body p { margin: .6em 0; }
.md-body h1, .md-body h2, .md-body h3, .md-body h4 { margin: 1em 0 .5em; line-height: 1.4; }
.md-body h1 { font-size: 1.5em; } .md-body h2 { font-size: 1.3em; } .md-body h3 { font-size: 1.15em; }
.md-body ul, .md-body ol { padding-left: 1.5em; margin: .6em 0; }
.md-body li { margin: .25em 0; }
.md-body a { color: var(--accent); text-decoration: none; }
.md-body a:hover { text-decoration: underline; }
.md-body blockquote {
  border-left: 3px solid var(--accent); padding: 2px 14px;
  color: var(--text-dim); background: var(--panel); border-radius: 0 8px 8px 0;
  margin: .7em 0;
}
.md-body table { border-collapse: collapse; margin: .8em 0; font-size: 13.5px; display: block; overflow-x: auto; max-width: 100%; }
.md-body th, .md-body td { border: 1px solid var(--border-2); padding: 6px 12px; text-align: left; }
.md-body th { background: var(--panel-2); font-weight: 600; }
.md-body code {
  font-family: var(--mono); font-size: .9em;
  background: var(--panel-2); padding: 1.5px 6px; border-radius: 5px;
}
.md-body pre {
  background: var(--code-bg); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 12px 14px;
  overflow-x: auto; margin: .8em 0; position: relative;
}
.md-body pre code {
  background: none; padding: 0; font-size: 13px; line-height: 1.65;
}
.md-body pre .code-head {
  position: absolute; top: 0; left: 0; right: 0;
  display: flex; align-items: center; justify-content: space-between;
  padding: 4px 10px;
  background: var(--panel-2); border-bottom: 1px solid var(--border);
  border-radius: var(--radius) var(--radius) 0 0;
  font-size: 11px; color: var(--text-faint);
}
.md-body pre .code-head .copy-btn {
  color: var(--text-dim); font-size: 11px; padding: 2px 8px; border-radius: 5px;
}
.md-body pre .code-head .copy-btn:hover { background: var(--panel-3); color: var(--text); }
.md-body pre:has(.code-head) { padding-top: 34px; }
.md-body img { max-width: 100%; border-radius: 8px; }
.md-body hr { border: none; border-top: 1px solid var(--border); margin: 1.2em 0; }
.stream-cursor {
  display: inline-block; width: 8px; height: 16px;
  background: var(--accent); border-radius: 2px;
  vertical-align: -2px; animation: blink .9s infinite;
}

/* 消息操作条 */
.ai-foot { display: flex; align-items: center; gap: 10px; font-size: 11.5px; color: var(--text-faint); }
.ai-foot .usage { font-family: var(--mono); }
.ai-foot .op-btn { color: var(--text-faint); font-size: 12px; display: flex; align-items: center; gap: 4px; }
.ai-foot .op-btn:hover { color: var(--text); }

/* 错误卡片 */
.err-card {
  border: 1px solid rgba(248,113,113,.4); background: var(--danger-bg);
  border-radius: var(--radius); padding: 12px 16px;
  color: #fca5a5; font-size: 13.5px; line-height: 1.6;
}
.err-card .err-code { font-family: var(--mono); font-size: 11px; opacity: .7; margin-bottom: 4px; display: block; }

/* ============ 输入区 ============ */
.composer-wrap {
  padding: 10px 20px 12px;
  background: linear-gradient(transparent, var(--bg) 30%);
}
.composer {
  max-width: 840px; margin: 0 auto;
  background: var(--panel);
  border: 1px solid var(--border-2);
  border-radius: 18px;
  box-shadow: var(--shadow);
  transition: border-color .15s;
}
.composer:focus-within { border-color: var(--accent); }
#input {
  width: 100%; border: none; background: none; color: var(--text);
  resize: none; outline: none;
  font-size: 14.5px; line-height: 1.6;
  padding: 14px 18px 4px;
  max-height: 200px;
}
#input::placeholder { color: var(--text-faint); }
.composer-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 8px 12px 10px;
}
.chips { display: flex; align-items: center; gap: 5px; flex-wrap: wrap; }
.chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 9px; border-radius: 20px;
  font-size: 12px; color: var(--text-dim);
  border: 1px solid var(--border);
  background: var(--bg-soft);
  transition: all .15s;
}
.chip:hover { color: var(--text); border-color: var(--border-2); }
.chip-toggle.active {
  color: #fff;
  border-color: transparent;
  background: var(--gradient);
  box-shadow: 0 3px 10px rgba(99, 102, 241, .3);
}
.chip-ico { font-size: 13px; }
.chip-select { position: relative; }
.chip-select-btn { position: relative; max-width: 158px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip-select-btn span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip-menu {
  display: none; position: absolute;
  top: 0; left: 0;
  transform: translateY(calc(-100% - 8px));
  background: var(--panel-2); border: 1px solid var(--border-2);
  border-radius: var(--radius); box-shadow: var(--shadow);
  width: 320px; max-width: calc(100vw - 32px);
  max-height: 60vh; overflow-y: auto;
  padding: 6px; z-index: 200;
  pointer-events: auto;
}
.chip-menu.show { display: block; }
.menu-title { font-size: 11px; color: var(--text-faint); padding: 6px 10px; }
.menu-item {
  display: flex; flex-direction: column; gap: 2px;
  padding: 9px 12px; border-radius: var(--radius-sm);
  cursor: pointer; transition: background .12s;
}
.menu-item:hover { background: var(--panel-3); }
.menu-item.sel { background: var(--panel-3); }
.menu-item .mi-name { font-size: 13.5px; font-weight: 600; }
.menu-item .mi-desc { font-size: 12px; color: var(--text-faint); }
.menu-item.sel .mi-name::after { content: " ✓"; color: var(--accent); }

.composer-right { display: flex; align-items: center; gap: 10px; justify-content: flex-end; }
.hint { font-size: 11.5px; color: var(--text-faint); white-space: nowrap; margin-right: auto; }

/* 语音输入按钮 */
.btn-voice {
  width: 34px; height: 34px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-dim); border: 1px solid var(--border);
  background: var(--bg-soft);
  transition: all .15s; flex-shrink: 0;
}
.btn-voice:hover { background: var(--panel-2); color: var(--text); border-color: var(--border-2); }
.btn-voice.rec {
  color: #fff; background: var(--danger); border-color: transparent;
  animation: pulse 1.2s infinite;
  box-shadow: 0 3px 12px rgba(248, 113, 113, .4);
}
/* 识别中（Whisper 转写阶段）：蓝色脉冲 */
.btn-voice.busy {
  color: #fff; background: var(--accent); border-color: transparent;
  animation: pulse .8s infinite;
  box-shadow: 0 3px 12px rgba(77, 107, 254, .5);
}
.btn-send {
  width: 38px; height: 38px; border-radius: 50%;
  background: var(--gradient); color: #fff;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 14px rgba(99, 102, 241, .4);
  transition: transform .1s, opacity .15s;
}
.btn-send:hover { opacity: .92; }
.btn-send:active { transform: scale(.94); }
.btn-send:disabled { opacity: .4; cursor: not-allowed; box-shadow: none; }
.btn-stop {
  width: 38px; height: 38px; border-radius: 50%;
  background: var(--danger); color: #fff;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 14px rgba(248,113,113,.35);
}
.composer-note { text-align: center; font-size: 11px; color: var(--text-faint); margin-top: 8px; }

/* 回到底部按钮 */
.btn-scroll-down {
  position: absolute; right: 26px; bottom: 190px;
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--panel-2); border: 1px solid var(--border-2);
  color: var(--text-dim);
  display: flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow); z-index: 15;
  opacity: 0; pointer-events: none; transform: translateY(10px);
  transition: all .2s;
}
.btn-scroll-down.show { opacity: 1; pointer-events: auto; transform: none; }
.btn-scroll-down:hover { color: var(--text); border-color: var(--accent); background: var(--panel-3); }

/* ============ 附件区 ============ */
.attach-box {
  display: none; flex-wrap: wrap; gap: 6px; align-items: center;
  padding: 6px 16px 2px;
}
.attach-box.show { display: flex; }
.attach-item {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 4px 4px 4px 12px;
  height: 30px;
  border-radius: 20px;
  background: var(--panel-2);
  border: 1px solid var(--border-2);
  font-size: 12.5px; color: var(--text-dim);
  max-width: 280px;
  position: relative;
  animation: fadeUp .2s ease;
}
.attach-preview {
  position: absolute;
  bottom: calc(100% + 10px);
  left: 50%;
  transform: translateX(-50%);
  max-width: 340px;
  padding: 6px;
  background: var(--panel-2);
  border: 1px solid var(--border-2);
  border-radius: 10px;
  box-shadow: var(--shadow);
  display: none;
  z-index: 60;
}
.attach-item:hover .attach-preview { display: block; }
.attach-preview img {
  display: block;
  max-width: 320px;
  max-height: 240px;
  border-radius: 6px;
  object-fit: contain;
  background: var(--code-bg);
}
.attach-item .af-icon {
  font-size: 14px; opacity: .85;
  flex-shrink: 0;
}
.attach-item .af-name {
  flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  min-width: 0;
}
.attach-del {
  position: static;
  width: 22px; height: 22px;
  background: transparent;
  color: var(--text-faint);
  font-size: 13px; line-height: 22px; text-align: center;
  border-radius: 50%;
  flex-shrink: 0;
  opacity: .5;
}
.attach-item:hover .attach-del { opacity: .9; }
.attach-del:hover { background: var(--danger); color: #fff; opacity: 1; }

/* 消息内的图片 */
/* 消息内的图片：截图风格卡片 */
.bubble-imgs { display: flex; flex-direction: column; gap: 10px; max-width: 480px; }
.bubble-img-card {
  position: relative;
  border-radius: 12px;
  overflow: hidden;
  background: var(--bg-soft);
  border: 1px solid var(--border-2);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.04);
  cursor: zoom-in;
}
.bubble-img-card::before {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 4px;
  background: linear-gradient(180deg, #4d6bfe, #8b5cf6);
  border-radius: 0 12px 12px 0;
  z-index: 1;
}
.bubble-img-card img {
  display: block;
  width: 100%;
  max-height: 420px;
  object-fit: contain;
  background: var(--code-bg);
}
.bubble-img-card .img-cap {
  padding: 7px 12px 7px 16px;
  background: rgba(0, 0, 0, 0.35);
  font-size: 11.5px;
  color: var(--text-dim);
  display: flex; align-items: center; gap: 6px;
  border-top: 1px solid var(--border);
}
.bubble-img-card .img-cap .cap-ico { opacity: .65; font-size: 12px; }
.bubble-img-card .img-cap .cap-name {
  flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.img-viewer {
  position: fixed; inset: 0; z-index: 300;
  background: rgba(0, 0, 0, 0.85);
  display: flex; align-items: center; justify-content: center;
  cursor: zoom-out;
}
.img-viewer img { max-width: 92vw; max-height: 92vh; border-radius: 8px; }

/* ============ 沙箱面板 ============ */
.sandbox-panel {
  position: fixed; top: 0; right: 0; bottom: 0;
  width: 380px; max-width: 92vw;
  background: var(--bg-soft);
  border-left: 1px solid var(--border);
  z-index: 80;
  display: flex; flex-direction: column;
  transform: translateX(105%);
  transition: transform .25s ease;
  box-shadow: -12px 0 40px rgba(0, 0, 0, 0.4);
}
.sandbox-panel.open { transform: translateX(0); }
.sbx-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 14px 10px;
  border-bottom: 1px solid var(--border);
}
.sbx-title { font-weight: 700; font-size: 15px; }
.sbx-actions { display: flex; gap: 2px; }
.sbx-files { flex: 1; overflow-y: auto; padding: 10px; }
.sbx-empty {
  text-align: center; color: var(--text-faint); font-size: 13px;
  padding: 48px 16px; line-height: 1.8;
}
.sbx-empty span { font-size: 12px; color: var(--text-faint); }
.sbx-file {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 10px; border-radius: 8px;
  font-size: 13px; color: var(--text-dim);
  cursor: pointer; transition: background .1s;
}
.sbx-file:hover { background: var(--panel); color: var(--text); }
.sbx-file .f-ico { font-size: 15px; flex-shrink: 0; }
.sbx-file .f-path {
  flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-family: var(--mono); font-size: 12px;
}
.sbx-file .f-size { font-size: 11px; color: var(--text-faint); flex-shrink: 0; }
.sbx-file .f-del {
  display: none; width: 20px; height: 20px; border-radius: 6px;
  color: var(--text-faint); font-size: 12px; flex-shrink: 0;
}
.sbx-file:hover .f-del { display: block; }
.sbx-file .f-del:hover { color: var(--danger); background: var(--panel-2); }
.sbx-guide {
  border-top: 1px solid var(--border);
  padding: 12px 14px 16px;
  font-size: 12px; color: var(--text-dim); line-height: 1.7;
  background: var(--bg);
}
.sbx-guide-title { font-weight: 600; color: var(--text); margin-bottom: 8px; font-size: 12.5px; }
.sbx-guide-item { margin-bottom: 8px; }
.sbx-guide-item code {
  font-family: var(--mono); font-size: 11px;
  background: var(--panel-2); padding: 1px 6px; border-radius: 5px;
  color: var(--text);
  word-break: break-all;
}

/* ============ 登录遮罩 ============ */
.login-overlay {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(5, 7, 12, 0.85);
  backdrop-filter: blur(12px);
  display: flex; align-items: center; justify-content: center;
}
.login-card {
  width: 360px; max-width: 90vw;
  background: var(--panel); border: 1px solid var(--border-2);
  border-radius: 20px; padding: 34px 30px 28px;
  box-shadow: var(--shadow); text-align: center;
  animation: fadeUp .4s ease;
}
.login-logo .logo-mark { margin: 0 auto 14px; }
.login-title { font-size: 19px; font-weight: 700; margin-bottom: 4px; }
.login-sub { font-size: 13px; color: var(--text-dim); margin-bottom: 22px; }
#loginKey {
  width: 100%; padding: 11px 14px;
  background: var(--bg-soft); border: 1px solid var(--border-2);
  border-radius: 10px; color: var(--text); font-size: 14px;
  outline: none; margin-bottom: 12px;
}
#loginKey:focus { border-color: var(--accent); }
.btn-login {
  width: 100%; padding: 11px; border-radius: 10px;
  background: var(--gradient); color: #fff; font-weight: 600; font-size: 14px;
}
.btn-login:hover { opacity: .92; }
.login-err { color: var(--danger); font-size: 12.5px; margin-top: 10px; min-height: 18px; }
.login-card.shake { animation: shake .4s; }
@keyframes shake { 20%,60% { transform: translateX(-8px); } 40%,80% { transform: translateX(8px); } }

/* ============ Toast ============ */
.toast {
  position: fixed; top: 18px; left: 50%; transform: translateX(-50%);
  background: var(--panel-2); border: 1px solid var(--border-2);
  color: var(--text); font-size: 13px;
  padding: 9px 18px; border-radius: 10px;
  box-shadow: var(--shadow); z-index: 200;
  opacity: 0; pointer-events: none; transition: opacity .25s;
  max-width: 80vw;
}
.toast.show { opacity: 1; }
.toast.err { border-color: rgba(248,113,113,.5); color: #fca5a5; }

/* ============ 响应式 ============ */
@media (max-width: 960px) {
  .hint { display: none; }
}
@media (max-width: 860px) {
  #sidebar { position: fixed; left: 0; top: 0; bottom: 0; transform: translateX(-105%); box-shadow: var(--shadow); }
  #sidebar.open { transform: translateX(0); }
  .sidebar-mask.show { display: block; }
  #btnSidebar { display: flex; }
  .chat { padding: 20px 14px 30px; gap: 18px; }
  .w-title { font-size: 26px; }
  .w-cards { grid-template-columns: 1fr; }
  .msg-user .bubble { max-width: 88%; }
  .composer-wrap { padding: 8px 10px 10px; }
}
@media (max-width: 480px) {
  .chip-toggle span:not(.chip-ico) { display: none; }
  .chip-toggle { padding: 5px 9px; }
}


/* ---------- 沙箱一键清除弹窗 + 进度条 ---------- */
.clear-dlg {
  position: fixed; inset: 0; z-index: 999;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0, 0, 0, .55);
}
.clear-dlg-card {
  width: min(420px, 90vw);
  background: var(--panel);
  border: 1px solid var(--border-2);
  border-radius: 16px;
  padding: 22px 24px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .5);
  animation: dlgIn .18s ease-out;
}
@keyframes dlgIn { from { transform: scale(.92); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.clear-dlg-title { font-size: 16px; font-weight: 600; margin-bottom: 12px; }
.clear-dlg-body { color: var(--text); font-size: 14px; line-height: 1.7; }
.clear-dlg-body .danger { color: var(--danger); }
.clear-dlg-body .dim { color: var(--text-faint); font-size: 12.5px; margin-top: 6px; }
.clear-dlg-actions { display: flex; gap: 10px; margin-top: 18px; justify-content: flex-end; }
.clear-dlg-actions button {
  padding: 8px 18px; border-radius: 10px; font-size: 14px;
  border: 1px solid var(--border-2); background: var(--panel-2); color: var(--text);
  cursor: pointer; transition: all .15s;
}
.clear-dlg-actions button:hover { background: var(--panel-3); }
.clear-dlg-actions .btn-danger { background: var(--danger); border-color: transparent; color: #fff; }
.clear-dlg-actions .btn-danger:hover { filter: brightness(1.1); }
.clear-progress { margin-top: 16px; }
.clear-progress-bar {
  height: 8px; border-radius: 6px; background: var(--panel-2);
  border: 1px solid var(--border); overflow: hidden;
}
.clear-progress-fill {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, #f87171, #ef4444);
  border-radius: 6px;
  transition: width .2s ease-out;
}
.clear-progress-text { margin-top: 8px; font-size: 12.5px; color: var(--text-dim); text-align: center; }
