/* ==========================================================================
   墨脉 InkVein —— Web 端样式
   设计取向：商业产品质感。中性色打底 + 单一强调色，质感靠**层级 / 间距 /
   动效 / 字号节奏**做出来，不靠花哨配色。深/浅双主题切 :root[data-theme]。
   ========================================================================== */

:root {
  color-scheme: light;

  /* 三层画布：画布 → 面板 → 浮起 */
  --bg: #f6f6f5;
  --bg-soft: #fbfbfa;
  --bg-elev: #ffffff;
  --bg-sunk: #eeeeec;

  /* 文本三级 */
  --fg: #191a1e;
  --fg-dim: #5c6169;
  --fg-faint: #8b9098;

  /* 描边两级 */
  --line: #e4e3e0;
  --line-soft: #eeeeec;

  /* 品牌靛蓝：主色 / 按下 / 浅底 / 反白字 / 焦点环 */
  --accent: #4f46e5;
  --accent-hi: #4338ca;
  --accent-soft: #eef0fe;
  --accent-fg: #ffffff;
  --accent-ring: rgba(79, 70, 229, 0.26);

  --warn: #b7791f;
  --danger: #dc2626;
  --danger-soft: #fdeceb;
  --ok: #15803d;
  --ghost: #b45309;

  --r-lg: 14px;
  --r: 10px;
  --r-sm: 7px;
  --r-xs: 5px;

  --sans: system-ui, -apple-system, "Segoe UI", "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Noto Sans SC", sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
    "Liberation Mono", "Courier New", monospace;

  --sh-1: 0 1px 2px rgba(19, 20, 24, 0.06), 0 1px 1px rgba(19, 20, 24, 0.04);
  --sh-2: 0 2px 6px rgba(19, 20, 24, 0.06), 0 10px 28px -10px rgba(19, 20, 24, 0.16);
  --sh-3: 0 16px 48px -12px rgba(19, 20, 24, 0.28), 0 3px 10px rgba(19, 20, 24, 0.08);

  --ease: cubic-bezier(0.2, 0.8, 0.25, 1);
  --dur: 0.16s;
}

:root[data-theme='dark'] {
  color-scheme: dark;

  --bg: #101114;
  --bg-soft: #15171b;
  --bg-elev: #1b1e24;
  --bg-sunk: #1f232a;

  --fg: #e9ebef;
  --fg-dim: #a2a8b3;
  --fg-faint: #71788a;

  --line: #262b33;
  --line-soft: #1e222a;

  --accent: #7b8cff;
  --accent-hi: #93a1ff;
  --accent-soft: rgba(123, 140, 255, 0.14);
  --accent-fg: #0c0e14;
  --accent-ring: rgba(123, 140, 255, 0.3);

  --warn: #e5b04a;
  --danger: #ff6b6b;
  --danger-soft: rgba(255, 107, 107, 0.14);
  --ok: #4ade80;
  --ghost: #e5b04a;

  --sh-1: 0 1px 2px rgba(0, 0, 0, 0.4);
  --sh-2: 0 2px 8px rgba(0, 0, 0, 0.4), 0 12px 32px -12px rgba(0, 0, 0, 0.6);
  --sh-3: 0 20px 56px -12px rgba(0, 0, 0, 0.7), 0 4px 12px rgba(0, 0, 0, 0.4);
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  font-family: var(--sans);
  font-size: 13.5px;
  line-height: 1.6;
  color: var(--fg);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow: hidden;
}

::selection { background: var(--accent-soft); color: var(--accent-hi); }
:root[data-theme='dark'] ::selection { color: var(--fg); }

/* 细滚动条：默认的粗白条最毁质感 */
* { scrollbar-width: thin; scrollbar-color: var(--line) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--line);
  border-radius: 999px;
  border: 3px solid transparent;
  background-clip: content-box;
}
::-webkit-scrollbar-thumb:hover { background: var(--fg-faint); background-clip: content-box; }

/* 键盘可达性：只在键盘导航时出焦点环，鼠标点击不闪 */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  border-radius: var(--r-xs);
}

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

