:root {
  --bg: #f5f7fb;
  --card: #ffffff;
  --ink: #1d2b36;
  --muted: #6b7b8a;
  --line: #e2e8f0;
  --brand: #2453e8;
  --brand-soft: #eaf0ff;
  --ok: #12805c;
  --ok-soft: #e6f6ef;
  --bad: #c0392b;
  --bad-soft: #fdecea;
  --warn: #a86610;
  --warn-soft: #fff8e6;
  --warn-line: #f3e0b0;
  --bad-line: #f3c6c0;
  --brand-strong: #1c44c9;
  --brand-line: #bfe0ff;
  --line-strong: #c9d4e3;
  --on-accent: #ffffff;
  --chip: #f1f4f8;
  --hover: #eef2f7;
  --track: #e9eef6;
  --surface-2: #fafbfd;
  --topbar: rgba(255, 255, 255, .88);
  --lv1: #eef4ff; --lv1-line: #dbe8ff;
  --lv2: #dfeaff; --lv2-line: #c7dbff;
  --lv3: #cfdfff; --lv3-line: #b6cdfb;
  color-scheme: light dark;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 8px 24px rgba(16, 24, 40, .06);
  --font: "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, sans-serif;
  --fr: "Iowan Old Style", Georgia, "Times New Roman", serif;
}

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

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

.topbar {
  position: sticky; top: 0; z-index: 20;
  background: var(--topbar);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.topbar-inner {
  max-width: 960px; margin: 0 auto; padding: 12px 20px;
  display: flex; align-items: center; gap: 18px; flex-wrap: wrap; row-gap: 6px;
}
.brand { font-size: 21px; font-weight: 800; letter-spacing: .5px; line-height: 1; color: var(--ink); display: inline-flex; align-items: center; gap: 8px; white-space: nowrap; }
.brand span { color: var(--brand); }
.brand .brand-name { color: var(--ink); }
.brand .brand-name span { color: var(--brand); }
.brand-logo { display: block; width: 30px; height: 30px; border-radius: 7px; }

.lang-menu { position: relative; flex: 0 0 auto; z-index: 25; }
.lang-toggle {
  border: 0; background: var(--brand-soft); color: var(--brand);
  border-radius: 999px; padding: 6px 12px; line-height: 0;
  cursor: pointer; transition: .15s ease;
}
.lang-toggle:hover, .lang-toggle[aria-expanded="true"] { filter: brightness(0.95); }
.lang-toggle:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

.lang-dropdown {
  position: absolute; right: 0; top: calc(100% + 6px);
  min-width: 132px; padding: 6px;
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: 0 10px 28px rgba(16, 24, 40, .14);
  display: grid; gap: 2px;
}
.lang-dropdown[hidden] { display: none; }
.lang-option {
  border: 0; background: none; text-align: left; cursor: pointer;
  padding: 8px 10px; border-radius: 8px; font-size: 14px; color: var(--ink);
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
}
.lang-option:hover { background: var(--brand-soft); color: var(--brand); }
.lang-option.is-active { color: var(--brand); font-weight: 600; }
.lang-option.is-active::after { content: "✓"; font-size: 13px; }
.nav { display: flex; gap: 6px; margin-left: auto; flex-wrap: wrap; }
.nav a { color: var(--muted); padding: 6px 12px; border-radius: 999px; font-size: 14px; }
.nav a:hover { background: var(--brand-soft); color: var(--brand); text-decoration: none; }
.nav a[aria-current="page"] { background: var(--brand-soft); color: var(--brand); font-weight: 600; }

main { max-width: 960px; margin: 0 auto; padding: 28px 20px 72px; }

.hero h1 { font-size: 26px; margin: 4px 0 8px; }
.hero p { color: var(--muted); margin: 0 0 4px; }
.hero .note { font-size: 13px; color: var(--muted); margin-top: 10px; }

.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); margin-top: 22px; }

.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
}

.section-card { padding: 18px 20px; display: flex; flex-direction: column; gap: 10px; }
.section-card h2 { font-size: 18px; margin: 0; }
.section-card .fr { font-family: var(--fr); color: var(--muted); font-size: 14px; }
.section-card .facts { display: flex; gap: 14px; font-size: 13px; color: var(--muted); flex-wrap: wrap; }
.section-card .facts strong { color: var(--ink); }
.section-card .actions { margin-top: auto; display: flex; gap: 8px; flex-wrap: wrap; }

