:root {
  --primary: #2b6bf3;
  --primary-dark: #1f55d0;
  --bg: #f2f4f9;
  --card: #ffffff;
  --text: #1f2329;
  --text-2: #646a73;
  --text-3: #8f959e;
  --line: #e8eaef;
  --wechat: #07c160;
  --alipay: #1677ff;
  --radius: 16px;
}

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

html, body { margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 15px;
  line-height: 1.5;
  min-height: 100vh;
}

.hidden { display: none !important; }

.booting {
  padding: 80px 24px;
  text-align: center;
  color: var(--text-3);
  font-size: 14px;
}

.bootError { color: #e34d4d; line-height: 2; }
.bootError button {
  border: 0; background: var(--primary); color: #fff;
  border-radius: 10px; padding: 9px 20px; font-size: 14px;
}

/* 布局 */
.app {
  max-width: 560px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding-bottom: calc(76px + env(safe-area-inset-bottom, 0px));
}

.hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 22px 18px 10px;
}

.heroTitle { font-size: 22px; font-weight: 700; letter-spacing: 0.5px; }
.heroSub { font-size: 13px; color: var(--text-3); margin-top: 4px; }

.creditPill {
  border: 0;
  background: rgba(43, 107, 243, 0.1);
  color: var(--primary);
  border-radius: 999px;
  padding: 7px 14px;
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
  cursor: pointer;
  font-family: inherit;
}

.creditPill b { font-size: 19px; }
.creditPill span { font-size: 12px; }

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

.view { display: none; }
.view.active { display: block; }

/* 卡片 */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
}

.cardHead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.cardTitle { font-size: 15px; font-weight: 600; }
.cardHint { font-size: 12px; color: var(--text-3); }

.tip { color: var(--text-3); font-size: 12px; margin: 12px 0 0; line-height: 1.7; }
.tipLine { text-align: center; color: var(--text-3); font-size: 12px; margin: 4px 0 12px; }

/* 上传区 */
.uploaderRow { display: flex; gap: 10px; }

.uploader {
  position: relative;
  flex: 1 1 0;
  min-width: 0;
  aspect-ratio: 1 / 1;
  border: 1.5px dashed #d6dbe6;
  border-radius: 14px;
  background: #fbfcfe;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  cursor: pointer;
  transition: border-color 0.15s;
}

.uploader.hasImg { border-style: solid; border-color: transparent; background: #f5f7fb; }
.uploader:active { border-color: var(--primary); }

.placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  color: var(--text-3);
  font-size: 12.5px;
  pointer-events: none;
}

