/* ============================================
   AI Generator - Main Stylesheet
   Google-inspired design with dark theme
   ============================================ */

/* --- Reset & Base --- */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg-primary: #0f0f0f;
    --bg-secondary: #1a1a1a;
    --bg-tertiary: #2a2a2a;
    --bg-hover: #303030;
    --text-primary: #e8eaed;
    --text-secondary: #9aa0a6;
    --text-muted: #5f6368;
    --accent-blue: #8ab4f8;
    --accent-blue-hover: #a8c7fa;
    --accent-green: #34d399;
    --accent-red: #f87171;
    --accent-yellow: #fbbf24;
    --border-color: #333;
    --border-light: #3c4043;
    --shadow: 0 1px 6px rgba(0,0,0,0.3);
    --shadow-lg: 0 4px 20px rgba(0,0,0,0.4);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 24px;
    --radius-full: 50px;
    --transition: 0.2s ease;
    --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font);
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* --- Background Art Slideshow --- */
.bg-art-show {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 0;
    overflow: hidden;
    background: #000;
    pointer-events: none;
    transform-style: flat;
    -webkit-transform-style: flat;
    contain: strict;
}
.bg-art-show .bg-slide {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    opacity: 0;
    will-change: transform, opacity;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}
.bg-art-show .bg-slide.active {
    opacity: 0.15;
}
.bg-art-show .bg-slide.zoom-in {
    animation: bgZoomIn 4s ease-out forwards;
}
.bg-art-show .bg-slide.hold {
    opacity: 0.15;
    transform: scale(1.15);
}
.bg-art-show .bg-slide.fade-out {
    animation: bgFadeOut 2s ease-in forwards;
}
@keyframes bgZoomIn {
    0% { transform: scale(1); opacity: 0; }
    100% { transform: scale(1.15); opacity: 0.15; }
}
@keyframes bgFadeOut {
    0% { transform: scale(1.15); opacity: 0.15; }
    100% { transform: scale(1.15); opacity: 0; }
}
@keyframes bgSlowRotate {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* --- Footer --- */
.site-footer {
    position: relative;
    z-index: 1;
    text-align: center;
    padding: 20px;
    border-top: 1px solid var(--border-color);
    background: rgba(15,15,15,0.8);
    backdrop-filter: blur(8px);
}
.footer-content {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    font-size: 13px;
    color: var(--text-muted);
}
.footer-sep { color: var(--border-color); }
.footer-email {
    color: var(--accent-blue) !important;
    text-decoration: none !important;
    font-weight: 500;
    transition: color var(--transition);
}
.footer-email:hover { color: var(--accent-blue-hover) !important; text-decoration: underline !important; }

/* --- Enhance Button --- */
#enhanceBtn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.2), rgba(236, 72, 153, 0.2));
    border: 1px solid rgba(139, 92, 246, 0.3);
    border-radius: 50%;
    color: #c084fc;
    cursor: pointer;
    transition: all var(--transition);
    flex-shrink: 0;
}
#enhanceBtn:hover {
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.35), rgba(236, 72, 153, 0.35));
    border-color: rgba(139, 92, 246, 0.6);
    color: #d8b4fe;
    transform: scale(1.1);
}
#enhanceBtn:active { transform: scale(0.95); }
#enhanceBtn.enhancing {
    pointer-events: none;
    opacity: 0.6;
    animation: enhancePulse 1s ease-in-out infinite;
}
@keyframes enhancePulse {
    0%, 100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(139, 92, 246, 0.4); }
    50% { transform: scale(1.08); box-shadow: 0 0 12px 4px rgba(139, 92, 246, 0.2); }
}

a { color: var(--accent-blue); text-decoration: none; }
a:hover { text-decoration: underline; }

/* --- Header --- */
.header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: rgba(15, 15, 15, 0.9);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-color);
    z-index: 100;
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
}

.header-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 24px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.logo {
    font-size: 22px;
    font-weight: 800;
    text-decoration: none !important;
    letter-spacing: -0.5px;
    display: flex;
    align-items: center;
    gap: 0;
}

.logo-artifex {
    background: linear-gradient(135deg, #8ab4f8, #c084fc);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.logo-canvas {
    background: linear-gradient(135deg, #f472b6, #fb923c);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.logo:hover {
    opacity: 0.9;
}

.header-links {
    display: flex;
    gap: 8px;
    align-items: center;
}

.header-link {
    padding: 8px 16px;
    color: var(--text-secondary) !important;
    text-decoration: none !important;
    font-size: 14px;
    font-weight: 500;
    border-radius: var(--radius-sm);
    transition: all var(--transition);
}

.header-link:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary) !important;
    text-decoration: none !important;
}

.header-link.active {
    color: var(--accent-blue) !important;
    background: rgba(138, 180, 248, 0.1);
}

/* --- Language Button --- */
.lang-btn {
    padding: 6px 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
    font-family: var(--font);
    display: flex;
    align-items: center;
    gap: 4px;
}
.lang-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.lang-select {
    padding: 6px 28px 6px 10px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    font-family: var(--font);
    outline: none;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 24 24' fill='none' stroke='%239aa0a6' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
    transition: all var(--transition);
}
.lang-select:hover {
    border-color: var(--border-light);
    color: var(--text-primary);
}
.lang-select:focus {
    border-color: var(--accent-blue);
}
.lang-select option {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

/* --- Help Button --- */
.help-btn {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #8ab4f8, #c084fc);
    border: none;
    border-radius: 50%;
    color: #000;
    font-size: 15px;
    cursor: pointer;
    transition: all var(--transition);
    line-height: 1;
    box-shadow: 0 0 12px rgba(138,180,248,0.2);
}
.help-btn:hover {
    transform: scale(1.1) rotate(5deg);
    box-shadow: 0 0 20px rgba(138,180,248,0.4);
}

/* --- About Page (Stunning Advertial) --- */
.about-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.85);
    z-index: 1000;
    overflow-y: auto;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}