.pill {
  display: inline-block; padding: 2px 9px; border-radius: 999px;
  background: var(--brand-soft); color: var(--brand); font-size: 12px; font-weight: 600;
}
.pill.muted { background: var(--chip); color: var(--muted); font-weight: 500; }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--line); background: var(--card); color: var(--ink);
  padding: 9px 16px; border-radius: 10px; font-size: 14px; font-weight: 600;
  cursor: pointer; transition: .15s ease;
}
.btn:hover { border-color: var(--line-strong); background: var(--hover); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--on-accent); }
.btn.primary:hover { background: var(--brand-strong); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn.ghost:hover { background: var(--hover); color: var(--ink); }
.btn.danger { color: var(--bad); border-color: var(--bad-line); background: var(--card); }
.btn:disabled { opacity: .45; cursor: not-allowed; }

.timer {
  font-variant-numeric: tabular-nums; font-weight: 700; font-size: 18px;
  padding: 4px 12px; border-radius: 10px; background: var(--brand-soft); color: var(--brand);
}
.timer.low { background: var(--bad-soft); color: var(--bad); }

.bar { height: 6px; background: var(--track); border-radius: 999px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--brand); transition: width .2s ease; }

.quiz-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.quiz-head .grow { flex: 1; min-width: 180px; }
.quiz-head .title { font-weight: 700; }
.quiz-head .sub { font-size: 13px; color: var(--muted); }
.quiz-head .bar { margin-top: 8px; }

/* ---------- 选套页：格子 + 刷题次数底色 ---------- */
.paper-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 10px;
}
.paper-card {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 12px 6px; border: 1px solid var(--line); border-radius: 12px;
  color: var(--ink); text-decoration: none; transition: border-color .15s ease;
}
.paper-card:hover { border-color: var(--brand); text-decoration: none; }
.paper-card:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.paper-card strong { font-size: 15px; color: var(--brand-strong); font-weight: 600; }
.paper-card span { font-size: 12px; color: var(--muted); }
.paper-card.is-doing::after {
  content: ""; position: absolute; top: 7px; right: 7px; width: 6px; height: 6px;
  border-radius: 50%; background: var(--brand);
}
.paper-card.lv0 { background: var(--card); }
.paper-card.lv1 { background: color-mix(in srgb, var(--brand) 7%, var(--card)); border-color: color-mix(in srgb, var(--brand) 22%, var(--card)); }
.paper-card.lv2 { background: color-mix(in srgb, var(--brand) 13%, var(--card)); border-color: color-mix(in srgb, var(--brand) 32%, var(--card)); }
.paper-card.lv3 { background: color-mix(in srgb, var(--brand) 19%, var(--card)); border-color: color-mix(in srgb, var(--brand) 44%, var(--card)); }

/* ---------- 收藏按钮 ---------- */
.qn-fav {
  margin-left: auto; border: 0; background: none; cursor: pointer;
  font-size: 22px; line-height: 1; padding: 2px 4px; color: var(--muted); border-radius: 6px;
}
.qn-fav.is-on { color: var(--warn); }
.qn-fav:hover { color: var(--warn); }

/* 从收藏夹跳转时高亮目标题 */
.review-item.is-focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }

/* ---------- 首页：四个入口 ---------- */
.home-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  max-width: 720px;
  margin: 20px auto 0;
}
.tile {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 26px 24px;
  min-height: 132px;
  justify-content: center;
  text-decoration: none;
  color: var(--ink);
  transition: transform .15s ease, border-color .15s ease, box-shadow .15s ease;
}
.tile:hover {
  text-decoration: none;
  border-color: var(--brand);
  box-shadow: 0 12px 28px rgba(36, 83, 232, .12);
  transform: translateY(-2px);
}
.tile:focus-visible { outline: 2px solid var(--brand); outline-offset: 3px; }
.tile-title { font-size: 21px; font-weight: 700; letter-spacing: .5px; }
.tile .fr { font-family: var(--fr); font-size: 14px; color: var(--muted); }
.tile-meta { margin-top: 8px; font-size: 12px; color: var(--muted); }

@media (max-width: 560px) {
  .home-grid { grid-template-columns: 1fr; max-width: none; }
  .tile { min-height: 104px; padding: 20px; }
}

/* ---------- 板块页：套题 / 刷题 ---------- */
.mode-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  max-width: 860px;
  margin: 20px auto 0;
}
.mode-grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); max-width: 580px; }
.mode-card {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 160px;
  text-decoration: none;
  color: var(--ink);
  transition: transform .15s ease, border-color .15s ease, box-shadow .15s ease;
}
.mode-card:hover {
  text-decoration: none;
  border-color: var(--brand);
  box-shadow: 0 12px 28px rgba(36, 83, 232, .12);
  transform: translateY(-2px);
}
.mode-card:focus-visible { outline: 2px solid var(--brand); outline-offset: 3px; }
.mode-title { font-size: 24px; font-weight: 700; letter-spacing: 1px; }
.mode-card.review-card { flex-direction: column; gap: 8px; }
.mode-card.review-card .mode-meta { font-size: 13px; color: var(--muted); letter-spacing: 0; }

