/* ── 基础重置 ────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --bg: #0a0a0a;
    --card-bg: #161616;
    --border: #2a2a2a;
    --text: #e0e0e0;
    --text-muted: #888;
    --accent: #00cc88;
    --accent-hover: #00ee99;
    --danger: #e94560;
    --gold: #ffd700;
    --radius: 12px;
}

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

/* ── 入场动画 ──────────────────────────────────────────────── */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(20px); }
    to   { opacity: 1; transform: translateY(0); }
}

header {
    animation: fadeInUp 0.5s ease-out;
}

main > *:nth-child(1) { animation: fadeInUp 0.5s ease-out 0.05s both; }
main > *:nth-child(2) { animation: fadeInUp 0.5s ease-out 0.1s both; }
main > *:nth-child(3) { animation: fadeInUp 0.5s ease-out 0.15s both; }
main > *:nth-child(4) { animation: fadeInUp 0.5s ease-out 0.2s both; }
main > *:nth-child(5) { animation: fadeInUp 0.5s ease-out 0.25s both; }
main > *:nth-child(6) { animation: fadeInUp 0.5s ease-out 0.3s both; }

/* ── 布局 ────────────────────────────────────────────────────── */
.container {
    max-width: 640px;
    margin: 0 auto;
    padding: 24px 16px 48px;
}

header {
    padding: 32px 0 24px;
}

.header-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
}

.header-brand h1 {
    font-size: 22px;
    font-weight: 700;
    color: #fff;
    line-height: 1.3;
}

.header-brand .subtitle {
    color: var(--text-muted);
    font-size: 13px;
    margin-top: 4px;
}

.header-actions {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}

.lang-btn {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-muted);
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.lang-btn:hover {
    border-color: #555;
    color: var(--text);
}

.lang-btn.active {
    color: var(--accent);
    border-color: var(--accent);
    background: rgba(0, 204, 136, 0.08);
}

.auth-btn {
    background: rgba(255, 215, 0, 0.1);
    border-color: rgba(255, 215, 0, 0.3);
    color: var(--gold);
}

.auth-btn:hover {
    background: rgba(255, 215, 0, 0.15);
}

main { display: flex; flex-direction: column; gap: 16px; }
footer { text-align: center; padding: 32px 0 0; color: #555; font-size: 12px; }

.footer-links {
    margin-top: 8px;
    font-size: 12px;
}

.footer-links a {
    color: #888;
    text-decoration: none;
    transition: color 0.2s;
}

.footer-links a:hover {
    color: var(--accent);
}

.footer-links .separator {
    color: #444;
    margin: 0 6px;
}

/* ── 卡片 ────────────────────────────────────────────────────── */
.card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
}

/* ── 用量栏 ──────────────────────────────────────────────────── */
.usage-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    font-size: 14px;
}

.usage-text { color: #ccc; }
.usage-text strong { color: var(--accent); }

.usage-badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}

.usage-badge.free {
    background: rgba(0, 204, 136, 0.15);
    color: var(--accent);
    border: 1px solid rgba(0, 204, 136, 0.3);
}

.usage-badge.pro {
    background: rgba(255, 215, 0, 0.15);
    color: var(--gold);
    border: 1px solid rgba(255, 215, 0, 0.3);
}