.about-overlay.active { display: block; }

.about-page {
    max-width: 960px;
    margin: 40px auto;
    position: relative;
    animation: aboutFadeIn 0.6s ease;
}
@keyframes aboutFadeIn {
    from { opacity: 0; transform: translateY(30px); }
    to { opacity: 1; transform: translateY(0); }
}

.about-close {
    position: fixed;
    top: 20px;
    right: 24px;
    width: 44px;
    height: 44px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 50%;
    color: var(--text-primary);
    font-size: 28px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    transition: all var(--transition);
    line-height: 1;
}
.about-close:hover {
    background: var(--accent-red);
    border-color: var(--accent-red);
    color: #fff;
    transform: rotate(90deg);
}

/* Hero */
.about-hero {
    position: relative;
    padding: 80px 48px 64px;
    text-align: center;
    border-radius: 24px 24px 0 0;
    overflow: hidden;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
}
.about-hero-bg {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background:
        radial-gradient(ellipse at 20% 50%, rgba(138,180,248,0.15) 0%, transparent 60%),
        radial-gradient(ellipse at 80% 50%, rgba(192,132,252,0.15) 0%, transparent 60%),
        radial-gradient(ellipse at 50% 100%, rgba(244,114,182,0.1) 0%, transparent 50%);
    pointer-events: none;
}
.about-hero-content { position: relative; z-index: 1; }
.about-hero-badge {
    display: inline-block;
    padding: 6px 18px;
    background: rgba(138,180,248,0.15);
    border: 1px solid rgba(138,180,248,0.3);
    border-radius: 50px;
    font-size: 12px;
    font-weight: 600;
    color: #8ab4f8;
    letter-spacing: 1px;
    margin-bottom: 20px;
    text-transform: uppercase;
}
.about-hero-title {
    font-size: 64px;
    font-weight: 800;
    letter-spacing: -2px;
    margin-bottom: 16px;
    background: linear-gradient(135deg, #8ab4f8, #c084fc, #f472b6);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    line-height: 1.1;
}
.about-hero-sub {
    font-size: 18px;
    color: var(--text-secondary);
    max-width: 600px;
    margin: 0 auto 32px;
    line-height: 1.7;
}
.about-hero-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
}
.about-cta-primary {
    padding: 14px 32px;
    background: linear-gradient(135deg, #8ab4f8, #c084fc);
    border: none;
    border-radius: 50px;
    color: #000;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    font-family: var(--font);
    transition: all var(--transition);
    letter-spacing: 0.3px;
}
.about-cta-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 30px rgba(138,180,248,0.35);
}
.about-cta-secondary {
    padding: 14px 32px;
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: 50px;
    color: var(--text-secondary);
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    font-family: var(--font);
    transition: all var(--transition);
}
.about-cta-secondary:hover {
    border-color: var(--border-light);
    color: var(--text-primary);
    background: var(--bg-hover);
}

/* Stats */
.about-stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1px;
    background: var(--border-color);
    background-color: var(--border-color);
}
.about-stat {
    background: var(--bg-secondary);
    padding: 32px 20px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}
