/* ===== 重置 ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; font-family: -apple-system, 'PingFang SC', 'Helvetica Neue', sans-serif; background: #FFF9FB; color: #333; font-size: 14px; }
button { cursor: pointer; border: none; background: none; font-family: inherit; }
input { outline: none; font-family: inherit; }
img { display: block; max-width: 100%; }

/* ===== 布局 ===== */
#app { min-height: 100vh; display: flex; flex-direction: column; }
.page { display: none; flex: 1; overflow-y: auto; }
.page.active { display: flex; flex-direction: column; }

.container { width: 100%; max-width: 480px; margin: 0 auto; padding: 16px; }

/* ===== 颜色变量 ===== */
:root {
  --primary: #FF6B9D;
  --secondary: #9B59B6;
  --bg: #FFF9FB;
  --text: #333333;
  --text-muted: #999999;
  --border: #F0F0F0;
  --card-shadow: 0 4px 16px rgba(255, 107, 157, 0.1);
}

/* ===== 渐变 ===== */
.gradient-text {
  background: linear-gradient(135deg, #FF6B9D, #9B59B6);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.gradient-bg { background: linear-gradient(135deg, #FF6B9D 0%, #9B59B6 100%); }

/* ===== 按钮 ===== */
.btn { display: flex; align-items: center; justify-content: center; height: 48px; border-radius: 24px; font-size: 16px; font-weight: 600; letter-spacing: 1px; transition: opacity .2s; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-primary { background: linear-gradient(135deg, #FF6B9D 0%, #9B59B6 100%); color: #fff; width: 100%; }
.btn-primary:active:not(:disabled) { opacity: .85; }

.btn-secondary { background: #fff; color: var(--primary); border: 1.5px solid var(--primary); width: 100%; }

.btn-ghost { background: transparent; color: var(--text-muted); border: 1.5px solid #E8E8E8; }

.btn-sm { height: 36px; font-size: 13px; padding: 0 16px; border-radius: 18px; }

/* ===== 卡片 ===== */
.card { background: #fff; border-radius: 16px; padding: 20px; box-shadow: var(--card-shadow); margin-bottom: 16px; }

/* ===== 标签 chip ===== */
.chip { display: inline-flex; align-items: center; height: 34px; padding: 0 16px; border-radius: 17px; background: #F5F5F5; color: #666; font-size: 13px; cursor: pointer; margin: 0 8px 8px 0; white-space: nowrap; transition: all .2s; border: 1.5px solid transparent; user-select: none; }
.chip:hover { border-color: var(--primary); color: var(--primary); }
.chip.active { background: linear-gradient(135deg, #FF6B9D, #9B59B6); color: #fff; border-color: transparent; }

/* ===== 输入框 ===== */
.input { width: 100%; height: 48px; background: #F8F8F8; border: 1.5px solid transparent; border-radius: 12px; padding: 0 16px; font-size: 15px; transition: border-color .2s; }
.input:focus { border-color: var(--primary); background: #fff; }

/* ===== 进度条 ===== */
.progress-bar { height: 6px; background: #F0F0F0; border-radius: 3px; overflow: hidden; }
.progress-fill { height: 100%; background: linear-gradient(90deg, #FF6B9D, #9B59B6); border-radius: 3px; transition: width .4s ease; }

/* ===== 导航栏 ===== */
.navbar { height: 56px; background: linear-gradient(135deg, #FF6B9D 0%, #9B59B6 100%); display: flex; align-items: center; padding: 0 16px; position: sticky; top: 0; z-index: 100; flex-shrink: 0; }
.navbar-title { flex: 1; text-align: center; color: #fff; font-size: 17px; font-weight: 700; }
.navbar-back { color: #fff; font-size: 24px; width: 40px; display: flex; align-items: center; cursor: pointer; }
.navbar-action { width: 40px; display: flex; justify-content: flex-end; align-items: center; color: #fff; font-size: 13px; cursor: pointer; }

/* ===== Tab Bar ===== */
.tabbar { height: 56px; background: #fff; display: flex; border-top: 1px solid #F0F0F0; position: sticky; bottom: 0; flex-shrink: 0; z-index: 100; }
.tab-item { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; cursor: pointer; color: #999; font-size: 10px; gap: 2px; }
.tab-item.active { color: var(--primary); }
.tab-icon { font-size: 22px; }

/* ===== 弹窗 ===== */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 1000; display: flex; align-items: flex-end; justify-content: center; }
.modal-box { width: 100%; max-width: 480px; background: #fff; border-radius: 20px 20px 0 0; padding: 24px 20px 40px; max-height: 85vh; overflow-y: auto; }
.modal-box.center { align-self: center; border-radius: 16px; margin: 16px; }
.modal-title { font-size: 18px; font-weight: 700; text-align: center; margin-bottom: 8px; }
.modal-subtitle { font-size: 13px; color: var(--text-muted); text-align: center; margin-bottom: 20px; }

/* ===== Toast ===== */
.toast { position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); background: rgba(0,0,0,.75); color: #fff; padding: 10px 20px; border-radius: 8px; font-size: 14px; z-index: 9999; pointer-events: none; white-space: nowrap; opacity: 0; transition: opacity .2s; }
.toast.show { opacity: 1; }

/* ===== 加载状态 ===== */
.loading-overlay { position: fixed; inset: 0; background: rgba(255,249,251,.8); display: flex; flex-direction: column; align-items: center; justify-content: center; z-index: 999; }
.spinner { width: 40px; height: 40px; border: 3px solid #FFE4EE; border-top-color: var(--primary); border-radius: 50%; animation: spin 1s linear infinite; margin-bottom: 12px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== 空状态 ===== */
.empty { display: flex; flex-direction: column; align-items: center; padding: 80px 0; color: #CCC; text-align: center; }
.empty-icon { font-size: 64px; margin-bottom: 16px; }
.empty-text { font-size: 15px; margin-bottom: 8px; }
.empty-hint { font-size: 13px; margin-bottom: 24px; }

/* ===== 页面：首页 ===== */
.home-header { text-align: center; padding: 32px 0 24px; }
.logo { font-size: 32px; font-weight: 800; margin-bottom: 8px; }
.logo-emoji { margin-right: 6px; }
.tagline { font-size: 13px; color: var(--text-muted); }

.upload-area { border: 2px dashed #FFAED0; border-radius: 16px; background: #fff; min-height: 220px; display: flex; align-items: center; justify-content: center; cursor: pointer; overflow: hidden; position: relative; margin-bottom: 16px; box-shadow: var(--card-shadow); }
.upload-area:active { opacity: .85; }
.upload-placeholder { display: flex; flex-direction: column; align-items: center; padding: 32px; text-align: center; }
.upload-icon { font-size: 48px; margin-bottom: 12px; }
.upload-title { font-size: 16px; font-weight: 600; margin-bottom: 8px; }
.upload-hint { font-size: 12px; color: var(--text-muted); margin-bottom: 4px; }
.upload-spec { font-size: 11px; color: #CCC; }
.preview-img { width: 100%; height: 220px; object-fit: cover; }
.preview-change { position: absolute; bottom: 0; left: 0; right: 0; background: linear-gradient(transparent, rgba(0,0,0,.5)); color: #fff; text-align: center; padding: 12px; font-size: 13px; }

.upload-progress { margin-bottom: 16px; }
.upload-progress-text { font-size: 12px; color: var(--text-muted); text-align: right; margin-top: 4px; }

.quota-card { padding: 16px 20px; }
.quota-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.quota-label { font-size: 13px; color: #666; }
.quota-value { font-size: 14px; font-weight: 700; color: var(--primary); }
.quota-hint { font-size: 12px; color: var(--text-muted); margin-top: 8px; }
.quota-vip-link { color: var(--primary); }

/* ===== 页面：选择风格 ===== */
.select-section { margin-bottom: 12px; }
.select-label { font-size: 13px; font-weight: 700; color: #333; margin-bottom: 12px; display: flex; align-items: center; gap: 6px; }
.select-required { font-size: 11px; color: var(--primary); background: #FFE4EE; padding: 2px 8px; border-radius: 10px; }
.chips-wrap { display: flex; flex-wrap: wrap; }
.style-chip { flex-direction: column; align-items: flex-start; height: auto; padding: 8px 14px; }
.style-chip-name { font-size: 14px; font-weight: 600; margin-bottom: 2px; }
.style-chip-desc { font-size: 11px; opacity: .7; }
.summary-bar { background: linear-gradient(135deg, #FFF0F7, #F5EEFF); border-radius: 12px; padding: 12px 16px; margin-bottom: 12px; display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; color: var(--primary); }
.summary-sep { color: #DDD; }
.submit-hint { font-size: 12px; color: #CCC; text-align: center; margin-top: 8px; }

/* ===== 页面：生成中 ===== */
.processing-page { background: linear-gradient(135deg, #FFF0F7 0%, #F5EEFF 100%); }
.processing-wrap { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 40px 24px; }
.spin-container { position: relative; width: 160px; height: 160px; margin-bottom: 32px; display: flex; align-items: center; justify-content: center; }
.ring { position: absolute; border-radius: 50%; border: 3px solid transparent; }
.ring-1 { inset: 0; border-top-color: #FF6B9D; border-right-color: #FF6B9D; animation: spin 3s linear infinite; }
.ring-2 { inset: 20px; border-top-color: #9B59B6; border-left-color: #9B59B6; animation: spin 2s linear infinite reverse; }
.ring-3 { inset: 40px; border-top-color: #FFAED0; animation: spin 1.5s linear infinite; }
.center-emoji { font-size: 40px; z-index: 1; }
.processing-title { font-size: 20px; font-weight: 700; color: #333; margin-bottom: 8px; text-align: center; }
.processing-step { font-size: 14px; color: var(--primary); margin-bottom: 24px; text-align: center; min-height: 20px; }
.progress-wrap { width: 100%; margin-bottom: 24px; }
.progress-pct { text-align: right; font-size: 13px; font-weight: 700; color: var(--primary); margin-top: 4px; }
.tips-list { text-align: center; }
.tip { font-size: 13px; color: #CCC; margin-bottom: 6px; transition: color .3s; }
.tip.active { color: #999; }

/* ===== 页面：结果 ===== */
.skin-card { display: flex; flex-direction: column; gap: 12px; }
.skin-row { display: flex; align-items: center; gap: 12px; }
.skin-swatch { width: 40px; height: 40px; border-radius: 50%; border: 2px solid #F0F0F0; flex-shrink: 0; }
.skin-name { font-size: 15px; font-weight: 700; }
.skin-desc { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.skin-tags { display: flex; gap: 8px; }
.skin-tag { font-size: 11px; padding: 3px 10px; border-radius: 10px; }
.tag-warm { background: #FFF0E6; color: #FF8C42; }
.tag-cool { background: #E8F0FF; color: #5B8AFF; }
.tag-neutral { background: #F5F5F5; color: #999; }
.tag-depth { background: #F0F4FF; color: #6B7FFF; }
.color-rec { font-size: 12px; color: var(--text-muted); }
.rec-value { color: var(--primary); }

.result-tabs { display: flex; gap: 8px; margin-bottom: 12px; overflow-x: auto; padding-bottom: 4px; }
.result-tab { flex-shrink: 0; height: 32px; padding: 0 16px; border-radius: 16px; font-size: 13px; background: #F5F5F5; color: #666; cursor: pointer; display: flex; align-items: center; transition: all .2s; }
.result-tab.active { background: linear-gradient(135deg, #FF6B9D, #9B59B6); color: #fff; }
.result-tab-pending { color: #CCC !important; background: #FAFAFA !important; cursor: default; }

.result-panels { position: relative; }
.result-panel { display: none; opacity: 1; transition: opacity .25s ease; }
.result-panel.active { display: block; }

.result-img-wrap { position: relative; border-radius: 16px; overflow: hidden; margin-bottom: 8px; background: #F8F8F8; }
.result-img { width: 100%; height: auto; max-height: 70vh; object-fit: contain; cursor: zoom-in; display: block; }
.result-badge { position: absolute; top: 10px; left: 10px; background: linear-gradient(135deg, #FF6B9D, #9B59B6); color: #fff; font-size: 12px; font-weight: 600; padding: 6px 12px; border-radius: 12px; line-height: 1.4; }
.badge-desc { font-size: 10px; font-weight: 400; opacity: .88; margin-top: 1px; }

.skin-toggle { display: flex; align-items: center; gap: 8px; padding: 10px 4px 6px; cursor: pointer; }
.skin-toggle-summary { display: flex; align-items: center; flex: 1; gap: 6px; }
.skin-swatch-sm { width: 16px; height: 16px; border-radius: 50%; flex-shrink: 0; border: 1px solid #eee; }
.tag-sm { font-size: 11px; padding: 2px 8px; border-radius: 8px; background: #F5F5F5; color: #666; }

.plan-detail-toggle { display: flex; justify-content: space-between; align-items: center; padding: 10px 4px; font-size: 13px; color: #999; cursor: pointer; border-bottom: 1px solid #F5F5F5; margin-bottom: 0; }
.toggle-arrow { font-size: 12px; }
.plan-detail { padding: 10px 0 4px; }
.plan-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 8px; }
.plan-item { background: #FFF9FB; border-radius: 10px; padding: 10px; }
.plan-key { font-size: 11px; color: var(--text-muted); display: block; margin-bottom: 2px; }
.plan-val { font-size: 13px; font-weight: 500; }
.makeup-desc { font-size: 12px; color: #999; padding: 6px 0 2px; }
.plan-section-title { font-size: 13px; font-weight: 600; color: #555; margin: 10px 0 6px; }

/* ===== 穿搭微调 ===== */
.refine-wrap { margin-top: 12px; display: flex; flex-direction: column; gap: 8px; }
.refine-input { width: 100%; border: 1.5px solid #F0D0E0; border-radius: 10px; padding: 10px 12px; font-size: 13px; color: #333; resize: none; background: #FFF9FB; font-family: inherit; line-height: 1.6; }
.refine-input:focus { border-color: var(--primary); outline: none; }
.refine-btn { width: 100%; }
.refine-err { font-size: 12px; color: #F44336; background: #FFF5F5; border-radius: 8px; padding: 8px 10px; }

/* ===== 对比按钮 ===== */
.compare-btn { position: absolute; bottom: 10px; right: 10px; background: rgba(0,0,0,.48); color: #fff; font-size: 12px; padding: 6px 12px; border-radius: 16px; border: none; cursor: pointer; user-select: none; touch-action: none; transition: background .15s; }
.compare-btn.comparing { background: rgba(255,107,157,.85); }

/* ===== 合成加载蒙层 ===== */
.adj-loading { position: absolute; inset: 0; background: rgba(255,255,255,.65); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; border-radius: 16px; }
.adj-spinner { width: 36px; height: 36px; border: 3px solid #F0F0F0; border-top-color: #FF6B9D; border-radius: 50%; animation: spin .8s linear infinite; }
.adj-loading-text { font-size: 13px; color: var(--primary); font-weight: 600; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== 妆容强度调整 ===== */
.makeup-adjust { margin: 8px 0 4px; background: #FFF9FB; border-radius: 12px; padding: 14px 14px 10px; }
.adjust-title { font-size: 13px; font-weight: 600; color: #555; margin-bottom: 12px; }
.adjust-row { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.adjust-label { font-size: 12px; color: #999; width: 30px; flex-shrink: 0; }
.adjust-slider { flex: 1; -webkit-appearance: none; height: 4px; border-radius: 2px; background: linear-gradient(to right, #FF6B9D, #9B59B6); outline: none; }
.adjust-slider::-webkit-slider-thumb { -webkit-appearance: none; width: 18px; height: 18px; border-radius: 50%; background: #fff; border: 2px solid #FF6B9D; cursor: pointer; box-shadow: 0 1px 4px rgba(0,0,0,.15); }
.adjust-val { font-size: 12px; color: var(--primary); font-weight: 600; width: 24px; text-align: right; flex-shrink: 0; }
.adjust-apply { width: 100%; margin-top: 4px; }
.adjust-applied { margin-top: 8px; font-size: 12px; color: #4CAF50; font-weight: 600; text-align: center; }
.adjust-err { margin-top: 8px; font-size: 12px; color: #F44336; background: #FFF5F5; border-radius: 8px; padding: 8px 10px; text-align: center; }

.action-bar { display: flex; gap: 10px; margin-bottom: 16px; }
.action-btn { flex: 1; height: 48px; border-radius: 12px; font-size: 13px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; }
.action-btn .icon { font-size: 18px; }
.btn-save { background: linear-gradient(135deg, #FF6B9D, #9B59B6); color: #fff; }
.btn-share { background: #F5F5F5; color: #666; }
.btn-regen { background: #FFF0F7; color: var(--primary); }

/* ===== 页面：历史 ===== */
.history-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.history-item { background: #fff; border-radius: 12px; overflow: hidden; box-shadow: var(--card-shadow); cursor: pointer; position: relative; }
.history-thumb { height: 160px; background: linear-gradient(135deg, #FFE4EE, #F3D9FF); display: flex; align-items: center; justify-content: center; font-size: 40px; position: relative; }
.history-thumb img { width: 100%; height: 100%; object-fit: cover; }
.status-dot { position: absolute; top: 8px; right: 8px; width: 20px; height: 20px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 10px; color: #fff; }
.dot-completed { background: #4CAF50; }
.dot-processing, .dot-pending { background: #FF9800; }
.dot-failed { background: #F44336; }
.del-btn { position: absolute; top: 8px; left: 8px; width: 20px; height: 20px; border-radius: 50%; background: rgba(0,0,0,.3); color: #fff; font-size: 10px; display: flex; align-items: center; justify-content: center; }
.history-info { padding: 10px 12px; }
.history-scene { font-size: 13px; font-weight: 600; color: #333; display: block; margin-bottom: 3px; }
.history-date { font-size: 11px; color: var(--text-muted); }
.load-more { text-align: center; padding: 20px; color: var(--primary); font-size: 14px; cursor: pointer; }

/* ===== 页面：个人中心 ===== */
.profile-header { background: linear-gradient(135deg, #FF6B9D, #9B59B6); color: #fff; border-radius: 16px; padding: 24px 20px; margin-bottom: 16px; display: flex; align-items: center; gap: 16px; box-shadow: 0 8px 24px rgba(255,107,157,.3); }
.profile-avatar { width: 64px; height: 64px; border-radius: 50%; border: 3px solid rgba(255,255,255,.5); object-fit: cover; background: rgba(255,255,255,.2); flex-shrink: 0; display: flex; align-items: center; justify-content: center; font-size: 32px; }
.profile-name { font-size: 20px; font-weight: 700; margin-bottom: 4px; }
.profile-mobile { font-size: 13px; opacity: .85; }

.vip-banner { background: linear-gradient(135deg, #FFF8E1, #FFF3E0); border: 1.5px solid #FFE0B2; border-radius: 16px; padding: 16px 20px; margin-bottom: 16px; display: flex; align-items: center; justify-content: space-between; cursor: pointer; }
.vip-left { display: flex; align-items: center; gap: 12px; }
.vip-emoji { font-size: 28px; }
.vip-title { font-size: 15px; font-weight: 700; color: #E65100; }
.vip-desc { font-size: 12px; color: #FF8F00; }
.vip-badge { background: #FF8F00; color: #fff; font-size: 11px; padding: 4px 10px; border-radius: 10px; }

.menu-card { padding: 0; overflow: hidden; }
.menu-item { display: flex; align-items: center; padding: 16px 20px; border-bottom: 1px solid #F5F5F5; cursor: pointer; }
.menu-item:last-child { border-bottom: none; }
.menu-item:active { background: #FFF9FB; }
.menu-icon { font-size: 20px; width: 28px; margin-right: 14px; text-align: center; }
.menu-text { flex: 1; font-size: 15px; color: #333; }
.menu-arrow { color: #CCC; font-size: 18px; }
.menu-danger .menu-text { color: #F44336; }
.version-text { text-align: center; color: #CCC; font-size: 12px; padding: 20px 0; }

/* ===== 页面：登录 ===== */
.login-page { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 100vh; background: linear-gradient(135deg, #FFF0F7 0%, #F5EEFF 100%); padding: 24px; }
.login-logo { text-align: center; margin-bottom: 40px; }
.login-logo-text { font-size: 36px; font-weight: 800; margin-bottom: 8px; }
.login-tagline { font-size: 14px; color: var(--text-muted); }
.login-card { width: 100%; max-width: 400px; background: #fff; border-radius: 20px; padding: 28px 24px; box-shadow: 0 8px 32px rgba(255,107,157,.15); }
.login-title { font-size: 20px; font-weight: 700; margin-bottom: 6px; }
.login-subtitle { font-size: 13px; color: var(--text-muted); margin-bottom: 24px; }
.form-group { margin-bottom: 16px; }
.form-label { font-size: 13px; color: #666; margin-bottom: 6px; display: block; }
.sms-row { display: flex; gap: 10px; }
.sms-input { flex: 1; }
.btn-sms { flex-shrink: 0; width: 110px; height: 48px; border-radius: 12px; background: linear-gradient(135deg, #FF6B9D, #9B59B6); color: #fff; font-size: 13px; }
.btn-sms:disabled { background: #E8E8E8; color: #999; }
.agree-row { display: flex; align-items: center; gap: 8px; margin-bottom: 20px; font-size: 12px; color: var(--text-muted); }
.agree-check { width: 18px; height: 18px; accent-color: var(--primary); }
.agree-link { color: var(--primary); cursor: pointer; }

/* ===== 页面：隐私 ===== */
.privacy-content { padding: 16px; }
.privacy-title { font-size: 22px; font-weight: 700; margin-bottom: 8px; }
.privacy-date { font-size: 12px; color: var(--text-muted); margin-bottom: 24px; }
.privacy-h2 { font-size: 15px; font-weight: 700; color: #333; margin: 20px 0 8px; }
.privacy-p { font-size: 13px; color: #666; line-height: 1.8; margin-bottom: 8px; }

/* ===== 重新生成弹窗 ===== */
.regen-label { font-size: 13px; font-weight: 600; color: #666; margin-bottom: 8px; }
.regen-scroll { overflow-x: auto; white-space: nowrap; padding-bottom: 4px; margin-bottom: 12px; }
.regen-section { margin-bottom: 16px; }
.modal-actions { display: flex; gap: 12px; margin-top: 20px; }
.modal-actions .btn { flex: 1; }

/* ===== 协议弹窗 ===== */
.agreement-scroll { max-height: 45vh; overflow-y: auto; margin-bottom: 20px; }
.agreement-text { font-size: 13px; color: #666; line-height: 1.8; white-space: pre-wrap; }
.agreement-btns { display: flex; gap: 12px; }
.agreement-btns .btn { flex: 1; }
.agreement-link { text-align: center; margin-top: 12px; font-size: 12px; color: var(--primary); cursor: pointer; }

/* ===== 绑定手机弹窗 ===== */
.bind-actions { display: flex; gap: 10px; margin-top: 16px; }
.bind-skip { text-align: center; margin-top: 12px; color: var(--text-muted); font-size: 13px; cursor: pointer; }

/* ===== 安全区域适配 ===== */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
  .tabbar { padding-bottom: env(safe-area-inset-bottom); height: calc(56px + env(safe-area-inset-bottom)); }
}

/* ===== 响应式 ===== */
@media (min-width: 480px) {
  .container { padding: 20px; }
}
