/* ==========================================================================
   我的笔记 · 样式表
   设计原则：简洁、现代、克制；跟随系统明暗主题；纯静态、无外链。
   目录：
     1. 设计 token（浅色 / 深色）
     2. 基础重置与排版
     3. 布局骨架（侧栏 / 顶栏 / 内容 / 页脚）
     4. 侧栏与目录树
     5. 顶栏、面包屑、操作按钮
     6. 通用组件（按钮、输入框、空状态）
     7. 首页卡片列表
     8. 阅读页与 Markdown 正文
     9. 编辑页
    10. 搜索页
    11. 登录页 / 错误页 / ⌘K 浮层
    12. 响应式与动效降级
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. 设计 token
   -------------------------------------------------------------------------- */

:root {
  color-scheme: light;

  --bg: #FAFAF9;
  --surface: #FFFFFF;
  --surface-2: #F6F7F9;
  --raised: #FFFFFF;

  --text: #1C1F23;
  --text-muted: #6B7280;
  --text-faint: #9CA3AF;

  --border: rgba(0, 0, 0, .08);
  --border-strong: rgba(0, 0, 0, .14);

  --accent: #4F6BED;
  --accent-hover: #3E58D6;
  --accent-soft: rgba(79, 107, 237, .10);
  --accent-ring: rgba(79, 107, 237, .15);
  --accent-border: rgba(79, 107, 237, .30);
  --accent-contrast: #FFFFFF;
  --gradient-end: #A78BFA;

  --success: #16A34A;
  --danger: #DC2626;
  --danger-soft: rgba(220, 38, 38, .08);
  --warn: #92400E;

  --mark: #FEF08A;
  --mark-text: #1C1F23;
  --check: #FFFFFF;

  --code-bg: #F6F7F9;
  --table-head: #F8F9FA;
  --table-stripe: rgba(0, 0, 0, .02);

  --shadow-1: 0 1px 2px rgba(0, 0, 0, .04);
  --shadow-2: 0 1px 2px rgba(0, 0, 0, .04), 0 4px 16px rgba(0, 0, 0, .06);
  --shadow-3: 0 2px 4px rgba(0, 0, 0, .04), 0 12px 32px rgba(0, 0, 0, .10);

  --glow-1: rgba(238, 242, 255, .55);
  --glow-2: rgba(253, 242, 248, .60);
  --topbar-bg: rgba(250, 250, 249, .82);
  --scrim: rgba(23, 25, 31, .42);
  --blob-1: rgba(79, 107, 237, .40);
  --blob-2: rgba(236, 72, 153, .22);

  --sidebar-w: 280px;
  --content: 72ch;
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --ease: cubic-bezier(.2, .7, .2, 1);

  --font-sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI",
    "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", "Microsoft YaHei",
    system-ui, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

/* 深色：跟随系统（未被强制为浅色时生效） */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;

    --bg: #0F1115;
    --surface: #16191F;
    --surface-2: #1B1F27;
    --raised: #1C2028;

    --text: #E6E8EB;
    --text-muted: #9AA1AC;
    --text-faint: #6B7280;

    --border: rgba(255, 255, 255, .08);
    --border-strong: rgba(255, 255, 255, .14);

    --accent: #889BFF;
    --accent-hover: #A3B2FF;
    --accent-soft: rgba(136, 155, 255, .14);
    --accent-ring: rgba(136, 155, 255, .20);
    --accent-border: rgba(136, 155, 255, .36);
    --accent-contrast: #0B0E14;
    --gradient-end: #C4B5FD;

    --success: #4ADE80;
    --danger: #F87171;
    --danger-soft: rgba(248, 113, 113, .12);
    --warn: #FCD34D;

    --mark: rgba(250, 204, 21, .22);
    --mark-text: #F5F3C8;
    --check: #0B0E14;

    --code-bg: #111318;
    --table-head: #1B1F27;
    --table-stripe: rgba(255, 255, 255, .03);

    --shadow-1: 0 1px 2px rgba(0, 0, 0, .30);
    --shadow-2: 0 1px 2px rgba(0, 0, 0, .30), 0 6px 20px rgba(0, 0, 0, .35);
    --shadow-3: 0 2px 6px rgba(0, 0, 0, .40), 0 16px 40px rgba(0, 0, 0, .45);

    --glow-1: rgba(19, 26, 51, .85);
    --glow-2: rgba(26, 19, 48, .80);
    --topbar-bg: rgba(15, 17, 21, .78);
    --scrim: rgba(0, 0, 0, .55);
    --blob-1: rgba(79, 107, 237, .30);
    --blob-2: rgba(147, 51, 234, .22);
  }
}