.about-stat:nth-child(odd) { background: #1e1e2e; }
.about-stat:nth-child(even) { background: #22223a; }
.about-stat-num {
    font-size: 36px;
    font-weight: 800;
    background: linear-gradient(135deg, #8ab4f8, #c084fc);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}
.about-stat-label {
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* Features */
.about-features {
    background: var(--bg-secondary);
    padding: 64px 48px;
}
.about-section-title {
    font-size: 32px;
    font-weight: 700;
    text-align: center;
    margin-bottom: 8px;
    color: var(--text-primary);
}
.about-section-sub {
    text-align: center;
    color: var(--text-muted);
    font-size: 16px;
    margin-bottom: 40px;
}
.about-feature-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
}
.about-feature-card {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 32px 24px;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}
.about-feature-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: linear-gradient(90deg, #8ab4f8, #c084fc, #f472b6);
    opacity: 0;
    transition: opacity 0.3s ease;
}
.about-feature-card:hover {
    border-color: var(--border-light);
    transform: translateY(-4px);
    box-shadow: 0 12px 40px rgba(0,0,0,0.3);
}
.about-feature-card:hover::before { opacity: 1; }
.about-feature-icon { font-size: 40px; margin-bottom: 16px; }
.about-feature-card h3 {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 10px;
}
.about-feature-card p {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.7;
    margin-bottom: 16px;
}
.about-feature-card ul {
    list-style: none;
    padding: 0;
}
.about-feature-card ul li {
    font-size: 13px;
    color: var(--text-muted);
    padding: 4px 0;
    border-top: 1px solid var(--border-color);
}
.about-feature-card ul li:first-child { border-top: none; }

/* How It Works */
.about-how {
    background: #1a1a2e;
    padding: 64px 48px;
}
.about-steps {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    max-width: 700px;
    margin: 0 auto;
}
.about-step {
    text-align: center;
    flex: 1;
    padding: 24px 16px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    transition: all var(--transition);
}
.about-step:hover {
    border-color: var(--accent-blue);
    box-shadow: 0 0 20px rgba(138,180,248,0.1);
}
.about-step-num {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, #8ab4f8, #c084fc);
    color: #000;
    font-size: 18px;
    font-weight: 800;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 12px;
}
.about-step h3 {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 6px;
}
.about-step p {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.5;
}
.about-step-arrow {
    font-size: 28px;
    color: var(--text-muted);
    flex-shrink: 0;
    font-weight: 300;
}

/* Extra Features */
.about-extras {
    background: var(--bg-secondary);
    padding: 64px 48px;
}
.about-extra-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
    max-width: 700px;
    margin: 0 auto;
}
.about-extra-item {
    display: flex;
    gap: 16px;
    align-items: flex-start;
    padding: 20px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    transition: all var(--transition);
}
.about-extra-item:hover {
    border-color: var(--border-light);
    background: var(--bg-hover);
}
.about-extra-icon { font-size: 28px; flex-shrink: 0; margin-top: 2px; }
.about-extra-item h4 {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
}
.about-extra-item p {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.5;
}

/* CTA Section */
.about-cta {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
    padding: 64px 48px;
    text-align: center;
}
.about-cta h2 {
    font-size: 32px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 12px;
}
.about-cta p {
    font-size: 16px;
    color: var(--text-secondary);
    margin-bottom: 28px;
}

/* Footer */
.about-footer {
    background: var(--bg-primary);
    padding: 24px 48px;
    text-align: center;
    border-radius: 0 0 24px 24px;
    border-top: 1px solid var(--border-color);
}
.about-footer p {
    font-size: 13px;
    color: var(--text-muted);
}

/* Responsive */
@media (max-width: 768px) {
    .about-page { margin: 20px 12px; }
    .about-hero { padding: 48px 24px; }
    .about-hero-title { font-size: 40px; }
    .about-hero-sub { font-size: 16px; }
    .about-stats { grid-template-columns: repeat(2, 1fr); }
    .about-features { padding: 40px 24px; }
    .about-feature-grid { grid-template-columns: 1fr; }
    .about-how { padding: 40px 24px; }
    .about-steps { flex-direction: column; gap: 16px; }
    .about-step-arrow { transform: rotate(90deg); }
    .about-extras { padding: 40px 24px; }
    .about-extra-grid { grid-template-columns: 1fr; }
    .about-cta { padding: 40px 24px; }
    .about-cta h2 { font-size: 24px; }
}

/* --- User Menu --- */
.user-menu { position: relative; }
.user-btn {
    padding: 6px 14px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    font-family: var(--font);
    transition: all var(--transition);
    white-space: nowrap;
}
.user-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
.signup-btn { background: rgba(52, 211, 153, 0.12); color: #34d399; border-color: rgba(52, 211, 153, 0.3); }
.signup-btn:hover { background: rgba(52, 211, 153, 0.2); color: #34d399; }
.user-avatar { display: inline-flex; align-items: center; gap: 4px; }

.user-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 4px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 6px;
    min-width: 200px;
    flex-direction: column;
    gap: 2px;
    box-shadow: 0 8px 30px rgba(0,0,0,0.5);
    z-index: 200;
}
.user-dropdown .user-name {
    padding: 8px 10px 6px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 4px;
}
.user-dropdown button {
    width: 100%;
    padding: 8px 10px;
    background: transparent;
    border: none;
    border-radius: 6px;
    color: var(--text-secondary);
    font-size: 13px;
    cursor: pointer;
    text-align: left;
    font-family: var(--font);
    transition: all var(--transition);
}
.user-dropdown button:hover { background: var(--bg-hover); color: var(--text-primary); }

/* --- History Grid --- */
.history-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 12px;
}
.history-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    overflow: hidden;
    cursor: pointer;
    transition: all var(--transition);
    position: relative;
}
.history-card:hover { border-color: var(--border-light); box-shadow: var(--shadow); }
.history-card.history-card-archived {
    opacity: 0.6;
    border-color: rgba(251, 191, 36, 0.2);
}
.history-card.history-card-archived:hover {
    opacity: 0.85;
    border-color: rgba(251, 191, 36, 0.4);
}
.history-media {
    width: 100%;
    aspect-ratio: 16/9;
    background: var(--bg-tertiary);
    overflow: hidden;
    position: relative;
}
.history-media img, .history-media video { width: 100%; height: 100%; object-fit: cover; }
.play-icon {
    position: absolute; top: 50%; left: 50%; transform: translate(-50%,-50%);
    font-size: 32px; opacity: 0.7; text-shadow: 0 2px 8px rgba(0,0,0,0.5);
}
.history-failed, .history-pending {
    display: flex; align-items: center; justify-content: center;
    height: 100%; font-size: 14px; color: var(--text-muted);
}
.video-pending {
    flex-direction: column; gap: 8px;
}
.video-pending .history-pending-spinner {
    width: 24px; height: 24px;
    border: 2px solid var(--border-color);
    border-top-color: var(--accent-blue);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.check-status-btn {
    padding: 4px 12px;
    font-size: 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--accent-blue);
    cursor: pointer;
    transition: all var(--transition);
}
.check-status-btn:hover {
    background: var(--bg-hover);
    border-color: var(--accent-blue);
}

/* --- Video Polling UI (result section) --- */
.video-polling {
    display: flex; flex-direction: column; align-items: center;
    justify-content: center; padding: 60px 20px; gap: 16px;
}
.video-polling-spinner .spinner-ring {
    width: 48px; height: 48px;
    border: 3px solid var(--border-color);
    border-top-color: var(--accent-blue);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
.video-polling-text {
    font-size: 18px; color: var(--text-primary); font-weight: 500;
}
.video-polling-sub {
    font-size: 12px; color: var(--text-muted);
}
.video-polling-bar {
    width: 100%; max-width: 400px; height: 4px;
    background: var(--bg-tertiary); border-radius: 2px; overflow: hidden;
}
.processing-status {
    color: var(--accent-yellow); font-weight: 500;
}
.history-info { padding: 10px 12px; position: relative; }
.history-prompt { font-size: 13px; color: var(--text-primary); margin-bottom: 4px; line-height: 1.4; }
.history-meta { font-size: 11px; color: var(--text-muted); }
.history-provider { font-size: 10px; color: var(--accent-green); margin-top: 2px; }
.history-params { margin-top: 6px; display: flex; flex-wrap: wrap; gap: 4px; }
.history-param-tag {
    font-size: 10px;
    padding: 2px 6px;
    background: rgba(138,180,248,0.1);
    border: 1px solid rgba(138,180,248,0.15);
    border-radius: 4px;
    color: #8ab4f8;
}
.history-actions {
    position: absolute;
    top: 10px;
    right: 10px;
    display: flex;
    gap: 4px;
    opacity: 0;
    transition: opacity var(--transition);
}
.history-card:hover .history-actions {
    opacity: 1;
}
.history-archive-btn, .history-delete-btn {
    background: rgba(248, 113, 113, 0.1);
    border: 1px solid rgba(248, 113, 113, 0.25);
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    padding: 3px 6px;
    line-height: 1;
    transition: all var(--transition);
}
.history-archive-btn {
    background: rgba(52, 211, 153, 0.1);
    border-color: rgba(52, 211, 153, 0.25);
}
.history-archive-btn:hover {
    background: rgba(52, 211, 153, 0.25);
    border-color: var(--accent-green);
    transform: scale(1.1);
}
.history-archive-btn.archived {
    background: rgba(251, 191, 36, 0.1);
    border-color: rgba(251, 191, 36, 0.25);
}
.history-archive-btn.archived:hover {
    background: rgba(251, 191, 36, 0.25);
    border-color: var(--accent-yellow);
    transform: scale(1.1);
}
.history-delete-btn:hover {
    background: rgba(248, 113, 113, 0.25);
    border-color: var(--accent-red);
    transform: scale(1.1);
}

/* --- History Full-Screen Page --- */
.history-page {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 200;
    background: var(--bg-primary);
    display: flex;
    flex-direction: column;
    animation: historyPageIn 0.3s ease;
}
@keyframes historyPageIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}
.history-page-header {
    flex-shrink: 0;
    background: rgba(15,15,15,0.95);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 10;
}
.history-page-header-inner {
    max-width: 1400px;
    margin: 0 auto;
    padding: 16px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.history-page-header-inner h2 {
    font-size: 22px;
    font-weight: 700;
    background: linear-gradient(135deg, #8ab4f8, #c084fc);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}
.history-page-close {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 50%;
    color: var(--text-secondary);
    font-size: 22px;
    cursor: pointer;
    transition: all var(--transition);
}
.history-page-close:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
    border-color: var(--border-light);
}
.history-page-body {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    max-width: 1400px;
    width: 100%;
    margin: 0 auto;
}
.history-page-filters {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
    align-items: center;
    flex-wrap: wrap;
}
.history-filter-group {
    position: relative;
}
.history-filter-group select {
    padding: 10px 36px 10px 14px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 14px;
    font-family: var(--font);
    cursor: pointer;
    outline: none;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%239aa0a6' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    min-width: 150px;
    transition: border-color var(--transition);
}
.history-filter-group select:hover { border-color: var(--border-light); }
.history-filter-group select:focus { border-color: var(--accent-blue); }
.history-filter-group select option { background: var(--bg-secondary); color: var(--text-primary); }
.history-search-group {
    flex: 1;
    min-width: 200px;
    max-width: 400px;
    position: relative;
}
.history-search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
}
.history-search-group input {
    width: 100%;
    padding: 10px 36px 10px 38px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 14px;
    font-family: var(--font);
    outline: none;
    transition: border-color var(--transition);
}
.history-search-group input:hover { border-color: var(--border-light); }
.history-search-group input:focus { border-color: var(--accent-blue); }
.history-search-group input::placeholder { color: var(--text-muted); }
.history-search-clear {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 18px;
    cursor: pointer;
    padding: 4px;
    line-height: 1;
    border-radius: 50%;
    transition: all var(--transition);
}
.history-search-clear:hover { color: var(--text-primary); background: var(--bg-hover); }

/* Archive toggle in history */
.history-archive-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
    user-select: none;
    white-space: nowrap;
}
.history-archive-toggle:hover {
    border-color: var(--border-light);
    color: var(--text-primary);
    background: var(--bg-tertiary);
}
.history-archive-toggle input[type="checkbox"] {
    appearance: none;
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    cursor: pointer;
    transition: all var(--transition);
    flex-shrink: 0;
    margin: 0;
    position: relative;
}
.history-archive-toggle input[type="checkbox"]:checked {
    background: var(--accent-green);
    border-color: var(--accent-green);
}
.history-archive-toggle input[type="checkbox"]:checked::after {
    content: '✓';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #000;
    font-size: 11px;
    font-weight: 700;
}

.history-page-stats {
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-color);
}
.history-page-empty {
    text-align: center;
    padding: 80px 20px;
    color: var(--text-muted);
}
.history-empty-icon {
    font-size: 64px;
    margin-bottom: 16px;
    opacity: 0.5;
}
.history-page-empty h3 {
    font-size: 20px;
    color: var(--text-secondary);
    margin-bottom: 8px;
}
.history-page-empty p {
    font-size: 14px;
    color: var(--text-muted);
}

/* Override history grid for full-screen: more columns */
.history-page-body .history-grid {
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
}

/* Pagination for history page */
.pagination {
    display: flex;
    justify-content: center;
    gap: 8px;
    padding: 24px 0;
    flex-wrap: wrap;
}
.pagination button {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-secondary);
    font-size: 14px;
    font-family: var(--font);
    cursor: pointer;
    transition: all var(--transition);
}
.pagination button:hover {
    background: var(--bg-hover);
    border-color: var(--border-light);
    color: var(--text-primary);
}
.pagination button.active {
    background: rgba(138, 180, 248, 0.15);
    border-color: var(--accent-blue);
    color: var(--accent-blue);
    font-weight: 600;
}

