/* style.css — 儿童友好、大按钮、简洁 */
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; -webkit-user-select: none; user-select: none; }
/* 输入类控件仍允许选中文字，否则无法编辑/退格 */
input, textarea, select { -webkit-user-select: text; user-select: text; }
body {
  font-family: "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  background: #e3eede; color: #333;
}
/* 护眼大背景：低饱和淡芽绿渐变 + 柔和光斑与细点装饰，不干扰内容阅读 */
body::before {
  content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(circle at 12% 8%, rgba(255,255,255,.5) 0 46px, transparent 47px),
    radial-gradient(circle at 88% 14%, rgba(200,222,190,.55) 0 64px, transparent 65px),
    radial-gradient(circle at 80% 84%, rgba(255,255,255,.38) 0 78px, transparent 79px),
    radial-gradient(circle at 14% 78%, rgba(188,214,180,.5) 0 54px, transparent 55px),
    radial-gradient(rgba(255,255,255,.22) 1.4px, transparent 1.5px),
    linear-gradient(160deg, #e9f2e4 0%, #ddebd6 55%, #d6e6d0 100%);
  background-size: auto, auto, auto, auto, 26px 26px, auto;
}
#app { max-width: 640px; margin: 0 auto; padding: 12px 16px 40px; }
.hidden { display: none !important; }
.view { animation: fadein .18s ease; }
@keyframes fadein { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; } }

