:root {
  --brand: #2f6bff;
  --brand-dark: #1f4fd0;
  --bg: #f5f7fb;
  --card: #ffffff;
  --text: #1c2430;
  --muted: #8a94a6;
  --line: #e8edf6;
  --ok: #17a673;
  --warn: #e8890c;
  --radius: 16px;
}

* { 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", sans-serif;
  -webkit-font-smoothing: antialiased;
}

.app {
  max-width: 480px; margin: 0 auto; min-height: 100vh;
  padding: calc(12px + env(safe-area-inset-top)) 16px calc(84px + env(safe-area-inset-bottom));
}

.loading { text-align: center; color: var(--muted); padding: 48px 0; }

h1 { font-size: 20px; margin: 8px 0 4px; }
.brand { font-size: 26px; font-weight: 800; letter-spacing: 2px; margin: 16px 0 2px; }
.slogan { color: var(--muted); font-size: 13px; margin: 0 0 12px; }
h2 { font-size: 16px; margin: 0 0 8px; }
p { line-height: 1.6; }
.muted { color: var(--muted); font-size: 13px; }

.topbar { display: flex; align-items: baseline; justify-content: space-between; padding: 8px 2px; }
.child-name { font-size: 20px; font-weight: 700; }
.today { color: var(--muted); font-size: 13px; }

.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px; margin-bottom: 12px;
}
.card .row { display: flex; justify-content: space-between; align-items: center; }

