:root {
  --bg: #ffffff;
  --bg-side: #f6f7f9;
  --bg-hover: #eceef1;
  --bg-active: #e3e6ea;
  --border: #e3e6ea;
  --text: #1f2329;
  --text-soft: #6b7280;
  --accent: #4c7bf3;
  --accent-soft: #e8f0fe;
  --code-bg: #f3f4f6;
  --callout-bg: #f1f5fb;
  --tag-bg: #eef1f5;
  --radius: 8px;
  --sidebar-w: 300px;
}

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

/* ---------------- 登录 ---------------- */
.login-screen {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(160deg, #f6f7f9, #eef1f6);
}
.login-card {
  width: 320px; max-width: 90vw;
  background: #fff; border: 1px solid var(--border);
  border-radius: 14px; padding: 32px 28px;
  box-shadow: 0 10px 40px rgba(0,0,0,.08);
  text-align: center;
}
.login-card h1 { margin: 0 0 4px; font-size: 22px; }
.login-sub { margin: 0 0 20px; color: var(--text-soft); font-size: 13px; }
.login-card input {
  width: 100%; padding: 11px 12px; margin-bottom: 12px;
  border: 1px solid var(--border); border-radius: var(--radius);
  font-size: 15px; outline: none;
}
.login-card input:focus { border-color: var(--accent); }
.login-card button {
  width: 100%; padding: 11px; border: none; border-radius: var(--radius);
  background: var(--accent); color: #fff; font-size: 15px; cursor: pointer;
}
.login-card button:hover { filter: brightness(1.05); }
.login-err { color: #e5484d; font-size: 13px; min-height: 18px; margin: 8px 0 0; }
.login-foot { color: var(--text-soft); font-size: 12px; margin: 16px 0 0; }

/* ---------------- 布局 ---------------- */
.app { display: flex; height: 100vh; overflow: hidden; }
.sidebar {
  width: var(--sidebar-w); flex: 0 0 var(--sidebar-w);
  background: var(--bg-side); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; height: 100%;
}
.main { flex: 1; overflow-y: auto; height: 100%; }

.sidebar-head { padding: 12px; border-bottom: 1px solid var(--border); }
#search {
  width: 100%; padding: 8px 10px; border: 1px solid var(--border);
  border-radius: var(--radius); font-size: 14px; outline: none;
}
#search:focus { border-color: var(--accent); }

.tree { padding: 8px 6px; overflow-y: auto; max-height: 38%; border-bottom: 1px solid var(--border); }
.tree-item { padding: 4px 8px; border-radius: 6px; cursor: pointer; user-select: none; font-size: 13px; color: var(--text-soft); }
.tree-item:hover { background: var(--bg-hover); }
.tree-item.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.tree-children { padding-left: 14px; }

.list { flex: 1; overflow-y: auto; padding: 6px; }
.list-item {
  padding: 8px 10px; border-radius: 6px; cursor: pointer;
  border-bottom: 1px solid transparent;
}
.list-item:hover { background: var(--bg-hover); }
.list-item.active { background: var(--bg-active); }
.list-item .li-title { font-size: 14px; }
.list-item .li-folder { font-size: 11px; color: var(--text-soft); margin-top: 2px; }

.sidebar-foot {
  padding: 8px 12px; border-top: 1px solid var(--border);
  display: flex; justify-content: space-between; align-items: center;
  font-size: 12px; color: var(--text-soft);
}
.logout { border: none; background: none; color: var(--text-soft); cursor: pointer; font-size: 12px; }
.logout:hover { color: var(--accent); }

/* ---------------- 阅读区 ---------------- */
.content { max-width: 820px; margin: 0 auto; padding: 40px 32px 120px; }
.content .empty { color: var(--text-soft); text-align: center; margin-top: 20vh; }
.content h1 { font-size: 26px; margin: 0 0 6px; }
.note-meta { margin-bottom: 18px; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.tag {
  background: var(--tag-bg); color: var(--text-soft);
  font-size: 12px; padding: 2px 8px; border-radius: 20px;
}
.content h2 { font-size: 21px; margin: 28px 0 10px; border-bottom: 1px solid var(--border); padding-bottom: 6px; }
.content h3 { font-size: 17px; margin: 22px 0 8px; }
.content p { margin: 10px 0; }
.content ul, .content ol { padding-left: 24px; }
.content li { margin: 4px 0; }
.content code {
  background: var(--code-bg); padding: 2px 6px; border-radius: 4px;
  font-size: 13px; font-family: "SFMono-Regular", Consolas, monospace;
}
.content pre {
  background: var(--code-bg); padding: 14px; border-radius: var(--radius);
  overflow-x: auto;
}
.content pre code { background: none; padding: 0; }
.content blockquote {
  border-left: 3px solid var(--accent); margin: 12px 0; padding: 4px 14px;
  color: var(--text-soft); background: var(--accent-soft); border-radius: 0 6px 6px 0;
}
.content a { color: var(--accent); text-decoration: none; }
.content a.wikilink { color: var(--accent); border-bottom: 1px dashed var(--accent); }
.content img { max-width: 100%; border-radius: 6px; }
.content table { border-collapse: collapse; width: 100%; margin: 12px 0; }
.content th, .content td { border: 1px solid var(--border); padding: 6px 10px; text-align: left; }

/* callout */
.callout {
  border: 1px solid var(--border); background: var(--callout-bg);
  border-left: 4px solid var(--accent); border-radius: var(--radius);
  padding: 10px 14px; margin: 12px 0;
}
.callout-title { font-weight: 600; margin-bottom: 4px; text-transform: capitalize; }
.callout-body > :first-child { margin-top: 0; }
.callout-body > :last-child { margin-bottom: 0; }

/* 菜单按钮(移动端) */
.menu-toggle {
  display: none; position: fixed; top: 12px; left: 12px; z-index: 30;
  width: 40px; height: 40px; border: 1px solid var(--border);
  border-radius: 8px; background: #fff; font-size: 18px; cursor: pointer;
}

/* ---------------- 响应式 ---------------- */
@media (max-width: 768px) {
  .menu-toggle { display: block; }
  .sidebar {
    position: fixed; top: 0; left: 0; z-index: 20;
    transform: translateX(-100%); transition: transform .2s ease;
    box-shadow: 2px 0 20px rgba(0,0,0,.12);
  }
  .sidebar.open { transform: translateX(0); }
  .content { padding: 64px 18px 100px; }
}
