/* ============================================================
   Simple Notes - 样式
   主题：浅色 / 深色 / AMOLED 纯黑
   ============================================================ */

:root {
  --bg: #f5f6f8;
  --bg-elevated: #ffffff;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --border: #e3e6eb;
  --border-strong: #d2d6dd;
  --text: #171a20;
  --text-soft: #3d434e;
  --muted: #707885;
  --accent: #3567d6;
  --accent-hover: #2b57bd;
  --accent-soft: rgba(53, 103, 214, 0.1);
  --danger: #d64545;
  --danger-soft: rgba(214, 69, 69, 0.1);
  --success: #2f8757;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.06);
  --shadow-md: 0 8px 24px rgba(16, 24, 40, 0.1);
  --shadow-lg: 0 20px 48px rgba(16, 24, 40, 0.16);
  --radius: 12px;
  --radius-lg: 16px;
  --sidebar-w: 264px;
  --font-size: 15px;
  --mono: ui-monospace, SFMono-Regular, "Cascadia Code", Consolas, "Liberation Mono", monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB",
          "Microsoft YaHei", "Noto Sans SC", Roboto, Helvetica, Arial, sans-serif;
}

html[data-font="s"] { --font-size: 14px; }
html[data-font="m"] { --font-size: 15px; }
html[data-font="l"] { --font-size: 17px; }

@media (prefers-color-scheme: dark) {
 :root {
    --bg: #101215;
    --bg-elevated: #16191d;
    --surface: #181b20;
    --surface-2: #20242b;
    --border: #282d35;
    --border-strong: #363c46;
    --text: #eceef2;
    --text-soft: #c4c9d2;
    --muted: #8b929e;
    --accent: #6b93f5;
    --accent-hover: #82a4f7;
    --accent-soft: rgba(107, 147, 245, 0.14);
    --danger: #f07777;
    --danger-soft: rgba(240, 119, 119, 0.12);
    --success: #6ec48f;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 8px 28px rgba(0, 0, 0, 0.45);
    --shadow-lg: 0 24px 60px rgba(0, 0, 0, 0.55);
  }
}

html[data-theme="light"] {
  --bg: #f5f6f8;
  --bg-elevated: #ffffff;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --border: #e3e6eb;
  --border-strong: #d2d6dd;
  --text: #171a20;
  --text-soft: #3d434e;
  --muted: #707885;
  --accent: #3567d6;
  --accent-hover: #2b57bd;
  --accent-soft: rgba(53, 103, 214, 0.1);
  --danger: #d64545;
  --danger-soft: rgba(214, 69, 69, 0.1);
  --success: #2f8757;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.06);
  --shadow-md: 0 8px 24px rgba(16, 24, 40, 0.1);
  --shadow-lg: 0 20px 48px rgba(16, 24, 40, 0.16);
}

html[data-theme="dark"] {
  --bg: #101215;
  --bg-elevated: #16191d;
  --surface: #181b20;
  --surface-2: #20242b;
  --border: #282d35;
  --border-strong: #363c46;
  --text: #eceef2;
  --text-soft: #c4c9d2;
  --muted: #8b929e;
  --accent: #6b93f5;
  --accent-hover: #82a4f7;
  --accent-soft: rgba(107, 147, 245, 0.14);
  --danger: #f07777;
  --danger-soft: rgba(240, 119, 119, 0.12);
  --success: #6ec48f;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 8px 28px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 24px 60px rgba(0, 0, 0, 0.55);
}

html[data-theme="amoled"] {
  --bg: #000000;
  --bg-elevated: #07080a;
  --surface: #0a0b0d;
  --surface-2: #141619;
  --border: #1f2227;
  --border-strong: #2c3037;
  --text: #f3f4f7;
  --text-soft: #c8ccd4;
  --muted: #868d99;
  --accent: #7fa1ff;
  --accent-hover: #9ab5ff;
  --accent-soft: rgba(127, 161, 255, 0.14);
  --danger: #ff7f7f;
  --danger-soft: rgba(255, 127, 127, 0.12);
  --success: #78d29b;
  --shadow-sm: none;
  --shadow-md: 0 10px 28px rgba(0, 0, 0, 0.7);
  --shadow-lg: 0 24px 64px rgba(0, 0, 0, 0.85);
}

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