.upgrade-btn {
    padding: 6px 16px;
    border-radius: 20px;
    background: linear-gradient(135deg, #ffd700, #ffaa00);
    color: #000;
    border: none;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.upgrade-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 15px rgba(255, 215, 0, 0.3);
}

.usage-exhausted .usage-text {
    color: var(--danger);
}

.usage-exhausted .usage-badge.free {
    background: rgba(233, 69, 96, 0.15);
    color: var(--danger);
    border-color: rgba(233, 69, 96, 0.3);
}

/* ── 拖拽上传区 ──────────────────────────────────────────────── */
.drop-zone {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 40px 20px;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
}

.drop-zone:hover,
.drop-zone.drag-over {
    border-color: var(--accent);
    background: rgba(0, 204, 136, 0.05);
}

.upload-icon {
    width: 48px;
    height: 48px;
    color: var(--text-muted);
    margin: 0 auto 12px;
}

.upload-text { font-size: 15px; color: #bbb; }
.upload-hint { font-size: 12px; color: #666; margin-top: 4px; }

/* ── 预览 ────────────────────────────────────────────────────── */
.preview-container {
    position: relative;
    border-radius: var(--radius);
    overflow: hidden;
    margin-top: 12px;
}

.preview-container img {
    width: 100%;
    max-height: 320px;
    object-fit: contain;
    display: block;
    border-radius: var(--radius);
}

.remove-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(0,0,0,0.7);
    color: #fff;
    border: none;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.remove-btn:hover { background: var(--danger); }

/* ── 文本框 ──────────────────────────────────────────────────── */
.field-label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: #ddd;
    margin-bottom: 8px;
}

.optional {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 400;
}

.text-area {
    width: 100%;
    background: #0d0d0d;
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    padding: 12px;
    font-size: 14px;
    resize: vertical;
    font-family: inherit;
    transition: border-color 0.2s;
}

.text-area:focus {
    outline: none;
    border-color: var(--accent);
}

/* ── 风格选项 ────────────────────────────────────────────────── */
.style-options {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}

.style-option { display: contents; }

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

.style-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 16px 8px;
    border: 2px solid var(--border);
    border-radius: 10px;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
}

.style-card:hover { border-color: #444; }

.style-option input:checked + .style-card {
    border-color: var(--accent);
    background: rgba(0, 204, 136, 0.08);
}

.style-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #222;
    color: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}

.style-label-zh {
    font-size: 13px;
    font-weight: 600;
    color: #ddd;
}

/* ── 生成按钮 ────────────────────────────────────────────────── */
.generate-btn {
    width: 100%;
    padding: 16px;
    border: none;
    border-radius: var(--radius);
    background: var(--accent);
    color: #000;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.2s, opacity 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.generate-btn:hover:not(:disabled) { background: var(--accent-hover); }
.generate-btn:disabled { opacity: 0.6; cursor: not-allowed; }

@keyframes pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(0, 204, 136, 0.4); }
    50%      { box-shadow: 0 0 0 12px rgba(0, 204, 136, 0); }
}

.generate-btn.loading {
    animation: pulse 1.5s ease-in-out infinite;
}

.spinner {
    width: 20px;
    height: 20px;
    animation: spin 1s linear infinite;
    color: #000;
}

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

/* ── 状态提示 ────────────────────────────────────────────────── */
.status {
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 13px;
    text-align: center;
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.status.hidden {
    opacity: 0;
    transform: translateY(-10px);
    pointer-events: none;
}

.status.success {
    background: rgba(0, 204, 136, 0.1);
    color: var(--accent);
    border: 1px solid rgba(0, 204, 136, 0.2);
}

.status.error {
    background: rgba(233, 69, 96, 0.1);
    color: var(--danger);
    border: 1px solid rgba(233, 69, 96, 0.2);
}

.status.info {
    background: rgba(0, 150, 255, 0.1);
    color: #4da6ff;
    border: 1px solid rgba(0, 150, 255, 0.2);
}

/* ── 结果展示 ────────────────────────────────────────────────── */
.result-container {
    animation: fadeInUp 0.4s ease-out;
    margin-top: 8px;
}

.result-title {
    font-size: 16px;
    font-weight: 600;
    color: #fff;
    margin-bottom: 12px;
}

.result-images {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
}

.result-images img {
    width: 100%;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    display: block;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    cursor: zoom-in;
}

.result-images img:hover {
    transform: scale(1.02);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5);
}

/* ── 水印 ────────────────────────────────────────────────────── */
.watermark-wrapper {
    position: relative;
    display: inline-block;
    width: 100%;
}

.watermark-wrapper img {
    width: 100%;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    display: block;
}

.watermark-text {
    position: absolute;
    bottom: 8px;
    right: 8px;
    background: rgba(0,0,0,0.6);
    color: rgba(255,255,255,0.7);
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 12px;
    pointer-events: none;
    user-select: none;
}