.plus { font-size: 26px; line-height: 1; color: #b8bfcc; font-weight: 300; }

.thumb {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #fff;
}

.uploaderBadge {
  position: absolute;
  left: 8px;
  top: 8px;
  font-size: 11px;
  color: #fff;
  border-radius: 6px;
  padding: 2px 7px;
  pointer-events: none;
}

.uploaderBadge.wechat { background: var(--wechat); }
.uploaderBadge.alipay { background: var(--alipay); }

/* 分段选择 */
.segRow {
  display: flex;
  background: #f2f4f8;
  border-radius: 11px;
  padding: 4px;
  margin-bottom: 16px;
}

.segItem {
  flex: 1;
  border: 0;
  background: transparent;
  color: var(--text-2);
  font-size: 14px;
  font-family: inherit;
  padding: 8px 0;
  border-radius: 8px;
  cursor: pointer;
}

.segItem.active { background: #fff; color: var(--primary); font-weight: 600; box-shadow: 0 2px 8px rgba(28, 46, 88, 0.08); }

/* 表单字段 */
.field { display: flex; align-items: center; gap: 12px; margin-top: 12px; }

.fieldLabel { flex: 0 0 46px; color: var(--text-2); font-size: 13.5px; }

.textInput {
  flex: 1 1 auto;
  min-width: 0;
  border: 1px solid var(--line);
  background: #fbfcfe;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 14px;
  color: var(--text);
  outline: none;
  font-family: inherit;
}

.textInput:focus { border-color: var(--primary); background: #fff; }

.range { flex: 1 1 auto; min-width: 0; accent-color: var(--primary); height: 26px; }

.fieldValue {
  flex: 0 0 34px;
  text-align: right;
  color: var(--text-2);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

/* 预览 */
.previewImg {
  width: 100%;
  display: block;
  border-radius: 12px;
  background: #f5f7fb;
  cursor: zoom-in;
}

.previewActions { display: flex; gap: 10px; margin-top: 14px; }
.previewActions .btn { flex: 1; }

/* 按钮 */
.btn {
  border: 1px solid transparent;
  border-radius: 11px;
  padding: 11px 18px;
  font-size: 15px;
  font-family: inherit;
  cursor: pointer;
  background: #f2f4f8;
  color: var(--text);
  transition: opacity 0.15s, background 0.15s;
}

.btn:active { opacity: 0.85; }
.btnPrimary { background: var(--primary); color: #fff; }
.btn.primary { background: var(--primary); color: #fff; }
.btn.ghost { background: #fff; border-color: var(--line); color: var(--text-2); }
.btn.big { width: 100%; padding: 14px; font-size: 16px; font-weight: 600; }
.btn.small { padding: 8px 14px; font-size: 13px; }
.btn:disabled { opacity: 0.6; cursor: default; }

/* 次数页 */
.balanceCard { text-align: center; padding: 20px 16px; }
.balanceLabel { color: var(--text-3); font-size: 13px; }
.balanceNum { margin-top: 6px; color: var(--primary); display: flex; align-items: baseline; justify-content: center; gap: 4px; }
.balanceNum b { font-size: 38px; line-height: 1.1; }
.balanceNum span { font-size: 14px; }
.balanceTip { color: var(--text-3); font-size: 12px; margin-top: 8px; }

.redeemRow { display: flex; gap: 10px; }
.redeemRow .textInput { flex: 1; }

.packageList { display: flex; flex-direction: column; gap: 10px; }
.packageList .empty { color: var(--text-3); font-size: 13px; text-align: center; margin: 10px 0; }

.pkgItem {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 13px 14px;
  background: #fbfcfe;
}

.pkgName { font-weight: 600; font-size: 14.5px; }
.pkgDesc { color: var(--text-3); font-size: 12.5px; margin-top: 3px; }
.pkgRight { text-align: right; flex: 0 0 auto; }
.pkgPrice { color: #e34d4d; font-weight: 700; font-size: 17px; margin-bottom: 6px; }
.pkgPrice small { font-size: 11px; font-weight: 500; margin-left: 2px; }

/* 底部 tab */
.tabbar {
  position: fixed;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  width: 100%;
  max-width: 560px;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(10px);
  border-top: 1px solid var(--line);
  display: flex;
  padding: 8px 14px calc(8px + env(safe-area-inset-bottom, 0px));
  z-index: 20;
}

.tabItem {
  flex: 1;
  border: 0;
  background: transparent;
  color: var(--text-3);
  font-family: inherit;
  font-size: 13px;
  padding: 6px 0;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.tabItem.active { color: var(--primary); font-weight: 600; }

/* 大图弹层 */
.imgModal {
  position: fixed;
  inset: 0;
  background: rgba(12, 16, 24, 0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 60;
  padding: 20px;
}

.imgModal img {
  max-width: 100%;
  max-height: 100%;
  border-radius: 10px;
  object-fit: contain;
}

.imgModalClose {
  position: absolute;
  top: calc(14px + env(safe-area-inset-top, 0px));
  right: 16px;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 0;
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
}

/* toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(96px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%) translateY(12px);
  background: rgba(31, 35, 41, 0.92);
  color: #fff;
  font-size: 13.5px;
  padding: 10px 18px;
  border-radius: 10px;
  max-width: 80vw;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 80;
}

.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* 隐藏的画布（只用于导出，不参与布局） */
.mergeCanvas {
  position: absolute;
  left: -9999px;
  top: 0;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

@media (min-width: 561px) {
  body { background: #e9edf5; }
  .app { background: var(--bg); box-shadow: 0 0 40px rgba(22, 40, 90, 0.08); }
}

/* 一码付：对外地址提示 */
.notice {
  border: 1px solid #ffd9a8;
  background: #fff7e6;
  color: #a86500;
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 12.5px;
  line-height: 1.75;
  margin-bottom: 12px;
}

.notice b { display: block; font-size: 13px; margin-bottom: 2px; }

.notice.danger {
  border-color: #ffc9c2;
  background: #fff2f0;
  color: #c0332b;
}

.noticeUrls {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px dashed rgba(168, 101, 0, 0.25);
  font-size: 12px;
  color: #646a73;
}

.noticeUrls .mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  margin-top: 2px;
  word-break: break-all;
}

/* 解码状态角标 */
.decodeBadge {
  position: absolute;
  right: 8px;
  bottom: 8px;
  font-size: 11px;
  border-radius: 6px;
  padding: 3px 8px;
  color: #fff;
  background: rgba(31, 35, 41, 0.55);
  pointer-events: none;
}

.decodeBadge.loading { background: rgba(43, 107, 243, 0.85); }
.decodeBadge.ok { background: rgba(7, 193, 96, 0.9); }
.decodeBadge.fail { background: rgba(227, 77, 77, 0.9); }

/* 聚合码预览 */
.qrPreview {
  width: 100%;
  max-width: 320px;
  display: block;
  margin: 0 auto;
  border-radius: 12px;
  background: #fff;
  cursor: zoom-in;
  box-shadow: 0 6px 20px rgba(28, 46, 88, 0.08);
}

/* 我的聚合码列表 */
.codeList { display: flex; flex-direction: column; gap: 10px; }

.codeList .empty { color: var(--text-3); font-size: 13px; text-align: center; margin: 10px 0; }

.codeItem {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  background: #fbfcfe;
}

.codeMain { flex: 1 1 auto; min-width: 0; }
.codeTitle { font-weight: 600; font-size: 14.5px; }
.codeMeta { color: var(--text-3); font-size: 12px; margin-top: 3px; word-break: break-all; }

.codeActions { display: flex; gap: 8px; flex: 0 0 auto; }


/* ================= 文档转换 ================= */
.docDrop {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px 16px;
  border: 1.5px dashed #d6dbe6;
  border-radius: 14px;
  background: #fbfcfe;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.docDrop.drag, .docDrop:active { border-color: var(--primary); background: #f2f7ff; }
.docIcon {
  width: 48px; height: 56px; flex: 0 0 auto;
  border-radius: 8px; background: var(--primary); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; letter-spacing: .5px;
}
.docPickText { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.docPickText b { font-size: 15px; }
.docPickText span { font-size: 12px; color: var(--text-3); line-height: 1.6; }

.docFileMeta {
  display: flex; flex-direction: column; gap: 2px;
  margin-top: 12px; padding: 10px 12px;
  background: #f6f8fc; border-radius: 10px;
  font-size: 12px; color: var(--text-2);
}
.docFileMeta b { font-size: 13px; color: var(--text); word-break: break-all; }

.docResultRow { display: flex; align-items: center; gap: 12px; }
.docResultIcon {
  width: 44px; height: 52px; border-radius: 8px; flex: 0 0 auto;
  background: #fff1f0; color: #d9363e; border: 1px solid #ffd6d3;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700;
}
.docResultInfo { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.docResultInfo b { font-size: 14px; word-break: break-all; }
.docResultInfo span { font-size: 12px; color: var(--text-3); }

.plainList { margin: 0; padding-left: 18px; color: var(--text-2); font-size: 12.5px; line-height: 1.9; }
.plainList b { color: var(--text); }

/* ================= 证件照 ================= */
.specGrid { display: flex; flex-direction: column; gap: 14px; }
.specGroupTitle { font-size: 12px; color: var(--text-3); margin-bottom: 8px; }
.specRow { display: flex; flex-wrap: wrap; gap: 8px; }
.specChip {
  border: 1px solid var(--line); background: #fff; color: var(--text-2);
  border-radius: 10px; padding: 8px 10px; cursor: pointer; font-family: inherit;
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px;
  min-width: 82px;
}
.specChip b { font-size: 13px; color: var(--text); }
.specChip span { font-size: 11px; color: var(--text-3); }
.specChip.active { border-color: var(--primary); background: rgba(43,107,243,.07); }
.specChip.active b { color: var(--primary); }

.photoStage {
  position: relative;
  display: flex; justify-content: center; align-items: center;
  min-height: 220px;
  padding: 10px;
  background: repeating-conic-gradient(#f4f6fa 0% 25%, #eef1f6 0% 50%) 50% / 20px 20px;
  border-radius: 12px;
  overflow: hidden;
  touch-action: none;
}
#photoCanvas { border-radius: 4px; box-shadow: 0 2px 10px rgba(20,30,50,.12); display: block; max-width: 100%; }
.photoEmpty { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; color: var(--text-3); font-size: 14px; text-align: center; line-height: 1.8; }
.photoEmpty small { font-size: 12px; color: #b1b6bf; }
.photoBusy { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(255,255,255,.86); padding: 18px; text-align: center; }
.photoBusyText { font-size: 13px; color: var(--text-2); line-height: 1.7; }

.photoTools { margin-top: 14px; display: flex; flex-direction: column; gap: 12px; }
.toolRow { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--text-2); }
.toolRow > span { width: 34px; flex: 0 0 auto; }
.toolRow input[type=range] { flex: 1; accent-color: var(--primary); }
.toolRow b { width: 44px; text-align: right; font-size: 12px; color: var(--text-3); font-weight: 500; }

.bgPicker { display: flex; gap: 8px; }
.bgDot {
  min-width: 44px; height: 30px; border-radius: 8px; border: 1px solid rgba(0,0,0,.12);
  font-size: 12px; color: #fff; cursor: pointer; font-family: inherit;
}
.bgDot.active { box-shadow: 0 0 0 2px var(--primary); }
.bgDot.plain { background: #fff; color: var(--text-2); }

.photoResultImg { width: 100%; max-width: 240px; border-radius: 10px; display: block; margin: 0 auto; }

/* ================= 我的 ================= */
.profileGrid { display: flex; flex-direction: column; }
.profileRow { display: flex; justify-content: space-between; gap: 14px; padding: 9px 0; border-bottom: 1px dashed #eef0f5; font-size: 13px; }
.profileRow:last-child { border-bottom: 0; }
.profileRow span { color: var(--text-3); flex: 0 0 auto; }
.profileRow b { color: var(--text); font-weight: 500; text-align: right; word-break: break-all; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }

.orderItem { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px dashed #eef0f5; }
.orderItem:last-child { border-bottom: 0; }
.orderMain { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.orderMain b { font-size: 13.5px; }
.orderMain span { font-size: 11.5px; color: var(--text-3); }
.orderExtra { color: #8f959e; }
.orderSide { text-align: right; flex: 0 0 auto; }
.orderSide b { display: block; font-size: 14px; }
.orderSide span { font-size: 11.5px; color: var(--wechat); }

.segTabs { display: flex; gap: 6px; margin-bottom: 10px; }
.segTab {
  flex: 1; border: 1px solid var(--line); background: #fff; color: var(--text-2);
  border-radius: 9px; padding: 7px 4px; font-size: 12.5px; font-family: inherit; cursor: pointer;
}
.segTab.active { background: rgba(43,107,243,.08); border-color: rgba(43,107,243,.35); color: var(--primary); font-weight: 600; }

.recordList { display: flex; flex-direction: column; }
.recordItem { display: flex; align-items: center; gap: 10px; padding: 11px 0; border-bottom: 1px dashed #eef0f5; }
.recordItem:last-child { border-bottom: 0; }
.recordThumb { width: 44px; height: 54px; object-fit: cover; border-radius: 8px; background: #f4f6fa; flex: 0 0 auto; }
.recordIcon {
  width: 44px; height: 54px; border-radius: 8px; flex: 0 0 auto;
  background: #f2f6ff; color: var(--primary); font-size: 12px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.recordBody { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.recordBody b { font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.recordBody span { font-size: 11.5px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.recordBody .recordTime { color: #b1b6bf; }
.recordActions { display: flex; flex-direction: column; gap: 4px; flex: 0 0 auto; }
.miniBtn {
  border: 1px solid var(--line); background: #fff; color: var(--text-2);
  border-radius: 7px; padding: 4px 9px; font-size: 11.5px; font-family: inherit; cursor: pointer;
}
.miniBtn.danger { color: #d9363e; border-color: #ffd6d3; }
.miniBtn:disabled { opacity: .5; }