/* hidden 属性必须真正隐藏：.card-menu/.color-popover 的 display 会覆盖浏览器默认规则 */
[hidden] { display: none !important; }

html { font-size: var(--font-size); }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 1rem;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; }
img { max-width: 100%; }
code, pre { font-family: var(--mono); }

h1, h2, h3, h4 { line-height: 1.3; margin: 0; font-weight: 650; letter-spacing: -0.01em; }
h1 { font-size: 1.55rem; }
h2 { font-size: 1.1rem; }
h3 { font-size: 1rem; }

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

.icon { width: 1.15em; height: 1.15em; flex: none; display: inline-block; vertical-align: -0.18em; }

/* ---------- 通用组件 ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 0.93rem;
  font-weight: 550;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.1s, color 0.15s;
  white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-ghost { background: transparent; }
.btn-ghost:hover { background: var(--surface-2); }
.btn-danger-ghost { color: var(--danger); border-color: transparent; background: transparent; }
.btn-danger-ghost:hover { background: var(--danger-soft); }
.btn-small { padding: 5px 10px; font-size: 0.85rem; border-radius: 8px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: 0.55; cursor: default; }

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn.is-active { color: var(--accent); background: var(--accent-soft); }
.icon-btn.danger:hover { color: var(--danger); background: var(--danger-soft); }
.icon-btn .icon { width: 20px; height: 20px; }

.color-dot {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 1px solid rgba(0, 0, 0, 0.12);
  background: var(--dot, transparent);
  cursor: pointer;
  padding: 0;
  flex: none;
  transition: transform 0.12s, box-shadow 0.12s;
}
.color-dot:hover { transform: scale(1.15); }
.color-dot.active { box-shadow: 0 0 0 2px var(--surface), 0 0 0 3.5px var(--dot, var(--border-strong)); }
.color-default { --dot: var(--border-strong); }
.color-red { --dot: #e05252; }
.color-orange { --dot: #e8873a; }
.color-yellow { --dot: #d8b425; }
.color-green { --dot: #3f9e63; }
.color-teal { --dot: #2c9c96; }
.color-blue { --dot: #4077d6; }
.color-purple { --dot: #8b6bd8; }
.color-pink { --dot: #d95f9b; }
.color-gray { --dot: #8b9299; }

.chip {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  font-size: 0.82rem;
  cursor: pointer;
}
.chip:hover { background: var(--surface-2); color: var(--text); }
.chip.active { background: var(--accent-soft); border-color: transparent; color: var(--accent); font-weight: 600; }

.badge {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 0.78rem;
}

.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; }
.field > span { font-size: 0.86rem; color: var(--muted); font-weight: 550; }
input[type="text"], input[type="password"], input[type="search"], input[type="file"], select, textarea {
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 8px 11px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  min-width: 0;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
select { cursor: pointer; }
.check-row { display: flex; align-items: center; gap: 8px; font-size: 0.88rem; color: var(--muted); margin: 4px 0 14px; }
.check-row input[type="checkbox"] { accent-color: var(--accent); }

.muted { color: var(--muted); }
.small { font-size: 0.82rem; }
.nowrap { white-space: nowrap; }
.mt { margin-top: 14px; }
.row { display: flex; align-items: center; }
.gap { gap: 10px; flex-wrap: wrap; }

/* ---------- 侧边栏 ---------- */
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  background: var(--bg-elevated);
  border-right: 1px solid var(--border);
  padding: 14px 12px 10px;
  overflow-y: auto;
  z-index: 30;
  scrollbar-width: thin;
}

