:root {
  --bg: #f6f7f9;
  --card: #ffffff;
  --line: #e9ebef;
  --text: #1f2328;
  --text-2: #6b7280;
  --text-3: #9aa1ab;
  --brand: #3b6ef6;
  --brand-soft: #eaf0ff;
  --danger: #e5484d;
  --ok: #12a150;
  --warn: #f5a524;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 6px 16px rgba(16, 24, 40, .05);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

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", system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; border: none; background: none; padding: 0; }
input, textarea { outline: none; }

.hidden { display: none !important; }

/* ---------- 登录 ---------- */
.auth-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px calc(24px + env(safe-area-inset-bottom));
}
.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--card);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 28px 24px 24px;
}
.auth-logo { font-size: 26px; font-weight: 700; letter-spacing: 4px; text-align: center; margin-bottom: 4px; }
.auth-sub { text-align: center; color: var(--text-3); font-size: 13px; margin-bottom: 22px; }
.seg { display: flex; background: var(--bg); border-radius: 10px; padding: 3px; margin-bottom: 18px; }
.seg button {
  flex: 1; padding: 8px 0; border-radius: 8px; font-size: 14px; color: var(--text-2);
}
.seg button.on { background: var(--card); color: var(--text); font-weight: 600; box-shadow: 0 1px 3px rgba(16,24,40,.08); }
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 13px; color: var(--text-2); margin-bottom: 6px; }
.input {
  width: 100%; padding: 11px 12px; border: 1px solid var(--line); border-radius: 10px;
  background: #fff; font-size: 15px; transition: border-color .15s;
}
.input:focus { border-color: var(--brand); }
.row-inline { display: flex; gap: 8px; }
.row-inline .input { flex: 1; }
.btn {
  width: 100%; padding: 12px; border-radius: 10px; background: var(--brand); color: #fff;
  font-weight: 600; font-size: 15px; margin-top: 6px; transition: opacity .15s;
}
.btn:active { opacity: .82; }
.btn:disabled { opacity: .5; cursor: default; }
.btn.ghost { background: transparent; color: var(--brand); border: 1px solid var(--line); }
.btn.small { width: auto; padding: 8px 14px; font-size: 14px; margin-top: 0; }
.auth-foot { display: flex; justify-content: space-between; margin-top: 14px; font-size: 13px; color: var(--text-2); }
.auth-foot button { color: var(--brand); }
.tip { font-size: 13px; color: var(--text-2); background: var(--brand-soft); border-radius: 10px; padding: 10px 12px; margin-bottom: 12px; }
.err { font-size: 13px; color: var(--danger); margin-top: 8px; min-height: 18px; }

