/* ========================================
   头像生成器 - 样式表
   风格：年轻、极简、白黑主调、液态玻璃
   ======================================== */

:root {
  /* 颜色 */
  --color-bg: #EDEDED;            /* 朋友圈背景灰 */
  --color-surface: #FFFFFF;
  --color-surface-2: #F7F7F7;
  --color-text: #111111;
  --color-text-secondary: #8A8A8A;
  --color-text-tertiary: #BDBDBD;
  --color-border: #ECECEC;
  --color-divider: #F0F0F0;
  --color-primary: #111111;
  --color-primary-on: #FFFFFF;
  --color-accent: #1A1A1A;

  /* 玻璃质感 */
  --glass-bg: rgba(255, 255, 255, 0.72);
  --glass-border: rgba(255, 255, 255, 0.6);
  --glass-shadow: 0 8px 32px rgba(0, 0, 0, 0.08);
  --glass-blur: 20px;

  /* 圆角 */
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 18px;
  --r-xl: 24px;
  --r-full: 999px;

  /* 间距 */
  --gap-1: 4px;
  --gap-2: 8px;
  --gap-3: 12px;
  --gap-4: 16px;
  --gap-5: 20px;
  --gap-6: 24px;

  /* 字号 */
  --fs-xs: 11px;
  --fs-sm: 12px;
  --fs-md: 14px;
  --fs-lg: 16px;
  --fs-xl: 18px;
  --fs-2xl: 22px;
  --fs-3xl: 28px;

  /* 阴影 */
  --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-2: 0 4px 16px rgba(0, 0, 0, 0.06);
  --shadow-3: 0 8px 24px rgba(0, 0, 0, 0.08);
}

/* ===== 重置 ===== */
*, *::before, *::after {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;          /* 禁止 body 滚动，整体页面保持不动 */
  background: var(--color-bg);
  color: var(--color-text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-size: var(--fs-md);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overscroll-behavior-y: contain;
  text-rendering: optimizeLegibility;
}

img {
  max-width: 100%;
  display: block;
}

img.crop-image {
  max-width: none; /* 裁剪图片必须按 natural size 渲染，才能让 transform scale 正确生效 */
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  outline: none;
}

/* ===== App 容器 ===== */
.app {
  position: relative;
  width: 100%;
  max-width: 480px;
  height: 100%;              /* 撑满 body，不再用 min-height 增长 */
  overflow: hidden;          /* 防止 .app 内容溢出到 body */
  margin: 0 auto;
  background: var(--color-bg);
  padding-top: env(safe-area-inset-top);
}

/* ===== 页面切换 ===== */
.page {
  display: none;
  animation: fadeIn 0.3s ease;
}
.page.active {
  display: block;
  height: 100%;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: calc(160px + env(safe-area-inset-bottom));
}

/* 创建页：flex 列布局，风格区域独立滚动 */
.page-create.active {
  display: flex;
  flex-direction: column;
  height: 100%;              /* 相对于 .app 内容区域 */
  overflow: hidden;
  /* 底部导航栏 fixed，操作栏也 fixed，无需在此预留；滚动留白交给 styles-wrap */
  padding-bottom: env(safe-area-inset-bottom);
}

/* 仅做透明度渐显，不使用 transform —— 否则带 transform 的祖先会成为
   .action-bar(position:fixed) 的包含块，切换页面时操作栏会从中间跳到底部 */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* ===== 顶部：模拟朋友圈 ===== */
.moments {
  position: relative;
  width: 100%;
  /* 背景显示区改成正方形（桌面端） */
  aspect-ratio: 1 / 1;
  overflow: visible;
  background: #e0e0e0;
  margin-bottom: 22px;   /* 给错落溢出的头像预留空间，避免压到下方分类 */
  flex-shrink: 0;
}

/* 手机端：4:3 比例（宽度铺满、高度随比例生成，下方腾出空间给 icon 列表） */
@media (max-width: 500px) and (max-height: 900px) {
  .moments {
    aspect-ratio: 4 / 3;
    max-height: min(52vh, 380px);
    margin-bottom: 10px;
  }
  /* 分类标签区也稍微紧凑 */
  .categories {
    padding: 10px 16px 4px;
  }
}

.moments-bg-wrap {
  position: absolute;
  inset: 0;
  z-index: 0;
  border-radius: 0;
  box-shadow: none;
}

.moments-bg {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: opacity 0.5s ease;
}

/* 去掉顶部白色过渡蒙版（朋友圈无此效果） */
.moments-bg-mask {
  display: none;
}

/* 顶部标题栏 */
.moments-header {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 3;
  padding: 12px 16px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  pointer-events: none;
}
.moments-header > * {
  pointer-events: auto;
}

.moments-title {
  font-size: var(--fs-lg);
  font-weight: 600;
  color: #fff;
  letter-spacing: 0.2px;
  text-shadow: 0 1px 4px rgba(0,0,0,.25);
}

/* 底部用户区：头像在右下角错落压在背景底部边缘上，
   用户名在头像左侧、白色文字 */
.moments-user {
  position: absolute;
  right: 14px;
  bottom: -22px;          /* 头像明显错落，压在背景底部边缘下方 */
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 10px;
}

.moments-avatar-btn {
  position: relative;
  display: block;
  margin: 0;
  padding: 0;
  border: none;
  background: none;
  line-height: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  flex-shrink: 0;
}

.moments-avatar-wrap {
  width: 70px;
  height: 70px;
  border-radius: 10px;     /* 圆润小圆角，非完全圆形 */
  overflow: hidden;
  background: #ddd;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18);
  /* 去掉白色边框 */
  border: none;
}

.moments-avatar {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* 用户名：头像左侧，白色带阴影 */
.moments-meta {
  padding-bottom: 2px;
  text-align: right;
  transform: translateY(-6px);  /* 文字相对头像居中偏上 */
}

.moments-name {
  font-size: 15px;
  font-weight: 600;
  color: #fff;
  margin-bottom: 0;
  text-shadow: 0 1px 4px rgba(0,0,0,.35);
  letter-spacing: 0.3px;
}

/* 隐藏"刚刚"时间 */
.moments-time {
  display: none;
}

/* 可点击更换：背景整层 */
.moments-bg-btn {
  position: absolute;
  inset: 0;
  z-index: 1;
  margin: 0;
  padding: 0;
  border: none;
  background: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.moments-bg-btn .moments-bg-wrap {
  position: absolute;
  inset: 0;
}

/* 编辑角标：去掉圆形框，更低调 */
.moments-edit-badge {
  position: absolute;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 6px;
  background: none;
  color: #fff;
  border: none;
  box-shadow: none;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.45));
  z-index: 4;
  opacity: .7;
  transition: opacity .2s;
}
.moments-edit-badge:hover,
.moments-edit-badge:active {
  opacity: 1;
}
.moments-edit-bg {
  left: 12px;
  bottom: 12px;
}
.moments-edit-avatar {
  right: -2px;
  bottom: -2px;
}

/* ===== 分类标签 ===== */
.categories {
  display: flex;
  gap: 6px;
  padding: 14px 16px 6px;
  overflow-x: auto;
  scrollbar-width: none;
  flex-shrink: 0;
}
.categories::-webkit-scrollbar {
  display: none;
}

.category {
  flex-shrink: 0;
  padding: 8px 14px;
  border-radius: var(--r-full);
  font-size: var(--fs-md);
  color: var(--color-text-secondary);
  background: transparent;
  transition: all 0.2s ease;
  position: relative;
}

.category.active {
  color: var(--color-text);
  font-weight: 600;
}

.category.active::before {
  content: "";
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 20px;
  height: 3px;
  background: var(--color-text);
  border-radius: 0 0 2px 2px;
}

/* ===== 风格网格 ===== */
.styles-wrap {
  padding: 8px 16px 200px;
  position: relative;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;
  scrollbar-width: thin;
  scrollbar-color: transparent transparent;
  transition: scrollbar-color 0.35s ease;
}

.styles-wrap:hover,
.styles-wrap:active {
  scrollbar-color: rgba(0,0,0,0.12) transparent;
}
/* ── 极简滚动条（WebKit） ── */
.styles-wrap::-webkit-scrollbar {
  width: 4px;
}
.styles-wrap::-webkit-scrollbar-track {
  background: transparent;
}
.styles-wrap::-webkit-scrollbar-thumb {
  background: transparent;
  border-radius: 2px;
  transition: background 0.35s ease;
}
.styles-wrap:hover::-webkit-scrollbar-thumb,
.styles-wrap:active::-webkit-scrollbar-thumb {
  background: rgba(0,0,0,0.12);
}
.styles-wrap::-webkit-scrollbar-thumb:hover {
  background: rgba(0,0,0,0.22);
}

/* 风格网格：响应式列数，icon 保持自然大小，超出 styles-wrap 时自动滚动 */
/* #styles-grid 为外层容器，.cat-grid 为各分类常驻网格（只显隐不重建） */
.styles-grid { }

.cat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(52px, 1fr));
  justify-content: center;
  gap: 8px;
}

