:root {
  --bg: #f7f7f5;
  --card-bg: #ffffff;
  --text: #1a1a1a;
  --text-secondary: #6b6b6b;
  --text-tertiary: #9b9b9b;
  --border: #ececec;
  --accent: #1a1a1a;
  --accent-soft: #f0f0ee;
  --bubble-ai: #ffffff;
  --bubble-user: #1a1a1a;
  --bubble-user-text: #ffffff;
  --success: #4a7c59;
  --warning: #b8860b;
  --danger: #a0524d;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 1px 3px rgba(0,0,0,0.04), 0 4px 12px rgba(0,0,0,0.03);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Noto Sans SC', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  --font-serif: 'Georgia', 'Noto Serif SC', 'Songti SC', serif;
}

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

html, body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  height: 100%;
}

button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, textarea, select { font-family: inherit; font-size: inherit; color: inherit; }
ul { list-style: none; }

.app-shell { max-width: 480px; margin: 0 auto; min-height: 100vh; position: relative; }

/* ===== Splash Screen ===== */
.splash-screen {
  position: fixed; inset: 0; z-index: 9999;
  background: var(--bg);
  display: flex; align-items: center; justify-content: center;
  animation: splashFade 2.5s ease forwards;
}
.splash-text {
  font-family: var(--font-serif);
  font-size: 28px;
  font-weight: 400;
  color: var(--text);
  letter-spacing: 4px;
  opacity: 0;
  animation: textFadeIn 1.5s ease 0.3s forwards;
}
@keyframes textFadeIn {
  0% { opacity: 0; transform: translateY(10px); }
  40% { opacity: 1; transform: translateY(0); }
  80% { opacity: 1; }
  100% { opacity: 0.6; }
}
@keyframes splashFade {
  0% { opacity: 1; }
  70% { opacity: 1; }
  100% { opacity: 0; visibility: hidden; pointer-events: none; }
}

/* ===== Chat Interface ===== */
.chat-interface { min-height: 100vh; display: flex; flex-direction: column; }
.chat-interface.hidden { display: none; }

/* ===== Chat Header ===== */
.chat-header {
  position: sticky; top: 0; z-index: 100;
  background: rgba(247,247,245,0.85);
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  padding: calc(12px + var(--safe-top)) 20px 12px;
  display: flex; align-items: center; justify-content: space-between;
}
.chat-header h1 { font-size: 18px; font-weight: 700; letter-spacing: -0.3px; }
.header-btn { width: 36px; height: 36px; display: flex; align-items: center; justify-content: center; border-radius: 50%; font-size: 20px; color: var(--text-secondary); }
.header-btn:active { background: var(--accent-soft); }

/* ===== Side Menu (Right) ===== */
.menu-overlay {
  position: fixed; inset: 0; z-index: 199;
  background: rgba(0,0,0,0.3);
  opacity: 0; pointer-events: none; transition: opacity 0.3s;
}
.menu-overlay.show { opacity: 1; pointer-events: auto; }
.side-menu {
  position: fixed; top: 0; right: 0; z-index: 200;
  width: 260px; max-width: 80vw; height: 100vh;
  background: var(--card-bg);
  padding: calc(40px + var(--safe-top)) 0 20px;
  transform: translateX(100%); transition: transform 0.3s ease;
  box-shadow: -4px 0 24px rgba(0,0,0,0.08);
  overflow-y: auto;
}
.side-menu.show { transform: translateX(0); }
.menu-header {
  font-size: 20px; font-weight: 800; padding: 0 24px 16px;
  letter-spacing: 1px;
  display: flex; align-items: center; justify-content: space-between;
}
.menu-sort-btn {
  font-size: 12px; color: var(--text-secondary);
  padding: 4px 12px; border: 1px solid var(--border);
  border-radius: 12px; font-weight: 600;
}
.menu-sort-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.menu-item {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 24px; font-size: 15px; color: var(--text);
  transition: background 0.15s;
  position: relative;
}
.menu-item:active { background: var(--accent-soft); }
.menu-item span.menu-icon { font-size: 18px; width: 24px; text-align: center; }
.menu-item.dragging { opacity: 0.5; background: var(--accent-soft); }
.menu-item.drag-over { border-top: 2px solid var(--accent); }
.menu-drag-handle {
  position: absolute; left: 8px; top: 50%; transform: translateY(-50%);
  font-size: 14px; color: var(--text-tertiary); cursor: grab;
  display: none;
}
.side-menu.sort-mode .menu-drag-handle { display: block; }
.side-menu.sort-mode .menu-item { padding-left: 40px; }
.menu-divider { height: 1px; background: var(--border); margin: 8px 24px; }

