/* ============ 变量与基础 ============ */
:root {
  --primary: #16a34a;
  --primary-light: #22c55e;
  --primary-dark: #15803d;
  --bg: #f4f8f5;
  --card: #ffffff;
  --text: #1f2d24;
  --muted: #7c8a80;
  --border: #e3ebe5;
  --shadow: 0 2px 12px rgba(22,101,52,0.06);
  --shadow-hover: 0 6px 20px rgba(22,163,74,0.16);
  --radius: 12px;
  --success: #0d9488;
  --danger: #e17055;
  --warning: #f59e0b;
  --income: #16a34a;
  --expense: #e17055;
}

* { margin:0; padding:0; box-sizing:border-box; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
  min-height: 100vh;
}
button { cursor:pointer; font-family:inherit; border:none; background:none; }
input, select, textarea { font-family:inherit; font-size:14px; }
a { text-decoration:none; color:inherit; }
ul { list-style:none; }

/* ============ 布局 ============ */
body { display:flex; }
#sidebar {
  width: 230px;
  background: var(--card);
  border-right: 1px solid var(--border);
  height: 100vh;
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  z-index: 100;
}
#main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

/* 品牌 */
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 22px 20px;
  border-bottom: 1px solid var(--border);
}
.brand-logo {
  width: 42px; height: 42px;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  color: white; font-size: 22px;
  box-shadow: 0 4px 12px rgba(22,163,74,0.3);
}
.brand-name { font-weight: 700; font-size: 17px; }
.brand-sub { font-size: 11px; color: var(--muted); }

/* 导航 */
#nav { padding: 12px; flex: 1; overflow-y: auto; }
.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 14px;
  border-radius: 10px;
  color: var(--text);
  margin-bottom: 4px;
  transition: all 0.2s;
  cursor: pointer;
}
.nav-item:hover { background: var(--bg); }
.nav-item.active {
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: white;
  box-shadow: 0 4px 12px rgba(22,163,74,0.3);
}
.nav-icon { font-size: 18px; width: 22px; text-align: center; }
.nav-item { cursor: grab; user-select: none; }
.nav-item:active { cursor: grabbing; }
.nav-item.dragging { opacity: 0.45; border: 1px dashed var(--primary); }
.nav-item.drag-over { box-shadow: inset 0 3px 0 var(--primary); }
.nav-item.drag-over.active { box-shadow: inset 0 3px 0 #fff; }

.side-foot { padding: 12px; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 8px; }
.side-btn {
  padding: 9px; border-radius: 8px; background: var(--bg);
  color: var(--text); font-size: 13px; transition: all 0.2s;
}
.side-btn:hover { background: var(--primary); color: white; }

/* 顶栏 */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 28px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 50;
}
.topbar h1 { font-size: 22px; font-weight: 700; }
.topbar-right { color: var(--muted); font-size: 13px; }
.menu-toggle { display: none; font-size: 22px; }

/* 视图切换 */
.view { display: none; padding: 28px; }
.view.active { display: block; animation: fadeIn 0.3s; }
@keyframes fadeIn { from { opacity:0; transform: translateY(8px);} to {opacity:1; transform:none;} }

/* ============ 通用组件 ============ */
.toolbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 20px; flex-wrap: wrap;
}
.tool-left { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.btn {
  padding: 9px 16px;
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font-size: 13px;
  transition: all 0.2s;
  border: 1px solid var(--border);
}
.btn:hover { background: #eceef3; }
.btn.primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: white; border: none;
  box-shadow: 0 3px 10px rgba(22,163,74,0.25);
}
.btn.primary:hover { transform: translateY(-1px); box-shadow: 0 5px 15px rgba(22,163,74,0.35); }
.btn.danger { background: var(--danger); color: white; border: none; }
.btn.small { padding: 5px 10px; font-size: 12px; }

.select {
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
}

.search-box {
  display: flex; align-items: center; gap: 8px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  flex: 1; max-width: 320px;
}
.search-box input { border: none; outline: none; background: none; width: 100%; color: var(--text); }

.seg { display: flex; background: var(--card); border: 1px solid var(--border); border-radius: 8px; padding: 3px; }
.seg button { padding: 6px 12px; border-radius: 6px; color: var(--muted); font-size: 13px; transition: all 0.2s; }
.seg button.active { background: var(--primary); color: white; }

.panel {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 16px;
  overflow: hidden;
}
.panel-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}
.panel-head h3 { font-size: 15px; }
.panel-link { color: var(--primary); font-size: 12px; cursor: pointer; }
.panel-body { padding: 8px 18px; }

/* ============ 总览 ============ */
.welcome-card {
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  border-radius: var(--radius);
  padding: 28px;
  color: white;
  margin-bottom: 22px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  box-shadow: 0 8px 24px rgba(22,163,74,0.2);
}
.welcome-text h2 { font-size: 22px; margin-bottom: 6px; }
.welcome-text p { opacity: 0.85; font-size: 14px; }
.welcome-quote {
  max-width: 320px; text-align: right;
  font-style: italic; opacity: 0.9; font-size: 13px; line-height: 1.7;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 14px;
  margin-bottom: 22px;
}
.stat-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
  transition: all 0.2s;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-hover); }