/* --- Form group reuse for auth --- */
.form-group { margin-bottom: 14px; }
.form-group label { display: block; font-size: 13px; color: var(--text-secondary); margin-bottom: 4px; }
.form-group input, .form-group textarea, .form-group select {
    width: 100%; padding: 10px 12px; background: var(--bg-tertiary);
    border: 1px solid var(--border-color); border-radius: var(--radius-sm);
    color: var(--text-primary); font-size: 14px; font-family: var(--font);
}
.form-group input:focus, .form-group textarea:focus, .form-group select:focus { border-color: var(--accent-blue); outline: none; }

/* --- Modal Overlay (shared) --- */
.modal-overlay { display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.8); z-index: 1000; justify-content: center; align-items: center; }
.modal-overlay.active { display: flex; }
.modal-content { background: var(--bg-secondary); border-radius: 16px; padding: 30px; max-width: 800px; width: 90%; max-height: 90vh; overflow-y: auto; border: 1px solid var(--border-color); }
.modal-content h2 { color: var(--text-primary); margin-bottom: 15px; }
.modal-content .close-btn { float: right; background: none; border: none; color: var(--text-muted); font-size: 24px; cursor: pointer; }
.modal-content .close-btn:hover { color: var(--text-primary); }
.modal-content .detail-row { margin-bottom: 10px; }
.modal-content .detail-row strong { color: var(--text-muted); display: inline-block; min-width: 120px; }
.modal-content .detail-row span { color: var(--text-primary); }
.modal-content img, .modal-content video { max-width: 100%; border-radius: 8px; margin-top: 15px; }
.modal-content .prompt-text { background: var(--bg-tertiary); padding: 15px; border-radius: 8px; margin: 10px 0; line-height: 1.6; white-space: pre-wrap; }

