/* 单词卡 · 简洁练习本风 */
:root {
  --bg: #f6f7f9;
  --card: #ffffff;
  --ink: #1a1a1a;
  --muted: #6b7280;
  --line: #e5e7eb;
  --blue: #2563eb;
  --blue-ink: #ffffff;
  --pink: #ec4899;
  --pink-ink: #ffffff;
  --danger: #dc2626;
  --mark: #fef08a;
  --radius: 14px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101014;
    --card: #1c1c1f;
    --ink: #f3f4f6;
    --muted: #9ca3af;
    --line: #2e2e33;
    --mark: #713f12;
  }
}

* { 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", system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.6;
}

#app { min-height: 100dvh; }

.page {
  max-width: 430px;
  margin: 0 auto;
  padding: calc(12px + env(safe-area-inset-top)) 18px calc(24px + env(safe-area-inset-bottom));
}

.view[hidden] { display: none !important; }

.title {
  font-size: 34px;
  font-weight: 800;
  margin: 28px 0 4px;
  letter-spacing: 1px;
}
.title.small { font-size: 26px; }
.sub { color: var(--muted); margin: 0 0 24px; }
.center { text-align: center; }
.muted { color: var(--muted); font-size: 14px; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 0 12px;
}
.bar-title { font-weight: 700; }
.nick { font-weight: 700; }

/* 按钮：扁平、无辉光 */
.btn {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink);
  border-radius: 12px;
  padding: 10px 16px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
}
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.primary { background: var(--blue); border-color: var(--blue); color: var(--blue-ink); }
.btn.pink { background: var(--pink); border-color: var(--pink); color: var(--pink-ink); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--danger); border-color: var(--danger); }
.btn.big { display: block; width: 100%; padding: 14px; font-size: 18px; margin: 10px 0; }
.btn.mode { margin: 12px 0; }
.btn.grow { flex: 1; }
.btn.speak {
  display: inline-block;
  padding: 6px 12px;
  font-size: 14px;
  border-radius: 999px;
  margin: 4px 0 10px;
}

.row { display: flex; align-items: center; }
.row.gap { gap: 10px; margin: 12px 0; }

/* 输入框 */
.field {
  display: block;
  width: 100%;
  padding: 13px 14px;
  font-size: 16px; /* ≥16px，防止 iOS 聚焦放大 */
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--card);
  color: var(--ink);
  margin: 10px 0;
}
.field:focus { outline: 2px solid var(--blue); outline-offset: 0; border-color: var(--blue); }
.spell-input { font-size: 20px; letter-spacing: 1px; }

.err { color: var(--danger); font-size: 14px; min-height: 22px; margin: 4px 0; }

.spell-actions { display: flex; gap: 10px; margin: 10px 0; }
.spell-actions .btn { margin: 0; flex: 1; width: auto; min-width: 0; }

/* 登录/注册 tab */
.tabs { display: flex; gap: 8px; margin: 16px 0 6px; }
.tab {
  flex: 1;
  padding: 10px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--muted);
  border-radius: 12px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
}
.tab.active { color: var(--blue); border-color: var(--blue); }

/* 卡片 */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px 20px;
  margin: 12px 0;
  cursor: default;
}
#flash-card { cursor: pointer; min-height: 300px; }

.badge {
  display: inline-block;
  font-size: 13px;
  font-weight: 700;
  color: var(--blue);
  border: 1px solid var(--blue);
  border-radius: 999px;
  padding: 2px 10px;
  margin-bottom: 10px;
}

.word-big {
  font-size: 40px;
  font-weight: 800;
  letter-spacing: 0.5px;
  margin: 10px 0 18px;
  word-break: break-word;
}
.word-big.small { font-size: 30px; }

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

.sec-label {
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
  margin: 14px 0 2px;
  letter-spacing: 1px;
}
.def, .ex { margin: 4px 0; font-size: 17px; }
.zh { color: var(--muted); font-size: 15px; margin: 4px 0; }

mark {
  background: var(--mark);
  color: inherit;
  border-radius: 4px;
  padding: 0 2px;
}

/* 范围选择 */
.unit-group {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin: 10px 0;
}
.unit-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 800;
  font-size: 18px;
  margin-bottom: 6px;
}
.unit-toggle {
  border: none;
  background: none;
  color: var(--blue);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  padding: 6px;
}
.lesson-row { display: flex; flex-wrap: wrap; gap: 8px; }
.check-card {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 15px;
  cursor: pointer;
  user-select: none;
  margin: 6px 8px 6px 0;
}
.check-card input { width: 18px; height: 18px; accent-color: var(--blue); }
.check-card.disabled { opacity: 0.45; cursor: not-allowed; }
#mistake-card { display: flex; margin: 10px 0; }

/* 判分反馈 */
.result { font-size: 22px; font-weight: 800; margin-bottom: 8px; }
.result.ok { color: #16a34a; }
.result.no { color: var(--danger); }

/* 总结 */
.stat-line { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--line); }
.stat-line:last-child { border-bottom: none; }
.wrong-item { padding: 8px 0; border-bottom: 1px solid var(--line); }
.wrong-item .w { font-weight: 700; font-size: 18px; }
.wrong-item .z { color: var(--muted); font-size: 14px; margin-left: 8px; }
.section-title { font-weight: 800; margin: 18px 0 6px; }

/* 朗读开关关闭态 */
#tts-toggle.off { opacity: 0.4; }

/* 等级卡片 */
.level-card {
  padding: 16px 18px;
  margin: 14px 0 16px;
}
.level-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 10px;
}
.level-title {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 0.5px;
}
.level-progress-text {
  font-size: 14px;
  font-weight: 700;
  color: var(--muted);
}
.level-track {
  width: 100%;
  height: 8px;
  background: var(--line);
  border-radius: 999px;
  overflow: hidden;
}
.level-bar {
  height: 100%;
  background: var(--blue);
  border-radius: 999px;
  transition: width 0.3s ease;
  min-width: 0;
}

/* 徽章墙 */
.badge-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin: 16px 0 20px;
}
.badge-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  position: relative;
  box-sizing: border-box;
}
.badge-card.unlocked {
  border-color: rgba(37, 99, 235, 0.35);
}
.badge-card.locked {
  opacity: 0.55;
}
.badge-card.locked .badge-icon {
  filter: grayscale(1);
  opacity: 0.4;
}
.badge-icon {
  font-size: 32px;
  line-height: 1.2;
  margin-bottom: 6px;
}
.badge-name {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 4px;
  word-break: break-word;
}
.badge-desc {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.4;
  word-break: break-word;
  flex-grow: 1;
}
.badge-date {
  font-size: 11px;
  color: var(--muted);
  margin-top: 6px;
  font-weight: 500;
}

/* 顶部通知 Toast */
.toast-container {
  position: fixed;
  top: calc(14px + env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  width: calc(100% - 32px);
  max-width: 390px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
  z-index: 9999;
}
.toast {
  background: var(--card);
  color: var(--ink);
  border: 1px solid var(--line);
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.12);
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 600;
  text-align: center;
  pointer-events: auto;
  animation: toast-in 0.25s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  max-width: 100%;
  word-break: break-word;
}
@media (prefers-color-scheme: dark) {
  .toast {
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
  }
}
.toast.toast-out {
  animation: toast-out 0.25s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}
@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(-14px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}
@keyframes toast-out {
  from {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
  to {
    opacity: 0;
    transform: translateY(-14px) scale(0.96);
  }
}
