/* ==========================================================================
   静笺 · 私有 Markdown 笔记库
   设计基调：纸感米白 + 墨蓝，阅读优先，克制的层次与留白
   ========================================================================== */

:root {
  --paper: #f6f4ef;
  --paper-deep: #efece3;
  --surface: #fffdf9;
  --surface-2: #faf8f3;
  --ink: #211f1a;
  --ink-2: #514c42;
  --ink-3: #8b8478;
  --line: #e2ddd0;
  --line-soft: #eeeae0;
  --accent: #2c3f63;
  --accent-ink: #1e2c47;
  --accent-soft: #e9edf5;
  --danger: #9d3b32;
  --danger-soft: #f8ecea;
  --ok: #2f6b4f;
  --ok-soft: #eaf2ed;
  --code-bg: #1d2027;
  --radius: 10px;
  --radius-sm: 7px;
  --shadow-sm: 0 1px 2px rgba(38, 33, 22, .05);
  --shadow-md: 0 6px 24px -12px rgba(38, 33, 22, .28), 0 1px 3px rgba(38, 33, 22, .05);
  --shadow-lg: 0 24px 60px -24px rgba(30, 26, 18, .35);
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  --font-serif: "Songti SC", "Noto Serif SC", "Source Han Serif SC", "SimSun", Georgia, serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --sidebar-w: 284px;
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.65;
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-ink); }

h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -.01em; }

svg.ico { width: 16px; height: 16px; flex: none; }

.muted { color: var(--ink-3); }
.small { font-size: 12.5px; }
.nowrap { white-space: nowrap; }
code { font-family: var(--font-mono); font-size: .88em; }
::selection { background: #dfe5f1; }

/* 滚动条 */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #d7d1c3; border-radius: 10px; border: 3px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: #c3bcaa; background-clip: content-box; border: 3px solid transparent; }
::-webkit-scrollbar-track { background: transparent; }

/* ============================ 布局骨架 ============================ */
.layout {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  height: 100vh;
  height: 100dvh;
}

.main {
  min-width: 0;
  overflow-y: auto;
  overflow-x: hidden;
  position: relative;
}

/* ============================ 侧边栏 ============================ */
.sidebar {
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--line);
  background: linear-gradient(180deg, #f2efe7 0%, #efece3 100%);
  padding: 18px 14px 0;
  min-height: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 4px 8px 16px;
  color: var(--ink);
}
.brand:hover { color: var(--ink); }

.brand-mark {
  width: 34px; height: 34px;
  display: grid; place-items: center;
  border-radius: 9px;
  background: var(--accent);
  color: #f7f5ee;
  font-family: var(--font-serif);
  font-size: 19px;
  line-height: 1;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.18), var(--shadow-sm);
  flex: none;
}
.brand-mark-lg { width: 52px; height: 52px; font-size: 28px; border-radius: 13px; }
/* 品牌图：裁进圆角方块 */
.brand-mark { overflow: hidden; padding: 0; }
.brand-mark img { width: 100%; height: 100%; object-fit: cover; display: block; }

.brand-text { display: flex; flex-direction: column; line-height: 1.3; overflow: hidden; }
.brand-text strong { font-family: var(--font-serif); font-size: 17px; font-weight: 600; letter-spacing: .04em; }
.brand-text em { font-style: normal; font-size: 11.5px; color: var(--ink-3); letter-spacing: .02em; white-space: nowrap; }

