/* ============================================
   小记 - 每日任务与目标
   温暖手记风格
   ============================================ */

/* ---------- CSS Variables ---------- */
:root {
  --bg: #FAF7F2;
  --card-bg: #FFFFFF;
  --primary: #5B9BD5;
  --primary-light: #E8F0FA;
  --primary-dark: #4A8AC5;
  --accent: #E8838A;
  --success: #5DBC7D;
  --fail: #C9878A;
  --doing: #D4A54A;
  --warning: #F5C842;
  --text: #3D3D3D;
  --text-secondary: #7A7A7A;
  --text-light: #B0AFA4;
  --border: #EDE8E1;
  --shadow: 0 2px 12px rgba(0,0,0,0.04);
  --shadow-hover: 0 4px 20px rgba(0,0,0,0.08);
  --radius: 16px;
  --radius-sm: 12px;
  --radius-xs: 8px;
  --header-height: 120px;
  --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
  --modal-overlay: rgba(0,0,0,0.35);
  --toast-bg: #3D3D3D;
  --toast-text: #fff;
}

/* ---------- Dark Theme ---------- */
[data-theme="dark"] {
  --bg: #1E1D22;
  --card-bg: #2A2930;
  --primary: #6BA3DB;
  --primary-light: #253545;
  --primary-dark: #5A93CF;
  --text: #E8E6E3;
  --text-secondary: #A8A5A0;
  --text-light: #6A6860;
  --border: #3B3940;
  --shadow: 0 2px 12px rgba(0,0,0,0.2);
  --shadow-hover: 0 4px 20px rgba(0,0,0,0.35);
  --modal-overlay: rgba(0,0,0,0.55);
  --toast-bg: #E8E6E3;
  --toast-text: #1E1D22;
}

/* ---------- Reset ---------- */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100dvh;
  overflow-x: hidden;
  transition: background var(--transition), color var(--transition);
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
  font-size: inherit;
}

input, textarea {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

ul { list-style: none; }

/* ---------- Scrollbar ---------- */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--text-light); border-radius: 2px; }

/* ---------- App Container ---------- */
#app {
  max-width: 640px;
  margin: 0 auto;
  padding: 0 16px 100px;
  min-height: 100dvh;
  position: relative;
}

/* ============================================
   HEADER
   ============================================ */
#header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg);
  padding: 12px 0 8px;
  transition: background var(--transition);
}

.header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.header-date-area {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  justify-content: center;
}

#dateTitle {
  font-size: 1.15rem;
  font-weight: 600;
  white-space: nowrap;
  letter-spacing: 0.3px;
}

.nav-btn {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-size: 1.5rem;
  color: var(--text-secondary);
  transition: all var(--transition);
  flex-shrink: 0;
}

.nav-btn:hover {
  background: var(--primary-light);
  color: var(--primary);
}

.today-btn {
  font-size: 0.78rem;
  padding: 3px 10px;
  border-radius: 20px;
  color: var(--primary);
  background: var(--primary-light);
  transition: all var(--transition);
  white-space: nowrap;
}

.today-btn:hover {
  background: var(--primary);
  color: #fff;
}

.header-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 10px;
}

/* View Tabs */
.view-tabs {
  display: flex;
  gap: 4px;
  background: var(--border);
  border-radius: 20px;
  padding: 3px;
}

.view-tab {
  padding: 6px 18px;
  border-radius: 18px;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
  transition: all var(--transition);
}

.view-tab.active {
  background: var(--card-bg);
  color: var(--text);
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}

.view-tab:hover:not(.active) {
  color: var(--primary);
}

/* Header Actions */
.header-actions {
  display: flex;
  gap: 2px;
}

.icon-btn {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  color: var(--text-secondary);
  transition: all var(--transition);
}

.icon-btn:hover {
  background: var(--primary-light);
  color: var(--primary);
}

/* ============================================
   VIEWS
   ============================================ */
.view {
  display: none;
  animation: fadeIn 0.3s ease;
}

.view.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ============================================
   CARDS (通用卡片)
   ============================================ */
.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 14px;
  overflow: hidden;
  transition: background var(--transition), box-shadow var(--transition);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px 0;
}

.card-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
}

.card-body {
  padding: 12px 18px 18px;
}

/* ============================================
   SLEEP SECTION
   ============================================ */