.style-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  cursor: pointer;
  transition: transform 0.2s ease;
}

.style-item:active {
  transform: scale(0.96);
}

.style-thumb {
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: var(--r-md);
  background: var(--color-surface-2);
  overflow: hidden;
  position: relative;
  border: 2px solid transparent;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.style-item.selected .style-thumb {
  border-color: var(--color-text);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
}

.style-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
  -webkit-user-drag: none;
  user-drag: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

/* 免费风格角标：icon 右下角「免」，代表免费、不占生成次数 */
.free-badge {
  position: absolute;
  right: 3px;
  bottom: 3px;
  min-width: 15px;
  height: 15px;
  padding: 0 4px;
  border-radius: var(--r-full);
  background: rgba(0, 0, 0, 0.62);
  color: #fff;
  font-size: 10px;
  font-weight: 600;
  line-height: 15px;
  text-align: center;
  letter-spacing: 0;
  pointer-events: none;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

/* 多朵小花付费风格（如秘密花园消耗2朵）金色「精」角标，与免费「免」角标同款样式 */
.cost-badge {
  position: absolute;
  right: 3px;
  bottom: 3px;
  min-width: 15px;
  height: 15px;
  padding: 0 4px;
  border-radius: var(--r-full);
  background: linear-gradient(135deg, #f6d365 0%, #d4af37 100%);
  color: #5a3d00;
  font-size: 10px;
  font-weight: 700;
  line-height: 15px;
  text-align: center;
  letter-spacing: 0;
  pointer-events: none;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
}

.style-label {
  font-size: var(--fs-sm);
  color: var(--color-text);
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.style-item.selected .style-label {
  color: var(--color-text);
  font-weight: 600;
}

/* ===== 操作栏：固定在底部导航上方，图标列表从其后滚动而下 ===== */
.action-bar {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  bottom: calc(72px + env(safe-area-inset-bottom));
  padding: 4px 16px 16px;
  z-index: 9;
  /* 仅底部约 28% 实色（盖住提示文字），上方透明 → 露出弧形遮罩的曲线感 */
  background: linear-gradient(to bottom, transparent 0%, var(--color-bg) 72%);
}

/* ── action-bar 顶部弧形遮挡（固定不动，不随图标列表滚动） ── */
.action-bar::before {
  content: "";
  position: absolute;
  left: -8px;
  right: -8px;
  bottom: 0;
  height: 56px;
  pointer-events: none;
  background: radial-gradient(ellipse 115% 100% at 50% 100%, var(--color-bg) 58%, transparent 61%);
  z-index: 2;
}

/* 上传图片框：倾斜卡片，超出 action-row */
.upload-preview-box {
  position: relative;
  width: 64px;
  height: 84px;
  border-radius: 12px;
  background: #ffffff;
  border: 1.5px solid rgba(0, 0, 0, 0.08);
  transform: rotate(-5deg);
  margin-top: -30px;
  margin-left: 2px;
  margin-right: 2px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  cursor: pointer;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.25s ease;
  flex-shrink: 0;
}

.upload-preview-box:hover {
  transform: rotate(-5deg) scale(1.08);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.14);
}

.upload-preview-box:active {
  transform: rotate(-5deg) scale(0.95);
}

.upload-preview-box.has-image {
  background: #ffffff;
  border-color: rgba(0, 0, 0, 0.06);
}

.upload-preview-box.has-image .upload-plus,
.upload-preview-box.has-image .upload-hint {
  display: none;
}

.upload-plus {
  font-size: 26px;
  font-weight: 300;
  color: rgba(0, 0, 0, 0.45);
  line-height: 1;
}

.upload-hint {
  font-size: 11px;
  color: var(--color-text-secondary);
  font-weight: 500;
  letter-spacing: 0.3px;
}

.upload-preview-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: fill;
  border-radius: 12px;
}

.action-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: var(--color-surface);
  padding: 6px;
  border-radius: var(--r-full);
  box-shadow: var(--shadow-2);
  border: 1px solid var(--color-border);
  width: min(264px, 90vw);
  margin: 0 auto;
}

.action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 44px;
  border-radius: var(--r-full);
  padding: 0 16px;
  font-size: var(--fs-md);
  font-weight: 500;
  color: var(--color-text);
  white-space: nowrap;
  flex: 0 0 auto;
  transition: background 0.2s ease, transform 0.1s ease;
}

.action-btn:active {
  transform: scale(0.97);
}

.action-btn-ghost {
  background: transparent;
  color: var(--color-text);
}

.action-btn-ghost:hover {
  background: var(--color-surface-2);
}

.action-icon {
  display: inline-flex;
  align-items: center;
}

.action-btn-primary {
  flex: 0 0 auto;
  background: var(--color-text);
  color: var(--color-primary-on);
  flex-direction: column;
  height: 44px;
  padding: 0 18px;
  gap: 0;
  font-size: var(--fs-md);
  max-width: 100px;
}

.action-text {
  font-weight: 600;
  font-size: 14px;
  line-height: 1.2;
}

.action-quota {
  font-size: 9px;
  opacity: 0.7;
  line-height: 1.2;
  font-weight: 400;
}

/* 生成按钮左侧：红色花朵 + 小花数量（无边框，纯图标+数字） */
.quota-badge {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 0;
  flex: 0 0 auto;
}
.quota-flower {
  display: block;
  flex-shrink: 0;
}
.quota-num {
  font-size: var(--fs-sm);
  font-weight: 700;
  color: var(--color-text);
  line-height: 1;
  font-variant-numeric: tabular-nums;
  min-width: 10px;
  text-align: center;
}

/* 付费风格选中时，生成按钮内的消耗提示用热粉色突出 */
.action-quota.quota-cost {
  color: #d4af37;
  opacity: 1;
  font-weight: 600;
}