/* 深色：手动强制 */
html[data-theme="dark"] {
  color-scheme: dark;

  --bg: #0F1115;
  --surface: #16191F;
  --surface-2: #1B1F27;
  --raised: #1C2028;

  --text: #E6E8EB;
  --text-muted: #9AA1AC;
  --text-faint: #6B7280;

  --border: rgba(255, 255, 255, .08);
  --border-strong: rgba(255, 255, 255, .14);

  --accent: #889BFF;
  --accent-hover: #A3B2FF;
  --accent-soft: rgba(136, 155, 255, .14);
  --accent-ring: rgba(136, 155, 255, .20);
  --accent-border: rgba(136, 155, 255, .36);
  --accent-contrast: #0B0E14;
  --gradient-end: #C4B5FD;

  --success: #4ADE80;
  --danger: #F87171;
  --danger-soft: rgba(248, 113, 113, .12);
  --warn: #FCD34D;

  --mark: rgba(250, 204, 21, .22);
  --mark-text: #F5F3C8;
  --check: #0B0E14;

  --code-bg: #111318;
  --table-head: #1B1F27;
  --table-stripe: rgba(255, 255, 255, .03);

  --shadow-1: 0 1px 2px rgba(0, 0, 0, .30);
  --shadow-2: 0 1px 2px rgba(0, 0, 0, .30), 0 6px 20px rgba(0, 0, 0, .35);
  --shadow-3: 0 2px 6px rgba(0, 0, 0, .40), 0 16px 40px rgba(0, 0, 0, .45);

  --glow-1: rgba(19, 26, 51, .85);
  --glow-2: rgba(26, 19, 48, .80);
  --topbar-bg: rgba(15, 17, 21, .78);
  --scrim: rgba(0, 0, 0, .55);
  --blob-1: rgba(79, 107, 237, .30);
  --blob-2: rgba(147, 51, 234, .22);
}

/* 浅色：手动强制（系统深色时也保持浅色 token） */
html[data-theme="light"] {
  color-scheme: light;
}

/* --------------------------------------------------------------------------
   2. 基础重置与排版
   -------------------------------------------------------------------------- */

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

html {
  -webkit-text-size-adjust: 100%;
  background: var(--bg);
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  background-color: var(--bg);
  background-image:
    radial-gradient(900px 620px at 4% -12%, var(--glow-1), transparent 62%),
    radial-gradient(900px 620px at 104% 112%, var(--glow-2), transparent 60%);
  background-attachment: fixed;
  background-repeat: no-repeat;
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
  transition: background-color .3s ease, color .3s ease;
}

h1, h2, h3, h4, h5, h6 {
  margin: 0;
  line-height: 1.35;
  font-weight: 650;
  letter-spacing: -.01em;
}

p {
  margin: 0;
}

a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  text-decoration-color: rgba(79, 107, 237, .38);
  transition: color .16s var(--ease), text-decoration-color .16s var(--ease);
}

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

img {
  max-width: 100%;
  height: auto;
}

button,
input,
textarea,
select {
  font: inherit;
  color: inherit;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 6px;
}

::selection {
  background: var(--accent-soft);
}

/* 细滚动条 */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}

*::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

*::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 4px;
}

*::-webkit-scrollbar-track {
  background: transparent;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: fixed;
  top: 8px;
  left: 8px;
  z-index: 100;
  padding: 8px 14px;
  border-radius: var(--r-sm);
  background: var(--accent);
  color: var(--accent-contrast);
  text-decoration: none;
  transform: translateY(-160%);
  transition: transform .18s var(--ease);
}

.skip-link:focus-visible {
  transform: none;
}

/* --------------------------------------------------------------------------
   3. 布局骨架
   -------------------------------------------------------------------------- */

.app {
  position: relative;
  z-index: 1;
  min-height: 100vh;
}

.sidebar {
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 40;
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: var(--sidebar-w);
  padding: 16px 12px 12px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  transition: transform .24s var(--ease);
}

.workspace {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  margin-left: var(--sidebar-w);
}

.main {
  flex: 1;
  padding: 36px 24px 56px;
}

.main-inner {
  max-width: var(--content);
  margin: 0 auto;
  /* 用 backwards 而不是 both：动画结束后不残留 transform，
     否则 .main-inner 会成为 position: fixed 子元素的包含块（移动端「更多」浮层会错位）。 */
  animation: rise .24s var(--ease) backwards;
}

.foot {
  padding: 25px 16px 32px;
  text-align: center;
  font-size: 12px;
  color: var(--text-muted);
}

.foot a {
  color: inherit;
  text-decoration: none;
}

.foot a:hover {
  color: var(--text);
  text-decoration: underline;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* --------------------------------------------------------------------------
   4. 侧栏与目录树
   -------------------------------------------------------------------------- */

.side-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 6px 0;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  color: var(--text);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -.015em;
  text-decoration: none;
}

.brand:hover {
  color: var(--text);
  text-decoration: none;
}

.brand-mark {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: var(--accent-soft);
  color: var(--accent);
}

.brand-mark svg {
  width: 18px;
  height: 18px;
}

.sidebar .icon-btn.drawer-close {
  display: none;
  margin-left: auto;
}

/* 搜索框 */
.search {
  position: relative;
  display: flex;
  align-items: center;
  min-width: 0;
}

.search-icon {
  position: absolute;
  left: 11px;
  top: 50%;
  display: inline-flex;
  transform: translateY(-50%);
  color: var(--text-faint);
  pointer-events: none;
}

.search-icon svg {
  width: 16px;
  height: 16px;
}

.search input[type="search"] {
  width: 100%;
  height: 38px;
  padding: 0 32px 0 36px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 14px;
  transition: background-color .16s var(--ease), border-color .16s var(--ease),
    box-shadow .16s var(--ease);
}

