:root {
  --bg: #f7f5f0;
  --card: #ffffff;
  --ink: #1b1b1f;
  --ink-soft: #55555e;
  --muted: #8d8d96;
  --line: #e8e4db;
  --accent: #16675a;
  --accent-soft: #e3f1ec;
  --danger: #c2503f;
  --radius: 18px;
  --shadow: 0 1px 2px rgba(27, 27, 31, .04), 0 8px 24px -16px rgba(27, 27, 31, .24);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro SC", "PingFang SC", "Segoe UI", "Microsoft YaHei", system-ui, sans-serif;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

body {
  min-height: 100dvh;
  background-image: radial-gradient(120% 60% at 50% 0%, #fdfcf9 0%, var(--bg) 58%);
}

button, input {
  font-family: inherit;
  font-size: 16px;
  color: inherit;
}

button { cursor: pointer; border: none; background: none; }

.shell {
  width: 100%;
  max-width: 520px;
  margin: 0 auto;
  padding: calc(20px + env(safe-area-inset-top)) 18px calc(28px + env(safe-area-inset-bottom));
}

/* ---------------- 通用卡片 / 按钮 ---------------- */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.btn-primary {
  width: 100%;
  height: 52px;
  border-radius: 14px;
  background: var(--accent);
  color: #fff;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: .02em;
  transition: transform .16s ease, opacity .16s ease, background .16s ease;
}
.btn-primary:active { transform: scale(.985); opacity: .92; }
.btn-primary:disabled { opacity: .55; }

.btn-ghost {
  height: 32px;
  padding: 0 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink-soft);
  font-size: 13px;
  transition: background .16s ease, color .16s ease;
}
.btn-ghost:hover { background: #f3f1ec; color: var(--ink); }

/* ---------------- 登录 / 注册 ---------------- */
.auth {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: calc(100dvh - 48px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  gap: 26px;
  animation: fade-up .4s ease both;
}

.brand { text-align: center; }

.brand-mark {
  width: 56px;
  height: 56px;
  margin: 0 auto 14px;
  display: grid;
  place-items: center;
  border-radius: 18px;
  background: var(--accent);
  color: #fff;
  box-shadow: 0 10px 24px -12px rgba(22, 103, 90, .8);
}

.brand h1 {
  margin: 0;
  font-size: 27px;
  font-weight: 700;
  letter-spacing: .01em;
}

.brand-sub {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.auth-card { padding: 22px 20px 20px; }

.tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 4px;
  margin-bottom: 20px;
  border-radius: 12px;
  background: #f2efe9;
}

.tab {
  height: 38px;
  border-radius: 9px;
  font-size: 14.5px;
  font-weight: 500;
  color: var(--ink-soft);
  transition: background .18s ease, color .18s ease, box-shadow .18s ease;
}
.tab.is-active {
  background: var(--card);
  color: var(--ink);
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(27, 27, 31, .1);
}

.field { display: block; margin-bottom: 14px; }

.field-label {
  display: block;
  margin-bottom: 7px;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-soft);
}

.field input {
  width: 100%;
  height: 50px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fcfbf8;
  outline: none;
  transition: border-color .18s ease, background .18s ease, box-shadow .18s ease;
}
.field input::placeholder { color: #b4b4bb; }
.field input:focus {
  border-color: var(--accent);
  background: #fff;
  box-shadow: 0 0 0 3.5px rgba(22, 103, 90, .1);
}

.form-error {
  margin: 0 0 12px;
  padding: 10px 12px;
  border-radius: 10px;
  background: #fdeeea;
  color: var(--danger);
  font-size: 13.5px;
  line-height: 1.45;
}

.auth-hint {
  margin: 16px 0 0;
  text-align: center;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.5;
}

.auth-foot {
  margin: 0;
  text-align: center;
  font-size: 12px;
  color: #a9a9b0;
}

/* ---------------- 主界面 ---------------- */
.main { animation: fade-up .34s ease both; }

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.date {
  margin: 0 0 4px;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  letter-spacing: .04em;
}

.title {
  margin: 0;
  font-size: 26px;
  font-weight: 700;
  letter-spacing: .01em;
}

.user { display: flex; align-items: center; gap: 8px; padding-top: 4px; }

.avatar {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 14px;
  font-weight: 700;
  text-transform: uppercase;
  flex: none;
}

.progress { padding: 16px 16px 14px; margin-bottom: 14px; }

.progress-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 11px;
}

.remain { margin: 0; font-size: 15px; color: var(--ink-soft); }
.remain strong { font-size: 24px; font-weight: 700; color: var(--ink); margin-right: 2px; }

.progress-meta { margin: 0; font-size: 12.5px; color: var(--muted); white-space: nowrap; }

.bar {
  height: 7px;
  border-radius: 99px;
  background: #eeeae1;
  overflow: hidden;
}

.bar-fill {
  display: block;
  height: 100%;
  width: 0;
  border-radius: 99px;
  background: linear-gradient(90deg, #1c8a76, #16675a);
  transition: width .38s cubic-bezier(.3, .9, .3, 1);
}

.progress-tip {
  margin: 10px 0 0;
  font-size: 12.5px;
  color: var(--muted);
}

.add {
  position: sticky;
  top: 0;
  z-index: 6;
  display: flex;
  gap: 9px;
  padding: 8px 0 12px;
  background: linear-gradient(180deg, var(--bg) 62%, rgba(247, 245, 240, 0));
}

.add input {
  flex: 1;
  min-width: 0;
  height: 50px;
  padding: 0 15px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--card);
  box-shadow: var(--shadow);
  outline: none;
  transition: border-color .18s ease, box-shadow .18s ease;
}
.add input::placeholder { color: #b4b4bb; }
.add input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3.5px rgba(22, 103, 90, .1);
}

.btn-add {
  flex: none;
  min-width: 76px;
  height: 50px;
  padding: 0 16px;
  border-radius: 14px;
  background: var(--accent);
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  transition: opacity .16s ease, transform .16s ease;
}
.btn-add:active:not(:disabled) { transform: scale(.97); }
.btn-add:disabled { opacity: .4; cursor: default; }

.filters {
  display: flex;
  gap: 8px;
  margin: 2px 0 14px;
}

.chip {
  height: 34px;
  padding: 0 14px;
  border-radius: 99px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink-soft);
  font-size: 13.5px;
  transition: background .16s ease, color .16s ease, border-color .16s ease;
}
.chip.is-active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 500;
}

