/* ===== 北京小升初速练 ===== */
:root {
  --bg: #f2f5f9;
  --card: #ffffff;
  --line: #e6eaf1;
  --text: #17233d;
  --sub: #7c8798;
  --primary: #2f6bff;
  --primary-deep: #1b46d3;
  --green: #00b894;
  --green-bg: #e5faf4;
  --red: #ff5252;
  --red-bg: #ffecec;
  --orange: #ff9e3d;
  --gold: #f6c445;
  --ch-math: #2f6bff;
  --ch-chinese: #ff5252;
  --ch-english: #00b894;
  --radius: 16px;
  --shadow: 0 6px 20px rgba(23, 35, 61, .06);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}

* { 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, "PingFang SC", "HarmonyOS Sans SC", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

body { min-height: 100vh; }

#app {
  max-width: 540px;
  margin: 0 auto;
  min-height: 100vh;
  padding: calc(12px + var(--safe-t)) 14px calc(92px + var(--safe-b));
}

.page {
  animation: fadeIn .18s ease both;
}
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---------- 通用组件 ---------- */
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 14px;
}

.page-title {
  font-size: 22px;
  font-weight: 800;
  margin: 6px 0 2px;
}
.page-sub { color: var(--sub); font-size: 13px; margin-bottom: 14px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: none;
  border-radius: 14px;
  padding: 12px 18px;
  font-size: 15px;
  font-weight: 600;
  color: #fff;
  background: var(--primary);
  cursor: pointer;
  transition: transform .08s ease, opacity .15s;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .45; }
.btn.block { width: 100%; }
.btn.ghost { background: transparent; color: var(--primary); border: 1.5px solid var(--primary); }
.btn.soft { background: #e8efff; color: var(--primary); }
.btn.danger { background: var(--red); }
.btn.green { background: var(--green); }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 11px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  background: #eef2f8;
  color: var(--sub);
}
.chip.active { background: var(--primary); color: #fff; }

/* ---------- 顶栏 · 底部导航 ---------- */
.topbar {
  position: sticky;
  top: calc(var(--safe-t));
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 10px;
  margin: -12px -14px 14px;
  padding: 14px 16px;
  background: rgba(242, 245, 249, .85);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
}
.topbar .back {
  width: 34px; height: 34px;
  border-radius: 10px;
  background: #fff;
  display: flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow);
  font-size: 17px;
  color: var(--text);
  border: 1px solid var(--line);
}
.topbar h2 { font-size: 17px; font-weight: 700; margin: 0; flex: 1; }

.tabbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  margin: 0 auto;
  max-width: 540px;
  z-index: 30;
  display: flex;
  background: rgba(255, 255, 255, .92);
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
  border-top: 1px solid var(--line);
  padding-bottom: var(--safe-b);
}
.tabbar button {
  flex: 1;
  border: none;
  background: transparent;
  padding: 8px 0 7px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  font-size: 11px;
  color: var(--sub);
}
.tabbar button .ico { font-size: 21px; line-height: 1; }
.tabbar button.active { color: var(--primary); font-weight: 700; }

