:root {
  --bg: #f4f6fb;
  --glow: rgba(99, 102, 241, .12);
  --surface: #ffffff;
  --surface-soft: #f8f9fd;
  --border: #e7eaf3;
  --border-strong: #cfd5e6;
  --text: #1c2333;
  --muted: #8a92a6;
  --primary: #5b6cf0;
  --primary-strong: #4a5be0;
  --primary-soft: #eef0ff;
  --success: #18a96b;
  --danger: #e2585f;
  --shadow: 0 18px 45px rgba(31, 42, 84, .08);
  --shadow-sm: 0 6px 18px rgba(31, 42, 84, .06);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1320;
    --glow: rgba(99, 102, 241, .18);
    --surface: #191f30;
    --surface-soft: #20273c;
    --border: #2b3350;
    --border-strong: #414b6c;
    --text: #eef1fa;
    --muted: #9099b4;
    --primary: #7c8bff;
    --primary-strong: #6d7cff;
    --primary-soft: #262d50;
    --success: #3ddc97;
    --danger: #ff7b83;
    --shadow: 0 18px 45px rgba(0, 0, 0, .35);
    --shadow-sm: 0 6px 18px rgba(0, 0, 0, .22);
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(900px 420px at 15% -10%, var(--glow), transparent 70%),
    radial-gradient(700px 380px at 100% 0%, var(--glow), transparent 65%),
    var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.app {
  width: 100%;
  max-width: 680px;
  margin: 0 auto;
  padding: 56px 24px 64px;
}

/* ---------- 顶部 ---------- */
.eyebrow {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .14em;
}

.dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--primary);
  box-shadow: 0 0 0 4px var(--primary-soft);
}

.header h1 {
  margin: 0;
  font-size: 38px;
  font-weight: 750;
  letter-spacing: -.02em;
}

.subtitle {
  margin: 8px 0 30px;
  color: var(--muted);
  font-size: 15px;
}

/* ---------- 输入区 ---------- */
.composer {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 8px 8px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow);
  transition: border-color .2s, box-shadow .2s;
}

.composer:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px var(--primary-soft), var(--shadow);
}

.task-input {
  flex: 1 1 auto;
  min-width: 0;
  height: 44px;
  padding: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font-size: 16px; /* 16px 可避免 iOS Safari 聚焦时自动放大页面 */
  font-family: inherit;
}

.task-input::placeholder { color: var(--muted); opacity: .85; }

.btn-add {
  flex: 0 0 auto;
  height: 44px;
  padding: 0 20px;
  border: 0;
  border-radius: 12px;
  background: var(--primary);
  color: #fff;
  font-size: 15px;
  font-weight: 650;
  font-family: inherit;
  white-space: nowrap;
  cursor: pointer;
  transition: background .2s, transform .12s;
}

.btn-add:hover { background: var(--primary-strong); }
.btn-add:active { transform: scale(.96); }
.btn-add:focus-visible { outline: 3px solid var(--primary-soft); outline-offset: 3px; }

.hint {
  min-height: 22px;
  margin: 8px 4px 0;
  color: var(--muted);
  font-size: 13px;
}
.hint[data-kind="warn"] { color: var(--danger); }
.hint[data-kind="ok"] { color: var(--success); }

/* ---------- 列表面板 ---------- */
.board {
  margin-top: 18px;
  padding: 22px 22px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 22px;
  box-shadow: var(--shadow);
}

.board-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.counter { display: flex; align-items: baseline; gap: 8px; }

.counter strong {
  font-size: 32px;
  line-height: 1;
  font-weight: 750;
  color: var(--primary);
  font-variant-numeric: tabular-nums;
}

.counter-label { color: var(--muted); font-size: 14px; }

.btn-clear {
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  transition: color .2s, border-color .2s, background .2s;
}

.btn-clear:hover:not(:disabled) { color: var(--danger); border-color: var(--danger); }
.btn-clear:disabled { opacity: .5; cursor: default; }
.btn-clear:focus-visible { outline: 3px solid var(--primary-soft); outline-offset: 2px; }

.progress {
  height: 5px;
  margin: 16px 0 8px;
  border-radius: 99px;
  background: var(--surface-soft);
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  width: 0;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--primary), var(--success));
  transition: width .35s ease;
}

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

.todo-item {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 4px 6px 0;
  border-bottom: 1px solid var(--border);
  animation: item-in .22s ease both;
}

.todo-item:last-child { border-bottom: 0; }

@keyframes item-in {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: none; }
}

/* 自定义勾选框：44px 触控区域，手机也好点 */
.check-wrap {
  position: relative;
  flex: 0 0 44px;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.check {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
  z-index: 1;
}

.check-mark {
  position: relative;
  width: 22px;
  height: 22px;
  border: 2px solid var(--border-strong);
  border-radius: 8px;
  background: var(--surface);
  transition: background .18s, border-color .18s, transform .18s;
}

.check-mark::after {
  content: "";
  position: absolute;
  left: 6px;
  top: 2px;
  width: 6px;
  height: 11px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg) scale(0);
  transition: transform .18s ease;
}

.check:checked + .check-mark { background: var(--success); border-color: var(--success); }
.check:checked + .check-mark::after { transform: rotate(45deg) scale(1); }
.check:active + .check-mark { transform: scale(.9); }
.check:focus-visible + .check-mark { outline: 3px solid var(--primary-soft); outline-offset: 3px; }

.todo-text {
  flex: 1 1 auto;
  min-width: 0;
  padding: 0 6px;
  font-size: 16px;
  word-break: break-word;
  transition: color .2s;
}

.is-done .todo-text {
  color: var(--muted);
  text-decoration: line-through;
  text-decoration-color: var(--border-strong);
}

.btn-delete {
  flex: 0 0 44px;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--muted);
  font-size: 24px;
  line-height: 1;
  font-family: inherit;
  cursor: pointer;
  transition: color .2s, background .2s;
}

.btn-delete:hover { color: var(--danger); background: var(--surface-soft); }
.btn-delete:active { transform: scale(.92); }
.btn-delete:focus-visible { outline: 3px solid var(--primary-soft); outline-offset: -2px; }

/* ---------- 空状态 / 页脚 ---------- */
.empty { padding: 34px 10px 40px; text-align: center; }

.empty-icon {
  width: 56px;
  height: 56px;
  margin: 0 auto 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 18px;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 26px;
  font-weight: 700;
}

.empty-title { margin: 0 0 4px; font-size: 16px; font-weight: 650; }
.empty-desc { margin: 0; color: var(--muted); font-size: 13px; }

.footer {
  margin-top: 18px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.icp-link, .admin-link, .install-link {
  color: var(--muted);
  font-size: 12px;
  text-decoration: none;
}

.icp-link:hover, .admin-link:hover, .install-link:hover { color: var(--primary); text-decoration: underline; }
.admin-link { opacity: .8; }
.install-link { color: var(--danger); }

.footer #status[data-mode="offline"] { color: var(--danger); }

/* ---------- 手机适配 ---------- */
@media (max-width: 520px) {
  .app { padding: 30px 16px calc(40px + env(safe-area-inset-bottom)); }
  .header h1 { font-size: 30px; }
  .subtitle { margin-bottom: 24px; }
  .composer { padding-left: 14px; border-radius: 16px; }
  .btn-add { padding: 0 15px; }
  .board { padding: 18px 14px 10px; border-radius: 18px; }
  .counter strong { font-size: 28px; }
  .btn-clear { padding: 0 10px; font-size: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