.side-search {
  position: relative;
  display: flex;
  align-items: center;
  margin: 0 4px 12px;
}
.side-search-ico { position: absolute; left: 10px; color: var(--ink-3); pointer-events: none; }
.side-search input {
  width: 100%;
  height: 34px;
  padding: 0 10px 0 32px;
  font: inherit;
  font-size: 13px;
  color: var(--ink);
  background: rgba(255,255,255,.7);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color .15s, background .15s, box-shadow .15s;
}
.side-search input::placeholder { color: #a9a294; }
.side-search input:focus {
  background: #fff;
  border-color: #b9c4d8;
  box-shadow: 0 0 0 3px rgba(44, 63, 99, .08);
}

.side-actions { display: flex; gap: 8px; padding: 0 4px 14px; }
.side-actions .btn { flex: 1; justify-content: center; }

.side-nav { flex: 1; min-height: 0; overflow-y: auto; padding: 0 0 8px; }

.side-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px 7px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.side-label-tags { padding-top: 16px; }
.side-count { font-weight: 500; letter-spacing: 0; color: #a9a294; }
.side-empty { margin: 4px 12px; font-size: 13px; color: var(--ink-3); }

.doc-list { list-style: none; margin: 0; padding: 0 0 6px; }
.doc-item {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 7px 11px;
  margin: 1px 0;
  font-size: 13.5px;
  color: var(--ink-2);
  border-radius: var(--radius-sm);
  border-left: 2px solid transparent;
  transition: background .13s, color .13s;
}
.doc-item:hover { background: rgba(255,255,255,.75); color: var(--ink); }
.doc-item.is-active {
  background: #fff;
  color: var(--accent-ink);
  font-weight: 600;
  border-left-color: var(--accent);
  box-shadow: var(--shadow-sm);
}
.doc-item-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pin-dot { width: 5px; height: 5px; border-radius: 50%; background: var(--danger); flex: none; opacity: .75; }

.tag-cloud { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 8px 10px; }
.tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  font-size: 11.5px;
  color: var(--ink-2);
  background: rgba(255,255,255,.6);
  border: 1px solid var(--line);
  border-radius: 999px;
  transition: background .13s, color .13s, border-color .13s;
}
.tag-chip span { color: var(--ink-3); font-size: 10.5px; }
.tag-chip:hover { background: #fff; border-color: #cfc8b8; color: var(--accent); }
.tag-chip-sm { font-size: 11px; padding: 1px 7px; background: transparent; }

.side-foot { border-top: 1px solid var(--line); padding: 8px 4px 10px; }
.user-menu { position: relative; }
.user-menu summary {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  list-style: none;
  transition: background .13s;
}
.user-menu summary::-webkit-details-marker { display: none; }
.user-menu summary:hover { background: rgba(255,255,255,.7); }
.avatar {
  width: 28px; height: 28px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-size: 12.5px;
  font-weight: 700;
  flex: none;
}
.avatar-sm { width: 26px; height: 26px; font-size: 11.5px; }
/* 头像图：裁成圆形 */
.avatar { overflow: hidden; padding: 0; }
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.user-meta { display: flex; flex-direction: column; line-height: 1.25; overflow: hidden; flex: 1; }
.user-meta strong { font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-meta em { font-style: normal; font-size: 11px; color: var(--ink-3); }
.user-menu-ico { color: var(--ink-3); }

.user-pop {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 4px; right: 4px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: 5px;
  z-index: 30;
}
.user-pop a, .user-pop button {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 8px 10px;
  font: inherit;
  font-size: 13px;
  color: var(--ink-2);
  background: none;
  border: 0;
  border-radius: 6px;
  cursor: pointer;
  text-align: left;
}
.user-pop a:hover, .user-pop button:hover { background: var(--paper); color: var(--ink); }
.user-pop form { margin: 0; }
.user-pop form button { color: var(--danger); }

.sidebar-toggle {
  display: none;
  position: fixed;
  top: 12px; left: 12px;
  z-index: 60;
  width: 38px; height: 38px;
  align-items: center; justify-content: center;
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 9px;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
}
.sidebar-scrim { display: none; }

/* ============================ 通用按钮 ============================ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 36px;
  padding: 0 14px;
  font: inherit;
  font-size: 13.5px;
  font-weight: 500;
  line-height: 1;
  border-radius: 8px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink-2);
  cursor: pointer;
  white-space: nowrap;
  transition: background .14s, border-color .14s, color .14s, box-shadow .14s, transform .06s;
}
.btn:active { transform: translateY(.5px); }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn-sm { height: 30px; padding: 0 10px; font-size: 12.5px; border-radius: 7px; }
.btn-block { width: 100%; justify-content: center; height: 40px; }

.btn-primary {
  background: var(--accent);
  color: #f8f7f2;
  border-color: var(--accent);
  box-shadow: 0 1px 2px rgba(30, 44, 71, .22), inset 0 1px 0 rgba(255,255,255,.12);
}
.btn-primary:hover { background: var(--accent-ink); border-color: var(--accent-ink); color: #fff; }

.btn-quiet {
  background: var(--surface);
  border-color: var(--line);
  color: var(--ink-2);
  box-shadow: var(--shadow-sm);
}
.btn-quiet:hover { background: #fff; border-color: #d5cfc0; color: var(--ink); }

.btn-danger-quiet { background: transparent; border-color: transparent; color: var(--danger); }
.btn-danger-quiet:hover { background: var(--danger-soft); border-color: #edd8d5; }

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 32px; height: 32px;
  border-radius: 8px;
  color: var(--ink-2);
  flex: none;
}
.icon-btn:hover { background: rgba(0,0,0,.05); color: var(--ink); }

.link-quiet { color: var(--ink-2); border-bottom: 1px solid transparent; }
.link-quiet:hover { color: var(--accent); border-bottom-color: currentColor; }

/* ============================ 页面容器 ============================ */
.page {
  max-width: 1080px;
  margin: 0 auto;
  padding: 44px 44px 80px;
  animation: fade-up .32s ease both;
}
.page-narrow { max-width: 780px; }

@keyframes fade-up {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 26px;
}
.page-head h1 {
  font-family: var(--font-serif);
  font-size: 27px;
  font-weight: 600;
  letter-spacing: .01em;
}
.page-sub { margin: 7px 0 0; font-size: 13px; color: var(--ink-3); }

/* 列表排序切换（最近更新 / 按名称） */
.sort-switch {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  margin-left: 10px;
  padding: 2px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-2);
  vertical-align: 1px;
}
.sort-switch a {
  padding: 1px 9px;
  font-size: 11.5px;
  color: var(--ink-3);
  border-radius: 999px;
  white-space: nowrap;
}
.sort-switch a:hover { color: var(--ink); }
.sort-switch a.is-on {
  color: var(--ink);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}
.page-actions { display: flex; gap: 8px; flex: none; }
.chip-inline { color: var(--accent); font-weight: 600; }

/* ============================ 笔记卡片 ============================ */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(268px, 1fr));
  gap: 14px;
}

.card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 18px 18px 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--ink);
  min-height: 150px;
  box-shadow: var(--shadow-sm);
  transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease;
}
.card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: #d8d2c2;
  color: var(--ink);
}
.card-top { display: flex; gap: 6px; align-items: center; min-height: 18px; }
.card-top:empty { display: none; }
.card-title {
  font-family: var(--font-serif);
  font-size: 17px;
  font-weight: 600;
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card-desc {
  margin: 0;
  font-size: 13px;
  color: var(--ink-3);
  line-height: 1.6;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  flex: 1;
}
.card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding-top: 8px;
  border-top: 1px dashed var(--line-soft);
  font-size: 11.5px;
  color: var(--ink-3);
}
.card-tags { display: flex; gap: 8px; overflow: hidden; }
.card-tags span { color: #8d8677; white-space: nowrap; }

.pin-flag {
  display: inline-flex; align-items: center; gap: 3px;
  padding: 1px 6px;
  font-size: 10.5px;
  font-weight: 600;
  color: var(--danger);
  background: var(--danger-soft);
  border-radius: 4px;
}
.pin-flag svg { width: 11px; height: 11px; }

.vis-badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 7px;
  font-size: 11px;
  color: var(--ink-2);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 999px;
}
.vis-badge svg { width: 11px; height: 11px; }
.vis-badge-sm { font-size: 10.5px; padding: 1px 6px; }
.vis-plain { font-size: 12.5px; color: var(--ink-3); }

.empty-state {
  padding: 64px 24px;
  text-align: center;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  background: rgba(255,255,255,.45);
}
.empty-mark {
  width: 46px; height: 46px;
  margin: 0 auto 14px;
  display: grid; place-items: center;
  font-family: var(--font-serif);
  font-size: 20px;
  color: #b6ae9c;
  border: 1px solid var(--line);
  border-radius: 50%;
}
.empty-state h2 { font-size: 16px; margin-bottom: 6px; }
.empty-state p { margin: 0; font-size: 13.5px; color: var(--ink-3); }

.pager { display: flex; align-items: center; justify-content: center; gap: 14px; margin-top: 26px; }
.pager-info { font-size: 12.5px; color: var(--ink-3); }

