/* 单词背诵 · 全局样式（白 + 蓝浅色主题） */
:root {
  --bg: #F2F6FC;
  --card: #FFFFFF;
  --blue: #3B82F6;
  --blue-deep: #2563EB;
  --text: #1F2937;
  --text2: #6B7280;
  --line: #E3EAF5;
  --green: #10B981;
  --radius: 16px;
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body { height: 100%; }

body {
  background: #E4EAF4;
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--text);
  font-size: 16px;
}

.app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100dvh;
  background: var(--bg);
  padding-bottom: calc(84px + env(safe-area-inset-bottom));
}

/* 页面 */
.page { display: none; padding: calc(20px + env(safe-area-inset-top)) 16px 24px; }
.page.active { display: block; animation: fadein .25s ease; }
@keyframes fadein { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.page-head h1 { font-size: 26px; font-weight: 700; }
.page-head .sub { color: var(--text2); font-size: 14px; margin-top: 4px; }
.page-head { margin-bottom: 14px; }

/* 卡片 */
.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: 0 1px 3px rgba(31, 64, 122, .06);
  margin-bottom: 14px;
}

/* 今日任务卡（蓝色渐变） */
.task-card { background: linear-gradient(135deg, #4A9BFF, #2563EB); color: #fff; }
.task-card .task-label { font-size: 13px; opacity: .9; }
.task-card h2 { font-size: 22px; margin-top: 4px; }
.task-top { display: flex; justify-content: space-between; align-items: center; }

.ring {
  width: 56px; height: 56px; border-radius: 50%; flex: none;
  background: conic-gradient(#fff 0%, rgba(255,255,255,.28) 0%);
  display: flex; align-items: center; justify-content: center; position: relative;
}
.ring::before { content: ""; position: absolute; inset: 6px; background: #2E7BF0; border-radius: 50%; }
.ring span { position: relative; font-size: 13px; font-weight: 600; }

.progress { height: 8px; background: rgba(255,255,255,.25); border-radius: 99px; margin: 14px 0 8px; overflow: hidden; }
.progress .bar { height: 100%; width: 0; background: #fff; border-radius: 99px; transition: width .3s; }
.task-sub { font-size: 13px; opacity: .9; margin-bottom: 12px; }

/* 按钮 */
.btn {
  display: block; width: 100%; border: none; border-radius: 12px;
  padding: 13px; font-size: 16px; font-weight: 600; cursor: pointer; font-family: inherit;
}
.btn.primary { background: var(--blue); color: #fff; }
.btn.primary:active { background: var(--blue-deep); }
.btn.big { padding: 14px; }
.task-card .btn.primary { background: #fff; color: var(--blue-deep); }
.btn.ghost { background: transparent; color: var(--blue); border: 1px solid var(--line); }

/* 首页小卡片 */
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 14px; }
.mini { display: flex; align-items: center; gap: 10px; margin-bottom: 0; cursor: pointer; transition: transform .1s; }
.mini:active { transform: scale(.97); }
.mini-ico { font-size: 26px; }
.mini b { font-size: 20px; display: block; }
.mini p { font-size: 12px; color: var(--text2); }
.tip-card { color: var(--text2); font-size: 14px; line-height: 1.6; }

/* 搜索框 */
.search-box { margin-bottom: 14px; }
.search-box input {
  width: 100%; padding: 12px 14px; border: 1px solid var(--line);
  border-radius: 12px; background: #fff; font-size: 16px; font-family: inherit;
}
input:disabled { background: #F5F8FC; color: #9AA6B8; }

/* 空状态 */
.empty { text-align: center; padding: 48px 16px; }
.empty-ico { font-size: 56px; }
.empty-title { font-size: 18px; font-weight: 600; margin: 10px 0 4px; }
.empty-sub { color: var(--text2); font-size: 14px; margin-bottom: 20px; }
.empty .btn { margin-bottom: 10px; }

/* 介绍卡 */
.intro-card { text-align: center; padding: 24px 16px; }
.intro-ico { font-size: 44px; }
.intro-card h3 { margin: 8px 0; }
.intro-card p { color: var(--text2); font-size: 14px; line-height: 1.6; margin-bottom: 16px; }
.hl { color: var(--blue); font-weight: 600; }

/* 设置行 */
.row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 15px;
}
.row:last-of-type { border-bottom: none; }
.row b { font-weight: 600; }
.row .ok { color: var(--green); }
.row input[type=number] {
  width: 64px; padding: 6px 8px; border: 1px solid var(--line);
  border-radius: 8px; text-align: center; font-size: 16px; font-family: inherit;
}
.card .btn { margin-top: 12px; }
.card .btn:first-of-type { margin-top: 0; }

.version { text-align: center; color: #A6B2C4; font-size: 12px; margin-top: 16px; }

/* 底部标签栏 */
.tabbar {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: 0;
  width: 100%; max-width: 480px; display: flex; z-index: 10;
  background: rgba(255, 255, 255, .92);
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--line);
  padding: 8px 4px calc(8px + env(safe-area-inset-bottom));
}
.tab {
  flex: 1; background: none; border: none; cursor: pointer; font-family: inherit;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  font-size: 11px; color: var(--text2); padding: 4px 0;
}
.tab-ico { font-size: 22px; }
.tab.active { color: var(--blue); font-weight: 600; }

/* 提示浮层 */
#toast {
  position: fixed; left: 50%; top: calc(24px + env(safe-area-inset-top));
  transform: translate(-50%, -12px); z-index: 99;
  background: rgba(17, 24, 39, .92); color: #fff;
  padding: 10px 18px; border-radius: 99px; font-size: 14px;
  opacity: 0; pointer-events: none; transition: all .25s;
  max-width: 86vw; text-align: center;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

/* 四级词汇页 */
.cet4-tip { font-size: 13px; color: var(--text2); background: #EAF1FE; border-radius: 10px; padding: 10px 12px; margin-bottom: 12px; line-height: 1.5; }
.cet4-controls {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 0; position: sticky; top: 0; background: var(--bg); z-index: 5;
}
.btn.small { width: auto; padding: 8px 14px; font-size: 14px; }
.pager { display: flex; align-items: center; gap: 10px; }
.pager-btn {
  width: 34px; height: 34px; border-radius: 10px; border: 1px solid var(--line);
  background: #fff; font-size: 18px; color: var(--blue); cursor: pointer;
}
.pager-btn:disabled { opacity: .4; }
#cet4-pageinfo { font-size: 13px; color: var(--text2); min-width: 56px; text-align: center; }

.word-list { list-style: none; padding-bottom: 70px; }
.word-row {
  display: flex; align-items: flex-start; gap: 10px;
  background: var(--card); border-radius: 12px; padding: 12px; margin-bottom: 8px;
  cursor: pointer; box-shadow: 0 1px 3px rgba(31, 64, 122, .05);
}
.word-row .chk { flex: none; margin-top: 2px; }
.word-row input[type=checkbox] { display: none; }
.chk-box {
  display: flex; align-items: center; justify-content: center;
  width: 22px; height: 22px; border-radius: 50%;
  border: 2px solid #C6D2E4; color: #fff; font-size: 13px; transition: all .15s;
}
.word-row input:checked + .chk-box { background: var(--blue); border-color: var(--blue); }
.w-info { flex: 1; min-width: 0; }
.w-line1 { display: flex; align-items: baseline; gap: 8px; }
.w-line1 b { font-size: 16px; }
.w-line1 .ph { font-size: 12px; color: var(--text2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.w-trans {
  font-size: 13px; color: var(--text2); margin-top: 3px; line-height: 1.5;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}

/* 完成勾选悬浮栏（仅四级页显示） */
.finish-bar { display: none; }
#page-cet4.active .finish-bar {
  display: block; position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(62px + env(safe-area-inset-bottom));
  width: 100%; max-width: 480px; padding: 10px 16px 4px;
  background: linear-gradient(transparent, var(--bg) 45%); z-index: 8;
}

/* 确认弹窗 */
.modal-mask {
  position: fixed; inset: 0; background: rgba(15, 23, 42, .45);
  display: none; align-items: center; justify-content: center; z-index: 50; padding: 24px;
}
.modal-mask.show { display: flex; }
.modal {
  background: #fff; border-radius: 18px; padding: 22px; width: 100%;
  max-width: 320px; text-align: center; animation: fadein .2s ease;
}
.modal h3 { font-size: 17px; margin-bottom: 8px; }
.modal p { font-size: 14px; color: var(--text2); line-height: 1.6; }
.modal-btns { display: flex; gap: 10px; margin-top: 18px; }
.modal-btns .btn { margin-top: 0; }

/* 生词籍列表 */
.book-row { display: flex; background: var(--card); border-radius: 12px; padding: 12px; margin-bottom: 8px; box-shadow: 0 1px 3px rgba(31, 64, 122, .05); }
.book-row .icon-btn { background: none; border: none; font-size: 16px; cursor: pointer; padding: 2px; }
.book-row .w-line1 .icon-btn:first-of-type { margin-left: auto; }
.w-sent { font-size: 13px; color: var(--text2); margin-top: 6px; line-height: 1.5; border-top: 1px dashed var(--line); padding-top: 6px; }
.w-sent .w-sent-c { color: var(--blue); }
.w-sent.none { color: #A6B2C4; border: none; padding-top: 4px; }

/* 生词籍：管理模式 */
.head-row { display: flex; justify-content: space-between; align-items: center; }
.manage-btn {
  border: 1px solid var(--line); background: #fff; color: var(--blue);
  border-radius: 10px; padding: 6px 14px; font-size: 14px; cursor: pointer; font-family: inherit;
}
.edit-hint { font-size: 13px; color: var(--text2); }
.book-row .chk { flex: none; margin-top: 2px; }
.book-row.edit { cursor: pointer; }
.no-match { text-align: center; color: var(--text2); padding: 30px 0; font-size: 14px; list-style: none; }
#book-edit-bar { display: none; }
#book-edit-bar.show {
  display: flex; gap: 10px; position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(62px + env(safe-area-inset-bottom));
  width: 100%; max-width: 480px; padding: 10px 16px 4px;
  background: linear-gradient(transparent, var(--bg) 45%); z-index: 8;
}
#book-edit-bar .btn { flex: 1; margin-top: 0; }
.btn.danger { background: #FEE2E2; color: #DC2626; }

/* 添加单词弹窗 */
.head-btns { display: flex; gap: 8px; }
.add-modal { text-align: left; }
.add-modal h3 { text-align: center; }
.add-row { display: flex; gap: 8px; margin: 12px 0; }
.add-row input {
  flex: 1; min-width: 0; padding: 10px 12px; border: 1px solid var(--line);
  border-radius: 10px; font-size: 16px; font-family: inherit;
}
.add-row .btn { width: auto; margin: 0; }
.add-msg { font-size: 14px; color: var(--text2); padding: 8px 0; }
.add-preview { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.add-preview .w-trans { margin-top: 4px; }
#add-result { min-height: 60px; }

/* 拍照取词页 */
.ocr-photo-box {
  border: 2px dashed #C6D2E4; border-radius: var(--radius); background: #fff;
  min-height: 220px; display: flex; align-items: center; justify-content: center;
  cursor: pointer; overflow: hidden; margin-bottom: 12px;
}
.ocr-photo-box img { width: 100%; display: block; }
.ocr-placeholder { text-align: center; color: var(--text2); }
.ocr-placeholder-ico { font-size: 48px; margin-bottom: 8px; }
.ocr-placeholder p { font-size: 15px; }
.ocr-hint { font-size: 13px; color: var(--text2); text-align: center; margin: 10px 0 14px; min-height: 18px; }
#ocr-bar { display: none; }
#ocr-bar.show {
  display: flex; gap: 10px; position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(62px + env(safe-area-inset-bottom));
  width: 100%; max-width: 480px; padding: 10px 16px 4px;
  background: linear-gradient(transparent, var(--bg) 45%); z-index: 8;
}
#ocr-bar .btn { flex: 1; margin-top: 0; }

/* 设置页 OCR 密钥 */
.ocr-inputs { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.ocr-inputs input {
  padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px;
  font-size: 14px; font-family: inherit; font-family: ui-monospace, monospace;
}
.ocr-note { font-size: 12px; color: #A6B2C4; margin-top: 8px; }

/* 每日背诵任务 */
.quiz-progress { height: 8px; background: #E3EAF5; border-radius: 99px; margin-bottom: 16px; overflow: hidden; }
.quiz-progress .bar { height: 100%; width: 0; background: var(--blue); border-radius: 99px; transition: width .3s; }
.quiz-word-card { background: var(--card); border-radius: var(--radius); padding: 28px 16px; text-align: center; margin-bottom: 14px; box-shadow: 0 1px 3px rgba(31, 64, 122, .06); }
.quiz-word { font-size: 30px; font-weight: 700; }
.quiz-ph { color: var(--text2); font-size: 14px; margin-top: 6px; }
.quiz-meaning { font-size: 20px; font-weight: 600; }
.quiz-tip { color: var(--text2); font-size: 13px; margin-top: 8px; }
.quiz-opts { display: flex; flex-direction: column; gap: 10px; }
.quiz-opt {
  background: var(--card); border: 2px solid var(--line); border-radius: 12px;
  padding: 14px; font-size: 16px; cursor: pointer; font-family: inherit; color: var(--text);
  text-align: left; box-shadow: 0 1px 3px rgba(31, 64, 122, .05);
}
.quiz-opt:active { border-color: var(--blue); }
.quiz-opt.right { border-color: var(--green); background: #ECFDF5; color: #065F46; }
.quiz-opt.wrong { border-color: #F87171; background: #FEF2F2; color: #B91C1C; }
.quiz-fb { text-align: center; margin: 14px 0; font-size: 16px; }
.quiz-fb.ok { color: #065F46; }
.quiz-fb.bad { color: #B91C1C; }
.quiz-input-row { display: flex; gap: 10px; }
.quiz-input-row input { flex: 1; min-width: 0; padding: 12px 14px; border: 2px solid var(--line); border-radius: 12px; font-size: 18px; font-family: inherit; }
.quiz-input-row .btn { width: auto; }
.rev-note { font-size: 13px; color: var(--text2); margin: 8px 0 12px; }