.action-hints {
  position: relative;
  z-index: 3;
  text-align: center;
  font-size: var(--fs-xs);
  color: var(--color-text-secondary);
  font-weight: 500;
  margin-top: 10px;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.hint-sep {
  opacity: 0.55;
}

/* ===== 底部导航：液态玻璃 ===== */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  display: flex;
  align-items: center;
  justify-content: space-around;
  padding: 8px 12px calc(8px + env(safe-area-inset-bottom));
  background: var(--glass-bg);
  backdrop-filter: blur(var(--glass-blur)) saturate(180%);
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(180%);
  border-top: 1px solid var(--glass-border);
  box-shadow: var(--glass-shadow);
  z-index: 10;
}

.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  height: 56px;
  border-radius: var(--r-md);
  color: var(--color-text-tertiary);
  transition: color 0.2s ease, background 0.2s ease, transform 0.15s ease;
  position: relative;
}

.nav-item:active {
  transform: scale(0.95);
}

.nav-item.active {
  color: var(--color-text);
}

.nav-item.active::before {
  content: "";
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 24px;
  height: 3px;
  background: var(--color-text);
  border-radius: 0 0 4px 4px;
}

.nav-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.nav-label {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.3px;
}

/* 导航角标（生成队列数量提醒） */
.nav-badge {
  position: absolute;
  top: -6px;
  right: -4px;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  border-radius: 9px;
  background: #000;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  line-height: 18px;
  text-align: center;
  z-index: 5;
  pointer-events: none;
}
.nav-badge.hidden { display: none; }

/* ===== 页面通用 header ===== */
.page-header {
  padding: 24px 20px 12px;
}

.page-title {
  font-size: var(--fs-2xl);
  font-weight: 600;
  margin: 0 0 4px;
  letter-spacing: -0.3px;
}

.page-subtitle {
  font-size: var(--fs-sm);
  color: var(--color-text-secondary);
  margin: 0;
}

/* 已生成页头：标题 + 选择按钮 */
.archive-page-header {
  display: flex;
  align-items: center;
}

/* ===== 存档页 ===== */
/* 已生成页：本地存储提示条 */
.archive-storage-hint {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 16px 12px;
  padding: 10px 16px;
  background: var(--color-surface-2);
  border-radius: 999px;
  font-size: var(--fs-xs);
  color: var(--color-text-secondary);
  line-height: 1.5;
}
.archive-storage-hint svg {
  flex-shrink: 0;
  opacity: 0.7;
}
.archive-storage-hint[hidden] {
  display: none;
}

.archive-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 80px 24px;
  color: var(--color-text-tertiary);
}

.archive-empty.hidden {
  display: none;
}

.empty-illustration {
  margin-bottom: 16px;
  color: var(--color-text-tertiary);
  opacity: 0.6;
}

.empty-text {
  font-size: var(--fs-lg);
  color: var(--color-text-secondary);
  margin: 0 0 4px;
}

.empty-hint {
  font-size: var(--fs-sm);
  margin: 0;
}

.archive-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  padding: 0 4px 16px;
}

.archive-item {
  position: relative;
  aspect-ratio: 1 / 1;
  background: var(--color-surface-2);
  border-radius: var(--r-sm);
  overflow: hidden;
  cursor: pointer;
  touch-action: manipulation;  /* 消除移动端点击延迟/误判，点击更稳定 */
  transition: transform 0.2s ease;
}

.archive-item:active {
  transform: scale(0.97);
}

.archive-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;  /* 防止图片自身吞掉点击 */
}

.archive-item-label {
  position: absolute;
  bottom: 6px;
  left: 6px;
  font-size: 10px;
  color: #fff;
  background: rgba(0, 0, 0, 0.4);
  padding: 2px 6px;
  border-radius: var(--r-full);
  backdrop-filter: blur(8px);
  z-index: 2;
}

/* ===== 任务卡片（生成中 / 排队 / 失败）===== */
.archive-task {
  background: var(--color-surface-2);
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
  -webkit-user-select: none;
}
.archive-task .archive-item-label,
.archive-task .archive-fav-btn { display: none; }

.task-card-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 8px;
  text-align: center;
  width: 100%;
}

/* 排队态 */
.archive-task-queued {
  background: #1a1a1a;
}
.archive-task-queued .task-spinner {
  display: none;
}
.archive-task-queued .task-status-text,
.archive-task-queued .task-sub-text {
  color: rgba(255, 255, 255, 0.85);
}

.task-status-text {
  font-size: 11px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.9);
  margin: 0;
  line-height: 1.2;
}
.task-sub-text {
  font-size: 10px;
  color: rgba(255, 255, 255, 0.5);
  margin: 0;
}
.task-style-label {
  position: absolute;
  bottom: 6px;
  left: 6px;
  font-size: 10px;
  color: #fff;
  background: rgba(0, 0, 0, 0.4);
  padding: 2px 6px;
  border-radius: var(--r-full);
  backdrop-filter: blur(8px);
  z-index: 2;
}

/* 生成中 */
.archive-task-generating {
  background: #1a1a1a;
}
.archive-task-generating .task-status-text,
.archive-task-generating .task-sub-text {
  color: rgba(255, 255, 255, 0.85);
}
.task-progress-ring {
  width: 36px;
  height: 36px;
  margin-bottom: 2px;
}
.task-progress-ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.task-progress-bar {
  width: 80%;
  height: 3px;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 2px;
  overflow: hidden;
  margin: 2px 0;
}
.task-progress-fill {
  height: 100%;
  background: #fff;
  border-radius: 2px;
  transition: width 0.3s ease;
}