.inline-search {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px 6px 12px;
  margin-bottom: 22px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 9px;
  color: var(--ink-3);
  box-shadow: var(--shadow-sm);
}
.inline-search input {
  flex: 1;
  height: 30px;
  font: inherit;
  font-size: 13.5px;
  color: var(--ink);
  background: none;
  border: 0;
  outline: none;
}
.inline-search-lg { padding: 8px 10px 8px 14px; }
.inline-search-lg input { height: 34px; font-size: 14.5px; }

/* ============================ 阅读页 ============================ */
.reader {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 208px;
  gap: 40px;
  max-width: 1140px;
  margin: 0 auto;
  padding: 40px 40px 96px;
}

.paper {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow-md);
  padding: 46px 56px 34px;
  min-width: 0;
}

.doc-head { margin-bottom: 30px; padding-bottom: 22px; border-bottom: 1px solid var(--line-soft); }
.doc-tags { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 14px; }
.doc-title {
  font-family: var(--font-serif);
  font-size: 31px;
  line-height: 1.35;
  font-weight: 600;
  letter-spacing: .005em;
  margin: 0 0 14px;
}
.doc-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 16px;
  font-size: 12px;
  color: var(--ink-3);
}
.doc-meta span { display: inline-flex; align-items: center; gap: 5px; }
.doc-meta svg { width: 13px; height: 13px; opacity: .8; }

.doc-tools { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 16px; }
.doc-tools form { margin: 0; }

.version-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  margin-bottom: 22px;
  font-size: 13px;
  color: #7a5a1e;
  background: #fdf6e4;
  border: 1px solid #f0e3c2;
  border-radius: 9px;
}
.version-banner span { display: inline-flex; align-items: center; gap: 7px; }
.version-banner form { margin: 0; }

.doc-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-top: 40px;
  padding-top: 18px;
  border-top: 1px solid var(--line-soft);
  font-size: 12px;
  color: var(--ink-3);
}
.to-top { color: var(--ink-3); }
.to-top:hover { color: var(--accent); }

/* 目录 */
.toc { position: relative; }
.toc-inner {
  position: sticky;
  top: 32px;
  max-height: calc(100vh - 80px);
  overflow-y: auto;
  padding-left: 14px;
  border-left: 1px solid var(--line);
}
.toc-title {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .13em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin-bottom: 10px;
}
.toc ol { list-style: none; margin: 0; padding: 0; }
.toc li { margin: 0 0 2px; }
.toc a {
  display: block;
  padding: 3px 0;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--ink-3);
  border-left: 2px solid transparent;
  margin-left: -15px;
  padding-left: 13px;
  transition: color .13s, border-color .13s;
}
.toc a:hover { color: var(--accent); border-left-color: var(--accent); }
.toc a.is-active { color: var(--accent-ink); border-left-color: var(--accent); font-weight: 600; }
.toc-l3 a { padding-left: 25px; font-size: 12px; }
.toc-l4 a { padding-left: 37px; font-size: 11.5px; }

/* ============================ Markdown 正文 ============================ */
.markdown-body {
  font-size: 16px;
  line-height: 1.85;
  color: #262420;
  word-wrap: break-word;
  overflow-wrap: break-word;
}
.markdown-body > *:first-child { margin-top: 0; }
.markdown-body > *:last-child { margin-bottom: 0; }

.markdown-body h1, .markdown-body h2, .markdown-body h3,
.markdown-body h4, .markdown-body h5, .markdown-body h6 {
  font-family: var(--font-serif);
  font-weight: 600;
  line-height: 1.4;
  margin: 1.9em 0 .7em;
  scroll-margin-top: 24px;
  color: #1c1a15;
}
.markdown-body h1 { font-size: 1.62em; }
.markdown-body h2 {
  font-size: 1.3em;
  padding-bottom: .34em;
  border-bottom: 1px solid var(--line-soft);
}
.markdown-body h3 { font-size: 1.11em; }
.markdown-body h4 { font-size: 1em; color: var(--ink-2); }
.markdown-body h5, .markdown-body h6 { font-size: .95em; color: var(--ink-2); }

.markdown-body p { margin: 1em 0; }
.markdown-body strong { font-weight: 650; color: #17150f; }
.markdown-body em { font-style: italic; }
.markdown-body del { color: var(--ink-3); }

.markdown-body a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-color: rgba(44,63,99,.28);
  text-underline-offset: 3px;
  text-decoration-thickness: 1px;
}
.markdown-body a:hover { text-decoration-color: currentColor; }

.markdown-body ul, .markdown-body ol { margin: 1em 0; padding-left: 1.5em; }
.markdown-body li { margin: .32em 0; }
.markdown-body li > ul, .markdown-body li > ol { margin: .3em 0; }
.markdown-body li::marker { color: #b2a996; }
.markdown-body ul li.task-item { list-style: none; margin-left: -1.2em; }
.markdown-body .task-box {
  width: 14px; height: 14px;
  margin-right: .4em;
  vertical-align: -1px;
  accent-color: var(--accent);
}

.markdown-body blockquote {
  margin: 1.2em 0;
  padding: .6em 1.1em;
  color: var(--ink-2);
  background: var(--surface-2);
  border-left: 3px solid #c9c2b0;
  border-radius: 0 8px 8px 0;
}
.markdown-body blockquote p { margin: .4em 0; }

.markdown-body code {
  padding: .16em .38em;
  font-size: .875em;
  color: #9d3b32;
  background: #f3efe6;
  border: 1px solid #eae4d7;
  border-radius: 4px;
}

.markdown-body pre.code-block {
  position: relative;
  margin: 1.3em 0;
  padding: 16px 18px;
  background: var(--code-bg);
  border-radius: 10px;
  overflow-x: auto;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.04);
}
.markdown-body pre.code-block code {
  display: block;
  padding: 0;
  font-size: 13px;
  line-height: 1.7;
  color: #e6e6e6;
  background: none;
  border: 0;
  white-space: pre;
}