.sidebar-head { display: flex; align-items: center; justify-content: space-between; padding: 2px 6px 12px; }
.brand { display: flex; align-items: center; gap: 9px; min-width: 0; }
.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: var(--accent);
  color: #fff;
}
.brand-mark .icon { width: 19px; height: 19px; }
.brand-name { font-weight: 680; font-size: 0.98rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-close { display: none; }

.quick-actions { display: flex; gap: 8px; padding: 0 4px 14px; }
.quick-actions .btn { flex: 1; padding: 8px 8px; font-size: 0.87rem; }

.nav { display: flex; flex-direction: column; gap: 2px; padding: 0 2px 10px; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 7px 10px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--text-soft);
  font-size: 0.9rem;
  text-align: left;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.nav-item .icon { width: 18px; height: 18px; color: var(--muted); }
.nav-item span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-item small { color: var(--muted); font-size: 0.78rem; font-variant-numeric: tabular-nums; }
.nav-item:hover { background: var(--surface-2); }
.nav-item.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav-item.active .icon { color: var(--accent); }

.sidebar-section {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 10px 6px;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  font-weight: 600;
}
.sidebar-section .icon-btn { width: 26px; height: 26px; }
.sidebar-section .icon-btn .icon { width: 15px; height: 15px; }

.folder-list { list-style: none; margin: 0; padding: 0 2px 8px; }
.folder-row { display: flex; align-items: center; border-radius: 9px; }
.folder-row:hover { background: var(--surface-2); }
.folder-row.active { background: var(--accent-soft); }
.folder-link {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
  padding: 6px 4px 6px 10px;
  color: var(--text-soft);
  font-size: 0.88rem;
}
.folder-link .icon { width: 17px; height: 17px; color: var(--muted); }
.folder-row.active .folder-link { color: var(--accent); font-weight: 600; }
.folder-row.active .folder-link .icon { color: var(--accent); }
.folder-link span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.folder-link small { color: var(--muted); font-size: 0.76rem; }
.folder-more { width: 26px; height: 26px; opacity: 0; }
.folder-more .icon { width: 15px; height: 15px; }
.folder-row:hover .folder-more { opacity: 1; }
.folder-empty { padding: 6px 12px; font-size: 0.82rem; color: var(--muted); }

.tag-cloud { display: flex; flex-wrap: wrap; gap: 5px; padding: 0 6px 10px; }
.tag-chip {
  display: inline-flex;
  padding: 1px 7px;
  border-radius: 999px;
  font-size: 0.76rem;
  color: var(--muted);
  background: var(--surface-2);
  transition: color 0.15s, background 0.15s;
}
.tag-chip:hover { color: var(--accent); background: var(--accent-soft); }
.tag-chip.active { color: var(--accent); background: var(--accent-soft); font-weight: 600; }

.sidebar-foot { margin-top: auto; padding-top: 8px; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 1px; }
.sidebar-foot .nav-item { padding: 6px 10px; font-size: 0.86rem; }

.sidebar-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 29;
  backdrop-filter: blur(2px);
}
.sidebar-toggle {
  display: none;
  position: fixed;
  left: 12px;
  bottom: 16px;
  z-index: 26;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-md);
  cursor: pointer;
  align-items: center;
  justify-content: center;
}

/* ---------- 主区域 ---------- */
.main {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  padding: 22px clamp(16px, 3vw, 40px) 60px;
}
.main-auth { margin-left: 0; padding: 0; min-height: 100vh; }
.page { max-width: 1200px; margin: 0 auto; }

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}
.page-head h1 { display: flex; align-items: center; gap: 10px; }
.head-chip {
  font-size: 0.85rem;
  font-weight: 500;
  padding: 2px 10px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
}
.page-head .muted { margin: 4px 0 0; font-size: 0.85rem; }
.page-actions { display: flex; gap: 8px; }