/* 失败态 */
.archive-task-failed {
  background: linear-gradient(135deg, #1a1a1a 0%, #161616 100%);
}
.task-icon-fail {
  width: 28px;
  height: 28px;
  line-height: 28px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  color: #aaa;
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 2px;
}
.task-error-text {
  font-size: 9px;
  color: rgba(200, 160, 160, 0.85);
  margin: 0;
  line-height: 1.3;
  max-width: 90%;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
/* 失败卡片「重试」按钮（v334） */
.task-retry-btn {
  margin: 6px 0 2px;
  padding: 5px 18px;
  border: none;
  border-radius: 14px;
  background: #fff;
  color: #111;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.task-retry-btn:active { background: #e0e0e0; }

/* 收藏 / 筛选标签 */
.archive-filter {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 2px 16px 14px;
}

.filter-tab {
  flex: 0 0 auto;
  padding: 7px 16px;
  border: none;
  border-radius: var(--r-full);
  background: var(--color-surface-2);
  color: var(--color-text-secondary);
  font-size: var(--fs-sm);
  font-weight: 500;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.2s ease, color 0.2s ease;
}

.filter-tab.active {
  background: var(--color-text);
  color: #fff;
}

/* 作品收藏按钮（常驻右上角） */
.archive-fav-btn {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 30px;
  height: 30px;
  border: none;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.45);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(8px);
  z-index: 2;
  transition: transform 0.15s ease;
}

.archive-fav-btn:active {
  transform: scale(0.9);
}

.archive-fav-btn.faved {
  background: #ffffff;
  color: #111111;
}

/* 预览大图弹窗操作区（保存 / 删除） */
.archive-preview-actions {
  display: flex;
  gap: 10px;
  padding: 14px 16px 18px;
}
.archive-del-btn {
  flex: 1 1 0;
  height: 44px;
  border: 1px solid var(--color-border, rgba(0,0,0,0.12));
  border-radius: var(--r-full);
  background: var(--color-surface);
  color: #e5484d;
  font-size: var(--fs-md);
  font-weight: 600;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.2s ease;
}
.archive-del-btn:active {
  background: var(--color-surface-2);
}

/* ===== 我的页 ===== */
.profile-card {
  margin: 0 16px 16px;
  padding: 18px;
  background: var(--color-surface);
  border-radius: var(--r-lg);
  display: flex;
  align-items: flex-start;
  gap: 14px;
  box-shadow: var(--shadow-1);
  overflow: visible;
}

.profile-avatar {
  width: 60px;
  height: 60px;
  border-radius: var(--r-full);
  overflow: hidden;
  background: var(--color-surface-2);
  flex-shrink: 0;
}

.profile-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.profile-info {
  flex: 1;
}

.profile-name {
  font-size: var(--fs-lg);
  font-weight: 600;
  margin-bottom: 2px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.nickname-input {
  width: 100%;
  margin: 12px 0 4px;
  padding: 12px 14px;
  border: 1px solid var(--color-divider);
  border-radius: var(--r-md);
  font-size: var(--fs-md);
  background: var(--color-surface-2);
  color: var(--color-text);
  outline: none;
  -webkit-appearance: none;
}

.nickname-input:focus {
  border-color: var(--color-text);
}

/* 注册表单字段 */
.form-field {
  margin: 12px 0 4px;
  text-align: left;
}
.form-label {
  display: block;
  font-size: var(--fs-sm);
  color: var(--color-text-secondary);
  margin-bottom: 6px;
}
.form-input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--color-divider);
  border-radius: var(--r-md);
  font-size: var(--fs-md);
  background: var(--color-surface-2);
  color: var(--color-text);
  outline: none;
  -webkit-appearance: none;
  box-sizing: border-box;
}
.form-input:focus {
  border-color: var(--color-text);
}
.form-error {
  color: #e5484d;
  font-size: var(--fs-sm);
  min-height: 18px;
  margin: 8px 0 0;
  text-align: left;
}

.form-hint {
  margin-top: 10px;
  text-align: center;
  color: var(--color-text-secondary);
  font-size: var(--fs-sm);
  line-height: 1.6;
}

/* ── 密码字段：实时提示 + 对号 ── */
.pw-field {
  position: relative;
  display: flex;
  align-items: center;
}
.pw-field .form-input {
  padding-right: 38px;
}
.pw-check {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #2bbf6a;
  color: #fff;
  font-size: 12px;
  line-height: 18px;
  text-align: center;
  display: none;
}
.pw-check.show {
  display: block;
}
.pw-hint {
  font-size: var(--fs-xs);
  color: var(--color-text-secondary);
  margin: 6px 2px 0;
  text-align: left;
  transition: color 0.2s ease;
}
.pw-hint.valid {
  color: #2bbf6a;
}
.form-input.invalid {
  border-color: #e5484d;
}

/* ── 验证码行 ── */
.code-row {
  display: flex;
  gap: 8px;
  align-items: stretch;
}
.code-input {
  flex: 1;
  letter-spacing: 4px;
  font-weight: 600;
}
.code-btn {
  flex-shrink: 0;
  padding: 0 14px;
  border: 1px solid var(--color-text);
  border-radius: var(--r-md);
  background: transparent;
  color: var(--color-text);
  font-size: var(--fs-sm);
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
  transition: opacity 0.2s ease;
}
.code-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* ── 弹窗切换链接 ── */
.modal-switch {
  text-align: center;
  font-size: var(--fs-sm);
  color: var(--color-text-secondary);
  margin: 14px 0 2px;
}
.modal-switch a {
  color: var(--color-text);
  font-weight: 600;
  text-decoration: none;
  margin-left: 2px;
}
.modal-switch a:active {
  opacity: 0.6;
}

.profile-id {
  font-size: var(--fs-sm);
  color: var(--color-text-secondary);
}

.profile-status {
  display: inline-block;
  font-size: var(--fs-xs);
  padding: 2px 8px;
  border-radius: 10px;
  margin-top: 4px;
  font-weight: 500;
}

.profile-status-guest {
  background: #f0f0f0;
  color: #888;
}

.profile-status-registered {
  background: #e8f5e9;
  color: #43a047;
}

.profile-card {
  margin: 0 16px 16px;
  padding: 18px;
  background: var(--color-surface);
  border-radius: var(--r-lg);
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 14px;
  box-shadow: var(--shadow-1);
}

.profile-cta {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  margin-left: auto;
  position: relative;
}

/* 限时活动气泡提示（浮在注册按钮正上方，带上下浮动动画） */
.register-bubble {
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  margin-bottom: 10px;
  padding: 6px 12px;
  background: #c01302;
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  text-align: center;
  border-radius: 14px;
  box-shadow: 0 4px 12px rgba(192, 19, 2, .28);
  animation: bubble-float 1.8s ease-in-out infinite;
  white-space: nowrap;
  z-index: 10;
}

.register-bubble::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 100%;
  transform: translateX(-50%);
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-bottom: 7px solid #c01302;
}

@keyframes bubble-float {
  0%, 100% { margin-bottom: 10px; }
  50% { margin-bottom: 16px; }
}

.profile-register-btn {
  flex-shrink: 0;
  width: 64px;
  padding: 7px 0;
  border: none;
  border-radius: var(--r-full);
  background: var(--color-text);
  color: #fff;
  font-size: var(--fs-xs);
  font-weight: 600;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  white-space: nowrap;
}

/* 注册按钮包裹层（仅用于气泡定位参考） */
.register-btn-wrap {
  position: relative;
  display: inline-flex;
}

.profile-login-btn {
  flex-shrink: 0;
  width: 64px;
  padding: 7px 0;
  border: 1px solid var(--color-divider);
  border-radius: var(--r-full);
  background: transparent;
  color: var(--color-text-secondary);
  font-size: var(--fs-xs);
  font-weight: 500;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.profile-logout-btn {
  flex-shrink: 0;
  width: 64px;
  padding: 7px 0;
  border: 1px solid var(--color-divider);
  border-radius: var(--r-full);
  background: transparent;
  color: var(--color-text-secondary);
  font-size: var(--fs-xs);
  font-weight: 500;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.profile-btn-row {
  display: flex;
  gap: 8px;
  white-space: nowrap;
  margin-top: 8px;
}

.stat-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  padding: 0 16px 16px;
}

.stat-card {
  background: var(--color-surface);
  padding: 14px 8px;
  border-radius: var(--r-md);
  text-align: center;
  box-shadow: var(--shadow-1);
}

.stat-num {
  font-size: var(--fs-2xl);
  font-weight: 700;
  color: var(--color-text);
  margin-bottom: 2px;
  font-variant-numeric: tabular-nums;
}

.stat-label {
  font-size: var(--fs-xs);
  color: var(--color-text-secondary);
}

.menu-list {
  background: var(--color-surface);
  margin: 0 16px 16px;
  border-radius: var(--r-lg);
  overflow: hidden;
  box-shadow: var(--shadow-1);
}

.menu-item {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--color-divider);
  transition: background 0.2s ease;
}

.menu-item:last-child {
  border-bottom: none;
}

.menu-item:active {
  background: var(--color-surface-2);
}

/* 清除缓存右侧的缓存数量提示 */
.menu-cache-count {
  font-size: var(--fs-xs);
  color: var(--color-text-secondary);
  font-variant-numeric: tabular-nums;
}

.menu-left {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: var(--fs-md);
}

.menu-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--color-text-secondary);
}

.menu-arrow {
  color: var(--color-text-tertiary);
  font-size: 20px;
  line-height: 1;
}

.privacy-note {
  margin: 0 16px;
  padding: 14px 16px;
  background: var(--color-surface-2);
  border-radius: var(--r-md);
  border-left: 3px solid var(--color-text);
}

