:root {
  --bg: #f4f7fb;
  --card-bg: #ffffff;
  --primary: #4f7cff;
  --primary-dark: #3a63d8;
  --accent: #ff8a5c;
  --good: #2bb673;
  --warn: #ff6b6b;
  --text: #1f2a44;
  --text-soft: #6b7891;
  --line: #e6ebf2;
  --shadow: 0 10px 30px rgba(31, 42, 68, 0.10);
  --radius: 18px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", system-ui, sans-serif;
  background: linear-gradient(160deg, #eef3ff 0%, #f4f7fb 40%, #fef6f1 100%);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  padding: 24px 16px 48px;
  line-height: 1.6;
}

.app {
  width: 100%;
  max-width: 640px;
}

/* ---------- 顶部进度条 ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}
.brand { font-size: 20px; font-weight: 800; letter-spacing: .5px; }
.brand .dot { color: var(--accent); }
.topbar .stat { font-size: 13px; color: var(--text-soft); }

/* ---------- 通用卡片容器 ---------- */
.panel {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 26px;
  margin-bottom: 18px;
}

/* ---------- 首页 ---------- */
.hero { text-align: center; padding: 34px 26px; }
.hero h1 { font-size: 26px; margin-bottom: 8px; }
.hero p { color: var(--text-soft); font-size: 14px; margin-bottom: 22px; }

.goal-pick { margin: 18px 0 26px; }
.goal-pick .label { font-size: 14px; color: var(--text-soft); margin-bottom: 10px; }
.chips { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.chip {
  border: 1.5px solid var(--line);
  background: #fff;
  color: var(--text);
  border-radius: 999px;
  padding: 9px 18px;
  font-size: 15px;
  cursor: pointer;
  transition: all .15s ease;
  user-select: none;
}
.chip:hover { border-color: var(--primary); }
.chip.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  font-weight: 700;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  border-radius: 999px;
  padding: 13px 22px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: transform .1s ease, box-shadow .15s ease, background .15s ease;
  color: #fff;
}
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--primary); box-shadow: 0 8px 18px rgba(79,124,255,.35); }
.btn-primary:hover { background: var(--primary-dark); }
.btn-ghost { background: #eef2fb; color: var(--primary); }
.btn-ghost:hover { background: #e2e9fb; }
.btn-block { width: 100%; }
.btn-sm { padding: 9px 16px; font-size: 14px; }
.btn-good { background: var(--good); box-shadow: 0 8px 18px rgba(43,182,115,.30); }
.btn-warn { background: var(--warn); box-shadow: 0 8px 18px rgba(255,107,107,.30); }

.btn-row { display: flex; gap: 12px; }

/* ---------- 总体进度 ---------- */
.progress-wrap { margin: 4px 0 2px; }
.progress-meta { display: flex; justify-content: space-between; font-size: 13px; color: var(--text-soft); margin-bottom: 6px; }
.bar { height: 10px; background: var(--line); border-radius: 999px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: linear-gradient(90deg, var(--primary), #7fa0ff); border-radius: 999px; transition: width .4s ease; }

/* ---------- 学习卡片（翻转） ---------- */
.study-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; font-size: 13px; color: var(--text-soft); }
.cat-tag {
  display: inline-block;
  background: #eef2fb;
  color: var(--primary-dark);
  font-size: 12px;
  padding: 3px 10px;
  border-radius: 999px;
  font-weight: 600;
}

.flip { perspective: 1200px; margin-bottom: 16px; }
.flip-inner {
  position: relative;
  width: 100%;
  transition: transform .5s cubic-bezier(.4,.2,.2,1);
  transform-style: preserve-3d;
}
.flip.show-back .flip-inner { transform: rotateY(180deg); }
.face {
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border-radius: var(--radius);
  padding: 26px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
}
/* 背面在文档流中，决定卡片高度；正面绝对定位覆盖其上 */
.face.back {
  position: relative;
  min-height: 300px;
  background: #fff;
  color: var(--text);
  transform: rotateY(180deg);
  border: 1px solid var(--line);
  z-index: 1;
}
.face.front {
  position: absolute;
  inset: 0;
  z-index: 2;
  background: linear-gradient(155deg, #4f7cff, #6f93ff);
  color: #fff;
}

.face.front .kicker { font-size: 13px; opacity: .85; margin-bottom: auto; }
.face.front .title { font-size: 26px; font-weight: 800; margin: 14px 0 10px; }
.face.front .prompt { font-size: 15px; opacity: .95; }
.face.front .hint { margin-top: auto; font-size: 13px; opacity: .8; }

.face.back .b-title { font-size: 19px; font-weight: 800; margin-bottom: 12px; }
.face.back .b-title .cat-tag { margin-left: 8px; vertical-align: middle; }
.points { list-style: none; margin-bottom: 14px; }
.points li { position: relative; padding-left: 20px; margin-bottom: 8px; font-size: 15px; }
.points li::before { content: "•"; color: var(--primary); font-weight: 800; position: absolute; left: 4px; top: 0; }
.formula-box {
  background: #f3f6ff;
  border: 1px dashed #c5d2ff;
  border-radius: 12px;
  padding: 10px 14px;
  font-size: 15px;
  margin-bottom: 12px;
  color: var(--primary-dark);
  font-weight: 600;
  word-break: break-word;
}
.tip-box {
  background: #fff6ef;
  border-left: 4px solid var(--accent);
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 14px;
  color: #9a5a2c;
}

/* ---------- 例题区块 ---------- */
.example-box {
  margin-top: 12px;
  background: #f2fbf6;
  border: 1px solid #cdeeda;
  border-radius: 12px;
  padding: 12px 14px;
}
.example-box .ex-head {
  font-size: 13px;
  font-weight: 800;
  color: var(--good);
  margin-bottom: 6px;
}
.example-box .ex-q {
  font-size: 14.5px;
  color: var(--text);
  word-break: break-word;
}
.ex-detail { margin-top: 8px; }
.ex-detail summary {
  cursor: pointer;
  list-style: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  font-weight: 700;
  color: var(--good);
  background: #e2f6ec;
  padding: 5px 12px;
  border-radius: 999px;
  user-select: none;
  transition: background .15s ease;
}
.ex-detail summary::-webkit-details-marker { display: none; }
.ex-detail summary::before { content: "▸"; font-size: 11px; }
.ex-detail[open] summary::before { content: "▾"; }
.ex-detail summary:hover { background: #d3f0e0; }
.ex-detail .ex-sol {
  margin-top: 8px;
  font-size: 14px;
  color: #2f6b4c;
  background: #fff;
  border-radius: 8px;
  padding: 10px 12px;
  border: 1px dashed #cdeeda;
  word-break: break-word;
}

/* ---------- 复习测验 ---------- */
.quiz-q { font-size: 17px; font-weight: 700; margin-bottom: 6px; }
.quiz-clue {
  background: #f3f6ff;
  border-radius: 12px;
  padding: 14px 16px;
  font-size: 16px;
  color: var(--primary-dark);
  font-weight: 600;
  margin: 12px 0 18px;
  word-break: break-word;
}
.options { display: flex; flex-direction: column; gap: 10px; }
.option {
  text-align: left;
  border: 1.5px solid var(--line);
  background: #fff;
  border-radius: 12px;
  padding: 13px 16px;
  font-size: 15px;
  cursor: pointer;
  transition: all .12s ease;
  color: var(--text);
}
.option:hover:not(:disabled) { border-color: var(--primary); }
.option.correct { background: #e7f8ef; border-color: var(--good); color: #1c7a4d; font-weight: 700; }
.option.wrong { background: #ffeaea; border-color: var(--warn); color: #b53030; font-weight: 700; }
.option:disabled { cursor: default; }

.quiz-feedback { margin-top: 14px; font-size: 14px; min-height: 20px; }
.quiz-feedback.ok { color: var(--good); }
.quiz-feedback.no { color: var(--warn); }

/* ---------- 结算 / 统计 ---------- */
.result-emoji { font-size: 46px; text-align: center; margin-bottom: 6px; }
.result-title { text-align: center; font-size: 22px; font-weight: 800; margin-bottom: 4px; }
.result-sub { text-align: center; color: var(--text-soft); font-size: 14px; margin-bottom: 18px; }
.score-ring {
  width: 120px; height: 120px; border-radius: 50%;
  margin: 0 auto 18px;
  display: flex; align-items: center; justify-content: center;
  font-size: 30px; font-weight: 800; color: var(--primary);
  background: conic-gradient(var(--good) calc(var(--p)*1%), #eef2fb 0);
}
.score-ring span { background: #fff; width: 92px; height: 92px; border-radius: 50%; display: flex; align-items: center; justify-content: center; }

.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 18px; }
.stat-cell { background: #f6f9ff; border-radius: 12px; padding: 14px; text-align: center; }
.stat-cell .num { font-size: 24px; font-weight: 800; color: var(--primary); }
.stat-cell .lab { font-size: 12px; color: var(--text-soft); margin-top: 2px; }

/* ---------- 已学列表 ---------- */
.list { display: flex; flex-direction: column; gap: 8px; max-height: 320px; overflow: auto; margin-bottom: 8px; }
.list-item { display: flex; align-items: center; justify-content: space-between; padding: 10px 12px; border-radius: 10px; background: #f6f9ff; font-size: 14px; }
.list-item .st { font-size: 12px; padding: 2px 9px; border-radius: 999px; font-weight: 700; }
.st.mastered { background: #e7f8ef; color: #1c7a4d; }
.st.review { background: #fff0e6; color: #b5651d; }
.st.new { background: #eef2fb; color: #6b7891; }

.section-title { font-size: 15px; font-weight: 700; margin: 6px 0 12px; }
.hidden { display: none !important; }
.center { text-align: center; }
.muted { color: var(--text-soft); font-size: 13px; }
.mt { margin-top: 14px; }
.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%);
  background: var(--text); color: #fff; padding: 10px 18px; border-radius: 999px;
  font-size: 14px; opacity: 0; transition: opacity .25s ease; pointer-events: none; z-index: 50;
}
.toast.show { opacity: .95; }

/* ---------- 底部导航 ---------- */
.bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  background: rgba(255,255,255,.96);
  backdrop-filter: blur(8px);
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: space-around;
  align-items: center;
  padding: 6px 0 calc(6px + env(safe-area-inset-bottom, 0px));
  max-width: 640px;
  margin: 0 auto;
}
.bottom-nav .nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 6px 0;
  font-size: 12px;
  color: var(--text-soft);
  text-decoration: none;
  cursor: pointer;
  transition: color .15s ease;
  border: none;
  background: transparent;
}
.bottom-nav .nav-item .icon { font-size: 22px; line-height: 1; }
.bottom-nav .nav-item.active,
.bottom-nav .nav-item:hover { color: var(--primary); }

/* 给主体留底部导航高度 */
.app { padding-bottom: 70px; }

/* ---------- 更多页面卡片网格 ---------- */
.more-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
}
.more-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: #fff;
  border: 1.5px solid var(--line);
  border-radius: 16px;
  padding: 22px 12px;
  text-decoration: none;
  color: var(--text);
  transition: transform .12s ease, box-shadow .15s ease, border-color .15s ease;
}
.more-card:hover {
  transform: translateY(-2px);
  border-color: var(--primary);
  box-shadow: 0 10px 24px rgba(79,124,255,.12);
}
.more-card .icon {
  width: 50px;
  height: 50px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  background: #f3f6ff;
}
.more-card .title { font-size: 15px; font-weight: 700; }
.more-card .desc {
  font-size: 12px;
  color: var(--text-soft);
  text-align: center;
  line-height: 1.4;
}

/* 独立子页面公共布局 */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}
.page-header .back {
  font-size: 14px;
  color: var(--primary);
  text-decoration: none;
  background: #eef2fb;
  padding: 7px 14px;
  border-radius: 999px;
  font-weight: 600;
}
.page-header .back:hover { background: #e2e9fb; }
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-soft);
}
.empty-state .big { font-size: 48px; margin-bottom: 10px; }
.empty-state h2 { font-size: 18px; color: var(--text); margin-bottom: 6px; }

