/* 小奥错题本 · 样式 */
:root {
  --bg: #f6f3ec;
  --bg-deep: #efe9dd;
  --card: #ffffff;
  --ink: #1d2530;
  --ink-2: #414b5a;
  --muted: #67707f;
  --line: #e9e2d4;
  --brand: #2f5fd0;
  --brand-dark: #244aa8;
  --brand-soft: #e9efff;
  --accent: #e0742c;
  --accent-strong: #b8571f;
  --accent-soft: #fff0e5;
  --green: #23885e;
  --green-soft: #e6f6ee;
  --red: #c04541;
  --red-soft: #fdecec;
  --shadow: 0 2px 4px rgba(29, 37, 48, .04), 0 10px 24px -12px rgba(29, 37, 48, .18);
  --radius: 18px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --font: "PingFang SC", "HarmonyOS Sans SC", "Microsoft YaHei", "Noto Sans SC", system-ui, -apple-system, sans-serif;
  --serif: "Songti SC", "Noto Serif SC", Georgia, serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { background: var(--bg); -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(1200px 500px at 50% -240px, #ffffff 0%, rgba(255,255,255,0) 70%),
    var(--bg);
  -webkit-font-smoothing: antialiased;
  line-height: 1.55;
  font-size: 16px;
  min-height: 100dvh;
}
img { max-width: 100%; display: block; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--brand); text-decoration: none; }
h1, h2, h3, h4, p { margin: 0; }
ul, ol { margin: 0; padding-left: 1.2em; }
[hidden] { display: none !important; }

.app-shell { max-width: 780px; margin: 0 auto; min-height: 100vh; min-height: 100dvh; position: relative; }
.app-main {
  padding: calc(18px + env(safe-area-inset-top, 0px)) 16px calc(104px + var(--safe-b));
  min-height: 100vh; min-height: 100dvh;
}

/* ---------- 顶栏 ---------- */
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.page-head .eyebrow { font-size: 12px; letter-spacing: .12em; color: var(--muted); text-transform: uppercase; margin-bottom: 2px; }
.page-head h1 { font-size: 24px; letter-spacing: -.02em; line-height: 1.25; }
.page-head .sub { color: var(--muted); font-size: 13px; margin-top: 4px; }
.head-actions { display: flex; gap: 8px; align-items: center; }

.icon-btn {
  width: 38px; height: 38px; border-radius: 12px; border: 1px solid var(--line);
  background: rgba(255,255,255,.7); display: inline-grid; place-items: center;
  font-size: 15px; color: var(--ink-2); line-height: 1;
}
.icon-btn:active { transform: scale(.96); }

/* ---------- 卡片 ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
}
.card + .card { margin-top: 12px; }
.card.flat { box-shadow: none; }
.section { margin-top: 22px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 10px; }
.section-head h2 { font-size: 16px; letter-spacing: -.01em; }
.section-head .more { font-size: 13px; color: var(--muted); }
.section-head .more:active { opacity: .6; }
@media (min-width: 640px) { .card { padding: 18px; } }

/* ---------- 首页主卡 ---------- */
.hero {
  position: relative; overflow: hidden; border: 1px solid #dbe4fb;
  background: linear-gradient(135deg, #ffffff 0%, #f2f6ff 55%, #ecf1ff 100%);
}
.hero::after {
  content: ""; position: absolute; right: -60px; top: -70px; width: 200px; height: 200px;
  border-radius: 50%; background: radial-gradient(circle, rgba(47,95,208,.16), rgba(47,95,208,0) 70%);
}
.hero-top { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; position: relative; z-index: 1; }
.hero-title { font-size: 20px; line-height: 1.35; letter-spacing: -.02em; }
.hero-title b { color: var(--brand); font-weight: 800; }
.hero-sub { color: var(--muted); font-size: 13px; margin-top: 6px; }
.hero-actions { display: flex; gap: 10px; margin-top: 16px; position: relative; z-index: 1; flex-wrap: wrap; }
.hero-actions .btn { flex: 1 1 auto; min-width: 140px; }
.due-badge {
  flex: none; width: 84px; height: 84px; border-radius: 50%;
  display: grid; place-items: center; text-align: center;
  background: conic-gradient(var(--brand) var(--p, 0%), #e4e9f6 0);
  position: relative;
}
.due-badge::before { content: ""; position: absolute; inset: 7px; border-radius: 50%; background: #fff; }
.due-badge > div { position: relative; z-index: 1; line-height: 1.1; }
.due-badge b { display: block; font-size: 26px; font-weight: 800; color: var(--brand); }
.due-badge span { font-size: 11px; color: var(--muted); }

.stat-strip { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 12px; }
.stat-strip .stat { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 10px 12px; }
.stat .num { font-size: 20px; font-weight: 800; letter-spacing: -.02em; }
.stat .lbl { font-size: 11px; color: var(--muted); margin-top: 1px; }

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  min-height: 44px; padding: 0 18px; border-radius: 13px; border: 1px solid transparent;
  background: #fff; color: var(--ink); font-size: 15px; font-weight: 600;
  transition: transform .12s ease, box-shadow .12s ease, opacity .12s;
  white-space: nowrap;
}
.btn:active { transform: scale(.975); }
.btn:disabled { opacity: .5; pointer-events: none; }
.btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.btn-primary { background: linear-gradient(180deg, #3a6bdb, var(--brand)); color: #fff; box-shadow: 0 6px 16px -8px rgba(47,95,208,.8); }
.btn-accent { background: linear-gradient(180deg, #c25a1c, #a84a12); color: #fff; box-shadow: 0 6px 16px -8px rgba(168,74,18,.7); }
.btn-soft { background: var(--brand-soft); color: var(--brand-dark); border-color: #dbe4fb; }
.btn-ghost { background: #fff; border-color: var(--line); color: var(--ink-2); }
.btn-danger { background: var(--red-soft); color: #b23b38; border-color: #f6d5d4; }
.btn-sm { min-height: 34px; padding: 0 12px; font-size: 13px; border-radius: 10px; }
.btn-block { width: 100%; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }
.btn-row > .btn { flex: 1 1 0; min-width: 0; }

/* ---------- 标签 ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 5px; padding: 5px 11px; border-radius: 999px;
  background: #f3f0e8; color: var(--ink-2); font-size: 12.5px; border: 1px solid transparent; line-height: 1.5;
}
.chip.brand { background: var(--brand-soft); color: var(--brand-dark); }
.chip.accent { background: var(--accent-soft); color: #b8571f; }
.chip.green { background: var(--green-soft); color: #1f7a54; }
.chip.red { background: var(--red-soft); color: #b23b38; }
.chip.due { background: #fff6e6; color: #a8620a; border-color: #f7e3bd; }
.chip.pick { cursor: pointer; border: 1px dashed var(--line); background: #fff; }
.chip.pick.on { background: var(--brand); color: #fff; border-color: var(--brand); border-style: solid; }
.chip .x { opacity: .55; font-size: 14px; line-height: 1; }

/* ---------- 表单 ---------- */
.field { margin-top: 14px; }
.field:first-child { margin-top: 0; }
.field > label, .field-label { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 13px; font-weight: 600; color: var(--ink-2); margin-bottom: 6px; }
.field .hint { font-weight: 400; color: var(--muted); font-size: 11.5px; }
.input, .textarea, .select {
  width: 100%; border: 1px solid var(--line); border-radius: 12px; background: #fff;
  padding: 11px 13px; font-size: 16px; outline: none; transition: border-color .15s, box-shadow .15s;
}
.textarea { min-height: 92px; resize: vertical; line-height: 1.6; }
.input:focus, .textarea:focus, .select:focus { border-color: #a9bff3; box-shadow: 0 0 0 3px rgba(47,95,208,.1); }
.input::placeholder, .textarea::placeholder { color: #7e8798; }
.input-error { border-color: var(--red) !important; box-shadow: 0 0 0 3px rgba(192,69,65,.14) !important; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 480px) { .form-grid { grid-template-columns: 1fr; } }
.stars { display: flex; gap: 4px; font-size: 22px; line-height: 1; color: #e2dccd; user-select: none; }
.stars button { background: none; border: 0; padding: 2px; font-size: 22px; color: inherit; line-height: 1; }
.stars button.on { color: var(--accent); }

/* ---------- 错题列表 ---------- */
.list { display: flex; flex-direction: column; gap: 10px; }
.item {
  display: flex; gap: 12px; padding: 12px; border-radius: 16px; background: var(--card);
  border: 1px solid var(--line); box-shadow: 0 1px 2px rgba(29,37,48,.03); cursor: pointer;
  transition: transform .12s, border-color .12s;
}
.item:active { transform: scale(.99); border-color: #cfd9ef; }
.item-thumb {
  flex: none; width: 74px; height: 74px; border-radius: 12px; overflow: hidden; background: var(--bg-deep);
  display: grid; place-items: center; color: var(--muted); font-size: 22px; font-family: var(--serif);
  border: 1px solid #efe9dc;
}
.item-thumb img { width: 100%; height: 100%; object-fit: cover; }
.item-main { flex: 1; min-width: 0; }
.item-stem {
  font-size: 14.5px; line-height: 1.5; color: var(--ink);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  word-break: break-word;
}
.item-meta { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; align-items: center; }
.item-meta .dot { color: #d4cec0; }
.item-side { flex: none; display: flex; flex-direction: column; align-items: flex-end; justify-content: space-between; }
.star-btn { border: 0; background: none; font-size: 17px; line-height: 1; color: #d8d2c4; padding: 6px; margin: -4px -4px 0 0; }
.star-btn.on { color: #f2b23e; }
.mini-date { font-size: 11px; color: var(--muted); white-space: nowrap; }

.empty { text-align: center; padding: 40px 20px; color: var(--muted); }
.empty .glyph { font-size: 40px; margin-bottom: 10px; opacity: .8; font-family: var(--serif); }
.empty h3 { color: var(--ink-2); font-size: 15px; margin-bottom: 4px; }
.empty p { font-size: 13px; }
.empty .btn { margin-top: 16px; }

.filters { position: sticky; top: 0; z-index: 5; background: linear-gradient(var(--bg) 78%, rgba(246,243,236,0)); padding: 4px 0 10px; margin-top: -4px; }
.search { position: relative; }
.search svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 17px; height: 17px; fill: none; stroke: var(--muted); stroke-width: 2; }
.search .input { padding-left: 38px; background: #fff; box-shadow: 0 1px 2px rgba(29,37,48,.03); }
.filter-row { display: flex; gap: 7px; overflow-x: auto; margin-top: 9px; padding-bottom: 2px; scrollbar-width: none; }
.filter-row::-webkit-scrollbar { display: none; }
.filter-row .chip { flex: none; background: #fff; border: 1px solid var(--line); padding: 8px 13px; }
.filter-row .chip.on { background: var(--ink); color: #fff; border-color: var(--ink); }

/* ---------- 详情 ---------- */
.detail-img { border-radius: 14px; border: 1px solid var(--line); overflow: hidden; background: #fff; cursor: zoom-in; }
.detail-img img { width: 100%; max-height: 42vh; object-fit: contain; }
.qa-block { margin-top: 14px; padding-top: 14px; border-top: 1px dashed var(--line); }
.qa-block:first-child { margin-top: 0; padding-top: 0; border-top: 0; }
.qa-label { font-size: 11.5px; font-weight: 700; letter-spacing: .08em; color: var(--muted); margin-bottom: 5px; }
.stem-text { font-family: var(--serif); font-size: 17px; line-height: 1.75; white-space: pre-wrap; word-break: break-word; }
.prose { font-size: 14.5px; line-height: 1.8; white-space: pre-wrap; word-break: break-word; color: var(--ink-2); }
.answer-text { font-size: 17px; font-weight: 700; color: #1f7a54; word-break: break-word; }
.myanswer-text { font-size: 15px; color: var(--red); text-decoration: line-through; text-decoration-color: rgba(217,83,79,.35); word-break: break-word; }
.reveal-mask { filter: blur(7px); user-select: none; cursor: pointer; }
.meta-table { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px 14px; font-size: 13px; }
.meta-table .k { color: var(--muted); font-size: 11.5px; }
.meta-table .v { font-weight: 600; margin-top: 1px; }
.detail-actions { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin-top: 14px; }
.detail-actions .btn { min-height: 40px; font-size: 14px; }

/* ---------- 录入 ---------- */
.uploader {
  border: 1.5px dashed #d8d2c4; border-radius: 16px; background: #fffdf8;
  padding: 22px 16px; text-align: center; color: var(--muted); position: relative;
}
.uploader:active { background: #fbf7ee; }
.uploader .big { font-size: 30px; margin-bottom: 6px; }
.uploader b { color: var(--ink); display: block; font-size: 15px; margin-bottom: 3px; }
.uploader span { font-size: 12.5px; }
.thumbs { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.thumbs .thumb { position: relative; width: 84px; height: 84px; border-radius: 12px; overflow: hidden; border: 1px solid var(--line); background: #fff; }
.thumbs .thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumbs .thumb button {
  position: absolute; top: 3px; right: 3px; width: 20px; height: 20px; border-radius: 50%;
  border: 0; background: rgba(29,37,48,.62); color: #fff; font-size: 11px; line-height: 1; display: grid; place-items: center;
}
.ai-bar {
  display: flex; align-items: center; gap: 10px; margin-top: 12px; padding: 11px 13px;
  border-radius: 13px; background: linear-gradient(135deg, #fff7ef, #fff); border: 1px solid #f6e2cf;
}
.ai-bar .ai-ico { flex: none; width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); font-size: 15px; }
.ai-bar .ai-txt { flex: 1; min-width: 0; font-size: 12.5px; color: var(--ink-2); line-height: 1.45; }
.ai-bar .ai-txt b { display: block; font-size: 13.5px; color: var(--ink); }
.progress-line { height: 3px; background: #f0ebe0; border-radius: 3px; overflow: hidden; margin-top: 10px; }
.progress-line i { display: block; height: 100%; width: 30%; background: var(--accent); border-radius: 3px; animation: slide 1.1s infinite ease-in-out; }
@keyframes slide { 0% { transform: translateX(-100%); } 100% { transform: translateX(380%); } }
.ai-result { animation: fadeUp .25s ease both; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---------- 复习 ---------- */
.review-wrap { position: fixed; inset: 0; z-index: 40; background: var(--bg); overflow-y: auto; padding: 16px 16px calc(24px + var(--safe-b)); }
.review-inner { max-width: 680px; margin: 0 auto; }
.review-top { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.review-track { flex: 1; height: 6px; border-radius: 6px; background: #e8e2d4; overflow: hidden; }
.review-track i { display: block; height: 100%; background: linear-gradient(90deg, #3a6bdb, var(--brand)); border-radius: 6px; transition: width .3s; }
.review-card { min-height: 46vh; }
.review-stem { font-family: var(--serif); font-size: 20px; line-height: 1.85; white-space: pre-wrap; }
.review-grade { display: grid; grid-template-columns: repeat(2, 1fr); gap: 9px; margin-top: 14px; }
.review-grade .btn { min-height: 50px; flex-direction: column; gap: 1px; font-size: 14px; }
.review-grade .btn small { font-weight: 400; font-size: 11px; opacity: .75; }
.review-done { text-align: center; padding: 30px 0; }
.review-done .big { font-size: 46px; margin-bottom: 8px; }

/* ---------- 统计 ---------- */
.ring-box { display: flex; align-items: center; gap: 18px; }
.ring {
  --p: 0; width: 104px; height: 104px; border-radius: 50%; flex: none; display: grid; place-items: center;
  background: conic-gradient(var(--green) calc(var(--p) * 1%), #ece7dc 0);
  position: relative;
}
.ring::before { content: ""; position: absolute; inset: 9px; border-radius: 50%; background: #fff; }
.ring b { position: relative; font-size: 24px; font-weight: 800; }
.ring b small { font-size: 12px; font-weight: 600; color: var(--muted); }
.bars { display: flex; flex-direction: column; gap: 9px; margin-top: 4px; }
.bar-row { display: grid; grid-template-columns: 92px 1fr 34px; align-items: center; gap: 8px; font-size: 12.5px; }
.bar-row .name { color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-row .track { height: 8px; border-radius: 8px; background: #f0ebe0; overflow: hidden; }
.bar-row .track i { display: block; height: 100%; border-radius: 8px; background: linear-gradient(90deg, #6f93e8, var(--brand)); }
.bar-row .val { text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }
.bar-row.accent .track i { background: linear-gradient(90deg, #f6a874, var(--accent)); }
.spark { display: flex; align-items: flex-end; gap: 4px; height: 74px; margin-top: 6px; }
.spark .col { flex: 1; min-width: 0; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 4px; height: 100%; }
.spark .col i { width: 100%; max-width: 22px; border-radius: 5px 5px 2px 2px; background: #dfe6f7; min-height: 3px; }
.spark .col.today i { background: var(--brand); }
.spark .col span { font-size: 9px; color: var(--muted); white-space: nowrap; }

/* ---------- 设置 ---------- */
.setting-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 13px 0; border-bottom: 1px solid #f1ece1; }
.setting-row:last-child { border-bottom: 0; }
.setting-row .st { min-width: 0; }
.setting-row .st b { font-size: 14.5px; font-weight: 600; display: block; }
.setting-row .st span { font-size: 12px; color: var(--muted); }
.key-state { font-size: 12px; }
.key-state.ok { color: var(--green); }
.key-state.no { color: var(--accent-strong); }
.switch { position: relative; width: 46px; height: 28px; border-radius: 999px; background: #e2dccd; border: 0; flex: none; transition: background .18s; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.2); transition: transform .18s; }
.switch.on { background: var(--green); }
.switch.on::after { transform: translateX(18px); }
.note { font-size: 12px; color: var(--muted); line-height: 1.6; }
.note b { color: var(--ink-2); }
.note a { color: var(--brand); word-break: break-all; }
.note ol, .note ul { padding-left: 1.1em; margin: 6px 0; }

/* ---------- 底部导航 ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: grid; grid-template-columns: repeat(5, 1fr);
  padding: 7px 8px calc(7px + var(--safe-b));
  background: rgba(255,255,255,.92);
  backdrop-filter: blur(16px) saturate(150%);
  -webkit-backdrop-filter: blur(16px) saturate(150%);
  border-top: 1px solid rgba(233,226,212,.9);
  max-width: 780px; margin: 0 auto;
}
.tab { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 4px 0; color: #667080; font-size: 10.5px; position: relative; border-radius: 12px; }
.tab svg { width: 23px; height: 23px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.tab[data-tab="home"] svg { fill: currentColor; fill-opacity: .12; }
.tab.active { color: var(--brand); font-weight: 600; }
.tab-add .tab-add-btn {
  width: 48px; height: 48px; margin-top: -20px; border-radius: 50%;
  background: linear-gradient(160deg, #4b78e2, var(--brand)); color: #fff;
  display: grid; place-items: center; box-shadow: 0 8px 18px -8px rgba(47,95,208,.9), 0 2px 0 #fff;
  border: 3px solid #fff;
}
.tab-add .tab-add-btn svg { stroke: #fff; width: 24px; height: 24px; stroke-width: 2.4; }
.tab-add { color: var(--brand); }
.tab-dot { position: absolute; top: 2px; right: 22%; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); border: 1.5px solid #fff; }

/* ---------- 浮层 ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(92px + var(--safe-b)); transform: translate(-50%, 14px);
  background: rgba(29,37,48,.92); color: #fff; font-size: 13.5px; padding: 10px 16px; border-radius: 12px;
  opacity: 0; pointer-events: none; transition: .22s; z-index: 60; max-width: 86vw; text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.sheet-wrap { position: fixed; inset: 0; z-index: 50; display: flex; align-items: flex-end; justify-content: center; }
.sheet-mask { position: absolute; inset: 0; background: rgba(20,25,32,.42); animation: fadeIn .2s both; }
@keyframes fadeIn { from { opacity: 0; } }
.sheet {
  position: relative; width: 100%; max-width: 620px; max-height: 88vh; background: var(--card);
  border-radius: 22px 22px 0 0; display: flex; flex-direction: column;
  animation: sheetUp .26s cubic-bezier(.2,.8,.3,1) both; padding-bottom: var(--safe-b);
}
@keyframes sheetUp { from { transform: translateY(40px); opacity: .6; } }
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px 8px; }
.sheet-head h3 { font-size: 17px; }
.sheet-body { padding: 8px 18px 16px; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.sheet-foot { padding: 10px 18px calc(16px + var(--safe-b)); border-top: 1px solid #f1ece1; display: flex; gap: 10px; }
.sheet-foot:empty { display: none; }
.sheet-foot .btn { flex: 1; }
@media (min-width: 620px) {
  .sheet-wrap { align-items: center; }
  .sheet { border-radius: 22px; max-height: 84vh; }
}

.viewer { position: fixed; inset: 0; z-index: 70; background: rgba(12,15,20,.94); display: grid; place-items: center; padding: 20px; }
.viewer img { max-width: 100%; max-height: 90vh; object-fit: contain; border-radius: 8px; }
.viewer-close { position: absolute; top: calc(14px + env(safe-area-inset-top, 0px)); right: 14px; width: 38px; height: 38px; border-radius: 50%; border: 0; background: rgba(255,255,255,.16); color: #fff; }

/* ---------- 打印 ---------- */
.print-toolbar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.print-page {
  background: #fff; border: 1px solid var(--line); border-radius: 6px; padding: 20px 22px;
  margin-bottom: 14px; box-shadow: 0 2px 10px rgba(0,0,0,.04);
}
.print-q { padding: 10px 0 6px; border-bottom: 1px dashed #e5e0d4; page-break-inside: avoid; }
.print-q:last-child { border-bottom: 0; }
.print-q .no { font-weight: 800; font-size: 13px; color: var(--brand); margin-right: 6px; }
.print-q .q-stem { font-family: var(--serif); font-size: 14.5px; line-height: 1.9; white-space: pre-wrap; }
.print-q .q-stem img { max-height: 130px; width: auto; border-radius: 4px; margin: 6px 0; }
.print-q .q-lines { margin-top: 6px; }
.print-q .q-lines i { display: block; border-bottom: 1px solid #eee9de; height: 26px; }
.print-ans { font-size: 12.5px; line-height: 1.8; color: #333; background: #faf8f3; border-radius: 6px; padding: 8px 10px; margin-top: 6px; page-break-inside: avoid; }
.print-ans b { color: #1f5b3c; }
.print-head { display: flex; justify-content: space-between; font-size: 11px; color: #888; border-bottom: 1px solid #ddd; padding-bottom: 6px; margin-bottom: 8px; }

@media print {
  @page { size: A4; margin: 14mm 12mm; }
  body { background: #fff !important; }
  .tabbar, .toast, .print-toolbar, .page-head, .no-print, .sheet-wrap, .viewer { display: none !important; }
  .app-main { padding: 0 !important; }
  .app-shell { max-width: none; }
  .print-page { border: 0; box-shadow: none; padding: 0; margin: 0; page-break-after: always; }
  .print-page:last-child { page-break-after: auto; }
  .print-q { page-break-inside: avoid; }
}

/* ---------- 工具类 ---------- */
.row { display: flex; align-items: center; gap: 10px; }
.between { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.tiny { font-size: 11px; }
.bold { font-weight: 700; }
.center { text-align: center; }
.mt-6 { margin-top: 6px; } .mt-10 { margin-top: 10px; } .mt-14 { margin-top: 14px; } .mt-20 { margin-top: 20px; }
.mb-0 { margin-bottom: 0; }
.clamp-2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.divider { height: 1px; background: #f1ece1; margin: 14px 0; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }
.fade-in { animation: fadeUp .25s ease both; }


/* ---------- iPad / 平板（≥760px） ---------- */
@media screen and (min-width: 760px) {
  .app-shell { max-width: 1000px; }
  .app-main { padding-left: 24px; padding-right: 24px; }
  .tabbar { max-width: 1000px; }

  /* 错题列表两列 */
  #app[data-page="list"] .list {
    display: grid; grid-template-columns: 1fr 1fr; gap: 12px; align-items: stretch;
  }
  #app[data-page="list"] .item { height: 100%; }

  /* 阅读型页面限制行宽 */
  #app[data-page="home"] > * { max-width: 900px; margin-left: auto; margin-right: auto; }
  #app[data-page="stats"] > *,
  #app[data-page="print"] > * { max-width: 900px; margin-left: auto; margin-right: auto; }
  #app[data-page="item"] > *,
  #app[data-page="add"] > *,
  #app[data-page="me"] > *,
  #app[data-page="review"] > *:not(.review-wrap) {
    max-width: 780px; margin-left: auto; margin-right: auto;
  }

  .review-inner { max-width: 760px; }
  .page-head h1 { font-size: 26px; }

  /* A4 打印预览 */
  .print-page {
    width: 210mm; max-width: 100%; min-height: 296mm;
    padding: 15mm 13mm; margin-left: auto; margin-right: auto;
  }
}

/* 录入页：保存按钮吸顶，长表单/键盘打开时也点得到 */
#app[data-page="add"] .page-head {
  position: sticky;
  top: env(safe-area-inset-top, 0px);
  z-index: 18;
  padding: 8px 0 10px;
  margin: -8px 0 10px;
  background: var(--bg);
}
#app[data-page="add"] .page-head .btn { min-height: 40px; padding: 0 16px; }

/* ---------- 数学排版（分数/乘方/根号） ---------- */
.mfrac {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  vertical-align: middle;
  line-height: 1.05;
  margin: 0 .14em;
  font-size: .9em;
  position: relative;
  top: .04em;
}
.mfrac .mnum {
  border-bottom: 1px solid currentColor;
  padding: 0 .18em .02em;
  min-width: .9em;
}
.mfrac .mden { padding: .02em .18em 0; min-width: .9em; }
.mroot .mrad { border-top: 1px solid currentColor; padding: .02em .12em 0; margin-left: .02em; }
.stem-text sup, .prose sup, .review-stem sup, .answer-text sup, .print-q sup { font-size: .7em; line-height: 0; }

/* 录入页原题大图 */
.orig-preview {
  position: relative; margin-top: 12px; border: 1px solid var(--line);
  border-radius: 14px; overflow: hidden; background: #fff; cursor: zoom-in;
}
.orig-preview img { width: 100%; max-height: 38vh; object-fit: contain; background: #fff; }
.orig-label {
  position: absolute; top: 8px; left: 8px; z-index: 1;
  background: rgba(29,37,48,.74); color: #fff; font-size: 11px;
  padding: 3px 8px; border-radius: 6px;
}

/* KaTeX 排版 */
.katex { font-size: 1.08em; }
.katex-display { margin: .5em 0; overflow-x: auto; overflow-y: hidden; padding: .1em 0; }
.stem-text { overflow-wrap: break-word; }
@media print {
  .katex-display { overflow: visible; }
}

/* 录入页公式预览 */
.stem-preview {
  margin-top: 10px; padding: 10px 12px; border: 1px solid var(--line);
  border-radius: 12px; background: #fffdf8;
}
.stem-preview .qa-label { margin-bottom: 4px; }
.stem-preview .stem-text { font-size: 16px; }
