:root {
  --bg: #f5f6f8;
  --card: #ffffff;
  --line: #e4e4df;
  --fg: #1b1b1b;
  --fg2: #6d6d67;
  --fg3: #a0a09a;
  --brand: #185fa5;
  --brand2: #0c447c;
  --brand-soft: #e8f0fb;
  --ok: #1d9e75;
  --ok-soft: #e4f4ec;
  --bad: #d85a30;
  --bad-soft: #fcecea;
  --warn: #ba7517;
  --warn-soft: #faeeda;
  --radius: 12px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16161a;
    --card: #1e1e23;
    --line: #33333a;
    --fg: #ececf0;
    --fg2: #a6a6ae;
    --fg3: #74747c;
    --brand: #6fa9e0;
    --brand2: #a9cdf0;
    --brand-soft: #1d2a38;
    --ok: #5fd0a6;
    --ok-soft: #16302a;
    --bad: #f0906c;
    --bad-soft: #34211b;
    --warn: #e0b268;
    --warn-soft: #332a17;
  }
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
  background: var(--bg); color: var(--fg);
  font-size: 15px; line-height: 1.6;
  padding-bottom: 72px;
}
.wrap { max-width: 760px; margin: 0 auto; padding: 16px 14px 24px; }

/* 顶栏 */
header {
  position: sticky; top: 0; z-index: 20;
  background: var(--bg); border-bottom: 1px solid var(--line);
  padding: 10px 0 12px;
}
header .wrap { padding-bottom: 0; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
h1 { font-size: 17px; font-weight: 600; }
.sub { font-size: 12px; color: var(--fg2); }

/* 帮助卡片 */
.helpcard { border-left: 3px solid var(--brand); }
.helpcard .h { font-size: 14px; font-weight: 500; margin: 0 0 6px; }
.helpcard ul { margin: 0; padding-left: 18px; }
.helpcard li { font-size: 13px; color: var(--fg2); line-height: 1.75; margin: 4px 0; }
.helpcard li b { color: var(--fg); }

/* 底部导航 */
/* 底部导航：**永远等宽**（1fr 均分），装不下就让文字换行，不横滑。
   —— 原来是 flex + "题型多时改成横向滚动"，结果每一项宽度跟着文字长短走，
      有的宽有的窄，看着不齐（用户指出"图标要均匀分布"）。
      改成等宽网格后，不管这个考试有 2 种还是 9 种题型都整齐。 */
nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  background: var(--card); border-top: 1px solid var(--line);
  display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
  padding: 6px 2px calc(6px + env(safe-area-inset-bottom));
}
nav button {
  background: none; border: 0; cursor: pointer; min-width: 0;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  font-size: 10.5px; line-height: 1.15; color: var(--fg3);
  padding: 6px 1px; font-family: inherit; text-align: center;
  overflow-wrap: anywhere;
}
nav button .ic { font-size: 17px; line-height: 1; filter: grayscale(1) opacity(.55); }
nav button.on { color: var(--brand); font-weight: 500; }
nav button.on .ic { filter: none; }

/* 卡片 */
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px; margin-bottom: 12px;
}
.card.tight { padding: 12px 14px; }
.ttl { font-size: 16px; font-weight: 600; margin-bottom: 2px; }
.meta { font-size: 12px; color: var(--fg2); margin-bottom: 12px; line-height: 1.5; }
.sec { font-size: 14px; font-weight: 600; margin: 20px 0 8px; }
.sec:first-child { margin-top: 0; }

/* 按钮 */
button.btn, a.btn {
  display: inline-block; padding: 11px 20px; border-radius: 10px;
  background: var(--brand); color: #fff; border: 0; cursor: pointer;
  font-size: 15px; font-family: inherit; text-decoration: none; text-align: center;
}
button.btn:active { opacity: .85; }
button.ghost, a.ghost {
  background: var(--card); color: var(--brand); border: 1px solid var(--line);
}
button.sm { padding: 8px 14px; font-size: 13px; border-radius: 8px; }
button:disabled { opacity: .45; cursor: not-allowed; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-top: 14px; }

