:root {
  --accent: #0b7a5c;
  --accent-2: #12a07a;
  --bg: #f4f5f7;
  --card: #ffffff;
  --text: #1c1f23;
  --muted: #7a8089;
  --line: #e5e7eb;
  --danger: #d93025;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text);
  font: 15px/1.5 -apple-system, "PingFang SC", "HarmonyOS Sans SC", "MiSans", "Noto Sans CJK SC", "Microsoft YaHei", sans-serif; }
#app { min-height: 100%; display: flex; flex-direction: column; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
button:disabled { opacity: .35; }
.muted { color: var(--muted); }
.warn { color: #c77700; }
.link { color: var(--accent); text-decoration: underline; font-size: inherit; }

/* 顶栏 */
.bar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 8px;
  padding: calc(10px + var(--safe-top)) 12px 10px; background: var(--card); border-bottom: 1px solid var(--line); }
.bar.dark { background: #111; color: #fff; border-color: #222; }
.bar-title { flex: 1; min-width: 0; font-size: 17px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-align: center; }
.bar-title .pen { color: var(--muted); font-size: 14px; font-weight: 400; }
.icon-btn { width: 40px; height: 40px; font-size: 26px; line-height: 40px; text-align: center; border-radius: 20px; }
.icon-btn:active { background: rgba(0,0,0,.06); }
.home-bar { justify-content: space-between; padding-left: 18px; padding-right: 18px; border: 0; background: var(--bg); position: static; }
.brand { font-size: 24px; font-weight: 700; letter-spacing: 1px; }
.count { color: var(--muted); font-size: 13px; }
.btn-primary { background: var(--accent); color: #fff; border-radius: 20px; padding: 9px 20px; font-weight: 600; }
.btn-primary.sm { padding: 7px 16px; }
.btn-primary:active { background: var(--accent-2); }

/* 首页 */
.search { padding: 0 16px 10px; }
.search input { width: 100%; height: 42px; border: 0; border-radius: 21px; padding: 0 18px; font: inherit;
  background: var(--card); box-shadow: 0 1px 2px rgba(0,0,0,.05); outline: none; }
.list { flex: 1; padding: 0 12px calc(110px + var(--safe-bottom)); }
.item { display: flex; gap: 12px; align-items: center; background: var(--card); border-radius: 14px; padding: 10px; margin-bottom: 10px;
  box-shadow: 0 1px 2px rgba(0,0,0,.04); }
.item:active { background: #eef3f1; }
.thumb { width: 56px; height: 76px; flex: none; border-radius: 6px; overflow: hidden; background: #e9ecef; border: 1px solid var(--line); }
.thumb img { width: 100%; height: 100%; object-fit: cover; object-position: top; }
.info { flex: 1; min-width: 0; }
.title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.meta { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.snip { font-size: 12.5px; color: #4b5059; margin-top: 4px; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.snip mark { background: #ffe58f; color: inherit; padding: 0 1px; border-radius: 2px; }
.more { width: 36px; height: 36px; font-size: 20px; color: var(--muted); border-radius: 18px; flex: none; }
.empty { text-align: center; padding: 80px 20px; color: var(--text); }
.empty-ico { font-size: 54px; opacity: .5; }
.home-actions { position: fixed; left: 0; right: 0; bottom: 0; display: flex; gap: 12px; padding: 12px 16px calc(14px + var(--safe-bottom));
  background: linear-gradient(to top, var(--bg) 70%, rgba(244,245,247,0)); }
.btn-shoot { flex: 2; height: 54px; border-radius: 27px; background: var(--accent); color: #fff; font-size: 17px; font-weight: 700;
  box-shadow: 0 6px 16px rgba(11,122,92,.35); display: flex; align-items: center; justify-content: center; gap: 8px; }
.btn-shoot:active { background: var(--accent-2); }
.btn-ghost { flex: 1; height: 54px; border-radius: 27px; background: var(--card); font-weight: 600; box-shadow: 0 1px 3px rgba(0,0,0,.08);
  display: flex; align-items: center; justify-content: center; gap: 6px; }
.wide { width: 100%; flex: none; margin-top: 12px; }

/* 相机 */
.cam { position: fixed; inset: 0; background: #000; color: #fff; overflow: hidden; }
.cam video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.cam-flash { position: absolute; inset: 0; background: #fff; opacity: 0; pointer-events: none; transition: opacity .12s; }
.cam-flash.on { opacity: .7; transition: none; }
.cam-top { position: absolute; top: 0; left: 0; right: 0; display: flex; align-items: center; justify-content: space-between;
  padding: calc(12px + var(--safe-top)) 14px 12px; background: linear-gradient(rgba(0,0,0,.55), rgba(0,0,0,0)); }
.cam-close, .cam-torch { width: 42px; height: 42px; border-radius: 21px; background: rgba(0,0,0,.35); font-size: 20px; }
.cam-torch.on { background: #ffd54f; color: #000; }
.cam-count { font-weight: 600; background: rgba(0,0,0,.35); padding: 4px 14px; border-radius: 14px; }
.cam-guide { position: absolute; top: 46%; left: 0; right: 0; text-align: center; color: rgba(255,255,255,.75); font-size: 13px; text-shadow: 0 1px 2px #000; pointer-events: none; }
.cam-bottom { position: absolute; left: 0; right: 0; bottom: 0; display: flex; align-items: center; justify-content: space-around;
  padding: 18px 20px calc(26px + var(--safe-bottom)); background: linear-gradient(rgba(0,0,0,0), rgba(0,0,0,.65)); }
.cam-shutter { width: 76px; height: 76px; border-radius: 50%; border: 4px solid #fff; padding: 5px; }
.cam-shutter span { display: block; width: 100%; height: 100%; border-radius: 50%; background: #fff; transition: transform .1s; }
.cam-shutter:active span { transform: scale(.88); }
.cam-last { position: relative; width: 52px; height: 52px; border-radius: 8px; border: 2px solid rgba(255,255,255,.8);
  background: rgba(255,255,255,.12) center/cover no-repeat; }
.badge { position: absolute; top: -8px; right: -8px; min-width: 22px; height: 22px; border-radius: 11px; background: var(--accent-2);
  font-size: 12px; font-weight: 700; line-height: 22px; padding: 0 6px; }
.cam-done { width: 64px; height: 40px; border-radius: 20px; background: var(--accent); font-weight: 700; }
.cam-status { position: absolute; bottom: calc(120px + var(--safe-bottom)); left: 0; right: 0; text-align: center; font-size: 13px; color: rgba(255,255,255,.85); }
.syscam { flex: 1; display: flex; align-items: center; justify-content: center; padding: 24px; }
.syscam-box { width: 100%; max-width: 360px; text-align: center; }
.syscam-count { font-size: 28px; font-weight: 700; }

/* 编辑 */
.screen { position: fixed; inset: 0; display: flex; flex-direction: column; background: var(--bg); }
.screen.dark { background: #111; }
.edit-main { flex: 1; display: flex; flex-direction: column; padding: 12px 14px 8px; min-height: 0; background: #e9ebee; }
.edit-view { position: relative; flex: 1; width: 100%; min-height: 0; }
.edit-view img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; filter: drop-shadow(0 3px 10px rgba(0,0,0,.2)); }
.edit-idx { text-align: center; margin-top: 6px; font-size: 13px; color: var(--muted); }
.strip { display: flex; gap: 8px; overflow-x: auto; padding: 10px 12px; background: var(--card); border-top: 1px solid var(--line); scrollbar-width: none; }
.strip::-webkit-scrollbar { display: none; }
.strip-item { position: relative; flex: none; width: 48px; height: 64px; border-radius: 5px; overflow: hidden; border: 2px solid transparent; background: #eee; }
.strip-item.on { border-color: var(--accent); }
.strip-item img { width: 100%; height: 100%; object-fit: cover; }
.strip-item span { position: absolute; right: 2px; bottom: 1px; font-size: 10px; background: rgba(0,0,0,.55); color: #fff; padding: 0 4px; border-radius: 4px; }
.strip-add { flex: none; width: 48px; height: 64px; border-radius: 5px; border: 2px dashed #b7bcc4; color: #8a9099; font-size: 24px;
  display: flex; align-items: center; justify-content: center; }
.tools { display: flex; justify-content: space-around; padding: 8px 4px calc(10px + var(--safe-bottom)); background: var(--card); border-top: 1px solid var(--line); }
.tools button { display: flex; flex-direction: column; align-items: center; font-size: 12px; color: #3c4046; min-width: 50px; }
.tools button span { font-size: 20px; line-height: 28px; }

/* 裁剪 */
.crop-main { position: relative; flex: 1; display: flex; align-items: center; justify-content: center; background: #111; min-height: 0; }
.crop-stage { position: relative; touch-action: none; }
.crop-stage img { width: 100%; height: 100%; display: block; user-select: none; -webkit-user-drag: none; }
.crop-stage svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; touch-action: none; }
.crop-shade { fill: rgba(0,0,0,.5); }
.crop-line { fill: none; stroke: var(--accent-2); stroke-width: 2.5; }
.crop-h { fill: rgba(18,160,122,.25); stroke: #fff; stroke-width: 3; }
.loupe { position: absolute; width: 110px; height: 110px; border-radius: 50%; border: 3px solid #fff; box-shadow: 0 2px 10px rgba(0,0,0,.6);
  background-repeat: no-repeat; pointer-events: none; }
.loupe::after { content: ""; position: absolute; left: 50%; top: 50%; width: 10px; height: 10px; margin: -5px; border-radius: 50%; border: 2px solid var(--accent-2); }
.crop-tools { display: flex; gap: 10px; padding: 12px 16px calc(14px + var(--safe-bottom)); background: #111; }
.crop-tools button { flex: 1; height: 44px; border-radius: 22px; background: #2a2d31; color: #fff; }
.crop-tools .btn-primary { background: var(--accent); }

/* 详情 */
.doc-meta { padding: 10px 16px 0; color: var(--muted); font-size: 13px; }
.doc-actions { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; padding: 12px; }
.doc-actions button { background: var(--card); border-radius: 12px; padding: 10px 4px 8px; display: flex; flex-direction: column; align-items: center;
  font-size: 13px; font-weight: 600; box-shadow: 0 1px 2px rgba(0,0,0,.05); }
.doc-actions button:active { background: #eef3f1; }
.doc-actions .ico { font-size: 22px; line-height: 30px; }
.doc-actions small { font-size: 10.5px; color: var(--muted); font-weight: 400; margin-top: 1px; white-space: nowrap; }
.tabs { display: flex; gap: 6px; padding: 0 16px; border-bottom: 1px solid var(--line); }
.tabs button { padding: 8px 14px; color: var(--muted); border-bottom: 2px solid transparent; font-weight: 600; }
.tabs button.on { color: var(--accent); border-color: var(--accent); }
.doc-body { padding: 14px 16px calc(24px + var(--safe-bottom)); }
.doc-page { margin: 0 0 14px; position: relative; }
.doc-page img { width: 100%; display: block; background: #fff; box-shadow: 0 2px 8px rgba(0,0,0,.12); }
.doc-page figcaption { position: absolute; right: 8px; bottom: 8px; font-size: 11px; background: rgba(0,0,0,.5); color: #fff; padding: 0 6px; border-radius: 6px; }
.doc-text { white-space: pre-wrap; background: var(--card); border-radius: 12px; padding: 14px; font-size: 14.5px; line-height: 1.75;
  user-select: text; -webkit-user-select: text; word-break: break-all; }
.viewer { position: fixed; inset: 0; z-index: 30; background: #000; display: flex; align-items: center; justify-content: center; }
.viewer img { max-width: 100%; max-height: 100%; }
.viewer-idx { position: absolute; bottom: calc(20px + var(--safe-bottom)); color: #fff; font-size: 13px; }

/* 弹层 */
.toast { position: fixed; left: 50%; bottom: calc(120px + var(--safe-bottom)); transform: translate(-50%, 10px); z-index: 50;
  background: rgba(28,31,35,.92); color: #fff; padding: 9px 18px; border-radius: 20px; font-size: 14px; opacity: 0; transition: .2s; max-width: 86vw; text-align: center; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.busy { position: fixed; inset: 0; z-index: 40; background: rgba(0,0,0,.35); display: flex; align-items: center; justify-content: center; }
.busy-box { background: #fff; border-radius: 14px; padding: 20px 26px; min-width: 160px; text-align: center; }
.spinner { width: 34px; height: 34px; margin: 0 auto 10px; border-radius: 50%; border: 3px solid #d7efe7; border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.modal { position: fixed; inset: 0; z-index: 45; background: rgba(0,0,0,.4); display: flex; align-items: center; justify-content: center; padding: 24px; }
.modal-box { background: #fff; border-radius: 16px; width: 100%; max-width: 340px; padding: 20px 18px 14px; }
.modal-title { font-size: 17px; font-weight: 700; margin-bottom: 8px; }
.modal-msg { color: #4b5059; white-space: pre-wrap; word-break: break-all; margin-bottom: 10px; }
.modal-input { width: 100%; height: 42px; border: 1px solid var(--line); border-radius: 10px; padding: 0 12px; font: inherit; margin: 4px 0 12px; outline-color: var(--accent); }
.modal-btns { display: flex; justify-content: flex-end; gap: 8px; }
.modal-btns button { padding: 8px 16px; border-radius: 18px; font-weight: 600; color: #4b5059; }
.modal-btns .primary { background: var(--accent); color: #fff; }
.modal-btns .danger { background: var(--danger); color: #fff; }
.sheet-mask { position: fixed; inset: 0; z-index: 44; background: rgba(0,0,0,0); transition: background .2s; }
.sheet-mask.show { background: rgba(0,0,0,.4); }
.sheet { position: absolute; left: 0; right: 0; bottom: 0; background: #fff; border-radius: 18px 18px 0 0; padding: 8px 10px calc(10px + var(--safe-bottom));
  transform: translateY(100%); transition: transform .2s; }
.sheet-mask.show .sheet { transform: none; }
.sheet-title { text-align: center; color: var(--muted); font-size: 13px; padding: 8px 0 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sheet-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 13px 12px; border-radius: 12px; font-size: 16px; text-align: left; flex-wrap: wrap; }
.sheet-item:active { background: #f1f3f5; }
.sheet-item .ico { font-size: 20px; width: 26px; text-align: center; }
.sheet-item small { flex-basis: 100%; color: var(--muted); font-size: 12px; margin-top: -2px; padding-left: 0; }
.sheet-item .ico ~ small { padding-left: 36px; }
.sheet-item.cancel { justify-content: center; color: var(--muted); border-top: 1px solid var(--line); border-radius: 0; margin-top: 4px; }
.sheet-item.danger { color: var(--danger); }
.sheet-item.accent { color: var(--accent); font-weight: 600; }

/* 滤镜面板 */
.screen.filtering .strip, .screen.filtering .tools { display: none; }
.edit-view img { transition: opacity .15s; }
.edit-view img.loading { opacity: .5; }
.fpanel { background: var(--card); border-top: 1px solid var(--line); padding: 8px 0 calc(4px + var(--safe-bottom)); }
.fp-adj { display: flex; align-items: center; gap: 10px; padding: 2px 18px; font-size: 13px; color: var(--muted); }
.fp-adj.off { visibility: hidden; }
.fp-adj input { flex: 1; accent-color: var(--accent); }
.fp-adj b { width: 28px; text-align: right; color: var(--text); font-weight: 600; }
.fp-tip { min-height: 18px; padding: 0 18px 6px; font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fp-tiles { display: flex; gap: 8px; overflow-x: auto; padding: 2px 12px 8px; scrollbar-width: none; }
.fp-tiles::-webkit-scrollbar { display: none; }
.fp-tile { flex: none; width: 66px; border-radius: 6px; overflow: hidden; background: #6b7078; border: 2px solid transparent; }
.fp-tile.on { border-color: var(--accent); background: var(--accent); }
.fp-img { position: relative; height: 80px; background: #eceef1; display: flex; align-items: center; justify-content: center; }
.fp-img img { width: 100%; height: 100%; object-fit: cover; object-position: top; }
.fp-tile > span { display: block; color: #fff; font-size: 12px; line-height: 22px; text-align: center; white-space: nowrap; }
.fp-load { width: 16px; height: 16px; border-radius: 50%; border: 2px solid #cfd3d8; border-top-color: var(--accent); animation: spin .8s linear infinite; }
.fp-bar { display: flex; align-items: center; justify-content: space-between; padding: 4px 10px 2px; }
.fp-x, .fp-ok { width: 48px; height: 40px; font-size: 20px; }
.fp-ok { color: var(--accent); font-size: 24px; font-weight: 700; }
.fp-all { padding: 7px 16px; border-radius: 18px; background: #eef3f1; color: var(--accent); font-weight: 600; font-size: 14px; }

/* 取景框识别框 */
.cam-svg { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.cam-svg polygon { fill: rgba(18,160,122,.18); stroke: #19c99a; stroke-width: 3; stroke-linejoin: round; opacity: 0; transition: opacity .2s; }
.cam-svg.found polygon { opacity: 1; transition: opacity .2s, points .12s; }

/* 转文字 */
.ok { color: var(--accent); }
.doc-actions button.hl { background: #e6f4ef; color: var(--accent); }
.doc-actions button.hl small { color: var(--accent); opacity: .8; }
.empty-ocr { text-align: center; padding: 28px 16px; }
.empty-ocr .btn-primary { margin: 6px 0 10px; padding: 11px 26px; font-size: 16px; }
.small { font-size: 12px; }

.tools button.on { color: var(--accent); font-weight: 600; }
.tools button { min-width: 44px; }

/* 网页版提示 */
.webtip { position: relative; margin: 0 16px 10px; padding: 10px 40px 10px 14px; border-radius: 12px; background: #e6f4ef; color: #0b5c46;
  display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; font-size: 13px; }
.webtip b { flex-basis: 100%; font-size: 14px; }
.webtip span { flex: 1; min-width: 0; }
.webtip.warn { background: #fff4e5; color: #8a4b00; padding-right: 14px; }
.webtip-x { position: absolute; top: 6px; right: 6px; width: 28px; height: 28px; color: inherit; opacity: .6; }
.ios-share { display: inline-block; width: 14px; height: 16px; vertical-align: -2px; border: 1.6px solid currentColor; border-top: 0; border-radius: 0 0 3px 3px; position: relative; margin: 0 2px; }
.ios-share::before { content: ""; position: absolute; left: 50%; top: -7px; width: 1.6px; height: 11px; background: currentColor; transform: translateX(-50%); }
.ios-share::after { content: ""; position: absolute; left: 50%; top: -8px; width: 5px; height: 5px; border-left: 1.6px solid currentColor; border-top: 1.6px solid currentColor; transform: translateX(-50%) rotate(45deg); }
