:root {
  --bg: #f7f9fc;
  --card: #ffffff;
  --ink: #243044;
  --muted: #8a93a6;
  --primary: #e8543f;
  --primary-d: #cf3f2c;
  --accent: #f4a261;
  --ok: #2e9e6b;
  --line: #eef1f6;
  --shadow: 0 6px 22px rgba(36, 48, 68, .08);
  --radius: 16px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.55;
  padding-bottom: env(safe-area-inset-bottom);
}
.muted { color: var(--muted); }
.center { text-align: center; }
.hidden { display: none !important; }

/* 顶栏 */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px;
  background: rgba(255,255,255,.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; cursor: pointer; }
.logo {
  width: 40px; height: 40px; border-radius: 12px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: #fff; font-weight: 800; font-size: 22px;
  display: grid; place-items: center; box-shadow: var(--shadow);
}
.brand-name { font-weight: 800; font-size: 17px; }
.brand-tag { font-size: 12px; color: var(--muted); }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.lang-select {
  border: 1px solid var(--line); border-radius: 10px; padding: 7px 8px;
  background: #fff; color: var(--ink); font-size: 13px;
}
.user-chip {
  background: #fff3f0; color: var(--primary-d); font-weight: 700;
  border-radius: 999px; padding: 6px 12px; font-size: 13px;
}

/* 视图容器 */
.view { max-width: 720px; margin: 0 auto; padding: 20px 16px 96px; }

/* 卡片 */
.card {
  background: var(--card); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 22px; margin-bottom: 16px;
}

/* 按钮 */
.btn {
  border: none; border-radius: 12px; padding: 13px 18px;
  font-size: 15px; font-weight: 700; cursor: pointer; width: 100%;
  transition: transform .05s ease, background .2s;
}
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-d); }
.btn.primary.big { font-size: 18px; padding: 16px; margin-top: 8px; }
.btn.ghost { background: #fff; color: var(--primary-d); border: 1px solid var(--line); width: auto; padding: 11px 18px; }
.btn.ghost:hover { background: #fff3f0; }

/* 认证 */
.auth-card { max-width: 380px; margin: 24px auto 0; }
.tabs { display: flex; gap: 8px; margin-bottom: 16px; }
.tab {
  flex: 1; padding: 10px; border: none; background: var(--line);
  border-radius: 10px; font-weight: 700; color: var(--muted); cursor: pointer;
}
.tab.active { background: var(--primary); color: #fff; }
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.field input {
  width: 100%; border: 1px solid var(--line); border-radius: 10px;
  padding: 12px; font-size: 15px; background: #fbfcfe; color: var(--ink);
}
.field input:focus { outline: 2px solid #ffd9d1; border-color: var(--primary); }
.hint { color: var(--primary-d); font-size: 13px; min-height: 18px; margin: 8px 0 0; }
.switch-line { text-align: center; font-size: 13px; color: var(--muted); }
.switch-line a { color: var(--primary); text-decoration: none; font-weight: 700; }

/* 主页 */
.home-hero { text-align: center; padding-top: 12px; }
.stat-row { display: flex; gap: 12px; justify-content: center; margin-bottom: 18px; }
.stat {
  flex: 1; max-width: 150px; background: var(--card); border-radius: 14px;
  box-shadow: var(--shadow); padding: 16px 8px;
}
.stat-num { font-size: 26px; font-weight: 800; color: var(--primary); }
.stat-label { font-size: 12px; color: var(--muted); }
.progress-wrap { margin: 6px 0 22px; }
.progress-bar { height: 12px; background: var(--line); border-radius: 999px; overflow: hidden; }
.progress-fill { height: 100%; width: 0%; background: linear-gradient(90deg, var(--primary), var(--accent)); transition: width .4s; }

/* 学习单课 */
.lesson-card { text-align: center; }
.lesson-stage { font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.lesson-emoji { font-size: 84px; line-height: 1.1; margin: 8px 0; }
.lesson-item { font-size: 56px; font-weight: 800; letter-spacing: 2px; }
.lesson-pinyin { font-size: 24px; color: var(--primary-d); font-weight: 700; margin: 6px 0 14px; }
.speak-btn {
  display: inline-flex; align-items: center; gap: 6px; cursor: pointer;
  background: #fff3f0; color: var(--primary-d); border: 1px solid #ffd9d1;
  border-radius: 999px; padding: 9px 16px; font-weight: 700; font-size: 14px;
}
.speak-btn:active { transform: scale(.97); }
.lesson-meaning { font-size: 18px; font-weight: 600; margin: 14px 0 6px; }
.lesson-examples { text-align: left; background: #fbfcfe; border: 1px solid var(--line); border-radius: 12px; padding: 12px 16px; margin: 14px 0; }
.lesson-examples div { padding: 5px 0; border-bottom: 1px dashed var(--line); font-size: 15px; }
.lesson-examples div:last-child { border-bottom: none; }
.encourage {
  text-align: center; background: #fff; border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 18px; margin-top: 10px;
  font-size: 17px; font-weight: 700; color: var(--ok);
}
.encourage .pts { display: block; color: var(--primary); font-size: 14px; margin-top: 6px; font-weight: 600; }

/* 阶段 */
.section-title { margin: 4px 0 14px; font-size: 20px; }
.stages-list { display: grid; gap: 12px; }
.stage-item { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; }
.stage-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.stage-name { font-weight: 800; font-size: 16px; }
.stage-hsk { font-size: 12px; color: #fff; background: var(--accent); border-radius: 999px; padding: 3px 10px; white-space: nowrap; }
.stage-desc { font-size: 13px; color: var(--muted); margin: 6px 0 10px; }
.stage-meta { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--muted); margin-bottom: 10px; }
.stage-actions { display: flex; gap: 8px; }
.stage-actions .btn { width: auto; flex: 1; padding: 10px; font-size: 14px; }
.badge-ok { color: var(--ok); font-weight: 700; }
.badge-best { color: var(--primary); font-weight: 700; }

/* 测试 */
.q-item { margin-bottom: 18px; padding-bottom: 14px; border-bottom: 1px solid var(--line); }
.q-text { font-weight: 700; margin-bottom: 10px; }
.opt { display: block; padding: 11px 14px; border: 1px solid var(--line); border-radius: 10px; margin-bottom: 8px; cursor: pointer; }
.opt input { margin-right: 10px; }
.opt.sel { border-color: var(--primary); background: #fff3f0; }
.test-result { text-align: center; }
.test-score { font-size: 48px; font-weight: 800; color: var(--primary); }
.test-verdict { font-size: 18px; font-weight: 700; margin: 6px 0; }

/* 列表 */
.list .row { display: flex; justify-content: space-between; padding: 10px 0; border-bottom: 1px dashed var(--line); font-size: 14px; }
.list .row:last-child { border-bottom: none; }

/* 底部导航 */
.bottomnav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 20;
  display: flex; background: #fff; border-top: 1px solid var(--line);
  padding: 6px 0 calc(6px + env(safe-area-inset-bottom));
}
.navbtn { flex: 1; border: none; background: none; cursor: pointer; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 0; }
.navbtn span { font-size: 20px; }
.navbtn small { font-size: 11px; }
.navbtn.active { color: var(--primary); }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: 84px; transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 999px;
  font-size: 14px; opacity: 0; pointer-events: none; transition: opacity .25s; z-index: 50; max-width: 90%;
}
.toast.show { opacity: 1; }

@media (min-width: 600px) {
  .lesson-emoji { font-size: 110px; }
  .lesson-item { font-size: 72px; }
}
