/* ============================================================
   AI 图像工坊 — Apple Style
   SF Pro · 毛玻璃 · 细腻层级
   ============================================================ */

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  /* 背景层级 */
  --bg: #F5F5F7;
  --bg-elevated: #FFFFFF;
  --bg-secondary: #E8E8ED;

  /* 文字 */
  --text: #1D1D1F;
  --text-secondary: #6E6E73;
  --text-tertiary: #86868B;

  /* 分隔线 */
  --separator: rgba(0, 0, 0, 0.08);
  --separator-strong: rgba(0, 0, 0, 0.12);

  /* 主色 — Apple Blue */
  --accent: #0071E3;
  --accent-hover: #0077ED;
  --accent-pressed: #006EDB;
  --accent-tint: rgba(0, 113, 227, 0.1);

  /* 语义色 */
  --success: #34C759;
  --error: #FF3B30;
  --warning: #FF9500;

  /* 阴影 — Apple 细腻多层 */
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.08), 0 2px 6px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 20px 50px rgba(0, 0, 0, 0.12), 0 4px 12px rgba(0, 0, 0, 0.06);
  --shadow-accent: 0 4px 14px rgba(0, 113, 227, 0.3);

  /* 圆角 — Apple 体系 */
  --radius-xs: 6px;
  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-xl: 28px;

  --transition: 200ms cubic-bezier(0.25, 0.1, 0.25, 1);
  --transition-spring: 400ms cubic-bezier(0.34, 1.56, 0.64, 1);

  --font: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'SF Pro Text', 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  --font-mono: 'SF Mono', 'JetBrains Mono', 'Fira Code', monospace;
}

/* ===== 暗色主题 ===== */
[data-theme="dark"] {
  --bg: #000000;
  --bg-elevated: #1C1C1E;
  --bg-secondary: #2C2C2E;

  --text: #F5F5F7;
  --text-secondary: #A1A1A6;
  --text-tertiary: #6E6E73;

  --separator: rgba(255, 255, 255, 0.10);
  --separator-strong: rgba(255, 255, 255, 0.16);

  --accent: #0A84FF;
  --accent-hover: #409CFF;
  --accent-pressed: #0071E3;
  --accent-tint: rgba(10, 132, 255, 0.15);

  --success: #30D158;
  --error: #FF453A;
  --warning: #FF9F0A;

  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.4), 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.5), 0 2px 6px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 20px 50px rgba(0, 0, 0, 0.6), 0 4px 12px rgba(0, 0, 0, 0.4);
  --shadow-accent: 0 4px 14px rgba(10, 132, 255, 0.35);
}

html {
  font-family: var(--font);
  color: var(--text);
  line-height: 1.47;
  letter-spacing: -0.01em;
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: 'kern', 'liga', 'calt';
}

body {
  min-height: 100dvh;
  background: var(--bg);
  position: relative;
  overflow-x: hidden;
}

/* ===== 动态极光背景 ===== */
body::before {
  content: '';
  position: fixed;
  inset: -50%;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(circle 40vmax at 20% 30%, rgba(0, 122, 255, 0.18), transparent 60%),
    radial-gradient(circle 35vmax at 80% 20%, rgba(0, 222, 255, 0.15), transparent 55%),
    radial-gradient(circle 45vmax at 60% 80%, rgba(191, 90, 242, 0.16), transparent 60%),
    radial-gradient(circle 30vmax at 30% 90%, rgba(255, 45, 85, 0.10), transparent 55%);
  filter: blur(40px);
  animation: aurora 25s ease-in-out infinite alternate;
}

[data-theme="dark"] body::before {
  background:
    radial-gradient(circle 40vmax at 20% 30%, rgba(10, 132, 255, 0.28), transparent 60%),
    radial-gradient(circle 35vmax at 80% 20%, rgba(90, 200, 250, 0.22), transparent 55%),
    radial-gradient(circle 45vmax at 60% 80%, rgba(191, 90, 242, 0.25), transparent 60%),
    radial-gradient(circle 30vmax at 30% 90%, rgba(255, 55, 95, 0.18), transparent 55%);
}

@keyframes aurora {
  0% { transform: translate(0, 0) rotate(0deg) scale(1); }
  33% { transform: translate(3%, -3%) rotate(60deg) scale(1.08); }
  66% { transform: translate(-3%, 3%) rotate(-40deg) scale(0.95); }
  100% { transform: translate(2%, -2%) rotate(10deg) scale(1.05); }
}

