/* ===== 变量 ===== */
:root {
  --bg:          #1e1e1e;
  --bg-panel:    #252525;
  --bg-panel-2:  #2b2b2b;
  --bg-hover:    #303030;
  --bg-active:   #3a3a3a;
  --border:      #3f3f3f;
  --text:        #dadada;
  --text-muted:  #9a9a9a;
  --text-faint:  #757575;
  --text-accent: #a78bfa;
  --accent:      #a78bfa;
  --accent-dim:  rgba(167, 139, 250, .16);
  --green:       #8fbf7f;
  --red:         #e06c75;
  --yellow:      #e5c07b;
  --code-bg:     #191919;
  --radius:      5px;
  --shadow:      0 12px 36px rgba(0,0,0,.28);
  --font-mono:   'JetBrains Mono', 'Fira Code', 'Cascadia Code', 'SFMono-Regular', Menlo, monospace;
  --font-body:   'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Helvetica Neue', Arial, 'PingFang SC', 'Microsoft YaHei', sans-serif;
  --sidebar-w:   300px;
  --nav-h:       44px;
}
[data-theme="light"] {
  --bg:          #ffffff;
  --bg-panel:    #f6f6f6;
  --bg-panel-2:  #eeeeee;
  --bg-hover:    #ececec;
  --bg-active:   #e1e1e1;
  --border:      #dddddd;
  --text:        #2c2c2c;
  --text-muted:  #6f6f6f;
  --text-faint:  #9a9a9a;
  --text-accent: #6f48c9;
  --accent:      #6f48c9;
  --accent-dim:  rgba(111, 72, 201, .12);
  --code-bg:     #f5f5f5;
  --shadow:      0 12px 30px rgba(0,0,0,.12);
}
[data-theme="sepia"] {
  --bg:          #fbf6ee;
  --bg-panel:    #f0e9df;
  --bg-panel-2:  #e8ded0;
  --bg-hover:    #e7dccd;
  --bg-active:   #ddd0be;
  --border:      #d8cbbb;
  --text:        #3f3a34;
  --text-muted:  #766d62;
  --text-faint:  #9c9081;
  --text-accent: #775c2f;
  --accent:      #775c2f;
  --accent-dim:  rgba(119, 92, 47, .12);
  --code-bg:     #f3eadf;
  --yellow:      #ad7d19;
  --shadow:      0 12px 30px rgba(80,62,42,.12);
}

/* ===== 重置 ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; }
body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
  min-height: 100vh;
  letter-spacing: 0;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button { cursor: pointer; font-family: inherit; }

/* ===== 滚动条 ===== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--bg-active); border-radius: 3px; }

/* ===== 顶部导航 ===== */
.nav {
  position: fixed; top: 0; left: 0; right: 0; height: var(--nav-h);
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px; padding: 0 14px;
  z-index: 100;
  box-shadow: none;
}
.nav-brand { font-weight: 600; font-size: .9rem; color: var(--text); flex-shrink: 0; }
.nav-search {
  flex: 1; max-width: 420px;
  display: flex; align-items: center; gap: 8px;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 0 10px; height: 30px;
  transition: border-color .2s;
}
.nav-search:focus-within { border-color: var(--accent); }
.nav-search input {
  flex: 1; background: none; border: none; outline: none;
  color: var(--text); font-size: .875rem;
}
.nav-search input::placeholder { color: var(--text-muted); }
.nav-actions { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.btn-icon {
  background: none; border: none;
  color: var(--text-muted); font-size: 1.1rem;
  min-width: 30px; height: 30px;
  padding: 4px 6px; border-radius: var(--radius);
  transition: color .2s, background .2s;
}
.btn-icon:hover { color: var(--text); background: var(--bg-hover); }
.print-icon {
  font-size: 1.28rem;
  line-height: 1;
}
.username-tag {
  font-size: .78rem; color: var(--text-muted);
  padding: 2px 7px; background: transparent;
  border-radius: var(--radius); border: 1px solid var(--border);
}

/* ===== 主布局 ===== */
.layout {
  display: flex;
  padding-top: var(--nav-h);
  min-height: 100vh;
}

/* ===== 侧边栏 ===== */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--bg-panel);
  border-right: 1px solid var(--border);
  position: fixed;
  top: var(--nav-h); bottom: 0; left: 0;
  overflow-y: auto;
  transition: transform .25s ease;
  z-index: 90;
}
.sidebar-header {
  padding: 12px 14px 6px;
  font-size: .75rem; font-weight: 600; letter-spacing: .08em;
  color: var(--text-muted); text-transform: uppercase;
}
.doc-list { list-style: none; padding: 0 6px 40px; }
.doc-item {
  padding: 5px 8px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: .86rem;
  display: flex; align-items: flex-start; gap: 6px;
  transition: background .15s;
  word-break: break-word;
}
.doc-item:hover { background: var(--bg-hover); }
.doc-item.active { background: var(--bg-active); color: var(--text); }
.doc-item-icon { display: none; }
.doc-date {
  font-size: .7rem; color: var(--text-faint);
  display: block; margin-top: 1px;
}

