/* ============ 基础变量与重置 ============ */
:root {
  --primary: #4f46e5;
  --primary-dark: #4338ca;
  --primary-soft: #eef2ff;
  --success: #16a34a;
  --success-soft: #dcfce7;
  --danger: #dc2626;
  --danger-soft: #fee2e2;
  --bg: #f3f4f6;
  --card: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --border: #e5e7eb;
  --shadow: 0 2px 10px rgba(17, 24, 39, 0.08);
  --radius: 14px;
  --header-h: 58px;
  --nav-h: 60px;
}

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

/* 强制 hidden 属性生效，避免作者样式中的 display 声明覆盖 UA 默认的 [hidden]{display:none} */
[hidden] { display: none !important; }

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.55;
  min-height: 100vh;
  -webkit-tap-highlight-color: transparent;
}

button {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
  background: none;
  border: none;
  cursor: pointer;
}

h2, h3 { line-height: 1.3; }

/* ============ 顶部 Header ============ */
.app-header {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--header-h);
  background: var(--primary);
  z-index: 100;
  box-shadow: 0 2px 8px rgba(79, 70, 229, 0.25);
}

.header-inner {
  max-width: 720px;
  margin: 0 auto;
  height: 100%;
  padding: 0 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 7px;
  color: #fff;
  font-weight: 700;
  font-size: 16px;
  white-space: nowrap;
}

.brand-icon { width: 24px; height: 24px; }

.dict-select-wrap { position: relative; flex: 1; max-width: 62%; }

#dictSelect {
  width: 100%;
  height: 38px;
  padding: 0 32px 0 12px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.35);
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
  font-weight: 600;
  appearance: none;
  -webkit-appearance: none;
  outline: none;
}

#dictSelect option { color: var(--text); background: #fff; }

.select-caret {
  position: absolute;
  right: 9px; top: 50%;
  transform: translateY(-50%);
  width: 18px; height: 18px;
  color: #fff;
  pointer-events: none;
}

/* ============ 主内容 ============ */
.app-main {
  max-width: 720px;
  margin: 0 auto;
  padding: calc(var(--header-h) + 12px) 14px calc(var(--nav-h) + 26px);
}

.view { display: none; animation: fadeIn 0.22s ease; }
.view.active { display: block; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ============ 复习横幅 ============ */
.review-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #fff7ed;
  border: 1px solid #fed7aa;
  color: #9a3412;
  padding: 9px 12px;
  border-radius: 10px;
  font-size: 13.5px;
  margin-bottom: 12px;
}

.review-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: #ea580c;
  flex-shrink: 0;
}

.link-btn { color: var(--primary); font-weight: 700; margin-left: auto; }
.link-btn:active { opacity: 0.6; }

/* ============ 简介卡 ============ */
.intro-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 10px 14px;
  margin-bottom: 14px;
}

.intro-card summary {
  font-weight: 700;
  color: var(--primary);
  min-height: 32px;
  display: flex;
  align-items: center;
}

.intro-card[open] summary { margin-bottom: 6px; }
.intro-card p { color: var(--muted); font-size: 14px; }

/* ============ 分段控件 ============ */
.segmented {
  display: flex;
  background: #e5e7eb;
  border-radius: 11px;
  padding: 3px;
  margin-bottom: 14px;
  gap: 3px;
}

.seg-item {
  flex: 1;
  min-height: 42px;
  border-radius: 9px;
  font-weight: 600;
  color: var(--muted);
  transition: background 0.18s, color 0.18s;
}

.seg-item.active {
  background: #fff;
  color: var(--primary);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12);
}

/* ============ 进度 ============ */
.progress-line {
  display: flex;
  justify-content: space-between;
  font-size: 13.5px;
  color: var(--muted);
  font-weight: 600;
  margin-bottom: 6px;
}

.progress-bar {
  height: 8px;
  background: #e5e7eb;
  border-radius: 99px;
  overflow: hidden;
  margin-bottom: 14px;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), #818cf8);
  border-radius: 99px;
  width: 0;
  transition: width 0.3s ease;
}

/* ============ 单词卡（背诵） ============ */
.word-card {
  position: relative;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px 18px;
  margin-bottom: 14px;
  min-height: 260px;
}