/* 网格线 */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background-image:
    linear-gradient(var(--grid-color) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-color) 1px, transparent 1px);
  background-size: 60px 60px;
  mask-image: radial-gradient(ellipse 80% 80% at 50% 50%, #000 30%, transparent 100%);
  -webkit-mask-image: radial-gradient(ellipse 80% 80% at 50% 50%, #000 30%, transparent 100%);
}

:root { --grid-color: rgba(0, 0, 0, 0.035); }
[data-theme="dark"] { --grid-color: rgba(255, 255, 255, 0.04); }

/* 浮动光点 */
.particles {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  overflow: hidden;
}

.particle {
  position: absolute;
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--accent);
  opacity: 0;
  box-shadow: 0 0 8px var(--accent);
  animation: particleFloat linear infinite;
}

@keyframes particleFloat {
  0% { opacity: 0; transform: translateY(0) scale(0.5); }
  10% { opacity: 0.8; }
  90% { opacity: 0.4; }
  100% { opacity: 0; transform: translateY(-100vh) scale(1); }
}

.app {
  position: relative;
  z-index: 2;
}

/* ===== 滚动条 ===== */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--separator-strong); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-tertiary); }

/* ===== 布局 ===== */
.app {
  max-width: 860px;
  margin: 0 auto;
  padding: 48px 24px 80px;
  width: 100%;
}

/* ===== 页头 ===== */
.header {
  text-align: center;
  margin-bottom: 44px;
  position: relative;
  animation: headerIn 800ms cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes headerIn {
  from { opacity: 0; transform: translateY(-12px); }
  to { opacity: 1; transform: translateY(0); }
}

/* 页头装饰光晕 */
.header::before {
  content: '';
  position: absolute;
  top: -60px;
  left: 50%;
  transform: translateX(-50%);
  width: 400px;
  height: 200px;
  background: radial-gradient(ellipse, var(--accent-tint), transparent 70%);
  filter: blur(20px);
  z-index: -1;
  pointer-events: none;
  animation: orbPulse 6s ease-in-out infinite;
}

@keyframes orbPulse {
  0%, 100% { opacity: 0.6; transform: translateX(-50%) scale(1); }
  50% { opacity: 1; transform: translateX(-50%) scale(1.08); }
}

.header__badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-secondary);
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: 100px;
  margin-bottom: 20px;
  letter-spacing: 0.02em;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.header__badge svg { flex-shrink: 0; color: var(--accent); animation: boltFlash 3s ease-in-out infinite; }

@keyframes boltFlash {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; color: var(--accent-hover); }
}

.header__title {
  font-size: clamp(34px, 6vw, 56px);
  font-weight: 700;
  line-height: 1.05;
  letter-spacing: -0.03em;
  color: var(--text);
  margin-bottom: 12px;
}