.sleep-inputs {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}

.sleep-item {
  flex: 1;
  min-width: 120px;
}

.sleep-label {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.sleep-day-toggle {
  margin-left: 4px;
  padding: 2px 9px;
  font-size: 0.72rem;
  line-height: 1.4;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s;
}
.sleep-day-toggle:hover {
  border-color: var(--primary);
  color: var(--primary);
}
.sleep-day-toggle.is-yesterday {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.sleep-icon {
  font-size: 1rem;
}

.time-input {
  width: 100%;
  padding: 10px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-xs);
  background: var(--bg);
  color: var(--text);
  font-size: 1.1rem;
  font-weight: 500;
  transition: border-color var(--transition);
  outline: none;
}

.time-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(91,127,255,0.15);
}

.sleep-duration {
  margin-top: 10px;
  padding: 8px 12px;
  background: var(--primary-light);
  border-radius: var(--radius-xs);
  font-size: 0.9rem;
  color: var(--primary-dark);
  text-align: center;
  font-weight: 500;
  transition: opacity var(--transition);
}

.sleep-duration.hint {
  opacity: 0.5;
}

/* ============================================
   MOOD SECTION (与备注合并)
   ============================================ */
.mood-selector {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin-bottom: 12px;
}

.mood-btn {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  font-size: 1.45rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
  background: transparent;
  border: 2px solid transparent;
  filter: grayscale(0.4);
  opacity: 0.45;
}

.mood-btn:hover {
  filter: grayscale(0);
  opacity: 0.75;
  transform: scale(1.15) translateY(-1px);
}

.mood-btn.active {
  filter: grayscale(0);
  opacity: 1;
  border-color: var(--primary);
  background: var(--primary-light);
  transform: scale(1.12);
  box-shadow: 0 2px 8px rgba(91,155,213,0.2);
}

/* ============================================
   TASK / GOAL LIST (三态 + 备注)
   ============================================ */
.add-item-row {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.item-input {
  flex: 1;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-xs);
  background: var(--bg);
  outline: none;
  transition: border-color var(--transition);
}

.item-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(91,155,213,0.12);
}

.item-input::placeholder {
  color: var(--text-light);
  font-style: italic;
}

.add-btn {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-xs);
  background: var(--primary);
  color: #fff;
  font-size: 1.4rem;
  font-weight: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
  flex-shrink: 0;
}

.add-btn:hover:not(:disabled) {
  background: var(--primary-dark);
  transform: scale(1.05);
}

.add-btn:disabled {
  background: var(--border);
  color: var(--text-light);
  cursor: default;
  transform: none;
}

.item-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.item-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-xs);
  transition: background var(--transition);
}

.item-row:hover {
  background: var(--bg);
}

/* ===== 三态标记 (doing / done / fail) ===== */

/* 通用状态图标按钮 */
.item-checkbox {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: all var(--transition);
  position: relative;
  margin-top: 2px;
  font-size: 0.95rem;
  font-weight: 600;
  user-select: none;
  border: none;
  background: transparent;
  line-height: 1;
}

/* --- 进行中 doing (• 蓝色/橙色点) --- */
.item-checkbox.status-doing {
  color: var(--doing);
}
.item-checkbox.status-doing::before {
  content: '•';
  font-size: 1.4rem;
  line-height: 1;
}

.item-checkbox.status-doing:hover {
  background: rgba(212,165,74,0.12);
  border-radius: 50%;
}

/* --- 完成 done (✓ 绿色勾) --- */
.item-checkbox.status-done {
  color: var(--success);
}
.item-checkbox.status-done::before {
  content: '✓';
  font-size: 1.05rem;
  line-height: 1;
}

.item-checkbox.status-done:hover {
  background: rgba(93,188,125,0.12);
  border-radius: 50%;
}

/* 完成动画 */
.item-checkbox.status-done {
  animation: checkPop 0.3s ease;
}

@keyframes checkPop {
  0% { transform: scale(1); }
  50% { transform: scale(1.25); }
  100% { transform: scale(1); }
}

/* --- 未完成 fail (✗ 红/灰色叉) --- */
.item-checkbox.status-fail {
  color: var(--fail);
}
.item-checkbox.status-fail::before {
  content: '✗';
  font-size: 1rem;
  line-height: 1;
}

