:root {
  --bg: #f5f7ff;
  --card: #ffffff;
  --primary: #4f6ef7;
  --primary-2: #7b5cf0;
  --text: #1f2a44;
  --muted: #6b7690;
  --line: #e7ebf5;
  --success: #1fa36b;
  --warn: #f2a93b;
  --danger: #e5484d;
  --radius: 20px;
  --shadow: 0 10px 30px rgba(79, 110, 247, .10);
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  max-width: 100%;
  overflow-x: hidden;
}
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--text);
  background: linear-gradient(180deg, #eef3ff 0%, #f8faff 42%, #f5f7ff 100%);
  font-size: 16px;
  line-height: 1.55;
  -webkit-tap-highlight-color: transparent;
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }
img, svg { max-width: 100%; }

.app { min-height: 100vh; display: flex; flex-direction: column; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 12px clamp(16px, 3vw, 40px);
  background: rgba(255,255,255,.94);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; flex: 0 0 auto; }
.brand-mark {
  width: 42px; height: 42px; border-radius: 13px;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  color: #fff; display: grid; place-items: center;
  font-weight: 900; font-size: 20px; box-shadow: 0 6px 16px rgba(79,110,247,.28);
}
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text strong { font-size: 17px; }
.brand-text small { color: var(--muted); font-size: 12px; }

.nav { display: flex; gap: 6px; overflow-x: auto; flex: 1 1 auto; scrollbar-width: none; }
.nav::-webkit-scrollbar { display: none; }
.nav a {
  white-space: nowrap; min-height: 44px; display: inline-flex; align-items: center;
  padding: 0 16px; border-radius: 999px; color: var(--muted); font-weight: 700;
  transition: .18s ease;
}
.nav a:hover { background: #f0f3ff; color: var(--primary); }
.nav a.active { background: linear-gradient(135deg, var(--primary), var(--primary-2)); color: #fff; box-shadow: 0 6px 16px rgba(79,110,247,.25); }

.user-chip {
  flex: 0 0 auto; display: flex; align-items: center; gap: 8px;
  padding: 6px 12px; border-radius: 999px; background: #f2f5ff; font-size: 14px; font-weight: 700;
}
.user-chip .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--success); }

.main { width: min(1440px, 100%); margin: 0 auto; padding: clamp(16px, 2.5vw, 32px); flex: 1 1 auto; }
.footer { text-align: center; color: var(--muted); font-size: 13px; padding: 18px 16px 26px; }

.grid { display: grid; gap: 18px; }
.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 1080px) { .cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 900px) {
  .topbar { flex-wrap: wrap; gap: 10px; }
  .nav { order: 3; width: 100%; }
  .cols-3, .cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
  .cols-2, .cols-3, .cols-4 { grid-template-columns: minmax(0, 1fr); }
  .main { padding: 14px; }
}