@media (max-width: 720px) {
  .mode-grid { grid-template-columns: 1fr; max-width: none; }
  .mode-card { min-height: 120px; }
}

/* ---------- 复习页：错题 / 收藏标签 ---------- */
.review-tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 4px 0 18px;
}
.review-tab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
  background: var(--card);
}
.review-tab:hover { text-decoration: none; border-color: var(--brand); color: var(--brand); }
.review-tab.is-active { background: var(--brand-soft); border-color: var(--brand); color: var(--brand); }

/* ---------- 统计页 ---------- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}
.stat-card {
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--shadow);
}
.stat-card b { display: block; font-size: 26px; line-height: 1.2; }
.stat-card span { display: block; margin-top: 4px; font-size: 12px; color: var(--muted); }
.stats-card { padding: 18px 20px; margin-top: 16px; }
.stats-card h2 { font-size: 16px; margin: 0 0 12px; }
.local-note { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.local-note p { margin: 0; }
.stats-scroll { overflow: auto; }
.stats-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.stats-table th, .stats-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  white-space: nowrap;
}
.stats-table th { color: var(--muted); font-weight: 600; }
.stats-table tr:last-child td { border-bottom: 0; }
.stat-grid.stat-grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.stats-periods { margin: 0 0 12px; }
.stats-periods .review-tab { cursor: pointer; font: inherit; font-size: 14px; font-weight: 600; }
.stats-levels th[colspan] { text-align: center; }
.stats-levels thead tr + tr th { font-weight: 500; }
.stats-total td { font-weight: 600; }
.stats-mock td:last-child { text-align: right; }
.btn.small { padding: 4px 12px; font-size: 13px; }
.record-text {
  margin-top: 12px; padding: 12px 14px;
  border: 1px solid var(--line); border-radius: 10px;
  white-space: pre-wrap; line-height: 1.6;
}

/* ---------- 导出菜单 ---------- */
.export-menu { position: relative; }
.export-menu > summary { list-style: none; cursor: pointer; }
.export-menu > summary::-webkit-details-marker { display: none; }
.export-dropdown {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 30;
  min-width: 190px; padding: 6px;
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: 0 10px 28px rgba(16, 24, 40, .14);
  display: grid; gap: 2px;
}
.export-dropdown button {
  border: 0; background: none; cursor: pointer;
  padding: 8px 10px; border-radius: 8px; text-align: left;
  font-size: 13px; color: var(--ink); white-space: nowrap;
}
.export-dropdown button:hover { background: var(--brand-soft); color: var(--brand); }

@media (max-width: 720px) {
  .stat-grid, .stat-grid.stat-grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 480px) {
  .stat-grid, .stat-grid.stat-grid-3 { grid-template-columns: 1fr; }
  .export-menu { margin-left: 0; }
  .export-dropdown { left: 0; right: auto; }
}

/* 重复题提示 */
.dup-note {
  margin: 8px 0 4px;
  padding: 6px 10px;
  border-left: 3px solid var(--brand);
  background: var(--brand-soft);
  color: var(--muted);
  border-radius: 6px;
  font-size: 13px;
}

/* ---------- 刷题配置 ---------- */
.field { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.field label { font-size: 14px; color: var(--muted); }
.field select {
  padding: 8px 12px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--card); font-size: 14px; color: var(--ink); min-width: 160px;
}
.field-group { display: flex; flex-wrap: wrap; gap: 16px; margin-bottom: 6px; }


.practice {
  display: grid;
  grid-template-columns: 172px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}
.practice-main { min-width: 0; min-height: calc(100vh - 96px); }
/* 没有左侧题号导航时，单列铺满 */
.practice.no-nav { grid-template-columns: minmax(0, 1fr); }