button {
  cursor: pointer;
  border: 1px solid var(--line);
  background: var(--bg-elev);
  border-radius: var(--r-sm);
  padding: 5px 11px;
  color: var(--fg);
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease),
    color var(--dur) var(--ease), box-shadow var(--dur) var(--ease), transform var(--dur) var(--ease);
}
button:hover { background: var(--bg-sunk); }
button:active { transform: translateY(0.5px); }
button:disabled { opacity: 0.55; cursor: default; transform: none; }

/* 主按钮：渐变 + 内侧高光，商业产品的"确认"手感 */
button.primary {
  background: linear-gradient(180deg, var(--accent) 0%, var(--accent-hi) 100%);
  border-color: var(--accent-hi);
  color: var(--accent-fg);
  font-weight: 600;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.18), 0 1px 3px var(--accent-ring);
}
button.primary:hover {
  background: linear-gradient(180deg, var(--accent-hi) 0%, var(--accent-hi) 100%);
}
button.primary:focus-visible { outline-offset: 2px; }

button.sm { padding: 3px 9px; font-size: 12px; border-radius: var(--r-xs); }

button.icon,
button.icon-btn {
  border-color: transparent;
  background: transparent;
  color: var(--fg-dim);
  padding: 5px 8px;
  font-size: 15px;
  line-height: 1;
  border-radius: var(--r-sm);
}
button.icon:hover,
button.icon-btn:hover { background: var(--bg-sunk); color: var(--fg); }
button.danger, button.icon-btn.danger:hover { color: var(--danger); }

button.ghost-btn {
  border-color: transparent;
  background: transparent;
  color: var(--fg-dim);
  font-size: 12px;
  padding: 4px 9px;
}
button.ghost-btn:hover { background: var(--bg-sunk); color: var(--fg); }
button.ghost-btn.danger { color: var(--danger); }
button.ghost-btn.danger:hover { background: var(--danger-soft); }

input[type='text'], input[type='url'], input[type='password'], input[type='search'], textarea, select {
  width: 100%;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: 6px 10px;
  outline: none;
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease),
    background var(--dur) var(--ease);
}
input::placeholder, textarea::placeholder { color: var(--fg-faint); }
input:hover, textarea:hover, select:hover { border-color: var(--fg-faint); }
input:focus, textarea:focus, select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-ring);
}

kbd {
  font-family: var(--mono);
  font-size: 10px;
  line-height: 1.4;
  color: var(--fg-faint);
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: var(--r-xs);
  padding: 1px 5px;
}

/* 工具类 */
.dim { color: var(--fg-dim); }
.faint { color: var(--fg-faint); }
.small { font-size: 12px; }
.mono { font-family: var(--mono); }
.grow { flex: 1; }
.row { display: flex; align-items: center; gap: 8px; }
.col { display: flex; flex-direction: column; }
.hidden { display: none !important; }
/* HTML 的 hidden 属性必须真的能藏住元素：浏览器里**作者样式会盖掉 UA 的
   `[hidden] { display: none }`**——`.setup { display: grid }` 就把登录页顶住了，
   于是登录成功后登录页关不掉（2026-09-17 上线当天踩到的真 bug）。
   自己声明一遍，别再依赖 UA 规则。 */
[hidden] { display: none !important; }

/* 进场动效：短、轻，只用来消解"突然出现"的廉价感 */
@keyframes iv-fade-up {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}
@keyframes iv-pop {
  from { opacity: 0; transform: scale(0.985) translateY(-4px); }
  to { opacity: 1; transform: none; }
}
@keyframes iv-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