/* --- Auth Buttons --- */
.auth-actions { display: flex; flex-direction: column; gap: 10px; margin-top: 20px; }
.auth-submit-btn {
    width: 100%; padding: 14px; border: none; border-radius: var(--radius-sm);
    font-size: 16px; font-weight: 700; cursor: pointer; font-family: var(--font);
    background: linear-gradient(135deg, #8ab4f8, #c084fc);
    color: #000; transition: all var(--transition); letter-spacing: 0.3px;
}
.auth-submit-btn:hover { transform: translateY(-1px); box-shadow: 0 4px 15px rgba(138,180,248,0.3); }
.auth-submit-btn:active { transform: translateY(0); }

.auth-toggle-btn {
    width: 100%; padding: 10px; border: none; border-radius: var(--radius-sm);
    font-size: 13px; font-weight: 500; cursor: pointer; font-family: var(--font);
    background: transparent; color: var(--text-muted);
    transition: all var(--transition);
}
.auth-toggle-btn:hover { color: var(--accent-blue); background: rgba(138,180,248,0.06); }

/* Remember Me checkbox */
.remember-me-group {
    margin-bottom: 0 !important;
}
.remember-me-label {
    display: flex !important;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 13px;
    color: var(--text-secondary);
    user-select: none;
}
.remember-me-label input[type="checkbox"] {
    appearance: none;
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    cursor: pointer;
    transition: all var(--transition);
    flex-shrink: 0;
    margin: 0;
    position: relative;
}
.remember-me-label input[type="checkbox"]:checked {
    background: var(--accent-blue);
    border-color: var(--accent-blue);
}
.remember-me-label input[type="checkbox"]:checked::after {
    content: '✓';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #000;
    font-size: 11px;
    font-weight: 700;
}
.remember-me-label:hover {
    color: var(--text-primary);
}

/* --- Subscription Plans --- */
.sub-plans { display: flex; gap: 16px; margin-top: 20px; }
.sub-plan {
    flex: 1; background: var(--bg-secondary); border: 1px solid var(--border-color);
    border-radius: var(--radius-md); padding: 24px; position: relative;
    display: flex; flex-direction: column; gap: 12px;
}
.sub-plan.sub-featured { border-color: var(--accent-blue); box-shadow: 0 0 20px rgba(138,180,248,0.1); }
.sub-badge {
    position: absolute; top: -10px; left: 50%; transform: translateX(-50%);
    background: var(--accent-blue); color: #000; font-size: 10px; font-weight: 700;
    padding: 3px 12px; border-radius: 20px; letter-spacing: 0.5px;
}
.sub-plan h3 { font-size: 18px; font-weight: 700; color: var(--text-primary); }
.sub-price { font-size: 32px; font-weight: 800; color: var(--text-primary); }
.sub-price span { font-size: 14px; font-weight: 400; color: var(--text-muted); }
.sub-plan ul { list-style: none; padding: 0; margin: 0; flex: 1; }
.sub-plan ul li { padding: 5px 0; font-size: 13px; color: var(--text-secondary); border-bottom: 1px solid var(--border-color); }
.sub-plan ul li:last-child { border-bottom: none; }
.sub-current {
    text-align: center; padding: 8px; background: rgba(138,180,248,0.1);
    border: 1px solid rgba(138,180,248,0.2); border-radius: var(--radius-sm);
    font-size: 13px; font-weight: 600; color: var(--accent-blue);
}
.user-plan-badge {
    font-size: 11px; padding: 3px 8px; border-radius: 20px;
    margin: 2px 10px 6px; text-align: center;
}
.user-plan-badge.free { background: rgba(251,191,36,0.1); color: #fbbf24; }
.user-plan-badge.monthly { background: rgba(52,211,153,0.1); color: #34d399; }

@media (max-width: 600px) { .sub-plans { flex-direction: column; } }

/* --- Main Content --- */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 80px 20px 40px;
    min-height: 100vh;
    position: relative;
    z-index: 1;
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
}

/* --- Hero Section --- */
.hero {
    text-align: center;
    max-width: 720px;
    width: 100%;
    animation: fadeInUp 0.5s ease;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.hero-icon {
    font-size: 64px;
    margin-bottom: 16px;
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

.hero-title {
    font-size: 48px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 8px;
    letter-spacing: -1.5px;
    background: linear-gradient(135deg, #8ab4f8, #c084fc, #f472b6);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.hero-subtitle {
    font-size: 16px;
    color: var(--text-secondary);
    margin-bottom: 32px;
}

/* --- Search Box (Google-like) --- */
.search-container {
    width: 100%;
    max-width: 640px;
    margin: 0 auto;
}

.search-box {
    display: flex;
    align-items: flex-start;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 12px 20px;
    transition: all var(--transition);
    gap: 12px;
    position: relative;
}

.search-box:focus-within {
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 2px rgba(138, 180, 248, 0.15);
    background: var(--bg-secondary);
}

.search-box:hover {
    border-color: var(--border-light);
}

.search-icon {
    width: 20px;
    height: 20px;
    color: var(--text-muted);
    flex-shrink: 0;
    margin-top: 8px;
}

.prompt-input {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 16px;
    font-family: var(--font);
    resize: none;
    outline: none;
    min-height: 24px;
    max-height: 400px;
    line-height: 1.5;
    padding: 4px 0;
    scrollbar-width: thin;
    scrollbar-color: var(--border-light) transparent;
}

.prompt-input::-webkit-scrollbar {
    width: 6px;
}

.prompt-input::-webkit-scrollbar-track {
    background: transparent;
}

.prompt-input::-webkit-scrollbar-thumb {
    background: var(--border-light);
    border-radius: 3px;
}

.prompt-input::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

.prompt-input::placeholder {
    color: var(--text-muted);
}

.search-actions {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
    margin-top: 4px;
}

.action-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 6px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
}

.action-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

/* --- Mode Toggle --- */
.mode-toggle {
    display: flex;
    gap: 8px;
    justify-content: center;
    margin-top: 20px;
}

.mode-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 24px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-full);
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
    font-family: var(--font);
}

.mode-btn:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.mode-btn.active {
    background: rgba(138, 180, 248, 0.12);
    border-color: var(--accent-blue);
    color: var(--accent-blue);
}

/* --- Model Selector --- */
.model-selector {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-top: 16px;
    font-size: 14px;
}

.model-selector label {
    color: var(--text-secondary);
}

.model-selector select {
    padding: 8px 32px 8px 14px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 14px;
    font-family: var(--font);
    cursor: pointer;
    outline: none;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%239aa0a6' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    max-width: 400px;
}

.model-selector select:focus {
    border-color: var(--accent-blue);
}

.model-selector select option {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

/* --- Style Reference --- */
.style-reference {
    margin-top: 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 14px 16px;
    text-align: left;
}

.style-ref-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
    flex-wrap: wrap;
}

.style-ref-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    letter-spacing: 0.3px;
}

.style-ref-tabs {
    display: flex;
    gap: 4px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    padding: 3px;
}

.ref-tab {
    padding: 4px 12px;
    background: transparent;
    border: none;
    border-radius: 6px;
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
    font-family: var(--font);
}

.ref-tab:hover {
    color: var(--text-secondary);
}

.ref-tab.active {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.ref-clear-btn {
    margin-left: auto;
    padding: 4px 10px;
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-size: 12px;
    cursor: pointer;
    transition: all var(--transition);
    font-family: var(--font);
}

.ref-clear-btn:hover {
    background: rgba(248, 113, 113, 0.1);
    border-color: var(--accent-red);
    color: var(--accent-red);
}

.ref-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 4px;
}

.ref-chip {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    padding: 6px 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition);
    text-align: left;
    font-family: var(--font);
    max-width: 180px;
}