/* ===== Chat Main ===== */
.chat-main {
  flex: 1; padding: 16px 20px calc(72px + var(--safe-bottom));
  overflow-y: auto;
  transition: padding-bottom 0.2s;
}
.chat-main.no-bottom-nav { padding-bottom: calc(20px + var(--safe-bottom)); }

.page { display: none; }
.page.active { display: block; animation: fadeIn 0.3s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

/* ===== Chat Messages ===== */
.chat-messages {
  display: flex; flex-direction: column; gap: 16px;
  padding-bottom: 20px;
}
.chat-bubble {
  max-width: 80%; padding: 12px 16px; border-radius: 20px;
  font-size: 15px; line-height: 1.7; word-break: break-word;
  animation: bubbleIn 0.4s ease;
}
@keyframes bubbleIn { from { opacity: 0; transform: translateY(8px) scale(0.95); } to { opacity: 1; transform: translateY(0) scale(1); } }
.chat-bubble.ai {
  align-self: flex-start;
  background: var(--bubble-ai);
  border-bottom-left-radius: 6px;
  box-shadow: var(--shadow);
}
.chat-bubble.user {
  align-self: flex-end;
  background: var(--bubble-user);
  color: var(--bubble-user-text);
  border-bottom-right-radius: 6px;
}
.chat-bubble-time { font-size: 11px; color: var(--text-tertiary); margin-top: 4px; }
.chat-bubble-name { font-size: 11px; font-weight: 600; margin-bottom: 2px; opacity: 0.7; }
.chat-bubble.ai .chat-bubble-time { color: var(--text-tertiary); }
.chat-bubble.user .chat-bubble-time { color: rgba(255,255,255,0.6); }
.chat-bubble.user .chat-bubble-name { color: rgba(255,255,255,0.7); }
.chat-bubble-mood { font-size: 18px; margin-bottom: 4px; }

/* ===== Home Points Banner ===== */
.home-points-banner {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 16px; margin-bottom: 8px;
  background: var(--card-bg); border-radius: var(--radius-sm);
  box-shadow: var(--shadow); cursor: pointer; transition: transform 0.15s;
}
.home-points-banner:active { transform: scale(0.98); }
.home-points-icon { font-size: 20px; }
.home-points-label { font-size: 14px; color: var(--text-secondary); flex: 1; }
.home-points-value { font-size: 20px; font-weight: 800; color: var(--warning); }

/* ===== Chat Quick Actions ===== */
.chat-quick-actions {
  display: flex; gap: 8px; padding: 8px 0 12px;
  overflow-x: auto; -webkit-overflow-scrolling: touch;
}
.chat-quick-actions::-webkit-scrollbar { display: none; }
.quick-btn {
  flex-shrink: 0; padding: 10px 18px;
  background: var(--card-bg); border: 1px solid var(--border);
  border-radius: 20px; font-size: 14px; font-weight: 600;
  color: var(--text); transition: all 0.15s;
}
.quick-btn:active { transform: scale(0.95); background: var(--accent-soft); }

/* ===== Chat Input Bar ===== */
.chat-input-bar {
  display: flex; gap: 8px; align-items: center;
  padding: 8px 0;
  border-top: 1px solid var(--border);
  position: sticky; bottom: 0; background: var(--bg);
}
.chat-input-bar input {
  flex: 1; padding: 12px 16px;
  border: 1px solid var(--border); border-radius: 24px;
  background: var(--card-bg); outline: none; font-size: 15px;
  transition: border-color 0.2s;
}
.chat-input-bar input:focus { border-color: var(--accent); }
.chat-send-btn {
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--accent); color: #fff;
  font-size: 16px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  transition: transform 0.1s;
}
.chat-send-btn:active { transform: scale(0.9); }