/* ── 未登录 / 首次配置：一张"欢迎卡"─────────────────────────── */
.setup {
  height: 100%;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(1100px 520px at 50% -10%, var(--accent-soft), transparent 70%),
    var(--bg);
}
.setup-card {
  width: 100%;
  max-width: 440px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-3);
  padding: 30px 32px 28px;
  animation: iv-fade-up 0.36s var(--ease) both;
}
.setup-mark {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  font-size: 22px;
  font-weight: 600;
  color: #fff;
  background: linear-gradient(145deg, var(--accent) 0%, var(--accent-hi) 100%);
  border-radius: 13px;
  box-shadow: 0 6px 18px -6px var(--accent-ring), inset 0 1px 0 rgba(255, 255, 255, 0.25);
  margin-bottom: 18px;
  user-select: none;
}
.setup-card h1 {
  margin: 0 0 8px;
  font-size: 23px;
  font-weight: 700;
  letter-spacing: -0.015em;
}
.setup-card h1 .dim { font-weight: 400; font-size: 17px; letter-spacing: 0.01em; }
.setup-card > p {
  margin: 0 0 22px;
  font-size: 13px;
  color: var(--fg-dim);
  line-height: 1.7;
}
.setup-card label,
.modal label {
  display: block;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--fg-faint);
  margin: 16px 0 6px;
}
.setup-card input { padding: 9px 11px; font-size: 13.5px; }
.setup-card button.primary {
  width: 100%;
  margin-top: 20px;
  padding: 10px;
  font-size: 14px;
  border-radius: var(--r);
}
.setup-card .hint {
  font-size: 11.5px;
  color: var(--fg-faint);
  margin: 16px 0 0;
  line-height: 1.75;
  background: var(--bg-soft);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-sm);
  padding: 10px 12px;
}
.setup-card .hint code {
  background: var(--bg-sunk);
  padding: 1px 5px;
  border-radius: 4px;
  font-family: var(--mono);
  font-size: 11px;
}
.err {
  color: var(--danger);
  font-size: 12px;
  margin: 10px 0 0;
  background: var(--danger-soft);
  border-radius: var(--r-sm);
  padding: 8px 11px;
}

/* ── 应用骨架 ─────────────────────────────────────────────── */
.app { height: 100%; display: flex; flex-direction: column; }

.topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 52px;
  padding: 0 12px 0 14px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg-soft) 88%, transparent);
  backdrop-filter: blur(12px);
  flex: 0 0 auto;
  z-index: 20;
}
.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  letter-spacing: 0.01em;
  padding-right: 6px;
  user-select: none;
}
.brand-mark {
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  font-size: 14px;
  font-weight: 600;
  color: #fff;
  background: linear-gradient(145deg, var(--accent) 0%, var(--accent-hi) 100%);
  border-radius: 8px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.22);
}

.searchbox {
  flex: 1;
  max-width: 400px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  text-align: left;
  color: var(--fg-faint);
  background: var(--bg-elev);
  border-color: var(--line);
  padding: 6px 8px 6px 11px;
  border-radius: var(--r);
  font-size: 13px;
  box-shadow: var(--sh-1);
}
.searchbox::before { content: '⌕'; font-size: 15px; color: var(--fg-faint); }
.searchbox:hover { border-color: var(--fg-faint); background: var(--bg-elev); }

/* 视图切换：分段控件，比一排裸按钮更像产品 */
.views {
  display: flex;
  gap: 2px;
  padding: 3px;
  background: var(--bg-sunk);
  border-radius: var(--r);
}
.view-btn {
  border-color: transparent;
  background: transparent;
  color: var(--fg-dim);
  padding: 4px 12px;
  font-size: 12.5px;
  border-radius: var(--r-sm);
}
.view-btn:hover { background: transparent; color: var(--fg); }
.view-btn.is-on {
  background: var(--bg-elev);
  color: var(--fg);
  font-weight: 600;
  box-shadow: var(--sh-1);
}

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

.sync-pill {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  color: var(--fg-dim);
  padding: 5px 11px;
  border-radius: 999px;
  border-color: transparent;
  background: transparent;
}
.sync-pill:hover { background: var(--bg-sunk); }
.dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--fg-faint);
  flex: 0 0 auto;
  transition: background var(--dur) var(--ease);
}
.dot.ok { background: var(--ok); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 18%, transparent); }
.dot.busy { background: var(--warn); animation: iv-pulse 1.1s var(--ease) infinite; }
.dot.err { background: var(--danger); box-shadow: 0 0 0 3px color-mix(in srgb, var(--danger) 18%, transparent); }

.workspace { flex: 1; display: flex; min-height: 0; }

