/* ============================================================
   极简·第二大脑 前端样式
   白底 #FFFFFF · 主色 #4A6CF7 · 轻风绿 #52C41A
   移动优先，响应式：手机单列 / 平板2列 / 桌面3列
   ============================================================ */

* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --primary: #4A6CF7;
  --qingfeng: #52C41A;
  --bg: #FFFFFF;
  --bg-soft: #F7F8FA;
  --text: #1A1A1A;
  --text-soft: #8A8F99;
  --border: #ECEEF1;
  --danger: #F5222D;
  /* 默认移动端：单列窄宽 */
  --maxw: 480px;
  --card-min: 300px;   /* 笔记卡片最小宽度，决定网格列数 */
  --content-pad: 14px;
}

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
               "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  color: var(--text);
  background: var(--bg-soft);
  -webkit-font-smoothing: antialiased;
}

#app { max-width: var(--maxw); margin: 0 auto; min-height: 100vh; position: relative; background: var(--bg-soft); }

.view { min-height: 100vh; }
.hidden { display: none !important; }

/* ---------- 登录页 ---------- */
#login-view { display: flex; align-items: center; justify-content: center; padding: 24px 24px 80px; }
.login-card { width: 100%; text-align: center; }
.logo { font-size: 56px; margin-bottom: 12px; }
.login-card h1 { font-size: 24px; font-weight: 700; }
.subtitle { color: var(--text-soft); font-size: 14px; margin: 6px 0 28px; }
#login-form { display: flex; flex-direction: column; gap: 12px; }
#login-form input {
  height: 46px; border: 1px solid var(--border); border-radius: 12px;
  padding: 0 16px; font-size: 16px; background: #fff;
}
#login-form input:focus { outline: none; border-color: var(--primary); }
#login-btn, .primary-btn {
  height: 44px; border: none; border-radius: 12px; background: var(--primary);
  color: #fff; font-size: 15px; font-weight: 600; cursor: pointer;
  transition: opacity 0.15s, transform 0.1s, box-shadow 0.15s;
  box-shadow: 0 2px 8px rgba(74,108,247,0.25);
}
/* 登录页按钮保持全宽 */
#login-btn { width: 100%; }
/* 编辑态保存按钮：自适应宽度，不全宽 */
.primary-btn { padding: 0 28px; align-self: flex-start; }
.primary-btn:hover { opacity: 0.92; box-shadow: 0 4px 14px rgba(74,108,247,0.35); }
.primary-btn:active { opacity: 0.85; transform: translateY(1px); box-shadow: 0 1px 4px rgba(74,108,247,0.2); }
.error-msg { color: var(--danger); font-size: 13px; min-height: 18px; margin-top: 10px; }
.switch-auth { margin-top: 14px; font-size: 13px; }
.switch-auth a { color: var(--primary); text-decoration: none; }
.switch-auth a:active { opacity: 0.7; }

/* ---------- 顶栏 ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 8px;
  padding: 12px var(--content-pad); background: #fff; border-bottom: 1px solid var(--border);
  max-width: var(--maxw); margin: 0 auto;
}
.brand { font-weight: 700; font-size: 15px; white-space: nowrap; }
#search-input {
  flex: 1; height: 36px; border: 1px solid var(--border); border-radius: 18px;
  padding: 0 14px; font-size: 13px; background: var(--bg-soft);
}
#search-input:focus { outline: none; border-color: var(--primary); background: #fff; }
.search-input-wrap { position: relative; flex: 1; display: flex; align-items: center; }
.search-input-wrap #search-input { width: 100%; padding-right: 30px; }
.search-input-clear {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  border: none; background: none; color: var(--text-soft); font-size: 14px;
  cursor: pointer; padding: 2px 4px; line-height: 1;
}
.search-input-clear:hover { color: var(--text); }
.search-input-clear.hidden { display: none; }
#search-btn { border: none; background: none; font-size: 16px; cursor: pointer; padding: 4px; }
#logout-btn {
  border: 1px solid var(--border); border-radius: 16px; background: #fff;
  color: var(--text-soft); font-size: 12px; cursor: pointer;
  padding: 5px 12px; white-space: nowrap; transition: color 0.15s, border-color 0.15s;
}
#logout-btn:active { opacity: 0.8; }

/* ---------- 搜索结果 ---------- */
.search-result { padding: 12px var(--content-pad); background: #fff; border-bottom: 1px solid var(--border); max-width: var(--maxw); margin: 0 auto; }
.search-result .qf-content { max-height: 50vh; overflow-y: auto; }
.search-actions { display: flex; align-items: center; gap: 8px; margin-top: 10px; }
.search-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 8px var(--content-pad); background: rgba(74,108,247,0.06);
  border-bottom: 1px solid var(--border); max-width: var(--maxw); margin: 0 auto;
  font-size: 13px; color: var(--primary);
}
#ask-ai-btn { border: none; background: none; font-size: 16px; cursor: pointer; padding: 4px; }