.privacy-title {
  margin: 0 0 6px;
  font-size: var(--fs-sm);
  font-weight: 600;
}

.privacy-text {
  margin: 0;
  font-size: var(--fs-xs);
  color: var(--color-text-secondary);
  line-height: 1.5;
}

/* ===== 模态框 ===== */
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.25s ease;
}

.modal.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  z-index: 1;              /* [v353] 确保在 modal-content(z:2) 之下 */
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.modal-content {
  position: relative;
  z-index: 2;              /* [v353] 确保内容在 backdrop 之上 */
  background: var(--color-surface);
  border-radius: var(--r-xl);
  padding: 28px 24px 20px;
  width: 88%;
  max-width: 360px;
  text-align: center;
  transform: scale(0.95);
  transition: transform 0.25s ease;
  box-shadow: var(--shadow-3);
}

.modal.active .modal-content {
  transform: scale(1);
}

.modal-title {
  margin: 0 0 12px;
  font-size: var(--fs-xl);
  font-weight: 600;
}

.modal-text {
  margin: 0 0 20px;
  font-size: var(--fs-md);
  color: var(--color-text-secondary);
  line-height: 1.6;
}

.modal-text-block {
  text-align: left;
  margin: 0 0 20px;
  font-size: var(--fs-sm);
  color: var(--color-text-secondary);
  line-height: 1.6;
}

.modal-text-block p {
  margin: 0 0 12px;
}

.modal-text-block p:last-child {
  margin-bottom: 0;
}

.modal-text-block strong {
  color: var(--color-text);
  font-weight: 600;
}

.guide-body p {
  margin-bottom: 8px;
}
.guide-body p > b {
  display: block;
  margin-top: 12px;
  margin-bottom: 2px;
}

/* 图片选择器：底部弹层 */
#media-picker-modal {
  align-items: flex-end;
}
.modal-picker {
  position: relative;
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  background: var(--color-surface);
  border-radius: 22px 22px 0 0;
  padding: 14px 16px calc(18px + env(safe-area-inset-bottom));
  text-align: left;
  transform: translateY(100%);
  max-height: 76vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 -8px 30px rgba(0, 0, 0, 0.18);
}
.modal.active .modal-picker {
  transform: translateY(0);
}
.picker-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 4px 12px;
}
.picker-header .modal-title {
  margin: 0;
  font-size: var(--fs-lg);
}
.picker-close {
  border: none;
  background: none;
  color: var(--color-text-secondary);
  /* [v360] 全部改用 CSS 背景图绘制 ×，彻底消除 SVG 内嵌在 flex 按钮中的尺寸/热区错位 */
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  position: relative;
  z-index: 10;
  /* [v361] 删除 pointer-events:auto —— .modal 未激活时容器是 none，
     子按钮显式 auto 会变成"隐形点击黑洞"，盖在其他弹窗按钮上抢点击
     （真凶：收款项弹窗的 .qr-close-btn 隐形盖住裁剪页 ×，导致"点右边才能关"）。
     激活时 .modal.active 已统一恢复 pointer-events:auto，无需子元素自己开。 */
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  padding: 0;
  margin: 0;
  /* 兜底：防止 flex 自动按内容 intrinsic 宽度撑大按钮 */
  min-width: 0;
  /* 统一背景图（18×18 居中），适合所有 .picker-close 按钮 */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238A8A8A' stroke-width='2.2' stroke-linecap='round'%3E%3Cline x1='6' y1='6' x2='18' y2='18'/%3E%3Cline x1='18' y1='6' x2='6' y2='18'/%3E%3C/svg%3E");
  background-position: center;
  background-repeat: no-repeat;
  background-size: 18px 18px;
  /* 隐藏按钮内文字（旧媒体/存档页仍用 × 文字，但被背景图覆盖） */
  font-size: 0;
  line-height: 0;
}
.picker-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 2px 2px 4px;
  flex: 1;
  min-height: 0;
  /* ── 极简滚动条（与风格列表一致） ── */
  scrollbar-width: thin;
  scrollbar-color: transparent transparent;
  transition: scrollbar-color 0.35s ease;
}
.picker-grid:hover,
.picker-grid:active {
  scrollbar-color: rgba(0,0,0,0.12) transparent;
}
.picker-grid::-webkit-scrollbar {
  width: 4px;
}
.picker-grid::-webkit-scrollbar-track {
  background: transparent;
}
.picker-grid::-webkit-scrollbar-thumb {
  background: transparent;
  border-radius: 2px;
  transition: background 0.35s ease;
}
.picker-grid:hover::-webkit-scrollbar-thumb,
.picker-grid:active::-webkit-scrollbar-thumb {
  background: rgba(0,0,0,0.12);
}
.picker-grid::-webkit-scrollbar-thumb:hover {
  background: rgba(0,0,0,0.22);
}
.picker-item {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 14px;
  overflow: hidden;
  border: 2px solid transparent;
  cursor: pointer;
  background: var(--color-surface-2);
  box-sizing: border-box;
}
.picker-item img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  margin: 0;
  padding: 0;
}
.picker-item:active {
  border-color: var(--color-text);
}
.picker-item-label {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  font-size: 11px;
  color: #fff;
  padding: 10px 6px 4px;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.55));
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.modal-actions {
  display: flex;
  gap: 8px;
  margin-top: 16px;
}

.btn {
  flex: 1;
  height: 44px;
  border-radius: var(--r-full);
  font-size: var(--fs-md);
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.2s ease, transform 0.1s ease;
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background: var(--color-text);
  color: var(--color-primary-on);
}

.btn-full {
  width: 100%;
  display: block;
}

.btn-secondary {
  background: var(--color-surface-2);
  color: var(--color-text);
}

.btn-ghost {
  background: transparent;
  color: var(--color-text);
  border: 1px solid var(--color-border, rgba(0,0,0,0.12));
}

/* 加载模态框 */
.modal-loading {
  background: transparent;
  box-shadow: none;
  color: #fff;
}

.loading-spinner {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-bottom: 14px;
}

.loading-spinner span {
  width: 8px;
  height: 8px;
  background: #fff;
  border-radius: 50%;
  display: inline-block;
  animation: bounce 1.2s infinite ease-in-out;
}

.loading-spinner span:nth-child(2) {
  animation-delay: 0.15s;
}
.loading-spinner span:nth-child(3) {
  animation-delay: 0.3s;
}
.loading-spinner span:nth-child(4) {
  animation-delay: 0.45s;
}

@keyframes bounce {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.5; }
  40% { transform: scale(1); opacity: 1; }
}

.loading-text {
  font-size: var(--fs-md);
  margin: 0 0 4px;
  font-weight: 500;
  color: #fff;
}

.loading-sub {
  font-size: var(--fs-xs);
  margin: 0;
  color: rgba(255, 255, 255, 0.7);
}

.loading-progress-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 220px;
  max-width: 72vw;
  margin: 14px auto 6px;
}

.loading-progress-bar {
  flex: 1;
  height: 6px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.22);
  overflow: hidden;
}

.loading-progress-bar span {
  display: block;
  height: 100%;
  width: 0%;
  border-radius: 3px;
  background: #fff;
  transition: width 0.2s ease;
}

.loading-progress {
  font-size: var(--fs-sm);
  font-variant-numeric: tabular-nums;
  color: #fff;
  min-width: 40px;
  text-align: right;
  font-weight: 600;
  margin: 0;
}

/* 配额模态框 */
.modal-quota {
  padding: 32px 24px 24px;
}