/* ---------- 工具栏 / 搜索 ---------- */
.toolbar { margin-bottom: 18px; }
.search-form { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.search-box {
  position: relative;
  display: flex;
  align-items: center;
  flex: 1 1 320px;
  min-width: 220px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0 10px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.search-box:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.search-box .icon { width: 18px; height: 18px; color: var(--muted); }
.search-box input {
  flex: 1;
  border: 0;
  background: transparent;
  box-shadow: none;
  padding: 9px 6px;
}
.search-box input:focus { box-shadow: none; }
.search-clear { display: inline-flex; padding: 4px; color: var(--muted); }
.search-clear:hover { color: var(--text); }
.search-box input[type="search"]::-webkit-search-cancel-button { display: none; }

.sort-box {
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding-left: 8px;
}
.sort-box .icon { width: 17px; height: 17px; color: var(--muted); }
.sort-box select { border: 0; background: transparent; padding: 8px 8px 8px 2px; box-shadow: none; }
.sort-box select:focus { box-shadow: none; }

.filter-row { display: flex; align-items: center; flex-wrap: wrap; gap: 7px; margin-top: 12px; }
.filter-label { font-size: 0.78rem; color: var(--muted); margin: 0 2px 0 6px; font-weight: 600; }
.color-filters { display: flex; gap: 6px; align-items: center; }

/* ---------- 笔记卡片 ---------- */
.note-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 14px;
  align-items: start;
}

.note-card {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 148px;
  padding: 13px 14px 11px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.18s, transform 0.18s, border-color 0.18s;
  overflow: visible;
}
.note-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
/* hover 的 transform 会创建 stacking context，必须抬高当前卡片，否则后面的卡片会盖住弹出菜单 */
.note-card:hover,
.note-card:focus-within,
.note-card:has(.card-menu:not([hidden])) { z-index: 20; }
.note-card:not(.color-default) {
  background:
    linear-gradient(color-mix(in srgb, var(--dot) 11%, transparent), color-mix(in srgb, var(--dot) 5%, transparent)),
    var(--surface);
  border-color: color-mix(in srgb, var(--dot) 26%, var(--border));
}
.note-card.is-pinned { border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); }

