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

:root {
  --primary: #4f46e5;
  --primary-light: #818cf8;
  --primary-dark: #3730a3;
  --primary-soft: #eef2ff;
  --bg: #fafbfc;
  --card: #ffffff;
  --text: #0f172a;
  --text-secondary: #64748b;
  --text-muted: #94a3b8;
  --border: #e2e8f0;
  --success: #10b981;
  --warning: #f59e0b;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-lg: 0 4px 24px rgba(0,0,0,0.08);
}

body {
  font-family: -apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,'PingFang SC','Microsoft YaHei',sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

.container { max-width: 480px; margin: 0 auto; min-height: 100vh; background: var(--bg); }

/* ===== 顶部栏 ===== */
.header {
  background: var(--card);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 100;
}
.header-content {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 16px; max-width: 480px; margin: 0 auto;
}
.logo { display: flex; align-items: center; gap: 8px; }
.logo-icon { color: var(--primary); font-size: 20px; }
.logo-text { color: var(--text); font-size: 17px; font-weight: 700; letter-spacing: -0.3px; }

.user-info { display: flex; align-items: center; gap: 10px; }
.user-profile { display: flex; align-items: center; gap: 4px; }
.user-id-badge {
  background: var(--primary-soft); color: var(--primary);
  padding: 2px 8px; border-radius: 6px; font-size: 11px; font-weight: 600;
  max-width: 80px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.nickname-edit {
  background: var(--bg); padding: 2px 8px; border-radius: 6px;
  font-size: 11px; color: var(--text-muted); cursor: pointer; white-space: nowrap;
}
.nickname-edit:hover { color: var(--primary); }
.nickname-edit.has-nickname { color: var(--primary); background: var(--primary-soft); }
.auth-badge {
  color: var(--primary); font-size: 12px; font-weight: 500; cursor: pointer;
  padding: 4px 10px; border-radius: 8px; background: var(--primary-soft);
}
.auth-badge.logged-in { color: var(--text-secondary); background: transparent; font-size: 12px; cursor: default; }

.balance-display {
  display: flex; align-items: center; gap: 3px;
  background: var(--bg); padding: 4px 10px; border-radius: 8px;
  font-size: 12px; white-space: nowrap;
}
.balance-label { color: var(--text-muted); }
.balance-amount { color: var(--text); font-weight: 700; font-size: 15px; }
.balance-unit { color: var(--text-muted); font-size: 11px; }

.btn-recharge {
  background: var(--primary); color: #fff; border: none;
  padding: 6px 14px; border-radius: 8px; font-size: 12px; font-weight: 600;
  cursor: pointer; transition: 0.15s;
}
.btn-recharge:active { opacity: 0.85; transform: scale(0.97); }

/* ===== 区块 ===== */
section { padding: 16px; }
.section-title {
  font-size: 15px; font-weight: 600; margin-bottom: 12px;
  display: flex; align-items: center; gap: 6px; color: var(--text);
}
.title-icon { font-size: 15px; }

/* ===== 模型选择 ===== */
.model-tabs {
  display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px;
}
.model-tab {
  padding: 6px 14px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--card); font-size: 12px; font-weight: 500;
  cursor: pointer; color: var(--text-secondary); transition: 0.15s;
}
.model-tab:active { transform: scale(0.97); }
.model-tab.active {
  background: var(--primary); color: #fff; border-color: var(--primary);
}

.model-detail {
  background: var(--card); border-radius: var(--radius);
  padding: 16px; box-shadow: var(--shadow);
}
.model-detail-name { font-size: 17px; font-weight: 700; color: var(--text); margin-bottom: 2px; }
.model-detail-provider { font-size: 12px; color: var(--text-muted); margin-bottom: 8px; }
.model-detail-desc { font-size: 13px; color: var(--text-secondary); line-height: 1.6; margin-bottom: 12px; }
.model-detail-price {
  display: inline-flex; align-items: center; gap: 4px;
  background: var(--primary-soft); padding: 6px 12px; border-radius: 8px; font-size: 13px;
}
.model-detail-price .price-num { color: var(--primary); font-weight: 700; font-size: 16px; }
.model-detail-features { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 8px; }
.feature-tag {
  background: var(--bg); color: var(--text-secondary);
  padding: 3px 8px; border-radius: 6px; font-size: 11px; font-weight: 500;
}

/* ===== 输入区域 ===== */
.input-section { padding-top: 4px; }
.prompt-input {
  width: 100%; padding: 12px 14px;
  border: 1px solid var(--border); border-radius: var(--radius);
  font-size: 14px; resize: none; outline: none;
  font-family: inherit; background: var(--card); line-height: 1.5;
  transition: 0.15s;
}
.prompt-input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(79,70,229,0.08); }

