/* ==========================================================================
   便签本 · 设计系统
   风格：暖纸色 + 黄铜单一点缀 · 扁平 · 克制阴影 · 移动端优先
   ========================================================================== */

/* ---------- 设计令牌 ---------- */
:root {
  --bg: #F6F5F1;            /* 暖纸底色 */
  --panel: #FFFFFF;         /* 卡片 / 面板 */
  --panel-2: #F0EEE8;       /* 弱填充（标签、hover） */
  --border: #E6E3DB;        /* 发丝分隔线 */
  --border-strong: #D8D4C9;
  --text: #1C1B17;          /* 墨色正文 */
  --muted: #8F8A7D;         /* 次要文字 */
  --faint: #B9B4A6;         /* 占位 / 弱图标 */

  --accent: #A5823B;        /* 黄铜 · 全站唯一强调色 */
  --accent-deep: #86692C;
  --accent-soft: rgba(165, 130, 59, .12);
  --accent-ink: #FFFDF8;    /* 强调色上的文字 */

  --danger: #B3472F;        /* 克制的砖红 */
  --danger-soft: rgba(179, 71, 47, .10);

  --shadow-sm: 0 1px 2px rgba(28, 27, 23, .05);
  --shadow-md: 0 8px 28px rgba(28, 27, 23, .10);

  --radius: 14px;
  --radius-sm: 10px;
  --radius-full: 999px;

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161513;
    --panel: #1E1D1A;
    --panel-2: #282622;
    --border: #302E29;
    --border-strong: #403D36;
    --text: #ECE9E1;
    --muted: #9B9588;
    --faint: #6E6A60;
    --accent: #C2A25C;
    --accent-deep: #D3B46E;
    --accent-soft: rgba(194, 162, 92, .16);
    --accent-ink: #1C1B17;
    --danger: #E0715C;
    --danger-soft: rgba(224, 113, 92, .14);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
    --shadow-md: 0 8px 28px rgba(0, 0, 0, .45);
  }
}

/* ---------- 基础 ---------- */
* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  -webkit-tap-highlight-color: transparent;  /* 去除移动端点击高亮 */
  touch-action: manipulation;                /* 去除快速点按的双击缩放延迟 */
}

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

button { font-family: inherit; cursor: pointer; }
input, textarea, select { font-family: inherit; color: inherit; }
svg { display: block; }

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

a { color: inherit; }

/* ==========================================================================
   布局外壳
   ========================================================================== */
.app-shell {
  display: flex;
  min-height: 100vh;
  min-height: 100dvh;
}

.content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

/* ==========================================================================
   侧边栏（桌面）
   ========================================================================== */
.sidebar {
  width: 236px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 22px 14px 16px;
  background: var(--panel);
  border-right: 1px solid var(--border);
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100dvh;
  z-index: 20;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 2px 8px 16px;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: .02em;
  color: var(--text);
}

.brand-mark {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: var(--accent);
  color: var(--accent-ink);
}
.brand-mark svg { width: 46%; height: 46%; }

/* ---------- 分类导航 ---------- */
.cats {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}

.cat {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  color: var(--muted);
  text-decoration: none;
  font-size: 14px;
  transition: background .15s ease, color .15s ease;
}
.cat:hover { background: var(--panel-2); color: var(--text); }
.cat.active { background: var(--accent-soft); color: var(--accent-deep); font-weight: 600; }

.cat-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cat-count {
  font-size: 12px;
  color: var(--muted);
  background: var(--panel-2);
  border-radius: var(--radius-full);
  padding: 1px 8px;
  min-width: 24px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.cat.active .cat-count { background: rgba(165, 130, 59, .18); color: var(--accent-deep); }

/* 分类删除（桌面 hover 显示） */
.inline-del { margin: 0; display: inline-flex; }
.inline-del button {
  border: none;
  background: none;
  color: var(--faint);
  width: 22px;
  height: 22px;
  border-radius: 6px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  visibility: hidden;
}
.inline-del svg { width: 13px; height: 13px; }
.cat:hover .inline-del button { visibility: visible; }
.inline-del button:hover { color: var(--danger); background: var(--danger-soft); }

/* 「＋ 分类」chip：仅移动端显示 */
.cat-add {
  display: none;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
  margin-left: 2px;
  padding: 7px 12px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-full);
  background: none;
  color: var(--faint);
  font-size: 13px;
  transition: color .15s ease, border-color .15s ease, background .15s ease;
}
.cat-add svg { width: 14px; height: 14px; }
.cat-add:hover { color: var(--accent-deep); border-color: var(--accent); background: var(--accent-soft); }