/* ===== Cards ===== */
.card {
  background: var(--card-bg); border-radius: var(--radius); padding: 20px;
  box-shadow: var(--shadow); margin-bottom: 14px;
}
.card-title { font-size: 13px; font-weight: 600; color: var(--text-tertiary); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 12px; }
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.card-header h3 { font-size: 16px; font-weight: 700; }

/* ===== Section Title ===== */
.section-title { font-size: 22px; font-weight: 800; letter-spacing: -0.5px; margin-bottom: 16px; }
.page-date { font-size: 13px; color: var(--text-tertiary); }

/* ===== Buttons ===== */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 12px 20px; border-radius: var(--radius-sm); font-size: 15px; font-weight: 600; transition: opacity 0.2s, transform 0.1s; }
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--accent); color: #fff; }
.btn-secondary { background: var(--accent-soft); color: var(--text); }
.btn-ghost { color: var(--text-secondary); }
.btn-danger { background: #fdf0f0; color: var(--danger); }
.btn-full { width: 100%; }
.btn-sm { padding: 8px 14px; font-size: 13px; }

/* ===== Forms ===== */
.input-group { margin-bottom: 16px; }
.input-label { display: block; font-size: 13px; font-weight: 600; color: var(--text-secondary); margin-bottom: 6px; }
.text-input, .textarea-input, .select-input {
  width: 100%; padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--card-bg); outline: none; transition: border-color 0.2s;
}
.text-input:focus, .textarea-input:focus, .select-input:focus { border-color: var(--accent); }
.textarea-input { resize: vertical; min-height: 100px; line-height: 1.7; }

