:root {
  --bg: #f7f5f0;
  --card: #ffffff;
  --text: #2c2a26;
  --muted: #8a8578;
  --accent: #5b6ef5;
  --accent-soft: #eef0ff;
  --good: #1fa06a;
  --good-bg: #e6f6ef;
  --bad: #e04f4f;
  --bad-bg: #fdeaea;
  --blank: #ffd76e;
  --blank-bg: #fff4d6;
  --border: #e8e4da;
  --radius: 16px;
  --shadow: 0 2px 12px rgba(60, 50, 30, 0.06);
}

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

html, body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
  font-size: 16px;
  line-height: 1.6;
}

body { min-height: 100vh; }

.screen { display: none; padding: 20px 16px 40px; max-width: 640px; margin: 0 auto; }
.screen.active { display: block; animation: fade .25s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* 头部 */
.header { text-align: center; padding: 24px 0 16px; }
.logo { font-size: 28px; letter-spacing: .5px; }
.logo span { color: var(--accent); font-weight: 600; }
.sub { color: var(--muted); margin-top: 6px; font-size: 14px; }

/* 卡片 */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
  margin-bottom: 16px;
}
.card h2 { font-size: 17px; margin-bottom: 6px; }
.hint { color: var(--muted); font-size: 13px; margin-bottom: 12px; }
.hint.small { margin-top: 10px; margin-bottom: 0; }

/* 文章列表 */
.article-list { display: flex; flex-direction: column; gap: 10px; }
.article-item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px; border: 1px solid var(--border); border-radius: 12px;
  cursor: pointer; transition: .15s; background: #fff;
}
.article-item:hover { border-color: var(--accent); background: var(--accent-soft); }
.article-item .a-icon { font-size: 24px; }
.article-item .a-body { flex: 1; }
.article-item .a-title { font-weight: 600; font-size: 15px; }
.article-item .a-meta { color: var(--muted); font-size: 12px; }
.article-item .a-go { color: var(--accent); font-weight: 600; }

/* 设置行 */
.row { display: flex; align-items: center; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid var(--border); }
.data-row { display: flex; gap: 10px; padding-top: 14px; flex-wrap: wrap; }

/* 词库管理 */
.wordbook-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.wb-entry {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  border: 1px solid var(--border); border-radius: 8px;
}
.wb-entry-name { font-weight: 600; flex: 1; }
.wb-entry-count { color: var(--muted); font-size: 13px; }
.wb-add-row { display: flex; gap: 10px; margin-bottom: 10px; }
.wb-add-row input { flex: 1; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg); color: var(--text); }

.row:last-child { border-bottom: none; }
.row label { font-size: 15px; }
select {
  font-size: 15px; padding: 8px 12px; border: 1px solid var(--border);
  border-radius: 10px; background: #fff; color: var(--text); outline: none;
}
select:focus { border-color: var(--accent); }