.search input[type="search"]::placeholder {
  color: var(--text-muted);
}

.search input[type="search"]:hover {
  border-color: var(--border-strong);
}

.search input[type="search"]:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--surface);
  box-shadow: 0 0 0 3px var(--accent-ring);
}

.tree-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 4px 8px 0;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .08em;
  color: var(--text-muted);
}

.tree-head .count {
  font-weight: 500;
  letter-spacing: 0;
  font-variant-numeric: tabular-nums;
}

.tree-wrap {
  flex: 1;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 2px 0 8px;
  overscroll-behavior: contain;
}

.tree,
.tree ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

.tree ul {
  margin-left: 7px;
  padding-left: 9px;
  border-left: 1px solid var(--border);
}

.tree li {
  margin: 1px 0;
}

.tree summary {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 6px 8px;
  border-radius: var(--r-sm);
  color: var(--text-muted);
  font-size: 13.5px;
  font-weight: 500;
  line-height: 1.5;
  cursor: pointer;
  list-style: none;
  user-select: none;
  transition: background-color .16s var(--ease), color .16s var(--ease);
}

.tree summary::-webkit-details-marker {
  display: none;
}

.tree summary::before {
  content: "";
  flex: none;
  width: 5px;
  height: 5px;
  margin-left: 2px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(-45deg);
  opacity: .7;
  transition: transform .18s var(--ease);
}

.tree details[open] > summary::before {
  transform: rotate(45deg);
}

.tree summary:hover {
  background: var(--surface-2);
  color: var(--text);
}

.tree-file a {
  display: block;
  padding: 6px 8px 6px 24px;
  border-radius: var(--r-sm);
  color: var(--text-muted);
  font-size: 13.5px;
  line-height: 1.5;
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: background-color .16s var(--ease), color .16s var(--ease);
}

.tree-file a:hover {
  background: var(--surface-2);
  color: var(--text);
}

.tree-file a[aria-current="page"] {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

.side-foot {
  display: none;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.side-user {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 4px 8px;
  color: var(--text-muted);
  font-size: 12.5px;
}

.side-new {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px;
  border-radius: var(--r-sm);
  color: var(--text);
  font-size: 14px;
  text-decoration: none;
}

.side-new:hover {
  background: var(--surface-2);
  text-decoration: none;
}

/* 空状态 */
.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 32px 16px;
  text-align: center;
  color: var(--text-muted);
}

.empty-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  margin-bottom: 4px;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--text-faint);
}

.empty-title {
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
}

.empty-text {
  max-width: 30ch;
  font-size: 12.5px;
  line-height: 1.6;
}

.empty .btn {
  margin-top: 10px;
}

/* --------------------------------------------------------------------------
   5. 顶栏
   -------------------------------------------------------------------------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  background: var(--topbar-bg);
  border-bottom: 1px solid var(--border);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}

.topbar-inner {
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: var(--content);
  min-height: 56px;
  margin: 0 auto;
  padding: 8px 24px;
}

.topbar .icon-btn.menu-btn {
  display: none;
}

.crumbs {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  overflow: hidden;
  font-size: 13px;
  color: var(--text-muted);
}

.crumb {
  position: relative;
  color: inherit;
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 26ch;
}

a.crumb:hover {
  color: var(--text);
}

.crumb-sep {
  flex: none;
  color: var(--text-faint);
  opacity: .8;
}

.crumb[aria-current="page"] {
  color: var(--text);
  font-weight: 600;
}

.crumb[aria-current="page"]::after {
  content: "";
  position: absolute;
  right: 0;
  bottom: -7px;
  left: 0;
  height: 3px;
  border-radius: 2px;
  background: linear-gradient(90deg, var(--accent), var(--gradient-end));
}

.topbar-title {
  display: none;
  min-width: 0;
  font-size: 15px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
}

.btn-new {
  min-height: 34px;
  padding: 0 12px;
  border-color: transparent;
  background: transparent;
  color: var(--text-muted);
  font-size: 13.5px;
  font-weight: 500;
}

.btn-new:hover {
  background: var(--surface-2);
  border-color: var(--border);
  color: var(--text);
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: background-color .16s var(--ease), border-color .16s var(--ease),
    color .16s var(--ease), transform .16s var(--ease);
}

.icon-btn:hover {
  background: var(--surface-2);
  border-color: var(--border);
  color: var(--text);
}

.icon-btn:active {
  transform: scale(.96);
}

.icon-btn svg {
  width: 19px;
  height: 19px;
}

.theme-toggle {
  position: relative;
  overflow: hidden;
}

.theme-icon {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transform: rotate(-45deg) scale(.75);
  transition: opacity .2s var(--ease), transform .2s var(--ease);
}

html[data-theme="system"] .theme-icon.icon-auto,
html[data-theme="light"] .theme-icon.icon-sun,
html[data-theme="dark"] .theme-icon.icon-moon {
  opacity: 1;
  transform: none;
}

.mobile-search {
  display: none;
  padding: 0 16px 12px;
}

/* --------------------------------------------------------------------------
   6. 通用组件
   -------------------------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface);
  color: var(--text);
  font-size: 13.5px;
  font-weight: 500;
  line-height: 1.4;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color .16s var(--ease), border-color .16s var(--ease),
    color .16s var(--ease), box-shadow .16s var(--ease), transform .16s var(--ease);
}

.btn:hover {
  border-color: var(--border-strong);
  background: var(--surface-2);
  color: var(--text);
  text-decoration: none;
  box-shadow: var(--shadow-1);
}

.btn:active {
  transform: scale(.98);
}

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

.btn-primary {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--accent-contrast);
  font-weight: 600;
  box-shadow: 0 1px 2px var(--accent-ring);
}

.btn-primary:hover {
  border-color: var(--accent-hover);
  background: var(--accent-hover);
  color: var(--accent-contrast);
  box-shadow: 0 2px 8px var(--accent-ring);
}

.btn-danger {
  color: var(--danger);
}

.btn-danger:hover {
  border-color: rgba(220, 38, 38, .28);
  background: var(--danger-soft);
  color: var(--danger);
}

html[data-theme="dark"] .btn-danger:hover,
html[data-theme="dark"] .btn-danger {
  border-color: rgba(248, 113, 113, .28);
}

.btn-block {
  width: 100%;
}

.inline {
  display: inline;
  margin: 0;
}

.linkbtn {
  padding: 0;
  border: 0;
  background: none;
  color: var(--text-muted);
  font-size: 12.5px;
  text-decoration: none;
  cursor: pointer;
}

.linkbtn:hover {
  color: var(--text);
  text-decoration: underline;
}

/* 表单 */
.field {
  display: block;
  margin: 0 0 16px;
}

