:root {
  --bg: #f6f7fb;
  --card: #ffffff;
  --ink: #1f2430;
  --ink-2: #5b6478;
  --ink-3: #8b94a8;
  --line: #e8ebf2;
  --brand: #5b6cff;
  --brand-soft: #eef0ff;
  --green: #22a06b;
  --green-soft: #e6f7ef;
  --amber: #f0a020;
  --amber-soft: #fff4e0;
  --red: #e5484d;
  --red-soft: #fdecec;
  --radius: 16px;
  --shadow: 0 2px 10px rgba(31, 36, 48, .06);
  --shadow-lg: 0 12px 40px rgba(31, 36, 48, .14);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }

/* 作者样式里写的 display 会盖掉浏览器默认的 [hidden]，这里统一兜住 */
[hidden] { display: none !important; }

.wrap { max-width: 1080px; margin: 0 auto; padding: 18px 16px 80px; }

/* ---------- 顶栏 ---------- */
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
  padding: 10px 18px;
  background: rgba(255,255,255,.9);
  backdrop-filter: saturate(180%) blur(8px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 17px; }
.brand-icon { font-size: 20px; }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 12px; border-radius: 999px;
  background: var(--brand-soft); color: var(--brand);
  font-size: 13px; font-weight: 600; white-space: nowrap;
}

