/* ===== 儿童每日打卡 ToDo · 全局样式 ===== */
:root {
  --bg: #f4f7fb;
  --surface: #ffffff;
  --surface-2: #f0f4f9;
  --text: #2b3a4a;
  --text-soft: #6b7c8f;
  --primary: #5b8def;
  --primary-soft: #e8f0ff;
  --border: #e3e9f0;
  --radius: 16px;
  --shadow: 0 4px 18px rgba(40, 70, 120, 0.08);
  --danger: #ef5350;
  --ok: #26c281;
  --warn: #ffa726;
  --tap: 48px;
}

* { 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, "PingFang SC", "Microsoft YaHei", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
}

button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; font-size: 16px; }

/* ===== 顶部导航 ===== */
.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  gap: 12px;
  flex-wrap: wrap;
}
.brand {
  font-weight: 800;
  font-size: 18px;
  color: var(--primary);
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}
.view-tabs { display: flex; gap: 8px; background: var(--surface-2); padding: 4px; border-radius: 12px; }
.view-tabs button {
  border: none;
  background: transparent;
  color: var(--text-soft);
  font-weight: 700;
  padding: 8px 16px;
  border-radius: 9px;
  font-size: 15px;
  transition: .15s;
}
.view-tabs button.active { background: var(--primary); color: #fff; box-shadow: 0 2px 8px rgba(91,141,239,.35); }

/* ===== 布局容器 ===== */
main { max-width: 860px; margin: 0 auto; padding: 16px; }
.view { animation: fade .2s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(6px);} to { opacity: 1; transform: none; } }

/* ===== 通用卡片 ===== */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 14px;
}
.card-title { font-weight: 800; font-size: 16px; margin: 0 0 12px; display: flex; align-items: center; gap: 8px; }

/* ===== 孩子切换 chips ===== */
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  border: 1.5px solid var(--border);
  background: var(--surface);
  border-radius: 999px;
  padding: 7px 14px;
  font-weight: 700;
  color: var(--text-soft);
  display: flex; align-items: center; gap: 6px;
  min-height: 40px;
}
.chip.active { border-color: var(--primary); background: var(--primary-soft); color: var(--primary); }
.chip .ava { font-size: 18px; }