/* ===== 内容区 ===== */
.content {
  flex: 1;
  margin-left: var(--sidebar-w);
  padding: 0 54px 88px;
  max-width: 920px;
}
.content > #content-empty,
.content > #doc-view,
.content > #doc-loading,
.content > #tab-newpage { padding-top: 32px; }

/* ===== 标签页（Obsidian 风格圆角） ===== */
.tab-bar {
  display: none;
  position: sticky;
  top: var(--nav-h);
  z-index: 60;
  background: var(--bg-panel);
  margin: 0 -54px;
  align-items: end;
  height: 38px;
  padding: 0 4px;
}
.tab-bar.visible { display: flex; }
.tab-list {
  flex: 1;
  display: flex;
  align-items: end;
  height: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
}
.tab-list::-webkit-scrollbar { display: none; }
.tab-item {
  flex: 0 0 auto;
  height: 32px;
  display: flex; align-items: center; gap: 6px;
  padding: 0 6px 0 12px;
  border-radius: 8px 8px 0 0;
  background: transparent;
  color: var(--text-muted);
  font-size: .82rem;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  min-width: 100px; max-width: 200px;
  transition: background .12s, color .12s;
  position: relative;
}
.tab-item:hover { background: var(--bg-hover); color: var(--text); }
.tab-item.active {
  background: var(--bg);
  color: var(--text);
}
/* 两个连续非活动 tab 之间的细分隔线（活动 tab 旁不显示） */
.tab-item:not(.active) + .tab-item:not(.active)::before {
  content: '';
  position: absolute;
  left: 0; top: 8px; bottom: 8px;
  width: 1px;
  background: var(--border);
}
.tab-title {
  flex: 1; min-width: 0;
  overflow: hidden; text-overflow: ellipsis;
}
.tab-close {
  flex-shrink: 0;
  width: 18px; height: 18px;
  border: none; background: transparent;
  color: var(--text-faint);
  font-size: .78rem; line-height: 1;
  border-radius: 3px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background .12s, color .12s;
}
.tab-close:hover { background: var(--bg-active); color: var(--text); }
.tab-item.dragging { opacity: .4; }
.tab-item.drag-over { box-shadow: inset 2px 0 0 var(--accent); }
.tab-item.drag-over.drag-over-after { box-shadow: inset -2px 0 0 var(--accent); }
.tab-add {
  flex-shrink: 0;
  height: 28px; width: 28px;
  margin: 0 4px 2px;
  border: none; background: transparent;
  color: var(--text-muted);
  font-size: 1.05rem; line-height: 1;
  border-radius: 6px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background .12s, color .12s;
}
.tab-add:hover { background: var(--bg-hover); color: var(--text); }

/* 新标签页选项区 */
.tab-newpage {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  min-height: 60vh;
  gap: 14px;
}
.tab-newpage-action {
  background: transparent; border: none;
  color: var(--accent);
  font-size: 1.02rem;
  padding: 8px 14px;
  border-radius: var(--radius);
  cursor: pointer;
  display: inline-flex; align-items: center; gap: 10px;
  transition: background .15s;
  font-family: inherit;
}
.tab-newpage-action:hover { background: var(--bg-hover); }
.tab-newpage-action kbd {
  font-family: var(--font-mono);
  font-size: .82rem;
  color: var(--text-muted);
  font-weight: normal;
}
.tab-newpage-action[hidden] { display: none; }

@media (max-width: 768px) {
  .tab-bar { margin: 0 -18px; padding: 0 2px; }
  .tab-item { min-width: 72px; max-width: 130px; padding: 0 4px 0 10px; font-size: .78rem; }
  .tab-add { width: 26px; height: 26px; margin: 0 2px 2px; }
}
.content-empty {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; min-height: 60vh;
  color: var(--text-muted); gap: 12px; font-size: .95rem;
}
.content-empty .icon { font-size: 3rem; opacity: .3; }