.item-checkbox.status-fail:hover {
  background: rgba(201,135,138,0.12);
  border-radius: 50%;
}

/* ===== 任务内容区 ===== */
.item-content {
  flex: 1;
  min-width: 0;
}

.item-text {
  font-size: 0.93rem;
  line-height: 1.5;
  word-break: break-word;
  transition: all var(--transition);
}

/* 不同状态下的文字效果 */
.item-row.status-done .item-text {
  text-decoration: line-through;
  color: var(--text-light);
}

.item-row.status-fail .item-text {
  opacity: 0.55;
  color: var(--text-secondary);
}

/* ===== 任务备注行 ===== */
.task-note {
  margin-top: 4px;
  font-size: 0.82rem;
  line-height: 1.45;
  color: var(--text-light);
  font-style: italic;
  cursor: text;
  padding: 4px 8px;
  border-radius: 6px;
  background: transparent;
  border: 1px solid transparent;
  outline: none;
  transition: all var(--transition);
  width: 100%;
  font-family: inherit;
  resize: none;
  overflow: hidden;
  min-height: 20px;
  display: block;
}

.task-note:hover {
  background: rgba(0,0,0,0.02);
  border-color: var(--border);
}

.task-note:focus {
  background: var(--card-bg);
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(91,155,213,0.10);
  color: var(--text-secondary);
  font-style: normal;
}

.task-note::placeholder {
  color: var(--text-light);
  opacity: 0.6;
  font-style: italic;
}

.task-note:empty::before {
  content: attr(data-placeholder);
  color: var(--text-light);
  font-style: italic;
  opacity: 0.6;
}

.item-delete {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-light);
  font-size: 0.9rem;
  opacity: 0;
  transition: all var(--transition);
  flex-shrink: 0;
  margin-top: 2px;
}

.item-row:hover .item-delete {
  opacity: 1;
}

.item-delete:hover {
  background: rgba(232,131,138,0.12);
  color: var(--accent);
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 24px 0;
  color: var(--text-light);
  font-size: 0.85rem;
}

.empty-state-icon {
  display: block;
  font-size: 1.5rem;
  margin-bottom: 6px;
  opacity: 0.6;
}

/* 任务卡片标题区域增加温度感 */
.task-badge {
  font-size: 0.78rem;
  padding: 2px 10px;
  border-radius: 20px;
  background: var(--primary-light);
  color: var(--primary);
  font-weight: 500;
}

/* ============================================
   GOAL TYPE TABS
   ============================================ */
.goal-type-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 12px;
  background: var(--bg);
  border-radius: var(--radius-xs);
  padding: 3px;
}

.goal-type-tab {
  flex: 1;
  padding: 6px 8px;
  border-radius: var(--radius-xs);
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-secondary);
  transition: all var(--transition);
  text-align: center;
}

.goal-type-tab.active {
  background: var(--card-bg);
  color: var(--text);
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.goal-type-tab:hover:not(.active) {
  color: var(--primary);
}

/* Goal type section title */
.goal-type-hint {
  font-size: 0.78rem;
  color: var(--text-light);
  margin-bottom: 8px;
  text-align: center;
}

/* ============================================
   NOTES (已合并到心情卡片)
   ============================================ */
.note-textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-xs);
  background: var(--bg);
  outline: none;
  resize: vertical;
  min-height: 80px;
  line-height: 1.65;
  transition: all var(--transition);
}

.note-textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(91,155,213,0.10);
}

.note-textarea::placeholder {
  color: var(--text-light);
  font-style: italic;
}

/* ============================================
   WEEK VIEW
   ============================================ */
.week-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
  margin-top: 8px;
}

.week-header {
  text-align: center;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-secondary);
  padding: 6px 0;
}

.week-day-card {
  background: var(--card-bg);
  border-radius: var(--radius-sm);
  padding: 10px 6px;
  cursor: pointer;
  transition: all var(--transition);
  text-align: center;
  box-shadow: var(--shadow);
  border: 2px solid transparent;
}

.week-day-card:hover {
  box-shadow: var(--shadow-hover);
  transform: translateY(-1px);
}

.week-day-card.today {
  border-color: var(--primary);
}

.week-day-card .day-number {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 4px;
}

.week-day-card .day-name {
  font-size: 0.72rem;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.week-day-card .day-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  margin: 1px;
}

