/* Reset & Base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --secondary: #8b5cf6;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --bg: #0f172a;
    --bg-secondary: #1e293b;
    --bg-tertiary: #334155;
    --text: #f1f5f9;
    --text-secondary: #cbd5e1;
    --border: #475569;
    --shadow: rgba(0, 0, 0, 0.3);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

/* Header */
.header {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    padding: 1rem 0;
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(10px);
}

.container {
    max-width: 1920px;
    margin: 0 auto;
    padding: 0 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
}

/* 响应式容器宽度 */
@media (min-width: 1920px) {
    .container {
        max-width: 95%;
    }
}

@media (min-width: 2560px) {
    .container {
        max-width: 90%;
    }
}

.logo {
    font-size: 1.5rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    white-space: nowrap;
    flex-shrink: 0;
}

.nav-tabs {
    display: flex;
    gap: 0.5rem;
    flex-shrink: 0;
}

.nav-tab {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 0.5rem 1.5rem;
    cursor: pointer;
    border-radius: 0.5rem;
    font-size: 1rem;
    transition: all 0.2s;
}

.nav-tab:hover {
    background: var(--bg-tertiary);
    color: var(--text);
}

.nav-tab.active {
    background: var(--primary);
    color: white;
}

/* Main Content - 响应式宽度 */
.main-content {
    max-width: 1920px;
    margin: 0 auto;
    padding: 2rem;
}

@media (min-width: 1920px) {
    .main-content {
        max-width: 95%;
    }
}

@media (min-width: 2560px) {
    .main-content {
        max-width: 90%;
    }
}

.tab-panel {
    display: none;
}

.tab-panel.active {
    display: block;
    max-width: 1920px;
    margin: 0 auto;
    padding: 1rem;
}

/* 超大屏幕优化 */
@media (min-width: 1920px) {
    .tab-panel.active {
        max-width: 95%;
    }
}

@media (min-width: 2560px) {
    .tab-panel.active {
        max-width: 90%;
    }
}

/* Create Layout - 响应式 */
.create-layout {
    display: grid;
    grid-template-columns: minmax(350px, 400px) 1fr;
    gap: 2rem;
    min-height: calc(100vh - 200px);
    max-width: 1920px;
    margin: 0 auto;
    padding: 0 1rem;
}

@media (min-width: 1920px) {
    .create-layout {
        max-width: 95%;
        grid-template-columns: minmax(400px, 450px) 1fr;
    }
}

@media (min-width: 2560px) {
    .create-layout {
        max-width: 90%;
        grid-template-columns: minmax(450px, 500px) 1fr;
    }
}

/* Prompt Editor */
.prompt-editor {
    background: var(--bg-secondary);
    border-radius: 1rem;
    padding: 2rem;
    height: fit-content;
    position: sticky;
    top: 100px;
    overflow-y: auto;
    max-height: calc(100vh - 120px);
}

.prompt-editor::-webkit-scrollbar {
    width: 8px;
}

.prompt-editor::-webkit-scrollbar-track {
    background: var(--bg-tertiary);
    border-radius: 4px;
}

.prompt-editor::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

.prompt-editor h2 {
    margin-bottom: 1.5rem;
    font-size: 1.25rem;
}

.section {
    margin-bottom: 1.5rem;
}

.section label {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.section input,
.section textarea,
.section select {
    width: 100%;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    padding: 0.75rem;
    color: var(--text);
    font-size: 0.875rem;
    transition: all 0.2s;
}

.section input:focus,
.section textarea:focus,
.section select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.section textarea {
    resize: vertical;
    font-family: inherit;
}

/* Buttons */
.btn-primary,
.btn-secondary {
    width: 100%;
    padding: 0.875rem;
    border: none;
    border-radius: 0.5rem;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 30px rgba(99, 102, 241, 0.3);
}

.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text);
}

.btn-secondary:hover {
    background: var(--border);
}

/* Prompt Preview */
.prompt-preview {
    background: var(--bg);
    border-radius: 0.5rem;
    padding: 1rem;
}

.preview-box {
    font-size: 0.875rem;
    color: var(--text-secondary);
    line-height: 1.8;
    min-height: 60px;
}