/* 折叠块（「我的考试」里的试卷结构表 —— 内容长，默认收起来） */
details.fold > summary {
  cursor: pointer; list-style: none;
  font-size: 12.5px; font-weight: 600; color: var(--brand); line-height: 1.5;
}
details.fold > summary::-webkit-details-marker { display: none; }
details.fold > summary::before {
  content: '▸'; font-size: 11px; color: var(--fg3); margin-right: 5px;
}
details.fold[open] > summary::before { content: '▾'; }
details.fold[open] > summary { margin-bottom: 10px; }

/* 试卷结构表（选考试 / 我的考试）
   table-layout:fixed 是**防御性**的：三列宽度确定，长标签一律换行，
   无论标签多长、多不可断行都不会把表撑出容器。
   （排查记录：曾以为 390px 下「分值」列被挤到屏幕外，其实是
     --window-size 对 --screenshot / --dump-dom 都不生效，
     页面按 504px 布局、截图只截了左边 390px。真机 390px 下实测
     card 14–361 / table 29–346，没有任何元素越界。） */
table.pt { width: 100%; border-collapse: collapse; font-size: 12.5px; table-layout: fixed; }
table.pt th {
  text-align: left; font-weight: 600; color: var(--fg3); font-size: 11.5px;
  padding: 0 0 6px; border-bottom: 1px solid var(--line); white-space: nowrap;
}
table.pt th.num, table.pt td.num { text-align: right; width: 40px; white-space: nowrap; }
table.pt td { padding: 7px 0; border-bottom: 1px solid var(--line); vertical-align: top;
              overflow-wrap: anywhere; }
table.pt td:first-child { padding-right: 8px; }
table.pt tr:last-child td { border-bottom: 0; }
table.pt td b { font-weight: 600; }
table.pt td.num { color: var(--fg); font-variant-numeric: tabular-nums; }
table.pt td.num i { color: var(--fg3); font-style: normal; }
table.pt tfoot td {
  border-bottom: 0; border-top: 1px solid var(--line);
  padding-top: 8px; font-weight: 600; color: var(--fg2);
}
table.pt .blk {
  display: inline-block; font-style: normal; font-size: 10.5px; margin-left: 6px;
  color: var(--brand); background: var(--brand-soft); border-radius: 5px; padding: 1px 5px;
  vertical-align: 1px; max-width: 100%; overflow-wrap: anywhere;
}
table.pt .pr { display: block; color: var(--fg3); font-size: 11.5px; margin-top: 2px; line-height: 1.45; }
/* 表格外也会用（比如"试卷结构"标题下面的来源说明） */
.pr { display: block; color: var(--fg3); font-size: 11.5px; margin-top: 2px; line-height: 1.45; }

/* 首页 */
.stat-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 10px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.stat .k { font-size: 12px; color: var(--fg2); margin-bottom: 4px; }
.stat .v { font-size: 22px; font-weight: 600; font-variant-numeric: tabular-nums; }
.stat .v small { font-size: 12px; font-weight: 400; color: var(--fg2); }
.entry { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 10px; }
.entry a {
  display: block; background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px; text-decoration: none; color: var(--fg);
}
.entry a .n { font-size: 15px; font-weight: 500; margin-bottom: 3px; }
.entry a .d { font-size: 12px; color: var(--fg2); }

