/* ===== 全局样式 ===== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

:root {
  --primary-color: #2563eb;
  --primary-light: #eff6ff;
  --primary-dark: #1d4ed8;
  --text-primary: #1f2937;
  --text-secondary: #6b7280;
  --text-tertiary: #9ca3af;
  --bg-primary: #ffffff;
  --bg-secondary: #f9fafb;
  --bg-tertiary: #f3f4f6;
  --border-color: #e5e7eb;
  --success-color: #10b981;
  --warning-color: #f59e0b;
  --danger-color: #ef4444;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
}

html {
  font-size: 16px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
  background-color: var(--bg-secondary);
  color: var(--text-primary);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  background-color: var(--bg-secondary);
  position: relative;
}

/* ===== 顶部问候区 ===== */
.header {
  background: linear-gradient(135deg, #2563eb 0%, #3b82f6 100%);
  padding: 48px 20px 40px;
  color: white;
  border-bottom-left-radius: var(--radius-xl);
  border-bottom-right-radius: var(--radius-xl);
  position: relative;
  overflow: hidden;
}

.header::before {
  content: '';
  position: absolute;
  top: -50%;
  right: -20%;
  width: 200px;
  height: 200px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 50%;
}

.header::after {
  content: '';
  position: absolute;
  bottom: -30%;
  left: -10%;
  width: 150px;
  height: 150px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 50%;
}

.greeting {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  position: relative;
  z-index: 1;
}

.greeting-icon {
  font-size: 20px;
}

.greeting-text {
  font-size: 15px;
  opacity: 0.9;
  font-weight: 500;
}

.app-title {
  font-size: 26px;
  font-weight: 700;
  margin-bottom: 6px;
  position: relative;
  z-index: 1;
}

.app-subtitle {
  font-size: 14px;
  opacity: 0.85;
  position: relative;
  z-index: 1;
}

/* ===== 快捷入口 ===== */
.quick-actions {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  padding: 0 16px;
  margin-top: -24px;
  position: relative;
  z-index: 2;
}

.quick-card {
  background: white;
  border-radius: var(--radius-lg);
  padding: 16px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  box-shadow: var(--shadow-md);
  cursor: pointer;
  transition: all 0.2s ease;
}

.quick-card:active {
  transform: scale(0.95);
}

.quick-icon {
  font-size: 20px;
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--primary-light);
  border-radius: 12px;
}

.quick-label {
  font-size: 13px;
  color: var(--text-primary);
  font-weight: 500;
}

/* ===== 全部工具 ===== */
.tools-section {
  padding: 24px 16px 0;
}

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

.section-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
}

.section-count {
  font-size: 13px;
  color: var(--text-tertiary);
}

.tools-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.tool-card {
  background: white;
  border-radius: var(--radius-md);
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 14px;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: all 0.2s ease;
  border: 1px solid transparent;
}

.tool-card:active {
  transform: scale(0.98);
  border-color: var(--primary-color);
}

.tool-icon {
  font-size: 24px;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--primary-light);
  border-radius: 10px;
  flex-shrink: 0;
}

.tool-info {
  flex: 1;
  min-width: 0;
}