.btn {
  display: block; width: 100%; padding: 14px; font-size: 16px;
  border: none; border-radius: 12px; background: var(--card);
  border: 1px solid var(--line); color: var(--text); margin-bottom: 10px;
  text-align: center; font-weight: 600;
}
.btn:active { transform: scale(0.99); }
.btn-primary { background: var(--brand); color: #fff; border-color: var(--brand); padding: 20px; font-size: 19px; }
.btn-ghost { background: transparent; border-style: dashed; color: var(--brand-dark); }
.btn-sm { padding: 10px; font-size: 14px; margin-bottom: 0; }
.btn:disabled { opacity: .5; }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid2 .btn { margin-bottom: 0; }

/* ---- 首页分组（孩子端）----
   设计意图：入口按「什么时候用」分成四组，孩子一眼能看出今天先做什么；
   每组标题小而淡，组内按钮同尺寸，避免所有按钮一样大导致看不出重点。
   新增功能时往对应组里加即可，首页结构不用再改。 */
.group { margin-bottom: 18px; }
.group-head {
  display: flex; align-items: baseline; gap: 8px;
  margin: 0 4px 8px;
}
.group-title { font-size: 14px; font-weight: 700; color: var(--text); }
.group-hint { font-size: 12px; color: var(--muted); }
/* 组内的两列格子与单列按钮共用间距 */
.group .btn { margin-bottom: 0; }
.group .stack { display: flex; flex-direction: column; gap: 10px; }
.group .grid2 { gap: 10px; }
/* 设置类用更轻的样式：不抢视线，但点得到 */
.group.settings .btn {
  font-size: 15px; font-weight: 500; padding: 12px;
  background: transparent; border-style: dashed; text-align: left;
  padding-left: 14px;
}
/* 分组标题左侧的竖条，用于快速区分区块（纯装饰，不影响信息） */
.group-title::before {
  content: ""; display: inline-block; width: 3px; height: 12px;
  background: var(--brand); border-radius: 2px; margin-right: 6px;
  vertical-align: -1px;
}

input[type=text], input[type=number], input[type=password], textarea, select {
  width: 100%; padding: 12px; font-size: 16px; border: 1px solid var(--line);
  border-radius: 12px; background: #fff; color: var(--text); font-family: inherit;
}
textarea { resize: vertical; min-height: 88px; }
label { display: block; font-size: 13px; color: var(--muted); margin: 12px 0 6px; }

.chat { display: flex; flex-direction: column; gap: 10px; margin-bottom: 12px; }
.msg { max-width: 86%; padding: 10px 14px; border-radius: 14px; white-space: pre-wrap; line-height: 1.5; }
.msg.tutor { align-self: flex-start; background: #fff; border: 1px solid var(--line); }
.msg.child { align-self: flex-end; background: var(--brand); color: #fff; }
.msg.sys { align-self: center; background: #fff7e8; border: 1px solid #f3d9a8; font-size: 13px; color: #8a5a00; }
.speak-btn { margin-left: 8px; cursor: pointer; opacity: .7; }
.qimg { width: 100%; border-radius: 12px; margin-bottom: 12px; border: 1px solid var(--line); }

.list-item { padding: 12px 0; border-bottom: 1px solid var(--line); }
.list-item:last-child { border-bottom: none; }
.tag { display: inline-block; font-size: 12px; padding: 2px 8px; border-radius: 999px; background: #eef3ff; color: var(--brand-dark); margin-right: 6px; }
.tag.ok { background: #e7f7f0; color: var(--ok); }
.tag.warn { background: #fff2e0; color: var(--warn); }

.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  max-width: 480px; margin: 0 auto;
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: #fff; border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.nav button {
  border: none; background: none; padding: 10px 4px 12px; font-size: 12px;
  color: var(--muted); font-family: inherit;
}
.nav button.active { color: var(--brand); font-weight: 700; }
.nav .ico { display: block; font-size: 20px; line-height: 1.4; }

/* 拍题来源选择：底部弹出的选择条。
   存在的意义：拍照和相册本是同一个动作的两种来源，
   把它们做成两个并列的大按钮会显得重复又占地方。 */
.sheet {
  position: fixed; left: 0; right: 0; top: 0; bottom: 0;
  background: rgba(28, 36, 48, .45); z-index: 60;
  display: flex; align-items: flex-end; justify-content: center;
}
.sheet[hidden] { display: none; }
.sheet-card {
  width: 100%; max-width: 480px;
  background: #fff; border-radius: 20px 20px 0 0;
  padding: 18px 16px calc(18px + env(safe-area-inset-bottom));
}
.sheet-card h2 { margin: 0 0 2px; }
.sheet-card .btn { margin-bottom: 8px; }
.sheet-card .btn:last-child { margin-bottom: 0; }
.toast {
  position: fixed; left: 50%; bottom: 96px; transform: translateX(-50%);
  background: rgba(28,36,48,.92); color: #fff; padding: 10px 16px;
  border-radius: 12px; font-size: 14px; z-index: 50; max-width: 88%;
}
.big { font-size: 26px; font-weight: 800; }
.kv { display: flex; justify-content: space-between; padding: 6px 0; }
.photo-input { display: none; }
.center { text-align: center; }
.spinner { text-align: center; color: var(--muted); padding: 24px; }

/* 等待 AI 思考时的「小老师在想」气泡。
   动效刻意做得慢而柔：孩子等待时看到的是「它在认真想」，
   而不是「程序卡住了」。颜色与老师气泡一致，位置也一致，
   这样回复出现时视觉上是同一个气泡「长出了文字」，不会跳动。 */
.msg.thinking {
  align-self: flex-start;
  background: #fff;
  border: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
}
.msg.thinking .dots { display: inline-flex; gap: 4px; }
.msg.thinking .dots i {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--brand); opacity: .35;
  animation: ft-bounce 1.25s ease-in-out infinite;
}
.msg.thinking .dots i:nth-child(2) { animation-delay: .18s; }
.msg.thinking .dots i:nth-child(3) { animation-delay: .36s; }
@keyframes ft-bounce {
  0%, 70%, 100% { transform: translateY(0); opacity: .35; }
  35% { transform: translateY(-4px); opacity: 1; }
}
/* 无障碍：用户若在系统里关闭了动效，退化为静态提示，不闪烁。 */
@media (prefers-reduced-motion: reduce) {
  .msg.thinking .dots i { animation: none; opacity: .6; }
}
/* 依据链（家长端「看依据」）：纯展示，样式与现有卡片体系一致 */
.ev-wrap { margin-top: 4px; border-top: 1px dashed var(--line); }
.ev-item {
  background: #f7f9fc; border: 1px solid var(--line);
  border-radius: 12px; padding: 12px; margin-top: 10px;
}
.ev-title { font-weight: 600; font-size: 14px; margin-bottom: 4px; }
.ev-facts { margin-top: 8px; }
.ev-fact {
  display: flex; justify-content: space-between; align-items: baseline;
  padding: 6px 0; border-bottom: 1px solid var(--line); font-size: 14px;
}
.ev-fact:last-child { border-bottom: none; }
.ev-label { color: var(--muted); font-size: 13px; }
.ev-value { font-weight: 700; color: var(--brand-dark); }
/* 报告数据陈旧提示：告知「有新数据」，但不催、不自动花钱 */
.stale-tip {
  background: #fff7e8; border: 1px solid #f3d9a8; color: #8a5a00;
  border-radius: 12px; padding: 10px 12px; font-size: 13px; margin-bottom: 8px;
}
#encSuggest { display: flex; flex-direction: column; gap: 8px; }
#encSuggest .btn { margin-bottom: 0; }
