/* 卡片盒 · 移动端 PWA
   设计基线：深色为主（与 mac 版同一套语义色），浅色为完整另一套 token。
   一切颜色走变量；尺寸走 4 的倍数；可点区域 ≥ 44px。 */

/* ── tokens ───────────────────────────────────────────── */
:root {
  --bg: #0b0c0e;
  --bg-soft: #101216;
  --surface: #15181d;
  --surface-2: #1b1f25;
  --surface-3: #232830;
  --line: rgba(255, 255, 255, 0.075);
  --line-strong: rgba(255, 255, 255, 0.14);
  --text: #e9ecea;
  --text-2: #b6bdb9;
  --muted: #838c88;
  --faint: #5d6562;
  --accent: #12b872;
  --accent-dim: rgba(18, 184, 114, 0.14);
  --accent-line: rgba(18, 184, 114, 0.34);
  --danger: #ff6b6b;
  --danger-dim: rgba(255, 107, 107, 0.12);
  --amber: #e7b24b;
  --blue: #5b9dff;
  --purple: #b48bff;
  --wash: rgba(255, 255, 255, 0.04);
  --wash-2: rgba(255, 255, 255, 0.07);
  --shadow: 0 8px 30px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 -14px 50px rgba(0, 0, 0, 0.55);

  --r-xs: 6px;
  --r-sm: 10px;
  --r-md: 14px;
  --r-lg: 20px;
  --r-xl: 28px;

  --fs: 16px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --tab-h: 58px;
  --top-h: 54px;

  --font-ui: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", system-ui, sans-serif;
  --font-read: "New York", "Songti SC", "Noto Serif SC", Georgia, serif;
  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
}

[data-theme="light"] {
  --bg: #f7f8f7;
  --bg-soft: #ffffff;
  --surface: #ffffff;
  --surface-2: #f2f4f2;
  --surface-3: #e8ece9;
  --line: rgba(16, 30, 24, 0.09);
  --line-strong: rgba(16, 30, 24, 0.18);
  --text: #17201c;
  --text-2: #3f4b46;
  --muted: #6d7a74;
  --faint: #9aa5a0;
  --accent: #0a8f57;
  --accent-dim: rgba(10, 143, 87, 0.1);
  --accent-line: rgba(10, 143, 87, 0.3);
  --danger: #d14343;
  --danger-dim: rgba(209, 67, 67, 0.1);
  --amber: #a8741a;
  --blue: #2f6fd0;
  --purple: #7b52c9;
  --wash: rgba(16, 30, 24, 0.035);
  --wash-2: rgba(16, 30, 24, 0.06);
  --shadow: 0 8px 26px rgba(20, 40, 30, 0.1);
  --shadow-lg: 0 -14px 44px rgba(20, 40, 30, 0.14);
}

[data-font="small"] { --fs: 15px; }
[data-font="large"] { --fs: 17.5px; }

/* ── reset ─────────────────────────────────────────────── */
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: var(--fs);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
  text-rendering: optimizeLegibility;
}
h1, h2, h3, h4, p { margin: 0; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
input, textarea, select { font: inherit; color: inherit; }
a { color: var(--accent); text-decoration: none; }
svg { width: 22px; height: 22px; display: block; }
::selection { background: var(--accent-dim); }

/* 滚动条（桌面预览时才可见） */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: var(--wash-2); border-radius: 8px; }

/* ── shell ─────────────────────────────────────────────── */
#app {
  min-height: 100%;
  display: flex;
  flex-direction: column;
  max-width: 720px;
  margin: 0 auto;
  position: relative;
}

#topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  padding-top: var(--safe-top);
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: saturate(180%) blur(22px);
  -webkit-backdrop-filter: saturate(180%) blur(22px);
  border-bottom: 1px solid var(--line);
}
.topbar-inner {
  height: var(--top-h);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 12px;
}
.tb-back {
  width: 34px; height: 34px;
  display: grid; place-items: center;
  border-radius: 50%;
  color: var(--text-2);
  background: var(--wash);
  flex: none;
}
.tb-back:active { background: var(--wash-2); }
.tb-back svg { width: 19px; height: 19px; }
.tb-titles { min-width: 0; flex: 1; }
.tb-titles h1 {
  font-size: 17px;
  font-weight: 650;
  letter-spacing: 0.2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tb-titles p {
  font-size: 11.5px;
  color: var(--muted);
  margin-top: -1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tb-actions { display: flex; align-items: center; gap: 6px; flex: none; }
.tb-under { padding: 0 12px 10px; }
.tb-under:empty { display: none; }

.btn {
  height: 32px;
  padding: 0 12px;
  border-radius: var(--r-sm);
  font-size: 13px;
  font-weight: 550;
  color: var(--text-2);
  background: var(--wash);
  border: 1px solid transparent;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  transition: background 140ms var(--ease), color 140ms var(--ease);
}
.btn:active { background: var(--wash-2); }
.btn svg { width: 17px; height: 17px; }
.btn-primary { background: var(--accent); color: #04150d; font-weight: 650; }
[data-theme="light"] .btn-primary { color: #fff; }
.btn-primary:active { filter: brightness(0.92); }
.btn-ghost { background: transparent; border-color: var(--line); }
.btn-danger { background: var(--danger-dim); color: var(--danger); }
.btn-icon { width: 34px; padding: 0; justify-content: center; }
.btn[disabled], .btn:disabled { opacity: 0.45; pointer-events: none; }

#view {
  flex: 1;
  /* 底部留出 FAB 的位置，最后一张卡不会被悬浮按钮压住 */
  padding-bottom: calc(var(--tab-h) + var(--safe-bottom) + 84px);
  outline: none;
}
#view.no-tab { padding-bottom: calc(var(--safe-bottom) + 24px); }

/* ── tabbar ────────────────────────────────────────────── */
#tabbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 45;
  display: flex;
  max-width: 720px;
  margin: 0 auto;
  padding-bottom: var(--safe-bottom);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(180%) blur(22px);
  -webkit-backdrop-filter: saturate(180%) blur(22px);
  border-top: 1px solid var(--line);
  transition: transform 220ms var(--ease), opacity 180ms var(--ease);
}
#tabbar.hide { transform: translateY(110%); opacity: 0; pointer-events: none; }
.tab {
  flex: 1;
  height: var(--tab-h);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: var(--faint);
  font-size: 10.5px;
  letter-spacing: 0.3px;
  transition: color 140ms var(--ease);
}
.tab svg { width: 21px; height: 21px; }
.tab.on { color: var(--accent); }
.tab:active { color: var(--text-2); }

#fab {
  position: fixed;
  right: max(16px, calc(50vw - 344px));
  bottom: calc(var(--tab-h) + var(--safe-bottom) + 18px);
  z-index: 44;
  width: 52px; height: 52px;
  border-radius: 50%;
  display: grid; place-items: center;
  background: var(--accent);
  color: #04150d;
  box-shadow: 0 8px 22px rgba(18, 184, 114, 0.34), 0 2px 6px rgba(0, 0, 0, 0.4);
  transition: transform 160ms var(--ease), opacity 160ms var(--ease);
}
[data-theme="light"] #fab { color: #fff; }
#fab:active { transform: scale(0.94); }
#fab svg { width: 24px; height: 24px; }
#fab.hide { opacity: 0; transform: scale(0.7); pointer-events: none; }

/* ── 卡片流 ────────────────────────────────────────────── */
.searchbar {
  display: flex; align-items: center; gap: 8px;
  height: 38px;
  padding: 0 12px;
  background: var(--wash);
  border-radius: var(--r-sm);
  color: var(--muted);
}
.searchbar svg { width: 17px; height: 17px; flex: none; }
.searchbar input {
  flex: 1; min-width: 0;
  background: none; border: 0; outline: none;
  font-size: 14px;
  color: var(--text);
  appearance: none;
  -webkit-appearance: none;
}
.searchbar input::-webkit-search-cancel-button { -webkit-appearance: none; }
.searchbar input::placeholder { color: var(--faint); }
.searchbar .x { width: 22px; height: 22px; display: grid; place-items: center; color: var(--faint); font-size: 13px; }

.chips {
  display: flex;
  gap: 7px;
  overflow-x: auto;
  padding: 2px 0;
  scrollbar-width: none;
}
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none;
  height: 30px;
  padding: 0 12px;
  border-radius: 999px;
  font-size: 12.5px;
  color: var(--text-2);
  background: var(--wash);
  border: 1px solid transparent;
  display: inline-flex; align-items: center; gap: 5px;
  transition: background 140ms var(--ease), color 140ms var(--ease), border-color 140ms var(--ease);
}
.chip .n { color: var(--faint); font-size: 11px; font-variant-numeric: tabular-nums; }
.chip.on { background: var(--accent-dim); color: var(--accent); border-color: var(--accent-line); }
.chip.on .n { color: var(--accent); opacity: 0.75; }
.chip:active { background: var(--wash-2); }

