/* ===================== 基础 ===================== */
* { -webkit-tap-highlight-color: transparent; box-sizing: border-box; }

:root {
  --bg: #F2F4F9;
  --card: #FFFFFF;
  --ink: #151A26;
  --ink-2: #4B5468;
  --muted: #8B92A6;
  --line: #E8EBF3;
  --brand: #4F7CFF;
  --brand-2: #7C5CFF;
  --brand-soft: #EDF2FF;
  --ok: #12B76A;
  --ok-soft: #E7F8F0;
  --star: #FFB020;
  --danger: #F04438;
  --r: 18px;
  --shadow: 0 2px 10px rgba(21, 26, 38, .05), 0 12px 30px rgba(21, 26, 38, .04);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --tabbar-h: 62px;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Source Han Sans SC", "Noto Sans CJK SC", sans-serif;
  font-size: 15px;
  line-height: 1.5;
  overscroll-behavior-y: none;
}

body { -webkit-font-smoothing: antialiased; }
b, strong { font-weight: 700; }
button { font-family: inherit; font-size: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, textarea { font-family: inherit; font-size: 16px; }
.is-hidden { display: none !important; }

.view {
  min-height: 100vh;
  min-height: 100dvh;
  max-width: 560px;
  margin: 0 auto;
  position: relative;
  background: var(--bg);
}

/* ===================== 通用控件 ===================== */
.card {
  background: var(--card);
  border-radius: var(--r);
  box-shadow: var(--shadow);
  padding: 16px;
}

.btn {
  border-radius: 14px;
  padding: 14px 18px;
  font-weight: 600;
  font-size: 16px;
  transition: transform .12s ease, opacity .12s ease, background .15s;
}
.btn:active { transform: scale(.975); }
.btn-primary {
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color: #fff;
  box-shadow: 0 6px 18px rgba(79, 124, 255, .28);
}
.btn-ghost { background: var(--brand-soft); color: var(--brand); }
.btn-block { display: block; width: 100%; }
.btn[disabled] { opacity: .55; pointer-events: none; }

.form { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 7px; }
.field > span { font-size: 13px; color: var(--muted); font-weight: 500; }
.field input, .field textarea {
  width: 100%;
  border: 1.5px solid var(--line);
  background: #FBFCFE;
  border-radius: 12px;
  padding: 12px 14px;
  color: var(--ink);
  outline: none;
  transition: border-color .15s, background .15s;
  resize: none;
}
.field input:focus, .field textarea:focus { border-color: var(--brand); background: #fff; }
.field input::placeholder, .field textarea::placeholder { color: #B9BFCC; }
.row-2 { display: flex; gap: 12px; }
.row-2 .field { flex: 1; }
.field-sm { max-width: 96px; }

.hint { font-size: 12.5px; color: var(--muted); margin: 0; text-align: center; }
.foot-note { text-align: center; font-size: 12px; color: #AEB4C2; margin: 22px 0 8px; }
.sec-title { font-size: 14px; color: var(--muted); font-weight: 600; margin: 22px 4px 10px; }
.arrow { color: #C3C9D6; font-size: 18px; }

.seg {
  display: flex;
  background: #E7EAF3;
  border-radius: 13px;
  padding: 4px;
  margin-bottom: 16px;
}
.seg-btn {
  flex: 1;
  padding: 10px;
  border-radius: 10px;
  font-size: 14.5px;
  font-weight: 600;
  color: var(--ink-2);
  transition: all .18s;
}
.seg-btn.is-on { background: #fff; color: var(--ink); box-shadow: 0 1px 4px rgba(0,0,0,.07); }

/* ===================== 登录页 ===================== */
.auth-wrap {
  padding: max(38px, env(safe-area-inset-top)) 20px 30px;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(120% 60% at 50% -10%, #E4ECFF 0%, rgba(242,244,249,0) 62%),
    var(--bg);
}
.brand { text-align: center; margin-bottom: 26px; }
.brand-logo { width: 74px; height: 74px; margin: 0 auto 14px; }
.brand-logo svg { width: 100%; height: 100%; filter: drop-shadow(0 8px 18px rgba(91,140,255,.32)); }
.brand h1 { font-size: 25px; margin: 0 0 6px; letter-spacing: .5px; }
.brand p { margin: 0; color: var(--muted); font-size: 14px; }

.role-pick { display: flex; gap: 10px; }
.role-btn {
  flex: 1;
  border: 1.5px solid var(--line);
  border-radius: 14px;
  padding: 12px;
  text-align: left;
  background: #FBFCFE;
  transition: all .16s;
}
.role-btn b { display: block; font-size: 15px; }
.role-btn small { color: var(--muted); font-size: 12px; }
.role-btn.is-on { border-color: var(--brand); background: var(--brand-soft); }
.role-btn.is-on b { color: var(--brand); }

/* ===================== 孩子端 ===================== */
#view-child { padding-bottom: calc(var(--tabbar-h) + var(--safe-b) + 8px); }

.kid-head {
  background: linear-gradient(150deg, #5B8CFF 0%, #7C5CFF 100%);
  color: #fff;
  padding: max(18px, env(safe-area-inset-top)) 18px 22px;
  border-radius: 0 0 26px 26px;
  position: relative;
  overflow: hidden;
}
.kid-head::after {
  content: "";
  position: absolute;
  inset: -60% -30% auto auto;
  width: 220px; height: 220px;
  background: radial-gradient(circle, rgba(255,255,255,.28), transparent 68%);
  pointer-events: none;
}
.kid-head-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.kid-hello { font-size: 19px; font-weight: 700; letter-spacing: .3px; }
.kid-date { font-size: 13px; opacity: .82; margin-top: 3px; }
.kid-pills { display: flex; gap: 8px; flex: none; }
.pill {
  display: flex; align-items: center; gap: 4px;
  background: rgba(255,255,255,.2);
  border-radius: 999px;
  padding: 5px 11px;
  font-size: 14px;
  backdrop-filter: blur(6px);
}
.pill b { font-size: 15px; }
.pill-star { color: #FFF3CD; }
.pill-fire { color: #FFE0D0; }

.date-strip {
  display: flex;
  gap: 8px;
  margin: 18px -18px 0;
  padding: 2px 18px;
  overflow-x: auto;
  scrollbar-width: none;
}
.date-strip::-webkit-scrollbar { display: none; }
.dchip {
  flex: none;
  width: 48px;
  padding: 9px 0;
  border-radius: 15px;
  background: rgba(255,255,255,.16);
  color: #fff;
  text-align: center;
  transition: all .18s;
  border: 1.5px solid transparent;
}
.dchip b { display: block; font-size: 17px; line-height: 1.2; }
.dchip small { font-size: 11px; opacity: .8; }
.dchip.is-on { background: #fff; color: var(--brand); box-shadow: 0 6px 16px rgba(20,30,80,.18); }
.dchip .dot { display: block; width: 5px; height: 5px; border-radius: 50%; background: #FFD36B; margin: 3px auto -1px; }
.dchip.is-on .dot { background: var(--star); }
.dchip.all-done .dot { background: #7BE3A8; }

.progress-card {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-top: 18px;
}
.ring-wrap { position: relative; width: 92px; height: 92px; flex: none; }
.ring { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring-bg { fill: none; stroke: rgba(255,255,255,.24); stroke-width: 10; }
.ring-fg {
  fill: none;
  stroke: #FFD36B;
  stroke-width: 10;
  stroke-linecap: round;
  stroke-dasharray: 327;
  stroke-dashoffset: 327;
  transition: stroke-dashoffset .6s cubic-bezier(.22,.9,.3,1);
}
.ring-label {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  line-height: 1.1;
}
.ring-label b { font-size: 21px; }
.ring-label small { font-size: 11px; opacity: .8; margin-top: 2px; }
.progress-text b { display: block; font-size: 16px; }
.progress-text small { font-size: 12.5px; opacity: .82; }

.kid-main { padding: 16px; }
.task-list { display: flex; flex-direction: column; gap: 11px; }

.task {
  display: flex;
  align-items: flex-start;
  gap: 13px;
  background: var(--card);
  border-radius: 16px;
  padding: 14px;
  box-shadow: var(--shadow);
  transition: transform .16s ease, opacity .2s, background .2s;
  position: relative;
  overflow: hidden;
}
.task::before {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 4px;
  background: var(--sc, #94A3B8);
}
.task:active { transform: scale(.985); }
.task.is-done { background: #F7FAF8; }
.task.is-done .task-title { color: #9AA3B2; text-decoration: line-through; text-decoration-thickness: 1.5px; }
.task.is-done::before { background: var(--ok); }

.check {
  flex: none;
  width: 30px; height: 30px;
  border-radius: 50%;
  border: 2.5px solid #D8DEEA;
  background: #fff;
  display: flex; align-items: center; justify-content: center;
  margin-top: 1px;
  transition: all .2s cubic-bezier(.22,.9,.3,1);
}
.check svg { width: 17px; height: 17px; stroke: #fff; stroke-width: 3.4; fill: none; stroke-linecap: round; stroke-linejoin: round; opacity: 0; transform: scale(.4); transition: all .22s cubic-bezier(.34,1.56,.64,1); }
.task.is-done .check { background: var(--ok); border-color: var(--ok); }
.task.is-done .check svg { opacity: 1; transform: scale(1); }
.check.pop { animation: pop .42s cubic-bezier(.34,1.56,.64,1); }
@keyframes pop { 0% { transform: scale(1); } 40% { transform: scale(1.22); } 100% { transform: scale(1); } }

.task-body { flex: 1; min-width: 0; }
.task-sub {
  display: flex; align-items: center; gap: 6px;
  font-size: 11.5px; font-weight: 600;
  color: var(--sc, #94A3B8);
  margin-bottom: 3px;
}
.task-sub .pts { color: var(--star); font-weight: 700; }
.task-title { font-size: 15.5px; font-weight: 500; color: var(--ink); word-break: break-word; transition: color .2s; }
.task-note { font-size: 12.5px; color: var(--muted); margin-top: 4px; word-break: break-word; }
.task-time { font-size: 11.5px; color: #B0B7C5; margin-top: 5px; }

.empty { text-align: center; padding: 46px 20px; color: var(--muted); }
.empty-emoji { font-size: 40px; margin-bottom: 10px; }
.empty p { margin: 0; font-size: 14px; }

/* 星星 / 奖励 */
.stat-row { display: flex; gap: 10px; }
.stat-card {
  flex: 1;
  background: var(--card);
  border-radius: 15px;
  padding: 14px 10px;
  text-align: center;
  box-shadow: var(--shadow);
}
.stat-card b { display: block; font-size: 21px; color: var(--brand); }
.stat-card small { font-size: 11.5px; color: var(--muted); }

.reward-list { display: flex; flex-direction: column; gap: 11px; }
.reward {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--card);
  border-radius: 16px;
  padding: 14px;
  box-shadow: var(--shadow);
}
.reward-emoji { font-size: 24px; flex: none; width: 42px; height: 42px; border-radius: 13px; background: #FFF7E6; display: flex; align-items: center; justify-content: center; }
.reward-body { flex: 1; min-width: 0; }
.reward-title { font-size: 15px; font-weight: 500; }
.reward-cost { font-size: 12.5px; color: var(--star); font-weight: 600; margin-top: 2px; }
.reward-btn {
  flex: none;
  border-radius: 11px;
  padding: 9px 14px;
  font-size: 13.5px;
  font-weight: 600;
  background: var(--brand-soft);
  color: var(--brand);
}
.reward-btn:active { transform: scale(.96); }
.reward-btn.is-locked { background: #F1F3F8; color: #B4BBC9; }
.reward-btn.is-pending { background: #FFF3E0; color: #D9820A; }
.reward-btn.is-claimed { background: var(--ok-soft); color: var(--ok); }

/* ===================== 家长端 ===================== */
#view-parent { padding-bottom: calc(var(--tabbar-h) + var(--safe-b) + 8px); }

.p-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: max(18px, env(safe-area-inset-top)) 18px 14px;
  background: #fff;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 20;
}
.p-title { font-size: 18px; font-weight: 700; }
.p-sub { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.chip-btn {
  background: var(--brand-soft);
  color: var(--brand);
  font-weight: 700;
  font-size: 13px;
  padding: 8px 13px;
  border-radius: 999px;
  letter-spacing: 1px;
}

.p-main { padding: 16px; }
.p-summary {
  background: #fff;
  border-radius: 16px;
  padding: 16px;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 16px;
}
.p-summary-left b { font-size: 26px; color: var(--brand); }
.p-summary-left small { display: block; font-size: 12.5px; color: var(--muted); }
.p-summary .bar { flex: 1; height: 9px; background: #EEF1F7; border-radius: 999px; overflow: hidden; }
.p-summary .bar i { display: block; height: 100%; width: 0; border-radius: 999px; background: linear-gradient(90deg, var(--brand), var(--brand-2)); transition: width .5s ease; }

.p-list { display: flex; flex-direction: column; gap: 9px; }
.p-item {
  background: #fff;
  border-radius: 14px;
  padding: 13px 14px;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 11px;
}
.p-item.is-done { opacity: .72; }
.p-item.is-done .p-item-title { text-decoration: line-through; color: #9AA3B2; }
.p-item-dot { width: 9px; height: 9px; border-radius: 50%; flex: none; background: var(--sc, #94A3B8); }
.p-item.is-done .p-item-dot { background: var(--ok); }
.p-item-body { flex: 1; min-width: 0; }
.p-item-title { font-size: 14.5px; word-break: break-word; }
.p-item-meta { font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.p-item-del { color: #C9CEDA; font-size: 19px; padding: 2px 4px; }

.day-chips, .subject-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.day-chips .d2, .subject-chips .s2 {
  padding: 8px 13px;
  border-radius: 11px;
  border: 1.5px solid var(--line);
  font-size: 13.5px;
  color: var(--ink-2);
  background: #FBFCFE;
  transition: all .15s;
}
.day-chips .d2.is-on, .subject-chips .s2.is-on {
  border-color: var(--brand);
  background: var(--brand-soft);
  color: var(--brand);
  font-weight: 600;
}

.stepper { display: flex; align-items: center; gap: 0; width: 132px; border: 1.5px solid var(--line); border-radius: 12px; overflow: hidden; }
.stepper button { width: 42px; height: 44px; font-size: 19px; color: var(--ink-2); background: #FBFCFE; }
.stepper input { flex: 1; text-align: center; border: none; background: #fff; padding: 0; height: 44px; }
.stepper input::-webkit-outer-spin-button, .stepper input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

.list-card { padding: 0; overflow: hidden; margin-top: 18px; }
.list-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 15px 17px;
  font-size: 15px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  text-decoration: none;
}
.list-row:last-child { border-bottom: none; }
.list-row b { color: var(--brand); letter-spacing: 1.5px; font-size: 16px; }
.list-row-danger { color: var(--danger); }

.p-badge {
  display: inline-block;
  background: #FFF3E0;
  color: #D9820A;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 6px;
  margin-left: 6px;
}

/* ===================== 底部导航 ===================== */
.tabbar {
  position: fixed;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  width: 100%;
  max-width: 560px;
  height: calc(var(--tabbar-h) + var(--safe-b));
  padding-bottom: var(--safe-b);
  background: rgba(255,255,255,.94);
  backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
  display: flex;
  z-index: 30;
}
.tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: #A9B0BF;
  font-size: 11px;
  font-weight: 500;
  transition: color .16s;
}
.tab svg { width: 22px; height: 22px; }
.tab.is-on { color: var(--brand); }
.tab-switch { color: #B7BECD; }

/* ===================== 提示 / 动效 ===================== */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--tabbar-h) + var(--safe-b) + 26px);
  transform: translate(-50%, 16px);
  background: rgba(24, 28, 40, .92);
  color: #fff;
  font-size: 14px;
  padding: 11px 18px;
  border-radius: 12px;
  opacity: 0;
  pointer-events: none;
  transition: all .24s ease;
  z-index: 90;
  max-width: 84vw;
  text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.confetti-layer { position: fixed; inset: 0; pointer-events: none; z-index: 80; overflow: hidden; }
.confetti {
  position: absolute;
  width: 9px; height: 9px;
  border-radius: 2px;
  animation: fall linear forwards;
}
@keyframes fall {
  from { transform: translateY(-10vh) rotate(0deg); opacity: 1; }
  to { transform: translateY(105vh) rotate(720deg); opacity: .1; }
}

.fly-star {
  position: fixed;
  font-size: 22px;
  pointer-events: none;
  z-index: 85;
  animation: flyStar .9s cubic-bezier(.3,.8,.4,1) forwards;
}
@keyframes flyStar {
  0% { transform: translate(0, 0) scale(.6); opacity: 0; }
  25% { opacity: 1; }
  100% { transform: translate(var(--dx), var(--dy)) scale(1.15); opacity: 0; }
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
.anim-in { animation: fadeUp .28s ease both; }

/* ===================== 弹窗 ===================== */
.modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(16, 20, 32, .42);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 100;
  backdrop-filter: blur(2px);
}
.modal-box {
  width: 100%;
  max-width: 320px;
  background: #fff;
  border-radius: 20px;
  padding: 22px 20px 16px;
  box-shadow: 0 20px 50px rgba(10, 15, 30, .26);
}
.modal-box h3 { margin: 0 0 8px; font-size: 17px; text-align: center; }
.modal-box p { margin: 0 0 14px; font-size: 13.5px; color: var(--muted); text-align: center; line-height: 1.55; }
.modal-input {
  width: 100%;
  border: 1.5px solid var(--line);
  background: #FBFCFE;
  border-radius: 12px;
  padding: 12px 14px;
  outline: none;
  text-align: center;
  letter-spacing: 3px;
  margin-bottom: 14px;
}
.modal-input:focus { border-color: var(--brand); background: #fff; }
.modal-actions { display: flex; gap: 10px; }
.modal-actions .btn { flex: 1; padding: 12px; font-size: 15px; }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
