/* ============================================================
   公考备考程序 · 设计系统
   参考「不背单词」：暖白纸感、墨色文字、衬线标题、轻卡片、五栏底部导航
   ============================================================ */

/* ---------- 1. Design tokens ---------- */
:root {
  --paper: #F6F3EE;
  --paper-2: #EFEAE2;
  --card: #FFFFFF;
  --card-2: #FBFAF7;
  --ink: #1C1B19;
  --ink-1: #3A3833;
  --ink-2: #8B857B;
  --ink-3: #B7B1A6;
  --line: #ECE7DF;
  --line-2: #F2EEE7;
  --brand: #2F6B57;
  --brand-1: #3A7D67;
  --brand-soft: #E8F0EB;
  --accent: #D9622B;
  --accent-soft: #FBEADE;
  --gold: #E5A100;
  --green: #3F9C6B;
  --green-soft: #E8F4EC;
  --yellow: #E5A100;
  --yellow-soft: #FCF3DA;
  --red: #D64541;
  --red-soft: #FBEAE8;
  --shadow: 0 2px 12px rgba(28, 27, 25, .06);
  --shadow-lg: 0 16px 48px rgba(28, 27, 25, .16);
  --radius: 18px;
  --radius-sm: 12px;
  --radius-lg: 26px;
  --serif: "Songti SC", "STSong", "Noto Serif SC", "Source Han Serif SC", "SimSun", serif;
  --sans: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Segoe UI", sans-serif;
  --nav-h: 62px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--sans);
  color: var(--ink);
  background: var(--paper-2);
  font-size: 15px;
  line-height: 1.6;
  overscroll-behavior-y: none;
}
button, input, textarea, select { font-family: inherit; font-size: inherit; color: inherit; }
button { cursor: pointer; border: none; background: none; padding: 0; }
a { color: var(--brand); text-decoration: none; }
img, svg { display: block; }
/* App.icon() 输出的 SVG 不带 width/height，在 flex 容器里会被撑成巨大图标；
   这里给「没有显式尺寸」的 SVG 一个 16px 默认值（:where 零优先级，任何具体样式都能覆盖） */
:where(svg:not([width]):not([height])) { width: 16px; height: 16px; flex: none; }
::selection { background: var(--brand-soft); }