/* ── 左侧笔记列表 ─────────────────────────────────────────── */
.sidebar {
  width: 278px;
  flex: 0 0 auto;
  border-right: 1px solid var(--line);
  background: var(--bg-soft);
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.sidebar.is-off { display: none; }
.sidebar-head { display: flex; gap: 6px; padding: 10px 10px 8px; align-items: center; }
.sidebar-head input { flex: 1; background: var(--bg-elev); }
.sidebar-head button.primary { flex: 0 0 auto; padding: 6px 10px; font-size: 12px; border-radius: var(--r-sm); }

.tagbar {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 0 10px 9px;
  max-height: 96px;
  overflow-y: auto;
}
.tagbar:empty { display: none; }

.notelist {
  list-style: none;
  margin: 0;
  padding: 2px 8px 14px;
  overflow-y: auto;
  flex: 1;
}
.note-item {
  position: relative;
  padding: 9px 11px 10px;
  border-radius: var(--r);
  cursor: pointer;
  border: 1px solid transparent;
  margin-bottom: 2px;
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.note-item:hover { background: var(--bg-elev); border-color: var(--line); }
.note-item.is-on {
  background: var(--bg-elev);
  border-color: color-mix(in srgb, var(--accent) 35%, var(--line));
  box-shadow: var(--sh-1);
}
.note-item.is-on::before {
  content: '';
  position: absolute;
  left: 0;
  top: 12px;
  bottom: 12px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--accent);
}
.note-item .ni-title {
  font-weight: 600;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 5px;
  color: var(--fg);
}
.note-item.is-on .ni-title { color: var(--accent-hi); }
:root[data-theme='dark'] .note-item.is-on .ni-title { color: var(--accent); }
.note-item .ni-title span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.note-item .ni-meta {
  font-size: 11px;
  color: var(--fg-faint);
  display: flex;
  gap: 8px;
  margin-top: 3px;
  font-variant-numeric: tabular-nums;
}
.note-item .ni-excerpt {
  font-size: 12px;
  color: var(--fg-dim);
  margin-top: 4px;
  line-height: 1.55;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.note-item .star { color: var(--warn); font-size: 11px; }

.empty {
  padding: 34px 22px;
  text-align: center;
  color: var(--fg-faint);
  font-size: 12.5px;
  line-height: 1.7;
}
.empty::before {
  content: '◌';
  display: block;
  font-size: 26px;
  margin-bottom: 8px;
  color: var(--line);
}

/* ── 主区 ─────────────────────────────────────────────────── */
.main-pane {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg-elev);
}
.pane { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.pane-head {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 46px;
  padding: 0 20px;
  border-bottom: 1px solid var(--line);
  font-weight: 600;
  font-size: 13px;
  flex: 0 0 auto;
}
.pane-head .dim { font-weight: 400; margin-left: auto; font-size: 12px; }

/* ── 编辑器 ───────────────────────────────────────────────── */
.editor-head {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  max-width: 880px;
  margin: 0 auto;
  padding: 22px 30px 6px;
  flex: 0 0 auto;
}
.note-title {
  border: none;
  background: transparent;
  font-size: 23px;
  font-weight: 700;
  letter-spacing: -0.015em;
  padding: 2px 0;
  line-height: 1.35;
}
.note-title:hover { border: none; }
.note-title:focus { border: none; outline: none; box-shadow: none; }
.note-title::placeholder { color: var(--fg-faint); font-weight: 600; }
.editor-actions { display: flex; gap: 2px; flex: 0 0 auto; align-items: center; }
.editor-actions .ghost-btn {
  border: 1px solid var(--line);
  background: var(--bg-elev);
  padding: 4px 11px;
  border-radius: 999px;
}
.editor-actions .ghost-btn:hover { background: var(--bg-sunk); border-color: var(--fg-faint); }

.editor-body {
  flex: 1;
  min-height: 0;
  display: flex;
  position: relative;
  width: 100%;
  max-width: 880px;
  margin: 0 auto;
}
.note-body {
  flex: 1;
  width: 100%;
  border: none;
  border-radius: 0;
  resize: none;
  padding: 6px 30px 60px;
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.85;
  background: transparent;
  overflow-y: auto;
  letter-spacing: 0.005em;
}
.note-body:hover, .note-body:focus { border: none; box-shadow: none; }
.preview { flex: 1; width: 100%; overflow-y: auto; padding: 6px 30px 80px; }

.editor-foot {
  display: flex;
  gap: 16px;
  padding: 7px 30px;
  border-top: 1px solid var(--line-soft);
  font-size: 11.5px;
  color: var(--fg-faint);
  background: var(--bg-soft);
  flex: 0 0 auto;
  font-variant-numeric: tabular-nums;
}
.editor-foot .dim { color: var(--fg-faint); }
.editor-foot .dim:last-child { margin-left: auto; }
#stat-save { transition: color var(--dur) var(--ease); }

/* ── Markdown 渲染（render.js 产出）───────────────────────── */
.markdown {
  font-size: 15.5px;
  line-height: 1.85;
  color: var(--fg);
  letter-spacing: 0.005em;
}
.markdown p { margin: 0 0 1em; }
.markdown h1, .markdown h2, .markdown h3 {
  margin: 1.6em 0 0.6em;
  line-height: 1.4;
  letter-spacing: -0.01em;
  font-weight: 700;
}
.markdown h1 { font-size: 1.55em; }
.markdown h2 { font-size: 1.28em; }
.markdown h3 { font-size: 1.1em; }
.markdown h2 { padding-bottom: 0.3em; border-bottom: 1px solid var(--line-soft); }
.markdown h1:first-child, .markdown h2:first-child, .markdown h3:first-child { margin-top: 0; }
.markdown ul, .markdown ol { margin: 0 0 1em; padding-left: 1.45em; }
.markdown li { margin: 0.25em 0; }
.markdown li::marker { color: var(--fg-faint); }
.markdown blockquote {
  margin: 0 0 1em;
  padding: 10px 16px;
  border-left: 3px solid var(--accent);
  border-radius: 0 var(--r-sm) var(--r-sm) 0;
  background: var(--bg-soft);
  color: var(--fg-dim);
}
.markdown blockquote p:last-child { margin-bottom: 0; }
.markdown hr { border: none; border-top: 1px solid var(--line); margin: 1.8em 0; }
.markdown img { max-width: 100%; border-radius: var(--r-sm); box-shadow: var(--sh-1); }
.markdown table {
  border-collapse: separate;
  border-spacing: 0;
  margin: 0 0 1em;
  font-size: 13.5px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  overflow: hidden;
}
.markdown th, .markdown td { border: none; border-bottom: 1px solid var(--line-soft); padding: 7px 12px; text-align: left; }
.markdown tr:last-child td { border-bottom: none; }
.markdown th { background: var(--bg-soft); font-weight: 600; font-size: 12.5px; color: var(--fg-dim); }
.markdown tbody tr:hover { background: var(--bg-soft); }
.md-code-inline {
  font-family: var(--mono);
  font-size: 0.87em;
  background: var(--bg-sunk);
  padding: 1.5px 5px;
  border-radius: var(--r-xs);
  color: var(--fg);
}
.md-code {
  background: var(--bg-soft);
  border: 1px solid var(--line-soft);
  border-radius: var(--r);
  padding: 13px 15px;
  overflow-x: auto;
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.7;
  margin: 0 0 1em;
  white-space: pre;
}
.md-code .lang {
  display: block;
  font-size: 10px;
  color: var(--fg-faint);
  margin-bottom: 7px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
}
.md-todo { list-style: none; padding-left: 0; display: flex; align-items: flex-start; gap: 8px; margin: 0.2em 0; }
.md-todo .box {
  flex: 0 0 auto;
  width: 16px;
  height: 16px;
  margin-top: 0.35em;
  display: grid;
  place-items: center;
  border: 1.5px solid var(--line);
  border-radius: var(--r-xs);
  color: transparent;
  font-size: 11px;
  transition: all var(--dur) var(--ease);
}
.md-todo.is-done .box {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-fg);
}
.md-todo.is-done { color: var(--fg-faint); text-decoration: line-through; text-decoration-color: var(--line); }

.md-link {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid color-mix(in srgb, var(--accent) 35%, transparent);
  cursor: pointer;
  padding-bottom: 0.5px;
  transition: background var(--dur) var(--ease);
}
.md-link:hover { background: var(--accent-soft); }
.md-link.is-ghost {
  color: var(--ghost);
  border-bottom-style: dashed;
  border-bottom-color: color-mix(in srgb, var(--ghost) 45%, transparent);
}
.md-link.is-ghost:hover { background: color-mix(in srgb, var(--ghost) 12%, transparent); }
.md-tag {
  display: inline-block;
  color: var(--accent-hi);
  background: var(--accent-soft);
  border-radius: 999px;
  padding: 1px 10px;
  font-size: 0.85em;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: all var(--dur) var(--ease);
}
:root[data-theme='dark'] .md-tag { color: var(--accent); }
.md-tag:hover { background: color-mix(in srgb, var(--accent) 22%, transparent); }

/* ── 双链/标签自动补全 ────────────────────────────────────── */
.autocomplete {
  position: absolute;
  z-index: 30;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--sh-3);
  max-height: 232px;
  overflow-y: auto;
  min-width: 230px;
  padding: 5px;
  animation: iv-pop 0.14s var(--ease) both;
}
.ac-item {
  padding: 7px 10px;
  border-radius: var(--r-sm);
  cursor: pointer;
  font-size: 13px;
  display: flex;
  gap: 8px;
  align-items: center;
}
.ac-item:hover { background: var(--bg-sunk); }
.ac-item.is-on { background: var(--accent-soft); color: var(--accent-hi); font-weight: 500; }
:root[data-theme='dark'] .ac-item.is-on { color: var(--accent); }
.ac-item .ac-kind {
  margin-left: auto;
  font-size: 9.5px;
  color: var(--fg-faint);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
}