.tool-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.tool-desc {
  font-size: 13px;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tool-arrow {
  font-size: 22px;
  color: var(--text-tertiary);
  font-weight: 300;
}

.image-upload-btn .upload-text {
  font-size: 11px;
  color: var(--text-tertiary);
  flex-shrink: 0;
}

/* ===== 底部留白 ===== */
.bottom-spacer {
  height: 40px;
}

/* ===== 功能详情页 ===== */
.detail-page {
  display: none;
  min-height: 100vh;
  background: var(--bg-secondary);
}

.detail-page.active {
  display: block;
}

.detail-header {
  background: white;
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 10;
  border-bottom: 1px solid var(--border-color);
}

.back-btn {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  color: var(--text-primary);
  cursor: pointer;
  border-radius: 8px;
  transition: background 0.2s;
}

.back-btn:active {
  background: var(--bg-tertiary);
}

.detail-title {
  font-size: 17px;
  font-weight: 600;
  flex: 1;
}

.detail-content {
  padding: 16px;
}

/* ===== 表单卡片 ===== */
.form-card {
  background: white;
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
}

.form-label {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 10px;
  display: block;
}

.form-label .optional {
  font-weight: 400;
  color: var(--text-tertiary);
  font-size: 13px;
  margin-left: 4px;
}

.form-input,
.form-textarea {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: 15px;
  color: var(--text-primary);
  background: var(--bg-secondary);
  transition: all 0.2s;
  font-family: inherit;
}

.form-input:focus,
.form-textarea:focus {
  outline: none;
  border-color: var(--primary-color);
  background: white;
}

.form-textarea {
  resize: none;
  min-height: 100px;
  line-height: 1.6;
}

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

/* ===== 图片上传 ===== */
.image-upload-area {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.image-upload-item {
  aspect-ratio: 1;
  border-radius: var(--radius-sm);
  overflow: hidden;
  position: relative;
  background: var(--bg-secondary);
  border: 1.5px dashed var(--border-color);
}

.image-upload-item.preview {
  border-style: solid;
  border-color: var(--border-color);
}

.image-upload-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.image-upload-item .image-loading {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  color: var(--text-tertiary);
  gap: 4px;
}

.image-upload-item .image-loading span {
  font-size: 11px;
}

.image-upload-btn {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  cursor: pointer;
  color: var(--text-tertiary);
  font-size: 12px;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  user-select: none;
  touch-action: manipulation;
}

.image-upload-btn:active {
  opacity: 0.7;
  transform: scale(0.97);
}

.image-upload-btn .upload-plus {
  font-size: 20px;
  font-weight: 300;
}

.image-upload-btn .upload-text {
  font-size: 11px;
  color: var(--text-tertiary);
  line-height: 1;
}

.image-remove {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 22px;
  height: 22px;
  background: rgba(0, 0, 0, 0.6);
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  cursor: pointer;
  line-height: 1;
}

/* ===== 生成按钮 ===== */
.generate-btn {
  width: 100%;
  padding: 16px;
  background: linear-gradient(135deg, #2563eb 0%, #3b82f6 100%);
  color: white;
  border: none;
  border-radius: var(--radius-md);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

.generate-btn:active {
  transform: scale(0.98);
  opacity: 0.9;
}

.generate-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.generate-btn.loading {
  position: relative;
  color: transparent;
}

/* ===== 效果图选项卡 ===== */
.render-option-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px;
  background: var(--bg-secondary);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s;
  border: 1px solid var(--border-color);
}

.render-option-card:hover {
  border-color: var(--primary-color);
  background: var(--primary-light);
}

.render-option-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.render-option-icon {
  font-size: 24px;
}

.render-option-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.render-option-desc {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 2px;
}

/* 开关 */
.switch {
  width: 44px;
  height: 24px;
  background: #ccc;
  border-radius: 12px;
  position: relative;
  transition: all 0.2s;
  flex-shrink: 0;
}

.switch::after {
  content: '';
  position: absolute;
  width: 20px;
  height: 20px;
  background: white;
  border-radius: 50%;
  top: 2px;
  left: 2px;
  transition: all 0.2s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.switch.active {
  background: var(--primary-color);
}

.switch.active::after {
  left: 22px;
}

/* 展开设置 */
.render-settings {
  margin-top: 14px;
  padding: 14px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-sm);
}

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

/* 数量选择 */
.quantity-selector {
  display: flex;
  gap: 8px;
}

.quantity-btn {
  flex: 1;
  padding: 8px 0;
  text-align: center;
  background: white;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  font-size: 13px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s;
}

.quantity-btn:hover {
  border-color: var(--primary-color);
  color: var(--primary-color);
}

.quantity-btn.active {
  background: var(--primary-color);
  border-color: var(--primary-color);
  color: white;
  font-weight: 500;
}

/* 进度条 */
.render-progress {
  margin-top: -8px;
  margin-bottom: 16px;
  padding: 12px 14px;
  background: var(--primary-light);
  border-radius: var(--radius-sm);
  border: 1px solid #bfdbfe;
}

.render-progress-text {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  color: var(--primary-dark);
  margin-bottom: 8px;
  font-weight: 500;
}

.render-progress-bar-bg {
  height: 6px;
  background: #bfdbfe;
  border-radius: 3px;
  overflow: hidden;
}

.render-progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary-color), #3b82f6);
  border-radius: 3px;
  transition: width 0.3s ease;
}

.generate-btn.loading::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 20px;
  height: 20px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: translate(-50%, -50%) rotate(360deg); }
}