.field-label {
  display: block;
  margin-bottom: 6px;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
}

input[type="text"],
input[type="password"],
input[type="search"],
input[type="file"],
select,
textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
}

input[type="text"],
input[type="password"],
input[type="search"],
select {
  height: 40px;
  padding: 0 12px;
}

input::placeholder,
textarea::placeholder {
  color: var(--text-muted);
}

input[type="text"]:hover,
input[type="password"]:hover,
input[type="search"]:hover,
textarea:hover {
  border-color: var(--border-strong);
}

input[type="text"]:focus,
input[type="password"]:focus,
input[type="search"]:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-ring);
}

input[type="file"] {
  padding: 8px 10px;
  font-size: 13px;
  color: var(--text-muted);
  background: var(--surface-2);
}

.form-error {
  margin: -4px 0 14px;
  color: var(--danger);
  font-size: 13px;
  line-height: 1.6;
}

/* --------------------------------------------------------------------------
   7. 首页
   -------------------------------------------------------------------------- */

.page-head {
  margin-bottom: 26px;
}

.page-head h1 {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -.02em;
}

.page-sub {
  margin-top: 4px;
  color: var(--text-muted);
  font-size: 13.5px;
}

.note-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.note-link {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto 18px;
  grid-template-areas:
    "title time go"
    "path time go";
  gap: 2px 16px;
  padding: 15px 18px;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--surface);
  box-shadow: var(--shadow-1);
  color: var(--text);
  text-decoration: none;
  transition: transform .18s var(--ease), box-shadow .18s var(--ease),
    border-color .18s var(--ease), background-color .18s var(--ease);
}

.note-link:hover {
  transform: translateY(-2px);
  border-color: var(--accent-border);
  box-shadow: var(--shadow-2);
  text-decoration: none;
}

.note-title {
  grid-area: title;
  overflow: hidden;
  color: var(--text);
  font-size: 15px;
  font-weight: 600;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.note-path {
  grid-area: path;
  overflow: hidden;
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 11.5px;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.note-time {
  grid-area: time;
  align-self: center;
  color: var(--text-muted);
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  transition: color .16s var(--ease);
}

.note-go {
  grid-area: go;
  align-self: center;
  justify-self: end;
  color: var(--accent);
  opacity: 0;
  transform: translateX(-4px);
  transition: opacity .16s var(--ease), transform .16s var(--ease);
}

.note-link:hover .note-go {
  opacity: 1;
  transform: none;
}

.note-link:hover .note-time {
  color: var(--accent);
}

/* --------------------------------------------------------------------------
   8. 阅读页与 Markdown
   -------------------------------------------------------------------------- */

.note {
  padding: 40px 44px;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--surface);
  box-shadow: var(--shadow-2);
  transition: transform .18s var(--ease), box-shadow .18s var(--ease);
}

.note-head {
  margin-bottom: 30px;
}

.note-head h1 {
  margin-bottom: 8px;
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -.02em;
  line-height: 1.28;
}

.note-meta {
  color: var(--text-muted);
  font-size: 12.5px;
  overflow-wrap: anywhere;
}

.note-meta .dot {
  margin: 0 6px;
  color: var(--text-faint);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 18px;
}

.actions .btn {
  min-height: 34px;
  padding: 0 12px;
  font-size: 13px;
  background: transparent;
}

.actions .btn:hover {
  background: var(--surface-2);
}

.actions .btn-danger {
  border-color: transparent;
  background: transparent;
}

.actions .btn-danger:hover {
  border-color: rgba(220, 38, 38, .25);
  background: var(--danger-soft);
}

html[data-theme="dark"] .actions .btn-danger:hover,
html[data-theme="dark"] .actions .btn-danger {
  border-color: transparent;
}

html[data-theme="dark"] .actions .btn-danger:hover {
  border-color: rgba(248, 113, 113, .28);
}

/* 正文 */
.article {
  font-size: 15px;
  line-height: 1.75;
  overflow-wrap: anywhere;
}

.article > :first-child {
  margin-top: 0;
}

.article > :last-child {
  margin-bottom: 0;
}

.article p {
  margin: .85em 0;
}

.article h1,
.article h2,
.article h3,
.article h4,
.article h5,
.article h6 {
  margin: 1.7em 0 .6em;
  color: var(--text);
  scroll-margin-top: 80px;
}

.article h1 {
  font-size: 26px;
  font-weight: 700;
}

.article h2 {
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-strong);
  font-size: 22px;
  font-weight: 650;
}

