/* ============================================================
   打字背单词 — 样式（Chrome 61 基线层）
   约束：无 flex gap / aspect-ratio / clamp / inset / 逻辑属性 / :has
   主题：学科 · 清爽蓝绿（与 24点 一致）
   ============================================================ */

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

html, body { height: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI",
               "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: #f5f7fa;
  color: #1f2329;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
  display: -webkit-box;
  display: -webkit-flex;
  display: flex;
  -webkit-box-orient: vertical;
  -webkit-flex-direction: column;
  flex-direction: column;
  height: 100vh;
  height: calc(var(--app-height, 100vh));
}

/* ---------- 顶栏 ---------- */
.app-header {
  -webkit-box-flex: 0;
  -webkit-flex: 0 0 auto;
  flex: 0 0 auto;
  padding-top: var(--safe-area-inset-top, env(safe-area-inset-top, 0px));
  background: #ffffff;
  border-bottom: 1px solid #e5e6eb;
}

.header-brand {
  display: -webkit-box;
  display: -webkit-flex;
  display: flex;
  -webkit-box-align: center;
  -webkit-align-items: center;
  align-items: center;
  -webkit-box-pack: center;
  -webkit-justify-content: center;
  justify-content: center;
  padding: 10px 16px;
}

.header-icon {
  width: 32px;
  height: 32px;
  margin-right: 8px;
  border-radius: 8px;
  -webkit-box-flex: 0;
  -webkit-flex: 0 0 auto;
  flex: 0 0 auto;
}

.header-title { font-size: 17px; font-weight: 600; }

.header-ver {
  margin-left: 6px;
  font-size: 10px;
  color: #c9cdd4;
}

/* ---------- 主体 ---------- */
.app-main {
  -webkit-box-flex: 1;
  -webkit-flex: 1 1 auto;
  flex: 1 1 auto;
  min-height: 0; /* 关键：允许 flex 子项收缩，否则内容超高时 overflow-y:auto 不生效 */
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
}

.view {
  padding: 12px 16px;
  max-width: 480px; /* PC 打开居中、内容不超宽 */
  margin: 0 auto;
  min-width: 0;
}

/* ---------- 通用按钮 ---------- */
.btn {
  min-height: 48px;
  border: none;
  border-radius: 10px;
  font-size: 16px;
  color: #2f6feb;
  background: #e8f0fe;
  cursor: pointer;
  -webkit-box-flex: 1;
  -webkit-flex: 1 1 auto;
  flex: 1 1 auto;
  min-width: 0;
}