/* ---------- Tabs ---------- */
.tabs {
  position: sticky; top: 52px; z-index: 25;
  display: flex; gap: 6px; overflow-x: auto;
  padding: 10px 18px;
  background: rgba(255,255,255,.9);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  flex: 0 0 auto;
  padding: 7px 16px; border: 0; border-radius: 999px;
  background: transparent; color: var(--ink-2);
  font-size: 14px; font-weight: 600; cursor: pointer;
  transition: .15s;
}
.tab:hover { background: #f0f2f8; }
.tab.active { background: var(--brand); color: #fff; }
.tab .badge {
  display: inline-block; min-width: 18px; margin-left: 6px;
  padding: 0 5px; border-radius: 999px;
  background: var(--red); color: #fff; font-size: 11px; line-height: 18px; text-align: center;
}
.tab.active .badge { background: rgba(255,255,255,.35); }

/* ---------- 卡片 ---------- */
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px;
  box-shadow: var(--shadow);
}
.grid { display: grid; gap: 14px; }
.grid-2 { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spread { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.mt { margin-top: 14px; }
.muted { color: var(--ink-3); }
.dim { color: var(--ink-2); }
.small { font-size: 13px; }
.tiny { font-size: 12px; }
.center { text-align: center; }
.sec-title { margin: 22px 0 10px; font-size: 15px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.sec-title:first-child { margin-top: 0; }
hr.sep { border: 0; border-top: 1px solid var(--line); margin: 16px 0; }

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 16px; border: 1px solid var(--line); border-radius: 10px;
  background: #fff; color: var(--ink);
  font-weight: 600; cursor: pointer; transition: .15s;
}
.btn:hover { background: #f5f6fa; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: #4a5bef; }
.btn-green { background: var(--green); border-color: var(--green); color: #fff; }
.btn-green:hover { background: #1c8d5e; }
.btn-red { background: var(--red); border-color: var(--red); color: #fff; }
.btn-red:hover { background: #cf3b40; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: #f0f2f8; }
.btn-sm { padding: 5px 11px; font-size: 13px; border-radius: 8px; }
.btn-lg { padding: 12px 22px; font-size: 16px; border-radius: 12px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.icon-btn {
  border: 0; background: transparent; cursor: pointer;
  color: var(--ink-3); font-size: 16px; padding: 4px 6px; border-radius: 8px;
}
.icon-btn:hover { background: #f0f2f8; color: var(--ink); }

/* ---------- 表单 ---------- */
.field { display: flex; flex-direction: column; gap: 5px; }
.field > label { font-size: 13px; font-weight: 600; color: var(--ink-2); }
input[type=text], input[type=password], input[type=number], select, textarea {
  width: 100%; padding: 9px 12px;
  border: 1px solid var(--line); border-radius: 10px;
  background: #fff; outline: none; transition: .15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
textarea { resize: vertical; min-height: 68px; }
.form-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.hint { font-size: 12px; color: var(--ink-3); }
.check { display: inline-flex; align-items: center; gap: 7px; font-size: 14px; cursor: pointer; user-select: none; }
.check input { width: 16px; height: 16px; accent-color: var(--brand); }

.switch { position: relative; display: inline-block; width: 42px; height: 24px; flex: 0 0 auto; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span {
  position: absolute; inset: 0; cursor: pointer; border-radius: 999px;
  background: #d7dbe6; transition: .2s;
}
.switch span::before {
  content: ''; position: absolute; width: 18px; height: 18px; left: 3px; top: 3px;
  border-radius: 50%; background: #fff; transition: .2s;
}
.switch input:checked + span { background: var(--green); }
.switch input:checked + span::before { transform: translateX(18px); }

/* ---------- 标签 ---------- */
.tag {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 9px; border-radius: 999px;
  font-size: 12px; font-weight: 600;
  background: #f0f2f8; color: var(--ink-2);
}
.tag-green { background: var(--green-soft); color: var(--green); }
.tag-amber { background: var(--amber-soft); color: #b97a10; }
.tag-red { background: var(--red-soft); color: var(--red); }
.tag-brand { background: var(--brand-soft); color: var(--brand); }

/* ---------- 孩子卡 ---------- */
.kid-card { border-left: 5px solid var(--brand); }
.kid-avatar {
  width: 46px; height: 46px; border-radius: 14px; flex: 0 0 auto;
  display: grid; place-items: center; font-size: 24px; background: #f3f5fa;
}
.points-big { font-size: 30px; font-weight: 800; line-height: 1.1; }
.points-big small { font-size: 13px; font-weight: 600; color: var(--ink-3); margin-left: 3px; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(88px, 1fr)); gap: 10px; margin-top: 12px; }
.stat {
  background: #f8f9fc; border-radius: 12px; padding: 9px 10px; text-align: center;
}
.stat b { display: block; font-size: 18px; line-height: 1.2; }
.stat span { font-size: 12px; color: var(--ink-3); }

.bar { height: 8px; border-radius: 999px; background: #eef0f6; overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, #6f7dff, #9b6bff); transition: width .4s; }

/* ---------- 打卡项 ---------- */
.task-card { display: flex; gap: 12px; align-items: flex-start; }
.task-icon {
  width: 44px; height: 44px; flex: 0 0 auto; border-radius: 13px;
  display: grid; place-items: center; font-size: 22px; background: #f3f5fa;
}
.task-body { flex: 1; min-width: 0; }
.task-title { font-weight: 700; }
.task-std { font-size: 13px; color: var(--ink-2); margin-top: 2px; }
.task-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 7px; }
.task-actions { display: flex; flex-direction: column; gap: 6px; align-items: flex-end; }
.done-card { background: var(--green-soft); border-color: #cdebdd; }

/* ---------- 列表行 ---------- */
.list-row {
  display: flex; gap: 12px; align-items: center;
  padding: 11px 0; border-bottom: 1px solid var(--line);
}
.list-row:last-child { border-bottom: 0; }
.empty { padding: 34px 10px; text-align: center; color: var(--ink-3); }
.empty .emo { font-size: 34px; display: block; margin-bottom: 6px; }

/* ---------- 弹窗 ---------- */
.modal-mask {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(24,28,38,.42);
  display: grid; place-items: center; padding: 16px;
  animation: fade .15s ease;
}
.modal {
  width: min(520px, 100%); max-height: 88vh; overflow: auto;
  background: #fff; border-radius: 18px; box-shadow: var(--shadow-lg);
  animation: pop .18s ease;
}
.modal-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 15px 18px; border-bottom: 1px solid var(--line);
  position: sticky; top: 0; background: #fff; border-radius: 18px 18px 0 0;
}
.modal-head h3 { margin: 0; font-size: 16px; }
.modal-body { padding: 16px 18px; }
.modal-foot {
  display: flex; justify-content: flex-end; gap: 10px;
  padding: 12px 18px 16px; position: sticky; bottom: 0; background: #fff;
}
@keyframes fade { from { opacity: 0 } }
@keyframes pop { from { opacity: 0; transform: translateY(10px) scale(.98) } }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 34px; transform: translate(-50%, 20px);
  z-index: 90; padding: 10px 20px; border-radius: 999px;
  background: rgba(31,36,48,.94); color: #fff; font-size: 14px; font-weight: 600;
  opacity: 0; pointer-events: none; transition: .22s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- 登录 / 引导 ---------- */
.auth-wrap { max-width: 460px; margin: 0 auto; padding: 40px 16px; }
.hero { text-align: center; margin-bottom: 22px; }
.hero .emo { font-size: 48px; }
.hero h1 { margin: 6px 0 4px; font-size: 24px; }
.kid-pick {
  display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
}
.kid-pick button {
  padding: 16px 8px; border: 1px solid var(--line); border-radius: 16px;
  background: #fff; cursor: pointer; transition: .15s;
}
.kid-pick button:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: var(--brand); }
.kid-pick .emo { font-size: 30px; display: block; }
.kid-pick .nm { font-weight: 700; margin-top: 4px; }

/* ---------- 每日一记 ---------- */
.refl-box {
  margin-top: 7px; padding: 9px 11px;
  border: 1px dashed #d9e0ea; border-radius: 12px;
  background: #fbfcff;
}
.refl-box > div + div { margin-top: 3px; }

/* ---------- 目标 ---------- */
.step-no {
  width: 26px; height: 26px; flex: 0 0 auto; border-radius: 8px;
  display: grid; place-items: center; font-size: 13px; font-weight: 700;
  background: #f0f2f8; color: var(--ink-2);
}
.step-no.step-done { background: var(--green-soft); color: var(--green); }

/* ---------- 成就板（奖牌） ---------- */
.medal-board { display: flex; flex-direction: column; gap: 12px; }
.mb-row { display: flex; gap: 12px; align-items: flex-start; }
.mb-who {
  flex: 0 0 auto; width: 96px; display: flex; flex-direction: column;
  align-items: center; gap: 3px; text-align: center; padding-top: 2px;
}
.mb-avatar { font-size: 24px; line-height: 1; }
.mb-who-name { font-size: 13px; font-weight: 700; }
.mb-count { font-size: 12px; color: var(--ink-3); }

.mb-strip {
  flex: 1; min-width: 0; display: flex; gap: 8px;
  overflow-x: auto; padding-bottom: 6px; scrollbar-width: thin;
}
.mb-strip::-webkit-scrollbar { height: 6px; }
.mb-strip::-webkit-scrollbar-thumb { background: #dfe3ee; border-radius: 999px; }

.medal {
  flex: 0 0 auto; width: 82px; padding: 8px 6px;
  border: 1px solid var(--line); border-radius: 12px; background: #fff;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  cursor: pointer; font: inherit; color: var(--ink); transition: .15s;
}
.medal:hover { border-color: var(--brand); transform: translateY(-1px); }
.mb-icon { font-size: 22px; line-height: 1.1; }
.mb-name { font-size: 12px; font-weight: 700; text-align: center; line-height: 1.2; }
.mb-sub { font-size: 11px; color: var(--ink-3); }
.medal.got {
  background: linear-gradient(160deg, #fff8e6, #ffefd0);
  border-color: #f5d9a0;
  box-shadow: 0 2px 8px rgba(240, 160, 32, .18);
}
.medal.got .mb-sub { color: #b97a10; }
.medal.lock { background: #f7f8fc; border-style: dashed; color: var(--ink-3); }
.medal.lock .mb-icon { filter: grayscale(1); opacity: .55; }
.medal.lock .mb-name { color: var(--ink-3); font-weight: 600; }
.medal.flash { animation: medalFlash 1s ease-in-out 2; }
@keyframes medalFlash {
  0%, 100% { box-shadow: 0 0 0 0 rgba(240, 160, 32, 0); }
  50% { box-shadow: 0 0 0 6px rgba(240, 160, 32, .35); }
}

/* 成长记录里「该模块已点亮的奖牌」小图标 */
.medal-mini { font-size: 14px; margin-left: 4px; letter-spacing: 1px; }

/* 排行榜名次 */
.rank-no {
  flex: 0 0 auto; width: 30px; height: 30px; border-radius: 999px;
  background: #f0f2f8; color: var(--ink-2);
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 700;
}
/* 0 分不排名：名次位显示「—」，做成虚线圈、淡化，跟真名次区分开 */
.rank-no.rank-none {
  background: transparent; border: 1px dashed var(--line);
  color: var(--ink-3); font-weight: 400;
}

/* ---------- 问卷 ---------- */
.q-pick {
  text-align: left; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: 12px;
  background: #fff; color: var(--ink); cursor: pointer;
  font-size: 13px; line-height: 1.5; transition: .15s;
}
.q-pick:hover { border-color: var(--brand); background: #fafbff; }
.q-pick.picked { border-color: var(--brand); background: var(--brand-soft); box-shadow: 0 0 0 2px var(--brand-soft); }

/* ---------- 图表 ---------- */
.chart { width: 100%; height: auto; display: block; }

.log-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.log-table th, .log-table td { padding: 8px 6px; border-bottom: 1px solid var(--line); text-align: left; }
.log-table th { color: var(--ink-3); font-weight: 600; }
.log-table td.num { text-align: right; font-variant-numeric: tabular-nums; }
.pos { color: var(--green); font-weight: 700; }
.neg { color: var(--red); font-weight: 700; }

@media (max-width: 640px) {
  .wrap { padding: 14px 12px 70px; }
  .points-big { font-size: 26px; }
  .topbar { padding: 9px 12px; }
  .tabs { top: 50px; padding: 8px 12px; }
}

/* ---------- 每日一记：引导提问框 / 回答段落 / AI 栏 ---------- */
.jprompt-box {
  max-height: 200px; overflow-y: auto;
  padding: 10px 12px;
  border: 1px solid var(--line); border-radius: 12px;
  background: #fbfcff;
}
.jprompt-box .check { display: flex; align-items: flex-start; margin: 3px 0; }
.jprompt-box .check input { flex: 0 0 auto; margin-top: 3px; }
.jgroup + .jgroup { margin-top: 10px; }
.jp-item { margin-top: 7px; }
.jp-ans { margin-left: 10px; color: var(--ink-2); }

/* 引导句按钮：点一条就把原文追加到正文里 */
.jp-pick {
  display: flex; align-items: flex-start; gap: 8px;
  width: 100%; text-align: left; white-space: normal; line-height: 1.45;
  padding: 7px 9px; border: 1px solid transparent; border-radius: 10px;
  background: transparent; color: var(--ink); font-size: 14px; cursor: pointer;
}
.jp-pick:hover { background: #eef1fb; }
.jp-pick .jp-mark {
  flex: 0 0 auto; width: 18px; text-align: center;
  color: var(--brand); font-weight: 700;
}
/* 已经追加进正文的引导句：变灰 + 打勾，孩子知道哪几条加过了 */
.jp-pick.jp-used { color: var(--ink-3); }
.jp-pick.jp-used .jp-mark { color: var(--green); }

/* 追问 AI：输入框右上角一个发送小按钮，不占一整行 */
.ask-wrap { position: relative; }
.ask-wrap textarea { width: 100%; padding-right: 44px; }
.ask-wrap .ask-send {
  position: absolute; top: 8px; right: 8px;
  width: 30px; height: 30px; font-size: 14px; line-height: 1;
  display: flex; align-items: center; justify-content: center;
}
.ask-wrap .ask-send:disabled { opacity: .5; cursor: not-allowed; }

.ai-box {
  margin-top: 8px; padding: 10px 12px;
  border: 1px dashed #cfd6e6; border-radius: 12px;
  background: #fbfcff;
}