.week-day-card .day-dot.has-record {
  background: var(--primary);
}

.week-day-card .day-dot.no-record {
  background: var(--border);
}

.week-day-card .day-info {
  font-size: 0.7rem;
  color: var(--text-light);
  margin-top: 4px;
  line-height: 1.3;
}

/* ============================================
   MONTH VIEW
   ============================================ */
.month-calendar {
  margin-top: 4px;
}

.month-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
  margin-bottom: 4px;
}

.month-weekday {
  text-align: center;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-secondary);
  padding: 8px 0;
}

.month-days {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
}

.month-day {
  aspect-ratio: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition);
  position: relative;
  font-size: 0.9rem;
  font-weight: 500;
}

.month-day:hover {
  background: var(--primary-light);
}

.month-day.today {
  background: var(--primary);
  color: #fff;
  font-weight: 600;
}

.month-day.other-month {
  color: var(--text-light);
}

.month-day .month-day-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  margin-top: 3px;
}

.month-day .month-day-dot.has-record {
  background: var(--primary);
  opacity: 0.7;
}

.month-day.today .month-day-dot.has-record {
  background: #fff;
  opacity: 1;
}

.month-day .month-day-dot.no-record {
  display: none;
}

/* ============================================
   STATS BAR
   ============================================ */
.stats-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--card-bg);
  border-top: 1px solid var(--border);
  padding: 10px 16px;
  display: flex;
  justify-content: center;
  gap: 24px;
  z-index: 100;
  transition: background var(--transition);
  box-shadow: 0 -2px 10px rgba(0,0,0,0.04);
}

.stat-item {
  text-align: center;
}

.stat-label {
  display: block;
  font-size: 0.72rem;
  color: var(--text-secondary);
  margin-bottom: 2px;
}

.stat-value {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--primary);
}

/* ============================================
   TOAST
   ============================================ */
.toast {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%) translateY(-80px);
  background: var(--toast-bg);
  color: var(--toast-text);
  padding: 10px 24px;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 500;
  z-index: 1000;
  opacity: 0;
  transition: all 0.35s ease;
  pointer-events: none;
  box-shadow: 0 4px 16px rgba(0,0,0,0.15);
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ============================================
   MODAL
   ============================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: var(--modal-overlay);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn 0.2s ease;
}

.modal-overlay.hidden {
  display: none;
}

.modal {
  background: var(--card-bg);
  border-radius: var(--radius);
  max-width: 380px;
  width: 100%;
  box-shadow: 0 8px 30px rgba(0,0,0,0.12);
  overflow: hidden;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px 0;
}

.modal-header h3 {
  font-size: 1.05rem;
  font-weight: 600;
}

.modal-close {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-size: 1.4rem;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
}

.modal-close:hover {
  background: var(--bg);
  color: var(--text);
}

.modal-desc {
  font-size: 0.88rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

.modal-body {
  padding: 16px 20px 20px;
}

.modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 16px;
}

/* 导出模板选择 */
.export-template-modal {
  max-width: 360px;
}
.template-grid {
  display: flex;
  gap: 12px;
  margin-top: 6px;
}
.template-card {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 10px 6px;
  border-radius: 14px;
  border: 2px solid transparent;
  cursor: pointer;
  transition: transform 0.15s, border-color 0.15s;
  background: var(--bg);
}
.template-card:hover {
  transform: translateY(-3px);
  border-color: var(--primary);
}
.template-thumb {
  width: 100%;
  height: 76px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  font-weight: 800;
  color: #fff;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,0.04);
}
.thumb-warm {
  background: linear-gradient(135deg, #F7F1E3, #EAD9BE);
  color: #8A6D4B;
}
.thumb-pink {
  background: linear-gradient(135deg, #FFF6F9, #F7D3E0);
  color: #C76E91;
}
.thumb-ink {
  background: linear-gradient(135deg, #FBFBF9, #E6E6E2);
  color: #2B2B2B;
}
.template-name {
  font-size: 0.82rem;
  color: var(--text-secondary);
}

.btn {
  padding: 10px 20px;
  border-radius: var(--radius-xs);
  font-size: 0.9rem;
  font-weight: 500;
  transition: all var(--transition);
  text-align: center;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
  flex: 1;
}

.btn-primary:hover {
  background: var(--primary-dark);
}

.btn-secondary {
  background: var(--bg);
  color: var(--text);
  flex: 1;
  border: 1.5px solid var(--border);
}

.btn-secondary:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.backup-info {
  margin-top: 14px;
  padding: 10px 14px;
  border-radius: var(--radius-xs);
  background: var(--success);
  color: #fff;
  font-size: 0.85rem;
  text-align: center;
  transition: all var(--transition);
}

.backup-info.hidden {
  display: none;
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 480px) {
  #app {
    padding: 0 12px 90px;
  }

  #dateTitle {
    font-size: 1.05rem;
  }

  .card-body {
    padding: 10px 14px 14px;
  }

  .card-header {
    padding: 14px 14px 0;
  }

  .sleep-inputs {
    flex-direction: column;
    gap: 10px;
  }

  .sleep-item {
    min-width: 0;
  }

  .mood-btn {
    width: 40px;
    height: 40px;
    font-size: 1.3rem;
  }

  .week-grid {
    gap: 4px;
  }

  .week-day-card {
    padding: 8px 4px;
  }

  .stats-bar {
    gap: 16px;
    padding: 8px 12px;
  }

  .month-day {
    font-size: 0.82rem;
  }
}

@media (min-width: 641px) {
  #app {
    padding: 0 20px 100px;
  }

  .card:hover {
    box-shadow: var(--shadow-hover);
  }
}

