/* ========== Base ========== */
*, *::before, *::after { box-sizing: border-box; }

:root {
    --accent: #f0a020;
    --accent2: #f57c30;
    --accent-glow: rgba(240,160,32,0.2);
    --bg: #f5f3ef;
    --surface: #fff;
    --surface2: #fafaf8;
    --border: #e8e5df;
    --border-hover: #d8d0c0;
    --text: #2c2416;
    --text2: #6b6050;
    --text3: #a09888;
    --radius: 18px;
    --radius-sm: 12px;
    --shadow: 0 2px 12px rgba(0,0,0,0.04), 0 0 0 1px rgba(0,0,0,0.03);
    --shadow-lg: 0 8px 40px rgba(0,0,0,0.08), 0 0 0 1px rgba(0,0,0,0.04);
    --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

[v-cloak] { display: none; }

html { scroll-behavior: smooth; }

body {
    font-family: "Inter", -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
    background: var(--bg);
    color: var(--text);
    margin: 0;
    padding: 0;
    min-height: 100vh;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

/* ========== Header ========== */
header {
    text-align: center;
    padding: 64px 20px 12px;
}

.logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.logo-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), var(--accent2));
    box-shadow: 0 0 12px var(--accent-glow);
}

header h1 {
    margin: 0;
    font-size: 2rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--text);
}

header h1 .accent {
    color: var(--accent);
}

.tagline {
    margin: 8px 0 0;
    color: var(--text3);
    font-size: 0.95rem;
}

/* ========== Auth Page ========== */
.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
}

.auth-card {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border);
    padding: 48px 40px;
    width: 100%;
    max-width: 420px;
}

.auth-header {
    text-align: center;
    margin-bottom: 36px;
}

.auth-header .logo { display: flex; align-items: center; justify-content: center; gap: 10px; }
.auth-header h1 { margin: 0; font-size: 1.8rem; font-weight: 700; color: var(--text); }
.auth-header h1 .accent { color: var(--accent); }
.auth-header .tagline { margin-top: 6px; }

.auth-tabs {
    display: flex;
    gap: 0;
    margin-bottom: 28px;
    border-bottom: 2px solid var(--border);
}

.auth-tabs button {
    flex: 1;
    padding: 10px;
    border: none;
    background: none;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text3);
    cursor: pointer;
    transition: all var(--transition);
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
}

.auth-tabs button.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.auth-form .form-group label { margin-bottom: 6px; }

.auth-form input[type="text"],
.auth-form input[type="password"] {
    width: 100%;
    padding: 12px 16px;
    background: var(--surface2);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-family: inherit;
    font-size: 0.95rem;
    outline: none;
    transition: all var(--transition);
}

.auth-form input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(240,160,32,0.08);
}

.auth-btn {
    margin-top: 6px;
    background: linear-gradient(135deg, #2c2416, #3a3020);
    border: none;
    padding: 14px;
    border-radius: var(--radius-sm);
    font-weight: 700;
    font-size: 1rem;
    cursor: pointer;
    color: #fff;
    transition: all var(--transition);
}

.auth-btn:hover:not(:disabled) { background: linear-gradient(135deg, #3a3020, #4a3e2c); }
.auth-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.auth-error {
    margin-top: 18px;
    text-align: center;
    color: #d04848;
    font-size: 0.9rem;
    font-weight: 500;
}

/* ========== Top Bar ========== */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 32px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.topbar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
}

.brand-name {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text);
}

.brand-name .accent { color: var(--accent); }

.topbar-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.user-name {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text2);
}

.logout-btn {
    padding: 6px 16px;
    border: 1px solid var(--border);
    background: var(--surface2);
    color: var(--text2);
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.82rem;
    font-weight: 500;
    transition: all var(--transition);
}

.logout-btn:hover { border-color: #d04848; color: #d04848; }

/* ========== Model Selector ========== */
.model-select {
    display: flex;
    gap: 10px;
}

.model-select button {
    flex: 1;
    padding: 12px 16px;
    border: 2px solid var(--border);
    background: var(--surface2);
    color: var(--text2);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    transition: all var(--transition);
}

.model-select button:hover { border-color: var(--border-hover); }

.model-select button.active {
    border-color: var(--accent);
    background: rgba(240,160,32,0.06);
    color: var(--accent);
    box-shadow: 0 2px 12px rgba(240,160,32,0.1);
}

/* ========== Layout ========== */
.container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 28px 28px 80px;
}