.ref-chip:hover {
    background: var(--bg-hover);
    border-color: var(--border-light);
}

.ref-chip.selected {
    background: rgba(138, 180, 248, 0.1);
    border-color: var(--accent-blue);
}

.ref-chip .chip-name {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.3;
}

.ref-chip .chip-era {
    font-size: 10px;
    color: var(--text-muted);
    line-height: 1.2;
}

.ref-quick-row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 4px;
}

.ref-chip-quick {
    background: rgba(138, 180, 248, 0.08);
    border-color: rgba(138, 180, 248, 0.2);
}

.ref-all-row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 6px;
    padding-top: 6px;
    border-top: 1px solid var(--border-color);
}

.ref-toggle-btn {
    display: block;
    width: 100%;
    margin-top: 6px;
    padding: 5px;
    background: transparent;
    border: 1px dashed var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
    font-family: var(--font);
}
.ref-toggle-btn:hover {
    border-color: var(--accent-blue);
    color: var(--accent-blue);
}

.ref-preview {
    margin-top: 10px;
    padding: 10px 12px;
    background: rgba(138, 180, 248, 0.06);
    border: 1px solid rgba(138, 180, 248, 0.2);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: flex-start;
    gap: 8px;
    animation: fadeInUp 0.2s ease;
}

.ref-preview-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--accent-blue);
    white-space: nowrap;
    flex-shrink: 0;
    margin-top: 1px;
}

.ref-preview-value {
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.4;
}

.ref-catalogue-btn {
    padding: 5px 12px;
    background: rgba(138, 180, 248, 0.1);
    border: 1px solid rgba(138, 180, 248, 0.25);
    border-radius: var(--radius-sm);
    color: var(--accent-blue);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
    font-family: var(--font);
}
.ref-catalogue-btn:hover {
    background: rgba(138, 180, 248, 0.2);
    border-color: var(--accent-blue);
}

.no-refs {
    font-size: 13px;
    color: var(--text-muted);
    padding: 8px 0;
}

/* --- Catalogue Modal --- */
.catalogue-modal {
    max-width: 1100px !important;
}

.cat-search-box {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    margin-bottom: 12px;
}
.cat-search-box:focus-within {
    border-color: var(--accent-blue);
}
.cat-search-box svg {
    flex-shrink: 0;
    color: var(--text-muted);
}
.cat-search-box input {
    flex: 1;
    background: none;
    border: none;
    outline: none;
    color: var(--text-primary);
    font-size: 14px;
    font-family: var(--font);
}
.cat-search-box input::placeholder {
    color: var(--text-muted);
}

.catalogue-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-color);
}

.cat-tag {
    padding: 5px 14px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-full);
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
    font-family: var(--font);
}
.cat-tag:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}
.cat-tag.active {
    background: rgba(138, 180, 248, 0.15);
    border-color: var(--accent-blue);
    color: var(--accent-blue);
}

.catalogue-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
}

.cat-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 14px;
    transition: all var(--transition);
    display: flex;
    flex-direction: column;
}
.cat-card:hover {
    border-color: var(--border-light);
    box-shadow: var(--shadow);
}