/* 新建分类（桌面内联输入） */
.new-cat {
  display: flex;
  gap: 6px;
  border-top: 1px solid var(--border);
  padding-top: 12px;
  margin-top: 4px;
}
.new-cat input {
  flex: 1;
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  font-size: 14px;
  outline: none;
  background: var(--panel);
  color: var(--text);
  transition: border-color .15s ease, box-shadow .15s ease;
}
.new-cat input::placeholder { color: var(--faint); }
.new-cat input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.new-cat button {
  border: none;
  background: var(--accent);
  color: var(--accent-ink);
  border-radius: var(--radius-sm);
  width: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s ease;
}
.new-cat button svg { width: 16px; height: 16px; }
.new-cat button:hover { background: var(--accent-deep); }

/* 退出登录（桌面底部） */
.logout { margin: 0; }
.logout-side { border-top: 1px solid var(--border); padding-top: 12px; margin-top: 4px; }
.logout-btn { width: 100%; }

/* ==========================================================================
   顶部栏（移动端）
   ========================================================================== */
.topbar {
  display: none;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  padding-top: calc(10px + env(safe-area-inset-top));
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  z-index: 20;
}
.topbar-brand { display: flex; align-items: center; gap: 9px; font-size: 16px; font-weight: 700; letter-spacing: .02em; }
.topbar-brand .brand-mark { width: 27px; height: 27px; border-radius: 8px; }

.logout-top button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border: none;
  background: none;
  color: var(--muted);
  border-radius: var(--radius-sm);
  transition: background .15s ease, color .15s ease;
}
.logout-top svg { width: 18px; height: 18px; }
.logout-top button:hover { background: var(--panel-2); color: var(--text); }

/* ==========================================================================
   主区域
   ========================================================================== */
.main {
  flex: 1;
  width: 100%;
  max-width: 780px;
  margin: 0 auto;
  padding: 32px 40px 72px;
}
.main--list { max-width: none; }  /* 笔记列表占满可用宽度，不限制 780px */
.main > * { animation: fade-up .22s ease; }

.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 20px;
}
.page-title-wrap { min-width: 0; }
.page-title { font-size: 22px; font-weight: 700; letter-spacing: .01em; }
.page-count { font-size: 13px; color: var(--muted); margin-top: 2px; display: block; }

/* ==========================================================================
   按钮
   ========================================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  flex-shrink: 0;
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  transition: background .15s ease, border-color .15s ease, color .15s ease, transform .05s ease;
}
.btn svg { width: 16px; height: 16px; }
.btn:hover { background: var(--panel-2); }
.btn:active { transform: scale(.98); }

.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: var(--accent-deep); border-color: var(--accent-deep); }

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

/* 图标按钮（编辑器头部 / 顶栏） */
.icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 38px;
  height: 38px;
  border: none;
  background: none;
  color: var(--muted);
  border-radius: var(--radius-sm);
  text-decoration: none;
  transition: background .15s ease, color .15s ease;
}
.icon-btn svg { width: 19px; height: 19px; }
.icon-btn:hover { background: var(--panel-2); color: var(--text); }
.icon-btn.danger { color: var(--faint); }
.icon-btn.danger:hover { color: var(--danger); background: var(--danger-soft); }

/* ==========================================================================
   笔记列表
   ========================================================================== */
.note-list { list-style: none; display: flex; flex-direction: column; gap: 10px; }

.note-item {
  display: block;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  text-decoration: none;
  color: var(--text);
  transition: border-color .15s ease, box-shadow .15s ease, transform .15s ease;
}
.note-item:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
}

.note-item-preview {
  font-size: 15px;
  line-height: 1.6;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
}

.note-item-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
  font-size: 12px;
  color: var(--muted);
}
.tag {
  background: var(--panel-2);
  color: var(--muted);
  border-radius: 6px;
  padding: 2px 8px;
  max-width: 40%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.time { font-variant-numeric: tabular-nums; }

/* ---------- 空状态 ---------- */
.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 64px 0;
  text-align: center;
  color: var(--faint);
}
.empty svg { margin-bottom: 10px; opacity: .9; }
.empty-title { font-size: 16px; font-weight: 600; color: var(--text); }
.empty-text { font-size: 14px; color: var(--muted); }

/* ==========================================================================
   浮动新建按钮（移动端）
   ========================================================================== */
