/* ============================================================
   PIM 设计系统
   深色为默认；所有颜色走变量，换肤只需改 :root
   ============================================================ */

/* 默认明亮；深色通过 html[data-theme="dark"] 覆盖同一组变量 */
:root {
  color-scheme: light;

  --bg: #f4f7fb;
  --bg-elev: #ffffff;
  --surface: #ffffff;
  --surface-2: #f2f6fb;
  --surface-3: #e6edf6;
  --line: #dfe7f1;
  --line-soft: #edf2f8;

  --text: #172033;
  --text-2: #3e4b62;
  --text-3: #68758d;
  --text-4: #97a3b7;

  --accent: #2f6bed;
  --accent-soft: rgba(47, 107, 237, .10);
  --accent-line: rgba(47, 107, 237, .32);
  --ok: #0f9d6b;
  --ok-soft: rgba(15, 157, 107, .10);
  --warn: #b7791f;
  --warn-soft: rgba(183, 121, 31, .10);
  --danger: #d64545;
  --danger-soft: rgba(214, 69, 69, .10);

  --r-sm: 8px;
  --r: 12px;
  --r-lg: 16px;
  --r-xl: 22px;

  --shadow-1: 0 1px 2px rgba(20, 40, 80, .06);
  --shadow-2: 0 12px 32px rgba(20, 40, 80, .10);
  --shadow-3: 0 24px 60px rgba(20, 40, 80, .14);

  /* 滚动条：跟随主题，别用纯黑打断整体色 */
  --scroll-thumb: rgba(23, 32, 51, .20);
  --scroll-thumb-hover: rgba(23, 32, 51, .36);

  --sidebar: 236px;
  --maxw: 1180px;
  --tabbar-h: 62px;

  --fs-xs: 11.5px;
  --fs-sm: 13px;
  --fs: 14px;
  --fs-md: 15px;
  --fs-lg: 18px;
  --fs-xl: 24px;
  --fs-2xl: 32px;
}

html[data-theme="dark"] {
  color-scheme: dark;

  --bg: #0a0c11;
  --bg-elev: #0f131b;
  --surface: #141924;
  --surface-2: #1a2130;
  --surface-3: #212a3b;
  --line: #232c3d;
  --line-soft: #1b2331;

  --text: #e9eef8;
  --text-2: #b4bed1;
  --text-3: #7f8aa0;
  --text-4: #5b6478;

  --accent: #5b8cff;
  --accent-soft: rgba(91, 140, 255, .14);
  --accent-line: rgba(91, 140, 255, .38);
  --ok: #37d39b;
  --ok-soft: rgba(55, 211, 155, .12);
  --warn: #f5a524;
  --warn-soft: rgba(245, 165, 36, .12);
  --danger: #ff6b6b;
  --danger-soft: rgba(255, 107, 107, .12);

  --shadow-1: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow-2: 0 12px 32px rgba(0, 0, 0, .45);
  --shadow-3: 0 24px 60px rgba(0, 0, 0, .55);

  --scroll-thumb: rgba(233, 238, 248, .16);
  --scroll-thumb-hover: rgba(233, 238, 248, .30);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  font-size: var(--fs);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* 数字等宽，金额列表不跳动 */
.num, .home-cell strong, .h-value, .stat-value, .acct-item strong,
.report-row, .stmt-row, .amt, table.data td.num, .kpi-value {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
}

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

h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -.01em; }

/* 滚动条跟随主题：透明确实边距，深色/浅色都不突兀 */
/* 只在没有 ::-webkit-scrollbar 的浏览器（Firefox）用标准属性，
   避免 Chromium 因标准属性接管后宽度与自定义规则不一致 */
@supports not selector(::-webkit-scrollbar) {
  html { scrollbar-color: var(--scroll-thumb) transparent; }
}
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb {
  background: var(--scroll-thumb);
  border-radius: 999px;
  border: 3px solid transparent;
  background-clip: padding-box;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--scroll-thumb-hover);
  background-clip: padding-box;
}
::-webkit-scrollbar-track { background: transparent; }

/* ============================================================
   外壳
   ============================================================ */

.app { min-height: 100dvh; display: flex; }

/* 侧边栏：仅桌面 */
.sidebar { display: none; }

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

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 10px 16px;
  background: color-mix(in srgb, var(--bg-elev) 86%, transparent);
  backdrop-filter: saturate(160%) blur(14px);
  border-bottom: 1px solid var(--line-soft);
}

.topbar-left { display: flex; align-items: center; gap: 10px; min-width: 0; }

.topbar-title {
  font-size: var(--fs-md);
  font-weight: 600;
  letter-spacing: .01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-actions { display: flex; align-items: center; gap: 8px; }

main#view {
  flex: 1;
  width: 100%;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 20px 16px calc(var(--tabbar-h) + 32px + env(safe-area-inset-bottom, 0px));
}

/* 页面宽度：三种模式都随屏幕自适应，存的是模式而不是像素宽度 */
main#view.page-wide .pe-row { max-width: none !important; }
main#view.page-full { max-width: none; }
main#view.page-full .pe-row { max-width: none !important; }
main#view.page-reading { max-width: min(860px, 100%); }
main#view.page-reading .pe-row { max-width: min(760px, 100%) !important; }

/* 配置过页面布局时，用 flex 顺序重排区块；没配置过保持原样 */
main#view.blocks-flex {
  display: flex;
  flex-direction: column;
}
main#view.blocks-flex > * { width: 100%; }

/* 底部导航：仅移动 */
.tabbar {
  position: fixed;
  z-index: 40;
  left: 0; right: 0; bottom: 0;
  display: flex;
  gap: 2px;
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom, 0px));
  background: rgba(15, 19, 27, .94);
  backdrop-filter: saturate(160%) blur(18px);
  border-top: 1px solid var(--line-soft);
}

.tabbar button {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 7px 0 5px;
  background: none;
  border: none;
  border-radius: 12px;
  color: var(--text-4);
  font-size: var(--fs-xs);
  letter-spacing: .02em;
  transition: color .16s ease, background .16s ease;
}

.tabbar button:hover { background: none; }
.tabbar button.active { color: var(--text); }
.tabbar .dot {
  width: 5px; height: 5px;
  border-radius: 50%;
  background: transparent;
  transition: background .16s ease, transform .16s ease;
}
.tabbar button.active .dot { background: var(--accent); transform: scale(1.2); }

/* ============================================================
   页面头
   ============================================================ */

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin: 4px 0 18px;
}

.page-head-text { min-width: 0; }

.eyebrow {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: var(--fs-xs);
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--text-4);
  margin-bottom: 6px;
}

.page-title { font-size: var(--fs-xl); line-height: 1.25; letter-spacing: -.02em; }

.page-desc {
  margin: 6px 0 0;
  font-size: var(--fs-sm);
  color: var(--text-3);
  max-width: 62ch;
}

.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 26px 0 10px;
}

.section-head h2,
.section-title {
  font-size: var(--fs-xs);
  font-weight: 600;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--text-3);
  margin: 0;
}

.section-head .count { color: var(--text-4); font-weight: 400; letter-spacing: 0; }

/* ============================================================
   卡片 / 网格
   ============================================================ */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 18px;
  margin-top: 14px;
  box-shadow: var(--shadow-1);
}

.card.flush { padding: 0; overflow: hidden; }
.card.tight { padding: 14px; }
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line-soft);
}
.card-head h3 { font-size: var(--fs); }
.card-body { padding: 16px 18px; }

.grid { display: grid; gap: 12px; }
.grid.two { grid-template-columns: 1fr; }
.grid.three { grid-template-columns: 1fr; }
.grid.auto { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }

.row { display: flex; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.row > * { flex: 1 1 180px; min-width: 0; }
.row.tight { flex-wrap: nowrap; }
.row.tight > * { flex: 0 0 auto; }

.stack { display: flex; flex-direction: column; gap: 10px; }
.split { display: flex; align-items: center; justify-content: space-between; gap: 12px; }

/* ============================================================
   KPI / 数字卡
   ============================================================ */

.kpi-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }

.kpi {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  padding: 15px 16px;
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  color: var(--text);
  font-weight: 400;
  transition: border-color .16s ease, background .16s ease, transform .16s ease;
}

button.kpi { cursor: pointer; }
button.kpi:hover { background: var(--surface-2); border-color: var(--surface-3); transform: translateY(-1px); }

.kpi-label { font-size: var(--fs-xs); color: var(--text-3); letter-spacing: .04em; }
.kpi-value { font-size: 22px; font-weight: 650; letter-spacing: -.02em; line-height: 1.25; }
.kpi-hint { font-size: var(--fs-xs); color: var(--text-4); }
.kpi.warn { border-color: rgba(245, 165, 36, .32); background: linear-gradient(180deg, var(--warn-soft), transparent 70%), var(--surface); }
.kpi.warn .kpi-value { color: var(--warn); }
.kpi.danger { border-color: rgba(255, 107, 107, .32); background: linear-gradient(180deg, var(--danger-soft), transparent 70%), var(--surface); }
.kpi.danger .kpi-value { color: var(--danger); }
.kpi.ok .kpi-value { color: var(--ok); }

/* ============================================================
   按钮
   ============================================================ */

button, .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font: inherit;
  font-size: var(--fs-sm);
  font-weight: 500;
  line-height: 1.2;
  color: #fff;
  background: var(--accent);
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 9px 14px;
  cursor: pointer;
  white-space: nowrap;
  transition: background .16s ease, border-color .16s ease, opacity .16s ease, transform .06s ease;
}

button:hover, .btn:hover { background: #6f9bff; text-decoration: none; }
button:active, .btn:active { transform: translateY(1px); }
button:disabled { opacity: .45; cursor: not-allowed; }

button.ghost, .btn.ghost { background: transparent; border-color: var(--line); color: var(--text-2); }
button.ghost:hover, .btn.ghost:hover { background: var(--surface-2); border-color: var(--surface-3); color: var(--text); }

button.subtle { background: var(--surface-2); border-color: var(--line); color: var(--text-2); }
button.subtle:hover { background: var(--surface-3); color: var(--text); }

button.danger { background: transparent; border-color: rgba(255, 107, 107, .4); color: var(--danger); }
button.danger:hover { background: var(--danger-soft); }

button.sm, .btn.sm { padding: 6px 11px; font-size: var(--fs-xs); border-radius: 9px; }
button.xs { padding: 4px 9px; font-size: var(--fs-xs); border-radius: 8px; }
button.block { width: 100%; }

button.icon {
  width: 34px; height: 34px;
  padding: 0;
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-3);
  border-radius: 10px;
  font-size: 16px;
}
button.icon:hover { background: var(--surface-2); color: var(--text); }

.btn-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 13px;
  font-size: var(--fs-sm);
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--text-2);
  text-decoration: none;
}
.btn-link:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }

/* ============================================================
   表单
   ============================================================ */

input, textarea, select {
  font: inherit;
  font-size: var(--fs);
  color: var(--text);
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  width: 100%;
  transition: border-color .16s ease, background .16s ease, box-shadow .16s ease;
}

input::placeholder, textarea::placeholder { color: var(--text-4); }
input:hover, textarea:hover, select:hover { border-color: var(--surface-3); }

input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--accent-line);
  background: var(--surface);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

textarea { resize: vertical; min-height: 96px; line-height: 1.65; }

