:root {
  --bg: #f2f2f7;
  --card: #ffffff;
  --text: #1c1c1e;
  --muted: #8e8e93;
  --primary: #007aff;
  --primary-d: #0066d6;
  --border: #e5e5ea;
  --danger: #ff3b30;
  --radius: 16px;
  --shadow: 0 2px 10px rgba(0,0,0,.05);
  /* iOS system colors */
  --blue: #007aff; --green: #34c759; --orange: #ff9500; --red: #ff3b30; --purple: #af52de; --teal: #30b0c7; --indigo: #5856d6; --pink: #ff2d55; --yellow: #ffcc00; --gray5: #aeaeb2;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  background: #e5e5ea;
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  width: 100%;
  max-width: 520px;
  margin: 0 auto;
  background: var(--bg);
  box-shadow: 0 0 24px rgba(0,0,0,.08);
  overflow: hidden;
}

/* 响应式宽度：手机保持窄栏，平板/电脑横向铺满 */
@media (min-width: 600px)  { #app { max-width: 680px; } }
@media (min-width: 900px)  { #app { max-width: 920px; } }
@media (min-width: 1280px) { #app { max-width: 1120px; } }

/* ---------- top bar ---------- */
.app-bar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: rgba(255,255,255,.82);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 0.5px solid rgba(0,0,0,.08);
  padding-top: calc(14px + env(safe-area-inset-top));
}
.app-title { font-weight: 700; font-size: 17px; letter-spacing: .2px; }
.app-user { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.app-user:active { opacity: .6; }
.uname { font-size: 14px; max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.avatar {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: var(--bg);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 18px; flex: 0 0 auto;
}
.avatar.lg { width: 48px; height: 48px; font-size: 26px; }

/* ---------- main scroll area ---------- */
#main {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 12px;
}

/* ---------- bottom tab bar ---------- */
.tab-bar {
  flex: 0 0 auto;
  display: flex;
  background: rgba(255,255,255,.82);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  border-top: 0.5px solid rgba(0,0,0,.08);
  padding-bottom: env(safe-area-inset-bottom);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.tab-bar::-webkit-scrollbar { display: none; }
.tab {
  flex: 0 0 auto;
  min-width: 58px;
  border: none; background: none;
  padding: 7px 8px 6px;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  font-family: inherit; font-size: 11px;
  color: var(--muted); cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.tab .tab-ico { font-size: 19px; line-height: 1; }
.tab.active { color: var(--primary); font-weight: 600; }
.tab.active .tab-ico { transform: translateY(-1px); }

/* ---------- dashboard ---------- */
.dash-greet { margin: 4px 4px 0; grid-column: 1 / -1; }
.dash-hi { font-size: 28px; font-weight: 700; letter-spacing: -.3px; }
.dash-date { font-size: 13px; color: var(--muted); margin-top: 3px; }

.dash-grid { display: grid; grid-template-columns: 1fr; gap: 14px; }

/* 宽屏时首页看板两列排布，财务卡占满底部 */
@media (min-width: 900px) {
  .dash-grid { grid-template-columns: 1fr 1fr; }
  .dash-fin { grid-column: 1 / -1; }
  #main { padding: 18px 22px; }
}

.dash-card { background: var(--card); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.dash-ov-title { font-size: 15px; font-weight: 600; margin-bottom: 12px; }

/* 财务主卡（腾讯蓝） */
.dash-hero { background: linear-gradient(135deg, #007aff, #0055d4); color: #fff; border-radius: 20px; padding: 20px 18px; box-shadow: 0 10px 24px rgba(0,122,255,.28); cursor: pointer; }
.dash-hero-label { font-size: 13px; opacity: .85; }
.dash-hero-val { font-size: 34px; font-weight: 700; margin: 4px 0 16px; letter-spacing: -.5px; }
.dash-hero-row { display: flex; gap: 8px; }
.dash-hero-item { flex: 1; background: rgba(255,255,255,.16); border-radius: 12px; padding: 10px 8px; text-align: center; }
.dash-hero-item .k { font-size: 11px; opacity: .82; }
.dash-hero-item .v { font-size: 15px; font-weight: 600; margin-top: 3px; }

/* 财务概览（白色卡片，净资产大数字） */
.dash-networth { font-size: 34px; font-weight: 700; letter-spacing: -.5px; text-align: center; margin: 4px 0 2px; }
.dash-networth-label { font-size: 12px; text-align: center; margin-bottom: 4px; }

/* 今日概览 KPI */
.dash-ov-row { display: flex; gap: 10px; }
.dash-mini { flex: 1; background: var(--bg); border-radius: 14px; padding: 14px 6px; text-align: center; }
.dash-mini.clk { cursor: pointer; }
.dash-mini-emoji { width: 40px; height: 40px; margin: 0 auto 8px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 20px; background: rgba(0,122,255,.1); }
.dash-mini-val { font-size: 20px; font-weight: 700; margin: 2px 0; }
.dash-mini-label { font-size: 12px; color: var(--muted); }

.prog { height: 8px; background: var(--bg); border-radius: 6px; margin-top: 12px; overflow: hidden; }
.prog-bar { height: 100%; background: var(--primary); border-radius: 6px; transition: width .4s; }

/* KPI 网格 */
.dash-metrics { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.metric-card { background: var(--card); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); cursor: pointer; }
.metric-card:active { transform: scale(.98); }
.metric-emoji { width: 36px; height: 36px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 18px; background: var(--bg); margin-bottom: 10px; }
.metric-val { font-size: 18px; font-weight: 700; margin: 2px 0; word-break: break-word; }
.metric-label { font-size: 12px; color: var(--muted); }

/* ---------- buttons ---------- */
.btn {
  font-family: inherit; font-size: 14px;
  border: none; border-radius: 10px;
  padding: 10px 16px;
  background: var(--border); color: var(--text);
  cursor: pointer; line-height: 1.2;
}
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--primary); color: #fff; }
.btn.primary:active { background: var(--primary-d); }
.btn.ghost { background: transparent; border: 1px solid var(--border); }
.btn.block { width: 100%; }
.btn.sm { padding: 6px 12px; font-size: 13px; }
.btn.danger { color: var(--danger); }

/* ---------- inputs ---------- */
.inp {
  width: 100%;
  box-sizing: border-box;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-family: inherit; font-size: 15px;
  background: #fff; color: var(--text);
  margin: 0;
}
.inp:focus { outline: none; border-color: var(--primary); }
textarea.inp { resize: vertical; min-height: 60px; }
.inp[type="color"] { height: 42px; padding: 3px; }
.inp[type="number"] { -moz-appearance: textfield; }

/* ---------- cards & lists ---------- */
.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: var(--shadow);
}
.card.row { display: flex; align-items: center; gap: 10px; padding: 12px 14px; }
.grow { flex: 1 1 auto; min-width: 0; }

/* ---- media poster (豆瓣封面/海报缩略图) ---- */
.media-poster-wrap { flex: 0 0 auto; width: 48px; height: 68px; border-radius: 8px; overflow: hidden; background: var(--bg); }
.media-poster { width: 100%; height: 100%; object-fit: cover; display: block; }

/* ---- accounts overview (净资产折叠卡 + 前缀分组) ---- */
.acc-net { cursor: pointer; display: flex; align-items: center; gap: 10px; padding: 14px; user-select: none; }
.acc-net:active { opacity: 0.7; }
.acc-net-val { font-size: 28px; font-weight: 700; margin-top: 4px; }
.acc-group { font-size: 12px; color: var(--muted); font-weight: 600; margin: 10px 4px 6px; }

.list { display: flex; flex-direction: column; gap: 10px; }
.todo-sec-head { display: flex; align-items: center; gap: 8px; margin: 14px 2px 4px; padding-top: 8px; border-top: 1px solid var(--border); }
.todo-sec-head:first-child { border-top: none; margin-top: 2px; padding-top: 0; }
.todo-sec-head .lab { font-size: 13px; font-weight: 600; color: var(--text); letter-spacing: .5px; }
.todo-sec-head .cnt { font-size: 11px; color: var(--muted); background: var(--bg); border-radius: 10px; padding: 1px 8px; }

/* ---------- section header ---------- */
.sec-head { display: flex; align-items: center; justify-content: space-between; margin: 4px 2px 12px; }
.sec-head h3 { margin: 0; font-size: 16px; }

.empty { color: var(--muted); text-align: center; padding: 34px 0; font-size: 14px; }
.muted { color: var(--muted); font-size: 13px; }

/* ---------- segmented control ---------- */
.seg { display: inline-flex; background: var(--bg); border-radius: 10px; padding: 3px; gap: 3px; }
.seg-btn {
  border: none; background: none;
  padding: 7px 14px; border-radius: 8px;
  font-family: inherit; font-size: 13px; color: var(--muted); cursor: pointer;
}
.seg-btn.active { background: #fff; color: var(--primary); box-shadow: var(--shadow); font-weight: 600; }

/* ---------- habits ---------- */
.habit-today.done { background: #eafaf1; }
.h-name { font-weight: 600; font-size: 15px; }
.stepper { display: flex; align-items: center; gap: 10px; }
.stepper .count { min-width: 44px; text-align: center; font-weight: 600; font-size: 15px; }

.heat { overflow-x: auto; padding: 4px 0 6px; -webkit-overflow-scrolling: touch; }
.heat svg { display: block; }

.stat-line { display: flex; justify-content: space-between; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--bg); font-size: 14px; }
.stat-line:last-child { border-bottom: none; }

.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.paper-stat-grid { grid-template-columns: repeat(2, 1fr); }
.stat-card { background: var(--card); border-radius: var(--radius); padding: 14px 6px; text-align: center; box-shadow: var(--shadow); }
.stat-val { font-size: 22px; font-weight: 700; color: var(--primary); }
.stat-label { font-size: 12px; color: var(--muted); margin-top: 4px; }

/* ---------- friend rows ---------- */
.friend-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  background: var(--card); border-radius: var(--radius);
  padding: 12px 14px; box-shadow: var(--shadow);
}
.friend-row.muted { opacity: .7; }
.clk { cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.clk:active { opacity: .6; }

/* ---------- auth ---------- */
.auth-box {
  max-width: 360px;
  margin: auto;
  background: var(--card);
  border-radius: var(--radius);
  padding: 28px 22px;
  box-shadow: var(--shadow);
}
.auth-logo { display: flex; flex-direction: column; align-items: center; gap: 12px; margin-bottom: 18px; }
.auth-icon { width: 80px; height: 80px; border-radius: 19px; box-shadow: 0 8px 24px rgba(0, 122, 255, .28); }
.auth-name { font-size: 22px; font-weight: 700; }
.auth-sub { color: var(--muted); text-align: center; margin-bottom: 20px; font-size: 14px; }
.auth-box .inp { margin-bottom: 12px; }
.auth-hint { color: var(--muted); font-size: 12px; text-align: center; margin-top: 14px; line-height: 1.5; }

/* ---------- menu ---------- */
.menu-user { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.menu-item {
  display: block; width: 100%; text-align: left;
  border: none; background: none;
  padding: 13px 4px; font-family: inherit; font-size: 15px;
  color: var(--text); cursor: pointer; border-bottom: 1px solid var(--bg);
}
.menu-item.danger { color: var(--danger); }
.menu-item:last-child { border-bottom: none; }
.menu-item:active { background: var(--bg); }

/* ---------- invites / admin ---------- */
.invite-list { display: flex; flex-direction: column; gap: 6px; margin: 8px 0 14px; }
.invite-row { display: flex; justify-content: space-between; align-items: center; background: var(--bg); padding: 8px 12px; border-radius: 8px; font-size: 13px; }
code { background: var(--bg); padding: 2px 6px; border-radius: 5px; font-size: 13px; }

/* ---------- generic row + forms ---------- */
.row { display: flex; gap: 8px; align-items: center; }
.row > .inp { flex: 1 1 auto; }

.form { display: flex; flex-direction: column; gap: 2px; }
.form label { font-size: 13px; color: var(--muted); margin-top: 8px; }
.form .inp { margin-top: 2px; }

.freq { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 4px; }
.freq-day { display: flex; align-items: center; gap: 4px; font-size: 14px; }
.freq-day input { margin: 0; }

/* ---------- modal (bottom sheet on mobile) ---------- */
.tb-modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.45);
  display: flex; align-items: flex-end; justify-content: center;
  z-index: 100;
}
.tb-modal {
  background: var(--card);
  width: 100%; max-width: 520px;
  border-radius: 18px 18px 0 0;
  padding: 20px 18px calc(20px + env(safe-area-inset-bottom));
  max-height: 88vh; overflow-y: auto;
}
.tb-modal-title { font-size: 18px; font-weight: 700; margin-bottom: 14px; }
.tb-modal-actions { display: flex; gap: 10px; margin-top: 18px; }
.tb-modal-actions .btn { flex: 1 1 0; }

@media (min-width: 600px) {
  .tb-modal-overlay { align-items: center; }
  .tb-modal { border-radius: 18px; max-height: 90vh; }
  .tab-bar { justify-content: center; }
}

/* ---------- toast ---------- */
.tb-toast {
  position: fixed; left: 50%; bottom: 90px;
  transform: translateX(-50%) translateY(20px);
  background: rgba(0,0,0,.82); color: #fff;
  padding: 10px 18px; border-radius: 22px;
  font-size: 14px; opacity: 0; pointer-events: none;
  transition: opacity .25s, transform .25s;
  z-index: 200; max-width: 80%; text-align: center;
}
.tb-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- todos (TickTick style) ---------- */
.todo-card { background: var(--card); border-radius: var(--radius); padding: 12px 14px; box-shadow: var(--shadow); }
.todo-card.done { opacity: .55; }
.todo-row { display: flex; align-items: flex-start; gap: 10px; }
.chk { flex: 0 0 auto; width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--border); margin-top: 2px; cursor: pointer; box-sizing: border-box; }
.chk.on { background: var(--primary); border-color: var(--primary); position: relative; }
.chk.on::after { content: '✓'; color: #fff; font-size: 12px; line-height: 16px; position: absolute; left: 3px; top: 0; }
.prio-dot { flex: 0 0 auto; width: 10px; height: 10px; border-radius: 50%; margin-top: 6px; display: inline-block; box-sizing: border-box; }
.todo-main { min-width: 0; }
.todo-title { font-size: 15px; font-weight: 600; word-break: break-word; }
.todo-card.done .todo-title { text-decoration: line-through; color: var(--muted); }
.todo-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; align-items: center; }
.tag-chip { font-size: 12px; padding: 2px 8px; border-radius: 10px; background: var(--bg); color: var(--muted); cursor: pointer; display: inline-block; }
.tag-chip.on { background: var(--primary); color: #fff; }
.due-chip { font-size: 12px; padding: 2px 8px; border-radius: 10px; background: #fff3e0; color: #c77700; }
.due-chip.over { background: #fde8e8; color: var(--danger); }
.proj-chip { font-size: 12px; color: var(--muted); }
.sub-prog { font-size: 12px; color: var(--muted); cursor: pointer; }
.todo-edit { margin: 0; font-size: 15px; font-weight: 600; }
.list-bar { display: flex; gap: 6px; overflow-x: auto; padding: 2px 0 8px; -webkit-overflow-scrolling: touch; }
.list-chip { flex: 0 0 auto; border: none; background: var(--bg); color: var(--muted); padding: 6px 12px; border-radius: 20px; font-size: 13px; cursor: pointer; white-space: nowrap; font-family: inherit; }
.list-chip.active { background: var(--primary); color: #fff; }
.list-chip .cnt { opacity: .7; margin-left: 4px; font-size: 11px; }
.tag-bar { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.sub-box { margin-top: 8px; padding-left: 30px; }
.sub-item { display: flex; align-items: center; gap: 8px; padding: 4px 0; font-size: 14px; }
.sub-chk { width: 16px; height: 16px; border-radius: 4px; border: 2px solid var(--border); cursor: pointer; flex: 0 0 auto; box-sizing: border-box; }
.sub-chk.on { background: var(--primary); border-color: var(--primary); position: relative; }
.sub-chk.on::after { content: '✓'; color: #fff; font-size: 11px; line-height: 12px; position: absolute; left: 1px; top: 0; }
.tb-undo { position: fixed; left: 50%; bottom: 80px; transform: translateX(-50%); background: rgba(0,0,0,.85); color: #fff; padding: 10px 14px; border-radius: 12px; display: flex; gap: 12px; align-items: center; z-index: 300; font-size: 14px; max-width: 90%; }
.tb-undo .btn { padding: 6px 12px; font-size: 13px; }
.prio-sel { display: flex; gap: 8px; margin-top: 4px; }
.prio-btn { flex: 1; border: 1px solid var(--border); background: #fff; border-radius: 10px; padding: 8px; cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 6px; font-size: 13px; font-family: inherit; }
.prio-btn.on { border-color: var(--primary); background: #f0faf5; }

/* ---------- diary ---------- */
.diary-nav { display: flex; align-items: center; gap: 8px; margin: 0 2px 12px; flex-wrap: wrap; }
.diary-nav .seg { flex: 0 0 auto; }
.diary-nav .btn.ghost.sm { margin-left: auto; }
.filter-chip { border: none; background: var(--primary); color: #fff; border-radius: 14px; padding: 5px 12px; font-size: 13px; cursor: pointer; font-family: inherit; }
.diary-lbl { font-size: 13px; color: var(--muted); margin-top: 10px; display: block; }

/* calendar */
.cal-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.cal-arrow { border: none; background: var(--bg); width: 34px; height: 34px; border-radius: 50%; font-size: 18px; cursor: pointer; color: var(--text); }
.cal-mlabel { font-weight: 600; font-size: 15px; }
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-wd { text-align: center; font-size: 12px; color: var(--muted); padding: 4px 0; }
.cal-cell { border: none; background: var(--card); border-radius: 10px; min-height: 46px; padding: 4px 0; cursor: pointer; font-family: inherit; display: flex; flex-direction: column; align-items: center; justify-content: center; box-shadow: var(--shadow); }
.cal-cell.empty { background: transparent; box-shadow: none; cursor: default; }
.cal-cell.today { outline: 2px solid var(--primary); outline-offset: -2px; }
.cal-num { font-size: 14px; font-weight: 600; }
.cal-cell.has .cal-num { color: var(--primary); }
.cal-emoji { font-size: 14px; line-height: 1; margin-top: 2px; }

/* timeline */
.tl-item { background: var(--card); border-radius: var(--radius); padding: 12px 14px; box-shadow: var(--shadow); cursor: pointer; margin-bottom: 10px; }
.tl-row { display: flex; align-items: center; gap: 8px; }
.tl-mood { font-size: 18px; }
.tl-date { font-size: 13px; color: var(--muted); }
.tl-title { font-size: 15px; font-weight: 600; margin-top: 4px; }
.tl-prev { font-size: 13px; color: var(--muted); margin-top: 3px; line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* detail / view (read-only) */
.diary-detail-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.diary-view { font-size: 15px; line-height: 1.7; word-break: break-word; }
.diary-view:empty::before { content: '(空)'; color: var(--muted); }
.diary-actions { display: flex; gap: 8px; margin-top: 12px; }

/* editor (rich text) */
.diary-toolbar { display: flex; flex-wrap: wrap; gap: 4px; margin: 6px 0; align-items: center; }
.diary-tb-sel { font-family: inherit; font-size: 13px; padding: 5px 6px; border: 1px solid var(--border); border-radius: 8px; background: #fff; }
.diary-tb-btn { min-width: 30px; height: 30px; border: 1px solid var(--border); background: #fff; border-radius: 8px; cursor: pointer; font-family: inherit; font-size: 13px; padding: 0 8px; }
.diary-tb-btn:active { background: var(--bg); }
.diary-editor { border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; min-height: 160px; font-size: 15px; line-height: 1.7; background: #fff; outline: none; overflow-y: auto; max-height: 50vh; }
.diary-editor:focus { border-color: var(--primary); }
.diary-editor:empty::before { content: attr(data-ph); color: var(--muted); }

/* ---------- finance: import/export toolbar + selection ---------- */
.finance-tbar { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.finance-tbar .btn { flex: 0 0 auto; }
.finance-selbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 12px; background: var(--card); }
.finance-selbar .count { font-size: 13px; color: var(--muted); }
.finance-selbar input[type="checkbox"] { width: 18px; height: 18px; flex: 0 0 auto; }
.list .card.row input[type="checkbox"] { width: 18px; height: 18px; flex: 0 0 auto; }

/* ---------- todos: view toggle & project menu ---------- */
.view-toggle { display: inline-flex; background: var(--bg); border-radius: 10px; padding: 3px; gap: 3px; }
.vt-btn { border: none; background: none; padding: 6px 14px; border-radius: 8px; font-family: inherit; font-size: 13px; color: var(--muted); cursor: pointer; }
.vt-btn.on { background: #fff; color: var(--primary); box-shadow: var(--shadow); font-weight: 600; }

.list-chip-wrap { display: inline-flex; align-items: stretch; flex: 0 0 auto; }
.list-chip-wrap .list-chip { border-radius: 20px 0 0 20px; margin: 0; }
.list-chip-menu { flex: 0 0 auto; border: none; background: var(--bg); color: var(--muted); border-radius: 0 20px 20px 0; padding: 6px 9px; font-size: 14px; cursor: pointer; font-family: inherit; margin-left: 2px; }
.list-chip-wrap .list-chip.active + .list-chip-menu { background: var(--primary); color: #fff; }

/* ---------- todos: status & recurrence chips ---------- */
.status-chip { font-size: 11px; padding: 1px 7px; border-radius: 9px; }
.status-chip.doing { background: #e7f0ff; color: #2f6bd8; }
.recur-chip { font-size: 11px; padding: 1px 7px; border-radius: 9px; background: #f3ecff; color: #7b3fe4; }

/* ---------- todos: drag & manual sort ---------- */
.todo-card.dragging { opacity: .4; }
.todo-card.drag-over { border: 1px dashed var(--primary); }
.kanban { cursor: grab; }

/* ---------- todos: kanban board ---------- */
.board { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; align-items: start; }
.board-col { background: var(--bg); border-radius: 12px; padding: 8px; display: flex; flex-direction: column; min-width: 0; }
.board-col.drag-over { outline: 2px dashed var(--primary); outline-offset: -2px; }
.board-col-head { display: flex; align-items: center; justify-content: space-between; font-size: 13px; font-weight: 600; margin-bottom: 8px; padding: 0 2px; }
.board-col-body { display: flex; flex-direction: column; gap: 8px; min-height: 40px; }
.board-empty { color: var(--muted); font-size: 12px; text-align: center; padding: 14px 4px; border: 1px dashed var(--border); border-radius: 10px; }
.board-col .todo-card { padding: 10px 12px; }
.board-col .todo-row { gap: 8px; }
.board-col .todo-title { font-size: 14px; }

/* ---------- todos: detail modal ---------- */
.detail { display: flex; flex-direction: column; gap: 12px; }
.detail-title { font-size: 18px; font-weight: 700; word-break: break-word; }
.detail-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.detail-item { background: var(--bg); border-radius: 10px; padding: 8px 10px; }
.detail-k { font-size: 12px; color: var(--muted); margin-bottom: 2px; }
.detail-v { font-size: 14px; font-weight: 600; word-break: break-word; }
.detail-sub { font-size: 13px; color: var(--muted); margin: 4px 0 6px; }
.detail-note { background: var(--bg); border-radius: 10px; padding: 10px 12px; }
.detail-note-body { font-size: 14px; line-height: 1.6; white-space: pre-wrap; word-break: break-word; }
.detail-subs { background: var(--bg); border-radius: 10px; padding: 10px 12px; }
.detail-sub-list { display: flex; flex-direction: column; gap: 6px; }
.detail-meta { font-size: 12px; color: var(--muted); border-top: 1px solid var(--border); padding-top: 10px; }

/* ---------- timer: live timer card ---------- */
.timer-card { text-align: center; padding: 18px 14px; }
.timer-state { font-size: 13px; color: var(--muted); margin-bottom: 8px; }
.timer-state.running { color: #e53935; font-weight: 600; }
.timer-display { font-size: 44px; font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: 1px; line-height: 1.1; margin: 4px 0 6px; }
.timer-cat { font-size: 13px; color: var(--muted); margin-bottom: 14px; }

/* ---------- timer: goals (core feedback) ---------- */
.goals { display: flex; flex-direction: column; gap: 12px; }
.goal { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 12px; }
.goal-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.goal-cat { font-weight: 700; font-size: 15px; }
.goal-pct { font-size: 14px; font-weight: 700; color: var(--primary); }
.goal-pct.done { color: #2e9e4f; }
.goal-bar { height: 10px; background: var(--bg); border-radius: 6px; overflow: hidden; }
.goal-fill { height: 100%; border-radius: 6px; transition: width .35s ease; background: var(--primary); }
.goal-fill.over { background: #2e9e4f; }
.goal-meta { font-size: 12px; color: var(--muted); margin-top: 6px; }
.goal-ops { display: flex; gap: 8px; margin-top: 8px; }

/* ---------- timer: segmented control ---------- */
.seg { display: inline-flex; background: var(--bg); border-radius: 10px; padding: 3px; gap: 3px; margin-bottom: 10px; }
.seg-btn { border: none; background: none; padding: 6px 14px; border-radius: 8px; font-family: inherit; font-size: 13px; color: var(--muted); cursor: pointer; }
.seg-btn.active { background: #fff; color: var(--primary); box-shadow: var(--shadow); font-weight: 600; }

/* ---------- timer: charts ---------- */
.chart-box { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 10px; }
.heat-host { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 10px; overflow-x: auto; }
.center { text-align: center; }

/* ---------- timer: logs ---------- */
.logs { display: flex; flex-direction: column; gap: 8px; }
.log-row { display: flex; align-items: center; gap: 10px; background: var(--card); border: 1px solid var(--border); border-radius: 10px; padding: 8px 10px; }
.log-main { flex: 1 1 auto; min-width: 0; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.log-cat { font-size: 12px; font-weight: 600; border: 1px solid var(--border); border-left-width: 3px; border-radius: 6px; padding: 2px 8px; }
.log-note { font-size: 13px; color: var(--muted); }
.log-meta { flex: 0 0 auto; font-size: 12px; color: var(--muted); }

/* ---------- notes (second brain / knowledge base) ---------- */
.notes-root { display: flex; flex-direction: column; height: 100%; }
.notes-app { flex: 1 1 auto; min-height: 0; display: flex; gap: 10px; }
.notes-side { flex: 0 0 192px; display: flex; flex-direction: column; min-height: 0; }
.nv-search { margin-bottom: 8px; }
.nv-cats { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 8px; flex: 0 0 auto; scrollbar-width: none; }
.nv-cats::-webkit-scrollbar { display: none; }
.nv-cat-chip { flex: 0 0 auto; border: none; background: var(--bg); color: var(--muted); padding: 5px 12px; border-radius: 20px; font-size: 13px; cursor: pointer; font-family: inherit; white-space: nowrap; }
.nv-cat-chip.active { background: var(--primary); color: #fff; }
.nv-list { flex: 1 1 auto; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; min-height: 0; }
.nv-item { background: var(--card); border-radius: var(--radius); padding: 10px 12px; box-shadow: var(--shadow); cursor: pointer; border: 1px solid transparent; }
.nv-item.active { border-color: var(--primary); }
.nv-item-top { display: flex; align-items: center; gap: 4px; }
.nv-item-title { font-size: 14px; font-weight: 600; flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nv-item-prev { font-size: 12px; color: var(--muted); margin-top: 4px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; line-height: 1.4; }
.nv-item-time { font-size: 11px; color: var(--muted); margin-top: 4px; }
.nv-pin, .nv-star { font-size: 12px; flex: 0 0 auto; }
.nv-item.trashed { opacity: .6; }
mark { background: #fff3a0; color: inherit; border-radius: 3px; padding: 0 1px; }
.nv-main { flex: 1 1 auto; display: flex; flex-direction: column; min-height: 0; }
.nv-back { display: none; align-self: flex-start; margin-bottom: 8px; }
.nv-title { font-size: 16px; font-weight: 700; margin-bottom: 8px; }
.nv-toolbar { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-bottom: 8px; }
.nv-cat { width: auto; flex: 1 1 auto; min-width: 90px; }
.nv-body { flex: 1 1 auto; min-height: 0; resize: none; font-family: inherit; line-height: 1.6; font-size: 15px; }
.nv-preview { flex: 1 1 auto; overflow-y: auto; background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; font-size: 15px; line-height: 1.7; word-break: break-word; }
.nv-saved { font-size: 12px; margin-left: auto; }
.nv-empty { text-align: center; padding: 40px 10px; }
.btn.on { background: var(--primary); color: #fff; }

/* markdown preview */
.nv-preview .nv-h { margin: .5em 0 .35em; line-height: 1.3; }
.nv-preview h1 { font-size: 20px; } .nv-preview h2 { font-size: 18px; } .nv-preview h3 { font-size: 16px; }
.nv-preview p { margin: .5em 0; }
.nv-preview ul, .nv-preview ol { margin: .4em 0; padding-left: 1.4em; }
.nv-preview li { margin: .2em 0; }
.nv-preview blockquote { margin: .5em 0; padding: 6px 12px; border-left: 3px solid var(--border); color: var(--muted); background: var(--bg); border-radius: 0 8px 8px 0; }
.nv-preview pre { background: var(--bg); padding: 10px 12px; border-radius: 10px; overflow-x: auto; }
.nv-preview code { background: var(--bg); padding: 1px 5px; border-radius: 5px; font-size: 13px; }
.nv-preview pre code { padding: 0; background: none; }
.nv-preview a { color: var(--primary); }
.nv-preview hr { border: none; border-top: 1px solid var(--border); margin: .8em 0; }

/* responsive: phone single column */
@media (max-width: 479px) {
  .notes-app { display: block; }
  .notes-side { flex: none; width: auto; height: 100%; }
  .notes-root.show-editor .notes-side { display: none; }
  .notes-root:not(.show-editor) .nv-main { display: none; }
  .nv-back { display: inline-flex; }
  .nv-main { height: 100%; }
}

/* ---------- goals (SMART + milestones + review) ---------- */
.goal { padding: 14px; }
.goal-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.goal-title { font-size: 15px; font-weight: 700; flex: 1 1 auto; min-width: 0; }
.goal-smart { font-size: 12px; color: var(--muted); margin-top: 6px; line-height: 1.5; }
.goal-meta { display: flex; justify-content: space-between; gap: 8px; margin-top: 8px; font-size: 13px; }
.goal-ms { font-size: 12px; color: var(--muted); margin-top: 4px; }
.goal-ops { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.goal-ops .btn { flex: 0 0 auto; }
.goal-badge { flex: 0 0 auto; font-size: 11px; padding: 2px 8px; border-radius: 10px; background: var(--bg); color: var(--muted); white-space: nowrap; }
.goal-badge.ok { background: #eafaf1; color: #2e9e4f; }
.goal-badge.done { background: #e7f6ec; color: #2e9e4f; }
.goal-badge.warn { background: #fff4e0; color: #c77700; }
.goal-badge.bad { background: #fde8e8; color: var(--danger); }
.goal-badge.arch { background: var(--bg); color: var(--muted); }
.goal-kv { display: flex; gap: 8px; padding: 4px 0; font-size: 13px; border-bottom: 1px solid var(--bg); }
.goal-kv:last-child { border-bottom: none; }
.goal-k { flex: 0 0 92px; color: var(--muted); }
.goal-v { flex: 1 1 auto; min-width: 0; word-break: break-word; }
.ms-row { display: flex; align-items: center; gap: 8px; padding: 6px 0; font-size: 14px; border-bottom: 1px solid var(--bg); }
.ms-row:last-child { border-bottom: none; }
.ms-row input[type="checkbox"] { width: 18px; height: 18px; flex: 0 0 auto; }
.ms-title { flex: 1 1 auto; min-width: 0; }
.ms-done .ms-title { text-decoration: line-through; color: var(--muted); }
.ms-row .btn { flex: 0 0 auto; padding: 2px 10px; }
.goal-smartlegend { display: flex; gap: 4px; }
.sm-chip { width: 22px; height: 22px; border-radius: 6px; display: inline-flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 600; background: var(--bg); color: var(--muted); border: 1px solid var(--border); }
.sm-chip.on { background: #eafaf1; color: #2e9e4f; border-color: #bce8cd; border-width: 2px; }

/* ---- data backup panel ---- */
.ds-all { padding: 14px; margin-bottom: 6px; }
.ds-all-title { font-weight: 600; font-size: 15px; }
.ds-all-sub { font-size: 12px; margin-top: 2px; }
.ds-list { display: flex; flex-direction: column; gap: 8px; }
.ds-row { display: flex; align-items: center; gap: 10px; padding: 10px 12px; }
.ds-label { font-weight: 600; font-size: 14px; }
.ds-note { font-size: 11px; margin-top: 2px; }
.ds-btns { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }

/* ---- reconciliation highlight ---- */
.recon-hl { background: #fff8e1 !important; border-color: #f3d27a !important; }

/* ---- dashboard goal cards ---- */
.dash-goals { display: flex; flex-direction: column; gap: 10px; }
.dash-goal { padding: 8px 0; }
.dash-goal-top { display: flex; justify-content: space-between; align-items: baseline; font-size: 14px; font-weight: 600; }
.dash-goal-pct { font-size: 13px; color: var(--muted); }
.dash-goal-meta { font-size: 12px; color: var(--muted); margin-top: 3px; }
.dash-goal.done .dash-goal-pct { color: #2e9e4b; }
.dash-goal.over .dash-goal-pct { color: #dc2626; }
.dash-goal.warn .dash-goal-pct { color: #f59e0b; }

/* ---- habit skip / paused ---- */
.habit-today.skipped { opacity: 0.6; }
.habit-today.skipped .h-name { text-decoration: line-through; }
.card.row.paused { opacity: 0.55; }

/* ---- star rating picker ---- */
.star-pick { display: flex; gap: 6px; font-size: 28px; cursor: pointer; user-select: none; padding: 4px 0; }
.star-pick .star { color: #d1d5db; transition: color 0.1s; }
.star-pick .star.on { color: #f59e0b; }

/* ---- notes rich-text toolbar ---- */
.nv-fmtbar { display: flex; flex-wrap: wrap; gap: 4px; margin: 6px 0; }
.fmt-btn { border: 1px solid var(--border); background: var(--bg); color: var(--text); border-radius: 6px; padding: 3px 8px; font-size: 12px; cursor: pointer; }
.fmt-btn:hover { border-color: var(--primary); color: var(--primary); }

/* ---- todo calendar view ---- */
.calendar { display: flex; flex-direction: column; }
.cal-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.cal-title { font-weight: 600; font-size: 15px; }
.cal-week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; margin-bottom: 4px; }
.cal-dow { text-align: center; font-size: 12px; color: var(--muted); padding: 2px 0; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-cell { position: relative; border: 1px solid var(--border); border-radius: 8px; padding: 6px 4px; text-align: center; cursor: pointer; min-height: 40px; background: var(--bg); }
.cal-cell.empty { border-color: transparent; cursor: default; }
.cal-cell.today { border-color: var(--primary); }
.cal-cell.sel { background: var(--primary); }
.cal-cell.sel .cal-num { color: #fff; }
.cal-num { font-size: 13px; }
.cal-dot { position: absolute; top: 4px; right: 4px; min-width: 16px; height: 16px; border-radius: 8px; background: var(--primary); color: #fff; font-size: 10px; line-height: 16px; text-align: center; padding: 0 3px; }
.cal-cell.sel .cal-dot { background: #fff; color: var(--primary); }
.cal-list { margin-top: 10px; display: flex; flex-direction: column; gap: 6px; }

/* ---- timer timeline ---- */
.timeline { display: flex; flex-direction: column; margin-top: 8px; }

/* ---- countdown (倒数日) ---- */
.cd-card { position: relative; display: flex; flex-wrap: wrap; align-items: center; gap: 14px 14px; padding: 14px 12px; border: 1px solid var(--border); border-radius: 12px; background: var(--card); margin-bottom: 8px; }
.cd-card.pinned { border-color: var(--primary); background: color-mix(in srgb, var(--primary) 6%, var(--card)); }
.cd-card.today { border-color: #f59e0b; }
.cd-num-wrap { display: flex; flex-direction: column; align-items: center; min-width: 64px; }
.cd-num { font-size: 34px; font-weight: 700; line-height: 1; color: var(--primary); }
.cd-card.today .cd-num { color: #f59e0b; }
.cd-unit { font-size: 12px; color: var(--muted); margin-top: 4px; }
.cd-main { flex: 1; min-width: 0; }
.cd-title { display: flex; align-items: center; gap: 4px; font-weight: 600; font-size: 15px; }
.cd-pin { font-size: 12px; }
.cd-sub { font-size: 13px; color: var(--text); margin-top: 2px; }
.cd-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; align-items: center; }
.cd-tag { font-size: 12px; color: var(--muted); }
.cd-ops { display: flex; flex-direction: column; gap: 4px; flex-shrink: 0; }
.cd-note { font-size: 12px; margin-top: 2px; padding-top: 6px; border-top: 1px dashed var(--border); width: 100%; flex-basis: 100%; }

/* ===== 论文推进首页（thesis home） ===== */
.th-sec-title { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 15px; margin-bottom: 10px; }
.th-link { margin-left: auto; font-size: 12px; color: var(--primary); cursor: pointer; }
.th-link:hover { text-decoration: underline; }

/* 激励语 */
.th-motiv { background: color-mix(in srgb, var(--primary) 7%, var(--card)); }
.th-motiv-text { font-size: 15px; line-height: 1.6; color: var(--text); white-space: pre-wrap; }

/* 提交论文倒计时 hero */
.th-hero { background: linear-gradient(135deg, #007aff, #0055d4); color: #fff; border: none; box-shadow: 0 10px 24px rgba(0,122,255,.28); }
.th-hero-label { font-size: 14px; opacity: .9; }
.th-hero-num { font-size: 56px; font-weight: 800; line-height: 1; margin: 6px 0; letter-spacing: -1px; }
.th-hero-sub { font-size: 13px; opacity: .92; }

/* 行列表（打卡 / 待办） */
.th-rows { display: flex; flex-direction: column; gap: 8px; }
.th-row { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--bg); }
.th-row.done { background: color-mix(in srgb, #22c55e 10%, var(--bg)); border-color: color-mix(in srgb, #22c55e 38%, var(--border)); }
.th-row-main { flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; }
.th-emoji { font-size: 18px; flex-shrink: 0; }
.th-name { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.th-row.done .th-name { color: var(--muted); text-decoration: line-through; }
.th-todo-title { flex: 1; min-width: 0; font-size: 14px; cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.th-todo-title:hover { color: var(--primary); }
.th-chk { width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--border); flex-shrink: 0; cursor: pointer; position: relative; transition: border-color .1s; }
.th-chk:hover { border-color: var(--primary); }
.th-chk.on { background: var(--primary); border-color: var(--primary); }
.th-chk.on::after { content: '✓'; color: #fff; font-size: 12px; position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; }

/* 论文日记 */
.th-diary-body { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; }
.th-diary-done { font-size: 14px; color: #16a34a; font-weight: 600; }
.th-diary-todo { font-size: 14px; color: var(--muted); }
.th-empty { font-size: 13px; color: var(--muted); padding: 4px 2px; }

/* 愿望清单 · 毕业奖励 */
.th-wish-add { display: flex; gap: 8px; margin-top: 10px; }
.th-wish-inp { flex: 1; min-width: 0; }
.th-del { border: none; background: transparent; color: var(--muted); cursor: pointer; font-size: 15px; line-height: 1; padding: 0 6px; flex-shrink: 0; transition: color .1s; }
.th-del:hover { color: #ef4444; }

/* ===== 体重趋势折线图悬浮提示 ===== */
.chart-tip { position: absolute; pointer-events: none; background: rgba(20,20,25,.92); color: #fff; padding: 6px 9px; border-radius: 8px; font-size: 12px; line-height: 1.45; box-shadow: 0 4px 14px rgba(0,0,0,.25); white-space: nowrap; z-index: 5; }
.chart-tip-date { opacity: .72; font-size: 11px; }
.chart-tip-val { font-weight: 600; }
#lc-svg { touch-action: none; }

/* 首页体重速览卡片 */
.th-weight { cursor: default; }
.th-weight-main { padding: 2px 2px 4px; }
.th-weight-num { font-size: 32px; font-weight: 800; line-height: 1.1; color: var(--text); letter-spacing: -.5px; }
.th-weight-meta { margin-top: 5px; font-size: 13px; color: var(--muted); display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.th-weight-delta { font-weight: 600; }
.th-weight-delta.up { color: #f59e0b; }
.th-weight-delta.down { color: #2e9e6b; }
.th-weight-delta.flat { color: var(--muted); }
.th-weight-chart-title { margin: 12px 0 2px; font-size: 13px; font-weight: 600; color: var(--muted); }
.th-weight-chart { margin-top: 4px; }
.th-weight-chart .empty { font-size: 13px; padding: 10px 0 2px; }

/* 论文写作：进度条 + 首页卡片 */
.th-progress { height: 10px; background: var(--bg); border-radius: 6px; overflow: hidden; }
.th-progress-fill { height: 100%; background: linear-gradient(90deg, #8b5cf6, #3b82f6); border-radius: 6px; transition: width .4s ease; }
.th-paper { cursor: default; }
.th-paper-main { display: flex; align-items: flex-start; gap: 28px; margin-top: 6px; flex-wrap: wrap; }
.th-paper-col { display: flex; flex-direction: column; }
.th-paper-num { font-size: 28px; font-weight: 800; line-height: 1.1; color: var(--text); letter-spacing: -.5px; }
.th-paper-lbl { font-size: 12px; color: var(--muted); margin-top: 4px; }
.th-paper-meta { display: flex; gap: 12px; color: var(--muted); font-size: 13px; margin-top: 10px; flex-wrap: wrap; }
