/* ================= tokens ================= */
:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --panel-2: #fbfbfc;
  --border: #e6e8eb;
  --border-strong: #d8dce1;
  --text: #1a1f26;
  --text-2: #5b6470;
  --text-3: #8b949e;
  --accent: #2f6feb;
  --accent-hover: #2559c9;
  --accent-soft: #eaf1fe;
  --danger: #cf3b31;
  --danger-soft: #fdeceb;
  --radius: 8px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 8px 24px rgba(16, 24, 40, .06);
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
          "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
}

body {
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

button, input, select, textarea {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

button { cursor: pointer; }

/* ================= buttons ================= */
.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: none;
  background: var(--accent);
  color: #fff;
  padding: 9px 16px;
  border-radius: 6px;
  font-weight: 500;
  transition: background .15s;
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:disabled { opacity: .55; cursor: default; }

.btn-sm { padding: 6px 11px; font-size: 13px; }
.btn-block { width: 100%; justify-content: center; padding: 11px; }

.btn-ghost {
  border: 1px solid var(--border-strong);
  background: #fff;
  padding: 8px 15px;
  border-radius: 6px;
  color: var(--text-2);
}
.btn-ghost:hover { background: var(--panel-2); color: var(--text); }

.icon-btn {
  border: none;
  background: transparent;
  color: var(--text-3);
  width: 26px;
  height: 26px;
  border-radius: 5px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background .15s, color .15s;
}
.icon-btn:hover { background: #eef0f3; color: var(--text); }
.icon-btn.danger:hover { background: var(--danger-soft); color: var(--danger); }

/* ================= login ================= */
.login-wrap {
  min-height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px 0;
  background:
    radial-gradient(900px 420px at 50% -10%, #e8effc 0%, transparent 70%),
    var(--bg);
}

/* 卡片舞台：吃掉剩余高度并把卡片垂直居中，备案行才能稳稳压在最底部 */
.login-stage {
  flex: 1 1 auto;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-card {
  width: 100%;
  max-width: 372px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 34px 32px 26px;
  box-shadow: var(--shadow);
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 20px;
  font-weight: 650;
  letter-spacing: .3px;
  color: var(--text);
}
.login-brand svg { color: var(--accent); }

.login-sub {
  margin: 6px 0 26px;
  color: var(--text-3);
  font-size: 13px;
}

.field { display: block; margin-bottom: 15px; }
.field > span {
  display: block;
  font-size: 12.5px;
  color: var(--text-2);
  margin-bottom: 6px;
  font-weight: 500;
}
.field input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  outline: none;
  background: #fff;
  transition: border-color .15s, box-shadow .15s;
}
.field input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(47, 111, 235, .12);
}

.form-error {
  color: var(--danger);
  font-size: 12.5px;
  min-height: 18px;
  margin: 2px 0 10px;
}

.login-foot {
  text-align: center;
  color: var(--text-3);
  font-size: 12px;
  margin: 20px 0 0;
}

/* ================= 备案信息（合规必需，勿删） ================= */
/* 登录页底部，未登录即可见；必须是文字，不能换成图片 */
.icp-bar {
  flex: 0 0 auto;
  width: 100%;
  padding: 14px 20px 20px;
  text-align: center;
  font-size: 12px;
  line-height: 1.8;
  color: var(--text-3);
}
.icp-bar a,
.icp-mini a {
  color: var(--text-3);
  text-decoration: none;
}
.icp-bar a:hover,
.icp-mini a:hover {
  color: var(--accent);
  text-decoration: underline;
}
.icp-dot {
  margin: 0 6px;
  opacity: .6;
}
.icp-mini {
  padding: 10px 12px 12px;
  font-size: 11px;
  line-height: 1.6;
  color: var(--text-3);
  text-align: center;
  border-top: 1px solid rgba(255, 255, 255, .08);
}

/* ================= layout ================= */
.app {
  display: flex;
  height: 100vh;
  overflow: hidden;
  background: var(--panel);
}

/* ---------- sidebar ---------- */
.sidebar {
  width: 232px;
  flex: 0 0 232px;
  background: var(--panel-2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 14px 10px 10px;
  position: relative;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 650;
  font-size: 15px;
  padding: 2px 8px 14px;
  color: var(--text);
}
.brand svg { color: var(--accent); }

.search-box {
  position: relative;
  display: flex;
  align-items: center;
  margin: 0 4px 12px;
}
.search-box svg {
  position: absolute;
  left: 9px;
  color: var(--text-3);
  pointer-events: none;
}
.search-box input {
  width: 100%;
  padding: 7px 30px 7px 30px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  outline: none;
  font-size: 13px;
}
.search-box input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(47, 111, 235, .1);
}
.search-box input::-webkit-search-cancel-button { cursor: pointer; }
.search-box kbd {
  position: absolute;
  right: 7px;
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--text-3);
  background: #f1f3f5;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0 5px;
  line-height: 16px;
}

.nav { display: flex; flex-direction: column; gap: 1px; }

.nav-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 7px 9px;
  border-radius: 6px;
  color: var(--text-2);
  cursor: pointer;
  user-select: none;
  font-size: 13.5px;
  transition: background .12s, color .12s;
  text-decoration: none;
}
.nav-item:hover { background: #eef0f3; color: var(--text); }
.nav-item.active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 550;
}
.nav-item.active .nav-count { color: var(--accent); background: #fff; }

.nav-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav-count {
  font-size: 11.5px;
  color: var(--text-3);
  background: #eef0f3;
  border-radius: 20px;
  padding: 0 7px;
  min-width: 22px;
  text-align: center;
  line-height: 18px;
  flex: 0 0 auto;
}

.side-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 9px 6px;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: .6px;
  text-transform: uppercase;
  color: var(--text-3);
}

.cat-list {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
}

.side-foot {
  border-top: 1px solid var(--border);
  padding-top: 9px;
  margin-top: 8px;
  position: relative;
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 5px 5px 5px 6px;
  border-radius: 7px;
}
.avatar {
  width: 28px;
  height: 28px;
  flex: 0 0 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, #4c86f5, #2f6feb);
  color: #fff;
  font-size: 12.5px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  text-transform: uppercase;
}
.user-meta { flex: 1; min-width: 0; }
.user-name {
  font-size: 13px;
  font-weight: 550;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.user-role { font-size: 11.5px; color: var(--text-3); }

.menu {
  position: absolute;
  bottom: 46px;
  left: 6px;
  right: 6px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 4px;
  z-index: 30;
}
.menu button {
  display: block;
  width: 100%;
  text-align: left;
  border: none;
  background: transparent;
  padding: 8px 10px;
  border-radius: 5px;
  font-size: 13px;
  color: var(--text-2);
}
.menu button:hover { background: #f1f3f5; color: var(--text); }
.menu button.danger { color: var(--danger); }
.menu button.danger:hover { background: var(--danger-soft); }

/* ---------- list pane ---------- */
.list-pane {
  width: 328px;
  flex: 0 0 328px;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  background: #fff;
}

.list-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding: 16px 16px 12px;
  border-bottom: 1px solid var(--border);
}
.list-head h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 650;
}
.list-sub {
  margin: 2px 0 0;
  font-size: 12px;
  color: var(--text-3);
}

.doc-list {
  flex: 1;
  overflow-y: auto;
  padding: 6px;
}

.doc-card {
  padding: 11px 11px 12px;
  border-radius: 7px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background .12s, border-color .12s;
}
.doc-card:hover { background: #f7f8fa; }
.doc-card.active {
  background: var(--accent-soft);
  border-color: #cfe0fd;
}

.doc-card h3 {
  margin: 0 0 3px;
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.doc-excerpt {
  margin: 0;
  font-size: 12px;
  color: var(--text-3);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.doc-foot {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
  font-size: 11px;
  color: var(--text-3);
  flex-wrap: wrap;
}
.doc-tag {
  background: #f0f2f5;
  border-radius: 4px;
  padding: 0 5px;
  line-height: 17px;
}

.list-empty {
  padding: 40px 16px;
  text-align: center;
  color: var(--text-3);
  font-size: 13px;
}

/* ---------- editor ---------- */
.editor-pane {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: #fff;
}

.empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  color: #c3c9d1;
  font-size: 13.5px;
}

.editor {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.editor-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 18px 10px;
  border-bottom: 1px solid var(--border);
}

.title-input {
  flex: 1;
  min-width: 0;
  border: none;
  outline: none;
  font-size: 17px;
  font-weight: 650;
  padding: 4px 0;
  background: transparent;
  color: var(--text);
}
.title-input::placeholder { color: #b9c0c9; font-weight: 500; }

.editor-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}

.seg {
  display: inline-flex;
  background: #f1f3f5;
  border-radius: 6px;
  padding: 2px;
}
.seg button {
  border: none;
  background: transparent;
  padding: 4px 10px;
  font-size: 12.5px;
  border-radius: 5px;
  color: var(--text-2);
}
.seg button.active {
  background: #fff;
  color: var(--text);
  font-weight: 550;
  box-shadow: 0 1px 2px rgba(16, 24, 40, .08);
}

.kbd-hint {
  font-size: 10.5px;
  opacity: .7;
  font-family: var(--mono);
}

.meta-row {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 9px 18px;
  border-bottom: 1px solid var(--border);
  background: var(--panel-2);
  flex-wrap: wrap;
}
.meta-item {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12.5px;
  color: var(--text-3);
  white-space: nowrap;
  flex: 0 0 auto;
}
.meta-item > span { flex: 0 0 auto; }
.meta-item.grow { flex: 1; min-width: 160px; }
.meta-item select,
.meta-item input {
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 5px;
  padding: 4px 8px;
  font-size: 12.5px;
  color: var(--text);
  outline: none;
  min-width: 110px;
}
.meta-item input { width: 100%; }
.meta-item select:focus,
.meta-item input:focus { border-color: var(--accent); }
.doc-stat { color: var(--text-3); font-size: 12px; }

.split {
  flex: 1;
  min-height: 0;
  display: flex;
}

.pane {
  flex: 1;
  min-width: 0;
  overflow: auto;
}

#doc-content {
  width: 100%;
  height: 100%;
  border: none;
  outline: none;
  resize: none;
  padding: 20px 22px 60px;
  font-family: var(--mono);
  font-size: 13.2px;
  line-height: 1.78;
  color: var(--text);
  background: #fff;
  tab-size: 2;
}
#doc-content::placeholder { color: #b9c0c9; font-family: var(--sans); }

.preview {
  border-left: 1px solid var(--border);
  padding: 20px 26px 60px;
  background: #fff;
}

/* mode switching */
.split.mode-edit .preview { display: none; }
.split.mode-preview .pane:first-child { display: none; }
.split.mode-preview .preview { border-left: none; }

/* ---------- markdown body ---------- */
.markdown-body { font-size: 14px; line-height: 1.78; color: var(--text); }
.markdown-body > *:first-child { margin-top: 0; }
.markdown-body h1,
.markdown-body h2,
.markdown-body h3,
.markdown-body h4 {
  margin: 1.5em 0 .6em;
  font-weight: 650;
  line-height: 1.35;
}
.markdown-body h1 { font-size: 1.5em; padding-bottom: .3em; border-bottom: 1px solid var(--border); }
.markdown-body h2 { font-size: 1.26em; padding-bottom: .25em; border-bottom: 1px solid var(--border); }
.markdown-body h3 { font-size: 1.1em; }
.markdown-body h4 { font-size: 1em; }
.markdown-body p { margin: .75em 0; }
.markdown-body ul,
.markdown-body ol { margin: .7em 0; padding-left: 1.6em; }
.markdown-body li { margin: .25em 0; }
.markdown-body a { color: var(--accent); text-decoration: none; }
.markdown-body a:hover { text-decoration: underline; }
.markdown-body code {
  font-family: var(--mono);
  font-size: .88em;
  background: #f2f4f7;
  border-radius: 4px;
  padding: .15em .4em;
  color: #b4325a;
}
.markdown-body pre {
  background: #f7f8fa;
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 13px 15px;
  overflow: auto;
  margin: 1em 0;
}
.markdown-body pre code {
  background: none;
  padding: 0;
  color: #24292f;
  font-size: 12.7px;
  line-height: 1.65;
}
.markdown-body blockquote {
  margin: 1em 0;
  padding: .2em 1em;
  border-left: 3px solid #d5dce6;
  color: var(--text-2);
  background: #fafbfc;
  border-radius: 0 5px 5px 0;
}
.markdown-body table {
  border-collapse: collapse;
  margin: 1em 0;
  width: 100%;
  font-size: 13px;
}
.markdown-body th,
.markdown-body td {
  border: 1px solid var(--border-strong);
  padding: 7px 11px;
  text-align: left;
}
.markdown-body th { background: #f6f7f9; font-weight: 600; }
.markdown-body tr:nth-child(even) td { background: #fbfcfd; }
.markdown-body img { max-width: 100%; border-radius: 6px; }
.markdown-body hr { border: none; border-top: 1px solid var(--border); margin: 1.6em 0; }
.markdown-body input[type="checkbox"] { margin-right: 6px; }

/* ================= modal ================= */
.mask {
  position: fixed;
  inset: 0;
  background: rgba(16, 24, 40, .38);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
}
.modal {
  width: 100%;
  max-width: 420px;
  background: #fff;
  border-radius: 11px;
  padding: 22px 24px 18px;
  box-shadow: 0 20px 48px rgba(16, 24, 40, .22);
}
.modal h3 { margin: 0 0 14px; font-size: 15.5px; font-weight: 650; }
.modal p { margin: 0 0 12px; color: var(--text-2); font-size: 13.5px; }
.modal .field { margin-bottom: 12px; }
.modal .field:last-child { margin-bottom: 0; }

/* 弹窗内输入控件统一外观：纵向排列、撑满宽度。
   不加这段，裸 input 会用浏览器默认宽度挤成一行并压到按钮上。 */
.modal .field select,
.modal .field textarea,
#modal-body > input:not([type="checkbox"]):not([type="radio"]),
#modal-body > select,
#modal-body > textarea {
  display: block;
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  outline: none;
  background: #fff;
  font-size: 13.5px;
  line-height: 1.45;
  transition: border-color .15s, box-shadow .15s;
}
.modal .field select:focus,
.modal .field textarea:focus,
#modal-body > input:not([type="checkbox"]):not([type="radio"]):focus,
#modal-body > select:focus,
#modal-body > textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(47, 111, 235, .12);
}
.modal .field select,
#modal-body > select { cursor: pointer; }
#modal-body > input:not([type="checkbox"]):not([type="radio"])::placeholder,
#modal-body > textarea::placeholder { color: #b9c0c9; }
/* 相邻的裸输入框之间留出间距 */
#modal-body > input + input,
#modal-body > input + select,
#modal-body > select + input { margin-top: 10px; }
/* 输入框不会把按钮挤出弹窗 */
#modal-body { overflow-wrap: anywhere; }
.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 9px;
  margin-top: 18px;
}

.user-row {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.user-row:last-of-type { border-bottom: none; }
.user-row .u-name { font-weight: 550; flex: 1; }
.user-row .u-role {
  font-size: 11px;
  color: var(--text-3);
  background: #f1f3f5;
  border-radius: 4px;
  padding: 1px 6px;
}
.user-list { max-height: 300px; overflow: auto; margin-bottom: 6px; }

/* ================= toast ================= */
.toast {
  position: fixed;
  bottom: 26px;
  left: 50%;
  transform: translateX(-50%) translateY(10px);
  background: #1f2430;
  color: #fff;
  padding: 9px 18px;
  border-radius: 7px;
  font-size: 13px;
  opacity: 0;
  transition: opacity .2s, transform .2s;
  z-index: 200;
  pointer-events: none;
  max-width: 80vw;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.err { background: var(--danger); }

/* ================= scrollbars ================= */
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb {
  background: #d7dbe0;
  border-radius: 5px;
  border: 2px solid transparent;
  background-clip: content-box;
}
::-webkit-scrollbar-thumb:hover { background: #c2c8d0; background-clip: content-box; }
::-webkit-scrollbar-track { background: transparent; }

/* ================= responsive ================= */
@media (max-width: 1100px) {
  .list-pane { width: 280px; flex-basis: 280px; }
  .sidebar { width: 208px; flex-basis: 208px; }
}

@media (max-width: 840px) {
  .app { flex-direction: column; overflow: auto; }
  .sidebar { width: 100%; flex: 0 0 auto; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 8px; }
  .brand { padding: 0 8px 0 4px; }
  .search-box { flex: 1; min-width: 150px; margin: 0 6px; }
  .nav, .side-head, .cat-list { display: none; }
  .side-foot { border: none; padding: 0; margin: 0; }
  .user-meta { display: none; }
  .list-pane { width: 100%; flex: 0 0 auto; max-height: 40vh; }
  .editor-head { flex-wrap: wrap; }
  .split { flex-direction: column; }
  .preview { border-left: none; border-top: 1px solid var(--border); }
}

/* ---------- 目录树（大目录 + 文档） ---------- */
.tree-group { margin-bottom: 1px; }

.tree-head {
  font-weight: 550;
}
.tree-head .tree-caret {
  width: 10px;
  font-size: 10px;
  color: var(--text-3);
  flex: 0 0 10px;
  text-align: center;
}
.tree-head .nav-label { flex: 1; }

.tree-docs {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 1px 0 3px 15px;
  border-left: 1px solid var(--border);
  margin: 0 0 2px 9px;
}

.tree-doc {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 7px;
  border-radius: 5px;
  font-size: 12.5px;
  color: var(--text-2);
  cursor: pointer;
  text-decoration: none;
  line-height: 1.4;
}
.tree-doc:hover { background: #eef0f3; color: var(--text); }
.tree-doc.active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 550;
}
.tree-doc .tree-num {
  flex: 0 0 auto;
  font-size: 10.5px;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
  min-width: 20px;
}
.tree-doc.active .tree-num { color: var(--accent); }
.tree-doc .tree-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* 文档卡片编号 */
.doc-card h3 .doc-num {
  color: var(--text-3);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  margin-right: 6px;
  font-size: 12px;
}

/* 正文里的图片：可点击放大，不撑破版面 */
.markdown-body img {
  max-width: 100%;
  height: auto;
  border-radius: 6px;
  border: 1px solid var(--border);
  cursor: zoom-in;
  background: #fff;
}

/* ---------- 图片灯箱 ---------- */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: none;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 12px;
  padding: 32px;
  background: rgba(12, 16, 22, .82);
  cursor: zoom-out;
}
.lightbox.show { display: flex; }
.lightbox img {
  max-width: 100%;
  max-height: calc(100vh - 100px);
  border-radius: 6px;
  box-shadow: 0 12px 48px rgba(0, 0, 0, .45);
  background: #fff;
}
.lightbox-hint { color: rgba(255, 255, 255, .62); font-size: 12px; }

/* ---------- 行操作（⋯）与浮层菜单 ---------- */
.row-more {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  padding: 0;
  flex: 0 0 20px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--text-3);
  cursor: pointer;
  opacity: 0;
  transition: opacity .12s, background .12s, color .12s;
}
.row-more:hover { background: #e3e7ec; color: var(--text); }

.doc-card { position: relative; padding-right: 34px; }
.doc-card .row-more { position: absolute; top: 8px; right: 7px; }
.doc-card:hover .row-more,
.doc-card.active .row-more { opacity: .85; }
.doc-card:hover .row-more:hover { opacity: 1; }

.tree-head .row-more { margin-left: 2px; }
.tree-head:hover .row-more,
.tree-head.active .row-more { opacity: .8; }

.tree-doc .tree-title { flex: 1; min-width: 0; }
.tree-doc .row-more { flex-basis: 18px; width: 18px; height: 18px; }
.tree-doc:hover .row-more,
.tree-doc.active .row-more { opacity: .8; }

@media (hover: none) {
  .row-more { opacity: .8; }
}

.row-menu {
  position: fixed;
  z-index: 300;
  min-width: 152px;
  padding: 5px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 10px 30px rgba(15, 23, 42, .16);
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.row-menu button {
  display: block;
  width: 100%;
  padding: 7px 10px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--text);
  font-size: 12.5px;
  text-align: left;
  cursor: pointer;
  font-family: inherit;
}
.row-menu button:hover:not(:disabled) { background: #f1f3f6; }
.row-menu button:disabled { color: var(--text-3); cursor: default; }
.row-menu button.danger { color: #d33; }
.row-menu button.danger:hover:not(:disabled) { background: #fdecec; }
.row-menu-sep { height: 1px; margin: 4px 6px; background: var(--border); }

.modal-hint { margin: 0 0 8px; color: var(--text-2); font-size: 12.5px; }
.modal-hint.warn { color: #b45309; }
.modal-hint code {
  font-family: var(--mono);
  font-size: 12px;
  background: #f1f3f5;
  border-radius: 4px;
  padding: 1px 5px;
  color: var(--text);
}

/* ================= 加密区 ================= */
.lock-head { padding-top: 14px; }

.lock-list {
  padding-bottom: 4px;
  /* 加密文档一多就把底部用户区顶出屏幕，这里限高内部滚动 */
  max-height: min(240px, 32vh);
  overflow-y: auto;
  flex: 0 0 auto;
}

.lock-ico {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 17px;
  height: 17px;
  flex: 0 0 17px;
  color: var(--text-3);
}

.lock-entry { justify-content: flex-start; }
.lock-entry .lock-ico { color: var(--accent); }
.lock-entry .nav-label { flex: 1 1 auto; }
.lock-entry .nav-count { margin-left: auto; }

.lock-bar {
  margin: 4px 9px 6px;
  padding: 4px 8px;
  font-size: 11px;
  line-height: 1.5;
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: 5px;
  text-align: center;
}

.lock-empty {
  padding: 8px 9px;
  font-size: 12.5px;
  color: var(--text-3);
}

.lock-setup {
  margin: 4px 9px;
  padding: 6px 8px;
  gap: 7px;
  justify-content: flex-start;
  border: 1px dashed var(--border-strong);
  border-radius: 6px;
  font-size: 12.5px;
  color: var(--text-3);
}

.lock-setup:hover {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-soft);
}

.lock-setup .lock-ico { color: inherit; }

.lock-doc .row-more { opacity: 0; transition: opacity .12s; }
.lock-doc:hover .row-more,
.lock-doc.active .row-more { opacity: 1; }

.lock-doc .nav-label { flex: 1 1 auto; }

/* 文档上的加密标记 */
.lock-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
  margin-right: 6px;
  vertical-align: -2px;
}

.lock-mark svg { display: block; }

.doc-card h3 .lock-mark { opacity: .9; }

.lock-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px 3px 7px;
  border-radius: 20px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 11.5px;
  font-weight: 600;
  line-height: 1.4;
  white-space: nowrap;
  flex: 0 0 auto;
  align-self: center;
}

.lock-chip svg { display: block; }

/* =========================================================
   阅读模式 —— learn2 风格文档站
   参考 help.baobaot.com：深色 300px 目录 + 单栏 900px 正文
   ========================================================= */

.read-toggle {
  margin-left: auto;
  border: 1px solid var(--border-strong);
  background: #fff;
  color: var(--text-2);
  font-size: 12px;
  line-height: 1.5;
  padding: 3px 9px;
  border-radius: 5px;
  transition: color .15s, border-color .15s, background .15s;
}
.read-toggle:hover { color: var(--accent); border-color: var(--accent); }

body.reading .app { background: #f6f6f6; }
body.reading .list-pane { display: none; }

/* ---------- 深色目录 ---------- */
body.reading .sidebar {
  width: 300px;
  flex: 0 0 300px;
  background: #38424d;
  border-right: none;
  padding: 0;
  font-weight: 500;
}
body.reading .brand {
  background: #1694ca;
  color: #fff;
  padding: 14px 18px;
  font-size: 16px;
  font-weight: 600;
  gap: 9px;
}
body.reading .brand svg { color: #fff; }
body.reading .read-toggle {
  border-color: rgba(255, 255, 255, .5);
  background: transparent;
  color: #fff;
}
body.reading .read-toggle:hover {
  background: rgba(255, 255, 255, .18);
  border-color: #fff;
  color: #fff;
}

body.reading .search-box { margin: 14px 12px 10px; }
body.reading .search-box input {
  background: #2d353e;
  border-color: #2d353e;
  color: #d5d5d5;
  padding: 8px 30px;
}
body.reading .search-box input::placeholder { color: #7f8891; }
body.reading .search-box input:focus {
  border-color: #1694ca;
  box-shadow: 0 0 0 3px rgba(22, 148, 202, .18);
}
body.reading .search-box svg { color: #7f8891; }
body.reading .search-box kbd {
  background: #2d353e;
  border-color: #47525f;
  color: #7f8891;
}

body.reading .nav { padding: 0 10px; }
body.reading .nav-item { color: #bbbbbb; font-size: 13.5px; padding: 7px 10px; }
body.reading .nav-item:hover { background: #2d353e; color: #eeeeee; }
body.reading .nav-item.active { background: #fff; color: #555555; font-weight: 600; }
body.reading .nav-item.active .nav-count { background: #eef0f3; color: #555555; }
body.reading .nav-count { background: #2d353e; color: #9aa3ad; }
body.reading .side-head { color: #7f8891; padding: 16px 20px 6px; }
body.reading .cat-list { padding: 0 10px; }

body.reading .tree-head { color: #bbbbbb; font-weight: 500; }
body.reading .tree-head:hover { background: #2d353e; color: #eee; }
body.reading .tree-head.active { background: #2d353e; color: #e8e8e8; }
body.reading .tree-head .nav-count { background: #2d353e; color: #8a939e; }
body.reading .tree-doc { color: #a4acb5; }
body.reading .tree-doc:hover { background: #2d353e; color: #e6e6e6; }
body.reading .tree-doc.active { background: #fff; color: #555555; font-weight: 600; }
body.reading .tree-doc.active .tree-num { color: #1694ca; }
body.reading .tree-doc .tree-num { color: #6b7480; }
body.reading .tree-doc .row-more,
body.reading .tree-head .row-more { color: #9aa3ad; }

body.reading .side-foot {
  border-top: 1px solid #47525f;
  margin: 10px 12px 12px;
  padding-top: 10px;
}
body.reading .user-name { color: #d5d5d5; }
body.reading .user-role { color: #8a939e; }
body.reading .icon-btn { color: #9aa3ad; }
body.reading .icon-btn:hover { background: #2d353e; color: #fff; }

/* ---------- 正文 ---------- */
.reader {
  position: relative;
  flex: 1;
  min-width: 0;
  min-height: 0;          /* 关键：不然内容把容器撑高，滚动条出不来 */
  display: flex;
  background: #fff;
}
.reader-scroll {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.reader-inner {
  max-width: 900px;
  margin: 0 auto;
  padding: 0 96px 96px;
}

/* 通栏顶栏：面包屑在左，操作按钮在右 */
.reader-topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 -96px 30px;
  padding: 9px 96px;
  background: #f6f6f6;
  border-radius: 0 0 2px 2px;
}
.reader-crumb {
  flex: 1;
  min-width: 0;
  font-size: 12.5px;
  color: #8a939e;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.reader-actions {
  display: flex;
  flex: 0 0 auto;
  gap: 8px;
}
.reader-actions .btn-sm { font-size: 12.5px; padding: 5px 12px; }
.reader-crumb .crumb-sep { padding: 0 6px; color: #c8ccd2; }
.reader-crumb .crumb-doc { color: #5b6470; }

.reader-title {
  margin: 0 0 10px;
  font-size: 30px;
  line-height: 1.34;
  font-weight: 700;
  letter-spacing: -.2px;
  color: #232a31;
}

.reader-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  padding-bottom: 16px;
  margin-bottom: 26px;
  border-bottom: 1px solid #eceef1;
  font-size: 12.5px;
  color: #8a939e;
}
.reader-meta .meta-tag {
  background: #f1f3f5;
  color: #5b6470;
  border-radius: 20px;
  padding: 1px 9px;
  font-size: 11.5px;
}
.reader-meta .lock-chip { margin-right: 2px; }

body.reading .reader-body.markdown-body {
  font-size: 16px;
  line-height: 1.8;
  color: #2b333b;
}
body.reading .reader-body.markdown-body h1 {
  font-size: 1.7em;
  border-bottom: none;
  padding-bottom: 0;
  margin: 1.9em 0 .7em;
}
body.reading .reader-body.markdown-body h2 {
  font-size: 1.45em;
  border-bottom: none;
  padding-bottom: 0;
  margin: 2em 0 .7em;
  color: #232a31;
}
body.reading .reader-body.markdown-body h3 {
  font-size: 1.16em;
  margin: 1.7em 0 .55em;
  color: #2b333b;
}
body.reading .reader-body.markdown-body p { margin: .9em 0; }
body.reading .reader-body.markdown-body li { margin: .4em 0; }
body.reading .reader-body.markdown-body ul,
body.reading .reader-body.markdown-body ol { padding-left: 1.5em; }
body.reading .reader-body.markdown-body img {
  display: block;
  margin: 2.2em auto;
  max-width: 100%;
  border-radius: 4px;
  box-shadow: 0 6px 22px rgba(16, 24, 40, .1);
  cursor: zoom-in;
}
body.reading .reader-body.markdown-body pre {
  background: #f7f8fa;
  border: 1px solid #eceef1;
  font-size: 13.5px;
}
body.reading .reader-body.markdown-body blockquote {
  border-left: 3px solid #1694ca;
  background: #f7fbfd;
  color: #4a545e;
  margin: 1.2em 0;
  padding: .6em 1em;
}

/* 左右翻页箭头（learn2 的 nav-prev / nav-next） */
.reader-arrow {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 64px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #d3d7dc;
  cursor: pointer;
  z-index: 2;
  transition: background .15s, color .15s;
}
.reader-arrow.prev { left: 0; }
.reader-arrow.next { right: 0; }
.reader-arrow:hover { background: #f6f6f6; color: #1694ca; }

/* 底部上一页 / 下一页 */
.reader-pager {
  display: flex;
  gap: 16px;
  margin-top: 64px;
  padding-top: 22px;
  border-top: 1px solid #eceef1;
}
.reader-pager a {
  flex: 1 1 0;
  max-width: calc(50% - 8px);
  min-width: 0;
  border: 1px solid #e6e8eb;
  border-radius: 8px;
  padding: 12px 16px;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.reader-pager a:hover { border-color: #1694ca; background: #f7fbfd; }
.reader-pager .pager-dir { display: block; font-size: 11.5px; color: #8a939e; margin-bottom: 3px; }
.reader-pager .pager-title {
  display: block;
  font-size: 14px;
  color: #2b333b;
  font-weight: 550;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.reader-pager a.next { text-align: right; }

@media (max-width: 1180px) {
  .reader-inner { padding: 0 48px 72px; }
  .reader-topbar { margin: 0 -48px 26px; padding: 9px 48px; }
  .reader-arrow { display: none; }
}
@media (max-width: 820px) {
  body.reading .sidebar { width: 250px; flex-basis: 250px; }
  .reader-inner { padding: 0 22px 56px; }
  .reader-topbar { margin: 0 -22px 22px; padding: 8px 22px; flex-wrap: wrap; }
  .reader-title { font-size: 24px; }
  .reader-pager { flex-direction: column; }
}

/* 阅读模式下目录标题允许折行（原站 learn2 也是折行显示） */
body.reading .tree-head { align-items: flex-start; }
body.reading .tree-head .tree-caret { margin-top: 3px; }
body.reading .tree-head .nav-label {
  white-space: normal;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  line-height: 1.4;
}
body.reading .tree-doc { align-items: flex-start; }
body.reading .tree-doc .tree-num { margin-top: 1px; }
body.reading .tree-doc .tree-title {
  white-space: normal;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  line-height: 1.4;
}