/* ========== Generator Card ========== */
.generator-card {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    display: grid;
    grid-template-columns: 1.1fr 0.9fr;
    gap: 0;
    overflow: hidden;
    border: 1px solid var(--border);
}

@media (max-width: 800px) {
    .generator-card { grid-template-columns: 1fr; }
}

/* ========== Upload Section ========== */
.upload-section {
    border-right: 1px solid var(--border);
    min-height: 440px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--transition);
    background: var(--surface2);
}

@media (max-width: 800px) {
    .upload-section {
        border-right: none;
        border-bottom: 1px solid var(--border);
        min-height: 280px;
    }
}

.upload-section.drag-over {
    background: rgba(240,160,32,0.06);
}

.upload-placeholder {
    text-align: center;
    padding: 40px 30px;
}

.upload-icon {
    color: var(--text3);
    margin-bottom: 18px;
    transition: all var(--transition);
}

.upload-section:hover .upload-icon {
    color: var(--accent);
    transform: translateY(-3px);
}

.upload-title {
    font-size: 1.15rem;
    font-weight: 600;
    margin: 0 0 8px;
    color: var(--text2);
}

.upload-hint {
    font-size: 0.85rem;
    color: var(--text3);
    margin: 0 0 4px;
}

.upload-note {
    font-size: 0.8rem;
    color: var(--accent);
    margin: 4px 0 0;
    font-weight: 500;
}

/* ========== Previews ========== */
.previews-wrapper {
    width: 100%;
    height: 100%;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    gap: 12px;
    padding: 24px;
    overflow-y: auto;
    align-content: start;
}

.preview-item {
    aspect-ratio: 1;
    position: relative;
    border-radius: var(--radius-sm);
    overflow: hidden;
    background: #f0ede8;
    border: 1px solid var(--border);
    transition: all var(--transition);
}

.preview-item:hover {
    border-color: var(--accent);
    box-shadow: 0 4px 16px rgba(0,0,0,0.06);
}

.ref-preview {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.remove-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    border: none;
    background: rgba(0,0,0,0.55);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transform: scale(0.8);
    transition: all var(--transition);
    backdrop-filter: blur(6px);
}

.preview-item:hover .remove-btn { opacity: 1; transform: scale(1); }
.remove-btn:hover { background: #e04040; }

.add-more {
    aspect-ratio: 1;
    border: 2px dashed var(--border);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    color: var(--text3);
    cursor: pointer;
    transition: all var(--transition);
}

.add-more:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: rgba(240,160,32,0.04);
}

.ref-hint {
    margin: 4px 0 0 4px;
    font-size: 0.78rem;
    color: var(--text3);
}

/* ========== Input Section ========== */
.input-section {
    display: flex;
    flex-direction: column;
    gap: 24px;
    padding: 36px 32px;
}

.form-group label {
    display: block;
    margin-bottom: 10px;
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--text2);
    letter-spacing: 0.02em;
}

textarea {
    width: 100%;
    height: 130px;
    padding: 16px 18px;
    background: var(--surface2);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-family: inherit;
    font-size: 0.95rem;
    line-height: 1.7;
    resize: none;
    transition: all var(--transition);
    outline: none;
}

textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(240,160,32,0.08);
}
textarea::placeholder { color: var(--text3); }

/* ========== Ratio Buttons ========== */
.ratio-group {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.ratio-group button {
    padding: 8px 16px;
    border: 1.5px solid var(--border);
    background: var(--surface2);
    color: var(--text2);
    border-radius: 22px;
    cursor: pointer;
    font-size: 0.82rem;
    font-weight: 500;
    transition: all var(--transition);
}

.ratio-group button:hover {
    border-color: var(--border-hover);
    background: #fff;
}

.ratio-group button.active {
    background: linear-gradient(135deg, var(--accent), var(--accent2));
    border-color: transparent;
    color: #fff;
    font-weight: 700;
    box-shadow: 0 4px 16px var(--accent-glow);
}

/* ========== Generate Button ========== */
.generate-btn {
    margin-top: auto;
    background: linear-gradient(135deg, #2c2416, #3a3020);
    border: none;
    padding: 18px 32px;
    border-radius: var(--radius-sm);
    font-weight: 700;
    font-size: 1.05rem;
    cursor: pointer;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all var(--transition);
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
}

.generate-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 8px 30px rgba(0,0,0,0.15);
    background: linear-gradient(135deg, #3a3020, #4a3e2c);
}

.generate-btn:active:not(:disabled) { transform: translateY(0); }

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

.btn-star {
    font-size: 1.1rem;
    color: var(--accent);
}

/* ========== Generating Status ========== */
.generating-status {
    margin-top: auto;
    text-align: center;
    padding: 28px 16px;
}

.pulse-ring {
    width: 56px;
    height: 56px;
    margin: 0 auto 18px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), var(--accent2));
    box-shadow: 0 0 0 0 var(--accent-glow);
    animation: pulse 2s ease-out infinite;
}

