:root {
  --bg: #f5e6d3;
  --bg-soft: #fffaf0;
  --surface: #fffaf0;
  --surface-2: #fdf3e3;
  --primary: #3d2817;
  --primary-rgb: 61, 40, 23;
  --primary-light: #5a3d26;
  --gold: #c9a35a;
  --gold-deep: #a8833a;
  --gold-light: #e8c880;
  --accent: var(--accent);
  --accent-deep: var(--accent-deep);
  --accent-light: var(--accent-light);
  --text: #2d1f15;
  --text-secondary: #7d6650;
  --muted: #9c846b;
  --danger: #b94e4e;
  --success: #5c8d57;
  --radius: 14px;
  --radius-sm: 8px;
  --shadow: 0 2px 10px rgba(61,40,23,0.08);
  --shadow-lg: 0 8px 28px rgba(61,40,23,0.14);
  --header-h: 52px;
  --nav-h: 62px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

/* 强调色覆盖（用户可选：金色 / 主色 / 低调灰） */
[data-accent="primary"] { --accent: var(--primary); --accent-deep: var(--primary); --accent-light: var(--primary-light); }
[data-accent="muted"]    { --accent: #8c7a66; --accent-deep: #6e5e4d; --accent-light: #a8927a; }
[data-accent="gold"]     { --accent: var(--gold); --accent-deep: var(--gold-deep); --accent-light: var(--gold-light); }

[data-theme="mocha"] {
  --bg: #efe6de;
  --bg-soft: #faf5ef;
  --surface: #faf5ef;
  --surface-2: #f5ebe2;
  --primary: #4a3222;
  --primary-rgb: 74,50,34;
  --gold: #b88d4f;
}

[data-theme="sage"] {
  --bg: #f0ece6;
  --bg-soft: #f8f7f3;
  --surface: #f8f7f3;
  --surface-2: #eef1ea;
  --primary: #3e4a3a;
  --primary-rgb: 62,74,58;
  --gold: #889b7e;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0; padding: 0;
  height: 100%; width: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 15px;
  line-height: 1.5;
  overflow: hidden;
}

html:has(#wbContainer:not([style*="display: none"])),
body:has(#wbContainer:not([style*="display: none"])) {
  overscroll-behavior: none;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100%;
}

#wbContainer {
  position: relative;
  z-index: 1;
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
  height: 100%;
  overflow: hidden;
}

#wbContainer .app-main {
  min-height: 0;
  flex: 1 1 auto;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  scrollbar-gutter: stable;
}

@media (max-width: 799px) {
  html, body { overflow-y: auto; }
  #wbContainer { min-height: 100%; height: auto; overflow: visible; }
  #wbContainer .app-main { overflow: visible; height: auto; flex: none; }
}

button, input, select, textarea {
  font-family: inherit;
  font-size: inherit;
  outline: none;
}
button { cursor: pointer; border: none; background: transparent; }
input, textarea, select {
  border: 1px solid rgba(var(--primary-rgb),0.12);
  background: var(--surface);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}
textarea { resize: vertical; min-height: 76px; }

/* 桌面端容器 */
body {
    display: flex;
    flex-direction: column;
}
  /* 工作台在动态背景 canvas 上方 */
  #wbContainer { position: relative; z-index: 1; flex: 1; display: flex !important; flex-direction: column; min-height: 0; overflow: hidden; }
  /* 兜底：登录后强制隐藏动态背景 canvas（即使其他代码尝试重新显示） */
  #dynamicBgCanvas.wb-hidden-bg { display: none !important; }

/* 顶部导航 */
.app-header {
  position: sticky; top: 0; z-index: 50;
  height: var(--header-h);
  background: var(--primary);
  color: #fff;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 12px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}
.app-header-left, .app-header-right { display: flex; align-items: center; gap: 8px; }
.app-title { font-size: 17px; font-weight: 600; margin: 0; letter-spacing: 0.5px; }
.icon-btn {
  color: #fff; opacity: 0.95;
  width: 34px; height: 34px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  transition: background .2s;
}
.icon-btn:active { background: rgba(255,255,255,0.15); }
.status-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 6px var(--accent);
}
.status-dot.offline { background: #888; box-shadow: none; }

/* 日期条 */
.date-bar {
  background: var(--surface);
  display: flex; align-items: center; justify-content: center;
  padding: 10px 12px;
  gap: 10px;
  border-bottom: 1px solid rgba(var(--primary-rgb),0.06);
  position: relative;
}
.date-bar-collapse {
  position: absolute; left: 10px;
  color: var(--text-secondary);
  transform: rotate(0deg);
  transition: transform .2s;
}
.date-bar-collapse.open { transform: rotate(180deg); }
.date-arrow {
  color: var(--accent-deep); font-size: 20px; font-weight: 700;
  width: 30px; height: 30px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
}
.date-arrow:active { background: rgba(var(--primary-rgb),0.08); }
.date-bar-title { font-weight: 600; min-width: 86px; text-align: center; }
.date-pill {
  display: none;
  background: rgba(var(--primary-rgb),0.06);
  padding: 3px 10px; border-radius: 20px;
  font-size: 12px; color: var(--text-secondary);
}
.date-jump {
  position: absolute; right: 10px;
  font-size: 12px; color: var(--accent-deep);
  background: rgba(201,163,90,0.12);
  padding: 4px 10px; border-radius: 20px;
}

/* 日历面板 — 紧凑居中，不让格子过度拉大 */
.calendar-panel {
  background: var(--surface);
  padding: 10px 14px 16px;
  border-bottom: 1px solid rgba(var(--primary-rgb),0.06);
  animation: slideDown .2s ease;
}
@keyframes slideDown { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: translateY(0); } }
/* 居中容器：限制最大宽度 + 居中，避免在宽屏上空旷 */
.calendar-weekdays, .calendar-days {
  max-width: 560px;
  margin-left: auto;
  margin-right: auto;
}
.calendar-weekdays {
  display: grid; grid-template-columns: repeat(7,1fr);
  text-align: center; font-size: 12px; color: var(--muted);
  margin-bottom: 6px;
  gap: 4px;
}
.calendar-days {
  display: grid; grid-template-columns: repeat(7,1fr);
  gap: 4px;
}
/* 紧凑模式：格子小 */
.calendar-days.cal-compact .cal-day {
  height: 38px;
  font-size: 12px;
}
.calendar-days.cal-compact { gap: 2px; }
/* 标准模式：固定适中尺寸（不再用 aspect-ratio:1，否则宽屏会拉大） */
.cal-day {
  height: 46px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  border-radius: var(--radius-sm);
  font-size: 13px; font-weight: 500;
  position: relative;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  transition: background .15s ease, transform .1s ease;
}
@media (max-width: 480px) {
  .cal-day { height: 40px; font-size: 12px; }
  .calendar-weekdays, .calendar-days { max-width: 100%; }
}
.cal-day:hover { background: rgba(var(--primary-rgb),0.05); }
.cal-day.active {
  background: var(--primary); color: #fff;
  box-shadow: 0 2px 8px rgba(61,40,23,0.25);
}
.cal-day.other { color: var(--muted); opacity: 0.7; }
.cal-dot {
  position: absolute; bottom: 4px;
  width: 4px; height: 4px; border-radius: 50%;
  background: var(--accent);
}

/* 主内容区 */
.app-main {
  flex: 1;
  padding: 12px;
  padding-bottom: calc(var(--nav-h) + var(--safe-bottom) + 20px);
  min-height: 0;
}
.app-main::-webkit-scrollbar { width: 6px; }
.app-main::-webkit-scrollbar-thumb { background: rgba(var(--primary-rgb),0.15); border-radius: 3px; }

/* 桌面端：主内容区滚动 */
@media (min-width: 800px) {
  .app-main { overflow-y: auto; scroll-behavior: smooth; }
}

/* 移动端：body 自然滚动 */
@media (max-width: 799px) {
  body { overflow: auto; -webkit-overflow-scrolling: touch; }
  .app-main { overflow: visible; flex: none; }
}
.view-content, .home-content { max-width: 680px; margin: 0 auto; }

/* 滚轮滑动支持 */
.wheel-scroll {
  overflow-y: auto;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

.view-content, .home-content { max-width: 680px; margin: 0 auto; }

/* 公共卡片 */
.section-block, .card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
  box-shadow: var(--shadow);
}
.block-title {
  font-size: 15px; font-weight: 700; margin: 0 0 12px;
  display: flex; align-items: center; justify-content: space-between;
}
.link-more {
  color: var(--accent-deep); font-size: 13px; font-weight: 500;
}

/* 首页模块网格 */
.module-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}
.module-card {
  background: var(--surface-2);
  border-radius: var(--radius);
  padding: 12px 8px;
  text-align: center;
  transition: transform .15s, box-shadow .15s;
  box-shadow: var(--shadow);
}
.module-card:active { transform: scale(0.97); }
.module-icon { font-size: 28px; margin-bottom: 6px; }
.module-name { font-size: 13px; font-weight: 600; margin-bottom: 3px; }
.module-stat { font-size: 11px; color: var(--text-secondary); }
.module-stat b { color: var(--primary); }