.feed { padding: 4px 0 0; }
.day-sep {
  position: sticky;
  top: calc(var(--safe-top) + var(--top-h));
  z-index: 5;
  padding: 10px 14px 6px;
  font-size: 11px;
  letter-spacing: 0.6px;
  color: var(--faint);
  background: linear-gradient(var(--bg) 62%, transparent);
}
.card-row {
  display: block;
  width: 100%;
  text-align: left;
  padding: 14px 14px 15px;
  border-bottom: 1px solid var(--line);
  transition: background 120ms var(--ease);
  position: relative;
}
.card-row:active { background: var(--wash); }
.card-row .cr-title {
  font-size: 15.5px;
  font-weight: 600;
  line-height: 1.4;
  letter-spacing: 0.1px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card-row .cr-title.placeholder { color: var(--muted); font-weight: 500; font-style: italic; }
.card-row .cr-excerpt {
  margin-top: 4px;
  font-size: 13px;
  line-height: 1.6;
  color: var(--muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
}
.card-row .cr-meta {
  margin-top: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: var(--faint);
  min-width: 0;
}
.cr-meta .dot { width: 2px; height: 2px; border-radius: 50%; background: currentColor; opacity: 0.7; flex: none; }
.cr-meta .tags { display: flex; gap: 5px; overflow: hidden; white-space: nowrap; flex: 1; min-width: 0; }
.cr-meta .tag { color: var(--muted); }
.cr-meta .box {
  flex: none;
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 4px;
  background: var(--wash);
  color: var(--text-2);
  letter-spacing: 0.3px;
}
.cr-meta .box.permanent { color: var(--accent); background: var(--accent-dim); }
.cr-meta .box.literature { color: var(--blue); background: rgba(91, 157, 255, 0.12); }
.cr-meta .warn { color: var(--amber); }

.empty {
  padding: 64px 28px;
  text-align: center;
  color: var(--muted);
  font-size: 13.5px;
  line-height: 1.9;
}
.empty b { display: block; color: var(--text-2); font-size: 15px; font-weight: 600; margin-bottom: 6px; }
.empty .btn { margin-top: 16px; }

/* ── 详情 ──────────────────────────────────────────────── */
.detail { padding: 0 0 24px; }
.d-scroll { padding: 14px 16px 0; }
.d-title {
  width: 100%;
  background: none;
  border: 0;
  outline: none;
  font-size: 22px;
  font-weight: 680;
  line-height: 1.35;
  letter-spacing: -0.2px;
  padding: 2px 0 8px;
  resize: none;
  overflow: hidden;
  color: var(--text);
}
.d-title::placeholder { color: var(--faint); font-weight: 500; }
.d-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
  font-size: 11.5px;
  color: var(--faint);
}
.d-meta .sep { opacity: 0.5; }
.d-tags { display: flex; flex-wrap: wrap; gap: 5px; }
.tag-chip {
  display: inline-flex; align-items: center; gap: 4px;
  height: 23px; padding: 0 8px;
  border-radius: 5px;
  font-size: 11.5px;
  color: var(--text-2);
  background: var(--wash);
}
.tag-chip b { font-weight: 500; }
.tag-chip .x { color: var(--faint); font-size: 13px; padding: 0 1px; }
.tag-chip.add { color: var(--accent); background: var(--accent-dim); }

.seg {
  display: inline-flex;
  background: var(--wash);
  border-radius: 8px;
  padding: 2px;
  gap: 2px;
}
.seg button {
  height: 26px;
  padding: 0 11px;
  border-radius: 6px;
  font-size: 12px;
  color: var(--muted);
  transition: background 120ms var(--ease), color 120ms var(--ease);
}
.seg button.on { background: var(--surface-3); color: var(--text); }

.d-editor { padding: 16px 16px 0; }
.d-body {
  width: 100%;
  min-height: 46vh;
  background: none;
  border: 0;
  outline: none;
  resize: none;
  font-family: var(--font-read);
  font-size: 16.5px;
  line-height: 1.85;
  color: var(--text);
  padding: 0;
  caret-color: var(--accent);
}
.d-body::placeholder { color: var(--faint); font-family: var(--font-ui); font-size: 14px; }
.d-preview {
  font-family: var(--font-read);
  font-size: 16.5px;
  line-height: 1.85;
  word-break: break-word;
  padding-bottom: 40px;
}
.d-preview h1, .d-preview h2, .d-preview h3 { font-family: var(--font-ui); font-weight: 650; line-height: 1.45; margin: 22px 0 8px; }
.d-preview h1 { font-size: 20px; }
.d-preview h2 { font-size: 18px; }
.d-preview h3 { font-size: 16px; }
.d-preview p { margin: 0 0 12px; }
.d-preview ul, .d-preview ol { margin: 0 0 12px; padding-left: 22px; }
.d-preview li { margin: 3px 0; }
.d-preview blockquote {
  margin: 0 0 12px; padding: 2px 0 2px 12px;
  border-left: 2px solid var(--accent-line);
  color: var(--text-2);
}
.d-preview code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.86em;
  background: var(--wash-2);
  padding: 1.5px 5px;
  border-radius: 4px;
}
.d-preview pre {
  background: var(--surface-2);
  padding: 12px;
  border-radius: var(--r-sm);
  overflow-x: auto;
  margin: 0 0 12px;
}
.d-preview pre code { background: none; padding: 0; }
.d-preview hr { border: 0; border-top: 1px solid var(--line); margin: 20px 0; }
.d-preview a { border-bottom: 1px solid var(--accent-line); }
.d-preview mark { background: #ffe9a8; color: #16241d; border-radius: 2px; padding: 0 2px; }
.d-preview strong { font-weight: 650; }
.d-preview img { max-width: 100%; border-radius: var(--r-sm); }
.d-preview table { width: 100%; border-collapse: collapse; font-size: 13.5px; margin-bottom: 12px; }
.d-preview th, .d-preview td { border: 1px solid var(--line); padding: 6px 8px; text-align: left; }

.d-foot {
  position: fixed;
  left: 0; right: 0;
  bottom: 0;
  z-index: 42;
  max-width: 720px;
  margin: 0 auto;
  padding: 8px 14px calc(8px + var(--safe-bottom));
  display: flex;
  align-items: center;
  gap: 8px;
  background: color-mix(in srgb, var(--bg) 90%, transparent);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--line);
}
.d-foot .state { font-size: 11.5px; color: var(--faint); flex: 1; display: flex; align-items: center; gap: 6px; }
.d-foot .state .led { width: 6px; height: 6px; border-radius: 50%; background: var(--faint); }
.d-foot .state.dirty .led { background: var(--amber); }
.d-foot .state.saved .led { background: var(--accent); }
.d-foot .state.offline .led { background: var(--muted); }