@keyframes pulse {
    0% { box-shadow: 0 0 0 0 var(--accent-glow); transform: scale(0.95); }
    50% { box-shadow: 0 0 0 22px transparent; transform: scale(1); }
    100% { box-shadow: 0 0 0 0 transparent; transform: scale(0.95); }
}

.gen-title {
    margin: 0;
    font-weight: 700;
    font-size: 1.15rem;
    color: var(--text);
}

.gen-timer {
    margin: 8px 0 16px;
    font-size: 2.5rem;
    font-weight: 300;
    letter-spacing: 0.06em;
    font-variant-numeric: tabular-nums;
    color: var(--accent2);
}

.gen-hint {
    margin: 14px 0 0;
    font-size: 0.82rem;
    color: var(--text3);
}

/* ========== Progress Track ========== */
.progress-track {
    width: 100%;
    max-width: 280px;
    height: 4px;
    margin: 0 auto;
    background: #e8e5df;
    border-radius: 4px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    width: 30%;
    background: linear-gradient(90deg, var(--accent), var(--accent2));
    border-radius: 4px;
    animation: progress-wander 2.5s ease-in-out infinite;
}

@keyframes progress-wander {
    0% { width: 20%; margin-left: 0%; }
    50% { width: 50%; margin-left: 35%; }
    100% { width: 20%; margin-left: 75%; }
}

/* ========== Result Card ========== */
.result-card {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    padding: 40px;
    text-align: center;
    margin-top: 28px;
}

.result-card h2 {
    margin: 0 0 24px;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text2);
}

.result-container img {
    max-width: 100%;
    border-radius: var(--radius-sm);
    margin-bottom: 24px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.08);
}

.download-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--text);
    color: #fff;
    text-decoration: none;
    padding: 14px 32px;
    border-radius: var(--radius-sm);
    font-weight: 700;
    font-size: 0.95rem;
    transition: all var(--transition);
    box-shadow: 0 4px 20px rgba(0,0,0,0.08);
}

.download-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 30px rgba(0,0,0,0.12);
}

/* ========== Error Toast ========== */
.error-toast {
    position: fixed;
    bottom: 36px;
    left: 50%;
    transform: translateX(-50%);
    background: #e04848;
    color: #fff;
    padding: 15px 30px;
    border-radius: 30px;
    font-weight: 600;
    font-size: 0.9rem;
    box-shadow: 0 8px 30px rgba(224,72,72,0.25);
    z-index: 1000;
}

.toast-enter-active, .toast-leave-active {
    transition: all 0.3s ease;
}
.toast-enter-from, .toast-leave-to {
    opacity: 0;
    transform: translateX(-50%) translateY(12px);
}

/* ========== History Section ========== */
.history-section {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    padding: 32px;
    margin-top: 28px;
}

.history-section h2 {
    font-size: 1.05rem;
    font-weight: 600;
    margin: 0 0 10px;
    color: var(--text2);
}

.history-note {
    font-size: 0.78rem;
    color: var(--text3);
    margin: 0 0 18px;
    line-height: 1.5;
}

.history-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 14px;
}

.history-item {
    aspect-ratio: 1;
    border-radius: var(--radius-sm);
    overflow: hidden;
    cursor: pointer;
    position: relative;
    border: 1px solid var(--border);
    transition: all var(--transition);
    background: var(--surface2);
}

.history-item:hover {
    transform: translateY(-3px);
    border-color: var(--accent);
    box-shadow: 0 8px 25px rgba(0,0,0,0.08);
}

.history-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.history-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity var(--transition);
    backdrop-filter: blur(4px);
}

.history-item:hover .history-overlay { opacity: 1; }

.history-overlay span {
    color: #fff;
    font-weight: 600;
    font-size: 0.85rem;
    border: 1px solid rgba(255,255,255,0.4);
    padding: 6px 16px;
    border-radius: 20px;
}

.empty-msg {
    color: var(--text3);
    font-size: 0.9rem;
    text-align: center;
    padding: 24px 0;
}

/* ========== Scrollbar ========== */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #d8d4cc; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #c0bab0; }

/* ========== Selection ========== */
::selection { background: var(--accent); color: #fff; }
