:root {
  --bg: #eef2f7;
  --card: #ffffff;
  --card-2: #f7f9fc;
  --line: #e2e8f0;
  --line-2: #eef2f7;
  --text: #0f172a;
  --muted: #64748b;
  --muted-2: #94a3b8;
  --brand: #1668dc;
  --brand-d: #0f52b3;
  --brand-l: #e8f1ff;
  --ok: #15a34a;
  --ok-l: #e7f7ed;
  --bad: #e5484d;
  --bad-l: #fdeded;
  --warn: #f59e0b;
  --warn-l: #fff6e5;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 4px 14px rgba(16, 24, 40, .06);
  --r: 14px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

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

html, body {
  margin: 0; padding: 0;
  background: var(--bg); color: var(--text);
  font: 15px/1.6 -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Source Han Sans SC", sans-serif;
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
button { cursor: pointer; border: none; background: none; }
a { color: var(--brand); }

/* ---------------- 布局 ---------------- */
#app { max-width: 820px; margin: 0 auto; min-height: 100vh; display: flex; flex-direction: column; }

.topbar {
  position: sticky; top: 0; z-index: 30;
  background: linear-gradient(135deg, #1668dc 0%, #2b8ef0 100%);
  color: #fff;
  padding: calc(12px + var(--safe-top, env(safe-area-inset-top, 0px))) 16px 14px;
  box-shadow: 0 2px 10px rgba(22, 104, 220, .25);
}
.topbar .row1 { display: flex; align-items: center; gap: 10px; }
.topbar .logo { font-size: 19px; font-weight: 700; letter-spacing: .5px; }
.topbar .sub { font-size: 12px; opacity: .85; margin-left: auto; }
.bank-chip {
  margin-top: 10px; display: flex; align-items: center; gap: 8px;
  background: rgba(255, 255, 255, .18);
  border: 1px solid rgba(255, 255, 255, .28);
  border-radius: 999px; padding: 6px 10px 6px 12px;
  color: #fff; font-size: 13px; width: 100%; text-align: left;
  backdrop-filter: blur(6px);
}
.bank-chip .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.bank-chip .cnt { font-size: 12px; opacity: .9; }
.bank-chip .arw { opacity: .85; font-size: 12px; }

main { flex: 1; padding: 14px 14px 96px; }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  display: flex; background: rgba(255, 255, 255, .96);
  border-top: 1px solid var(--line);
  padding-bottom: var(--safe-b);
  backdrop-filter: blur(10px);
}
.tabbar-inner { max-width: 820px; margin: 0 auto; width: 100%; display: flex; }
.tabbar button {
  flex: 1; padding: 8px 2px 9px; display: flex; flex-direction: column;
  align-items: center; gap: 2px; color: var(--muted-2); font-size: 11px; transition: color .15s;
  position: relative;
}
.tab-dot {
  position: absolute; top: 6px; left: 50%; margin-left: 9px;
  width: 7px; height: 7px; border-radius: 50%; background: var(--bad);
  box-shadow: 0 0 0 2px rgba(255, 255, 255, .96);
}
.tabbar button .ic { font-size: 19px; line-height: 1.1; filter: grayscale(1); opacity: .55; }
.tabbar button.on { color: var(--brand); font-weight: 600; }
.tabbar button.on .ic { filter: none; opacity: 1; }

/* ---------------- 通用组件 ---------------- */
.card {
  background: var(--card); border-radius: var(--r);
  box-shadow: var(--shadow); padding: 15px; margin-bottom: 12px;
}
.card.tight { padding: 12px; }
.sec-title { font-size: 13px; font-weight: 700; color: var(--muted); margin: 2px 0 9px; letter-spacing: .3px; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.tiny { font-size: 11.5px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 16px; border-radius: 10px; font-size: 14px; font-weight: 600;
  background: var(--card-2); color: var(--text); border: 1px solid var(--line);
  transition: transform .08s, background .15s;
}
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--brand); color: #fff; border-color: var(--brand); }
.btn.primary:active { background: var(--brand-d); }
.btn.ghost { background: transparent; }
.btn.block { width: 100%; }
.btn.sm { padding: 7px 12px; font-size: 13px; border-radius: 9px; }
.btn:disabled { opacity: .5; }

.row { display: flex; gap: 8px; align-items: center; }
.wrap { flex-wrap: wrap; }
.spacer { flex: 1; }

.tag {
  display: inline-block; padding: 2px 8px; border-radius: 999px;
  font-size: 11.5px; background: var(--brand-l); color: var(--brand); font-weight: 600;
}
.tag.gray { background: #eef2f7; color: var(--muted); }
.tag.ok { background: var(--ok-l); color: var(--ok); }
.tag.bad { background: var(--bad-l); color: var(--bad); }
.tag.warn { background: var(--warn-l); color: #b45309; }
.tag.ebb { background: #f3e8ff; color: #7c3aed; }

/* 错题复习（艾宾浩斯） */
.ebb-line { display: flex; align-items: center; gap: 12px; }
.ebb-n {
  flex: none; width: 56px; height: 56px; border-radius: 14px;
  background: var(--brand-l); color: var(--brand);
  display: flex; align-items: center; justify-content: center;
  font-size: 24px; font-weight: 800;
}
.ebb-t { flex: 1; min-width: 0; }
.ebb-a { font-size: 14px; font-weight: 700; }
.ebb-b { font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.ebb-pct { flex: none; text-align: right; font-size: 15px; font-weight: 800; color: var(--ok); }
.ebb-pct span { display: block; font-size: 10.5px; color: var(--muted); font-weight: 500; }

.chips { display: flex; gap: 7px; flex-wrap: wrap; }
.chip {
  padding: 5px 12px; border-radius: 999px; font-size: 13px;
  background: var(--card-2); border: 1px solid var(--line); color: var(--muted);
}
.chip.hot:not(.on) { border-color: var(--brand); color: var(--brand); font-weight: 700; background: var(--brand-l); }
.chip.on { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600; }

input[type=text], input[type=search], textarea, select {
  width: 100%; padding: 11px 12px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--card-2); outline: none;
  transition: border-color .15s, background .15s;
}
input:focus, textarea:focus, select:focus { border-color: var(--brand); background: #fff; }
textarea { resize: vertical; min-height: 84px; line-height: 1.65; }

/* ---------------- 搜题结果 ---------------- */
.qcard { background: var(--card); border-radius: var(--r); box-shadow: var(--shadow); padding: 14px; margin-bottom: 11px; }
.qcard.top { border: 1.5px solid var(--brand); }
.qhead { display: flex; align-items: center; gap: 7px; margin-bottom: 9px; flex-wrap: wrap; }
.score { font-size: 12px; font-weight: 700; color: var(--brand); background: var(--brand-l); padding: 2px 8px; border-radius: 999px; }
.qtext { font-size: 15.5px; line-height: 1.75; font-weight: 600; margin: 2px 0 10px; }
.qtext em { font-style: normal; background: #fff3bf; border-radius: 3px; padding: 0 1px; }

.opts { display: flex; flex-direction: column; gap: 6px; }
.opt {
  display: flex; gap: 9px; padding: 8px 11px; border-radius: 9px;
  background: var(--card-2); border: 1px solid transparent; font-size: 14.5px; line-height: 1.55;
}
.opt .k { font-weight: 700; color: var(--muted); flex: none; width: 15px; }
.opt.correct { background: var(--ok-l); border-color: #b7e7c9; }
.opt.correct .k { color: var(--ok); }
.opt.correct .t { font-weight: 600; }
.opt.match { background: #fff9e6; border-color: #ffe08a; }

.answer-box {
  margin-top: 11px; padding: 10px 12px; border-radius: 10px;
  background: var(--ok-l); border: 1px solid #c3ecd3;
}
.answer-box .lbl { font-size: 12px; color: var(--ok); font-weight: 700; }
.answer-box .val { font-size: 17px; font-weight: 800; color: #0d7a37; }
.answer-box .val .txt { font-size: 14px; font-weight: 500; color: #14532d; line-height: 1.7; display: block; margin-top: 4px; }

.exp {
  margin-top: 10px; padding: 10px 12px; border-radius: 10px;
  background: var(--card-2); border: 1px dashed var(--line);
  font-size: 13.5px; color: #334155; line-height: 1.7; white-space: pre-wrap;
}
.exp .lbl { font-size: 11.5px; font-weight: 700; color: var(--muted); display: block; margin-bottom: 3px; }

.src { margin-top: 9px; font-size: 11.5px; color: var(--muted-2); }

/* ---------------- 拍照页 ---------------- */
.cam-box {
  position: relative; border-radius: var(--r); overflow: hidden;
  background: #0b1220; aspect-ratio: 4 / 5; max-height: 58vh;
  display: flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow);
}
.cam-box video, .cam-box img { width: 100%; height: 100%; object-fit: contain; display: block; }
.cam-empty { color: #8fa3bd; text-align: center; padding: 24px; font-size: 13.5px; }
.cam-empty .big { font-size: 40px; margin-bottom: 8px; opacity: .7; }

/* --- 框选舞台 --- */
.stage {
  position: relative; border-radius: var(--r); overflow: hidden;
  background: #0b1220; box-shadow: var(--shadow);
  max-height: 60vh; display: flex; align-items: center; justify-content: center;
}
.stage-inner { position: relative; line-height: 0; max-width: 100%; max-height: 60vh; }
.stage-canvas { display: block; max-width: 100%; max-height: 60vh; width: auto; height: auto; }
.ov { position: absolute; inset: 0; touch-action: none; overflow: hidden; }

.tbox {
  position: absolute; border: 1.5px solid rgba(56, 189, 248, .8);
  background: rgba(56, 189, 248, .10); border-radius: 4px;
  transition: background .12s, border-color .12s;
}
.tbox.on { border-color: #22c55e; background: rgba(34, 197, 94, .20); border-width: 2px; }
.tbox::before {
  content: attr(data-no);
  position: absolute; top: -9px; left: -9px;
  min-width: 18px; height: 18px; padding: 0 4px;
  background: #0ea5e9; color: #fff; border-radius: 999px;
  font-size: 11px; font-weight: 700; line-height: 18px; text-align: center;
}
.tbox.on::before { background: #16a34a; }

.mbox {
  position: absolute; border: 2px dashed #38bdf8;
  background: rgba(56, 189, 248, .10);
  box-shadow: 0 0 0 9999px rgba(6, 12, 26, .42);
  touch-action: none;
}
/* 角手柄样式见文件末尾「手动框选灵敏度增强」段（热区由 JS 命中测试保证） */

.crop-tools {
  display: flex; gap: 7px; flex-wrap: wrap; align-items: center;
  margin-top: 10px; padding: 9px 10px;
  background: var(--card-2); border: 1px solid var(--line-2); border-radius: 10px;
}
.seg { display: flex; background: #e6ebf2; border-radius: 8px; padding: 2px; }
.seg button { padding: 5px 11px; border-radius: 6px; font-size: 12.5px; color: var(--muted); font-weight: 600; }
.seg button.on { background: #fff; color: var(--brand); box-shadow: 0 1px 2px rgba(0, 0, 0, .08); }

.drop-zone {
  border: 1.5px dashed #c3cfe0; border-radius: 10px; padding: 14px;
  text-align: center; color: var(--muted); font-size: 13px; background: var(--card-2);
  transition: border-color .15s, background .15s;
}
.drop-zone.over { border-color: var(--brand); background: var(--brand-l); color: var(--brand); }

.progress { height: 6px; border-radius: 999px; background: var(--line); overflow: hidden; margin-top: 9px; }
.progress i { display: block; height: 100%; background: linear-gradient(90deg, #1668dc, #38bdf8); width: 0; transition: width .25s; }

.ocr-text {
  font-size: 13px; line-height: 1.7; color: #334155; white-space: pre-wrap;
  background: var(--card-2); border: 1px solid var(--line-2); border-radius: 10px;
  padding: 10px; max-height: 190px; overflow: auto;
}

/* ---------------- 题库列表 ---------------- */
.bank-item {
  display: flex; align-items: center; gap: 11px; padding: 12px;
  border-radius: 11px; border: 1px solid var(--line); background: var(--card);
  margin-bottom: 9px; width: 100%; text-align: left;
}
.bank-item.on { border-color: var(--brand); background: var(--brand-l); }
.bank-item .ic { font-size: 22px; }
.bank-item .nm { font-weight: 700; font-size: 14.5px; }
.bank-item .ds { font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.bank-item .bk-prog { color: var(--brand); font-weight: 700; }
.bank-item .ck { color: var(--brand); font-weight: 800; font-size: 17px; }
.bank-item { cursor: pointer; }
.bank-item.off { opacity: .62; background: var(--card-2); }
.bank-item .ck.del { color: var(--muted); font-size: 15px; padding: 2px 2px 2px 8px; cursor: pointer; }
.bank-item .ck.del:hover, .bank-item .ck.del:active { color: var(--bad); }

/* ---------------- 弹层 ---------------- */
.mask {
  position: fixed; inset: 0; background: rgba(15, 23, 42, .45); z-index: 60;
  display: flex; align-items: flex-end; justify-content: center; animation: fade .18s;
}
@keyframes fade { from { opacity: 0 } to { opacity: 1 } }
.sheet {
  background: var(--card); width: 100%; max-width: 820px;
  border-radius: 18px 18px 0 0; padding: 16px 16px calc(18px + var(--safe-b));
  max-height: 88vh; overflow: auto; animation: up .22s cubic-bezier(.2, .8, .3, 1);
}
@keyframes up { from { transform: translateY(24px); opacity: .6 } to { transform: none; opacity: 1 } }
.sheet h3 { margin: 0 0 4px; font-size: 17px; }
.sheet .grip { width: 38px; height: 4px; border-radius: 99px; background: var(--line); margin: -6px auto 12px; }

/* ---------------- 刷题 ---------------- */
.practice-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; font-size: 13px; color: var(--muted); }
.opt-btn {
  display: flex; gap: 10px; padding: 12px; border-radius: 11px; width: 100%; text-align: left;
  background: var(--card-2); border: 1.5px solid var(--line); margin-bottom: 8px; font-size: 14.5px; line-height: 1.6;
}
.opt-btn .k {
  flex: none; width: 24px; height: 24px; border-radius: 50%; background: #dfe6f0; color: #475569;
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px;
}
.opt-btn.picked { border-color: var(--brand); background: var(--brand-l); }
.opt-btn.picked .k { background: var(--brand); color: #fff; }
.opt-btn.right { border-color: #7ed09b; background: var(--ok-l); }
.opt-btn.right .k { background: var(--ok); color: #fff; }
.opt-btn.wrong { border-color: #f0a6a8; background: var(--bad-l); }
.opt-btn.wrong .k { background: var(--bad); color: #fff; }

/* 刷题记忆卡片 */
.resume-card { border: 1.5px solid #bcd6fb; background: linear-gradient(180deg, #f5faff 0%, #ffffff 70%); }
.resume-card .rz-line { display: flex; align-items: center; gap: 10px; }
.resume-card .rz-ic {
  flex: none; width: 34px; height: 34px; border-radius: 11px; color: #fff; font-size: 13px;
  background: linear-gradient(135deg, #1668dc, #38bdf8);
  display: flex; align-items: center; justify-content: center;
}
.resume-card .rz-t { font-weight: 700; font-size: 14.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.resume-card .rz-s { font-size: 12px; color: var(--muted); margin-top: 2px; }
.resume-card .rz-pct { flex: none; font-size: 13px; font-weight: 800; color: var(--brand); }

.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; text-align: center; }.stat-grid .n { font-size: 20px; font-weight: 800; color: var(--brand); }
.stat-grid .l { font-size: 11px; color: var(--muted); }

.empty { text-align: center; padding: 40px 20px; color: var(--muted-2); }
.empty .big { font-size: 42px; margin-bottom: 10px; opacity: .6; }

#toast {
  position: fixed; left: 50%; bottom: 92px; transform: translateX(-50%);
  background: rgba(15, 23, 42, .92); color: #fff; padding: 9px 16px;
  border-radius: 999px; font-size: 13.5px; z-index: 99; opacity: 0;
  pointer-events: none; transition: opacity .22s, transform .22s; max-width: 84vw; text-align: center;
}
#toast.on { opacity: 1; transform: translateX(-50%) translateY(-6px); }

/* ------------- 应用内相机（夸克搜题风格：拍单题/拍整页 + 确认框选） ------------- */
body.camov-lock { overflow: hidden; }
.camov {
  position: fixed; inset: 0; z-index: 80; background: #000;
  display: flex; flex-direction: column; overflow: hidden;
  color: #fff;
}
.flex1 { flex: 1; }

/* ===== 相机页 ===== */
.camov-live { position: absolute; inset: 0; }
/* 取景区：按原始比例完整显示（contain），绝不裁切放大 —— 所见即所得 */
.camov-view {
  position: absolute; inset: 0; background: #000;
  display: flex; align-items: center; justify-content: center;
  padding: calc(108px + var(--safe-top, env(safe-area-inset-top, 0px))) 0 calc(140px + env(safe-area-inset-bottom, 0px));
}
.camov video {
  display: block; width: auto; height: auto;
  max-width: 100%; max-height: 100%; min-height: 0;
  background: #000;
}
/* 中央取景框 */
.camov-guide {
  position: absolute; inset: 0; z-index: 2; pointer-events: none;
  display: flex; align-items: center; justify-content: center;
  padding: calc(108px + var(--safe-top, env(safe-area-inset-top, 0px))) 0 calc(140px + env(safe-area-inset-bottom, 0px));
}
.camov-frame {
  position: relative; width: 78%; aspect-ratio: 4 / 3; max-height: 62%;
  border: 1.5px solid rgba(255, 255, 255, .9); border-radius: 14px;
  background: rgba(255, 255, 255, .04);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, .25);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 6px;
}
.camov-frame.page { width: 86%; aspect-ratio: 3 / 4; max-height: 78%; }
.camov-frame .plus { font-size: 30px; font-weight: 300; color: rgba(255, 255, 255, .95); line-height: 1; }
.camov-frame .cap { font-size: 13px; color: rgba(255, 255, 255, .92); text-shadow: 0 1px 3px rgba(0, 0, 0, .5); }
/* 顶栏 */
.camov-top {
  position: absolute; left: 0; right: 0; top: 0; z-index: 4;
  padding: calc(12px + var(--safe-top, env(safe-area-inset-top, 0px))) 14px 10px;
  display: flex; align-items: center;
}
.camov-title { font-size: 21px; font-weight: 700; letter-spacing: .5px; }
.camov-set {
  flex: none; height: 34px; padding: 0 14px; border-radius: 999px; border: none;
  background: rgba(60, 60, 60, .7); color: #fff; font-size: 13px; margin-right: 10px;
}
.camov-set.on { background: #fff; color: #111; font-weight: 600; }
.camov-x {
  flex: none; width: 36px; height: 36px; border-radius: 50%; color: #fff; font-size: 15px;
  background: rgba(60, 60, 60, .7); border: none;
}
/* 镜头 / 参数面板 */
.camov-panel {
  position: absolute; z-index: 6; left: 12px; right: 12px;
  top: calc(96px + var(--safe-top, env(safe-area-inset-top, 0px)));
  max-height: 62vh; overflow-y: auto;
  background: rgba(28, 28, 30, .96); border: 1px solid rgba(255, 255, 255, .12);
  border-radius: 14px; padding: 12px 14px 14px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, .5);
}
.cvp-row { display: flex; justify-content: space-between; gap: 10px; font-size: 12.5px; padding: 3px 0; }
.cvp-k { color: rgba(255, 255, 255, .6); flex: none; }
.cvp-v { color: #fff; text-align: right; word-break: break-all; }
.cvp-sec { font-size: 12px; color: rgba(255, 255, 255, .6); margin: 12px 0 7px; }
.cvp-chips, .cvp-cams { display: flex; flex-wrap: wrap; gap: 8px; }
.cvp-chips button, .cvp-cams button {
  border: 1px solid rgba(255, 255, 255, .22); background: rgba(255, 255, 255, .08);
  color: #fff; border-radius: 999px; padding: 7px 13px; font-size: 12.5px;
}
.cvp-chips button.on, .cvp-cams button.on { background: #3478f6; border-color: #3478f6; font-weight: 600; }
.cvp-empty { font-size: 12px; color: rgba(255, 255, 255, .5); }
.cvp-tip { margin-top: 12px; font-size: 11.5px; line-height: 1.6; color: rgba(255, 255, 255, .55); }

/* 铺满模式：像系统相机一样填满整屏（会裁掉画面边缘） */
.camov.fit-cover .camov-view { padding: 0; }
.camov.fit-cover video { width: 100%; height: 100%; max-width: none; max-height: none; object-fit: cover; }
.camov.fit-cover .camov-guide { padding: calc(108px + var(--safe-top, env(safe-area-inset-top, 0px))) 0 calc(140px + env(safe-area-inset-bottom, 0px)); }
/* 模式切换胶囊 */
.camov-tabs {
  position: absolute; left: 0; right: 0; z-index: 4;
  top: calc(52px + var(--safe-top, env(safe-area-inset-top, 0px)));
  display: flex; justify-content: center; gap: 6px;
}
.camov-tabs button {
  padding: 6px 16px; border-radius: 999px; border: none; font-size: 13.5px;
  color: rgba(255, 255, 255, .92); background: rgba(60, 60, 60, .65);
}
.camov-tabs button.on { background: #fff; color: #111; font-weight: 600; }
.camov-hint {
  position: absolute; left: 50%; transform: translateX(-50%); z-index: 4;
  bottom: calc(148px + env(safe-area-inset-bottom, 0px));
  color: #fff; font-size: 12.5px; padding: 5px 12px; border-radius: 999px;
  background: rgba(0, 0, 0, .5); transition: opacity .2s; white-space: nowrap;
}
.camov-ring {
  position: absolute; width: 74px; height: 74px; margin: -37px 0 0 -37px; z-index: 5;
  border: 2px solid #fff; border-radius: 50%; box-shadow: 0 0 0 1px rgba(0, 0, 0, .4);
}
.camov-ring.pop { animation: camRing .72s ease-out; }
@keyframes camRing {
  0% { transform: scale(1.35); opacity: 1 }
  70% { transform: scale(1); opacity: 1 }
  100% { transform: scale(1); opacity: 0 }
}
/* 底栏（相机页 & 确认页共用） */
.camov-bar {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 4;
  padding: 18px 26px calc(24px + env(safe-area-inset-bottom, 0px));
  display: flex; align-items: center; justify-content: center; gap: 34px;
}
.camov-side {
  width: 64px; background: none; border: none; color: #fff;
  display: flex; flex-direction: column; align-items: center; gap: 5px;
}
.camov-side .ic { font-size: 23px; line-height: 1; }
.camov-side .lb { font-size: 11.5px; color: rgba(255, 255, 255, .9); }
.camov-side.on .ic { text-shadow: 0 0 8px #ffe27a; }
.camov-shutter {
  width: 78px; height: 78px; border-radius: 50%; padding: 0;
  background: rgba(255, 255, 255, .25); border: 4px solid #fff;
  display: flex; align-items: center; justify-content: center;
}
.camov-shutter i {
  display: block; width: 60px; height: 60px; border-radius: 50%;
  background: #fff; transition: transform .09s ease;
}
.camov-shutter:active i { transform: scale(.86); }

/* ===== 拍后确认框选页 ===== */
.camov-confirm { position: absolute; inset: 0; background: #000; }
.camov-shot-area {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  padding: calc(30px + var(--safe-top, env(safe-area-inset-top, 0px))) 12px calc(170px + env(safe-area-inset-bottom, 0px));
}
.camov-shot-inner { position: relative; max-width: 100%; max-height: 100%; }
.camov-photo {
  display: block; width: auto; height: auto;
  max-width: 100%; max-height: calc(100vh - 200px - var(--safe-top, env(safe-area-inset-top, 0px)) - env(safe-area-inset-bottom, 0px));
}
.camov-crop {
  position: absolute; cursor: move; touch-action: none;
  border: 1px solid rgba(255, 255, 255, .95);
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, .45);
  border-radius: 2px;
}
.camov-crop .hd {
  position: absolute; width: 26px; height: 26px; touch-action: none;
}
.camov-crop .hd::before {
  content: ''; position: absolute; inset: 0;
  border: 0 solid #fff;
}
.camov-crop .hd.tl { left: -3px; top: -3px; cursor: nwse-resize; }
.camov-crop .hd.tr { right: -3px; top: -3px; cursor: nesw-resize; }
.camov-crop .hd.bl { left: -3px; bottom: -3px; cursor: nesw-resize; }
.camov-crop .hd.br { right: -3px; bottom: -3px; cursor: nwse-resize; }
.camov-crop .hd.tl::before { border-left-width: 3.5px; border-top-width: 3.5px; }
.camov-crop .hd.tr::before { border-right-width: 3.5px; border-top-width: 3.5px; }
.camov-crop .hd.bl::before { border-left-width: 3.5px; border-bottom-width: 3.5px; }
.camov-crop .hd.br::before { border-right-width: 3.5px; border-bottom-width: 3.5px; }
.camov-confirm-hint {
  position: absolute; left: 0; right: 0; z-index: 2;
  bottom: calc(128px + env(safe-area-inset-bottom, 0px));
  text-align: center; font-size: 13.5px; color: rgba(255, 255, 255, .95);
  text-shadow: 0 1px 3px rgba(0, 0, 0, .6);
}
.camov-ok {
  width: 70px; height: 70px; border-radius: 50%;
  background: #3478f6; border: 4px solid #fff;
  color: #fff; font-size: 30px; font-weight: 700; line-height: 1;
  display: flex; align-items: center; justify-content: center;
}
.camov-ok:active { transform: scale(.94); }

.camov-flash {
  position: absolute; inset: 0; background: #fff; opacity: 0;
  pointer-events: none; z-index: 9;
}
.camov-flash.on { animation: camFlash .32s ease-out; }
@keyframes camFlash { 0% { opacity: .9 } 100% { opacity: 0 } }

.hide { display: none !important; }
.spin {
  width: 15px; height: 15px; border: 2px solid rgba(255, 255, 255, .35);
  border-top-color: #fff; border-radius: 50%; animation: sp .7s linear infinite; display: inline-block;
}
@keyframes sp { to { transform: rotate(360deg) } }

@media (min-width: 720px) {
  main { padding: 18px 18px 100px; }
  .tabbar { position: sticky; bottom: 0; }
}

/* ---------------- 拍题结果弹窗（夸克风格底部半屏弹层） ---------------- */
.rsheet { position: fixed; inset: 0; z-index: 70; }
.rsheet.hide { display: none; }
.rsheet-mask {
  position: absolute; inset: 0; background: rgba(0, 0, 0, .45);
  opacity: 0; transition: opacity .18s ease;
}
.rsheet.on .rsheet-mask { opacity: 1; }
.rsheet-body {
  position: absolute; left: 0; right: 0; bottom: 0;
  max-width: 820px; margin: 0 auto;
  height: 84%;
  display: flex; flex-direction: column;
  background: var(--card);
  border-radius: 18px 18px 0 0;
  box-shadow: 0 -8px 30px rgba(0, 0, 0, .2);
  transform: translateY(100%);
  transition: transform .22s ease;
  overflow: hidden;
}
.rsheet.on .rsheet-body { transform: translateY(0); }
.rsheet-grip {
  flex: none; width: 44px; height: 5px; border-radius: 3px;
  background: #d5dbe3; margin: 10px auto 2px;
}
.rsheet-chips {
  flex: none; display: flex; gap: 8px;
  padding: 10px 16px 4px; overflow-x: auto; scrollbar-width: none;
}
.rsheet-chips::-webkit-scrollbar { display: none; }
.rs-chip {
  flex: none; padding: 6px 14px; border-radius: 999px; font-size: 13.5px;
  background: var(--card-2); color: var(--muted); border: 1px solid var(--line);
}
.rs-chip.on {
  background: var(--brand); border-color: var(--brand);
  color: #fff; font-weight: 600;
}
.rs-chip .pct {
  font-style: normal; font-size: 11px; margin-left: 5px; opacity: .75;
}
.rs-warn {
  margin: 0 2px 10px;
  padding: 9px 12px;
  border-radius: 10px;
  background: #fff7e6;
  border: 1px solid #ffd591;
  color: #874d00;
  font-size: 13px;
  line-height: 1.55;
}
.rs-warn b { color: #ad6800; }
.rsheet-scroll {
  flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding: 10px 16px 16px;
}
.rsheet-foot {
  flex: none; display: flex; gap: 10px; align-items: center;
  padding: 10px 16px calc(10px + var(--safe-b));
  border-top: 1px solid var(--line-2); background: var(--card);
}
.rsheet-foot .btn { padding: 12px 14px; font-size: 15px; }
.rsheet .qcard { box-shadow: none; border: 1px solid var(--line-2); }

/* ---------------- 手动框选灵敏度增强 ---------------- */
.mbox { z-index: 3; }
.mbox .hd {
  position: absolute; width: 30px; height: 30px; margin: -15px 0 0 -15px;
  border-radius: 50%; background: #fff; border: 3px solid #0ea5e9;
  box-shadow: 0 1px 4px rgba(0, 0, 0, .4); touch-action: none;
}
.mbox .hd.nw { left: 0; top: 0; }
.mbox .hd.ne { left: 100%; top: 0; }
.mbox .hd.sw { left: 0; top: 100%; }
.mbox .hd.se { left: 100%; top: 100%; }
.mbadge {
  position: absolute; left: 0; top: -30px;
  background: rgba(14, 165, 233, .95); color: #fff;
  font-size: 12px; line-height: 1; padding: 5px 8px; border-radius: 6px;
  white-space: nowrap; pointer-events: none; font-weight: 600;
}
/* 手动模式下的"吸附提示框"：点一下对齐到该文字块 */
.snapbox {
  position: absolute; z-index: 2;
  border: 1.5px dashed rgba(56, 189, 248, .5);
  background: rgba(56, 189, 248, .04); border-radius: 4px;
}
/* 拖拽参考线 */
.guide { position: absolute; z-index: 1; pointer-events: none; opacity: 0; transition: opacity .12s; }
.guide.on { opacity: 1; }
.guide.gv1, .guide.gv2 {
  width: 0; border-left: 1.5px dashed rgba(14, 165, 233, .75);
}
.guide.gh1, .guide.gh2 {
  height: 0; border-top: 1.5px dashed rgba(14, 165, 233, .75);
}

/* 手动微调按钮排 */
.mpad {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  margin-top: 9px; padding: 7px 9px;
  background: var(--card-2); border: 1px dashed var(--line); border-radius: 10px;
}
.mbtn {
  min-width: 38px; height: 34px; padding: 0 10px;
  border-radius: 8px; background: #fff; border: 1px solid var(--line);
  font-size: 14px; color: var(--text); font-weight: 600;
}
.mbtn:active { background: var(--brand-l); border-color: var(--brand); }
.mbtn.wide { flex: 1; font-size: 13px; }
.mpad-sep { width: 1px; height: 20px; background: var(--line); margin: 0 2px; }

/* 确认页拖拽增强：参考线 + 尺寸角标 + 更大的角手柄 */
.camov-shot-inner { touch-action: none; }
.camov-guide { position: absolute; z-index: 6; pointer-events: none; opacity: 0; transition: opacity .12s; }
.camov-guide.on { opacity: 1; }
.camov-guide.gv1, .camov-guide.gv2 { width: 0; border-left: 1.5px dashed rgba(255, 255, 255, .85); }
.camov-guide.gh1, .camov-guide.gh2 { height: 0; border-top: 1.5px dashed rgba(255, 255, 255, .85); }
.camov-size {
  position: absolute; z-index: 7; pointer-events: none; opacity: 0; transition: opacity .12s;
  background: rgba(52, 120, 246, .95); color: #fff;
  font-size: 12px; font-weight: 600; line-height: 1; padding: 5px 8px; border-radius: 6px;
  white-space: nowrap;
}
.camov-size.on, .camov-guide.on { opacity: 1; }
.camov-crop .hd { width: 32px; height: 32px; }
.camov-crop .hd::after {
  content: ''; position: absolute; inset: -14px;   /* 扩大手势热区 */
}

/* ---------------- iOS「添加到主屏幕」引导条 ---------------- */
#pwaTip {
  position: fixed; left: 12px; right: 12px; z-index: 60;
  bottom: calc(64px + var(--safe-b));
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 14px;
  background: rgba(22, 104, 220, .96); color: #fff;
  box-shadow: 0 8px 22px rgba(22, 104, 220, .32);
  font-size: 12px; line-height: 1.4;
  animation: pwaTipIn .28s ease-out;
  transition: opacity .22s ease, transform .22s ease;
}
#pwaTip.off { opacity: 0; transform: translateY(8px); }
#pwaTip .pt-ic { font-size: 20px; line-height: 1; flex: none; }
#pwaTip .pt-tx { flex: 1; display: flex; flex-direction: column; min-width: 0; }
#pwaTip .pt-tx b { font-size: 13px; font-weight: 600; }
#pwaTip .pt-tx span { opacity: .92; }
#pwaTip button {
  flex: none; width: 26px; height: 26px; border-radius: 50%;
  background: rgba(255, 255, 255, .18); color: #fff;
  font-size: 16px; line-height: 1;
  display: flex; align-items: center; justify-content: center;
}
@keyframes pwaTipIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