/* ---------- 主框架 ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 18px; background: rgba(255,255,255,.9); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.brand { font-size: 18px; font-weight: 700; letter-spacing: 3px; }
.brand .dot { color: var(--brand); }
.user-mail { font-size: 13px; color: var(--text-3); max-width: 45vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.link-btn { font-size: 13px; color: var(--text-2); }
.link-btn:hover { color: var(--brand); }

.main { max-width: 720px; margin: 0 auto; padding: 16px 16px 96px; }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: flex; background: rgba(255,255,255,.94); backdrop-filter: blur(8px);
  border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom);
}
.tabbar button {
  flex: 1; padding: 10px 0 8px; text-align: center; color: var(--text-3); font-size: 12px;
}
.tabbar button.on { color: var(--brand); font-weight: 600; }
.tabbar .ic { display: block; font-size: 19px; line-height: 1.2; }

@media (min-width: 760px) {
  .tabbar { top: 57px; bottom: auto; border-top: none; border-bottom: 1px solid var(--line); max-width: 720px; left: 50%; transform: translateX(-50%); border-left: 1px solid var(--line); border-right: 1px solid var(--line); border-radius: 0 0 12px 12px; }
  .tabbar button { font-size: 13px; padding: 9px 0; }
  .main { padding-top: 24px; }
}

/* ---------- 卡片 / 通用 ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin-bottom: 14px; }
.card-title { font-size: 14px; font-weight: 600; margin-bottom: 12px; display: flex; align-items: center; justify-content: space-between; }
.muted { color: var(--text-3); font-size: 13px; }
.empty { text-align: center; color: var(--text-3); font-size: 14px; padding: 22px 0; }

/* ---------- 任务 ---------- */
.add-box { display: flex; gap: 8px; align-items: center; }
.add-box .input { flex: 1; }
.icon-btn { width: 38px; height: 38px; border-radius: 10px; background: var(--bg); color: var(--text-2); font-size: 18px; flex: none; }
.icon-btn.on { background: var(--brand-soft); color: var(--brand); }
.opt-panel { display: none; margin-top: 12px; padding-top: 12px; border-top: 1px dashed var(--line); }
.opt-panel.show { display: block; }
.opt-grid { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.chip { padding: 6px 12px; border-radius: 999px; background: var(--bg); font-size: 13px; color: var(--text-2); border: 1px solid transparent; }
.chip.on { background: var(--brand-soft); color: var(--brand); border-color: #cfdcff; font-weight: 600; }
.opt-line { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-2); margin-bottom: 8px; }
.opt-line input[type="date"], .opt-line input[type="time"] { padding: 6px 10px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }

.group-h { font-size: 13px; color: var(--text-3); margin: 18px 2px 8px; display: flex; justify-content: space-between; }
.group-h .count { color: var(--text-3); }
.task {
  display: flex; align-items: flex-start; gap: 11px; padding: 11px 14px; background: var(--card);
  border: 1px solid var(--line); border-radius: 12px; margin-bottom: 8px;
}
.task .check {
  width: 21px; height: 21px; border-radius: 50%; border: 2px solid #cfd4dc; flex: none; margin-top: 3px;
  display: flex; align-items: center; justify-content: center; font-size: 12px; color: #fff; transition: .15s;
}
.task .check.on { background: var(--brand); border-color: var(--brand); }
.task .body { flex: 1; min-width: 0; cursor: pointer; }
.task .t-title { word-break: break-word; }
.task.done .t-title { color: var(--text-3); text-decoration: line-through; }
.task .t-meta { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; font-size: 12px; color: var(--text-3); }
.tag-p { color: var(--danger); }
.tag-w { color: var(--warn); }
.tag-l { color: var(--text-3); }
.task .del { color: var(--text-3); font-size: 15px; padding: 0 2px; flex: none; }
.overdue-flag { color: var(--danger); }
.task .t-note { color: var(--text-2); }
.more-btn {
  display: block; width: 100%; padding: 10px; margin-top: 2px;
  border: 1px dashed var(--line); border-radius: 10px;
  color: var(--text-2); font-size: 13px; background: transparent;
}

/* 任务编辑 */
.task.editing { display: block; border-color: var(--brand); background: #fcfdff; }
.edit-form { width: 100%; }
.edit-form .input { margin-bottom: 8px; }
.edit-form .opt-grid { margin-bottom: 8px; }
.edit-form .opt-k { width: 40px; flex: none; }
.edit-form .opt-line input[type="date"], .edit-form .opt-line input[type="time"] { flex: 1; min-width: 0; }
.edit-actions { display: flex; gap: 8px; margin-top: 10px; }
.edit-actions .btn { flex: 1; }

/* PIN 锁 */
.pin-input { text-align: center; font-size: 22px; letter-spacing: 10px; }

/* 账单导入 */
.import-box { margin-top: 12px; padding-top: 12px; border-top: 1px dashed var(--line); }
.imp-sample { margin: 10px 0; padding: 10px 12px; background: var(--bg); border-radius: 10px; font-size: 13px; color: var(--text-2); }
.imp-day { margin-bottom: 8px; }
.imp-day:last-child { margin-bottom: 0; }
.imp-day b { color: var(--text); font-weight: 600; }

/* 非正式域名提示条 */
.origin-warn {
  position: fixed; top: 0; left: 0; right: 0; z-index: 300;
  background: #fff7e6; color: #8a5300; font-size: 13px;
  padding: 10px 14px; text-align: center; box-shadow: 0 1px 4px rgba(0,0,0,.08);
}
.origin-warn a { color: var(--brand); font-weight: 600; margin-left: 6px; }

/* ---------- 记录 ---------- */
.date-nav { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.date-nav .d-main { font-size: 16px; font-weight: 600; }
.date-nav .d-sub { font-size: 12px; color: var(--text-3); }
.nav-btn { padding: 5px 12px; border-radius: 8px; background: var(--bg); color: var(--text-2); font-size: 14px; }
.nav-btn:disabled { color: #c6cad1; }
.log-item { border-left: 3px solid var(--brand-soft); padding: 2px 0 2px 12px; margin-bottom: 14px; }
.log-item:last-child { margin-bottom: 0; }
.log-time { font-size: 12px; color: var(--text-3); }
.log-text { white-space: pre-wrap; word-break: break-word; margin-top: 2px; }
.log-tags { margin-top: 6px; display: flex; flex-wrap: wrap; gap: 6px; }
.log-tag { font-size: 12px; color: var(--brand); background: var(--brand-soft); border-radius: 6px; padding: 1px 8px; }
.log-mood { font-size: 12px; color: var(--text-2); }
textarea.input { resize: vertical; min-height: 76px; line-height: 1.6; }

/* ---------- 统计 ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.stat-cell { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 14px 10px; text-align: center; }
.stat-cell .num { font-size: 24px; font-weight: 700; line-height: 1.2; }
.stat-cell .lbl { font-size: 12px; color: var(--text-3); margin-top: 2px; }
.bars { display: flex; align-items: flex-end; gap: 8px; height: 120px; margin-top: 6px; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; }
.bar { width: 100%; max-width: 26px; background: var(--brand-soft); border-radius: 5px 5px 0 0; min-height: 3px; transition: height .3s; }
.bar.today { background: var(--brand); }
.bar-lbl { font-size: 11px; color: var(--text-3); margin-top: 6px; }
.bar-num { font-size: 11px; color: var(--text-2); margin-bottom: 3px; }
.checkin-btn { margin-top: 4px; }

/* ---------- 反馈 ---------- */
#toast {
  position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%) translateY(10px);
  background: rgba(31,35,40,.92); color: #fff; font-size: 14px; padding: 10px 18px; border-radius: 10px;
  opacity: 0; pointer-events: none; transition: .22s; z-index: 99; max-width: 80vw; text-align: center;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#loading {
  position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  background: var(--bg); z-index: 200; font-size: 14px; color: var(--text-3);
}
.spinner { width: 20px; height: 20px; border: 2px solid var(--line); border-top-color: var(--brand); border-radius: 50%; animation: spin .7s linear infinite; margin-right: 10px; }
@keyframes spin { to { transform: rotate(360deg); } }