.quota-icon {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--color-surface-2);
  color: var(--color-text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 14px;
}

/* 购买模态框 */
.modal-buy {
  max-width: 380px;
}

.plan-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 12px 0 0;
}

.plan-card {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-radius: var(--r-md);
  background: var(--color-surface-2);
  border: 1.5px solid transparent;
  transition: all 0.2s ease;
  text-align: left;
}

.plan-card.selected {
  border-color: var(--color-text);
  background: var(--color-surface);
}

.plan-card.recommended::after {
  content: "推荐";
  position: absolute;
  top: -8px;
  right: 12px;
  background: var(--color-text);
  color: var(--color-primary-on);
  font-size: 10px;
  padding: 2px 8px;
  border-radius: var(--r-full);
  font-weight: 500;
}

.plan-amount {
  font-size: var(--fs-md);
  font-weight: 600;
  color: var(--color-text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
}
.plan-amount .pa-num {
  font-variant-numeric: tabular-nums;
}
.plan-flower {
  flex-shrink: 0;
  display: block;
}

.plan-price {
  font-size: var(--fs-lg);
  font-weight: 700;
  color: var(--color-text);
  font-variant-numeric: tabular-nums;
}

/* ===== 数量选择器 ===== */
.quantity-selector {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin: 14px 0 4px;
  padding: 10px 0;
  border-top: 1px dashed var(--color-border);
}

.quantity-label {
  font-size: var(--fs-sm);
  color: var(--color-text-secondary);
  font-weight: 500;
}

.qty-btn {
  width: 34px;
  height: 34px;
  border-radius: var(--r-full);
  border: 1.5px solid var(--color-border);
  background: var(--color-surface-2);
  color: var(--color-text);
  font-size: 18px;
  font-weight: 600;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.qty-btn:active {
  background: var(--color-border);
  transform: scale(0.92);
}

.qty-num {
  min-width: 36px;
  text-align: center;
  font-size: var(--fs-lg);
  font-weight: 700;
  color: var(--color-text);
  font-variant-numeric: tabular-nums;
}

/* 数量按钮达到上下限时置灰（不可点击） */
.qty-btn.disabled {
  opacity: 0.35;
  pointer-events: none;
  background: var(--color-surface-2);
  color: var(--color-text-secondary);
}

/* 单次支付上限提示 */
.qty-limit-hint {
  display: none;
  text-align: center;
  font-size: 11px;
  line-height: 1.4;
  color: var(--color-text-secondary);
  margin: -4px 0 8px;
  padding: 0 12px;
}

/* ===== 小红花图标（价格/付费标记）===== */
.flower-icon {
  --flower-size: 28px;
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--flower-size);
  height: var(--flower-size);
  flex-shrink: 0;
}

.flower-petal {
  position: absolute;
  width: 14px;
  height: 14px;
  border-radius: 50% 50% 50% 0;
  background: #e53935;
  transform-origin: center bottom;
}
.flower-petal:nth-child(1) { transform: rotate(0deg) translateY(-4px); }
.flower-petal:nth-child(2) { transform: rotate(72deg) translateY(-4px); }
.flower-petal:nth-child(3) { transform: rotate(144deg) translateY(-4px); }
.flower-petal:nth-child(4) { transform: rotate(216deg) translateY(-4px); }
.flower-petal:nth-child(5) { transform: rotate(288deg) translateY(-4px); }

.flower-center {
  position: relative;
  z-index: 1;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #222;
  display: flex;
  align-items: center;
  justify-content: center;
}

.flower-num {
  font-size: 9px;
  font-weight: 800;
  color: #fff;
  line-height: 1;
}

/* ===== Toast ===== */
.toast {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translateX(-50%) translateY(calc(-50% + 20px));
  background: rgba(0, 0, 0, 0.85);
  color: #fff;
  padding: 10px 20px;
  border-radius: var(--r-full);
  font-size: var(--fs-sm);
  font-weight: 500;
  z-index: 200;
  opacity: 0;
  pointer-events: none;
  transition: all 0.3s ease;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  white-space: nowrap;
  max-width: 80%;
  text-align: center;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(-50%);
}

/* ===== 工具类 ===== */
.hidden {
  display: none !important;
}

/* ===== 响应式微调 ===== */
@media (min-width: 481px) {
  .app {
    box-shadow: 0 0 32px rgba(0, 0, 0, 0.05);
  }
}

@media (max-width: 360px) {
  :root {
    --fs-2xl: 20px;
  }
  .styles-grid {
    grid-template-columns: repeat(auto-fill, minmax(48px, 1fr));
    gap: 6px;
  }
  .action-row {
    gap: 8px;
    padding: 5px;
  }
}

/* ===== 横屏微调 ===== */
@media (orientation: landscape) and (max-height: 500px) {
  .moments {
    height: 200px;
  }
}

/* ===== 开发者测试面板（隐藏，仅测试用） ===== */
.dev-panel {
  position: fixed;
  right: 12px;
  bottom: 12px;
  width: min(360px, calc(100vw - 24px));
  max-height: 78vh;
  overflow-y: auto;
  background: rgba(20, 20, 24, 0.94);
  color: #f2f2f2;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 16px;
  padding: 14px 14px 16px;
  z-index: 9999;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
  font-size: 13px;
}
.dev-panel[hidden] { display: none; }
.dev-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 6px;
}
.dev-close {
  background: none;
  border: none;
  color: #f2f2f2;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  padding: 0 4px;
}
.dev-tip {
  color: #ffb4b4;
  font-size: 11px;
  margin: 0 0 10px;
  line-height: 1.5;
}
.dev-style-info {
  background: rgba(120, 170, 255, 0.16);
  border: 1px solid rgba(120, 170, 255, 0.3);
  color: #d6e6ff;
  border-radius: 10px;
  padding: 7px 10px;
  font-size: 12px;
  margin-bottom: 10px;
  line-height: 1.4;
}
.dev-check {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 10px;
  cursor: pointer;
}
.dev-label {
  display: block;
  margin: 8px 0 4px;
  font-size: 12px;
  color: #bdbdbd;
}
.dev-textarea {
  width: 100%;
  min-height: 64px;
  resize: vertical;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.06);
  color: #f2f2f2;
  padding: 8px 10px;
  font-size: 12px;
  line-height: 1.5;
  font-family: inherit;
  box-sizing: border-box;
}
.dev-textarea::placeholder { color: #7a7a7a; }
.dev-textarea-readonly {
  background: rgba(120, 170, 255, 0.08);
  border-color: rgba(120, 170, 255, 0.22);
  color: #d6e6ff;
}
.dev-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.dev-select {
  width: 100%;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.06);
  color: #f2f2f2;
  padding: 8px 10px;
  font-size: 12px;
  box-sizing: border-box;
}
.dev-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}
.dev-btn {
  flex: 1 1 auto;
  border: none;
  border-radius: 10px;
  padding: 9px 10px;
  font-size: 12px;
  cursor: pointer;
  min-width: 0;
}
.dev-btn-ghost {
  background: rgba(255, 255, 255, 0.12);
  color: #f2f2f2;
}
.dev-btn-ghost:active { background: rgba(255, 255, 255, 0.2); }
.dev-btn-primary {
  background: #4f8cff;
  color: #fff;
  font-weight: 600;
}
.dev-btn-primary:active { background: #3f78e6; }
.dev-status {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  font-size: 11px;
  line-height: 1.6;
  color: #cfcfcf;
  word-break: break-word;
}
.dev-status-row { margin-bottom: 8px; }

/* ===== 已生成作品：大图预览 + 保存 ===== */
.modal-archive-preview {
  width: 100%;
  max-width: 460px;
  margin: auto;
  background: var(--color-surface);
  border-radius: 22px;
  padding: 16px 16px calc(18px + env(safe-area-inset-bottom));
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25);
}
.modal-archive-preview .picker-header {
  padding: 2px 2px 12px;
}
.archive-preview-img {
  width: 100%;
  max-height: 58vh;
  aspect-ratio: 1 / 1;  /* 加载前即正方形占位，消除「横版长方形→正方形」跳变 */
  object-fit: contain;
  border-radius: 14px;
  background: var(--color-surface-2);
  display: block;
  -webkit-touch-callout: default; /* 允许 iOS 长按弹出「存储到相册」菜单 */
}
.archive-save-btn {
  flex: 1 1 0;
  height: 44px;
  border: none;
  border-radius: var(--r-full);
  font-size: var(--fs-md);
  font-weight: 600;
  color: #fff;
  background: #222;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: opacity 0.2s ease;
}
.archive-save-btn:active { opacity: 0.85; }
.archive-save-tip {
  margin: 10px 4px 2px;
  text-align: center;
  font-size: 13px;
  color: var(--color-text-2, #888);
  line-height: 1.5;
}

/* ===== 正方形裁剪界面 ===== */
.modal-crop {
  width: 92vw;
  max-width: 380px;
  max-height: 85vh;
  border-radius: 20px;
  padding: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: #fff;
}
.crop-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: relative;
  z-index: 5;
  padding: 16px 16px 8px;
}
.crop-header .modal-title {
  /* [v359] 裁剪页标题清零底部 margin（默认继承 .modal-title 的 0 0 12px），
     否则 flex align-items:center 按 margin-box 对齐时，标题文字中心比按钮中心高约 6px → × 看起来偏下 */
  margin: 0;
  font-size: 17px;
  font-weight: 700;
  color: #111;
}

