:root {
  --blue: #2563eb;
  --blue-dark: #1d4ed8;
  --green: #16a34a;
  --red: #dc2626;
  --bg: #f1f5f9;
  --card: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --border: #e2e8f0;
  --radius: 14px;
  --shadow: 0 1px 3px rgba(15, 23, 42, 0.08), 0 1px 2px rgba(15, 23, 42, 0.04);
}

* { 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",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

.hidden { display: none !important; }

.view {
  max-width: 640px;
  margin: 0 auto;
  padding: 16px;
  padding-bottom: calc(24px + env(safe-area-inset-bottom));
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
  font-size: 15px;
}

input {
  font-family: inherit;
  font-size: 15px;
  color: var(--text);
}

/* ---------- 登录视图 ---------- */
#auth-view {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  min-height: 100dvh;
}

.auth-card {
  width: 100%;
  max-width: 380px;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 32px 28px;
  text-align: center;
}

.brand { font-size: 52px; line-height: 1; }
.auth-card h1 { margin: 12px 0 4px; font-size: 24px; }
.subtitle { margin: 0 0 24px; color: var(--muted); font-size: 14px; }

#auth-form { text-align: left; }
#auth-form label { display: block; margin: 12px 0 6px; font-size: 14px; color: var(--muted); }
#auth-form input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  outline: none;
  background: #f8fafc;
}
#auth-form input:focus { border-color: var(--blue); background: #fff; }

.primary-btn {
  display: block;
  width: 100%;
  margin-top: 20px;
  padding: 13px;
  background: var(--blue);
  color: #fff;
  border-radius: 10px;
  font-size: 16px;
  font-weight: 600;
}
.primary-btn:active { background: var(--blue-dark); }

.link-btn {
  display: block;
  width: 100%;
  margin-top: 12px;
  padding: 8px;
  color: var(--blue);
  font-size: 14px;
}

.hint { margin: 20px 0 0; color: var(--muted); font-size: 12px; }

.error {
  margin-top: 12px;
  padding: 10px 12px;
  background: #fef2f2;
  color: var(--red);
  border: 1px solid #fecaca;
  border-radius: 8px;
  font-size: 13px;
}

/* ---------- 顶部栏 ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 2px 12px;
}
.topbar h1 { margin: 0; font-size: 20px; }

.icon-btn {
  color: var(--muted);
  font-size: 14px;
  padding: 6px 10px;
  border-radius: 8px;
  background: var(--card);
  box-shadow: var(--shadow);
}

/* ---------- 月份导航 ---------- */
.month-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 10px 12px;
  margin-bottom: 12px;
}
.month-label { font-size: 17px; font-weight: 600; }
.nav-arrow { font-size: 26px; padding: 0 14px; line-height: 1; }

/* ---------- 汇总 ---------- */
.summary {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 16px;
  margin-bottom: 12px;
}
.summary-text { font-size: 14px; color: var(--muted); margin-bottom: 8px; }
.summary-text span { color: var(--text); font-weight: 700; }
.progress { height: 8px; background: var(--border); border-radius: 999px; overflow: hidden; }
.progress-bar {
  height: 100%;
  width: 0;
  background: var(--green);
  border-radius: 999px;
  transition: width 0.25s ease;
}

/* ---------- 添加任务 ---------- */
.add-row { display: flex; gap: 8px; margin-bottom: 16px; }
.add-row input {
  flex: 1;
  padding: 13px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--card);
  outline: none;
}
.add-row input:focus { border-color: var(--blue); }
.add-row .primary-btn { width: auto; margin-top: 0; padding: 13px 18px; }

/* ---------- 任务列表 ---------- */
.task-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }

.task {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 12px 14px;
  display: flex;
  gap: 12px;
  align-items: flex-start;
  transition: opacity 0.2s ease;
}

.task.done { opacity: 0.6; }

/* 复选框 */
.task-check { position: relative; flex-shrink: 0; margin-top: 2px; }
.task-check input {
  position: absolute;
  opacity: 0;
  width: 24px;
  height: 24px;
  cursor: pointer;
}
.checkmark {
  display: block;
  width: 24px;
  height: 24px;
  border: 2px solid var(--border);
  border-radius: 8px;
  transition: all 0.15s ease;
}
.task-check input:checked + .checkmark {
  background: var(--green);
  border-color: var(--green);
}
.checkmark::after {
  content: "";
  position: absolute;
  left: 8px;
  top: 4px;
  width: 6px;
  height: 11px;
  border: solid #fff;
  border-width: 0 3px 3px 0;
  transform: rotate(45deg) scale(0);
  transition: transform 0.15s ease;
}
.task-check input:checked + .checkmark::after { transform: rotate(45deg) scale(1); }

.task-body { flex: 1; min-width: 0; }
.task-top { display: flex; align-items: center; gap: 8px; }

.task-title {
  flex: 1;
  min-width: 0;
  border: none;
  background: transparent;
  padding: 4px 2px;
  font-size: 16px;
  font-weight: 600;
  outline: none;
  border-bottom: 1px dashed transparent;
}
.task-title:focus { border-bottom-color: var(--blue); }
.task.done .task-title { text-decoration: line-through; color: var(--muted); }

.delete-btn {
  flex-shrink: 0;
  color: var(--muted);
  font-size: 18px;
  padding: 4px 6px;
  border-radius: 8px;
}
.delete-btn:active { color: var(--red); }

.note-toggle {
  margin-top: 4px;
  padding: 2px 0;
  font-size: 13px;
  color: var(--blue);
}

.note-area { margin-top: 10px; display: flex; flex-direction: column; gap: 10px; }
.note-field label {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 4px;
}
.note-field input {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #f8fafc;
  outline: none;
  font-size: 14px;
}
.note-field input:focus { border-color: var(--blue); background: #fff; }

.empty {
  text-align: center;
  color: var(--muted);
  padding: 48px 16px;
  font-size: 15px;
}

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(28px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  background: rgba(15, 23, 42, 0.92);
  color: #fff;
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 14px;
  z-index: 100;
  max-width: 86vw;
  text-align: center;
}

/* ---------- 桌面端 ---------- */
@media (min-width: 720px) {
  .view { padding-top: 32px; }
  .topbar h1 { font-size: 24px; }
}
