/* 牛牛修图 H5 —— 与小程序版同一套设计 token（rpx÷2 ≈ px） */
:root {
  --primary: #4F46E5;
  --primary-dark: #4338CA;
  --bg: #f6f7fb;
  --card: #ffffff;
  --text: #1f2430;
  --text-sub: #8a90a6;
  --radius: 12px;
  --gold1: #ffe9a8;
  --gold2: #ffd666;
  --safe-b: env(safe-area-inset-bottom, 0px);
}
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  background: #e8eaf2;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", Helvetica, Arial, sans-serif;
  color: var(--text);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}
#app { max-width: 480px; margin: 0 auto; height: 100dvh; display: flex; flex-direction: column; background: var(--bg); position: relative; overflow: hidden; }
#screen { flex: 1; overflow-y: auto; overflow-x: hidden; -webkit-overflow-scrolling: touch; }
#screen::-webkit-scrollbar { display: none; }

/* 顶栏 */
#navbar {
  height: 44px; background: #fff; display: flex; align-items: center; justify-content: center;
  font-size: 17px; font-weight: 600; flex-shrink: 0; box-shadow: 0 .5px 0 rgba(0,0,0,.06);
  position: relative; z-index: 20;
}
#nav-back { position: absolute; left: 4px; top: 0; height: 44px; width: 44px; display: flex; align-items: center; justify-content: center; font-size: 28px; color: #333; cursor: pointer; }
#nav-right { position: absolute; right: 12px; top: 0; height: 44px; display: flex; align-items: center; font-size: 13px; color: var(--primary); }

/* 底部 tab */
#tabbar {
  display: flex; background: #fff; border-top: .5px solid rgba(0,0,0,.06);
  padding-bottom: var(--safe-b); flex-shrink: 0; z-index: 20;
}
#tabbar .tab { flex: 1; display: flex; flex-direction: column; align-items: center; padding: 6px 0 4px; cursor: pointer; }
#tabbar .tab img { width: 26px; height: 26px; }
#tabbar .tab span { font-size: 11px; color: #9aa0b4; margin-top: 2px; }
#tabbar .tab.on span { color: var(--primary); font-weight: 600; }

/* ===== 通用组件 ===== */
.card { background: var(--card); border-radius: var(--radius); }
.btn-primary {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  height: 48px; border-radius: 24px; background: var(--primary); color: #fff;
  font-size: 16px; font-weight: 600; border: 0; cursor: pointer; user-select: none;
}
.btn-primary:active { background: var(--primary-dark); }
.btn-ghost {
  display: flex; align-items: center; justify-content: center;
  height: 44px; border-radius: 22px; background: #eef0f7; color: var(--text);
  font-size: 15px; font-weight: 500; border: 0; cursor: pointer;
}
.text-sub { color: var(--text-sub); font-size: 12px; }