.list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.item {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  padding: 13px 12px 13px 14px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
  animation: pop .26s cubic-bezier(.3, .9, .3, 1) both;
  transition: background .2s ease, border-color .2s ease;
}

.item.is-done { background: #fbfaf7; box-shadow: none; }

.check {
  flex: none;
  width: 24px;
  height: 24px;
  margin-top: 1px;
  display: grid;
  place-items: center;
  border: 1.8px solid #cfcbc2;
  border-radius: 50%;
  color: transparent;
  background: #fff;
  transition: background .18s ease, border-color .18s ease, color .18s ease, transform .12s ease;
}
.check:active { transform: scale(.9); }
.check svg { width: 13px; height: 13px; }

.item.is-done .check {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.item-text {
  flex: 1;
  min-width: 0;
  margin: 0;
  font-size: 15.5px;
  line-height: 1.5;
  word-break: break-word;
  overflow-wrap: anywhere;
  transition: color .2s ease;
}

.item.is-done .item-text {
  color: #a4a4ac;
  text-decoration: line-through;
  text-decoration-thickness: 1.5px;
  text-decoration-color: #c9c9cf;
}

.del {
  flex: none;
  width: 30px;
  height: 30px;
  margin: -3px -4px 0 0;
  display: grid;
  place-items: center;
  border-radius: 9px;
  color: #bdbdc4;
  transition: background .16s ease, color .16s ease;
}
.del:hover { background: #fdeeea; color: var(--danger); }
.del:active { background: #fbe3dd; color: var(--danger); }
.del svg { width: 15px; height: 15px; }

.empty {
  margin: 34px 0 6px;
  text-align: center;
  color: #b0b0b8;
  animation: fade-up .3s ease both;
}
.empty svg { color: #b0b0b8; }
.empty p { margin: 6px 0 0; font-size: 14px; color: var(--muted); }

.clear-done {
  display: block;
  margin: 20px auto 0;
  padding: 10px 18px;
  border-radius: 99px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  font-size: 13.5px;
  transition: color .16s ease, border-color .16s ease, background .16s ease;
}
.clear-done:hover { color: var(--danger); border-color: #f0d3cc; background: #fdf6f4; }

/* ---------------- Toast ---------------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(28px + env(safe-area-inset-bottom));
  transform: translate(-50%, 14px);
  padding: 11px 18px;
  border-radius: 99px;
  background: rgba(27, 27, 31, .9);
  color: #fff;
  font-size: 13.5px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity .22s ease, transform .22s ease;
  z-index: 40;
  backdrop-filter: blur(6px);
}
.toast.is-show { opacity: 1; transform: translate(-50%, 0); }

@keyframes fade-up {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes pop {
  from { opacity: 0; transform: translateY(-6px) scale(.985); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-6px); }
  45% { transform: translateX(5px); }
  70% { transform: translateX(-3px); }
}
.shake { animation: shake .32s ease; }

@media (min-width: 600px) {
  .shell { padding-left: 24px; padding-right: 24px; }
  .title { font-size: 28px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}
