:root {
  --bg: #faf7f5;
  --panel: #ffffff;
  --border: #ece3df;
  --text: #2c2622;
  --muted: #9b8e88;
  --rose: #c24a6b;
  --rose-soft: #f6e7ec;
  --hover: #f3ece9;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--text);
  background: var(--bg);
}
.muted { color: var(--muted); font-size: 13px; }
.hidden { display: none !important; }

/* 登录 */
.login-mask {
  position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #f6e7ec, #faf7f5);
}
.login-card {
  background: var(--panel); border: 1px solid var(--border); border-radius: 14px;
  padding: 32px 28px; width: 320px; box-shadow: 0 12px 40px rgba(0,0,0,.08);
  display: flex; flex-direction: column; gap: 12px;
}
.login-card h1 { margin: 0; color: var(--rose); }
.login-card input {
  padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; font-size: 14px;
}
.login-card button {
  padding: 10px; border: none; border-radius: 8px; background: var(--rose); color: #fff;
  font-size: 15px; cursor: pointer;
}
.login-card button:hover { filter: brightness(1.05); }
.error { color: #d33; font-size: 13px; min-height: 16px; }

/* 布局 */
.app { display: flex; height: 100vh; }
.sidebar {
  width: 280px; min-width: 280px; background: var(--panel); border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
}
.sidebar-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; border-bottom: 1px solid var(--border);
}
.sidebar-head strong { color: var(--rose); }
#btn-new {
  border: 1px solid var(--border); background: var(--rose-soft); color: var(--rose);
  width: 28px; height: 28px; border-radius: 7px; cursor: pointer; font-size: 16px; line-height: 1;
}
.search-box { padding: 10px 12px; border-bottom: 1px solid var(--border); }
.search-box input {
  width: 100%; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; font-size: 13px;
}
.tree { flex: 1; overflow: auto; padding: 8px 6px; }
.sidebar-foot {
  padding: 10px 16px; border-top: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.link { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 13px; }

/* 树 */
.node { user-select: none; }
.node-row {
  display: flex; align-items: center; gap: 6px; padding: 4px 8px; border-radius: 6px;
  cursor: pointer; font-size: 14px;
}
.node-row:hover { background: var(--hover); }
.node-row.active { background: var(--rose-soft); color: var(--rose); font-weight: 600; }
.node-row .ico { width: 16px; text-align: center; opacity: .8; }
.node-row .label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.children { padding-left: 14px; }

/* 树行悬浮操作按钮 */
.node-row .acts { display: none; gap: 2px; }
.node-row:hover .acts { display: inline-flex; }
.ra {
  border: none; background: transparent; color: var(--muted); cursor: pointer;
  font-size: 12px; line-height: 1; padding: 3px 4px; border-radius: 4px;
}
.ra:hover { background: var(--rose-soft); color: var(--rose); }
.search-hit { padding: 6px 10px; border-radius: 6px; cursor: pointer; font-size: 13px; }
.search-hit:hover { background: var(--hover); }
.search-hit .snip { color: var(--muted); font-size: 12px; display: block; margin-top: 2px; }
.search-hit mark { background: #ffe6a0; }

/* 主区 */
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar {
  display: flex; align-items: center; gap: 12px; padding: 12px 18px;
  border-bottom: 1px solid var(--border); background: var(--panel);
}
.crumb { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.save-status { font-size: 13px; }
.save-status.ok { color: #2a9d57; }
.save-status.err { color: #d33; }
.primary {
  border: none; background: var(--rose); color: #fff; padding: 8px 18px;
  border-radius: 8px; cursor: pointer; font-size: 14px;
}
.primary:disabled { opacity: .5; cursor: default; }
.editor { flex: 1; min-height: 0; }

/* 全文搜索结果面板（覆盖主区，与编辑器互斥显示） */
.search-panel { flex: 1; min-height: 0; display: flex; flex-direction: column; background: var(--panel); }
.sp-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 18px; border-bottom: 1px solid var(--border);
}
.sp-title { font-size: 13px; color: var(--muted); }
.sp-list { flex: 1; overflow: auto; padding: 8px 12px; }
.sp-item {
  padding: 10px 12px; border-radius: 8px; cursor: pointer;
  border-bottom: 1px solid var(--border);
}
.sp-item:hover { background: var(--hover); }
.sp-item:last-child { border-bottom: none; }
.sp-file { display: flex; align-items: center; gap: 8px; }
.sp-name { font-weight: 600; font-size: 14px; }
.sp-count {
  font-size: 12px; color: var(--rose); background: var(--rose-soft);
  border-radius: 10px; padding: 1px 8px; white-space: nowrap;
}
.sp-path { font-size: 12px; color: var(--muted); margin-top: 2px; word-break: break-all; }
.sp-item .snip {
  font-size: 12px; color: var(--muted); margin-top: 4px; line-height: 1.6;
  overflow: hidden; text-overflow: ellipsis; display: -webkit-box;
  -webkit-line-clamp: 2; -webkit-box-orient: vertical;
}
.sp-item mark, .search-hit mark { background: #ffe6a0; color: inherit; border-radius: 2px; }

/* Vditor 铺满主区 */
.editor .vditor { display: flex; flex-direction: column; height: 100%; border: none; border-radius: 0; }
.editor .vditor-content { flex: 1; min-height: 0; }
.editor .vditor-reset { min-height: 100%; }