.qn-nav {
  position: sticky;
  top: 76px;
  max-height: calc(100vh - 96px);
  overflow: auto;
  padding: 14px 12px;
}
.qn-nav.clean { padding: 12px 10px; }
.qn-nav-head {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 8px; margin-bottom: 12px; font-size: 13px;
}
.qn-level { margin: 0 0 12px; }
.qn-level:last-of-type { margin-bottom: 8px; }
.qn-level h4 {
  display: flex; align-items: center; gap: 6px;
  margin: 0 0 6px; font-size: 11px; letter-spacing: .06em;
  color: var(--muted); text-transform: uppercase;
}
.qn-count {
  background: var(--chip); color: var(--muted); border-radius: 999px;
  padding: 0 6px; font-size: 10px; letter-spacing: 0;
}
.qn-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; }
.qn-btn {
  height: 28px; padding: 0; border-radius: 8px;
  border: 1px solid var(--line); background: var(--card); color: var(--ink);
  font-size: 12px; font-variant-numeric: tabular-nums; cursor: pointer;
  transition: .12s ease;
}
.qn-btn:hover { border-color: var(--brand-line); }
.qn-btn:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.qn-btn.active:focus-visible { outline-color: var(--ink); }
.qn-btn.answered { border-color: var(--brand); background: var(--brand-soft); color: var(--brand); }
.qn-btn.correct { border-color: var(--ok); background: var(--ok-soft); color: var(--ok); }
.qn-btn.wrong { border-color: var(--bad); background: var(--bad-soft); color: var(--bad); }
.qn-btn.active {
  background: var(--brand); border-color: var(--brand); color: var(--on-accent); font-weight: 700;
  box-shadow: 0 4px 12px rgba(36, 83, 232, .28);
}
.qn-btn.active.wrong {
  box-shadow: inset 0 0 0 2px var(--bad), 0 4px 12px rgba(36, 83, 232, .2);
}
.qn-legend {
  display: flex; flex-wrap: wrap; gap: 8px 10px;
  border-top: 1px dashed var(--line); padding-top: 10px;
  font-size: 11px; color: var(--muted);
}
.qn-legend span { display: inline-flex; align-items: center; gap: 4px; }
.qn-dot {
  width: 8px; height: 8px; border-radius: 3px; display: inline-block;
  background: var(--card); border: 1px solid var(--line);
}
.qn-dot.answered { background: var(--brand-soft); border-color: var(--brand); }
.qn-dot.correct { background: var(--ok-soft); border-color: var(--ok); }
.qn-dot.wrong { background: var(--bad-soft); border-color: var(--bad); }