/* 题型选择 */
.tabs { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 12px; }
.tabs::-webkit-scrollbar { display: none; }
.tab {
  flex: 0 0 auto; padding: 9px 15px; border-radius: 999px; cursor: pointer;
  background: var(--card); border: 1px solid var(--line);
  font-size: 14px; font-family: inherit; color: var(--fg); white-space: nowrap;
}
.tab.on { background: var(--brand); color: #fff; border-color: var(--brand); }
.tab .n { font-size: 11px; opacity: .65; margin-left: 3px; }

/* 正文 */
.passage { font-size: 15.5px; line-height: 1.9; }
.passage p { margin-bottom: 11px; }
.para { margin-bottom: 12px; font-size: 15.5px; line-height: 1.85; }
.para .lt { font-weight: 600; color: var(--brand); margin-right: 6px; }
.w { cursor: pointer; border-radius: 3px; }
.w.hit { background: var(--ok-soft); box-shadow: inset 0 -2px 0 var(--ok); }
.w.miss { background: var(--warn-soft); box-shadow: inset 0 -2px 0 var(--warn); }
/* 自己划的线（持久保留） */
.w.ul { box-shadow: inset 0 -2px 0 var(--brand); }
/* 已经在生词本里的词 */
.w.saved { border-bottom: 1px dashed var(--fg3); }
/* 排除掉的选项（点前面的字母切换） */
.opt.strike > span:last-child { text-decoration: line-through; color: var(--fg3); }
.opt .k { cursor: pointer; }
.opt.strike .k { opacity: .5; }

/* 题目 */
.q { padding: 14px 0; border-bottom: 1px solid var(--line); }
.q:last-child { border-bottom: 0; padding-bottom: 0; }
/* pre-line：GRE 数量比较那种"两行量"的题目靠 \n 换行，要能显示成两行 */
.qt { font-size: 15px; font-weight: 500; margin-bottom: 10px; white-space: pre-line; }
.opt {
  display: flex; gap: 10px; padding: 11px 13px; border-radius: 9px;
  border: 1px solid transparent; cursor: pointer; font-size: 14.5px;
  line-height: 1.55; margin-bottom: 6px;
}
.opt .k { font-weight: 600; color: var(--fg3); min-width: 15px; }
.opt.sel { background: var(--brand-soft); border-color: var(--brand); }
.opt.ok { background: var(--ok-soft); border-color: var(--ok); }
.opt.bad { background: var(--bad-soft); border-color: var(--bad); }
.exp {
  margin-top: 10px; font-size: 13px; line-height: 1.75; color: var(--fg2);
  background: var(--bg); padding: 10px 13px; border-radius: 9px;
  border-left: 3px solid var(--fg3);
}
.exp b { color: var(--brand); }

/* 选词填空 */
.blank {
  display: inline-block; min-width: 72px; text-align: center;
  padding: 1px 7px; margin: 0 2px; cursor: pointer;
  border-bottom: 1.5px solid var(--brand); color: var(--brand);
  font-size: 14px; border-radius: 4px 4px 0 0;
}
.blank.filled { background: var(--brand-soft); border-bottom-color: transparent; }
.blank.ok { background: var(--ok-soft); border-bottom-color: var(--ok); color: var(--ok); }
.blank.bad { background: var(--bad-soft); border-bottom-color: var(--bad); color: var(--bad); }
.bank { display: flex; flex-wrap: wrap; gap: 7px; padding: 12px; background: var(--bg); border-radius: 10px; margin: 14px 0 4px; }
.chip {
  padding: 7px 12px; border-radius: 8px; background: var(--card);
  border: 1px solid var(--line); font-size: 14px; cursor: pointer; font-family: inherit; color: var(--fg);
}
.chip.picked { background: var(--brand); color: #fff; border-color: var(--brand); }
.chip.used { opacity: .32; text-decoration: line-through; cursor: default; }

/* 导入：三步走（复制提示词 → 发给 AI → 粘回来） */
.step { display: flex; gap: 10px; align-items: flex-start; margin: 16px 0 0; }
.step > div { flex: 1; min-width: 0; }
.step .n {
  flex: 0 0 auto; width: 21px; height: 21px; border-radius: 999px;
  background: var(--brand); color: #fff; font-size: 12px; font-weight: 600;
  display: flex; align-items: center; justify-content: center; margin-top: 1px;
}
.step b { font-size: 13.5px; }
.step .meta:last-child { margin-bottom: 0; }
code {
  font-family: ui-monospace, Consolas, monospace; font-size: 12px;
  background: var(--brand-soft); color: var(--brand);
  padding: 1px 4px; border-radius: 4px;
}
/* 格式示例（默认收起，状态记在 JS 里，不靠 inline style 反复改） */
.fmt {
  display: none; margin: 10px 0 0; padding: 10px 12px; max-height: 320px;
  overflow: auto; background: var(--bg); border: 1px solid var(--line);
  border-radius: 8px; font-family: ui-monospace, Consolas, monospace;
  font-size: 11.5px; line-height: 1.7; color: var(--fg2);
  white-space: pre-wrap; word-break: break-word;
}

/* 导入：拖放区 */
.drop {
  margin: 8px 0; padding: 16px 12px; text-align: center;
  border: 1.5px dashed var(--line); border-radius: 10px;
  background: var(--bg); font-size: 13px; color: var(--fg2);
  transition: border-color .18s ease, background .18s ease;
}
.drop.over { border-color: var(--brand); background: var(--brand-soft); color: var(--brand); }
.drop .btn { display: inline-block; margin-top: 8px; }

/* 匹配 */
.stmt { display: flex; gap: 10px; align-items: flex-start; padding: 11px 0; border-bottom: 1px solid var(--line); }
.stmt:last-child { border-bottom: 0; }
.stmt .no { font-size: 12px; color: var(--fg3); min-width: 16px; padding-top: 6px; }
.stmt .s { flex: 1; font-size: 14.5px; line-height: 1.7; }
.stmt.ok .s { color: var(--ok); }
.stmt.bad .s { color: var(--bad); }
select {
  padding: 7px 9px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--card); color: var(--fg); font-size: 14px; font-family: inherit;
}

/* 结果条 */
.result {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: center;
  margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line);
}
.score { font-size: 14px; }
.score b { color: var(--brand); }