/* ---------- 笔记列表 ---------- */
/* 响应式网格：列数随容器宽度自适应（auto-fill + minmax），
   手机单列、平板两列、桌面三列，无需写死断点 */
.notes-list {
  padding: var(--content-pad);
  padding-bottom: 120px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(var(--card-min), 1fr));
  gap: 12px;
  max-width: var(--maxw);
  margin: 0 auto;
}
.note-card { background: #fff; border-radius: 14px; padding: 14px 14px 10px; box-shadow: 0 1px 3px rgba(0,0,0,0.04); height: 200px; display: flex; flex-direction: column; cursor: pointer; }
.note-card:hover { box-shadow: 0 2px 8px rgba(0,0,0,0.08); }
/* 卡片内容区固定高度，超出省略 */
.note-card .note-content { flex: 1; min-height: 0; overflow: hidden; }
.note-card .note-content-clamp { display: -webkit-box; -webkit-line-clamp: 6; -webkit-box-orient: vertical; overflow: hidden; }
/* 卡片操作区固定可见，不被 overflow 裁掉 */
.note-card .qf-actions { flex-shrink: 0; }
.note-meta { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-soft); margin-bottom: 8px; }
.note-type { font-size: 13px; }
.note-author { font-size: 11px; color: var(--primary); background: rgba(74,108,247,0.08); padding: 0 6px; border-radius: 4px; }
.note-time { margin-left: auto; }
.note-content { font-size: 15px; line-height: 1.6; word-break: break-word; }
.note-content p { margin: 0 0 8px; }
.note-content p:last-child { margin-bottom: 0; }
.note-content h1, .note-content h2, .note-content h3 { font-size: 17px; font-weight: 700; margin: 10px 0 6px; line-height: 1.3; }
.note-content h1 { font-size: 19px; }
.note-content ul, .note-content ol { margin: 6px 0 8px; padding-left: 22px; }
.note-content li { margin: 2px 0; }
.note-content blockquote { margin: 6px 0; padding: 4px 10px; border-left: 3px solid var(--border); color: var(--text-soft); }
.note-content code { background: var(--bg-soft); padding: 1px 5px; border-radius: 4px; font-size: 13px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.note-content pre { background: var(--bg-soft); padding: 10px; border-radius: 8px; overflow-x: auto; margin: 6px 0; }
.note-content pre code { background: none; padding: 0; }
.note-content hr { border: none; border-top: 1px solid var(--border); margin: 10px 0; }
.note-content img { max-width: 100%; border-radius: 8px; margin: 6px 0; display: block; }
.note-content a { color: var(--primary); }

/* 代码块容器 + 复制按钮 */
.code-block { position: relative; margin: 8px 0; }
.code-block pre { margin: 0; }
.code-copy-btn {
  position: absolute; top: 6px; right: 6px;
  border: 1px solid var(--border); border-radius: 6px; background: #fff;
  color: var(--text-soft); font-size: 11px; padding: 2px 8px; cursor: pointer;
  opacity: 0; transition: opacity 0.15s;
}
.code-block:hover .code-copy-btn { opacity: 1; }
.code-copy-btn:active { background: var(--bg-soft); }

/* Mermaid 图表 */
.mermaid {
  margin: 12px 0; padding: 12px;
  background: var(--bg-soft); border-radius: 8px;
  overflow-x: auto; text-align: center; line-height: 1.4;
}
.mermaid svg { max-width: 100%; height: auto; }
.mermaid-error { margin: 0; font-size: 12px; color: var(--text-soft); white-space: pre-wrap; text-align: left; }

/* markdown 表格 */
.md-table-wrap { overflow-x: auto; margin: 8px 0; }
.md-table { border-collapse: collapse; width: 100%; font-size: 13px; }
.md-table th, .md-table td { border: 1px solid var(--border); padding: 6px 10px; text-align: left; }
.md-table th { background: var(--bg-soft); font-weight: 600; }
.md-table tr:nth-child(even) td { background: rgba(0,0,0,0.015); }

/* 编辑器工具栏 */
.editor-toolbar { display: flex; align-items: center; gap: 4px; padding: 4px 0; }
.tool-icon {
  width: 32px; height: 32px; border: 1px solid var(--border); border-radius: 8px;
  background: #fff; cursor: pointer; font-size: 14px; color: var(--text-soft);
  display: flex; align-items: center; justify-content: center; font-weight: 600;
}
.tool-icon:active { background: var(--bg-soft); }
.note-content.refined { color: var(--text-soft); text-decoration: line-through; }
.note-refined { margin-top: 8px; padding: 8px 10px; background: var(--bg-soft); border-radius: 8px; font-size: 14px; line-height: 1.6; }
.note-refined-label { font-size: 11px; color: var(--qingfeng); font-weight: 600; margin-bottom: 4px; display: flex; align-items: center; justify-content: space-between; }
.note-refined-body { word-break: break-word; }
.note-refined-body h1, .note-refined-body h2, .note-refined-body h3 { font-size: 1em; margin: 0.5em 0 0.25em; }
.note-refined-body p { margin: 0.3em 0; }
.note-refined-body .mermaid { margin-top: 12px; text-align: center; }
.refine-actions { display: flex; gap: 6px; flex-shrink: 0; margin-left: 12px; }
.qf-btn.refine-dismiss { border-color: var(--text-soft); color: var(--text-soft); }

/* 轻风结果块 */
.qf-block {
  border-left: 3px solid var(--qingfeng);
  padding: 8px 0 8px 12px; margin-top: 10px;
  font-size: 14px; line-height: 1.6; white-space: pre-wrap; word-break: break-word;
  display: none;
}
.qf-block.show { display: block; }
.qf-label { color: var(--qingfeng); font-weight: 600; font-size: 13px; margin-bottom: 4px; display: flex; align-items: center; justify-content: space-between; }
.qf-meta { color: var(--text-soft); font-size: 12px; margin-top: 8px; }
.qf-close-btn { font-size: 12px; font-weight: 400; }
.qf-loading { color: var(--text-soft); font-size: 13px; }

/* 轻风胶囊按钮 */
.qf-actions { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.qf-btn {
  border: 1px solid var(--qingfeng); color: var(--qingfeng); background: #fff;
  border-radius: 14px; padding: 4px 12px; font-size: 12px; cursor: pointer;
}
.qf-btn:active { background: rgba(82,196,26,0.08); }
.qf-btn.refine-apply { border-color: var(--primary); color: var(--primary); }
/* 置顶按钮 */
.qf-btn.pin-btn { border-color: var(--qingfeng); }
.qf-btn.pin-btn.active { background: var(--qingfeng); color: #fff; }
/* 置顶卡片高亮 */
.note-card.is-pinned { border: 1px solid var(--qingfeng); box-shadow: 0 1px 6px rgba(82,196,26,0.12); }
.pin-mark { font-size: 12px; }

.note-del { margin-top: 8px; color: var(--text-soft); font-size: 12px; cursor: pointer; background: none; border: none; }
.note-del:active { color: var(--danger); }

.loading, .empty { text-align: center; color: var(--text-soft); padding: 40px 0; font-size: 14px; }

/* ---------- 分页 ---------- */
.pager {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  padding: 16px 14px 120px; flex-wrap: wrap;
  max-width: var(--maxw); margin: 0 auto;
}
.pager .pg-num {
  min-width: 32px; height: 32px; padding: 0 8px;
  border: none; border-radius: 50%; background: transparent;
  color: var(--text-soft); font-size: 13px; cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.pager .pg-num:hover { background: var(--bg-soft); color: var(--text); }
.pager .pg-num.active { background: var(--primary); color: #fff; font-weight: 600; }
.pager .pg-arrow {
  min-width: 32px; height: 32px; padding: 0 8px;
  border: none; border-radius: 50%; background: transparent;
  color: var(--text-soft); font-size: 16px; cursor: pointer;
  transition: background 0.15s;
}
.pager .pg-arrow:hover:not(:disabled) { background: var(--bg-soft); color: var(--text); }
.pager .pg-arrow:disabled { opacity: 0.3; cursor: not-allowed; }
.pager .pg-ellipsis { color: var(--text-soft); padding: 0 2px; font-size: 13px; }
.pager .pg-info { color: var(--text-soft); font-size: 12px; margin-left: 8px; }

/* ---------- 详情页 ---------- */
#detail-view { background: var(--bg-soft); }
.detail-topbar { justify-content: space-between; }
.detail-topbar .brand { font-size: 15px; }
.back-btn { color: var(--primary); font-size: 15px; font-weight: 600; padding: 4px 8px; }
/* 顶栏右侧「编辑」按钮：宽一点、有描边，像个操作按钮而非小图标 */
#detail-edit-toggle {
  padding: 6px 16px; min-width: 72px; height: 34px;
  border: 1px solid var(--primary); border-radius: 18px; background: #fff;
  color: var(--primary); font-size: 14px; font-weight: 600; cursor: pointer;
  transition: background 0.15s, opacity 0.15s;
}
#detail-edit-toggle:hover { background: rgba(74,108,247,0.08); }
#detail-edit-toggle:active { opacity: 0.8; }
.detail-body { padding: 16px var(--content-pad) 120px; max-width: var(--maxw); margin: 0 auto; }
.detail-meta { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text-soft); margin-bottom: 12px; }
/* AI 速览框 */
.detail-summary {
  background: rgba(82,196,26,0.06); border: 1px solid rgba(82,196,26,0.2);
  border-radius: 12px; padding: 12px 14px; margin-bottom: 14px;
}
.detail-summary .summary-label {
  color: var(--qingfeng); font-size: 12px; font-weight: 600; margin-bottom: 6px;
}
.detail-summary .summary-content {
  font-size: 14px; line-height: 1.6; color: var(--text); white-space: pre-wrap; word-break: break-word;
}
.detail-content { background: #fff; border-radius: 14px; padding: 18px; font-size: 15px; line-height: 1.7; min-height: 80px; }
.detail-content h1, .detail-content h2, .detail-content h3 { scroll-margin-top: 56px; }

/* 目录导航 */
.detail-toc {
  position: fixed; right: 12px; bottom: 90px; z-index: 25;
  background: #fff; border: 1px solid var(--border); border-radius: 12px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.1); max-width: 220px; max-height: 60vh;
  overflow: hidden; display: flex; flex-direction: column;
}
.toc-head { padding: 8px 12px; font-size: 13px; font-weight: 600; cursor: pointer; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.toc-arrow { color: var(--text-soft); font-size: 12px; }
.toc-body { overflow-y: auto; padding: 6px 0; }
.toc-body.collapsed { display: none; }
.toc-item { padding: 5px 12px; font-size: 13px; color: var(--text-soft); cursor: pointer; line-height: 1.4; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.toc-item:hover { color: var(--primary); background: var(--bg-soft); }
.toc-item.toc-l2 { padding-left: 24px; font-size: 12px; }
.toc-item.toc-l3 { padding-left: 36px; font-size: 12px; }
@media (min-width: 768px) {
  .detail-toc { right: calc(50% - var(--maxw)/2 + 12px); }
}
.detail-content img { max-width: 100%; border-radius: 8px; margin: 8px 0; }
#detail-textarea { width: 100%; border: 1px solid var(--border); border-radius: 12px; padding: 12px; font-size: 15px; line-height: 1.6; resize: none; font-family: inherit; min-height: 240px; }
#detail-textarea:focus { outline: none; border-color: var(--primary); }
/* 编辑区保存按钮：宽、醒目、有间距 */
#detail-save { margin: 12px; align-self: flex-end; }
.detail-actions { margin-top: 20px; }
.qf-btn.danger { border-color: var(--danger); color: var(--danger); }
.detail-body .qf-block { margin-top: 16px; }
#detail-refined { margin-top: 16px; }

/* ---------- 底部工具栏 ---------- */
.toolbar {
  position: fixed; bottom: 32px; left: 0; right: 0; height: 64px;
  display: flex; align-items: center; justify-content: center; gap: 24px;
  background: #fff; border-top: 1px solid var(--border);
  z-index: 20; max-width: var(--maxw); margin: 0 auto;
}
.tool-btn {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  border: none; background: none; cursor: pointer; font-size: 20px;
  color: var(--text); line-height: 1;
}
.tool-btn span { font-size: 11px; color: var(--text-soft); }
.tool-btn.sprout span { color: var(--qingfeng); }
.tool-btn.skill span { color: var(--primary); }

/* 技能管理弹层 */
.skill-sheet { max-height: 90vh; overflow-y: auto; gap: 14px; }
.skill-desc { font-size: 13px; color: var(--text-soft); line-height: 1.6; }
.skill-desc code { background: var(--bg-soft); padding: 1px 5px; border-radius: 4px; font-size: 12px; }
.skill-section { display: flex; flex-direction: column; gap: 8px; }
.skill-section-title { font-size: 14px; font-weight: 600; }
.skill-gen-row { display: flex; gap: 8px; }
.skill-gen-row input {
  flex: 1; height: 40px; border: 1px solid var(--border); border-radius: 10px; padding: 0 12px; font-size: 14px;
}
.skill-gen-row .primary-btn { width: auto; padding: 0 18px; }
.skill-key-list { display: flex; flex-direction: column; gap: 8px; }
.skill-key-item {
  display: flex; align-items: center; gap: 10px; justify-content: space-between;
  padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; font-size: 13px;
}
.skill-key-item .key-prefix { font-family: ui-monospace, Menlo, monospace; color: var(--primary); }
.skill-key-item .key-meta { color: var(--text-soft); font-size: 12px; }
.skill-key-item .key-del { color: var(--danger); background: none; border: none; cursor: pointer; font-size: 12px; }
.skill-new-key { background: rgba(245,34,45,0.05); border: 1px solid rgba(245,34,45,0.2); border-radius: 10px; padding: 12px; }
.skill-warn { color: var(--danger); font-size: 13px; margin-bottom: 8px; }
.skill-key-box { display: flex; align-items: center; gap: 8px; }
.skill-key-box code {
  flex: 1; font-size: 12px; word-break: break-all; background: var(--bg-soft); padding: 8px; border-radius: 6px;
}

/* 发芽结果展示 */
.sprout-result {
  padding: 14px var(--content-pad); margin: 0 auto 120px;
  max-width: var(--maxw);
}
.sprout-result .qingfeng-block {
  background: #fff; border-radius: 14px; padding: 16px;
  border-left: 3px solid var(--qingfeng);
  box-shadow: 0 1px 4px rgba(0,0,0,0.05);
}
.sprout-actions { display: flex; align-items: center; gap: 12px; margin-top: 14px; }
.sprout-actions .primary-btn { padding: 0 20px; }

/* ---------- 弹层 ---------- */
.modal { position: fixed; inset: 0; z-index: 50; display: flex; align-items: flex-end; justify-content: center; }
.modal-mask { position: absolute; inset: 0; background: rgba(0,0,0,0.4); }
.modal-sheet {
  position: relative; width: 100%; max-width: var(--maxw); background: #fff;
  border-radius: 18px 18px 0 0; padding: 16px; display: flex; flex-direction: column; gap: 12px;
  animation: slideUp 0.2s ease;
}
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
.modal-head { display: flex; align-items: center; justify-content: space-between; font-weight: 700; font-size: 16px; }
.icon-btn { border: none; background: none; font-size: 18px; cursor: pointer; color: var(--text-soft); }
#text-input {
  width: 100%; border: 1px solid var(--border); border-radius: 12px; padding: 12px;
  font-size: 15px; line-height: 1.5; resize: none; font-family: inherit;
}
#text-input:focus { outline: none; border-color: var(--primary); }

.link-btn { background: none; border: none; color: var(--primary); font-size: 13px; cursor: pointer; margin-top: 8px; }

/* ---------- toast ---------- */
.toast {
  position: fixed; bottom: 110px; left: 50%; transform: translateX(-50%);
  background: rgba(0,0,0,0.8); color: #fff; padding: 8px 16px; border-radius: 20px;
  font-size: 13px; z-index: 100; max-width: 90%;
}

/* 备案页脚：固定在最底部，工具栏在其上方 */
.site-footer {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 21;
  background: var(--bg-soft); border-top: 1px solid var(--border);
  padding: 4px 14px; text-align: center;
  font-size: 11px; color: var(--text-soft); line-height: 1.6;
  max-width: var(--maxw); margin: 0 auto;
}
.footer-beian { display: flex; align-items: center; justify-content: center; gap: 4px; flex-wrap: wrap; }
.site-footer a { color: var(--text-soft); text-decoration: none; }
.site-footer a:hover { color: var(--primary); }
.footer-sep { margin: 0 4px; opacity: 0.4; }
.footer-ga { display: inline-flex; align-items: center; gap: 4px; }
.ga-icon { width: 16px; height: 16px; vertical-align: middle; }

/* 回到顶部按钮（左下角浮动）*/
.back-top {
  position: fixed; left: 16px; bottom: 110px;
  width: 40px; height: 40px; border-radius: 50%;
  border: 1px solid var(--border); background: #fff;
  color: var(--primary); font-size: 20px; line-height: 1;
  cursor: pointer; z-index: 30;
  box-shadow: 0 2px 8px rgba(0,0,0,0.12);
  display: flex; align-items: center; justify-content: center;
  transition: opacity 0.2s, transform 0.2s;
}
.back-top:hover { background: var(--primary); color: #fff; }
.back-top:active { transform: scale(0.92); }
@media (min-width: 768px) {
  .back-top { left: calc(50% - var(--maxw)/2 + 16px); }
}

/* ---------- 编辑器分栏：左编辑 / 右预览 ---------- */
.editor-split {
  display: flex; gap: 0; margin-top: 8px; min-height: 400px;
}
.editor-left {
  flex: 1 1 0%; min-width: 200px; display: flex; flex-direction: column;
  background: #fff; border: 1px solid var(--border); border-radius: 12px;
  overflow: hidden;
}
.editor-right {
  flex: 1 1 0%; min-width: 200px; display: flex; flex-direction: column;
  background: #fff; border: 1px solid var(--border); border-radius: 12px;
  overflow: hidden;
}
.editor-preview-content {
  flex: 1; overflow-y: auto; padding: 14px;
  font-size: 14px; line-height: 1.7; word-break: break-word;
}

/* 可拖拽分隔条 */
.editor-divider {
  width: 6px; cursor: col-resize; flex-shrink: 0;
  background: var(--border); border-radius: 3px; margin: 0 6px;
  transition: background 0.15s;
  align-self: stretch;
}
.editor-divider:hover,
.editor-divider.active {
  background: var(--primary);
}

/* 编辑区 textarea 自适应高度 */
.editor-left #detail-textarea {
  flex: 1; min-height: 300px; resize: none;
  border: none; border-radius: 0; box-shadow: none;
}

/* 手机端：分栏改为上下布局 */
@media (max-width: 767px) {
  .editor-split { flex-direction: column; }
  .editor-divider {
    width: 100%; height: 6px; cursor: row-resize; margin: 6px 0;
  }
  .editor-left, .editor-right { min-width: 0; }
  .editor-right { min-height: 200px; max-height: 50vh; }
}

/* ---------- AI 对话弹窗（基于笔记） ---------- */
.chat-modal {
  position: fixed; bottom: 80px; right: 20px; z-index: 40;
  width: 380px; min-width: 300px; max-width: 90vw;
  height: 480px; min-height: 320px; max-height: 80vh;
  background: #fff; border: 1px solid var(--border); border-radius: 14px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.15);
  display: flex; flex-direction: column; overflow: hidden;
  overscroll-behavior: contain;
  resize: both;
}
.chat-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px; border-bottom: 1px solid var(--border);
  background: var(--bg-soft); cursor: move; flex-shrink: 0;
}
.chat-title { font-size: 14px; font-weight: 600; }
.chat-header-actions { display: flex; gap: 4px; }
.chat-header-btn {
  border: none; background: none; font-size: 14px; cursor: pointer;
  padding: 2px 6px; color: var(--text-soft); border-radius: 4px;
}
.chat-header-btn:hover { background: var(--border); color: var(--text); }

/* 消息列表 */
.chat-messages {
  flex: 1; overflow-y: auto; padding: 14px;
  display: flex; flex-direction: column; gap: 10px;
  overscroll-behavior: contain;
}
.chat-empty {
  text-align: center; color: var(--text-soft); font-size: 13px;
  margin-top: 60px;
}

/* 聊天气泡 */
.chat-bubble {
  max-width: 85%; padding: 10px 14px; border-radius: 16px;
  font-size: 13px; line-height: 1.6; word-break: break-word;
  animation: chatIn 0.2s ease;
}
@keyframes chatIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.chat-bubble.user {
  align-self: flex-end; background: var(--primary); color: #fff;
  border-bottom-right-radius: 4px;
}
.chat-bubble.assistant {
  align-self: flex-start; background: var(--bg-soft); color: var(--text);
  border-bottom-left-radius: 4px;
}
/* AI 消息内的 markdown 样式 */
.chat-bubble.assistant p { margin: 0 0 4px; }
.chat-bubble.assistant p:last-child { margin-bottom: 0; }
.chat-bubble.assistant ul, .chat-bubble.assistant ol { margin: 4px 0; padding-left: 18px; }
.chat-bubble.assistant li { margin: 2px 0; }
.chat-bubble.assistant code { background: rgba(0,0,0,0.06); padding: 1px 4px; border-radius: 3px; font-size: 12px; }
.chat-bubble.assistant pre { background: rgba(0,0,0,0.04); padding: 8px; border-radius: 6px; overflow-x: auto; margin: 4px 0; font-size: 12px; }
.chat-bubble.assistant pre code { background: none; padding: 0; }
.chat-bubble.assistant blockquote { border-left: 2px solid var(--border); padding-left: 8px; margin: 4px 0; color: var(--text-soft); }
.chat-bubble.user .chat-time,
.chat-bubble.assistant .chat-time {
  font-size: 10px; opacity: 0.6; margin-top: 4px;
}

/* 输入区 */
.chat-input-area {
  display: flex; align-items: flex-end; gap: 8px;
  padding: 10px 14px; border-top: 1px solid var(--border);
  background: #fff; flex-shrink: 0;
}
.chat-input {
  flex: 1; border: 1px solid var(--border); border-radius: 18px;
  padding: 8px 14px; font-size: 13px; line-height: 1.4; resize: none;
  font-family: inherit; max-height: 100px; outline: none;
}
.chat-input:focus { border-color: var(--primary); }
.chat-send-btn {
  border: none; background: var(--primary); color: #fff;
  padding: 8px 16px; border-radius: 18px; font-size: 13px;
  font-weight: 600; cursor: pointer; white-space: nowrap;
  transition: opacity 0.15s;
}
.chat-send-btn:hover { opacity: 0.9; }
.chat-send-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* 打字指示器 */
.chat-typing {
  align-self: flex-start; padding: 10px 14px;
  color: var(--text-soft); font-size: 13px;
}
.chat-typing span { animation: chatDot 1.4s infinite; }
.chat-typing span:nth-child(2) { animation-delay: 0.2s; }
.chat-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes chatDot { 0%,80%,100% { opacity: 0.2; } 40% { opacity: 1; } }

/* 移动端 */
@media (max-width: 767px) {
  .chat-modal {
    bottom: 0; right: 0; left: 0; width: 100%; max-width: 100%;
    height: 60vh; border-radius: 18px 18px 0 0; resize: none;
  }
}

/* ============================================================
   响应式断点：平板 / 桌面 / 宽屏
   移动优先，此处仅在大屏覆盖变量与少量布局
   ============================================================ */

/* 平板 ≥ 768px：两列，放宽容器 */
@media (min-width: 768px) {
  :root {
    --maxw: 760px;
    --content-pad: 20px;
  }
  .topbar { padding: 14px var(--content-pad); }
  .brand { font-size: 16px; }
  #search-input { height: 40px; font-size: 14px; }
  .modal-sheet { max-width: 560px; border-radius: 18px; }
  .modal { align-items: center; }              /* 桌面端弹层居中而非底部贴边 */
  .login-card .logo { font-size: 64px; }
  .login-card h1 { font-size: 26px; }
}

/* 桌面 ≥ 1024px：三列，进一步放宽 */
@media (min-width: 1024px) {
  :root {
    --maxw: 1040px;
    --card-min: 300px;
  }
  .note-card { padding: 16px 16px 12px; }
  .note-content { font-size: 15px; }
  .toolbar { gap: 32px; }
  .tool-btn { font-size: 22px; cursor: pointer; }
  .tool-btn:hover { opacity: 0.7; }
  .qf-btn:hover, .note-del:hover { opacity: 0.75; }
  .primary-btn:hover { opacity: 0.9; }
}

/* 宽屏 ≥ 1440px：四列，封顶宽度避免过宽 */
@media (min-width: 1440px) {
  :root {
    --maxw: 1320px;
    --card-min: 290px;
  }
}