/* ── 下载区 ──────────────────────────────────────────────────── */
.download-area {
    display: flex;
    gap: 8px;
    margin-top: 12px;
    flex-wrap: wrap;
}

.download-btn {
    padding: 8px 16px;
    border-radius: 8px;
    background: #222;
    color: #ccc;
    border: 1px solid var(--border);
    font-size: 13px;
    cursor: pointer;
    transition: background 0.2s;
    text-decoration: none;
}

.download-btn:hover { background: #333; color: #fff; }

/* ── 弹窗 ────────────────────────────────────────────────────── */
.modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.7);
    backdrop-filter: blur(4px);
}

.modal-content {
    position: relative;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 32px;
    max-width: 500px;
    width: 90%;
    animation: fadeInUp 0.3s ease-out;
    max-height: 90vh;
    overflow-y: auto;
}

.auth-modal-content {
    max-width: 400px;
}

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

.modal-header h2 {
    font-size: 20px;
    color: #fff;
}

.modal-close {
    background: none;
    border: none;
    color: #888;
    font-size: 24px;
    cursor: pointer;
    padding: 4px 8px;
}

.modal-close:hover { color: #fff; }

.plan-card {
    background: #0d0d0d;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 16px;
    text-align: center;
}

.free-plan {
    border-color: var(--accent);
    background: rgba(0, 204, 136, 0.05);
}

.starter-plan {
    border-color: #00cc88;
    background: rgba(0, 204, 136, 0.05);
}

.pro-plan {
    border-color: var(--gold);
    background: rgba(255, 215, 0, 0.05);
}

.paygo-plan {
    border-color: #4da6ff;
    background: rgba(77, 166, 255, 0.05);
}

.plan-card h3 {
    font-size: 18px;
    color: #fff;
    margin-bottom: 8px;
}

.plan-price {
    font-size: 28px;
    font-weight: 700;
    color: var(--gold);
    margin-bottom: 12px;
}

.plan-price span {
    font-size: 14px;
    color: #888;
    font-weight: 400;
}

.plan-features {
    list-style: none;
    padding: 0;
    margin: 0 0 16px;
}

.plan-features li {
    padding: 6px 0;
    color: #ccc;
    font-size: 14px;
}

.plan-buy-btn {
    width: 100%;
    padding: 14px;
    border: none;
    border-radius: 10px;
    background: linear-gradient(135deg, #ffd700, #ffaa00);
    color: #000;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.2s;
}

.plan-buy-btn:hover {
    transform: scale(1.03);
}

/* ── 认证表单 ────────────────────────────────────────────────── */
#auth-form input {
    width: 100%;
    padding: 12px;
    margin-bottom: 12px;
    background: #0d0d0d;
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-size: 14px;
    transition: border-color 0.2s;
}

#auth-form input:focus {
    outline: none;
    border-color: var(--accent);
}

.auth-switch {
    text-align: center;
    margin-top: 16px;
    font-size: 13px;
    color: var(--text-muted);
}

.auth-switch button {
    color: var(--accent);
    background: none;
    border: none;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    padding: 0;
}

.auth-switch button:hover {
    text-decoration: underline;
}

.auth-error {
    color: var(--danger);
    font-size: 12px;
    text-align: center;
    margin-top: 8px;
    min-height: 18px;
}

/* ── 工具类 ──────────────────────────────────────────────────── */
.hidden { display: none !important; }

/* ── 响应式 ──────────────────────────────────────────────────── */
@media (min-width: 480px) {
    .result-images { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 360px) {
    .style-options { grid-template-columns: 1fr; }
    .style-card { flex-direction: row; padding: 12px; }
    .style-icon { width: 32px; height: 32px; font-size: 16px; }
    .usage-bar { flex-wrap: wrap; gap: 8px; }
    .header-brand h1 { font-size: 18px; }
    .header-actions { gap: 4px; }
    .lang-btn { padding: 3px 6px; font-size: 11px; }
}