/* ===== Markdown 渲染 ===== */
.md-body { line-height: 1.82; font-size: 1rem; }
.md-body h1 { font-size: 1.75rem; margin: 0 0 .9em; border-bottom: 1px solid var(--border); padding-bottom: .42em; }
.md-body h2 { font-size: 1.38rem; margin: 1.7em 0 .62em; }
.md-body h3 { font-size: 1.16rem; margin: 1.4em 0 .5em; }
.md-body h4, .md-body h5, .md-body h6 { margin: 1.2em 0 .4em; }
.md-body p { margin: 1em 0; }
.md-body ul, .md-body ol { margin: .6em 0 .6em 1.4em; }
.md-body li { margin: .3em 0; }
.md-body blockquote {
  border-left: 3px solid var(--border);
  margin: 1em 0; padding: .4em 1em;
  background: var(--bg-panel); border-radius: 0 var(--radius) var(--radius) 0;
  color: var(--text-muted);
}

/* ===== Callouts ===== */
.md-body blockquote.callout {
  margin: 1em 0;
  padding: 0;
  background: var(--callout-bg, var(--bg-panel));
  border-left: 3px solid var(--callout-border, var(--border));
  border-radius: var(--radius);
  color: var(--text);
  overflow: hidden;
}
.md-body blockquote.callout > .callout-title {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 14px;
  font-weight: 600;
  font-size: .92rem;
  color: var(--callout-fg, var(--text-accent));
  background: var(--callout-title-bg, transparent);
}
.md-body blockquote.callout > .callout-title .callout-icon {
  font-size: 1rem; line-height: 1;
}
.md-body blockquote.callout > p,
.md-body blockquote.callout > ul,
.md-body blockquote.callout > ol,
.md-body blockquote.callout > pre,
.md-body blockquote.callout > blockquote,
.md-body blockquote.callout > table,
.md-body blockquote.callout > h1,
.md-body blockquote.callout > h2,
.md-body blockquote.callout > h3,
.md-body blockquote.callout > h4 {
  margin: .6em 14px;
  color: var(--text);
}
.md-body blockquote.callout > p:first-of-type { margin-top: 0; }
.md-body blockquote.callout > :last-child { margin-bottom: 12px; }

.md-body blockquote.callout-note {
  --callout-fg: #5aa9ff;
  --callout-border: #5aa9ff;
  --callout-bg: rgba(90, 169, 255, .08);
  --callout-title-bg: rgba(90, 169, 255, .12);
}
.md-body blockquote.callout-tip {
  --callout-fg: #56c596;
  --callout-border: #56c596;
  --callout-bg: rgba(86, 197, 150, .08);
  --callout-title-bg: rgba(86, 197, 150, .12);
}
.md-body blockquote.callout-important {
  --callout-fg: #b08cf0;
  --callout-border: #b08cf0;
  --callout-bg: rgba(176, 140, 240, .08);
  --callout-title-bg: rgba(176, 140, 240, .12);
}
.md-body blockquote.callout-warning {
  --callout-fg: #e0b04a;
  --callout-border: #e0b04a;
  --callout-bg: rgba(224, 176, 74, .08);
  --callout-title-bg: rgba(224, 176, 74, .12);
}
.md-body blockquote.callout-caution {
  --callout-fg: #e07a7a;
  --callout-border: #e07a7a;
  --callout-bg: rgba(224, 122, 122, .08);
  --callout-title-bg: rgba(224, 122, 122, .12);
}