.header__title em {
  font-style: normal;
  background: linear-gradient(135deg, var(--accent) 0%, #5AC8FA 50%, #AF52DE 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  background-size: 200% 200%;
  animation: gradientShift 8s ease infinite;
}

@keyframes gradientShift {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

.header__subtitle {
  font-size: 17px;
  font-weight: 400;
  color: var(--text-secondary);
  max-width: 480px;
  margin: 0 auto;
  line-height: 1.4;
}

/* 主题切换按钮 */
.theme-toggle {
  position: absolute;
  top: 0;
  right: 0;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--separator);
  background: var(--bg-elevated);
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
  box-shadow: var(--shadow-xs);
}

.theme-toggle:hover {
  background: var(--bg-secondary);
  color: var(--text);
  transform: scale(1.05);
}

.theme-icon { position: absolute; transition: opacity 250ms ease, transform 250ms ease; }
.theme-icon--sun { opacity: 1; transform: rotate(0deg) scale(1); }
.theme-icon--moon { opacity: 0; transform: rotate(-90deg) scale(0.5); }

[data-theme="dark"] .theme-icon--sun { opacity: 0; transform: rotate(90deg) scale(0.5); }
[data-theme="dark"] .theme-icon--moon { opacity: 1; transform: rotate(0deg) scale(1); }

/* ===== 模式切换 ===== */
.mode-tabs {
  display: flex;
  gap: 4px;
  background: var(--bg-secondary);
  border-radius: var(--radius-sm);
  padding: 4px;
  margin-bottom: 28px;
  position: relative;
  box-shadow: inset 0 1px 3px rgba(0,0,0,0.06);
}

/* 滑动指示器 */
.mode-tabs__indicator {
  position: absolute;
  top: 4px;
  bottom: 4px;
  width: calc(50% - 4px);
  left: 4px;
  border-radius: 8px;
  background: var(--bg-elevated);
  box-shadow:
    0 2px 8px rgba(0,0,0,0.08),
    0 0 0 1px var(--accent-tint),
    0 0 12px var(--accent-tint);
  transition: left 400ms cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 400ms ease;
  z-index: 0;
}

.mode-tabs[data-active="edit"] .mode-tabs__indicator {
  left: calc(50% + 0px);
}

.mode-tab {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 10px 18px;
  font-family: var(--font);
  font-size: 14px;
  font-weight: 600;
  color: var(--text-tertiary);
  background: transparent;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: color 300ms ease;
  position: relative;
  z-index: 1;
}

.mode-tab:hover { color: var(--text-secondary); }

.mode-tab.active {
  color: var(--accent);
}

.mode-tab.active svg { color: var(--accent); }

/* 激活时指示器发光增强 */
.mode-tabs[data-active="edit"] .mode-tabs__indicator,
.mode-tabs[data-active="generate"] .mode-tabs__indicator {
  box-shadow:
    0 2px 12px rgba(0, 122, 255, 0.18),
    0 0 0 1px var(--accent-tint),
    0 0 16px var(--accent-tint);
}

/* ===== 状态提示 ===== */
.status {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 16px;
  opacity: 0;
  transform: translateY(-8px);
  transition: all 300ms cubic-bezier(0.34, 1.56, 0.64, 1);
  pointer-events: none;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

.status.visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.status--error {
  background: rgba(255, 59, 48, 0.1);
  color: var(--error);
  border: 1px solid rgba(255, 59, 48, 0.2);
}

.status--success {
  background: rgba(52, 199, 89, 0.1);
  color: var(--success);
  border: 1px solid rgba(52, 199, 89, 0.2);
}

/* ===== 卡片 ===== */
.card {
  background: var(--bg-elevated);
  border: 1px solid var(--separator);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition), border-color var(--transition), transform var(--transition);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  animation: cardIn 600ms cubic-bezier(0.22, 1, 0.36, 1) both;
}

.card:nth-child(1) { animation-delay: 50ms; }
.card:nth-child(2) { animation-delay: 100ms; }
.card:nth-child(3) { animation-delay: 150ms; }
.card:nth-child(4) { animation-delay: 200ms; }

@keyframes cardIn {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

.card:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--separator-strong);
  transform: translateY(-1px);
}

.card__label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 16px;
}

/* ===== 表单 ===== */
textarea, input[type="text"], input[type="password"], input[type="number"], select {
  width: 100%;
  background: var(--bg-secondary);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  padding: 12px 14px;
  transition: all var(--transition);
  outline: none;
}

textarea:hover, input:hover, select:hover {
  background: var(--bg-elevated);
  border-color: var(--separator);
}

textarea:focus, input:focus, select:focus {
  background: var(--bg-elevated);
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-tint);
}

textarea {
  resize: vertical;
  min-height: 110px;
  line-height: 1.5;
}

textarea::placeholder, input::placeholder {
  color: var(--text-tertiary);
}

select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='none' stroke='%236E6E73' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round' viewBox='0 0 24 24'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
  cursor: pointer;
}

label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.form-group { margin-bottom: 20px; }
.form-group:last-child { margin-bottom: 0; }

.form-hint {
  display: block;
  font-size: 11px;
  color: var(--text-tertiary);
  margin-top: 6px;
}

/* ===== 网格 ===== */
.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

