:root {
  --bg: #0b1220;
  --bg-soft: #111c34;
  --card: #ffffff;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e5e9f0;
  --accent: #2563eb;
  --accent-ink: #1d4ed8;
  --accent-soft: #eff6ff;
  --ok: #16a34a;
  --err: #dc2626;
  --radius: 14px;
  --topbar-h: 60px;
  --shadow-card: 0 18px 40px rgba(2, 6, 23, 0.45);
  --shadow-pop: 0 12px 32px rgba(2, 6, 23, 0.35);

  /* 蓝色系标题色阶（深→浅） */
  --h1: #0b3d91;
  --h2: #1d4ed8;
  --h3: #2563eb;
  --h4: #3b82f6;
  --h5: #60a5fa;
  --h6: #93c5fd;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(37, 99, 235, 0.22), transparent 60%),
    radial-gradient(1000px 500px at 110% 10%, rgba(99, 102, 241, 0.18), transparent 55%),
    var(--bg);
  min-height: 100vh;
  line-height: 1.6;
}

code {
  font-family: "SFMono-Regular", Menlo, Consolas, "Liberation Mono", monospace;
  background: rgba(148, 163, 184, 0.18);
  padding: 0.1em 0.4em;
  border-radius: 5px;
  font-size: 0.9em;
}

.hidden { display: none !important; }