/* ===== 首页 ===== */
.page { padding: 12px 16px calc(20px + var(--safe-b)); }
.hero { display: flex; justify-content: space-between; align-items: flex-start; padding: 8px 4px 14px; }
.logo { font-size: 24px; font-weight: 800; letter-spacing: .5px; }
.slogan { font-size: 12px; color: var(--text-sub); margin-top: 4px; }
.demo-badge { display: inline-block; margin-top: 6px; font-size: 10px; color: #a16207; background: rgba(250,173,20,.12); padding: 2px 8px; border-radius: 8px; }
.quota-pill { display: flex; flex-direction: column; align-items: center; background: var(--card); border-radius: 14px; padding: 8px 14px; box-shadow: 0 2px 8px rgba(31,36,48,.06); cursor: pointer; }
.quota-num { font-size: 20px; font-weight: 800; color: var(--primary); }
.quota-pill--vip .quota-num { background: linear-gradient(135deg, #b8860b, #ffd666); -webkit-background-clip: text; background-clip: text; color: transparent; }
.quota-text { font-size: 10px; color: var(--text-sub); margin-top: 1px; }

.notice { display: flex; align-items: center; gap: 6px; background: #fffbe8; border-radius: 10px; padding: 8px 12px; font-size: 12px; color: #8a6d1a; margin-bottom: 10px; }
.consult { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; margin-bottom: 12px; }
.consult-title { font-size: 15px; font-weight: 700; }
.consult-desc { font-size: 11px; color: var(--text-sub); margin-top: 3px; }
.consult-btn { background: #07c160; color: #fff; font-size: 13px; font-weight: 600; padding: 8px 16px; border-radius: 18px; cursor: pointer; }
.consult-btn:active { opacity: .85; }

.main-btn { margin: 2px 0 16px; position: relative; }
.main-btn-icon { width: 22px; height: 22px; filter: brightness(0) invert(1); }
.main-btn--busy { opacity: .7; pointer-events: none; }

.section-head { display: flex; justify-content: space-between; align-items: center; margin: 16px 4px 10px; }
.section-title { font-size: 16px; font-weight: 700; }
.section-more { font-size: 12px; color: var(--text-sub); cursor: pointer; }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid-item { padding: 14px 12px; cursor: pointer; transition: transform .12s; }
.grid-item:active { transform: scale(.97); }
.grid-icon { width: 40px; height: 40px; margin-bottom: 8px; }
.grid-name { font-size: 14px; font-weight: 600; display: flex; align-items: center; gap: 5px; }
.grid-desc { font-size: 11px; color: var(--text-sub); margin-top: 4px; line-height: 1.4; }
.vip-tag { font-size: 9px; font-weight: 700; color: #8a6d1a; background: linear-gradient(135deg, var(--gold1), var(--gold2)); padding: 1px 5px; border-radius: 5px; }

.vipcard { display: flex; justify-content: space-between; align-items: center; margin-top: 16px; padding: 16px; border-radius: var(--radius); background: linear-gradient(135deg, #2b2b3a, #4a4a5e); color: #fff; cursor: pointer; }
.vipcard-title { font-size: 15px; font-weight: 700; }
.vipcard-desc { font-size: 11px; opacity: .75; margin-top: 4px; }
.vipcard-price { font-size: 18px; font-weight: 800; color: var(--gold2); margin-right: 4px; }
.vipcard-cta { font-size: 13px; opacity: .9; }

.works-scroll { display: flex; gap: 10px; overflow-x: auto; padding: 2px; }
.works-scroll::-webkit-scrollbar { display: none; }
.work-card { flex-shrink: 0; width: 88px; cursor: pointer; }
.work-thumb { width: 88px; height: 88px; border-radius: 10px; background: #e9ebf3; object-fit: cover; display: block; }
.work-time { font-size: 10px; color: var(--text-sub); margin-top: 4px; text-align: center; }

/* ===== 工具页 ===== */
.tool-page { padding: 12px 16px calc(24px + var(--safe-b)); display: flex; flex-direction: column; min-height: 100%; }
.tool-tip { font-size: 12px; color: var(--text-sub); margin-bottom: 12px; padding: 0 4px; }
.pick-area { border: 1.5px dashed #c7cbe0; border-radius: var(--radius); padding: 36px 16px; text-align: center; color: var(--text-sub); cursor: pointer; background: #fff; }
.pick-area img { max-width: 100%; max-height: 260px; border-radius: 8px; }
.pick-text { font-size: 14px; }
.pick-sub { font-size: 11px; margin-top: 4px; opacity: .8; }
.opt-row { display: flex; align-items: center; justify-content: space-between; background: #fff; border-radius: 10px; padding: 10px 14px; margin-top: 10px; gap: 10px; }
.opt-label { font-size: 14px; flex-shrink: 0; }
.opt-row input[type=text], .opt-row input[type=number], .opt-row input:not([type]) { flex: 1; border: 1px solid #e3e5f0; border-radius: 8px; padding: 8px 10px; font-size: 14px; outline: none; min-width: 0; }
.opt-row input:focus { border-color: var(--primary); }
.opt-row input[type=range] { flex: 1; accent-color: var(--primary); }
.opt-row input[type=range] + .opt-val, .opt-val { font-size: 12px; color: var(--text-sub); min-width: 36px; text-align: right; }
.opt-seg { display: flex; flex-wrap: wrap; gap: 8px; flex: 1; justify-content: flex-end; }
.opt-chip { font-size: 12px; padding: 6px 12px; border-radius: 15px; background: #eef0f7; color: var(--text); cursor: pointer; border: 1px solid transparent; }
.opt-chip.on { background: rgba(79,70,229,.1); border-color: var(--primary); color: var(--primary); font-weight: 600; }
.switch { position: relative; width: 46px; height: 26px; flex-shrink: 0; cursor: pointer; }
.switch input { opacity: 0; width: 100%; height: 100%; position: absolute; margin: 0; cursor: pointer; z-index: 1; }
.switch .track { position: absolute; inset: 0; background: #d5d8e6; border-radius: 13px; transition: .2s; }
.switch .track::after { content: ''; position: absolute; left: 3px; top: 3px; width: 20px; height: 20px; background: #fff; border-radius: 50%; transition: .2s; box-shadow: 0 1px 3px rgba(0,0,0,.2); }
.switch input:checked + .track { background: var(--primary); }
.switch input:checked + .track::after { transform: translateX(20px); }
.tool-actions { margin-top: 16px; display: flex; flex-direction: column; gap: 10px; }
.result-box { margin-top: 14px; background: #fff; border-radius: var(--radius); padding: 12px; }
.result-box img, .result-box canvas { max-width: 100%; border-radius: 8px; display: block; }
.result-text { font-size: 12px; color: var(--text-sub); margin-top: 8px; line-height: 1.5; white-space: pre-wrap; }
.file-card { display: flex; align-items: center; gap: 10px; background: #eef0f7; border-radius: 10px; padding: 14px; }
.file-card .fname { font-size: 14px; font-weight: 600; word-break: break-all; }

/* ===== 编辑器 ===== */
.editor { display: flex; flex-direction: column; height: 100%; }
.canvas-wrap { flex: 1; position: relative; margin: 12px 16px; border-radius: var(--radius); overflow: hidden; min-height: 280px;
  background: repeating-conic-gradient(#e9e9ef 0% 25%, #fff 0% 50%) 0 0 / 20px 20px; }
.bg-layer { position: absolute; inset: 0; }
.bg-layer img { width: 100%; height: 100%; object-fit: cover; }
#e-fg { position: absolute; top: 0; left: 0; transform-origin: 0 0; touch-action: none; user-select: none; -webkit-user-drag: none; }
.spec-bar, .bg-bar { display: flex; gap: 8px; overflow-x: auto; padding: 8px 16px; flex-shrink: 0; }
.spec-bar::-webkit-scrollbar, .bg-bar::-webkit-scrollbar { display: none; }
.spec-chip { flex-shrink: 0; font-size: 12px; padding: 7px 14px; border-radius: 16px; background: #fff; border: 1px solid #e3e5f0; cursor: pointer; }
.spec-chip.on { border-color: var(--primary); color: var(--primary); font-weight: 600; background: rgba(79,70,229,.08); }
.bg-chip { flex-shrink: 0; width: 56px; text-align: center; cursor: pointer; position: relative; }
.bg-thumb { width: 56px; height: 56px; border-radius: 10px; border: 2px solid transparent; overflow: hidden; background: repeating-conic-gradient(#ddd 0% 25%, #fff 0% 50%) 0 0 / 12px 12px; }
.bg-thumb > div { width: 100%; height: 100%; }
.bg-thumb img { width: 100%; height: 100%; object-fit: cover; }
.bg-chip.on .bg-thumb { border-color: var(--primary); }
.bg-name { font-size: 10px; color: var(--text-sub); margin-top: 3px; }
.bg-lock { position: absolute; top: 2px; right: 2px; background: linear-gradient(135deg, var(--gold1), var(--gold2)); font-size: 8px; font-weight: 700; color: #5d4300; padding: 1px 4px; border-radius: 4px; }
.adj-panel { padding: 4px 16px 0; flex-shrink: 0; }
.adj-row { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; }
.adj-row label { font-size: 12px; color: var(--text-sub); width: 40px; }
.adj-row input { flex: 1; accent-color: var(--primary); }
.editor-actions { display: flex; gap: 10px; padding: 10px 16px calc(12px + var(--safe-b)); flex-shrink: 0; }
.editor-actions .btn-primary { flex: 1; }
.editor-actions .btn-ghost { flex: 1; }

/* 证件照规格模式 */
#idp-wrap { position: absolute; inset: 0; display: none; align-items: center; justify-content: center; background: #f0f0f4; }
#idp-canvas { position: relative; box-shadow: 0 2px 12px rgba(0,0,0,.12); overflow: hidden; }
#idp-bg { position: absolute; inset: 0; }
#idp-fg { position: absolute; touch-action: none; user-select: none; -webkit-user-drag: none; }

/* ===== 作品/我的/VIP ===== */
.works-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; padding: 12px 16px; }
.work-cell { border-radius: 10px; overflow: hidden; background: #fff; cursor: pointer; }
.work-cell img { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; background: #e9ebf3; }
.work-cell .wt { font-size: 10px; color: var(--text-sub); padding: 4px 6px; }
.empty { text-align: center; padding: 80px 0; color: var(--text-sub); }
.empty img { width: 96px; opacity: .6; }
.empty p { margin-top: 10px; font-size: 13px; }
.mine-head { display: flex; align-items: center; gap: 14px; padding: 20px 16px; }
.mine-avatar { width: 56px; height: 56px; border-radius: 50%; background: linear-gradient(135deg, #667eea, #764ba2); display: flex; align-items: center; justify-content: center; font-size: 26px; }
.mine-name { font-size: 17px; font-weight: 700; }
.mine-sub { font-size: 12px; color: var(--text-sub); margin-top: 3px; }
.mine-card { margin: 0 16px 12px; padding: 4px 0; border-radius: var(--radius); background: #fff; }
.mine-row { display: flex; justify-content: space-between; align-items: center; padding: 14px 16px; font-size: 14px; border-bottom: .5px solid #f0f1f6; cursor: pointer; }
.mine-row:last-child { border-bottom: 0; }
.mine-row .val { color: var(--text-sub); font-size: 13px; }
.vip-hero { margin: 16px; padding: 24px 20px; border-radius: 16px; background: linear-gradient(135deg, #2b2b3a, #4a4a5e); color: #fff; }
.vip-hero .price { font-size: 40px; font-weight: 800; color: var(--gold2); }
.vip-hero .price small { font-size: 14px; font-weight: 400; }
.vip-perk { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.vip-perk span { font-size: 11px; background: rgba(255,255,255,.12); padding: 4px 10px; border-radius: 10px; }
.vip-btn { margin: 16px; height: 48px; border-radius: 24px; background: linear-gradient(135deg, var(--gold1), var(--gold2)); color: #4a3500; font-size: 16px; font-weight: 700; display: flex; align-items: center; justify-content: center; cursor: pointer; border: 0; }
.vip-note { text-align: center; font-size: 11px; color: var(--text-sub); padding-bottom: 20px; }

/* ===== AI 任务页 ===== */
.aitask-page { padding: 12px 16px calc(24px + var(--safe-b)); }
.slot { display: flex; gap: 10px; margin-bottom: 12px; }
.slot-item { flex: 1; border: 1.5px dashed #c7cbe0; border-radius: var(--radius); min-height: 120px; display: flex; flex-direction: column; align-items: center; justify-content: center; color: var(--text-sub); cursor: pointer; background: #fff; overflow: hidden; }
.slot-item img { width: 100%; height: 100%; object-fit: cover; }
.slot-item .sname { font-size: 13px; font-weight: 600; }
.slot-item .sreq { font-size: 10px; margin-top: 2px; }
.slot-item.required::after { content: '必填'; position: absolute; }
textarea.prompt { width: 100%; border: 1px solid #e3e5f0; border-radius: 10px; padding: 10px 12px; font-size: 14px; min-height: 72px; resize: none; outline: none; font-family: inherit; }
textarea.prompt:focus { border-color: var(--primary); }
.chip-row { display: flex; gap: 8px; flex-wrap: wrap; margin: 10px 0; }
.demo-mark { font-size: 11px; color: #a16207; background: rgba(250,173,20,.1); border-radius: 8px; padding: 6px 10px; margin-top: 10px; }

/* ===== 自定义工具（九宫格/裁剪/打码/压缩/拼接） ===== */
.custom-tool { padding: 12px 16px calc(24px + var(--safe-b)); }
.nine-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; background: #fff; border-radius: var(--radius); padding: 8px; margin-top: 12px; }
.nine-cell { position: relative; }
.nine-cell img { width: 100%; display: block; border-radius: 4px; }
.nine-cell .ndl { position: absolute; right: 4px; bottom: 4px; background: rgba(0,0,0,.55); color: #fff; font-size: 10px; padding: 2px 6px; border-radius: 8px; cursor: pointer; }
.mosaic-canvas-wrap { position: relative; margin-top: 12px; border-radius: 8px; overflow: hidden; line-height: 0; }
.mosaic-canvas-wrap canvas { width: 100%; touch-action: none; display: block; }
.crop-stage { position: relative; margin-top: 12px; line-height: 0; touch-action: none; }
.crop-stage img { width: 100%; display: block; border-radius: 8px; }
.crop-mask { position: absolute; border: 1.5px solid var(--primary); box-shadow: 0 0 0 999px rgba(0,0,0,.45); }
.crop-handle { position: absolute; width: 22px; height: 22px; background: var(--primary); border-radius: 50%; border: 2px solid #fff; }

/* ===== wx 组件 shim ===== */
.wx-toast { position: fixed; left: 50%; top: 40%; transform: translate(-50%,-50%); background: rgba(0,0,0,.75); color: #fff; font-size: 14px; padding: 10px 18px; border-radius: 10px; z-index: 9999; opacity: 0; pointer-events: none; transition: opacity .2s; max-width: 80vw; text-align: center; }
.wx-toast.on { opacity: 1; }
.wx-toast .wt-ok { display: block; font-size: 26px; margin-bottom: 4px; font-style: normal; }
.wx-loading { position: fixed; inset: 0; background: rgba(0,0,0,.3); display: none; align-items: center; justify-content: center; z-index: 9998; }
.wx-loading.on { display: flex; }
.wx-load-box { background: rgba(0,0,0,.75); color: #fff; font-size: 13px; padding: 18px 24px; border-radius: 12px; text-align: center; }
.wx-spinner { width: 26px; height: 26px; border: 3px solid rgba(255,255,255,.3); border-top-color: #fff; border-radius: 50%; margin: 0 auto 8px; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg) } }
.wx-modal { position: fixed; inset: 0; background: rgba(0,0,0,.5); display: none; align-items: center; justify-content: center; z-index: 9999; padding: 30px; }
.wx-modal.on { display: flex; }
.wx-mbox { background: #fff; border-radius: 14px; width: 100%; max-width: 320px; overflow: hidden; }
.wx-mtitle { font-size: 16px; font-weight: 700; text-align: center; padding: 18px 16px 6px; }
.wx-mcontent { font-size: 14px; color: #555; text-align: center; padding: 6px 20px 16px; line-height: 1.6; }
.wx-mbtns { display: flex; border-top: .5px solid #eee; }
.wx-mbtn { flex: 1; height: 46px; border: 0; background: #fff; font-size: 15px; cursor: pointer; }
.wx-mbtn.confirm { color: var(--primary); font-weight: 600; border-left: .5px solid #eee; }
.wx-sheet { position: absolute; bottom: 0; left: 0; right: 0; background: #fff; border-radius: 14px 14px 0 0; padding-bottom: var(--safe-b); }
.wx-sitem { display: block; width: 100%; height: 50px; border: 0; border-bottom: .5px solid #f0f1f6; background: #fff; font-size: 15px; cursor: pointer; }
.wx-sitem.cancel { color: var(--text-sub); }
.wx-preview { position: fixed; inset: 0; background: rgba(0,0,0,.92); z-index: 9999; display: none; align-items: center; justify-content: center; flex-direction: column; }
.wx-preview.on { display: flex; }
.wx-preview img { max-width: 100vw; max-height: 88vh; object-fit: contain; }
.wx-pv-tip { color: rgba(255,255,255,.6); font-size: 12px; margin-top: 14px; }

/* 抠图遮罩 */
#mask { position: fixed; inset: 0; background: rgba(20,22,34,.82); display: none; align-items: center; justify-content: center; z-index: 9997; }
#mask.on { display: flex; }
.mask-box { text-align: center; color: #fff; }
.mask-orb { width: 72px; height: 72px; border-radius: 50%; margin: 0 auto 18px; background: conic-gradient(#4F46E5, #a855f7, #4F46E5); animation: spin 1.4s linear infinite; position: relative; }
.mask-orb::after { content: ''; position: absolute; inset: 6px; background: #14161f; border-radius: 50%; }
#mask-text { font-size: 15px; font-weight: 600; }
#mask-sub { font-size: 12px; opacity: .7; margin-top: 6px; }

@media (min-width: 481px) { #app { box-shadow: 0 0 0 1px rgba(0,0,0,.06), 0 12px 40px rgba(30,30,60,.12); } }