.fab {
  display: none;
  position: fixed;
  right: calc(20px + env(safe-area-inset-right));
  bottom: calc(26px + env(safe-area-inset-bottom));
  z-index: 30;
  width: 56px;
  height: 56px;
  border: none;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-ink);
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 24px rgba(134, 105, 44, .35);
  transition: background .15s ease, transform .15s ease;
}
.fab svg { width: 24px; height: 24px; }
.fab:hover { background: var(--accent-deep); }
.fab:active { transform: scale(.92); }

/* ==========================================================================
   编辑器
   ========================================================================== */
.editor {
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.editor-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
}
.editor-title {
  flex: 1;
  min-width: 0;
  text-align: center;
  font-size: 15px;
  font-weight: 600;
  color: var(--muted);
}
.editor-save { margin-left: auto; }

.editor-body {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 18px;
}

.editor-meta { display: flex; align-items: center; gap: 14px; }
.cat-select { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.cat-select select {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 10px;
  font-size: 14px;
  outline: none;
  background: var(--panel);
  color: var(--text);
  max-width: 200px;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.cat-select select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.editor-time { font-size: 12px; color: var(--faint); margin-left: auto; font-variant-numeric: tabular-nums; }

.content-input {
  border: none;
  outline: none;
  resize: none;
  width: 100%;
  min-height: 40vh;
  background: transparent;
  color: var(--text);
  font-size: 16px;          /* ≥16px 防 iOS 聚焦缩放 */
  line-height: 1.75;
}
.content-input::placeholder { color: var(--faint); }

/* ==========================================================================
   弹层（新建分类 · 移动端底部弹出）
   ========================================================================== */
.modal-mask {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(28, 27, 23, .45);
  opacity: 0;
  transition: opacity .18s ease;
}
.modal-mask[hidden] { display: none; }
.modal-mask.show { opacity: 1; }

.modal {
  width: 100%;
  max-width: 360px;
  background: var(--panel);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-md);
  transform: translateY(8px) scale(.98);
  transition: transform .18s ease;
}
.modal-mask.show .modal { transform: none; }

.modal-title { font-size: 16px; font-weight: 700; }
.modal-sub { font-size: 13px; color: var(--muted); margin-top: 4px; }

.modal-form { margin-top: 16px; }
.modal-form input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 11px 12px;
  font-size: 16px;
  outline: none;
  background: var(--panel);
  color: var(--text);
  transition: border-color .15s ease, box-shadow .15s ease;
}
.modal-form input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.modal-actions { display: flex; gap: 10px; margin-top: 16px; }
.modal-actions .btn { flex: 1; }

/* ==========================================================================
   Toast 提示
   ========================================================================== */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(26px + env(safe-area-inset-bottom));
  transform: translateX(-50%) translateY(12px);
  z-index: 70;
  max-width: calc(100vw - 40px);
  padding: 10px 18px;
  border-radius: var(--radius-full);
  background: rgba(28, 27, 23, .92);
  color: #F6F5F1;
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.error { background: rgba(179, 71, 47, .95); }

/* ==========================================================================
   登录页
   ========================================================================== */
.login-body {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(1100px 520px at 50% -10%, var(--accent-soft), transparent 62%),
    var(--bg);
}

.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 36px 32px 30px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  animation: fade-up .35s ease;
}

.login-logo {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  margin: 0 0 8px;
}
.login-logo .brand-mark { width: 52px; height: 52px; border-radius: 16px; }
.login-logo h1 { font-size: 20px; font-weight: 700; letter-spacing: .02em; }

.login-tip { text-align: center; color: var(--muted); font-size: 14px; margin-bottom: 12px; }

.login-input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 13px 14px;
  font-size: 16px;
  outline: none;
  background: var(--panel);
  color: var(--text);
  transition: border-color .15s ease, box-shadow .15s ease;
}
.login-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.login-input::placeholder { color: var(--faint); }

.login-err { color: var(--danger); font-size: 13px; text-align: center; }
.login-btn { width: 100%; padding: 13px; font-size: 15px; border-radius: 12px; margin-top: 14px; }

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

/* ==========================================================================
   移动端
   ========================================================================== */
