/* ============ 主题变量 ============ */
:root {
  --bg: #eef1f6;
  --card: #ffffff;
  --text: #1f2430;
  --text2: #7a8194;
  --line: #e6e9f0;
  --accent: #4a6cf7;
  --accent2: #6a8dff;
  --accent-soft: #eef2ff;
  --green: #2fc48b;
  --orange: #ffa34d;
  --red: #f25b5b;
  --shadow: 0 2px 12px rgba(31, 36, 48, .07);
  --radius: 16px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14161d;
    --card: #1e222b;
    --text: #e8eaf0;
    --text2: #8b92a5;
    --line: #2a2e3a;
    --accent: #5b7cff;
    --accent2: #7c97ff;
    --accent-soft: #222b4d;
    --shadow: 0 2px 14px rgba(0, 0, 0, .4);
  }
}

/* ============ 基础 ============ */
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, textarea { font-family: inherit; }

/* ============ 头部 ============ */
.app-header {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px;
  background: linear-gradient(135deg, var(--accent2), var(--accent));
  color: #fff;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-logo {
  width: 30px; height: 30px; border-radius: 9px;
  background: rgba(255,255,255,.22);
  display: grid; place-items: center; font-size: 16px; font-weight: 700;
}
.brand h1 { margin: 0; font-size: 19px; font-weight: 600; }
.header-actions { display: flex; gap: 8px; align-items: center; }
.icon-btn {
  width: 34px; height: 34px; border-radius: 10px;
  background: rgba(255,255,255,.2); color: #fff; font-size: 17px;
}
.chip-btn {
  padding: 7px 14px; border-radius: 20px;
  background: rgba(255,255,255,.2); color: #fff; font-size: 14px; font-weight: 500;
}
.chip-btn.primary { background: #fff; color: var(--accent); }

/* ============ 主区域 ============ */
.app-main {
  max-width: 560px; margin: 0 auto;
  padding: 14px 14px 92px;
}
.view { animation: fade .18s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* ============ 日历 ============ */
.calendar-card {
  background: var(--card); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 14px 12px;
}
.calendar-nav {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 8px;
}
.nav-btn {
  width: 36px; height: 36px; border-radius: 10px;
  font-size: 22px; color: var(--text2); background: var(--bg);
}
.cal-title { font-size: 17px; font-weight: 600; }
.calendar-weekdays {
  display: grid; grid-template-columns: repeat(7, 1fr);
  text-align: center; color: var(--text2); font-size: 12px; margin-bottom: 4px;
}
.calendar-grid {
  display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px;
}
.day-cell {
  aspect-ratio: 1 / 1; border-radius: 12px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; position: relative; cursor: pointer;
  font-size: 15px; color: var(--text);
}
.day-cell.dim { color: var(--line); }
.day-cell.today { box-shadow: inset 0 0 0 2px var(--accent); }
.day-cell.selected { background: var(--accent); color: #fff; }
.day-cell.selected .dot { border-color: rgba(255,255,255,.7); }
.day-dots { display: flex; gap: 2px; height: 6px; }
.day-cell .dot {
  width: 6px; height: 6px; border-radius: 50%; border: 1px solid transparent;
}
.day-cell .dot.done { background: var(--green); }
.day-cell .dot.part { background: var(--orange); }
.day-cell .dot.todo { background: #fff; border-color: var(--accent); }
.day-cell.selected .dot.todo { background: rgba(255,255,255,.85); border-color: transparent; }
.day-cell .day-count {
  position: absolute; top: 3px; right: 5px; font-size: 10px; color: var(--accent); font-weight: 600;
}
.day-cell.selected .day-count { color: #fff; }

/* ============ 当天列表 ============ */
.day-section { margin-top: 14px; }
.day-section-head {
  display: flex; align-items: center; justify-content: space-between;
  margin: 4px 2px 10px;
}
.day-title { font-size: 18px; font-weight: 600; }
.day-sub { font-size: 12px; color: var(--text2); margin-top: 2px; }

/* ============ 待办列表 ============ */
.filter-bar { display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 12px; }
.filter-chip {
  flex: 0 0 auto; padding: 7px 16px; border-radius: 18px;
  background: var(--card); color: var(--text2); font-size: 13px; box-shadow: var(--shadow);
}
.filter-chip.active { background: var(--accent); color: #fff; }
.task-list { display: flex; flex-direction: column; gap: 10px; }

.date-group-title {
  font-size: 13px; font-weight: 600; color: var(--text2);
  margin: 10px 2px 2px;
}
.todo-card {
  background: var(--card); border-radius: 14px; box-shadow: var(--shadow);
  padding: 13px 14px; display: flex; gap: 12px; align-items: flex-start;
}
.checkbox {
  flex: 0 0 auto; width: 24px; height: 24px; border-radius: 50%;
  border: 2px solid var(--line); display: grid; place-items: center;
  margin-top: 1px; transition: all .15s; color: #fff; font-size: 13px;
}
.todo-card.done .checkbox { background: var(--green); border-color: var(--green); }
.todo-body { flex: 1; min-width: 0; cursor: pointer; }
.todo-title { font-size: 15px; font-weight: 500; word-break: break-word; }
.todo-card.done .todo-title { text-decoration: line-through; color: var(--text2); }
.todo-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 5px; }
.meta-tag {
  font-size: 11px; padding: 2px 8px; border-radius: 8px;
  background: var(--bg); color: var(--text2);
}
.meta-tag.time { background: var(--accent-soft); color: var(--accent); }
.meta-tag.overdue { background: #fdeaea; color: var(--red); }
.progress-wrap { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.progress-track { flex: 1; height: 6px; border-radius: 3px; background: var(--bg); overflow: hidden; }
.progress-fill { height: 100%; border-radius: 3px; transition: width .2s; }
.progress-pct { font-size: 11px; color: var(--text2); min-width: 34px; text-align: right; }
.gain-block {
  margin-top: 9px; padding: 8px 11px; border-radius: 10px;
  background: #fff8e6; color: #8a6d1a; font-size: 13px; line-height: 1.5;
  border-left: 3px solid #f0b429; word-break: break-word;
}
@media (prefers-color-scheme: dark) {
  .gain-block { background: #2c281a; color: #e3c76a; border-left-color: #d4a72c; }
}
.todo-actions { display: flex; flex-direction: column; gap: 6px; }
.mini-btn {
  width: 30px; height: 30px; border-radius: 9px; background: var(--bg);
  display: grid; place-items: center; font-size: 14px; color: var(--text2);
}
.mini-btn.del { color: var(--red); }

.empty-state {
  text-align: center; color: var(--text2); padding: 40px 20px; font-size: 14px;
}
.empty-state .big { font-size: 40px; display: block; margin-bottom: 10px; }

/* ============ 悬浮按钮 & 底部导航 ============ */
.fab {
  position: fixed; right: 20px; bottom: 88px; z-index: 15;
  width: 56px; height: 56px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent2), var(--accent));
  color: #fff; font-size: 28px; font-weight: 300;
  box-shadow: 0 6px 18px rgba(74,108,247,.4);
  display: grid; place-items: center;
}
.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  max-width: 560px; margin: 0 auto;
  display: flex; background: var(--card);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tab {
  flex: 1; padding: 10px 0 8px; display: flex; flex-direction: column; align-items: center; gap: 2px;
  color: var(--text2); font-size: 11px;
}
.tab-icon { font-size: 20px; filter: grayscale(1) opacity(.6); }
.tab.active { color: var(--accent); }
.tab.active .tab-icon { filter: none; }

/* ============ 弹窗 ============ */
.overlay {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(15,18,28,.5); backdrop-filter: blur(2px);
  display: flex; align-items: flex-end; justify-content: center;
  padding: 12px;
}
.overlay .sheet {
  background: var(--card); border-radius: 20px;
  width: 100%; max-width: 480px; max-height: 88vh; overflow-y: auto;
  padding: 20px 18px calc(18px + env(safe-area-inset-bottom));
  animation: slideUp .22s ease;
}
@keyframes slideUp { from { transform: translateY(30px); opacity: 0; } to { transform: none; opacity: 1; } }
.sheet h2 { margin: 0 0 16px; font-size: 19px; }
.sheet-icon { font-size: 42px; text-align: center; margin-bottom: 4px; }
.reminder-sub { color: var(--text2); font-size: 14px; margin: 0 0 14px; text-align: center; }
.reminder-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; max-height: 40vh; overflow-y: auto; }
.reminder-item {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  background: var(--bg); border-radius: 12px; font-size: 14px;
}
.reminder-item .time { color: var(--accent); font-weight: 600; font-size: 13px; }
.sheet-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; }
.btn {
  padding: 11px 20px; border-radius: 12px; font-size: 15px; font-weight: 500;
}
.btn.primary { background: var(--accent); color: #fff; }
.btn.ghost { background: var(--bg); color: var(--text2); }
.btn.danger { background: #fdeaea; color: var(--red); }
.btn.small { padding: 8px 14px; font-size: 13px; border-radius: 10px; background: var(--accent-soft); color: var(--accent); }
.btn.small.danger { background: #fdeaea; color: var(--red); }

/* ============ 表单 ============ */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field-row { display: flex; gap: 10px; }
.field-row .field { flex: 1; }
.field-label { font-size: 13px; color: var(--text2); }
.field input[type="text"], .field input[type="date"], .field input[type="time"], .field textarea {
  border: 1px solid var(--line); background: var(--bg);
  border-radius: 12px; padding: 11px 12px; font-size: 15px; color: var(--text); width: 100%;
}
.field input:focus, .field textarea:focus { outline: none; border-color: var(--accent); }
.field-inline { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text2); margin-bottom: 14px; }
.field-inline input { width: 16px; height: 16px; accent-color: var(--accent); }
.progress-label { color: var(--accent); }
input[type="range"] { width: 100%; accent-color: var(--accent); margin: 4px 0; }
.seg { display: flex; gap: 8px; margin-top: 6px; }
.seg button {
  flex: 1; padding: 7px; border-radius: 10px; background: var(--bg);
  font-size: 13px; color: var(--text2);
}
.seg button.on { background: var(--accent); color: #fff; }

/* ============ 设置 ============ */
.setting-row {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  padding: 13px 0; border-bottom: 1px solid var(--line);
}
.setting-text { display: flex; flex-direction: column; gap: 3px; }
.setting-title { font-size: 15px; }
.setting-desc { font-size: 12px; color: var(--text2); }
.setting-row input[type="time"] {
  border: 1px solid var(--line); background: var(--bg); border-radius: 10px; padding: 7px 10px; color: var(--text);
}
.switch { position: relative; display: inline-block; width: 48px; height: 28px; flex: 0 0 auto; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider {
  position: absolute; inset: 0; border-radius: 28px; background: var(--line); transition: .2s;
}
.switch .slider::before {
  content: ""; position: absolute; width: 22px; height: 22px; border-radius: 50%;
  background: #fff; top: 3px; left: 3px; transition: .2s;
}
.switch input:checked + .slider { background: var(--accent); }
.switch input:checked + .slider::before { transform: translateX(20px); }