/* ============================================
   UTILITIES
   ============================================ */
.hidden {
  display: none !important;
}

/* Smooth scroll for the whole page */
html {
  scroll-behavior: smooth;
}

/* Disable animations for users who prefer reduced motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* ============================================
   MOOD TREND (心情趋势竖条)
   ============================================ */
.mood-trend {
  --mood-1: #D98A8A;
  --mood-2: #E0A878;
  --mood-3: #E8C869;
  --mood-4: #9CCB86;
  --mood-5: #5DBC7D;
  display: flex;
  align-items: flex-end;
  gap: 6px;
  height: 92px;
  padding: 4px 2px 0;
}

.mood-trend.compact {
  height: 64px;
  gap: 3px;
}

.trend-col {
  flex: 1;
  min-width: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
}

.trend-bar-wrap {
  flex: 1;
  width: 100%;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.trend-bar {
  width: 72%;
  max-width: 24px;
  min-height: 4px;
  border-radius: 6px 6px 3px 3px;
  transition: height var(--transition);
}

.trend-label {
  margin-top: 5px;
  font-size: 0.62rem;
  color: var(--text-light);
  white-space: nowrap;
}

.mood-trend.compact .trend-label {
  display: none;
}

.trend-empty {
  width: 100%;
  text-align: center;
  font-size: 0.85rem;
  color: var(--text-light);
  padding: 18px 0;
}

/* 日视图心情卡片内的最近 7 天 */
.mood-trend-mini {
  margin: 6px 0 14px;
}

.mood-trend-title {
  display: block;
  margin-bottom: 6px;
  font-size: 0.75rem;
  color: var(--text-secondary);
}

/* ============================================
   TASK TEXT INLINE EDIT
   ============================================ */
.item-text.editable {
  cursor: text;
  border-bottom: 1px dashed transparent;
  border-radius: 3px;
}

.item-text.editable:hover {
  border-bottom-color: var(--text-light);
  background: rgba(0,0,0,0.03);
}

.item-text-edit {
  flex: 1;
  min-width: 0;
  font: inherit;
  color: var(--text);
  background: var(--card-bg);
  border: 1.5px solid var(--primary);
  border-radius: var(--radius-xs);
  padding: 2px 8px;
  outline: none;
}

/* ============================================
   补充变量（风格预设 / 背景 / 导航）
   ============================================ */
:root {
  --bg-opacity: 0;                /* 背景图蒙版透明度 */
  --nav-h: 60px;                  /* 底部导航高度 */
  --sun: #F5A623;
  --moon: #6C7AED;
}

/* ============================================
   风格预设：简约风 / 可爱风
   (dark 已有；warm 为默认，对应 :root)
   ============================================ */
[data-theme="minimal"] {
  --bg: #F4F4F5;
  --card-bg: #FFFFFF;
  --primary: #3A3A3C;
  --primary-light: #EAEAEB;
  --primary-dark: #1F1F21;
  --accent: #FF6B6B;
  --success: #34C759;
  --fail: #FF9F0A;
  --doing: #8E8E93;
  --warning: #FFCC00;
  --text: #1C1C1E;
  --text-secondary: #636366;
  --text-light: #AEAEB2;
  --border: #E2E2E4;
  --shadow: 0 1px 4px rgba(0,0,0,0.06);
  --shadow-hover: 0 2px 10px rgba(0,0,0,0.10);
  --radius: 8px;
  --radius-sm: 6px;
  --radius-xs: 5px;
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
}
[data-theme="minimal"] .card { border: 1px solid var(--border); }

[data-theme="cute"] {
  --bg: #FFF0F5;
  --card-bg: #FFFDFE;
  --primary: #FF8FB1;
  --primary-light: #FFE3EC;
  --primary-dark: #F56A93;
  --accent: #FFB347;
  --success: #7BD389;
  --fail: #FF9AA2;
  --doing: #FFD59E;
  --warning: #FFE066;
  --text: #5A4A52;
  --text-secondary: #A08892;
  --text-light: #D4B8C4;
  --border: #FBDDE7;
  --shadow: 0 4px 16px rgba(255,143,177,0.15);
  --shadow-hover: 0 6px 22px rgba(255,143,177,0.25);
  --radius: 22px;
  --radius-sm: 18px;
  --radius-xs: 14px;
  --font: 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', 'Comic Sans MS', sans-serif;
}
[data-theme="cute"] .mood-btn { border-radius: 30% 70% 70% 30% / 30% 30% 70% 70%; }

/* ============================================
   背景图层
   ============================================ */
.bg-layer {
  position: fixed;
  inset: 0;
  z-index: -2;
  background-size: cover;
  background-position: center;
  display: none;
}
.bg-layer.enabled {
  display: block;
  /* 模糊虚化人像细节；不用 transform: scale() 避免移动端 fixed+transform 导致背景消失 */
  filter: blur(12px);
}
.bg-layer::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(255,255,255, var(--bg-opacity));
  transition: background 0.3s ease;
}
[data-theme="dark"] .bg-layer::after {
  background: rgba(20,20,28, var(--bg-opacity));
}
body.bg-enabled {
  background: transparent;
}