.question { padding: 20px 22px; scroll-margin-top: 84px; }
.q-timer {
  float: right; margin: 0 0 10px 12px; padding: 4px 10px;
  border: 1px solid var(--line); border-radius: 999px;
  background: var(--card); color: var(--muted); font-size: 13px; font-weight: 700;
  font-variant-numeric: tabular-nums; min-width: 62px; text-align: center;
}
.q-timer.low { color: var(--bad); border-color: var(--bad-line); background: var(--bad-soft); }
.question .qmeta { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.fr-text { font-family: var(--fr); font-size: 18px; line-height: 1.7; }
.prompt { margin: 2px 0 10px; }
.zh { color: var(--muted); font-size: 14px; margin: 2px 0 10px; }

.article {
  background: var(--surface-2); border: 1px dashed var(--line); border-radius: 12px;
  padding: 14px 16px; margin: 12px 0 16px; white-space: pre-wrap;
}
.article .label, .transcript .label {
  font-size: 12px; color: var(--muted); text-transform: uppercase;
  letter-spacing: .06em; margin-bottom: 6px;
}
.transcript { background: var(--surface-2); border-radius: 12px; padding: 14px 16px; margin-top: 14px; white-space: pre-wrap; }
.qimg { display: block; max-width: 100%; max-height: 340px; width: auto; object-fit: contain; border-radius: 12px; border: 1px solid var(--line); margin: 10px auto; }
audio { width: 100%; margin: 10px 0 4px; }

/* 听力音频：自动播放 + 倍速菜单 */
.audio-row { display: flex; align-items: center; gap: 10px; margin: 10px 0 6px; }
.audio-row audio { flex: 1 1 auto; width: auto; min-width: 0; margin: 0; }
.rate-menu { position: relative; flex: 0 0 auto; }
.rate-toggle {
  border: 1px solid var(--line); background: var(--card); color: var(--ink);
  border-radius: 10px; padding: 6px 10px; min-width: 54px;
  font-size: 13px; font-weight: 600; cursor: pointer;
  font-variant-numeric: tabular-nums; transition: .15s ease;
}
.rate-toggle:hover { border-color: var(--brand); color: var(--brand); }
.rate-toggle:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.rate-toggle[aria-expanded="true"] { border-color: var(--brand); color: var(--brand); background: var(--brand-soft); }
.rate-dropdown {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 15;
  min-width: 96px; padding: 6px; display: grid; gap: 2px;
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: 0 10px 28px rgba(16, 24, 40, .14);
}
.rate-dropdown[hidden] { display: none; }
.rate-option {
  border: 0; background: none; cursor: pointer;
  padding: 6px 10px; border-radius: 8px; text-align: center;
  font-size: 13px; color: var(--ink); font-variant-numeric: tabular-nums;
}
.rate-option:hover { background: var(--brand-soft); color: var(--brand); }
.rate-option.is-on { background: var(--brand-soft); color: var(--brand); font-weight: 700; }

/* 模拟考：题号只展示不可点 */
.qn-nav.locked .qn-btn { cursor: not-allowed; }
.qn-nav.locked .qn-btn:not(.active) { opacity: .72; }
.qn-nav.locked .qn-btn:hover { border-color: var(--line); }


.options { list-style: none; padding: 0; margin: 16px 0 0; display: grid; gap: 10px; }
.option {
  display: flex; gap: 12px; align-items: flex-start; position: relative;
  border: 1.5px solid var(--line); border-radius: 12px; padding: 12px 14px;
  cursor: pointer; background: var(--card); transition: .15s ease;
}
.option:hover { border-color: var(--brand-line); }
.option input { position: absolute; opacity: 0; pointer-events: none; }
.option .letter {
  flex: 0 0 26px; height: 26px; border-radius: 8px; background: var(--chip);
  display: grid; place-items: center; font-weight: 700; font-size: 13px; color: var(--muted);
}
/* 选项没有文字时的占位（Proposition X） */
.option .ph { color: var(--muted); }

/* 每个选项固定一行高度，长文本单行省略（完整内容见 title） */
.option { height: 64px; align-items: center; padding-block: 6px; }
.option .text { flex: 1; min-width: 0; }
.option .text > span, .option .text > .zh { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.option .text .zh { margin: 2px 0 0; }
.option.selected { border-color: var(--brand); background: var(--brand-soft); }
.option.selected .letter { background: var(--brand); color: var(--on-accent); }
.option.correct { border-color: var(--ok); background: var(--ok-soft); }
.option.correct .letter { background: var(--ok); color: var(--on-accent); }
.option.wrong { border-color: var(--bad); background: var(--bad-soft); }
.option.wrong .letter { background: var(--bad); color: var(--on-accent); }
.option.disabled { cursor: default; }

.feedback { margin-top: 16px; padding: 14px 16px; border-radius: 12px; font-weight: 600; }
.feedback.ok { background: var(--ok-soft); color: var(--ok); }
.feedback.bad { background: var(--bad-soft); color: var(--bad); }
.feedback small { display: block; font-weight: 400; color: var(--muted); margin-top: 4px; }

.explain { margin-top: 14px; border-top: 1px dashed var(--line); padding-top: 14px; }
.explain h3 { font-size: 14px; margin: 0 0 8px; color: var(--muted); letter-spacing: .04em; }
.explain p { margin: 6px 0; white-space: pre-wrap; }

.quiz-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 18px; align-items: center; }
.quiz-actions .spacer { flex: 1; }

.toggle {
  display: inline-flex; align-items: center; gap: 8px; font-size: 14px;
  color: var(--muted); cursor: pointer; user-select: none;
}
.toggle input { width: 16px; height: 16px; accent-color: var(--brand); }

.result-hero { padding: 22px; display: flex; gap: 22px; align-items: center; flex-wrap: wrap; }
.score { font-size: 40px; font-weight: 800; line-height: 1; }
.score small { font-size: 16px; color: var(--muted); font-weight: 500; }
.result-hero .stats { display: flex; gap: 24px; flex-wrap: wrap; }
.result-hero .stat b { display: block; font-size: 20px; }
.result-hero .stat span { font-size: 12px; color: var(--muted); }

.review { margin-top: 18px; display: grid; gap: 12px; }
.review-item { padding: 14px 16px; }
.review-item header { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.review-item .prompt { margin: 10px 0 4px; }
.review-item details { margin-top: 8px; }
.review-item summary { cursor: pointer; color: var(--brand); font-size: 14px; }

.list { display: grid; gap: 12px; margin-top: 16px; }
.empty { padding: 28px; text-align: center; color: var(--muted); }

.tasks { display: grid; gap: 16px; margin-top: 18px; }
.task { padding: 18px 20px; }
.task h2 { font-size: 17px; margin: 6px 0 2px; }
.task .wordlimit { font-size: 13px; color: var(--muted); }
.task .doc {
  background: var(--surface-2); border: 1px dashed var(--line);
  border-radius: 10px; padding: 12px 14px; margin: 10px 0;
}
.task textarea {
  width: 100%; min-height: 160px; margin-top: 12px; padding: 12px 14px;
  border: 1px solid var(--line); border-radius: 12px; font-family: var(--fr);
  font-size: 15px; line-height: 1.7; resize: vertical; background: var(--card);
}
.task textarea.tall { min-height: 360px; }
.task[hidden] { display: none; }

/* 写作分类练习 */
.wb { display: grid; grid-template-columns: 240px minmax(0, 1fr); padding: 0; overflow: hidden; }
.wb-side { border-right: 1px solid var(--line); padding: 16px 14px; }
.wb-tabs { display: flex; gap: 22px; border-bottom: 1px solid var(--line); margin-bottom: 12px; }
.wb-tab {
  border: 0; background: none; padding: 8px 2px 10px; margin-bottom: -1px; cursor: pointer;
  font: inherit; font-size: 15px; color: var(--muted); border-bottom: 2px solid transparent;
}
.wb-tab.is-on { color: var(--ink); font-weight: 700; border-bottom-color: var(--brand); }
.wb-cats { display: grid; gap: 2px; max-height: 70vh; overflow: auto; }
.wb-cat {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  border: 0; background: none; padding: 10px 12px; border-radius: 10px;
  font: inherit; font-size: 15px; color: var(--ink); cursor: pointer; text-align: left;
}
.wb-cat .n { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.wb-cat:hover { background: var(--surface-2); }
.wb-cat.is-on { background: var(--brand-soft); color: var(--brand); font-weight: 700; }
.wb-cat.is-on .n { color: var(--brand); }
.wb-main { padding: 16px 20px; min-width: 0; }
.wb-filters { display: flex; gap: 14px; flex-wrap: wrap; }
.wb-field { display: grid; gap: 6px; font-size: 13px; color: var(--muted); }
.wb-field.grow { flex: 1; min-width: 200px; }
.wb-field select, .wb-field input {
  padding: 9px 12px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--card); color: var(--ink); font: inherit; font-size: 14px; min-width: 150px;
}
.wb-total { font-size: 13px; color: var(--muted); margin: 14px 0 8px; }
.wb-row {
  display: flex; align-items: center; gap: 14px; padding: 14px 8px;
  border-top: 1px solid var(--line); color: inherit; text-decoration: none;
}
.wb-row:hover { background: var(--surface-2); text-decoration: none; }
.wb-badge { flex: 0 0 auto; padding: 4px 9px; border-radius: 6px; background: var(--brand-soft); color: var(--brand); font-size: 12px; font-weight: 600; }
.wb-text { flex: 1; min-width: 0; }
.wb-text b { display: block; font-size: 15px; }
.wb-text span { display: block; margin-top: 3px; font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wb-month { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.wb-go { color: var(--brand); }
@media (max-width: 720px) {
  .wb { grid-template-columns: 1fr; }
  .wb-side { border-right: 0; border-bottom: 1px solid var(--line); }
  .wb-cats { grid-auto-flow: column; overflow-x: auto; max-height: none; }
  .wb-cat { white-space: nowrap; }
  .wb-month { display: none; }
}

/* 写作 / 口语：左侧任务标签 */
.open-layout { display: grid; grid-template-columns: 140px minmax(0, 1fr); gap: 16px; margin-top: 18px; align-items: start; }
.open-layout.single { grid-template-columns: minmax(0, 1fr); }
.task-tabs { display: grid; gap: 8px; padding: 10px; position: sticky; top: 16px; }
.task-tab {
  border: 1.5px solid var(--line); background: var(--card); color: var(--ink);
  border-radius: 10px; padding: 10px 12px; font: inherit; font-weight: 600;
  text-align: left; cursor: pointer; transition: .15s ease;
}
.task-tab:hover { border-color: var(--brand-line); }
.task-tab.is-on { border-color: var(--brand); background: var(--brand-soft); color: var(--brand); }
.task-tab.done::after { content: " ✓"; color: var(--ok); }
.task-tabs.locked .task-tab { cursor: default; }
.task-tabs.locked .task-tab:not(.is-on) { opacity: .6; }
.task-tabs.locked .task-tab:hover:not(.is-on) { border-color: var(--line); }
.task-tab:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.speak-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 14px; }
.speak-bar .pill.rec { background: var(--bad-soft); color: var(--bad); }
.speak-bar[hidden], .mic-gate[hidden], .speak-bar [hidden] { display: none; }
.mic-gate { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.rec-btn { display: inline-flex; align-items: center; gap: 8px; }
.rec-btn.is-rec {
  background: var(--bad); border-color: var(--bad); color: #fff;
  animation: rec-ring 1.4s ease-out infinite;
}
.rec-dot { width: 10px; height: 10px; border-radius: 50%; background: #fff; animation: rec-pulse 1s ease-in-out infinite; }
.speak-bar.is-rec .pill.rec::before {
  content: ""; display: inline-block; width: 8px; height: 8px; margin-right: 6px;
  border-radius: 50%; background: var(--bad); animation: rec-pulse 1s ease-in-out infinite;
}
@keyframes rec-pulse { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: .35; transform: scale(.7); } }
@keyframes rec-ring {
  0% { box-shadow: 0 0 0 0 rgba(220, 38, 38, .45); }
  100% { box-shadow: 0 0 0 12px rgba(220, 38, 38, 0); }
}
.task audio[data-playback] { margin-top: 12px; }
@media (max-width: 720px) {
  .open-layout { grid-template-columns: 1fr; }
  .task-tabs { grid-auto-flow: column; position: static; }
  .task-tab { text-align: center; }
}

.task .draft-info {
  font-size: 12px; color: var(--muted); margin-top: 6px;
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
}
.task .draft-info [data-save] { margin-left: auto; padding: 6px 14px; font-size: 13px; }

.modal-backdrop {
  position: fixed; inset: 0; z-index: 100; display: grid; place-items: center;
  background: rgba(15, 20, 25, .45); padding: 20px;
}
.modal { width: min(380px, 100%); padding: 20px 22px; }
.modal p { margin: 0 0 18px; font-size: 15px; color: var(--ink); }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }

.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.toolbar .grow { flex: 1; }
.link-btn {
  border: 0; background: none; padding: 4px 6px; cursor: pointer;
  font: inherit; font-size: 13px; color: var(--muted);
}
.link-btn:hover { color: var(--brand); text-decoration: underline; }
.link-btn:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 4px; }

.foot { max-width: 960px; margin: 0 auto; padding: 18px 20px 40px; color: var(--muted); font-size: 12px; }

.banner {
  padding: 14px 16px; border-radius: 12px; background: var(--card)8e6; color: var(--warn);
  border: 1px solid var(--warn-line); font-size: 14px; margin-top: 16px;
}

@media (max-width: 860px) {
  .practice { grid-template-columns: 1fr; gap: 12px; }
  .practice-main { min-height: 0; }
  .qn-nav { position: static; max-height: none; padding: 10px 12px; }
  .qn-nav-head { margin-bottom: 8px; }
  .qn-level { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
  .qn-level h4 { margin: 0; flex: 0 0 auto; }
  .qn-grid { display: flex; flex-wrap: nowrap; overflow-x: auto; gap: 6px; padding-bottom: 2px; }
  .qn-btn { flex: 0 0 34px; }
  .qn-legend { border-top: 0; padding-top: 2px; }
}

@media (max-width: 640px) {
  main { padding: 18px 14px 60px; }
  .question { padding: 16px; }
  .result-hero { padding: 18px; }
  .topbar-inner { padding: 10px 14px; column-gap: 10px; }
  .brand { font-size: 19px; flex: 1 1 auto; }
  .brand-logo { width: 28px; height: 28px; }
  .lang-menu { order: 2; margin-left: auto; }
  .lang-dropdown { right: 0; }
  .nav {
    order: 3; flex: 1 1 100%; margin-left: 0;
    justify-content: flex-start; flex-wrap: nowrap; overflow-x: auto;
  }
  .nav a { padding: 5px 9px; font-size: 13px; white-space: nowrap; }
  .score { font-size: 32px; }
  .fr-text { font-size: 17px; }
}


/* ---------- 暗色模式（跟随系统） ---------- */
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1419;
    --card: #171d24;
    --ink: #e6edf3;
    --muted: #97a6b6;
    --line: #2a3440;
    --line-strong: #3a4655;
    --brand: #7c9dff;
    --brand-strong: #9db6ff;
    --brand-soft: #1c2945;
    --brand-line: #3d5aa8;
    --ok: #4cc38a;
    --ok-soft: #13302a;
    --bad: #ff7b72;
    --bad-soft: #3a1c1d;
    --bad-line: #6b2c2c;
    --warn: #e3b341;
    --warn-soft: #30270e;
    --warn-line: #5c4a1a;
    --on-accent: #0b1020;
    --chip: #222b35;
    --hover: #1f2731;
    --track: #26303b;
    --surface-2: #1b222a;
    --topbar: rgba(15, 20, 25, .86);
    --lv1: #172238; --lv1-line: #22324f;
    --lv2: #1b2a48; --lv2-line: #2a3f66;
    --lv3: #20345d; --lv3-line: #33508a;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
  }
  .qimg { background: #fff; }
}

.task textarea { color: var(--ink); }
.field select { color: var(--ink); }

/* ---------- 键盘焦点 ---------- */
.btn:focus-visible, .nav a:focus-visible, .review-tab:focus-visible,
.lang-option:focus-visible, .rate-option:focus-visible, .qn-fav:focus-visible,
.export-menu > summary:focus-visible {
  outline: 2px solid var(--brand); outline-offset: 2px;
}
.option:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-color: var(--brand); }
main:focus { outline: none; }

/* ---------- 对错不只靠颜色：题号角标 ✓ / ✗ ---------- */
.qn-btn { position: relative; }
.qn-btn.correct::after, .qn-btn.wrong::after {
  position: absolute; top: -6px; right: -4px;
  font-size: 10px; line-height: 14px; width: 14px; height: 14px; border-radius: 50%;
  color: var(--on-accent); text-align: center; font-weight: 700;
}
.qn-btn.correct::after { content: "✓"; background: var(--ok); }
.qn-btn.wrong::after { content: "✗"; background: var(--bad); }

/* ---------- 首页：继续上次 ---------- */

/* ---------- 加载 / 音频提示 / toast ---------- */
.loading { animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .45; } }
.audio-tap { margin: 10px 0 4px; }
.audio-error { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 10px 0; }