.topbar { display: flex; align-items: center; gap: 10px; padding: 10px 0 16px; }
.topbar h1 { font-size: 22px; }
/* 返回/退出按钮统一靠右上角（DOM 在标题前，用 order 排到末尾并右对齐） */
.topbar .back { order: 2; margin-left: auto; }
/* 词库页：添加课外词按钮在返回左侧，整体靠右 */
#view-words .topbar #btn-add-word { order: 1; margin: 0 0 0 auto; font-size: 14px; padding: 7px 14px; border-radius: 20px; }
#view-words .topbar .back { order: 2; margin-left: 8px; }
/* 首页底部作者署名 */
.author { text-align: center; font-size: 13px; font-weight: 700; color: #7ba07e; letter-spacing: 1px; margin: 26px 0 8px; }
.back { border: none; background: #dde9f7; color: #3572c5; font-size: 16px; padding: 6px 14px; border-radius: 20px; cursor: pointer; }

/* 首页等级卡：徽章 + 等级名 + 进度条，激励升级；宽度与统计/按钮网格对齐 */
.level-card { display: flex; align-items: center; gap: 12px; background: #fff; border-radius: 14px; padding: 10px 14px; box-shadow: 0 2px 6px rgba(60,110,190,.08); width: min(100%, 380px); margin: 0 auto 10px; }
.level-card .lv-badge { font-size: 30px; line-height: 1; }
.level-card .lv-main { flex: 1; min-width: 0; }
.level-card .lv-top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.level-card .lv-name { font-size: 15px; font-weight: 700; color: #3572c5; }
.level-card .lv-count { font-size: 12px; color: #8aa; white-space: nowrap; }
.level-card .lv-bar { height: 8px; border-radius: 5px; background: #e8f0e4; margin: 6px 0 4px; overflow: hidden; }
.level-card .lv-bar i { display: block; height: 100%; border-radius: 5px; background: linear-gradient(90deg, #7fc27f, #2e7d43); transition: width .4s; }
.level-card .lv-next { font-size: 12px; color: #7f96a5; }
/* 升级推荐行：推荐复习单元 + 直达按钮；收尾时列出遗漏词 */
.level-card .lv-tip { font-size: 12px; color: #6b8bb5; margin-top: 5px; line-height: 1.55; }
.level-card .lv-tip b { color: #3572c5; }
.level-card .lv-tip.lv-tail { color: #7a5b00; background: #fff8e0; border-radius: 8px; padding: 4px 8px; }
.level-card .lv-jump { border: none; background: #eaf3ff; color: #3572c5; font-size: 12px; font-weight: 700; padding: 3px 10px; border-radius: 12px; cursor: pointer; }
.level-card .lv-tail .lv-jump { margin-top: 6px; }

/* 首页统计：一行三栏（今日掌握/已掌握/错题本）；宽度与下方应用按钮网格对齐 */
.stats-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 0 auto 18px; width: min(100%, 380px); }
.stat-card { background: #fff; border-radius: 14px; padding: 12px 4px; text-align: center; box-shadow: 0 2px 6px rgba(60,110,190,.08); }
.stat-card .num { font-size: 24px; font-weight: 700; color: #3572c5; }
/* 统计数字配色：对/已掌握绿，错/错题本红（与成绩页同色） */
.stat-card .num .g, .stat-card .num.g { color: #2e7d43; }
.stat-card .num .r, .stat-card .num.r { color: #c03535; }
.stat-card .lab { font-size: 12px; color: #8aa; margin-top: 2px; }

/* 首页 6 个入口：2×3 方格，按钮 1:1，宽屏居中留边 */
.app-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; width: min(100%, 380px); margin: 0 auto 18px; }
.app-grid button { aspect-ratio: 1 / 1; border: none; border-radius: 18px; color: #fff; font-weight: 700; cursor: pointer; box-shadow: 0 4px 10px rgba(0,0,0,.10); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; }
.app-grid button:active { transform: scale(.97); }
.app-grid .ico { font-size: 34px; }
.app-grid .txt { font-size: 17px; }
.mode-btn.preview { background: #58b368; }
.mode-btn.learn  { background: #3572c5; }
.mode-btn.review { background: #e8833a; }
.home-link.words { background: #7b5ec9; }
.home-link.notebook { background: #e05a5a; }
.home-link.settings { background: #6b8bb5; }

/* 卡片 */
.big-card, .question-card {
  background: #fff; border-radius: 20px; padding: 34px 20px; text-align: center;
  box-shadow: 0 4px 14px rgba(60,110,190,.10); margin: 10px 0 16px; min-height: 150px;
}
.card-word, .q-prompt { font-size: 40px; font-weight: 800; color: #2c3e50; word-break: break-all; }
/* 出题页题目行：题目靠左、喇叭靠右，同一行垂直居中 */
.q-prompt-row { display: flex; align-items: center; justify-content: center; gap: 12px; }
.q-prompt-row .q-prompt { flex: 1; text-align: left; }
.card-phonetic, .q-phonetic { font-size: 20px; color: #8aa; margin-top: 8px; }
.q-phonetic { text-align: left; } /* 跟题目一起左对齐，对齐题目行左边缘 */
.card-meaning { font-size: 26px; color: #58b368; margin-top: 14px; font-weight: 700; }
.card-progress, .quiz-progress { text-align: center; color: #8aa; font-size: 14px; margin-bottom: 8px; }

.speak { border: none; background: #eaf3ff; font-size: 28px; width: 64px; height: 64px; border-radius: 50%; cursor: pointer; flex: none; }
.speak-inline { width: 48px; height: 48px; font-size: 22px; } /* 题目右侧的喇叭：略小，不依挤占题目空间 */
.quiz-actions { display: flex; justify-content: center; gap: 14px; margin: 8px 0 16px; }

/* 选项 */
.q-options { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.opt-btn { border: 2px solid #dde9f7; background: #fff; border-radius: 14px; padding: 14px 8px; font-size: 18px; cursor: pointer; }
.opt-btn.picked { border-color: #3572c5; background: #eaf3ff; font-weight: 700; } /* 选中待提交：主色调高亮，尚未判分 */
.opt-btn.correct { border-color: #58b368; background: #eafaf0; }
.opt-btn.wrong { border-color: #e05a5a; background: #fdecec; }
.opt-btn:disabled { cursor: default; opacity: .9; }

/* 拼写 */
#q-spell { display: flex; gap: 10px; margin-bottom: 14px; }
#spell-input { flex: 1; font-size: 20px; padding: 12px 14px; border: 2px solid #dde9f7; border-radius: 14px; outline: none; }
#spell-input:focus { border-color: #3572c5; }

.q-feedback { text-align: center; font-size: 20px; font-weight: 700; padding: 12px; border-radius: 14px; margin-bottom: 12px; }
.q-feedback.ok { background: #eafaf0; color: #2e7d43; }
.q-feedback.no { background: #fdecec; color: #c03535; }

button.primary { border: none; background: #3572c5; color: #fff; font-size: 18px; padding: 12px 26px; border-radius: 14px; cursor: pointer; display: block; margin: 10px auto 0; }
button.primary.large { font-size: 22px; padding: 16px 40px; }
button.primary:active { transform: scale(.97); }
button.danger { border: none; background: #e05a5a; color: #fff; font-size: 16px; padding: 12px 20px; border-radius: 12px; cursor: pointer; width: 100%; }

/* 单词列表 */
/* 单词列表：页内不滚动，列表区内部滚动（词库页 + 错题本页） */
#view-words, #view-notebook { height: calc(100vh - 52px); display: flex; flex-direction: column; }
@supports (height: 100dvh) { #view-words, #view-notebook { height: calc(100dvh - 52px); } }
#view-words .words-toolbar, #view-words .topbar, #view-notebook .topbar, #view-notebook .hint { flex-shrink: 0; }
#view-words .word-list, #view-notebook .word-list { flex: 1; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; padding-bottom: 8px; padding-right: 8px;}
.word-list { list-style: none; }
.word-list li { background: #fff; border-radius: 14px; padding: 12px 14px; margin-bottom: 8px; display: flex; align-items: center; gap: 10px; box-shadow: 0 1px 4px rgba(60,110,190,.08); }
.word-list .w-en { font-size: 19px; font-weight: 700; color: #2c3e50; }
.word-list .w-ph { font-size: 14px; color: #8aa; }
.word-list .w-cn { flex: 1; font-size: 16px; color: #555; }
.word-list .w-tag { font-size: 12px; color: #3572c5; background: #eaf3ff; border-radius: 8px; padding: 2px 8px; white-space: nowrap; }
/* 列表条目：竖排多行，窄屏不出水平滚动条（词库 + 错题本） */
#words-list li, #notebook-list li { flex-direction: column; align-items: stretch; gap: 4px; }
#words-list .nb-row, #notebook-list .nb-row { display: flex; align-items: center; gap: 8px; min-width: 0; }
#words-list .w-cn, #notebook-list .w-cn { flex: none; }
#notebook-list .nb-unit { margin-left: auto; }
/* 喇叭（及其后的删除钮）靠第一行右缘 */
#words-list .nb-row:first-child .spk, #notebook-list .nb-row:first-child .spk { margin-left: auto; }
.word-list .w-err { font-size: 13px; color: #e05a5a; white-space: nowrap; }
.icon-btn { border: none; background: none; font-size: 20px; cursor: pointer; padding: 2px 6px; }

/* 表单 / 设置 */
select { font-size: 16px; padding: 8px 10px; border: 2px solid #dde9f7; border-radius: 10px; background: #fff; margin: 6px 0; }
.form-card { background: #fff; border-radius: 16px; padding: 16px; margin: 12px 0; display: flex; flex-direction: column; gap: 10px; }
.form-card input { font-size: 16px; padding: 10px 12px; border: 2px solid #dde9f7; border-radius: 10px; }
/* 添加课外词：保存/取消同行等宽 */
.form-btns { display: flex; gap: 10px; }
.form-btns > button { flex: 1; margin: 0; padding: 12px 0; }
button.ghost { border: 2px solid #c9d8ee; background: #fff; color: #5b7ba6; font-size: 18px; border-radius: 14px; cursor: pointer; }
button.ghost:active { transform: scale(.97); }
.words-toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 10px; }
.words-toolbar select { flex: 1; min-width: 0; }
.words-toolbar input[type="search"] { flex: 1.4; min-width: 0; font-size: 15px; padding: 8px 12px; border: 2px solid #dde9f7; border-radius: 12px; background: #fff; }
.words-toolbar input[type="search"]:focus { outline: none; border-color: #3572c5; }
.wb-empty { justify-content: center; color: #8aa; font-size: 15px; padding: 24px 0 !important; }
.settings-form { background: #fff; border-radius: 16px; padding: 18px; }
.setting-row { display: flex; flex-direction: column; gap: 4px; margin-bottom: 16px; }
.setting-row label { font-weight: 700; font-size: 15px; color: #2c3e50; }
.setting-row small { color: #8aa; }
.file-label { border: 2px dashed #3572c5; color: #3572c5; border-radius: 14px; padding: 12px; text-align: center; cursor: pointer; margin-top: 8px; }
/* 备份导出/导入左右等宽排版 */
.btn-pair { display: flex; gap: 10px; margin-top: 8px; }
.btn-pair > button.primary { flex: 1; margin: 0; padding: 12px 0; font-size: 16px; }
.btn-pair > .file-label { flex: 1; margin-top: 0; display: flex; align-items: center; justify-content: center; font-size: 16px; padding: 12px 0; }

/* 出题范围勾选列表 */
.scope-quick { display: flex; align-items: center; gap: 8px; margin: 4px 0; }
.scope-quick button { border: 1px solid #3572c5; background: #fff; color: #3572c5; border-radius: 10px; font-size: 14px; padding: 6px 14px; cursor: pointer; }
.scope-list { max-height: 280px; overflow-y: auto; border: 2px solid #dde9f7; border-radius: 12px; background: #fff; margin-top: 4px; }
.scope-group + .scope-group { border-top: 1px solid #eef3fa; }
.scope-grouptitle { position: sticky; top: 0; background: #f0f6ff; color: #3572c5; font-size: 14px; font-weight: 700; padding: 8px 14px; border-bottom: 1px solid #e4eefa; }
.scope-items { display: grid; grid-template-columns: repeat(3, 1fr); }
.scope-item { display: flex; align-items: center; gap: 8px; padding: 12px 14px; font-size: 16px; cursor: pointer; border-bottom: 1px solid #f3f7fc; user-select: none; }
.scope-item input { width: 20px; height: 20px; accent-color: #3572c5; }
.hint { color: #8aa; font-size: 14px; margin: 8px 0; }
/* 模式说明行：标题下补充玩法与状态变化条件 */
.mode-hint { color: #7f96a5; font-size: 13px; line-height: 1.5; margin: -6px 0 12px; }
.warning { background: #fff3cd; color: #7a5b00; border-radius: 12px; padding: 10px 14px; font-size: 14px; margin-bottom: 10px; }
.result-numbers { display: flex; justify-content: center; gap: 26px; margin: 20px 0; font-size: 18px; }
.result-numbers b { font-size: 34px; }
.result-numbers .ok { color: #2e7d43; } .result-numbers .no { color: #c03535; }

/* 拼写内置键盘：固定在屏幕底部，横向占满 */
.spell-display {
  min-height: 54px; background: #fff; border: 2px solid #dde9f7; border-radius: 14px;
  display: flex; align-items: center; justify-content: center; text-align: center;
  font-size: 26px; font-weight: 800; letter-spacing: 3px; color: #2c3e50;
  padding: 8px 12px; margin-bottom: 12px; word-break: break-all;
}
.spell-display .ph { font-size: 15px; color: #8aa; font-weight: 400; letter-spacing: 0; }
.spell-display .sp { display: inline-block; width: 14px; } /* 空格占位：固定宽度空白，保证连续空格也能看出间隔 */
.kbd {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 90;
  max-width: 640px; margin: 0 auto; padding: 10px 6px calc(10px + env(safe-area-inset-bottom));
  background: #d8e6d4; box-shadow: 0 -6px 18px rgba(40, 60, 45, .12);
  display: flex; flex-direction: column; gap: 7px; user-select: none;
}
.kbd-row { display: flex; justify-content: center; gap: 5px; }
.kbd-letters { flex: 1; min-width: 0; display: grid; grid-template-columns: repeat(9, minmax(0, 1fr)); gap: 5px; }
.kbd-side { display: flex; flex-direction: column; gap: 5px; width: 16%; }
.kbd-side .kbd-key { flex: 1; padding: 0; }
.kbd-key {
  border: none; background: #fff; color: #2c3e50; font-size: 19px; font-weight: 600;
  padding: 13px 0; border-radius: 10px; box-shadow: 0 2px 0 #b3c8ac; cursor: pointer; flex: 1; min-width: 0;
}
.kbd-letters .kbd-key { padding: 12px 0; font-size: 18px; }
.kbd-key:active { transform: translateY(2px); box-shadow: none; }
.kbd-key.act { background: #eef4fb; color: #3572c5; font-size: 14px; }
.kbd-key.punct { font-size: 19px; font-weight: 700; }
.kbd-key.space { background: #eef4fb; color: #3572c5; font-size: 15px; font-weight: 600; padding: 11px 0; flex: 4; }
.kbd-key.enter { background: #3572c5; color: #fff; font-size: 17px; font-weight: 700; padding: 14px 0; }

/* 自定义弹窗 */
.modal-overlay {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(30, 45, 70, .45);
  display: flex; align-items: center; justify-content: center;
  animation: fadein .15s ease;
}
.modal-box {
  background: #fff; border-radius: 22px; padding: 28px 22px 20px;
  width: min(86%, 360px); box-shadow: 0 12px 40px rgba(0, 0, 0, .18);
  animation: pop .18s ease;
}
@keyframes pop { from { transform: scale(.86); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.modal-title { font-size: 19px; font-weight: 800; color: #2c3e50; text-align: center; margin-bottom: 16px; }
/* 对话框内的表单复用 form-card 结构，但去掉卡片外壳 */
.modal-box .form-card { background: none; padding: 0; margin: 0; }
.modal-msg { font-size: 17px; line-height: 1.7; text-align: center; color: #2c3e50; margin-bottom: 22px; white-space: pre-line; }
.modal-btns { display: flex; gap: 12px; }
.modal-btn { flex: 1; border: none; border-radius: 14px; font-size: 17px; padding: 12px 0; cursor: pointer; }
.modal-btn.ok { background: #3572c5; color: #fff; font-weight: 700; }
.modal-btn.cancel { background: #eef2f8; color: #667; }
.modal-btn:active { transform: scale(.97); }
/* 离线音频：下载进度条 + 清空按钮(危险色描边) */
.audio-bar { height: 10px; border-radius: 5px; background: #e8f0e4; overflow: hidden; margin-bottom: 22px; }
.audio-bar > i { display: block; height: 100%; width: 0; border-radius: 5px; background: linear-gradient(90deg, #7fc27f, #2e7d43); transition: width .3s; }
button.ghost.danger-ghost { border-color: #f0b8b8; color: #c03535; }
.btn-pair > button.ghost { flex: 1; margin: 0; padding: 12px 0; font-size: 16px; }