/* ===== 按钮 ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  font-family: var(--font);
  font-size: 15px;
  font-weight: 600;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 250ms cubic-bezier(0.34, 1.56, 0.64, 1);
  text-decoration: none;
  min-height: 46px;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn--primary {
  color: #FFFFFF;
  width: 100%;
  letter-spacing: 0.02em;
  position: relative;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.22) 0%, rgba(255,255,255,0) 45%),
    linear-gradient(180deg, #1a8bff 0%, #0071e3 100%);
  border-radius: var(--radius-sm);
  box-shadow:
    0 4px 14px rgba(0, 113, 227, 0.35),
    0 1px 0 rgba(255, 255, 255, 0.3) inset;
}

/* 旋转发光边框 */
.btn--primary::before {
  content: '';
  position: absolute;
  inset: -1px;
  border-radius: inherit;
  padding: 1px;
  background: conic-gradient(
    from 0deg,
    transparent 0deg,
    rgba(255, 255, 255, 0.7) 60deg,
    transparent 120deg,
    transparent 360deg
  );
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  opacity: 0;
  transition: opacity 300ms ease;
  pointer-events: none;
}

.btn--primary:hover:not(:disabled) {
  background:
    linear-gradient(180deg, rgba(255,255,255,0.28) 0%, rgba(255,255,255,0) 45%),
    linear-gradient(180deg, #2a96ff 0%, #0a7be8 100%);
  transform: translateY(-2px);
  box-shadow:
    0 8px 24px rgba(0, 113, 227, 0.45),
    0 1px 0 rgba(255, 255, 255, 0.35) inset;
}

.btn--primary:hover:not(:disabled)::before {
  opacity: 1;
  animation: borderSpin 2.5s linear infinite;
}

@keyframes borderSpin {
  to { transform: rotate(360deg); }
}

.btn--primary:active:not(:disabled) {
  transform: translateY(0);
  box-shadow:
    0 2px 6px rgba(0, 113, 227, 0.3),
    0 1px 0 rgba(255, 255, 255, 0.2) inset;
}

/* 图标 */
.btn--primary svg {
  position: relative;
  z-index: 1;
  transition: transform 250ms cubic-bezier(0.34, 1.56, 0.64, 1);
  filter: drop-shadow(0 1px 2px rgba(0,0,0,0.15));
}

.btn--primary:hover:not(:disabled) svg {
  transform: translateX(3px) scale(1.1);
}

.btn--primary span,
.btn--primary {
  position: relative;
  z-index: 1;
}

.btn--ghost {
  background: transparent;
  color: var(--text-secondary);
  padding: 8px 14px;
  font-size: 13px;
  min-height: 36px;
  border: 1px solid var(--separator);
}

.btn--ghost:hover:not(:disabled) {
  background: var(--bg-secondary);
  color: var(--text);
}

/* ===== Spinner ===== */
.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #FFFFFF;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ===== API 设置 ===== */
.settings-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  padding: 4px 0;
  transition: color var(--transition);
  user-select: none;
  border: none;
  background: none;
  font-family: var(--font);
  width: 100%;
}

.settings-toggle:hover { color: var(--text); }

.settings-toggle svg {
  transition: transform var(--transition);
  color: var(--accent);
}

.settings-toggle.open svg { transform: rotate(90deg); }

.settings-toggle .endpoint {
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 12px;
}

.settings-toggle .spacer { flex: 1; }

.settings-panel {
  max-height: 0;
  overflow: hidden;
  transition: max-height 400ms cubic-bezier(0.4, 0, 0.2, 1);
}

.settings-panel.open { max-height: 500px; }

/* ===== 尺寸选择 ===== */
.size-options {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.size-option {
  flex: 1;
  min-width: 70px;
}

.size-option input[type="radio"] { display: none; }

.size-option label {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 12px 8px;
  background: var(--bg-secondary);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition);
  text-align: center;
  margin-bottom: 0;
}

.size-option input:checked + label {
  border-color: var(--accent);
  background: var(--accent-tint);
  color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-tint);
}

.size-option label:hover {
  background: var(--bg-elevated);
  border-color: var(--separator);
}

.size-option label .size-label {
  font-size: 15px;
  font-weight: 600;
}

.size-option label .size-desc {
  font-size: 11px;
  color: var(--text-tertiary);
}

.size-option input:checked + label .size-desc {
  color: var(--accent);
  opacity: 0.7;
}

/* ===== 开关 ===== */
.toggle-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.toggle-input { display: none; }

.toggle-label {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  user-select: none;
  margin-bottom: 0 !important;
}

.toggle-switch {
  position: relative;
  width: 44px;
  height: 26px;
  background: var(--bg-secondary);
  border: 1px solid var(--separator);
  border-radius: 13px;
  transition: all var(--transition);
  flex-shrink: 0;
}

