:root {
  --bg: #f6f6f8;
  --card: #ffffff;
  --ink: #17171c;
  --muted: #6b6b78;
  --faint: #9a9aa6;
  --line: #e7e7ec;
  --brand: #4f46e5;
  --brand-dark: #4338ca;
  --brand-soft: #eef0ff;
  --danger: #dc2626;
  --danger-soft: #fef2f2;
  --ok: #059669;
  --ok-soft: #ecfdf5;
  --amber: #d97706;
  --amber-soft: #fffbeb;
  --radius: 14px;
  --tabbar-h: 60px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
               "Microsoft YaHei", "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.6;
  -webkit-text-size-adjust: 100%;
}

a { color: var(--brand); text-decoration: none; }
button, input, textarea, select { font: inherit; color: inherit; }

.page {
  max-width: 680px;
  margin: 0 auto;
  padding: 14px 14px calc(var(--tabbar-h) + 30px + env(safe-area-inset-bottom));
}

/* ---------- 通用组件 ---------- */

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
}

.h-title { font-size: 20px; font-weight: 600; margin: 4px 0 2px; letter-spacing: -0.01em; }
.h-sub { font-size: 13px; color: var(--muted); margin: 0 0 14px; }
.sec-title { font-size: 13px; font-weight: 600; color: var(--muted); margin: 18px 2px 8px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--line); background: #fff; color: var(--ink);
  border-radius: 10px; padding: 10px 16px; font-size: 15px; font-weight: 500;
  cursor: pointer; transition: background .12s, transform .06s;
}
.btn:active { transform: scale(.98); }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:active { background: var(--brand-dark); }
.btn-block { display: flex; width: 100%; }
.btn-lg { padding: 14px 18px; font-size: 16px; border-radius: 12px; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-sm { padding: 6px 10px; font-size: 13px; border-radius: 8px; }
.btn-danger { color: var(--danger); border-color: #f3d5d5; background: var(--danger-soft); }

.field { margin-bottom: 12px; }
.field > label {
  display: block; font-size: 12px; color: var(--muted);
  margin-bottom: 5px; font-weight: 500;
}
.input, .textarea, .select {
  width: 100%; border: 1px solid var(--line); background: #fff;
  border-radius: 10px; padding: 11px 12px; font-size: 16px; outline: none;
  transition: border-color .12s, box-shadow .12s;
}
.input:focus, .textarea:focus, .select:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, .10);
}
.textarea { resize: vertical; min-height: 72px; line-height: 1.55; }
.input-xl { font-size: 22px; padding: 14px; letter-spacing: .01em; }