/* Generation Preview */
.generation-preview {
    background: var(--bg-secondary);
    border-radius: 1rem;
    padding: 2rem;
    min-height: 600px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.empty-state {
    text-align: center;
    color: var(--text-secondary);
}

.empty-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.empty-state h3 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
    color: var(--text);
}

/* Generated Images */
.generated-images {
    width: 100%;
}

.generated-images h3 {
    margin-bottom: 1rem;
    font-size: 1.25rem;
}

.image-grid {
    display: grid;
    gap: 1rem;
}

.generated-item {
    background: var(--bg);
    border-radius: 0.75rem;
    overflow: hidden;
    transition: transform 0.2s;
}

.generated-item:hover {
    transform: scale(1.02);
}

.generated-item img {
    width: 100%;
    height: auto;
    display: block;
}

.generated-item-info {
    padding: 1rem;
}

.generated-item-info p {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.generated-item-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 1rem;
}

.btn-small {
    flex: 1;
    padding: 0.5rem;
    border: none;
    border-radius: 0.375rem;
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-favorite {
    background: var(--warning);
    color: white;
}

.btn-favorite.active {
    background: var(--danger);
}

.btn-delete {
    background: var(--bg-tertiary);
    color: var(--text);
}

.btn-delete:hover {
    background: var(--danger);
    color: white;
}

/* Gallery */
.gallery-header,
.prompts-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.gallery-title-section {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.gallery-title-section h2 {
    font-size: 1.5rem;
    font-weight: 600;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin: 0;
    white-space: nowrap;
}

.upload-btn {
    font-size: 0.875rem !important;
    padding: 0.5rem 1rem !important;
    width: auto !important;
    white-space: nowrap;
}

.filters {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.filters select {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    padding: 0.5rem 1rem;
    color: var(--text);
    cursor: pointer;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
}

.checkbox-label input {
    cursor: pointer;
}

/* Gallery Grid - 瀑布流布局容器 */
.gallery-grid {
    position: relative;
    width: 100%;
    min-height: 400px;
    padding: 1rem;
    /* 不再使用 grid 布局，改用 JS 控制的绝对定位 */
}

/* 瀑布流项目 */
.gallery-item {
    cursor: pointer;
    position: absolute;
    /* 移除 overflow: hidden，防止图片被裁剪 */
    border-radius: 2px;
    outline: 1px solid rgba(255, 255, 255, 0.12);
    background: var(--bg-tertiary);
    transition: all 0.3s ease;
    will-change: transform;
}

.gallery-item img {
    width: 100%;
    height: auto;
    display: block;
    transition: all 0.2s ease;
    background: var(--bg-tertiary);
    border-radius: 2px; /* 图片本身有圆角 */
}

.gallery-item:hover {
    outline-color: rgba(255, 255, 255, 0.4);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.gallery-item:hover img {
    filter: brightness(1.1);
}

.favorite-badge {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    background: rgba(0, 0, 0, 0.7);
    padding: 0.25rem 0.5rem;
    border-radius: 0.375rem;
    font-size: 1.25rem;
}

/* Like Button */
.like-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-secondary);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border-radius: 2rem;
    font-size: 0.875rem;
    transition: all 0.2s;
}

.like-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.2);
    color: var(--text);
    transform: translateY(-1px);
}

.like-btn.liked {
    background: rgba(239, 68, 68, 0.15);
    border-color: #ef4444;
    color: #ef4444;
}

.like-btn.liked:hover {
    background: rgba(239, 68, 68, 0.25);
    border-color: #dc2626;
    color: #dc2626;
}

.like-btn .heart-icon {
    font-size: 1.125rem;
    transition: transform 0.2s;
    line-height: 1;
}

.like-btn.liked .heart-icon {
    transform: scale(1.2);
    animation: heartBeat 0.3s ease;
}

@keyframes heartBeat {
    0%, 100% { transform: scale(1.2); }
    50% { transform: scale(1.4); }
}

.like-count {
    font-weight: 600;
    font-size: 0.9rem;
    min-width: 1.5rem;
    text-align: center;
}

.gallery-item-info {
    padding: 1rem;
}