.article h3 {
  font-size: 18px;
  font-weight: 600;
}

.article h4 {
  font-size: 16px;
  font-weight: 600;
}

.article a {
  color: var(--accent);
}

.article ul,
.article ol {
  margin: .7em 0;
  padding-left: 1.5em;
}

.article li {
  margin: .3em 0;
}

.article li > p {
  margin: .25em 0;
}

.article li > ul,
.article li > ol {
  margin: .25em 0;
}

.article strong {
  font-weight: 650;
}

.article blockquote {
  margin: 1.2em 0;
  padding: 2px 0 2px 18px;
  border-left: 3px solid var(--accent);
  color: var(--text-muted);
}

.article blockquote p {
  margin: .4em 0;
}

.article code {
  padding: .12em .38em;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--code-bg);
  font-family: var(--font-mono);
  font-size: .88em;
}

.article pre {
  margin: 1.2em 0;
  padding: 16px 18px;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--code-bg);
  font-size: 12.5px;
  line-height: 1.65;
  tab-size: 2;
}

.article pre code {
  padding: 0;
  border: 0;
  background: none;
  font-size: inherit;
}

.article hr {
  margin: 2em 0;
  border: 0;
  border-top: 1px solid var(--border);
}

/* 表格：表头浅底、斑马纹、圆角边框 */
.article .table-wrap {
  margin: 1.2em 0;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
}

.article table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

.article thead th {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--table-head);
  color: var(--text);
  font-weight: 600;
  text-align: left;
  white-space: nowrap;
}

.article tbody td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

.article tbody tr:nth-child(even) {
  background: var(--table-stripe);
}

.article tbody tr:last-child td {
  border-bottom: 0;
}

/* 图片：圆角 + 可点开新窗口 */
.article img {
  max-width: 100%;
  height: auto;
  margin: .5em 0;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
}

.article .img-link {
  display: inline-block;
  max-width: 100%;
  text-decoration: none;
  cursor: zoom-in;
}

/* 任务列表 */
.article .task-list {
  padding-left: 0;
  list-style: none;
}

.article .task-item {
  margin-left: 0;
}

.article input[type="checkbox"] {
  position: relative;
  width: 16px;
  height: 16px;
  margin: 0 8px 0 0;
  border: 1.5px solid var(--border-strong);
  border-radius: 5px;
  background: var(--surface);
  vertical-align: -3px;
  -webkit-appearance: none;
  appearance: none;
  cursor: default;
}

.article input[type="checkbox"]:checked {
  border-color: var(--accent);
  background: var(--accent);
}

.article input[type="checkbox"]:checked::after {
  content: "";
  position: absolute;
  top: 1px;
  left: 4px;
  width: 5px;
  height: 9px;
  border: solid var(--check);
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

/* 搜索命中 */
mark {
  padding: 0 2px;
  border-radius: 3px;
  background: var(--mark);
  color: var(--mark-text);
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
}

/* 上一篇 / 下一篇 */
.note-pager {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 18px;
}

.note-pager[hidden] {
  display: none;
}

.pager-link {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
  transition: border-color .16s var(--ease), transform .16s var(--ease),
    box-shadow .16s var(--ease);
}

.pager-link:hover {
  border-color: var(--accent-border);
  box-shadow: var(--shadow-1);
  text-decoration: none;
}

.pager-link:active {
  transform: scale(.99);
}

.pager-next {
  text-align: right;
  align-items: flex-end;
}

.pager-dir {
  color: var(--text-muted);
  font-size: 12px;
}

.pager-title {
  max-width: 100%;
  overflow: hidden;
  font-size: 13.5px;
  font-weight: 600;
  white-space: nowrap;
  text-overflow: ellipsis;
}

/* 滑动反馈 */
.note.is-swiping {
  transition: none;
}

.note.is-leaving {
  transition: transform .18s var(--ease);
}

/* --------------------------------------------------------------------------
   9. 编辑页
   -------------------------------------------------------------------------- */

.editor {
  margin: 0;
}

.editor .path-label {
  display: block;
  margin-bottom: 6px;
  color: var(--text-muted);
  font-size: 13px;
}

.editor .meta {
  margin: 0 0 16px;
}

.editor textarea {
  min-height: 60vh;
  padding: 16px 18px;
  border-radius: var(--r-md);
  background: var(--surface);
  font-family: var(--font-mono);
  font-size: 13.5px;
  line-height: 1.7;
  resize: vertical;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin: 10px 0 18px;
  color: var(--text-muted);
  font-size: 12.5px;
}

.chip {
  padding: 5px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-muted);
  font-size: 12.5px;
  cursor: pointer;
  transition: border-color .16s var(--ease), color .16s var(--ease),
    background-color .16s var(--ease);
}

