:root {
  --bg: #f7f2e8;
  --card: #ffffff;
  --ink: #2c2a26;
  --muted: #8a8378;
  --line: #ece5d8;
  --green: #1f7a5c;
  --green-soft: #e3f1ea;
  --orange: #d98324;
  --orange-soft: #fbeedd;
  --blue: #2f6fa8;
  --blue-soft: #e4eef8;
  --red: #b94a3f;
  --shadow: 0 6px 18px rgba(70, 55, 30, .08);
}

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

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: system-ui, -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 16px;
  line-height: 1.6;
}

body { padding-bottom: 78px; }

#app { max-width: 540px; margin: 0 auto; padding: 0 16px; }

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 2px 10px;
}

.brand { font-size: 18px; font-weight: 700; letter-spacing: .5px; }
.brand span { color: var(--green); }

.chip {
  font-size: 12px;
  color: var(--green);
  background: var(--green-soft);
  border-radius: 999px;
  padding: 4px 12px;
  font-weight: 600;
}

.hero { margin: 6px 2px 14px; }
.hero h1 { font-size: 26px; margin: 0 0 4px; line-height: 1.25; }
.hero .sub { color: var(--muted); font-size: 13px; }
.hero .sub b { color: var(--ink); font-weight: 600; }

.card {
  background: var(--card);
  border-radius: 18px;
  padding: 16px;
  box-shadow: var(--shadow);
  margin-bottom: 14px;
}

.card h2 {
  font-size: 15px;
  margin: 0 0 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.card h2 .dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--green); display: inline-block;
}

.card.child h2 .dot { background: var(--orange); }

.tasks { display: flex; flex-direction: column; gap: 8px; }

.task {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  cursor: pointer;
  transition: background .15s, border-color .15s;
}

.task:active { transform: scale(.995); }
.task.done { background: var(--green-soft); border-color: #c9e3d7; }
.task.done .t-title { text-decoration: line-through; color: var(--muted); }

.box {
  width: 24px; height: 24px; flex: 0 0 24px;
  border: 2px solid #cfc6b5;
  border-radius: 8px;
  margin-top: 1px;
  display: grid; place-items: center;
  font-size: 14px; color: #fff;
  transition: all .15s;
}

.task.done .box { background: var(--green); border-color: var(--green); }

.t-title { font-weight: 600; font-size: 15px; }
.t-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }

.words { display: flex; flex-wrap: wrap; gap: 8px; }
.word {
  border: 1px solid var(--line);
  background: #fffdf8;
  border-radius: 12px;
  padding: 8px 12px;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: .3px;
  cursor: pointer;
}
.word:active { background: var(--blue-soft); }

.actions { display: flex; gap: 10px; margin-top: 14px; }

.btn {
  flex: 1;
  border: 0;
  border-radius: 14px;
  padding: 14px;
  font-size: 16px;
  font-weight: 700;
  font-family: inherit;
  background: var(--green);
  color: #fff;
  cursor: pointer;
}