.card-hit { position: absolute; inset: 0; border-radius: inherit; z-index: 0; }
.card-head { position: relative; z-index: 1; display: flex; align-items: flex-start; gap: 6px; margin-bottom: 4px; }
.card-title {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 1rem;
  font-weight: 650;
  overflow-wrap: anywhere;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.pin-mark { color: var(--accent); display: inline-flex; }
.pin-mark .icon { width: 14px; height: 14px; }
.card-title-link { color: inherit; }
.card-title-link:hover,
.card-title-link:focus-visible { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }
.card-tools { position: relative; z-index: 2; flex: none; }
.card-tools .icon-btn { width: 28px; height: 28px; opacity: 0.55; }
.card-tools .icon-btn:hover { opacity: 1; }
.note-card:hover .card-tools .icon-btn { opacity: 1; }

.card-preview {
  position: relative;
  z-index: 0;
  margin: 2px 0 8px;
  font-size: 0.88rem;
  line-height: 1.55;
  color: var(--text-soft);
  overflow-wrap: anywhere;
  display: -webkit-box;
  -webkit-line-clamp: 5;
  -webkit-box-orient: vertical;
  overflow: hidden;
  white-space: pre-line;
}

.card-checklist { list-style: none; margin: 2px 0 8px; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.card-checklist li { font-size: 0.86rem; color: var(--text-soft); }
.card-checklist li.is-checked span { text-decoration: line-through; color: var(--muted); }
.card-checklist .more-items { color: var(--muted); font-size: 0.8rem; padding-left: 24px; }
.check-wrap { display: flex; align-items: flex-start; gap: 7px; cursor: pointer; position: relative; z-index: 1; }
.check-wrap input {
  appearance: none;
  width: 15px;
  height: 15px;
  border: 1.5px solid var(--border-strong);
  border-radius: 4px;
  margin: 3px 0 0;
  flex: none;
  cursor: pointer;
  position: relative;
}
.check-wrap input:checked { background: var(--accent); border-color: var(--accent); }
.check-wrap input:checked::after {
  content: "";
  position: absolute;
  left: 4px;
  top: 1px;
  width: 4px;
  height: 8px;
  border-right: 2px solid #fff;
  border-bottom: 2px solid #fff;
  transform: rotate(40deg);
}
.check-wrap span { min-width: 0; overflow-wrap: anywhere; }

.check-progress { height: 3px; border-radius: 2px; background: var(--surface-2); margin: 2px 0 7px; overflow: hidden; }
.check-progress span { display: block; height: 100%; background: var(--accent); border-radius: inherit; transition: width 0.2s; }

.card-foot { position: relative; z-index: 1; margin-top: auto; padding-top: 8px; display: flex; align-items: flex-end; justify-content: space-between; gap: 8px; }
.card-meta { display: flex; flex-direction: column; gap: 2px; font-size: 0.76rem; color: var(--muted); min-width: 0; }
.card-meta .meta-folder { display: inline-flex; align-items: center; gap: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-meta .meta-folder .icon { width: 13px; height: 13px; }
.card-tags { display: flex; flex-wrap: wrap; gap: 4px; justify-content: flex-end; position: relative; z-index: 1; }
.card-tags .tag-chip { pointer-events: auto; }

.trash-actions { position: relative; z-index: 1; display: flex; align-items: center; gap: 8px; margin-top: 10px; padding-top: 9px; border-top: 1px dashed var(--border); flex-wrap: wrap; }
.trash-countdown { font-size: 0.75rem; color: var(--muted); margin-left: auto; }

/* 卡片菜单 */
.card-menu {
  position: absolute;
  top: 34px;
  right: 0;
  width: 208px;
  padding: 6px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 11px;
  box-shadow: var(--shadow-lg);
  z-index: 40;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.menu-item {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 7px 9px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--text-soft);
  font-size: 0.86rem;
  text-align: left;
  cursor: pointer;
}
.menu-item:hover { background: var(--surface-2); color: var(--text); }
.menu-item .icon { width: 16px; height: 16px; color: var(--muted); }
.menu-item.menu-danger { color: var(--danger); }
.menu-item.menu-danger .icon { color: var(--danger); }
.menu-item.menu-danger:hover { background: var(--danger-soft); }
.menu-sep { height: 1px; background: var(--border); margin: 4px 2px; }
.menu-colors { display: flex; flex-wrap: wrap; gap: 8px; padding: 6px 9px 8px; }
.menu-folder { display: flex; align-items: center; gap: 6px; padding: 4px 6px 6px; }
.menu-folder .icon { width: 15px; height: 15px; color: var(--muted); }
.menu-folder select { flex: 1; padding: 5px 7px; font-size: 0.82rem; }

/* ---------- 空状态 / 分页 ---------- */
.empty-state { text-align: center; padding: 70px 20px 60px; color: var(--muted); }
.empty-icon {
  width: 62px;
  height: 62px;
  margin: 0 auto 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--muted);
}
.empty-icon .icon { width: 28px; height: 28px; }
.empty-state h2 { color: var(--text); font-size: 1.15rem; margin-bottom: 6px; }
.empty-state p { margin: 0 auto 18px; max-width: 420px; font-size: 0.9rem; }

.pager { display: flex; align-items: center; justify-content: center; gap: 14px; margin-top: 26px; font-size: 0.86rem; }

/* ---------- 编辑器 ---------- */
.editor-page {
  max-width: 980px;
  margin: 0 auto;
  min-height: calc(100vh - 82px);
  display: flex;
  flex-direction: column;
}
.editor-head {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0 10px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.editor-head-left { display: flex; align-items: center; gap: 8px; min-width: 0; }
.editor-head-right { display: flex; align-items: center; gap: 2px; flex-wrap: wrap; }
.save-status { font-size: 0.82rem; color: var(--muted); white-space: nowrap; }
.save-status.saving { color: var(--accent); }
.save-status.error { color: var(--danger); }
.folder-select { max-width: 140px; padding: 5px 8px; font-size: 0.83rem; }
.color-popover-wrap { position: relative; }
.color-popover {
  position: absolute;
  top: 38px;
  right: 0;
  display: grid;
  grid-template-columns: repeat(5, 22px);
  gap: 9px;
  padding: 12px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  z-index: 45;
}

.title-input {
  width: 100%;
  border: 0;
  background: transparent;
  box-shadow: none;
  padding: 4px 2px;
  font-size: 1.75rem;
  font-weight: 680;
  letter-spacing: -0.02em;
  line-height: 1.3;
  border-radius: 6px;
}
.title-input::placeholder { color: var(--muted); opacity: 0.7; font-weight: 500; }
.title-input:focus { box-shadow: none; border-color: transparent; }

.editor-subline {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
  font-size: 0.79rem;
  color: var(--muted);
  padding: 2px 1px 12px;
}
.editor-subline .dot { opacity: 0.5; }
.subline-tags a { color: var(--accent); margin-right: 5px; }

.editor-tabs { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.mode-tabs { display: inline-flex; padding: 3px; gap: 2px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; }
.mode-tab {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 11px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  font-size: 0.84rem;
  cursor: pointer;
}
.mode-tab .icon { width: 15px; height: 15px; }
.mode-tab.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.autosave-hint { font-size: 0.76rem; color: var(--muted); }

.text-editor { flex: 1; display: flex; flex-direction: column; min-height: 420px; }
.md-toolbar {
  display: flex;
  align-items: center;
  gap: 1px;
  flex-wrap: wrap;
  padding: 5px 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-bottom: 0;
  border-radius: var(--radius) var(--radius) 0 0;
}
.md-toolbar button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 31px;
  height: 30px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--text-soft);
  cursor: pointer;
  font-size: 0.85rem;
  padding: 0 6px;
}
.md-toolbar button:hover { background: var(--surface-2); color: var(--text); }
.md-toolbar button .icon { width: 17px; height: 17px; }
.toolbar-spacer { flex: 1; }
.toolbar-count { font-size: 0.76rem; color: var(--muted); padding-right: 6px; white-space: nowrap; }

.editor-panes {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr;
  border: 1px solid var(--border);
  border-radius: 0 0 var(--radius) var(--radius);
  background: var(--surface);
  overflow: hidden;
  min-height: 380px;
}
.editor-panes.mode-split { grid-template-columns: 1fr 1fr; }
.editor-panes.mode-edit .md-preview { display: none; }
.editor-panes.mode-preview .note-body { display: none; }
.editor-panes.mode-split .md-preview { border-left: 1px solid var(--border); }

.note-body {
  width: 100%;
  min-height: 380px;
  border: 0;
  border-radius: 0;
  resize: none;
  padding: 18px 20px;
  font-family: var(--sans);
  font-size: 0.97rem;
  line-height: 1.75;
  background: transparent;
  box-shadow: none;
  overflow-y: auto;
}
.note-body:focus { box-shadow: none; }

.md-preview {
  padding: 16px 22px 40px;
  overflow-y: auto;
  max-height: none;
  font-size: 0.95rem;
  line-height: 1.75;
  overflow-wrap: anywhere;
}

/* Markdown 渲染样式 */
.md-preview h1, .md-preview h2, .md-preview h3,
.md-preview h4, .md-preview h5, .md-preview h6 { margin: 1.1em 0 0.45em; line-height: 1.35; }
.md-preview h1 { font-size: 1.5rem; }
.md-preview h2 { font-size: 1.3rem; }
.md-preview h3 { font-size: 1.14rem; }
.md-preview h4 { font-size: 1.02rem; }
.md-preview p { margin: 0 0 0.85em; }
.md-preview ul, .md-preview ol { margin: 0 0 0.9em; padding-left: 1.45em; }
.md-preview li { margin: 0.18em 0; }
.md-preview li .md-check { margin-right: 5px; accent-color: var(--accent); }
.md-preview blockquote {
  margin: 0 0 0.9em;
  padding: 6px 14px;
  border-left: 3px solid var(--border-strong);
  color: var(--text-soft);
  background: var(--surface-2);
  border-radius: 0 8px 8px 0;
}
.md-preview hr { border: 0; border-top: 1px solid var(--border); margin: 1.4em 0; }
.md-preview a { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }
.md-preview code {
  padding: 1px 5px;
  border-radius: 4px;
  background: var(--surface-2);
  font-size: 0.88em;
  border: 1px solid var(--border);
}
.md-preview pre.code-block {
  margin: 0 0 1em;
  padding: 13px 15px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow-x: auto;
  font-size: 0.86rem;
  line-height: 1.6;
}
.md-preview pre.code-block code { background: none; border: 0; padding: 0; }
.md-preview .md-table-wrap { overflow-x: auto; margin-bottom: 1em; }
.md-preview table.md-table { border-collapse: collapse; width: 100%; font-size: 0.88rem; }
.md-preview table.md-table th, .md-preview table.md-table td { border: 1px solid var(--border); padding: 6px 10px; }
.md-preview table.md-table th { background: var(--surface-2); font-weight: 600; }
.md-preview img { border-radius: 8px; margin: 4px 0; max-height: 520px; object-fit: contain; }
.md-preview mark { background: color-mix(in srgb, #f4d03f 45%, transparent); color: inherit; border-radius: 3px; padding: 0 2px; }

/* 清单编辑器 */
.checklist-editor { flex: 1; display: flex; flex-direction: column; min-height: 300px; }
.checklist-toolbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.check-progress-wrap { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 160px; }
.check-progress-wrap .check-progress { flex: 1; margin: 0; height: 5px; }
.check-progress-label { font-size: 0.8rem; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.check-items { display: flex; flex-direction: column; gap: 2px; }
.check-item {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 3px 2px;
  border-radius: 8px;
  background: transparent;
}
.check-item:hover { background: var(--surface-2); }
.check-item.dragging { opacity: 0.45; }
.check-toggle {
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  flex: none;
}
.check-toggle .circle {
  width: 19px;
  height: 19px;
  border-radius: 50%;
  border: 1.7px solid var(--border-strong);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.12s, border-color 0.12s;
}
.check-toggle .circle .icon { width: 12px; height: 12px; opacity: 0; color: #fff; }
.check-item.is-checked .check-toggle .circle { background: var(--accent); border-color: var(--accent); }
.check-item.is-checked .check-toggle .circle .icon { opacity: 1; }
.check-text {
  flex: 1;
  border: 0;
  background: transparent;
  box-shadow: none;
  padding: 6px 4px;
  font-size: 0.95rem;
  border-radius: 6px;
  min-width: 0;
}
.check-text:focus { box-shadow: none; border-color: transparent; }
.check-item.is-checked .check-text { text-decoration: line-through; color: var(--muted); }
.grip { width: 24px; height: 30px; display: inline-flex; align-items: center; justify-content: center; color: var(--border-strong); cursor: grab; flex: none; opacity: 0; }
.grip .icon { width: 16px; height: 16px; }
.check-item:hover .grip { opacity: 1; }
.item-del { width: 28px; height: 28px; opacity: 0; }
.item-del:hover { opacity: 1; color: var(--danger); }
.check-item:hover .item-del { opacity: 0.7; }
.check-divider {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 10px 2px 6px;
  font-size: 0.76rem;
  color: var(--muted);
}
.check-divider::before, .check-divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }

.check-add-row { display: flex; gap: 8px; margin-top: 8px; }
.check-add-row input { flex: 1; }
.checklist-foot { display: flex; align-items: center; justify-content: space-between; margin-top: 12px; color: var(--muted); font-size: 0.8rem; }

.drop-hint {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  border: 3px dashed var(--accent);
  color: var(--accent);
  font-size: 1.2rem;
  font-weight: 600;
  z-index: 50;
  pointer-events: none;
}
.drop-hint.show { display: flex; }

/* ---------- 设置 / 表格 ---------- */
.settings-page { max-width: 980px; }
.settings-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; align-items: start; }
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 18px 20px;
  box-shadow: var(--shadow-sm);
}
.panel h2 { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.panel h2 .icon { width: 19px; height: 19px; color: var(--accent); }
.panel .muted { font-size: 0.86rem; margin: 2px 0 14px; }
.panel .stack { display: flex; flex-direction: column; }
.panel .field input { width: 100%; }
.stack .btn { align-self: flex-start; margin-top: 2px; }

.stat-list { list-style: none; margin: 8px 0 10px; padding: 0; }
.stat-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 7px 0;
  border-bottom: 1px dashed var(--border);
  font-size: 0.88rem;
}
.stat-list li span { color: var(--muted); }
.stat-list li strong { font-weight: 600; font-variant-numeric: tabular-nums; }

.theme-options { display: flex; flex-wrap: wrap; gap: 7px; }
.theme-option {
  padding: 7px 13px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-soft);
  font-size: 0.86rem;
  cursor: pointer;
}
.theme-option:hover { background: var(--surface-2); }
.theme-option.active { background: var(--accent-soft); border-color: transparent; color: var(--accent); font-weight: 600; }

.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.data-table { width: 100%; border-collapse: collapse; font-size: 0.86rem; }
.data-table th, .data-table td { padding: 9px 12px; text-align: left; border-bottom: 1px solid var(--border); }
.data-table th { background: var(--surface-2); color: var(--muted); font-weight: 600; white-space: nowrap; }
.data-table tr:last-child td { border-bottom: 0; }
.data-table a { color: var(--accent); }

/* ---------- 登录 / 初始化 ---------- */
.auth-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(1200px 600px at 15% -10%, var(--accent-soft), transparent 70%),
    var(--bg);
}
.auth-card {
  width: 100%;
  max-width: 390px;
  padding: 30px 28px 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow-lg);
}
.auth-brand { display: flex; justify-content: center; margin-bottom: 12px; }
.auth-brand .brand-mark { width: 46px; height: 46px; border-radius: 13px; }
.auth-brand .brand-mark .icon { width: 25px; height: 25px; }
.auth-card h1 { text-align: center; font-size: 1.35rem; margin-bottom: 4px; }
.auth-sub { text-align: center; color: var(--muted); font-size: 0.86rem; margin: 0 0 20px; }
.auth-card .field input { width: 100%; padding: 10px 12px; }
.auth-note { margin: 16px 0 0; font-size: 0.76rem; color: var(--muted); text-align: center; }
.setup-tips { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--border); }
.setup-tips p { font-size: 0.78rem; color: var(--muted); line-height: 1.6; margin: 0 0 8px; }
.setup-tips code { font-size: 0.75rem; background: var(--surface-2); padding: 1px 4px; border-radius: 4px; }

