/* ============================================
   工作备忘 — 移动端优先样式表
   ============================================ */

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

:root {
  --primary: #0ea5e9;
  --primary-light: #38bdf8;
  --primary-dark: #0284c7;
  --done: #9CA3AF;
  --danger: #EF4444;
  --success: #10B981;
  --warning: #F59E0B;
  --bg: #F3F4F6;
  --card-bg: #FFFFFF;
  --text: #1F2937;
  --text-light: #6B7280;
  --border: #E5E7EB;
  --radius: 12px;
  --tabbar-h: 56px;
}

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 15px;
  color: var(--text);
  background: var(--bg);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

#app {
  max-width: 500px;
  margin: 0 auto;
  min-height: 100vh;
  padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
}

/* ===== 顶部标题栏 ===== */
.topbar {
  background: var(--primary);
  color: #fff;
  padding: 12px 16px;
  padding-top: calc(12px + env(safe-area-inset-top));
  text-align: center;
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
}
.topbar .back-btn {
  position: absolute;
  left: 8px;
  top: 50%;
  transform: translateY(-50%);
  margin-top: calc(env(safe-area-inset-top) / 2);
  color: #fff;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  text-decoration: none;
  transition: background 0.2s;
}
.topbar .back-btn:active { background: rgba(255,255,255,0.2); }
.topbar h1 {
  font-size: 18px;
  font-weight: 600;
}

/* ===== View 切换 ===== */
.view { display: none; padding: 16px; }
.view.active { display: block; }

/* ===== 日历视图 ===== */
.cal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.cal-title { font-size: 17px; font-weight: 600; }
.cal-nav-btn {
  width: 40px; height: 40px;
  border: none;
  background: var(--card-bg);
  border-radius: 50%;
  font-size: 22px;
  color: var(--primary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}
.cal-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  text-align: center;
  font-size: 13px;
  color: var(--text-light);
  margin-bottom: 8px;
  font-weight: 500;
  padding: 0 8px;
  gap: 2px;
}
.cal-weekdays .weekend { color: var(--danger); }
.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 8px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
.cal-cell {
  aspect-ratio: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  font-size: 14px;
  border-radius: 8px;
  position: relative;
  cursor: pointer;
  min-height: 52px;
  transition: background 0.15s;
  padding: 12px 0 0;
  overflow: hidden;
  box-sizing: border-box;
  width: 100%;
  min-width: 0;
}
.cal-cell.weekend .day-num { color: var(--danger); }
.cal-cell.weekend .lunar-text { color: var(--danger); }
.cal-cell.holiday .lunar-text { color: var(--danger); font-weight: 600; }
.cal-cell .lunar-text {
  font-size: 10px;
  color: var(--text-light);
  line-height: 1.2;
  margin-top: 1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}