.word-head {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.word-text {
  font-size: 28px;
  font-weight: 800;
  color: var(--primary-dark);
  word-break: break-word;
}

.badge {
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 12px;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 99px;
}

.phonetic { color: var(--muted); font-size: 15px; margin-top: 4px; }
.pos { color: #9333ea; font-weight: 600; font-size: 13.5px; margin-top: 8px; }

.meaning {
  margin-top: 10px;
  font-size: 16px;
  white-space: pre-line;
  color: #111827;
}

.example-block {
  margin-top: 14px;
  padding: 10px 12px;
  background: #f9fafb;
  border-left: 3px solid var(--primary);
  border-radius: 8px;
}

.example { font-style: italic; color: #374151; }
.example-cn { color: var(--muted); font-size: 13.5px; margin-top: 3px; }

.freq-line { margin-top: 14px; font-size: 12.5px; color: var(--muted); }

.mastered-flag {
  position: absolute;
  top: 14px; right: 14px;
  background: var(--success-soft);
  color: var(--success);
  font-size: 12px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 99px;
}

/* ============ 翻转卡 ============ */
.flip-card {
  perspective: 1200px;
  margin-bottom: 14px;
}

.flip-inner {
  position: relative;
  width: 100%;
  min-height: 300px;
  transform-style: preserve-3d;
  transition: transform 0.55s cubic-bezier(0.4, 0.2, 0.2, 1);
}

.flip-card.flipped .flip-inner { transform: rotateY(180deg); }

.flip-face {
  position: absolute;
  inset: 0;
  min-height: 300px;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px 18px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.flip-front { gap: 12px; }
.flip-front .word-text { font-size: 32px; }

.flip-hint {
  position: absolute;
  top: 14px;
  font-size: 12.5px;
  color: var(--muted);
}

.flip-back {
  transform: rotateY(180deg);
  justify-content: flex-start;
  align-items: flex-start;
  text-align: left;
  overflow-y: auto;
}

.back-word { font-size: 24px; font-weight: 800; color: var(--primary-dark); }
.flip-back .meaning { font-size: 15px; }

/* ============ 按钮 ============ */
.btn {
  min-height: 44px;
  padding: 10px 16px;
  border-radius: 11px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.1s, filter 0.15s, background 0.15s;
  border: 1px solid transparent;
}

.btn:active { transform: scale(0.96); }
.btn:disabled { opacity: 0.45; pointer-events: none; }

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

.btn-outline {
  background: #fff;
  border-color: var(--border);
  color: var(--text);
}

.btn-ghost {
  background: var(--primary-soft);
  color: var(--primary-dark);
  flex: 1;
}

.btn-success { background: var(--success); color: #fff; }
.btn-success:active { filter: brightness(0.9); }

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:active { filter: brightness(0.9); }

.btn-lg { min-height: 52px; font-size: 17px; padding: 12px 20px; }
.btn-block { width: 100%; }

.flash-actions {
  display: flex;
  gap: 12px;
  margin-bottom: 14px;
}
.flash-actions .btn { flex: 1; }

.recite-actions {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.nav-actions {
  display: flex;
  gap: 10px;
}
.nav-actions .btn { flex: 1; }
.nav-actions .btn-outline { flex: 0 0 auto; padding: 0 14px; }

/* ============ 中英互测 ============ */
.quiz-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px 16px;
  margin-bottom: 12px;
}

.quiz-label {
  font-size: 12.5px;
  color: var(--muted);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.quiz-question {
  font-size: 23px;
  font-weight: 800;
  margin: 8px 0 16px;
  word-break: break-word;
  white-space: pre-line;
  color: var(--primary-dark);
}

.quiz-options { display: flex; flex-direction: column; gap: 10px; }

.option-btn {
  width: 100%;
  min-height: 50px;
  padding: 10px 14px;
  border-radius: 11px;
  border: 1.5px solid var(--border);
  background: #fff;
  text-align: left;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 10px;
  line-height: 1.4;
}

.option-btn .option-key {
  flex-shrink: 0;
  width: 26px; height: 26px;
  border-radius: 50%;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 13px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
}

.option-text {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.option-btn:active { background: #f9fafb; }

.option-btn.correct {
  border-color: var(--success);
  background: var(--success-soft);
  color: #166534;
}
.option-btn.correct .option-key { background: var(--success); color: #fff; }

.option-btn.wrong {
  border-color: var(--danger);
  background: var(--danger-soft);
  color: #991b1b;
}
.option-btn.wrong .option-key { background: var(--danger); color: #fff; }

.option-btn.dimmed { opacity: 0.5; }

.quiz-feedback {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
}
.quiz-feedback.ok { background: var(--success-soft); color: #166534; }
.quiz-feedback.no { background: var(--danger-soft); color: #991b1b; }

.quiz-start { padding-top: 30px; }

.empty-text { color: var(--muted); text-align: center; margin-bottom: 16px; }

/* ============ 错题本 ============ */
.wrong-actions { display: flex; gap: 10px; margin-bottom: 14px; }
.wrong-actions .btn { flex: 1; }

.wrong-item {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px;
  margin-bottom: 10px;
}

.wrong-item-head {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.wrong-word { font-size: 19px; font-weight: 800; color: var(--primary-dark); }

.wrong-meaning {
  margin-top: 6px;
  color: #374151;
  font-size: 14px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  white-space: pre-line;
}

.wrong-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
  font-size: 12.5px;
  color: var(--muted);
  flex-wrap: wrap;
}

.meta-chip {
  background: #f3f4f6;
  padding: 2px 9px;
  border-radius: 99px;
  font-weight: 600;
}

.meta-chip.mastered-chip { background: var(--success-soft); color: var(--success); }

.remove-wrong-btn {
  margin-left: auto;
  color: var(--danger);
  font-weight: 700;
  min-height: 34px;
  padding: 0 10px;
  border-radius: 8px;
}
.remove-wrong-btn:active { background: var(--danger-soft); }

/* ============ 空状态 ============ */
.empty-state {
  text-align: center;
  padding: 56px 20px;
  color: var(--muted);
}

.empty-icon { width: 64px; height: 64px; color: #c7d2fe; margin-bottom: 12px; }
.empty-state p { font-weight: 600; font-size: 16px; }
.empty-sub { font-size: 13.5px !important; font-weight: 400 !important; margin-top: 4px; }

/* ============ 统计 ============ */
.section-title {
  font-size: 16px;
  font-weight: 800;
  margin: 18px 0 10px;
}
.section-title:first-child { margin-top: 4px; }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.stat-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 12px;
  text-align: center;
}

.stat-num { font-size: 24px; font-weight: 800; color: var(--primary); }
.stat-label { font-size: 13px; color: var(--muted); margin-top: 2px; }

.settings-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px;
  border-bottom: 1px solid var(--border);
}
.setting-row:last-child { border-bottom: none; }

.setting-title { font-weight: 700; font-size: 14.5px; }
.setting-sub { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.danger-row .setting-title { color: var(--danger); }

.version-note {
  font-size: 12px;
  color: var(--muted);
  margin-top: 14px;
  text-align: center;
}

/* ============ 底部导航 ============ */
.bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
  background: #fff;
  border-top: 1px solid var(--border);
  display: flex;
  z-index: 100;
}

.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.nav-item svg { width: 23px; height: 23px; }
.nav-item.active { color: var(--primary); }
.nav-item:active { background: #f9fafb; }

/* ============ Toast ============ */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--nav-h) + 18px);
  transform: translateX(-50%);
  background: rgba(17, 24, 39, 0.92);
  color: #fff;
  padding: 10px 18px;
  border-radius: 99px;
  font-size: 13.5px;
  font-weight: 600;
  z-index: 300;
  max-width: 86%;
  text-align: center;
  animation: toastIn 0.2s ease;
}

@keyframes toastIn {
  from { opacity: 0; transform: translate(-50%, 8px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

/* ============ Modal ============ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(17, 24, 39, 0.55);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  animation: fadeIn 0.18s ease;
}

.modal {
  background: #fff;
  border-radius: 16px;
  width: 100%;
  max-width: 380px;
  padding: 22px 20px 18px;
}

.modal-title { font-size: 18px; font-weight: 800; }
.modal-text { color: var(--muted); font-size: 14px; margin: 10px 0 18px; }

.modal-actions { display: flex; gap: 10px; }
.modal-actions .btn { flex: 1; }

/* ============ 桌面端微调 ============ */
@media (min-width: 721px) {
  body { background: #e9ebf0; }
  .app-main { padding-top: calc(var(--header-h) + 20px); }
}