/* ---------- 提示 ---------- */
.flash-stack { margin-bottom: 14px; display: flex; flex-direction: column; gap: 8px; }
.flash {
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 0.88rem;
  border: 1px solid transparent;
}
.flash-success { background: color-mix(in srgb, var(--success) 12%, var(--surface)); border-color: color-mix(in srgb, var(--success) 30%, transparent); color: var(--success); }
.flash-error { background: var(--danger-soft); border-color: color-mix(in srgb, var(--danger) 30%, transparent); color: var(--danger); }
.flash-info { background: var(--accent-soft); color: var(--accent); }

.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translate(-50%, 14px);
  max-width: min(90vw, 420px);
  padding: 10px 16px;
  border-radius: 10px;
  background: var(--text);
  color: var(--bg);
  font-size: 0.88rem;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 80;
  text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.is-error { background: var(--danger); color: #fff; }

/* ---------- 响应式 ---------- */
@media (max-width: 960px) {
  .main { margin-left: 0; padding: 16px 14px 80px; }
  .main-auth { padding: 0; }
  .sidebar { transform: translateX(-100%); transition: transform 0.22s ease; box-shadow: var(--shadow-lg); width: min(82vw, 300px); }
  .sidebar.open { transform: translateX(0); }
  .sidebar-close { display: inline-flex; }
  .sidebar-toggle { display: inline-flex; }
  .sidebar-backdrop[hidden] { display: none; }
  .sidebar-backdrop:not([hidden]) { display: block; }
  .note-grid { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
  .page-head { align-items: flex-start; }
  .editor-head { gap: 6px; }
  .editor-head-right .hide-sm, .hide-sm { display: none; }
  .title-input { font-size: 1.4rem; }
  .editor-panes.mode-split { grid-template-columns: 1fr; }
  .editor-panes.mode-split .md-preview { border-left: 0; border-top: 1px solid var(--border); }
  .md-toolbar { overflow-x: auto; flex-wrap: nowrap; }
  .md-toolbar button { flex: none; }
  .folder-select { max-width: 110px; }
}

@media (max-width: 560px) {
  .page-head h1 { font-size: 1.3rem; }
  .quick-actions { flex-direction: column; }
  .search-form { flex-direction: column; align-items: stretch; }
  .search-box { flex: 1 1 auto; }
  .sort-box { justify-content: space-between; }
  .sort-box select { flex: 1; }
  .note-grid { grid-template-columns: 1fr; }
  .editor-head-right { gap: 0; }
  .editor-head-right .icon-btn { width: 31px; height: 31px; }
  .btn#doneBtn { display: none; }
  .auth-card { padding: 24px 20px 20px; }
  .page-actions .btn { padding: 7px 10px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