select {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, #7f8aa0 50%),
    linear-gradient(135deg, #7f8aa0 50%, transparent 50%);
  background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 34px;
}

/* 通用表单布局：字段顺序用 order，整宽用 grid-column，隐藏优先级最高 */
.fk-hidden { display: none !important; }
.fk-group { display: contents; }
.fk-wire {
  height: 34px; display: flex; align-items: center; padding: 0 10px;
  border: 1px dashed var(--line); border-radius: 8px;
  color: var(--text-4); font-size: 12px; background: var(--surface-2, #f7f9fc);
}

label.field { display: block; }
label.field > span,
.field-label {
  display: block;
  font-size: var(--fs-xs);
  color: var(--text-3);
  margin-bottom: 5px;
  letter-spacing: .03em;
}

.field-grid { display: grid; grid-template-columns: 1fr; gap: 12px; }

.hint { font-size: var(--fs-xs); color: var(--text-4); margin: 6px 0 0; }
.warn-text { color: var(--warn); font-weight: 600; }

/* 草稿恢复提示：出现在编辑区上方，可一键丢弃 */
.draft-tip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0 0 10px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: 10px;
  background: var(--bg-elev);
  font-size: var(--fs-xs);
  color: var(--text-3);
}
.draft-tip button { flex: 0 0 auto; }

.inline-form {
  margin-top: 12px;
  padding: 16px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--r);
}
.inline-form input, .inline-form textarea, .inline-form select { background: var(--surface); }

.inline-check { display: flex; align-items: center; gap: 8px; font-size: var(--fs-sm); color: var(--text-2); }
.inline-check input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--accent); }

.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 12px; }
.chip {
  padding: 6px 13px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--text-2);
  font-size: var(--fs-sm);
  font-weight: 400;
}
.chip:hover { background: var(--surface-2); }
.chip.on { background: var(--accent); border-color: var(--accent); color: #fff; }

.dir-bar {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  margin-top: 12px;
  padding-bottom: 2px;
  scrollbar-width: none;
}
.dir-bar::-webkit-scrollbar { display: none; }
.dir-bar .chip { flex: 0 0 auto; }

.seg {
  display: inline-flex;
  padding: 3px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 10px;
  gap: 2px;
}
.seg button {
  background: transparent;
  border: none;
  color: var(--text-3);
  padding: 5px 12px;
  font-size: var(--fs-xs);
  border-radius: 8px;
  font-weight: 400;
}
.seg button:hover { background: transparent; color: var(--text); }
.seg button.on { background: var(--surface-3); color: var(--text); }

/* ============================================================
   列表 / 行
   ============================================================ */

.list { list-style: none; padding: 0; margin: 14px 0 0; }

.list li {
  display: flex;
  gap: 14px;
  padding: 13px 2px;
  border-bottom: 1px solid var(--line-soft);
}
.list li:last-child { border-bottom: none; }
.list time { color: var(--text-4); font-size: var(--fs-xs); flex: 0 0 108px; padding-top: 3px; }

.ev-main { flex: 1; min-width: 0; }
.ev-main strong { font-weight: 550; }
.amt { color: var(--ok); font-size: var(--fs-sm); margin-left: 6px; }
.amt.out { color: var(--danger); }
.note { margin: 4px 0 0; color: var(--text-3); font-size: var(--fs-sm); white-space: pre-wrap; word-break: break-word; }

.muted { color: var(--text-3); font-size: var(--fs-sm); }
.dim { color: var(--text-4); }
.err { color: var(--danger); font-size: var(--fs-sm); min-height: 20px; margin: 8px 0 0; }
.ok { color: var(--ok); font-size: var(--fs-sm); }
.hidden { display: none !important; }

/* 菜单列表（我的） */
.menu-list {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  overflow: hidden;
}
.menu-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  text-align: left;
  background: transparent;
  border: none;
  border-radius: 0;
  border-bottom: 1px solid var(--line-soft);
  padding: 14px 16px;
  color: var(--text);
  font-weight: 400;
}
.menu-item:last-child { border-bottom: none; }
.menu-item:hover { background: var(--surface-2); }
.menu-text { display: flex; flex-direction: column; gap: 2px; }
.menu-label { font-size: var(--fs); color: var(--text); font-weight: 500; }
.menu-desc { font-size: var(--fs-xs); color: var(--text-4); }
.menu-arrow { color: var(--text-4); font-size: 18px; }

/* ============================================================
   首页
   ============================================================ */

.quick-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 2px 0 16px;
}
.quick {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 3px;
  padding: 14px 16px;
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  color: var(--text);
  transition: border-color .15s, background .15s;
}
.quick:hover { border-color: var(--accent); background: var(--surface-2); }
.quick b { font-size: var(--fs-md); font-weight: 600; }
.quick span { font-size: var(--fs-xs); color: var(--text-4); }
@media (max-width: 480px) {
  .quick { padding: 12px; }
  .quick b { font-size: var(--fs-sm); }
}

.home-head { margin: 0 0 4px; }
.home-head .task-date { font-size: var(--fs-sm); color: var(--text-3); font-weight: 400; }

.home-hero {
  width: 100%;
  margin-top: 12px;
  padding: 22px;
  display: flex;
  justify-content: flex-start;
  align-items: baseline;
  gap: 12px;
  text-align: left;
  background: radial-gradient(120% 140% at 100% 0%, rgba(91, 140, 255, .16), transparent 60%), var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  color: var(--text);
}
.home-hero:hover {
  background: radial-gradient(120% 140% at 100% 0%, rgba(91, 140, 255, .23), transparent 60%), var(--surface-2);
}
.home-hero-num { font-size: 40px; font-weight: 700; letter-spacing: -.04em; line-height: 1; }
.home-hero-label { font-size: var(--fs-sm); color: var(--text-3); }

.home-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-top: 12px; }
.home-cell {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 3px;
  text-align: left;
  padding: 14px 15px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  color: var(--text);
  font-weight: 400;
}
.home-cell:hover { background: var(--surface-2); border-color: var(--surface-3); }
.home-cell-label { font-size: var(--fs-xs); color: var(--text-3); }
.home-cell strong { font-size: 17px; font-weight: 600; letter-spacing: -.01em; }
.home-cell.warn { border-color: rgba(245, 165, 36, .3); background: linear-gradient(180deg, var(--warn-soft), transparent 70%), var(--surface); }
.home-cell.warn strong { color: var(--warn); }

.home-quick { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 16px; }

/* 提醒：字段与任务列表对齐（提醒/说明/级别/到期/来源/操作） */
.inbox-list { margin-top: 8px; }
.inbox-table { min-width: 640px; }
.inbox-table td:first-child { min-width: 190px; }
.inbox-table .task-note { max-width: 260px; }
.inbox-table .badge { white-space: nowrap; }

/* 回流提示 */
.attention {
  margin-top: 14px;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 3px solid var(--warn);
  border-radius: var(--r);
}
.attention h3 { margin: 0 0 10px; font-size: var(--fs-sm); color: var(--warn); letter-spacing: .04em; }
.att-item { padding: 8px 0; border-top: 1px solid var(--line-soft); }
.att-item:first-of-type { border-top: none; padding-top: 0; }
.att-item strong { display: block; font-size: var(--fs); }
.att-item .muted { display: block; margin-top: 2px; }
.mini { list-style: none; margin: 8px 0 0; padding: 0; }
.mini li { font-size: var(--fs-sm); color: var(--text-2); padding: 3px 0 3px 12px; position: relative; }
.mini li:before { content: '·'; position: absolute; left: 2px; color: var(--warn); }

/* ============================================================
   任务
   ============================================================ */

.task-head { display: flex; align-items: baseline; justify-content: space-between; margin-top: 18px; }
.task-date { font-size: var(--fs-md); font-weight: 600; letter-spacing: .01em; }
.task-count { font-size: var(--fs-xs); color: var(--text-4); }

.task-section { margin-top: 14px; }
.task-section h4 {
  margin: 0 0 2px;
  font-size: var(--fs-xs);
  font-weight: 500;
  color: var(--text-4);
  letter-spacing: .1em;
  text-transform: uppercase;
}

.task-item {
  display: flex;
  align-items: flex-start;
  gap: 13px;
  padding: 14px 4px;
  border-bottom: 1px solid var(--line-soft);
  transition: opacity .24s ease, transform .24s ease;
}
.task-item:last-child { border-bottom: none; }
.task-item.overdue { border-left: 2px solid var(--warn); padding-left: 13px; }
.task-item.done { opacity: 0; transform: translateX(12px); }
.task-item.child .task-content { padding-left: 14px; border-left: 1px solid var(--line); }
.task-item.child .task-title { font-size: var(--fs-sm); color: var(--text-2); }

.task-check {
  flex: 0 0 24px;
  width: 24px; height: 24px;
  margin-top: 1px;
  padding: 0;
  border-radius: 50%;
  border: 1.5px solid var(--surface-3);
  background: transparent;
  cursor: pointer;
  transition: border-color .15s ease, background .15s ease, transform .1s ease;
}
.task-check:hover { border-color: var(--accent); background: var(--accent-soft); }
.task-check:active { transform: scale(.92); }

.task-content { flex: 1; min-width: 0; }
.task-title { font-size: var(--fs-md); line-height: 1.5; word-break: break-word; }
.task-meta { font-size: var(--fs-xs); color: var(--text-4); margin-top: 2px; }

.task-more {
  background: transparent;
  border: none;
  padding: 2px 8px;
  color: var(--text-4);
  font-size: 16px;
  line-height: 1;
  border-radius: 8px;
}
.task-more:hover { background: var(--surface-2); color: var(--text); }

.task-menu {
  position: absolute;
  z-index: 60;
  width: 176px;
  padding: 5px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--shadow-2);
}
.task-menu button {
  display: block;
  width: 100%;
  text-align: left;
  justify-content: flex-start;
  background: transparent;
  border: none;
  border-radius: 8px;
  padding: 9px 11px;
  font-size: var(--fs-sm);
  color: var(--text-2);
  font-weight: 400;
}
.task-menu button:hover { background: var(--surface-3); color: var(--text); }
.task-menu button.danger { color: var(--danger); }

.add-btn {
  width: 100%;
  margin-top: 16px;
  padding: 13px;
  background: transparent;
  border: 1px dashed var(--line);
  color: var(--text-3);
  font-weight: 400;
}
.add-btn:hover { background: var(--surface); color: var(--text); border-color: var(--surface-3); }

.rule-item { display: flex; align-items: center; gap: 10px; padding: 12px 2px; border-bottom: 1px solid var(--line-soft); }
.rule-item:last-child { border-bottom: none; }
.rule-content { flex: 1; min-width: 0; }
.rule-title { font-size: var(--fs-sm); }
.rule-meta { font-size: var(--fs-xs); color: var(--text-4); margin-top: 1px; }

/* ============================================================
   笔记
   ============================================================ */

.note-card { padding: 15px 2px; border-bottom: 1px solid var(--line-soft); }
.note-card:last-child { border-bottom: none; }
.note-card h3 { margin: 0 0 5px; font-size: var(--fs-md); }
.list .body {
  color: var(--text-3);
  font-size: var(--fs-sm);
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 120px;
  overflow: hidden;
}
.note-actions { display: flex; gap: 8px; margin-top: 10px; align-items: center; flex-wrap: wrap; }

.card-list { margin-top: 8px; border-top: 1px solid var(--line-soft); }
.card-row { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line-soft); }
.card-row:last-child { border-bottom: none; }
.card-row-front { flex: 1; font-size: var(--fs-sm); color: var(--text-2); word-break: break-word; }
.card-row-front.dim { color: var(--text-4); text-decoration: line-through; }
.card-block { border-bottom: 1px solid var(--line-soft); }
.card-block:last-child { border-bottom: none; }
.card-block .card-row { border-bottom: none; }