/* ============================================
   页面切换 (底部 Tab 对应的大页)
   ============================================ */
.page { display: none; }
.page.active { display: block; animation: fadeIn 0.3s ease; }

/* 非记录页隐藏顶部日期导航与底部统计 */
body:not(.page-record) #viewTabs,
body:not(.page-record) .nav-btn,
body:not(.page-record) .today-btn { display: none; }
body:not(.page-record) .header-top { justify-content: center; }
body:not(.page-record) #statsBar { display: none; }
body:not(.page-record) #header { position: static; }

/* ============================================
   底部导航
   ============================================ */
.bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: var(--nav-h);
  background: var(--card-bg);
  border-top: 1px solid var(--border);
  display: flex;
  z-index: 100;
  padding-bottom: env(safe-area-inset-bottom, 0);
  transition: background var(--transition);
}
.bottom-tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  color: var(--text-light);
  transition: color var(--transition);
}
.bottom-tab .tab-icon { font-size: 1.25rem; line-height: 1; }
.bottom-tab .tab-label { font-size: 0.66rem; }
.bottom-tab.active { color: var(--primary); }
.bottom-tab:active { transform: scale(0.94); }

/* 内容区为底部导航留白 */
#app { padding-bottom: calc(var(--nav-h) + 16px); }
.stats-bar { bottom: var(--nav-h); }

/* ============================================
   页面通用标题
   ============================================ */
.page-title {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text);
  margin: 4px 0 14px;
  text-align: center;
}
.page-subtitle {
  text-align: center;
  font-size: 0.82rem;
  color: var(--text-light);
  margin: -8px 0 14px;
}

/* ============================================
   习惯打卡（日视图卡片）
   ============================================ */
