/* ==========================================================================
   全能AI生图 · H5 版  设计基线
   —— 单一真相源：所有页面只引用这里的 token，不许在页面里写死颜色/字号
   —— 适配：360 窄屏 → 4K 全都要好看；手机竖屏 / 手机横屏·平板 / 电脑 三档
   ========================================================================== */

:root {
  /* 底色 */
  --bg:        #09090B;
  --bg-soft:   #111114;
  --card:      #141920;
  --line:      #212831;
  --line-soft: #1b1b20;
  --bg2:       #0F1318;
  --line2:     #2B3440;

  /* 文字 */
  --tx:        #F4F4F5;
  --tx-sub:    #A1A1AA;
  --tx-dim:    #71717A;
  --muted:     #9BA3AF;

  /* 主色 */
  --brand:     #4C7DF0;
  --brand-2:   #6AA0FF;
  --brand-grad: linear-gradient(135deg, #4C7DF0 0%, #6AA0FF 100%);
  --primary:   #4C7DF0;
  --primary2:  #6AA0FF;
  --ok:        #34D399;
  --warn:      #FBBF24;
  --err:       #F87171;

  /* 玻璃 */
  --glass:        rgba(255, 255, 255, 0.10);
  --glass-hover:  rgba(255, 255, 255, 0.16);
  --glass-line:   rgba(255, 255, 255, 0.08);
  --glass-solid:  rgba(20, 25, 32, 0.92);

  /* 尺寸阶梯（流式） */
  --fs-xs:  clamp(11px, 0.72rem + 0.2vw, 13px);
  --fs-sm:  clamp(12px, 0.80rem + 0.2vw, 14px);
  --fs-md:  clamp(13px, 0.88rem + 0.25vw, 15.5px);
  --fs-lg:  clamp(15px, 1.00rem + 0.3vw, 18px);
  --fs-xl:  clamp(18px, 1.20rem + 0.5vw, 24px);

  --r-sm: 8px;  --r-md: 12px;  --r-lg: 16px;  --r-pill: 999px;
  --radius: 14px; --radius-sm: 10px;
  --sp-1: 6px;  --sp-2: 10px;  --sp-3: 16px;  --sp-4: 22px;  --sp-5: 32px;
  --shadow: 0 8px 30px rgba(0, 0, 0, .45);

  /* 安全区 */
  --sa-top:    env(safe-area-inset-top, 0px);
  --sa-bottom: env(safe-area-inset-bottom, 0px);
  --sa-left:   env(safe-area-inset-left, 0px);
  --sa-right:  env(safe-area-inset-right, 0px);

  --header-h: 56px;
  --maxw: 1280px;
  --tabbar-h: 58px;
}

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

html, body {
  margin: 0; padding: 0;
  background: var(--bg); color: var(--tx);
  font-family: "HarmonyOS Sans SC", "Noto Sans SC", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  font-size: var(--fs-md); line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh; min-height: 100dvh;
}
body { padding-bottom: calc(var(--tabbar-h) + var(--sa-bottom) + 8px); }
img { display: block; max-width: 100%; }
button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
button { cursor: pointer; border: none; background: none; }

.wrap { width: 100%; max-width: var(--maxw); margin: 0 auto; padding-left: max(var(--sp-3), var(--sa-left)); padding-right: max(var(--sp-3), var(--sa-right)); }

/* ---------- 顶部固定栏 ---------- */
.topbar {
  position: sticky; top: 0; z-index: 40;
  background: rgba(9, 9, 11, 0.80);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--glass-line);
  padding-top: var(--sa-top);
}
.topbar-inner { display: flex; align-items: center; justify-content: space-between; min-height: var(--header-h); }
.brand { display: flex; align-items: center; gap: 9px; font-size: var(--fs-lg); font-weight: 700; letter-spacing: .3px; white-space: nowrap; }
.logo { width: 20px; height: 20px; border-radius: 6px; background: var(--brand-grad); display: inline-block; box-shadow: 0 0 18px rgba(76,125,240,.55); }
.bal { font-size: var(--fs-sm); color: var(--tx-sub); background: var(--card); border: 1px solid var(--line); padding: 5px 11px; border-radius: var(--r-pill); white-space: nowrap; }