/* 主体 */
.entity-list { margin-top: 8px; }
.entity-item { display: flex; align-items: center; gap: 10px; padding: 10px 2px; border-bottom: 1px solid var(--line-soft); }
.entity-item:last-child { border-bottom: none; }
.entity-name { flex: 1; font-size: var(--fs); }
.entity-name.dim { color: var(--text-4); text-decoration: line-through; }
.entity-tag {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 7px;
  border-radius: 6px;
  background: var(--accent-soft);
  color: #9dbbff;
  font-size: var(--fs-xs);
  font-weight: 400;
}

/* ============================================================
   复习
   ============================================================ */

.review-head { display: flex; gap: 16px; align-items: baseline; }
.review-head .num { font-size: 30px; font-weight: 650; letter-spacing: -.03em; }

.qcard {
  display: flex;
  flex-direction: column;
  justify-content: center;
  text-align: center;
  min-height: 220px;
  margin-top: 16px;
  padding: 44px 22px 34px;
  background: radial-gradient(120% 120% at 50% 0%, rgba(91, 140, 255, .07), transparent 70%), var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-xl);
}
.qcard .q { font-size: 19px; line-height: 1.55; white-space: pre-wrap; }
.qcard .a {
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px dashed var(--line);
  color: var(--text-2);
  white-space: pre-wrap;
}
.qcard .hint { color: var(--text-4); font-size: var(--fs-sm); }

.rate { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 14px; }
.rate button { padding: 12px 6px; font-size: var(--fs-sm); }
.rate .r1 { background: #a03535; }
.rate .r1:hover { background: #b03c3c; }
.rate .r2 { background: #96692a; }
.rate .r2:hover { background: #a67431; }
.rate .r3 { background: #3a6fd8; }
.rate .r3:hover { background: #487ce6; }
.rate .r4 { background: #27855c; }
.rate .r4:hover { background: #2d9468; }
.rate small { display: block; font-size: 10.5px; opacity: .82; margin-top: 2px; font-weight: 400; }

/* 卡片管理：筛选 chip、表格与编辑弹层 */
.qcard-edit {
  position: absolute;
  left: 12px;
  top: 10px;
  padding: 3px 10px;
  font-size: var(--fs-xs);
  font-weight: 500;
  color: var(--text-3);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  cursor: pointer;
}
.qcard-edit:hover { color: var(--text); border-color: var(--surface-3); }

.ct-facets { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 12px; }
.ct-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  font-size: var(--fs-xs);
  font-weight: 500;
  color: var(--text-3);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  cursor: pointer;
}
.ct-chip span { color: var(--text-4); font-variant-numeric: tabular-nums; }
.ct-chip:hover { color: var(--text); border-color: var(--surface-3); }
.ct-chip.on { color: var(--text); background: var(--accent-soft); border-color: transparent; }
.ct-chip.on span { color: var(--text-2); }

.ct-table td { vertical-align: top; }
.ct-front { max-width: 460px; }
.ct-q { font-size: var(--fs-sm); color: var(--text); line-height: 1.45; }
.ct-a { font-size: 12px; line-height: 1.45; margin-top: 2px; }
.ct-pager { display: flex; align-items: center; justify-content: center; gap: 10px; margin-top: 12px; }
.ce-preview {
  margin-top: 12px;
  padding: 12px 14px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r);
  font-size: var(--fs-sm);
  line-height: 1.6;
}


.empty { text-align: center; padding: 48px 16px; color: var(--text-4); }
.empty strong { display: block; color: var(--text-2); font-size: var(--fs-md); margin-bottom: 4px; }

/* ============================================================
   账本
   ============================================================ */

.acct-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(158px, 1fr)); gap: 10px; }
.acct-item {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  padding: 12px 13px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--r);
}
.acct-item strong { font-size: 17px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; font-weight: 600; letter-spacing: -.01em; }
.acct-item.credit { cursor: pointer; border-color: rgba(91, 140, 255, .22); }
.acct-item.credit:hover { background: var(--surface); }
.acct-sub { font-size: var(--fs-xs); color: var(--text-4); }
.acct-arch {
  position: absolute;
  top: 5px; right: 5px;
  padding: 2px 6px;
  background: transparent;
  border: none;
  color: var(--text-4);
  font-size: var(--fs-xs);
  line-height: 1;
  border-radius: 6px;
}
.acct-arch:hover { color: var(--danger); background: var(--danger-soft); }

.report-row {
  display: flex;
  gap: 12px;
  align-items: baseline;
  padding: 10px 2px;
  border-bottom: 1px solid var(--line-soft);
  font-size: var(--fs-sm);
}
.report-row:last-child { border-bottom: none; }
.report-month { width: 66px; flex: 0 0 66px; color: var(--text-2); }

.stmt-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 11px 0;
  border-bottom: 1px solid var(--line-soft);
}
.stmt-row:last-child { border-bottom: none; }
.stmt-main { font-size: var(--fs-sm); }
.stmt-meta { font-size: var(--fs-xs); color: var(--text-3); white-space: nowrap; }

.due-tag {
  display: inline-block;
  margin-left: 4px;
  padding: 1px 7px;
  border-radius: 6px;
  background: var(--warn-soft);
  color: var(--warn);
  font-size: var(--fs-xs);
}

.budget-item { margin-top: 14px; }
.budget-head { display: flex; justify-content: space-between; align-items: baseline; font-size: var(--fs-sm); color: var(--text-2); }
.budget-line { display: flex; justify-content: space-between; align-items: baseline; font-size: var(--fs-sm); margin-bottom: 6px; }

.bar { height: 6px; border-radius: 4px; background: var(--surface-3); overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: 4px; background: var(--accent); transition: width .3s ease; }
.bar.warn > i { background: var(--warn); }
.bar.danger > i { background: var(--danger); }

/* ============================================================
   健康
   ============================================================ */

.health-head { display: flex; align-items: baseline; justify-content: space-between; margin-top: 18px; }
.h-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-top: 14px; }
.h-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  min-height: 88px;
  padding: 14px;
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  color: var(--text);
  font-weight: 400;
}
.h-card:hover { background: var(--surface-2); border-color: var(--surface-3); }
.h-card.wide { grid-column: 1 / -1; }
.h-name { font-size: var(--fs-xs); color: var(--text-3); }
.h-value { font-size: 21px; font-weight: 600; letter-spacing: -.01em; }
.h-value.small { font-size: var(--fs-md); font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.h-unit { font-size: var(--fs-xs); color: var(--text-4); font-weight: 400; }
.h-bar { width: 100%; height: 5px; border-radius: 3px; background: var(--surface-3); overflow: hidden; margin-top: 5px; }
.h-bar i { display: block; height: 100%; border-radius: 3px; background: linear-gradient(90deg, var(--accent), #7fa8ff); transition: width .3s ease; }

.trend-row { display: flex; gap: 14px; padding: 9px 2px; border-bottom: 1px solid var(--line-soft); font-size: var(--fs-sm); color: var(--text-2); }
.trend-row:last-child { border-bottom: none; }
.trend-day { color: var(--text-4); width: 46px; flex: 0 0 46px; }

/* ============================================================
   表格
   ============================================================ */

.table-wrap { overflow-x: auto; margin: 0 -2px; }
table.data { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
table.data th {
  text-align: left;
  font-weight: 500;
  font-size: var(--fs-xs);
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--text-4);
  padding: 9px 10px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
table.data td { padding: 11px 10px; border-bottom: 1px solid var(--line-soft); color: var(--text-2); }
table.data tr:last-child td { border-bottom: none; }
table.data td.num, table.data th.num { text-align: right; }
table.data tbody tr:hover { background: var(--surface-2); }

/* ============================================================
   徽标 / 状态
   ============================================================ */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: var(--fs-xs);
  font-weight: 500;
  background: var(--surface-3);
  color: var(--text-2);
  white-space: nowrap;
}
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.danger { background: var(--danger-soft); color: var(--danger); }
.badge.info { background: var(--accent-soft); color: #9dbbff; }

/* ============================================================
   锁屏
   ============================================================ */

.lock-wrap {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 18px;
  background: radial-gradient(70% 55% at 50% 0%, rgba(91, 140, 255, .13), transparent 65%), var(--bg);
}

.lock-card {
  width: 100%;
  max-width: 372px;
  padding: 30px 26px;
  text-align: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-3);
}

.lock-mark {
  width: 46px; height: 46px;
  margin: 0 auto 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 14px;
  background: linear-gradient(145deg, #5b8cff, #3b62d8);
  color: #fff;
  font-weight: 700;
  font-size: 19px;
  letter-spacing: -.02em;
  box-shadow: 0 8px 24px rgba(59, 98, 216, .35);
}

.lock-card h1 { font-size: 19px; margin-bottom: 6px; }
.lock-card .muted { display: block; margin-bottom: 20px; }

/* ============================================================
   提示 / 弹层
   ============================================================ */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%) translateY(10px);
  z-index: 90;
  max-width: 86vw;
  padding: 11px 16px;
  text-align: center;
  background: var(--surface-3);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: var(--fs-sm);
  box-shadow: var(--shadow-2);
  opacity: 0;
  pointer-events: none;
  transition: opacity .18s ease, transform .18s ease;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.sheet-mask {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  /* 不做毛玻璃、不做入场动画：打开要即时，blur 在低配/移动端掉帧非常明显 */
  background: rgba(4, 6, 10, .62);
}

.sheet {
  width: 100%;
  max-width: 560px;
  max-height: 88dvh;
  overflow-y: auto;
  padding: 20px 20px calc(20px + env(safe-area-inset-bottom, 0px));
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--r-xl) var(--r-xl) 0 0;  box-shadow: var(--shadow-3);
}

.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.sheet-head h2 { font-size: var(--fs-lg); }

@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes slide-up { from { transform: translateY(18px); opacity: .6; } to { transform: translateY(0); opacity: 1; } }

/* ============================================================
   Markdown 正文
   ============================================================ */

.md { font-size: var(--fs-sm); color: var(--text-2); line-height: 1.7; word-break: break-word; }
.md p { margin: 0 0 .55em; }
.md p:last-child { margin-bottom: 0; }
.md h1, .md h2, .md h3, .md h4, .md h5, .md h6 {
  margin: .9em 0 .4em;
  color: var(--text);
  font-size: var(--fs-md);
  letter-spacing: -.01em;
}
.md h1 { font-size: 21px; }
.md h2 { font-size: var(--fs-lg); }
.md h6 { font-size: var(--fs-sm); color: var(--text-3); }
.md ul, .md ol { margin: .35em 0 .65em; padding-left: 1.3em; }
.md li { margin: .15em 0; }
.md code {
  padding: 1px 5px;
  border-radius: 5px;
  background: var(--surface-3);
  border: 1px solid var(--line);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: .92em;
  color: var(--text);
}
[data-theme="dark"] .md code { background: rgba(130, 150, 190, .16); border-color: transparent; color: #e8eefb; }
.md pre {
  margin: .6em 0;
  padding: 12px 14px;
  border-radius: var(--r);
  background: var(--bg);
  border: 1px solid var(--line);
  overflow-x: auto;
}
.md pre code { padding: 0; background: none; font-size: 12.5px; line-height: 1.6; }
.md blockquote {
  margin: .6em 0;
  padding: 4px 0 4px 12px;
  border-left: 2px solid var(--surface-3);
  color: var(--text-3);
}
.md hr { margin: 1em 0; border: none; border-top: 1px solid var(--line); }
.md a { color: var(--accent); }
/* 正文图片：不撑破容器，保持可点放大（点击由浏览器默认行为处理） */
/* 只有编辑器的可视化区可点图片（改尺寸/编辑），阅读页保持普通图片 */
.md-wysiwyg img[data-attach-id] { cursor: pointer; }
.md img, .nb-doc-body img {
  display: block;
  max-width: 100%;
  height: auto;
  margin: .6em 0;
  border-radius: 8px;
  background: var(--surface-3);
}

/* 正文附件卡片：默认收拢，展开才加载内容 */
.attach-card {
  margin: .6em 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-2);
  overflow: hidden;
}
.attach-card > summary {
  padding: 8px 12px;
  cursor: pointer;
  font-size: 12.5px;
  color: var(--text-2);
  list-style: none;
  display: flex;
  align-items: center;
  gap: 6px;
}
.attach-card > summary::-webkit-details-marker { display: none; }
.attach-card > summary::before {
  content: "▸";
  color: var(--text-4);
  font-size: 11px;
  transition: transform .15s;
}
.attach-card[open] > summary::before { transform: rotate(90deg); }
.attach-body {
  padding: 4px 12px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.attach-body img { max-width: 100%; border-radius: 8px; }
.attach-frame {
  width: 100%;
  height: 520px;
  border: 0;
  border-radius: 8px;
  background: var(--surface-3);
}
.attach-video { max-width: 100%; border-radius: 8px; }
.attach-text {
  max-height: 280px;
  overflow: auto;
  margin: 0;
  padding: 10px;
  border-radius: 8px;
  background: var(--bg);
  font-size: 12px;
  line-height: 1.6;
}
.attach-body audio { width: 100%; }
.md.clamp { max-height: 8.4em; overflow: hidden; position: relative; }
.md.clamp::after {
  content: '';
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 2.4em;
  background: linear-gradient(transparent, var(--surface));
}

/* ============================================================
   日历
   ============================================================ */

.cal {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 3px;
  margin-top: 12px;
}

.cal-w {
  padding: 4px 0;
  text-align: center;
  font-size: 11px;
  color: var(--text-4);
}

.cal-d {
  position: relative;
  aspect-ratio: 1;
  padding: 0;
  background: transparent;
  border: none;
  border-radius: 10px;
  color: var(--text-3);
  font-size: 13px;
  font-weight: 400;
}

.cal-d:hover { background: var(--surface-2); color: var(--text); }
.cal-d.has { color: var(--text); font-weight: 600; }
.cal-d.today { box-shadow: inset 0 0 0 1px var(--accent-line); }
.cal-d.on { background: var(--accent); color: #fff; }
.cal-d.on i { background: #fff; }
.cal-d i {
  position: absolute;
  left: 50%;
  bottom: 5px;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--accent);
  transform: translateX(-50%);
}

/* ============================================================
   响应式：桌面侧栏
   ============================================================ */

@media (min-width: 980px) {
  .tabbar { display: none; }

  main#view { padding: 26px 30px 56px; }

  .sidebar {
    position: sticky;
    top: 0;
    align-self: flex-start;
    display: flex;
    flex-direction: column;
    width: var(--sidebar);
    height: 100dvh;
    flex: 0 0 var(--sidebar);
    padding: 18px 12px 14px;
    background: var(--bg-elev);
    border-right: 1px solid var(--line-soft);
  }

  .side-brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 16px; }

  .side-mark {
    width: 32px; height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    background: linear-gradient(145deg, #5b8cff, #3b62d8);
    color: #fff;
    font-weight: 700;
    font-size: 14px;
    letter-spacing: -.02em;
  }

  .side-brand-text { display: flex; flex-direction: column; line-height: 1.2; }
  .side-brand-text b { font-size: var(--fs); font-weight: 600; letter-spacing: .01em; }
  .side-brand-text span { font-size: 10.5px; color: var(--text-4); letter-spacing: .12em; text-transform: uppercase; }

  .side-nav { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; }

  .side-group {
    margin: 14px 8px 5px;
    font-size: 10.5px;
    letter-spacing: .14em;
    text-transform: uppercase;
    color: var(--text-4);
    font-weight: 500;
  }

  .side-link {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 10px;
    width: 100%;
    padding: 8px 10px;
    background: transparent;
    border: none;
    border-radius: 9px;
    color: var(--text-3);
    font-size: var(--fs-sm);
    font-weight: 400;
    text-align: left;
  }

  .side-link:hover { background: var(--surface); color: var(--text); }
  .side-link.active { background: var(--accent-soft); color: #c8d8ff; }
  .side-link .glyph { width: 18px; text-align: center; font-size: 14px; opacity: .9; }
  .side-link .tail { margin-left: auto; font-size: var(--fs-xs); color: var(--text-4); }
  .side-link.active .tail { color: #9dbbff; }

  .side-foot {
    padding: 12px 8px 4px;
    border-top: 1px solid var(--line-soft);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
  }
  .side-foot .who { font-size: var(--fs-xs); color: var(--text-4); }

  .topbar { padding: 14px 30px; }
  .topbar-title { font-size: var(--fs-lg); letter-spacing: -.01em; }

  .grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .kpi-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .home-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .h-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .field-grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }

  .sheet-mask { align-items: center; }
  .sheet { border-radius: var(--r-xl); }
}

@media (min-width: 1280px) {
  .page-title { font-size: 27px; }
}

@media (max-width: 420px) {
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .home-hero-num { font-size: 34px; }
}

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

/* ============================================================
   笔记三栏：笔记本 / 列表 / 正文
   ============================================================ */

.nb-layout {
  display: grid;
  grid-template-columns: var(--nb-cols, 232px 330px minmax(0, 1fr));
  margin-top: 4px;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--surface);
  overflow: hidden;
  min-height: calc(100vh - 220px);
}

.nb-side {
  border-right: 1px solid var(--line);
  background: var(--surface-2);
  padding: 10px 12px 12px;
  overflow: auto;
}
.nb-side-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 0 2px 8px;
  font-size: 11.5px;
  color: var(--text-4);
  letter-spacing: .03em;
}
.nb-collapse {
  width: 26px; height: 26px;
  display: inline-flex; align-items: center; justify-content: center;
  border: 0; border-radius: 7px;
  background: transparent; color: var(--text-3);
  font: inherit; font-size: 17px; line-height: 1;
  cursor: pointer;
}
.nb-collapse:hover { background: var(--surface-3); color: var(--text); }
.nb-side-search input {
  width: 100%;
  height: 34px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 12.5px;
}
.nb-side-block { margin-top: 14px; }
.nb-sec {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 6px 6px;
  font-size: 11.5px;
  color: var(--text-4);
  letter-spacing: .02em;
}
.nb-sec .icon { width: 22px; height: 22px; font-size: 15px; }

.nb-nav, .nb-dir, .nb-tag {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 7px 8px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text-2);
  font: inherit;
  font-size: 13px;
  text-align: left;
  cursor: pointer;
}
.nb-nav:hover, .nb-dir:hover, .nb-tag:hover { background: var(--surface-3); }
.nb-nav.on, .nb-dir.on, .nb-tag.on { background: var(--accent-soft); color: var(--text); }
.nb-dir i { width: 12px; height: 12px; border-radius: 3px; flex: 0 0 auto; }
.nb-dir span:first-of-type { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nb-count { margin-left: auto; font-size: 11.5px; color: var(--text-4); }
.nb-tag { font-size: 12.5px; }
.nb-tag span { margin-left: auto; color: var(--text-4); font-size: 11px; }

.nb-list-col {
  display: flex;
  flex-direction: column;
  min-width: 0;
  border-right: 1px solid var(--line);
}
.nb-list-body {
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1;
}
.nb-list-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  padding: 13px 10px 8px 14px;
}
.nb-list-head h2 { margin: 0; font-size: 15px; font-weight: 600; }
#nbCount { font-size: 11.5px; }

.nb-list {
  list-style: none;
  margin: 0;
  padding: 0 8px 12px;
  overflow: auto;
  flex: 1;
}
.nb-item {
  display: flex;
  gap: 10px;
  padding: 11px 10px;
  border-bottom: 1px solid var(--line-soft);
  border-radius: 10px;
  cursor: pointer;
}
.nb-item:hover { background: var(--surface-2); }
.nb-item.on { background: var(--accent-soft); }
.nb-item-main { min-width: 0; flex: 1; }
.nb-item-title { display: flex; align-items: center; gap: 5px; font-size: 13.5px; color: var(--text); }
.nb-item-title b {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-weight: 600;
}
.nb-pin { color: var(--accent); font-size: 8px; }
.nb-star { color: var(--warn); font-size: 11px; }
.nb-item-ex {
  margin: 4px 0 0;
  font-size: 12px;
  color: var(--text-3);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.nb-item-foot {
  margin-top: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--text-4);
}
.nb-item-tags { display: flex; gap: 4px; overflow: hidden; }
.nb-mini-tag { background: var(--surface-3); border-radius: 4px; padding: 0 4px; }
.nb-thumb {
  width: 48px;
  height: 48px;
  flex: 0 0 auto;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--line);
}

.nb-detail { min-width: 0; display: flex; flex-direction: column; overflow: auto; }
.nb-detail-bar {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  row-gap: 6px;
  gap: 6px;
  padding: 9px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}
.nb-bar-sep { width: 1px; height: 18px; background: var(--line); margin: 0 4px; }
.nb-bar-title { font-size: 13px; color: var(--text-3); }
.nb-doc { padding: 22px 28px 40px; max-width: 840px; margin: 0 auto; }
.nb-doc h1 {
  margin: 0 0 8px;
  font-size: 26px;
  line-height: 1.3;
  letter-spacing: -.01em;
}
.nb-doc-meta { display: flex; gap: 12px; font-size: 12px; color: var(--text-4); margin-bottom: 10px; }
.nb-doc-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.nb-doc-tag {
  padding: 2px 9px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface-2);
  color: var(--text-3);
  font: inherit;
  font-size: 11.5px;
  cursor: pointer;
}
.nb-doc-body { font-size: 15px; line-height: 1.75; }
.nb-doc-body h1, .nb-doc-body h2, .nb-doc-body h3,
.nb-doc-body h4, .nb-doc-body h5, .nb-doc-body h6 {
  margin: .9em 0 .4em;
  color: var(--text);
  line-height: 1.35;
  letter-spacing: -.01em;
}
.nb-doc-body h1 { font-size: 21px; }
.nb-doc-body h2 { font-size: 18px; }
.nb-doc-body h3 { font-size: 16px; }
.nb-doc-body h4 { font-size: 15px; }
.nb-doc-body h5 { font-size: 14px; color: var(--text-2); }
.nb-doc-body h6 { font-size: 13px; color: var(--text-3); }
.nb-empty { padding: 44px 24px; text-align: center; color: var(--text-3); }
.nb-empty strong { display: block; margin-bottom: 6px; color: var(--text-2); }

