/* ============================================================
   任务星球 · 家庭任务与积分激励系统 — 共享样式
   方向：Human / approachable（亲子产品）
   配色：冷白中性底 + 活力橙主色（每屏 ≤2 处）+ 权重语义色
   断点：768px（Pad 竖屏）/ 1024px（Pad 横屏与 PC）
   ============================================================ */

:root {
  /* 中性层（占 70–90% 像素） */
  --bg:        oklch(97.5% 0.005 240);
  --surface:   oklch(100% 0 0);
  --surface-2: oklch(96% 0.007 240);
  --fg:        oklch(24% 0.02 250);
  --muted:     oklch(52% 0.015 250);
  --border:    oklch(91.5% 0.006 250);

  /* 主色：活力橙（品牌动作色，克制使用） */
  --accent:      oklch(63% 0.17 55);
  --accent-ink:  oklch(44% 0.13 55);
  --accent-soft: oklch(95.5% 0.035 65);

  /* 语义色 */
  --success:      oklch(58% 0.14 155);
  --success-soft: oklch(94% 0.045 155);
  --danger:       oklch(57% 0.19 27);
  --danger-soft:  oklch(94.5% 0.035 27);
  --warn:         oklch(66% 0.14 70);
  --warn-soft:    oklch(95% 0.05 85);
  --info:         oklch(55% 0.13 240);
  --info-soft:    oklch(94.5% 0.03 240);
  --gold:         oklch(70% 0.14 85);

  /* 权重等级色（核心/常规/鼓励） */
  --w-core:  var(--danger);
  --w-core-soft:  var(--danger-soft);
  --w-normal: var(--info);
  --w-normal-soft: var(--info-soft);
  --w-bonus: var(--success);
  --w-bonus-soft: var(--success-soft);

  --radius-lg: 18px;
  --radius-md: 14px;
  --radius-sm: 10px;

  --shadow-card: 0 1px 2px oklch(30% 0.02 250 / 0.05), 0 4px 14px oklch(30% 0.02 250 / 0.06);
  --shadow-pop:  0 8px 30px oklch(30% 0.02 250 / 0.16);

  --font-display: 'PingFang SC', 'HarmonyOS Sans SC', 'Source Han Sans SC', -apple-system, BlinkMacSystemFont, 'Microsoft YaHei', system-ui, sans-serif;
  --font-body:    -apple-system, BlinkMacSystemFont, 'PingFang SC', 'HarmonyOS Sans SC', 'Microsoft YaHei', system-ui, sans-serif;
  --font-num:     ui-monospace, 'SF Mono', 'JetBrains Mono', Menlo, monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

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

body {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
  min-height: 100dvh;
}

h1, h2, h3, h4 { font-family: var(--font-display); letter-spacing: -0.01em; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
img { max-width: 100%; display: block; }
a { color: var(--accent-ink); }

.num { font-family: var(--font-num); font-variant-numeric: tabular-nums; letter-spacing: 0; }

/* ---------- 布局容器 ---------- */
.page {
  max-width: 640px;            /* 孩子端：手机上满宽，Pad/PC 居中列 */
  margin: 0 auto;
  padding: 0 16px calc(96px + env(safe-area-inset-bottom));
}
@media (min-width: 768px)  { .page { padding: 0 24px calc(104px + env(safe-area-inset-bottom)); } }

/* ---------- 顶栏（孩子端 / 通用） ---------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in oklch, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.topbar-inner {
  max-width: 640px; margin: 0 auto;
  display: flex; align-items: center; gap: 12px;
  padding: 14px 16px;
}
@media (min-width: 768px) { .topbar-inner { padding: 16px 24px; } }
.topbar-title { font-size: 20px; font-weight: 600; letter-spacing: -0.01em; }
.topbar-sub { font-size: 12.5px; color: var(--muted); letter-spacing: 0.02em; }
.topbar .spacer { flex: 1; }

.back-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; border-radius: 12px;
  border: 1px solid var(--border); background: var(--surface);
  color: var(--fg); text-decoration: none; flex: none;
}
.back-btn svg { width: 20px; height: 20px; }

/* ---------- 卡片 ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
}
.card-pad { padding: 18px; }
@media (min-width: 768px) { .card-pad { padding: 22px; } }

.section-title {
  font-size: 15px; font-weight: 600; letter-spacing: 0.02em;
  color: var(--fg);
  display: flex; align-items: center; gap: 8px;
  margin: 26px 2px 12px;
}
.section-title .hint { font-weight: 400; font-size: 12.5px; color: var(--muted); }

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid transparent; border-radius: var(--radius-md);
  min-height: 48px; padding: 0 20px;
  font-size: 16px; font-weight: 550; letter-spacing: 0.02em;
  transition: transform .12s ease, background .15s ease, border-color .15s ease;
  user-select: none; -webkit-tap-highlight-color: transparent;
  text-decoration: none;
}
.btn:active { transform: translateY(2px) scale(0.99); }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: color-mix(in oklch, var(--accent) 92%, black); }
.btn-ghost { background: var(--surface); border-color: var(--border); color: var(--fg); }
.btn-ghost:hover { border-color: var(--muted); }
.btn-soft { background: var(--accent-soft); color: var(--accent-ink); }
.btn-success { background: var(--success); color: #fff; }
.btn-danger-soft { background: var(--danger-soft); color: var(--danger); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-sm { min-height: 40px; padding: 0 14px; font-size: 14px; border-radius: var(--radius-sm); }
.btn-lg { min-height: 56px; font-size: 17px; border-radius: var(--radius-lg); }
.btn-block { display: flex; width: 100%; }
.btn[disabled] { opacity: .45; pointer-events: none; }

/* 键盘焦点环（鼠标点击不触发） */
.btn:focus-visible, .back-btn:focus-visible,
.admin-nav a:focus-visible, .tabbar a:focus-visible, .seg-item:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px color-mix(in oklch, var(--accent) 32%, transparent);
}
.btn-primary:focus-visible, .btn-success:focus-visible {
  box-shadow: 0 0 0 3px color-mix(in oklch, var(--accent) 32%, transparent), inset 0 0 0 1.5px #fff;
}
.switch input:focus-visible + i {
  box-shadow: 0 0 0 3px color-mix(in oklch, var(--accent) 32%, transparent);
}

/* 表单错误态 */
.input.is-error, .textarea.is-error, .select.is-error {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px color-mix(in oklch, var(--danger) 14%, transparent);
}

/* ---------- 徽章 / 标签 ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 12px; font-weight: 550; letter-spacing: 0.03em;
  padding: 3px 9px; border-radius: 999px; white-space: nowrap;
}
.badge-core   { background: var(--w-core-soft);   color: var(--w-core); }
.badge-normal { background: var(--w-normal-soft); color: var(--w-normal); }
.badge-bonus  { background: var(--w-bonus-soft);  color: oklch(42% 0.11 155); }
.badge-warn   { background: var(--warn-soft);     color: oklch(48% 0.12 65); }
.badge-grey   { background: var(--surface-2);     color: var(--muted); }
.badge-gold   { background: var(--warn-soft);     color: oklch(50% 0.12 75); }

/* ---------- 任务卡片（孩子端核心组件） ---------- */
.task-card {
  position: relative;
  display: flex; align-items: center; gap: 14px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  box-shadow: var(--shadow-card);
  transition: border-color .2s, opacity .2s;
}
.task-card + .task-card { margin-top: 12px; }
.task-main { flex: 1; min-width: 0; }
.task-name { font-size: 17px; font-weight: 600; letter-spacing: -0.01em; }
.task-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin-top: 6px; font-size: 12.5px; color: var(--muted); }
.task-meta .clock { display: inline-flex; align-items: center; gap: 4px; }
.task-points {
  flex: none; text-align: center;
  font-family: var(--font-num); font-variant-numeric: tabular-nums;
}
.task-points b { display: block; font-size: 24px; font-weight: 700; letter-spacing: -0.02em; }
.task-points span { font-size: 11.5px; color: var(--muted); letter-spacing: 0.04em; }