.card {
  background: var(--card);
  border: 1px solid rgba(231,235,245,.9);
  border-radius: var(--radius);
  padding: clamp(18px, 2vw, 26px);
  box-shadow: var(--shadow);
}
.card.tight { padding: 16px; }
.card.gradient {
  background: linear-gradient(135deg, #5b75f8 0%, #855ff0 100%);
  color: #fff; border: 0;
}
.card.gradient .muted { color: rgba(255,255,255,.78); }

.section-title { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 0 0 16px; }
.section-title h2 { margin: 0; font-size: clamp(19px, 2vw, 24px); }
.section-title .hint { color: var(--muted); font-size: 14px; }

.muted { color: var(--muted); }
.small { font-size: 13px; }
.big-number { font-size: clamp(30px, 4vw, 48px); font-weight: 900; line-height: 1.1; }
.stat-label { color: var(--muted); font-size: 14px; font-weight: 700; margin-top: 6px; }

.hero {
  display: grid; grid-template-columns: 1.4fr 1fr; gap: 20px; align-items: center;
}
@media (max-width: 900px) { .hero { grid-template-columns: 1fr; } }
.hero h1 { margin: 0 0 8px; font-size: clamp(26px, 3.4vw, 42px); }
.hero p { margin: 0 0 20px; color: rgba(255,255,255,.82); font-size: 16px; }

.btn {
  min-height: 48px; padding: 0 20px; border: 0; border-radius: 14px;
  font-weight: 800; font-size: 16px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  transition: transform .12s ease, box-shadow .18s ease, background .18s ease;
  background: #eef1fb; color: var(--text);
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn.primary { background: linear-gradient(135deg, var(--primary), var(--primary-2)); color: #fff; box-shadow: 0 8px 20px rgba(79,110,247,.26); }
.btn.ghost { background: transparent; border: 2px solid var(--line); color: var(--text); }
.btn.light { background: rgba(255,255,255,.18); color: #fff; border: 1px solid rgba(255,255,255,.35); }
.btn.success { background: var(--success); color: #fff; }
.btn.warn { background: var(--warn); color: #fff; }
.btn.danger { background: var(--danger); color: #fff; }
.btn.sm { min-height: 40px; padding: 0 14px; font-size: 14px; border-radius: 11px; }
.btn.block { width: 100%; }
.btn[disabled] { opacity: .55; cursor: not-allowed; transform: none; }
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; }

.entry-grid { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 14px; }
@media (max-width: 900px) { .entry-grid { grid-template-columns: repeat(2, minmax(0,1fr)); } }
@media (max-width: 520px) { .entry-grid { grid-template-columns: minmax(0,1fr); } }
.entry {
  min-height: 92px; border-radius: 16px; background: #f7f9ff; border: 1px solid var(--line);
  display: flex; align-items: center; gap: 14px; padding: 14px 16px; cursor: pointer;
  transition: .18s ease; font-weight: 800;
}
.entry:hover { border-color: var(--primary); transform: translateY(-2px); box-shadow: 0 8px 20px rgba(79,110,247,.12); }
.entry .ico { width: 46px; height: 46px; border-radius: 14px; background: linear-gradient(135deg, #e8edff, #f0eaff); display: grid; place-items: center; font-size: 24px; }
.entry span { display: block; }
.entry small { display: block; color: var(--muted); font-weight: 600; font-size: 12px; }

.progress { height: 12px; background: #e9edf7; border-radius: 999px; overflow: hidden; }
.progress > i { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--primary), var(--primary-2)); transition: width .4s ease; }
.progress.light { background: rgba(255,255,255,.2); }
.progress.light > i { background: #fff; }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field label { font-weight: 700; font-size: 14px; }
input, select, textarea {
  width: 100%; min-height: 46px; padding: 10px 14px; border: 1px solid var(--line);
  border-radius: 12px; background: #fff; color: var(--text); outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(79,110,247,.12); }
textarea { min-height: 88px; resize: vertical; }
.inline { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.inline > input, .inline > select { width: auto; flex: 1 1 180px; }

.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 16px; }
.toolbar .grow { flex: 1 1 220px; }

.list { display: flex; flex-direction: column; gap: 10px; }
.list-item {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 16px; border-radius: 14px; border: 1px solid var(--line); background: #fff;
}
.list-item .title { font-weight: 800; font-size: 18px; }
.list-item .sub { color: var(--muted); font-size: 13px; }
.list-item .actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; }

.table-wrap { overflow-x: auto; width: 100%; }
table { width: 100%; border-collapse: collapse; min-width: 620px; }
th, td { text-align: left; padding: 12px 10px; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-size: 13px; }

.badge { display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 800; background: #eef1fb; color: var(--primary); }
.badge.green { background: #e6f7ef; color: var(--success); }
.badge.orange { background: #fff3df; color: #b57300; }
.badge.red { background: #ffe9ea; color: var(--danger); }

/* 学习卡片 */
.learn-shell { max-width: 980px; margin: 0 auto; }
.learn-card { padding: clamp(22px, 3vw, 42px); text-align: center; }
.learn-meta { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; color: var(--muted); font-weight: 700; }
.word-display { font-size: clamp(40px, 6vw, 76px); font-weight: 900; letter-spacing: .5px; line-height: 1.15; word-break: break-word; }
.phonetic { font-size: clamp(16px, 2vw, 22px); color: var(--muted); margin-top: 6px; }
.meaning { font-size: clamp(24px, 3vw, 38px); font-weight: 800; margin-top: 18px; }
.extra { text-align: left; margin-top: 20px; padding: 16px; border-radius: 14px; background: #f7f9ff; }
.extra p { margin: 6px 0; }
.speak-btn {
  width: 72px; height: 72px; border-radius: 50%; border: 0; cursor: pointer;
  background: linear-gradient(135deg, var(--primary), var(--primary-2)); color: #fff; font-size: 30px;
  box-shadow: 0 10px 24px rgba(79,110,247,.32); margin: 18px auto 6px; display: grid; place-items: center;
}
.speak-btn:active { transform: scale(.96); }
.answer-input { font-size: clamp(22px, 3vw, 34px); text-align: center; min-height: 64px; font-weight: 800; }
.choices { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 12px; margin-top: 18px; }
@media (max-width: 640px) { .choices { grid-template-columns: 1fr; } }
.choice {
  min-height: 62px; border-radius: 14px; border: 2px solid var(--line); background: #fff;
  font-size: 17px; font-weight: 700; cursor: pointer; padding: 10px 14px;
}
.choice:hover { border-color: var(--primary); }
.choice.correct { border-color: var(--success); background: #e9f8f1; }
.choice.wrong { border-color: var(--danger); background: #fff0f1; }

.pause-mask {
  position: fixed; inset: 0; z-index: 100; background: rgba(24,32,60,.55);
  display: grid; place-items: center; padding: 20px;
}
.pause-mask .card { max-width: 420px; width: 100%; text-align: center; }
.hidden { display: none !important; }

/* 游戏 */
.game-grid { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 14px; }
@media (max-width: 900px) { .game-grid { grid-template-columns: repeat(2, minmax(0,1fr)); } }
@media (max-width: 560px) { .game-grid { grid-template-columns: 1fr; } }
.match-grid { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 12px; }
@media (max-width: 760px) { .match-grid { grid-template-columns: repeat(2, minmax(0,1fr)); } }
.match-card {
  min-height: 84px; padding: 10px; border-radius: 14px; border: 2px solid var(--line);
  background: #fff; cursor: pointer; font-weight: 800; font-size: 16px; word-break: break-word;
  display: grid; place-items: center; text-align: center;
}
.match-card.selected { border-color: var(--primary); background: #eef2ff; }
.match-card.matched { border-color: var(--success); background: #e9f8f1; color: var(--success); opacity: .75; pointer-events: none; }
.quiz-card { text-align: center; padding: clamp(20px, 3vw, 36px); }
.quiz-q { font-size: clamp(26px, 4vw, 44px); font-weight: 900; margin: 16px 0 24px; word-break: break-word; }

.bars { display: flex; flex-direction: column; gap: 12px; }
.bar-row { display: grid; grid-template-columns: 100px 1fr 52px; gap: 10px; align-items: center; }
@media (max-width: 560px) { .bar-row { grid-template-columns: 78px 1fr 44px; font-size: 13px; } }
.bar-track { height: 16px; border-radius: 999px; background: #eef1f8; overflow: hidden; }
.bar-track > i { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--primary), var(--primary-2)); }

.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%) translateY(20px);
  background: #1f2a44; color: #fff; padding: 12px 20px; border-radius: 12px; font-weight: 700;
  opacity: 0; pointer-events: none; transition: .25s ease; z-index: 200; max-width: 90vw; text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.empty { text-align: center; padding: 48px 16px; color: var(--muted); }
.empty .emoji { font-size: 46px; margin-bottom: 8px; }
.spinner { width: 28px; height: 28px; border: 3px solid #e3e8f7; border-top-color: var(--primary); border-radius: 50%; animation: spin .8s linear infinite; margin: 32px auto; }
@keyframes spin { to { transform: rotate(360deg); } }

/* 单词详情页：学习卡片 */
.study-block { padding: 6px 2px 16px; margin-bottom: 8px; border-bottom: 1px dashed #dfe4f2; }
.en-sentence { font-size: clamp(17px, 2vw, 22px); font-weight: 700; line-height: 1.5; margin: 6px 0 4px; color: #22304f; }
.zh-sentence { font-size: clamp(15px, 1.7vw, 18px); color: var(--muted); line-height: 1.6; }
.tag-word { display: inline-block; background: #eef2ff; color: #3b4fd8; border-radius: 999px; padding: 3px 11px; margin: 2px 4px 2px 0; font-size: 14px; font-weight: 700; }
.tag-word.ant { background: #fff0f0; color: #d64550; }
