:root {
  --bg: #f4f7fb;
  --panel: #ffffff;
  --ink: #1f2a44;
  --muted: #6b7794;
  --line: #e4eaf3;
  --brand: #1f6fb2;
  --brand-d: #155a93;
  --brand-soft: #e8f2fb;
  --teal: #18a999;
  --amber: #e8a33d;
  --red: #e0556b;
  --green: #2faa6a;
  --radius: 14px;
  --shadow: 0 6px 24px rgba(31, 42, 68, .08);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.6;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* Top bar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 24px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 10;
  flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 12px; cursor: pointer; }
.logo { font-size: 30px; }
.brand-name { font-weight: 800; font-size: 20px; letter-spacing: .5px; color: var(--brand); }
.brand-sub { font-size: 12px; color: var(--muted); }
.nav { display: flex; gap: 6px; flex-wrap: wrap; }
.nav-btn {
  border: none;
  background: transparent;
  color: var(--muted);
  padding: 8px 14px;
  border-radius: 999px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  transition: all .15s;
}
.nav-btn:hover { background: var(--brand-soft); color: var(--brand); }
.nav-btn.active { background: var(--brand); color: #fff; }

main { flex: 1; padding: 28px 24px 40px; max-width: 1080px; width: 100%; margin: 0 auto; }

/* Buttons */
.btn {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  padding: 10px 18px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  transition: all .15s;
}
.btn:hover { border-color: var(--brand); color: var(--brand); }
.btn-primary { background: var(--brand); color: #fff; border-color: var(--brand); }
.btn-primary:hover { background: var(--brand-d); color: #fff; }
.btn-ghost { background: transparent; }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.muted { color: var(--muted); }
.hidden { display: none !important; }

/* Home */
.hero {
  background: linear-gradient(135deg, var(--brand) 0%, var(--teal) 100%);
  color: #fff;
  padding: 38px 34px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.hero h1 { margin: 0 0 10px; font-size: 30px; }
.hero p { margin: 0 0 22px; max-width: 640px; opacity: .95; }
.hero-actions { display: flex; gap: 12px; flex-wrap: wrap; }
.hero .btn-primary { background: #fff; color: var(--brand-d); border-color:#fff; }
.hero .btn-primary:hover { background: #f0f6fc; }
.hero .btn { color:#fff; border-color: rgba(255,255,255,.7); }
.hero .btn:hover { background: rgba(255,255,255,.15); color:#fff; }

.mode-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-top: 26px;
}
.mode-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  cursor: pointer;
  transition: all .15s;
  box-shadow: var(--shadow);
}
.mode-card:hover { transform: translateY(-3px); border-color: var(--brand); }
.mode-card .mc-icon { font-size: 26px; }
.mode-card h3 { margin: 8px 0 4px; font-size: 17px; }
.mode-card p { margin: 0; font-size: 13px; color: var(--muted); }

/* Banks */
.bank-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
  margin-top: 18px;
}
.bank-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: all .15s;
}
.bank-card:hover { border-color: var(--brand); transform: translateY(-2px); }
.bank-card .bc-icon { font-size: 28px; }
.bank-card h3 { margin: 8px 0 2px; }
.bank-card .bc-en { font-size: 12px; color: var(--brand); font-weight: 600; }
.bank-card .bc-desc { font-size: 13px; color: var(--muted); margin: 8px 0; }
.bank-card .bc-count { font-size: 12px; color: var(--muted); }

.word-list-wrap { margin-top: 22px; }
.wl-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; flex-wrap: wrap; gap: 8px; }
.word-table { width: 100%; border-collapse: collapse; background: var(--panel); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.word-table th, .word-table td { text-align: left; padding: 12px 14px; border-bottom: 1px solid var(--line); font-size: 14px; vertical-align: top; }
.word-table th { background: var(--brand-soft); color: var(--brand-d); font-size: 13px; }
.word-table tr:last-child td { border-bottom: none; }
.w-en { font-weight: 700; }
.w-phon { color: var(--muted); font-size: 12px; }
.audio-btn { border: none; background: var(--brand-soft); color: var(--brand); border-radius: 8px; cursor: pointer; padding: 2px 8px; font-size: 12px; }

/* Flashcard */
.learn-head, .quiz-meta, .quiz h2, .dictation h2, .stats h2, .banks h2, .custom h2 { display: flex; align-items: baseline; gap: 12px; }
.learn-meta, .quiz-meta { font-size: 13px; color: var(--muted); font-weight: 500; }
.flashcard {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  min-height: 320px;
  padding: 36px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  margin: 18px 0;
}
.fc-front .fc-word { font-size: 46px; font-weight: 800; color: var(--brand); margin-bottom: 6px; }
.fc-front .fc-phon { font-size: 18px; color: var(--muted); }
.fc-front .fc-hint { margin-top: 24px; color: var(--muted); font-size: 14px; }
.fc-back .fc-cn { font-size: 20px; font-weight: 700; margin-bottom: 6px; }
.fc-back .fc-pos { color: var(--teal); font-weight: 600; font-size: 14px; }
.fc-back .fc-ex { margin-top: 16px; font-style: italic; color: var(--ink); }
.fc-back .fc-ex-cn { color: var(--muted); font-size: 14px; }
.fc-controls { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.btn-know { background: var(--green); border-color: var(--green); color: #fff; }
.btn-know:hover { background: #26915a; color:#fff; }
.btn-vague { background: var(--amber); border-color: var(--amber); color: #fff; }
.btn-vague:hover { background: #cf8f2f; color:#fff; }
.btn-unknow { background: var(--red); border-color: var(--red); color: #fff; }
.btn-unknow:hover { background: #c8475b; color:#fff; }

/* Quiz / Dictation */
.quiz-card, .dict-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 30px;
  margin-top: 16px;
}
.quiz-q { font-size: 26px; font-weight: 800; margin-bottom: 4px; }
.quiz-sub { color: var(--muted); font-size: 14px; margin-bottom: 18px; }
.quiz-options { display: grid; gap: 10px; }
.opt {
  border: 1px solid var(--line);
  background: var(--panel);
  padding: 14px 16px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 15px;
  text-align: left;
  transition: all .12s;
}
.opt:hover { border-color: var(--brand); }
.opt.correct { background: #e6f7ee; border-color: var(--green); color: var(--green); font-weight: 700; }
.opt.wrong { background: #fdeaed; border-color: var(--red); color: var(--red); font-weight: 700; }
.opt.disabled { pointer-events: none; }
.quiz-feedback { margin-top: 16px; font-weight: 700; }
.quiz-feedback.ok { color: var(--green); }
.quiz-feedback.no { color: var(--red); }

.dict-prompt { font-size: 18px; margin-bottom: 8px; }
.dict-input { width: 100%; padding: 14px 16px; font-size: 18px; border-radius: 10px; border: 1px solid var(--line); margin: 12px 0; }
.dict-input:focus { outline: none; border-color: var(--brand); }
.dict-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* Stats */
.stat-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px,1fr)); gap: 14px; margin-top: 16px; }
.stat-card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.stat-card .sc-num { font-size: 30px; font-weight: 800; color: var(--brand); }
.stat-card .sc-label { font-size: 13px; color: var(--muted); }
.stat-bars { margin-top: 24px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.bar-row { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.bar-label { width: 120px; font-size: 13px; }
.bar-track { flex: 1; background: var(--bg); border-radius: 999px; height: 14px; overflow: hidden; }
.bar-fill { height: 100%; background: linear-gradient(90deg, var(--brand), var(--teal)); border-radius: 999px; }
.bar-val { width: 70px; text-align: right; font-size: 13px; color: var(--muted); }

/* Custom */
.custom-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px,1fr)); gap: 10px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); margin-top: 14px; }
.custom-form input { padding: 10px 12px; border-radius: 8px; border: 1px solid var(--line); font-size: 14px; }
.custom-form input:focus { outline: none; border-color: var(--brand); }
.custom-form .btn { grid-column: 1 / -1; justify-self: start; }
.custom-list { margin-top: 18px; display: grid; gap: 10px; }
.custom-item { display: flex; align-items: center; justify-content: space-between; gap: 10px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 12px 16px; box-shadow: var(--shadow); }
.custom-item .ci-main { font-weight: 700; }
.custom-item .ci-cn { color: var(--muted); font-size: 13px; }

.footer { text-align: center; padding: 16px; color: var(--muted); font-size: 12px; border-top: 1px solid var(--line); }
.due-badge { color: var(--brand); font-weight: 600; }

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

@media (max-width: 640px) {
  .fc-front .fc-word { font-size: 34px; }
  .hero h1 { font-size: 24px; }
  .bar-label { width: 90px; }
}
