/* 错句本 · 越南语学习通 */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Microsoft YaHei', 'Segoe UI', sans-serif;
  background: #f6f8fb;
  color: #1f2430;
  font-size: 14px;
  -webkit-tap-highlight-color: transparent;
  min-height: 100dvh;
  min-height: 100vh;
  padding-bottom: env(safe-area-inset-bottom, 0);
}
@media (min-width: 520px) {
  body { background: linear-gradient(135deg, #eef2f9 0%, #e6ecf7 100%); min-height: 100vh; }
}
.app { max-width: 480px; margin: 0 auto; }

/* ---------- AppBar ---------- */
.appbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 56px;
  margin: 12px 12px 0;
  border-bottom: 1px solid #eef0f4;
  border-radius: 20px 20px 0 0;
}
.appbar .title { margin: 0; font-size: 16px; font-weight: 600; letter-spacing: 0.5px; }
.settings-btn {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  width: 36px; height: 36px;
  border: none;
  background: transparent;
  color: #6b7588;
  border-radius: 8px;
  display: grid; place-items: center;
  cursor: pointer;
}
.settings-btn:active { background: #f1f4f8; }

/* ---------- 搜索 ---------- */
.search-wrap { padding: 14px 16px 6px; }
.search-box {
  display: flex;
  align-items: center;
  background: #fff;
  border-radius: 12px;
  padding: 0 12px;
  height: 40px;
  border: 1px solid #e6e9ef;
  box-shadow: 0 1px 2px rgba(20,30,50,0.04);
}
.search-icon { color: #9aa3b2; flex-shrink: 0; }
.search-box input {
  flex: 1;
  border: none; outline: none;
  background: transparent;
  margin: 0 8px;
  font-size: 14px;
  color: #1f2430;
}
.search-box input::placeholder { color: #a0a7b4; }
.search-clear {
  border: none;
  background: #eef1f6;
  color: #6b7588;
  border-radius: 50%;
  width: 22px; height: 22px;
  display: grid; place-items: center;
  cursor: pointer;
}
.search-clear[hidden] { display: none; }

/* ---------- Hero ---------- */
.hero { padding: 14px 16px 10px; }
.hero-title { margin: 0 0 4px; font-size: 22px; font-weight: 700; letter-spacing: 0.5px; }
.hero-sub { margin: 0; color: #6b7588; font-size: 13px; }

/* ---------- 错词本：统计 + 筛选 ---------- */
/* 类型筛选标签（全部 / 错句 / 错词） */
.type-tabs {
  display: flex;
  gap: 8px;
  padding: 4px 16px 12px;
  position: sticky;
  top: 48px;
  background: #f5f7fb;
  z-index: 12;
}
.type-tab {
  flex: 1;
  border: 1px solid #e6e9f0;
  background: #fff;
  color: #6b7588;
  font-size: 14px;
  font-weight: 600;
  padding: 9px 0;
  border-radius: 10px;
  cursor: pointer;
  transition: all .15s;
}
.type-tab:hover { color: #1f2430; }
.type-tab.active {
  background: #2f6bff;
  color: #fff;
  border-color: #2f6bff;
  box-shadow: 0 2px 8px rgba(47,107,255,.25);
}

/* ---------- 卡片 ---------- */
.list { padding: 8px 14px 24px; display: flex; flex-direction: column; gap: 12px; }

.card {
  background: #fff;
  border-radius: 14px;
  padding: 14px 14px 12px;
  box-shadow: 0 1px 2px rgba(20,30,50,0.04);
  border: 1px solid #eef0f4;
}
.card-head {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 10px;
}
.card-date {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: #6b7588;
  font-size: 12px;
}
.card-date svg { color: #9099a8; }
.card-spacer { flex: 1; }

.type-pill {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 11px;
  background: #ffe2e8;
  color: #e94c63;
  font-weight: 600;
}
.type-pill[data-type="word"] { background: #e3f1ff; color: #2a73d4; }
.type-pill .close-mark { color: #f66; margin-left: 1px; font-weight: 700; }

.del-btn {
  border: none;
  background: transparent;
  color: #ff6577;
  font-size: 16px;
  width: 24px; height: 24px;
  border-radius: 6px;
  cursor: pointer;
  display: grid; place-items: center;
  margin-left: -2px;
}
.del-btn:active { background: #ffe5ea; }

.edit-btn {
  border: none;
  background: transparent;
  color: #3b82f6;
  font-size: 14px;
  width: 24px; height: 24px;
  border-radius: 6px;
  cursor: pointer;
  display: grid; place-items: center;
  margin-left: 2px;
}
.edit-btn:active { background: #e3f1ff; }

.card-vi {
  font-size: 17px;
  font-weight: 700;
  line-height: 1.5;
  color: #1f2430;
  word-break: break-word;
  white-space: pre-wrap;
  margin: 2px 0 10px;
}
/* 错词本：词条黄色高亮 + 稍大字 */
body[data-mode="word"] .card-vi {
  font-size: 18px;
  background: #fff5b8;
  display: inline-block;
  padding: 2px 8px;
  border-radius: 6px;
  margin: 4px 0 12px;
}
.card-source {
  display: flex;
  align-items: center;
  gap: 6px;
  color: #6b7588;
  font-size: 12.5px;
  margin-bottom: 8px;
  border-top: 1px dashed #e6e9ef;
  padding-top: 8px;
}
.card-source svg { color: #9aa3b2; flex-shrink: 0; }
.card-source .src-text { color: #6b7588; }
.card-source .src-name { color: #1f2430; font-weight: 600; }
/* 来源文章可点击跳转 */
.card-source a.src-name,
.article-link {
  color: #2f6bff;
  text-decoration: none;
  cursor: pointer;
  transition: color .15s;
}
.card-source a.src-name:hover,
.article-link:hover { color: #1f4fd6; text-decoration: underline; }

.card-zh {
  display: none; /* 默认收起，点"译"展开 */
  color: #384056;
  background: #f3f6fb;
  border-radius: 8px;
  padding: 8px 10px;
  margin: 4px 0 10px;
  font-size: 13.5px;
  line-height: 1.5;
}
.card-zh.show { display: block; }

.card-foot {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.tag {
  background: #eef1f6;
  color: #6b7588;
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 999px;
  font-weight: 500;
}
.tag.severe { background: #ffe2e8; color: #d23f57; }

.foot-spacer { flex: 1; }

.icon-btn {
  width: 38px; height: 38px;
  border-radius: 50%;
  border: none;
  display: grid; place-items: center;
  cursor: pointer;
  transition: transform 0.1s ease;
}
.icon-btn:active { transform: scale(0.92); }
.icon-btn.speak { background: linear-gradient(135deg, #3ecba8 0%, #29b793 100%); color: #fff; box-shadow: 0 4px 10px rgba(40,183,147,0.35); }
/* 播放三态 */
.icon-btn.speak[data-state="playing"] { background: linear-gradient(135deg, #2f6bff 0%, #1a4fd6 100%); animation: speakPulse 1s infinite; }
.icon-btn.speak[data-state="played"] { background: #d7f0e3; color: #1a9d57; box-shadow: none; }
@keyframes speakPulse { 0% { box-shadow: 0 0 0 0 rgba(47,107,255,.5); } 70% { box-shadow: 0 0 0 8px rgba(47,107,255,0); } 100% { box-shadow: 0 0 0 0 rgba(47,107,255,0); } }
.icon-btn.trans { background: #e8f0ff; color: #3478f6; font-size: 15px; font-weight: 700; }
.icon-btn.trans:hover { background: #dde9ff; }

/* 错词本：掌握星标（错词卡片底部，与翻译/朗读并排） */
.star-btn {
  width: 28px; height: 28px;
  display: grid; place-items: center;
  border: none;
  background: transparent;
  color: #c9cfdb;   /* 未掌握：浅灰描边星 */
  cursor: pointer;
  padding: 0;
  border-radius: 50%;
}
.star-btn svg path,
.star-btn svg { fill: currentColor; }
.star-btn.is-known { color: #ff7a85; }  /* 已掌握：粉色实心星 */
.star-btn.is-known svg { fill: #ff7a85; }
.star-btn:hover { background: #fff3f4; color: #ff7a85; }

/* ---------- 自测入口 ---------- */
.quiz-entry {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0 16px 12px;
  padding: 14px 16px;
  border-radius: 14px;
  background: linear-gradient(135deg, #2f6bff, #4f8cff);
  color: #fff;
  box-shadow: 0 6px 16px rgba(47,107,255,.25);
}
.quiz-entry-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.quiz-entry-title { font-size: 15px; font-weight: 700; }
.quiz-entry-desc { font-size: 12px; opacity: .9; }
.quiz-start {
  flex-shrink: 0;
  border: 0;
  background: #fff;
  color: #2f6bff;
  font-size: 13.5px;
  font-weight: 700;
  padding: 9px 16px;
  border-radius: 999px;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0,0,0,.12);
  transition: transform .12s;
}
.quiz-start:active { transform: scale(.96); }

/* ---------- 听力训练入口 ---------- */
.listen-entry {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0 16px 12px;
  padding: 14px 16px;
  border-radius: 14px;
  background: linear-gradient(135deg, #1fc8c0, #14a89f);
  color: #fff;
  box-shadow: 0 6px 16px rgba(31,200,192,.25);
}
.listen-start {
  flex-shrink: 0;
  border: 0;
  background: #fff;
  color: #14a89f;
  font-size: 13.5px;
  font-weight: 700;
  padding: 9px 16px;
  border-radius: 999px;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0,0,0,.12);
  transition: transform .12s;
}
.listen-start:active { transform: scale(.96); }

/* ---------- 听力训练覆盖层 ---------- */
.listen-overlay[hidden] { display: none !important; }
.listen-overlay {
  position: fixed; inset: 0;
  background: rgba(20,30,50,.45);
  z-index: 200;
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
}
.listen-card {
  width: 100%; max-width: 400px;
  background: #fff; border-radius: 18px;
  padding: 18px 20px 22px;
  box-shadow: 0 18px 48px rgba(0,0,0,.22);
  animation: pop .18s ease;
}
.listen-play {
  display: block; margin: 6px auto 16px;
  width: 140px; height: 140px; border-radius: 50%;
  border: 0; cursor: pointer;
  background: linear-gradient(135deg, #1fc8c0, #14a89f);
  color: #fff; font-size: 20px; font-weight: 700;
  box-shadow: 0 8px 20px rgba(31,200,192,.35);
  transition: transform .12s;
}
.listen-play:active { transform: scale(.94); }
/* 播放中：脉冲动画 + 暗化背景 */
.listen-play[data-state="playing"] {
  animation: pulse 1.2s infinite;
  background: linear-gradient(135deg, #2f6bff, #1a4fd6);
}
/* 播放完：浅绿背景，表示已听 */
.listen-play[data-state="played"] {
  background: linear-gradient(135deg, #d7f0e3, #b8e0cb);
  color: #1a9d57;
  box-shadow: 0 8px 20px rgba(26,157,87,.25);
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(31,200,192,.5); }
  70% { box-shadow: 0 0 0 20px rgba(31,200,192,0); }
  100% { box-shadow: 0 0 0 0 rgba(31,200,192,0); }
}
.listen-options { display: flex; flex-direction: column; gap: 8px; }
.listen-options button {
  border: 1px solid #e6e9f0; background: #fafbfd; border-radius: 12px;
  padding: 12px 14px; font-size: 14.5px; text-align: left; cursor: pointer;
  color: #1f2430; transition: all .15s; line-height: 1.4;
}
.listen-options button:active { background: #f0f4fb; }
.listen-options button.correct { background: #e7f7ee; border-color: #1a9d57; color: #1a9d57; font-weight: 700; }
.listen-options button.wrong { background: #fde8e8; border-color: #d4351c; color: #d4351c; }
.listen-feedback {
  margin-top: 12px; border-radius: 10px; padding: 10px 12px;
  font-size: 13.5px; text-align: center; font-weight: 600;
}
.listen-feedback.ok { background: #e7f7ee; color: #1a9d57; }
.listen-feedback.no { background: #fde8e8; color: #d4351c; }

/* ---------- 组句练习 ---------- */
.build-entry {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0 16px 12px;
  padding: 14px 16px;
  border-radius: 14px;
  background: linear-gradient(135deg, #f59e0b, #f97316);
  color: #fff;
  box-shadow: 0 6px 16px rgba(245,158,11,.25);
}
.build-start {
  flex-shrink: 0;
  border: 0;
  background: #fff;
  color: #f97316;
  font-size: 13.5px;
  font-weight: 700;
  padding: 9px 16px;
  border-radius: 999px;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0,0,0,.12);
  transition: transform .12s;
}
.build-start:active { transform: scale(.96); }

.build-overlay[hidden] { display: none !important; }
.build-overlay {
  position: fixed; inset: 0;
  background: rgba(20,30,50,.45);
  z-index: 200;
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
}
.build-card {
  width: 100%; max-width: 420px;
  background: #fff; border-radius: 18px;
  padding: 18px 20px 22px;
  box-shadow: 0 18px 48px rgba(0,0,0,.22);
  animation: pop .18s ease;
}
.build-hint { font-size: 12.5px; color: #9aa3b2; margin-bottom: 10px; }
.build-answer {
  min-height: 48px; border: 1px dashed #c9d2e0; border-radius: 12px;
  padding: 8px; margin-bottom: 12px; display: flex; flex-wrap: wrap; gap: 6px;
  background: #fafbfd;
}
.build-pool { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.build-answer .word, .build-pool .word {
  padding: 8px 12px; border-radius: 10px; font-size: 14.5px; cursor: pointer;
  border: 1px solid #e6e9f0; background: #fff; color: #1f2430;
  user-select: none; transition: all .12s;
}
.build-pool .word { background: #f0f4fb; border-color: #d7e0f0; }
.build-answer .word:active, .build-pool .word:active { transform: scale(.95); }
.build-answer .word.correct { background: #e7f7ee; border-color: #1a9d57; color: #1a9d57; }
.build-answer .word.wrong { background: #fde8e8; border-color: #d4351c; color: #d4351c; }
.build-actions { display: flex; gap: 8px; }
.build-btn {
  flex: 1; border-radius: 10px; padding: 11px 0; font-size: 14px; font-weight: 700;
  cursor: pointer; border: 1px solid #e6e9f0;
}
.build-btn.ghost { background: #fff; color: #6b7588; }
.build-btn.primary { background: linear-gradient(135deg, #f59e0b, #f97316); color: #fff; border: 0; }
.build-feedback {
  margin-top: 12px; border-radius: 10px; padding: 10px 12px;
  font-size: 13.5px; text-align: center; font-weight: 600;
}
.build-feedback.ok { background: #e7f7ee; color: #1a9d57; }
.build-feedback.no { background: #fde8e8; color: #d4351c; }
.build-next {
  width: 100%; margin-top: 12px; border: 1px solid #2f6bff; background: #fff;
  color: #2f6bff; border-radius: 10px; padding: 11px 0; font-size: 14.5px;
  font-weight: 700; cursor: pointer;
}

/* ---------- 自测闪卡覆盖层 ---------- */
.quiz-overlay[hidden] { display: none !important; }
.quiz-overlay {
  position: fixed; inset: 0;
  background: rgba(20,30,50,.45);
  z-index: 200;
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
}
.quiz-card {
  width: 100%; max-width: 400px;
  background: #fff; border-radius: 18px;
  padding: 18px 20px 22px;
  box-shadow: 0 18px 48px rgba(0,0,0,.22);
  animation: pop .18s ease;
}
.quiz-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.quiz-progress { font-size: 12.5px; color: #6b7588; font-weight: 600; }
.quiz-close {
  border: 0; width: 30px; height: 30px; border-radius: 50%;
  background: #f2f4f8; color: #6b7588; cursor: pointer; font-size: 14px;
}
.quiz-type-pill {
  display: inline-block; padding: 3px 10px; border-radius: 999px;
  font-size: 11.5px; font-weight: 700; margin-bottom: 12px;
  background: #ffe2e8; color: #e94c63;
}
.quiz-type-pill[data-type="word"] { background: #e3f1ff; color: #2a73d4; }
.quiz-vi {
  font-size: 20px; font-weight: 700; line-height: 1.5; color: #1f2430;
  margin-bottom: 12px; word-break: break-word; white-space: pre-wrap;
  min-height: 30px;
}
.quiz-speak {
  border: 0; background: #e8f0ff; color: #3478f6; border-radius: 10px;
  padding: 8px 14px; font-size: 13.5px; font-weight: 600; cursor: pointer;
  margin-bottom: 12px;
  transition: background .15s, color .15s;
}
/* 播放中 */
.quiz-speak[data-state="playing"] {
  background: linear-gradient(135deg, #2f6bff, #1a4fd6); color: #fff;
  animation: pulse 1.2s infinite;
}
/* 播放完 */
.quiz-speak[data-state="played"] {
  background: #d7f0e3; color: #1a9d57;
}
.quiz-answer {
  background: #f3f6fb; border-radius: 10px; padding: 12px;
  font-size: 14.5px; line-height: 1.6; color: #384056; margin-bottom: 12px;
}
.quiz-answer .answer-zh { color: #1f2430; font-weight: 600; }
.quiz-answer .answer-src { font-size: 12px; color: #9aa3b2; margin-top: 6px; }
.quiz-reveal {
  width: 100%; border: 1px solid #2f6bff; background: #fff; color: #2f6bff;
  border-radius: 12px; padding: 12px 0; font-size: 14.5px; font-weight: 700;
  cursor: pointer; transition: background .15s;
}
.quiz-reveal:hover { background: #f3f8ff; }
.quiz-rating { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.quiz-rating button {
  border: 0; border-radius: 10px; padding: 12px 0; font-size: 13.5px;
  font-weight: 700; cursor: pointer; color: #fff; transition: transform .1s;
}
.quiz-rating button:active { transform: scale(.95); }
.rate-again { background: #ef5350; }
.rate-hard  { background: #ff9800; }
.rate-good  { background: #66bb6a; }
.rate-easy  { background: #42a5f5; }
.quiz-done { text-align: center; padding: 20px 0 8px; }
.quiz-done-emoji { font-size: 48px; margin-bottom: 8px; }
.quiz-done p { margin: 4px 0; font-size: 16px; font-weight: 700; color: #1f2430; }
.quiz-done .quiz-done-sub { font-size: 12.5px; font-weight: 400; color: #9aa3b2; }
.quiz-done .quiz-start { margin-top: 16px; }

/* ---------- 空 ---------- */
.empty-state {
  text-align: center;
  padding: 80px 20px;
  color: #6b7588;
}
.empty-state .empty-emoji { font-size: 50px; margin-bottom: 10px; }
.empty-state p { margin: 4px 0; }
.empty-state .empty-sub { color: #9aa3b2; font-size: 12.5px; }

/* TabBar 样式见 tabbar.css（统一） */

/* ---------- 弹层 ---------- */
.modal-mask {
  position: fixed; inset: 0;
  background: rgba(20,30,50,0.4);
  display: grid; place-items: center;
  z-index: 100;
}
/* hidden 属性必须能盖过上面的 display:grid */
.modal-mask[hidden] { display: none !important; }
.modal {
  width: 86%;
  max-width: 360px;
  background: #fff;
  border-radius: 14px;
  padding: 18px;
  box-shadow: 0 12px 40px rgba(20,30,50,0.18);
  animation: pop .18s ease;
}
.modal h3 { margin: 0 0 12px; font-size: 16px; }
.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 2px;
  border-bottom: 1px solid #f1f4f8;
  font-size: 14px;
}
.setting-row:last-of-type { border-bottom: none; }
.setting-row select {
  border: 1px solid #e6e9ef;
  border-radius: 6px;
  padding: 4px 6px;
  background: #fff;
}
.modal-actions { display: flex; justify-content: flex-end; margin-top: 14px; gap: 10px; }
.modal-actions button {
  border: none;
  background: #3478f6;
  color: #fff;
  padding: 8px 18px;
  border-radius: 8px;
  font-size: 14px;
  cursor: pointer;
}
.modal-actions button.ghost {
  background: #fff;
  color: #6b7588;
  border: 1px solid #e6e9ef;
}

/* 编辑弹窗：纵向布局 + 输入框 */
#editModal .setting-row {
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
  padding: 10px 0;
}
#editModal .setting-row span {
  font-size: 13px;
  color: #6b7588;
}
#editModal .setting-row input {
  border: 1px solid #e6e9ef;
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 15px;
  width: 100%;
  box-sizing: border-box;
  outline: none;
}
#editModal .setting-row input:focus { border-color: #3478f6; }

@keyframes pop { from { transform: scale(0.95); opacity: 0; } to { transform: scale(1); opacity: 1; } }
