/* ============ 词记 WordMemo · 样式（浅色主题） ============ */
:root {
  --bg: #f2f4fa;
  --surface: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --border: #e5e7eb;
  --accent: #6366f1;
  --accent-2: #8b5cf6;
  --ok: #16a34a;
  --ok-bg: #ecfdf5;
  --bad: #dc2626;
  --bad-bg: #fef2f2;
  --warn: #d97706;
  --warn-bg: #fffbeb;
  --shadow: 0 12px 32px rgba(31, 41, 55, 0.10);
  --radius: 18px;
}

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

body {
  font-family: "PingFang SC", "Microsoft YaHei", "Segoe UI", system-ui, -apple-system, sans-serif;
  background:
    radial-gradient(1200px 500px at 10% -10%, rgba(99, 102, 241, 0.10), transparent 60%),
    radial-gradient(1000px 420px at 95% 0%, rgba(139, 92, 246, 0.10), transparent 55%),
    var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.hidden { display: none !important; }

/* ---------- 顶栏 ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding: 16px 28px;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand { display: flex; align-items: center; gap: 12px; }
.logo {
  font-size: 30px;
  width: 52px; height: 52px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border-radius: 14px;
  box-shadow: 0 6px 16px rgba(99, 102, 241, 0.35);
}
.brand-text h1 { font-size: 20px; letter-spacing: 0.5px; }
.brand-text p { font-size: 12px; color: var(--muted); margin-top: 2px; }

.topbar-right { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.book-label { font-size: 13px; color: var(--muted); }

.book-select {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%236b7280'/%3E%3C/svg%3E") no-repeat right 12px center;
  border-radius: 10px;
  padding: 8px 34px 8px 12px;
  font-size: 14px;
  color: var(--text);
  cursor: pointer;
  min-width: 170px;
}
.book-select:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

.mode-switch {
  display: flex;
  background: #eef0f6;
  border-radius: 10px;
  padding: 3px;
  gap: 2px;
}
.mode-btn {
  border: none;
  background: transparent;
  padding: 7px 16px;
  border-radius: 8px;
  font-size: 14px;
  color: var(--muted);
  cursor: pointer;
  transition: all 0.2s;
}
.mode-btn.active { background: var(--surface); color: var(--text); box-shadow: 0 2px 6px rgba(0,0,0,0.08); font-weight: 600; }

/* ---------- 主区域 ---------- */
main {
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  padding: 22px 18px 40px;
  flex: 1;
}

/* ---------- 工具栏 ---------- */
.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.filter-group { display: flex; gap: 6px; flex-wrap: wrap; }
.filter-btn {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
}
.filter-btn:hover { border-color: var(--accent); color: var(--accent); }
.filter-btn.active {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border-color: transparent;
  color: #fff;
  font-weight: 600;
}

.tool-actions { display: flex; gap: 8px; }
.tool-btn {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  border-radius: 10px;
  padding: 6px 12px;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
}
.tool-btn:hover { color: var(--accent); border-color: var(--accent); }

/* ---------- 翻卡 ---------- */
.card-stage { perspective: 1500px; margin-bottom: 16px; }

.flashcard {
  position: relative;
  width: 100%;
  height: 330px;
  transform-style: preserve-3d;
  transition: transform 0.55s cubic-bezier(0.4, 0.1, 0.2, 1);
  cursor: pointer;
}
.flashcard.flipped { transform: rotateY(180deg); }

.card-face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 22px;
  box-shadow: var(--shadow);
  padding: 30px 26px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  text-align: center;
  overflow: auto;
}
.card-back { transform: rotateY(180deg); }

.pos-badge {
  position: absolute;
  top: 18px;
  left: 20px;
  font-size: 12px;
  color: var(--accent);
  background: #eef0fe;
  border-radius: 999px;
  padding: 3px 10px;
  font-weight: 600;
}

.word {
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(38px, 7vw, 54px);
  font-weight: 700;
  letter-spacing: 0.5px;
  line-height: 1.15;
  word-break: break-word;
}

.phonetic { font-size: 17px; color: var(--muted); font-family: Georgia, serif; }