.code-copy {
  position: absolute;
  top: 8px; right: 8px;
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 8px;
  font: inherit;
  font-size: 11px;
  color: #b7bcc6;
  background: rgba(255,255,255,.07);
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 6px;
  cursor: pointer;
  opacity: 0;
  transition: opacity .15s, background .15s, color .15s;
}
pre.code-block:hover .code-copy { opacity: 1; }
.code-copy:hover { background: rgba(255,255,255,.15); color: #fff; }
.code-copy.is-done { color: #8ddba4; border-color: rgba(141,219,164,.4); }

.markdown-body table {
  width: 100%;
  margin: 1.3em 0;
  border-collapse: collapse;
  font-size: .93em;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
}
.markdown-body th, .markdown-body td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--line-soft);
  border-right: 1px solid var(--line-soft);
  text-align: left;
  vertical-align: top;
}
.markdown-body th { background: var(--surface-2); font-weight: 600; color: var(--ink-2); }
.markdown-body tr:last-child td { border-bottom: 0; }
.markdown-body th:last-child, .markdown-body td:last-child { border-right: 0; }
.markdown-body tbody tr:hover { background: #fcfaf5; }

.markdown-body img {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
  border: 1px solid var(--line-soft);
  margin: .4em 0;
}
.markdown-body hr {
  height: 1px;
  margin: 2.4em 0;
  border: 0;
  background: repeating-linear-gradient(90deg, var(--line) 0 6px, transparent 6px 12px);
}
.markdown-body kbd {
  padding: .1em .4em;
  font-family: var(--font-mono);
  font-size: .82em;
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 4px;
  background: var(--surface-2);
}
.markdown-body mark { background: #fdf0b8; padding: 0 .15em; border-radius: 2px; }
.markdown-body details {
  margin: 1em 0;
  padding: .6em 1em;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 8px;
}
.markdown-body summary { cursor: pointer; font-weight: 600; }

/* highlight.js 配色（暗色代码块） */
.hljs-comment, .hljs-quote { color: #8b949e; font-style: italic; }
.hljs-keyword, .hljs-selector-tag, .hljs-literal, .hljs-type { color: #ff7b72; }
.hljs-string, .hljs-doctag, .hljs-regexp, .hljs-addition { color: #a5d6ff; }
.hljs-number, .hljs-symbol, .hljs-bullet, .hljs-variable, .hljs-template-variable { color: #79c0ff; }
.hljs-title, .hljs-title.class_, .hljs-title.function_, .hljs-section { color: #d2a8ff; }
.hljs-attr, .hljs-attribute, .hljs-name, .hljs-tag { color: #7ee787; }
.hljs-built_in, .hljs-params, .hljs-meta, .hljs-selector-id, .hljs-selector-class { color: #ffa657; }
.hljs-emphasis { font-style: italic; }
.hljs-strong { font-weight: 700; }
.hljs-deletion { color: #ffa198; }

/* ============================ 编辑器 ============================ */
.editor {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  background: var(--surface);
  animation: fade-up .25s ease both;
}
.editor-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #fbf9f4, #f8f6f0);
}
.title-input {
  flex: 1;
  min-width: 0;
  height: 38px;
  padding: 0 10px;
  font-family: var(--font-serif);
  font-size: 18px;
  font-weight: 600;
  color: var(--ink);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
  outline: none;
}
.title-input:hover { background: rgba(255,255,255,.7); }
.title-input:focus { background: #fff; border-color: #c6cfdf; box-shadow: 0 0 0 3px rgba(44,63,99,.07); }
.title-input::placeholder { color: #b7b0a1; font-weight: 500; }
.editor-head-actions { display: flex; gap: 6px; flex: none; }

.editor-meta {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 8px 20px;
  border-bottom: 1px solid var(--line-soft);
  background: #fdfbf7;
  font-size: 12.5px;
  flex-wrap: wrap;
}
.meta-field { display: flex; align-items: center; gap: 7px; }
.meta-field > span { color: var(--ink-3); }
.meta-field input, .meta-field select {
  height: 28px;
  padding: 0 8px;
  font: inherit;
  font-size: 12.5px;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
  outline: none;
}
.meta-field input { width: 240px; }
.meta-field select { width: 118px; }
.meta-field input:focus, .meta-field select:focus { border-color: #b9c4d8; box-shadow: 0 0 0 3px rgba(44,63,99,.07); }
.meta-hint { margin-left: auto; color: var(--ink-3); }

.editor-error {
  padding: 9px 20px;
  font-size: 13px;
  color: var(--danger);
  background: var(--danger-soft);
  border-bottom: 1px solid #edd8d5;
}

.editor-toolbar {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 5px 12px;
  border-bottom: 1px solid var(--line-soft);
  background: #fdfbf7;
  flex-wrap: wrap;
}
.tool {
  display: inline-grid;
  place-items: center;
  width: 28px; height: 28px;
  color: var(--ink-2);
  background: none;
  border: 0;
  border-radius: 6px;
  cursor: pointer;
}
.tool:hover { background: rgba(44,63,99,.08); color: var(--accent); }
.tool-text { width: auto; padding: 0 9px; font: inherit; font-size: 12px; }
.tool-sep { width: 1px; height: 16px; margin: 0 5px; background: var(--line); }
.toolbar-spacer { flex: 1; }

.editor-body {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
}
.pane { min-width: 0; min-height: 0; overflow-y: auto; }
.pane-write { border-right: 1px solid var(--line-soft); background: #fffefb; }
.pane-preview { background: var(--surface); padding: 26px 30px 60px; }

#md-input {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 100%;
  padding: 24px 26px 80px;
  font-family: var(--font-mono);
  font-size: 13.5px;
  line-height: 1.75;
  color: #2c2a24;
  background: transparent;
  border: 0;
  outline: none;
  resize: none;
  tab-size: 2;
}
#md-input::placeholder { color: #b6afa0; }

.editor-status {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 18px;
  font-size: 12px;
  color: var(--ink-2);
  border-top: 1px solid var(--line-soft);
  background: #faf8f2;
}
.dot-sep { color: #cfc8b8; }
.status-spacer { flex: 1; }
.kbd-hint { display: flex; align-items: center; gap: 4px; color: var(--ink-3); font-size: 11.5px; }
kbd {
  display: inline-block;
  padding: 1px 5px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--ink-2);
  background: #fff;
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 4px;
}
[data-status].is-dirty { color: #9a6b1f; }
[data-status].is-saved { color: var(--ok); }

/* ============================ 高亮与数学公式 ============================ */
/* ==文字== 高亮 */
.paper mark, .md-preview mark, mark {
  background: rgba(214, 198, 156, .5);
  color: inherit;
  padding: 0 .2em;
  border-radius: 2px;
}

/* KaTeX：MathML 输出 + 本站样式微调 */
.paper .katex, .md-preview .katex { font-size: 1.06em; }
.paper .katex-display, .md-preview .katex-display {
  margin: 1.1em 0;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 2px 0;
}
.paper .katex-display > .katex, .md-preview .katex-display > .katex { display: block; text-align: center; }
/* 公式里的中文（如 \text{有效}）回退到系统中文字体 */
.paper .katex, .md-preview .katex {
  font-family: KaTeX_Main, "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", "Microsoft YaHei", sans-serif;
}
.math-error {
  font-family: var(--font-mono);
  font-size: .88em;
  color: var(--danger);
  background: var(--danger-soft);
  padding: .1em .35em;
  border-radius: 4px;
}

/* ============================ 告警框（> [!类型]） ============================ */
.callout {
  margin: 1em 0;
  padding: 10px 14px;
  border-left: 3px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}
.callout > .callout-title {
  margin: 0 0 4px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink);
}
.callout > .callout-title:only-child { margin-bottom: 0; }
.callout > :last-child { margin-bottom: 0; }

.callout-note, .callout-abstract, .callout-summary, .callout-tldr,
.callout-info, .callout-todo { border-left-color: var(--accent); background: var(--accent-soft); }
.callout-tip, .callout-hint, .callout-important,
.callout-success, .callout-check, .callout-done { border-left-color: var(--ok); background: var(--ok-soft); }
.callout-question, .callout-help, .callout-faq,
.callout-example { border-left-color: #6b4f9e; background: #f1ecf8; }
.callout-warning, .callout-caution, .callout-attention { border-left-color: #9a6b1f; background: #f8efdd; }
.callout-failure, .callout-fail, .callout-danger,
.callout-error, .callout-bug { border-left-color: var(--danger); background: var(--danger-soft); }
.callout-quote, .callout-cite { border-left-color: var(--ink-3); background: var(--paper-deep); }

/* ============================ 弹窗 ============================ */
.dialog {
  width: min(560px, calc(100vw - 32px));
  max-height: 86vh;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}
.dialog::backdrop { background: rgba(32, 28, 20, .42); backdrop-filter: blur(2px); }
.dialog-form { padding: 22px 24px; overflow-y: auto; max-height: 86vh; }
.dialog h2 { font-family: var(--font-serif); font-size: 19px; margin-bottom: 6px; }
.dialog-sub { margin: 0 0 18px; font-size: 12.5px; color: var(--ink-3); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }

.acl-list { margin-top: 16px; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; }
.acl-head, .acl-row {
  display: grid;
  grid-template-columns: 1fr 52px 62px;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
}
.acl-head {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .06em;
  color: var(--ink-3);
  background: var(--surface-2);
  border-bottom: 1px solid var(--line);
  text-align: center;
}
.acl-head span:first-child { text-align: left; }
.acl-row { border-bottom: 1px solid var(--line-soft); font-size: 13px; }
.acl-row:last-child { border-bottom: 0; }
.acl-name { display: flex; flex-direction: column; line-height: 1.3; }
.acl-name em { font-style: normal; font-size: 11px; color: var(--ink-3); }
.acl-check { display: grid; place-items: center; }
.acl-check input { width: 15px; height: 15px; accent-color: var(--accent); cursor: pointer; }

/* ============================ 表单 ============================ */
.field { display: block; margin-bottom: 15px; }
.field > span { display: block; margin-bottom: 6px; font-size: 12.5px; font-weight: 500; color: var(--ink-2); }
.field input, .field select, .field textarea {
  width: 100%;
  height: 38px;
  padding: 0 11px;
  font: inherit;
  font-size: 14px;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: none;
  transition: border-color .14s, box-shadow .14s;
}
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: #b9c4d8;
  box-shadow: 0 0 0 3px rgba(44,63,99,.08);
}
.field-hint { display: block; margin-top: 5px; font-style: normal; font-size: 11.5px; color: var(--ink-3); }

.card-form {
  padding: 26px 28px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow-sm);
}
.form-actions { display: flex; gap: 8px; margin-top: 20px; }

.field-inline { display: flex; flex-direction: column; gap: 5px; }
.field-inline > span { font-size: 11.5px; color: var(--ink-3); }
.field-inline input, .field-inline select {
  height: 32px;
  padding: 0 9px;
  font: inherit;
  font-size: 13px;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 7px;
  outline: none;
}
.field-inline input:focus, .field-inline select:focus { border-color: #b9c4d8; box-shadow: 0 0 0 3px rgba(44,63,99,.07); }

.row-form {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  flex-wrap: wrap;
}
.stack-form { display: flex; flex-direction: column; gap: 9px; padding: 10px 0; border-bottom: 1px dashed var(--line-soft); }
.stack-form:last-child { border-bottom: 0; }
.filter-bar { display: flex; align-items: flex-end; gap: 10px; margin-bottom: 16px; }

/* ============================ 面板 / 表格 ============================ */
.panel {
  padding: 20px 22px;
  margin-bottom: 20px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow-sm);
}
.panel-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
}
.panel-head h2 { font-family: var(--font-serif); font-size: 16px; }
.panel-head-tight { margin-top: 24px; padding-top: 16px; border-top: 1px solid var(--line-soft); }

.split-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; align-items: start; }

.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th {
  padding: 8px 10px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--ink-3);
  text-align: left;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.table td { padding: 10px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: #fdfbf6; }
.table-compact td { padding: 7px 10px; font-size: 12.5px; }
.col-actions { text-align: right; }
.table-link { color: var(--ink); font-weight: 500; }
.table-link:hover { color: var(--accent); }

.user-cell { display: flex; align-items: center; gap: 9px; }
.user-cell span { display: flex; flex-direction: column; line-height: 1.3; }
.user-cell em { font-style: normal; font-size: 11px; color: var(--ink-3); }
.role-badge {
  display: inline-block;
  padding: 2px 8px;
  font-size: 11px;
  border-radius: 999px;
  color: var(--ink-2);
  background: var(--paper);
  border: 1px solid var(--line);
}
.role-badge[data-role="admin"] { color: var(--accent-ink); background: var(--accent-soft); border-color: #cfd8ea; }
.role-badge[data-role="editor"] { color: var(--ok); background: var(--ok-soft); border-color: #cfe2d7; }
.status-on { color: var(--ok); font-size: 12.5px; }
.status-off { color: var(--danger); font-size: 12.5px; }
.status-hint { margin-left: 6px; font-size: 10.5px; color: #9a6b1f; background: #fdf6e4; padding: 1px 5px; border-radius: 4px; }

.row-menu { position: relative; display: inline-block; }
.row-menu summary { list-style: none; cursor: pointer; }
.row-menu summary::-webkit-details-marker { display: none; }
.row-menu-pop {
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
  z-index: 20;
  width: 260px;
  padding: 8px 12px 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--shadow-md);
  text-align: left;
}
.row-menu-pop .field-inline { margin-bottom: 6px; }

.kv-list { margin: 0; }
.kv-list > div { display: flex; justify-content: space-between; gap: 12px; padding: 7px 0; border-bottom: 1px dashed var(--line-soft); font-size: 13px; }
.kv-list > div:last-child { border-bottom: 0; }
.kv-list dt { color: var(--ink-3); }
.kv-list dd { margin: 0; text-align: right; }

.check-list { list-style: none; margin: 0; padding: 0; }
.check-list li { display: flex; gap: 9px; align-items: flex-start; padding: 6px 0; font-size: 13px; color: var(--ink-2); }
.check-list li svg { margin-top: 3px; }
.check-list li.ok svg { color: var(--ok); }
.check-list li.warn svg { color: #b58a2b; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; margin-bottom: 22px; }
.stat {
  padding: 16px 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.stat-label { font-size: 11.5px; letter-spacing: .06em; color: var(--ink-3); text-transform: uppercase; }
.stat-value { font-family: var(--font-serif); font-size: 27px; line-height: 1.25; color: var(--ink); }
.stat-foot { font-size: 11.5px; color: var(--ink-3); }

.event-list { list-style: none; margin: 0; padding: 0; }
.event-list li {
  display: grid;
  grid-template-columns: 132px minmax(0, 1fr) 88px 68px;
  gap: 8px;
  align-items: center;
  padding: 6px 0;
  font-size: 12.5px;
  border-bottom: 1px dashed var(--line-soft);
}
.event-list li:last-child { border-bottom: 0; }
.event-action {
  display: inline-block;
  padding: 1px 7px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-2);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.event-action[data-kind="login"] { color: var(--accent); background: var(--accent-soft); border-color: #cfd8ea; }
.event-action[data-kind="doc"] { color: var(--ok); background: var(--ok-soft); border-color: #cfe2d7; }
.event-action[data-kind="user"] { color: #8a5a1e; background: #fdf6e4; border-color: #f0e3c2; }
.event-target { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink-2); }
.event-actor { color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.event-list time { color: var(--ink-3); text-align: right; }

.rank-list { list-style: none; margin: 0; padding: 0; }
.rank-list li { display: flex; justify-content: space-between; gap: 10px; padding: 6px 0; font-size: 13px; }
.rank-list span { color: var(--ink-3); font-size: 12px; }

.backup-ok { display: flex; align-items: center; gap: 7px; margin: 0 0 6px; font-size: 13px; color: var(--ok); }
.backup-warn { display: flex; align-items: center; gap: 7px; margin: 0 0 6px; font-size: 13px; color: #9a6b1f; }

.admin-nav {
  display: flex;
  gap: 4px;
  margin-bottom: 20px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
}
.admin-nav a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  font-size: 13px;
  color: var(--ink-3);
  border-radius: 7px;
  white-space: nowrap;
}
.admin-nav a:hover { background: rgba(255,255,255,.7); color: var(--ink); }
.admin-nav a.is-active { color: var(--accent-ink); background: #fff; box-shadow: var(--shadow-sm); font-weight: 600; }

.flash-inline {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 9px 14px;
  margin-bottom: 16px;
  font-size: 13px;
  color: var(--ok);
  background: var(--ok-soft);
  border: 1px solid #cfe2d7;
  border-radius: 9px;
}

/* ============================ 上传 ============================ */
.upload-form { margin-bottom: 30px; }
.dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 46px 24px;
  text-align: center;
  background: var(--surface);
  border: 1.5px dashed #d3ccbb;
  border-radius: 12px;
  cursor: pointer;
  transition: border-color .15s, background .15s, transform .15s;
}
.dropzone:hover, .dropzone.is-over { border-color: var(--accent); background: #fbfcff; }
.dropzone.is-over { transform: scale(1.005); }
.dropzone-ico { color: var(--accent); opacity: .8; }
.dropzone-ico svg { width: 30px; height: 30px; }
.dropzone strong { font-size: 14.5px; }
.dropzone-sub { font-size: 12px; color: var(--ink-3); max-width: 460px; line-height: 1.6; }

.file-list { list-style: none; margin: 14px 0 0; padding: 0; }
.file-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 12px;
  margin-bottom: 6px;
  font-size: 13px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}
.file-list em { font-style: normal; color: var(--ink-3); font-size: 11.5px; }

.upload-actions { display: flex; align-items: center; gap: 12px; margin-top: 16px; }

.hint-block { padding: 20px 22px; background: rgba(255,255,255,.5); border: 1px solid var(--line); border-radius: 12px; }
.hint-block h2 { font-size: 14px; margin-bottom: 8px; }
.hint-block p { margin: 0 0 12px; font-size: 13px; color: var(--ink-2); line-height: 1.7; }
.code-inline-sample {
  margin: 0;
  padding: 12px 14px;
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.7;
  color: var(--ink-2);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow-x: auto;
}

.result-list { list-style: none; margin: 0 0 8px; padding: 0; }
.result-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  margin-bottom: 6px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 9px;
  font-size: 13.5px;
}
.result-ok { color: var(--ok); display: inline-flex; }
.result-bad { color: var(--danger); display: inline-flex; }
.result-name { display: flex; flex-direction: column; line-height: 1.35; flex: 1; min-width: 0; }
.result-name em { font-style: normal; font-size: 11.5px; color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; }
.result-name a { color: var(--ink); font-weight: 500; }
.section-title { font-size: 14px; margin: 22px 0 10px; }
.result-list-bad li { border-color: #edd8d5; background: #fdf8f7; }

/* ============================ 历史版本 ============================ */
.version-list { list-style: none; margin: 0; padding: 0; }
.version-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  margin-bottom: 8px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 9px;
  box-shadow: var(--shadow-sm);
}
.version-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.version-title { font-size: 13.5px; font-weight: 500; }
.version-meta { font-size: 11.5px; color: var(--ink-3); display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.version-actions { display: flex; gap: 6px; flex: none; }
.version-actions form { margin: 0; }
.badge {
  padding: 1px 6px;
  font-size: 10px;
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: 4px;
}

/* ============================ 搜索结果 ============================ */
.search-list { list-style: none; margin: 24px 0 0; padding: 0; }
.search-item { padding: 16px 0; border-bottom: 1px solid var(--line-soft); }
.search-item:last-child { border-bottom: 0; }
.search-title { font-family: var(--font-serif); font-size: 16.5px; font-weight: 600; color: var(--ink); }
.search-title:hover { color: var(--accent); }
.search-snippet { margin: 6px 0 8px; font-size: 13.5px; line-height: 1.7; color: var(--ink-2); }
.search-snippet mark { background: #fdf0b8; color: inherit; padding: 0 2px; border-radius: 2px; }
.search-meta { display: flex; align-items: center; gap: 8px; font-size: 11.5px; color: var(--ink-3); }

/* ============================ 登录页 ============================ */
.auth-body {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 32px 20px;
  background:
    radial-gradient(900px 480px at 50% -10%, #fffdf7 0%, transparent 70%),
    radial-gradient(600px 400px at 100% 100%, #f1ede2 0%, transparent 65%),
    var(--paper);
}
.auth-wrap { width: 100%; max-width: 400px; animation: fade-up .4s ease both; }
.auth-brand { text-align: center; margin-bottom: 24px; }
.auth-brand .brand-mark { margin: 0 auto 14px; }
.auth-brand h1 {
  font-family: var(--font-serif);
  font-size: 26px;
  font-weight: 600;
  letter-spacing: .12em;
}
.auth-brand p { margin: 6px 0 0; font-size: 12.5px; color: var(--ink-3); letter-spacing: .04em; }

.auth-card {
  position: relative;
  overflow: hidden;
  padding: 30px 30px 24px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow-md);
}
.auth-card::before {
  content: '';
  position: absolute;
  inset: 0 0 auto 0;
  height: 3px;
  background: linear-gradient(90deg, var(--accent) 0%, #6a7fa9 60%, #cbbfa4 100%);
}
.auth-card h2 { font-family: var(--font-serif); font-size: 19px; margin-bottom: 4px; }
.auth-sub { margin: 0 0 20px; font-size: 12.5px; color: var(--ink-3); }

.auth-error {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 10px 12px;
  margin-bottom: 16px;
  font-size: 12.5px;
  line-height: 1.6;
  color: var(--danger);
  background: var(--danger-soft);
  border: 1px solid #edd8d5;
  border-radius: 8px;
}
.auth-error svg { margin-top: 2px; }

.auth-foot {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin: 18px 0 0;
  font-size: 11.5px;
  color: var(--ink-3);
}

/* ============================ 凭据页 / 错误页 ============================ */
.credential-panel {
  padding: 34px 36px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow-md);
  text-align: center;
}
.credential-badge {
  width: 46px; height: 46px;
  margin: 0 auto 14px;
  display: grid; place-items: center;
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: 50%;
}
.credential-badge svg { width: 22px; height: 22px; }
.credential-panel h1 { font-family: var(--font-serif); font-size: 20px; margin-bottom: 8px; }
.credential-note { margin: 0 auto 22px; max-width: 460px; font-size: 13px; color: var(--ink-2); line-height: 1.7; }
.credential-list { margin: 0 0 24px; text-align: left; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.credential-list > div { display: flex; justify-content: space-between; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--line-soft); }
.credential-list > div:last-child { border-bottom: 0; }
.credential-list dt { font-size: 12.5px; color: var(--ink-3); }
.credential-list dd { margin: 0; }
.credential-pw {
  font-family: var(--font-mono);
  font-size: 15px;
  letter-spacing: .06em;
  color: var(--accent-ink);
  background: var(--accent-soft);
  padding: 2px 8px;
  border-radius: 5px;
  user-select: all;
}
.credential-actions { display: flex; justify-content: center; }

.error-panel { padding: 56px 36px; text-align: center; }
.error-panel-auth {
  padding: 44px 36px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow-md);
  max-width: 420px;
}
.error-code {
  font-family: var(--font-serif);
  font-size: 44px;
  line-height: 1;
  color: #cdc5b2;
  margin-bottom: 10px;
}
.error-panel h1 { font-family: var(--font-serif); font-size: 21px; margin-bottom: 8px; }
.error-panel p { margin: 0 auto 22px; max-width: 420px; font-size: 13.5px; color: var(--ink-2); line-height: 1.75; }
.error-actions { display: flex; justify-content: center; gap: 8px; }

/* ============================ Toast ============================ */
.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%) translateY(12px);
  padding: 10px 18px;
  font-size: 13px;
  color: #f6f5f0;
  background: rgba(32, 29, 22, .94);
  border-radius: 999px;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  pointer-events: none;
  transition: opacity .22s ease, transform .22s ease;
  z-index: 100;
}
.toast.is-visible { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.is-error { background: rgba(120, 34, 26, .95); }

/* ============================ 文件夹 ============================ */
.side-mini {
  display: inline-grid;
  place-items: center;
  width: 20px; height: 20px;
  padding: 0;
  color: var(--ink-3);
  background: transparent;
  border: 0;
  border-radius: 5px;
  cursor: pointer;
}
.side-mini:hover { background: rgba(255,255,255,.85); color: var(--accent); }
.side-mini svg { width: 13px; height: 13px; }

.folder-list { list-style: none; margin: 0 0 4px; padding: 0 0 2px; }
.folder-children { list-style: none; margin: 0; padding: 0; }
.folder-item {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 6px 10px;
  margin: 1px 0;
  font-size: 13px;
  color: var(--ink-2);
  border-radius: var(--radius-sm);
  border-left: 2px solid transparent;
  transition: background .13s, color .13s;
}
.folder-item:hover { background: rgba(255,255,255,.75); color: var(--ink); }
.folder-item.is-active {
  background: #fff;
  color: var(--accent-ink);
  font-weight: 600;
  border-left-color: var(--accent);
  box-shadow: var(--shadow-sm);
}
.folder-item.d1 { padding-left: 24px; }
.folder-item.d2 { padding-left: 38px; }
.folder-ico { width: 14px; height: 14px; color: #a49b87; }
.folder-item.is-active .folder-ico { color: var(--accent); }
.folder-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.folder-count {
  font-size: 10.5px;
  color: var(--ink-3);
  background: rgba(255,255,255,.7);
  border-radius: 999px;
  padding: 0 5px;
  min-width: 18px;
  text-align: center;
}
.folder-item.is-active .folder-count { background: var(--accent-soft); color: var(--accent-ink); }

/* 面包屑 */
.crumb {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
  font-size: 12.5px;
  color: var(--ink-3);
}
.crumb a { color: var(--ink-3); }
.crumb a:hover { color: var(--accent); }
.crumb-sep { color: #cbc4b4; }
.crumb-current { color: var(--ink-2); font-weight: 500; }
.crumb-doc { margin-bottom: 16px; }

/* 子文件夹卡片 */
.folder-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 10px;
  margin-bottom: 20px;
}
.folder-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 13px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--ink);
  box-shadow: var(--shadow-sm);
  transition: transform .14s, box-shadow .14s, border-color .14s;
}
.folder-card:hover { transform: translateY(-1px); box-shadow: var(--shadow-md); border-color: #d8d2c2; color: var(--ink); }
.folder-card-ico {
  width: 32px; height: 32px;
  display: grid; place-items: center;
  border-radius: 8px;
  background: var(--paper);
  color: #9a917d;
  flex: none;
}
.folder-card-body { display: flex; flex-direction: column; line-height: 1.35; min-width: 0; }
.folder-card-body strong { font-size: 13.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.folder-card-body em { font-style: normal; font-size: 11px; color: var(--ink-3); }

.kind-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 1px 7px;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: .04em;
  color: #6c5c3a;
  background: #f7f1e2;
  border: 1px solid #ecdfc6;
  border-radius: 4px;
}
.kind-badge svg { width: 11px; height: 11px; }
.doc-kind-ico { width: 12px; height: 12px; color: #a89c82; }
.card-folder { display: inline-flex; align-items: center; gap: 3px; color: #8d8677; white-space: nowrap; }
.card-folder svg { width: 11px; height: 11px; }

/* 文件夹管理页 */
.folder-manage { list-style: none; margin: 0 0 14px; padding: 0; }
.folder-manage-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 14px;
  margin-bottom: 7px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 9px;
  box-shadow: var(--shadow-sm);
}
.folder-manage-row.d1 { margin-left: 26px; }
.folder-manage-row.d2 { margin-left: 52px; }
.folder-manage-main { display: flex; align-items: center; gap: 9px; min-width: 0; }
.folder-manage-ico { color: #a49b87; display: inline-flex; }
.folder-manage-name { font-size: 13.5px; font-weight: 500; }
.folder-manage-count { font-size: 11.5px; color: var(--ink-3); }
.folder-manage-actions { display: flex; gap: 6px; flex: none; align-items: center; }

/* 上传目标 */
.upload-target {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 14px;
  padding: 10px 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
}
.upload-target .meta-field select { width: 220px; }

/* 文件型文档 */
.file-preview { margin: 6px 0 0; }
.file-image {
  display: block;
  max-width: 100%;
  margin: 0 auto;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--paper);
}
.file-frame {
  width: 100%;
  height: min(72vh, 760px);
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}
.file-frame-text { height: min(60vh, 620px); background: #fdfbf6; }
.file-standalone {
  padding: 46px 24px;
  text-align: center;
  background: var(--surface-2);
  border: 1px dashed var(--line);
  border-radius: 12px;
}
.file-standalone-ico {
  width: 54px; height: 54px;
  margin: 0 auto 14px;
  display: grid; place-items: center;
  color: #9a917d;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
}
.file-standalone-ico svg { width: 26px; height: 26px; }
.file-standalone h2 { font-family: var(--font-serif); font-size: 18px; margin-bottom: 6px; word-break: break-all; }
.file-standalone p { margin: 4px 0; }
.file-standalone .btn { margin-top: 14px; }
.file-edit-panel { flex: 1; display: grid; place-items: center; padding: 40px 24px; overflow-y: auto; }
.dialog-sm { width: min(460px, calc(100vw - 32px)); }

/* ============================ 响应式 ============================ */
@media (max-width: 1180px) {
  .reader { grid-template-columns: minmax(0, 1fr); padding: 28px 28px 80px; }
  .toc { display: none; }
}

@media (max-width: 900px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .sidebar-toggle { display: flex; }
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: 286px;
    z-index: 50;
    transform: translateX(-102%);
    transition: transform .22s ease;
    box-shadow: var(--shadow-lg);
  }
  body.sidebar-open .sidebar { transform: none; }
  body.sidebar-open .sidebar-scrim {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 40;
    background: rgba(30, 26, 18, .35);
  }
  .main { padding-top: 8px; }
  .page { padding: 56px 18px 64px; }
  .page-head { flex-direction: column; align-items: flex-start; gap: 12px; }
  .paper { padding: 28px 22px 26px; border-radius: 10px; }
  .reader { padding: 58px 12px 60px; }
  .doc-title { font-size: 25px; }
  .split-2 { grid-template-columns: 1fr; }
  .cards { grid-template-columns: 1fr; }
  .editor-head { padding: 8px 10px; gap: 4px; }
  .title-input { font-size: 16px; }
  .editor-head-actions .btn { padding: 0 8px; }
  .editor-body { grid-template-columns: minmax(0, 1fr); }
  .editor-body[data-view="split"] .pane-preview { display: none; }
  .editor-body[data-view="preview"] .pane-write { display: none; }
  .editor-body[data-view="preview"] .pane-preview { display: block; }
  .pane-write { border-right: 0; }
  .meta-hint { display: none; }
  .event-list li { grid-template-columns: 1fr auto; }
  .event-list .event-actor, .event-list .event-target { display: none; }
  .table { font-size: 12.5px; }
  .table th:nth-child(4), .table td:nth-child(4),
  .table th:nth-child(5), .table td:nth-child(5) { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ============================ 打印 ============================ */
@media print {
  .sidebar, .sidebar-toggle, .toc, .doc-tools, .to-top, .editor-toolbar, .editor-status, .toast { display: none !important; }
  body, .main { background: #fff; height: auto; overflow: visible; }
  .layout { display: block; }
  .reader { display: block; padding: 0; max-width: none; }
  .paper { border: 0; box-shadow: none; padding: 0; }
  .markdown-body pre.code-block { background: #f5f3ee; color: #222; }
  .markdown-body pre.code-block code, .hljs-comment, .hljs-keyword, .hljs-string, .hljs-number, .hljs-title { color: #222 !important; }
  a { text-decoration: none; color: #222; }
}
