:root {
  --primary: #4f7cff;
  --primary-dark: #3a63e0;
  --bg: #f4f6fb;
  --card: #ffffff;
  --text: #22283a;
  --muted: #7a8299;
  --border: #e6e9f2;
  --good: #2ecc71;
  --bad: #ff6b6b;
  --radius: 14px;
  --shadow: 0 4px 16px rgba(60, 80, 160, .08);
}
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
  font-family: "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  background: var(--bg); color: var(--text);
}
.hidden { display: none !important; }
button { font-family: inherit; cursor: pointer; }

/* ---------- 顶部导航 ---------- */
#topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 24px;
  background: var(--card); padding: 10px 28px;
  box-shadow: var(--shadow);
}
.brand { font-size: 20px; font-weight: 700; color: var(--primary); }
.brand span { font-size: 13px; color: var(--muted); font-weight: 400; }
#topbar nav { display: flex; gap: 6px; flex: 1; }
.nav-btn {
  border: none; background: none; padding: 8px 14px;
  border-radius: 10px; font-size: 15px; color: var(--text);
}
.nav-btn:hover { background: var(--bg); }
.nav-btn.active { background: var(--primary); color: #fff; }
.user-chip { display: flex; align-items: center; gap: 12px; font-size: 14px; }
.user-chip span { background: var(--bg); padding: 4px 10px; border-radius: 20px; }
.link-btn { border: none; background: none; color: var(--primary); font-size: 14px; }
.link-btn:hover { text-decoration: underline; }

main { max-width: 1080px; margin: 24px auto; padding: 0 20px 60px; }
h2 { font-size: 22px; margin-bottom: 16px; }
h3 { font-size: 17px; margin: 26px 0 12px; color: var(--text); }

/* ---------- 登录页 ---------- */
.auth-wrap { display: flex; gap: 40px; align-items: center; justify-content: center; min-height: calc(100vh - 120px); flex-wrap: wrap; }
.auth-hero { max-width: 420px; }
.auth-hero h1 { font-size: 34px; color: var(--primary); }
.auth-hero p { font-size: 18px; margin: 10px 0; color: var(--text); }
.auth-flags { font-size: 34px; letter-spacing: 10px; margin: 12px 0; }
.auth-hero ul { list-style: none; }
.auth-hero li { padding: 7px 0; color: var(--muted); font-size: 15px; }
.auth-card {
  background: var(--card); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 30px; width: 340px;
}
.auth-tabs { display: flex; margin-bottom: 20px; border-bottom: 1px solid var(--border); }
.auth-tab {
  flex: 1; border: none; background: none; padding: 10px;
  font-size: 16px; color: var(--muted); border-bottom: 2px solid transparent;
}
.auth-tab.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }
.auth-form input {
  width: 100%; padding: 12px 14px; margin-bottom: 14px;
  border: 1px solid var(--border); border-radius: 10px; font-size: 15px;
}
.auth-form input:focus { outline: 2px solid var(--primary); border-color: transparent; }
.auth-error { color: var(--bad); font-size: 13px; min-height: 20px; margin-bottom: 8px; }
.btn-primary {
  width: 100%; padding: 12px; border: none; border-radius: 10px;
  background: var(--primary); color: #fff; font-size: 16px; font-weight: 600;
}
.btn-primary:hover { background: var(--primary-dark); }

/* ---------- Dashboard ---------- */
.stat-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin: 18px 0; }
.stat-card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; text-align: center; }
.stat-num { font-size: 26px; font-weight: 700; color: var(--primary); }
.stat-label { font-size: 13px; color: var(--muted); margin-top: 4px; }

.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }
.lesson-card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 16px; cursor: pointer; transition: transform .15s;
  border-left: 5px solid var(--primary);
}
.lesson-card:hover { transform: translateY(-3px); }
.lesson-card .lc-title { font-weight: 600; margin-bottom: 6px; }
.lesson-card .lc-desc { font-size: 13px; color: var(--muted); min-height: 34px; }
.lc-meta { display: flex; justify-content: space-between; margin-top: 10px; font-size: 12px; color: var(--muted); }
.lc-done { color: var(--good); font-weight: 600; }