/* 浅色 / 米黄主题下饱和度略提高 */
[data-theme="light"] .md-body blockquote.callout-note      { --callout-fg: #1d6fc6; --callout-border: #1d6fc6; --callout-bg: rgba(29, 111, 198, .07); --callout-title-bg: rgba(29, 111, 198, .14); }
[data-theme="light"] .md-body blockquote.callout-tip       { --callout-fg: #1f8a55; --callout-border: #1f8a55; --callout-bg: rgba(31, 138, 85, .07);  --callout-title-bg: rgba(31, 138, 85, .14); }
[data-theme="light"] .md-body blockquote.callout-important { --callout-fg: #6e4ad8; --callout-border: #6e4ad8; --callout-bg: rgba(110, 74, 216, .07); --callout-title-bg: rgba(110, 74, 216, .14); }
[data-theme="light"] .md-body blockquote.callout-warning   { --callout-fg: #b87b15; --callout-border: #b87b15; --callout-bg: rgba(184, 123, 21, .08); --callout-title-bg: rgba(184, 123, 21, .14); }
[data-theme="light"] .md-body blockquote.callout-caution   { --callout-fg: #b94545; --callout-border: #b94545; --callout-bg: rgba(185, 69, 69, .07);  --callout-title-bg: rgba(185, 69, 69, .14); }
[data-theme="sepia"] .md-body blockquote.callout-note      { --callout-fg: #2d6592; --callout-border: #2d6592; --callout-bg: rgba(45, 101, 146, .08); --callout-title-bg: rgba(45, 101, 146, .14); }
[data-theme="sepia"] .md-body blockquote.callout-tip       { --callout-fg: #527a3f; --callout-border: #527a3f; --callout-bg: rgba(82, 122, 63, .08);  --callout-title-bg: rgba(82, 122, 63, .14); }
[data-theme="sepia"] .md-body blockquote.callout-important { --callout-fg: #6b4f9b; --callout-border: #6b4f9b; --callout-bg: rgba(107, 79, 155, .08); --callout-title-bg: rgba(107, 79, 155, .14); }
[data-theme="sepia"] .md-body blockquote.callout-warning   { --callout-fg: #9a6b1c; --callout-border: #9a6b1c; --callout-bg: rgba(154, 107, 28, .09); --callout-title-bg: rgba(154, 107, 28, .15); }
[data-theme="sepia"] .md-body blockquote.callout-caution   { --callout-fg: #a14040; --callout-border: #a14040; --callout-bg: rgba(161, 64, 64, .08);  --callout-title-bg: rgba(161, 64, 64, .14); }

/* KaTeX 在我们的字号体系下稍小，给点呼吸 */
.md-body .katex { font-size: 1.05em; }
.md-body .katex-display { margin: 1em 0; overflow-x: auto; overflow-y: hidden; }
.md-body code {
  font-family: var(--font-mono);
  font-size: .875em;
  background: var(--code-bg);
  padding: .15em .4em;
  border-radius: 3px;
  color: var(--yellow);
}
.md-body pre {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1em 1.2em;
  overflow-x: auto;
  margin: 1em 0;
}
.md-body pre code {
  background: none; padding: 0; color: inherit;
  font-size: .85rem;
}
.copy-btn {
  position: absolute;
  top: 6px;
  right: 8px;
  font-size: .75rem;
  padding: 2px 8px;
  background: var(--bg-active);
  border: none;
  border-radius: 3px;
  color: var(--text-muted);
  cursor: pointer;
  opacity: .5;
  transition: opacity .15s;
}
.copy-btn:hover { opacity: 1; }
@media (hover: none) {
  .copy-btn { opacity: .85; }
}
.md-body table {
  width: 100%; border-collapse: collapse; margin: 1em 0; font-size: .9em;
}
.md-body th, .md-body td {
  border: 1px solid var(--border);
  padding: .5em .8em; text-align: left;
}
.md-body th { background: var(--bg-panel); font-weight: 600; }
.md-body tr:nth-child(even) td { background: var(--bg-hover); }
.md-body hr { border: none; border-top: 1px solid var(--border); margin: 1.5em 0; }
.md-body img { max-width: 100%; border-radius: var(--radius); display: block; margin: .6em auto; }
.md-body a { color: var(--accent); }
mark { background: var(--yellow); color: #000; padding: 0 2px; border-radius: 2px; }
/* Meilisearch 搜索高亮 */
.search-hit-title em,
.search-hit-snippet em { font-style: normal; background: var(--yellow); color: #000; padding: 0 2px; border-radius: 2px; }

/* ===== TOC ===== */
.toc {
  position: fixed; top: calc(var(--nav-h) + 20px); right: 20px;
  width: 200px; max-height: calc(100vh - var(--nav-h) - 40px);
  overflow-y: auto;
  background: var(--bg-panel);
  border-left: 1px solid var(--border);
  border-top: none;
  border-right: none;
  border-bottom: none;
  border-radius: 0;
  padding: 10px 12px;
  font-size: .8rem;
  display: none;
}
.toc-title { font-weight: 600; margin-bottom: 8px; color: var(--text-muted); font-size: .75rem; letter-spacing: 0; }
.toc a { display: block; color: var(--text-muted); padding: 2px 0; transition: color .15s; }
.toc a:hover { color: var(--text-accent); text-decoration: none; }
.toc a.active { color: var(--text-accent); font-weight: 600; }
.toc-h2 { padding-left: 0; }
.toc-h3 { padding-left: 12px; }
.toc-h4 { padding-left: 24px; }
@media (min-width: 1440px) { .toc { display: block; } }

/* ===== 搜索面板 ===== */
.search-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,.6); z-index: 200;
  align-items: flex-start; justify-content: center;
  padding-top: 80px;
}
.search-overlay.open { display: flex; }
.search-box {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  width: 600px; max-width: 92vw;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.search-input-wrap {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}
.search-input-wrap input {
  flex: 1; background: none; border: none; outline: none;
  color: var(--text); font-size: 1.05rem;
}
.search-results { max-height: 420px; overflow-y: auto; }
.search-hit {
  padding: 12px 16px; cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: background .15s;
}
.search-hit:hover { background: var(--bg-hover); }
.search-hit.active { background: var(--bg-hover); outline: 2px solid var(--accent); outline-offset: -2px; }
.search-hit:last-child { border-bottom: none; }
.search-hit-title { font-weight: 600; margin-bottom: 4px; }
.search-hit-snippet { font-size: .82rem; color: var(--text-muted); line-height: 1.5; }
.search-empty { padding: 24px; text-align: center; color: var(--text-muted); }
.search-history-title {
  padding: 12px 16px 6px;
  font-size: .75rem;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: .05em;
}
.search-history-item {
  display: block;
  width: 100%;
  padding: 10px 16px;
  background: none;
  border: none;
  border-top: 1px solid var(--border);
  color: var(--text);
  text-align: left;
  font-size: .9rem;
  cursor: pointer;
}
.search-history-item:hover { background: var(--bg-hover); }
.search-kbd {
  font-size: .7rem; background: var(--bg-panel-2);
  border: 1px solid var(--border);
  border-radius: 4px; padding: 1px 5px; color: var(--text-muted);
  font-family: var(--font-mono);
}

/* ===== 登录页 ===== */
.login-wrap {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
}
.login-card {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 34px 38px;
  width: 360px; max-width: 94vw;
  box-shadow: var(--shadow);
}
.login-logo {
  text-align: center; margin-bottom: 28px;
  font-size: 1.25rem; font-weight: 650; color: var(--text);
}
.form-group { margin-bottom: 18px; }
.form-group label {
  display: block; margin-bottom: 6px;
  font-size: .85rem; color: var(--text-muted);
}
.form-input {
  width: 100%; padding: 9px 12px;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius); color: var(--text);
  font-size: .95rem; font-family: inherit;
  transition: border-color .2s;
  outline: none;
}
.form-input:focus { border-color: var(--accent); }
.btn-primary {
  width: 100%; padding: 10px;
  background: var(--accent); color: #fff;
  border: none; border-radius: var(--radius);
  font-size: .95rem; font-weight: 600;
  transition: opacity .2s;
}
.btn-primary:hover { opacity: .85; }
.btn-primary:disabled { opacity: .5; cursor: not-allowed; }
.form-error {
  color: var(--red); font-size: .85rem;
  margin-top: 12px; text-align: center;
  display: none;
}
.form-error.show { display: block; }

/* ===== 响应式 ===== */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: translateX(0);
    box-shadow: 4px 0 20px rgba(0,0,0,.4);
  }
  .content { margin-left: 0; padding: 0 18px 64px; max-width: none; }
  .content > #content-empty,
  .content > #doc-view,
  .content > #doc-loading,
  .content > #tab-newpage { padding-top: 24px; }
  .toc { display: none !important; }
  .nav-search { display: none; }
  .nav-brand { max-width: 32vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .username-tag { display: none; }
  .doc-header-inner { flex-wrap: wrap; gap: 8px; }
}
.sidebar-toggle {
  display: none;
  background: none; border: none;
  color: var(--text); font-size: 1.3rem;
  padding: 6px; cursor: pointer;
}
@media (max-width: 768px) { .sidebar-toggle { display: flex; align-items: center; } }

/* ===== 加载动画 ===== */
.loading {
  display: flex; align-items: center; justify-content: center;
  gap: 8px; color: var(--text-muted); padding: 40px 0;
}
.spinner {
  width: 18px; height: 18px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== 登录页 Tab 切换 ===== */
.login-tabs {
  display: flex; margin-bottom: 22px;
  border-bottom: 1px solid var(--border);
}
.login-tab {
  flex: 1; background: none; border: none;
  padding: 8px 0; font-size: .9rem; color: var(--text-muted);
  cursor: pointer; transition: color .15s;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.login-tab.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.login-tab:hover { color: var(--text); }
.btn-send-otp {
  flex-shrink: 0; padding: 9px 14px;
  background: var(--bg-hover); border: 1px solid var(--border);
  border-radius: var(--radius); color: var(--text); font-size: .875rem;
  cursor: pointer; white-space: nowrap; transition: background .15s;
}
.btn-send-otp:hover { background: var(--bg-active); }
.btn-send-otp:disabled { opacity: .6; cursor: not-allowed; }

/* ===== 侧边栏标签页 ===== */
.sidebar-header {
  display: flex !important;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  padding: 0;
  font-size: inherit;
  font-weight: inherit;
  letter-spacing: inherit;
  color: inherit;
  text-transform: none;
}
.sidebar-tabs {
  display: flex;
  flex: 1;
  min-width: 0;
  border-bottom: 1px solid var(--border);
  padding: 4px 6px 0;
  gap: 2px;
}
.sidebar-tab {
  flex: 0 0 auto;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  font-size: .78rem;
  font-weight: 500;
  letter-spacing: 0;
  padding: 7px 8px 7px 2px;
  cursor: pointer;
  text-align: left;
  transition: color .15s, border-color .15s;
  margin-bottom: -1px;
}
.sidebar-tab:hover { color: var(--text); }
.sidebar-tab.active { color: var(--text); border-bottom-color: var(--text-muted); }

/* ===== 侧边栏操作按钮 ===== */
.sidebar-header-acts {
  display: flex;
  gap: 4px;
  padding: 6px 8px;
  justify-content: flex-end;
  border-bottom: 1px solid var(--border);
}
.btn-sidebar-act {
  background: none; border: none;
  color: var(--text-muted); font-size: 1.08rem;
  min-width: 30px; height: 30px;
  padding: 3px 6px; border-radius: var(--radius);
  cursor: pointer; transition: color .15s, background .15s;
}
#nav-search-trigger,
#btn-select-toggle {
  font-size: 1.18rem;
}
.btn-sidebar-act:hover, .btn-sidebar-act.active { color: var(--text); background: var(--bg-hover); }

/* ===== 批量下载操作栏 ===== */
.sidebar-dl-bar {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px;
  border-top: 1px solid var(--border);
  background: var(--bg-panel);
  position: sticky; bottom: 0;
}
.dl-bar-count { font-size: .8rem; color: var(--text-muted); flex: 1; }
.btn-select-all,
.btn-dl-selected,
.btn-move-selected {
  background: var(--accent); color: #fff;
  border: none; border-radius: var(--radius);
  font-size: .8rem; padding: 5px 12px; cursor: pointer;
  transition: opacity .15s;
}
.btn-select-all {
  background: var(--bg-hover);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-select-all:hover,
.btn-move-selected:hover,
.btn-dl-selected:hover { opacity: .85; }
.btn-select-all:disabled,
.btn-move-selected:disabled,
.btn-dl-selected:disabled { opacity: .4; cursor: not-allowed; }

/* ===== 复选框模式 ===== */
.doc-check {
  flex-shrink: 0; width: 15px; height: 15px;
  accent-color: var(--accent); cursor: pointer;
  margin-right: 2px;
}
.doc-item.checked { background: var(--bg-active); }

/* ===== 文档树 ===== */
.folder-group { list-style: none; }
.folder-header {
  display: flex; align-items: center; gap: 6px;
  padding: 5px 8px; border-radius: var(--radius);
  cursor: pointer; font-size: .85rem; font-weight: 500;
  color: var(--text-muted); transition: background .15s;
  user-select: none;
}
.folder-header:hover { background: var(--bg-hover); color: var(--text); }
.folder-name { flex: 1; }
.folder-icon { display: none; }
.folder-arrow {
  order: -1;
  width: 14px;
  color: var(--text-faint);
  font-size: .72rem;
  line-height: 1;
  text-align: center;
}
.folder-docs {
  list-style: none;
  padding-left: 20px;
  display: none;
}
.folder-group.open .folder-docs { display: block; }

/* ===== 下载按钮 ===== */
.btn-download {
  flex-shrink: 0;
  background: var(--bg-panel); border: 1px solid var(--border);
  border-radius: var(--radius); color: var(--text-muted);
  font-size: .78rem; padding: 4px 10px; cursor: pointer;
  transition: color .15s, background .15s;
  white-space: nowrap; align-self: flex-start; margin-top: 4px;
}
.btn-download:hover { color: var(--text); background: var(--bg-hover); }
.btn-download.active { color: var(--yellow); background: var(--bg-hover); }
.doc-mode-toggle {
  flex-shrink: 0;
  width: 30px;
  height: 30px;
  margin-top: 2px;
  border: none;
  border-radius: var(--radius);
  background: transparent;
  color: var(--text-muted);
  font-size: 1.08rem;
  line-height: 1;
}
.doc-mode-toggle:hover,
.doc-mode-toggle.editing {
  color: var(--text);
  background: var(--bg-hover);
}
.doc-mode-toggle:disabled {
  opacity: .5;
  cursor: wait;
}
.version-select {
  flex-shrink: 0;
  max-width: 150px;
  background: var(--bg-hover);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: .78rem;
  padding: 4px 8px;
  margin-top: 4px;
}

/* ===== doc-header 内部 flex ===== */
.doc-header-inner { display: flex; align-items: flex-start; gap: 10px; flex-wrap: wrap; }

/* ===== 回到顶部 ===== */
.back-to-top {
  position: fixed; bottom: 32px; right: 24px;
  width: 36px; height: 36px;
  background: var(--bg-panel); color: var(--text-muted);
  border: 1px solid var(--border); border-radius: var(--radius); font-size: 1rem;
  cursor: pointer; z-index: 50;
  opacity: 0; transform: translateY(10px);
  transition: opacity .2s, transform .2s;
  box-shadow: var(--shadow);
}
.back-to-top.visible { opacity: 1; transform: translateY(0); }

/* ===== Mermaid 图表 ===== */
.mermaid {
  margin: 1em 0;
  text-align: center;
  overflow-x: auto;
}
.mermaid svg {
  max-width: 100%;
  border-radius: var(--radius);
}

/* ===== 文档标题 ===== */
.doc-header {
  border-bottom: 1px solid var(--border);
  margin-bottom: 28px; padding-bottom: 16px;
}
.doc-header h1 { font-size: 1.5rem; line-height: 1.35; font-weight: 700; }
.doc-meta { font-size: .8rem; color: var(--text-muted); margin-top: 6px; }
.doc-editor {
  min-height: calc(100vh - var(--nav-h) - 160px);
}
.doc-editor textarea {
  width: 100%;
  min-height: calc(100vh - var(--nav-h) - 170px);
  resize: none;
  background: transparent;
  border: none;
  border-radius: 0;
  color: var(--text);
  padding: 0;
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.82;
  outline: none;
}
.doc-editor textarea:focus {
  outline: none;
}
.render-fallback {
  white-space: pre-wrap;
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1em;
  overflow-x: auto;
}

@media print {
  :root {
    --bg: #fff;
    --text: #111;
    --text-muted: #555;
    --border: #ddd;
    --code-bg: #f6f6f6;
  }
  body {
    background: #fff;
    color: #111;
  }
  .nav,
  .sidebar,
  .toc,
  .tab-bar,
  .back-to-top,
  .btn-download,
  .copy-btn {
    display: none !important;
  }
  .layout {
    display: block;
    padding-top: 0;
    min-height: auto;
  }
  .content {
    margin-left: 0;
    max-width: none;
    padding: 0;
  }
  .doc-header {
    margin-bottom: 18px;
    padding-bottom: 10px;
  }
  .md-body {
    line-height: 1.75;
  }
  .md-body pre,
  .md-body blockquote,
  .md-body table {
    break-inside: avoid;
  }
  .md-body a {
    color: #111;
    text-decoration: underline;
  }
}

/* ===== 移动文档弹窗 ===== */
.placement-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.55);
  display: flex; align-items: center; justify-content: center;
  z-index: 200;
}
.placement-box {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  width: 320px; max-width: 90vw;
  box-shadow: var(--shadow);
}
.placement-header {
  font-weight: 650; font-size: .95rem; margin-bottom: 12px;
}
.placement-folder-list {
  max-height: 200px; overflow-y: auto; margin-bottom: 4px;
}
.placement-folder-item {
  display: flex; align-items: center; gap: 6px;
  width: 100%;
  background: transparent; border: 1px solid var(--border);
  border-radius: var(--radius); padding: 7px 10px; margin-bottom: 6px;
  color: var(--text); font-size: .875rem; text-align: left;
  cursor: pointer; font-family: inherit;
  transition: background .15s;
}
.placement-folder-item:hover { background: var(--bg-hover); }
.placement-divider { border: none; border-top: 1px solid var(--border); margin: 10px 0; }
.placement-new { display: flex; gap: 6px; margin-bottom: 10px; }
.placement-new input {
  flex: 1;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius); color: var(--text);
  padding: 6px 10px; font-size: .875rem; font-family: inherit; outline: none;
}
.placement-new input:focus { border-color: var(--accent); }
.placement-new button {
  background: var(--accent); border: none; border-radius: var(--radius);
  color: #fff; padding: 6px 12px; font-size: .8rem;
  cursor: pointer; font-family: inherit; white-space: nowrap;
}
.placement-new button:hover { opacity: .85; }
.placement-cancel-btn {
  display: block; width: 100%;
  background: none; border: 1px solid var(--border);
  border-radius: var(--radius); color: var(--text-muted);
  padding: 7px; font-size: .85rem; font-family: inherit; cursor: pointer;
  transition: background .15s;
}
.placement-cancel-btn:hover { background: var(--bg-hover); }

/* ===== 文件夹内联管理按钮 ===== */
.btn-folder-rename, .btn-folder-delete {
  background: none; border: none;
  color: var(--text-muted); font-size: .8rem;
  padding: 2px 5px; border-radius: 3px;
  cursor: pointer; opacity: 0;
  transition: opacity .15s, color .15s;
  flex-shrink: 0;
}
.folder-group:hover .btn-folder-rename,
.folder-group:hover .btn-folder-delete { opacity: 1; }
.btn-folder-rename:hover { color: var(--accent); }
.btn-folder-delete:hover { color: var(--red); }

/* ===== 通用弹窗（修改密码 / 分享链接） ===== */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.55);
  display: flex; align-items: center; justify-content: center;
  z-index: 200;
}
.modal-box {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 340px; max-width: 92vw;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.modal-header {
  padding: 16px 20px;
  font-weight: 650; font-size: .95rem;
  border-bottom: 1px solid var(--border);
}
.modal-body { padding: 16px 20px; }
.modal-footer {
  display: flex; gap: 8px; justify-content: flex-end;
  padding: 12px 20px;
  border-top: 1px solid var(--border);
}
.modal-input {
  display: block; width: 100%;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius); color: var(--text);
  padding: 8px 10px; font-size: .875rem; font-family: inherit;
  margin-bottom: 10px; outline: none;
}
.modal-input:focus { border-color: var(--accent); }
.modal-error {
  color: var(--red); font-size: .8rem; min-height: 1.2em;
  margin-top: 2px;
}
.modal-btn-primary {
  background: var(--accent); border: none; border-radius: var(--radius);
  color: #fff; padding: 7px 18px; font-size: .875rem;
  font-family: inherit; cursor: pointer; transition: opacity .15s;
}
.modal-btn-primary:hover { opacity: .85; }
.modal-btn-primary:disabled { opacity: .5; cursor: not-allowed; }
.modal-btn-cancel {
  background: none; border: 1px solid var(--border);
  border-radius: var(--radius); color: var(--text-muted);
  padding: 7px 18px; font-size: .875rem;
  font-family: inherit; cursor: pointer; transition: background .15s;
}
.modal-btn-cancel:hover { background: var(--bg-hover); }

/* ===== 分享有效期选项 ===== */
.share-duration-group {
  display: flex; gap: 8px; margin-bottom: 14px; flex-wrap: wrap;
}
.share-duration-opt {
  display: flex; align-items: center; gap: 4px;
  font-size: .875rem; cursor: pointer;
  padding: 6px 12px;
  border: 1px solid var(--border); border-radius: var(--radius);
  transition: background .15s, border-color .15s;
}
.share-duration-opt:has(input:checked) {
  border-color: var(--text-muted); background: var(--bg-hover); color: var(--text);
}
.share-duration-opt input { display: none; }
.share-link-box { margin-top: 8px; }