.nb-editor { padding: 16px 20px 40px; }
.nb-title-input {
  width: 100%;
  padding: 6px 0;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 22px;
  font-weight: 600;
}
.nb-editor-tools { display: flex; align-items: center; gap: 8px; margin-top: 10px; }
.nb-body-input {
  width: 100%;
  min-height: 46vh;
  margin-top: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 14.5px;
  line-height: 1.7;
  resize: vertical;
}
#nbBack { display: none; }

@media (max-width: 1180px) {
  .nb-layout { grid-template-columns: 200px 290px minmax(0, 1fr); }
  .nb-doc { padding: 20px 20px 36px; }
}

@media (max-width: 980px) {
  .nb-layout { grid-template-columns: 1fr; min-height: calc(100vh - 190px); }
  .nb-collapse { display: none; }
  .nb-layout [data-nbcollapse] { display: none !important; }
  .nb-layout.side-closed .nb-side-body,
  .nb-layout.list-closed .nb-list-body { display: flex; }
  .nb-side { display: none; }
  .nb-detail { display: none; }
  .nb-layout.show-detail .nb-list-col { display: none; }
  .nb-layout.show-detail .nb-detail { display: flex; }
  #nbBack { display: inline-flex; }
  .nb-doc { padding: 18px 16px 32px; }
  .nb-doc h1 { font-size: 21px; }
  .nb-editor { padding: 12px 12px 32px; }
}