/* ── 图谱 ─────────────────────────────────────────────────── */
#graph-canvas { flex: 1; display: block; width: 100%; cursor: grab; }
#graph-canvas:active { cursor: grabbing; }
.graph-tip {
  padding: 7px 20px 9px;
  font-size: 11.5px;
  border-top: 1px solid var(--line-soft);
  background: var(--bg-soft);
  margin: 0;
}

/* ── 标签云 ───────────────────────────────────────────────── */
.tagcloud {
  padding: 22px 24px;
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  align-content: flex-start;
  overflow-y: auto;
}
.tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 14px;
  font-size: 13px;
  cursor: pointer;
  transition: all var(--dur) var(--ease);
}
.tag-chip:hover {
  border-color: var(--accent);
  color: var(--accent);
  transform: translateY(-1px);
  box-shadow: var(--sh-1);
}
.tag-chip.is-on {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent-hi);
  font-weight: 600;
}
:root[data-theme='dark'] .tag-chip.is-on { color: var(--accent); }
.tag-chip .cnt { font-size: 11px; color: var(--fg-faint); font-variant-numeric: tabular-nums; }
.tag-chip.is-on .cnt { color: inherit; opacity: 0.7; }

/* ── 今日 ─────────────────────────────────────────────────── */
.daily-list { padding: 14px 18px 40px; overflow-y: auto; }
.daily-day {
  padding: 13px 16px;
  border-radius: var(--r);
  border: 1px solid var(--line-soft);
  background: var(--bg-elev);
  margin: 0 0 10px;
  cursor: pointer;
  transition: all var(--dur) var(--ease);
}
.daily-day:hover { border-color: var(--line); background: var(--bg-soft); box-shadow: var(--sh-1); }
.daily-day .dd-date {
  font-weight: 600;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  display: flex;
  align-items: center;
  gap: 8px;
}
.daily-day .dd-date::before {
  content: '';
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  flex: 0 0 auto;
}
.daily-day .dd-line {
  font-size: 12.5px;
  color: var(--fg-dim);
  padding-left: 15px;
  border-left: 1px solid var(--line);
  margin: 6px 0 0 3px;
}