@media (max-width: 767px) {
  .app-shell { flex-direction: column; }

  /* 侧栏变为顶部横向分类条 */
  .sidebar {
    width: 100%;
    height: auto;
    position: static;
    flex-direction: row;
    align-items: center;
    padding: 8px 12px;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  .sidebar .brand { display: none; }
  .sidebar .new-cat { display: none; }
  .sidebar .logout-side { display: none; }

  .cats {
    flex-direction: row;
    gap: 8px;
    flex: none;
    overflow-x: auto;
    padding: 4px 2px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    overscroll-behavior-x: contain;
  }
  .cats::-webkit-scrollbar { display: none; }
  .cat { flex-shrink: 0; padding: 7px 12px; }
  .cat-add { display: flex; }
  .inline-del button { visibility: visible; width: 26px; height: 26px; }

  /* 顶部栏 */
  .topbar { display: flex; }

  /* 主区域 */
  .main { padding: 20px 16px 96px; }
  .page-title { font-size: 19px; }
  .page-count { font-size: 12px; }
  .btn-new { display: none; }          /* 用 FAB 代替 */
  .fab { display: flex; }

  /* 笔记卡片 */
  .note-item { padding: 14px 16px; }
  .note-item:active { background: var(--panel-2); }

  /* 编辑器：全宽无边框，更像书写画布 */
  .editor { border-radius: 0; border-left: none; border-right: none; }
  .editor-head { padding: 10px 12px; }
  .editor-body { padding: 16px 16px 24px; }
  .content-input { min-height: 32vh; }

  /* 弹层：底部抽屉 */
  .modal-mask { align-items: flex-end; padding: 0; }
  .modal {
    max-width: none;
    border-radius: 18px 18px 0 0;
    padding: 24px 20px calc(20px + env(safe-area-inset-bottom));
    transform: translateY(100%);
  }
  .modal-mask.show .modal { transform: none; }

  /* Toast 移到顶部，避开 FAB */
  .toast { top: calc(64px + env(safe-area-inset-top)); bottom: auto; transform: translateX(-50%) translateY(-8px); }
  .toast.show { transform: translateX(-50%) translateY(0); }
}

/* ==========================================================================
   Markdown 编辑器（所见即所得）
   ========================================================================== */
.md-editor {
  min-height: 40vh;
  font-size: 16px;             /* ≥16px 防 iOS 聚焦缩放 */
  line-height: 1.8;
  outline: none;
  overflow-wrap: break-word;
  word-break: break-word;
  color: var(--text);
}
.md-editor:empty::before {
  content: attr(data-placeholder);
  color: var(--faint);
  pointer-events: none;
}

/* ---------- 排版 ---------- */
.md-editor h1, .md-editor h2, .md-editor h3,
.md-editor h4, .md-editor h5, .md-editor h6 {
  font-weight: 700;
  line-height: 1.4;
  margin: 1.4em 0 .55em;
  letter-spacing: .01em;
  scroll-margin-top: 24px;
}
.md-editor h1 { font-size: 1.6em; }
.md-editor h2 { font-size: 1.35em; }
.md-editor h3 { font-size: 1.18em; }
.md-editor h4 { font-size: 1.05em; }
.md-editor h5, .md-editor h6 { font-size: 1em; color: var(--muted); }
.md-editor h1:first-child, .md-editor h2:first-child { margin-top: .2em; }

.md-editor p { margin: .55em 0; }
.md-editor strong { font-weight: 700; }
.md-editor em { font-style: italic; }
.md-editor del { opacity: .72; }

.md-editor a {
  color: var(--accent-deep);
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-color: var(--accent-soft);
}
.md-editor a:hover { text-decoration-color: var(--accent); }

.md-editor code {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: .88em;
  background: var(--panel-2);
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 2px 6px;
}
.md-editor pre {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  margin: .7em 0;
  overflow-x: auto;
  line-height: 1.6;
}
.md-editor pre code {
  background: none;
  border: none;
  padding: 0;
  font-size: .85em;
  white-space: pre;
}

.md-editor ul, .md-editor ol { margin: .5em 0; padding-left: 1.5em; }
.md-editor li { margin: .28em 0; }
.md-editor li::marker { color: var(--accent); font-weight: 600; }
.md-editor li > ul, .md-editor li > ol { margin: .2em 0; }

.md-editor blockquote {
  margin: .7em 0;
  padding: 4px 14px;
  border-left: 3px solid var(--accent);
  color: var(--muted);
}
.md-editor blockquote p { margin: .3em 0; }

.md-editor hr {
  border: none;
  border-top: 1px solid var(--border-strong);
  margin: 1.5em 0;
}

.md-editor img {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius-sm);
}
.md-editor img[alt]:empty::after { content: '（图片）'; color: var(--faint); }