/* ---------- 首页 ---------- */
.hero {
  background: linear-gradient(135deg, #2f6bff 0%, #6a4bff 55%, #b548ff 100%);
  border-radius: 20px;
  padding: 20px 18px;
  color: #fff;
  margin-bottom: 16px;
  position: relative;
  overflow: hidden;
}
.hero::after {
  content: "⚡";
  position: absolute;
  right: -6px; bottom: -14px;
  font-size: 90px;
  opacity: .14;
  transform: rotate(-12deg);
}
.hero h1 { margin: 0 0 4px; font-size: 21px; font-weight: 800; }
.hero p { margin: 0; font-size: 13px; opacity: .9; }
.hero .stats { display: flex; gap: 22px; margin-top: 16px; }
.hero .stats b { font-size: 19px; display: block; }
.hero .stats span { font-size: 12px; opacity: .85; }

.subject-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 16px; }
.subject-card {
  border-radius: 16px;
  padding: 14px 10px 12px;
  text-align: center;
  color: #fff;
  box-shadow: var(--shadow);
  border: none;
  cursor: pointer;
}
.subject-card .big { font-size: 30px; }
.subject-card b { display: block; margin-top: 6px; font-size: 15px; }
.subject-card span { font-size: 11px; opacity: .92; }
.sc-math { background: linear-gradient(135deg, #2f6bff, #4f8dff); }
.sc-chinese { background: linear-gradient(135deg, #ff5252, #ff7a6b); }
.sc-english { background: linear-gradient(135deg, #00b894, #0ad0a0); }

.section-title {
  font-size: 15px;
  font-weight: 800;
  margin: 4px 2px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.section-title .more { font-size: 12px; color: var(--primary); font-weight: 600; }

/* ---------- 科目/分类 ---------- */
.unit-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 13px 4px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
}
.unit-row:last-child { border-bottom: none; }
.unit-row .t { font-size: 15px; font-weight: 600; }
.unit-row .d { font-size: 12px; color: var(--sub); margin-top: 2px; }
.unit-row .n { font-size: 12px; font-weight: 700; color: var(--primary); }
.unit-row .chev { color: #c3ccda; }

.mode-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.s-row { background: #f3f6fb; border-radius: 12px; padding: 10px; }
.s-row label { display: block; font-size: 12px; color: var(--sub); margin-bottom: 7px; font-weight: 600; }
.s-row .chip { margin: 0 4px 4px 0; }
.mode-btn {
  border: none;
  border-radius: 14px;
  padding: 14px;
  text-align: left;
  background: var(--card);
  box-shadow: var(--shadow);
  cursor: pointer;
}
.mode-btn .emoji { font-size: 22px; }
.mode-btn b { display: block; margin-top: 4px; font-size: 14px; }
.mode-btn span { font-size: 11.5px; color: var(--sub); }

/* ---------- 答题页 ---------- */
.quiz-header {
  position: sticky;
  top: calc(var(--safe-t));
  z-index: 20;
  background: rgba(242,245,249,.92);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  padding: 8px 0 10px;
  margin: -8px -14px 10px;
}
.quiz-progress {
  height: 6px;
  background: #e3e9f2;
  border-radius: 4px;
  overflow: hidden;
}
.quiz-progress i { display: block; height: 100%; background: var(--primary); border-radius: 4px; transition: width .2s; }
.quiz-meta { display: flex; align-items: center; justify-content: space-between; margin-top: 9px; font-size: 12px; color: var(--sub); font-weight: 600; }
.timer {
  font-variant-numeric: tabular-nums;
  background: #fff;
  border-radius: 999px;
  padding: 4px 12px;
  box-shadow: var(--shadow);
  color: var(--primary);
  font-size: 13px;
}
.timer.warn { color: var(--red); background: var(--red-bg); }

.q-text { font-size: 17px; line-height: 1.75; font-weight: 600; margin: 18px 2px; }
.q-text .blank { border-bottom: 2px solid var(--primary); padding: 0 22px; color: transparent; position: relative; }
.q-text .blank::after { content: "?"; position: absolute; left: 50%; transform: translateX(-50%); color: var(--primary); }

.opts { display: flex; flex-direction: column; gap: 10px; }
.opt {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  width: 100%;
  text-align: left;
  border: 1.5px solid var(--line);
  background: #fff;
  border-radius: 14px;
  padding: 13px 14px;
  font-size: 15px;
  line-height: 1.5;
  cursor: pointer;
  transition: border-color .12s, background .12s;
}
.opt .k {
  flex: none;
  width: 26px; height: 26px;
  border-radius: 50%;
  border: 1.5px solid #cfd8e6;
  color: var(--sub);
  font-weight: 700;
  font-size: 13px;
  display: flex; align-items: center; justify-content: center;
}
.opt .v { flex: 1; white-space: pre-wrap; }
.opt.right { border-color: var(--green); background: var(--green-bg); }
.opt.right .k { background: var(--green); border-color: var(--green); color: #fff; }
.opt.wrong { border-color: var(--red); background: var(--red-bg); }
.opt.wrong .k { background: var(--red); border-color: var(--red); color: #fff; }

.fill-box { margin: 4px 2px 6px; }
.fill-box input {
  width: 100%;
  font-size: 19px;
  padding: 13px 14px;
  border: 1.5px solid var(--line);
  border-radius: 14px;
  background: #fff;
  outline: none;
  text-align: center;
  font-weight: 700;
  letter-spacing: 1px;
}
.fill-box input:focus { border-color: var(--primary); }

.feedback {
  margin-top: 14px;
  border-radius: 14px;
  padding: 12px 14px;
  font-size: 13.5px;
  line-height: 1.7;
}
.feedback.ok { background: var(--green-bg); color: #007a5f; }
.feedback.bad { background: var(--red-bg); color: #b23a3a; }
.feedback b { display: block; font-size: 15px; margin-bottom: 3px; }
.feedback .ans { font-weight: 700; }

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

/* ---------- 结果页 ---------- */
.result-ring {
  width: 132px; height: 132px;
  border-radius: 50%;
  margin: 8px auto 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border: 8px solid var(--primary);
  color: var(--primary);
}
.result-ring b { font-size: 34px; }
.result-ring span { font-size: 12px; }
.rate-green { border-color: var(--green); color: var(--green); }
.rate-red { border-color: var(--red); color: var(--red); }

.sum-row { display: flex; justify-content: space-between; padding: 9px 0; border-bottom: 1px dashed var(--line); font-size: 14px; }
.sum-row:last-child { border-bottom: none; }
.sum-row span { color: var(--sub); }
.sum-row b { font-variant-numeric: tabular-nums; }

/* ---------- 错题本 ---------- */
.wrong-item {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 11px 2px;
  border-bottom: 1px solid var(--line);
}
.wrong-item .tag {
  flex: none;
  font-size: 11px;
  font-weight: 700;
  padding: 4px 8px;
  border-radius: 8px;
  color: #fff;
}
.wrong-item .q { flex: 1; font-size: 14px; line-height: 1.5; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.wrong-item .tm { flex: none; font-size: 11px; color: var(--sub); }
.wrong-item .del {
  flex: none;
  border: none;
  background: transparent;
  color: #c3ccda;
  font-size: 15px;
  padding: 4px;
}

/* ---------- 统计 ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.stat-box {
  background: var(--card);
  border-radius: 14px;
  padding: 13px;
  box-shadow: var(--shadow);
  text-align: center;
}
.stat-box b { font-size: 21px; display: block; }
.stat-box span { font-size: 12px; color: var(--sub); }

.bar-row { display: flex; align-items: center; gap: 8px; margin: 9px 0; font-size: 13px; }
.bar-row .lb { width: 34px; font-weight: 700; }
.bar-track { flex: 1; height: 14px; background: #eef2f8; border-radius: 8px; overflow: hidden; }
.bar-track i { display: block; height: 100%; border-radius: 8px; }

.day-bars { display: flex; gap: 6px; align-items: flex-end; height: 80px; margin-top: 8px; }
.day-bars .col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.day-bars .col .bar { width: 100%; max-width: 26px; background: var(--primary); border-radius: 5px 5px 2px 2px; min-height: 2px; }
.day-bars .col.today .bar { background: var(--orange); }
.day-bars .col span { font-size: 10px; color: var(--sub); }

/* ---------- 排行榜 ---------- */
.rank-item { display: flex; align-items: center; gap: 10px; padding: 10px 2px; border-bottom: 1px solid var(--line); }
.rank-item .no { flex: none; width: 24px; font-weight: 800; text-align: center; color: var(--sub); }
.rank-item .no.top3 { color: #fff; border-radius: 8px; }
.rank-item .no.gold { background: #efb10a; }
.rank-item .no.silver { background: #9aa6b2; }
.rank-item .no.bronze { background: #c9733c; }
.rank-item .nm { flex: 1; font-size: 14px; font-weight: 600; }
.rank-item .sc { font-size: 13px; font-weight: 700; color: var(--primary); font-variant-numeric: tabular-nums; }
.rank-item.me { background: #eaf0ff; border-radius: 12px; padding-left: 12px; }
.rank-item.me .nm::after { content: " 我"; color: var(--primary); font-size: 11px; }

/* ---------- 教材同步 ---------- */
.textbook-unit {
  border-left: 4px solid var(--primary);
  border-radius: 12px;
  padding: 12px 12px;
  margin-bottom: 10px;
  background: var(--card);
  box-shadow: var(--shadow);
}
.textbook-unit b { font-size: 15px; display: block; }
.textbook-unit span { font-size: 12px; color: var(--sub); }

/* ---------- 设置 ---------- */
.set-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 13px 2px;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
}
.set-row:last-child { border-bottom: none; }
.set-row input {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 7px 10px;
  font-size: 14px;
  width: 140px;
  text-align: right;
  outline: none;
}
.set-row input:focus { border-color: var(--primary); }

.install-tip {
  margin-top: 14px;
  background: #fff8e6;
  border-radius: 14px;
  padding: 12px 14px;
  font-size: 13px;
  line-height: 1.7;
  color: #8a6d1a;
}
.install-tip b { color: #5c4a0e; }

/* ---------- 空状态 ---------- */
.empty { text-align: center; padding: 36px 16px; color: var(--sub); }
.empty .big { font-size: 44px; margin-bottom: 8px; }
.empty p { font-size: 14px; margin: 4px 0 14px; }

/* ---------- 通用小工具 ---------- */
.hidden { display: none !important; }
.toast {
  position: fixed;
  left: 50%; bottom: calc(110px + var(--safe-b));
  transform: translateX(-50%) translateY(10px);
  background: rgba(23, 35, 61, .9);
  color: #fff;
  padding: 9px 16px;
  border-radius: 999px;
  font-size: 13px;
  z-index: 60;
  opacity: 0;
  transition: opacity .2s, transform .2s;
  pointer-events: none;
  white-space: nowrap;
}
.toast.show { opacity: 1; transform: translateX(-50%); }

.subj-tag { font-weight: 800; font-size: 15px; }

.score-pop {
  text-align: center;
  font-size: 15px;
  font-weight: 800;
  color: var(--gold);
  letter-spacing: 1px;
}
/* ---------- ����Ӣ�� KET/PET ---------- */
.camb-entry {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  border: none;
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 14px;
  background: linear-gradient(135deg, #00b894, #00a8ff);
  color: #fff;
  box-shadow: var(--shadow);
  cursor: pointer;
  text-align: left;
}
.camb-entry:active { transform: scale(.98); }
.camb-entry .big { font-size: 26px; }
.camb-entry b { font-size: 16px; display: block; }
.camb-entry span { font-size: 12px; opacity: .92; }
.camb-entry .chev { font-size: 22px; opacity: .9; }

.passage {
  background: #f6f8fb;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px 16px;
  max-height: 44vh;
  overflow-y: auto;
  margin-bottom: 10px;
  font-size: 16px;
  line-height: 1.85;
  -webkit-overflow-scrolling: touch;
}
.passage.closed { max-height: 60px; overflow: hidden; cursor: pointer; }
.passage-t {
  display: flex;
  align-items: center;
  font-size: 13px;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 8px;
  padding-bottom: 6px;
  border-bottom: 1px dashed #dbe0e8;
}
.passage-t .tg {
  margin-left: auto;
  font-size: 12px;
  font-weight: 600;
  color: var(--sub);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px 10px;
  cursor: pointer;
}
.passage p { margin: 0; color: var(--text); word-break: break-word; }

.lv-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 7px;
  padding: 2px 0;
}
.lv-grid .chip {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  white-space: nowrap;
  margin: 0;
  padding: 8px 0;
  border-radius: 12px;
  font-size: 12px;
  line-height: 1.25;
  width: 100%;
}
.lv-grid .chip b { font-size: 13px; }
.lv-grid .chip i { font-style: normal; font-size: 10px; opacity: .75; }

.dict-actions {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-top: 14px;
}
.dict-actions .btn { font-size: 13px; padding: 9px 4px; }
.dict-word { font-size: 22px; margin-top: 6px; }
.dict-sub { font-size: 13px; color: var(--sub); margin-top: 6px; }

/* ---------- 账号登录页 ---------- */
.auth-wrap {
  padding-top: calc(40px + var(--safe-t));
}
.auth-card {
  max-width: 380px;
  margin: 0 auto;
}
.auth-logo {
  font-size: 52px;
  text-align: center;
}
.auth-title {
  margin: 8px 0 4px;
  text-align: center;
  font-size: 24px;
  font-weight: 800;
}
.auth-list {
  padding: 6px 14px;
}
.auth-tip {
  margin: 14px 4px 0;
  text-align: center;
  font-size: 12px;
  color: var(--sub);
  line-height: 1.6;
}