/* 三栏收拢：列宽收到 38px 只留一个展开按钮 */
.nb-layout.side-closed .nb-side { padding: 8px 0; display: flex; justify-content: center; overflow: hidden; }
.nb-layout.side-closed .nb-side-head { padding: 0; justify-content: center; }
.nb-layout.side-closed .nb-side-head span,
.nb-layout.side-closed .nb-side-body { display: none; }
.nb-layout.list-closed .nb-list-head { padding: 10px 0; justify-content: center; }
.nb-layout.list-closed .nb-list-head > div,
.nb-layout.list-closed .nb-list-body { display: none; }

/* 正文全屏：详情栏覆盖整个视口，Esc 退出 */
.nb-layout.detail-full {
  position: fixed;
  inset: 0;
  z-index: 60;
  margin: 0;
  border: 0;
  border-radius: 0;
  grid-template-columns: 1fr;
  min-height: 100vh;
  height: 100vh;
  background: var(--surface);
}
.nb-layout.detail-full .nb-side,
.nb-layout.detail-full .nb-list-col { display: none; }
.nb-layout.detail-full .nb-detail { display: flex; }
.nb-layout.detail-full .nb-doc {
  max-width: none; width: 100%; margin: 0;
  padding: clamp(20px, 4vw, 56px) clamp(20px, 5vw, 72px) 64px;
}
.nb-layout.detail-full .nb-editor {
  max-width: none; width: 100%; margin: 0;
  padding: clamp(16px, 3vw, 36px) clamp(20px, 5vw, 72px) 48px;
}
.nb-layout.detail-full .nb-body-input,
.nb-layout.detail-full .md-input,
.nb-layout.detail-full .md-wysiwyg,
.nb-layout.detail-full .md-render { min-height: calc(100vh - 320px); }
.nb-layout.detail-full [data-nbcollapse] { display: none !important; }
.nb-layout.detail-full .md-editor[data-mode="split"] .md-body { height: calc(100vh - 300px); }

/* 专注：只留正文，隐藏标题与字段区 */
.nb-editor.focus-mode > [data-fk="title"],
.nb-editor.focus-mode > .field-grid { display: none !important; }
body.nb-locked { overflow: hidden; }

/* 通用 Markdown 编辑器：Markdown / 可视化 / 肝胆相照（分屏） */
.md-editor { margin-top: 2px; }
.md-modes { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.md-modes button {
  height: 30px; padding: 0 10px;
  border: 1px solid transparent; border-radius: 8px;
  background: transparent; color: var(--text-3);
  font: inherit; font-size: 12.5px; cursor: pointer;
}
.md-modes button:hover { background: var(--surface-3); color: var(--text); }
.md-modes button.on { background: var(--surface-3); color: var(--text); border-color: var(--line); }
.md-modes [hidden] { display: none !important; }
.md-modes-gap { flex: 1; }
.md-body {
  display: flex; align-items: stretch;
  margin-top: 8px;
  border: 1px solid var(--line); border-radius: 10px;
  background: var(--surface); overflow: hidden;
}
.md-pane { min-width: 0; display: none; }
.md-input {
  width: 100%; min-height: 46vh; padding: 12px;
  border: 0; outline: none; background: transparent;
  color: var(--text); font: inherit; font-size: 14px; line-height: 1.7;
  resize: vertical;
}
.md-wysiwyg { flex: 1; min-height: 46vh; padding: 12px 14px; outline: none; }
.md-render { flex: 1; min-height: 46vh; padding: 12px 16px; overflow: auto; }
.md-gutter { flex: 0 0 7px; background: var(--line); cursor: col-resize; }
body.md-dragging { cursor: col-resize; user-select: none; }

.md-editor[data-mode="markdown"] .md-source-pane { display: flex; flex-direction: column; flex: 1; }
.md-editor[data-mode="visual"] .md-visual-pane { display: flex; flex-direction: column; flex: 1; }
.md-editor[data-mode="split"] .md-source-pane {
  display: flex; flex-direction: column; flex: 0 0 var(--md-ratio, 50%);
}
.md-editor[data-mode="split"] .md-preview-pane {
  display: flex; flex-direction: column; flex: 1 1 0;
  border-left: 1px solid var(--line);
}
/* 分屏时两栏各自内部滚动，便于滚动联动 */
.md-editor[data-mode="split"] .md-body { height: max(46vh, 380px); }
.md-editor[data-mode="split"] .md-pane { height: 100%; }
.md-editor[data-mode="split"] .md-input { height: 100%; min-height: 0; resize: none; }
.md-editor[data-mode="split"] .md-render { height: 100%; min-height: 0; }
.md-editor[data-mode="split"] .md-preview-pane .md-render { border-left: 0; }
.md-editor[data-mode="split"][data-swapped="1"] .md-body { flex-direction: row-reverse; }
.md-editor[data-mode="split"][data-swapped="1"] .md-preview-pane {
  border-left: 0; border-right: 1px solid var(--line);
}

/* Markdown 工具栏 */
.md-toolbar {
  display: flex; flex-wrap: wrap; gap: 3px;
  margin-top: 10px; padding: 5px;
  border: 1px solid var(--line); border-radius: 10px;
  background: var(--surface-2);
}
.md-toolbar button {
  min-width: 30px; height: 28px; padding: 0 8px;
  border: 0; border-radius: 6px;
  background: transparent; color: var(--text-2);
  font: inherit; font-size: 12.5px; cursor: pointer;
}
.md-toolbar button:hover { background: var(--surface-3); color: var(--text); }

/* 笔记页显示模式 */
.nb-layout.mode-reading { grid-template-columns: 1fr; min-height: calc(100vh - 150px); }
.nb-layout.mode-reading .nb-side,
.nb-layout.mode-reading .nb-list-col { display: none; }
.nb-layout.mode-reading .nb-detail { display: flex; }
.nb-layout.mode-reading .nb-doc { max-width: 760px; margin: 0 auto; width: 100%; }
.nb-layout.no-side { grid-template-columns: 330px minmax(0, 1fr); }
.nb-layout.no-side .nb-side { display: none; }
.nb-layout.no-list { grid-template-columns: 232px minmax(0, 1fr); }
.nb-layout.no-list .nb-list-col { display: none; }
.nb-layout.no-side.no-list { grid-template-columns: 1fr; }
main#view.nb-full { padding: 0; max-width: none; }
main#view.nb-full .nb-layout {
  border-radius: 0; border-left: 0; border-right: 0;
  min-height: calc(100vh - 100px);
}
@media (max-width: 980px) {
  .nb-layout.mode-reading { grid-template-columns: 1fr; }
  .nb-layout.mode-reading .nb-detail { display: flex; }
}

/* 时间线工具条：筛选 + 搜索，窄屏自动换行，避免按钮溢出边框 */
.tl-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.tl-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  min-width: 0;
  flex: 1 1 auto;
}
.tl-filters select {
  max-width: 180px;
  min-width: 110px;
}
.tl-search {
  display: flex;
  gap: 6px;
  align-items: center;
  min-width: 0;
  flex: 1 1 220px;
}
.tl-search input {
  flex: 1 1 auto;
  min-width: 0;
}
.tl-search button {
  flex: 0 0 auto;
}

/* 只读 Markdown 渲染（事件备注等），与编辑器里的 .md-body 区分 */
.md-doc { font-size: 13px; line-height: 1.65; color: var(--text); }
.md-doc p { margin: 0 0 6px; }
.md-doc h4, .md-doc h5, .md-doc h6 { margin: 10px 0 4px; font-size: 13.5px; }
.md-doc ul, .md-doc ol { margin: 4px 0 6px; padding-left: 20px; }
.md-doc li { margin: 2px 0; }
.md-doc blockquote {
  margin: 6px 0; padding: 4px 10px;
  border-left: 3px solid var(--line); color: var(--text-3);
}
.md-doc code {
  background: var(--surface-3); padding: 1px 4px;
  border-radius: 4px; font-size: 12px;
}
.md-doc pre {
  background: var(--surface-3); padding: 8px 10px;
  border-radius: 8px; overflow: auto; margin: 6px 0;
}
.md-doc pre code { background: none; padding: 0; }
.md-doc a { color: #5b8cff; text-decoration: underline; }
.md-doc hr { border: 0; border-top: 1px solid var(--line); margin: 10px 0; }

/* ============================================================
   CRM
   ============================================================ */

.crm-kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.crm-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin: 6px 0 10px; }
.crm-toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin: 2px 0 10px; }
.crm-toolbar input { flex: 1 1 220px; width: auto; min-width: 160px; max-width: 360px; }
.crm-toolbar select { flex: 0 0 auto; width: auto; min-width: 140px; }
.crm-count { margin-left: auto; font-size: var(--fs-xs); color: var(--text-4); }

.crm-table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.crm-table { width: 100%; border-collapse: collapse; min-width: 780px; }
.crm-table th { text-align: left; font-size: var(--fs-xs); font-weight: 500; color: var(--text-4); padding: 9px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.crm-table td { padding: 10px 12px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
.crm-table tbody tr { cursor: pointer; }
.crm-table tbody tr:hover { background: var(--surface-2); }
.crm-table tbody tr:last-child td { border-bottom: 0; }
.crm-name { font-size: var(--fs); font-weight: 600; }
.crm-sub { font-size: var(--fs-xs); color: var(--text-4); margin-top: 2px; }
.crm-level { display: inline-block; min-width: 22px; text-align: center; padding: 1px 7px; border-radius: 6px; font-size: var(--fs-xs); border: 1px solid var(--line); color: var(--text-2); }
.crm-level.lv-A { color: var(--ok); border-color: rgba(46, 160, 103, .35); background: rgba(46, 160, 103, .10); }
.crm-level.lv-B { color: var(--accent); border-color: var(--accent-line); background: var(--accent-soft); }
.crm-overdue { color: var(--danger); font-size: var(--fs-xs); }
.crm-row-act { text-align: right; white-space: nowrap; }
.crm-row-act button + button { margin-left: 6px; }

.crm-empty { text-align: center; padding: 36px 12px; border: 1px dashed var(--line); border-radius: 12px; }
.crm-empty p { margin: 0 0 6px; }
.crm-empty p:first-child { font-size: 14px; font-weight: 600; }
.crm-empty button { margin-top: 10px; }

.crm-detail-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 14px; flex-wrap: wrap; }
.crm-detail-name { font-size: 17px; font-weight: 650; }
.crm-detail-acts { display: flex; gap: 6px; flex-wrap: wrap; }
.crm-metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin: 14px 0 4px; }
.crm-metric { background: var(--surface-2); border: 1px solid var(--line-soft); border-radius: 10px; padding: 8px 10px; }
.crm-metric .num { font-size: 15px; font-weight: 600; margin-top: 2px; }
.crm-detail-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr); gap: 18px; }
.crm-section { font-size: var(--fs-xs); color: var(--text-4); letter-spacing: .04em; margin: 16px 0 6px; }

.crm-contact { display: flex; align-items: center; gap: 8px; padding: 7px 0; border-bottom: 1px solid var(--line-soft); }
.crm-contact:last-child { border-bottom: 0; }
.crm-contact-name { flex: 1; font-size: 13px; }
.crm-avatar { width: 24px; height: 24px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; background: var(--accent-soft); color: var(--accent); font-size: 11px; }
.crm-role { font-size: var(--fs-xs); color: var(--text-3); border: 1px solid var(--line); border-radius: 6px; padding: 1px 6px; }