/* ---------- 表格 ---------- */
.md-editor table {
  border-collapse: collapse;
  margin: .8em 0;
  width: 100%;
  font-size: .92em;
  display: table;
}
.md-editor th, .md-editor td {
  border: 1px solid var(--border);
  padding: 7px 11px;
  text-align: left;
  vertical-align: top;
}
.md-editor th { background: var(--panel-2); font-weight: 600; }
.md-editor tr:nth-child(even) td { background: rgba(0,0,0,.015); }
@media (prefers-color-scheme: dark) { .md-editor tr:nth-child(even) td { background: rgba(255,255,255,.02); } }

/* ---------- 任务列表 ---------- */
.md-editor li.task {
  list-style: none;
  margin-left: -1.5em;
  padding-left: 1.5em;
  display: flex;
  align-items: flex-start;
  gap: 9px;
}
.md-editor li.task input[type=checkbox] {
  appearance: none;
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  margin: .28em 0 0;
  flex-shrink: 0;
  border: 1.5px solid var(--border-strong);
  border-radius: 5px;
  background: var(--panel);
  position: relative;
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease;
}
.md-editor li.task input[type=checkbox]:checked {
  background: var(--accent);
  border-color: var(--accent);
}
.md-editor li.task input[type=checkbox]:checked::after {
  content: '';
  position: absolute;
  left: 4px;
  top: 1px;
  width: 5px;
  height: 9px;
  border: solid var(--accent-ink);
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}
.md-editor li.task.done > * { color: var(--muted); text-decoration: line-through; }

/* ---------- 源码态 ---------- */
.md-source {
  display: block;
  width: 100%;
  min-height: 40vh;
  border: none;
  outline: none;
  resize: none;
  background: transparent;
  color: var(--text);
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 14px;
  line-height: 1.7;
}
.md-source::placeholder { color: var(--faint); }

/* ---------- 编辑器头 / 元信息 ---------- */
.editor-meta { padding: 14px 18px 0; }
.md-wrap { padding: 4px 18px 18px; }
.editor-time { margin-left: 0; }

.save-status {
  margin-left: auto;
  font-size: 12px;
  color: var(--faint);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.save-status[data-status="saving"] { color: var(--muted); }
.save-status[data-status="dirty"] { color: var(--accent-deep); }
.save-status[data-status="error"] { color: var(--danger); cursor: pointer; text-decoration: underline; }

.icon-btn.active { background: var(--accent-soft); color: var(--accent-deep); }

/* ==========================================================================
   大纲
   ========================================================================== */
.outline-rail {
  position: fixed;
  top: 92px;
  right: 18px;
  width: 216px;
  max-height: calc(100vh - 130px);
  overflow-y: auto;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 10px;
  z-index: 40;
  box-shadow: var(--shadow-sm);
}
.outline-rail[hidden] { display: none; }
.outline-rail-head {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--faint);
  padding: 2px 8px 8px;
}
.outline-items { display: flex; flex-direction: column; gap: 1px; }

.outline-item {
  display: block;
  width: 100%;
  text-align: left;
  border: none;
  background: none;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
  padding: 5px 8px;
  border-radius: 7px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  transition: background .12s ease, color .12s ease;
}
.outline-item:hover { background: var(--panel-2); color: var(--text); }
.outline-item.active { background: var(--accent-soft); color: var(--accent-deep); font-weight: 600; }
.outline-item.lv-2 { padding-left: 20px; }
.outline-item.lv-3 { padding-left: 32px; }
.outline-item.lv-4 { padding-left: 44px; }
.outline-item.lv-5, .outline-item.lv-6 { padding-left: 56px; }

/* 移动端抽屉里的大号点击目标 */
.outline-sheet .outline-item { padding: 11px 10px; font-size: 15px; }

/* 桌面窄屏不显示大纲栏（用抽屉） */
@media (max-width: 1179px) {
  .outline-rail { display: none; }
}

/* ==========================================================================
   Markdown 编辑器 · 移动端
   ========================================================================== */
@media (max-width: 767px) {
  .md-editor { min-height: 32vh; font-size: 16px; }
  .md-source { min-height: 32vh; font-size: 15px; }
  .md-editor h1, .md-editor h2, .md-editor h3,
  .md-editor h4, .md-editor h5, .md-editor h6 { scroll-margin-top: 84px; }
  .editor-meta { padding: 12px 14px 0; }
  .md-wrap { padding: 2px 14px 16px; }
  .save-status { font-size: 12px; }
  .md-editor table { display: block; overflow-x: auto; }
  .md-editor pre { max-width: 100%; }
}