.tap-hint { font-size: 12px; color: #b6bcc8; margin-top: 4px; }

.back-word {
  font-family: Georgia, serif;
  font-size: 24px;
  font-weight: 700;
  color: var(--accent);
}
.back-word .ph { font-size: 14px; color: var(--muted); font-weight: 400; margin-left: 8px; }

.meaning { font-size: 20px; font-weight: 600; }

.example-box {
  width: 100%;
  max-width: 520px;
  background: #f8f9fd;
  border-left: 4px solid var(--accent);
  border-radius: 10px;
  padding: 14px 16px;
  text-align: left;
}
.example-en { font-size: 15px; line-height: 1.6; font-family: Georgia, serif; }
.example-zh { font-size: 13px; color: var(--muted); margin-top: 6px; line-height: 1.6; }

/* ---------- 按钮 ---------- */
.speak-btn {
  border: 1px solid #dcdff5;
  background: #f5f6ff;
  color: var(--accent);
  border-radius: 999px;
  padding: 8px 18px;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s;
}
.speak-btn:hover { background: var(--accent); color: #fff; border-color: var(--accent); }
.speak-btn.small { padding: 5px 12px; font-size: 13px; }

.ctrl-btn {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 12px;
  padding: 11px 18px;
  font-size: 15px;
  cursor: pointer;
  transition: all 0.18s;
}
.ctrl-btn:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(0,0,0,0.08); }
.ctrl-btn:active { transform: translateY(0); }

.know-btn { background: var(--ok-bg); border-color: #bbe7cd; color: var(--ok); font-weight: 600; }
.know-btn:hover { background: var(--ok); color: #fff; }
.unknown-btn { background: var(--warn-bg); border-color: #f5dfae; color: var(--warn); font-weight: 600; }
.unknown-btn:hover { background: var(--warn); color: #fff; }

.primary-btn {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border-color: transparent;
  color: #fff;
  font-weight: 700;
  padding: 12px 34px;
  font-size: 16px;
}
.primary-btn:hover { box-shadow: 0 8px 20px rgba(99, 102, 241, 0.4); }

.controls {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 14px;
}

/* ---------- 进度 ---------- */
.progress-wrap { margin-bottom: 14px; }
.progress-info {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 6px;
}
.status-text { font-weight: 600; color: var(--accent); }
.progress-bar {
  height: 8px;
  background: #e8eaf3;
  border-radius: 999px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width 0.3s;
}

/* ---------- 选项行 ---------- */
.options-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 16px;
  margin-bottom: 14px;
}
.opt-toggle { font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 6px; cursor: pointer; }
.opt-toggle input { accent-color: var(--accent); width: 15px; height: 15px; cursor: pointer; }

.rate-control { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.rate-control input[type="range"] { accent-color: var(--accent); width: 110px; cursor: pointer; }
.rate-value { min-width: 36px; font-variant-numeric: tabular-nums; }

/* ---------- 统计 ---------- */
.stats {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 16px;
  font-size: 13px;
  color: var(--muted);
  text-align: center;
  margin-bottom: 8px;
}

.kbd-hint { text-align: center; font-size: 12px; color: #b6bcc8; }

/* ---------- 测验 ---------- */
.quiz-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px 24px;
}

.quiz-intro { text-align: center; padding: 24px 0 8px; }
.quiz-intro h2 { font-size: 22px; margin-bottom: 10px; }
.quiz-intro p { color: var(--muted); font-size: 14px; margin-bottom: 22px; }

.quiz-progress {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 18px;
}
#quizScoreText { font-weight: 700; color: var(--accent); }

.quiz-question { text-align: center; margin-bottom: 22px; }
.quiz-word { font-family: Georgia, serif; font-size: 40px; font-weight: 700; }
.quiz-phonetic { color: var(--muted); font-size: 14px; margin: 6px 0 12px; }

.quiz-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.quiz-option {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 12px;
  padding: 14px 12px;
  font-size: 15px;
  cursor: pointer;
  text-align: left;
  transition: all 0.18s;
  display: flex;
  align-items: center;
  gap: 10px;
}
.quiz-option:hover:not(:disabled) { border-color: var(--accent); background: #f8f8ff; }
.quiz-option:disabled { cursor: default; opacity: 0.75; }
.quiz-option .opt-key {
  width: 24px; height: 24px;
  flex: none;
  display: grid; place-items: center;
  border-radius: 8px;
  background: #eef0f6;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}
.quiz-option.correct { border-color: var(--ok); background: var(--ok-bg); color: var(--ok); font-weight: 700; }
.quiz-option.correct .opt-key { background: var(--ok); color: #fff; }
.quiz-option.wrong { border-color: var(--bad); background: var(--bad-bg); color: var(--bad); font-weight: 700; }
.quiz-option.wrong .opt-key { background: var(--bad); color: #fff; }

.quiz-feedback { min-height: 44px; font-size: 14px; margin: 14px 0; line-height: 1.6; }
.quiz-feedback.ok { color: var(--ok); font-weight: 700; }
.quiz-feedback.bad { color: var(--bad); }
.quiz-next-wrap { text-align: right; }

#quizResult h2 { text-align: center; font-size: 22px; margin-bottom: 14px; }
.result-score {
  text-align: center;
  font-size: 44px;
  font-weight: 800;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  margin-bottom: 18px;
}
.wrong-title { font-size: 14px; color: var(--muted); margin-bottom: 10px; }
.wrong-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 14px;
  margin-bottom: 8px;
}
.wrong-word { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.wrong-word b { font-family: Georgia, serif; font-size: 17px; }
.wrong-word span { font-size: 13px; color: var(--muted); }
.all-right { text-align: center; color: var(--ok); font-size: 16px; font-weight: 700; padding: 12px 0 18px; }
.result-actions { display: flex; justify-content: center; gap: 12px; margin-top: 18px; }

/* ---------- 其他 ---------- */
footer {
  text-align: center;
  font-size: 12px;
  color: #9aa1af;
  padding: 18px;
  border-top: 1px solid var(--border);
  background: rgba(255,255,255,0.6);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 34px;
  transform: translateX(-50%);
  background: #1f2937;
  color: #fff;
  font-size: 14px;
  border-radius: 999px;
  padding: 10px 22px;
  box-shadow: 0 10px 26px rgba(0,0,0,0.25);
  z-index: 99;
  animation: toast-in 0.25s ease;
}
@keyframes toast-in {
  from { opacity: 0; transform: translate(-50%, 8px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

/* ---------- 主导航 ---------- */
.main-nav {
  display: flex;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 14px 18px 0;
  max-width: 760px;
  width: 100%;
  margin: 0 auto;
}
.nav-btn {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  border-radius: 999px;
  padding: 9px 20px;
  font-size: 15px;
  cursor: pointer;
  transition: all 0.2s;
}
.nav-btn:hover { border-color: var(--accent); color: var(--accent); }
.nav-btn.active {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border-color: transparent;
  color: #fff;
  font-weight: 700;
  box-shadow: 0 6px 16px rgba(99, 102, 241, 0.35);
}

.tool-btn.accent { color: var(--accent); border-color: #c7cbf5; background: #f5f6ff; font-weight: 600; }
.tool-btn.accent:hover { background: var(--accent); color: #fff; }
.tool-btn.danger { color: var(--bad); border-color: #f3c2c2; }
.tool-btn.danger:hover { background: var(--bad); color: #fff; border-color: var(--bad); }

/* ---------- 阅读 ---------- */
.reading-layout {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 16px;
  align-items: start;
}

.reading-list-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px;
  position: sticky;
  top: 92px;
}
.reading-filter { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.reading-progress-text { font-size: 12px; color: var(--muted); margin-bottom: 8px; text-align: center; }

.reading-list { max-height: 60vh; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; }
.reading-item {
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 10px;
  padding: 9px 11px;
  font-size: 13px;
  cursor: pointer;
  text-align: left;
  transition: all 0.15s;
  color: var(--text);
}
.reading-item:hover { border-color: var(--accent); background: #f8f8ff; }
.reading-item.active { border-color: var(--accent); background: #eef0fe; font-weight: 700; }
.reading-item .ri-id {
  flex: none;
  width: 26px; height: 26px;
  display: grid; place-items: center;
  border-radius: 8px;
  background: #eef0f6;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}
.reading-item.read .ri-id { background: var(--ok); color: #fff; }
.reading-item .ri-title { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.reading-item .ri-level { flex: none; font-size: 11px; color: var(--muted); }

.reading-reader {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 26px 28px;
  min-height: 60vh;
}
.reader-empty { text-align: center; color: var(--muted); padding: 60px 0; font-size: 15px; }
.reader-empty p:first-child { font-size: 44px; margin-bottom: 12px; }
.reader-tip { font-size: 12px; color: #b6bcc8; margin-top: 10px; }

.reader-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.reader-head h2 { font-size: 22px; }
.level-badge {
  font-size: 12px;
  color: var(--accent);
  background: #eef0fe;
  border-radius: 999px;
  padding: 3px 12px;
  font-weight: 700;
}
.reader-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 18px; }

.reader-content .p-block { margin-bottom: 16px; }
.reader-content .p-en {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 16.5px;
  line-height: 1.75;
  cursor: pointer;
}
.reader-content .p-en:hover { background: #f5f6ff; border-radius: 6px; }
.reader-content .p-zh {
  font-size: 14px;
  line-height: 1.8;
  color: var(--muted);
  border-left: 3px solid #dcdff5;
  padding-left: 12px;
  margin-top: 6px;
}
.reader-content .p-zh.zh-hidden { display: none; }

/* ---------- 记录本 ---------- */
.records-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px 26px;
}
.records-head { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 10px; margin-bottom: 16px; }
.records-head h2 { font-size: 20px; }
.records-head-actions { display: flex; gap: 8px; }

.records-overview {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 20px;
}
.overview-card {
  background: linear-gradient(160deg, #f7f8fd, #eef0fe);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 10px;
  text-align: center;
}
.overview-card .num { font-size: 24px; font-weight: 800; color: var(--accent); }
.overview-card .lbl { font-size: 12px; color: var(--muted); margin-top: 4px; }

.record-group-date {
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
  margin: 16px 0 8px;
}
.record-item {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 16px;
  margin-bottom: 10px;
  font-size: 13px;
}
.record-item .ri-top { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 6px; }
.record-item .ri-time { color: var(--muted); font-variant-numeric: tabular-nums; }
.record-item .ri-book { font-weight: 700; color: var(--accent); }
.record-item .ri-type {
  font-size: 11px;
  background: #eef0fe;
  color: var(--accent);
  border-radius: 999px;
  padding: 2px 9px;
  font-weight: 700;
}
.record-item .ri-type.quiz { background: #fff7ed; color: var(--warn); }
.record-chips { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 6px; }
.record-chips .chip {
  border-radius: 999px;
  padding: 2px 10px;
  font-size: 12px;
  background: #f3f4f6;
  color: var(--muted);
}
.record-chips .chip.known { background: var(--ok-bg); color: var(--ok); font-weight: 700; }
.record-chips .chip.unknown { background: var(--warn-bg); color: var(--warn); font-weight: 700; }
.record-chips .chip.quiz { background: #eef0fe; color: var(--accent); font-weight: 700; }
.record-words { display: flex; gap: 5px; flex-wrap: wrap; }
.record-words .rw {
  font-size: 12px;
  border-radius: 6px;
  padding: 1px 8px;
  background: #f3f4f6;
  color: var(--muted);
  cursor: default;
}
.record-words .rw.known { background: var(--ok-bg); color: var(--ok); }
.record-words .rw.unknown { background: var(--warn-bg); color: var(--warn); }
.records-empty { text-align: center; color: var(--muted); padding: 40px 0; font-size: 14px; }

/* ---------- 响应式 ---------- */
@media (max-width: 640px) {
  .topbar { padding: 12px 16px; }
  .controls { grid-template-columns: 1fr 1fr; }
  .flashcard { height: 360px; }
  .quiz-options { grid-template-columns: 1fr; }
  .options-row { justify-content: center; }
  .reading-layout { grid-template-columns: 1fr; }
  .reading-list-wrap { position: static; }
  .reading-list { max-height: 220px; }
  .records-overview { grid-template-columns: repeat(2, 1fr); }
  .reading-reader { padding: 18px 16px; }
}