/* loader */
.loader {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  color: #e2e8f0;
  background: var(--bg);
  z-index: 50;
}
.loader p { color: #94a3b8; font-size: 14px; }
.spinner {
  width: 42px; height: 42px;
  border-radius: 50%;
  border: 4px solid rgba(148, 163, 184, 0.25);
  border-top-color: #60a5fa;
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ============ 顶部浮动栏 ============ */
.topbar {
  position: fixed;
  top: 12px;
  left: 12px;
  right: 12px;
  height: var(--topbar-h);
  z-index: 40;
  pointer-events: none; /* 让外层不挡住，仅内部交互 */
}
.topbar-inner {
  pointer-events: auto;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 14px;
  border-radius: 16px;
  background: rgba(17, 28, 52, 0.72);
  backdrop-filter: saturate(160%) blur(14px);
  -webkit-backdrop-filter: saturate(160%) blur(14px);
  border: 1px solid rgba(148, 163, 184, 0.22);
  box-shadow: var(--shadow-pop);
}

.brand { display: flex; align-items: center; gap: 10px; color: #e2e8f0; min-width: 0; }
.brand-mark {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px;
  border-radius: 10px;
  background: linear-gradient(135deg, #2563eb, #60a5fa);
  color: #fff; font-weight: 800; font-size: 14px;
  box-shadow: 0 6px 18px rgba(37, 99, 235, 0.45);
}
.brand-title {
  font-size: 14.5px; font-weight: 700; letter-spacing: 0.2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.arrow { color: #60a5fa; font-weight: 800; }

.topbar-tools { display: flex; align-items: center; gap: 8px; flex-wrap: nowrap; }

.tool-btn {
  display: inline-flex; align-items: center; gap: 6px;
  height: 36px; padding: 0 12px;
  border-radius: 10px;
  border: 1px solid rgba(148, 163, 184, 0.28);
  background: rgba(255, 255, 255, 0.06);
  color: #e2e8f0;
  font-size: 13px; font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.05s, color 0.15s;
  white-space: nowrap;
}
.tool-btn svg { width: 16px; height: 16px; fill: currentColor; }
.tool-btn:hover { background: rgba(96, 165, 250, 0.18); border-color: rgba(96, 165, 250, 0.5); color: #fff; }
.tool-btn:active { transform: translateY(1px); }
.tool-btn.primary {
  background: linear-gradient(135deg, var(--accent), #3b82f6);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 8px 22px rgba(37, 99, 235, 0.4);
}
.tool-btn.primary:hover:not(:disabled) { background: linear-gradient(135deg, var(--accent-ink), #2563eb); }
.tool-btn.primary:disabled { background: rgba(148, 163, 184, 0.35); cursor: not-allowed; box-shadow: none; }
.tool-btn.ghost { background: transparent; border-color: transparent; color: #cbd5e1; }
.tool-btn.ghost:hover { background: rgba(248, 113, 113, 0.16); color: #fecaca; border-color: transparent; }

/* 下拉面板 */
.dropdown { position: relative; }
.dropdown-panel {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 240px;
  background: #fff;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow-pop);
  padding: 12px 14px;
  display: flex; flex-direction: column; gap: 10px;
  z-index: 60;
}
.dropdown-panel.hidden { display: none; }
.dropdown-panel .opt { font-size: 13px; }
.dropdown-panel .opt input[type="text"] { width: 100%; margin-top: 4px; }
.dropdown-panel .opt select { margin-left: 4px; }

/* ============ 笔记簿下拉面板 ============ */
.notes-panel {
  width: 320px;
  max-width: calc(100vw - 24px);
  padding: 10px;
  gap: 8px;
}
.notes-panel-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 4px;
}
.notes-panel-title { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.5px; }
.notes-mini-btn {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--muted);
  width: 24px; height: 24px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  transition: background 0.15s, color 0.15s;
}
.notes-mini-btn:hover:not(:disabled) { background: var(--accent-soft); color: var(--accent-ink); border-color: var(--accent); }
.notes-mini-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.notes-search {
  width: 100%;
  height: 32px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 13px;
  color: var(--ink);
  background: #fff;
}
.notes-search:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(37,99,235,0.12); }

.notes-list {
  max-height: min(50vh, 380px);
  overflow-y: auto;
  display: flex; flex-direction: column;
  gap: 4px;
  padding: 2px;
  margin: 0 -2px;
}
.notes-list.busy { opacity: 0.6; }
.notes-list::-webkit-scrollbar { width: 6px; }
.notes-list::-webkit-scrollbar-thumb { background: rgba(148,163,184,0.4); border-radius: 3px; }

.notes-item {
  display: flex; align-items: center; gap: 8px;
  text-align: left;
  width: 100%;
  padding: 8px 10px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
}
.notes-item:hover { background: var(--accent-soft); border-color: rgba(37,99,235,0.25); }
.notes-item.active {
  background: linear-gradient(135deg, rgba(37,99,235,0.12), rgba(96,165,250,0.12));
  border-color: var(--accent);
  color: var(--accent-ink);
  font-weight: 700;
}
.notes-item-text {
  flex: 1; min-width: 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.notes-empty {
  padding: 16px 8px; text-align: center;
  color: #94a3b8; font-size: 12.5px;
}

.notes-new-btn {
  margin-top: 4px;
  height: 34px;
  border: 1px dashed var(--accent);
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-size: 13px; font-weight: 600;
  cursor: pointer;
  transition: background 0.12s;
}
.notes-new-btn:hover { background: rgba(37,99,235,0.18); }

.notes-count {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 9px;
  background: var(--accent);
  color: #fff;
  font-size: 10.5px; font-weight: 700;
  margin-left: 2px;
}
.notes-count.hidden { display: none; }

/* 当前笔记指示器（编辑器头部） */
.current-note {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; color: var(--accent-ink);
  background: var(--accent-soft);
  padding: 3px 10px;
  border-radius: 999px;
  font-weight: 600;
  max-width: 280px;
}
.current-note.hidden { display: none; }
.current-note-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.2);
  flex-shrink: 0;
}
.current-note.local .current-note-dot {
  background: #ef4444;
  box-shadow: 0 0 0 3px rgba(239,68,68,0.2);
}
.current-note-text {
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* ============ 模态框 ============ */
.modal-mask {
  position: fixed; inset: 0;
  background: rgba(2, 6, 23, 0.55);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
  padding: 16px;
}
.modal-mask.hidden { display: none; }
.modal-box {
  width: 100%; max-width: 380px;
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 24px 60px rgba(2, 6, 23, 0.5);
  padding: 20px 22px;
  display: flex; flex-direction: column; gap: 12px;
}
.modal-title {
  font-size: 16px; font-weight: 700; color: var(--ink);
}
.modal-field { display: flex; flex-direction: column; gap: 6px; }
.modal-field.hidden { display: none; }
.modal-label {
  font-size: 12px; font-weight: 600; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.5px;
}
.modal-field input {
  height: 36px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 14px;
  color: var(--ink);
  background: #fff;
}
.modal-field input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.12);
}
.modal-hint {
  font-size: 11.5px; color: var(--err); min-height: 14px;
}
.modal-msg {
  font-size: 12.5px; color: var(--muted); min-height: 16px;
}
.modal-msg.err { color: var(--err); }
.modal-msg.busy { color: var(--accent-ink); }
.modal-actions {
  display: flex; justify-content: flex-end; gap: 8px;
  margin-top: 4px;
}
.modal-actions .tool-btn { height: 34px; }
.modal-actions .tool-btn.primary:disabled { opacity: 0.6; cursor: not-allowed; }

.status {
  font-size: 12.5px; color: #cbd5e1; max-width: 260px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.status.ok { color: #86efac; }
.status.err { color: #fca5a5; }
.status.busy { color: #bfdbfe; }
.status.busy::before {
  content: ""; display: inline-block; width: 12px; height: 12px;
  border: 2px solid rgba(148, 163, 184, 0.3); border-top-color: #60a5fa;
  border-radius: 50%; margin-right: 6px; vertical-align: -2px;
  animation: spin 0.9s linear infinite;
}

/* ============ 主体两栏布局 ============ */
.app {
  max-width: 1600px;
  margin: 0 auto;
  padding: calc(var(--topbar-h) + 24px) 16px 32px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  align-items: stretch;
}

.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: var(--shadow-card);
  border: 1px solid rgba(148, 163, 184, 0.18);
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - var(--topbar-h) - 80px);
}

.pane-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; margin-bottom: 10px;
  padding: 0 4px;
}
.pane-label { font-size: 13px; font-weight: 700; color: var(--muted); }
.pane-hint { font-size: 11.5px; color: #93a3b8; background: var(--accent-soft); color: var(--accent-ink); padding: 2px 8px; border-radius: 999px; font-weight: 600; }

/* 编辑器 */
.md-editor {
  flex: 1;
  width: 100%;
  min-height: 360px;
  resize: none;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px 16px;
  font-family: "SFMono-Regular", Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 13px;
  line-height: 1.65;
  color: var(--ink);
  background: #fafbfc;
  tab-size: 2;
}
.md-editor:focus { outline: none; border-color: var(--accent); background: #fff; box-shadow: 0 0 0 3px rgba(37,99,235,0.12); }

/* MD 阅读器（预览） */
.md-preview {
  flex: 1;
  overflow: auto;
  padding: 18px 22px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 14px;
  line-height: 1.7;
  color: #1f2937;
}
.preview-empty { color: #94a3b8; font-size: 13px; padding: 24px 4px; text-align: center; }

/* 预览内 Markdown 排版（蓝色系标题） */
.md-preview h1, .md-preview h2, .md-preview h3,
.md-preview h4, .md-preview h5, .md-preview h6 {
  margin: 1.2em 0 0.5em;
  line-height: 1.3;
  font-weight: 700;
}
.md-preview h1 { color: var(--h1); font-size: 1.7em; border-bottom: 2px solid #dbeafe; padding-bottom: 0.25em; }
.md-preview h2 { color: var(--h2); font-size: 1.45em; border-bottom: 1px solid #e0edff; padding-bottom: 0.2em; }
.md-preview h3 { color: var(--h3); font-size: 1.25em; }
.md-preview h4 { color: var(--h4); font-size: 1.1em; }
.md-preview h5 { color: var(--h5); font-size: 1em; }
.md-preview h6 { color: var(--h6); font-size: 0.92em; }
.md-preview p { margin: 0.5em 0; }
.md-preview ul, .md-preview ol { margin: 0.4em 0 0.6em; padding-left: 1.6em; }
.md-preview li { margin: 0.2em 0; }
.md-preview code {
  font-family: "SFMono-Regular", Menlo, Consolas, "Liberation Mono", monospace;
  background: #f1f5f9; color: #be185d; padding: 0.1em 0.4em; border-radius: 5px; font-size: 0.88em;
}
.md-preview pre {
  background: #0f172a; color: #e2e8f0; padding: 12px 14px; border-radius: 10px;
  overflow: auto; margin: 0.6em 0; font-size: 12.5px; line-height: 1.55;
}
.md-preview pre code { background: transparent; color: inherit; padding: 0; font-size: inherit; }
.md-preview blockquote {
  margin: 0.6em 0; padding: 0.2em 1em; color: #475569;
  border-left: 4px solid #93c5fd; background: #f8fbff; border-radius: 0 8px 8px 0;
}
.md-preview a { color: var(--accent); text-decoration: none; }
.md-preview a:hover { text-decoration: underline; }
.md-preview mark { background: #fef08a; color: inherit; padding: 0.05em 0.2em; border-radius: 3px; }
.md-preview img { max-width: 100%; border-radius: 8px; margin: 0.5em 0; }
.md-preview hr { border: none; border-top: 1px solid var(--line); margin: 1em 0; }
.md-preview table { border-collapse: collapse; margin: 0.6em 0; width: 100%; font-size: 13px; }
.md-preview th, .md-preview td { border: 1px solid var(--line); padding: 6px 10px; text-align: left; }
.md-preview th { background: #f1f5f9; color: var(--h1); font-weight: 700; }
.md-preview tr:nth-child(even) td { background: #fafbfc; }

/* ============ AI 设置面板 ============ */
.ai-settings-panel {
  min-width: 280px;
  gap: 10px;
}
.ai-settings-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--accent-ink);
  margin-bottom: 2px;
}
.ai-settings-panel .opt {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--muted);
}
.ai-settings-panel .opt select,
.ai-settings-panel .opt input {
  height: 30px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 13px;
  color: var(--ink);
  background: #fff;
  font-weight: 500;
}
.ai-settings-panel .opt input:focus,
.ai-settings-panel .opt select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(37,99,235,0.1);
}
.ai-settings-hint {
  font-size: 11.5px;
  color: #94a3b8;
  margin-top: 2px;
}

/* ============ AI 问答聊天面板 ============ */
.ai-chat-panel {
  position: fixed;
  top: calc(var(--topbar-h) + 16px);
  right: 16px;
  bottom: 24px;
  width: 440px;
  max-width: calc(100vw - 32px);
  background: #fff;
  border-radius: 16px;
  border: 1px solid rgba(148, 163, 184, 0.3);
  box-shadow: 0 24px 60px rgba(2, 6, 23, 0.55);
  display: flex;
  flex-direction: column;
  z-index: 45;
  overflow: hidden;
  animation: slideIn 0.25s ease-out;
}
@keyframes slideIn {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}
.ai-chat-panel.hidden { display: none; }

.ai-chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(135deg, #eff6ff, #dbeafe);
}
.ai-chat-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 700;
  color: var(--accent-ink);
}
.ai-chat-title svg { width: 18px; height: 18px; fill: currentColor; }
.ai-chat-model {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  background: rgba(255,255,255,0.7);
  padding: 2px 8px;
  border-radius: 999px;
  margin-left: 4px;
}
.ai-chat-header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}
.ai-chat-history-btn {
  border: 1px solid rgba(148, 163, 184, 0.4);
  background: rgba(255,255,255,0.8);
  color: var(--muted);
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 600;
  transition: all 0.15s;
}
.ai-chat-history-btn:hover {
  background: #fff;
  color: #ef4444;
  border-color: #fca5a5;
}
.ai-chat-close-btn {
  width: 26px;
  height: 26px;
  border: none;
  background: rgba(255,255,255,0.6);
  color: var(--muted);
  border-radius: 6px;
  font-size: 18px;
  cursor: pointer;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}
.ai-chat-close-btn:hover {
  background: #fff;
  color: #ef4444;
}

/* 欢迎页 */
.ai-chat-welcome {
  padding: 32px 20px;
  text-align: center;
  color: var(--muted);
}
.ai-chat-welcome-icon {
  font-size: 42px;
  margin-bottom: 12px;
}
.ai-chat-welcome-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 8px;
}
.ai-chat-welcome-desc {
  font-size: 13px;
  line-height: 1.7;
  margin-bottom: 20px;
  color: #64748b;
}
.ai-chat-welcome-tips {
  text-align: left;
  background: var(--accent-soft);
  border-radius: 10px;
  padding: 14px 16px;
}
.ai-chat-tip-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--accent-ink);
  margin-bottom: 8px;
}
.ai-chat-tip-item {
  font-size: 12.5px;
  color: #475569;
  line-height: 1.8;
}

/* 消息列表 */
.ai-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  scroll-behavior: smooth;
}
.ai-chat-messages::-webkit-scrollbar { width: 6px; }
.ai-chat-messages::-webkit-scrollbar-thumb { background: rgba(148,163,184,0.4); border-radius: 3px; }

.ai-msg {
  display: flex;
  gap: 10px;
  max-width: 100%;
  animation: msgFadeIn 0.25s ease-out;
}
@keyframes msgFadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
.ai-msg.user {
  flex-direction: row-reverse;
}
.ai-msg-avatar {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}
.ai-msg.user .ai-msg-avatar {
  background: linear-gradient(135deg, #2563eb, #3b82f6);
  color: #fff;
}
.ai-msg.assistant .ai-msg-avatar {
  background: linear-gradient(135deg, #8b5cf6, #a78bfa);
  color: #fff;
}
.ai-msg-body {
  flex: 1;
  min-width: 0;
}
.ai-msg-bubble {
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 13.5px;
  line-height: 1.7;
  white-space: pre-wrap;
  word-break: break-word;
}
.ai-msg.user .ai-msg-bubble {
  background: linear-gradient(135deg, #2563eb, #3b82f6);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.ai-msg.assistant .ai-msg-bubble {
  background: #f1f5f9;
  color: var(--ink);
  border-bottom-left-radius: 4px;
}
.ai-msg.assistant .ai-msg-bubble strong { color: var(--accent-ink); }
.ai-msg.assistant .ai-msg-bubble code {
  background: #e2e8f0;
  color: #be185d;
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 0.9em;
}
.ai-msg-meta {
  font-size: 11px;
  color: #94a3b8;
  margin-top: 4px;
  padding: 0 2px;
}
.ai-msg.user .ai-msg-meta { text-align: right; }

/* 消息中的来源引用 */
.ai-msg-source {
  display: inline-block;
  background: #dbeafe;
  color: var(--accent-ink);
  font-size: 11px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 4px;
  margin: 2px 2px 0;
}

/* 加载动画 */
.ai-chat-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 8px 16px;
  color: var(--muted);
  font-size: 12.5px;
  background: #f8fafc;
  border-top: 1px solid var(--line);
}
.ai-chat-loading-dots {
  display: flex;
  gap: 4px;
}
.ai-chat-loading-dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #60a5fa;
  animation: dotBounce 1.2s infinite ease-in-out;
}
.ai-chat-loading-dots span:nth-child(2) { animation-delay: 0.15s; }
.ai-chat-loading-dots span:nth-child(3) { animation-delay: 0.3s; }
@keyframes dotBounce {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.5; }
  40% { transform: scale(1); opacity: 1; }
}

/* 信息栏 */
.ai-chat-info {
  padding: 8px 16px;
  font-size: 11.5px;
  color: var(--muted);
  background: #f8fafc;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}
.ai-chat-info.error { color: var(--err); background: #fef2f2; }
.ai-chat-info.success { color: var(--ok); background: #f0fdf4; }

/* 输入区 */
.ai-chat-input-area {
  border-top: 1px solid var(--line);
  padding: 12px;
  background: #fff;
}
.ai-chat-input-row {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}
.ai-chat-input {
  flex: 1;
  min-height: 40px;
  max-height: 120px;
  resize: none;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--ink);
  background: #f8fafc;
  font-family: inherit;
  transition: border-color 0.15s, background 0.15s;
}
.ai-chat-input:focus {
  outline: none;
  border-color: var(--accent);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}
.ai-chat-send {
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), #3b82f6);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.15s;
}
.ai-chat-send svg { width: 18px; height: 18px; fill: #fff; }
.ai-chat-send:hover:not(:disabled) {
  background: linear-gradient(135deg, var(--accent-ink), #2563eb);
  transform: scale(1.05);
}
.ai-chat-send:disabled {
  background: #cbd5e1;
  cursor: not-allowed;
}

/* ============ 响应式 ============ */
@media (max-width: 980px) {
  .app { grid-template-columns: 1fr; }
  .card { min-height: 420px; }
  .brand-title { display: none; }
}
@media (max-width: 640px) {
  .topbar { top: 8px; left: 8px; right: 8px; }
  .topbar-inner { padding: 0 8px; gap: 6px; border-radius: 12px; }
  .tool-btn { padding: 0 8px; }
  .tool-btn span { display: none; }
  .status { display: none; }
  .app { padding: calc(var(--topbar-h) + 20px) 10px 24px; }
  .md-preview { padding: 14px; font-size: 13px; }
  .ai-chat-panel {
    top: calc(var(--topbar-h) + 8px);
    right: 8px;
    left: 8px;
    bottom: 16px;
    width: auto;
    max-width: none;
  }
  .ai-chat-welcome { padding: 20px 16px; }
  .ai-chat-welcome-tips { padding: 12px 14px; }
  .ai-settings-panel { min-width: 260px; }
}