/* 标签 */
.tag {
  display: inline-block; font-size: 11px; padding: 2px 7px; border-radius: 999px;
  background: var(--bg); color: var(--fg2); border: 1px solid var(--line);
  margin-right: 4px; vertical-align: middle;
}
.tag.open { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.tag.orig { background: var(--warn-soft); color: var(--warn); border-color: transparent; }

/* 生词弹层 */
.pop {
  position: fixed; left: 12px; right: 12px; bottom: 84px; z-index: 50;
  background: var(--fg); color: var(--bg);
  padding: 12px 15px; border-radius: 10px; font-size: 14px; line-height: 1.6;
  box-shadow: 0 6px 24px rgba(0,0,0,.25);
}
.pop b { font-size: 16px; }
.pop .add { margin-top: 8px; display: flex; gap: 8px; flex-wrap: wrap; }
.pop .add button {
  padding: 6px 12px; border-radius: 7px; border: 0; cursor: pointer;
  font-size: 12px; background: var(--brand); color: #fff; font-family: inherit;
}
.pop .add button.sec { background: rgba(128,128,128,.35); color: inherit; }
.pop.hide { display: none; }

/* 列表 */
.item { padding: 12px 0; border-bottom: 1px solid var(--line); }
.item:last-child { border-bottom: 0; }
.item .h { font-size: 14.5px; margin-bottom: 3px; }
.item .m { font-size: 12px; color: var(--fg2); }
.vlist .v { display: flex; justify-content: space-between; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line); align-items: baseline; }
.vlist .v:last-child { border-bottom: 0; }
.vlist .v b { color: var(--brand); flex: 0 0 auto; }
/* ⚠️ 两处都不能省：不加 min-width:0，flex 子项按内容宽度算，长释义会直接
   冲出卡片、被屏幕右边裁掉（生词本里一屏全是半截释义就是这个原因）。
   加上之后让它换行显示，宁可占两行也别把字裁了。 */
.vlist .v span { font-size: 13px; color: var(--fg2); text-align: right;
                 min-width: 0; overflow-wrap: anywhere; }