.xp-chart { display: flex; align-items: flex-end; gap: 12px; height: 140px; background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; }
.xp-bar { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; }
.xp-bar .bar { width: 100%; max-width: 46px; background: linear-gradient(180deg, var(--primary), #8aa6ff); border-radius: 6px 6px 0 0; min-height: 4px; }
.xp-bar .lbl { font-size: 11px; color: var(--muted); }
.xp-bar .val { font-size: 11px; color: var(--primary); font-weight: 600; }

/* ---------- 课程中心 ---------- */
.lang-tabs { display: flex; gap: 10px; margin-bottom: 20px; }
.lang-tab {
  padding: 10px 20px; border-radius: 24px; border: 1px solid var(--border);
  background: var(--card); font-size: 15px;
}
.lang-tab.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.level-block { margin-bottom: 26px; }
.level-head { display: flex; align-items: baseline; gap: 12px; margin-bottom: 10px; }
.level-head h4 { font-size: 17px; }
.level-head span { font-size: 13px; color: var(--muted); }
.level-progress { height: 6px; background: var(--border); border-radius: 3px; overflow: hidden; margin-bottom: 12px; }
.level-progress i { display: block; height: 100%; background: var(--good); }

/* ---------- 学习模块 ---------- */
.module-tabs { display: flex; gap: 10px; margin: 16px 0; flex-wrap: wrap; }
.module-tab {
  padding: 9px 18px; border-radius: 22px; border: 1px solid var(--border);
  background: var(--card); font-size: 14px;
}
.module-tab.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.module-tab .score { font-size: 12px; opacity: .85; margin-left: 4px; }
.module-body { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 28px; min-height: 340px; }
.lesson-title { font-size: 22px; font-weight: 700; margin-top: 8px; }
.lesson-sub { color: var(--muted); font-size: 14px; margin-top: 4px; }

/* 单词卡片 */
.flashcard {
  width: 320px; height: 200px; margin: 20px auto; perspective: 800px; cursor: pointer;
}
.flashcard-inner {
  position: relative; width: 100%; height: 100%;
  transition: transform .5s; transform-style: preserve-3d;
}
.flashcard.flipped .flashcard-inner { transform: rotateY(180deg); }
.flash-face {
  position: absolute; inset: 0; backface-visibility: hidden;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  border-radius: 16px; box-shadow: var(--shadow);
  background: linear-gradient(135deg, #6a8dff, #4f7cff); color: #fff;
}
.flash-face.back { transform: rotateY(180deg); background: linear-gradient(135deg, #8e6de0, #6a4fd0); }
.flash-face .fw { font-size: 34px; font-weight: 700; }
.flash-face .fm { font-size: 20px; margin-top: 8px; }
.flash-face .fe { font-size: 13px; opacity: .85; margin-top: 10px; padding: 0 20px; text-align: center; }
.flash-hint { text-align: center; color: var(--muted); font-size: 13px; }
.mod-footer { display: flex; justify-content: center; gap: 14px; margin-top: 20px; }
.mod-footer button { padding: 10px 26px; border: none; border-radius: 10px; font-size: 15px; }
.btn-know { background: var(--good); color: #fff; }
.btn-dont { background: var(--bad); color: #fff; }
.btn-next { background: var(--primary); color: #fff; }
.progress-line { text-align: center; color: var(--muted); font-size: 13px; margin-top: 8px; }

/* 测验题 */
.quiz-q { font-size: 18px; font-weight: 600; margin: 10px 0 18px; }
.quiz-opts { display: grid; gap: 10px; max-width: 460px; }
.quiz-opt {
  padding: 12px 16px; border: 1px solid var(--border); border-radius: 10px;
  background: var(--bg); text-align: left; font-size: 15px;
}
.quiz-opt:hover { border-color: var(--primary); }
.quiz-opt.correct { background: #e6f9ee; border-color: var(--good); color: #1c8a4c; }
.quiz-opt.wrong { background: #fdecec; border-color: var(--bad); color: #c0392b; }
.quiz-explain { margin-top: 14px; padding: 12px; background: #fff8e6; border-radius: 10px; font-size: 14px; color: #8a6d1a; }

/* 口语 / 听力 */
.speak-sentence { font-size: 22px; font-weight: 600; text-align: center; margin: 22px 0; }
.center { text-align: center; }
.big-btn {
  width: 74px; height: 74px; border-radius: 50%; border: none;
  font-size: 28px; color: #fff; background: var(--primary);
  box-shadow: 0 6px 18px rgba(79, 124, 255, .4);
}
.big-btn:hover { background: var(--primary-dark); }
.big-btn.listening { background: #8e6de0; }
.rec-result { margin-top: 16px; font-size: 15px; text-align: center; }
.rec-good { color: var(--good); }
.rec-bad { color: var(--bad); }

/* 模块完成页 */
.mod-complete { text-align: center; padding: 40px 0; }
.mod-complete .big { font-size: 52px; }
.mod-complete h4 { font-size: 20px; margin: 12px 0; }
.mod-complete p { color: var(--muted); }

/* ---------- 社区 ---------- */
.post-editor { display: flex; gap: 12px; margin-bottom: 20px; align-items: flex-end; }
.post-editor textarea {
  flex: 1; padding: 12px; border: 1px solid var(--border);
  border-radius: 10px; font-family: inherit; font-size: 15px; resize: vertical;
}
.post-editor .btn-primary { width: auto; padding: 12px 26px; }
.post-card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 18px; margin-bottom: 14px; }
.post-head { display: flex; gap: 10px; align-items: center; margin-bottom: 8px; }
.avatar { width: 38px; height: 38px; border-radius: 50%; background: var(--primary); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; }
.post-user { font-weight: 600; }
.post-time { font-size: 12px; color: var(--muted); }
.post-content { font-size: 15px; line-height: 1.6; white-space: pre-wrap; }
.post-actions { margin-top: 10px; }
.post-actions button { border: none; background: none; color: var(--muted); font-size: 14px; padding: 4px 8px; border-radius: 8px; }
.post-actions button:hover, .post-actions button.liked { color: var(--bad); background: #fdecec; }

/* ---------- 成就 ---------- */
.badge-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px; }
.badge-card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 22px; text-align: center;
}
.badge-card.locked { opacity: .45; filter: grayscale(1); }
.badge-icon { font-size: 40px; }
.badge-name { font-weight: 700; margin: 8px 0 4px; }
.badge-desc { font-size: 13px; color: var(--muted); }

/* ---------- 个人中心 ---------- */
.profile-card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px; display: flex; gap: 18px; align-items: center; }
.profile-card .avatar { width: 64px; height: 64px; font-size: 24px; }
.prog-row { margin-bottom: 14px; }
.prog-row .pr-head { display: flex; justify-content: space-between; font-size: 14px; margin-bottom: 5px; }
.prog-bar { height: 10px; background: var(--border); border-radius: 5px; overflow: hidden; }
.prog-bar i { display: block; height: 100%; border-radius: 5px; }
.module-bars { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px; }

/* ---------- Toast ---------- */
#toast-wrap { position: fixed; bottom: 26px; right: 26px; z-index: 99; display: flex; flex-direction: column; gap: 10px; }
.toast {
  background: #22283a; color: #fff; padding: 14px 20px; border-radius: 12px;
  font-size: 14px; box-shadow: var(--shadow); animation: slideIn .3s ease;
}
@keyframes slideIn { from { transform: translateX(60px); opacity: 0; } to { transform: none; opacity: 1; } }

@media (max-width: 720px) {
  .stat-row { grid-template-columns: repeat(2, 1fr); }
  #topbar { flex-wrap: wrap; gap: 10px; padding: 10px 14px; }
}
