/* 移动端专用样式（m.html）
   字体策略：不加载 10.3MB 的 PingFang.ttf，中文直接用系统字体：
     iOS → PingFang SC ；Android → Noto Sans CJK / Roboto
   只加载 3 个十几 KB 的数字字体（金额、单号用），所以手机首屏体积 ≈ 代码 + 头像（按需） */

/* —— 数字字体（体积很小，保留，让金额与 PC 一致）—— */
@font-face { font-family: "SansStdRegular"; src: url("/assets/fonts/SansStdRegular.ttf") format("truetype"); font-display: swap; }
@font-face { font-family: "SansStdMedium";  src: url("/assets/fonts/SansStdMedium.ttf")  format("truetype"); font-display: swap; }
@font-face { font-family: "SansStdBold";    src: url("/assets/fonts/SansStdBold.ttf")    format("truetype"); font-display: swap; }
@font-face { font-family: "WeChatNum";      src: url("/assets/fonts/WeChatNum.ttf")      format("truetype"); font-display: swap; }

:root {
  --green: #07c160;
  --bg: #f2f2f2;
  --card: #fff;
  --line: #ececec;
  --text: #1a1a1a;
  --sub: #8a8a8a;
  --tabbar: 58px;
  --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.5 -apple-system, BlinkMacSystemFont, "PingFang SC", "Noto Sans CJK SC", "Microsoft YaHei", sans-serif;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior-y: none;
}

/* —— 顶部栏 —— */
header {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 8px;
  height: 52px; padding: 0 12px;
  background: rgba(255, 255, 255, .96);
  backdrop-filter: saturate(180%) blur(10px);
  border-bottom: 1px solid var(--line);
  padding-top: env(safe-area-inset-top, 0px);
  height: calc(52px + env(safe-area-inset-top, 0px));
}
header h1 { flex: 1; font-size: 16px; font-weight: 600; margin: 0; }
header .link { font-size: 13px; color: var(--green); text-decoration: none; }
header button {
  font-size: 14px; padding: 7px 12px; border: 1px solid var(--line);
  background: #fff; border-radius: 8px; color: var(--text);
}

/* —— 主体 —— */
main { padding: 10px 10px calc(var(--tabbar) + var(--safe-b) + 18px); }
.view { display: none; }
.view.active { display: block; }

.card { background: var(--card); border-radius: 12px; margin-bottom: 10px; overflow: hidden; }
.card.pad { padding: 12px; }

/* 顶部常改卡片：标签在左、控件在右，紧凑 */
.card.top { padding: 4px 12px 8px; }
.card.top .field { display: flex; align-items: center; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--line); }
.card.top .field:last-child { border-bottom: 0; }
.card.top .field > label { flex: 0 0 auto; width: 84px; color: var(--sub); font-size: 14px; }
.card.top .field > input, .card.top .field > select, .card.top .field > textarea { flex: 1; }
.card.top .field .hint-inline { display: none; }