.chip:hover {
  border-color: var(--accent-border);
  color: var(--accent);
  background: var(--accent-soft);
}

.attach {
  margin-top: 22px;
  padding: 18px 20px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
}

.attach h2 {
  margin: 0 0 6px;
  font-size: 14px;
  font-weight: 600;
}

.attach .hint {
  margin: 0 0 10px;
  color: var(--text-muted);
  font-size: 12.5px;
  line-height: 1.6;
}

.attach input[type="file"] {
  display: inline-block;
  width: auto;
  max-width: 100%;
  vertical-align: middle;
}

.status {
  margin-left: 8px;
  color: var(--text-muted);
  font-size: 12.5px;
}

.warn {
  margin: 0;
  color: var(--warn);
  font-size: 12.5px;
}

html[data-theme="dark"] .warn {
  color: #FBBF24;
}

.editor-bar {
  position: sticky;
  bottom: 0;
  z-index: 12;
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 26px;
  padding: 14px 0;
  border-top: 1px solid var(--border);
  background: var(--topbar-bg);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}

.editor-hint {
  margin-right: auto;
  color: var(--text-muted);
  font-size: 12.5px;
}

/* --------------------------------------------------------------------------
   10. 搜索页
   -------------------------------------------------------------------------- */

.search-big {
  display: flex;
  gap: 8px;
  margin: 18px 0 16px;
}

.search-big .search {
  flex: 1;
}

.search-big .search input[type="search"] {
  height: 44px;
  border-radius: var(--r-md);
  background: var(--surface);
  box-shadow: var(--shadow-1);
}

.result-count {
  margin: 0 0 16px;
  color: var(--text-muted);
  font-size: 13px;
}

.result-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.result-card {
  display: block;
  padding: 16px 18px;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--surface);
  box-shadow: var(--shadow-1);
  color: var(--text);
  text-decoration: none;
  transition: transform .18s var(--ease), box-shadow .18s var(--ease),
    border-color .18s var(--ease);
}

.result-card:hover {
  transform: translateY(-2px);
  border-color: var(--accent-border);
  box-shadow: var(--shadow-2);
  text-decoration: none;
}

.result-title {
  display: block;
  overflow: hidden;
  color: var(--text);
  font-size: 15px;
  font-weight: 600;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.result-path {
  display: block;
  margin: 2px 0 8px;
  overflow: hidden;
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 11.5px;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.snippet {
  margin: 0;
  color: var(--text-muted);
  font-size: 13.5px;
  line-height: 1.7;
}

/* --------------------------------------------------------------------------
   11. 登录 / 错误 / ⌘K
   -------------------------------------------------------------------------- */

.auth {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  overflow: hidden;
}

.auth::before,
.auth::after {
  content: "";
  position: absolute;
  z-index: 0;
  width: 420px;
  height: 420px;
  border-radius: 50%;
  filter: blur(80px);
  pointer-events: none;
}

.auth::before {
  top: -120px;
  left: -80px;
  background: var(--blob-1);
}

.auth::after {
  right: -100px;
  bottom: -140px;
  background: var(--blob-2);
}

.auth-main {
  position: relative;
  z-index: 1;
  display: flex;
  flex: 1;
  align-items: center;
  justify-content: center;
  padding: 48px 16px;
}

.login-card {
  width: 100%;
  max-width: 392px;
  padding: 34px 30px 30px;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--surface);
  box-shadow: var(--shadow-3);
  animation: rise .24s var(--ease) both;
}

.brand-mark-lg {
  width: 48px;
  height: 48px;
  margin-bottom: 18px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--gradient-end));
  color: #fff;
  box-shadow: 0 8px 20px var(--accent-ring);
}

html[data-theme="dark"] .brand-mark-lg {
  color: #0B0E14;
}

.brand-mark-lg svg {
  width: 22px;
  height: 22px;
}

.login-card h1 {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -.02em;
}

.login-card form {
  margin-top: 22px;
}

.login-card .btn-block {
  min-height: 42px;
  margin-top: 6px;
}

.error-card {
  max-width: 520px;
  margin: 8vh auto 0;
  padding: 40px 32px;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--surface);
  box-shadow: var(--shadow-2);
  text-align: center;
}

.error-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 52px;
  height: 52px;
  margin-bottom: 14px;
  border-radius: 50%;
  background: var(--danger-soft);
  color: var(--danger);
}

.error-code {
  font-size: 34px;
  font-weight: 700;
  letter-spacing: -.02em;
  line-height: 1.2;
}

.error-card p {
  color: var(--text-muted);
  font-size: 14px;
}

.error-card .btn {
  margin-top: 22px;
}

/* ⌘K 搜索浮层 */
.cmdk {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: none;
}

.cmdk.is-open {
  display: block;
}

.cmdk-backdrop {
  position: absolute;
  inset: 0;
  background: var(--scrim);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
  animation: fade-in .18s var(--ease) both;
}

.cmdk-card {
  position: relative;
  z-index: 1;
  max-width: 560px;
  margin: 13vh auto 0;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--raised);
  box-shadow: var(--shadow-3);
  animation: rise .2s var(--ease) both;
}