/* ===== 进度条 ===== */
.progress-wrap { margin-top: 4px; }
.progress-bar { height: 12px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.progress-fill { height: 100%; background: linear-gradient(90deg,#7ed0a5,#26c281); border-radius: 999px; transition: width .3s; }
.progress-text { font-size: 14px; color: var(--text-soft); margin-top: 6px; }

/* ===== 任务卡片（孩子打卡页） ===== */
.task {
  position: relative;
  display: flex; align-items: center; gap: 12px;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px;
  margin-bottom: 12px;
  border-left: 6px solid var(--type-color, var(--primary));
  transition: background-color .35s ease, border-left-color .35s ease, box-shadow .35s ease;
}
.task.important { background: #fff8f0; }
.task.overdue { border-left-color: var(--danger); background: #fff3f2; }
.task.done { opacity: .72; }
.task .icon {
  width: 46px; height: 46px; border-radius: 12px;
  display: grid; place-items: center; font-size: 24px;
  background: var(--type-soft, var(--primary-soft));
  flex-shrink: 0;
}
.task .body { flex: 1; min-width: 0; }
.task .tname { font-weight: 800; font-size: 16px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.task .tag-prio { font-size: 11px; font-weight: 800; color: #fff; background: var(--warn); border-radius: 6px; padding: 1px 6px; }
.task .meta { font-size: 13px; color: var(--text-soft); margin-top: 2px; display: flex; gap: 10px; flex-wrap: wrap; }
.task .meta .overdue-tag { color: var(--danger); font-weight: 800; }
.task .note { font-size: 13px; color: var(--text-soft); margin-top: 4px; }
.task .record {
  margin-top: 8px; width: 100%; border: 1px solid var(--border); border-radius: 10px;
  padding: 8px 10px; background: var(--surface-2); color: var(--text);
}
.task .record::placeholder { color: #aab6c4; }

.checkbox {
  width: 42px; height: 42px; border-radius: 12px; border: 2.5px solid var(--type-color, var(--primary));
  flex-shrink: 0; display: grid; place-items: center; color: #fff; font-size: 22px; font-weight: 900;
  background: transparent; transition: .15s; margin-left: 6px;
}
.checkbox.on { background: var(--type-color, var(--primary)); }

.task .tname { padding-right: 30px; }
.del-btn {
  position: absolute; top: 7px; right: 7px; z-index: 2;
  width: 26px; height: 26px; border-radius: 8px; border: 1px solid transparent;
  background: transparent; color: #b6c0cc; font-size: 13px; cursor: pointer;
  display: grid; place-items: center; transition: .15s;
}
.del-btn:hover { background: var(--danger); color: #fff; border-color: var(--danger); }
.del-btn:active { transform: scale(.9); }

/* ===== 日期选择条 ===== */
.date-bar { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.date-nav {
  width: 42px; height: 42px; border-radius: 12px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font-size: 22px; cursor: pointer; flex-shrink: 0;
  display: grid; place-items: center; box-shadow: var(--shadow); transition: .15s;
}
.date-nav:hover { border-color: var(--brand, #5b54c9); }
.date-mid {
  flex: 1; display: flex; align-items: center; justify-content: center; gap: 8px;
  height: 42px; border-radius: 12px; border: 1px solid var(--border);
  background: var(--surface); cursor: pointer; box-shadow: var(--shadow); transition: .15s;
}
.date-mid:hover { border-color: var(--brand, #5b54c9); }
.date-str { font-weight: 800; font-size: 15px; color: var(--text); }
.date-tag {
  font-size: 12px; font-weight: 800; color: var(--text-soft);
  background: var(--surface-2); border-radius: 6px; padding: 2px 8px;
}
.date-tag.today { color: #fff; background: var(--brand, #5b54c9); }
.date-today {
  height: 42px; padding: 0 14px; border-radius: 12px; border: 1px solid var(--brand, #5b54c9);
  background: var(--surface); color: var(--brand, #5b54c9); font-size: 14px; font-weight: 800; cursor: pointer; flex-shrink: 0;
}
.date-today:hover { background: var(--brand, #5b54c9); color: #fff; }

/* ===== 提醒横幅 ===== */
.reminder-banner {
  background: #fff3cd; border: 1px solid #ffe69c; color: #8a6d00;
  border-radius: 12px; padding: 10px 14px; margin-bottom: 14px; font-size: 14px; font-weight: 600;
}
.reminder-banner b { color: var(--danger); }

/* ===== 按钮 ===== */
.btn {
  border: none; border-radius: 12px; padding: 10px 16px; font-weight: 800; font-size: 15px;
  display: inline-flex; align-items: center; gap: 6px; justify-content: center;
  min-height: var(--tap);
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-soft { background: var(--primary-soft); color: var(--primary); }
.btn-ghost { background: var(--surface-2); color: var(--text-soft); }
.btn-danger { background: #ffe9e8; color: var(--danger); }
.btn-block { width: 100%; }
.btn-sm { min-height: 38px; padding: 6px 12px; font-size: 14px; }
.add-btn {
  position: fixed; right: 18px; bottom: 22px; z-index: 15;
  width: 60px; height: 60px; border-radius: 50%; background: var(--primary); color: #fff;
  font-size: 30px; box-shadow: 0 6px 20px rgba(91,141,239,.45); border: none;
  display: grid; place-items: center;
}

/* ===== 家长页子标签 ===== */
.sub-tabs { display: flex; gap: 8px; background: var(--surface-2); padding: 4px; border-radius: 12px; margin-bottom: 14px; }
.sub-tabs button {
  flex: 1; border: none; background: transparent; color: var(--text-soft); font-weight: 700;
  padding: 9px; border-radius: 9px; font-size: 14px;
}
.sub-tabs button.active { background: var(--primary); color: #fff; }

/* ===== 模板列表 ===== */
.tpl {
  display: flex; align-items: center; gap: 12px; padding: 12px;
  background: var(--surface-2); border-radius: 12px; margin-bottom: 10px;
}
.tpl .icon { width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; font-size: 21px; background: var(--type-soft); flex-shrink: 0; }
.tpl .body { flex: 1; min-width: 0; }
.tpl .tname { font-weight: 800; }
.tpl .meta { font-size: 13px; color: var(--text-soft); }
.tpl.off { opacity: .5; }
.tpl .actions { display: flex; gap: 6px; align-items: center; }
.switch { position: relative; width: 46px; height: 26px; flex-shrink: 0; }
.switch input { display: none; }
.switch .slider { position: absolute; inset: 0; background: #cdd6e0; border-radius: 999px; transition: .2s; }
.switch .slider::before { content: ""; position: absolute; width: 20px; height: 20px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .2s; }
.switch input:checked + .slider { background: var(--ok); }
.switch input:checked + .slider::before { transform: translateX(20px); }

/* ===== 成员卡 ===== */
.member {
  display: flex; align-items: center; gap: 12px; padding: 12px;
  background: var(--surface-2); border-radius: 12px; margin-bottom: 10px;
}
.member .ava { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; font-size: 24px; flex-shrink: 0; }
.member .body { flex: 1; font-weight: 800; }
.member .actions { display: flex; gap: 6px; }

/* ===== 统计 ===== */
.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.stat-box { background: var(--surface-2); border-radius: 12px; padding: 14px; text-align: center; }
.stat-box .num { font-size: 26px; font-weight: 900; color: var(--primary); }
.stat-box .label { font-size: 12px; color: var(--text-soft); margin-top: 2px; }
.stat-box.ok .num { color: var(--ok); }
.stat-box.warn .num { color: var(--danger); }

.type-stat { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.type-stat .dot { width: 12px; height: 12px; border-radius: 4px; flex-shrink: 0; }
.type-stat .bar { flex: 1; height: 18px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.type-stat .bar > i { display: block; height: 100%; border-radius: 999px; }
.type-stat .cnt { font-weight: 800; font-size: 14px; min-width: 56px; text-align: right; color: var(--text-soft); }

.chart-box { width: 100%; }
.chart-box canvas { width: 100%; height: 220px; display: block; }

/* ===== 历史列表 ===== */
.hist-day { display: flex; align-items: center; justify-content: space-between; padding: 12px; background: var(--surface-2); border-radius: 12px; margin-bottom: 8px; }
.hist-day .d { font-weight: 800; }
.hist-day .r { font-size: 13px; color: var(--text-soft); }

/* ===== 弹窗 ===== */
.modal-mask {
  position: fixed; inset: 0; background: rgba(20,30,45,.45); z-index: 50;
  display: flex; align-items: flex-end; justify-content: center;
}
@media (min-width: 600px) { .modal-mask { align-items: center; } }
.modal {
  background: var(--surface); border-radius: 20px 20px 0 0; width: 100%; max-width: 520px;
  padding: 20px; max-height: 90vh; overflow-y: auto; animation: slideUp .25s ease;
}
@media (min-width: 600px) { .modal { border-radius: 20px; } }
@keyframes slideUp { from { transform: translateY(40px); opacity: .6; } to { transform: none; opacity: 1; } }
.modal h3 { margin: 0 0 16px; font-size: 18px; }
.field { margin-bottom: 14px; }
.field label { display: block; font-weight: 700; font-size: 14px; margin-bottom: 6px; color: var(--text-soft); }
.field input, .field select, .field textarea {
  width: 100%; border: 1.5px solid var(--border); border-radius: 12px; padding: 11px 12px; background: var(--surface-2); color: var(--text);
}
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--primary); background: #fff; }
.field.row { display: flex; gap: 10px; }
.field.row > div { flex: 1; }
.prio-group { display: flex; gap: 10px; }
.prio-group label { flex: 1; border: 1.5px solid var(--border); border-radius: 12px; padding: 11px; text-align: center; font-weight: 800; color: var(--text-soft); }
.prio-group input { display: none; }
.prio-group input:checked + span { color: var(--primary); }
.prio-group label:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); }
.avatar-pick { display: flex; flex-wrap: wrap; gap: 8px; }
.avatar-pick button { width: 42px; height: 42px; border-radius: 12px; border: 2px solid var(--border); background: var(--surface-2); font-size: 22px; }
.avatar-pick button.sel { border-color: var(--primary); }
.color-pick { display: flex; flex-wrap: wrap; gap: 8px; }
.color-pick button { width: 34px; height: 34px; border-radius: 50%; border: 3px solid transparent; }
.color-pick button.sel { border-color: #2b3a4a; }
.modal-actions { display: flex; gap: 10px; margin-top: 8px; }
.modal-actions .btn { flex: 1; }

/* ===== Toast ===== */
.toast {
  position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%);
  background: #2b3a4a; color: #fff; padding: 10px 18px; border-radius: 999px; font-weight: 700;
  font-size: 14px; z-index: 60; box-shadow: 0 6px 20px rgba(0,0,0,.25); animation: fade .2s;
}

/* ===== 空状态 ===== */
.empty { text-align: center; color: var(--text-soft); padding: 30px 10px; font-size: 14px; }

/* ===== 桌面端微调 ===== */
@media (min-width: 768px) {
  main { padding: 24px; }
  .task { padding: 16px 18px; }
  .task .icon { width: 52px; height: 52px; font-size: 27px; }
}
/* 适用星期选择器 */
.day-pick { display: flex; flex-wrap: wrap; gap: 8px; }
.day-btn {
  width: 42px; height: 42px; border-radius: 10px;
  border: 1.5px solid var(--border, #dbe2ec); background: #fff;
  color: #5f6b7a; font-size: 14px; cursor: pointer; transition: .15s;
}
.day-btn:hover { border-color: var(--brand, #5b54c9); }
.day-btn.on { background: var(--brand, #5b54c9); border-color: var(--brand, #5b54c9); color: #fff; }
.day-hint { font-size: 12px; color: #9aa7b5; margin-top: 6px; }

@media (max-width: 420px) {
  .stat-grid { grid-template-columns: repeat(3, 1fr); gap: 8px; }
  .stat-box .num { font-size: 22px; }
  .stat-box .label { font-size: 11px; }
  .brand { font-size: 16px; }
  .view-tabs button { padding: 7px 12px; font-size: 14px; }
  .day-btn { width: 44px; height: 44px; }
}

/* ===== 应用门禁（全屏登录，防止陌生人访问） ===== */
.login-screen { display: none; }
body.locked .login-screen { display: flex; }
body.locked .app-header,
body.locked main,
body.locked .add-btn { display: none !important; }
.login-screen {
  position: fixed; inset: 0; z-index: 40;
  align-items: center; justify-content: center; padding: 20px;
  background: linear-gradient(160deg, #e9f1ff 0%, #f4f7fb 55%, #eef3fb 100%);
}
.login-card {
  width: 100%; max-width: 380px;
  background: var(--surface); border-radius: 24px;
  box-shadow: 0 14px 44px rgba(40,70,120,.18);
  padding: 30px 24px 26px; text-align: center;
  animation: popIn .32s cubic-bezier(.22,.61,.36,1);
}
@keyframes popIn { from { opacity: 0; transform: translateY(18px) scale(.97); } to { opacity: 1; transform: none; } }
.login-logo { font-size: 54px; line-height: 1; margin-bottom: 10px; }
.login-title { font-size: 22px; font-weight: 800; color: var(--text); }
.login-sub { color: var(--text-soft); font-size: 14px; margin: 6px 0 20px; line-height: 1.5; }
.login-card .field { text-align: left; }
.login-err { color: var(--danger); font-size: 13px; min-height: 18px; margin: -6px 0 8px; text-align: left; }
.login-hint { color: var(--text-soft); font-size: 13px; margin: -4px 0 14px; text-align: left; }
.login-remember { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-soft); margin: 4px 0 16px; justify-content: flex-start; cursor: pointer; }
.login-remember input { width: 18px; height: 18px; accent-color: var(--primary); }
.login-link {
  display: block; width: 100%; margin-top: 12px; border: none; background: none;
  color: var(--primary); font-size: 14px; font-weight: 700; cursor: pointer; padding: 6px;
}
.login-link:active { opacity: .7; }
/* 登录失败抖动 */
@keyframes shake {
  10%, 90% { transform: translateX(-2px); }
  20%, 80% { transform: translateX(4px); }
  30%, 50%, 70% { transform: translateX(-8px); }
  40%, 60% { transform: translateX(8px); }
}
.login-card.shake { animation: shake .5s; }

/* 头部锁定按钮 */
.lock-btn {
  margin-left: auto; width: 40px; height: 40px; border-radius: 50%;
  border: 1px solid var(--border); background: var(--surface-2);
  font-size: 17px; display: grid; place-items: center; color: var(--text-soft);
  transition: transform .12s;
}
.lock-btn:active { transform: scale(.92); }
@media (max-width: 420px) {
  .lock-btn { width: 36px; height: 36px; font-size: 15px; }
}