/* 状态变体 */
.task-card.is-urgent {
  border-color: var(--danger);
  background: linear-gradient(0deg, var(--danger-soft), var(--danger-soft)), var(--surface);
  animation: urgent-pulse 2s ease-in-out infinite;
}
@keyframes urgent-pulse {
  0%, 100% { box-shadow: 0 0 0 0 oklch(57% 0.19 27 / 0.28); }
  50%      { box-shadow: 0 0 0 7px oklch(57% 0.19 27 / 0); }
}
.task-card.is-pending { border-color: var(--warn); }
.task-card.is-done { border-color: color-mix(in oklch, var(--success) 45%, var(--border)); }
.task-card.is-expired { opacity: .62; background: var(--surface-2); box-shadow: none; }

.status-chip {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 13px; font-weight: 550; letter-spacing: 0.02em;
  padding: 6px 12px; border-radius: 999px; flex: none;
}
.status-chip svg { width: 15px; height: 15px; }
.status-todo    { background: var(--accent-soft);  color: var(--accent-ink); }
.status-pending { background: var(--warn-soft);    color: oklch(48% 0.12 65); }
.status-done    { background: var(--success-soft); color: oklch(42% 0.12 155); }
.status-expired { background: var(--surface-2);    color: var(--muted); }
.status-rejected { background: var(--danger-soft);  color: var(--danger); }
.status-info    { background: var(--info-soft);    color: var(--info); }