.cmdk-card .search input[type="search"] {
  height: 46px;
  border-radius: var(--r-md);
  background: var(--surface-2);
}

.cmdk-hint {
  margin: 8px 8px 2px;
  color: var(--text-muted);
  font-size: 12px;
}

/* --------------------------------------------------------------------------
   11.5 目录树徽标 / 浏览目录页（/browse）
   -------------------------------------------------------------------------- */

.tree-label {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.tree-count {
  flex: none;
  margin-left: auto;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text-faint);
  font-size: 10.5px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  line-height: 15px;
}

.tree-more a {
  display: block;
  padding: 6px 8px 6px 24px;
  border-radius: var(--r-sm);
  color: var(--accent);
  font-size: 12.5px;
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: background-color .16s var(--ease), color .16s var(--ease);
}

.tree-more a:hover {
  background: var(--accent-soft);
  text-decoration: none;
}

/* 浏览页工具条 */
.browse-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 12px;
  margin: 22px 0 10px;
}

.browse-filter {
  flex: 1 1 240px;
  min-width: 180px;
}

.browse-filter input[type="search"] {
  height: 40px;
}

.browse-toolbar .chips {
  margin: 0;
  gap: 6px;
}

.browse-toolbar .chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 32px;
  white-space: nowrap;
}

.browse-toolbar .chip.is-active {
  border-color: transparent;
  background: var(--accent);
  color: var(--accent-contrast);
}

.browse-toolbar .chip.is-active:hover {
  background: var(--accent-hover);
  color: var(--accent-contrast);
}

.chip-n {
  color: var(--text-faint);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.chip.is-active .chip-n {
  color: inherit;
  opacity: .75;
}

.chip-more {
  position: relative;
}

.chip-more > summary {
  list-style: none;
  cursor: pointer;
}

.chip-more > summary::-webkit-details-marker {
  display: none;
}

.chip-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 25;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 176px;
  max-height: 300px;
  overflow-y: auto;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--raised);
  box-shadow: var(--shadow-3);
}

.chip-menu .chip {
  justify-content: space-between;
  width: 100%;
  min-height: 34px;
  border: 0;
  background: transparent;
}

.chip-menu .chip:hover {
  border: 0;
  background: var(--surface-2);
  color: var(--text);
}

.browse-status {
  margin: 0 0 12px;
  color: var(--text-muted);
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
}

/* 月份分组 */
.browse-root {
  display: block;
}

.month-group {
  margin: 0 0 6px;
}

.month-group > summary {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 10px;
  border-radius: var(--r-sm);
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  list-style: none;
  user-select: none;
  transition: background-color .16s var(--ease);
}

.month-group > summary::-webkit-details-marker {
  display: none;
}

.month-group > summary::before {
  content: "";
  flex: none;
  width: 5px;
  height: 5px;
  margin-left: 2px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(-45deg);
  opacity: .6;
  transition: transform .18s var(--ease);
}

.month-group[open] > summary::before {
  transform: rotate(45deg);
}

.month-group > summary:hover {
  background: var(--surface-2);
}

.month-label {
  font-variant-numeric: tabular-nums;
}

