/* ===== 学习页 ===== */
body { background: var(--paper); }

.ghost-input {
  position: fixed;
  top: -100px;
  left: 0;
  width: 10px;
  height: 10px;
  opacity: 0;
  border: none;
  pointer-events: none;
}

.bar {
  max-width: 860px;
  margin: 0 auto;
  padding: 18px 22px 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}
.back {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: var(--card);
  border: 1px solid var(--line);
  font-size: 19px;
  box-shadow: 0 1px 0 #dfe6df;
}
.back:hover { box-shadow: var(--shadow); }
.bar-mark { display: flex; align-items: center; gap: 9px; font-family: var(--font-display); font-size: 19px; letter-spacing: 1px; }
.bar-mark .mark-tile { width: 30px; height: 30px; font-size: 15px; border-radius: 8px; }
.bar-stats { display: flex; gap: 8px; }
.stat {
  min-width: 44px;
  text-align: center;
  padding: 5px 10px;
  border-radius: 999px;
  font-family: var(--font-letter);
  font-weight: 700;
  font-size: 15px;
}
.stat-ok { background: var(--moss-wash); color: var(--moss-deep); }
.stat-bad { background: var(--wrong-wash); color: var(--wrong); }

.progress {
  max-width: 860px;
  margin: 6px auto 0;
  padding: 0 22px;
}
.progress i {
  display: block;
  height: 8px;
  border-radius: 99px;
  background: var(--moss);
  width: 0;
  transition: width 0.4s cubic-bezier(0.22, 1, 0.36, 1);
  box-shadow: inset 0 -2px 0 rgba(0,0,0,.12);
}
.progress { position: relative; }
.progress::before {
  content: '';
  position: absolute;
  left: 22px;
  right: 22px;
  top: 0;
  height: 8px;
  border-radius: 99px;
  background: #e2e9e2;
  z-index: -1;
}

.stage { max-width: 860px; margin: 0 auto; padding: 18px 22px 60px; }

.flash {
  position: relative;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  animation: card-in 0.35s cubic-bezier(0.22, 1, 0.36, 1);
}
@keyframes card-in { from { opacity: 0; transform: translateY(16px); } }

/* 生成的图片是正方形（1024x1024），照片区也做成正方形，保证整图完整可见 */
.photo-wrap {
  position: relative;
  margin: 18px auto;
  width: min(100%, 46vh, 420px);
  width: min(100%, 46dvh, 420px);
  aspect-ratio: 1;
  border-radius: 16px;
  overflow: hidden;
  background: #e9efe9;
}
.photo-wrap img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  user-select: none;
  transition: opacity 0.25s ease;
}
.photo-wrap img.switching { opacity: 0; }

/* 词卡模式（没有配图的词）：作答前只展示音标与释义，例句等揭示后再出现 */
.word-card {
  margin: 18px auto;
  width: min(100%, 46vh, 420px);
  width: min(100%, 46dvh, 420px);
  min-height: 210px;
  padding: 26px 22px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: #f7faf7;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  text-align: center;
}
.word-card-tag {
  font-size: 12px;
  letter-spacing: 1px;
  color: var(--ink-faint);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px 12px;
}
.word-card-phonetic {
  font-family: var(--font-letter);
  font-size: clamp(19px, 3vw, 24px);
  letter-spacing: 1px;
  color: var(--moss-deep);
}
.word-card-meaning {
  font-size: clamp(20px, 3.2vw, 26px);
  font-weight: 700;
  line-height: 1.5;
  color: var(--ink);
}

.answer { padding: 4px 26px 26px; text-align: center; }

.pinyin {
  min-height: 26px;
  font-family: var(--font-letter);
  font-size: 18px;
  letter-spacing: 3px;
  color: var(--moss-deep);
  margin-bottom: 8px;
}