.linkbox { padding: 18px 16px 0; }
.linkbox h3 { font-size: 11px; letter-spacing: 0.8px; color: var(--faint); font-weight: 600; margin-bottom: 8px; }
.linkrow {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px;
  border-radius: var(--r-sm);
  background: var(--surface);
  border: 1px solid var(--line);
  margin-bottom: 6px;
  width: 100%;
  text-align: left;
  font-size: 13.5px;
}
.linkrow:active { background: var(--surface-2); }
.linkrow .t { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.linkrow .k { font-size: 10px; color: var(--faint); flex: none; }
.linkrow svg { width: 15px; height: 15px; color: var(--faint); flex: none; }

/* ── 白板 ──────────────────────────────────────────────── */
.cv-shell { position: fixed; inset: 0; z-index: 70; background: var(--bg); display: flex; flex-direction: column; padding-top: var(--safe-top); max-width: 720px; margin: 0 auto; }
.cv-head { height: 48px; display: flex; align-items: center; gap: 8px; padding: 0 12px; border-bottom: 1px solid var(--line); flex: none; }
.cv-head .name { font-size: 14px; font-weight: 600; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cv-wrap {
  flex: 1;
  position: relative;
  overflow: hidden;
  touch-action: none;
  background-color: var(--bg);
  background-image: radial-gradient(circle, var(--wash-2) 1px, transparent 1px);
  background-size: 22px 22px;
}
.cv-stage { position: absolute; left: 0; top: 0; transform-origin: 0 0; will-change: transform; }
.cv-node {
  position: absolute;
  border-radius: var(--r-md);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  box-shadow: var(--shadow);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  touch-action: none;
  transition: border-color 140ms var(--ease), box-shadow 140ms var(--ease);
}
.cv-node.dragging { border-color: var(--accent-line); box-shadow: 0 14px 40px rgba(0, 0, 0, 0.55); }
.cv-node .nh {
  padding: 8px 10px 5px;
  font-size: 12.5px;
  font-weight: 600;
  line-height: 1.35;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.cv-node .nb {
  padding: 0 10px 10px;
  font-size: 10.5px;
  line-height: 1.5;
  color: var(--muted);
  display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden;
  flex: 1;
}
.cv-edges { position: absolute; left: 0; top: 0; width: 1px; height: 1px; overflow: visible; pointer-events: none; }
.cv-edges path { fill: none; stroke: var(--line-strong); stroke-width: 1.4; }
.cv-hud {
  position: absolute;
  right: 12px; bottom: 14px;
  display: flex; flex-direction: column; gap: 8px;
  z-index: 12;
}
.cv-hud button {
  width: 38px; height: 38px;
  border-radius: 12px;
  display: grid; place-items: center;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  border: 1px solid var(--line);
  color: var(--text-2);
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}
.cv-hint { position: absolute; left: 12px; bottom: 14px; font-size: 10.5px; color: var(--faint); background: color-mix(in srgb, var(--bg) 70%, transparent); padding: 4px 8px; border-radius: 6px; }

/* ── 重温 ──────────────────────────────────────────────── */
.rv { padding: 16px; display: flex; flex-direction: column; gap: 14px; min-height: calc(100vh - var(--top-h) - var(--tab-h) - 120px); }
.rv-progress { display: flex; gap: 4px; }
.rv-progress i { flex: 1; height: 3px; border-radius: 2px; background: var(--wash-2); transition: background 180ms var(--ease); }
.rv-progress i.done { background: var(--accent); }
.rv-progress i.on { background: var(--accent); opacity: 0.5; }
.rv-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 22px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: var(--shadow);
  flex: 1;
}
.rv-card .rv-k { font-size: 10.5px; letter-spacing: 1px; color: var(--faint); text-transform: uppercase; }
.rv-card .rv-t { font-size: 20px; font-weight: 650; line-height: 1.4; letter-spacing: -0.2px; }
.rv-card .rv-b {
  font-family: var(--font-read);
  font-size: 15.5px;
  line-height: 1.85;
  color: var(--text-2);
  white-space: pre-wrap;
  overflow-y: auto;
  flex: 1;
  max-height: 46vh;
  -webkit-mask-image: linear-gradient(#000 88%, transparent);
  mask-image: linear-gradient(#000 88%, transparent);
}
.rv-b p { margin: 0 0 10px; }
.rv-b p:last-child { margin-bottom: 0; }
.rv-b strong { font-weight: 650; color: var(--text); }
.rv-b h1, .rv-b h2, .rv-b h3 { font-family: var(--font-ui); font-size: 16px; margin: 2px 0 8px; }
.rv-b ul, .rv-b ol { margin: 0 0 10px; padding-left: 20px; }
.rv-b li { margin: 2px 0; }
.rv-b blockquote { margin: 0 0 10px; padding-left: 10px; border-left: 2px solid var(--accent-line); color: var(--muted); }
.rv-b code { font-family: ui-monospace, Menlo, monospace; font-size: 0.88em; background: var(--wash-2); padding: 1px 4px; border-radius: 4px; }

.rv-actions { display: flex; gap: 10px; }
.rv-actions .btn { flex: 1; height: 46px; justify-content: center; font-size: 14px; border-radius: var(--r-md); }
.rv-actions .btn-ok { background: var(--accent); color: #04150d; font-weight: 650; }
[data-theme="light"] .rv-actions .btn-ok { color: #fff; }
.rv-actions .btn-vague { background: var(--wash); color: var(--text-2); }

/* ── 设置 ──────────────────────────────────────────────── */
.st { padding: 6px 16px 30px; }
.st-group { margin-top: 22px; }
.st-group > h2 {
  font-size: 11px;
  letter-spacing: 1px;
  color: var(--faint);
  font-weight: 600;
  padding: 0 2px 8px;
}
.st-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  overflow: hidden;
}
.st-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 14px;
  border-bottom: 1px solid var(--line);
  width: 100%;
  text-align: left;
  min-height: 48px;
  background: none;
}
.st-row:last-child { border-bottom: 0; }
.st-row:active { background: var(--wash); }
.st-row .k { flex: 1; min-width: 0; }
.st-row .k b { display: block; font-size: 14px; font-weight: 500; }
.st-row .k small { display: block; color: var(--muted); font-size: 11.5px; line-height: 1.5; margin-top: 2px; word-break: break-all; }
.st-row .v { color: var(--muted); font-size: 13px; flex: none; max-width: 45%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.st-row .chev { color: var(--faint); font-size: 15px; flex: none; }
.st-row.danger b { color: var(--danger); }
.st-row .dotstate { width: 7px; height: 7px; border-radius: 50%; background: var(--faint); flex: none; }
.st-row .dotstate.ok { background: var(--accent); }
.st-row .dotstate.warn { background: var(--amber); }
.st-row .dotstate.off { background: var(--faint); }
.st-field { padding: 12px 14px; border-bottom: 1px solid var(--line); }
.st-field:last-child { border-bottom: 0; }
.st-field label { display: block; font-size: 11.5px; color: var(--muted); margin-bottom: 5px; }
.st-field input, .st-field select {
  width: 100%;
  height: 36px;
  padding: 0 10px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--bg-soft);
  font-size: 13.5px;
  outline: none;
}
.st-field input:focus, .st-field select:focus { border-color: var(--line-strong); background: var(--surface-2); }
.st-field .hint { font-size: 11px; color: var(--faint); margin-top: 6px; line-height: 1.6; }
.st-note {
  padding: 12px 14px;
  font-size: 12px;
  line-height: 1.75;
  color: var(--muted);
  background: var(--wash);
  border-radius: var(--r-md);
  margin-top: 8px;
}
.st-note b { color: var(--text-2); font-weight: 600; }
.st-split { display: flex; gap: 10px; padding: 12px 14px; }
.st-split .btn { flex: 1; height: 38px; justify-content: center; }
.badge-soft { font-size: 10px; padding: 1px 6px; border-radius: 4px; background: var(--wash-2); color: var(--muted); margin-left: 6px; }

/* ── sheet ─────────────────────────────────────────────── */
.sheet-root { position: fixed; inset: 0; z-index: 90; }
.sheet-backdrop {
  position: absolute; inset: 0;
  background: rgba(0, 0, 0, 0.52);
  backdrop-filter: blur(3px);
  animation: fade 160ms var(--ease);
}
.sheet {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  max-width: 720px;
  margin: 0 auto;
  background: var(--surface);
  border-radius: var(--r-xl) var(--r-xl) 0 0;
  border-top: 1px solid var(--line-strong);
  box-shadow: var(--shadow-lg);
  padding-bottom: calc(10px + var(--safe-bottom));
  animation: rise 240ms var(--ease);
  max-height: 86vh;
  display: flex;
  flex-direction: column;
}
.sheet-grip { width: 38px; height: 4px; border-radius: 2px; background: var(--wash-2); margin: 8px auto 4px; flex: none; }
.sheet-body { padding: 6px 16px 14px; overflow-y: auto; }
.sheet h3 { font-size: 15px; font-weight: 650; padding: 6px 2px 10px; }
.sheet-msg { font-size: 12.5px; color: var(--muted); line-height: 1.75; padding: 0 2px 8px; }
.st-note code, .sheet-msg code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.92em;
  background: var(--wash-2);
  padding: 1px 5px;
  border-radius: 4px;
}
.sheet-list { display: flex; flex-direction: column; }
.sheet-item {
  display: flex; align-items: center; gap: 10px;
  min-height: 48px;
  padding: 10px 2px;
  border-bottom: 1px solid var(--line);
  width: 100%; text-align: left;
  font-size: 14.5px;
}
.sheet-item:last-child { border-bottom: 0; }
.sheet-item .k { flex: 1; min-width: 0; }
.sheet-item .k small {
  display: block;
  color: var(--muted);
  font-size: 11.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sheet-item .btn { flex: none; height: 28px; padding: 0 10px; font-size: 12px; }
.sheet-item .chev { color: var(--faint); }
.sheet-item.danger { color: var(--danger); }
.sheet-item:active { background: var(--wash); }
.sheet .field { margin-top: 10px; }
.sheet .field label { display: block; font-size: 11.5px; color: var(--muted); margin-bottom: 5px; }
.sheet .field input, .sheet .field textarea {
  width: 100%; border-radius: 10px; border: 1px solid var(--line);
  background: var(--bg-soft); padding: 10px 12px; font-size: 14px; outline: none;
}
.sheet .field textarea { min-height: 96px; resize: vertical; line-height: 1.6; }
.sheet .field input:focus, .sheet .field textarea:focus { border-color: var(--line-strong); }
.sheet-actions { display: flex; gap: 10px; margin-top: 16px; }
.sheet-actions .btn { flex: 1; height: 44px; justify-content: center; font-size: 14px; border-radius: var(--r-md); }

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

/* ── toast ─────────────────────────────────────────────── */
.toast-root {
  position: fixed;
  left: 0; right: 0;
  bottom: calc(var(--tab-h) + var(--safe-bottom) + 22px);
  z-index: 100;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
  padding: 0 16px;
}
.toast {
  max-width: 460px;
  background: var(--surface-3);
  color: var(--text);
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  padding: 9px 16px;
  font-size: 12.8px;
  line-height: 1.4;
  box-shadow: var(--shadow);
  animation: toastIn 200ms var(--ease);
  text-align: center;
}
.toast.err { color: #ffd9d9; border-color: rgba(255, 107, 107, 0.4); }
.toast.ok { color: #d4ffe9; border-color: rgba(18, 184, 114, 0.4); }
@keyframes toastIn { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }

/* 顶栏细进度条（同步中） */
.tb-progress { position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; overflow: hidden; }
.tb-progress i { display: block; width: 38%; height: 100%; background: var(--accent); animation: slide 1.1s infinite var(--ease); }
@keyframes slide { 0% { transform: translateX(-100%); } 100% { transform: translateX(300%); } }

/* 宽屏（桌面预览 / iPad）：两栏留白，不拉伸卡片 */
@media (min-width: 760px) {
  body { background: var(--bg-soft); }
  #app {
    background: var(--bg);
    border-left: 1px solid var(--line);
    border-right: 1px solid var(--line);
    min-height: 100vh;
  }
  #tabbar { border-left: 1px solid var(--line); border-right: 1px solid var(--line); }
}

/* 未连云端的提示条（卡片流顶部） */
.nb {
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: calc(100% - 24px);
  margin: 10px 12px 0;
  padding: 12px 14px;
  text-align: left;
  background: var(--accent-dim);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  color: var(--text);
}
.nb:active { filter: brightness(0.97); }
.nb b { font-size: 13px; font-weight: 650; }
.nb span { font-size: 11.5px; line-height: 1.55; color: var(--text-2); }
.nb u { text-decoration-color: var(--accent); text-underline-offset: 2px; }

/* ── 写作视图 ───────────────────────────────────────────── */
.wv {
  display: flex;
  flex-direction: column;
  min-height: calc(100dvh - var(--top-h) - var(--tab-h) - var(--safe-bottom));
  padding: 0 16px;
}
.wv-title {
  border: 0;
  background: transparent;
  color: var(--text);
  font: 650 22px/1.35 var(--font-ui);
  padding: 10px 0 8px;
  width: 100%;
}
.wv-title::placeholder { color: var(--faint); font-weight: 500; }
.wv-title:focus, .wv-body:focus { outline: none; }
.wv-body {
  flex: 1;
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--text);
  font: 16.5px/1.9 var(--font-read);
  padding: 2px 0 18px;
  min-height: 240px;
  resize: none;
  overflow: hidden;
}
.wv-body::placeholder { color: var(--faint); }
.wv-foot {
  position: sticky;
  bottom: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0 14px;
  background: linear-gradient(to top, var(--bg) 72%, transparent);
}
.wv-foot #wvCount { font-size: 12px; color: var(--muted); flex: none; }
.wv-foot #wvState {
  flex: 1;
  min-width: 0;
  font-size: 11.5px;
  color: var(--faint);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#wvSave.on-card { background: var(--surface-3); color: var(--text); }

/* ── 全局图谱 ───────────────────────────────────────────── */
#view.flush { padding-bottom: 0; }
.gv {
  position: relative;
  height: calc(100dvh - var(--top-h) - var(--tab-h) - var(--safe-bottom));
  overflow: hidden;
  touch-action: none;
  background:
    radial-gradient(circle at 50% 40%, var(--wash) 0%, transparent 60%),
    var(--bg);
}
#gvCanvas { display: block; position: absolute; inset: 0; touch-action: none; }
.gv-legend {
  position: absolute;
  left: 12px;
  top: 10px;
  display: flex;
  gap: 12px;
  font-size: 11px;
  color: var(--muted);
  background: var(--wash);
  padding: 6px 11px;
  border-radius: 999px;
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}
.gv-legend span { display: inline-flex; align-items: center; }
.gv-legend .dot { width: 7px; height: 7px; border-radius: 50%; margin-right: 4px; }
.dot.perm { background: var(--accent); }
.dot.temp { background: var(--amber); }
.dot.lit { background: var(--blue); }
.gv-hint {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 14px;
  text-align: center;
  font-size: 11.5px;
  color: var(--faint);
  transition: opacity 260ms var(--ease);
}

/* ── 索引 ───────────────────────────────────────────────── */
.ix-sec { padding: 18px 16px 6px; font-size: 11.5px; color: var(--faint); letter-spacing: 0.5px; }
.ix-row {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 12px 16px;
  text-align: left;
  background: transparent;
  border-bottom: 1px solid var(--line);
  color: var(--text);
}
.ix-row:active { background: var(--wash); }
.ix-num { flex: none; width: 40px; font: 650 12px/1 var(--font-ui); color: var(--accent); }
.ix-main { flex: 1; min-width: 0; }
.ix-main b { display: block; font-size: 14.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ix-main small { display: block; color: var(--muted); font-size: 11.5px; margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ix-go { width: 13px; height: 13px; flex: none; color: var(--faint); transform: rotate(180deg); }

/* ── 每日 ───────────────────────────────────────────────── */
.dy-stats { display: flex; gap: 10px; padding: 16px 16px 6px; }
.dy-card {
  flex: 1;
  padding: 14px 10px;
  text-align: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
}
.dy-card b { display: block; font-size: 22px; font-weight: 650; letter-spacing: -0.3px; }
.dy-card span { font-size: 11px; color: var(--muted); }
.mp-actions { display: flex; gap: 8px; padding: 12px 16px; }
.mp-card .mp-actions { padding: 0; margin-top: 14px; }

/* ── 更多 ───────────────────────────────────────────────── */
.mp-card {
  margin: 14px 16px 4px;
  padding: 16px;
  border-radius: var(--r-lg);
  background: var(--surface);
  border: 1px solid var(--line);
}
.mp-cloud-top { display: flex; align-items: center; gap: 10px; }
.mp-cloud-ico { width: 22px; height: 22px; flex: none; color: var(--accent); }
.mp-card.warn .mp-cloud-ico { color: var(--amber); }
.mp-card b { font-size: 15px; font-weight: 650; }
.mp-card small { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; }
.mp-card p { margin: 10px 0 0; font-size: 12.5px; line-height: 1.62; color: var(--text-2); }
.mp-card p b { font-size: 12.5px; color: var(--text); }
.mp-group {
  margin: 12px 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  overflow: hidden;
}
.mp-row {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 13px 14px;
  background: transparent;
  border-bottom: 1px solid var(--line);
  text-align: left;
  color: var(--text);
}
.mp-row:last-child { border-bottom: 0; }
.mp-row:active { background: var(--wash); }
.mp-row svg { width: 18px; height: 18px; flex: none; color: var(--muted); }
.mp-row b { font-size: 14px; font-weight: 600; }
.mp-row small { margin-left: auto; color: var(--muted); font-size: 11.5px; text-align: right; }
.mp-foot { padding: 18px 16px 10px; text-align: center; font-size: 11px; line-height: 1.8; color: var(--faint); }
.btn.block { width: 100%; justify-content: center; }
.empty.small { padding: 26px 16px; }
.empty.small p { font-size: 13px; }

/* iOS 的坑：输入框字号 < 16px，聚焦时 Safari 会把整个页面放大。
   只针对表单控件抬高到 16px，正文编辑区（16.5px）与标题（22px）不受影响。 */
@supports (-webkit-touch-callout: none) {
  .searchbar input,
  .sheet .field input,
  .sheet .field textarea,
  .st-field input,
  .st-field select { font-size: 16px; }
}

/* 减弱动效 */
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}
