/* ========== 基础变量 ========== */
:root {
  --bg: #f5f6fa;
  --bg-card: #ffffff;
  --bg-soft: #eef0f6;
  --border: #e3e6ef;
  --text: #1d2233;
  --text-soft: #5b6478;
  --text-mute: #8a93a6;
  --primary: #4f6df5;
  --primary-soft: #eaeefe;
  --success: #18a957;
  --success-soft: #e6f6ec;
  --danger: #e35d6a;
  --shadow: 0 6px 24px rgba(20, 30, 60, 0.06);
  --radius: 14px;
  --radius-sm: 10px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1020;
    --bg-card: #141a30;
    --bg-soft: #1c2240;
    --border: #232a48;
    --text: #eef0f7;
    --text-soft: #b6bcd0;
    --text-mute: #7c83a0;
    --primary: #7c95ff;
    --primary-soft: #1f285a;
    --success: #34d399;
    --success-soft: #14342a;
    --danger: #ff6b78;
    --shadow: 0 8px 30px rgba(0, 0, 0, 0.35);
  }
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

body {
  min-height: 100vh;
  padding: 24px 16px 80px;
}

/* ========== 布局 ========== */
.app {
  max-width: 760px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ========== 日期导航 ========== */
.date-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 12px 14px;
  box-shadow: var(--shadow);
}

.icon-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--bg-soft);
  color: var(--text);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform .12s ease, background .12s ease;
}
.icon-btn:hover { background: var(--primary-soft); }
.icon-btn:active { transform: scale(0.94); }

.date-display {
  flex: 1;
  text-align: center;
  user-select: none;
}
.date-main {
  font-size: 22px;
  font-weight: 600;
  letter-spacing: .5px;
}
.date-week {
  margin-top: 2px;
  font-size: 13px;
  color: var(--text-mute);
}

.today-btn {
  height: 38px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid var(--primary);
  background: transparent;
  color: var(--primary);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background .12s ease, color .12s ease;
}
.today-btn:hover { background: var(--primary); color: #fff; }
.today-btn[disabled] {
  opacity: .5;
  cursor: not-allowed;
}

/* ========== 统计卡片 ========== */
.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}
.stat-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 16px;
  text-align: center;
  box-shadow: var(--shadow);
}
.stat-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--primary);
  letter-spacing: .5px;
  font-variant-numeric: tabular-nums;
}
.stat-label {
  margin-top: 4px;
  font-size: 13px;
  color: var(--text-mute);
}

/* ========== 任务列表 ========== */
.list-wrap {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 8px 8px 4px;
  box-shadow: var(--shadow);
}

.list-head,
.task-item {
  display: grid;
  grid-template-columns: 36px 1fr 64px 72px 36px;
  align-items: center;
  gap: 8px;
  padding: 10px 8px;
}

.list-head {
  font-size: 12px;
  color: var(--text-mute);
  border-bottom: 1px solid var(--border);
  padding-bottom: 8px;
}

.col-time, .col-status { text-align: center; }

.task-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.task-item {
  border-radius: var(--radius-sm);
  position: relative;
  transition: background .12s ease;
}
.task-item + .task-item { border-top: 1px dashed var(--border); }
.task-item:hover { background: var(--bg-soft); }

/* 复选框 */
.check {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid var(--text-mute);
  background: transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  transition: background .12s ease, border-color .12s ease, transform .12s ease;
  color: #fff;
  font-size: 14px;
  line-height: 1;
}
.check:hover { border-color: var(--primary); }
.check:active { transform: scale(0.92); }
.check.checked {
  background: var(--success);
  border-color: var(--success);
}

.task-name {
  font-size: 15px;
  color: var(--text);
  word-break: break-word;
  transition: color .15s ease, text-decoration-color .15s ease;
  text-decoration: line-through transparent;
}
.task-item.done .task-name {
  color: var(--text-mute);
  text-decoration: line-through var(--text-mute);
}

.task-time {
  text-align: center;
  font-variant-numeric: tabular-nums;
  color: var(--text-soft);
  font-size: 14px;
}

.task-status {
  text-align: center;
  font-size: 13px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary);
  display: inline-block;
}
.task-status.done {
  background: var(--success-soft);
  color: var(--success);
}

.del-btn {
  width: 28px;
  height: 28px;
  border: none;
  background: transparent;
  color: var(--text-mute);
  border-radius: 50%;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  opacity: 0;
  transition: opacity .12s ease, background .12s ease, color .12s ease;
}
.task-item:hover .del-btn,
.task-item:focus-within .del-btn { opacity: 1; }
.del-btn:hover { background: rgba(227, 93, 106, 0.12); color: var(--danger); }

.empty {
  padding: 36px 16px;
  text-align: center;
  color: var(--text-mute);
}
.empty-icon {
  font-size: 36px;
  margin-bottom: 6px;
}

/* ========== 添加表单 ========== */
.add-form {
  display: grid;
  grid-template-columns: 1fr 96px auto;
  gap: 8px;
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 12px;
  box-shadow: var(--shadow);
}
.input {
  height: 42px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-soft);
  color: var(--text);
  padding: 0 12px;
  font-size: 15px;
  outline: none;
  transition: border-color .12s ease, background .12s ease;
  font-family: inherit;
}
.input:focus { border-color: var(--primary); background: var(--bg-card); }
.time-input { text-align: center; }

.add-btn {
  height: 42px;
  padding: 0 22px;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--primary);
  color: #fff;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  transition: filter .12s ease, transform .12s ease;
}
.add-btn:hover { filter: brightness(1.08); }
.add-btn:active { transform: scale(0.97); }
.add-btn[disabled] { opacity: .6; cursor: not-allowed; }

/* ========== 页脚 ========== */
.foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  color: var(--text-mute);
  padding: 0 4px;
}
.sync[data-state="loading"] { color: var(--primary); }
.sync[data-state="ok"] { color: var(--success); }
.sync[data-state="error"] { color: var(--danger); }

/* ========== 响应式 ========== */
@media (max-width: 520px) {
  body { padding: 12px 10px 80px; font-size: 14px; }
  .date-main { font-size: 19px; }
  .stat-value { font-size: 24px; }
  .list-head,
  .task-item {
    grid-template-columns: 32px 1fr 56px 64px 32px;
    gap: 6px;
    padding: 10px 4px;
  }
  .task-status { padding: 2px 6px; font-size: 12px; }
  .add-form { grid-template-columns: 1fr 80px auto; }
  .icon-btn { width: 36px; height: 36px; }
}