/* --- START OF FILE style.css --- */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;600;800&display=swap');

:root {
    --bg-color: #0b0f19;
    --panel-bg: rgba(20, 25, 40, 0.6);
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --accent: #8b5cf6;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --border-color: rgba(255, 255, 255, 0.1);
}

* { box-sizing: border-box; margin: 0; padding: 0; font-family: 'Inter', 'PingFang SC', sans-serif; }

body {
    background-color: var(--bg-color);
    color: var(--text-main);
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
    position: relative;
    overflow-x: hidden;
}

/* 动态氛围背景光 */
.bg-glow { position: fixed; border-radius: 50%; filter: blur(120px); z-index: -1; opacity: 0.5; }
.blob-1 { width: 400px; height: 400px; background: var(--primary); top: -100px; left: -100px; animation: float 10s infinite alternate; }
.blob-2 { width: 500px; height: 500px; background: var(--accent); bottom: -200px; right: -100px; animation: float 12s infinite alternate-reverse; }
@keyframes float { 0% { transform: translateY(0) scale(1); } 100% { transform: translateY(50px) scale(1.1); } }

/* 玻璃态通用类 */
.glass-panel {
    background: var(--panel-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

/* 导航栏 */
.user-bar {
    width: 100%; max-width: 900px; padding: 15px 30px; margin-bottom: 30px;
    display: flex; justify-content: space-between; align-items: center;
}
.logo { font-size: 20px; font-weight: 800; background: linear-gradient(to right, #6366f1, #d946ef); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }
.user-actions { display: flex; align-items: center; gap: 15px; font-size: 14px; }
.user-points b { color: #facc15; }
#userInfo { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }

/* 按钮库 */
button { cursor: pointer; transition: all 0.3s ease; font-weight: 600; border-radius: 8px; }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-glow { background: linear-gradient(135deg, var(--primary), var(--accent)); color: white; border: none; box-shadow: 0 4px 15px rgba(99, 102, 241, 0.4); }
.btn-glow:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(99, 102, 241, 0.6); }
.btn-outline { background: transparent; color: var(--text-main); border: 1px solid var(--border-color); }
.btn-outline:hover { background: rgba(255,255,255,0.05); }
.btn-ghost { background: transparent; color: var(--text-muted); border: none; }
.btn-ghost:hover { color: var(--text-main); }
.btn-mega { width: 100%; max-width: 400px; padding: 16px; font-size: 18px; border-radius: 12px; background: linear-gradient(135deg, #3b82f6, #8b5cf6); border: none; color: white; margin: 20px auto; display: block; box-shadow: 0 10px 30px -5px rgba(139, 92, 246, 0.5); }
.btn-mega:hover { transform: scale(1.02); }
.w-100 { width: 100%; padding: 12px; margin-top: 15px; }

/* 主体容器 */
.app-container { width: 100%; max-width: 900px; padding: 40px; margin-bottom: 50px; }
header { text-align: center; margin-bottom: 30px; }
header h1 { font-size: 32px; margin-bottom: 10px; font-weight: 800; letter-spacing: -0.5px; }
header p { color: var(--text-muted); font-size: 14px; line-height: 1.5; }

/* 模式切换 Tabs */
.mode-tabs { display: flex; background: rgba(0,0,0,0.2); border-radius: 12px; padding: 5px; margin-bottom: 30px; border: 1px solid var(--border-color); }
.tab-btn { flex: 1; padding: 12px; background: transparent; border: none; color: var(--text-muted); border-radius: 8px; font-size: 15px; }
.tab-btn.active { background: var(--panel-bg); color: #fff; box-shadow: 0 4px 10px rgba(0,0,0,0.2); }
.badge { background: linear-gradient(45deg, #ef4444, #f97316); font-size: 10px; padding: 2px 6px; border-radius: 4px; margin-left: 5px; color: white; }

.hidden { display: none !important; }

/* 上传区域 */
.upload-wrapper { display: flex; gap: 25px; flex-wrap: wrap; }
.upload-box { flex: 1; min-width: 300px; }
.preview-area { height: 380px; border: 2px dashed rgba(255,255,255,0.2); border-radius: 16px; background: rgba(0,0,0,0.2); display: flex; align-items: center; justify-content: center; cursor: pointer; transition: 0.3s; position: relative; overflow: hidden; }
.preview-area:hover { border-color: var(--primary); background: rgba(99, 102, 241, 0.05); }
.preview-area img { width: 100%; height: 100%; object-fit: contain; }
.placeholder { text-align: center; color: var(--text-muted); }
.plus-icon { font-size: 40px; font-weight: 300; margin-bottom: 10px; }

/* 自定义模式 UI */
.prompt-box { margin-bottom: 25px; }
#customPrompt { width: 100%; height: 100px; background: rgba(0,0,0,0.3); border: 1px solid var(--border-color); border-radius: 12px; padding: 15px; color: #fff; font-size: 15px; resize: none; outline: none; transition: 0.3s; }
#customPrompt:focus { border-color: var(--primary); box-shadow: 0 0 15px rgba(99,102,241,0.2); }
.image-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 15px; }
.grid-item, .upload-btn { height: 120px; border-radius: 12px; background: rgba(0,0,0,0.3); border: 1px dashed var(--border-color); display: flex; flex-direction: column; align-items: center; justify-content: center; cursor: pointer; color: var(--text-muted); font-size: 13px; position: relative; overflow: hidden; transition: 0.3s;}
.upload-btn:hover { border-color: var(--primary); color: var(--primary); }
.grid-item img { width: 100%; height: 100%; object-fit: cover; }
.delete-btn { position: absolute; top: 5px; right: 5px; background: rgba(255,0,0,0.7); color: white; border: none; width: 20px; height: 20px; border-radius: 50%; font-size: 12px; display: flex; align-items: center; justify-content: center; z-index: 10;}

/* 加载动画 */
#loadingBar { text-align: center; color: var(--primary); font-weight: 600; margin-top: 15px; display: flex; align-items: center; justify-content: center; gap: 10px; }
.loader { border: 3px solid rgba(255,255,255,0.1); border-top: 3px solid var(--primary); border-radius: 50%; width: 24px; height: 24px; animation: spin 1s linear infinite; }
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

/* 结果区 */
#resultArea { margin-top: 40px; text-align: center; padding-top: 30px; border-top: 1px solid var(--border-color); }
#resultArea h3 { margin-bottom: 20px; color: #fff; }
.image-result img { max-width: 100%; max-height: 600px; border-radius: 12px; box-shadow: 0 10px 30px rgba(0,0,0,0.5); margin-bottom: 25px; }
#downloadBtn { display: inline-block; padding: 12px 30px; text-decoration: none; border-radius: 30px; }

/* 模态框 */
.modal { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.6); backdrop-filter: blur(5px); z-index: 999; display: flex; align-items: center; justify-content: center; }
/* 修改：将固定宽度改为百分比适应手机端 */
.modal-content { width: 90%; max-width: 350px; padding: 30px; text-align: center; position: relative; }
.close { position: absolute; top: 15px; right: 20px; font-size: 24px; color: var(--text-muted); cursor: pointer; }
.close:hover { color: #fff; }
.modal-content h2 { margin-bottom: 20px; font-size: 22px; }
.input-field { width: 100%; padding: 12px 15px; background: rgba(0,0,0,0.3); border: 1px solid var(--border-color); border-radius: 8px; color: #fff; margin-bottom: 15px; outline: none; }
.input-field:focus { border-color: var(--primary); }
.input-group { display: flex; gap: 10px; margin-bottom: 15px; }
.input-group .input-field { margin-bottom: 0; flex: 1; }

#errorMsg { margin-top: 20px; padding: 15px; background: rgba(239, 68, 68, 0.1); border: 1px solid rgba(239, 68, 68, 0.4); color: #fca5a5; border-radius: 8px; text-align: center; }


/* ========================================= */
/* 📱 移动端响应式适配 (Media Queries)        */
/* ========================================= */
@media screen and (max-width: 768px) {
    body {
        padding: 10px; /* 减小外部留白 */
    }

    /* 顶部导航栏折叠居中 */
    .user-bar {
        flex-direction: column;
        gap: 15px;
        padding: 15px 20px;
    }
    
    #userInfo {
        justify-content: center;
    }

    /* 主体容器边距减小 */
    .app-container {
        padding: 20px 15px;
    }

    /* 标题字号缩小 */
    header h1 {
        font-size: 24px;
    }

    /* 上传区域 */
    .upload-box {
        min-width: 100%; /* 手机端让上传框占满宽度 */
    }
    
    .preview-area {
        height: 240px; /* 关键优化：手机端高度降低，防止占满整个屏幕 */
    }

    /* 自定义模式的多图网格缩放 */
    .image-grid {
        grid-template-columns: repeat(auto-fill, minmax(80px, 1fr)); /* 更密集的网格 */
        gap: 10px;
    }
    
    .grid-item, .upload-btn {
        height: 80px; /* 图标缩小 */
        font-size: 11px;
    }
    
    .plus-icon {
        font-size: 28px;
        margin-bottom: 5px;
    }

    /* 模态框内部留白微调 */
    .modal-content {
        padding: 20px 15px;
    }
    
    /* 开始生成按钮优化 */
    .btn-mega {
        padding: 12px;
        font-size: 16px;
    }
}
/* ========================================= */
/* ✨ 异步渲染、作品库与通知消息样式          */
/* ========================================= */

/* 浮动通知 (Toast) */
.toast-container {
    position: fixed; top: 20px; right: 20px; z-index: 9999;
    display: flex; flex-direction: column; gap: 15px;
    pointer-events: none;
}
.toast {
    background: var(--panel-bg); backdrop-filter: blur(16px);
    border: 1px solid var(--border-color); border-left: 4px solid var(--primary);
    padding: 15px 20px; border-radius: 8px; color: #fff;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    animation: slideInRight 0.4s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
    width: 300px;
}
.toast.toast-success { border-left-color: #10b981; }
.toast.toast-error { border-left-color: #ef4444; }
.toast strong { font-size: 15px; display: block; margin-bottom: 5px; }
.toast p { font-size: 13px; color: #cbd5e1; line-height: 1.4; margin: 0; }

@keyframes slideInRight {
    0% { transform: translateX(120%); opacity: 0; }
    100% { transform: translateX(0); opacity: 1; }
}

/* 作品库网格布局 */
.gallery-layout {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 15px;
    margin-top: 10px; max-height: 600px; overflow-y: auto; padding-right: 10px;
}
.gallery-layout::-webkit-scrollbar { width: 6px; }
.gallery-layout::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.2); border-radius: 4px; }

.gallery-card {
    position: relative; border-radius: 12px; overflow: hidden;
    border: 1px solid rgba(255,255,255,0.1); background: rgba(0,0,0,0.3);
    aspect-ratio: 9/16; /* 适配 9:16 模型输出 */
}
.gallery-card img {
    width: 100%; height: 100%; object-fit: cover; transition: 0.3s;
}
.gallery-card:hover img { transform: scale(1.05); }
.gallery-card .card-overlay {
    position: absolute; bottom: 0; left: 0; width: 100%; padding: 15px 10px 10px;
    background: linear-gradient(to top, rgba(0,0,0,0.9), transparent);
    display: flex; justify-content: space-between; align-items: flex-end;
}
.gallery-card .time { font-size: 11px; color: #94a3b8; }
.gallery-card .dl-btn {
    background: var(--primary); color: white; border: none; padding: 4px 10px;
    border-radius: 6px; font-size: 12px; text-decoration: none; font-weight: 600;
}
.gallery-card .dl-btn:hover { background: var(--primary-hover); }

@media screen and (max-width: 768px) {
    .gallery-layout { grid-template-columns: repeat(2, 1fr); max-height: 450px; }
    .toast-container { right: 10px; left: 10px; top: 10px; align-items: center; }
    .toast { width: 100%; max-width: 350px; }
}