:root {
  --blue: #1769e0;
  --blue-dark: #1358bf;
  --blue-light: #e8f1fd;
  --text: #1f2329;
  --text-2: #646a73;
  --text-3: #8f959e;
  --line: #e5e8eb;
  --bg: #f5f7fa;
  --card: #ffffff;
  --danger: #d4380d;
  --danger-bg: #fff0ef;
  --radius: 16px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei",
    "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

/* ================= 登录 / 注册 ================= */
.auth-view {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
}

.auth-card {
  width: 100%;
  max-width: 380px;
  background: var(--card);
  border-radius: 24px;
  box-shadow: 0 12px 32px rgba(31, 35, 41, 0.08);
  padding: 36px 28px 32px;
}

.auth-brand { text-align: center; }

.auth-logo {
  width: 60px;
  height: 60px;
  line-height: 60px;
  margin: 0 auto;
  border-radius: 18px;
  background: var(--blue);
  color: #fff;
  font-size: 32px;
  font-weight: 700;
}

.auth-brand h1 { margin: 16px 0 4px; font-size: 26px; }
.auth-brand p { margin: 0; color: var(--text-2); font-size: 14px; }

.auth-tabs {
  display: flex;
  margin-top: 28px;
  background: #f2f3f5;
  border-radius: 12px;
  padding: 4px;
}

.auth-tab {
  flex: 1;
  border: 0;
  border-radius: 9px;
  padding: 9px 0;
  background: transparent;
  color: var(--text-2);
  font-size: 15px;
  cursor: pointer;
  transition: all 0.2s;
}

.auth-tab.active { background: var(--card); color: var(--text); font-weight: 600;
  box-shadow: 0 2px 6px rgba(31, 35, 41, 0.08); }

.field { display: block; margin-top: 18px; }

.field span { display: block; font-size: 13px; color: var(--text-2); margin-bottom: 8px; }

.field input {
  width: 100%;
  padding: 13px 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  font-size: 16px; /* >=16px 防 iOS 聚焦缩放 */
  color: var(--text);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.field input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(23, 105, 224, 0.12);
}

.form-error {
  margin: 16px 0 0;
  padding: 10px 14px;
  border-radius: 10px;
  background: var(--danger-bg);
  color: var(--danger);
  font-size: 13px;
}

.btn-primary {
  width: 100%;
  margin-top: 24px;
  padding: 13px 0;
  border: 0;
  border-radius: 12px;
  background: var(--blue);
  color: #fff;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}

.btn-primary:hover { background: var(--blue-dark); }
.btn-primary:disabled { opacity: 0.6; cursor: default; }

/* ================= 待办列表 ================= */
.todo-view { max-width: 560px; margin: 0 auto; padding: 24px 16px 96px; }

.todo-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 18px;
}

.todo-header h1 { margin: 0; font-size: 24px; }

.todo-count { margin: 6px 0 0; color: var(--text-2); font-size: 14px; }
.todo-count b { color: var(--blue); font-size: 16px; }

.header-right { display: flex; align-items: center; gap: 10px; }

.username { color: var(--text-3); font-size: 13px; max-width: 90px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.btn-ghost {
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--text-2);
  border-radius: 10px;
  padding: 6px 12px;
  font-size: 13px;
  cursor: pointer;
}

.btn-ghost:hover { color: var(--danger); border-color: #ffd8d6; }

.state-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  padding: 10px 14px;
  border-radius: 12px;
  background: var(--danger-bg);
  color: var(--danger);
  font-size: 13px;
}

.state-bar .btn-ghost { background: transparent; border: 0; color: var(--danger);
  font-weight: 600; }

.todo-list { display: flex; flex-direction: column; gap: 10px; }

.todo-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--card);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: 0 1px 3px rgba(31, 35, 41, 0.05);
  animation: item-in 0.22s ease;
}

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

.check {
  flex: none;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid #c9ced6;
  background: transparent;
  padding: 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 13px;
  line-height: 1;
  transition: all 0.18s;
}

.check:hover { border-color: var(--blue); }
.check.checked { background: var(--blue); border-color: var(--blue); }

.item-content {
  flex: 1;
  min-width: 0;
  font-size: 15px;
  line-height: 1.5;
  word-break: break-word;
  transition: color 0.18s;
}

.item-content.done {
  color: var(--text-3);
  text-decoration: line-through;
}

.item-delete {
  flex: none;
  border: 0;
  background: transparent;
  color: var(--text-3);
  font-size: 18px;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.18s;
}

.item-delete:hover { background: var(--danger-bg); color: var(--danger); }

.empty-state {
  text-align: center;
  padding: 56px 16px;
  background: var(--card);
  border-radius: var(--radius);
  border: 1px dashed var(--line);
}

.empty-icon { font-size: 40px; }
.empty-state p { margin: 12px 0 0; font-size: 15px; color: var(--text-2); }
.empty-sub { font-size: 13px; color: var(--text-3) !important; }

/* ================= 底部输入栏 ================= */
.add-bar {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 18px;
  bottom: calc(18px + var(--safe-bottom));
  width: min(528px, calc(100% - 32px));
  display: flex;
  gap: 10px;
  padding: 10px;
  background: var(--card);
  border-radius: 18px;
  box-shadow: 0 8px 28px rgba(31, 35, 41, 0.14);
}

.add-bar input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: none;
  background: transparent;
  font-size: 16px;
  padding: 6px 8px;
  color: var(--text);
}

.add-bar input::placeholder { color: var(--text-3); }

.add-bar.shake { animation: shake 0.35s; }

@keyframes shake {
  0%, 100% { transform: translateX(-50%); }
  25% { transform: translateX(calc(-50% - 8px)); }
  75% { transform: translateX(calc(-50% + 8px)); }
}

.btn-add {
  flex: none;
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 12px;
  background: var(--blue);
  color: #fff;
  font-size: 22px;
  cursor: pointer;
  transition: background 0.2s;
}

.btn-add:hover { background: var(--blue-dark); }
.btn-add:disabled { opacity: 0.6; }