.month-count {
  margin-left: auto;
  color: var(--text-faint);
  font-size: 11.5px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

.browse-list {
  margin: 2px 0 10px;
}

.browse-list li[hidden],
.month-group[hidden],
.empty[hidden] {
  display: none;
}

@media (max-width: 767px) {
  .browse-toolbar {
    margin-top: 16px;
  }

  .browse-filter {
    flex-basis: 100%;
  }

  /* chips 单行横向滚动，避免撑出页面横向滚动条 */
  .browse-toolbar .chips {
    flex-wrap: nowrap;
    max-width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    padding-bottom: 4px;
    scrollbar-width: none;
  }

  .browse-toolbar .chips::-webkit-scrollbar {
    display: none;
  }

  .browse-toolbar .chip {
    flex: none;
    min-height: 44px;
  }

  .browse-toolbar .chip-more {
    flex: none;
  }

  .chip-menu {
    position: fixed;
    top: auto;
    left: 12px;
    right: 12px;
    bottom: 12px;
    min-width: 0;
    max-height: 50vh;
  }

  .month-group > summary {
    min-height: 44px;
  }

  /* 「显示全部 N 篇」与「更多」下拉项也要有 44px 触控高度 */
  .tree-more a {
    display: flex;
    align-items: center;
    min-height: 44px;
    padding-top: 0;
    padding-bottom: 0;
  }

  .chip-menu .chip {
    min-height: 44px;
  }
}

/* --------------------------------------------------------------------------
   12. 响应式
   -------------------------------------------------------------------------- */

@media (max-width: 1023px) {
  :root {
    --sidebar-w: 240px;
  }

  .main {
    padding: 30px 20px 48px;
  }

  .note {
    padding: 32px 30px;
  }
}

.backdrop {
  display: none;
}

@media (max-width: 767px) {
  .sidebar {
    width: min(300px, 84vw);
    transform: translateX(-100%);
    box-shadow: none;
  }

  body.nav-open .sidebar {
    transform: none;
    box-shadow: var(--shadow-3);
  }

  body.nav-open {
    overflow: hidden;
  }

  .backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 35;
    border: 0;
    background: var(--scrim);
    opacity: 0;
    visibility: hidden;
    transition: opacity .24s var(--ease), visibility .24s var(--ease);
  }

  body.nav-open .backdrop {
    opacity: 1;
    visibility: visible;
  }

  .topbar .icon-btn.menu-btn,
  .sidebar .icon-btn.drawer-close {
    display: inline-flex;
  }

  .workspace {
    margin-left: 0;
  }

  .topbar-inner {
    min-height: 52px;
    padding: 6px 12px;
    gap: 6px;
  }

  .crumbs {
    display: none;
  }

  .topbar-title {
    display: block;
  }

  .btn-new {
    width: 44px;
    min-height: 44px;
    padding: 0;
  }

  .btn-new .btn-label {
    display: none;
  }

  .topbar-actions .logout-form {
    display: none;
  }

  .mobile-search {
    display: block;
  }

  .side-foot {
    display: block;
  }

  .main {
    padding: 20px 16px 40px;
  }

  .page-head h1 {
    font-size: 24px;
  }

  .note {
    padding: 24px 18px;
    border-radius: 14px;
  }

  .note-head h1 {
    font-size: 23px;
  }

  .note-head {
    margin-bottom: 22px;
  }

  .note-link {
    padding: 14px;
    gap: 2px 12px;
  }

  .note-go {
    display: none;
  }

  .note-link {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "title time"
      "path time";
  }

  .tree summary,
  .tree-file a {
    padding-top: 10px;
    padding-bottom: 10px;
  }

  .icon-btn {
    width: 44px;
    height: 44px;
  }

  .actions .btn {
    min-height: 44px;
  }

  .note-pager {
    grid-template-columns: 1fr;
  }

  .pager-next {
    text-align: left;
    align-items: flex-start;
  }

  .editor textarea {
    min-height: 56vh;
  }

  .editor-bar {
    flex-wrap: wrap;
  }

  .editor-hint {
    width: 100%;
    margin: 0 0 2px;
  }

  .search-big {
    flex-wrap: wrap;
  }

  .login-card {
    padding: 28px 22px 24px;
  }

  .error-card {
    margin-top: 4vh;
    padding: 32px 22px;
  }

  .cmdk-card {
    margin: 10vh 12px 0;
  }
}

/* 深色下危险色边框（媒体跟随模式） */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .btn-danger {
    border-color: rgba(248, 113, 113, .28);
  }
}

/* 动效降级 */
@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    transition-delay: 0s !important;
  }

  .note-link:hover,
  .result-card:hover {
    transform: none;
  }
}

/* 目录树分批展开 */
.tree-load-btn {
  display: block;
  width: 100%;
  margin: 2px 0;
  padding: 6px 8px 6px 24px;
  border: 0;
  border-radius: var(--r-sm);
  background: none;
  color: var(--accent);
  font: inherit;
  font-size: 13px;
  text-align: left;
  cursor: pointer;
}
.tree-load-btn:hover { background: var(--accent-soft); }
.tree-load-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

/* 浏览页排序切换 */
.sort-toggle { display: flex; gap: 8px; margin: 10px 0 4px; }
.sort-toggle .chip { text-decoration: none; }

.side-theme {
  display: block;
  width: 100%;
  margin: 6px 0;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: none;
  color: var(--fg-2);
  font: inherit;
  font-size: 13px;
  text-align: left;
  cursor: pointer;
  min-height: 40px;
}
.side-theme:hover { background: var(--accent-soft); color: var(--fg-1); }
@media (max-width: 767px) { .side-theme { min-height: 44px; } }

/* --------------------------------------------------------------------------
   编辑器：源码 / 所见即所得
   -------------------------------------------------------------------------- */

[hidden] { display: none !important; }

.editor-modes {
  display: flex;
  gap: 6px;
  margin: 4px 0 10px;
}

.mode-btn {
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--fg-2);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}

.mode-btn.is-active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-fg);
}

.rich-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  padding: 8px;
  border: 1px solid var(--line);
  border-bottom: 0;
  border-radius: var(--r-md) var(--r-md) 0 0;
  background: var(--surface-2);
}

.rt-btn {
  min-width: 36px;
  height: 32px;
  padding: 0 8px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: none;
  color: var(--fg-2);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}

.rt-btn:hover { background: var(--accent-soft); color: var(--fg-1); }
.rt-btn:active { transform: scale(.96); }
.rt-sep { width: 1px; height: 18px; margin: 0 4px; background: var(--line); }

.rich-editor {
  min-height: 60vh;
  padding: 18px 20px;
  border: 1px solid var(--line);
  border-radius: 0 0 var(--r-md) var(--r-md);
  background: var(--surface);
  overflow-y: auto;
  outline: none;
}

.rich-editor:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.rich-editor > :first-child { margin-top: 0; }
.rich-editor table { width: 100%; border-collapse: collapse; }
.rich-editor pre { overflow-x: auto; }

@media (max-width: 767px) {
  .rich-toolbar { position: sticky; top: 0; z-index: 10; }
  .rt-btn { min-height: 40px; }
  .rich-editor { min-height: 55vh; }
}