.habit-checkin-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 4px; }
.habit-checkin-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-xs);
  background: var(--bg);
  transition: background var(--transition);
}
.habit-checkin-icon {
  width: 38px; height: 38px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.3rem;
  background: var(--card-bg);
  flex-shrink: 0;
  overflow: hidden;
}
.habit-checkin-icon img { width: 100%; height: 100%; object-fit: cover; }
.habit-checkin-name { flex: 1; font-size: 0.92rem; min-width: 0; }
.habit-checkin-btn {
  width: 40px; height: 40px;
  border-radius: 50%;
  border: 2px solid var(--border);
  color: var(--text-light);
  font-size: 1.2rem;
  display: flex; align-items: center; justify-content: center;
  transition: all var(--transition);
  flex-shrink: 0;
}
.habit-checkin-btn.done {
  background: var(--success);
  border-color: var(--success);
  color: #fff;
}

/* ============================================
   习惯页
   ============================================ */
.habit-add-bar { margin-bottom: 14px; }
.habit-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 14px;
  overflow: hidden;
  transition: background var(--transition), box-shadow var(--transition);
}
.habit-card-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
}
.habit-card-icon {
  width: 44px; height: 44px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.5rem;
  background: var(--primary-light);
  flex-shrink: 0;
  overflow: hidden;
}
.habit-card-icon img { width: 100%; height: 100%; object-fit: cover; }
.habit-card-info { flex: 1; min-width: 0; }
.habit-card-name { font-size: 1rem; font-weight: 600; }
.habit-card-meta { font-size: 0.78rem; color: var(--text-light); margin-top: 2px; }
.habit-card-actions { display: flex; gap: 6px; flex-shrink: 0; }
.habit-mini-btn {
  width: 34px; height: 34px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem;
  color: var(--text-secondary);
  background: var(--bg);
  transition: all var(--transition);
}
.habit-mini-btn:hover { background: var(--primary-light); color: var(--primary); }
.habit-card-detail { display: none; padding: 0 16px 16px; border-top: 1px solid var(--border); }
.habit-card.expanded .habit-card-detail { display: block; padding-top: 14px; }

/* 热力图 */
.habit-range-tabs {
  display: flex; gap: 4px; margin-bottom: 12px;
  background: var(--bg); border-radius: var(--radius-xs); padding: 3px; width: fit-content;
}
.habit-range-tab {
  padding: 5px 16px; border-radius: var(--radius-xs);
  font-size: 0.82rem; font-weight: 500; color: var(--text-secondary);
  transition: all var(--transition);
}
.habit-range-tab.active { background: var(--card-bg); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,0.06); }

.heat-calendar { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; }
.heat-cell {
  aspect-ratio: 1;
  border-radius: 6px;
  background: var(--bg);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.62rem; color: var(--text-light);
  position: relative;
}
.heat-cell.checked { background: var(--primary); color: #fff; }
.heat-cell.checked.partial { background: var(--doing); }
.heat-cell.today { box-shadow: 0 0 0 2px var(--primary); }
.heat-weekday { text-align: center; font-size: 0.68rem; color: var(--text-light); padding-bottom: 2px; }

.habit-stats {
  display: flex; gap: 10px; margin-top: 14px;
}
.habit-stat {
  flex: 1; text-align: center;
  background: var(--bg); border-radius: var(--radius-xs); padding: 10px 4px;
}
.habit-stat-value { font-size: 1.15rem; font-weight: 700; color: var(--primary); }
.habit-stat-label { font-size: 0.72rem; color: var(--text-light); margin-top: 2px; }

/* ============================================
   兑换页
   ============================================ */
.points-banner {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff;
  border-radius: var(--radius);
  padding: 20px;
  text-align: center;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}
.points-banner-value { font-size: 2.2rem; font-weight: 800; line-height: 1.1; }
.points-banner-label { font-size: 0.82rem; opacity: 0.85; margin-top: 2px; }

.reward-grid {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px;
}
.reward-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 16px 14px;
  text-align: center;
  box-shadow: var(--shadow);
  position: relative;
  transition: background var(--transition), box-shadow var(--transition);
}
.reward-card-icon { font-size: 2rem; line-height: 1; }
.reward-card-name { font-size: 0.9rem; font-weight: 600; margin: 8px 0 4px; }
.reward-card-cost { font-size: 0.8rem; color: var(--primary); font-weight: 600; }
.reward-card-btn {
  margin-top: 10px; width: 100%;
  padding: 8px; border-radius: var(--radius-xs);
  background: var(--primary); color: #fff; font-size: 0.85rem; font-weight: 600;
  transition: all var(--transition);
}
.reward-card-btn:disabled { background: var(--border); color: var(--text-light); }
.reward-card-del {
  position: absolute; top: 6px; right: 6px;
  width: 24px; height: 24px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-light); font-size: 0.9rem; opacity: 0;
  transition: all var(--transition);
}
.reward-card:hover .reward-card-del { opacity: 1; }
.reward-card-del:hover { background: rgba(232,131,138,0.12); color: var(--accent); }