.countdown {
  display: inline-flex; align-items: baseline; gap: 4px;
  font-family: var(--font-num); font-variant-numeric: tabular-nums;
  color: var(--danger); font-weight: 600; font-size: 13.5px;
}

/* ---------- 底部 TabBar（孩子端） ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 60;
  background: color-mix(in oklch, var(--surface) 92%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbar-inner {
  max-width: 640px; margin: 0 auto;
  display: grid; grid-template-columns: repeat(3, 1fr);
}
.tabbar a {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 10px 0 12px;
  font-size: 11.5px; font-weight: 550; letter-spacing: 0.04em;
  color: var(--muted); text-decoration: none;
}
.tabbar a svg { width: 24px; height: 24px; }
.tabbar a.active { color: var(--accent-ink); }
.tabbar a.active svg { color: var(--accent); }

/* ---------- 进度条 / 进度环 ---------- */
.progress {
  height: 10px; border-radius: 999px;
  background: var(--surface-2); overflow: hidden;
}
.progress > i {
  display: block; height: 100%; border-radius: 999px;
  background: var(--accent);
  transition: width .5s cubic-bezier(.2,.8,.2,1);
}
.progress.gold > i { background: var(--gold); }

.ring { transform: rotate(-90deg); }
.ring .track { stroke: var(--surface-2); }
.ring .fill  { stroke: var(--accent); stroke-linecap: round; transition: stroke-dashoffset .6s ease; }

/* ---------- 表单 ---------- */
.field { margin-bottom: 16px; }
.field-label { display: block; font-size: 13.5px; font-weight: 550; letter-spacing: 0.02em; margin-bottom: 7px; }
.field-label .req { color: var(--danger); margin-left: 2px; }
.field-help { font-size: 12px; color: var(--muted); margin-top: 5px; }
.input, .select, .textarea {
  width: 100%; min-height: 48px;
  border: 1.5px solid var(--border); border-radius: var(--radius-md);
  background: var(--surface); padding: 10px 14px; font-size: 15.5px;
  transition: border-color .15s, box-shadow .15s;
}
.textarea { min-height: 88px; resize: vertical; }
.input:focus, .select:focus, .textarea:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in oklch, var(--accent) 18%, transparent);
}
.input::placeholder, .textarea::placeholder { color: color-mix(in oklch, var(--muted) 70%, transparent); }