/* ---------- 导航：手机底部常驻 ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
  background: var(--glass-solid);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--glass-line);
  padding-bottom: var(--sa-bottom);
}
.tabbar-inner { display: flex; align-items: stretch; justify-content: space-between; gap: 2px; }
.tab {
  flex: 1 1 0; padding: 11px 2px 12px; text-align: center; color: var(--tx-dim);
  font-size: var(--fs-xs); font-weight: 600; border-radius: var(--r-md);
  transition: color .15s, background .15s; white-space: nowrap;
}
.tab.active { color: var(--brand-2); background: linear-gradient(180deg, rgba(76,125,240,.20), rgba(76,125,240,0)); position: relative; }
.tab.active::after { content: ""; position: absolute; left: 50%; transform: translateX(-50%); bottom: 4px; width: 18px; height: 3px; border-radius: 3px; background: var(--brand-grad); }

/* ---------- 页面 ---------- */
main { padding-top: var(--sp-3); padding-bottom: var(--sp-4); }
.page { display: none; animation: fade .18s ease; }
.page.active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--r-lg); padding: var(--sp-3);
  margin-bottom: var(--sp-3); box-shadow: var(--shadow);
}
.card + .card { margin-top: 0; }
.card-title { font-size: var(--fs-lg); font-weight: 700; margin-bottom: var(--sp-2); }
.row { display: flex; flex-wrap: wrap; gap: var(--sp-2); }
.row.gap { gap: var(--sp-2); }
.row.between { justify-content: space-between; align-items: center; }
.field { margin: var(--sp-2) 0; }
.hint { font-size: var(--fs-xs); color: var(--tx-dim); line-height: 1.6; }
.empty { color: var(--tx-dim); font-size: var(--fs-sm); padding: 26px 10px; text-align: center; width: 100%; }

/* ---------- 输入 ---------- */
.textarea, .input, select {
  width: 100%; background: var(--bg-soft); color: var(--tx);
  border: 1px solid var(--line); border-radius: var(--r-md);
  padding: 12px 14px; font-size: var(--fs-md); outline: none;
  -webkit-appearance: none; transition: border-color .15s, box-shadow .15s;
}
.textarea { min-height: 104px; resize: vertical; line-height: 1.6; }
.textarea:focus, .input:focus, select:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(76,125,240,.16); }
select { background-image: linear-gradient(45deg, transparent 50%, var(--tx-dim) 50%), linear-gradient(135deg, var(--tx-dim) 50%, transparent 50%); background-position: calc(100% - 16px) 50%, calc(100% - 11px) 50%; background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; padding-right: 30px; }
input.num { width: 78px; text-align: center; }

.grid-4 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-2); margin-top: var(--sp-2); }
.sel { display: flex; flex-direction: column; gap: 5px; font-size: var(--fs-xs); color: var(--tx-sub); }
.sel.inline { flex-direction: row; align-items: center; gap: 8px; }

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 0 18px; border-radius: var(--r-md);
  border: 1px solid var(--line2); background: var(--bg-soft); color: var(--tx);
  font-size: var(--fs-md); font-weight: 700;
  transition: transform .06s, filter .15s, opacity .15s; white-space: nowrap; user-select: none;
}
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--brand-grad); border-color: transparent; color: #fff; box-shadow: 0 6px 20px rgba(76,125,240,.35); }
.btn.primary[disabled] { opacity: .55; filter: grayscale(.2); box-shadow: none; }
.btn.ghost { background: transparent; }
.btn.small { min-height: 36px; padding: 0 14px; font-size: var(--fs-sm); font-weight: 600; border-radius: var(--r-sm); }
.btn[disabled] { opacity: .55; cursor: default; }
.add-ref { margin: 4px 0 2px; align-self: flex-start; }

/* ---------- 参考图 ---------- */
.refs { display: flex; flex-wrap: wrap; gap: var(--sp-2); }
.refs:empty { display: none; }
.ref { position: relative; width: 70px; height: 70px; border-radius: var(--r-sm); overflow: hidden; border: 1px solid var(--line); background: var(--bg-soft); }
.ref img { width: 100%; height: 100%; object-fit: cover; }
.ref .x {
  position: absolute; top: 3px; right: 3px; width: 20px; height: 20px; border-radius: 50%;
  background: rgba(9, 9, 11, .82); color: #fff; font-size: 13px; line-height: 20px; text-align: center; font-weight: 700;
}