.cal-cell.today .lunar-text, .cal-cell.selected .lunar-text { color: #fff; }
.cal-cell.today .day-num, .cal-cell.selected .day-num { color: #fff; }
.cal-cell:active { background: var(--bg); }
.cal-cell.empty { pointer-events: none; }
.cal-cell.today { background: var(--primary); color: #fff; font-weight: 700; border-radius: 8px; }
.cal-cell.selected { background: var(--primary-light); color: #fff; border-radius: 8px; }
.cal-cell .dot {
  margin-top: auto;
  display: flex;
  gap: 2px;
  height: 4px;
}
.cal-cell .dot span {
  width: 4px; height: 4px;
  border-radius: 50%;
  background: var(--primary);
}
.cal-cell.today .dot span, .cal-cell.selected .dot span { background: #fff; }
.cal-cell.all-done .dot span { background: var(--success); }
.cal-cell .day-num { font-size: 14px; line-height: 1.1; }

/* 日历下方事项区 */
.day-memos {
  margin-top: 16px;
}
.day-memos-title {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text);
}

/* ===== 备忘卡片 ===== */
.memo-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 8px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.06);
  display: flex;
  align-items: flex-start;
  gap: 12px;
  transition: opacity 0.2s, transform 0.2s;
  position: relative;
  overflow: hidden;
}
.memo-card.done .memo-title { color: var(--text); }

.memo-check {
  width: 24px; height: 24px;
  border: 2px solid var(--danger);
  border-radius: 50%;
  flex-shrink: 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 1px;
  transition: all 0.2s;
  position: relative;
}
.memo-check:not(.checked)::after {
  content: '';
  width: 8px; height: 8px;
  background: var(--danger);
  border-radius: 50%;
}
.memo-check.checked {
  background: var(--success);
  border-color: var(--success);
}
.memo-check.checked::after {
  content: '✓';
  color: #fff;
  font-size: 14px;
  font-weight: bold;
}
.memo-body {
  flex: 1;
  min-width: 0;
}
.memo-title {
  font-size: 15px;
  font-weight: 500;
  word-break: break-word;
}
.memo-meta {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 4px;
}
.memo-time { font-size: 12px; color: var(--text-light); }
.memo-tag {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 10px;
  color: #fff;
  font-weight: 500;
}
.memo-priority {
  font-size: 11px;
  padding: 1px 6px;
  border-radius: 4px;
  font-weight: 500;
}
.memo-priority.p1 { background: #FEF3C7; color: #92400E; }
.memo-priority.p2 { background: #FEE2E2; color: #991B1B; }
.memo-content {
  font-size: 13px;
  color: var(--text-light);
  margin-top: 4px;
  word-break: break-word;
  white-space: pre-wrap;
}
.memo-card .swipe-delete {
  position: absolute;
  right: -72px;
  top: 0; bottom: 0;
  width: 72px;
  background: var(--danger);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  transition: right 0.2s;
}

/* ===== 列表工具栏 ===== */
.list-toolbar {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}
.search-input {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  background: var(--card-bg);
  outline: none;
}
.search-input:focus { border-color: var(--primary); }
.filter-select {
  padding: 8px 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  background: var(--card-bg);
  color: var(--text);
  outline: none;
}

/* 日期分组标题 */
.list-date-group {
  font-size: 13px;
  color: var(--text-light);
  font-weight: 600;
  padding: 8px 0 6px;
  position: sticky;
  top: 52px;
  background: var(--bg);
  z-index: 5;
}

/* ===== 统计仪表盘 ===== */
.stats-tabs {
  display: flex;
  gap: 0;
  margin-bottom: 16px;
  background: var(--card-bg);
  border-radius: 8px;
  overflow: hidden;
}
.stats-tab {
  flex: 1;
  padding: 10px;
  border: none;
  background: transparent;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-light);
  cursor: pointer;
  transition: all 0.2s;
}
.stats-tab.active {
  background: var(--primary);
  color: #fff;
}

.stats-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.06);
}
.stats-card h3 {
  font-size: 14px;
  color: var(--text-light);
  margin-bottom: 12px;
  font-weight: 500;
}

.stats-numbers {
  display: flex;
  justify-content: space-around;
  text-align: center;
}
.stat-item .stat-val {
  font-size: 28px;
  font-weight: 700;
  line-height: 1.2;
}
.stat-item .stat-lbl { font-size: 12px; color: var(--text-light); margin-top: 2px; }
.stat-val.green { color: var(--success); }
.stat-val.red { color: var(--danger); }
.stat-val.blue { color: var(--primary); }

.progress-bar {
  width: 100%;
  height: 8px;
  background: var(--border);
  border-radius: 4px;
  margin-top: 12px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: var(--success);
  border-radius: 4px;
  transition: width 0.5s ease;
}

/* 分类统计条 */
.cat-bar-row { margin-bottom: 10px; }
.cat-bar-label {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  margin-bottom: 4px;
}
.cat-bar-track {
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
}
.cat-bar-fill { height: 100%; border-radius: 3px; transition: width 0.5s; }

/* 导出区域 */
.export-section { margin-top: 20px; }
.export-section h3 { font-size: 15px; font-weight: 600; margin-bottom: 10px; }
.export-btns { display: flex; gap: 10px; }
.btn-export {
  flex: 1;
  text-align: center;
  padding: 10px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--primary);
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
}
.btn-export:active { background: var(--bg); }