/* ── 右侧栏：反链 / 出链 / 提及 / 大纲 ────────────────────── */
.rail {
  width: 300px;
  flex: 0 0 auto;
  border-left: 1px solid var(--line);
  background: var(--bg-soft);
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.rail.is-off { display: none; }
.rail-tabs {
  display: flex;
  gap: 2px;
  padding: 4px;
  margin: 8px 10px 6px;
  background: var(--bg-sunk);
  border-radius: var(--r);
  flex: 0 0 auto;
}
.rail-tab {
  flex: 1;
  border: none;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--fg-dim);
  font-size: 12px;
  padding: 5px 0;
  font-weight: 500;
}
.rail-tab:hover { background: transparent; color: var(--fg); }
.rail-tab.is-on {
  background: var(--bg-elev);
  color: var(--fg);
  font-weight: 600;
  box-shadow: var(--sh-1);
}
.rail-body { flex: 1; overflow-y: auto; padding: 2px 10px 18px; }
.rail-item {
  padding: 9px 11px;
  border-radius: var(--r);
  cursor: pointer;
  margin-bottom: 3px;
  border: 1px solid transparent;
  transition: all var(--dur) var(--ease);
}
.rail-item:hover { background: var(--bg-elev); border-color: var(--line); box-shadow: var(--sh-1); }
.rail-item .ri-title { font-weight: 600; font-size: 13px; }
.rail-item .ri-ctx {
  font-size: 12px;
  color: var(--fg-dim);
  margin-top: 3px;
  line-height: 1.6;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.rail-item .ri-ctx mark {
  background: var(--accent-soft);
  color: var(--accent-hi);
  border-radius: 3px;
  padding: 0 2px;
}
:root[data-theme='dark'] .rail-item .ri-ctx mark { color: var(--accent); }
.rail-group {
  font-size: 10.5px;
  font-weight: 600;
  color: var(--fg-faint);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 14px 11px 6px;
}
.rail-body .empty::before { content: '◇'; }

/* ── 浮层：命令面板 / 设置 ────────────────────────────────── */
.overlay {
  position: fixed;
  inset: 0;
  background: color-mix(in srgb, #0b0c10 52%, transparent);
  backdrop-filter: blur(3px);
  display: flex;
  justify-content: center;
  padding-top: 10vh;
  z-index: 100;
  animation: iv-fade-up 0.12s var(--ease) both;
}
.palette, .modal {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-3);
  width: 100%;
  max-height: 74vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: iv-pop 0.16s var(--ease) both;
}
.palette { max-width: 560px; height: max-content; }
.modal { max-width: 500px; padding: 22px 24px 20px; overflow-y: auto; }
.palette input, .modal input { border: none; border-radius: 0; padding: 15px 18px; font-size: 15px; }
.palette input { border-bottom: 1px solid var(--line); background: transparent; }
.palette input:focus { box-shadow: none; }
.modal input {
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: 7px 11px;
  font-size: 13.5px;
  background: var(--bg-soft);
}
.palette-list { list-style: none; margin: 0; padding: 6px; overflow-y: auto; }
.palette-item {
  padding: 9px 12px;
  border-radius: var(--r-sm);
  cursor: pointer;
  display: flex;
  gap: 10px;
  align-items: center;
  font-size: 13.5px;
}
.palette-item.is-on { background: var(--accent-soft); color: var(--accent-hi); font-weight: 500; }
:root[data-theme='dark'] .palette-item.is-on { color: var(--accent); }
.palette-item .pi-kind {
  margin-left: auto;
  font-size: 9.5px;
  color: var(--fg-faint);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  font-weight: 600;
}
.palette-item .pi-sub { font-size: 11px; color: var(--fg-faint); margin-left: 8px; }

.modal h2 { margin: 0 0 4px; font-size: 17px; letter-spacing: -0.01em; }
.modal label:first-of-type { margin-top: 14px; }
.modal .stat {
  font-size: 12px;
  font-family: var(--mono);
  color: var(--fg-dim);
  background: var(--bg-soft);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-sm);
  padding: 9px 12px;
  white-space: pre-wrap;
  line-height: 1.7;
}
.modal .row { flex-wrap: wrap; }
.modal-foot {
  margin-top: 22px;
  padding-top: 16px;
  border-top: 1px solid var(--line-soft);
  display: flex;
  justify-content: flex-end;
}