.stat-num { font-size: 26px; font-weight: 700; color: var(--primary); }
.stat-lbl { font-size: 12px; color: var(--muted); margin-top: 4px; }

.dash-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.dash-grid-3 { grid-template-columns: repeat(3, 1fr); }
.dash-col { min-width: 0; }

.empty-tip {
  text-align: center; color: var(--muted); padding: 30px 10px; font-size: 13px;
}

/* ============ 列表项 ============ */
.list { display: flex; flex-direction: column; gap: 10px; }
.list-item {
  background: var(--card);
  border-radius: var(--radius);
  padding: 14px 18px;
  box-shadow: var(--shadow);
  display: flex; align-items: center; gap: 12px;
  transition: all 0.2s;
}
.list-item:hover { box-shadow: var(--shadow-hover); }

.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 500;
}
.badge-income { background: rgba(0,184,148,0.12); color: var(--income); }
.badge-expense { background: rgba(225,112,85,0.12); color: var(--expense); }
.badge-p-important-urgent { background: rgba(225,112,85,0.15); color: var(--danger); }
.badge-p-important-not-urgent { background: rgba(9,132,227,0.12); color: #0984e3; }
.badge-p-not-important-urgent { background: rgba(243,156,18,0.15); color: #f39c12; }
.badge-p-not-important-not-urgent { background: rgba(0,184,148,0.12); color: var(--success); }
/* 兼容旧优先级 class */
.badge-p-high { background: rgba(225,112,85,0.15); color: var(--danger); }
.badge-p-mid { background: rgba(9,132,227,0.12); color: #0984e3; }
.badge-p-low { background: rgba(0,184,148,0.12); color: var(--success); }

.item-title { font-weight: 600; }
.item-meta { font-size: 12px; color: var(--muted); margin-top: 3px; }
.item-actions { margin-left: auto; display: flex; gap: 6px; }
.icon-btn {
  width: 30px; height: 30px;
  border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  color: var(--muted); transition: all 0.2s; font-size: 14px;
}
.icon-btn:hover { background: var(--bg); color: var(--text); }
.icon-btn.danger:hover { background: rgba(225,112,85,0.1); color: var(--danger); }

/* ============ 记账 ============ */
.bk-summary { display: flex; gap: 18px; font-size: 13px; }
.bk-summary span b { font-size: 16px; }
.bk-inc { color: var(--income); }
.bk-exp { color: var(--expense); }
.bk-balance { color: var(--primary); font-weight: 700; }

/* 记账统计分析 */
.bk-stats {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
  margin-bottom: 16px;
}
.bk-stats-bar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.bk-stats-dates { display: flex; align-items: center; gap: 8px; }
.bk-stats-range { font-size: 12px; color: var(--muted); margin-bottom: 14px; }
.bk-stats-cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 16px; }
.bk-stat-card {
  background: var(--bg); border-radius: 10px; padding: 14px; text-align: center;
}
.bk-stat-num { font-size: 20px; font-weight: 700; color: var(--text); }
.bk-stat-lbl { font-size: 12px; color: var(--muted); margin-top: 4px; }
.bk-stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.bk-stats-col h4 { font-size: 14px; }
.bk-donut-wrap { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.bk-donut {
  width: 168px; height: 168px; border-radius: 50%; flex-shrink: 0; position: relative;
  box-shadow: var(--shadow);
}
.bk-donut-hole {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  width: 108px; height: 108px; border-radius: 50%; background: var(--card);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  box-shadow: inset 0 0 0 1px var(--border);
}
.bk-donut-total { font-size: 15px; font-weight: 700; color: var(--text); }
.bk-donut-lbl { font-size: 11px; color: var(--muted); margin-top: 2px; }
.bk-legend { flex: 1; min-width: 180px; max-height: 200px; overflow-y: auto; }
.bk-legend-row {
  display: flex; align-items: center; gap: 8px; padding: 5px 0;
  border-bottom: 1px dashed var(--border); font-size: 13px;
}
.bk-legend-row:last-child { border-bottom: none; }
.bk-legend-dot { width: 10px; height: 10px; border-radius: 3px; flex-shrink: 0; }
.bk-legend-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bk-legend-pct { width: 52px; text-align: right; color: var(--muted); font-size: 12px; flex-shrink: 0; }
.bk-legend-val { width: 84px; text-align: right; font-weight: 600; font-size: 12px; flex-shrink: 0; }
@media (max-width: 900px) {
  .bk-stats-grid { grid-template-columns: 1fr; }
  .bk-stats-cards { grid-template-columns: repeat(2, 1fr); }
  .bk-donut-wrap { flex-direction: column; align-items: stretch; }
  .bk-legend { max-height: none; }
}

.bk-bar-row { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.bk-bar-label { width: 70px; font-size: 12px; color: var(--muted); flex-shrink: 0; }
.bk-bar-track { flex: 1; height: 18px; background: var(--bg); border-radius: 9px; overflow: hidden; }
.bk-bar-fill { height: 100%; background: linear-gradient(90deg, var(--primary), var(--primary-light)); border-radius: 9px; transition: width 0.5s; }
.bk-bar-val { width: 80px; text-align: right; font-size: 12px; font-weight: 600; }

.bk-amount { margin-left: auto; font-weight: 700; font-size: 16px; }
.item-sub { color: var(--muted); font-weight: 400; font-size: 13px; }

/* 记账图片上传 */
.bk-img-upload { position: relative; }
.bk-img-preview {
  width: 120px; height: 120px; border: 2px dashed var(--border);
  border-radius: 10px; display: flex; align-items: center; justify-content: center;
  cursor: pointer; background: var(--bg); color: var(--muted);
  font-size: 12px; text-align: center; position: relative; overflow: hidden;
  transition: border-color 0.2s;
}
.bk-img-preview:hover { border-color: var(--primary); }
.bk-img-preview.has-img { border-style: solid; padding: 0; }
.bk-img-preview img { width: 100%; height: 100%; object-fit: cover; }
.bk-img-del {
  position: absolute; top: 4px; right: 4px; width: 22px; height: 22px;
  border-radius: 50%; border: none; background: rgba(0,0,0,0.6); color: white;
  cursor: pointer; font-size: 12px; line-height: 1; display: flex;
  align-items: center; justify-content: center;
}
.bk-img-del:hover { background: var(--danger); }
.bk-thumb {
  width: 44px; height: 44px; border-radius: 8px; object-fit: cover;
  cursor: pointer; border: 1px solid var(--border); flex-shrink: 0;
  transition: transform 0.15s;
}
.bk-thumb:hover { transform: scale(1.08); }

/* 记账目标与预算 */
.bk-goal-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 14px; margin-bottom: 16px;
}
.bk-goal-card {
  background: var(--card); border-radius: var(--radius);
  padding: 16px 18px; box-shadow: var(--shadow);
}
.bk-goal-head {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 14px; font-weight: 600; margin-bottom: 10px;
}
.bk-goal-num { font-size: 22px; font-weight: 700; color: var(--text); }
.bk-goal-total { font-size: 13px; font-weight: 400; color: var(--muted); }
.bk-goal-pct { font-size: 12px; color: var(--muted); margin-top: 6px; }
.bk-year-stats { display: flex; flex-direction: column; gap: 4px; font-size: 13px; }
.bk-bar-fill.over { background: linear-gradient(90deg, var(--danger), #ff7675); }

/* 记账二级分类管理 */
.bk-cat-group { margin-bottom: 8px; }
.bk-sub-list { padding-left: 4px; }
.bk-sub-row { }
.bk-toggle {
  background: none; border: none; cursor: pointer;
  font-size: 11px; color: var(--muted); padding: 0 2px;
  width: 18px; text-align: center;
}
.bk-toggle:hover { color: var(--primary); }
.bk-third-list { background: rgba(0,0,0,0.015); border-radius: 6px; margin: 2px 0; }
.bk-sub-add {
  display: flex; gap: 6px; padding: 8px 14px 8px 36px;
}
.bk-sub-add .sub-input {
  flex: 1; padding: 6px 10px; border: 1px dashed var(--border);
  border-radius: 6px; background: var(--bg); outline: none; font-size: 12px;
}
.bk-sub-add .sub-input:focus { border-color: var(--primary); background: var(--card); }

/* ============ 备忘录 ============ */
.color-filter { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.color-chip {
  width: 24px; height: 24px; border-radius: 50%;
  border: 2px solid transparent; cursor: pointer; transition: all 0.2s;
}
.color-chip.active { border-color: var(--text); transform: scale(1.15); }
.color-chip.all { background: linear-gradient(135deg, #ff6b6b, #feca57, #48dbfb, #1dd1a1); }

.memo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px;
}
.memo-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  border-left: 4px solid var(--primary);
  cursor: pointer;
  transition: all 0.2s;
  min-height: 120px;
  display: flex; flex-direction: column;
}
.memo-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-hover); }
.memo-card.pinned { box-shadow: 0 0 0 2px var(--warning), var(--shadow); }
.memo-card h4 { font-size: 15px; margin-bottom: 8px; display: flex; align-items: center; gap: 6px; }
.memo-card p { font-size: 13px; color: var(--text); flex: 1; white-space: pre-wrap; word-break: break-word; }
.memo-card .memo-foot { font-size: 11px; color: var(--muted); margin-top: 10px; display: flex; justify-content: space-between; }

/* ============ 待办 ============ */
.todo-progress { font-size: 13px; color: var(--muted); }
.todo-progress b { color: var(--primary); }
.todo-check {
  width: 22px; height: 22px; border-radius: 50%;
  border: 2px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; flex-shrink: 0; transition: all 0.2s;
}
.todo-check.done { background: var(--primary); border-color: var(--primary); color: white; }
.todo-item.done .item-title { text-decoration: line-through; color: var(--muted); }

/* ============ 物品归纳 ============ */
.inv-tabs {
  display: flex; gap: 8px; margin-bottom: 14px;
  border-bottom: 2px solid var(--border); padding-bottom: 0;
}
.inv-tab {
  background: none; border: none; padding: 8px 18px;
  font-size: 14px; color: var(--muted); cursor: pointer;
  border-bottom: 2px solid transparent; margin-bottom: -2px;
  transition: all 0.2s; font-weight: 500;
}
.inv-tab:hover { color: var(--text); }
.inv-tab.active {
  color: var(--primary); border-bottom-color: var(--primary); font-weight: 600;
}
.inv-summary {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px; margin-bottom: 18px;
}
.inv-stat {
  background: var(--card); border-radius: var(--radius);
  padding: 14px; box-shadow: var(--shadow); text-align: center;
}
.inv-stat .num { font-size: 22px; font-weight: 700; color: var(--primary); }
.inv-stat .lbl { font-size: 12px; color: var(--muted); margin-top: 2px; }

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 14px;
}
.item-card {
  background: var(--card); border-radius: var(--radius);
  padding: 16px; box-shadow: var(--shadow); transition: all 0.2s;
}
.item-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-hover); }
.item-card h4 { font-size: 15px; margin-bottom: 6px; }
.item-card .meta { font-size: 12px; color: var(--muted); margin-bottom: 8px; }
.item-card .qty {
  display: inline-block; background: var(--bg); padding: 2px 10px;
  border-radius: 12px; font-size: 12px; margin-right: 6px;
}
.inv-img {
  width: 100%; height: 140px; border-radius: 8px; overflow: hidden;
  margin-bottom: 10px; cursor: pointer; background: var(--bg);
}
.inv-img img { width: 100%; height: 100%; object-fit: cover; }
.inv-info {
  display: flex; flex-wrap: wrap; gap: 4px 10px;
  font-size: 12px; color: var(--muted); margin-top: 4px;
}
.inv-price { color: var(--expense); font-weight: 600; }

/* ============ 读书笔记 ============ */
.read-card { border-left: 4px solid #4ade80; }
.read-card .rating { color: var(--warning); margin-bottom: 6px; }
.read-card .book-meta { font-size: 12px; color: var(--muted); margin-bottom: 8px; }
.read-card .notes { font-size: 13px; line-height: 1.6; max-height: 100px; overflow: hidden; position: relative; }
.read-progress { margin: 8px 0; }
.read-progress-bar {
  height: 8px; background: var(--bg); border-radius: 4px; overflow: hidden;
}
.read-progress-fill {
  height: 100%; background: linear-gradient(90deg, #86efac, #16a34a);
  border-radius: 4px; transition: width 0.3s;
}
.read-progress-text {
  display: block; font-size: 12px; color: var(--muted); margin-top: 4px;
}
.read-stats {
  display: flex; flex-wrap: wrap; gap: 10px; font-size: 12px; color: var(--muted);
  margin-top: 4px;
}
.read-sessions { border-top: 1px solid var(--border); padding-top: 8px; }
.read-session-item {
  padding: 8px 0; border-bottom: 1px dashed var(--border);
}
.read-session-item:last-child { border-bottom: none; }
.rs-meta { font-size: 12px; color: var(--muted); }
.rs-notes { font-size: 13px; margin-top: 4px; color: var(--text); }

/* ============ 习惯打卡 ============ */
.habit-list { display: flex; flex-direction: column; gap: 14px; }
.habit-card {
  background: var(--card); border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow);
}
.habit-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.habit-name { font-weight: 700; font-size: 15px; }
.habit-streak {
  background: linear-gradient(135deg, #ff6b6b, #ee5a52);
  color: white; padding: 2px 10px; border-radius: 12px; font-size: 12px;
}
.habit-cal { display: flex; flex-wrap: wrap; gap: 4px; }
.habit-day {
  width: 30px; height: 30px; border-radius: 6px;
  background: var(--bg); display: flex; align-items: center; justify-content: center;
  font-size: 11px; cursor: pointer; transition: all 0.15s;
  color: var(--muted);
}
.habit-day:hover { transform: scale(1.1); }
.habit-day.checked { background: var(--primary); color: white; }
.habit-day.today { border: 2px solid var(--primary); }
.habit-day.future { opacity: 0.3; cursor: not-allowed; }

/* ============ 专注打卡 ============ */
.focus-layout { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.focus-timer-card {
  background: linear-gradient(135deg, #22c55e, #15803d);
  border-radius: var(--radius);
  padding: 40px 30px;
  color: white;
  text-align: center;
  box-shadow: 0 10px 30px rgba(22,163,74,0.25);
}
.timer-display {
  font-size: 72px; font-weight: 200; letter-spacing: 2px;
  font-variant-numeric: tabular-nums;
  margin-bottom: 8px;
}
.timer-mode { font-size: 14px; opacity: 0.85; margin-bottom: 20px; }
.timer-task input {
  width: 100%; padding: 10px 14px; border-radius: 8px;
  border: none; outline: none; margin-bottom: 16px;
  background: rgba(255,255,255,0.15); color: white;
}
.timer-task input::placeholder { color: rgba(255,255,255,0.6); }
.timer-controls { display: flex; gap: 10px; justify-content: center; margin-bottom: 20px; }
.timer-controls .btn { background: rgba(255,255,255,0.2); color: white; border: none; }
.timer-controls .btn.primary { background: white; color: var(--primary); }
.timer-settings { display: flex; gap: 16px; justify-content: center; font-size: 13px; opacity: 0.9; flex-wrap: wrap; }
.timer-settings input {
  width: 50px; padding: 4px 8px; border-radius: 6px; border: none;
  text-align: center; margin: 0 4px;
}
.focus-mode-tabs {
  display: flex; gap: 6px; justify-content: center; margin-bottom: 16px;
  background: rgba(0,0,0,0.15); border-radius: 10px; padding: 4px;
}
.fm-tab {
  flex: 1; background: none; border: none; color: rgba(255,255,255,0.7);
  padding: 8px 10px; border-radius: 7px; cursor: pointer;
  font-size: 13px; transition: all 0.2s; font-weight: 500;
}
.fm-tab:hover { color: white; }
.fm-tab.active { background: rgba(255,255,255,0.25); color: white; font-weight: 600; }
.focus-cat-select {
  width: 100%; padding: 10px 14px; border-radius: 8px;
  border: none; outline: none;
  background: rgba(255,255,255,0.15); color: white;
}
.focus-cat-select option { color: var(--text); background: white; }

.focus-today {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px;
  padding: 8px 0;
}
.focus-today .ft { text-align: center; }
.focus-today .ft .num { font-size: 24px; font-weight: 700; color: var(--primary); }
.focus-today .ft .lbl { font-size: 12px; color: var(--muted); }

/* ============ 弹窗 ============ */
.overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.45);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000; padding: 20px;
}
.overlay[hidden] { display: none; }
.modal {
  background: var(--card);
  border-radius: var(--radius);
  width: 100%; max-width: 520px;
  max-height: 85vh; overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
  animation: slideUp 0.25s;
}
@keyframes slideUp { from { opacity:0; transform: translateY(20px);} to {opacity:1; transform:none;} }
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 22px; border-bottom: 1px solid var(--border);
}
.modal-title { font-weight: 700; font-size: 17px; }
.x { width: 30px; height: 30px; border-radius: 6px; color: var(--muted); font-size: 16px; }
.x:hover { background: var(--bg); color: var(--text); }
.modal-body { padding: 20px 22px; }
.modal-foot {
  padding: 14px 22px; border-top: 1px solid var(--border);
  display: flex; justify-content: flex-end; gap: 10px;
}

.field { margin-bottom: 14px; }
.field > span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.field input, .field select, .field textarea {
  width: 100%; padding: 9px 12px;
  border: 1px solid var(--border); border-radius: 8px;
  background: var(--bg); outline: none; color: var(--text);
  transition: border 0.2s;
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--primary); background: var(--card); }
.field textarea { resize: vertical; min-height: 80px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.color-picker { display: flex; gap: 8px; flex-wrap: wrap; }
.color-dot {
  width: 26px; height: 26px; border-radius: 50%; cursor: pointer;
  border: 2px solid transparent; transition: all 0.15s;
}
.color-dot.active { border-color: var(--text); transform: scale(1.15); }

/* ============ Toast ============ */
#toast {
  position: fixed; top: 20px; left: 50%; transform: translateX(-50%);
  background: var(--text); color: white;
  padding: 10px 20px; border-radius: 8px;
  font-size: 13px; z-index: 2000;
  opacity: 0; pointer-events: none;
  transition: opacity 0.3s, transform 0.3s;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(8px); }

/* ============ 资料库 ============ */
.kb-card h4 { margin-bottom: 4px; }
.kb-toolbar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.kb-toolbar .btn { font-size: 13px; padding: 7px 14px; }
.kb-attach-grid { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 12px; }
.kb-att {
  position: relative; width: 96px; height: 96px; border-radius: 8px;
  overflow: hidden; border: 1px solid var(--border); background: var(--bg);
}
.kb-att img { width: 100%; height: 100%; object-fit: cover; }
.kb-att-tag {
  position: absolute; left: 0; bottom: 0; right: 0;
  background: rgba(0,0,0,0.55); color: #fff; font-size: 11px; text-align: center; padding: 2px 0;
}
.kb-doc {
  display: flex; align-items: center; gap: 10px;
  background: var(--bg); border-radius: 8px; padding: 8px 12px;
  font-size: 13px; min-width: 220px;
}
.kb-view-imgs { display: flex; flex-wrap: wrap; gap: 12px; }
.kb-view-imgs figure { margin: 0; width: calc(50% - 6px); }
.kb-view-imgs img { width: 100%; border-radius: 8px; border: 1px solid var(--border); }
.kb-view-imgs figcaption { font-size: 12px; color: var(--muted); text-align: center; margin-top: 4px; }
.kb-doc-text {
  border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; margin-bottom: 8px;
}
.kb-doc-text summary { cursor: pointer; font-size: 13px; }
.kb-doc-text pre {
  white-space: pre-wrap; word-break: break-word; max-height: 280px; overflow: auto;
  background: var(--bg); border-radius: 6px; padding: 10px; margin-top: 8px;
  font-size: 12px; line-height: 1.6;
}
.draw-toolbar {
  display: flex; justify-content: space-between; align-items: center;
  flex-wrap: wrap; gap: 8px; margin-bottom: 10px;
}
.draw-colors { display: flex; gap: 6px; }
.draw-color {
  width: 26px; height: 26px; border-radius: 50%; cursor: pointer;
  border: 2px solid transparent;
}
.draw-color.active { border-color: var(--text); transform: scale(1.15); }
.draw-tools { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.draw-tools .btn { font-size: 12px; padding: 5px 10px; }
.draw-canvas {
  width: 100%; border: 1px solid var(--border); border-radius: 8px;
  touch-action: none; background: #fff; cursor: crosshair;
}

/* ============ 计划总览 ============ */
.plan-card {
  background: var(--card); border-radius: var(--radius);
  padding: 16px 18px; margin-bottom: 12px; box-shadow: var(--shadow);
  border-left: 4px solid #16a34a;
}
.plan-head {
  display: flex; justify-content: space-between; align-items: center;
  flex-wrap: wrap; gap: 8px; margin-bottom: 6px;
}
.plan-period { font-size: 12px; color: var(--muted); font-weight: 600; }
.plan-title { font-size: 16px; font-weight: 700; margin-bottom: 4px; }
.plan-title.done { text-decoration: line-through; color: var(--muted); }
.plan-parent-hint { font-size: 12px; color: #16a34a; margin-bottom: 4px; }
.plan-desc { font-size: 13px; color: var(--muted); line-height: 1.6; margin-bottom: 8px; }
.plan-prog { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.plan-prog-bar {
  flex: 1; height: 10px; background: var(--bg); border-radius: 5px; overflow: hidden;
}
.plan-prog-fill {
  height: 100%; background: linear-gradient(90deg, #86efac, #16a34a);
  border-radius: 5px; transition: width 0.3s;
}
.plan-prog-fill.done { background: linear-gradient(90deg, #4ade80, #15803d); }
.plan-prog-txt { font-size: 13px; font-weight: 700; color: #16a34a; min-width: 40px; text-align: right; }
.plan-checks {
  margin-top: 8px; padding-top: 8px; border-top: 1px dashed var(--border);
  display: flex; flex-direction: column; gap: 6px;
}
.plan-check {
  display: flex; align-items: center; gap: 8px; font-size: 14px; cursor: pointer;
}
.plan-check.done span { text-decoration: line-through; color: var(--muted); }
.plan-check-add { display: flex; gap: 8px; margin-top: 4px; }
.plan-check-add input {
  flex: 1; padding: 7px 12px; border: 1px solid var(--border);
  border-radius: 8px; background: var(--bg); outline: none; font-size: 13px;
}
.plan-children { margin-top: 10px; display: flex; flex-direction: column; gap: 10px; }
.plan-children .plan-card { margin-bottom: 0; border-left-color: #4ade80; box-shadow: none; background: var(--bg); }

/* 总览计划面板 */
.dash-plan-sub { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.dash-plan-item {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 0; border-bottom: 1px solid var(--border);
}
.dash-plan-title { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dash-plan-title.done { text-decoration: line-through; color: var(--muted); }
.dash-plan-pct { font-size: 13px; font-weight: 700; color: #16a34a; flex-shrink: 0; margin-left: 8px; }

/* 计划完成勾选 */
.plan-title-wrap { display: flex; align-items: flex-start; gap: 10px; margin-bottom: 4px; }
.plan-title-wrap .plan-title { margin-bottom: 0; flex: 1; }
.plan-done-check { position: relative; display: inline-flex; flex-shrink: 0; cursor: pointer; margin-top: 2px; }
.plan-done-check input { position: absolute; opacity: 0; width: 20px; height: 20px; cursor: pointer; margin: 0; }
.plan-done-box {
  width: 20px; height: 20px; border: 2px solid var(--primary); border-radius: 6px;
  color: #fff; font-size: 13px; line-height: 17px; text-align: center; font-weight: 700;
  background: var(--card); transition: all 0.15s;
}
.plan-done-check input:checked + .plan-done-box { background: var(--primary); border-color: var(--primary); }

/* ============ 资料库（笔记本式布局） ============ */
.kb-layout {
  display: grid; grid-template-columns: 280px 1fr; gap: 16px;
  align-items: start;
}
.kb-tree {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  overflow: hidden; position: sticky; top: 16px; max-height: calc(100vh - 110px);
  display: flex; flex-direction: column;
}
.kb-tree-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; border-bottom: 1px solid var(--border);
}
.kb-tree-title { font-size: 16px; font-weight: 700; }
.kb-tree-count {
  background: var(--primary); color: #fff; font-size: 12px; font-weight: 700;
  min-width: 22px; height: 22px; line-height: 22px; text-align: center; border-radius: 11px; padding: 0 6px;
}
.kb-tree-body { flex: 1; overflow-y: auto; padding: 8px; }
.kb-group { margin-bottom: 2px; }
.kb-group-head {
  display: flex; align-items: center; gap: 8px; width: 100%;
  padding: 9px 10px; border-radius: 8px; text-align: left;
  font-size: 14px; font-weight: 600; color: var(--text);
}
.kb-group-head:hover { background: var(--bg); }
.kb-caret { width: 12px; font-size: 10px; color: var(--muted); flex-shrink: 0; }
.kb-folder-ico { flex-shrink: 0; }
.kb-group-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kb-count {
  font-size: 11px; color: var(--muted); background: var(--bg);
  border-radius: 9px; padding: 1px 8px; flex-shrink: 0;
}
.kb-group-items { padding: 2px 0 4px 22px; display: flex; flex-direction: column; gap: 1px; }
.kb-item-row {
  display: flex; align-items: center; gap: 8px; width: 100%;
  padding: 8px 10px; border-radius: 8px; text-align: left; font-size: 13px;
  color: var(--text); border-left: 3px solid transparent;
}
.kb-item-row:hover { background: var(--bg); }
.kb-item-row.active {
  background: #e9f7ee; border-left-color: var(--primary); font-weight: 600;
}
.kb-item-ico { flex-shrink: 0; }
.kb-item-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kb-item-badges { display: flex; gap: 4px; flex-shrink: 0; }
.kb-item-badges em {
  font-style: normal; font-size: 11px; color: var(--muted); background: var(--bg);
  border-radius: 8px; padding: 0 6px;
}
.kb-quick-add {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 13px 16px; border-top: 1px solid var(--border);
  font-size: 14px; font-weight: 600; color: var(--primary); text-align: left;
}
.kb-quick-add:hover { background: var(--bg); }

/* 资料详情 */
.kb-detail {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  min-height: 420px;
}
.kb-detail-empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-height: 420px; color: var(--muted); text-align: center; padding: 30px;
}
.kb-detail-head {
  display: flex; justify-content: space-between; align-items: flex-start; gap: 12px;
  padding: 20px 24px; border-bottom: 1px solid var(--border); flex-wrap: wrap;
}
.kb-detail-head h2 { font-size: 20px; margin-bottom: 6px; }
.kb-detail-body { padding: 20px 24px 28px; }
.kb-detail-text {
  white-space: pre-wrap; word-break: break-word; line-height: 1.9; font-size: 14px;
  background: var(--bg); border-radius: 10px; padding: 16px 18px; margin-bottom: 18px;
}
.kb-sec-title { font-size: 15px; margin: 18px 0 10px; }
.kb-sec-title small { font-size: 12px; color: var(--muted); font-weight: 400; }
.kb-view-imgs figure { cursor: zoom-in; }
.kb-doc-list { display: flex; flex-direction: column; gap: 12px; }
.kb-doc-file {
  border: 1px solid var(--border); border-radius: 10px; overflow: hidden; background: var(--card);
}
.kb-doc-file-bar {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  padding: 10px 14px; background: var(--bg); font-size: 13px; flex-wrap: wrap;
}
.kb-doc-file-bar em { font-style: normal; color: var(--muted); font-size: 12px; margin-right: 10px; }
.kb-doc-file-bar .btn { font-size: 12px; padding: 4px 12px; }
.kb-preview-iframe { width: 100%; height: 560px; border: none; display: block; background: #f0f0f0; }
.kb-preview-img { max-width: 100%; max-height: 600px; display: block; margin: 0 auto; padding: 12px; }
.kb-no-preview { padding: 28px; text-align: center; color: var(--muted); font-size: 13px; }
.kb-doc-text summary em { font-style: normal; color: var(--muted); font-size: 12px; margin-left: 6px; }

/* ============ 日记 ============ */
.diary-layout { display: flex; flex-direction: column; gap: 14px; }
.diary-card {
  display: grid; grid-template-columns: 110px 1fr;
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  overflow: hidden; border-left: 4px solid var(--primary-light);
}
.diary-card.today { border-left-color: var(--primary); box-shadow: 0 4px 18px rgba(22,163,74,0.14); }
.diary-date-col {
  background: linear-gradient(160deg, #f0fbf4, #e3f6ea);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 18px 8px; gap: 2px; text-align: center;
}
.diary-date-md { font-size: 17px; font-weight: 800; color: var(--primary-dark); }
.diary-date-wd { font-size: 13px; color: var(--primary); font-weight: 600; }
.diary-date-y { font-size: 11px; color: var(--muted); margin-bottom: 6px; }
.diary-mood { font-size: 26px; line-height: 1; }
.diary-main { padding: 16px 20px; min-width: 0; }
.diary-card-head {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  margin-bottom: 10px;
}
.diary-card-head h3 { font-size: 17px; }
.diary-today-tag {
  display: inline-block; font-size: 11px; font-weight: 600; color: #fff;
  background: var(--primary); border-radius: 9px; padding: 1px 9px; margin-left: 8px; vertical-align: middle;
}
.diary-sec { display: flex; gap: 10px; padding: 7px 0; }
.diary-sec-ico { font-size: 16px; flex-shrink: 0; margin-top: 2px; }
.diary-sec-label { font-size: 12px; font-weight: 700; color: var(--primary-dark); margin-bottom: 2px; }
.diary-sec-text {
  font-size: 13.5px; line-height: 1.75; white-space: pre-wrap; word-break: break-word; color: var(--text);
}
.diary-mood-picker { display: flex; gap: 10px; flex-wrap: wrap; }
.diary-mood-opt {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 8px 14px; border: 2px solid var(--border); border-radius: 10px; background: var(--card);
  min-width: 64px; transition: all 0.15s;
}
.diary-mood-opt:hover { border-color: var(--primary-light); }
.diary-mood-opt.active { border-color: var(--primary); background: #f0fbf4; }
.diary-mood-emoji { font-size: 24px; }
.diary-mood-label { font-size: 11px; color: var(--muted); }
.diary-mood-opt.active .diary-mood-label { color: var(--primary-dark); font-weight: 600; }

/* ============ 响应式 ============ */
@media (max-width: 900px) {
  .dash-grid, .focus-layout, .kb-layout { grid-template-columns: 1fr; }
  .kb-tree { position: static; max-height: none; }
}
@media (max-width: 768px) {
  #sidebar {
    position: fixed; left: 0; top: 0;
    transform: translateX(-100%);
    transition: transform 0.3s;
    box-shadow: 4px 0 20px rgba(0,0,0,0.1);
  }
  #sidebar.open { transform: translateX(0); }
  .menu-toggle { display: block; }
  .view { padding: 18px; }
  .topbar { padding: 14px 18px; }
  .welcome-card { flex-direction: column; text-align: center; }
  .welcome-quote { text-align: center; max-width: none; }
  .diary-card { grid-template-columns: 1fr; }
  .diary-date-col { flex-direction: row; gap: 10px; padding: 10px 16px; justify-content: flex-start; }
  .diary-date-y { margin-bottom: 0; }
  .kb-preview-iframe { height: 420px; }
}

/* ============ 云同步（sync.js） ============ */
#syncEntry { font-size: 13px; line-height: 1.4; white-space: normal; text-align: left; }
#syncEntry:disabled { opacity: 0.6; cursor: not-allowed; }
.sync-auth { display: flex; flex-direction: column; gap: 12px; }
.sync-seg { display: flex; gap: 4px; background: var(--bg); border-radius: 8px; padding: 4px; }
.sync-seg button { flex: 1; padding: 8px 0; border-radius: 6px; color: var(--muted); font-size: 14px; }
.sync-seg button.active { background: var(--card); color: var(--primary-dark); font-weight: 700; box-shadow: var(--shadow); }
.sync-field { display: flex; flex-direction: column; gap: 5px; }
.sync-field label { font-size: 12px; color: var(--muted); font-weight: 600; }
.sync-field input {
  padding: 9px 11px; border: 1px solid var(--border); border-radius: 8px;
  font-size: 14px; background: var(--card);
}
.sync-field input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(22,163,74,0.12); }
.sync-err {
  background: #fdecea; color: #b3261e; border: 1px solid #f5c6c2;
  border-radius: 8px; padding: 8px 11px; font-size: 13px;
}
.sync-tip { font-size: 12px; color: var(--warning); background: #fff8eb; border-radius: 8px; padding: 8px 11px; }
.sync-guide { font-size: 12px; color: var(--muted); line-height: 1.7; background: var(--bg); border-radius: 8px; padding: 9px 11px; }
.sync-actions { display: flex; justify-content: flex-end; gap: 8px; }
.sync-status-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 2px; border-bottom: 1px dashed var(--border); font-size: 14px;
}
.sync-status-row:last-of-type { border-bottom: none; }
.sync-status-row span { color: var(--muted); }
.btn.danger:hover { background: #c8442f; }
