:root { 
    --primary: #52FF00;
    --primary-gradient: linear-gradient(90deg, #52FF00 0%, #00F0FF 100%);
    --bg-deep: #050505; 
    --glass-border: rgba(255, 255, 255, 0.15);
    --text-main: #FFFFFF;
    --sidebar-width: 260px;
}

* { box-sizing: border-box; outline: none; user-select: none; }

/* === 🔥 1. 全局滚动条美化 (你刚才要求的) === */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #333; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #555; }

body { 
    margin: 0; padding: 0; background-color: var(--bg-deep); 
    color: var(--text-main); font-family: 'Inter', sans-serif; 
    display: flex; height: 100vh; overflow: hidden; /* 只有主容器溢出隐藏 */
    background-image: radial-gradient(circle at 50% 30%, #111 0%, #000 70%);
}

/* === 🔥 2. 侧边栏 (Sidebar) === */
.sidebar {
    width: var(--sidebar-width); 
    height: 100%; 
    background: rgba(10, 10, 10, 0.95); 
    border-right: 1px solid var(--glass-border);
    display: flex; flex-direction: column; 
    padding: 20px; z-index: 1000; /* 层级最高 */
    flex-shrink: 0;
    transition: margin-left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    margin-left: 0;
}
.sidebar.collapsed { margin-left: calc(var(--sidebar-width) * -1); }
.sidebar::-webkit-scrollbar { display: none; }

.back-btn {
    width: 100%; height: 40px; border-radius: 8px; background: #1A1A1A; border: 1px solid #333; 
    display: flex; align-items: center; justify-content: center; gap: 10px;
    cursor: pointer; color: #888; transition: 0.3s; text-decoration: none; font-size: 14px; margin-bottom: 20px;
    white-space: nowrap;
}
.back-btn:hover { border-color: var(--primary); color: var(--primary); }

.history-title { font-size: 12px; color: #666; margin-bottom: 10px; font-weight: bold; white-space: nowrap; }

.session-dock {
    flex: 1; width: 100%; display: flex; flex-direction: column; gap: 15px; 
    overflow-y: auto; padding-right: 5px;
}

.dock-item {
    width: 100%; height: auto; border-radius: 8px; background: #000; border: 1px solid #333;
    cursor: pointer; transition: all 0.2s; position: relative; overflow: hidden;
    flex-shrink: 0; display: block;
}
.dock-item video, .dock-item img {
    width: 100%; height: 100%; object-fit: cover; display: block; border-radius: 6px;
}
.dock-item:hover { border-color: var(--primary); box-shadow: 0 5px 15px rgba(0,0,0,0.5); transform: scale(1.02); }

/* === 🔥 3. 主舞台 (Stage) === */
.stage { flex: 1; position: relative; height: 100vh; display: flex; flex-direction: column; }

.google-menu-btn {
    position: absolute; top: 20px; left: 20px;
    width: 40px; height: 40px; border-radius: 50%;
    background: #222222; border: 1px solid #444444;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; color: #FFFFFF; z-index: 900;
    transition: all 0.2s;
}
.google-menu-btn:hover { background: #333333; border-color: #555555; transform: scale(1.05); }
.menu-icon { width: 18px; height: 12px; display: flex; flex-direction: column; justify-content: space-between; }
.menu-icon span { display: block; width: 100%; height: 2px; background-color: #FFFFFF; border-radius: 2px; }

/* 画廊容器 (找回了滚动逻辑) */
.gallery-view {
    flex: 1; overflow-y: auto; padding: 40px; padding-bottom: 300px;
    display: flex; flex-direction: column; align-items: center; gap: 40px;
    scroll-behavior: smooth;
    z-index: 10;
}

.result-container {
    width: fit-content; max-width: 90%;
    animation: slideUp 0.3s forwards;
    display: flex; flex-direction: column; align-items: center;
    padding: 10px; border-radius: 12px;
}
@keyframes slideUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }

/* 网格布局 */
.grid-1 { display: flex; justify-content: center; width: 100%; } 
.grid-1 .gen-img, .grid-1 .loading-ph, .grid-1 .img-wrapper { height: 500px !important; width: auto; object-fit: contain; max-width: 100%; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; width: 100%; }
.grid-2 .gen-img, .grid-2 .loading-ph, .grid-2 .img-wrapper { height: 350px !important; width: 100%; object-fit: contain; background: #111; }
.grid-4 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; width: 100%; }
.grid-4 .gen-img, .grid-4 .loading-ph, .grid-4 .img-wrapper { height: 350px !important; width: 100%; object-fit: contain; background: #111; }

/* === 🔥 4. 图片容器与生成结果 (基础样式) === */
.img-wrapper { position: relative; border-radius: 12px; overflow: hidden; border: 1px solid #333; transition: 0.3s; background: #111; }
.img-wrapper:hover { border-color: var(--primary); }
.gen-img { width: 100%; height: 100%; object-fit: contain; display: block; }

/* 生成时的遮罩 */
.img-overlay {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.75); backdrop-filter: blur(2px);
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
    opacity: 0; transition: 0.2s;
}
.img-wrapper:hover .img-overlay { opacity: 1; }

/* === 🔥 5. 按钮与输入 (找回了丢失的样式) === */
.action-btn {
    background: rgba(255,255,255,0.1); border: 1px solid #555; color: #fff;
    padding: 8px 16px; border-radius: 20px; font-size: 12px; cursor: pointer;
    transition: 0.2s; width: 140px; text-align: center;
}
.action-btn:hover { background: var(--primary); color: #000; border-color: var(--primary); font-weight: bold; }
.action-btn.download { border-color: #333; color: #aaa; }
.action-btn.download:hover { background: #333; color: #fff; border-color: #555; }

.gen-btn {
    background: var(--primary-gradient);
    color: #000; font-weight: 800; font-size: 13px;
    padding: 0 24px; height: 44px; border-radius: 12px;
    border: none; cursor: pointer; transition: 0.3s;
    display: flex; align-items: center; gap: 6px;
    white-space: nowrap;
}
.gen-btn:hover { transform: scale(1.02); box-shadow: 0 0 20px rgba(82, 255, 0, 0.4); }

.input-box {
    display: flex; align-items: flex-end; gap: 10px; background: #111;
    border: 1px solid #333; border-radius: 16px; padding: 5px;
}
.mini-upload-trigger { color: #666; font-size: 20px; cursor: pointer; padding: 12px; transition: 0.2s; }
.mini-upload-trigger:hover { color: #fff; }
textarea { flex: 1; background: transparent; border: none; color: #fff; font-size: 14px; height: 44px; padding: 12px; resize: none; font-family: inherit; }

/* === 🔥 6. 控制台与弹窗 (找回了丢失的逻辑) === */
.control-panel {
    position: absolute; bottom: 30px; left: 50%; transform: translateX(-50%);
    width: 850px; max-width: 95%;
    background: #181818; border: 1px solid #333; border-radius: 24px; padding: 15px 20px;
    box-shadow: 0 40px 80px rgba(0,0,0,0.8); z-index: 500;
}

.toolbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.tool-group { display: flex; gap: 8px; align-items: center; }

.pill {
    background: #252525; color: #aaa; padding: 6px 14px; border-radius: 20px;
    font-size: 12px; cursor: pointer; border: 1px solid transparent; transition: 0.3s;
    display: flex; align-items: center; gap: 6px; position: relative;
}
.pill:hover { color: #fff; border-color: transparent; background: linear-gradient(90deg, #333 0%, #555 100%); }
.pill.active { background: #222; border-color: #666; color: #fff; box-shadow: 0 0 10px rgba(255,255,255,0.05); }
.pill.active::after { content: ''; width: 4px; height: 4px; background: var(--primary); border-radius: 50%; }

#balance { color: var(--primary); font-weight: bold; }

/* 上传预览区域 */
.upload-expand-area {
    display: none; margin-bottom: 10px; padding: 0 5px;
    gap: 10px; overflow-x: auto; align-items: center; min-height: 70px;
}
.upload-expand-area.show { display: flex; }

.thumb-item { 
    width: 60px; height: 60px; border-radius: 8px; border: 1px solid #333; 
    position: relative; overflow: hidden; flex-shrink: 0; cursor: grab; background: #000;
}
.thumb-item:active { cursor: grabbing; border-color: var(--primary); }
.thumb-img { width: 100%; height: 100%; object-fit: cover; }

.del-btn { 
    position: absolute; top: 2px; right: 2px; width: 16px; height: 16px; 
    background: rgba(0,0,0,0.8); color: #fff; border-radius: 50%;
    display: flex; align-items: center; justify-content: center; 
    font-size: 10px; cursor: pointer; opacity: 0; transition: 0.2s;
}
.del-btn:hover { background: #ff4d4f; }
.thumb-item:hover .del-btn { opacity: 1; }

/* === 🔥 7. 弹窗与Toast (最关键的部分，找回了！) === */
.modal-overlay { 
    position: fixed; top: 0; left: 0; width: 100%; height: 100%; 
    background: rgba(0,0,0,0.8); z-index: 4000; /* 层级极高，防止被挡住 */
    display: none; justify-content: center; align-items: center; 
    backdrop-filter: blur(5px); 
}
.modal-box { 
    background: #111; border: 1px solid #333; width: 500px; max-height: 80vh; 
    border-radius: 12px; padding: 30px; position: relative; 
    display: flex; flex-direction: column; 
}
.modal-close { position: absolute; top: 15px; right: 20px; font-size: 20px; cursor: pointer; color: #666; }
.modal-title { font-size: 18px; font-weight: bold; margin-bottom: 20px; color: #52FF00; }

/* 修复点：强制隐藏滚动条但保留功能 */
.modal-content { 
    font-size: 13px; color: #ccc; line-height: 1.6; 
    overflow-y: auto; white-space: pre-wrap; text-align: left; 
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE 10+ */
}
.modal-content::-webkit-scrollbar { display: none; /* Chrome/Safari */ }

.ratio-popup {
    position: absolute; bottom: 50px; left: 0; background: #1A1A1A;
    border: 1px solid #333; border-radius: 16px; padding: 12px;
    display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px;
    opacity: 0; transform: translateY(10px) scale(0.95); pointer-events: none;
    transition: 0.2s; box-shadow: 0 20px 50px rgba(0,0,0,0.8); z-index: 600;
}
.ratio-popup.show { opacity: 1; transform: translateY(0) scale(1); pointer-events: auto; }
.ratio-item {
    width: 50px; height: 36px; background: #111; border: 1px solid #333;
    border-radius: 6px; display: flex; align-items: center; justify-content: center;
    font-size: 10px; color: #666; cursor: pointer; transition: 0.2s;
}
.ratio-item:hover { background: var(--primary-gradient); color: #000; border-color: transparent; font-weight: bold; }

.toast-container {
    position: fixed; top: 30px; left: 50%; transform: translateX(-50%);
    z-index: 9999; display: flex; flex-direction: column; gap: 10px; pointer-events: none;
}
.toast {
    background: rgba(20, 20, 20, 0.95);
    border: 1px solid #333; border-left: 4px solid #52FF00;
    color: #fff; padding: 12px 24px; border-radius: 8px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.6);
    font-size: 14px; display: flex; align-items: center; gap: 10px;
    animation: slideDown 0.3s cubic-bezier(0.2, 0.8, 0.2, 1) forwards, fadeOut 0.5s ease 2.5s forwards;
    pointer-events: auto; backdrop-filter: blur(10px);
}
.toast.error { border-left-color: #ff4d4f; }

.loading-ph {
    background-color: #111 !important; 
    border: 1px dashed #333; border-radius: 12px;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    color: #666; font-size: 14px; min-width: 200px;
}
.loading-ph.failed { background-color: #111 !important; border-color: #ff4d4f; color: #ff4d4f; }
.loading-ph.spinning::after {
    content: ''; width: 30px; height: 30px; border: 3px solid transparent; 
    border-top-color: var(--primary); border-radius: 50%; animation: spin 1s infinite; margin-bottom: 10px;
}
.loading-ph.spinning::before { content: '正在处理...'; margin-bottom: 10px; color: #888; }
.loading-ph.failed::after { display: none; }
.loading-ph.failed::before { content: '处理失败'; color: #ff4d4f; }
@keyframes spin { 100% { transform: rotate(360deg); } }
@keyframes slideDown { from { opacity: 0; transform: translateY(-20px); } to { opacity: 1; transform: translateY(0); } }
@keyframes fadeOut { to { opacity: 0; transform: translateY(-10px); } }

/* =========================================
   🔥 8. 首页画廊卡片 (仿抖音/小红书风格) - 最新添加
   ========================================= */

/* 卡片容器 */
.gallery-item {
    position: relative;
    overflow: hidden;
    border-radius: 12px;
    background: #000;
    cursor: pointer;
    border: 1px solid #222;
    transition: all 0.3s;
}
.gallery-item:hover {
    border-color: var(--primary);
    transform: translateY(-4px);
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
}

/* 遮罩层 */
.gallery-overlay {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background: linear-gradient(to top, rgba(0,0,0,0.9) 0%, rgba(0,0,0,0.4) 40%, transparent 100%);
    opacity: 0;
    transition: opacity 0.3s ease;
    display: flex;
    flex-direction: column;
    justify-content: flex-end; /* 内容沉底 */
    padding: 15px;
    z-index: 10;
}

.gallery-item:hover .gallery-overlay { opacity: 1; }

/* 底部信息栏 */
.card-info-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    margin-bottom: 12px;
    color: #fff;
}

/* 作者信息 */
.author-box {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: bold;
}
.author-avatar {
    width: 20px; height: 20px;
    border-radius: 50%;
    border: 1px solid #fff;
}

/* 点赞信息 */
.like-box {
    font-size: 12px;
    color: #ddd;
    display: flex;
    align-items: center;
    gap: 4px;
}

/* 宽屏按钮：仿图2样式 */
.make-btn-wide {
    width: 100%;
    height: 36px;
    background: rgba(255, 255, 255, 0.15); /* 半透明白 */
    backdrop-filter: blur(5px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    color: #fff;
    font-size: 13px;
    font-weight: bold;
    cursor: pointer;
    transition: 0.2s;
}
.make-btn-wide:hover {
    background: var(--primary); /* 悬停变老夜绿 */
    color: #000;
    border-color: var(--primary);
}