.cat-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 8px;
    margin-bottom: 8px;
}
.cat-card-header h3 {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.3;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px 6px;
    width: 100%;
}
.cat-card-header h3 .cat-era {
    margin-left: auto;
}
.cat-category {
    font-size: 10px;
    color: var(--accent-green);
    background: rgba(52, 211, 153, 0.1);
    padding: 1px 6px;
    border-radius: var(--radius-sm);
    display: inline-block;
    margin-top: 2px;
}
.cat-era {
    font-size: 11px;
    color: var(--accent-blue);
    background: rgba(138, 180, 248, 0.1);
    padding: 2px 8px;
    border-radius: var(--radius-sm);
    white-space: nowrap;
    flex-shrink: 0;
}

.cat-desc {
    font-size: 11px;
    color: var(--text-secondary);
    line-height: 1.4;
    margin-bottom: 8px;
}

/* Catalogue responsive */
@media (max-width: 1100px) {
    .catalogue-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 860px) {
    .catalogue-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 600px) {
    .catalogue-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 400px) {
    .catalogue-grid { grid-template-columns grid-template-columns: 1fr; }
}

.cat-images {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
    margin-bottom: 10px;
}
.cat-img-wrap {
    border-radius: var(--radius-sm);
    overflow: hidden;
    background: var(--bg-tertiary);
    aspect-ratio: 16 / 9;
}
.cat-img-wrap img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.cat-movies {
    margin-bottom: 12px;
}
.cat-movies strong {
    font-size: 12px;
    color: var(--text-secondary);
    display: block;
    margin-bottom: 6px;
}
.cat-movies ul {
    list-style: none;
    padding: 0;
}
.cat-movies li {
    font-size: 13px;
    color: var(--text-primary);
    padding: 3px 0;
}

.cat-select-btn {
    width: 100%;
    padding: 7px;
    margin-top: auto;
    background: rgba(138, 180, 248, 0.1);
    border: 1px solid rgba(138, 180, 248, 0.25);
    border-radius: var(--radius-sm);
    color: var(--accent-blue);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
    font-family: var(--font);
}
.cat-select-btn:hover {
    background: rgba(138, 180, 248, 0.2);
    border-color: var(--accent-blue);
}

/* --- Advanced Options --- */
.advanced-options {
    margin-top: 16px;
}

.options-row {
    display: flex;
    justify-content: center;
}

.option-group {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
}

.option-group label {
    font-size: 13px;
    color: var(--text-secondary);
}

.option-group select {
    padding: 6px 28px 6px 10px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 13px;
    font-family: var(--font);
    cursor: pointer;
    outline: none;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 24 24' fill='none' stroke='%239aa0a6' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
}

.option-group select:focus {
    border-color: var(--accent-blue);
}

/* --- Duration Number Input --- */
.duration-input-group {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    overflow: hidden;
}
.duration-input-group:hover {
    border-color: var(--border-light);
}
.duration-input-group:focus-within {
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 2px rgba(138,180,248,0.15);
}
.duration-input {
    width: 60px;
    padding: 6px 4px;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 14px;
    font-family: var(--font);
    text-align: center;
    outline: none;
    -moz-appearance: textfield;
}
.duration-input::-webkit-inner-spin-button,
.duration-input::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
.duration-btn {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    line-height: 1;
    padding: 0;
    font-family: var(--font);
}
.duration-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}
.duration-btn:active {
    background: rgba(138,180,248,0.15);
    color: var(--accent-blue);
}

/* --- Buttons --- */
.search-buttons {
    display: flex;
    gap: 12px;
    justify-content: center;
    margin-top: 24px;
}

.generate-btn, .lucky-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 28px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
    font-family: var(--font);
}

.generate-btn {
    background: var(--accent-blue);
    color: #000;
}

.generate-btn:hover {
    background: var(--accent-blue-hover);
    box-shadow: var(--shadow);
}

.generate-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: var(--border-color);
    color: var(--text-muted);
}

.lucky-btn {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.lucky-btn:hover {
    background: var(--bg-tertiary);
    border-color: var(--border-light);
    box-shadow: var(--shadow);
}

/* --- Loading Section --- */
.loading-section {
    text-align: center;
    max-width: 480px;
    animation: fadeInUp 0.3s ease;
}

.loading-spinner {
    margin-bottom: 24px;
}

.spinner-ring {
    width: 48px;
    height: 48px;
    border: 3px solid var(--border-color);
    border-top-color: var(--accent-blue);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-text {
    font-size: 18px;
    color: var(--text-primary);
    margin-bottom: 16px;
    font-weight: 500;
}

.loading-progress {
    width: 100%;
    height: 4px;
    background: var(--bg-tertiary);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 12px;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-blue), var(--accent-green));
    border-radius: 4px;
    width: 0%;
    animation: progress 30s ease-in-out forwards;
}

@keyframes progress {
    0% { width: 0%; }
    20% { width: 20%; }
    50% { width: 50%; }
    80% { width: 75%; }
    95% { width: 90%; }
    100% { width: 95%; }
}

.loading-tip {
    font-size: 13px;
    color: var(--text-muted);
}

/* --- Result Section --- */
.result-section {
    width: 100%;
    max-width: 800px;
    animation: fadeInUp 0.4s ease;
}

.result-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.result-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px;
    border-bottom: 1px solid var(--border-color);
}

.result-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
}

.result-actions {
    display: flex;
    gap: 8px;
}

.result-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
    font-family: var(--font);
}

.result-btn:hover {
    background: var(--bg-hover);
    border-color: var(--border-light);
}

.result-body {
    padding: 24px;
}

.result-media {
    margin-bottom: 20px;
    text-align: center;
}

.result-media-wrap {
    position: relative;
    margin-bottom: 20px;
}

.result-media {
    text-align: center;
}

.result-media img,
.result-media video {
    max-width: 100%;
    max-height: 600px;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg);
}