.crm-tl { display: grid; grid-template-columns: 44px minmax(0, 1fr); gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line-soft); }
.crm-tl:last-child { border-bottom: 0; }
.crm-tl-date { font-size: var(--fs-xs); color: var(--text-4); padding-top: 2px; font-variant-numeric: tabular-nums; }
.crm-tl-type { font-size: var(--fs-xs); padding: 1px 6px; border-radius: 5px; background: var(--surface-2); border: 1px solid var(--line-soft); color: var(--text-2); }
.crm-tl-extra { font-size: 11.5px; color: var(--text-4); margin-top: 3px; }

.crm-opp-kpis { margin: 0 0 12px; }
.crm-board { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 6px; align-items: flex-start; }
.crm-opp-col { flex: 1; min-width: 210px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; padding: 9px; display: flex; flex-direction: column; gap: 8px; }
.crm-opp-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; font-size: 13px; }
.crm-opp-head span { font-size: 11.5px; }
.crm-opp-card { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 9px 10px; }
.crm-opp-title { font-size: 13px; font-weight: 600; line-height: 1.4; word-break: break-word; }
.crm-opp-meta { display: flex; flex-wrap: wrap; gap: 4px 10px; margin-top: 5px; font-size: 11.5px; color: var(--text-4); }
.crm-opp-acts { display: flex; gap: 6px; margin-top: 8px; }

@media (max-width: 900px) {
  .crm-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .crm-detail-grid { grid-template-columns: 1fr; }
  .crm-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

.crm-bar-right { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.crm-width { display: inline-flex; align-items: center; gap: 4px; }
.crm-width .dim { font-size: var(--fs-xs); }
.crm-width button { height: 26px; padding: 0 8px; font-size: var(--fs-xs); border-radius: 7px; border: 1px solid var(--line); background: transparent; color: var(--text-3); cursor: pointer; }
.crm-width button.on { background: var(--accent-soft); border-color: var(--accent-line); color: var(--accent); }
.crm-th { cursor: pointer; user-select: none; white-space: nowrap; }
.crm-th:hover { color: var(--text-2); }
.crm-th.is-sorted { color: var(--accent); }
.crm-sort-mark { display: inline-block; margin-left: 3px; font-size: 9px; vertical-align: 1px; }
.crm-tl-click { cursor: pointer; border-radius: 8px; padding-left: 4px; padding-right: 4px; margin-left: -4px; margin-right: -4px; }
.crm-tl-click:hover { background: var(--surface-2); }
.crm-kv-list { margin-top: 12px; }
.crm-kv { padding: 6px 0; border-bottom: 1px solid var(--line-soft); }
.crm-kv:last-child { border-bottom: 0; }
.crm-tags { display: flex; flex-wrap: wrap; gap: 6px; }

/* 条件显示的字段：用类而不是行内样式，避免被表单布局重置 */
.ev-hide { display: none !important; }

/* 任务标题/看板卡片：可点开详情 */
[data-open-task] { cursor: pointer; }
.task-content[data-open-task]:hover .task-title { color: var(--accent); }

/* 任务列表：表格布局，和 CRM 客户表同一套观感 */
.task-table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.task-table { width: 100%; border-collapse: collapse; min-width: 760px; }
.task-table th { text-align: left; font-size: var(--fs-xs); font-weight: 500; color: var(--text-4); padding: 9px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.task-table td { padding: 10px 12px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
.task-table tbody tr[data-open-task] { cursor: pointer; }
.task-table tbody tr[data-open-task]:hover { background: var(--surface-2); }
.task-table .task-title { font-size: var(--fs); font-weight: 600; }
.task-table .task-sub { font-size: var(--fs-xs); color: var(--text-4); margin-top: 2px; }
.task-table .task-group td { background: var(--surface-2); color: var(--text-3); font-size: var(--fs-xs); padding: 6px 12px; }
.task-table .task-row-act { text-align: right; white-space: nowrap; }
.task-table .task-row-act button + button { margin-left: 6px; }

/* ============================================================
   日记：左（日历 + 当天活动） / 右（新建或详情） 1:3
   ============================================================ */

.diary-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 3fr);
  gap: 16px;
  align-items: start;
}
.diary-left { min-width: 0; }

/* 右栏常驻吸顶：左侧条目再多，详情始终贴在视口顶部；
   内容比视口高时右栏自己滚，换详情会重置到顶部 */
.diary-side {
  min-width: 0;
  position: sticky;
  top: 66px;
  align-self: start;
  max-height: calc(100dvh - 78px);
  overflow-y: auto;
  overscroll-behavior: contain;
}

.diary-top-btn {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 45;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text-2);
  box-shadow: var(--shadow-1);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
}
.diary-top-btn:hover { color: var(--accent); border-color: var(--accent-line); }

.diary-act-list { padding: 6px 12px; }
.diary-act {
  display: flex; align-items: center; gap: 10px; width: 100%;
  text-align: left; background: transparent; border: 0;
  border-bottom: 1px solid var(--line-soft); padding: 9px 2px;
  color: inherit; font: inherit; cursor: pointer;
}
.diary-act:last-child { border-bottom: 0; }
.diary-act:hover { background: var(--surface-2); }
.diary-act-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.diary-act-main b { font-size: 13px; font-weight: 600; }
.diary-act-main .dim { font-size: 11.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.diary-act-time { font-size: 11.5px; white-space: nowrap; }

.diary-side-sub { margin: 10px 0 0; font-size: 12px; }
.diary-fields .split { padding: 6px 0; border-bottom: 1px solid var(--line-soft); gap: 12px; }
.diary-fields .split:last-child { border-bottom: 0; }

@media (max-width: 980px) {
  .diary-layout { grid-template-columns: 1fr; }
  /* 窄屏上下堆叠，吸顶会让左栏永远被压在下面，改回普通布局 */
  .diary-side { position: static; max-height: none; overflow: visible; }
}

/* 首页待办主卡：展开 / 收起当天待办 */
.home-hero-wrap { min-width: 0; }
.home-hero-caret {
  margin-left: auto;
  color: var(--text-4);
  font-size: 16px;
  transition: transform .15s ease;
}
.home-hero-wrap .home-hero.open .home-hero-caret { transform: rotate(180deg); }
.home-hero-tasks {
  margin-top: 8px;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--surface);
  overflow: hidden;
}
.home-hero-task {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 0 10px 0 0;
  border-bottom: 1px solid var(--line-soft);
}
.home-hero-task-open {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex: 1 1 auto;
  min-width: 0;
  padding: 9px 14px;
  background: transparent;
  border: 0;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.home-hero-task:last-child { border-bottom: 0; }
.home-hero-task:hover { background: var(--surface-2); }
.home-hero-task-title {
  font-size: 13px;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* 日志右栏工具条：按钮多时换行，避免被挤出可视区 */
.diary-side .nb-detail-bar { flex-wrap: wrap; row-gap: 6px; }
.diary-side .nb-detail-bar > button { flex: 0 0 auto; }
.diary-side .nb-bar-title { min-width: 0; }
.diary-bar-gap { flex: 1 1 auto; min-width: 4px; }

/* 一键收拢左侧栏 */
.diary-layout.side-collapsed { grid-template-columns: minmax(0, 1fr); }
.diary-layout.side-collapsed .diary-left { display: none; }

/* 正文全屏：整页覆盖，Esc 退出 */
body.diary-full-lock { overflow: hidden; }
.diary-layout.editor-full {
  position: fixed;
  inset: 0;
  z-index: 65;
  display: flex;
  flex-direction: column;
  grid-template-columns: minmax(0, 1fr);
  padding: 12px 18px 18px;
  background: var(--bg);
  overflow-y: auto;
}
.diary-layout.editor-full .diary-left { display: none; }
.diary-layout.editor-full .diary-side {
  position: static;
  flex: 1;
  align-self: stretch;
  width: 100%;
  min-height: 0;
  display: flex;
  flex-direction: column;
  max-height: none;
  overflow: visible;
}
/* 正文一路撑到视口底部：专注隐藏标题/字段后不留空白 */
.diary-layout.editor-full #dCard,
.diary-layout.editor-full #deForm,
.diary-layout.editor-full #deForm > [data-fk="body"],
.diary-layout.editor-full #dMdEditor {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.diary-layout.editor-full #dMdEditor .md-editor {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.diary-layout.editor-full #dMdEditor .md-body {
  flex: 1;
  height: auto;
  min-height: 240px;
}
.diary-layout.editor-full #dMdEditor .md-input,
.diary-layout.editor-full #dMdEditor .md-wysiwyg,
.diary-layout.editor-full #dMdEditor .md-render { min-height: 0; }
.diary-layout.editor-full #dMdEditor .md-editor:not([data-mode="split"]) .md-input {
  flex: 1;
  height: auto;
  resize: none;
}

/* 右栏内容不要横向溢出，工具条按钮必须留在可视区内 */
.diary-side { overflow-x: hidden; }
.diary-side .nb-detail-bar { min-width: 0; }
.diary-side .nb-bar-title {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* 日志详情：引用与当天记录折叠 */
.diary-extra-fold { margin: 6px 18px 16px; border-top: 1px solid var(--line-soft); }
.diary-extra-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 10px 0 6px;
  background: none;
  border: 0;
  color: var(--text-3);
  font: inherit;
  font-size: 12.5px;
  text-align: left;
  cursor: pointer;
}
.diary-extra-toggle:hover { color: var(--text); }
.diary-extra-caret { margin-left: auto; font-size: 12px; transition: transform .15s ease; }
.diary-extra-toggle.open .diary-extra-caret { transform: rotate(180deg); }

/* ============================================================
   正文内联引用：链接 / 悬停卡 / 选择器 / 反向链接
   ============================================================ */

.ref-link {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px dashed color-mix(in srgb, var(--accent) 45%, transparent);
  cursor: pointer;
}
.ref-link:hover { border-bottom-style: solid; }
.ref-link.ref-missing { color: var(--text-4); border-bottom-color: var(--line); text-decoration: line-through; }

.ref-peek {
  position: fixed;
  z-index: 80;
  width: 260px;
  padding: 10px 12px;
  background: var(--bg-elev, var(--surface));
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--shadow-1);
  pointer-events: none;
}
.ref-peek-title { font-size: 13px; font-weight: 600; }
.ref-peek-sub { font-size: 11.5px; color: var(--text-4); margin-top: 2px; }
.ref-peek-row { display: flex; gap: 8px; font-size: 11.5px; margin-top: 5px; }
.ref-peek-row .dim { flex: 0 0 auto; }

.ref-list { margin-top: 10px; max-height: 52vh; overflow-y: auto; }
.ref-pick, .ref-back {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 9px 2px;
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--line-soft);
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.ref-pick:last-child, .ref-back:last-child { border-bottom: 0; }
.ref-pick:hover, .ref-back:hover { background: var(--surface-2); }
.ref-pick-main, .ref-back-main {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex: 1;
}
.ref-pick-main b, .ref-back-main { font-size: 13px; font-weight: 600; }
.ref-pick-main .dim { font-size: 11.5px; color: var(--text-4); }

/* 通用主体选择器：已选栏 + 候选（打勾即选中），左右各一半 */
@media (max-width: 640px) {
  .ent-multi { grid-template-columns: minmax(0, 1fr); }
}