/* ---------- 缩略图墙 ---------- */
.wall { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: var(--sp-2); }
.wall.small-grid { grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); }
.thumb { position: relative; border-radius: var(--r-sm); overflow: hidden; background: var(--bg-soft); border: 1px solid var(--line); cursor: pointer; }
.thumb img { width: 100%; aspect-ratio: 1/1; object-fit: cover; transition: transform .25s; }
.thumb img.imgbad { opacity: .25; }
.thumb:active img { transform: scale(1.03); }
.thumb .cap { position: absolute; left: 0; right: 0; bottom: 0; padding: 18px 8px 7px; font-size: var(--fs-xs); color: #e7ebf1; background: linear-gradient(transparent, rgba(9, 9, 11, .92)); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.thumb .del { position: absolute; top: 4px; right: 4px; width: 22px; height: 22px; border-radius: 50%; background: rgba(9, 9, 11, .85); color: #fff; font-size: 13px; line-height: 22px; text-align: center; font-weight: 700; z-index: 2; }

/* ---------- 模板 ---------- */
.catbar { display: flex; gap: var(--sp-2); overflow-x: auto; padding: 2px 0 var(--sp-2); -webkit-overflow-scrolling: touch; }
.catbar::-webkit-scrollbar { display: none; }
.cat { flex: 0 0 auto; min-height: 34px; padding: 0 14px; border-radius: var(--r-pill); background: var(--card); border: 1px solid var(--line); color: var(--tx-sub); font-size: var(--fs-sm); font-weight: 600; }
.cat.active { color: #fff; background: var(--brand-grad); border-color: transparent; }
.tplcard { border: 1px solid var(--line); border-radius: var(--r-md); overflow: hidden; background: var(--bg-soft); cursor: pointer; }
.tplcard img { width: 100%; aspect-ratio: 1/1; object-fit: cover; }
.tplcard .t { padding: 8px; font-size: var(--fs-sm); font-weight: 600; }
.tplcard .g { padding: 0 8px 8px; font-size: var(--fs-xs); color: var(--tx-dim); }

/* ---------- 方案列表 ---------- */
.plan-list { display: flex; flex-direction: column; gap: var(--sp-2); margin: var(--sp-2) 0; }
.plan-item { background: var(--bg-soft); border: 1px solid var(--line); border-radius: var(--r-md); padding: var(--sp-2); }
.plan-item .no { font-size: var(--fs-xs); color: var(--brand-2); font-weight: 700; margin-bottom: 5px; }
.plan-item .input { margin-bottom: 6px; font-weight: 600; }
.plan-item .textarea { min-height: 68px; font-size: var(--fs-sm); }

/* ---------- 我的 ---------- */
.balance { background: linear-gradient(135deg, rgba(76,125,240,.16), rgba(106,160,255,.06)); border: 1px solid var(--line2); border-radius: var(--r-lg); padding: var(--sp-3); margin-bottom: var(--sp-2); }
.balance-num { font-size: var(--fs-xl); font-weight: 800; letter-spacing: .5px; }
.kv { display: flex; justify-content: space-between; align-items: center; padding: 9px 0; border-bottom: 1px dashed var(--line); font-size: var(--fs-md); }
.kv:last-child { border-bottom: none; }
.kv span { color: var(--tx-sub); }
.kv b { font-weight: 700; }
.authtab.active { color: #fff; background: var(--brand-grad); border-color: transparent; }

.formula { background: rgba(76,125,240,.10); border: 1px dashed var(--line2); border-radius: var(--r-md); padding: 10px 12px; font-size: var(--fs-sm); color: var(--brand-2); font-weight: 600; margin-bottom: var(--sp-2); text-align: center; }

/* ---------- 大图预览 ---------- */
.lightbox { position: fixed; inset: 0; z-index: 100; background: rgba(4, 5, 7, .94); display: flex; flex-direction: column; }
.lightbox[hidden] { display: none; }
.lb-bar { display: flex; justify-content: flex-end; gap: var(--sp-2); padding: 12px max(var(--sp-3), var(--sa-right)) 12px max(var(--sp-3), var(--sa-left)); padding-top: calc(12px + var(--sa-top)); }
.lb-body { flex: 1; display: flex; align-items: center; justify-content: center; padding: 0 12px 24px; overflow: auto; }
.lb-body img { max-width: 100%; max-height: 100%; border-radius: var(--r-sm); box-shadow: var(--shadow); }

/* ---------- 提示条 ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + var(--sa-bottom) + 18px);
  transform: translate(-50%, 18px);
  background: rgba(20, 25, 32, .97); color: var(--tx); border: 1px solid var(--line2);
  border-radius: var(--r-pill); padding: 10px 18px; font-size: var(--fs-sm);
  max-width: 88vw; text-align: center; opacity: 0; pointer-events: none;
  transition: opacity .2s, transform .2s; z-index: 200; box-shadow: var(--shadow);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.err { border-color: #7f2a2a; background: rgba(48, 20, 20, .97); }

/* ==========================================================================
   断点：手机竖屏（默认）→ 平板（≥700）→ 电脑（≥901：顶部横排导航）
   ========================================================================== */
@media (min-width: 700px) {
  .wall { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: var(--sp-3); }
}

@media (min-width: 901px) {
  body { padding-bottom: var(--sp-4); }
  .tabbar { position: sticky; top: 0; bottom: auto; border-top: none; border-bottom: 1px solid var(--glass-line); }
  .tabbar-inner { justify-content: center; gap: 6px; }
  .tab { flex: 0 0 auto; padding: 13px 26px; font-size: var(--fs-md); border-radius: 0; }
  .tab.active { background: none; }
  .tab.active::after { bottom: 0; width: 26px; }
  .grid-4 { grid-template-columns: repeat(4, 1fr); }
  .wall { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: var(--sp-3); }
  .card { padding: var(--sp-4); }
  .toast { bottom: 36px; }
}

@media (min-width: 1600px) { :root { --maxw: 1440px; } }

/* 横屏手机高度很矮 */
@media (max-height: 480px) and (orientation: landscape) {
  .textarea { min-height: 72px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* ==========================================================================
   追加：预估价 / 懒加载骨架 / 参考图卡 / 作品分组 / 大图导航（12 条反馈配套）
   ========================================================================== */

/* 生图预估消耗（生成按钮上方） */
.gen-cost { margin: var(--sp-2) 0 0; font-size: var(--fs-sm); color: var(--tx-sub); font-weight: 600; }
.gen-cost b { color: var(--brand-2); font-weight: 800; font-size: var(--fs-md); }
.pending { color: var(--brand-2); font-weight: 700; }
.pending.on { color: var(--warn); }

/* 骨架屏：先占位，图到位再淡入 */
.sk {
  border-radius: var(--r-sm); border: 1px solid var(--line); aspect-ratio: 1 / 1;
  background: linear-gradient(100deg, #171b21 30%, #232a34 50%, #171b21 70%);
  background-size: 200% 100%; animation: shimmer 1.2s linear infinite;
}
.sk-tpl { aspect-ratio: 1 / 1.22; }
.sk-ref { aspect-ratio: 1 / 1; }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
img.lz { background: linear-gradient(100deg, #171b21 30%, #232a34 50%, #171b21 70%); background-size: 200% 100%; }
.thumb img.lz, .tplcard img.lz { min-height: 80px; }
img.lz:not([data-lazy]) { background: var(--bg-soft); }

/* 参考图卡：缩略图 + 删除 + 「这是什么」 */
.refs.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: var(--sp-2); }
.refcard { position: relative; border: 1px solid var(--line); border-radius: var(--r-sm); overflow: hidden; background: var(--bg-soft); }
.refcard img { width: 100%; aspect-ratio: 1 / 1; object-fit: cover; }
.refcard .x {
  position: absolute; top: 4px; right: 4px; width: 22px; height: 22px; border-radius: 50%;
  background: rgba(9, 9, 11, .85); color: #fff; font-size: 13px; line-height: 22px; text-align: center; font-weight: 700; z-index: 3;
}
.refcard input.refdesc {
  width: 100%; border: none; border-top: 1px solid var(--line); border-radius: 0;
  background: rgba(9, 9, 11, .35); padding: 7px 8px; font-size: var(--fs-xs);
}
.refcard input.refdesc:focus { border-top-color: var(--brand); box-shadow: none; }

/* 作品分组卡（一个 PPT / 一套图 = 一个卡组） */
.groupcard { grid-column: 1 / -1; border: 1px solid var(--line2); border-radius: var(--r-md); background: var(--bg-soft); padding: var(--sp-2); }
.ghead { display: flex; gap: var(--sp-2); align-items: center; }
.gcover { width: 76px; flex: 0 0 auto; }
.gmeta { flex: 1 1 auto; min-width: 0; }
.gtitle { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gsub { font-size: var(--fs-xs); color: var(--tx-dim); }
.gbody { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: var(--sp-2); margin-top: var(--sp-2); }
.gbody.hide { display: none; }

/* 提示横幅（成套扣费对账） */
.banner { margin-top: var(--sp-2); padding: 10px 12px; border-radius: var(--r-md); font-size: var(--fs-sm); font-weight: 600; }
.banner.warn { background: rgba(251, 191, 36, .12); border: 1px solid rgba(251, 191, 36, .40); color: var(--warn); }
.banner.ok { background: rgba(52, 211, 153, .10); border: 1px solid rgba(52, 211, 153, .35); color: var(--ok); }

/* 懒加载哨兵 */
.sentinel { text-align: center; padding: var(--sp-3) 0; }

/* 大图导航 + 下载进度 */
.lb-bar { justify-content: space-between; align-items: center; flex-wrap: wrap; }
.lb-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.lb-info .hint { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lb-actions { display: flex; gap: var(--sp-2); }
#lbProgress { color: var(--brand-2); font-weight: 600; }
#lbProgress.err { color: var(--err); }
.lb-body { position: relative; }
.lb-nav {
  position: absolute; top: 50%; transform: translateY(-50%); z-index: 3;
  width: 46px; height: 46px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  background: rgba(20, 25, 32, .88); border: 1px solid var(--line2); color: #fff; font-size: 26px; line-height: 1;
}
.lb-nav[hidden] { display: none; }
.lb-nav.prev { left: 6px; }
.lb-nav.next { right: 6px; }
.lb-tip { text-align: center; padding: 0 12px calc(10px + var(--sa-bottom)); }

@media (min-width: 901px) {
  .lb-nav.prev { left: 18px; }
  .lb-nav.next { right: 18px; }
}

/* ==========================================================================
   追加：首屏加载遮罩 / ✦ 智能推荐按钮 / 耗时动作进度条
   ========================================================================== */

/* 首屏加载遮罩：进页面立刻可见，数据就绪或最多 6 秒后淡出 */
.boot {
  position: fixed; inset: 0; z-index: 300;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg);
  transition: opacity .4s ease;
}
.boot[hidden] { display: none; }
.boot.out { opacity: 0; pointer-events: none; }
.boot-inner { display: flex; flex-direction: column; align-items: center; gap: 14px; padding: 0 24px; text-align: center; }
.boot-logo { width: 46px; height: 46px; border-radius: 14px; background: var(--brand-grad); box-shadow: 0 0 34px rgba(76, 125, 240, .55); }
.boot-name { font-size: var(--fs-lg); font-weight: 700; letter-spacing: .5px; }
.boot-spin {
  width: 30px; height: 30px; border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, .14); border-top-color: var(--brand-2);
  animation: bootspin .9s linear infinite;
}
.boot-tip { font-size: var(--fs-sm); color: var(--tx-dim); }
@keyframes bootspin { to { transform: rotate(360deg); } }

/* 提示词标题行 + ✦ 智能推荐按钮 */
.prompt-head { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2); margin-bottom: 6px; }
.prompt-label { font-size: var(--fs-xs); color: var(--tx-sub); font-weight: 600; }
.btn.suggest { color: var(--brand-2); border-color: var(--line2); }
.btn.suggest[disabled] { color: var(--tx-dim); }

/* 耗时动作进度条：生图 / 成套 / PPT 共用 */
.prog { margin-top: var(--sp-2); }
.prog[hidden] { display: none; }
.prog-bar { height: 6px; border-radius: var(--r-pill); background: var(--bg-soft); border: 1px solid var(--line); overflow: hidden; }
.prog-bar i { display: block; height: 100%; width: 0; background: var(--brand-grad); border-radius: var(--r-pill); transition: width .35s ease; }
.prog.indet .prog-bar i { width: 34% !important; animation: progmarch 1.15s ease-in-out infinite; }
@keyframes progmarch { 0% { margin-left: 0; } 50% { margin-left: 66%; } 100% { margin-left: 0; } }
.prog-tx { margin-top: 6px; font-size: var(--fs-xs); color: var(--brand-2); font-weight: 600; }
.prog.err .prog-bar i { background: var(--err); }
.prog.err .prog-tx { color: var(--err); }