.toast-host {
  position: fixed; left: 50%; transform: translateX(-50%); z-index: 50;
  bottom: 18px;
  width: min(560px, calc(100% - 28px)); pointer-events: none;
}
.toast {
  display: flex; align-items: center; gap: 12px; padding: 12px 16px;
  background: var(--ink); color: var(--bg); border-radius: 12px;
  box-shadow: 0 10px 28px rgba(16, 24, 40, .25); font-size: 14px; pointer-events: auto;
}
.toast span { flex: 1; }
.toast.is-error { background: var(--bad); color: var(--on-accent); }
.toast .btn { padding: 6px 12px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}

/* 听力题干提示弱化 */
.prompt.prompt-weak { font-size: 13px; font-weight: 400; color: var(--muted); }

/* 结果页：题号格子 */
.rv-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)); gap: 8px; margin-top: 12px; }
.rv-cell {
  display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 0;
  border: 1.5px solid var(--line); border-radius: 10px; background: var(--card); color: inherit;
  font: inherit; cursor: pointer;
}
.rv-cell b { font-size: 15px; }
.rv-cell.ok { border-color: var(--ok); background: var(--ok-soft); color: var(--ok); }
.rv-cell.bad { border-color: var(--bad); background: var(--bad-soft); color: var(--bad); }
.rv-cell.is-on { box-shadow: 0 0 0 3px var(--brand-soft); outline: 2px solid var(--brand); }
.review { margin-top: 14px; }