.ent-multi {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 8px;
  align-items: start;
}
.ent-side { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.ent-selected {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 6px 8px;
  background: var(--surface-2);
  max-height: 180px;
  overflow-y: auto;
}
.ent-picked-head { font-size: 11.5px; color: var(--text-4); padding: 2px 0 4px; }
.ent-empty { margin: 2px 0; font-size: 12px; }
.ent-pick {
  display: flex;
  align-items: center;
  gap: 7px;
  width: 100%;
  padding: 6px 4px;
  background: transparent;
  border: 0;
  border-radius: 7px;
  color: inherit;
  font: inherit;
  font-size: 13px;
  text-align: left;
  cursor: pointer;
}
.ent-pick:hover { background: var(--surface-3, var(--surface-2)); }
.ent-pick.on { color: var(--accent); }
.ent-tick {
  flex: 0 0 14px;
  width: 14px;
  text-align: center;
  font-size: 12px;
  color: var(--accent);
}
.ent-pick-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ent-cands { max-height: 190px; overflow-y: auto; border: 1px solid var(--line-soft); border-radius: 10px; padding: 4px 6px; }

.ent-current {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
  font-size: 12px;
}
.ent-current b { font-weight: 600; color: var(--text); }

/* 主体多选：已选压成单行（分号分隔、× 删除），候选改成下拉 */
.ent-multi { align-items: center; }
.ent-selected {
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-height: none;
  padding: 7px 10px;
}
.ent-tag {
  display: inline;
  padding: 2px 1px;
  border: 0;
  background: none;
  color: var(--accent);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}
.ent-tag:hover { text-decoration: line-through; }
.ent-tag i { font-style: normal; margin-left: 3px; opacity: .55; font-size: 11px; }
.ent-sep { color: var(--text-4); }

.ent-combo { position: relative; display: flex; align-items: center; gap: 6px; }
.ent-combo input { flex: 1 1 auto; min-width: 0; }
.ent-toggle {
  flex: 0 0 auto;
  width: 30px;
  height: 30px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text-3);
  cursor: pointer;
  transition: transform .15s ease;
}
.ent-toggle.open { transform: rotate(180deg); }
.ent-cands {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 4px);
  z-index: 32;
  max-height: 240px;
  overflow-y: auto;
  padding: 4px 6px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--shadow-1);
}

/* 笔记页「需要关注」：不再占版面，悬停副标题才出现 */
.page-desc.has-attention {
  display: inline-block;
  cursor: help;
  border-bottom: 1px dashed var(--line);
}
.attention.attention-pop {
  position: fixed;
  z-index: 82;
  width: 340px;
  max-width: calc(100vw - 24px);
  max-height: 60vh;
  overflow-y: auto;
  margin: 0;
  padding: 12px 14px;
  background: var(--bg-elev, var(--surface));
  box-shadow: var(--shadow-1);
}
.attention.attention-pop h3 { margin: 0 0 8px; font-size: 12.5px; }

/* 人情：按人物聚合的卡片 */
.gift-card {
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--surface);
  margin-top: 12px;
  overflow: hidden;
}
.gift-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line-soft);
  flex-wrap: wrap;
}
.gift-avatar {
  flex: 0 0 32px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 14px;
}
.gift-who { min-width: 0; }
.gift-who b { font-size: 14px; }
.gift-who .dim { font-size: 11.5px; margin-top: 2px; }
.gift-ops { margin-left: auto; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }

.gift-rows { padding: 4px 14px 8px; }
.gift-row {
  display: grid;
  grid-template-columns: 92px 44px minmax(0, 1fr) 120px 84px 32px;
  gap: 8px;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--line-soft);
  font-size: 13px;
}
.gift-row:last-child { border-bottom: 0; }
.gift-date { color: var(--text-3); font-size: 12px; font-variant-numeric: tabular-nums; }
.gift-dir { color: var(--text-3); font-size: 12px; }
.gift-title { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gift-amt { text-align: right; font-variant-numeric: tabular-nums; }
.gift-status { text-align: right; }

@media (max-width: 720px) {
  .gift-row { grid-template-columns: 70px 40px minmax(0, 1fr) 90px 32px; }
  .gift-row .gift-status { display: none; }
}

/* 人情工具条：左 4 份搜索筛选，右 1 份按钮 */
.gift-tools {
  display: grid;
  grid-template-columns: minmax(0, 4fr) minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  margin: 10px 0 6px;
}
.gift-tools-left { display: flex; gap: 8px; min-width: 0; }
.gift-tools-left input { flex: 1 1 auto; min-width: 0; }
.gift-tools-left select { flex: 0 0 140px; }
.gift-tools-right { display: flex; justify-content: flex-end; }
.gift-tools-right button { width: 100%; }

@media (max-width: 720px) {
  .gift-tools { grid-template-columns: minmax(0, 1fr); }
  .gift-tools-right button { width: auto; }
}

/* 历史版本对比：左历史 / 右当前 */
.sheet-wide { max-width: min(1180px, 96vw); }

/* 双链新建后的编辑浮层：默认给足宽度，可一键铺满全屏 */
.sheet.sheet-doc { width: min(1180px, 96vw); max-width: min(1180px, 96vw); max-height: 92dvh; }
.sheet.sheet-doc.sheet-doc-full {
  width: 100vw;
  max-width: none;
  height: 100dvh;
  max-height: none;
  border-radius: 0;
}
.sheet.sheet-doc-full .nb-editor { min-height: calc(100dvh - 150px); }
.ver-compare { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 12px; }
.ver-col {
  max-height: 62vh;
  overflow: auto;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-2);
}
.ver-col > header {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
  color: var(--text-3);
  margin-bottom: 6px;
  position: sticky;
  top: 0;
  padding-bottom: 6px;
  background: var(--surface-2);
  z-index: 1;
}
.ver-title { font-size: 17px; margin: 0 0 8px; }
.ver-body { font-size: 13px; }
@media (max-width: 760px) {
  .ver-compare { grid-template-columns: 1fr; }
  .ver-col { max-height: 40vh; }
}

/* 流水筛选：可输入的账户下拉 */
.acct-combo { position: relative; display: flex; align-items: center; gap: 4px; flex: 0 0 auto; }
.acct-combo input { width: 132px; }
.acct-cands {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  z-index: 30;
  min-width: 210px;
  max-height: 260px;
  overflow: auto;
  padding: 4px;
  border-radius: 10px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  box-shadow: 0 12px 30px rgba(0, 0, 0, .38);
}
.acct-cand {
  display: block;
  width: 100%;
  text-align: left;
  padding: 6px 10px;
  border: 0;
  border-radius: 7px;
  background: none;
  color: var(--text-2);
  font-size: 13px;
  cursor: pointer;
}
.acct-cand:hover, .acct-cand.on { background: var(--surface-3); color: var(--text-1); }