.redeem-list { margin-top: 18px; }
.redeem-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: var(--radius-xs);
  background: var(--card-bg); margin-bottom: 8px; box-shadow: var(--shadow);
}
.redeem-item-icon { font-size: 1.3rem; }
.redeem-item-name { flex: 1; font-size: 0.88rem; }
.redeem-item-time { font-size: 0.72rem; color: var(--text-light); }
.redeem-item-cost { font-size: 0.8rem; color: var(--accent); font-weight: 600; }

/* ============================================
   工具页
   ============================================ */
.tools-section { margin-bottom: 20px; }
.tools-section-title {
  font-size: 0.95rem; font-weight: 600; color: var(--text);
  margin-bottom: 12px; padding-left: 4px;
}
.tools-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px;
}
.tool-card {
  background: var(--card-bg); border-radius: var(--radius);
  padding: 18px 8px; text-align: center;
  box-shadow: var(--shadow);
  transition: all var(--transition);
  cursor: pointer;
}
.tool-card:active { transform: scale(0.96); }
.tool-card-icon { font-size: 1.8rem; line-height: 1; }
.tool-card-label { font-size: 0.8rem; color: var(--text-secondary); margin-top: 6px; }

/* 风格选择网格 */
.style-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.style-card {
  border-radius: var(--radius-sm); overflow: hidden;
  border: 2px solid var(--border); cursor: pointer;
  transition: all var(--transition);
}
.style-card.active { border-color: var(--primary); }
.style-card-preview {
  height: 70px; display: flex; align-items: center; justify-content: center; gap: 6px;
}
.style-card-preview .sc-dot { width: 22px; height: 22px; border-radius: 6px; }
.style-card-name { text-align: center; font-size: 0.8rem; padding: 8px; color: var(--text); background: var(--card-bg); }

/* 表单 */
.form-label { display: block; font-size: 0.85rem; color: var(--text-secondary); margin: 14px 0 6px; }
.form-input {
  width: 100%; padding: 10px 14px;
  border: 1.5px solid var(--border); border-radius: var(--radius-xs);
  background: var(--bg); color: var(--text); outline: none;
  transition: border-color var(--transition);
}
.form-input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(91,155,213,0.12); }

.emoji-picker { display: flex; flex-wrap: wrap; gap: 6px; }
.emoji-option {
  width: 40px; height: 40px; border-radius: var(--radius-xs);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.3rem; background: var(--bg);
  border: 2px solid transparent; transition: all var(--transition);
}
.emoji-option:hover { background: var(--primary-light); }
.emoji-option.active { border-color: var(--primary); background: var(--primary-light); }

.upload-row { display: flex; align-items: center; gap: 10px; margin-top: 10px; }
.upload-name { font-size: 0.78rem; color: var(--text-light); }

/* 背景设置 */
.bg-preview {
  width: 100%; height: 120px; border-radius: var(--radius-xs);
  background: var(--border); background-size: cover; background-position: center;
  margin-bottom: 12px; display: flex; align-items: center; justify-content: center;
  color: var(--text-light); font-size: 0.82rem;
}
.bg-controls { display: flex; flex-direction: column; gap: 12px; }
.bg-toggle-row { display: flex; align-items: center; justify-content: space-between; }
.switch {
  position: relative; width: 46px; height: 26px;
  background: var(--border); border-radius: 13px; cursor: pointer;
  transition: background var(--transition); flex-shrink: 0;
}
.switch.on { background: var(--success); }
.switch::after {
  content: ''; position: absolute; top: 3px; left: 3px;
  width: 20px; height: 20px; border-radius: 50%; background: #fff;
  transition: transform var(--transition);
}
.switch.on::after { transform: translateX(20px); }
.slider-row { display: flex; align-items: center; gap: 10px; }
.slider-row input[type=range] { flex: 1; accent-color: var(--primary); }
.slider-val { font-size: 0.8rem; color: var(--text-secondary); width: 36px; text-align: right; }

.hidden { display: none !important; }