/* ---- 裁剪模式标签 ---- */
.crop-modes {
  display: flex;
  gap: 6px;
  padding: 0 16px 12px;
  justify-content: center;
}

.crop-mode-btn {
  padding: 5px 16px;
  border-radius: 20px;
  border: 1.5px solid #d0d0d0;
  background: #fff;
  font-size: 13px;
  font-weight: 500;
  color: #888;
  cursor: pointer;
  transition: all 0.2s ease;
}

.crop-mode-btn.active {
  background: #111;
  color: #fff;
  border-color: #111;
}

.crop-container {
  flex: 1;
  min-height: 280px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px 16px;
  background: #000;
  position: relative;
  overflow: hidden;
  touch-action: none;       /* 阻止浏览器默认手势（双击缩放、滑动等） */
  -webkit-touch-callout: none;
  user-select: none;
  -webkit-user-select: none;
}
.crop-viewport {
  position: relative;
  overflow: hidden;
  border-radius: 4px;
  cursor: grab;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  min-width: 60px;
  min-height: 60px;
}
.crop-viewport:active { cursor: grabbing; }
.crop-image {
  position: absolute;
  top: 0;
  left: 0;
  transform-origin: 0 0;
  will-change: transform;
  pointer-events: none;
  /* 初始不可见，等 JS 设置 */
  visibility: hidden;
}
.crop-overlay {
  position: absolute;
  inset: 0;
  box-shadow: 0 0 0 9999px rgba(0,0,0,0.55);
  border-radius: 4px;
  pointer-events: none;
  z-index: 2;
}
.crop-grid {
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
}
.crop-grid-line {
  position: absolute;
  background: rgba(255,255,255,0.35);
}
.crop-grid-h1, .crop-grid-h2 {
  left: 0;
  right: 0;
  height: 1px;
  top: 33.33%;
}
.crop-grid-h2 { top: 66.66%; }
.crop-grid-v1, .crop-grid-v2 {
  top: 0;
  bottom: 0;
  width: 1px;
  left: 33.33%;
}
.crop-grid-v2 { left: 66.66%; }

.crop-controls {
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: auto;        /* 滑杆区域允许正常触摸 */
}
/* 裁剪舞台：图片 + 遮罩 + 网格 + 裁剪框 的统一容器；预览时整体缩放 */
.crop-stage {
  position: absolute;
  inset: 0;
  transform-origin: 0 0;
  transition: transform 0.32s cubic-bezier(0.22, 0.61, 0.36, 1);
  will-change: transform;
}
/* 预览态：隐藏遮罩 / 网格 / 裁剪框边框，只显示放大后的图像本身（无多余边框、无画中画） */
.crop-viewport.previewing .crop-overlay,
.crop-viewport.previewing .crop-grid { opacity: 0; }
.crop-viewport.previewing .crop-free-box { border-color: transparent; }
/* 编辑态：保持放大不变，但显示所有 UI 元素让用户可继续调整 */
.crop-viewport.editing .crop-overlay,
.crop-viewport.editing .crop-grid { opacity: 1; }
.crop-viewport.editing .crop-free-box { border-color: rgba(255,255,255,0.95); }
.crop-zoom-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}
.crop-zoom-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1.5px solid #ddd;
  background: #fff;
  font-size: 20px;
  font-weight: 600;
  color: #333;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  line-height: 1;
}
.crop-zoom-btn:active { background: #f5f5f5; }
.crop-zoom-slider {
  width: 160px;
  height: 4px;
  -webkit-appearance: none;
  appearance: none;
  background: #e0e0e0;
  border-radius: 2px;
  outline: none;
}
.crop-zoom-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #111;
  cursor: pointer;
  border: 2px solid #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,0.2);
}
.crop-zoom-slider::-moz-range-thumb {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #111;
  cursor: pointer;
  border: 2px solid #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,0.2);
}
.crop-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 8px 16px 18px;
}
.crop-actions-row {
  display: flex;
  gap: 10px;
}
.crop-actions .btn {
  flex: 1;
  padding: 12px;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 600;
  text-align: center;
  cursor: pointer;
  border: none;
}
.crop-actions .btn-keep {
  width: 100%;
  padding: 12px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 600;
  text-align: center;
  cursor: pointer;
  border: 1px dashed #bbb;
  background: #fafafa;
  color: #555;
}
.crop-actions .btn-keep:active {
  background: #f0f0f0;
}
.crop-actions .btn-secondary {
  background: #f0f0f0;
  color: #333;
}
.crop-actions .btn-primary {
  background: #111;
  color: #fff;
}

/* ---- 自由裁剪框（iPhone极简风格） ---- */
.crop-free-box {
  display: none; /* 默认隐藏，自由模式显示 */
  position: absolute;
  top: 0; left: 0;
  /* 细白边框 + 框外半透明暗色遮罩（box-shadow trick） */
  border: 1.5px solid rgba(255,255,255,0.95);
  box-shadow: 0 0 0 9999px rgba(0,0,0,0.55);
  z-index: 5;
  touch-action: none;
  cursor: move;
  box-sizing: border-box;
}
.crop-free-box.active { display: block; }

/* 手柄：中心对齐在裁剪框的角点/边中点 → 与裁剪框重叠，8 向可调 */
.crop-handle {
  position: absolute;
  width: 24px;
  height: 24px;
  z-index: 12;
  touch-action: none;
}
/* 角落手柄：L 形细线，锚定在手柄中心（= 裁剪框角），向框内延伸 → 与框重叠 */
.handle-nw, .handle-ne, .handle-sw, .handle-se { cursor: nwse-resize; }
.handle-nw { top: -12px; left: -12px; }
.handle-ne { top: -12px; right: -12px; left: auto; }
.handle-sw { bottom: -12px; top: auto; left: -12px; }
.handle-se { bottom: -12px; top: auto; right: -12px; left: auto; }