.tag {
  display: inline-block; font-size: 11px; padding: 2px 7px; border-radius: 6px;
  background: #f1f1f5; color: var(--muted); margin-right: 4px; white-space: nowrap;
}
.tag-ky { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.tag-hot { background: #eef0ff; color: var(--brand); }
.tag-warn { background: var(--amber-soft); color: var(--amber); }
.tag-ok { background: var(--ok-soft); color: var(--ok); }

.row { display: flex; gap: 10px; }
.row > * { flex: 1; }

.empty { text-align: center; color: var(--faint); padding: 40px 10px; font-size: 14px; }

/* ---------- 首页 ---------- */

.hero {
  background: linear-gradient(0deg, #fff, #fff);
  border: 1px solid var(--line);
  border-radius: 18px; padding: 20px; margin-bottom: 12px;
  border-left: 4px solid var(--brand);
}
.hero-num { font-size: 44px; font-weight: 700; line-height: 1.05; letter-spacing: -0.02em; }
.hero-label { font-size: 13px; color: var(--muted); margin-top: 2px; }
.hero-zero { color: var(--faint); }

.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 12px; }
.stat {
  background: #fff; border: 1px solid var(--line); border-radius: 12px;
  padding: 11px 8px; text-align: center;
}
.stat-num { font-size: 21px; font-weight: 650; line-height: 1.2; }
.stat-lbl { font-size: 11px; color: var(--muted); margin-top: 1px; }

.bar-stack { display: flex; height: 8px; border-radius: 5px; overflow: hidden; background: #eee; }
.bar-stack > span { display: block; height: 100%; }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); margin-top: 8px; flex-wrap: wrap; }
.legend i { width: 8px; height: 8px; border-radius: 3px; display: inline-block; margin-right: 5px; }

/* ---------- 词条 ---------- */

.word-row {
  background: #fff; border: 1px solid var(--line); border-radius: 12px;
  padding: 11px 13px; margin-bottom: 8px;
}
.word-head { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.word-text { font-size: 17px; font-weight: 600; letter-spacing: -.01em; }
.word-phon { font-size: 12px; color: var(--faint); }
.word-trans {
  font-size: 13px; color: #3d3d46; margin-top: 4px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
}
.word-meta { font-size: 11px; color: var(--faint); margin-top: 5px; display: flex; gap: 8px; flex-wrap: wrap; }
.word-sent {
  font-size: 13px; color: var(--muted); margin-top: 6px; padding-left: 9px;
  border-left: 2px solid var(--line); line-height: 1.5;
}

/* ---------- 复习 ---------- */

.review-wrap { padding-top: 6px; }
.progress-line {
  height: 4px; background: #e9e9ef; border-radius: 3px; overflow: hidden; margin-bottom: 16px;
}
.progress-line > span { display: block; height: 100%; background: var(--brand); transition: width .25s; }

.flash {
  background: #fff; border: 1px solid var(--line); border-radius: 18px;
  padding: 34px 20px; text-align: center; margin-bottom: 14px; min-height: 200px;
  display: flex; flex-direction: column; justify-content: center;
}
.flash-word { font-size: 34px; font-weight: 700; letter-spacing: -.02em; line-height: 1.2; }
.flash-phon { font-size: 14px; color: var(--faint); margin-top: 6px; }
.flash-answer { margin-top: 18px; text-align: left; border-top: 1px solid var(--line); padding-top: 16px; }
.flash-trans { font-size: 17px; font-weight: 550; line-height: 1.55; }
.flash-def { font-size: 13px; color: var(--muted); margin-top: 8px; line-height: 1.6; }
.flash-sent {
  font-size: 13px; color: #3d3d46; margin-top: 10px; padding: 9px 11px;
  background: #f8f8fb; border-radius: 9px; line-height: 1.55;
}
.flash-src { font-size: 11px; color: var(--faint); margin-top: 8px; }

.rate-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.rate {
  border: 1px solid var(--line); background: #fff; border-radius: 12px;
  padding: 13px 4px; text-align: center; cursor: pointer;
}
.rate:active { transform: scale(.97); }
.rate-name { font-size: 15px; font-weight: 600; }
.rate-hint { font-size: 11px; color: var(--faint); margin-top: 2px; }
.rate-again { background: var(--danger-soft); border-color: #f4d4d4; color: var(--danger); }
.rate-hard { background: var(--amber-soft); border-color: #f3e2c0; color: var(--amber); }
.rate-good { background: var(--brand-soft); border-color: #dcdefb; color: var(--brand); }
.rate-easy { background: var(--ok-soft); border-color: #c6eddb; color: var(--ok); }

/* ---------- 底部导航 ---------- */

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
  display: flex; background: rgba(255, 255, 255, .94);
  backdrop-filter: saturate(180%) blur(12px);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
}
.tab {
  flex: 1; display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 2px; color: var(--faint); font-size: 11px;
}
.tab.active { color: var(--brand); }
.tab svg { width: 22px; height: 22px; }

/* ---------- 提示条 ---------- */

.toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--tabbar-h) + 20px + env(safe-area-inset-bottom));
  background: #17171c; color: #fff; padding: 10px 18px; border-radius: 10px;
  font-size: 14px; z-index: 100; opacity: 0; pointer-events: none;
  transition: opacity .2s, transform .2s; max-width: 90vw; text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(-6px); }

/* ---------- 筛选 ---------- */

.chips { display: flex; gap: 7px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 10px; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  border: 1px solid var(--line); background: #fff; border-radius: 20px;
  padding: 6px 13px; font-size: 13px; white-space: nowrap; cursor: pointer; color: var(--muted);
}
.chip.active { background: var(--brand); border-color: var(--brand); color: #fff; }

/* ---------- 图表 ---------- */

.chart { display: flex; align-items: flex-end; gap: 3px; height: 90px; margin-top: 8px; }
.chart-col { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; height: 100%; gap: 2px; }
.chart-bar { background: var(--brand); border-radius: 2px 2px 0 0; min-height: 2px; }
.chart-bar.rev { background: #c7d2fe; }
.chart-lbl { font-size: 9px; color: var(--faint); text-align: center; margin-top: 4px; }

.tabs { display: flex; background: #eeeef2; border-radius: 10px; padding: 3px; margin-bottom: 14px; }
.tabs > button {
  flex: 1; border: 0; background: transparent; padding: 8px; border-radius: 8px;
  font-size: 14px; color: var(--muted); cursor: pointer; font-weight: 500;
}
.tabs > button.active { background: #fff; color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.08); }

.dict-hit {
  background: var(--brand-soft); border: 1px solid #dcdfef; border-radius: 12px;
  padding: 12px; margin-bottom: 12px;
}
.dict-hit .word-text { font-size: 19px; }
.miss { background: var(--amber-soft); border-color: #f3e2c0; }

@media (min-width: 700px) {
  .flash-word { font-size: 42px; }
  .hero-num { font-size: 52px; }
}