/* ===== 结果页 ===== */
.result-section {
  margin-bottom: 20px;
}

.result-section-title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.result-section-title .icon {
  font-size: 20px;
}

/* 文案结果卡片 */
.copy-card {
  background: white;
  border-radius: var(--radius-lg);
  padding: 18px;
  margin-bottom: 12px;
  box-shadow: var(--shadow-sm);
  border-left: 3px solid var(--primary-color);
}

.copy-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.copy-card-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--primary-color);
}

.copy-btn {
  padding: 6px 12px;
  font-size: 12px;
  background: var(--primary-light);
  color: var(--primary-color);
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 500;
  transition: all 0.2s;
}

.copy-btn:active {
  opacity: 0.7;
}

.copy-btn.copied {
  background: #d1fae5;
  color: var(--success-color);
}

.copy-card-content {
  font-size: 14px;
  line-height: 1.8;
  color: var(--text-primary);
  white-space: pre-wrap;
  word-break: break-word;
}

/* 效果图网格 */
.render-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.render-item {
  aspect-ratio: 1;
  border-radius: var(--radius-md);
  overflow: hidden;
  position: relative;
  background: var(--bg-tertiary);
  box-shadow: var(--shadow-sm);
}

.render-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s;
}

.render-item:active img {
  transform: scale(1.05);
}

.render-item .render-label {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 8px 10px;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.6));
  color: white;
  font-size: 12px;
}

.render-item .loading-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--bg-tertiary);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.render-item .loading-spinner {
  width: 28px;
  height: 28px;
  border: 2px solid #d1d5db;
  border-top-color: var(--primary-color);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.render-item .loading-text {
  font-size: 11px;
  color: var(--text-tertiary);
}

/* ===== 加载状态 ===== */
.loading-state {
  text-align: center;
  padding: 60px 20px;
}

.loading-state .spinner {
  width: 48px;
  height: 48px;
  border: 3px solid var(--border-color);
  border-top-color: var(--primary-color);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 16px;
}

.loading-state .loading-title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 8px;
}

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

/* ===== Toast 提示 ===== */
.toast {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(0, 0, 0, 0.8);
  color: white;
  padding: 12px 20px;
  border-radius: 8px;
  font-size: 14px;
  z-index: 9999;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
}

.toast.show {
  opacity: 1;
}

/* ===== 图片预览弹窗 ===== */
.image-preview-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.9);
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
}

.image-preview-modal.show {
  display: flex;
}

.image-preview-modal img {
  max-width: 95%;
  max-height: 90%;
  object-fit: contain;
}

.image-preview-close {
  position: absolute;
  top: 20px;
  right: 20px;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 20px;
  cursor: pointer;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 50%;
}

/* ===== 重新生成按钮 ===== */
.regenerate-btn {
  width: 100%;
  padding: 14px;
  background: white;
  color: var(--primary-color);
  border: 1.5px solid var(--primary-color);
  border-radius: var(--radius-md);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  margin-top: 8px;
}

.regenerate-btn:active {
  background: var(--primary-light);
}

/* ===== 功能说明标签 ===== */
.feature-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  background: linear-gradient(135deg, #fef3c7, #fde68a);
  color: #92400e;
  font-size: 11px;
  font-weight: 500;
  border-radius: 20px;
  margin-bottom: 12px;
}

.feature-badge .icon {
  font-size: 13px;
}
