/* style.css */
* { margin: 0; padding: 0; box-sizing: border-box; }
:root {
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --violet: #7c3aed;
  --cyan: rgb(8,145,178);
  --success: #16a34a;
  --warning: rgb(217,119,6);
  --danger: #dc2626;
  --bg: white;
  --bg-soft: #f8fafc;
  --border: rgb(226,232,240);
  --text: rgb(15,23,42);
  --text-soft: #64748b;
}
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}
button { cursor: pointer; border: none; background: none; font-family: inherit; }
input, textarea { font-family: inherit; }
.btn-primary {
  background: var(--primary);
  color: white;
  padding: 10px 20px;
  border-radius: 6px;
  font-size: 14px;
  transition: background .2s;
}
.btn-primary:hover { background: var(--primary-hover); }
.btn-primary:disabled { opacity: .5; cursor: not-allowed; }
.icon-btn {
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 6px; color: var(--text);
  transition: background .2s;
}
.icon-btn:hover { background: var(--bg-soft); }
.icon-btn:disabled { opacity: .5; cursor: not-allowed; }
.icon-btn svg { width: 20px; height: 20px; }

/* ============ 会话输入区发送按钮（图标按钮） ============ */
#send-btn {
  flex: none;
  width: 44px;
  height: 44px;
  min-width: 44px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
}
#send-btn svg {
  width: 22px;
  height: 22px;
  display: block;
  pointer-events: none;
}

/* 登录页 */
.auth-page { height: 100vh; height: 100dvh; display: flex; align-items: center; justify-content: center; background: var(--bg); overflow-y: auto; }
.auth-box { width: 360px; max-width: 100%; padding: 40px; }
.auth-box h1 { text-align: center; margin-bottom: 30px; color: var(--primary); font-size: 24px; }
.auth-tabs { display: flex; gap: 10px; margin-bottom: 20px; border-bottom: 1px solid var(--border); }
.auth-tab { flex: 1; padding: 10px; color: var(--text-soft); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.auth-tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.forgot-link { color: var(--primary); text-decoration: none; font-size: 13px; }
.forgot-link:hover { text-decoration: underline; }

.auth-form input {
  width: 100%; padding: 12px; border: 1px solid var(--border);
  border-radius: 6px; margin-bottom: 12px; font-size: 16px;
  background: #fff; color: var(--text);
}
.auth-form input:focus { outline: none; border-color: var(--primary); }
.auth-form > button { width: 100%; }
.msg { margin-top: 12px; font-size: 13px; text-align: center; }
.msg.error { color: var(--danger); }
.msg.success { color: var(--success); }

.pwd-field { position: relative; margin-bottom: 12px; }
.auth-form .pwd-field input { margin-bottom: 0; padding-right: 46px; }
.auth-form .pwd-field .pwd-eye {
  position: absolute; top: 50%; right: 4px; transform: translateY(-50%);
  width: 32px; height: 32px; min-width: 32px; max-width: 32px; padding: 0; margin: 0;
  display: flex; align-items: center; justify-content: center;
  border: none; border-radius: 6px; background: transparent;
  color: var(--text-soft); z-index: 2; cursor: pointer;
  transition: background .2s, color .2s;
}
.auth-form .pwd-field .pwd-eye:hover { background: var(--bg-soft); color: var(--text); }
.auth-form .pwd-field .pwd-eye:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }
.auth-form .pwd-field .pwd-eye svg { width: 18px; height: 18px; pointer-events: none; }
.auth-form .pwd-field .pwd-eye .eye-closed { display: none; }
.auth-form .pwd-field .pwd-eye.showing .eye-open { display: none; }
.auth-form .pwd-field .pwd-eye.showing .eye-closed { display: block; }