/* 开关 */
.switch { position: relative; display: inline-block; width: 46px; height: 26px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; inset: 0; background: #d8d3c6; border-radius: 26px; transition: .2s; cursor: pointer; }
.slider::before { content: ""; position: absolute; width: 20px; height: 20px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .2s; }
.switch input:checked + .slider { background: var(--accent); }
.switch input:checked + .slider::before { transform: translateX(20px); }

/* AI */
.ai-row { display: flex; gap: 10px; }
.ai-row input { flex: 1; font-size: 15px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; outline: none; }
.ai-row input:focus { border-color: var(--accent); }

/* 上传词表 */
.upload-card textarea {
  width: 100%; font-size: 15px; line-height: 1.7; padding: 12px;
  border: 1px solid var(--border); border-radius: 10px; outline: none;
  resize: vertical; min-height: 96px; font-family: inherit; color: var(--text);
  margin-bottom: 12px;
}
.upload-card textarea:focus { border-color: var(--accent); }
.upload-row { display: flex; gap: 10px; align-items: center; }
.file-btn { position: relative; cursor: pointer; display: inline-flex; align-items: center; gap: 4px; }
.file-btn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.upload-row .btn.primary { margin-left: auto; }
.hint.small.err { color: var(--bad); }
.hint.small.ok { color: var(--good); }

/* 按钮 */
.btn {
  font-size: 15px; padding: 10px 18px; border-radius: 10px; border: none;
  cursor: pointer; transition: .15s; font-weight: 500;
}
.btn.primary { background: var(--accent); color: #fff; }
.btn.primary:hover { background: #4a5be0; }
.btn.primary:disabled { background: #b9bfe8; cursor: not-allowed; }
.btn.ghost { background: transparent; color: var(--muted); border: 1px solid var(--border); }
.btn.ghost:hover { color: var(--text); border-color: var(--muted); }
.btn.text { background: transparent; color: var(--muted); padding: 8px; font-size: 13px; text-decoration: underline; }

.footer { text-align: center; color: var(--muted); font-size: 13px; padding-top: 8px; }

/* 学习统计 */
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 14px; }
.stat { text-align: center; padding: 10px 4px; background: var(--bg); border-radius: 12px; }
.stat-num { font-size: 22px; font-weight: 800; color: var(--accent); }
.stat-label { font-size: 12px; color: var(--muted); margin-top: 2px; }
.wrongbook-bar { display: flex; gap: 10px; }
.wrongbook-bar .btn { flex: 1; }

/* 错词本弹窗 */
.modal-mask {
  position: fixed; inset: 0; background: rgba(40,35,25,.45);
  display: none; align-items: center; justify-content: center;
  z-index: 100; padding: 20px;
}
.modal-mask.open { display: flex; animation: fade .2s ease; }
.modal {
  background: var(--card); border-radius: var(--radius); box-shadow: 0 10px 40px rgba(0,0,0,.2);
  width: 100%; max-width: 520px; max-height: 80vh; display: flex; flex-direction: column;
  padding: 20px;
}
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.modal-head h3 { font-size: 18px; }
.wrongbook-list { flex: 1; overflow-y: auto; margin: 8px 0 14px; }
.wb-item {
  display: flex; align-items: center; gap: 10px; padding: 12px 10px;
  border-bottom: 1px solid var(--border);
}
.wb-item:last-child { border-bottom: none; }
.wb-word { font-weight: 700; font-size: 16px; min-width: 88px; }
.wb-phon { color: var(--muted); font-size: 13px; }
.wb-meaning { color: var(--text); font-size: 13px; flex: 1; }
.wb-sound { background: none; border: none; cursor: pointer; font-size: 18px; padding: 4px; color: var(--accent); }
.wb-remove { background: none; border: none; cursor: pointer; color: var(--muted); font-size: 16px; padding: 4px; }
.wb-remove:hover { color: var(--bad); }
.wb-due { color: var(--bad); font-size: 12px; font-weight: 600; white-space: nowrap; }
.wb-next { color: var(--muted); font-size: 12px; white-space: nowrap; }

/* 音色选择 */
.voice-row { display: flex; align-items: center; gap: 10px; margin: 12px 0; }
.voice-label { font-size: 14px; font-weight: 600; min-width: 70px; color: var(--text); }
.voice-select {
  flex: 1; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--bg); color: var(--text); font-size: 14px;
}
.btn.small { font-size: 13px; padding: 6px 12px; }

.wb-empty { text-align: center; color: var(--muted); padding: 24px 0; }

/* 练习页 */
.header.compact { display: flex; align-items: center; justify-content: space-between; padding: 8px 0 16px; }
.progress-text { font-weight: 700; font-size: 18px; color: var(--accent); }

.article-title-box { text-align: center; margin-bottom: 16px; }
.article-title-box h2 { font-size: 20px; }
.tag { display: inline-block; background: var(--accent-soft); color: var(--accent); font-size: 12px; padding: 3px 12px; border-radius: 20px; margin-top: 6px; }

/* 进度条 */
.progress-bar-wrap {
  width: 100%; height: 8px; background: var(--border); border-radius: 6px;
  margin: 0 0 16px; overflow: hidden;
}
.progress-bar {
  height: 100%; width: 0%; background: linear-gradient(90deg, var(--accent), #7c5cff);
  border-radius: 6px; transition: width .3s ease;
}

/* 文章正文 */
.passage {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 20px 18px; margin-bottom: 16px;
}
.passage p { margin-bottom: 14px; font-size: 17px; line-height: 1.9; }
.passage p:last-child { margin-bottom: 0; }
.blank {
  display: inline-block; min-width: 72px; text-align: center;
  background: var(--blank-bg); color: #a88100;
  border-bottom: 2px dashed #d9b64a; border-radius: 4px 4px 0 0;
  padding: 0 6px; font-weight: 600; letter-spacing: 1px;
}
.blank.filled { background: var(--good-bg); color: var(--good); border-bottom: 2px solid var(--good); }
.blank.wrong { background: var(--bad-bg); color: var(--bad); border-bottom: 2px solid var(--bad); text-decoration: line-through; }
.blank.current { background: #fff3c4; color: #8a6d00; border-bottom: 2px solid var(--accent); box-shadow: 0 0 0 3px rgba(91,110,245,.15); }
.blank-meaning {
  font-size: 12px; color: var(--muted); font-weight: 400;
  letter-spacing: 0; margin: 0 2px;
}
/* 每个空旁的发音喇叭（提示入口） */
.blank-speak {
  background: none; border: none; cursor: pointer; font-size: 15px;
  padding: 2px 3px; margin-left: 3px; color: var(--accent); opacity: .65;
  vertical-align: middle; line-height: 1;
}
.blank-speak:hover { opacity: 1; transform: scale(1.15); }
/* 空格即输入框 */
input.blank {
  border: none; outline: none;
  border-bottom: 2px dashed #d9b64a;
  font-family: inherit; font-size: 16px;
  color: #8a6d00; caret-color: var(--accent);
  padding: 0 6px; min-width: 72px;
}
input.blank.current {
  background: #fff3c4; color: #8a6d00;
  border-bottom: 2px solid var(--accent);
  box-shadow: 0 0 0 3px rgba(91,110,245,.15);
}
.blank.locked { cursor: pointer; }
/* 已填的空也可点击看答案 */
.blank.filled, .blank.wrong { cursor: pointer; }
/* 点击查看答案时的高亮闪烁 */
.blank.flash { animation: blankflash .9s ease; }
@keyframes blankflash {
  0% { box-shadow: 0 0 0 4px rgba(91,110,245,.5); }
  100% { box-shadow: 0 0 0 0 rgba(91,110,245,0); }
}
/* 练习页双栏：宽屏文章在左、答题面板 sticky 在右；窄屏自动回退为上下布局 */
.practice-cols { display: block; }
@media (min-width: 1000px) {
  #practice { max-width: 1100px; }
  .practice-cols { display: flex; gap: 18px; align-items: flex-start; }
  .practice-main { flex: 1; min-width: 0; }
  .practice-main .results-panel { max-width: 640px; margin: 0 auto; }
  .answer-panel { width: 330px; flex-shrink: 0; position: sticky; top: 14px; max-height: calc(100vh - 28px); overflow-y: auto; }
}

.panel-row2 { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 10px; }
.panel-row2 .btn.text { white-space: nowrap; }

/* 朗读控制按钮组 */
.speak-controls { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; }
.sc-btn {
  font-size: 13px; padding: 9px 8px; border-radius: 9px;
  border: 1px solid var(--border); background: var(--bg); color: var(--text);
  cursor: pointer; transition: .15s; white-space: nowrap;
}
.sc-btn:hover { border-color: var(--accent); color: var(--accent); }
#auto-speak.on { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); font-weight: 700; }
#speak-stop.reading { border-color: var(--bad); color: var(--bad); font-weight: 700; }

/* 可点击单词 */
.pw { cursor: pointer; border-radius: 3px; transition: background .1s, color .1s; }
.pw:hover { background: var(--accent-soft); color: var(--accent); }
.passage.cn-mode .pw:hover { background: rgba(61, 220, 132, .16); color: #3ddc84; }

/* 朗读进度：已读完的内容加阴影（变淡 + 柔和灰底），让人一眼看出读到哪了 */
.tok, .blank { transition: color .2s ease, background .2s ease, box-shadow .2s ease; border-radius: 4px; }
.tok.read, .blank.read {
  color: var(--muted);
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, .10);
  background: rgba(0, 0, 0, .045);
}
.tok.read .pw { color: inherit; }
/* 中文深色卡片里，已读内容用半透明白淡化 */
.passage.cn-mode .tok.read, .passage.cn-mode .blank.read {
  color: rgba(255, 255, 255, .42);
  box-shadow: inset 0 -2px 0 rgba(255, 255, 255, .10);
  background: rgba(255, 255, 255, .06);
}


/* 点词查词卡片 */
.word-card {
  position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%);
  width: min(440px, calc(100vw - 32px));
  background: var(--card); border: 1px solid var(--border); border-radius: 14px;
  box-shadow: 0 10px 40px rgba(0,0,0,.2); padding: 14px 16px; z-index: 90;
  display: none;
}
.word-card.open { display: block; animation: fade .18s ease; }
.wc-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 6px; }
.wc-word { font-size: 20px; font-weight: 700; color: var(--text); }
.wc-phon { color: var(--muted); font-size: 14px; flex: 1; }
.wc-close { background: none; border: none; cursor: pointer; color: var(--muted); font-size: 15px; padding: 2px 6px; }
.wc-close:hover { color: var(--bad); }
.wc-body { max-height: 180px; overflow-y: auto; margin-bottom: 10px; }
.wc-def { font-size: 13.5px; line-height: 1.65; color: var(--text); padding: 4px 0; border-bottom: 1px dashed var(--border); }
.wc-def:last-child { border-bottom: none; }
.wc-def b { color: var(--accent); font-weight: 600; }
.wc-def i { color: var(--muted); font-style: normal; }
.wc-loading { color: var(--muted); font-size: 13px; padding: 6px 0; }
.wc-btns { display: flex; gap: 10px; }

/* 答题面板 */
.answer-panel {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px 18px;
}
.question-box { display: flex; gap: 12px; margin-bottom: 12px; }
.q-index {
  flex-shrink: 0; width: 34px; height: 34px; border-radius: 50%;
  background: var(--accent); color: #fff; display: flex; align-items: center; justify-content: center;
  font-weight: 700;
}
.q-info { flex: 1; }
.q-hint { font-size: 14px; color: var(--accent); font-weight: 600; margin-bottom: 2px; }
.q-sentence { font-size: 14px; color: var(--muted); }

.input-row { display: flex; gap: 10px; }
.input-row input {
  flex: 1; font-size: 18px; padding: 12px 14px; letter-spacing: 1px;
  border: 2px solid var(--border); border-radius: 10px; outline: none; text-transform: lowercase;
}
.input-row input:focus { border-color: var(--accent); }
.input-row input.correct { border-color: var(--good); background: var(--good-bg); }
.input-row input.incorrect { border-color: var(--bad); background: var(--bad-bg); }

#reveal { margin-top: 4px; }
.feedback { margin-top: 10px; font-size: 14px; min-height: 20px; }
.feedback.ok { color: var(--good); }
.feedback.no { color: var(--bad); }
.kbd-hint { margin-top: 8px; font-size: 12px; color: var(--muted); text-align: center; }

/* 结果 */
.results-panel {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 28px 20px; text-align: center;
}
.score-ring {
  width: 120px; height: 120px; border-radius: 50%; margin: 0 auto 16px;
  display: flex; align-items: center; justify-content: center;
  font-size: 34px; font-weight: 800;
}
.score-ring.great { background: var(--good-bg); color: var(--good); box-shadow: inset 0 0 0 6px var(--good); }
.score-ring.good { background: var(--good-bg); color: var(--good); box-shadow: inset 0 0 0 6px #79c9a3; }
.score-ring.mid { background: var(--blank-bg); color: #b58a00; box-shadow: inset 0 0 0 6px #e6c766; }
.score-ring.low { background: var(--bad-bg); color: var(--bad); box-shadow: inset 0 0 0 6px #ee9a9a; }
#score-title { font-size: 20px; margin-bottom: 4px; }
#score-sub { color: var(--muted); font-size: 14px; margin-bottom: 18px; }

/* 听写模式 */
.dictation-box {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 32px 24px; text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 16px;
}
.dict-word { font-size: 16px; color: var(--muted); min-height: 24px; }
.dict-play-btn { font-size: 22px; padding: 14px 28px; }
.dict-input {
  width: 100%; max-width: 320px; text-align: center; font-size: 22px; letter-spacing: 2px;
  padding: 12px 14px; border: 2px solid var(--border); border-radius: 10px;
  background: var(--bg); color: var(--text);
}
.dict-input:focus { border-color: var(--accent); outline: none; }
.dict-btns { display: flex; gap: 10px; }


.review-list { text-align: left; margin-bottom: 20px; }
.review-item {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border); font-size: 14px;
}
.review-item:last-child { border-bottom: none; }
.r-line { display: flex; align-items: center; gap: 8px; }
.review-item .r-ico { font-size: 18px; }
.review-item .r-word { font-weight: 600; }
.review-item .r-wrong { color: var(--bad); text-decoration: line-through; font-size: 13px; }
.review-item .r-arrow { color: var(--muted); }
.review-item .r-right { color: var(--good); font-weight: 600; }
.r-detail { color: var(--muted); font-size: 12.5px; margin: 2px 0 0 26px; }
.r-example { color: #6b7a8f; font-size: 12.5px; font-style: italic; margin: 2px 0 0 26px; }

.btn-row { display: flex; gap: 10px; justify-content: center; }

@media (max-width: 400px) {
  .passage p { font-size: 16px; }
}

/* ===== 中文语境挖空模式（秒记单词风格：深色沉浸卡片 + 绿色单词）===== */
.passage.cn-mode {
  background: linear-gradient(180deg, #232830 0%, #191d24 100%);
  border-color: #2e3440;
  color: #ece9e2;
}
.passage.cn-mode p {
  font-size: 20px;
  line-height: 2.4;
  color: #ece9e2;
  font-weight: 500;
  letter-spacing: .4px;
}
.passage.cn-mode .blank {
  background: transparent;
  color: #8b93a3;
  border-bottom: 2px dashed #4a5260;
}
.passage.cn-mode .blank.locked { color: #6b7280; }
/* 填对的词：绿色（视频同款） */
.passage.cn-mode .blank.filled {
  background: transparent;
  color: #3ddc84;
  border-bottom: 2px solid #3ddc84;
  font-weight: 700;
}
/* 填错的词（自动纠错后保留原答案） */
.passage.cn-mode .blank.wrong {
  background: transparent;
  color: #ff6b6b;
  border-bottom: 2px solid #ff6b6b;
  text-decoration: line-through;
}
/* 当前输入的空 */
.passage.cn-mode .blank.current,
.passage.cn-mode input.blank.current {
  background: rgba(61, 220, 132, .12);
  color: #3ddc84;
  caret-color: #3ddc84;
  border-bottom: 2px solid #3ddc84;
  box-shadow: 0 0 0 3px rgba(61, 220, 132, .18);
}
.passage.cn-mode input.blank {
  background: transparent;
  border-bottom: 2px dashed #4a5260;
  color: #3ddc84;
  font-size: 19px;
  font-weight: 600;
}
/* 释义括号：弱化的浅灰（视频里 (有凝聚力的) 的样式） */
.passage.cn-mode .blank-meaning {
  color: #a8b0bf;
  font-size: 15px;
  font-weight: 400;
}
.passage.cn-mode .blank-speak { color: #3ddc84; opacity: .7; }