.handle-nw::before, .handle-nw::after,
.handle-ne::before, .handle-ne::after,
.handle-sw::before, .handle-sw::after,
.handle-se::before, .handle-se::after {
  content: '';
  position: absolute;
  background: #fff;
  box-shadow: 0 1px 2px rgba(0,0,0,0.5);
}
/* 横线（2px 高，14px 长），纵向居中于角点；竖线（2px 宽，14px 长），横向居中于角点 */
.handle-nw::before, .handle-ne::before, .handle-sw::before, .handle-se::before { height: 2px; width: 14px; top: 11px; }
.handle-nw::after,  .handle-ne::after,  .handle-sw::after,  .handle-se::after  { width: 2px;  height: 14px; left: 11px; }
/* 方向：nw→右下，ne→左下，sw→右上，se→左上 */
.handle-nw::before { left: 12px; } .handle-nw::after { top: 12px; }
.handle-ne::before { left: -2px; } .handle-ne::after { top: 12px; }
.handle-sw::before { left: 12px; } .handle-sw::after { top: -2px; }
.handle-se::before { left: -2px; } .handle-se::after { top: -2px; }

/* 边缘手柄：短横/竖线，中心对齐在框边中点 → 与框重叠 */
.handle-n, .handle-s { cursor: ns-resize; }
.handle-w, .handle-e { cursor: ew-resize; }
.handle-n::before, .handle-s::before,
.handle-w::before, .handle-e::before {
  content: ''; position: absolute; background: #fff;
  box-shadow: 0 1px 2px rgba(0,0,0,0.5);
}
/* 上/下边：短横线（14px 长，2px 高），中心在框边中点 */
.handle-n::before, .handle-s::before { width: 14px; height: 2px; top: 11px; left: 5px; }
/* 左/右边：短竖线（2px 宽，14px 长） */
.handle-w::before, .handle-e::before { width: 2px; height: 14px; left: 11px; top: 5px; }
.handle-n { top: -12px; left: 50%; margin-left: -12px; }
.handle-s { bottom: -12px; top: auto; left: 50%; margin-left: -12px; }
.handle-w { left: -12px; top: 50%; margin-top: -12px; }
.handle-e { right: -12px; left: auto; top: 50%; margin-top: -12px; }

/* ===== 扫码支付弹窗 ===== */
/* ===== 支付宝风格扫码支付弹窗 v216 ===== */
.modal-qr-pay {
  max-width: 380px;
  background: #fff;
  border-radius: 16px;
  padding: 0;
  position: relative;
  box-shadow: 0 20px 60px rgba(0,0,0,.18);
}
.qr-close-btn {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 100;
  width: 32px; height: 32px;
  border: none;
  background: rgba(0,0,0,.06);
  color: #666;
  font-size: 20px;
  line-height: 32px;
  text-align: center;
  border-radius: 50%;
  cursor: pointer;
  transition: all .2s;
  /* [v361] 删除 pointer-events:auto —— 弹窗关闭时它变成隐形点击黑洞，
     恰好盖住裁剪页关闭按钮左半边，导致"必须点 × 右边才能关" */
}
.qr-close-btn:hover {
  background: rgba(0,0,0,.12);
  color: #333;
}

/* 头部：金额区域 */
.qrpay-header {
  text-align: center;
  padding: 28px 24px 12px;
}
.qrpay-label {
  font-size: 14px;
  color: #888;
  margin-bottom: 6px;
}
.qrpay-amount {
  font-size: 42px;
  font-weight: 700;
  color: #1a1a1a;
  letter-spacing: -1px;
  line-height: 1.1;
}
.rmb-symbol {
  font-size: 42px;
  font-weight: 700;
  color: #1a1a1a;
}
/* 二维码主体 */
.qrpay-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px 24px 20px;
}
.qr-code-box {
  position: relative;
  width: 200px; height: 200px;
  border-radius: 4px;
  padding: 8px;
  background: #fff;
  border: 1px solid #e8e8e8;
  display: flex;
  align-items: center;
  justify-content: center;
}
#qr-canvas {
  display: block;
  width: 184px !important;
  height: 184px !important;
  border-radius: 2px;
}
.qr-logo-overlay {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 44px; height: 44px;
  background: #fff;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(0,0,0,.1);
}
.qr-hint-row {
  margin-top: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: #999;
  line-height: 1.5;
  text-align: left;
}
.alipay-logo-icon {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  object-fit: contain;
}

/* 底部状态栏 */
.qrpay-footer {
  text-align: center;
  padding: 10px 24px 22px;
  border-top: 1px solid #f5f5f5;
  background: #fafafa;
}
.modal-qr-pay .qr-status {
  font-size: 13px;
  min-height: 20px;
  transition: color .3s;
}
.modal-qr-pay .qr-status.success {
  color: #00b578;
  font-weight: 600;
}

/* ===== 给我反馈弹窗 ===== */
.fb-field { margin-bottom: 16px; }
.fb-label { display: block; font-size: 13px; color: #666; margin-bottom: 8px; }

.fb-cats { display: flex; gap: 10px; }
.fb-cat {
  flex: 1; padding: 10px 0; border: 1px solid #e0e0e0; border-radius: 10px;
  background: #fff; font-size: 14px; color: #444; cursor: pointer; transition: .15s;
}
.fb-cat.active { border-color: #222; color: #222; background: #f5f5f5; font-weight: 600; }

.fb-stars { display: flex; gap: 6px; font-size: 30px; line-height: 1; }
.fb-star { color: #d8d8d8; cursor: pointer; transition: color .12s; user-select: none; }
.fb-star.on { color: #222; }

.fb-textarea {
  width: 100%; border: 1px solid #e0e0e0; border-radius: 10px; padding: 10px 12px;
  font-size: 14px; font-family: inherit; resize: vertical; box-sizing: border-box; color: #222;
}
.fb-textarea:focus { outline: none; border-color: #222; }

.fb-img-row { display: flex; align-items: center; gap: 12px; }
.fb-img-btn {
  display: inline-block; padding: 8px 14px; border: 1px dashed #ccc; border-radius: 10px;
  font-size: 13px; color: #666; background: #fafafa; cursor: pointer;
}
.fb-img-btn.disabled { opacity: .4; pointer-events: none; }
.fb-img-count { font-size: 12px; color: #999; }
.fb-img-list { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 12px; }
.fb-img-item { position: relative; width: 64px; height: 64px; border-radius: 10px; overflow: visible; border: 1px solid #eee; flex: 0 0 auto; }
.fb-img-item img { width: 100%; height: 100%; object-fit: cover; display: block; border-radius: 9px; }
.fb-img-item button {
  position: absolute; top: -8px; right: -8px; width: 20px; height: 20px; border-radius: 50%;
  border: none; background: #555; color: #fff; font-size: 14px; line-height: 20px; cursor: pointer; padding: 0;
  z-index: 2; box-shadow: 0 1px 3px rgba(0,0,0,.3);
}

/* 关于 - 可点击复制的邮箱 */
.about-contact { margin-top: 12px; color: #444; font-size: 14px; }
.copy-email {
  color: #222; font-weight: 600; cursor: pointer; border-bottom: 1px dashed #999;
  padding: 0 2px; user-select: all; transition: color .12s, border-color .12s;
}
.copy-email:active { color: #000; border-color: #222; }