.options-row { display: flex; gap: 10px; margin-top: 10px; }
.option-item { flex: 1; }
.option-label { display: block; font-size: 12px; font-weight: 500; color: var(--text-muted); margin-bottom: 4px; }
.option-select {
  width: 100%; padding: 9px 10px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-size: 13px; outline: none; background: var(--card); color: var(--text);
}
.option-select:focus { border-color: var(--primary); }

.btn-generate {
  width: 100%; margin-top: 14px; padding: 14px;
  background: var(--primary); color: #fff; border: none;
  border-radius: var(--radius); font-size: 15px; font-weight: 600;
  cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 6px;
  transition: 0.15s;
}
.btn-generate:active { opacity: 0.9; transform: scale(0.98); }
.btn-generate:disabled { opacity: 0.35; cursor: not-allowed; background: #cbd5e1; transform: none; }

/* ===== 结果 ===== */
.result-section { padding-top: 4px; }
.cost-info { text-align: center; font-size: 12px; color: var(--text-muted); margin-bottom: 12px; }
.image-grid { display: grid; gap: 12px; }
.image-grid.one { grid-template-columns: 1fr; }
.image-grid.two { grid-template-columns: 1fr 1fr; }
.image-grid.four { grid-template-columns: 1fr 1fr; }
.image-card {
  border-radius: var(--radius); overflow: hidden;
  background: var(--card); box-shadow: var(--shadow);
}
.image-card img { width: 100%; display: block; }
.image-actions { padding: 8px; }
.btn-download {
  width: 100%; padding: 8px; background: var(--primary); color: #fff;
  border: none; border-radius: var(--radius-sm); font-size: 12px; font-weight: 500; cursor: pointer;
}

/* ===== 加载 ===== */
.loading-overlay {
  position: fixed; top:0; left:0; right:0; bottom:0;
  background: rgba(15,23,42,0.4); display: flex;
  align-items: center; justify-content: center; z-index: 1000;
}
.loading-spinner { background: var(--card); padding: 36px; border-radius: 16px; text-align: center; }
.spinner {
  width: 36px; height: 36px; border: 3px solid var(--border);
  border-top-color: var(--primary); border-radius: 50%;
  animation: spin 0.7s linear infinite; margin: 0 auto 10px;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-text { color: var(--text-secondary); font-size: 13px; }

/* ===== 弹窗 ===== */
.modal-overlay {
  position: fixed; top:0; left:0; right:0; bottom:0;
  background: rgba(15,23,42,0.4); display: flex; align-items: flex-end;
  justify-content: center; z-index: 1000;
}
.modal {
  background: var(--card); width: 100%; max-width: 480px;
  border-radius: 16px 16px 0 0; max-height: 85vh; overflow-y: auto;
  animation: slideUp 0.25s ease;
}
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
.modal-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 18px 20px 0;
}
.modal-header h3 { font-size: 17px; font-weight: 700; }
.modal-close { background: none; border: none; font-size: 22px; color: var(--text-muted); cursor: pointer; padding: 4px; }
.modal-body { padding: 16px 20px; }
.modal-desc { font-size: 13px; color: var(--text-secondary); margin-bottom: 14px; }

.recharge-plans { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 14px; }
.recharge-plan {
  padding: 14px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  text-align: center; cursor: pointer; transition: 0.15s;
}
.recharge-plan:active { transform: scale(0.97); }
.recharge-plan.selected { border-color: var(--primary); background: var(--primary-soft); }
.plan-amount { display: block; font-size: 17px; font-weight: 700; color: var(--text); }

.payment-title { font-size: 13px; font-weight: 600; margin-bottom: 8px; }
.payment-tabs { display: flex; gap: 8px; margin-bottom: 14px; }
.payment-tab {
  flex: 1; padding: 10px; border: 1px solid var(--border);
  border-radius: var(--radius-sm); background: var(--card);
  font-size: 13px; font-weight: 500; cursor: pointer; text-align: center;
  transition: 0.15s; color: var(--text-secondary);
}
.payment-tab.active { border-color: var(--primary); background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.pay-tab-icon { display:inline-block; width:24px; height:24px; line-height:24px; border-radius:50%; font-size:12px; font-weight:600; text-align:center; margin-right:4px; flex-shrink:0; }
.wechat-icon { background:#07C160; color:#fff; }
.alipay-icon { background:#1677FF; color:#fff; }
.pay-tab-label { font-size: 12px; }

.qr-code-area { text-align: center; padding: 12px 0; }
.qr-code-area img { width: 200px; height: 200px; max-width: 100%; border-radius: 8px; box-shadow: var(--shadow-lg); }
.qr-fallback { padding: 36px 16px; background: var(--bg); border-radius: var(--radius-sm); }
.qr-fallback-text { font-size: 14px; color: var(--text-secondary); margin-bottom: 6px; }
.qr-contact { font-size: 14px; color: var(--text); }
.qr-tip { text-align: center; font-size: 12px; color: var(--text-muted); margin-top: 6px; }

.btn-confirm-recharge {
  width: 100%; padding: 14px; background: var(--primary); color: #fff;
  border: none; border-radius: var(--radius); font-size: 15px; font-weight: 600; cursor: pointer;
}
.btn-confirm-recharge:active { opacity: 0.9; }

/* ===== 认证 ===== */
.auth-tabs { display: flex; gap: 8px; margin-bottom: 14px; }
.auth-tab {
  flex: 1; padding: 10px; border: 1px solid var(--border);
  border-radius: var(--radius-sm); background: var(--card); font-size: 14px;
  font-weight: 500; cursor: pointer; text-align: center; transition: 0.15s; color: var(--text-secondary);
}
.auth-tab.active { border-color: var(--primary); background: var(--primary-soft); color: var(--primary); font-weight: 600; }
#loginForm input, #registerForm input {
  width: 100%; padding: 10px 14px; border: 1px solid var(--border);
  border-radius: var(--radius-sm); font-size: 14px; outline: none; margin-bottom: 10px; font-family: inherit; background: var(--card);
}
#loginForm input:focus, #registerForm input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(79,70,229,0.08); }
.auth-btn {
  width: 100%; padding: 12px; background: var(--primary); color: #fff;
  border: none; border-radius: var(--radius-sm); font-size: 15px; font-weight: 600; cursor: pointer; margin-top: 2px;
}

.hidden { display: none !important; }

/* ===== Toast ===== */
.toast {
  position: fixed; top: 56px; left: 50%; transform: translateX(-50%);
  background: #0f172a; color: #fff; padding: 10px 20px;
  border-radius: 8px; font-size: 13px; z-index: 2000;
  animation: fadeIn 0.2s ease; box-shadow: 0 4px 16px rgba(0,0,0,0.15);
}
@keyframes fadeIn { from { opacity: 0; transform: translateX(-50%) translateY(-8px); } to { opacity: 1; transform: translateX(-50%) translateY(0); } }

/* ===== Footer ===== */
.footer { text-align: center; padding: 24px 16px 32px; font-size: 11px; color: var(--text-muted); }