/* ========================================
   头像生成器 - 样式表
   风格：年轻、极简、白黑主调、液态玻璃
   ======================================== */

: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 约 72px + safe-area，flex 容器需预留 */
  padding-bottom: calc(72px + 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;
}

.moments-bg-wrap {
  position: absolute;
  inset: 0;
  z-index: 0;
  border-radius: 0;
}

.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 70px;
  position: relative;
  flex: 1;
  min-height: 0;        /* 允许 flex 子项收缩到小于内容高度 */
  overflow-y: auto;     /* 风格多时在此区域独立滚动 */
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch; /* iOS 惯性滚动 */
  scroll-behavior: smooth;

  /* ── 极简滚动条（Firefox） ── */
  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 {
  display: grid;
  grid-template-columns: repeat(6, 64px);
  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;
}

/* 免费风格角标：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);
}

.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;
}

/* ===== 操作栏：flex 子元素，不再 fixed ===== */
.action-bar {
  flex-shrink: 0;
  padding: 4px 16px 16px;
  z-index: 9;
}

/* 上传图片框：倾斜卡片，超出 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: 16px;
  background: var(--color-surface);
  padding: 6px;
  border-radius: var(--r-full);
  box-shadow: var(--shadow-2);
  border: 1px solid var(--color-border);
  width: 50%;
  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;
  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;
}

.action-hints {
  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;
}

.nav-label {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.3px;
}

/* ===== 页面通用 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-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;
  transition: transform 0.2s ease;
}

.archive-item:active {
  transform: scale(0.97);
}

.archive-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.archive-item-actions {
  position: absolute;
  bottom: 6px;
  right: 6px;
  display: flex;
  gap: 4px;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.archive-item:hover .archive-item-actions,
.archive-item:active .archive-item-actions {
  opacity: 1;
}

.archive-action-btn {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(8px);
}

.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-filter {
  display: flex;
  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-tools {
  display: flex;
  gap: 8px;
  padding: 0 16px 14px;
}
.archive-tool-btn {
  flex: 1 1 0;
  padding: 9px 0;
  border: 1px solid var(--color-border, rgba(0,0,0,0.12));
  border-radius: var(--r-full);
  background: var(--color-surface);
  color: var(--color-text-secondary);
  font-size: var(--fs-sm);
  font-weight: 600;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}
.archive-tool-btn:active {
  background: var(--color-surface-2);
}
.archive-tool-btn:hover {
  border-color: var(--color-primary, #7c5cff);
  color: var(--color-primary, #7c5cff);
}

/* 作品收藏按钮（常驻右上角） */
.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;
}

/* ===== 我的页 ===== */
.profile-card {
  margin: 0 16px 16px;
  padding: 18px;
  background: var(--color-surface);
  border-radius: var(--r-lg);
  display: flex;
  align-items: center;
  gap: 14px;
  box-shadow: var(--shadow-1);
}

.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);
}

.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-register-btn {
  flex-shrink: 0;
  padding: 8px 14px;
  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;
}

.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-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;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.modal-content {
  position: relative;
  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;
}

/* 图片选择器：底部弹层 */
#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;
  font-size: 26px;
  line-height: 1;
  color: var(--color-text-secondary);
  padding: 0 4px;
}
.picker-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 2px 2px 4px;
}
.picker-item {
  position: relative;
  aspect-ratio: 1 / 1;
  border-radius: 14px;
  overflow: hidden;
  border: 2px solid transparent;
  cursor: pointer;
  background: var(--color-surface-2);
}
.picker-item:active {
  border-color: var(--color-text);
}
.picker-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.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-secondary {
  background: var(--color-surface-2);
  color: var(--color-text);
}

/* 加载模态框 */
.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);
}

.plan-price {
  font-size: var(--fs-lg);
  font-weight: 700;
  color: var(--color-text);
  font-variant-numeric: tabular-nums;
}

.buy-hint {
  margin: 12px 0 0;
  font-size: var(--fs-xs);
  color: var(--color-text-tertiary);
  text-align: center;
}

/* ===== Toast ===== */
.toast {
  position: fixed;
  bottom: 120px;
  left: 50%;
  transform: translateX(-50%) translateY(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(0);
}

/* ===== 工具类 ===== */
.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(4, 64px);
  }
}

/* ===== 横屏微调 ===== */
@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;
  object-fit: contain;
  border-radius: 14px;
  background: var(--color-surface-2);
  display: block;
}
.archive-save-btn {
  width: 100%;
  margin-top: 14px;
  border: none;
  border-radius: 14px;
  padding: 13px;
  font-size: var(--fs-base, 15px);
  font-weight: 600;
  color: #fff;
  background: var(--color-primary, #111);
  cursor: pointer;
}
.archive-save-btn:active { opacity: 0.85; }

/* ===== 正方形裁剪界面 ===== */
.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;
  padding: 16px 16px 8px;
}
.crop-header .modal-title {
  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;
}
.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.5);
  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;
}
.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;
}