.gallery-item-info h4 {
    font-size: 0.875rem;
    margin-bottom: 0.5rem;
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.gallery-item-meta {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-bottom: 0.75rem;
}

.tag {
    font-size: 0.75rem;
    padding: 0.25rem 0.5rem;
    background: var(--bg-tertiary);
    border-radius: 0.25rem;
    color: var(--text-secondary);
}

.gallery-item-actions {
    display: flex;
    gap: 0.5rem;
}

/* Prompts List */
.prompts-list {
    display: grid;
    gap: 1rem;
}

.prompt-card {
    background: var(--bg-secondary);
    border-radius: 0.75rem;
    padding: 1.5rem;
    transition: all 0.2s;
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: 1.5rem;
    height: 400px; /* 固定高度，能容纳8张图片和完整内容 */
    overflow: hidden;
}

.prompt-card:hover {
    box-shadow: 0 4px 12px var(--shadow);
}

.prompt-card-left {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.prompt-card h3 {
    font-size: 1.125rem;
    margin-bottom: 0.75rem;
}

.prompt-card-content {
    display: grid;
    gap: 0.5rem;
    margin-bottom: 1rem;
    flex: 1;
    overflow: hidden;
}

.prompt-row {
    display: flex;
    gap: 1rem;
    font-size: 0.875rem;
}

.prompt-label {
    color: var(--text-secondary);
    min-width: 80px;
}

.prompt-value {
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2; /* 最多显示2行 */
    line-clamp: 2; /* 标准属性 */
    -webkit-box-orient: vertical;
    line-height: 1.4;
}

.prompt-card-actions {
    display: flex;
    gap: 0.5rem;
}

.btn-use {
    background: var(--primary);
    color: white;
}

/* Prompt Works Gallery */
.prompt-works-gallery {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
    background: var(--bg);
    border-radius: 0.5rem;
    padding: 0.5rem;
}

.prompt-work-item {
    aspect-ratio: 1;
    border-radius: 0.375rem;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
}

.prompt-work-item:hover {
    transform: scale(1.05);
    z-index: 1;
}

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

/* Add work button */
.prompt-work-add {
    background: rgba(255, 255, 255, 0.03);
    border: 2px dashed rgba(255, 255, 255, 0.2);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    transition: all 0.2s;
}

.prompt-work-add:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: var(--primary);
    transform: scale(1.05);
}

.add-work-icon {
    font-size: 2rem;
    color: var(--primary);
    font-weight: 300;
    line-height: 1;
}

.add-work-text {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

/* Delete work button */
.delete-work-btn {
    position: absolute;
    top: 0.25rem;
    right: 0.25rem;
    width: 1.5rem;
    height: 1.5rem;
    border-radius: 50%;
    background: rgba(239, 68, 68, 0.9);
    color: white;
    border: none;
    cursor: pointer;
    font-size: 1.25rem;
    line-height: 1;
    display: none;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    padding: 0;
    font-weight: bold;
}

.prompt-work-item:hover .delete-work-btn {
    display: flex;
}

.delete-work-btn:hover {
    background: rgba(239, 68, 68, 1);
}

/* More works overlay */
.prompt-work-more {
    position: relative;
}

.more-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.prompt-work-more:hover .more-overlay {
    background: rgba(0, 0, 0, 0.8);
}

.more-count {
    font-size: 2rem;
    font-weight: 600;
    color: white;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

.prompt-works-empty {
    grid-column: 1 / -1;
    text-align: center;
    padding: 2rem;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.prompt-works-more {
    grid-column: 1 / -1;
    text-align: center;
    padding: 0.5rem;
}

.prompt-works-more button {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 0.375rem;
    padding: 0.5rem 1rem;
    color: var(--text);
    cursor: pointer;
    font-size: 0.875rem;
    transition: all 0.2s;
}

.prompt-works-more button:hover {
    background: var(--bg);
    border-color: var(--primary);
}

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

/* Search Box */
.search-box {
    position: relative;
}

.search-box input {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    padding: 0.5rem 1rem;
    color: var(--text);
    width: 300px;
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

.loading-overlay p {
    margin-top: 1rem;
    font-size: 1.125rem;
    color: var(--text);
}

/* Toast */
.toast {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    background: var(--success);
    color: white;
    padding: 1rem 1.5rem;
    border-radius: 0.5rem;
    box-shadow: 0 10px 30px var(--shadow);
    transform: translateY(200%);
    transition: transform 0.3s;
    z-index: 1001;
}

.toast.show {
    transform: translateY(0);
}

.toast.error {
    background: var(--danger);
}

/* Photo Upload */
.photo-preview-container {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
    min-height: 100px;
}

.photo-preview-item {
    background: var(--bg);
    border: 2px solid var(--border);
    border-radius: 0.5rem;
    aspect-ratio: 1;
    overflow: hidden;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

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

.photo-preview-item .remove-photo {
    position: absolute;
    top: 0.25rem;
    right: 0.25rem;
    background: rgba(0, 0, 0, 0.8);
    border: none;
    color: white;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.875rem;
    transition: all 0.2s;
}

.photo-preview-item .remove-photo:hover {
    background: var(--danger);
    transform: scale(1.1);
}

.photo-preview-empty {
    border: 2px dashed var(--border);
    background: transparent;
    color: var(--text-secondary);
    font-size: 1.5rem;
    opacity: 0.5;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background: var(--bg-secondary);
    border-radius: 1rem;
    max-width: 900px;
    width: 90%;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem;
    border-bottom: 1px solid var(--border);
}

.modal-header h2 {
    margin: 0;
}

.modal-close {
    background: transparent;
    border: none;
    color: var(--text);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.5rem;
    line-height: 1;
}

.modal-close:hover {
    color: var(--danger);
}

.modal-body {
    padding: 1.5rem;
    overflow-y: auto;
}

.photo-library-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 1rem;
}

.photo-library-item {
    background: var(--bg);
    border-radius: 0.5rem;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.2s;
    border: 2px solid transparent;
}

.photo-library-item:hover {
    transform: scale(1.05);
    border-color: var(--primary);
}

.photo-library-item.selected {
    border-color: var(--success);
}

.photo-library-item img {
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
}

.photo-library-item-info {
    padding: 0.5rem;
}

.photo-library-item-info p {
    margin: 0;
    font-size: 0.75rem;
    color: var(--text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Settings */
.settings-container {
    max-width: 800px;
    margin: 0 auto;
}

.settings-container h2 {
    margin-bottom: 2rem;
    font-size: 1.75rem;
}

.settings-section {
    background: var(--bg-secondary);
    border-radius: 0.75rem;
    padding: 2rem;
    margin-bottom: 2rem;
}

.settings-section h3 {
    font-size: 1.25rem;
    margin-bottom: 1rem;
}

.settings-description {
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
    line-height: 1.6;
}

.setting-item {
    margin-bottom: 1.5rem;
}

.setting-item label {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.setting-item input,
.setting-item select {
    width: 100%;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    padding: 0.75rem;
    color: var(--text);
    font-size: 0.875rem;
    font-family: inherit;
}

.setting-item input[type="password"],
.setting-item input[type="text"] {
    flex: 1;
    min-width: 0;
}

.setting-item input:focus,
.setting-item select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.info-grid {
    display: grid;
    gap: 1rem;
}

.info-item {
    display: flex;
    justify-content: space-between;
    padding: 0.75rem;
    background: var(--bg);
    border-radius: 0.5rem;
}

.info-label {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.info-value {
    color: var(--text);
    font-weight: 500;
}

/* Multi-user additions */
.user-section {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-shrink: 0;
    min-width: 0;
}

.quota-badge {
    background: rgba(99, 102, 241, 0.2);
    border: 1px solid var(--primary);
    border-radius: 1rem;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--primary);
    white-space: nowrap;
}

.membership-badge {
    background: rgba(139, 92, 246, 0.2);
    border: 1px solid var(--secondary);
    border-radius: 1rem;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--secondary);
    text-decoration: none;
    white-space: nowrap;
    transition: all 0.2s;
}

.membership-badge:hover {
    background: rgba(139, 92, 246, 0.3);
    transform: translateY(-1px);
}

.user-menu-wrap {
    position: relative;
}

.user-menu-btn {
    background: var(--bg-tertiary);
    border: none;
    border-radius: 0.5rem;
    padding: 0.5rem 1rem;
    color: var(--text);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    transition: all 0.2s;
}

.user-menu-btn:hover {
    background: var(--border);
}

.dropdown-arrow {
    font-size: 0.625rem;
    transition: transform 0.2s;
}

.user-menu-wrap.active .dropdown-arrow {
    transform: rotate(180deg);
}

.user-menu-dropdown {
    position: absolute;
    top: calc(100% + 0.5rem);
    right: 0;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    min-width: 150px;
    box-shadow: 0 10px 30px var(--shadow);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.2s;
    z-index: 1000;
}

.user-menu-wrap.active .user-menu-dropdown {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.user-menu-dropdown button {
    width: 100%;
    background: transparent;
    border: none;
    color: var(--text);
    padding: 0.75rem 1rem;
    text-align: left;
    cursor: pointer;
    font-size: 0.875rem;
    transition: background 0.2s;
}

.user-menu-dropdown button:hover {
    background: var(--bg-tertiary);
}

.user-menu-dropdown button:first-child {
    border-radius: 0.5rem 0.5rem 0 0;
}

.user-menu-dropdown button:last-child {
    border-radius: 0 0 0.5rem 0.5rem;
}

/* Responsive */
@media (max-width: 1024px) {
    .create-layout {
        grid-template-columns: 1fr;
    }

    .prompt-editor {
        position: static;
        max-height: none;
    }

    .gallery-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    .gallery-header,
    .prompts-header {
        flex-direction: column;
        align-items: stretch;
        gap: 1.5rem;
    }

    .gallery-title-section {
        justify-content: space-between;
        width: 100%;
    }

    .gallery-title-section h2 {
        font-size: 1.25rem;
    }
}

@media (max-width: 768px) {
    .container {
        padding: 0 1rem;
        gap: 0.5rem;
    }

    .main-content {
        padding: 1rem;
    }

    .logo {
        font-size: 1.25rem;
    }

    .nav-tabs {
        gap: 0.25rem;
    }

    .nav-tab {
        padding: 0.375rem 0.75rem;
        font-size: 0.875rem;
    }

    .filters {
        flex-direction: column;
        align-items: stretch;
        gap: 0.75rem;
    }

    .filters select {
        width: 100%;
    }

    .user-section {
        gap: 0.5rem;
    }

    .quota-badge,
    .membership-badge {
        font-size: 0.75rem;
        padding: 0.375rem 0.75rem;
    }

    .user-menu-btn {
        font-size: 0.8rem;
        padding: 0.375rem 0.75rem;
    }
}

@media (max-width: 640px) {
    .gallery-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.75rem;
    }

    .logo {
        font-size: 1.1rem;
    }

    .nav-tab {
        padding: 0.3rem 0.6rem;
        font-size: 0.8rem;
    }

    .quota-badge,
    .membership-badge {
        font-size: 0.7rem;
        padding: 0.3rem 0.6rem;
    }

    .user-menu-btn {
        font-size: 0.75rem;
        padding: 0.3rem 0.6rem;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 0 0.5rem;
        gap: 0.25rem;
    }

    .main-content {
        padding: 0.75rem;
    }

    .gallery-grid {
        grid-template-columns: 1fr 1fr;
        gap: 0.5rem;
    }

    .logo {
        font-size: 1rem;
    }

    .nav-tab {
        padding: 0.25rem 0.5rem;
        font-size: 0.75rem;
    }

    .quota-badge,
    .membership-badge {
        font-size: 0.65rem;
        padding: 0.25rem 0.5rem;
    }

    .user-menu-btn {
        font-size: 0.7rem;
        padding: 0.25rem 0.5rem;
    }

    .user-section {
        gap: 0.25rem;
    }
}

/* ==================== Image Viewer Modal ==================== */
.image-viewer-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.2s ease;
}

.image-viewer-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.9);
    cursor: pointer;
}

.image-viewer-content {
    position: relative;
    max-width: 90vw;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    z-index: 1;
    animation: zoomIn 0.3s ease;
}

.image-viewer-content img {
    max-width: 90vw;
    max-height: 80vh;
    object-fit: contain;
    border-radius: 0.5rem;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.image-viewer-caption {
    background: rgba(0, 0, 0, 0.8);
    padding: 0.75rem 1.5rem;
    border-radius: 2rem;
    color: var(--text);
    font-size: 0.875rem;
    max-width: 600px;
    text-align: center;
}

.image-viewer-close {
    position: absolute;
    top: -3rem;
    right: 0;
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.image-viewer-close:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: rotate(90deg);
}

@keyframes zoomIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* ==================== Image Viewer Comments ==================== */

.image-viewer-comments {
    width: 100%;
    max-width: 600px;
    margin-top: 1.5rem;
    background: rgba(0, 0, 0, 0.8);
    border-radius: 0.75rem;
    padding: 1.5rem;
}

.comments-header {
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.comments-header h3 {
    margin: 0;
    font-size: 1.125rem;
    color: var(--text);
}

.comments-list {
    max-height: 300px;
    overflow-y: auto;
    margin-bottom: 1rem;
}

.comment-item {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 0.5rem;
    padding: 0.875rem;
    margin-bottom: 0.75rem;
}

.comment-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.comment-author {
    font-weight: 600;
    color: var(--primary);
    font-size: 0.875rem;
}

.comment-time {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.comment-content {
    color: var(--text);
    line-height: 1.6;
    font-size: 0.875rem;
    word-wrap: break-word;
}

.comment-delete {
    margin-top: 0.5rem;
    background: rgba(239, 68, 68, 0.2);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #ef4444;
    padding: 0.25rem 0.75rem;
    border-radius: 0.25rem;
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.2s;
}

.comment-delete:hover {
    background: rgba(239, 68, 68, 0.3);
}

.comment-form {
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    padding-top: 1rem;
}

.comment-form textarea {
    width: 100%;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 0.5rem;
    padding: 0.75rem;
    color: var(--text);
    font-size: 0.875rem;
    resize: vertical;
    min-height: 60px;
    font-family: inherit;
}

.comment-form textarea:focus {
    outline: none;
    border-color: var(--primary);
    background: rgba(255, 255, 255, 0.08);
}

.comment-form textarea::placeholder {
    color: var(--text-secondary);
}

/* ==================== Work Detail Fullscreen (Midjourney style) ==================== */

.work-detail-sidebar {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 10000;
    display: none;
    background: rgba(0, 0, 0, 0.95);
}

.work-detail-sidebar.active {
    display: flex;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.sidebar-overlay {
    position: absolute;
    inset: 0;
    background: transparent;
    cursor: pointer;
}

.sidebar-content {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: row;
    z-index: 1;
    pointer-events: none;
}

.sidebar-close {
    position: fixed;
    top: 1.5rem;
    right: 1.5rem;
    width: 3rem;
    height: 3rem;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.7);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    z-index: 10001;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    pointer-events: all;
}

.sidebar-close:hover {
    background: rgba(0, 0, 0, 0.9);
    transform: rotate(90deg);
    border-color: rgba(255, 255, 255, 0.3);
}

.sidebar-image {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 3rem;
    pointer-events: none;
}

.sidebar-image img {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 0.5rem;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.sidebar-info {
    width: 420px;
    background: var(--bg);
    overflow-y: auto;
    padding: 3rem 2rem;
    pointer-events: all;
    border-left: 1px solid rgba(255, 255, 255, 0.05);
}

.sidebar-section {
    margin-bottom: 2rem;
}

.sidebar-section h3 {
    font-size: 1.125rem;
    margin-bottom: 0.75rem;
    color: var(--text);
}

.sidebar-section h4 {
    font-size: 0.875rem;
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
    font-weight: 600;
}

.prompt-text {
    color: var(--text);
    line-height: 1.8;
    font-size: 0.95rem;
}

.sidebar-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.sidebar-tags .tag {
    padding: 0.375rem 0.875rem;
    background: rgba(99, 102, 241, 0.15);
    color: var(--primary);
    border-radius: 1rem;
    font-size: 0.8125rem;
    font-weight: 500;
}

.sidebar-actions {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.action-btn {
    padding: 0.75rem 1.5rem;
    border: 1px solid var(--border);
    background: var(--bg-tertiary);
    color: var(--text);
    border-radius: 0.5rem;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.9rem;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.action-btn:hover {
    background: var(--border);
    transform: translateY(-1px);
}

.action-btn.liked {
    background: rgba(239, 68, 68, 0.15);
    border-color: #ef4444;
    color: #ef4444;
}

#sidebarFavoriteBtn.active {
    background: rgba(251, 191, 36, 0.15);
    border-color: #fbbf24;
    color: #fbbf24;
}

/* Sidebar comments styling */
.sidebar-section .comments-list {
    max-height: 400px;
    overflow-y: auto;
    margin-bottom: 1rem;
    padding-right: 0.5rem;
}

.sidebar-section .comment-item {
    background: var(--bg-tertiary);
    padding: 1rem;
    border-radius: 0.5rem;
    margin-bottom: 0.75rem;
}

.sidebar-section .comment-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.sidebar-section .comment-author {
    font-weight: 600;
    color: var(--primary);
    font-size: 0.875rem;
}

.sidebar-section .comment-time {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.sidebar-section .comment-content {
    color: var(--text);
    line-height: 1.6;
    font-size: 0.875rem;
}

.sidebar-section .comment-delete {
    margin-top: 0.5rem;
    background: rgba(239, 68, 68, 0.2);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #ef4444;
    padding: 0.25rem 0.75rem;
    border-radius: 0.25rem;
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.2s;
}

.sidebar-section .comment-delete:hover {
    background: rgba(239, 68, 68, 0.3);
}

.sidebar-section .comment-form {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.sidebar-section .comment-form textarea {
    width: 100%;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    padding: 0.75rem;
    color: var(--text);
    font-size: 0.875rem;
    resize: vertical;
    min-height: 80px;
    font-family: inherit;
}

.sidebar-section .comment-form textarea:focus {
    outline: none;
    border-color: var(--primary);
}

.sidebar-section .comment-form .btn-primary {
    align-self: flex-start;
    padding: 0.625rem 1.25rem;
    font-size: 0.875rem;
}

/* Responsive design for work detail */
@media (max-width: 1024px) {
    .sidebar-content {
        flex-direction: column;
    }

    .sidebar-image {
        flex: 0 0 auto;
        max-height: 50vh;
        padding: 2rem;
    }

    .sidebar-info {
        width: 100%;
        flex: 1;
        padding: 2rem 1.5rem;
        border-left: none;
        border-top: 1px solid rgba(255, 255, 255, 0.05);
    }
}

/* Responsive Gallery */
@media (max-width: 640px) {
    .gallery-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* 已使用 auto-fill 自适应列数，不需要固定列数的媒体查询 */

/* Responsive Sidebar */
@media (max-width: 768px) {
    .sidebar-close {
        top: 1rem;
        right: 1rem;
        width: 2.5rem;
        height: 2.5rem;
    }

    .sidebar-image {
        padding: 1.5rem;
    }

    .sidebar-info {
        padding: 1.5rem 1rem;
    }
}


/* Modern Pagination */
.pagination-modern {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 2rem;
    padding: 1.5rem 1rem;
    flex-wrap: wrap;
}

.pagination-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 1rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.pagination-btn svg {
    transition: transform 0.2s ease;
}

.pagination-btn:hover:not(:disabled) {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

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

.pagination-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    background: rgba(255, 255, 255, 0.02);
}

.pagination-prev:hover:not(:disabled) svg {
    transform: translateX(-2px);
}

.pagination-next:hover:not(:disabled) svg {
    transform: translateX(2px);
}

/* Page Numbers */
.pagination-pages {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.pagination-page {
    min-width: 2.25rem;
    height: 2.25rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 0.5rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.pagination-page:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.2);
    transform: translateY(-1px);
}

.pagination-page.active {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
    cursor: default;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.4);
}

.pagination-page.active:hover {
    transform: none;
}

.pagination-ellipsis {
    min-width: 2.25rem;
    height: 2.25rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    font-size: 0.875rem;
    user-select: none;
}

/* Page Info */
.pagination-info {
    font-size: 0.875rem;
    color: var(--text-secondary);
    padding: 0 0.75rem;
    white-space: nowrap;
}

/* Responsive */
@media (max-width: 640px) {
    .pagination-modern {
        gap: 0.375rem;
        padding: 1rem 0.5rem;
    }
    
    .pagination-btn span {
        display: none;
    }
    
    .pagination-btn {
        padding: 0.625rem;
        min-width: 2.25rem;
        justify-content: center;
    }
    
    .pagination-info {
        width: 100%;
        text-align: center;
        order: -1;
        margin-bottom: 0.5rem;
    }
}


/* Modal Overlay */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    padding: 2rem;
}

.modal-content {
    background: var(--bg-secondary);
    border-radius: 1rem;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    max-width: 90vw;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.modal-header {
    padding: 1.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-header h3 {
    margin: 0;
    font-size: 1.25rem;
}

.modal-close {
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: var(--text-primary);
    font-size: 1.5rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.modal-close:hover {
    background: rgba(255, 68, 68, 0.8);
    transform: scale(1.1);
}

.modal-body {
    padding: 1.5rem;
    overflow-y: auto;
}


/* ========================================
   会员相关样式
   ======================================== */

/* 用户区域 */
.user-section {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* 配额徽章 */
.quota-badge {
    padding: 8px 16px;
    background: var(--bg-tertiary);
    border-radius: 20px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s;
    border: 1px solid var(--border);
}

.quota-badge:hover {
    background: var(--bg);
    border-color: var(--primary);
}

.quota-badge.warning {
    background: rgba(245, 158, 11, 0.1);
    border-color: var(--warning);
    color: var(--warning);
}

.quota-badge.danger {
    background: rgba(239, 68, 68, 0.1);
    border-color: var(--danger);
    color: var(--danger);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

/* 会员徽章 */
.membership-badge {
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    transition: all 0.3s;
    display: inline-block;
    border: 1px solid transparent;
}

.membership-badge.free {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    border-color: var(--border);
}

.membership-badge.free:hover {
    background: var(--bg);
    border-color: var(--primary);
    color: var(--primary);
}

.membership-badge.standard {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.membership-badge.standard:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.membership-badge.premium {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    color: white;
}

.membership-badge.premium:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(240, 147, 251, 0.4);
}

/* 用户菜单 */
.user-menu-wrap {
    position: relative;
}

.user-menu-btn {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 8px 16px;
    border-radius: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    transition: all 0.3s;
}

.user-menu-btn:hover {
    background: var(--bg);
    border-color: var(--primary);
}

.dropdown-arrow {
    font-size: 10px;
    transition: transform 0.3s;
}

.user-menu-wrap.active .dropdown-arrow {
    transform: rotate(180deg);
}

.user-menu-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 12px;
    min-width: 200px;
    box-shadow: 0 4px 20px var(--shadow);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.3s;
    z-index: 1000;
}

.user-menu-wrap.active .user-menu-dropdown {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.menu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: var(--text);
    text-decoration: none;
    background: transparent;
    border: none;
    width: 100%;
    text-align: left;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 14px;
}

.menu-item:hover {
    background: var(--bg-tertiary);
}

.menu-item:first-child {
    border-radius: 12px 12px 0 0;
}

.menu-item:last-child {
    border-radius: 0 0 12px 12px;
}

.menu-icon {
    font-size: 16px;
}

.menu-divider {
    height: 1px;
    background: var(--border);
    margin: 4px 0;
}

/* 配额不足提示 */
.quota-warning-toast {
    position: fixed;
    top: 80px;
    right: 20px;
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    color: white;
    padding: 16px 24px;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
    z-index: 10000;
    animation: slideIn 0.3s ease-out;
    max-width: 300px;
}

.quota-warning-toast .toast-title {
    font-weight: 600;
    margin-bottom: 8px;
}

.quota-warning-toast .toast-message {
    font-size: 14px;
    margin-bottom: 12px;
}

.quota-warning-toast .toast-action {
    background: white;
    color: #f5576c;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.3s;
}

.quota-warning-toast .toast-action:hover {
    transform: translateY(-2px);
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

@keyframes slideIn {
    from {
        transform: translateX(400px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* 响应式 */
@media (max-width: 768px) {
    .user-section {
        gap: 8px;
    }

    .quota-badge,
    .membership-badge,
    .user-menu-btn {
        padding: 6px 12px;
        font-size: 12px;
    }

    .membership-badge {
        display: none; /* 移动端隐藏会员徽章 */
    }
}