/* 今日概览圆圈 */
.overview-row {
  display: flex; justify-content: space-between; gap: 10px;
}
.overview-circle {
  flex: 1;
  text-align: center;
  padding: 14px 6px;
  background: var(--surface-2);
  border-radius: var(--radius);
}
.circle-num {
  font-size: 22px; font-weight: 700; color: var(--primary); margin-bottom: 4px;
}
.circle-num small { font-size: 12px; color: var(--muted); font-weight: 500; }
.circle-label { font-size: 12px; color: var(--text-secondary); }

.quick-todo-head { display: flex; justify-content: space-between; align-items: center; }
.quick-todo-list { display: flex; flex-direction: column; gap: 8px; }
.recent-list { display: flex; flex-direction: column; gap: 8px; }
.recent-item {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px; background: var(--surface-2); border-radius: var(--radius-sm);
  font-size: 13px;
}
.recent-item small { color: var(--muted); }

/* 页面头部 */
.page-head {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 14px;
}
.back-btn {
  font-size: 13px; color: var(--accent-deep); padding: 4px 8px;
  background: rgba(201,163,90,0.12); border-radius: 20px;
}
.page-title { margin: 0; font-size: 20px; }

/* 统计条 */
.stat-row {
  display: flex; gap: 10px; margin-bottom: 14px;
}
.stat-row-4 .stat-card { padding: 10px 6px; }
.stat-card {
  flex: 1; background: var(--surface); border-radius: var(--radius);
  padding: 12px; text-align: center; box-shadow: var(--shadow);
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  position: relative; overflow: hidden;
  transition: transform .15s ease, box-shadow .15s ease;
}
.stat-card::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: var(--accent); opacity: 0.6;
}
.stat-card:nth-child(1)::before { background: #6366f1; }
.stat-card:nth-child(2)::before { background: #f59e0b; }
.stat-card:nth-child(3)::before { background: #10b981; }
.stat-card:nth-child(4)::before { background: #ec4899; }
.stat-card:hover { transform: translateY(-2px); box-shadow: 0 6px 16px rgba(0,0,0,0.1); }
.stat-icon { font-size: 18px; margin-bottom: 2px; }
.stat-num { font-size: 22px; font-weight: 700; color: var(--primary); line-height: 1.1; }
.stat-label { font-size: 11px; color: var(--text-secondary); }
.stat-grid {
  display: grid; grid-template-columns: repeat(2,1fr); gap: 10px;
  margin-bottom: 14px;
}
.stat-pill {
  background: var(--surface); border-radius: var(--radius);
  padding: 12px; text-align: center; box-shadow: var(--shadow);
}
.sp-label { font-size: 12px; color: var(--muted); }
.sp-num { font-size: 18px; font-weight: 700; color: var(--primary); margin-top: 4px; }
.sp-num.green { color: var(--success); }
.sp-num.red { color: var(--danger); }

/* 按钮 */
.btn {
  padding: 10px 16px; border-radius: var(--radius-sm);
  font-weight: 600; transition: opacity .15s, transform .1s;
  display: inline-flex; align-items: center; justify-content: center; gap: 4px;
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-gold { background: var(--accent); color: #fff; }
.btn-ghost { background: rgba(var(--primary-rgb),0.06); color: var(--text); }
.btn-outline { border: 1px solid rgba(var(--primary-rgb),0.2); color: var(--text); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-block { width: 100%; }

/* 输入行 */
.input-row {
  display: flex; gap: 8px; margin-bottom: 14px;
}
.input-row input { flex: 1; }

/* Todo */
.todo-list { display: flex; flex-direction: column; gap: 8px; }
.todo-item {
  display: flex; align-items: center; gap: 10px;
  background: var(--surface); padding: 10px 12px; border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
}
.todo-item input[type="checkbox"] {
  width: 20px; height: 20px; accent-color: var(--accent-deep);
}
.todo-item .todo-text { flex: 1; }
.todo-item.done .todo-text { text-decoration: line-through; color: var(--muted); }
.todo-del { color: var(--danger); font-size: 18px; }

/* To-do List 优化版 */
.todo-input-bar {
  display: grid;
  grid-template-columns: 1fr 130px 110px 130px auto;
  gap: 8px; margin-bottom: 12px;
}
.todo-input-bar input, .todo-input-bar select {
  padding: 10px 12px; border-radius: var(--radius-sm);
  border: 1px solid rgba(var(--primary-rgb),0.15);
  background: var(--surface); color: var(--text); font-size: 13px;
}
.todo-input-bar input:focus, .todo-input-bar select:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(201,163,90,0.12);
}
.todo-input-bar #todoAddBtn { white-space: nowrap; }
@media (max-width: 720px) {
  .todo-input-bar { grid-template-columns: 1fr 1fr; }
  .todo-input-bar #todoAddBtn { grid-column: 1 / -1; }
}

.todo-filters { display: flex; gap: 10px; margin-bottom: 12px; align-items: center; flex-wrap: wrap; }
.todo-filters .tabs { flex: 1; min-width: 220px; margin: 0; }
.tabs-sm .tab { padding: 6px 10px; font-size: 13px; }
.todo-filter-extras { display: flex; gap: 8px; flex: 1; }
.todo-filter-extras select {
  padding: 6px 8px; border-radius: var(--radius-sm);
  border: 1px solid rgba(var(--primary-rgb),0.12);
  background: var(--surface); color: var(--text); font-size: 12px;
  flex: 1; min-width: 0;
}

/* 任务分类 chips */
.category-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 4px; }
.chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 10px; border-radius: 999px;
  background: rgba(var(--primary-rgb),0.06);
  color: var(--text-secondary); font-size: 12px;
  cursor: pointer; border: 1px solid transparent;
  transition: all .15s ease;
}
.chip:hover { background: rgba(var(--primary-rgb),0.1); }
.chip.chip-active { background: var(--primary); color: #fff; }
.chip .chip-x { font-size: 11px; opacity: 0.6; padding: 0 2px; }
.chip .chip-x:hover { opacity: 1; }
.chip[data-has-color="true"] { border-left: 3px solid var(--chip-color, var(--primary)); padding-left: 8px; }

/* 任务项：扩展版（带优先级、分类、日期） */
.todo-item { position: relative; }
.todo-item.prio-high   { border-left: 3px solid var(--danger); }
.todo-item.prio-medium { border-left: 3px solid var(--accent); }
.todo-item.prio-low    { border-left: 3px solid var(--success); }
.todo-item-main { flex: 1; min-width: 0; }
.todo-item-text { font-size: 14px; color: var(--text); }
.todo-item.done .todo-item-text { text-decoration: line-through; color: var(--muted); }
.todo-item-meta { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 4px; font-size: 11px; color: var(--muted); }
.todo-tag {
  display: inline-flex; align-items: center; gap: 3px;
  padding: 1px 8px; border-radius: 999px;
  background: rgba(var(--primary-rgb),0.08); color: var(--text-secondary);
  font-size: 11px;
}
.todo-tag.prio-high   { background: rgba(220,80,80,0.12); color: #c93a3a; }
.todo-tag.prio-medium { background: rgba(201,163,90,0.15); color: #a8833a; }
.todo-tag.prio-low    { background: rgba(76,153,114,0.12); color: #2e7a55; }
.todo-tag.cat-tag     { background: var(--tag-color, rgba(var(--primary-rgb),0.08)); color: #fff; }
.todo-actions { display: flex; gap: 6px; align-items: center; flex-shrink: 0; }
.todo-icon-btn {
  width: 28px; height: 28px; border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  border: 0; background: transparent; color: var(--text-secondary);
  cursor: pointer; font-size: 16px;
  transition: background .15s;
}
.todo-icon-btn:hover { background: rgba(var(--primary-rgb),0.08); color: var(--primary); }
.todo-icon-btn.del:hover { background: rgba(220,80,80,0.1); color: var(--danger); }
.todo-empty { text-align: center; padding: 40px 12px; color: var(--muted); font-size: 13px; }
.todo-empty-icon { font-size: 36px; margin-bottom: 8px; opacity: 0.5; }

/* 进度条 */
.todo-progress { height: 4px; background: rgba(var(--primary-rgb),0.08); border-radius: 999px; margin-bottom: 14px; overflow: hidden; }
.todo-progress-bar { height: 100%; border-radius: 999px; transition: width .4s ease, background .4s ease; }

/* 任务列表 header */
.todo-list-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.todo-list-title { font-size: 13px; font-weight: 600; color: var(--text-secondary); }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-ghost { background: transparent; border: 1px solid rgba(var(--primary-rgb),0.15); color: var(--text-secondary); border-radius: var(--radius-sm); cursor: pointer; transition: all .15s; }
.btn-ghost:hover { background: rgba(220,80,80,0.08); border-color: var(--danger); color: var(--danger); }

/* 到期提醒徽章 */
.due-badge { display: inline-block; padding: 0 5px; border-radius: 4px; font-size: 10px; font-weight: 600; margin-right: 3px; }
.due-badge.overdue { background: rgba(220,80,80,0.15); color: var(--danger); }
.due-badge.today { background: rgba(201,163,90,0.18); color: #a8833a; }
.due-badge.soon { background: rgba(76,153,114,0.12); color: #2e7a55; }

/* 行内编辑 */
.todo-inline-edit {
  width: 100%; padding: 2px 4px; border-radius: 4px;
  border: 1px solid var(--accent); background: var(--surface);
  color: var(--text); font-size: 14px; font-family: inherit;
}
.todo-inline-edit:focus { outline: none; box-shadow: 0 0 0 2px rgba(201,163,90,0.2); }

/* 任务项增强 */
.todo-item { transition: transform .15s ease, box-shadow .15s ease, opacity .25s ease; }
.todo-item:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(0,0,0,0.08); }
.todo-item.just-checked { animation: todoPop .3s ease; }
@keyframes todoPop { 0% { transform: scale(1); } 50% { transform: scale(1.015); } 100% { transform: scale(1); } }
.todo-item-text { cursor: pointer; border-radius: 3px; padding: 1px 2px; transition: background .12s; }
.todo-item-text:hover { background: rgba(var(--primary-rgb),0.06); }

/* Tabs */
.tabs, .seg {
  display: flex; gap: 6px; margin-bottom: 14px;
}
.tab, .seg-btn, .atab {
  flex: 1; padding: 8px 10px; border-radius: var(--radius-sm);
  background: rgba(var(--primary-rgb),0.06);
  color: var(--text-secondary); font-weight: 600; font-size: 14px;
}
.tab.tab-active, .seg-btn.seg-active, .atab.atab-active {
  background: var(--primary); color: #fff;
}
.account-tabs { display: flex; gap: 8px; margin-bottom: 14px; }
.atab { flex: 1; }

/* 周计划 */
.week-strip {
  display: flex; gap: 8px; overflow-x: auto; margin-bottom: 14px;
  padding-bottom: 6px;
}
.week-day {
  flex: 0 0 58px; text-align: center; padding: 10px 6px;
  background: var(--surface-2); border-radius: var(--radius-sm);
  font-size: 13px;
}
.week-day.active { background: var(--primary); color: #fff; }
.week-day .wd-name { font-size: 11px; opacity: 0.8; }
.week-day .wd-date { font-weight: 700; }
.plan-select { margin-bottom: 12px; }
.plan-select label { font-size: 13px; color: var(--text-secondary); margin-right: 6px; }
.exercise-list { display: flex; flex-direction: column; gap: 8px; }
.exercise-item {
  display: flex; align-items: center; gap: 10px;
  background: var(--surface-2); padding: 10px; border-radius: var(--radius-sm);
}
.exercise-item input { width: 20px; height: 20px; accent-color: var(--accent-deep); }
.exercise-info { flex: 1; font-size: 14px; }
.exercise-info small { color: var(--muted); font-size: 12px; display: block; }
.timer-box { text-align: center; }
.timer-display {
  font-size: 42px; font-weight: 700; color: var(--primary);
  font-variant-numeric: tabular-nums; margin: 10px 0;
}
.timer-actions {
  display: flex; gap: 8px; margin-bottom: 12px; flex-wrap: wrap;
}
.timer-actions input { flex: 1; min-width: 90px; }
.timer-controls {
  display: flex; gap: 8px; flex-wrap: wrap; justify-content: center;
  margin-bottom: 12px;
}
.photo-preview { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.photo-preview img {
  width: 78px; height: 78px; object-fit: cover; border-radius: var(--radius-sm);
}
.punch-feedback {
  background: var(--accent-light); color: var(--primary);
  padding: 12px; border-radius: var(--radius-sm); font-weight: 700;
  animation: pop .3s ease;
}
@keyframes pop { 0%{transform:scale(0.9);opacity:0} 100%{transform:scale(1);opacity:1} }

/* 记账 */
.record-form { margin-bottom: 14px; }
.rf-row { display: flex; gap: 8px; flex-wrap: wrap; }
.rf-row input { flex: 1; min-width: 80px; }
.record-list { display: flex; flex-direction: column; gap: 8px; }
.record-item {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--surface-2); padding: 12px; border-radius: var(--radius-sm);
}
.record-main { flex: 1; }
.record-main .r-title { font-weight: 600; }
.record-main .r-date { font-size: 11px; color: var(--muted); }
.record-amount { font-weight: 700; font-size: 16px; }
.record-amount.income { color: var(--success); }
.record-amount.expense { color: var(--danger); }

/* 账号 */
.kb-list { display: flex; flex-direction: column; gap: 8px; }
.kb-item {
  display: flex; justify-content: space-between; align-items: center;
  background: var(--surface-2); padding: 12px; border-radius: var(--radius-sm);
}
.kb-edit { display: flex; flex-direction: column; gap: 10px; }
.kb-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.kb-actions .btn { flex: 1; }
.kb-result {
  background: rgba(var(--primary-rgb),0.04); padding: 12px; border-radius: var(--radius-sm);
  font-size: 13px; color: var(--text-secondary); min-height: 60px;
}
.topic-list { display: flex; flex-direction: column; gap: 10px; margin-bottom: 14px; }
.topic-item {
  background: var(--surface-2); padding: 12px; border-radius: var(--radius-sm);
}
.topic-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.topic-status {
  font-size: 11px; padding: 2px 8px; border-radius: 12px;
  background: rgba(201,163,90,0.18); color: var(--accent-deep);
}
.topic-form { display: flex; gap: 8px; flex-wrap: wrap; }
.topic-form input, .topic-form select { flex: 1; min-width: 100px; }

.pub-calendar .calendar-weekdays, .pub-calendar .calendar-days { margin-bottom: 8px; }
.pub-day { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.pub-item {
  background: var(--surface-2); padding: 10px; border-radius: var(--radius-sm);
  display: flex; justify-content: space-between; align-items: center;
}
.pub-item.ad { border-left: 4px solid var(--accent); }
.pub-form { display: flex; gap: 8px; flex-wrap: wrap; }
.pub-form input, .pub-form select { flex: 1; min-width: 80px; }
.money-row { display: flex; gap: 10px; align-items: center; margin-bottom: 10px; }
.money-row label { min-width: 90px; font-size: 13px; color: var(--text-secondary); }
.money-row input { flex: 1; }

/* 摘录本 */
.ex-form { display: flex; flex-direction: column; gap: 10px; margin-bottom: 14px; }
.ex-list { display: flex; flex-direction: column; gap: 10px; }
.ex-item {
  background: var(--surface-2); padding: 14px; border-radius: var(--radius-sm);
  position: relative;
}
.ex-item p { margin: 0 0 8px; line-height: 1.6; }
.ex-item .ex-source { font-size: 12px; color: var(--muted); }
.ex-item .ex-date { position: absolute; right: 12px; top: 12px; font-size: 11px; color: var(--muted); }
.ex-item .ex-del { position: absolute; right: 10px; bottom: 10px; color: var(--danger); font-size: 12px; }

/* 学习工作 */
.study-form { display: flex; flex-direction: column; gap: 10px; margin-bottom: 14px; }
.study-list { display: flex; flex-direction: column; gap: 10px; }
.study-item {
  background: var(--surface-2); padding: 12px; border-radius: var(--radius-sm);
}
.study-bar {
  height: 8px; background: rgba(var(--primary-rgb),0.1); border-radius: 4px; margin: 8px 0; overflow: hidden;
}
.study-bar > div { height: 100%; background: var(--accent); border-radius: 4px; }

/* 设置 */
.sync-list { font-size: 13px; color: var(--text-secondary); padding-left: 18px; }
.sync-list li { margin-bottom: 6px; }
.opt-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; gap: 12px; }
.opt-row label { font-size: 13px; color: var(--text-secondary); flex-shrink: 0; }
.opt-row select { flex: 1; max-width: 240px; }
.opt-block { margin-bottom: 14px; }
.opt-label { display: block; font-size: 13px; color: var(--text-secondary); margin-bottom: 8px; font-weight: 500; }
.opt-row select, .opt-block select {
  width: 100%; max-width: 100%;
  padding: 8px 10px; border-radius: var(--radius-sm);
  border: 1px solid rgba(var(--primary-rgb),0.15);
  background: var(--surface); color: var(--text);
  font-size: 13px; cursor: pointer;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.opt-row select:focus, .opt-block select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(201,163,90,0.15); }

/* 颜色选择器（在外观卡片中） */
.opt-row input[type="color"] {
  width: 44px; height: 32px; padding: 0;
  border: 1px solid rgba(var(--primary-rgb),0.15); border-radius: var(--radius-sm);
  background: transparent; cursor: pointer;
}
.btn-sm { padding: 6px 12px; font-size: 12px; }

/* 外观卡片视觉 */
.appearance-card { background: linear-gradient(135deg, var(--surface) 0%, var(--surface-2) 100%); }

/* 界面元素隐藏开关 */
.ui-toggle-list { display: flex; flex-direction: column; gap: 4px; }
.ui-toggle-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 12px; border-radius: var(--radius-sm);
  background: rgba(var(--primary-rgb),0.04); cursor: pointer;
  transition: background .15s ease;
}
.ui-toggle-item:hover { background: rgba(var(--primary-rgb),0.08); }
.ui-toggle-label { font-size: 13px; color: var(--text); }
.ui-toggle-input { display: none; }
.ui-toggle-switch {
  position: relative; width: 40px; height: 22px;
  background: rgba(var(--primary-rgb),0.15); border-radius: 999px;
  transition: background .2s ease; flex-shrink: 0;
}
.ui-toggle-switch::after {
  content: ''; position: absolute; top: 2px; left: 2px;
  width: 18px; height: 18px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,0.15);
  transition: transform .2s ease;
}
.ui-toggle-input:checked + .ui-toggle-switch { background: var(--accent); }
.ui-toggle-input:checked + .ui-toggle-switch::after { transform: translateX(18px); }

/* 隐藏状态 */
.ui-hidden { display: none !important; }

/* 主题色板：多主题网格 */
.theme-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px;
}
.theme-item {
  position: relative; height: 80px; border-radius: var(--radius-sm);
  border: 2px solid transparent; cursor: pointer;
  display: flex; align-items: flex-end; justify-content: center;
  padding: 8px 6px; overflow: hidden;
  transition: transform .15s ease, border-color .15s ease, box-shadow .15s ease;
}
.theme-item:hover { transform: translateY(-2px); }
.theme-item.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(201,163,90,0.18), 0 4px 12px rgba(0,0,0,0.15);
}
.theme-item::before {
  content: '✓'; position: absolute; top: 6px; left: 8px;
  color: #fff; font-weight: 700; font-size: 14px;
  opacity: 0; transition: opacity .2s ease;
  text-shadow: 0 1px 2px rgba(0,0,0,0.5);
}
.theme-item.active::before { opacity: 1; }
.theme-item-name {
  color: #fff; font-size: 12px; font-weight: 600;
  text-shadow: 0 1px 2px rgba(0,0,0,0.5);
  z-index: 2; position: relative;
}
.theme-item .theme-item-del {
  position: absolute; top: 4px; right: 6px;
  width: 20px; height: 20px; border-radius: 50%;
  background: rgba(0,0,0,0.4); color: #fff;
  display: none; align-items: center; justify-content: center;
  font-size: 12px; line-height: 1; cursor: pointer;
  border: 0; padding: 0;
}
.theme-item:hover .theme-item-del { display: flex; }
.theme-item.preset .theme-item-del { display: none; } /* 预设不可删 */

/* 预设主题色（3 个内置） */
.ti-brown  { background: linear-gradient(135deg, #3d2817 0%, #5a3d26 50%, #c9a35a 100%); }
.ti-mocha  { background: linear-gradient(135deg, #4a3222 0%, #b88d4f 50%, #faf5ef 100%); }
.ti-sage   { background: linear-gradient(135deg, #3e4a3a 0%, #889b7e 50%, #f8f7f3 100%); }

/* 自定义主题色（按 primary/accent/text 渲染渐变） */
.theme-item.custom { background: linear-gradient(135deg, var(--ti-bg, #f8fafc) 0%, var(--ti-accent, #c9a35a) 100%); }
.theme-item.custom .theme-item-name { color: var(--ti-text, #2d1f15); text-shadow: 0 1px 2px rgba(255,255,255,0.4); }

/* 添加主题弹窗 */
.modal-mask {
  position: fixed; inset: 0; background: rgba(0,0,0,0.4);
  z-index: 200; display: flex; align-items: center; justify-content: center;
  padding: 16px;
  animation: fadeIn .15s ease;
}
.modal-mask[hidden] { display: none !important; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal-card {
  background: var(--surface); border-radius: var(--radius);
  padding: 20px; max-width: 360px; width: 100%;
  box-shadow: 0 20px 50px rgba(0,0,0,0.25);
  max-height: 90vh; overflow-y: auto;
  animation: slideUp .2s ease;
}
@keyframes slideUp { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.modal-row { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.modal-row label { font-size: 13px; color: var(--text-secondary); min-width: 70px; }
.modal-row input[type="text"] {
  flex: 1; padding: 8px 10px; border-radius: var(--radius-sm);
  border: 1px solid rgba(var(--primary-rgb),0.15);
  background: var(--surface); color: var(--text); font-size: 13px;
}
.modal-row input[type="color"] {
  width: 48px; height: 36px; border: 1px solid rgba(var(--primary-rgb),0.15);
  border-radius: var(--radius-sm); cursor: pointer; background: transparent;
}
.modal-preview {
  margin: 12px 0; padding: 12px; border-radius: var(--radius-sm);
  background: var(--mp-bg, #f8fafc); color: var(--mp-text, #2d1f15);
  border: 1px solid rgba(var(--primary-rgb),0.1);
}
.mp-bar { display: flex; gap: 6px; margin-bottom: 8px; }
.mp-dot { width: 14px; height: 14px; border-radius: 50%; }
.mp-dot1 { background: var(--mp-primary, #6366f1); }
.mp-dot2 { background: var(--mp-accent, #c9a35a); }
.mp-text { font-size: 13px; margin-bottom: 8px; }
.mp-btn {
  display: inline-block; padding: 5px 14px; border-radius: var(--radius-sm);
  background: var(--mp-primary, #6366f1); color: #fff;
  font-size: 12px; font-weight: 600;
}
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 8px; }

/* 背景图片/视频 */
.bg-layer, .bg-video, .bg-overlay {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  z-index: -1; pointer-events: none;
}
.bg-layer {
  background-size: cover; background-position: center; background-repeat: no-repeat;
  background-color: var(--bg);
}
.bg-video {
  width: 100%; height: 100%; object-fit: cover;
}
.bg-overlay {
  background: rgba(0,0,0,0);
  transition: background .2s ease;
}
.bg-preview {
  margin: 8px 0 0; min-height: 50px;
  border-radius: var(--radius-sm); overflow: hidden;
  background: rgba(var(--primary-rgb),0.04);
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; color: var(--muted);
  position: relative;
}
.bg-preview:empty::after { content: '尚无背景'; }
.bg-preview img, .bg-preview video {
  width: 100%; max-height: 200px; object-fit: cover;
  display: block;
}
.bg-preview .bg-info {
  position: absolute; bottom: 4px; right: 6px;
  background: rgba(0,0,0,0.5); color: #fff; padding: 2px 8px;
  border-radius: 4px; font-size: 11px;
}

/* 视频高清 */
.video-enhance-preview {
  border-radius: var(--radius-sm); overflow: hidden;
  background: rgba(var(--primary-rgb),0.04); padding: 10px;
}
.video-enhance-preview video, .video-enhance-result-wrap video {
  display: block; width: 100%; max-height: 420px; background: #000; border-radius: var(--radius-sm);
}
.video-enhance-preview .muted { margin-top: 8px; overflow-wrap: anywhere; }
.video-enhance-result-wrap {
  border-radius: var(--radius-sm); overflow: hidden;
  background: rgba(var(--primary-rgb),0.04); min-height: 100px;
}
.video-enhance-processing { position: relative; }
.video-enhance-processing::after {
  content: '处理中...'; position: absolute; inset: 0;
  background: rgba(0,0,0,0.5); color: #fff; display: flex; align-items: center; justify-content: center;
  font-size: 14px; border-radius: var(--radius-sm);
}

/* 紧凑模式加强：移动端更紧凑 */
.calendar-days.cal-compact .cal-dot { bottom: 2px; width: 3px; height: 3px; }
.history-list { display: flex; flex-direction: column; gap: 6px; }
.history-item {
  display: flex; justify-content: space-between; align-items: center;
  background: var(--surface-2); padding: 10px; border-radius: var(--radius-sm);
}
.about-card { text-align: center; }
.muted { color: var(--muted); font-size: 13px; }

/* 底部导航 */
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0;
  height: calc(var(--nav-h) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background: var(--surface);
  border-top: 1px solid rgba(var(--primary-rgb),0.08);
  display: flex; justify-content: space-around; align-items: center;
  z-index: 40;
  box-shadow: 0 -2px 10px rgba(61,40,23,0.06);
}
.nav-item {
  flex: 1; height: var(--nav-h);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  color: var(--muted); font-size: 11px; gap: 3px;
}
.nav-item.nav-active { color: var(--primary); }
.nav-icon { font-size: 20px; line-height: 1; }
.nav-label { font-size: 10px; }

/* 隐藏任务栏模式 */
body.nav-hidden .bottom-nav { display: none !important; }
body.nav-hidden .app-main { padding-bottom: 0 !important; }
body.nav-hidden .nav-toggle-fab .ic-eye-on  { display: none; }
body.nav-hidden .nav-toggle-fab .ic-eye-off { display: inline-block; }

/* 浮动按钮：切换任务栏可见性 */
.nav-toggle-fab {
  position: fixed; right: 14px; bottom: calc(var(--nav-h, 60px) + 14px);
  width: 42px; height: 42px; border-radius: 50%;
  background: var(--surface); color: var(--text-secondary);
  border: 1px solid rgba(var(--primary-rgb),0.12);
  box-shadow: 0 4px 14px rgba(61,40,23,0.15);
  display: flex; align-items: center; justify-content: center;
  z-index: 50; cursor: pointer;
  transition: transform .15s ease, background .2s ease, color .2s ease, bottom .2s ease;
}
body.nav-hidden .nav-toggle-fab { bottom: 14px; }
.nav-toggle-fab:hover { transform: scale(1.06); background: var(--surface-2); color: var(--primary); }
.nav-toggle-fab .ic-eye-off { display: none; }
.nav-toggle-fab .ic-eye-on  { display: inline-block; }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--nav-h) + 20px);
  transform: translateX(-50%) translateY(20px);
  background: rgba(45,31,21,0.92); color: #fff;
  padding: 10px 18px; border-radius: 24px; font-size: 13px;
  opacity: 0; pointer-events: none; transition: all .25s;
  z-index: 100;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* 桌面端优化 */
@media (min-width: 800px) {
  .app-main { padding: 20px; }
  .view-content, .home-content { max-width: 720px; }
  .module-grid { grid-template-columns: repeat(4, 1fr); }
  .bottom-nav {
    position: fixed; top: var(--header-h); left: 0; bottom: 0;
    width: 80px; height: auto; flex-direction: column; justify-content: flex-start;
    padding: 14px 0; border-top: none; border-right: 1px solid rgba(var(--primary-rgb),0.08);
    box-shadow: 2px 0 10px rgba(61,40,23,0.05);
    overflow-y: auto;
  }
  .nav-item { flex: 0 0 64px; }
  .app-main { margin-left: 80px; padding-bottom: 20px; }
  .date-bar, .calendar-panel { margin-left: 80px; }
  .date-pill { display: inline-block; }
  .stat-grid { grid-template-columns: repeat(4, 1fr); }
}

@media (min-width: 1100px) {
  .view-content, .home-content { max-width: 860px; }
  .module-grid { grid-template-columns: repeat(4, 1fr); }
}

/* 横屏小屏手机 */
@media (max-height: 500px) and (orientation: landscape) {
  .bottom-nav { height: 48px; }
  .nav-icon { font-size: 16px; }
  .nav-label { display: none; }
  .module-grid { grid-template-columns: repeat(4, 1fr); }
}

/* 隐藏滚动条但保留功能 */
.week-strip::-webkit-scrollbar { height: 4px; }
.week-strip::-webkit-scrollbar-thumb { background: rgba(var(--primary-rgb),0.15); border-radius: 2px; }

/* canvas 响应式 */
canvas { width: 100%; height: auto; display: block; margin: 10px 0; }

/* 导出下载链接 */
.hidden-link { display: none; }

/* 选中态日期 */
.cal-day.has-data { font-weight: 700; }
