/* 单词复习系统 — 浅色干净风格，移动端友好 */

* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --primary: #4f6ef7;
  --primary-dark: #3d5ae0;
  --good: #2ea44f;
  --good-bg: #e8f7ed;
  --bad: #e5534b;
  --bad-bg: #fdeceb;
  --text: #24292f;
  --text-light: #6a737d;
  --bg: #f6f8fa;
  --card-bg: #ffffff;
  --border: #e1e4e8;
  --radius: 12px;
}

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

.hidden { display: none !important; }

/* ----------------------------------------------------------- 通用 */

.btn {
  border: 1px solid var(--border);
  background: var(--card-bg);
  color: var(--text);
  border-radius: 8px;
  padding: 10px 18px;
  font-size: 15px;
  cursor: pointer;
  transition: all .15s;
  touch-action: manipulation;
}
.btn:hover { border-color: #c6cbd1; background: #f3f4f6; }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }

.btn-ghost { background: transparent; border-color: transparent; color: var(--text-light); }
.btn-ghost:hover { color: var(--text); background: #eff0f2; }

.btn-small { padding: 5px 10px; font-size: 13px; }
.btn-big { padding: 14px 32px; font-size: 17px; width: 100%; max-width: 320px; }
.btn-block { width: 100%; }

.btn-danger { color: var(--bad); border-color: #f1c7c4; }
.btn-danger:hover { background: var(--bad-bg); border-color: var(--bad); }

.btn-correct, .btn-wrong {
  flex: 1;
  padding: 16px 12px;
  font-size: 18px;
  font-weight: 600;
  border-radius: 12px;
}
.btn-correct { background: var(--good-bg); color: var(--good); border-color: #bfe3cc; }
.btn-correct:hover { background: #d4f0dd; border-color: var(--good); }
.btn-wrong { background: var(--bad-bg); color: var(--bad); border-color: #f1c7c4; }
.btn-wrong:hover { background: #fbdedb; border-color: var(--bad); }

.input, .textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 15px;
  font-family: inherit;
  background: var(--card-bg);
  color: var(--text);
  outline: none;
}
.input:focus, .textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(79,110,247,.12); }

.c-good { color: var(--good); }
.c-bad { color: var(--bad); }

/* ----------------------------------------------------------- 登录页 */

.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: linear-gradient(160deg, #eef2ff 0%, #f6f8fa 60%);
}
.login-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 40px 32px;
  width: 100%;
  max-width: 360px;
  box-shadow: 0 8px 30px rgba(36,41,47,.06);
  text-align: center;
}
.login-card h1 { font-size: 26px; margin-bottom: 6px; }
.login-sub { color: var(--text-light); font-size: 14px; margin-bottom: 24px; }
.login-card .input { margin-bottom: 14px; text-align: center; }
.login-error { color: var(--bad); font-size: 13px; margin-top: 12px; }

/* ----------------------------------------------------------- 顶栏 */

.topbar {
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  position: sticky;
  top: 0;
  z-index: 10;
}
.logo { font-weight: 700; font-size: 17px; white-space: nowrap; }
.nav { display: flex; gap: 2px; flex: 1; overflow-x: auto; }
.nav-link {
  padding: 7px 14px;
  border-radius: 8px;
  color: var(--text-light);
  cursor: pointer;
  font-size: 15px;
  white-space: nowrap;
  user-select: none;
}
.nav-link:hover { color: var(--text); background: #f3f4f6; }
.nav-link.active { color: var(--primary); background: #eef1fe; font-weight: 600; }

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

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

.review-head { text-align: center; margin-bottom: 16px; }
.progress {
  display: inline-block;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 5px 18px;
  font-size: 15px;
  font-weight: 600;
  color: var(--text-light);
}

.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 4px 20px rgba(36,41,47,.05);
  padding: 40px 24px 32px;
  text-align: center;
  max-width: 480px;
  margin: 0 auto;
  animation: cardIn .25s ease;
}
@keyframes cardIn {
  from { opacity: 0; transform: translateY(10px) scale(.98); }
  to { opacity: 1; transform: none; }
}

.card-word {
  font-size: 48px;
  font-weight: 700;
  letter-spacing: .5px;
  word-break: break-word;
  line-height: 1.2;
}
.card-phonetic { color: var(--text-light); font-size: 17px; margin-top: 8px; min-height: 24px; }

.note-hint {
  margin-top: 14px;
  background: #fff8e6;
  border: 1px solid #f2e2b6;
  color: #9a6b00;
  border-radius: 999px;
  padding: 6px 16px;
  font-size: 14px;
  cursor: pointer;
  max-width: 100%;
}
.note-hint:disabled { cursor: default; opacity: .95; }

.card-front .btn-big { margin-top: 26px; }
.key-hint { margin-top: 14px; font-size: 12px; color: #b0b6bd; }

.back-word { font-size: 26px; font-weight: 700; margin-bottom: 4px; word-break: break-word; }
.back-note {
  margin: 10px auto 0;
  background: #fff8e6;
  border: 1px solid #f2e2b6;
  color: #7a5600;
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 14px;
  max-width: 90%;
}
.back-explains { margin-top: 18px; text-align: left; max-width: 400px; margin-left: auto; margin-right: auto; }
.explain-line {
  padding: 7px 0 7px 14px;
  border-left: 3px solid var(--primary);
  margin-bottom: 6px;
  font-size: 16px;
  line-height: 1.5;
}
.back-error {
  margin-top: 14px;
  color: var(--bad);
  background: var(--bad-bg);
  border-radius: 8px;
  padding: 10px;
  font-size: 14px;
}
.answer-btns { display: flex; gap: 14px; margin-top: 26px; }

.feedback {
  text-align: center;
  margin-top: 16px;
  font-size: 17px;
  font-weight: 600;
  min-height: 26px;
  transition: opacity .2s;
}
.feedback.show.fb-good { color: var(--good); }
.feedback.show.fb-bad { color: var(--bad); }

.loading { color: var(--text-light); text-align: center; padding: 12px; font-size: 14px; }

/* 完成页 */
.empty { text-align: center; padding: 50px 20px; }
.empty-icon { font-size: 56px; margin-bottom: 10px; }
.empty h2 { font-size: 22px; margin-bottom: 20px; }
.finish-stats {
  max-width: 300px;
  margin: 0 auto 24px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 6px 18px;
}
.fs-row {
  display: flex;
  justify-content: space-between;
  padding: 11px 0;
  border-bottom: 1px solid #f0f2f4;
  font-size: 15px;
}
.fs-row:last-of-type { border-bottom: none; }
.fs-row b { font-size: 17px; }
.fs-tip { margin-top: 12px; font-size: 13px; color: var(--text-light); }
.btn-disabled { opacity: .55; }

/* ----------------------------------------------------------- 统计卡片 */

.stat-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}
.stat-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.stat-card span { font-size: 13px; color: var(--text-light); }
.stat-card b { font-size: 24px; font-weight: 700; }

/* ----------------------------------------------------------- 词库列表 */

#list-search { margin-bottom: 14px; }
.table-wrap {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow-x: auto;
}
.word-table { width: 100%; border-collapse: collapse; font-size: 14px; min-width: 560px; }
.word-table th {
  text-align: left;
  padding: 10px 12px;
  color: var(--text-light);
  font-weight: 600;
  font-size: 12px;
  border-bottom: 1px solid var(--border);
  background: #fafbfc;
  white-space: nowrap;
}
.word-table td {
  padding: 10px 12px;
  border-bottom: 1px solid #f0f2f4;
  vertical-align: middle;
}
.word-table tr:last-child td { border-bottom: none; }
.word-table tbody tr { cursor: pointer; }
.word-table tbody tr:hover { background: #f8f9fb; }
.td-word { font-weight: 600; font-size: 15px; }
.td-phonetic { color: var(--text-light); }
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  background: #f0f2f4;
  color: var(--text-light);
  white-space: nowrap;
}
.badge-due { background: var(--bad-bg); color: var(--bad); font-weight: 600; }
.empty-tip { text-align: center; color: var(--text-light); padding: 30px 10px; font-size: 14px; }

/* ----------------------------------------------------------- 添加页 */

.page-title { font-size: 19px; margin: 26px 0 12px; }
.page-title:first-child { margin-top: 0; }
.page-sub { font-size: 13px; color: var(--text-light); margin-bottom: 10px; }
.add-box { display: flex; gap: 10px; flex-wrap: wrap; }
.add-box .input { flex: 1; min-width: 180px; }
.input-note { margin-top: 12px; }

.lookup-result {
  margin-top: 14px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
}
.lookup-word { font-size: 20px; font-weight: 700; }
.lookup-word .card-phonetic { display: inline; font-size: 15px; margin-left: 8px; }

.textarea { margin-bottom: 12px; resize: vertical; font-size: 15px; }
.batch-result { margin-top: 14px; font-size: 14px; line-height: 1.8; color: var(--text); }

/* ----------------------------------------------------------- 统计页 */

.chart {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 160px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 10px 6px;
  overflow-x: auto;
}
.bar-col {
  flex: 1;
  min-width: 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  height: 100%;
  justify-content: flex-end;
}
.bar-stack {
  width: 70%;
  max-width: 22px;
  height: 110px;  /* 固定高度，让子元素百分比高度生效 */
  display: flex;
  flex-direction: column-reverse;
  justify-content: flex-start;
}
.bar { width: 100%; border-radius: 3px 3px 0 0; min-height: 0; }
.bar-c { background: var(--good); }
.bar-w { background: var(--bad); }
.bar-num { font-size: 10px; color: var(--text-light); margin-top: 3px; height: 12px; }
.bar-label { font-size: 9px; color: #b0b6bd; margin-top: 1px; white-space: nowrap; }

.chart-legend {
  display: flex;
  gap: 16px;
  justify-content: center;
  margin: 10px 0 6px;
  font-size: 13px;
  color: var(--text-light);
}
.legend-item { display: flex; align-items: center; gap: 5px; }
.dot { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.dot-c { background: var(--good); }
.dot-w { background: var(--bad); }

.history-list {
  list-style: none;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.history-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  border-bottom: 1px solid #f0f2f4;
  font-size: 14px;
}
.history-item:last-child { border-bottom: none; }
.h-time { color: var(--text-light); font-size: 12px; white-space: nowrap; }
.h-word { flex: 1; font-weight: 600; }
.h-result { font-size: 13px; white-space: nowrap; }

/* ----------------------------------------------------------- toast */

.toast {
  position: fixed;
  left: 50%;
  bottom: 32px;
  transform: translateX(-50%);
  background: rgba(36,41,47,.92);
  color: #fff;
  padding: 10px 22px;
  border-radius: 999px;
  font-size: 14px;
  z-index: 100;
  max-width: 86vw;
  text-align: center;
  animation: toastIn .2s ease;
}
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 8px); } }

/* ----------------------------------------------------------- 移动端 */

@media (max-width: 600px) {
  .container { padding: 16px 12px 80px; }
  .card { padding: 34px 16px 26px; }
  .card-word { font-size: 40px; }
  .answer-btns { gap: 10px; }
  .btn-correct, .btn-wrong { font-size: 17px; padding: 16px 8px; }
  .logo { font-size: 15px; }
  .nav-link { padding: 6px 10px; font-size: 14px; }
  .topbar { gap: 6px; padding: 8px 10px; }
  .explain-line { font-size: 15px; }
  .stat-card b { font-size: 20px; }
  .key-hint { display: none; }  /* 手机无键盘 */
}