.empty { color: var(--fg3); font-size: 13.5px; padding: 14px 0; text-align: center; }

/* 听力 */
.audio-card { text-align: center; padding: 24px 16px; }
.bigbtn {
  width: 76px; height: 76px; border-radius: 50%; border: 0; cursor: pointer;
  background: var(--brand); color: #fff; font-size: 28px; margin-bottom: 14px;
}
.bigbtn:active { opacity: .85; }
.bigbtn.playing { animation: pulse 1.4s infinite; }
@keyframes pulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.06); } }
.speed { display: flex; gap: 8px; justify-content: center; margin-top: 12px; flex-wrap: wrap; }

.notice {
  font-size: 12.5px; line-height: 1.7; color: var(--fg2);
  background: var(--warn-soft); border-radius: 10px; padding: 12px 14px;
}
.notice b { color: var(--warn); }
a.link { color: var(--brand); }

/* 填空题：自己打字的空（下划线输入框） */
.gapin {
  font-family: inherit; font-size: 15px; padding: 1px 6px; width: 8.5em;
  border: 0; border-bottom: 2px solid var(--brand);
  background: transparent; color: var(--fg); text-align: center;
}
.gapin:focus { outline: none; border-bottom-color: var(--ok); }
.gapin::placeholder { color: var(--fg3); letter-spacing: 1.5px; }

/* 写作 / 翻译 / 口语的作答框 */
textarea.big {
  width: 100%; box-sizing: border-box; font-family: inherit;
  font-size: 14.5px; line-height: 1.75; padding: 12px;
  border: 1px solid var(--line); border-radius: 10px;
  background: var(--card); color: var(--fg); resize: vertical;
}
textarea.big:focus { outline: none; border-color: var(--brand); }

/* 「你的作答」那一块 */
.sub { padding: 12px 0 4px; font-size: 14.5px; }

/* 上一篇 / 下一篇 —— 不用交卷就能翻 */
.pager {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; margin-top: 14px;
}
.pager .meta { margin: 0; }

/* 划线的样子：用 CSS Custom Highlight 画，连续一条、中英文都行 */
::highlight(ul) {
  background-color: var(--brand-soft);
  text-decoration: underline;
  text-decoration-color: var(--brand);
  text-decoration-thickness: 2px;
}
/* 老浏览器不支持 Highlight API 时的退路：逐词加 .ul（见 app.js） */
.w.ul { text-decoration: underline; text-decoration-color: var(--brand); text-decoration-thickness: 2px; }

/* 卷子进度条 */
.pbar { height: 8px; border-radius: 5px; background: var(--line); overflow: hidden; }
.pbar > i { display: block; height: 100%; background: var(--brand); border-radius: 5px;
            transition: width .25s ease; }

/* 口语的计时器 */
.spkbox { padding: 18px 12px; text-align: center; }
.spkclock {
  font-size: 30px; font-weight: 600; color: var(--brand);
  font-variant-numeric: tabular-nums; letter-spacing: .5px;
}

/* 轻提示：常驻 DOM，靠 opacity/transform 过渡淡入淡出（不是 display:none） */
#toast {
  position: fixed; left: 50%; bottom: 84px; z-index: 60;
  max-width: 86vw; padding: 10px 16px; border-radius: 10px;
  background: rgba(32, 32, 36, .94); color: #fff;
  font-size: 13px; line-height: 1.5; text-align: center;
  box-shadow: 0 6px 22px rgba(0, 0, 0, .22);
  pointer-events: none;
  opacity: 0; transform: translate(-50%, 10px) scale(.98);
  transition: opacity .22s ease, transform .22s cubic-bezier(.2, .8, .3, 1);
  will-change: opacity, transform;
}
#toast.on { opacity: 1; transform: translate(-50%, 0) scale(1); }
@media (prefers-reduced-motion: reduce) {
  #toast { transition: none; }
}