/* ── Toast ────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%);
  background: color-mix(in srgb, var(--fg) 92%, transparent);
  backdrop-filter: blur(8px);
  color: var(--bg);
  padding: 9px 20px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--sh-3);
  z-index: 200;
  max-width: 80vw;
  animation: iv-fade-up 0.2s var(--ease) both;
}
.toast.err { background: var(--danger); color: #fff; }
.toast.ok { background: var(--ok); color: #fff; }

/* ── 窄屏 ─────────────────────────────────────────────────── */
@media (max-width: 1240px) {
  .rail { width: 272px; }
}
@media (max-width: 1120px) {
  .rail { display: none; }
}
@media (max-width: 900px) {
  .views { display: none; }
  .searchbox { max-width: none; }
}
@media (max-width: 760px) {
  .sidebar {
    position: absolute;
    inset: 52px auto 0 0;
    z-index: 50;
    width: 86vw;
    max-width: 320px;
    box-shadow: var(--sh-3);
  }
  .brand-name { display: none; }
  .editor-head { padding: 16px 16px 4px; }
  .note-body, .preview { padding: 6px 16px 60px; }
  .note-title { font-size: 20px; }
  .editor-foot { padding: 6px 16px; }
}

/* 打印/导出：只留正文 */
@media print {
  .topbar, .sidebar, .rail, .editor-foot { display: none !important; }
  .main-pane, .note-body, .preview { background: #fff; color: #000; }
}

/* ── 列表范围 / 排序（笔记 · 归档 · 回收站） ──────────────── */
.scope-bar, .sort-bar {
  display: flex;
  gap: 4px;
  padding: 0 10px 8px;
  flex: 0 0 auto;
}
.sort-bar { padding-bottom: 8px; }
.scope-btn, .sort-btn {
  flex: 1;
  border: 1px solid transparent;
  background: transparent;
  color: var(--fg-dim);
  font-size: 12px;
  padding: 4px 6px;
  border-radius: var(--r-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  cursor: pointer;
}
.scope-btn:hover, .sort-btn:hover { background: var(--bg-elev); color: var(--fg); }
.scope-btn.is-on {
  background: var(--bg-elev);
  border-color: var(--line);
  color: var(--fg);
  font-weight: 600;
  box-shadow: var(--sh-1);
}
.sort-btn.is-on { color: var(--accent-hi); font-weight: 600; }
:root[data-theme='dark'] .sort-btn.is-on { color: var(--accent); }
.scope-btn .cnt,
.sort-btn .cnt {
  font-size: 10.5px;
  color: var(--fg-faint);
  font-variant-numeric: tabular-nums;
}
.scope-btn .cnt:empty { display: none; }

/* 回收站里每一行的就地操作 */
.note-item .ni-acts { display: flex; gap: 4px; margin-top: 6px; }
button.ghost-btn.xs { font-size: 11px; padding: 2px 8px; border-radius: var(--r-xs); }
button.ghost-btn.xs:hover { background: var(--bg-sunk); }

/* ── 编辑器工具栏 ─────────────────────────────────────────── */
.editor-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  width: 100%;
  max-width: 880px;
  margin: 0 auto;
  padding: 0 30px 6px;
  flex: 0 0 auto;
}
.editor-tools .tool {
  min-width: 30px;
  height: 26px;
  padding: 0 8px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--fg-dim);
  border-radius: var(--r-xs);
  font-size: 12px;
  font-family: var(--mono);
  cursor: pointer;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.editor-tools .tool:hover { background: var(--bg-elev); border-color: var(--line); color: var(--fg); }
.editor-tools .tool:active { background: var(--bg-sunk); }

/* 拖入附件的落点提示 */
.editor-body.is-drop {
  outline: 2px dashed var(--accent);
  outline-offset: -8px;
  background: var(--accent-soft);
}
:root[data-theme='dark'] .editor-body.is-drop { background: color-mix(in srgb, var(--accent) 12%, transparent); }

/* 预览里的图片：别撑破阅读宽度 */
.preview img, .markdown img {
  max-width: 100%;
  height: auto;
  border-radius: var(--r-sm);
  display: block;
  margin: 10px 0;
}
.preview a.md-a, .preview a[href] { color: var(--accent-hi); text-decoration: none; border-bottom: 1px solid var(--accent-ring); }
:root[data-theme='dark'] .preview a[href] { color: var(--accent); }