/* 复习落地页：全部 / 错题 / 收藏 × 全部 / 按套 / 按级别 */
.review-tabs.rv-groups { margin-top: -6px; }
.review-tabs.rv-groups .review-tab { font-size: 13px; padding: 4px 12px; }
.rv-box { padding: 4px 16px 16px; }
.rv-box .rv-grid { grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)); }
.rv-cell b { font-variant-numeric: tabular-nums; }
.rv-box .rv-cell { color: var(--ink); }
.rv-box .rv-cell b { color: var(--brand-strong); font-weight: 600; }
.rv-cell.w0 { border-color: var(--line); background: var(--card); }
.rv-cell.w1 { border-color: color-mix(in srgb, var(--brand) 22%, var(--card)); background: color-mix(in srgb, var(--brand) 7%, var(--card)); }
.rv-cell.w2 { border-color: color-mix(in srgb, var(--brand) 32%, var(--card)); background: color-mix(in srgb, var(--brand) 13%, var(--card)); }
.rv-cell.w3 { border-color: color-mix(in srgb, var(--brand) 44%, var(--card)); background: color-mix(in srgb, var(--brand) 19%, var(--card)); }
.rv-box .rv-cell:hover { border-color: var(--brand); }
.rv-cell span:empty::before { content: "\00a0"; }
.rv-star { color: var(--warn); }
.rv-detail { margin-top: 14px; box-shadow: none; }
.rv-group { margin-top: 18px; }
.rv-group-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.rv-group-head .btn { margin-left: auto; padding: 6px 14px; font-size: 13px; }
.rv-box a.rv-cell { text-decoration: none; }