/* Result Navigation Arrows */
.result-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: rgba(26, 26, 26, 0.85);
    backdrop-filter: blur(8px);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    font-size: 24px;
    font-weight: 300;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
    z-index: 10;
    box-shadow: var(--shadow);
    line-height: 1;
}

.result-nav:hover {
    background: var(--bg-hover);
    border-color: var(--accent-blue);
    color: var(--accent-blue);
    transform: translateY(-50%) scale(1.1);
}

.result-nav:active {
    transform: translateY(-50%) scale(0.95);
}

.result-nav-prev {
    left: 8px;
}

.result-nav-next {
    right: 8px;
}

.result-info {
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    padding: 16px;
}

.info-row {
    display: flex;
    justify-content: space-between;
    padding: 6px 0;
    font-size: 14px;
}

.info-row .label {
    color: var(--text-secondary);
}

.info-row .value {
    color: var(--text-primary);
    font-weight: 500;
}

.result-text {
    margin-top: 16px;
    padding: 16px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 14px;
    line-height: 1.6;
    white-space: pre-wrap;
}

/* Result Prompt Box */
.result-prompt-box {
    margin-bottom: 16px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    padding: 16px;
}

.result-prompt-label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.result-prompt-input {
    width: 100%;
    padding: 12px 14px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 14px;
    font-family: var(--font);
    line-height: 1.5;
    resize: vertical;
    min-height: 60px;
    max-height: 400px;
    scrollbar-width: thin;
    scrollbar-color: var(--border-light) transparent;
}

.result-prompt-input::-webkit-scrollbar {
    width: 6px;
}

.result-prompt-input::-webkit-scrollbar-track {
    background: transparent;
}

.result-prompt-input::-webkit-scrollbar-thumb {
    background: var(--border-light);
    border-radius: 3px;
}

.result-prompt-input::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

.result-prompt-input:focus {
    outline: none;
    border-color: var(--accent-blue);
}

.result-prompt-actions {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 8px;
    margin-top: 10px;
}

.copy-prompt-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
    font-family: var(--font);
}

.copy-prompt-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
    border-color: var(--border-light);
}

.copy-prompt-btn.copied {
    background: rgba(52, 211, 153, 0.15);
    border-color: var(--accent-green);
    color: var(--accent-green);
}

.regenerate-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 18px;
    background: var(--accent-blue);
    border: none;
    border-radius: var(--radius-sm);
    color: #000;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    font-family: var(--font);
}

.regenerate-btn:hover {
    background: var(--accent-blue-hover);
}

/* --- Footer --- */
.footer {
    text-align: center;
    padding: 24px;
    color: var(--text-muted);
    font-size: 13px;
}

.footer a {
    color: var(--accent-blue);
}

/* --- Responsive --- */
@media (max-width: 768px) {
    .hero-title {
        font-size: 32px;
    }
    .hero-icon {
        font-size: 48px;
    }
    .search-box {
        padding: 10px 16px;
    }
    .search-buttons {
        flex-direction: column;
        align-items: center;
    }
    .generate-btn, .lucky-btn {
        width: 100%;
        justify-content: center;
    }
    .option-group {
        flex-direction: column;
        align-items: center;
    }
    .header-content {
        padding: 0 16px;
    }
    .result-header {
        flex-direction: column;
        gap: 12px;
        align-items: flex-start;
    }
    .model-selector {
        flex-direction: column;
    }
    .model-selector select {
        max-width: 100%;
        width: 280px;
    }
}

/* === Reference Image Upload === */
.ref-image-section {
    margin-top: 12px;
    padding: 12px 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
}

.ref-image-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.ref-image-label {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

.ref-image-hint {
    font-size: 12px;
    color: var(--text-muted);
}

.ref-image-upload {
    width: 100%;
}

.ref-image-dropzone {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 20px;
    border: 2px dashed var(--border-light);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition);
    background: var(--bg-tertiary);
}

.ref-image-dropzone:hover {
    border-color: var(--accent-blue);
    background: rgba(138, 180, 248, 0.05);
}

.ref-image-dropzone svg {
    color: var(--text-muted);
}

.ref-image-drop-text {
    font-size: 13px;
    color: var(--text-secondary);
}

.ref-image-drop-hint {
    font-size: 11px;
    color: var(--text-muted);
}

.ref-image-preview {
    position: relative;
    display: inline-block;
    border-radius: var(--radius-sm);
    overflow: hidden;
    max-width: 200px;
}

.ref-image-preview img {
    width: 100%;
    height: auto;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
}

.ref-image-remove {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.6);
    border: none;
    color: #fff;
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
}

.ref-image-remove:hover {
    background: rgba(248, 113, 113, 0.8);
    transform: scale(1.1);
}

/* === Queue Progress === */
.queue-progress {
    display: none;
    max-width: 600px;
    margin: 40px auto;
    padding: 24px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    text-align: center;
}

.queue-progress-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.queue-progress-header h2 {
    font-size: 18px;
    font-weight: 700;
}

.queue-count {
    font-size: 24px;
    font-weight: 800;
    color: var(--accent-blue);
}

.queue-progress-bar-track {
    width: 100%;
    height: 8px;
    background: var(--bg-tertiary);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 16px;
}

.queue-progress-bar-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--accent-blue), var(--accent-green));
    border-radius: 4px;
    transition: width 0.5s ease;
}

.queue-progress-items {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 16px;
}

.queue-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    border-radius: var(--radius-sm);
    background: var(--bg-tertiary);
    font-size: 13px;
    transition: all var(--transition);
}

.queue-item.active {
    background: rgba(138, 180, 248, 0.1);
    border: 1px solid rgba(138, 180, 248, 0.3);
}

.queue-item.completed {
    opacity: 0.7;
}

.queue-item-status {
    font-size: 14px;
    width: 20px;
    text-align: center;
}

.queue-item-label {
    color: var(--text-primary);
}

.queue-current-item {
    font-size: 13px;
    color: var(--text-secondary);
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* Number of Images input styling */
#numImages {
    width: 60px;
    text-align: center;
}