.btn:active { opacity: 0.75; }
.btn-primary { background: #2f6feb; color: #ffffff; }

/* ---------- 通用文本 ---------- */
.page-title {
  font-size: 16px;
  font-weight: 600;
  margin: 8px 0 12px;
  text-align: center;
}

.home-hint {
  font-size: 12px;
  color: #8a919f;
  text-align: center;
  margin: -4px 0 12px;
}

.mode-title {
  font-size: 14px;
  font-weight: 600;
  color: #4e5969;
  margin: 14px 0 8px;
  text-align: center;
}

/* ---------- 首页：册选择 ---------- */
.book-list { margin-top: 4px; }

.book-card {
  background: #ffffff;
  border-radius: 14px;
  padding: 12px 14px;
  margin-bottom: 10px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
}

.book-btn {
  width: 100%;
  min-height: 52px;
  border: none;
  border-radius: 10px;
  font-size: 17px;
  font-weight: 600;
  color: #1f2329;
  background: #f0f6ff;
  cursor: pointer;
}

.book-btn:active { opacity: 0.7; }

.book-meta {
  margin-top: 6px;
  font-size: 12px;
  color: #8a919f;
  text-align: center;
}

/* ---------- 单元列表 ---------- */
.unit-list { margin-top: 4px; }

.unit-card {
  display: -webkit-box;
  display: -webkit-flex;
  display: flex;
  -webkit-box-align: center;
  -webkit-align-items: center;
  align-items: center;
  -webkit-box-pack: justify;
  -webkit-justify-content: space-between;
  justify-content: space-between;
  background: #ffffff;
  border-radius: 12px;
  padding: 10px 14px;
  margin-bottom: 8px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
  min-width: 0;
}

.unit-btn {
  border: none;
  background: none;
  color: #2f6feb;
  font-size: 16px;
  font-weight: 600;
  min-height: 40px;
  padding: 0 6px 0 0;
  cursor: pointer;
  -webkit-box-flex: 0;
  -webkit-flex: 0 0 auto;
  flex: 0 0 auto;
}

.unit-meta {
  font-size: 13px;
  color: #8a919f;
  -webkit-box-flex: 1;
  -webkit-flex: 1 1 auto;
  flex: 1 1 auto;
  min-width: 0;
  text-align: right;
}

/* ---------- 练习页：顶部状态条 ---------- */
.quiz-top {
  display: -webkit-box;
  display: -webkit-flex;
  display: flex;
  -webkit-box-align: center;
  -webkit-align-items: center;
  align-items: center;
  margin-bottom: 10px;
}

.quiz-back {
  border: none;
  background: none;
  color: #2f6feb;
  font-size: 14px;
  min-height: 36px;
  padding: 0 8px 0 0;
  cursor: pointer;
  -webkit-box-flex: 0;
  -webkit-flex: 0 0 auto;
  flex: 0 0 auto;
}

.quiz-info {
  -webkit-box-flex: 1;
  -webkit-flex: 1 1 auto;
  flex: 1 1 auto;
  min-width: 0;
  text-align: center;
}

.quiz-progress {
  font-size: 14px;
  font-weight: 600;
  color: #1f2329;
}

.quiz-score {
  font-size: 11px;
  color: #8a919f;
  margin-top: 2px;
}

.quiz-timer {
  -webkit-box-flex: 0;
  -webkit-flex: 0 0 auto;
  flex: 0 0 auto;
  font-size: 14px;
  font-weight: 700;
  color: #2f6feb;
  min-width: 62px;
  text-align: center;
}

/* ---------- 题目卡 ---------- */
.question-card {
  background: #ffffff;
  border-radius: 14px;
  padding: 24px 16px;
  text-align: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  min-height: 128px;
  display: -webkit-box;
  display: -webkit-flex;
  display: flex;
  -webkit-box-orient: vertical;
  -webkit-flex-direction: column;
  flex-direction: column;
  -webkit-box-align: center;
  -webkit-align-items: center;
  align-items: center;
  -webkit-box-pack: center;
  -webkit-justify-content: center;
  justify-content: center;
}

.question-cn {
  font-size: 30px;
  font-weight: 800;
  color: #1f2329;
  line-height: 1.4;
  word-break: break-all;
}

.question-hint {
  margin-top: 10px;
  font-size: 12px;
  color: #c9cdd4;
}

/* ---------- 作答区（字母槽，每字符一格） ---------- */
.answer-area {
  display: -webkit-box;
  display: -webkit-flex;
  display: flex;
  -webkit-box-pack: center;
  -webkit-justify-content: center;
  justify-content: center;
  margin-top: 12px;
  padding: 8px 4px;
  border-radius: 12px;
  min-height: 64px;
  min-width: 0;
}

.answer-area.answer-ok { background: #e9f8ef; }
.answer-area.answer-bad { background: #fff2f0; }

.answer-slots {
  display: -webkit-box;
  display: -webkit-flex;
  display: flex;
  -webkit-flex-wrap: wrap;
  flex-wrap: wrap;
  -webkit-box-pack: center;
  -webkit-justify-content: center;
  justify-content: center;
  min-width: 0;
}

.answer-slot {
  width: 30px;
  height: 42px;
  margin: 4px 3px 0;
  border-bottom: 3px solid #c9cdd4;
  border-radius: 6px 6px 0 0;
  background: #f7f8fa;
  text-align: center;
  line-height: 42px;
  font-size: 22px;
  font-weight: 700;
  color: #1f2329;
  min-width: 0;
}

/* 空格位（多词词条 "bus stop"）：加宽 + 虚线底 */
.answer-slot.slot-space {
  width: 46px;
  border-bottom-style: dashed;
}

.answer-slot.filled { border-bottom-color: #2f6feb; }

.answer-slot.char-ok {
  color: #12b76a;
  background: #e9f8ef;
  border-bottom-color: #12b76a;
}

.answer-slot.char-bad {
  color: #f04438;
  background: #fff2f0;
  border-bottom-color: #f04438;
}

/* ---------- 反馈行 ---------- */
.quiz-feedback {
  min-height: 36px;
  margin-top: 8px;
  font-size: 16px;
  font-weight: 600;
  text-align: center;
}

.quiz-feedback.ok { color: #12b76a; }
.quiz-feedback.bad { color: #f04438; }

/* ---------- 屏幕虚拟键盘 ---------- */
.kb-wrap {
  margin-top: 14px;
  padding-bottom: calc(var(--safe-area-inset-bottom, 0px));
}

.kb-row {
  display: -webkit-box;
  display: -webkit-flex;
  display: flex;
  margin-top: 6px;
}

.kb-row > * + * { margin-left: 6px; }

.kb-row:first-child { margin-top: 0; }

.kb-key {
  -webkit-box-flex: 1;
  -webkit-flex: 1 1 auto;
  flex: 1 1 auto;
  min-width: 0;
  min-height: 46px;
  border: none;
  border-radius: 8px;
  background: #ffffff;
  color: #1f2329;
  font-size: 18px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.kb-key:active { background: #eef4ff; }

.kb-key:disabled {
  opacity: 0.45;
  cursor: default;
}

.kb-back {
  color: #f04438;
  font-size: 16px;
}

.kb-key-space {
  -webkit-box-flex: 2;
  -webkit-flex: 2 1 auto;
  flex: 2 1 auto;
  color: #4e5969;
  font-size: 14px;
}

.kb-key-punct {
  color: #2f6feb;
  font-size: 18px;
}

.kb-key-submit {
  background: #2f6feb;
  color: #ffffff;
}

/* ---------- 结算页 ---------- */
.result-card {
  background: #ffffff;
  border-radius: 14px;
  padding: 24px;
  text-align: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  margin-bottom: 16px;
}

.result-title { font-size: 14px; color: #4e5969; }

.result-score {
  font-size: 44px;
  font-weight: 800;
  color: #2f6feb;
  margin-top: 6px;
}

.result-stats {
  display: -webkit-box;
  display: -webkit-flex;
  display: flex;
  -webkit-box-pack: center;
  -webkit-justify-content: center;
  justify-content: center;
  margin-top: 14px;
}

.result-stat {
  margin: 0 14px;
  font-size: 13px;
  color: #4e5969;
  text-align: center;
}

.result-stat b { display: block; font-size: 20px; color: #1f2329; }

.btn-row {
  display: -webkit-box;
  display: -webkit-flex;
  display: flex;
  margin-top: 12px;
}

.btn-row > * + * { margin-left: 10px; }

/* ---------- 成绩页：打卡月历 ---------- */
.calendar {
  background: #ffffff;
  border-radius: 14px;
  padding: 16px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.calendar-grid {
  display: -webkit-box;
  display: -webkit-flex;
  display: flex;
  -webkit-flex-wrap: wrap;
  flex-wrap: wrap;
  margin-top: 8px;
}

.calendar-grid > * { width: 14.28%; padding: 4px; }

.cal-day {
  width: 100%;
  padding: 8px 0;
  text-align: center;
  font-size: 13px;
  border-radius: 6px;
  color: #8a919f;
  background: #f7f8fa;
}

.cal-day.done { background: #ff9c1a; color: #ffffff; font-weight: 700; }

.cal-day.today { outline: 2px solid #2f6feb; }

.streak-line {
  text-align: center;
  font-size: 15px;
  color: #4e5969;
  margin-bottom: 4px;
}

.streak-line b { color: #ff9c1a; }

.streak-info { text-align: center; margin-top: 10px; font-size: 14px; color: #4e5969; }
.streak-info b { color: #ff9c1a; }

/* ---------- 成绩页：recent10 列表 ---------- */
.point-list { margin-top: 4px; }

.point-item {
  display: -webkit-box;
  display: -webkit-flex;
  display: flex;
  -webkit-box-align: center;
  -webkit-align-items: center;
  align-items: center;
  -webkit-box-pack: justify;
  -webkit-justify-content: space-between;
  justify-content: space-between;
  padding: 14px 16px;
  background: #ffffff;
  border-radius: 10px;
  margin-bottom: 8px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
  min-width: 0;
}

.point-name { font-size: 15px; font-weight: 600; }

.point-meta { font-size: 12px; color: #8a919f; margin-top: 3px; }

.point-right { text-align: right; }

.point-time { font-size: 16px; font-weight: 700; color: #2f6feb; }

/* ---------- toast ---------- */
.toast {
  position: fixed;
  top: 60px;
  left: 50%;
  -webkit-transform: translateX(-50%);
  transform: translateX(-50%);
  background: rgba(31, 35, 41, 0.9);
  color: #ffffff;
  font-size: 14px;
  padding: 10px 18px;
  border-radius: 20px;
  z-index: 1100;
  max-width: 78%;
  text-align: center;
  pointer-events: none;
  white-space: normal;
}

.toast-error { background: rgba(240, 68, 56, 0.95); }

/* ---------- 底栏 ---------- */
.app-footer {
  -webkit-box-flex: 0;
  -webkit-flex: 0 0 auto;
  flex: 0 0 auto;
  background: #ffffff;
  border-top: 1px solid #e5e6eb;
  padding-bottom: var(--safe-area-inset-bottom, env(safe-area-inset-bottom, 0px));
}

.footer-nav {
  display: -webkit-box;
  display: -webkit-flex;
  display: flex;
  -webkit-box-pack: center;
  -webkit-justify-content: center;
  justify-content: center;
  padding: 8px 12px 10px;
}

.footer-nav > * + * { margin-left: 10px; }

.footer-btn {
  min-width: 64px;
  padding: 9px 0;
  font-size: 13px;
  color: #2f6feb;
  text-align: center;
  border-radius: 8px;
  background: #f2f3f5;
}

.footer-btn.active {
  background: #2f6feb;
  color: #ffffff;
  font-weight: 600;
}

/* ---------- 安全区增强 ---------- */
@supports ((padding-bottom: var(--safe-area-inset-bottom)) or (padding-bottom: env(safe-area-inset-bottom))) {
  .app-header { padding-top: var(--safe-area-inset-top, env(safe-area-inset-top, 0px)); }
  .app-footer { padding-bottom: var(--safe-area-inset-bottom, env(safe-area-inset-bottom, 0px)); }
}
