:root {
  --bg: #f5f7fa;
  --card: #ffffff;
  --ink: #1f2430;
  --muted: #6b7280;
  --line: #e5e7eb;
  --brand: #4f46e5;
  --brand-soft: #eef2ff;
  --ok: #16a34a;
  --ok-soft: #ecfdf5;
  --warn: #d97706;
  --warn-soft: #fffbeb;
  --bad: #dc2626;
  --bad-soft: #fef2f2;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(16, 24, 40, .08), 0 1px 2px rgba(16, 24, 40, .04);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  line-height: 1.6;
}

/* 顶部导航 */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 10px 18px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
}
.brand {
  font-weight: 700;
  font-size: 17px;
  color: var(--ink);
  text-decoration: none;
  margin-right: 12px;
}
.nav { display: flex; gap: 6px; flex-wrap: wrap; }
.nav a {
  padding: 6px 12px;
  border-radius: 8px;
  color: var(--muted);
  text-decoration: none;
  font-size: 14px;
  transition: .15s;
}
.nav a:hover { background: var(--brand-soft); color: var(--brand); }
.nav a.active { background: var(--brand); color: #fff; }

.container { max-width: 860px; margin: 0 auto; padding: 20px 16px 64px; }

/* 卡片 */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 16px;
}
.card h2, .card h3 { margin: 0 0 12px; }

/* 按钮 */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 16px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink);
  font-size: 14px;
  cursor: pointer;
  text-decoration: none;
  transition: .15s;
}
.btn:hover { border-color: var(--brand); color: var(--brand); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { opacity: .9; color: #fff; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.small { padding: 5px 10px; font-size: 13px; }

.btn-row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 14px; }

/* 单元网格 */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }
.unit-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  text-decoration: none;
  color: var(--ink);
  transition: .15s;
}
.unit-card:hover { transform: translateY(-2px); border-color: var(--brand); }
.unit-card .theme { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }
.unit-card .title { font-size: 17px; font-weight: 700; margin: 4px 0 10px; }
.meta { font-size: 13px; color: var(--muted); }
.meta .bar { height: 6px; border-radius: 3px; background: var(--line); margin-top: 6px; overflow: hidden; }
.meta .bar > span { display: block; height: 100%; background: var(--brand); }

/* 统计 */
.stat-row { display: flex; gap: 14px; flex-wrap: wrap; margin-bottom: 18px; }
.stat {
  flex: 1;
  min-width: 140px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
}
.stat .num { font-size: 24px; font-weight: 700; }
.stat .label { font-size: 13px; color: var(--muted); }

/* 单词卡 / 拼写 */
.word-big { font-size: 40px; font-weight: 700; text-align: center; margin: 10px 0; }
.meaning-big { font-size: 20px; text-align: center; margin: 10px 0; }
.pos-badge { color: var(--muted); font-size: 15px; text-align: center; }
.speak-btn { cursor: pointer; color: var(--brand); font-size: 20px; border: none; background: none; }
input[type="text"] {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 9px;
  font-size: 18px;
  outline: none;
}
input[type="text"]:focus { border-color: var(--brand); }

.feedback { padding: 12px 14px; border-radius: 9px; margin-top: 12px; font-size: 15px; }
.feedback.ok { background: var(--ok-soft); color: var(--ok); }
.feedback.bad { background: var(--bad-soft); color: var(--bad); }

.options { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }
.option {
  text-align: left;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--card);
  cursor: pointer;
  font-size: 15px;
  transition: .12s;
}
.option:hover { border-color: var(--brand); }
.option.picked { border-color: var(--brand); background: var(--brand-soft); }
.option.correct { border-color: var(--ok); background: var(--ok-soft); color: var(--ok); }
.option.wrong { border-color: var(--bad); background: var(--bad-soft); color: var(--bad); }

/* 进度条 */
.progress { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--muted); margin-bottom: 12px; }
.progress .track { flex: 1; height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; }
.progress .track > span { display: block; height: 100%; background: var(--brand); transition: width .2s; }

/* 阅读 */
.passage .ph { margin: 0 0 14px; font-size: 16.5px; }
.passage .hh { font-size: 18px; font-weight: 700; margin: 18px 0 8px; color: var(--brand); }
.vocab-hl { background: #fef3c7; border-radius: 4px; padding: 0 2px; cursor: pointer; border-bottom: 1px dashed var(--warn); }
.vocab-hl:hover { background: #fde68a; }

.q-block { margin: 16px 0; padding: 16px; border: 1px solid var(--line); border-radius: var(--radius); }
.q-block .q-text { font-weight: 600; margin-bottom: 10px; }
.q-block .q-type { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }
.explain { margin-top: 10px; font-size: 14px; color: var(--muted); }

/* 对话 */
.chat { display: flex; flex-direction: column; gap: 12px; margin-bottom: 14px; }
.bubble { max-width: 78%; padding: 10px 14px; border-radius: 14px; font-size: 15px; white-space: pre-wrap; }
.bubble.partner { align-self: flex-start; background: var(--card); border: 1px solid var(--line); }
.bubble.me { align-self: flex-end; background: var(--brand); color: #fff; }
.bubble .who { display: block; font-size: 12px; opacity: .7; margin-bottom: 3px; }
.choice-bar { display: flex; flex-direction: column; gap: 8px; }
.choice-btn { text-align: left; }
.hint { font-size: 13px; color: var(--warn); margin-top: 4px; }

/* 词义弹窗 */
.word-pop {
  position: fixed;
  z-index: 50;
  background: var(--ink);
  color: #fff;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 14px;
  max-width: 260px;
  box-shadow: 0 4px 12px rgba(0,0,0,.25);
}

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: #fff;
  padding: 10px 18px;
  border-radius: 10px;
  font-size: 14px;
  z-index: 100;
}
.hidden { display: none !important; }

/* 设置 */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 5px; }
.field input[type="text"], .field input[type="password"] { font-size: 15px; }
.help { font-size: 13px; color: var(--muted); }

.empty { text-align: center; color: var(--muted); padding: 30px 0; }

@media (max-width: 560px) {
  .bubble { max-width: 90%; }
  .word-big { font-size: 30px; }
}