.btn:disabled { background: #d8d2c6; color: #fff; }
.btn.ghost { background: #fff; color: var(--ink); border: 1px solid var(--line); }

.steps { counter-reset: s; margin: 0; padding: 0; list-style: none; }
.steps li {
  display: flex;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px dashed var(--line);
}
.steps li:last-child { border-bottom: 0; }
.steps .time {
  flex: 0 0 44px;
  color: var(--orange);
  font-weight: 700;
  font-size: 13px;
}
.steps .what { font-size: 14px; }
.steps .what b { font-weight: 700; }

.script {
  background: var(--blue-soft);
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 13px;
  color: #24486b;
  margin-top: 10px;
}
.script b { color: #16324d; }

.note {
  font-size: 13px;
  color: var(--muted);
  margin-top: 10px;
  padding-left: 2px;
}

details summary {
  cursor: pointer;
  font-weight: 700;
  font-size: 15px;
  list-style: none;
}
details summary::-webkit-details-marker { display: none; }
details summary::after { content: "+"; float: right; color: var(--muted); }
details[open] summary::after { content: "－"; }

.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.stat {
  background: var(--card);
  border-radius: 16px;
  padding: 14px;
  box-shadow: var(--shadow);
}
.stat .n { font-size: 24px; font-weight: 800; line-height: 1.2; }
.stat .l { font-size: 12px; color: var(--muted); }

.heat { display: flex; flex-direction: column; gap: 4px; }
.hrow { display: flex; align-items: center; gap: 6px; }
.hlabel { width: 34px; font-size: 10px; color: var(--muted); text-align: right; }
.hcells { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; flex: 1; }
.hc { height: 16px; border-radius: 4px; background: #efe9dd; }
.hc.done { background: var(--green); }
.hc.part { background: #8fc7ad; }
.hc.miss { background: #f3d7cf; }
.hc.rest { background: #ece6da; }
.hc.future { background: #f6f1e7; border: 1px dashed #e4dccd; }

.weekrow {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 10px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
}
.weekrow:last-child { border-bottom: 0; }
.weekrow .wn { width: 42px; font-size: 12px; color: var(--muted); }
.weekrow .wt { flex: 1; font-size: 14px; font-weight: 600; }
.weekrow .wc { font-size: 12px; color: var(--muted); }

.stagehead {
  font-size: 13px;
  font-weight: 700;
  color: var(--green);
  margin: 18px 4px 6px;
  letter-spacing: .5px;
}

.tabs {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  background: rgba(255, 255, 255, .94);
  backdrop-filter: blur(10px);
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: center;
  gap: 4px;
  padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
  z-index: 20;
}
.tabs button {
  flex: 1;
  max-width: 120px;
  border: 0;
  background: transparent;
  padding: 8px 0;
  font-size: 12px;
  font-family: inherit;
  color: var(--muted);
  border-radius: 12px;
}
.tabs button.on { color: var(--green); background: var(--green-soft); font-weight: 700; }

.toast {
  position: fixed;
  left: 50%; bottom: 96px;
  transform: translateX(-50%) translateY(10px);
  background: #2c2a26;
  color: #fff;
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transition: all .25s;
  z-index: 40;
  white-space: nowrap;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.modal {
  position: fixed; inset: 0;
  background: rgba(30, 26, 20, .45);
  display: flex; align-items: flex-end; justify-content: center;
  z-index: 30;
}
.modal.hidden { display: none; }
.sheet {
  background: var(--bg);
  width: 100%;
  max-width: 540px;
  max-height: 82vh;
  overflow: auto;
  border-radius: 22px 22px 0 0;
  padding: 20px 18px calc(24px + env(safe-area-inset-bottom));
}

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field label { font-size: 12px; color: var(--muted); }
.field input {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  font-size: 15px;
  font-family: inherit;
  background: #fff;
}

.audio-group { margin-bottom: 12px; }
.audio-group h3 { font-size: 13px; margin: 0 0 8px; color: var(--muted); }
.track {
  display: flex; align-items: center; justify-content: space-between;
  padding: 9px 10px; border-bottom: 1px solid var(--line);
  font-size: 13px;
}
.track button {
  border: 0; background: var(--green-soft); color: var(--green);
  border-radius: 8px; padding: 5px 10px; font-size: 12px; font-family: inherit;
}

.small { font-size: 12px; color: var(--muted); }
.res { color: var(--green); text-decoration: none; border-bottom: 1px solid #bcdccd; }
.res:active { opacity: .6; }
.empty { text-align: center; color: var(--muted); padding: 30px 0; font-size: 14px; }

/* ---------- 模式切换 ---------- */
.top-right { display: flex; align-items: center; gap: 8px; }
.mode-btn {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--muted);
  border-radius: 999px;
  padding: 4px 12px;
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
}
.mode-btn:active { background: var(--green-soft); color: var(--green); }

/* ---------- 孩子模式 ---------- */
body.kid-mode { padding-bottom: 0; background: #fdf8ee; }
body.kid-mode .tabs { display: none; }
body.kid-mode #app { max-width: 760px; padding: 0 22px; }
body.kid-mode .top { padding: 20px 2px 6px; }
body.kid-mode .brand { font-size: 16px; }
body.kid-mode .mode-btn { background: #fff6e6; border-color: #f0dcbb; color: #b0742a; }

.kid-wrap {
  min-height: calc(100vh - 110px);
  display: flex;
  flex-direction: column;
  padding: 4px 0 26px;
}

.kid-top { display: flex; justify-content: space-between; align-items: center; color: var(--muted); font-size: 13px; }

.kid-card {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 10px;
  padding: 20px 8px;
}

.kid-icon { font-size: 76px; line-height: 1; margin-bottom: 6px; }
.kid-task { font-size: 30px; font-weight: 800; line-height: 1.35; letter-spacing: .5px; }
.kid-sub { font-size: 17px; color: var(--muted); max-width: 26em; }

.kid-words { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; margin-top: 8px; }
.kid-word {
  background: #fff;
  border: 2px solid #efe2ca;
  border-radius: 18px;
  padding: 14px 22px;
  font-size: 30px;
  font-weight: 800;
  letter-spacing: 1px;
  color: #2c2a26;
  box-shadow: 0 4px 0 #f0e3cc;
}
.kid-word:active { transform: translateY(2px); box-shadow: 0 2px 0 #f0e3cc; }

.kid-dots { display: flex; gap: 10px; justify-content: center; margin: 14px 0 18px; }
.kid-dot { width: 12px; height: 12px; border-radius: 50%; background: #e8dcc4; }
.kid-dot.on { background: var(--orange); transform: scale(1.15); }

.kid-btn {
  width: 100%;
  border: 0;
  border-radius: 22px;
  padding: 22px;
  font-size: 22px;
  font-weight: 800;
  font-family: inherit;
  color: #fff;
  background: var(--green);
  box-shadow: 0 6px 0 #155c45;
  cursor: pointer;
}
.kid-btn:active { transform: translateY(3px); box-shadow: 0 3px 0 #155c45; }
.kid-btn.orange { background: var(--orange); box-shadow: 0 6px 0 #a8621a; }
.kid-btn.ghost { background: #fff; color: var(--green); border: 2px solid #cfe4d8; box-shadow: none; }

.kid-speak {
  border: 0;
  background: var(--blue-soft);
  color: #24557d;
  border-radius: 999px;
  padding: 10px 18px;
  font-size: 15px;
  font-family: inherit;
  margin-top: 6px;
}

.kid-star { font-size: 92px; animation: pop .5s ease; }
@keyframes pop { 0% { transform: scale(.4); opacity: 0; } 70% { transform: scale(1.15); } 100% { transform: scale(1); } }

.kid-empty { text-align: center; color: var(--muted); font-size: 16px; }

/* ---------- 家长验证 ---------- */
.gate { position: fixed; inset: 0; background: rgba(30, 26, 20, .5); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 20px; }
.gate.hidden { display: none; }
.gate-card { background: #fff; border-radius: 20px; padding: 22px; width: 100%; max-width: 360px; box-shadow: 0 20px 40px rgba(0,0,0,.2); }
.gate-card h3 { margin: 0 0 6px; font-size: 17px; }
.gate-card p { margin: 0 0 12px; color: var(--muted); font-size: 13px; }
.gate-q { font-size: 30px; font-weight: 800; text-align: center; margin: 10px 0 14px; letter-spacing: 1px; }
.gate-card input {
  width: 100%; border: 1px solid var(--line); border-radius: 12px;
  padding: 12px; font-size: 20px; text-align: center; font-family: inherit;
  margin-bottom: 10px;
}
.gate-card input:focus { outline: 2px solid #cfe4d8; }
.gate-actions { display: flex; gap: 10px; }
.gate-actions button { flex: 1; border: 0; border-radius: 12px; padding: 12px; font-size: 15px; font-family: inherit; font-weight: 700; }
#gateOk { background: var(--green); color: #fff; }
#gateCancel { background: #f1ece2; color: var(--muted); }
.gate-err { color: var(--red); font-size: 13px; min-height: 18px; margin-bottom: 6px; }

@media (min-width: 700px) {
  body.kid-mode #app { max-width: 900px; }
  .kid-task { font-size: 42px; }
  .kid-icon { font-size: 110px; }
  .kid-sub { font-size: 22px; }
  .kid-btn { font-size: 26px; padding: 26px; }
  .kid-word { font-size: 40px; padding: 18px 30px; }
  .kid-star { font-size: 130px; }
  .kid-dot { width: 14px; height: 14px; }
}