.toggle-switch::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  background: #FFFFFF;
  border-radius: 50%;
  transition: all var(--transition-spring);
  box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}

.toggle-input:checked + .toggle-label .toggle-switch {
  background: var(--success);
  border-color: var(--success);
}

.toggle-input:checked + .toggle-label .toggle-switch::after {
  transform: translateX(18px);
}

.toggle-text {
  font-size: 13px;
  color: var(--text-secondary);
}

.toggle-hint {
  font-size: 11px;
  color: var(--text-tertiary);
  padding-left: 54px;
}

/* ===== 滑块 ===== */
.slider-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.slider {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  background: var(--bg-secondary);
  border-radius: 2px;
  outline: none;
}

.slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 22px;
  height: 22px;
  background: #FFFFFF;
  border: 0.5px solid rgba(0,0,0,0.08);
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 1px 4px rgba(0,0,0,0.15), 0 0 0 0.5px rgba(0,0,0,0.04);
  transition: transform var(--transition);
}

.slider::-webkit-slider-thumb:hover { transform: scale(1.1); }

.slider::-moz-range-thumb {
  width: 22px;
  height: 22px;
  background: #FFFFFF;
  border: 0.5px solid rgba(0,0,0,0.08);
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 1px 4px rgba(0,0,0,0.15);
}

.slider-label {
  font-size: 11px;
  color: var(--text-tertiary);
  white-space: nowrap;
}

/* ===== 画廊 ===== */
.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px;
}

.gallery:empty { display: none; }

.gallery__item {
  position: relative;
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--bg-secondary);
  aspect-ratio: 1;
  cursor: pointer;
  transition: transform var(--transition), box-shadow var(--transition);
  box-shadow: var(--shadow-sm);
}

.gallery__item:hover {
  transform: translateY(-4px) scale(1.02);
  box-shadow: var(--shadow-lg), 0 0 0 1px var(--accent-tint);
}

.gallery__item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 400ms ease;
}

.gallery__item:hover img { transform: scale(1.04); }

.gallery__overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(transparent 40%, rgba(0,0,0,0.75) 100%);
  opacity: 0;
  transition: opacity var(--transition);
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 14px;
}

.gallery__item:hover .gallery__overlay { opacity: 1; }

.gallery__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 8px;
}

.gallery__tag {
  display: inline-flex;
  align-items: center;
  font-size: 10px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 100px;
  background: rgba(255,255,255,0.2);
  color: rgba(255,255,255,0.9);
  backdrop-filter: blur(8px);
  white-space: nowrap;
}