/* ---------- 2. App shell ---------- */
#app {
  position: relative;
  width: 100%;
  max-width: 520px;
  margin: 0 auto;
  min-height: 100dvh;
  background: var(--paper);
  display: flex;
  flex-direction: column;
  box-shadow: 0 0 60px rgba(28, 27, 25, .07);
  overflow: hidden;
}
@media (min-width: 760px) {
  body {
    background:
      radial-gradient(1200px 600px at 20% -10%, #FBF8F2 0%, transparent 60%),
      radial-gradient(900px 500px at 100% 0%, #F0EAE0 0%, transparent 55%),
      var(--paper-2);
    padding: 24px 0;
  }
  #app { min-height: calc(100dvh - 48px); border-radius: 34px; box-shadow: 0 20px 70px rgba(28, 27, 25, .14); }
}

#app-view {
  flex: 1;
  min-height: 0;
  padding: 0 18px calc(var(--nav-h) + var(--safe-b) + 26px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
#app-view::-webkit-scrollbar { display: none; }

.page { animation: page-in .26s ease both; }
@keyframes page-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .page { animation: none; } }

/* ---------- 3. Typography ---------- */
.page-head { padding: calc(var(--safe-t) + 22px) 2px 14px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.page-head > div { min-width: 0; }
.page-title { font-family: var(--serif); font-size: 27px; line-height: 1.25; font-weight: 700; letter-spacing: .5px; margin: 0; }
.page-sub { margin: 6px 0 0; color: var(--ink-2); font-size: 13px; letter-spacing: .2px; }
.page-head .head-action { flex: none; }
.section-title { font-family: var(--serif); font-size: 17px; font-weight: 700; margin: 26px 2px 12px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.section-title .more { font-family: var(--sans); font-size: 12px; font-weight: 400; color: var(--ink-2); display: flex; align-items: center; gap: 2px; }
.muted { color: var(--ink-2); }
.tiny { font-size: 12px; }
.mono { font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace; font-size: 12px; }
.divider { height: 1px; background: var(--line); margin: 16px 0; border: 0; }
.js-ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.clamp-2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.clamp-3 { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }

/* ---------- 4. Cards ---------- */
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid rgba(236, 231, 223, .8);
  padding: 18px;
}
.card + .card { margin-top: 12px; }
.card-title { font-family: var(--serif); font-size: 16px; font-weight: 700; display: flex; align-items: center; gap: 8px; margin: 0 0 12px; }
.card-title svg { width: 19px; height: 19px; flex: none; color: var(--brand); }
.card-title .more { margin-left: auto; font-family: var(--sans); font-size: 12px; font-weight: 400; color: var(--ink-2); }
.section-title .more svg { width: 14px; height: 14px; flex: none; }
.card-flat { box-shadow: none; background: var(--card-2); }

/* ---------- 5. Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  flex: none; min-width: 0;
  height: 44px; padding: 0 20px;
  border-radius: 999px;
  font-size: 15px; font-weight: 600; line-height: 1.2; letter-spacing: .3px;
  white-space: nowrap; user-select: none;
  background: var(--card); color: var(--ink);
  border: 1px solid var(--line);
  transition: transform .12s ease, background .16s ease, border-color .16s ease, color .16s ease, box-shadow .16s ease, opacity .16s ease;
}
.btn:active { transform: scale(.97); }
.btn svg { width: 18px; height: 18px; flex: none; }
.btn-primary { background: var(--brand); color: #fff; border-color: var(--brand); box-shadow: 0 6px 16px rgba(47, 107, 87, .22); }
.btn-accent { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn-danger { background: var(--red-soft); color: var(--red); border-color: transparent; }
.btn-soft { background: var(--brand-soft); color: var(--brand); border-color: transparent; }
.btn-block { display: flex; width: 100%; }
.btn-lg { height: 52px; font-size: 16px; }
.btn-sm { height: 36px; padding: 0 14px; font-size: 13px; }
.btn-icon, .btn-sm.btn-icon { width: 40px; height: 40px; padding: 0; flex: none; }
.btn-sm.btn-icon { width: 36px; height: 36px; }
.btn[disabled] { opacity: .45; pointer-events: none; }
button.chip { transition: transform .12s ease, background .16s ease, border-color .16s ease; }
button.chip:active { transform: scale(.96); }

/* ---------- 6. Chips / badges / level ---------- */
.chip {
  display: inline-flex; align-items: center; gap: 5px;
  height: 26px; padding: 0 10px;
  border-radius: 999px;
  background: var(--paper-2); color: var(--ink-1);
  font-size: 12px; line-height: 1; white-space: nowrap;
}
.chip-brand { background: var(--brand-soft); color: var(--brand); }
.chip-accent { background: var(--accent-soft); color: var(--accent); }
.chip-green { background: var(--green-soft); color: var(--green); }
.chip-yellow { background: var(--yellow-soft); color: #A97600; }
.chip-red { background: var(--red-soft); color: var(--red); }
.chip-outline { background: transparent; border: 1px solid var(--line); color: var(--ink-2); }
.badge { display: inline-flex; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--accent); color: #fff; font-size: 11px; font-weight: 700; align-items: center; justify-content: center; }
.level-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; display: inline-block; }
.level-green { background: var(--green); }
.level-yellow { background: var(--yellow); }
.level-red { background: var(--red); }
.level-ring { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font-size: 11px; font-weight: 700; flex: none; }
.level-ring.level-green { background: var(--green-soft); color: var(--green); }
.level-ring.level-yellow { background: var(--yellow-soft); color: #A97600; }
.level-ring.level-red { background: var(--red-soft); color: var(--red); }

/* ---------- 7. Home hero ---------- */
.hero {
  position: relative; overflow: hidden;
  border-radius: var(--radius-lg);
  padding: 22px;
  background: linear-gradient(150deg, #2F6B57 0%, #275A49 55%, #1F4A3C 100%);
  color: #fff;
  box-shadow: 0 14px 32px rgba(31, 74, 60, .28);
}
.hero::after {
  content: ""; position: absolute; right: -50px; top: -60px; width: 190px; height: 190px;
  border-radius: 50%; background: radial-gradient(circle, rgba(255,255,255,.16), transparent 68%);
}
.hero::before {
  content: ""; position: absolute; left: -40px; bottom: -90px; width: 170px; height: 170px;
  border-radius: 50%; border: 1px solid rgba(255,255,255,.14);
}
.hero-top { display: flex; gap: 18px; align-items: center; position: relative; z-index: 1; }
.hero-copy { flex: 1; min-width: 0; }
.hero-eyebrow { font-size: 12px; letter-spacing: 2px; opacity: .72; text-transform: uppercase; }
.hero-title { font-family: var(--serif); font-size: 23px; font-weight: 700; margin: 6px 0 8px; line-height: 1.35; }
.hero-desc { font-size: 12.5px; opacity: .8; margin: 0 0 16px; }
.hero .btn { height: 40px; font-size: 14px; background: #fff; color: var(--brand); border-color: #fff; box-shadow: none; }
.ring-wrap { position: relative; flex: none; width: 92px; height: 92px; }
.ring { transform: rotate(-90deg); }
.ring-track { stroke: rgba(255,255,255,.18); }
.ring-bar { stroke: #fff; stroke-linecap: round; transition: stroke-dashoffset .6s cubic-bezier(.22,.8,.3,1); }
.ring-label { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; }
.ring-num { font-family: var(--serif); font-size: 26px; font-weight: 700; line-height: 1; }
.ring-cap { font-size: 10.5px; opacity: .75; margin-top: 3px; letter-spacing: 1px; }

.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 12px; }
.stat { background: rgba(255,255,255,.12); border-radius: 14px; padding: 10px 12px; text-align: center; }
.stat b { display: block; font-family: var(--serif); font-size: 19px; font-weight: 700; line-height: 1.2; }
.stat span { font-size: 11px; opacity: .75; }

/* ---------- 8. Level cards ---------- */
.level-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.level-card {
  border-radius: var(--radius); padding: 14px 12px; text-align: left;
  background: var(--card); border: 1px solid var(--line);
  transition: transform .12s ease;
}
.level-card:active { transform: scale(.97); }
.level-card .lc-top { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--ink-2); }
.level-card b { display: block; font-family: var(--serif); font-size: 24px; line-height: 1.3; margin-top: 6px; }
.level-card small { font-size: 11px; color: var(--ink-3); }
.level-card.is-active { outline: 2px solid var(--brand); outline-offset: -2px; }
.level-card[data-level="green"] .lc-top .level-dot { background: var(--green); }
.level-card[data-level="yellow"] .lc-top .level-dot { background: var(--yellow); }
.level-card[data-level="red"] .lc-top .level-dot { background: var(--red); }

/* ---------- 9. Lists ---------- */
.list { display: flex; flex-direction: column; gap: 10px; }
.list-item {
  display: flex; align-items: center; gap: 12px;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px; box-shadow: var(--shadow);
  transition: transform .12s ease, border-color .16s ease;
  text-align: left; width: 100%;
}
.list-item:active { transform: scale(.985); }
.list-item.is-tappable:hover { border-color: var(--line-2); }
.li-main { flex: 1; min-width: 0; }
.li-title { font-size: 14.5px; font-weight: 500; color: var(--ink); }
.li-sub { font-size: 12px; color: var(--ink-2); margin-top: 3px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.li-chevron { color: var(--ink-3); flex: none; width: 16px; height: 16px; }
.row { display: flex; align-items: center; gap: 10px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.spacer { flex: 1; }

/* ---------- 10. Progress / bars ---------- */
.progress { height: 8px; border-radius: 999px; background: var(--paper-2); overflow: hidden; }
.progress > i { display: block; height: 100%; border-radius: 999px; background: var(--brand); transition: width .5s ease; }
.bar-chart { display: flex; align-items: flex-end; gap: 8px; height: 96px; margin-top: 8px; }
.bar-chart .bar { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 6px; height: 100%; }
.bar-chart .bar > i { display: block; width: 100%; max-width: 26px; border-radius: 6px 6px 3px 3px; background: var(--brand-soft); min-height: 3px; transition: height .4s ease; }
.bar-chart .bar.is-today > i { background: var(--brand); }
.bar-chart .bar > span { font-size: 10px; color: var(--ink-3); }

/* ---------- 11. Question card ---------- */
.question-card { background: var(--card); border-radius: var(--radius-lg); padding: 20px 20px 16px; box-shadow: var(--shadow); border: 1px solid rgba(236,231,223,.9); }
.q-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.q-index { font-family: var(--serif); font-size: 13px; color: var(--ink-2); letter-spacing: .5px; }
.q-stem { font-size: 17px; line-height: 1.7; color: var(--ink); letter-spacing: .2px; white-space: pre-wrap; }
.q-stem .blank { border-bottom: 1.5px solid var(--ink-3); display: inline-block; min-width: 44px; }
.q-options { display: flex; flex-direction: column; gap: 10px; margin-top: 18px; }
.q-option {
  display: flex; align-items: flex-start; gap: 12px; width: 100%;
  padding: 13px 14px; border-radius: 14px;
  border: 1.5px solid var(--line); background: var(--card-2);
  text-align: left; font-size: 15px; line-height: 1.6;
  transition: border-color .16s, background .16s, transform .12s;
}
.q-option:active { transform: scale(.99); }
.q-option .opt-key {
  flex: none; width: 24px; height: 24px; border-radius: 50%;
  display: grid; place-items: center;
  border: 1.5px solid var(--ink-3); color: var(--ink-2);
  font-size: 12px; font-weight: 700; margin-top: 1px;
  transition: all .16s;
}
.q-option .opt-text { flex: 1; min-width: 0; }
.q-option.selected { border-color: var(--brand); background: var(--brand-soft); }
.q-option.selected .opt-key { background: var(--brand); border-color: var(--brand); color: #fff; }
.q-option.correct { border-color: var(--green); background: var(--green-soft); }
.q-option.correct .opt-key { background: var(--green); border-color: var(--green); color: #fff; }
.q-option.wrong { border-color: var(--red); background: var(--red-soft); }
.q-option.wrong .opt-key { background: var(--red); border-color: var(--red); color: #fff; }
.q-option.is-disabled { pointer-events: none; }
.q-source { margin-top: 14px; font-size: 12px; color: var(--ink-3); }

/* 答题结果 / 解析 */
.result-banner {
  display: flex; align-items: center; gap: 10px;
  border-radius: 14px; padding: 12px 14px; margin-top: 16px;
  font-size: 14px; font-weight: 600;
}
.result-banner.ok { background: var(--green-soft); color: var(--green); }
.result-banner.bad { background: var(--red-soft); color: var(--red); }
.result-banner .rb-icon { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; background: currentColor; }
.result-banner .rb-icon svg { width: 13px; height: 13px; stroke: #fff; }
.answer-box { margin-top: 12px; border-radius: 14px; background: var(--card-2); border: 1px dashed var(--line); padding: 14px; }
.answer-row { display: flex; align-items: baseline; gap: 10px; font-size: 14px; }
.answer-row + .answer-row { margin-top: 8px; }
.answer-row .k { color: var(--ink-2); font-size: 12.5px; flex: none; width: 56px; }
.answer-row .v { font-weight: 600; letter-spacing: 1px; display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.answer-row .v.good { color: var(--green); }
.answer-row .v.bad { color: var(--red); }
.explain-toggle {
  display: flex; align-items: center; justify-content: center; gap: 6px; width: 100%;
  height: 44px; margin-top: 12px; border-radius: 999px;
  background: var(--paper-2); color: var(--ink-1); font-size: 14px; font-weight: 600;
  transition: background .16s;
}
.explain-toggle:active { background: var(--line); }
.explain-toggle svg { width: 16px; height: 16px; transition: transform .2s; }
.explain-toggle.is-open svg { transform: rotate(180deg); }
.explain-box {
  margin-top: 12px; border-radius: 14px; background: var(--brand-soft);
  color: #20493C; padding: 15px 16px; font-size: 14px; line-height: 1.75;
  white-space: pre-wrap; animation: page-in .2s ease both;
}
.explain-box .ex-title { font-family: var(--serif); font-weight: 700; margin-bottom: 6px; display: flex; align-items: center; gap: 6px; }
.explain-box .ex-title svg { width: 16px; height: 16px; flex: none; }

/* 底部答题操作条 */
.quiz-bar {
  position: sticky; bottom: 0; z-index: 5;
  margin: 18px -18px 0; padding: 12px 18px calc(12px + var(--safe-b));
  background: linear-gradient(to top, var(--paper) 62%, rgba(246,243,238,0));
  display: flex; align-items: center; gap: 10px;
}
.quiz-bar .btn { flex: 1; }
.quiz-bar .btn, .quiz-bar .btn-sm { height: 48px; border-radius: 14px; }
.quiz-bar .btn-ghost { background: var(--card); border-color: var(--line); color: var(--ink-1); }

/* 答题进度 */
.quiz-progress { display: flex; align-items: center; gap: 10px; }
.quiz-progress .progress { flex: 1; }
.quiz-progress span { font-size: 12px; color: var(--ink-2); flex: none; }

/* ---------- 12. Review / level badge ---------- */
.review-badge { display: inline-flex; align-items: center; gap: 5px; }

/* ---------- 13. Segmented / tabs ---------- */
.segmented { display: flex; gap: 4px; background: var(--paper-2); padding: 4px; border-radius: 999px; }
.segmented > button { flex: 1; height: 32px; border-radius: 999px; font-size: 13px; color: var(--ink-2); font-weight: 500; transition: all .16s; }
.segmented > button.active { background: var(--card); color: var(--ink); box-shadow: 0 1px 4px rgba(28,27,25,.08); font-weight: 600; }
.tabs { display: flex; gap: 18px; border-bottom: 1px solid var(--line); margin: 16px 0 12px; }
.tabs > button { position: relative; padding: 8px 0 12px; font-size: 14px; color: var(--ink-2); }
.tabs > button.active { color: var(--ink); font-weight: 700; }
.tabs > button.active::after { content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; border-radius: 2px; background: var(--brand); }

/* ---------- 14. Forms ---------- */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; color: var(--ink-2); margin-bottom: 6px; }
.input, .textarea, .select {
  width: 100%; border-radius: 12px; border: 1.5px solid var(--line);
  background: var(--card-2); padding: 12px 14px; font-size: 14.5px; outline: none;
  transition: border-color .16s, background .16s;
}
.input:focus, .textarea:focus, .select:focus { border-color: var(--brand); background: #fff; }
.textarea { min-height: 96px; resize: vertical; line-height: 1.65; }
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 14px 0; border-bottom: 1px solid var(--line-2); }
.switch-row:last-child { border-bottom: 0; }
.switch-row .sw-title { font-size: 14.5px; }
.switch-row .sw-sub { font-size: 12px; color: var(--ink-2); margin-top: 2px; }
.switch { position: relative; width: 46px; height: 28px; border-radius: 999px; background: var(--line); transition: background .2s; flex: none; }
.switch::after { content: ""; position: absolute; left: 3px; top: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.2); transition: transform .2s; }
.switch.on { background: var(--brand); }
.switch.on::after { transform: translateX(18px); }

/* ---------- 15. Bottom nav ---------- */
.tabbar {
  position: sticky; bottom: 0; z-index: 20;
  display: flex; align-items: stretch;
  background: rgba(251, 250, 247, .92);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
  padding-bottom: var(--safe-b);
}
.tabbar button {
  flex: 1; height: var(--nav-h); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: var(--ink-3); font-size: 10.5px; letter-spacing: .5px;
  transition: color .16s;
  position: relative;
}
.tabbar button svg { width: 22px; height: 22px; }
.tabbar button.active { color: var(--brand); font-weight: 600; }
.tabbar button .tab-dot { position: absolute; top: 9px; right: calc(50% - 16px); width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }

/* ---------- 16. Empty / loading ---------- */
.empty { text-align: center; padding: 46px 20px; color: var(--ink-2); }
.empty .emoji { font-family: var(--serif); font-size: 40px; margin-bottom: 10px; opacity: .55; }
.empty h3 { font-family: var(--serif); font-size: 17px; color: var(--ink-1); margin: 0 0 6px; font-weight: 700; }
.empty p { font-size: 13px; margin: 0 0 18px; }
.loading { padding: 60px 0; text-align: center; color: var(--ink-2); font-size: 13px; }
.spinner { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--line); border-top-color: var(--brand); animation: spin .8s linear infinite; margin: 0 auto 10px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- 17. Toast / modal / sheet ---------- */
.toast-wrap { position: fixed; left: 0; right: 0; bottom: calc(var(--nav-h) + var(--safe-b) + 18px); display: flex; flex-direction: column; align-items: center; gap: 8px; z-index: 90; pointer-events: none; }
.toast {
  max-width: 88%;
  background: rgba(28, 27, 25, .92); color: #fff; font-size: 13.5px;
  padding: 10px 18px; border-radius: 999px;
  box-shadow: var(--shadow-lg);
  animation: toast-in .24s ease both;
}
.toast.err { background: rgba(214, 69, 65, .96); }
.toast.ok { background: rgba(47, 107, 87, .96); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px) scale(.96); } to { opacity: 1; transform: none; } }

.overlay {
  position: fixed; inset: 0; z-index: 80;
  background: rgba(28, 27, 25, .38);
  display: flex; align-items: flex-end; justify-content: center;
  animation: fade-in .2s ease both;
  padding: 0; 
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
.modal-card, .sheet-card {
  width: 100%; max-width: 520px;
  background: var(--card); border-radius: 22px 22px 0 0;
  padding: 20px 20px calc(20px + var(--safe-b));
  max-height: 86dvh; overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  animation: sheet-up .28s cubic-bezier(.22,.8,.3,1) both;
}
.overlay.center { align-items: center; padding: 24px; }
.overlay.center .modal-card { border-radius: 22px; animation: page-in .22s ease both; }
@keyframes sheet-up { from { transform: translateY(24px); opacity: .6; } to { transform: none; opacity: 1; } }
.sheet-handle { width: 38px; height: 4px; border-radius: 2px; background: var(--line); margin: -6px auto 14px; }
.modal-title { font-family: var(--serif); font-size: 18px; font-weight: 700; margin: 0; }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.modal-head .modal-close { margin: -6px -8px -6px 0; }
.modal-body { font-size: 14px; color: var(--ink-1); line-height: 1.7; }
.modal-actions { display: flex; gap: 10px; margin-top: 20px; }
.modal-actions .btn { flex: 1; height: 46px; border-radius: 14px; }

/* ---------- 18. Utility ---------- */
.mt-8 { margin-top: 8px; } .mt-12 { margin-top: 12px; } .mt-16 { margin-top: 16px; } .mt-24 { margin-top: 24px; }
.mb-0 { margin-bottom: 0; }
.hide { display: none !important; }
.tap { cursor: pointer; }
.tap:active { opacity: .7; }
.scroll-x { display: flex; gap: 10px; overflow-x: auto; padding: 2px 0 6px; scrollbar-width: none; }
.scroll-x::-webkit-scrollbar { display: none; }
.scroll-x > * { flex: none; }
.grow { flex: 1; min-width: 0; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.hairline { height: 1px; background: var(--line); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.stat-grid { display: grid; }
.kv { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--line-2); font-size: 14px; }
.kv:last-child { border-bottom: 0; }
.kv .k { color: var(--ink-2); font-size: 13px; }
.kv .v { font-weight: 600; }

/* ============================================================
   19. 桌面 / 横屏适配（>= 900px）
   手机端仍然是不背单词式的单栏 + 底部五栏；PC 横屏改成
   「左侧竖向导航 + 宽内容区 + 双栏排布」，答题页居中收窄更易读。
   ============================================================ */
.only-desktop { display: none !important; }

@media (min-width: 900px) {
  body {
    padding: 0;
    background:
      radial-gradient(1400px 700px at 12% -10%, #FBF8F2 0%, transparent 62%),
      radial-gradient(1000px 600px at 100% 0%, #F0EAE0 0%, transparent 58%),
      var(--paper-2);
  }

  /* --- 应用外壳：左导航 + 内容 --- */
  #app {
    max-width: 1320px;
    min-height: 100dvh;
    height: 100dvh;
    border-radius: 0;
    box-shadow: 0 0 90px rgba(28, 27, 25, .10);
    display: grid;
    grid-template-columns: 108px minmax(0, 1fr);
    grid-template-rows: 100dvh;
    overflow: hidden;
  }
  #app-view {
    grid-column: 2; grid-row: 1;
    height: 100dvh; overflow-y: auto;
    padding: 0;
    scrollbar-width: thin;
  }
  #app-view::-webkit-scrollbar { width: 8px; display: block; }
  #app-view::-webkit-scrollbar-thumb { background: #DED8CD; border-radius: 8px; }

  .tabbar {
    grid-column: 1; grid-row: 1;
    position: sticky; top: 0;
    height: 100dvh;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    gap: 6px;
    padding: 22px 12px;
    border-top: 0;
    border-right: 1px solid var(--line);
    background: rgba(251, 250, 247, .96);
    backdrop-filter: blur(16px);
  }
  .tabbar button {
    flex: none;
    height: 64px;
    border-radius: 16px;
    gap: 7px;
    font-size: 12px;
    letter-spacing: .5px;
    transition: background .16s, color .16s;
  }
  .tabbar button svg { width: 24px; height: 24px; }
  .tabbar button:hover { background: var(--paper-2); color: var(--ink-1); }
  .tabbar button.active { background: var(--brand-soft); color: var(--brand); }
  .tabbar button .tab-dot { top: 15px; right: calc(50% - 19px); }

  /* --- 页面容器 --- */
  .page {
    max-width: 1120px;
    margin: 0 auto;
    padding: 28px 44px 48px;
  }
  .page-head { padding: 12px 2px 18px; }
  .page-title { font-size: 31px; }
  .page-sub { font-size: 13.5px; }
  .section-title { font-size: 18px; margin: 30px 2px 14px; }

  /* 答题 / 复习页在宽屏上居中收窄，一次只专注一道题 */
  .page.quiz-page { max-width: 900px; }
  .page.quiz-page .question-card { padding: 26px 26px 20px; }
  .page.quiz-page .q-stem { font-size: 18px; }
  .page.quiz-page .quiz-bar {
    margin: 20px 0 0;
    padding: 14px 0 18px;
    background: linear-gradient(to top, var(--paper) 72%, rgba(246, 243, 238, 0));
  }
  .page.quiz-page .quiz-bar .btn { max-width: 260px; }
  .page.quiz-page .quiz-bar .btn:last-child { margin-left: auto; }

  /* 首页：主栏 + 侧栏（复习曲线 / 题库入口） */
  .home-cols { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); gap: 0 32px; align-items: start; }
  .home-side { position: sticky; top: 20px; }
  .home-side .section-title:first-child { margin-top: 0; }
  .home-main .hero { margin-top: 0; }
  .grid-2 { gap: 12px; }
  .hero-title { font-size: 26px; }
  .hero .ring-wrap { transform: scale(1.08); }

  /* 错题本 / 题库的列表在宽屏上双栏 */
  #app-view .list[data-ref="list"],
  #app-view .list[data-ref="qlist"] {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 10px;
  }
  #app-view .list[data-ref="list"] .list-item,
  #app-view .list[data-ref="qlist"] .list-item { background: var(--card); border-radius: var(--radius); }

  /* 统计页：指标四栏并排 */
  .v-stat-grid { grid-template-columns: repeat(4, minmax(0, 1fr)) !important; }
  .v-ch-wrap, .v-chart { max-width: none; }

  /* 设置页比较窄，保持单列可读 */
  #app-view[data-view="settings"] .page { max-width: 860px; }

  /* 桌面提示文字 */
  .only-desktop { display: inline-flex !important; }

  /* 弹层在桌面上居中呈现为对话框 */
  .overlay { align-items: center; padding: 30px; }
  .modal-card, .sheet-card {
    border-radius: 22px;
    max-width: 560px;
    max-height: 82dvh;
    padding: 24px 24px 22px;
  }
  .sheet-handle { display: none; }
}

/* ============================================================
   20. 桌面端细化（>= 900px，在 19 之上的补充）
   ============================================================ */
@media (min-width: 900px) {
  /* 题库页：操作按钮 4 列、题库卡片 2 列 */
  #app-view[data-view="library"] .v-ops .v-btn-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  #app-view[data-view="library"] [data-ref="banks"] {
    display: grid; grid-template-columns: 1fr 1fr; gap: 12px;
    align-items: stretch; grid-auto-rows: minmax(0, 1fr);
  }
  #app-view[data-view="library"] [data-ref="banks"] > .card { height: 100%; margin: 0; }

  /* 桌面交互反馈（鼠标悬停） */
  @media (hover: hover) {
    .v-quick, .level-card, .list-item, .v-wrong-item, .v-bank, .quick-card {
      transition: box-shadow .16s ease, transform .16s ease, border-color .16s ease;
    }
    .v-quick:hover, .level-card:hover, .v-wrong-item:hover, .v-bank:hover, .quick-card:hover {
      transform: translateY(-1px);
      box-shadow: 0 12px 28px rgba(28, 27, 25, .09);
    }
    .list-item:hover { background: #FFFDF9; border-color: var(--line-2, #E6E0D6); }
    .btn:hover { filter: brightness(1.03); }
    .q-option:hover { border-color: var(--brand); background: #FFFDFA; }
    .q-option.selected:hover, .q-option.correct:hover, .q-option.wrong:hover { filter: none; }
    .tabbar [data-tab]:hover { background: rgba(47, 107, 87, .07); }
  }

  /* 键盘可达性 */
  :focus-visible { outline: 3px solid rgba(47, 107, 87, .30); outline-offset: 2px; border-radius: 10px; }
}

/* ============================================================
   21. 对齐与交互精修
   ============================================================ */
#app-view.is-rerender .page { animation: none; }
/* 网格里的卡片按钮必须同宽同高，不能继承“相邻卡片”的上边距 */
.grid-2 { grid-auto-rows: minmax(0, 1fr); }
.grid-2 > .card { height: 100%; min-width: 0; margin: 0; }
#app-view[data-view="library"] [data-ref="banks"] { grid-auto-rows: minmax(0, 1fr); }
#app-view[data-view="library"] [data-ref="banks"] > .card { margin: 0; }
.head-action { align-self: center; }
.empty .row { flex-wrap: wrap; }
.q-option[aria-pressed="true"] { border-color: var(--brand); }
.chip[data-set-level], .chip[data-fix-level] { min-height: 34px; padding: 0 12px; }
.explain-toggle { border: 1px solid transparent; }
.v-loadmore { display: flex; justify-content: center; }
.v-loadmore[hidden] { display: none; }
.v-loadmore .btn { width: min(100%, 320px); }

@media (hover: hover) {
  .btn-ghost:hover { background: var(--paper-2); color: var(--ink-1); }
  .btn-soft:hover { background: #DDE9E1; }
  .btn-danger:hover { background: #F6DEDB; }
  .explain-toggle:hover { background: var(--line); }
  button.chip:hover { border-color: var(--brand); }
}

@media (min-width: 900px) {
  .page.quiz-page .quiz-bar { justify-content: flex-end; }
  .page.quiz-page .quiz-bar .btn:first-child:not(:last-child) { margin-right: auto; margin-left: 0; }
  .page.quiz-page .quiz-bar .btn:last-child { margin-left: 0; }
  #app-view[data-view="library"] [data-ref="banks"] { align-items: stretch; }
  #app-view[data-view="library"] [data-ref="banks"] > .v-bank {
    align-self: stretch; height: 100%; margin: 0; min-height: 176px;
  }
  #app-view .list[data-ref="list"], #app-view .list[data-ref="qlist"] { align-items: stretch; }
  #app-view .list[data-ref="list"] > .list-item,
  #app-view .list[data-ref="qlist"] > .list-item { height: 100%; }
}

/* ---------- 22. 学习增强：笔记 / 错因 / 题单 ---------- */
.learning-favorite { margin-left: auto; color: var(--ink-3); }
.learning-favorite.is-active, .learning-tool.is-active { color: var(--accent); }
.learning-favorite.is-active svg, .learning-tool.is-active svg { fill: currentColor; }
.learning-tools {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(0, 1fr));
  gap: 8px; margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line);
}
.learning-tool {
  position: relative; min-width: 0; min-height: 44px; padding: 8px 6px;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--line); border-radius: 12px; background: var(--card-2);
  color: var(--ink-1); font-size: 13px; font-weight: 600; line-height: 1.25;
  transition: transform .12s ease, background .16s ease, color .16s ease;
}
.learning-tool:active { transform: scale(.97); }
.learning-tool svg { width: 17px; height: 17px; }
.learning-tool.is-active { background: var(--accent-soft); border-color: transparent; }
.learning-tool.is-active svg { fill: none; }
.note-dot { position: absolute; top: 7px; right: 9px; width: 5px; height: 5px; border-radius: 50%; background: var(--accent); }
.note-preview { margin-top: 12px; padding: 15px 16px; border-radius: 14px; background: var(--brand-soft); }
.note-preview-title { display: flex; align-items: center; gap: 7px; color: var(--brand); font-weight: 700; font-size: 14px; margin-bottom: 8px; }
.note-preview-row { display: grid; grid-template-columns: 64px minmax(0,1fr); gap: 10px; padding: 7px 0; }
.note-preview-row + .note-preview-row { border-top: 1px solid rgba(47,107,87,.10); }
.note-preview-row > span { color: var(--brand); font-size: 12px; font-weight: 600; }
.note-preview-row p { margin: 0; font-size: 14px; line-height: 1.7; white-space: pre-wrap; overflow-wrap: anywhere; }
.reason-box { margin-top: 14px; padding: 14px; border-radius: 14px; background: var(--card-2); border: 1px solid var(--line-2); }
.reason-title { font-size: 13px; font-weight: 700; margin-bottom: 10px; }
.reason-title span { margin-left: 6px; color: var(--ink-2); font-size: 11px; font-weight: 400; }
.reason-chips { display: flex; flex-wrap: wrap; gap: 7px; }
.reason-chips .chip { min-height: 34px; }
.note-editor-stem { max-height: 82px; overflow: auto; margin-bottom: 16px; padding: 11px 13px; border-radius: 12px; background: var(--card-2); color: var(--ink-2); font-size: 13px; line-height: 1.6; }
.note-field { display: block; margin-top: 13px; }
.note-field > span { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; font-size: 13px; font-weight: 700; }
.note-field > span small { color: var(--ink-3); font-size: 11px; font-weight: 400; }
.note-field .textarea { width: 100%; min-height: 76px; resize: vertical; line-height: 1.65; }
.note-editor-actions { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 18px; }
.list-picker-new { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 8px; margin-bottom: 14px; }
.list-picker-new .input, .list-picker-new .btn { height: 44px; }
.list-picker-items { max-height: min(48vh, 430px); overflow-y: auto; display: grid; gap: 8px; }
.list-picker-item { min-height: 56px; padding: 9px 12px; display: flex; align-items: center; gap: 11px; text-align: left; border-radius: 13px; border: 1px solid var(--line); background: var(--card); }
.list-picker-item.is-selected { background: var(--brand-soft); border-color: rgba(47,107,87,.18); color: var(--brand); }
.list-picker-item .grow { min-width: 0; font-weight: 600; }
.list-picker-item small { display: block; color: var(--ink-2); font-size: 11px; font-weight: 400; }
.list-check { width: 30px; height: 30px; display: inline-flex; align-items: center; justify-content: center; border-radius: 50%; background: var(--paper); }
@media (max-width: 380px) {
  .learning-tool { font-size: 12px; gap: 4px; }
  .reason-title span { display: block; margin: 2px 0 0; }
  .note-preview-row { grid-template-columns: 58px minmax(0,1fr); }
}

/* ---------- 23. PWA 更新提示 ---------- */
.pwa-update[hidden] { display: none !important; }
.pwa-update {
  position: fixed; z-index: 1600; left: 50%; bottom: calc(86px + env(safe-area-inset-bottom));
  transform: translateX(-50%); width: min(520px, calc(100% - 28px));
  display: flex; align-items: center; gap: 11px; padding: 12px 12px 12px 14px;
  border: 1px solid rgba(255,255,255,.16); border-radius: 17px;
  background: rgba(35,61,52,.96); color: #fff;
  box-shadow: 0 14px 36px rgba(24,47,38,.26); backdrop-filter: blur(16px);
  animation: pwa-update-in .22s ease-out both;
}
.pwa-update-icon {
  flex: none; width: 34px; height: 34px; display: grid; place-items: center;
  border-radius: 11px; background: rgba(255,255,255,.13); color: #DCEADF;
  font-size: 21px; font-weight: 700;
}
.pwa-update-copy { flex: 1; min-width: 0; }
.pwa-update-copy strong { display: block; font-size: 14px; line-height: 1.4; }
.pwa-update-copy small { display: block; margin-top: 2px; color: rgba(255,255,255,.70); font-size: 11px; }
.pwa-update button { min-height: 40px; border-radius: 11px; font-weight: 700; }
.pwa-update-now { flex: none; padding: 0 14px; background: #F6F3EE; color: var(--brand); }
.pwa-update-later { flex: none; width: 32px; padding: 0; background: transparent; color: rgba(255,255,255,.68); font-size: 22px; }
@media (min-width: 900px) {
  .pwa-update { bottom: 28px; }
}
@media (max-width: 380px) {
  .pwa-update { gap: 8px; padding-left: 11px; }
  .pwa-update-copy small { display: none; }
  .pwa-update-now { padding: 0 11px; font-size: 12px; }
}
@keyframes pwa-update-in {
  from { opacity: 0; transform: translate(-50%, 10px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}
@media (prefers-reduced-motion: reduce) {
  .pwa-update { animation: none; }
}