.tiles {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 9px;
  margin: 4px 0 10px;
  min-height: 66px;
}
.tile {
  display: grid;
  place-items: center;
  width: clamp(42px, 8.5vw, 58px);
  height: clamp(46px, 9vw, 62px);
  border-radius: 13px;
  background: #fbfcfb;
  border: 2px solid var(--line);
  box-shadow: 0 2.5px 0 #dfe6df;
  font-family: var(--font-letter);
  font-weight: 700;
  font-size: clamp(22px, 4.5vw, 30px);
  color: var(--ink);
  transition: background 0.12s ease, border-color 0.12s ease, transform 0.12s ease;
}
.tile.sep {
  width: auto;
  min-width: 10px;
  border: none;
  box-shadow: none;
  background: transparent;
  color: var(--ink-faint);
  pointer-events: none;
}
.tile.ok {
  background: var(--moss);
  border-color: var(--moss-deep);
  color: #fff;
  box-shadow: 0 2.5px 0 var(--moss-deep);
  animation: tile-pop 0.28s cubic-bezier(0.22, 1.4, 0.36, 1);
}
.tile.hinted { background: #7cc79e; border-color: #58a87e; box-shadow: 0 2.5px 0 #58a87e; }
.tile.bad {
  background: var(--wrong-wash);
  border-color: var(--wrong);
  color: var(--wrong);
  box-shadow: 0 2.5px 0 #eeb9b6;
  animation: tile-shake 0.36s ease;
}
.tile.revealed { background: #f0f2f0; color: var(--ink-faint); border-style: dashed; }
@keyframes tile-pop { 0% { transform: scale(0.8); } 60% { transform: scale(1.12); } }
@keyframes tile-shake { 25% { transform: translateX(-5px); } 55% { transform: translateX(5px); } 80% { transform: translateX(-2px); } }

.flash.word-done .tile { animation: tile-wave 0.45s ease; animation-delay: calc(var(--i) * 0.06s); }
@keyframes tile-wave { 45% { transform: translateY(-9px); } }

.verdict { min-height: 24px; font-size: 14.5px; color: var(--ink-faint); margin-bottom: 12px; }
.verdict.bad { color: var(--wrong); font-weight: 500; }
.verdict.ok { color: var(--moss-deep); font-weight: 700; }

.controls { display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; }

/* 屏幕键盘：仅触屏设备的英语模式显示（JS 检测到触屏时给 body 加 touch 类；?kb=1 可强制开启预览） */
.kb { display: none; }
body.touch .kb {
  display: flex;
  flex-direction: column;
  gap: 7px;
  padding: 10px 10px max(14px, env(safe-area-inset-bottom));
  background: #f7faf7;
  border-top: 1px solid var(--line);
}
body.touch .kb-row { display: flex; gap: 5px; justify-content: center; }
body.touch .kb-key {
  flex: 1;
  max-width: 42px;
  height: 46px;
  border: 1.5px solid var(--line);
  border-radius: 9px;
  background: var(--card);
  box-shadow: 0 2px 0 #dfe6df;
  font-family: var(--font-letter);
  font-weight: 700;
  font-size: 19px;
  color: var(--ink);
  display: grid;
  place-items: center;
  padding: 0;
  cursor: pointer;
}
body.touch .kb-key:active {
  transform: translateY(2px);
  box-shadow: none;
  background: var(--moss-wash);
  border-color: var(--moss);
}
body.touch .kb-key.kb-wide { max-width: 56px; flex: 1.4; font-size: 17px; }

/* 庆祝层 */
.celebrate {
  position: absolute;
  inset: 0;
  cursor: pointer;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(3px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  animation: card-in 0.25s ease;
  z-index: 5;
}
.celebrate-check {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--moss);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 34px;
  font-weight: 700;
  box-shadow: 0 6px 0 var(--moss-deep);
  animation: check-pop 0.4s cubic-bezier(0.22, 1.6, 0.36, 1);
}
@keyframes check-pop { from { transform: scale(0.3); opacity: 0; } }
.celebrate-word {
  font-family: var(--font-display);
  font-size: clamp(34px, 6vw, 52px);
  letter-spacing: 4px;
  color: var(--ink);
  line-height: 1.2;
}
.celebrate-meta { color: var(--ink-soft); font-size: 16px; }
.celebrate-bar {
  width: 150px;
  height: 5px;
  border-radius: 99px;
  background: #e5ebe5;
  overflow: hidden;
  margin-top: 6px;
}
.celebrate-bar i { display: block; height: 100%; background: var(--moss); width: 0; animation: bar-fill 1.9s linear forwards; }
@keyframes bar-fill { to { width: 100%; } }
.celebrate-next { margin-top: 2px; }

/* 词卡词：庆祝层要放例句，改成「详情区自己滚动 + 按钮固定」，避免按钮遮住内容 */
.celebrate.is-card {
  justify-content: flex-start;
  padding: 12px 18px 12px;
  overflow: hidden;
  gap: 6px;
}
/* 顶部（对勾/单词/释义）压紧一些，把纵向空间留给下方解析 */
.celebrate.is-card .celebrate-check { width: 38px; height: 38px; font-size: 21px; box-shadow: 0 3px 0 var(--moss-deep); }
.celebrate.is-card .celebrate-word { font-size: clamp(24px, 3.6vw, 34px); letter-spacing: 2px; }
.celebrate.is-card .celebrate-meta { font-size: 15px; }
.celebrate.is-card .celebrate-bar { display: none; }
.celebrate.is-card .celebrate-detail {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding-right: 4px;
}
.celebrate.is-card .celebrate-next { margin-top: 6px; }

/* 词条解析区：用满卡片宽度（原来 520px 太窄，例句/词组被挤成窄条） */
.celebrate-detail {
  width: 100%;
  max-width: 720px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  text-align: left;
  margin-top: 2px;
}
/* 词卡词揭示时把卡片撑高，给解析区留出足够纵向空间 */
.flash.card-reveal { min-height: min(78vh, 720px); }
.cd-def {
  font-size: 14px;
  line-height: 1.6;
  color: var(--ink-soft);
  border-left: 3px solid var(--moss-wash);
  padding-left: 10px;
}
.cd-sec { background: #f7faf7; border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.cd-sec h4 { margin: 0 0 6px; font-size: 12px; font-weight: 700; letter-spacing: 1.5px; color: var(--ink-faint); }
.cd-sent { font-size: 14.5px; line-height: 1.6; color: var(--ink); }
.cd-sent + .cd-sent { margin-top: 7px; }
.cd-sent span { display: block; font-size: 13.5px; color: var(--ink-soft); }
.cd-forms { display: flex; flex-wrap: wrap; gap: 6px; }
.cd-form { font-size: 12.5px; background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 3px 9px; color: var(--ink-soft); }
.cd-form b { font-weight: 600; color: var(--ink); }

/* 结算 */
.summary {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  text-align: center;
  padding: 40px 26px;
  animation: card-in 0.35s ease;
}
.summary-eyebrow { font-family: var(--font-letter); letter-spacing: 3px; font-size: 12.5px; color: var(--moss); margin: 0 0 6px; }
.summary h2 { font-family: var(--font-display); font-weight: 400; font-size: 32px; margin: 0 0 22px; letter-spacing: 2px; }
.summary-grid { display: flex; justify-content: center; gap: 14px; flex-wrap: wrap; margin-bottom: 26px; }
.sg-item {
  background: var(--paper);
  border-radius: 14px;
  padding: 14px 22px;
  min-width: 92px;
}
.sg-item b { display: block; font-family: var(--font-letter); font-size: 26px; color: var(--moss-deep); }
.sg-item span { font-size: 13px; color: var(--ink-soft); }
.summary-actions { display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; }

/* 空状态 */
.empty { text-align: center; padding: 70px 20px; }
.empty-icon { font-size: 52px; margin-bottom: 6px; }
.empty h2 { font-family: var(--font-display); font-weight: 400; font-size: 26px; margin: 0 0 8px; }
.empty p { color: var(--ink-soft); margin: 0 0 22px; }

@media (max-width: 620px) {
  .bar { padding: 14px 16px 6px; }
  .progress { padding: 0 16px; }
  .progress::before { left: 16px; right: 16px; }
  .stage { padding: 14px 14px max(40px, env(safe-area-inset-bottom)); }
  .photo-wrap { margin: 12px auto; width: min(100%, 34vh); width: min(100%, 34dvh); }
  .word-card { margin: 12px auto; width: 100%; min-height: 150px; padding: 18px 16px; gap: 8px; }
  .celebrate.is-card { padding: 18px 14px; }
  .answer { padding: 0 14px 18px; }
  .bar-mark span:last-child { display: none; }
  .verdict { font-size: 14px; }
  .tiles { gap: 7px; min-height: 60px; }
  .tile {
    width: clamp(36px, 8vw, 50px);
    height: clamp(42px, 9vw, 56px);
    border-radius: 11px;
    font-size: clamp(20px, 4.2vw, 26px);
  }
  .controls .btn-sm { flex: 1; }
  .celebrate-word { letter-spacing: 2px; }
  .celebrate-meta { padding: 0 16px; text-align: center; }
  .summary { padding: 32px 18px; }
  .sg-item { min-width: 76px; padding: 12px 16px; }
}

/* 触屏学习页底部是屏幕键盘，右下角浮标会压住按键：
   这种情况下只保留「答完回首页自动弹反馈」的入口，浮标不显示 */
body.touch .fb-fab { display: none; }