/* 分组 */
.group-head {
  display: flex; align-items: center; gap: 8px;
  padding: 14px 14px; font-size: 15px; font-weight: 500;
  background: var(--card); border-bottom: 1px solid var(--line);
  cursor: pointer; user-select: none;
}
.group-head .cnt { margin-left: auto; color: var(--sub); font-size: 13px; font-weight: 400; }
.group-head .caret { color: #c0c0c0; transition: transform .18s ease; font-size: 13px; }
.group.open .group-head .caret { transform: rotate(90deg); }
.group-body { display: none; padding: 6px 14px 12px; background: var(--card); }
.group.open .group-body { display: block; }

/* 字段（与 PC 端 editor.js 生成的 DOM 兼容） */
.field { padding: 9px 0; }
.field.inline { display: flex; align-items: center; gap: 10px; }
.field > label { display: block; font-size: 13px; color: var(--sub); margin-bottom: 6px; }
.field.inline > label { margin-bottom: 0; flex: 1; }
.field input[type="text"], .field input[type="number"], .field select, .field textarea {
  width: 100%; min-height: 42px; padding: 9px 11px;
  font-size: 16px; /* ≥16px 防止 iOS 聚焦时自动放大 */
  border: 1px solid var(--line); border-radius: 9px; background: #fafafa; color: var(--text);
}
.field textarea { min-height: 76px; resize: vertical; }
.field input[type="checkbox"] { width: 22px; height: 22px; accent-color: var(--green); }
.field .hint-inline { display: block; font-size: 12px; color: #b0b0b0; margin-top: 4px; }
.field .row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.field .avatar-btn { width: 56px; height: 56px; padding: 0; border-radius: 50%; overflow: hidden; border: 1px solid var(--line); background: #f6f6f6; }
.field .avatar-btn img { width: 100%; height: 100%; object-fit: cover; display: block; }
.field button { min-height: 40px; padding: 8px 12px; font-size: 14px; border: 1px solid var(--line); border-radius: 9px; background: #fff; color: var(--text); }
.field button.primary, button.primary { background: var(--green); border-color: var(--green); color: #fff; }
.notice { background: #fff8e6; color: #8a6d1f; font-size: 12px; line-height: 1.6; padding: 10px 12px; border-radius: 10px; margin-bottom: 10px; }
.muted { color: var(--sub); font-size: 12px; }
.row-inline { display: flex; gap: 8px; align-items: center; }

/* —— 外观页 —— */
.setting { display: flex; align-items: center; gap: 10px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.setting:last-child { border-bottom: 0; }
.setting > label { flex: 0 0 78px; color: var(--sub); font-size: 14px; }
.setting select, .setting input { flex: 1; min-height: 42px; font-size: 16px; border: 1px solid var(--line); border-radius: 9px; background: #fafafa; padding: 8px 10px; }
.setting .chk { display: flex; align-items: center; gap: 8px; flex: 1; font-size: 15px; }

/* —— 预览页 —— */
#previewWrap { background: #ededed; border-radius: 12px; padding: 10px; }
#previewWrap canvas { display: block; width: 100%; height: auto; border-radius: 8px; background: #fff; box-shadow: 0 2px 10px rgba(0,0,0,.08); }
.preview-tip { text-align: center; color: var(--sub); font-size: 12px; margin: 10px 0 0; }
.preview-actions { display: flex; gap: 10px; margin: 12px 0 0; }
.preview-actions button { flex: 1; min-height: 48px; font-size: 16px; border-radius: 10px; border: 1px solid var(--line); background: #fff; color: var(--text); }
.preview-actions button.primary { background: var(--green); border-color: var(--green); color: #fff; }

/* —— 底部 tab —— */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: flex; height: calc(var(--tabbar) + var(--safe-b));
  padding-bottom: var(--safe-b);
  background: rgba(255, 255, 255, .97);
  border-top: 1px solid var(--line);
  backdrop-filter: saturate(180%) blur(10px);
}
.tabbar button {
  flex: 1; border: 0; background: none; color: var(--sub);
  font-size: 12px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  min-height: 44px; padding: 6px 0;
}
.tabbar button .ico { font-size: 19px; line-height: 1; }
.tabbar button.active { color: var(--green); font-weight: 600; }
.tabbar button:active { background: #f6f6f6; }

/* —— 提示条 / 模态 —— */
#toast {
  position: fixed; left: 50%; bottom: calc(var(--tabbar) + var(--safe-b) + 18px);
  transform: translateX(-50%) translateY(20px);
  background: rgba(0, 0, 0, .82); color: #fff; font-size: 14px;
  padding: 10px 16px; border-radius: 10px; opacity: 0; pointer-events: none;
  transition: opacity .2s ease, transform .2s ease; z-index: 60; max-width: 80vw; text-align: center;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#modal { position: fixed; inset: 0; background: rgba(0, 0, 0, .5); z-index: 70; display: flex; align-items: flex-end; }
#modal.hidden { display: none; }
#modal .sheet {
  width: 100%; max-height: 86vh; background: #fff;
  border-radius: 14px 14px 0 0; display: flex; flex-direction: column;
  padding-bottom: var(--safe-b);
}
#modal .sheet-head { display: flex; align-items: center; padding: 12px 14px; border-bottom: 1px solid var(--line); }
#modal .sheet-head h3 { flex: 1; margin: 0; font-size: 15px; }
#modal .sheet-head button { border: 0; background: none; color: var(--green); font-size: 15px; }
#modal-body { overflow: auto; padding: 12px 14px 16px; }
.avatar-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.avatar-grid button { padding: 0; border: 1px solid var(--line); border-radius: 50%; overflow: hidden; aspect-ratio: 1/1; background: #f6f6f6; }
.avatar-grid img { width: 100%; height: 100%; object-fit: cover; display: block; }
#share-panel { display: none; }
#share-panel.show { display: block; }
#share-url { color: var(--green); word-break: break-all; font-size: 12px; }