/* 预算卡沿用账户卡外观 */
.acct-item[data-budget] { cursor: pointer; }
.acct-item .budget-bar {
  display: block;
  width: 100%;
  height: 4px;
  border-radius: 3px;
  overflow: hidden;
  background: var(--surface-3);
}
.acct-item .budget-bar > i { display: block; height: 100%; background: var(--accent); }
.acct-item.over { border-color: rgba(255, 107, 107, .55); }
.acct-item.over strong { color: #ff6b6b; }
.acct-item.over .budget-bar > i { background: #ff6b6b; }

/* 账本三种内容块：同骨架、不同识别色 */
.acct-item { border-left: 3px solid transparent; }
.acct-item.is-budget { border-left-color: rgba(46, 204, 113, .55); }
.acct-item.is-budget strong { color: #4ade80; }
.acct-item.is-card { border-left-color: rgba(167, 139, 250, .6); }
.acct-item.is-card strong { color: #c4b5fd; }
.acct-item.is-card.over { border-color: #ff6b6b; border-left-color: #ff6b6b; }
.acct-item.is-card.over strong { color: #ff6b6b; }

/* 设置页：顶部功能 tab（一个功能项一页） */
.settings-tabs {
  position: sticky;
  top: 66px;
  z-index: 8;
  display: flex;
  gap: 4px;
  padding: 8px 0;
  margin: 0 0 6px;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  border-bottom: 1px solid var(--line);
  background: var(--bg);
  scrollbar-width: none;
}
.settings-tabs::-webkit-scrollbar { display: none; }
.settings-tab {
  flex: 0 0 auto;
  padding: 6px 12px;
  border: 0;
  border-radius: 8px;
  background: none;
  color: var(--text-3);
  font-size: 13px;
  line-height: 1.4;
  white-space: nowrap;
  cursor: pointer;
}
.settings-tab:hover { background: var(--surface-2); color: var(--text-2); }
.settings-tab.on { background: var(--surface-3); color: var(--text); font-weight: 600; }

/* 笔记详情：从笔记派生的任务 */
.nb-tasks {
  /* 直接放在正文容器里，宽度天然等于正文内容宽 */
  width: 100%;
  max-width: none;
  margin: 14px 0 0;
  padding: 12px 14px;
  box-sizing: border-box;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-2);
}

.nb-task-table { width: 100%; font-size: 12.5px; }
.nb-task-table thead th {
  padding: 6px 8px;
  font-size: 11.5px;
  font-weight: 500;
  color: var(--text-3);
  text-align: left;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.nb-task-table tbody td {
  padding: 6px 8px;
  border-bottom: 1px solid var(--line-soft);
  vertical-align: middle;
}
.nb-task-table tbody tr:nth-child(even) { background: var(--surface); }
.nb-task-table tbody tr:hover { background: var(--surface-3); }
.nb-task-table tbody tr.done td { color: var(--text-3); }
.nb-task-table tbody tr.done .nb-task-title { text-decoration: line-through; }
.nb-task-title {
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text);
}
.nb-task-note {
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-2);
}
.nb-task-acts { white-space: nowrap; text-align: right; }
.nb-task-acts button { margin-left: 4px; }

/* 任务控制台列表：备注列 */
.task-table .task-note {
  max-width: 190px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-2);
}
.crm-kv-note { white-space: pre-wrap; word-break: break-word; }

/* 提醒邮件：类别排序与模板 */
.dg-form { margin-top: 16px; border-top: 1px solid var(--line-soft); padding-top: 14px; }
.dg-title { font-size: 13px; margin: 0; }
.dg-block { margin-top: 14px; }
.dg-label { font-size: 12px; color: var(--text-4); margin-bottom: 6px; }
.dg-sec { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 4px 0; border-bottom: 1px dashed var(--line-soft); }
.dg-sec:last-child { border-bottom: 0; }
.dg-sec-title { width: 140px; height: 28px; padding: 4px 8px; font-size: 13px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface); color: var(--text); }
.dg-sec-acts { display: inline-flex; gap: 4px; }
.dg-sec-acts button { min-width: 26px; justify-content: center; }
.dg-html { width: 100%; min-height: 160px; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12px; line-height: 1.5; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; background: var(--surface); color: var(--text); }
.dg-preview { width: 100%; height: 480px; border: 1px solid var(--line); border-radius: 10px; margin-top: 10px; background: #fff; }
.dg-text { white-space: pre-wrap; font-size: 12px; color: var(--text-2); background: var(--surface-2); padding: 10px; border-radius: 8px; }

/* Markdown 扩展：表格 / 任务清单 / 删除线 / 嵌套列表 */
.md-table-wrap { margin: .7em 0; overflow-x: auto; }
.md-table { border-collapse: collapse; width: 100%; font-size: var(--fs-sm); }
.md-table th, .md-table td {
  border: 1px solid var(--line);
  padding: 6px 10px;
  text-align: left;
  vertical-align: top;
  word-break: break-word;
}
.md-table th { background: var(--surface-2); color: var(--text); font-weight: 600; }
.md li.md-task, .nb-doc-body li.md-task { list-style: none; margin-left: -1.15em; }
.md-check {
  display: inline-block;
  width: 13px; height: 13px;
  margin-right: 6px;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: var(--surface);
  position: relative;
  vertical-align: -2px;
  cursor: default;
}
.md-wysiwyg .md-check { cursor: pointer; }
.md-check.on { background: var(--accent); border-color: var(--accent); }
.md-check.on::after {
  content: '';
  position: absolute;
  left: 3px; top: 0;
  width: 4px; height: 8px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}
.md s, .nb-doc-body s { color: var(--text-3); }
.md ul ul, .md ul ol, .md ol ul, .md ol ol { margin: .2em 0 .2em; }

/* 复习卡：双面 Markdown 与来源 */
.qcard { position: relative; }
.qcard.has-src { padding-bottom: 52px; }
.qcard .q-md, .qcard .a-md {
  font-size: inherit;
  color: inherit;
  line-height: inherit;
  white-space: normal;
  text-align: center;
}
.qcard .q-md ul, .qcard .q-md ol, .qcard .q-md pre,
.qcard .q-md .md-table-wrap,
.qcard .a-md ul, .qcard .a-md ol, .qcard .a-md pre,
.qcard .a-md .md-table-wrap { text-align: left; }
.qcard .q-md > :first-child, .qcard .a-md > :first-child { margin-top: 0; }
.qcard .q-md > :last-child, .qcard .a-md > :last-child { margin-bottom: 0; }
.card-src {
  position: absolute;
  right: 18px;
  bottom: 12px;
  display: inline-flex;
  align-items: center;
  gap: 2px;
  margin: 0;
  padding: 2px 0;
  border: 0;
  background: none;
  color: var(--text-2);
  font: inherit;
  font-size: 12px;
  text-align: left;
  cursor: pointer;
}
.card-src { max-width: calc(100% - 36px); }
.card-src-title { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-src:hover { color: var(--accent); text-decoration: underline; }


/* ============================================================
   Markdown 编辑器：段落样式、浮层、斜杠菜单
   ============================================================ */

.md-block {
  height: 28px;
  padding: 0 6px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text-2);
  font: inherit;
  font-size: 12.5px;
  cursor: pointer;
}
.md-block:hover { background: var(--surface-3); color: var(--text); }
.md-color-btn { font-weight: 650; }

.md-pop {
  position: fixed;
  z-index: 95;
  min-width: 160px;
  padding: 8px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 16px 36px rgba(0, 0, 0, .32);
}
.md-pop-list { display: flex; flex-direction: column; gap: 2px; }
.md-pop-list button {
  width: 100%;
  padding: 7px 10px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text-2);
  font: inherit;
  font-size: 13px;
  text-align: left;
  cursor: pointer;
}
.md-pop-list button:hover { background: var(--surface-3); color: var(--text); }
.md-pop-list button.danger-text { color: var(--danger, #d05a5a); }

.md-swatches { display: grid; grid-template-columns: repeat(3, 28px); gap: 7px; }
.md-swatches button {
  width: 28px;
  height: 28px;
  border: 1px solid rgba(255, 255, 255, .22);
  border-radius: 50%;
  cursor: pointer;
}
.md-swatches button:hover { transform: scale(1.08); }

.md-slash {
  position: fixed;
  z-index: 85;
  width: 240px;
  max-height: 310px;
  overflow-y: auto;
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 18px 40px rgba(0, 0, 0, .34);
}
.md-slash button {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  padding: 6px 9px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text-2);
  font: inherit;
  font-size: 12.5px;
  text-align: left;
  cursor: pointer;
}
.md-slash button.on,
.md-slash button:hover { background: var(--accent-soft); color: var(--text); }

.md-align { margin: 0; }

.nb-find {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0 0 12px;
  padding: 8px 10px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 10px;
}
.nb-find input { flex: 1 1 auto; min-width: 0; }
.nb-find-hit { background: rgba(255, 214, 102, .45); color: inherit; border-radius: 2px; }
.nb-find-hit.on { background: #ffbf3c; color: #1b1b1b; }
.nb-dir-list button { padding: 9px 10px; }
[dir="rtl"] ul, [dir="rtl"] ol { padding-left: 0; padding-right: 22px; }

/* ============================================================
   打印 / 另存为 PDF
   ============================================================ */

@media print {
  .sidebar, .topbar, .tabbar, .page-head, .page-actions,
  .nb-detail-bar, .nb-list-col, .nb-side, .md-toolbar, .md-modes,
  .md-gutter, .sheet-mask, #toast, #nbFind, .nb-find,
  .md-pop, .md-slash, .task-menu, .pim-attention-pop { display: none !important; }
  html, body, .app, .main, #view { background: #fff !important; color: #111 !important; }
  .nb-layout, .nb-layout.mode-reading, .nb-layout.mode-full { display: block !important; }
  .nb-detail { display: block !important; }
  .nb-doc { max-width: none !important; margin: 0 !important; padding: 0 !important; }
  .nb-doc-body, .nb-doc-body * { color: #111 !important; }
  .nb-doc-body a { color: #111 !important; text-decoration: underline; }
  .nb-doc-body img { max-width: 100% !important; height: auto !important; }
  .md-table-wrap { overflow: visible !important; }
  @page { margin: 16mm; }
}


/* 段落样式：紧凑按钮，替代会撑满一行的原生下拉 */
.md-block-btn {
  height: 28px;
  padding: 0 8px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text-2);
  font: inherit;
  font-size: 12.5px;
  cursor: pointer;
  white-space: nowrap;
}
.md-block-btn:hover { background: var(--surface-3); color: var(--text); }

/* 可视化表格：插入后立刻可见边框，并允许列宽生效 */
.md-wysiwyg table { border-collapse: collapse; width: 100%; margin: 8px 0; }
.md-wysiwyg th, .md-wysiwyg td {
  border: 1px solid var(--line);
  padding: 6px 10px;
  vertical-align: top;
  word-break: break-word;
}
.md-wysiwyg th { background: var(--surface-2); font-weight: 600; }
.md-wysiwyg col { min-width: 36px; }
.md-table col { min-width: 36px; }


/* 站点 Logo：替换字母标记后去掉渐变底 */
.side-mark.has-logo, .lock-mark.has-logo {
  width: auto;
  height: auto;
  background: transparent;
  border-radius: 0;
  padding: 0;
}
.brand-logo { display: block; object-fit: contain; border-radius: 6px; }
.brand-preview-box {
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 84px;
  padding: 12px;
  border: 1px dashed var(--line);
  border-radius: var(--r);
  background: var(--surface-2);
}
.brand-preview {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 56px;
  min-height: 56px;
  padding: 4px;
  border-radius: 10px;
  background: var(--surface);
  border: 1px solid var(--line);
}


.lock-custom { margin: 0 0 14px; font-size: 13px; color: var(--text-2); text-align: left; }
.lock-custom p { margin: 0 0 8px; }
.lock-custom img { max-width: 100%; height: auto; border-radius: 8px; }

/* 语音转文字：录音面板 */
.stt-box { display: flex; flex-direction: column; gap: 10px; padding: 6px 0 2px; }
.stt-state { text-align: center; color: var(--text-3); font-size: 13px; }
.stt-timer {
  text-align: center;
  font: 600 30px/1.15 ui-monospace, SFMono-Regular, Menlo, monospace;
  letter-spacing: .04em;
  color: var(--text);
}
.stt-timer.rec { color: var(--danger); }
.stt-actions { display: flex; gap: 8px; justify-content: center; }
.stt-actions button { min-width: 116px; }
.stt-text {
  max-height: 240px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 10px 12px;
  font-size: 14px;
  line-height: 1.6;
  color: var(--text);
}
/* 新建笔记时发现旧草稿：只给恢复/丢弃，不自动填充 */
.nb-draft-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin: 0 0 10px;
  padding: 8px 10px;
  font-size: 12px;
  color: var(--text-2);
  background: var(--warn-soft);
  border: 1px solid var(--warn);
  border-radius: var(--r-sm);
}
.nb-draft-bar button { margin-left: 2px; }
/* 语音助手：目标模块与预览 */
.stt-targets { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 4px; }
.stt-chip {
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--text-2);
  cursor: pointer;
}
.stt-chip.on { border-color: var(--accent-line); background: var(--accent-soft); color: var(--accent); }
.vo-plan { display: flex; flex-direction: column; gap: 8px; }
.vo-row { display: flex; gap: 10px; font-size: 13px; line-height: 1.5; }
.vo-row > span { flex: 0 0 56px; color: var(--text-3); }
.vo-row > div { flex: 1; white-space: pre-wrap; word-break: break-word; color: var(--text); }
/* 时刻提醒：右下角卡片 */
.remind-stack {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 60;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 320px;
}
.remind-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 4px solid var(--warn);
  border-radius: var(--r);
  padding: 10px 12px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .12);
}
.remind-card.due { border-left-color: var(--danger); }
.remind-card.missed { border-left-color: var(--text-4); opacity: .85; }
.remind-head { display: flex; align-items: flex-start; gap: 8px; }
.remind-title { flex: 1; font-size: 13px; font-weight: 600; color: var(--text); line-height: 1.4; }
.remind-time { font-size: 12px; color: var(--text-3); margin-top: 2px; }
.remind-acts { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
/* 日历订阅预览 */
.cal-preview-list { margin-top: 6px; display: flex; flex-direction: column; gap: 4px; }
.cal-preview-row {
  display: grid;
  grid-template-columns: 92px 1fr 72px;
  gap: 8px;
  font-size: 12px;
  padding: 4px 6px;
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--text-2);
}
.cal-preview-row span:last-child { text-align: right; }
.cal-preview-list.all { max-height: 340px; overflow: auto; padding-right: 4px; }
/* ============ 移动端表格 ============ */
@media (max-width: 640px) {
  .tabbar button { font-size: 11px; }

  /* 今日提醒：转卡片，标题 + 到期 + 操作，说明/级别/来源折叠 */
  .inbox-live { min-width: 0; }
  .inbox-live thead { display: none; }
  .inbox-live tbody tr {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 2px 8px;
    padding: 10px 12px;
    border-bottom: 1px solid var(--line-soft);
  }
  .inbox-live tbody td { padding: 0; border: 0; }
  .inbox-live tbody td:nth-child(2),
  .inbox-live tbody td:nth-child(3),
  .inbox-live tbody td:nth-child(5) { display: none; }
  .inbox-live tbody td:nth-child(4) { text-align: right; font-size: 12px; color: var(--text-3); }
  .inbox-live tbody td.task-row-act {
    grid-column: 1 / -1;
    display: flex !important;
    justify-content: flex-end;
    gap: 6px;
    padding-top: 8px;
  }

  /* 其余宽表：操作列吸右，横向滚动时按钮始终可见 */
  .task-table .task-row-act {
    position: sticky;
    right: 0;
    background: var(--surface);
    box-shadow: -10px 0 12px -10px rgba(0, 0, 0, .35);
  }
  .task-table th:last-child { position: sticky; right: 0; background: var(--surface); }
}
/* 任务列表（任务页）移动端改卡片 */
@media (max-width: 640px) {
  .task-list-live { min-width: 0; }
  .task-list-live thead { display: none; }
  .task-list-live tbody tr[data-open-task] {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 2px 8px;
    padding: 10px 12px;
    border-bottom: 1px solid var(--line-soft);
  }
  .task-list-live tbody tr[data-open-task] td { padding: 0; border: 0; }
  .task-list-live tbody tr[data-open-task] td:nth-child(2),
  .task-list-live tbody tr[data-open-task] td:nth-child(5),
  .task-list-live tbody tr[data-open-task] td:nth-child(6) { display: none; }
  .task-list-live tbody tr[data-open-task] td:nth-child(4) {
    text-align: right; font-size: 12px; color: var(--text-3);
  }
  .task-list-live tbody tr[data-open-task] td.task-row-act {
    grid-column: 1 / -1;
    display: flex !important;
    flex-wrap: wrap;
    gap: 6px;
    justify-content: flex-end;
    padding-top: 8px;
    position: static;
    box-shadow: none;
    background: transparent;
  }
  .task-list-live tbody tr.task-group td { display: block; }
}