/* ===== 底部 Tab 导航 ===== */
.tabbar {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  background: var(--card-bg);
  border-top: 1px solid var(--border);
  display: flex;
  max-width: 500px;
  margin: 0 auto;
  z-index: 200;
}
.tab-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  color: var(--text-light);
  text-decoration: none;
  cursor: pointer;
  transition: color 0.2s;
  padding-bottom: env(safe-area-inset-bottom);
}
.tab-item.active { color: var(--primary); }
.tab-icon { font-size: 20px; display: flex; align-items: center; justify-content: center; }
.tab-icon svg { display: block; }
.tab-label { font-size: 11px; }

/* ===== FAB 悬浮按钮 ===== */
.fab {
  position: fixed;
  bottom: calc(var(--tabbar-h) + 20px + env(safe-area-inset-bottom));
  right: calc(50% - 250px + 20px);
  width: 52px; height: 52px;
  border: none;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-size: 28px;
  box-shadow: 0 4px 12px rgba(79,70,229,0.4);
  cursor: pointer;
  z-index: 150;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s;
}
.fab:active { transform: scale(0.9); }

/* 小屏自适应：FAB 右贴边 */
@media (max-width: 500px) {
  .fab { right: 20px; }
}

/* ===== Bottom Sheet ===== */
.sheet-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 300;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s;
}
.sheet-overlay.active { opacity: 1; pointer-events: auto; }

.bottom-sheet {
  position: fixed;
  bottom: 0; left: 50%;
  transform: translateX(-50%) translateY(100%);
  width: 100%;
  max-width: 500px;
  background: var(--card-bg);
  border-radius: 16px 16px 0 0;
  z-index: 301;
  transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1);
  max-height: 85vh;
  overflow-y: auto;
  padding-bottom: env(safe-area-inset-bottom);
}
.bottom-sheet.active { transform: translateX(-50%) translateY(0); }
.sheet-handle {
  width: 36px; height: 4px;
  background: var(--border);
  border-radius: 2px;
  margin: 8px auto 0;
}
.sheet-title {
  font-size: 17px;
  font-weight: 600;
  text-align: center;
  padding: 8px 16px 12px;
}
.sheet-body { padding: 0 16px 20px; }

/* ===== 表单 ===== */
.form-group { margin-bottom: 12px; }
.form-group label {
  display: block;
  font-size: 13px;
  color: var(--text-light);
  margin-bottom: 4px;
}
.form-row { display: flex; gap: 12px; }
.form-group.half { flex: 1; }
.form-input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 15px;
  outline: none;
  background: #FAFAFA;
  font-family: inherit;
}
.form-input:focus { border-color: var(--primary); background: #fff; }
.form-textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  outline: none;
  background: #FAFAFA;
  resize: none;
  font-family: inherit;
}
.form-textarea:focus { border-color: var(--primary); background: #fff; }

.sheet-actions {
  display: flex;
  gap: 12px;
  margin-top: 16px;
}
.btn-save {
  flex: 1;
  padding: 12px;
  border: none;
  border-radius: 8px;
  background: var(--primary);
  color: #fff;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
}
.btn-save:active { background: var(--primary-dark); }
.btn-delete {
  padding: 12px 20px;
  border: none;
  border-radius: 8px;
  background: #FEE2E2;
  color: var(--danger);
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
}

/* ===== 提醒弹窗 ===== */
.reminder-popup {
  position: fixed;
  top: calc(60px + env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  z-index: 500;
  width: calc(100% - 32px);
  max-width: 468px;
  display: none;
}
.reminder-popup.show { display: block; animation: slideDown 0.3s ease; }
@keyframes slideDown {
  from { transform: translateX(-50%) translateY(-20px); opacity: 0; }
  to { transform: translateX(-50%) translateY(0); opacity: 1; }
}
.reminder-item {
  background: var(--warning);
  color: #fff;
  border-radius: 10px;
  padding: 12px 16px;
  margin-bottom: 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  font-size: 14px;
}
.reminder-item .ri-title { font-weight: 600; }
.reminder-item .ri-time { font-size: 12px; opacity: 0.9; margin-top: 2px; }

/* ===== 空状态 ===== */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-light);
}
.empty-state .empty-icon { font-size: 48px; margin-bottom: 12px; }
.empty-state .empty-text { font-size: 14px; }