.seg { display: flex; gap: 8px; flex-wrap: wrap; }
.seg-item {
  flex: 1; min-width: 84px;
  border: 1.5px solid var(--border); border-radius: var(--radius-md);
  background: var(--surface); padding: 10px 8px;
  text-align: center; font-size: 14.5px; font-weight: 550;
  cursor: pointer; transition: all .15s; user-select: none;
}
.seg-item small { display: block; font-size: 11.5px; font-weight: 400; color: var(--muted); margin-top: 2px; }
.seg-item.on { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-ink); }
.seg-item.on small { color: inherit; opacity: .75; }

/* 开关 */
.switch { position: relative; width: 52px; height: 32px; flex: none; }
.switch input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.switch i {
  position: absolute; inset: 0; border-radius: 999px;
  background: oklch(85% 0.008 250); transition: background .2s;
}
.switch i::after {
  content: ""; position: absolute; top: 3px; left: 3px;
  width: 26px; height: 26px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 4px oklch(0% 0 0 / 0.2);
  transition: transform .2s cubic-bezier(.2,.8,.2,1);
}
.switch input:checked + i { background: var(--success); }
.switch input:checked + i::after { transform: translateX(20px); }

/* ---------- 弹窗 / 抽屉 ---------- */
.modal-mask {
  position: fixed; inset: 0; z-index: 100;
  background: oklch(20% 0.02 250 / 0.45);
  display: none; align-items: flex-end; justify-content: center;
  padding: 0;
}
.modal-mask.open { display: flex; }
@media (min-width: 768px) { .modal-mask { align-items: center; padding: 24px; } }
.modal {
  background: var(--surface);
  width: 100%; max-width: 520px; max-height: 88vh; max-height: 88dvh;
  overflow-y: auto; -webkit-overflow-scrolling: touch;
  border-radius: 22px 22px 0 0;
  padding: 22px 20px calc(22px + env(safe-area-inset-bottom));
  animation: sheet-up .28s cubic-bezier(.2,.8,.2,1);
}
@media (min-width: 768px) { .modal { border-radius: 22px; padding: 26px; } }
@keyframes sheet-up { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
.modal-title { font-size: 19px; font-weight: 600; letter-spacing: -0.01em; margin-bottom: 4px; }
.modal-sub { font-size: 13.5px; color: var(--muted); margin-bottom: 18px; }
.modal-actions { display: flex; gap: 10px; margin-top: 20px; }
.modal-actions .btn { flex: 1; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 110px; z-index: 200;
  transform: translateX(-50%) translateY(16px);
  background: oklch(28% 0.02 250); color: #fff;
  font-size: 14.5px; font-weight: 550;
  padding: 12px 20px; border-radius: 999px;
  opacity: 0; pointer-events: none;
  transition: opacity .25s, transform .25s;
  box-shadow: var(--shadow-pop);
  max-width: calc(100vw - 48px); text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- 家长端框架：PC 左侧导航 / 移动端顶栏 ---------- */
.admin-shell { min-height: 100vh; min-height: 100dvh; }
.admin-topbar {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in oklch, var(--surface) 92%, transparent);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.admin-topbar-inner {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px; max-width: 1120px; margin: 0 auto;
}
.admin-brand { display: flex; align-items: center; gap: 9px; font-weight: 650; font-size: 16.5px; letter-spacing: -0.01em; text-decoration: none; color: var(--fg); }
.brand-dot {
  width: 30px; height: 30px; border-radius: 9px; flex: none;
  background: var(--accent); color: #fff;
  display: grid; place-items: center;
}
.brand-dot svg { width: 17px; height: 17px; }
.admin-nav {
  display: flex; gap: 2px; overflow-x: auto; -webkit-overflow-scrolling: touch;
  padding: 0 12px 10px; max-width: 1120px; margin: 0 auto;
  scrollbar-width: none;
}
.admin-nav::-webkit-scrollbar { display: none; }
.admin-nav a {
  flex: none; padding: 8px 14px; border-radius: 999px;
  font-size: 14px; font-weight: 550; letter-spacing: 0.02em;
  color: var(--muted); text-decoration: none;
  display: inline-flex; align-items: center; gap: 7px;
}
.admin-nav a svg { width: 16px; height: 16px; }
.admin-nav a.active { background: var(--surface-2); color: var(--fg); }
.admin-nav a .dot-num {
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px;
  background: var(--danger); color: #fff;
  font-size: 11px; font-weight: 600; font-family: var(--font-num);
  display: inline-grid; place-items: center;
}
.admin-main { max-width: 1120px; margin: 0 auto; padding: 20px 16px 64px; }

@media (min-width: 1024px) {
  .admin-shell { display: grid; grid-template-columns: 232px 1fr; }
  .admin-topbar {
    position: sticky; top: 0; height: 100vh; height: 100dvh;
    border-bottom: 0; border-right: 1px solid var(--border);
    background: var(--surface);
    display: flex; flex-direction: column;
  }
  .admin-topbar-inner { padding: 22px 18px 12px; }
  .admin-nav { flex-direction: column; padding: 6px 12px; gap: 4px; overflow: visible; }
  .admin-nav a { padding: 11px 14px; border-radius: var(--radius-md); font-size: 14.5px; }
  .admin-main { padding: 28px 32px 64px; max-width: 880px; }
}

.page-head { margin-bottom: 20px; }
.page-head h1 { font-size: 24px; font-weight: 650; letter-spacing: -0.02em; }
.page-head p { color: var(--muted); font-size: 13.5px; margin-top: 4px; }

/* ---------- 数据展示 ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
@media (min-width: 768px) { .stat-grid { grid-template-columns: repeat(4, 1fr); } }
.stat {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-md); padding: 14px 16px;
  box-shadow: var(--shadow-card);
}
.stat b { display: block; font-size: 26px; font-weight: 700; letter-spacing: -0.02em; font-family: var(--font-num); font-variant-numeric: tabular-nums; }
.stat span { font-size: 12px; color: var(--muted); letter-spacing: 0.02em; }

.list-row {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 0; border-bottom: 1px solid var(--border);
}
.list-row:last-child { border-bottom: 0; }
.list-row .grow { flex: 1; min-width: 0; }

.avatar {
  width: 42px; height: 42px; border-radius: 50%; flex: none;
  display: grid; place-items: center;
  font-weight: 650; font-size: 16px; color: #fff;
  background: var(--info);
}

/* 占位图（图片占位，不用外链图库） */
.ph-img {
  display: grid; place-items: center;
  background: var(--surface-2);
  border: 1.5px dashed var(--border);
  border-radius: var(--radius-md);
  color: var(--muted);
}
.ph-img svg { width: 28px; height: 28px; opacity: .55; }

.empty {
  text-align: center; padding: 44px 20px; color: var(--muted);
  font-size: 14px;
}
.empty svg { width: 40px; height: 40px; margin: 0 auto 10px; opacity: .4; display: block; }

/* ---------- 工具类 ---------- */
.row { display: flex; align-items: center; gap: 10px; }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.strong { font-weight: 600; }
.mt8 { margin-top: 8px; } .mt12 { margin-top: 12px; } .mt16 { margin-top: 16px; } .mt20 { margin-top: 20px; } .mt24 { margin-top: 24px; }
.mb12 { margin-bottom: 12px; }
.tac { text-align: center; }
.ellip { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* 打卡成功动效（孩子端） */
@keyframes pop-in {
  0% { transform: scale(.4); opacity: 0; }
  60% { transform: scale(1.12); }
  100% { transform: scale(1); opacity: 1; }
}
@keyframes float-up {
  0% { transform: translateY(0); opacity: 1; }
  100% { transform: translateY(-56px); opacity: 0; }
}
.pop-in { animation: pop-in .5s cubic-bezier(.2,.8,.2,1) both; }

/* 减弱动效偏好：所有动画/过渡降为瞬时 */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}

/* ---------- ICP 备案悬挂（所有页面底部，低调样式） ---------- */
.icp-footer {
  text-align: center;
  padding: 20px 0 8px;
  font-size: 12px;
  color: var(--muted);
}
.icp-footer a { color: inherit; text-decoration: none; }
.icp-footer a:hover { color: var(--fg); }