/* ===== Mood Tags ===== */
.mood-tags { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
.mood-tag {
  padding: 8px 14px; border: 1px solid var(--border); border-radius: 20px; font-size: 14px;
  transition: all 0.2s; color: var(--text-secondary);
  display: flex; align-items: center; gap: 4px;
}
.mood-tag.selected { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ===== Cute Mood Icons ===== */
.mood-icon-wrapper {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; border-radius: 50%;
  font-size: 22px; transition: transform 0.2s;
  flex-shrink: 0;
}
.mood-icon-wrapper.happy { background: #fff9e6; }
.mood-icon-wrapper.calm { background: #e8f5e9; }
.mood-icon-wrapper.excited { background: #fce4ec; }
.mood-icon-wrapper.grateful { background: #f3e5f5; }
.mood-icon-wrapper.bothered { background: #fff3e0; }
.mood-icon-wrapper.anxious { background: #e3f2fd; }
.mood-icon-wrapper.depressed { background: #eceff1; }
.mood-icon-wrapper.angry { background: #ffebee; }
.mood-icon-wrapper:active { transform: scale(0.85); }
.mood-tag .mood-emoji { font-size: 18px; }
.mood-tag.selected .mood-emoji { filter: grayscale(0); }

/* ===== Checklist ===== */
.checklist-item { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.checklist-item:last-child { border-bottom: none; }
.checklist-info { flex: 1; }
.checklist-text { font-size: 15px; font-weight: 500; }
.checklist-progress-text { font-size: 12px; color: var(--text-tertiary); margin-top: 2px; }
.checklist-item.done .checklist-text { color: var(--text-tertiary); }

/* Multi-count checklist */
.checklist-counter {
  display: flex; align-items: center; gap: 8px;
}
.counter-btn {
  width: 32px; height: 32px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; font-weight: 700; transition: all 0.15s;
}
.counter-btn.minus { background: var(--accent-soft); color: var(--text-secondary); }
.counter-btn.plus { background: var(--accent); color: #fff; }
.counter-btn:active { transform: scale(0.85); }
.counter-display {
  min-width: 48px; text-align: center; font-size: 16px; font-weight: 700;
}
.counter-bar {
  height: 4px; background: var(--accent-soft); border-radius: 2px; overflow: hidden;
  margin-top: 6px;
}
.counter-bar-fill { height: 100%; background: var(--accent); border-radius: 2px; transition: width 0.3s; }

/* Single checklist checkbox */
.checkbox {
  width: 24px; height: 24px; border: 2px solid var(--border); border-radius: 50%;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0; transition: all 0.2s;
}
.checkbox.checked { background: var(--accent); border-color: var(--accent); }
.checkbox.checked::after { content: '✓'; color: #fff; font-size: 13px; font-weight: bold; }

/* Checklist actions (edit/delete) */
.checklist-actions { display: flex; gap: 2px; flex-shrink: 0; }
.action-btn {
  width: 28px; height: 28px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; color: var(--text-tertiary); transition: all 0.15s;
}
.action-btn:active { background: var(--accent-soft); color: var(--text); }

/* ===== Journal ===== */
.journal-prompt {
  background: var(--accent-soft); border-radius: var(--radius-sm); padding: 14px 16px; margin-bottom: 12px;
  font-family: var(--font-serif); font-size: 15px; color: var(--text-secondary); line-height: 1.7;
  border-left: 3px solid var(--accent);
}
.journal-entry { padding: 16px 0; border-bottom: 1px solid var(--border); }
.journal-entry:last-child { border-bottom: none; }
.journal-date { font-size: 12px; color: var(--text-tertiary); margin-bottom: 6px; }
.journal-content { font-size: 15px; line-height: 1.7; white-space: pre-wrap; }
.journal-mood { font-size: 16px; margin-top: 6px; }

/* ===== Finance ===== */
.finance-summary { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 16px; }
.finance-card { background: var(--card-bg); border-radius: var(--radius-sm); padding: 16px; box-shadow: var(--shadow); }
.finance-label { font-size: 12px; color: var(--text-tertiary); margin-bottom: 4px; }
.finance-amount { font-size: 20px; font-weight: 800; letter-spacing: -0.5px; }
.finance-amount.income { color: var(--success); }
.finance-amount.expense { color: var(--danger); }
.tx-item { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.tx-item:last-child { border-bottom: none; }
.tx-icon { width: 36px; height: 36px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 18px; flex-shrink: 0; }
.tx-icon.expense { background: #fdf0f0; }
.tx-icon.income { background: #f0f5f0; }
.tx-info { flex: 1; }
.tx-category { font-size: 14px; font-weight: 600; }
.tx-note { font-size: 12px; color: var(--text-tertiary); }
.tx-amount { font-size: 15px; font-weight: 700; }
.tx-amount.expense { color: var(--danger); }
.tx-amount.income { color: var(--success); }

/* ===== Points & Mall ===== */
.points-banner {
  display: flex; align-items: center; gap: 16px;
  background: linear-gradient(135deg, #1a1a1a, #333);
  color: #fff; border-radius: var(--radius); padding: 20px 24px;
  margin-bottom: 16px;
}
.points-icon { font-size: 32px; }
.points-label { font-size: 12px; opacity: 0.7; }
.points-value { font-size: 28px; font-weight: 800; letter-spacing: -0.5px; }

.mall-item-card {
  display: flex; align-items: center; gap: 14px;
  background: var(--card-bg); border-radius: var(--radius);
  padding: 16px; box-shadow: var(--shadow); margin-bottom: 12px;
}
.mall-item-icon { font-size: 32px; flex-shrink: 0; }
.mall-item-info { flex: 1; }
.mall-item-name { font-size: 15px; font-weight: 600; }
.mall-item-price { font-size: 13px; color: var(--warning); font-weight: 700; margin-top: 2px; }
.mall-item-actions { display: flex; gap: 4px; flex-shrink: 0; }
.redeem-btn {
  padding: 8px 14px; background: var(--accent); color: #fff;
  border-radius: var(--radius-sm); font-size: 13px; font-weight: 600;
  transition: opacity 0.2s;
}
.redeem-btn:disabled { opacity: 0.3; }
.redeem-btn:active { transform: scale(0.95); }

.redeem-history-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 0; border-bottom: 1px solid var(--border);
  font-size: 14px;
}
.redeem-history-item:last-child { border-bottom: none; }
.redeem-history-item .rh-icon { font-size: 18px; }
.redeem-history-item .rh-info { flex: 1; }
.redeem-history-item .rh-name { font-weight: 500; }
.redeem-history-item .rh-date { font-size: 12px; color: var(--text-tertiary); }
.redeem-history-item .rh-cost { color: var(--danger); font-weight: 600; font-size: 13px; }

.points-badge {
  display: inline-flex; align-items: center; gap: 2px;
  font-size: 12px; color: var(--warning); font-weight: 700;
  background: rgba(184,134,11,0.1); padding: 2px 8px; border-radius: 8px;
}

.reminder-badge {
  display: inline-flex; align-items: center; gap: 2px;
  font-size: 11px; color: #4a7c59; font-weight: 600;
  background: rgba(74,124,89,0.1); padding: 2px 8px; border-radius: 8px;
  margin-left: 4px;
}

/* ===== Todo Tasks (待办任务) ===== */
.todo-item {
  display: flex; align-items: center; gap: 12px; padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.todo-item:last-child { border-bottom: none; }
.todo-item.completed .todo-text { color: var(--text-tertiary); text-decoration: line-through; }
.todo-item.archived { opacity: 0.6; }
.todo-info { flex: 1; min-width: 0; }
.todo-text { font-size: 15px; font-weight: 500; }
.todo-badge {
  display: inline-block; font-size: 11px; font-weight: 700;
  padding: 2px 8px; border-radius: 8px; margin-top: 4px;
}
.todo-badge.point { color: var(--warning); background: rgba(184,134,11,0.1); }
.todo-badge.custom { color: var(--text-secondary); background: var(--accent-soft); }
.todo-actions { display: flex; gap: 4px; flex-shrink: 0; align-items: center; }
.mood-tag.disabled { opacity: 0.4; }

/* ===== Tab Bar ===== */
.tab-bar { display: flex; gap: 0; border-bottom: 1px solid var(--border); margin-bottom: 16px; }
.tab-item { flex: 1; padding: 10px 0; text-align: center; font-size: 14px; color: var(--text-tertiary); border-bottom: 2px solid transparent; }
.tab-item.active { color: var(--text); border-bottom-color: var(--accent); font-weight: 600; }

/* ===== Goals ===== */
.goal-card { background: var(--card-bg); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); margin-bottom: 12px; border-left: 3px solid var(--accent); }
.goal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.goal-title { font-size: 16px; font-weight: 700; }
.goal-type { font-size: 11px; padding: 3px 8px; border-radius: 4px; background: var(--accent-soft); color: var(--text-secondary); }
.goal-desc { font-size: 13px; color: var(--text-secondary); margin-bottom: 12px; }
.progress-bar { height: 6px; background: var(--accent-soft); border-radius: 3px; overflow: hidden; margin-bottom: 6px; }
.progress-fill { height: 100%; background: var(--accent); border-radius: 3px; transition: width 0.3s; }
.progress-text { font-size: 12px; color: var(--text-tertiary); display: flex; justify-content: space-between; }

/* ===== Habits ===== */
.habit-row { display: flex; align-items: center; gap: 12px; padding: 14px 0; border-bottom: 1px solid var(--border); }
.habit-row:last-child { border-bottom: none; }
.habit-icon { width: 40px; height: 40px; border-radius: 12px; background: var(--accent-soft); display: flex; align-items: center; justify-content: center; font-size: 20px; flex-shrink: 0; }
.habit-info { flex: 1; min-width: 0; }
.habit-name { font-size: 14px; font-weight: 600; }
.habit-value { font-size: 12px; color: var(--text-tertiary); margin-top: 2px; }

/* ===== Insights ===== */
.insight-card { background: var(--card-bg); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); margin-bottom: 12px; }
.insight-type { font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-tertiary); margin-bottom: 6px; }
.insight-title { font-size: 15px; font-weight: 700; margin-bottom: 6px; }
.insight-desc { font-size: 14px; color: var(--text-secondary); line-height: 1.6; }
.insight-icon { font-size: 20px; margin-bottom: 8px; }

/* ===== Modal / Sheet ===== */
.modal-overlay {
  position: fixed; inset: 0; z-index: 300; background: rgba(0,0,0,0.4);
  display: flex; align-items: flex-end; justify-content: center;
  opacity: 0; pointer-events: none; transition: opacity 0.3s;
}
.modal-overlay.show { opacity: 1; pointer-events: auto; }
.modal-sheet {
  background: var(--card-bg); border-radius: 24px 24px 0 0; width: 100%; max-width: 480px;
  padding: 20px 20px calc(24px + var(--safe-bottom)); max-height: 85vh; overflow-y: auto;
  transform: translateY(100%); transition: transform 0.3s;
}
.modal-overlay.show .modal-sheet { transform: translateY(0); }
.modal-handle { width: 36px; height: 4px; background: var(--border); border-radius: 2px; margin: 0 auto 16px; }
.modal-title { font-size: 18px; font-weight: 700; margin-bottom: 20px; text-align: center; }

/* ===== Empty State ===== */
.empty-state { text-align: center; padding: 40px 20px; color: var(--text-tertiary); }
.empty-icon { font-size: 40px; margin-bottom: 12px; opacity: 0.4; }
.empty-text { font-size: 14px; }

/* ===== Settings ===== */
.setting-row { display: flex; align-items: center; justify-content: space-between; padding: 14px 0; border-bottom: 1px solid var(--border); }
.setting-row:last-child { border-bottom: none; }
.setting-label { font-size: 15px; }
.setting-desc { font-size: 12px; color: var(--text-tertiary); margin-top: 2px; }

.toggle { width: 44px; height: 26px; border-radius: 13px; background: var(--accent-soft); position: relative; transition: background 0.2s; cursor: pointer; }
.toggle.on { background: var(--accent); }
.toggle::after { content: ''; position: absolute; width: 22px; height: 22px; border-radius: 50%; background: #fff; top: 2px; left: 2px; transition: transform 0.2s; box-shadow: 0 1px 3px rgba(0,0,0,0.2); }
.toggle.on::after { transform: translateX(18px); }

/* Switch (checkbox-based) */
.switch { position: relative; display: inline-block; width: 44px; height: 26px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; cursor: pointer; inset: 0; background: var(--accent-soft); border-radius: 13px; transition: 0.2s; }
.slider::before { content: ''; position: absolute; width: 22px; height: 22px; border-radius: 50%; background: #fff; top: 2px; left: 2px; transition: 0.2s; box-shadow: 0 1px 3px rgba(0,0,0,0.2); }
.switch input:checked + .slider { background: var(--accent); }
.switch input:checked + .slider::before { transform: translateX(18px); }

/* ===== Toast ===== */
.toast {
  position: fixed; bottom: 100px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--accent); color: #fff; padding: 10px 20px; border-radius: 20px;
  font-size: 14px; z-index: 400; opacity: 0; pointer-events: none; transition: all 0.3s; white-space: nowrap;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ===== Misc ===== */
.text-center { text-align: center; }
.text-secondary { color: var(--text-secondary); }
.text-tertiary { color: var(--text-tertiary); }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mb-16 { margin-bottom: 16px; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.hidden { display: none !important; }
.fade-in { animation: fadeIn 0.3s ease; }

::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

/* ===== Bottom Navigation Bar ===== */
.bottom-nav {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 480px; z-index: 150;
  background: rgba(255,255,255,0.92);
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--border);
  display: flex; justify-content: space-around; align-items: center;
  padding: 6px 0 calc(6px + var(--safe-bottom));
}
.bottom-nav-item {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 4px 8px; border-radius: 10px;
  transition: all 0.2s; color: var(--text-tertiary);
}
.bottom-nav-item.active { color: var(--text); }
.bottom-nav-icon { font-size: 18px; }
.bottom-nav-label { font-size: 9px; font-weight: 600; }
.bottom-nav-item:active { transform: scale(0.9); }

/* ===== Habit Calendar ===== */
.habit-calendar-card {
  background: var(--card-bg); border-radius: var(--radius); padding: 16px;
  box-shadow: var(--shadow); margin-bottom: 14px;
}
.habit-calendar-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 12px;
}
.habit-calendar-title { font-size: 15px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.habit-calendar-nav { display: flex; gap: 8px; align-items: center; }
.habit-calendar-nav button {
  width: 28px; height: 28px; border-radius: 50%; background: var(--accent-soft);
  font-size: 14px; display: flex; align-items: center; justify-content: center;
}
.habit-calendar-nav .cal-month-label { font-size: 13px; font-weight: 600; min-width: 70px; text-align: center; }
.habit-calendar-grid {
  display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px;
}
.habit-cal-weekday { text-align: center; font-size: 10px; color: var(--text-tertiary); padding: 2px 0; }
.habit-cal-day {
  aspect-ratio: 1; display: flex; align-items: center; justify-content: center;
  font-size: 11px; border-radius: 6px; transition: all 0.15s;
  background: var(--accent-soft); color: var(--text-secondary);
  position: relative;
}
.habit-cal-day.checked {
  background: var(--accent); color: #fff; font-weight: 700;
}
.habit-cal-day.checked::after {
  content: '✓'; position: absolute; font-size: 10px;
}
.habit-cal-day.today { border: 2px solid var(--accent); }
.habit-cal-day.empty { background: transparent; }
.habit-cal-day.future { opacity: 0.3; }
.habit-calendar-stats {
  display: flex; gap: 12px; margin-top: 10px; font-size: 12px; color: var(--text-tertiary);
}
.habit-calendar-stats .cal-stat { display: flex; align-items: center; gap: 4px; }
.habit-calendar-stats .cal-stat-val { font-weight: 700; color: var(--text); }

.habit-custom-row {
  display: flex; align-items: center; gap: 12px; padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.habit-custom-row:last-child { border-bottom: none; }

/* ===== Journal List ===== */
.journal-list-item {
  background: var(--card-bg); border-radius: var(--radius); padding: 16px;
  box-shadow: var(--shadow); margin-bottom: 12px;
}
.journal-list-header {
  display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px;
}
.journal-list-date { font-size: 13px; color: var(--text-tertiary); font-weight: 600; }
.journal-list-moods { font-size: 16px; }
.journal-list-content { font-size: 14px; line-height: 1.7; color: var(--text); white-space: pre-wrap; }
.journal-list-prompt { font-size: 12px; color: var(--text-tertiary); margin-bottom: 6px; font-style: italic; }
.journal-list-actions { display: flex; gap: 4px; margin-top: 8px; }

/* ===== Life Log (记录自己) ===== */
.lifelog-entry {
  padding: 12px 0; border-bottom: 1px solid var(--border);
  position: relative;
}
.lifelog-entry:last-child { border-bottom: none; }
.lifelog-entry-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 6px;
}
.lifelog-cat-tag {
  font-size: 12px; font-weight: 600; color: var(--text-secondary);
  background: var(--accent-soft); padding: 3px 10px; border-radius: 10px;
}
.lifelog-time { font-size: 11px; color: var(--text-tertiary); }
.lifelog-content {
  font-size: 14px; line-height: 1.7; color: var(--text); white-space: pre-wrap;
  padding-right: 60px;
}
.lifelog-actions {
  position: absolute; right: 0; top: 12px;
  display: flex; gap: 2px;
}
.lifelog-date-divider {
  font-size: 12px; font-weight: 600; color: var(--text-tertiary);
  padding: 10px 0 4px; border-top: 1px solid var(--border); margin-top: 4px;
}
.lifelog-date-divider:first-child { border-top: none; margin-top: 0; }

/* ===== Notebook Cards (随手记) ===== */
.notebook-card {
  display: flex; align-items: center; gap: 12px;
  padding: 14px; border-radius: var(--radius-sm);
  background: var(--card-bg); border: 1px solid var(--border);
  margin-bottom: 0; transition: all 0.15s; cursor: pointer;
}
.notebook-card:active { transform: scale(0.98); }
.notebook-card.active { border-color: var(--accent); background: var(--accent-soft); }
.notebook-icon {
  width: 40px; height: 40px; border-radius: 10px;
  background: var(--accent-soft); display: flex;
  align-items: center; justify-content: center; font-size: 20px; flex-shrink: 0;
}
.notebook-card.active .notebook-icon { background: var(--card-bg); }
.notebook-info { flex: 1; min-width: 0; }
.notebook-name { font-size: 15px; font-weight: 600; }
.notebook-count { font-size: 12px; color: var(--text-tertiary); margin-top: 2px; }
.notebook-actions { display: flex; gap: 2px; flex-shrink: 0; }
/* 本子列表滑动容器间距用 gap 而非 margin，避免按钮错位 */
#notebookList { display: flex; flex-direction: column; gap: 8px; }

/* ===== Swipe Actions (滑动操作) ===== */
.swipe-container {
  position: relative; overflow: hidden; border-radius: var(--radius-sm);
}
.swipe-content {
  position: relative; z-index: 1; background: var(--card-bg);
  transition: transform 0.25s ease; will-change: transform;
  touch-action: pan-y;
}
.swipe-actions {
  position: absolute; top: 0; right: 0; height: 100%;
  display: flex; z-index: 0;
}
.swipe-btn {
  display: flex; align-items: center; justify-content: center;
  width: 64px; font-size: 13px; font-weight: 600; color: #fff;
  border: none; cursor: pointer;
}
.swipe-btn.edit { background: var(--accent); }
.swipe-btn.delete { background: var(--danger); }
.swipe-container.swiped .swipe-content { transform: translateX(-128px); }
.swipe-container.swipe-single.swiped .swipe-content { transform: translateX(-80px); }

/* ===== Calendar (日历) ===== */
.cal-type-list { display: flex; flex-direction: column; gap: 12px; }
.cal-type-btn {
  display: flex; align-items: center; gap: 16px;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px; cursor: pointer;
  transition: all 0.2s; text-align: left;
}
.cal-type-btn:active { transform: scale(0.98); }
.cal-type-icon { font-size: 28px; flex-shrink: 0; }
.cal-type-name { font-size: 16px; font-weight: 600; color: var(--text-primary); }
.cal-type-desc { font-size: 12px; color: var(--text-tertiary); margin-top: 2px; }

.cal-now {
  text-align: center; padding: 16px 0;
  border-bottom: 1px solid var(--border); margin-bottom: 12px;
}
.cal-now-date { font-size: 16px; font-weight: 600; }
.cal-now-time { font-size: 28px; font-weight: 700; color: var(--accent); margin-top: 4px; font-variant-numeric: tabular-nums; }

.cal-nav {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 12px;
}
.cal-month-label { font-size: 15px; font-weight: 600; }

.cal-grid {
  display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px;
}
.cal-cell {
  aspect-ratio: 1; display: flex; align-items: center; justify-content: center;
  font-size: 14px; border-radius: 50%; cursor: pointer;
  transition: background 0.15s; user-select: none;
}
.cal-cell:active { background: var(--bg); }
.cal-cell.cal-header { font-size: 12px; color: var(--text-tertiary); cursor: default; font-weight: 600; }
.cal-cell.cal-today { background: var(--accent); color: #fff; font-weight: 700; }
.cal-cell.cal-period {
  background: rgba(233, 30, 99, 0.15); color: #e91e63; font-weight: 600;
  border: 2px solid rgba(233, 30, 99, 0.3);
}

.cal-legend {
  display: flex; gap: 16px; justify-content: center; margin-bottom: 8px;
}
.cal-legend-item { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-secondary); }
.cal-legend-dot { width: 12px; height: 12px; border-radius: 50%; }
.cal-period-dot { background: rgba(233, 30, 99, 0.3); border: 1px solid rgba(233, 30, 99, 0.5); }
.cal-today-dot { background: var(--accent); }

.cal-records { margin-top: 16px; }
.cal-records-title { font-size: 14px; font-weight: 600; margin-bottom: 8px; }
.cal-record-item {
  padding: 8px 12px; background: var(--bg); border-radius: var(--radius-sm);
  margin-bottom: 4px; display: flex; justify-content: space-between; align-items: center;
}
.cal-record-date { font-size: 13px; font-weight: 500; }
.cal-record-info { font-size: 12px; color: var(--text-secondary); }
.cal-record-note { font-size: 12px; color: var(--text-tertiary); margin-top: 4px; width: 100%; }