.gallery__tag--quality { background: var(--accent); }
.gallery__tag--format { background: var(--success); }
.gallery__tag--size { background: var(--warning); color: #000; }
.gallery__tag--transparent { background: rgba(255,255,255,0.3); }

.gallery__prompt {
  font-size: 12px;
  color: rgba(255,255,255,0.85);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: 10px;
}

.gallery__actions {
  display: flex;
  gap: 6px;
  width: 100%;
}

.gallery__actions .btn {
  flex: 1;
  padding: 6px 8px;
  font-size: 12px;
  min-height: 30px;
  background: rgba(255,255,255,0.15);
  color: #FFFFFF;
  border: none;
  backdrop-filter: blur(8px);
}

.gallery__actions .btn:hover {
  background: rgba(255,255,255,0.3);
}

/* ===== 空状态 ===== */
.empty-state {
  text-align: center;
  padding: 72px 24px;
  color: var(--text-tertiary);
}

.empty-state__icon {
  width: 56px;
  height: 56px;
  margin: 0 auto 16px;
  opacity: 0.3;
}

.empty-state__title {
  font-size: 17px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.empty-state__desc {
  font-size: 14px;
  max-width: 360px;
  margin: 0 auto;
}

/* ===== 历史 ===== */
.history { margin-top: 32px; }

.history__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.history__title {
  font-size: 19px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.01em;
}

.history__count {
  font-size: 12px;
  color: var(--text-tertiary);
  background: var(--bg-secondary);
  padding: 4px 10px;
  border-radius: 100px;
}

/* ===== Toast ===== */
.toast-container {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
}

.toast {
  background: var(--bg-elevated);
  border: 1px solid var(--separator);
  border-radius: 100px;
  padding: 10px 20px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  box-shadow: var(--shadow-md);
  animation: toastIn 300ms cubic-bezier(0.34, 1.56, 0.64, 1), toastOut 300ms ease 2.7s forwards;
  max-width: 90vw;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

@keyframes toastIn {
  from { opacity: 0; transform: translateY(-12px) scale(0.95); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes toastOut {
  to { opacity: 0; transform: translateY(-8px) scale(0.95); }
}

/* ===== 灯箱 ===== */
.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  z-index: 999;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 250ms ease;
  overflow: hidden;
}

.lightbox.open {
  opacity: 1;
  pointer-events: auto;
}

.lightbox img {
  max-width: 90vw;
  max-height: calc(100vh - 200px);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  object-fit: contain;
  flex-shrink: 1;
  min-height: 0;
}

.lightbox__close {
  position: absolute;
  top: 20px;
  right: 20px;
  background: rgba(255,255,255,0.15);
  border: none;
  color: #FFFFFF;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  font-weight: 300;
  transition: all var(--transition);
  z-index: 10;
  backdrop-filter: blur(10px);
}

.lightbox__close:hover {
  background: rgba(255,255,255,0.25);
  transform: rotate(90deg);
}

.lightbox__info {
  margin-top: 16px;
  text-align: center;
  max-width: 600px;
  flex-shrink: 0;
  max-height: 120px;
  overflow-y: auto;
}

.lightbox__info-text {
  font-size: 14px;
  color: rgba(255,255,255,0.8);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.lightbox__info-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
  margin-top: 10px;
}

.lightbox__info-tag {
  font-size: 11px;
  font-weight: 500;
  padding: 3px 10px;
  border-radius: 100px;
  background: rgba(255,255,255,0.15);
  color: rgba(255,255,255,0.85);
}

.lightbox__actions {
  display: flex;
  gap: 8px;
  margin-top: 14px;
  flex-wrap: wrap;
  justify-content: center;
}

.lightbox__actions .btn {
  background: rgba(255,255,255,0.15);
  color: #FFFFFF;
  border: none;
  backdrop-filter: blur(10px);
}

.lightbox__actions .btn:hover {
  background: rgba(255,255,255,0.28);
}

/* ===== 提示词计数 ===== */
.prompt-hint {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 8px;
}

.prompt-hint__text {
  font-size: 12px;
  color: var(--text-tertiary);
}

.prompt-hint__count {
  font-size: 12px;
  color: var(--text-tertiary);
  font-variant-numeric: tabular-nums;
}

/* ===== 上传区域 ===== */
.upload-zone {
  border: 2px dashed var(--separator-strong);
  border-radius: var(--radius-md);
  padding: 40px 20px;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition);
  background: var(--bg-secondary);
}

.upload-zone:hover, .upload-zone.dragover {
  border-color: var(--accent);
  background: var(--accent-tint);
}

.upload-zone__icon {
  width: 36px;
  height: 36px;
  margin: 0 auto 12px;
  color: var(--accent);
}

.upload-zone__title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
}

.upload-zone__desc {
  font-size: 12px;
  color: var(--text-tertiary);
}

.upload-zone input[type="file"] { display: none; }

/* 编辑参考图预览 */
.edit-refs {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.edit-ref {
  position: relative;
  aspect-ratio: 1;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--bg-secondary);
}

.edit-ref img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.edit-ref__remove {
  position: absolute;
  top: 5px;
  right: 5px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: rgba(0,0,0,0.6);
  border: none;
  color: #FFFFFF;
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
  line-height: 1;
}

.edit-ref__remove:hover { background: var(--error); transform: scale(1.1); }

.edit-ref__index {
  position: absolute;
  bottom: 5px;
  left: 5px;
  background: var(--accent);
  color: #FFFFFF;
  font-size: 10px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 100px;
}

/* ===== 模式面板 ===== */
.mode-panel { display: none; }
.mode-panel.active { display: block; animation: fadeInUp 350ms ease; }

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ===== 响应式 ===== */
@media (max-width: 640px) {
  .grid-2 { grid-template-columns: 1fr; }
  .gallery { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .app { padding: 28px 16px 48px; }
  .card { padding: 18px; }
  .header { margin-bottom: 32px; }
  .size-option { min-width: calc(50% - 4px); }
}

/* ===== 减少动画 ===== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
