/* 识字天天练 · 儿童友好配色（浅色主题） */
:root {
  --bg: #FFF6EC;
  --bg2: #FFFDF9;
  --orange: #FF8A3D;
  --orange-d: #F2711C;
  --teal: #3FB69A;
  --yellow: #FFC94A;
  --ink: #453B2E;
  --ink2: #8B7D6B;
  --line: #EFE2D1;
  --white: #FFFFFF;
  --radius: 18px;
  --shadow: 0 6px 20px rgba(120, 90, 50, .10);
  --good: #34A853;
  --bad: #E5484D;
}

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

html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", system-ui, sans-serif;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
}

body.locked { overflow: hidden; }

#app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  position: relative;
  background: var(--bg);
  padding-bottom: 72px;
}

.hidden { display: none !important; }

/* ---------- 通用 ---------- */
.btn {
  border: none; border-radius: 14px; padding: 13px 18px;
  font-size: 16px; font-weight: 600; cursor: pointer;
  background: var(--white); color: var(--ink);
  transition: transform .12s, opacity .12s;
  font-family: inherit;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--orange); color: #fff; box-shadow: 0 4px 14px rgba(255, 138, 61, .35); }
.btn.accent { background: var(--yellow); color: #6B4A05; }
.btn.ghost { background: #FFF1E2; color: var(--orange-d); }
.btn.plain { background: transparent; color: var(--ink2); }
.btn.block { display: block; width: 100%; }
.btn.big { padding: 16px 18px; font-size: 18px; border-radius: 16px; }
.btn.small { padding: 10px 14px; font-size: 14px; border-radius: 12px; }
.btn.grow { flex: 1; }

.field { display: block; margin: 12px 0; }
.field > span { display: block; font-size: 13px; color: var(--ink2); margin-bottom: 6px; font-weight: 600; }
.field input, .field select {
  width: 100%; padding: 13px 14px; border-radius: 14px;
  border: 1.5px solid var(--line); background: var(--white);
  font-size: 16px; color: var(--ink); font-family: inherit;
  outline: none;
}
.field input:focus, .field select:focus { border-color: var(--orange); }
.field-row { display: flex; gap: 8px; align-items: flex-end; }
.grow { flex: 1; }

/* ---------- 登录 ---------- */
.screen { min-height: 100vh; }
.screen.hidden { display: none; }
.auth {
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(160deg, #FFE9CF 0%, #FFF6EC 45%, #FFFDF9 100%);
  padding: 24px;
}
.auth-card {
  width: 100%; background: var(--white); border-radius: 24px;
  padding: 26px 22px; box-shadow: var(--shadow);
}
.auth-logo {
  font-size: 27px; font-weight: 800; text-align: center;
  color: var(--orange-d); letter-spacing: 1px;
}
.auth-sub { text-align: center; color: var(--ink2); font-size: 13px; margin: 6px 0 18px; }
.tabs { display: flex; background: #FFF1E2; border-radius: 12px; padding: 4px; gap: 2px; }
.tab { flex: 1; border: none; background: transparent; padding: 9px 4px; border-radius: 9px;
  font-size: 14px; font-weight: 600; color: var(--ink2); cursor: pointer; font-family: inherit; }
.tab.active { background: var(--white); color: var(--orange-d); box-shadow: 0 2px 6px rgba(0,0,0,.06); }
.msg { margin: 12px 0 0; padding: 10px 12px; border-radius: 10px; font-size: 13px;
  background: #EAF7F1; color: #1F7A5C; word-break: break-word; }
.msg.bad { background: #FDECEC; color: var(--bad); }
#auth-form { margin-top: 14px; }
.auth-links { text-align: center; margin-top: 14px; }
.auth-links a { color: var(--ink2); font-size: 13px; text-decoration: none; }
.auth-tip { text-align: center; color: #B3A693; font-size: 12px; margin-top: 14px; line-height: 1.6; }

/* ---------- 建档 ---------- */
.onboard { padding: 28px 20px; }
.onboard h2 { margin: 6px 0 16px; font-size: 22px; }
.panel { background: var(--white); border-radius: 20px; padding: 20px; box-shadow: var(--shadow); }

/* ---------- 顶栏 ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 18px 12px;
  background: var(--bg);
}
.hi { font-size: 20px; font-weight: 800; }
.sub { font-size: 12px; color: var(--ink2); margin-top: 3px; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 50%; border: none;
  background: var(--white); font-size: 18px; cursor: pointer; color: var(--ink);
  box-shadow: var(--shadow);
}
.icon-btn.light { background: rgba(255,255,255,.22); color: #fff; box-shadow: none; }

.content { padding: 4px 18px 18px; }

/* ---------- 任务卡 ---------- */
.task-card {
  background: var(--white); border-radius: 20px; padding: 18px;
  display: flex; align-items: center; gap: 16px; box-shadow: var(--shadow);
}
.ring {
  width: 74px; height: 74px; border-radius: 50%; flex: none;
  display: flex; align-items: center; justify-content: center;
  background: conic-gradient(#FF8A3D 0 0%, #F0E6D9 0% 100%);
}
.ring span {
  width: 58px; height: 58px; border-radius: 50%; background: var(--white);
  display: flex; align-items: center; justify-content: center;
  font-size: 15px; font-weight: 800; color: var(--orange-d);
}
.task-info { flex: 1; min-width: 0; }
.task-title { font-size: 13px; color: var(--ink2); }
.task-line { font-size: 17px; font-weight: 700; margin-top: 2px; }
.task-line b { color: var(--orange-d); font-size: 20px; }
.task-hint { font-size: 12px; color: #B3A693; margin-top: 4px; line-height: 1.5; }

.stat-row { display: flex; gap: 10px; margin: 16px 0 4px; }
.stat {
  flex: 1; background: var(--white); border-radius: 16px; padding: 14px 6px;
  text-align: center; box-shadow: var(--shadow);
}
.stat b { display: block; font-size: 22px; color: var(--orange-d); }
.stat span { font-size: 12px; color: var(--ink2); }

.sec-title { font-size: 15px; margin: 22px 0 10px; }

.chip-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border: none; background: var(--white); border-radius: 12px;
  padding: 10px 8px; min-width: 54px; cursor: pointer;
  box-shadow: var(--shadow); font-family: inherit;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
}
.chip em { font-style: normal; font-size: 11px; color: var(--ink2); }
.empty { color: #BFB2A0; font-size: 13px; padding: 18px 4px; text-align: center; line-height: 1.7; }

/* ---------- 复习 ---------- */
.seg { display: flex; background: #FFF1E2; border-radius: 12px; padding: 4px; margin-bottom: 14px; }
.seg-btn {
  flex: 1; border: none; background: transparent; padding: 10px; border-radius: 9px;
  font-size: 14px; font-weight: 600; color: var(--ink2); cursor: pointer; font-family: inherit;
}
.seg-btn.active { background: var(--white); color: var(--orange-d); }
.seg-btn em { font-style: normal; font-size: 12px; opacity: .7; }
.wrong-list { margin-top: 14px; display: flex; flex-direction: column; gap: 8px; }
.wrong-item {
  background: var(--white); border-radius: 14px; padding: 12px 14px;
  display: flex; align-items: center; gap: 12px; box-shadow: var(--shadow);
}
.wc { font-size: 24px; font-weight: 700; }
.wp { color: var(--teal); font-size: 14px; }
.wz { color: var(--ink2); font-size: 13px; flex: 1; }
.wn { color: var(--bad); font-size: 12px; }

/* ---------- 字库 ---------- */
select.book-select {
  width: 100%; padding: 13px 14px; border-radius: 14px; border: 1.5px solid var(--line);
  background: var(--white); font-size: 15px; color: var(--ink); font-family: inherit;
}
.progress-line { display: flex; align-items: center; gap: 10px; margin: 12px 0; }
.progress-line .bar { flex: 1; height: 8px; background: #F0E6D9; border-radius: 6px; overflow: hidden; }
.progress-line .bar i { display: block; height: 100%; background: var(--teal); width: 0; transition: width .3s; }
.progress-line span { font-size: 13px; color: var(--ink2); min-width: 34px; text-align: right; }
.char-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; }
.gchar {
  aspect-ratio: 1; border: none; background: var(--white); border-radius: 12px;
  font-size: 20px; font-family: "Kaiti SC", KaiTi, STKaiti, serif;
  color: var(--ink); cursor: pointer; box-shadow: 0 2px 6px rgba(120,90,50,.08);
}
.gchar.learned { background: #EAF7F1; color: var(--teal); }
.gchar.mastered { background: var(--teal); color: #fff; }

/* ---------- 底部导航 ---------- */
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; max-width: 480px; margin: 0 auto;
  display: flex; background: rgba(255, 255, 255, .96);
  border-top: 1px solid var(--line); backdrop-filter: blur(8px);
  padding: 6px 0 calc(6px + env(safe-area-inset-bottom));
  z-index: 40;
}
.nav {
  flex: 1; border: none; background: transparent; padding: 6px 0;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  color: var(--ink2); cursor: pointer; font-family: inherit;
}
.nav i { font-style: normal; font-size: 21px; line-height: 1; opacity: .5; }
.nav span { font-size: 11px; }
.nav.active { color: var(--orange-d); }
.nav.active i { opacity: 1; }

/* ---------- 学习浮层 ---------- */
.overlay {
  position: fixed; inset: 0; background: linear-gradient(170deg, #FF9A50 0%, #FF7A3C 55%, #F26B2A 100%);
  z-index: 60; display: flex; flex-direction: column; color: #fff;
  max-width: 480px; margin: 0 auto;
}
.overlay.hidden { display: none; }
.study-top {
  display: flex; align-items: center; gap: 12px; padding: 16px 16px 6px;
}
.study-progress { flex: 1; height: 7px; background: rgba(255,255,255,.3); border-radius: 5px; overflow: hidden; }
.study-progress i { display: block; height: 100%; width: 0; background: #fff; border-radius: 5px; transition: width .25s; }
.study-step { font-size: 13px; opacity: .9; min-width: 38px; text-align: right; }
.study-body { flex: 1; overflow-y: auto; padding: 8px 16px 0; }
.study-foot { padding: 12px 16px calc(16px + env(safe-area-inset-bottom)); display: flex; gap: 10px; }
.study-foot .btn.plain { color: #fff; }

.card {
  background: var(--white); border-radius: 22px; padding: 22px 18px; color: var(--ink);
  box-shadow: 0 10px 30px rgba(120, 50, 10, .18); margin-bottom: 8px;
}
.card-top { text-align: center; padding-bottom: 4px; }
.py {
  display: inline-block; background: #FFF1E2; color: var(--orange-d);
  padding: 5px 16px; border-radius: 20px; font-size: 17px; font-weight: 700; letter-spacing: .5px;
}
.big {
  font-size: 96px; line-height: 1.15; margin: 8px 0 2px; font-weight: 500;
  font-family: "Kaiti SC", KaiTi, STKaiti, "Songti SC", serif; color: var(--ink);
}
.speak-btn {
  border: none; background: var(--teal); color: #fff; border-radius: 20px;
  padding: 8px 18px; font-size: 14px; font-weight: 600; cursor: pointer; font-family: inherit;
}
.meta { display: flex; justify-content: center; gap: 18px; margin: 16px 0 12px; font-size: 13px; color: var(--ink2); }
.meta b { color: var(--ink); font-size: 15px; }
.meta .tag { background: #FFF1E2; color: var(--orange-d); padding: 3px 10px; border-radius: 10px; }
.words { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-bottom: 16px; }
.word {
  border: none; background: #EAF7F1; color: #1F7A5C; border-radius: 12px;
  padding: 9px 14px; font-size: 15px; cursor: pointer; font-family: inherit;
}
.writer-box { border-top: 1px dashed var(--line); padding-top: 14px; }
.hz-actions { display: flex; gap: 10px; }
.hz-actions .btn { flex: 1; }
.hz-grid {
  width: 260px; height: 260px; margin: 14px auto 6px; border-radius: 12px;
  border: 2px solid #F0CFC0;
  background-color: #FFFFFF;
  background-image:
    linear-gradient(to right, transparent 49.6%, #EFBFA8 49.6%, #EFBFA8 50.4%, transparent 50.4%),
    linear-gradient(to bottom, transparent 49.6%, #EFBFA8 49.6%, #EFBFA8 50.4%, transparent 50.4%),
    repeating-linear-gradient(45deg, transparent 0 7px, rgba(239, 191, 168, .55) 7px 8px),
    repeating-linear-gradient(-45deg, transparent 0 7px, rgba(239, 191, 168, .55) 7px 8px);
  background-repeat: no-repeat;
}
.hz-tip { text-align: center; font-size: 13px; color: var(--ink2); min-height: 18px; }

/* ---------- 测验 ---------- */
.quiz { text-align: center; }
.q-sub { font-size: 13px; color: var(--ink2); }
.q-prompt { margin: 10px 0 18px; }
.q-prompt.q-big { font-size: 62px; font-family: "Kaiti SC", KaiTi, STKaiti, serif; }
.q-prompt.q-py { font-size: 40px; color: var(--orange-d); font-weight: 700; }
.q-prompt.q-word { font-size: 38px; font-family: "Kaiti SC", KaiTi, STKaiti, serif; letter-spacing: 4px; }
.opts { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.opt {
  border: 2px solid var(--line); background: var(--white); border-radius: 16px;
  padding: 18px 6px; font-size: 26px; cursor: pointer; color: var(--ink);
  font-family: "Kaiti SC", KaiTi, STKaiti, serif;
}
.opt.right { border-color: var(--good); background: #EAF7EF; color: var(--good); }
.opt.wrong { border-color: var(--bad); background: #FDECEC; color: var(--bad); }
.q-result { margin-top: 14px; border-radius: 14px; padding: 12px 14px; text-align: left; }
.q-result.good { background: #EAF7EF; color: #1F7A5C; }
.q-result.bad { background: #FDECEC; color: var(--bad); }
.q-result b { display: block; margin-bottom: 3px; }
.q-result span { font-size: 13px; opacity: .9; }

.finish { text-align: center; padding: 60px 20px; color: #fff; }
.finish-emo { font-size: 68px; }
.finish h2 { margin: 10px 0 6px; }
.finish p { opacity: .9; }

/* ---------- 弹层 ---------- */
.sheet-panel, .sheet { }
#overlay-sheet {
  background: rgba(40, 28, 16, .5); justify-content: flex-end;
}
.sheet {
  background: var(--bg2); border-radius: 22px 22px 0 0; padding: 18px 18px calc(24px + env(safe-area-inset-bottom));
  width: 100%;
}
.sheet-head {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 17px; font-weight: 700; margin-bottom: 10px;
}
.sheet-body hr { border: none; border-top: 1px solid var(--line); margin: 16px 0; }
.sheet-body .btn { margin-bottom: 10px; }

/* ---------- 报表 ---------- */
.card-panel {
  background: var(--white); border-radius: 18px; padding: 16px;
  box-shadow: var(--shadow); margin-bottom: 14px;
}
.card-panel h3 { margin: 0 0 12px; font-size: 15px; }
.metric-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.metric { text-align: center; }
.metric b { display: block; font-size: 22px; color: var(--orange-d); }
.metric span { font-size: 12px; color: var(--ink2); }
.legend { display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--ink2); margin-bottom: 8px; }
.legend .cal { width: 13px; height: 13px; border-radius: 3px; }
.legend .dot { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.legend .dot.n { background: var(--orange); }
.legend .dot.r { background: var(--teal); }
.cal-grid { display: grid; grid-template-columns: repeat(15, 1fr); gap: 4px; }
.cal { height: 15px; border-radius: 3px; background: #F0E6D9; }
.cal.lv1 { background: #FFDAB8; }
.cal.lv2 { background: #FFB173; }
.cal.lv3 { background: var(--orange); }
.chart { width: 100%; height: 96px; }
.bchart { display: flex; align-items: flex-end; gap: 3px; height: 84px; }
.bcol { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; }
.bstk { display: flex; flex-direction: column; justify-content: flex-end; height: 62px; }
.bstk i { display: block; width: 12px; border-radius: 3px 3px 0 0; }
.bstk .bn { background: var(--orange); }
.bstk .br { background: var(--teal); }
.blab { font-size: 10px; color: #B3A693; margin-top: 3px; }
.weak-list { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.weak {
  border: none; background: #FDECEC; border-radius: 12px; padding: 8px 4px;
  display: flex; flex-direction: column; align-items: center; gap: 1px; cursor: pointer;
  font-family: inherit;
}
.weak .wc { font-size: 21px; color: var(--ink); font-family: "Kaiti SC", KaiTi, STKaiti, serif; }
.weak .wp { font-size: 11px; color: var(--teal); }
.weak .wn { font-size: 10px; color: var(--bad); }
.loading { text-align: center; color: var(--ink2); padding: 40px 0; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 96px; transform: translateX(-50%) translateY(14px);
  background: rgba(40, 28, 16, .92); color: #fff; padding: 10px 18px; border-radius: 20px;
  font-size: 14px; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s;
  z-index: 90; max-width: 86%; text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.bad { background: rgba(180, 40, 40, .94); }