/* 主界面 */
.main-app { display: flex; height: 100vh; height: 100dvh; background: var(--bg); }
.icon-bar {
  width: 60px; background: var(--bg-soft);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column; align-items: center;
  padding-block: 12px; padding-inline: 0; flex: none; overflow: hidden;
  transition: width .25s ease, padding .25s ease, opacity .2s ease, border-right-width .25s ease;
}
.icon-bar.collapsed {
  width: 0; padding-inline: 0; border-right-width: 0; opacity: 0; pointer-events: none;
}
.icon-item {
  width: 40px; height: 40px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 8px; color: var(--text-soft);
  margin-bottom: 8px; cursor: pointer; transition: all .2s; flex: none;
}
.icon-item:hover { background: var(--border); color: var(--text); }
.icon-item.active { background: var(--primary); color: white; }
.icon-item svg { width: 22px; height: 22px; }
.icon-spacer { flex: 1; }

.side-panel {
  width: 280px; background: var(--bg);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column; flex: none;
  transition: width .3s, margin-left .3s;
}
.side-panel.collapsed { display: none; }
.side-header { padding: 16px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.side-header h2 { font-size: 16px; font-weight: 600; }
.side-content { flex: 1; min-height: 1px; overflow-y: auto; padding: 8px; }

.import-progress-container { padding: 12px 16px; border-bottom: 1px solid var(--border); background: var(--bg-soft); }
.import-progress-title { font-size: 13px; font-weight: 600; margin-bottom: 8px; color: var(--primary); }
.import-progress-bar-bg { width: 100%; height: 6px; background: var(--border); border-radius: 3px; overflow: hidden; margin-bottom: 6px; }
.import-progress-bar-fill { height: 100%; background: linear-gradient(90deg, var(--primary), var(--violet)); transition: width .3s ease; width: 0%; }
.import-progress-text { font-size: 12px; color: var(--text-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.side-item { padding: 10px 12px; border-radius: 6px; cursor: pointer; display: flex; align-items: center; justify-content: space-between; margin-bottom: 2px; font-size: 14px; }
.side-item:hover { background: var(--bg-soft); }
.side-item.active { background: #dbeafe; color: var(--primary); }
.side-item-title { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-item-actions { display: none; gap: 4px; }
.side-item:hover .side-item-actions { display: flex; }
.side-item-actions button { width: 24px; height: 24px; border-radius: 4px; display: flex; align-items: center; justify-content: center; color: var(--text-soft); }
.side-item-actions button:hover { background: var(--border); color: var(--text); }
.side-item-actions svg { width: 14px; height: 14px; }
.side-item-sub { font-size: 12px; color: var(--text-soft); margin-top: 2px; }

.mat-breadcrumb { display: flex; align-items: center; gap: 8px; padding: 4px 6px 10px; font-size: 12px; color: var(--text-soft); }
.mat-up { font-size: 12px; color: var(--primary); padding: 4px 8px; border-radius: 6px; background: #eff6ff; flex: none; }
.mat-up:hover { background: #dbeafe; }
.mat-path { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-item.folder .mat-folder-name { flex: 1; min-width: 1px; display: flex; align-items: center; gap: 6px; }
.mat-folder-icon { width: 16px; height: 16px; color: #f59e0b; display: inline-flex; flex: none; }
.mat-folder-icon svg { width: 16px; height: 16px; }
.side-item.folder .side-item-title { font-weight: 500; }

.ctx-menu {
  position: fixed; z-index: 300; background: #fff;
  border: 1px solid var(--border); border-radius: 8px;
  box-shadow: 0 8px 24px rgba(15,23,42,.14);
  padding: 4px; min-width: 148px; display: none;
}
.ctx-menu.show { display: block; }
.ctx-item { display: block; width: 100%; text-align: left; padding: 8px 12px; border-radius: 6px; font-size: 13px; color: var(--text); }
.ctx-item:hover { background: var(--bg-soft); }
.ctx-item.danger { color: var(--danger); }
.ctx-item.danger:hover { background: #fef2f2; }

.settings-h { margin: 0 0 12px; font-size: 14px; font-weight: 600; }
.settings-label { display: block; font-size: 12px; color: var(--text-soft); margin-bottom: 6px; }
.settings-input {
  width: 100%; padding: 10px;
  border: 1px solid var(--border); border-radius: 6px;
  font-size: 14px; margin-bottom: 12px;
  background: #fff; color: var(--text);
}
.settings-input:focus { outline: none; border-color: var(--primary); }
textarea.settings-input { resize: vertical; line-height: 1.6; min-height: 90px; }
.settings-range { width: 100%; margin-bottom: 12px; accent-color: var(--primary); }
.settings-hr { margin-block: 20px; border: none; border-top: 1px solid var(--border); }

.preview-mask {
  position: fixed; inset: 0;
  background: rgba(15,23,42,.32);
  opacity: 0; pointer-events: none;
  transition: opacity .25s ease;
  z-index: 120;
}
.preview-mask.show { opacity: 1; pointer-events: auto; }
.preview-panel {
  position: fixed; top: 0; right: 0; bottom: 0;
  width: min(760px, 94vw);
  background: #fff;
  box-shadow: -8px 0 32px rgba(15,23,42,.18);
  transform: translateX(102%);
  transition: transform .28s cubic-bezier(.4,0,.2,1);
  z-index: 121;
  display: flex; flex-direction: column;
}
.preview-panel.show { transform: translateX(0); }
.preview-header {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 16px; border-bottom: 1px solid var(--border); flex: none;
}
.preview-title { font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.preview-actions { display: flex; gap: 6px; flex: none; }
.preview-close { font-size: 22px; line-height: 1; width: 32px; height: 32px; }
.preview-body { flex: 1; min-height: 1px; overflow: auto; padding: 16px; background: var(--bg-soft); }
.preview-body img { max-width: 100%; display: block; margin: 0 auto; border-radius: 8px; box-shadow: 0 2px 12px rgba(15,23,42,.12); }
.preview-code {
  margin: 0; padding: 16px; background: #fff;
  border: 1px solid var(--border); border-radius: 8px;
  font-family: "SF Mono", Monaco, Consolas, "Courier New", monospace;
  font-size: 13px; line-height: 1.65;
  white-space: pre-wrap; word-break: break-word; color: #111;
}

.move-list { max-height: 320px; overflow-y: auto; border: 1px solid var(--border); border-radius: 8px; }
.move-item { display: flex; align-items: center; gap: 8px; padding: 9px 12px; border-bottom: 1px solid var(--border); cursor: pointer; font-size: 14px; margin-bottom: 0; }
.move-item:last-child { border-bottom: none; }
.move-item:hover { background: var(--bg-soft); }
.modal-body .move-item input[type="radio"] { width: 16px; height: 16px; margin: 0; padding: 0; flex: none; accent-color: var(--primary); }

.main-content { flex: 1; display: flex; flex-direction: column; min-width: 1px; min-height: 1px; position: relative; }
.main-header { padding: 12px 16px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 12px; flex: none; }
.main-header h3 { font-size: 16px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.chat-area {
  flex: 1; min-height: 1px; overflow-y: auto; padding: 0; overflow-anchor: none;
}
.chat-area::before,
.chat-area::after { content: ''; display: block; height: 20px; }

.message {
  width: 100%; max-width: 800px; margin: 0 auto 24px;
  padding: 0 16px; display: flex; position: relative;
}
.message.user { justify-content: flex-end; }
.message.assistant { justify-content: flex-start; }
.message-body { max-width: 100%; min-width: 1px; }
.message.user .message-body { display: flex; flex-direction: column; align-items: flex-end; }
.message.assistant .message-body { display: flex; flex-direction: column; align-items: flex-start; }
.message-content { padding: 12px 16px; border-radius: 12px; background: #ffffff; font-size: 16px; line-height: 1.6; word-wrap: break-word; min-width: 1px; }
.message.user .message-content { background: #EDF3FE; color: #555555; white-space: pre-wrap; max-width: 680px; }

/* ★ 消息状态行：时间 + 垃圾桶 + 复制 + 重新生成，所有按钮在同一行 */
.message-time {
  display: flex;
  align-items: center;
  gap: 2px;
  font-size: 11px;
  color: var(--text-soft);
  margin-top: 4px;
  padding-inline: 4px;
  min-height: 24px;
}
.message.user .message-time { justify-content: flex-end; }

/* 垃圾桶按钮（图标稍放大以看清） */
.msg-del {
  display: none;
  width: 24px;
  height: 24px;
  padding: 0;
  border-radius: 4px;
  color: var(--text-soft);
  align-items: center;
  justify-content: center;
  flex: none;
  transition: background .15s, color .15s;
}
.msg-del svg {
  width: 14px;
  height: 14px;
  pointer-events: none;
}
.msg-del:hover { background: var(--bg-soft); color: var(--danger); }

/* 复制 / 重新生成（图标按钮，与垃圾桶同款尺寸） */
.msg-action-btn {
  display: none;
  width: 24px;
  height: 24px;
  padding: 0;
  border-radius: 4px;
  color: var(--text-soft);
  align-items: center;
  justify-content: center;
  flex: none;
  background: transparent;
  transition: background .15s, color .15s;
}
.msg-action-btn svg {
  width: 14px;
  height: 14px;
  pointer-events: none;
}
.msg-action-btn:hover { background: var(--bg-soft); color: var(--text); }

/* 消息 hover / 选中时展示所有操作按钮 */
.message:hover .msg-del,
.message:hover .msg-action-btn,
.message.selected .msg-del,
.message.selected .msg-action-btn {
  display: inline-flex;
}

/* 思考内容块 */
.thinking-block { margin-bottom: 10px; }
.thinking-toggle { display: inline-flex; align-items: center; gap: 6px; padding-block: 2px; color: var(--text-soft); font-size: 12px; cursor: pointer; user-select: none; }
.thinking-toggle:hover { color: #111; }
.thinking-toggle svg { width: 14px; height: 14px; flex: none; transition: transform .2s; }
.thinking-block.open .thinking-toggle svg { transform: rotate(90deg); }
.thinking-content {
  margin-top: 6px; padding: 4px 4px 4px 12px;
  border-left: 0px solid #e5e5e5; color: #676767;
  font-size: 13px; line-height: 1.7;
  white-space: pre-wrap; word-break: break-word;
  max-height: 320px; overflow-y: auto;
  contain: content; overflow-anchor: none;
}

.answer { min-width: 1px; }
.answer > * + * { margin-top: 10px; }
.md-seg > :first-child { margin-top: 0; }
.md-seg > :last-child { margin-bottom: 0; }
.md-plain { white-space: pre-wrap; word-break: break-word; }
.message-content p { margin-block: 8px; }
.message-content p:first-child { margin-top: 0; }
.message-content p:last-child { margin-bottom: 0; }

.md-h { font-weight: 650; line-height: 1.4; color: #111; }
.md-h1 { font-size: 1.45em; margin-block: 18px 10px; padding-bottom: 8px; position: relative; color: #111; }
.md-h1::after { content: ''; position: absolute; left: 1px; bottom: 1px; width: 64px; height: 3px; border-radius: 2px; background: #d4d4d4; }
.md-h2 { font-size: 1.25em; margin-block: 16px 8px; padding-left: 10px; position: relative; color: #1a1a1a; }
.md-h2::before { content: ''; position: absolute; left: 1px; top: .18em; bottom: .18em; width: 4px; border-radius: 2px; background: #d4d4d4; }
.md-h3 { font-size: 1.12em; margin-block: 14px 6px; color: #262626; }
.md-h4 { font-size: 1.05em; margin-block: 12px 6px; color: #333333; }
.md-h5 { font-size: .95em; margin-block: 10px 4px; color: #444444; }
.md-h6 { font-size: .9em; margin-block: 10px 4px; color: #666666; letter-spacing: .03em; }

.md-table-wrap {
  margin-block: 12px; border: 1px solid #e5e5e5; border-radius: 10px;
  overflow-x: auto; background: white; max-width: 100%;
}
.md-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.md-table th { background: #EBEEF2; color: #111111; font-weight: 600; text-align: left; padding: 9px 14px; border-bottom: 1px solid #e5e5e5; white-space: nowrap; }
.md-table td { padding: 8px 14px; border-top: 1px solid #eeeeee; color: #333333; vertical-align: top; word-break: break-word; }
.md-table tbody tr:nth-child(even) { background: #fafafa; }
.md-table tbody tr:hover { background: #EBEEF2; }
.md-table tbody tr:first-child td { border-top: none; }

.md-list { margin-block: 8px; padding-left: 24px; }
.md-list li { margin-block: 4px; }
.md-list li::marker { color: #666666; font-weight: 600; }
ol.md-list li::marker { color: #666666; }
.md-list .md-list { margin-block: 4px; }
.md-list .md-list li::marker { color: #888888; }
li.md-task { list-style: none; margin-left: -20px; }
li.md-task input[type="checkbox"] { accent-color: #333333; margin-right: 6px; vertical-align: -2px; }

.md-quote {
  margin-block: 10px; padding: 10px 14px;
  border-left: 3px solid #d4d4d4; background: #f7f7f7;
  border-radius: 1px 8px 8px 1px; color: #555555;
}
.md-quote > :first-child { margin-top: 0; }
.md-quote > :last-child { margin-bottom: 0; }

.md-hr {
  border: none; height: 2px; margin-block: 18px;
  background: linear-gradient(90deg, transparent, #d4d4d4 18%, #d4d4d4 82%, transparent);
}

.md-icode {
  background: #EBEEF2; color: #111111;
  border: 1px solid #e5e5e5; padding: 1px 6px; border-radius: 5px;
  font-family: "SF Mono", Monaco, Consolas, monospace;
  font-size: .88em; word-break: break-all;
}
.message.user .message-content .md-icode { background: rgba(255,255,255,.2); color: white; border-color: rgba(255,255,255,.3); }
.message-content a { color: #111111; text-decoration: underline; text-decoration-color: #bbbbbb; text-underline-offset: 3px; }
.message-content a:hover { text-decoration-color: #111111; }
.message.user .message-content a { color: #ffffff; text-decoration-color: rgba(255,255,255,.6); }
.message-content strong { font-weight: 650; color: #111111; }
.message.user .message-content strong { color: white; }
.message-content del { color: #888888; }
.md-img { max-width: 100%; border-radius: 8px; margin-block: 6px; display: block; }

.cite-badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 16px; height: 16px; padding: 0 4px; margin: 0 2px;
  border-radius: 4px; background: #e8eefc; color: #2563eb;
  font-size: 11px; font-weight: 600; line-height: 1;
  text-decoration: none; vertical-align: super; cursor: pointer;
  transition: background .15s, color .15s; border: none;
}
.cite-badge:hover { background: #2563eb; color: #fff; text-decoration: none; }
.message.user .message-content .cite-badge { background: rgba(255,255,255,.25); color: #fff; }
.message.user .message-content .cite-badge:hover { background: #fff; color: #2563eb; }

.code-block {
  margin-block: 12px; border: 1px solid #e5e5e5;
  border-radius: 0 0 8px 8px; background: white; max-width: 100%;
}
.code-header {
  position: sticky; top: 0; z-index: 5;
  background: #EBEEF2; padding: 8px 12px;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  color: #333333; font-size: 12px; border-bottom: 1px solid #e5e5e5;
}
.code-lang {
  font-family: monospace; text-transform: lowercase; color: #555555;
  font-weight: 500; display: inline-flex; align-items: center; gap: 7px;
  min-width: 1px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.code-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; background: #9a9a9a; }
.code-actions { display: flex; gap: 6px; align-items: center; flex: none; }
.code-actions button {
  background: #ffffff; color: #333333; padding: 4px 10px;
  border-radius: 4px; font-size: 12px; display: flex; align-items: center; gap: 4px;
  border: 1px solid #dcdcdc; transition: background .2s;
}
.code-actions button:hover { background: #ececec; }
.code-actions button:active { transform: translateY(1px); }
.code-actions button svg { color: #333333; }
.code-actions svg { width: 12px; height: 12px; }
.code-body { display: flex; background: white; border-radius: 0 0 8px 8px; overflow: hidden; }
.line-numbers {
  flex: none; padding: 14px 10px 14px 16px;
  text-align: right; color: #9a9a9a; background: #fafafa;
  border-right: 1px solid #e5e5e5;
  font-family: "SF Mono", Monaco, Consolas, "Courier New", monospace;
  font-size: 13px; line-height: 1.65; white-space: pre;
  user-select: none; pointer-events: none;
}
.code-block pre {
  margin: 0; padding: 14px 16px;
  overflow: visible; flex: 1 1 auto; min-width: 0;
  max-height: none; height: auto; color: #111111; background: white;
  font-family: "SF Mono", Monaco, Consolas, "Courier New", monospace;
  font-size: 13px; line-height: 1.65;
  white-space: pre-wrap; word-break: break-all;
  tab-size: 4; overflow-anchor: none;
}
.code-block code {
  font-family: inherit; background: none; border: none; padding: 0;
  color: inherit; font-size: inherit;
  white-space: pre-wrap; word-break: break-all; overflow-wrap: normal;
}
.code-stream-badge {
  display: inline-flex; align-items: center; gap: 5px;
  color: #666666; font-size: 11px; font-weight: 500;
  padding: 2px 8px; border-radius: 10px;
  background: #ffffff; border: 1px solid #e0e0e0;
}
.code-stream-badge i {
  width: 6px; height: 6px; border-radius: 50%;
  background: #9a9a9a; animation: streamPulse 1s ease-in-out infinite;
}
.code-block.streaming pre code::after {
  content: '▍'; color: #9a9a9a; animation: caretBlink 1s steps(1) infinite;
}
@keyframes streamPulse { from { opacity: 1; } 50% { opacity: .25; } to { opacity: 1; } }
@keyframes caretBlink { from, 49% { opacity: 1; } 50%, to { opacity: 0; } }
.answer.streaming > .md-seg:last-child > p:last-child::after,
.answer.streaming > .md-seg:last-child > h1:last-child::after,
.answer.streaming > .md-seg:last-child > h2:last-child::after,
.answer.streaming > .md-seg:last-child > h3:last-child::after,
.answer.streaming > .md-seg:last-child > h4:last-child::after,
.answer.streaming > .md-seg:last-child > h5:last-child::after,
.answer.streaming > .md-seg:last-child > h6:last-child::after,
.answer.streaming > .md-seg.md-plain:last-child::after {
  content: '▍'; color: #9a9a9a; animation: caretBlink 1s steps(1) infinite;
}
.stream-error {
  margin-top: 10px; padding: 10px 12px;
  background: #fef2f2; border: 1px solid #fecaca;
  color: var(--danger); border-radius: 8px;
  font-size: 13px; line-height: 1.5;
}
.jump-bottom {
  position: absolute; right: 24px; bottom: 112px;
  display: none; align-items: center; gap: 6px;
  padding: 8px 14px; background: var(--bg);
  border: 1px solid var(--border); border-radius: 999px;
  box-shadow: 0 4px 14px rgba(15,23,42,.12);
  color: var(--primary); font-size: 12px; font-weight: 500;
  z-index: 20; transition: background .2s, transform .2s;
}
.jump-bottom.show { display: inline-flex; }
.jump-bottom:hover { background: #eff6ff; transform: translateY(-1px); }
.jump-bottom svg { width: 14px; height: 14px; }

.msg-nav {
  position: absolute; top: 50%; right: 6px; transform: translateY(-50%);
  z-index: 30; display: none;
}
.msg-nav.show { display: block; }
.msg-nav-dots {
  display: flex; flex-direction: column; align-items: center; gap: 0;
  padding: 10px 4px; border-radius: 999px;
  background: rgba(255,255,255,.92); border: 1px solid var(--border);
  box-shadow: 0 2px 10px rgba(15,23,42,.08);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  overflow: hidden;
}
.msg-nav-dot {
  width: 20px; height: 20px; padding: 0; background: transparent;
  display: flex; align-items: center; justify-content: center;
  flex: none; border-radius: 50%;
}
.msg-nav-dot::before {
  content: ''; width: 6px; height: 6px; border-radius: 50%;
  background: #cbd5e1; transition: background .15s, transform .15s;
}
.msg-nav-dot:hover::before { background: #94a3b8; }
.msg-nav-dot.active::before { background: var(--primary); transform: scale(1.45); }
.msg-nav-popover {
  position: absolute; top: 50%; right: calc(100% + 10px);
  transform: translateY(-50%); width: 300px;
  max-height: min(60vh, 440px); background: #fff;
  border: 1px solid var(--border); border-radius: 10px;
  box-shadow: 0 10px 30px rgba(15,23,42,.14);
  display: none; flex-direction: column; overflow: hidden; z-index: 31;
}
.msg-nav-popover.show { display: flex; }
.msg-nav-popover-title {
  padding: 10px 14px; font-size: 12px; font-weight: 600;
  color: var(--text-soft); border-bottom: 1px solid var(--border);
  flex: none; letter-spacing: .02em;
}
.msg-nav-popover-list { flex: 1; min-height: 1px; overflow-y: auto; padding: 6px; }
.msg-nav-item {
  display: block; width: 100%; text-align: left;
  padding: 8px 10px; border-radius: 6px; font-size: 13px; line-height: 1.4;
  color: #333; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.msg-nav-item:hover { background: var(--bg-soft); }
.msg-nav-item.active { background: #dbeafe; color: var(--primary); }

.input-area { border-top: 1px solid var(--border); padding: 12px 16px; background: var(--bg); flex: none; }
.attachments-preview { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
.attachments-preview:empty { margin-bottom: 0; }
.attachment-item { background: var(--bg-soft); border: 1px solid var(--border); border-radius: 6px; padding: 6px 10px; font-size: 12px; display: flex; align-items: center; gap: 6px; max-width: 200px; }
.attachment-item img { width: 32px; height: 32px; object-fit: cover; border-radius: 4px; }
.attachment-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.attachment-remove { color: var(--text-soft); font-size: 16px; line-height: 1; }
.attachment-remove:hover { color: var(--danger); }
.input-row { display: flex; gap: 8px; align-items: flex-end; }
#message-input { flex: 1; border: 1px solid var(--border); border-radius: 8px; padding: 10px 14px; font-size: 14px; resize: none; max-height: 200px; min-height: 42px; line-height: 1.5; }
#message-input:focus { outline: none; border-color: var(--primary); }
.thinking-icon-btn { flex: none; transition: all .2s ease; color: var(--text-soft); }
.thinking-icon-btn:hover { background: var(--bg-soft); color: var(--text); }
.thinking-icon-btn.active { color: var(--primary); background: #eff6ff; }
.thinking-icon-btn.active:hover { background: #dbeafe; }
.thinking-icon-btn svg { width: 22px; height: 22px; }
.web-search-icon-btn { flex: none; transition: all .2s ease; color: var(--text-soft); }
.web-search-icon-btn:hover { background: var(--bg-soft); color: var(--text); }
.web-search-icon-btn.active { color: var(--primary); background: #eff6ff; }
.web-search-icon-btn.active:hover { background: #dbeafe; }
.web-search-icon-btn svg { width: 22px; height: 22px; }

.modal { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 99; align-items: center; justify-content: center; }
.modal.show { display: flex; }
.modal-content { background: var(--bg); border-radius: 12px; width: 90%; max-width: 500px; max-height: 80vh; overflow: hidden; display: flex; flex-direction: column; }
.modal-header { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.modal-header h3 { font-size: 16px; font-weight: 600; }
.modal-body { padding: 20px; overflow-y: auto; }
.modal-body input, .modal-body textarea { width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 6px; margin-bottom: 12px; font-size: 14px; }
.modal-body input:focus, .modal-body textarea:focus { outline: none; border-color: var(--primary); }
.modal-body label { display: block; font-size: 13px; color: var(--text-soft); margin-bottom: 6px; }
.mat-pick-list { max-height: 400px; overflow-y: auto; border: 1px solid var(--border); border-radius: 8px; }
.mat-pick-item { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-bottom: 1px solid var(--border); cursor: pointer; margin-bottom: 0; }
.mat-pick-item:last-child { border-bottom: none; }
.mat-pick-item:hover { background: var(--bg-soft); }
.mat-pick-item input[type="checkbox"] { width: 16px; height: 16px; margin: 0; flex: none; }
.flash-toast {
  position: fixed; top: 62px; left: 50%;
  transform: translateX(-50%) translateY(-10px);
  background: rgba(15,23,42,.88); color: white;
  padding: 8px 20px; border-radius: 20px;
  font-size: 13px; font-weight: 500;
  pointer-events: none; opacity: 0; z-index: 9998;
  white-space: nowrap; box-shadow: 0 4px 12px rgba(0,0,0,.15);
  transition: opacity .25s ease, transform .25s ease;
}
.flash-toast.show { opacity: 1; transform: translateX(-50%); }
.mobile-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 50; }
.mobile-overlay.show { display: block; }

.chat-loading {
  display: flex; align-items: center; justify-content: center;
  gap: 10px; padding: 80px 20px;
  color: var(--text-soft); font-size: 13px;
}
.chat-loading .typing-indicator span { background: var(--primary); }

@media (max-width: 900px) {
  .msg-nav { display: none !important; }
}

@media (max-width: 768px) {
  .icon-bar {
    width: 50px;
    padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
    position: relative; z-index: 52;
  }
  .icon-bar.collapsed { display: none; }
  .side-panel { position: fixed; left: 50px; top: 0; bottom: 0; z-index: 51; box-shadow: 2px 0 8px rgba(0,0,0,.1); }
  .message { padding: 0 10px; margin-bottom: 16px; }
  .message-body { max-width: 100%; }
  .message-content { padding: 10px 12px; }
  .chat-area::before,
  .chat-area::after { height: 14px; }
  .code-block pre { font-size: 12px; padding: 12px; }
  .line-numbers { font-size: 12px; padding: 12px 8px 12px 12px; }
  .md-table { font-size: 12px; }
  .md-table th, .md-table td { padding: 7px 10px; }
  .jump-bottom { right: 12px; }
  .input-area { padding: 8px 10px calc(8px + env(safe-area-inset-bottom, 0px)); }
  .input-row { flex-wrap: wrap; gap: 6px; align-items: center; }
  #message-input { flex: 1 1 100%; order: -1; min-height: 44px; max-height: 160px; font-size: 16px; padding: 10px 12px; }
  #send-btn { margin-left: auto; width: 42px; height: 42px; min-width: 42px; padding: 0; }
  #send-btn svg { width: 20px; height: 20px; }
  .preview-panel { width: 100vw; }
  /* 触摸设备上直接显示操作按钮，确保可点 */
  .msg-del, .msg-action-btn { display: inline-flex; }
}
@media (hover: none) {
  .side-item-actions { display: flex; }
  .msg-del, .msg-action-btn { display: inline-flex; }
}
* { scrollbar-width: thin; scrollbar-color: #cbd5e1 transparent; }
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #cbd5e1; }
.md-table-wrap { scrollbar-color: #d4d4d4 #fafafa; }
.md-table-wrap::-webkit-scrollbar { height: 8px; }
.md-table-wrap::-webkit-scrollbar-track { background: #fafafa; }
.md-table-wrap::-webkit-scrollbar-thumb { background: #d4d4d4; border-radius: 4px; }
.md-table-wrap::-webkit-scrollbar-thumb:hover { background: #b8b8b8; }
.msg-nav-popover-list::-webkit-scrollbar { width: 6px; }
.msg-nav-popover-list::-webkit-scrollbar-thumb { background: #d4d4d4; border-radius: 3px; }
.typing-indicator { display: inline-flex; gap: 4px; padding-block: 4px; }
.typing-indicator span { width: 6px; height: 6px; border-radius: 50%; background: var(--text-soft); animation: typing 1.4s infinite; }
.typing-indicator span:nth-child(2) { animation-delay: .2s; }
.typing-indicator span:nth-child(3) { animation-delay: .4s; }
@keyframes typing {
  from, 60%, to { opacity: .3; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-4px); }
}
.empty-state { text-align: center; color: var(--text-soft); padding: 40px 20px; font-size: 14px; }

html.is-mobile-init:not(.boot-ready) .icon-bar,
html.is-mobile-init:not(.boot-ready) .side-panel {
  display: none;
}