:root {
    --gallery-bg: #0a0a0f;
    --gallery-card-bg: #141419;
    --gallery-card-hover: #1a1a22;
    --gallery-accent: #6366f1;
    --gallery-accent-secondary: #a855f7;
    --gallery-accent-glow: rgba(99, 102, 241, 0.25);
    --gallery-text: #f4f4f5;
    --gallery-text-muted: #71717a;
    --gallery-success: #10b981;
    --gallery-pending: #f59e0b;
    --gallery-border: rgba(255, 255, 255, 0.06);
}

body {
    margin: 0;
}

.gallery-page {
    min-height: 100vh;
    background: var(--gallery-bg);
    padding: 0;
}

.gallery-header {
    display: flex;
    align-items: center;
    gap: 1.25rem;
    padding: 2rem 3rem;
    border-bottom: 1px solid var(--gallery-border);
    position: relative;
    overflow: hidden;
}

.gallery-header-accent {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--gallery-accent), var(--gallery-accent-secondary), transparent 70%);
}

.gallery-back-link {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: var(--gallery-card-bg);
    border: 1px solid var(--gallery-border);
    color: var(--gallery-text-muted);
    text-decoration: none;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.gallery-back-link:hover {
    background: var(--gallery-card-hover);
    color: var(--gallery-text);
    border-color: var(--gallery-accent);
}

.gallery-back-link svg {
    width: 20px;
    height: 20px;
}

.gallery-header-text {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.gallery-label {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    color: var(--gallery-accent);
}

.gallery-title {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--gallery-text);
    margin: 0;
    letter-spacing: -0.025em;
}

.gallery-content {
    padding: 2.5rem 3rem;
}

.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
}

.gallery-card {
    background: var(--gallery-card-bg);
    border-radius: 16px;
    overflow: hidden;
    border: 1px solid var(--gallery-border);
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
}

.gallery-card::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 16px;
    padding: 1px;
    background: linear-gradient(135deg, transparent 40%, var(--gallery-accent) 100%);
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    opacity: 0;
    transition: opacity 0.25s ease;
    pointer-events: none;
}

.gallery-card:hover {
    transform: translateY(-6px);
    background: var(--gallery-card-hover);
    box-shadow: 0 24px 48px -12px rgba(0, 0, 0, 0.6);
}

.gallery-card:hover::before {
    opacity: 1;
}

.gallery-card-image-container {
    position: relative;
    aspect-ratio: 16/10;
    background: #0d0d12;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.gallery-card-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0;
    transition: opacity 0.4s ease, transform 0.4s ease;
}

.gallery-card-image.loaded {
    opacity: 1;
}

.gallery-card:hover .gallery-card-image.loaded {
    transform: scale(1.03);
}

.gallery-card-spinner {
    position: absolute;
    width: 36px;
    height: 36px;
    border: 2px solid var(--gallery-border);
    border-top-color: var(--gallery-accent);
    border-radius: 50%;
    animation: gallery-spin 0.7s linear infinite;
}

.gallery-card-spinner.hidden {
    display: none;
}

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

.gallery-card-pending-icon {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    color: var(--gallery-text-muted);
}

.gallery-card-pending-icon svg {
    width: 40px;
    height: 40px;
    opacity: 0.4;
    animation: pulse-glow 2s ease-in-out infinite;
}

@keyframes pulse-glow {
    0%, 100% { opacity: 0.4; }
    50% { opacity: 0.7; }
}

.gallery-card-pending-icon span {
    font-size: 0.8rem;
    font-weight: 500;
    letter-spacing: 0.02em;
}

.gallery-card-info {
    padding: 1.25rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.gallery-card-date {
    font-size: 0.8rem;
    color: var(--gallery-text-muted);
}

.gallery-card-status {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.35rem 0.7rem;
    border-radius: 6px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.gallery-card-status.completed {
    background: rgba(16, 185, 129, 0.12);
    color: var(--gallery-success);
}

.gallery-card-status.pending {
    background: rgba(245, 158, 11, 0.12);
    color: var(--gallery-pending);
}

.gallery-card-status-dot {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: currentColor;
}

.gallery-popup-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(12px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    padding: 2rem;
}

.gallery-popup-overlay.active {
    opacity: 1;
    visibility: visible;
}

.gallery-popup {
    background: var(--gallery-card-bg);
    border-radius: 20px;
    border: 1px solid var(--gallery-border);
    max-width: 880px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    transform: scale(0.96) translateY(16px);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.gallery-popup-overlay.active .gallery-popup {
    transform: scale(1) translateY(0);
}

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

.gallery-popup-title {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--gallery-text);
    margin: 0;
}

.gallery-popup-date {
    font-size: 0.8rem;
    color: var(--gallery-text-muted);
    margin: 0.25rem 0 0;
}

.gallery-popup-close {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    border: 1px solid var(--gallery-border);
    background: transparent;
    color: var(--gallery-text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.gallery-popup-close:hover {
    background: var(--gallery-card-hover);
    color: var(--gallery-text);
    border-color: var(--gallery-accent);
}

.gallery-popup-body {
    padding: 2rem;
}

.gallery-popup-style-weight {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.1), rgba(168, 85, 247, 0.1));
    border: 1px solid rgba(99, 102, 241, 0.2);
    border-radius: 12px;
    margin-bottom: 2rem;
}

.gallery-popup-style-weight-label {
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--gallery-text);
}

.gallery-popup-style-weight-value {
    font-size: 1.25rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--gallery-accent), var(--gallery-accent-secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.gallery-popup-section {
    margin-bottom: 2rem;
}

.gallery-popup-section:last-child {
    margin-bottom: 0;
}

.gallery-popup-section-title {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--gallery-text-muted);
    margin-bottom: 1rem;
}

.gallery-popup-inputs {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
}

.gallery-popup-image-wrapper {
    position: relative;
    aspect-ratio: 1;
    background: #0d0d12;
    border-radius: 12px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.gallery-popup-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0;
    transition: opacity 0.4s ease;
}

.gallery-popup-image.loaded {
    opacity: 1;
}

.gallery-popup-image-label {
    position: absolute;
    bottom: 0.75rem;
    left: 0.75rem;
    padding: 0.35rem 0.65rem;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(4px);
    border-radius: 5px;
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--gallery-text);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.gallery-popup-output-wrapper {
    position: relative;
    aspect-ratio: 16/10;
    background: #0d0d12;
    border-radius: 12px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.gallery-popup-output-image {
    width: 100%;
    height: 100%;
    object-fit: contain;
    opacity: 0;
    transition: opacity 0.4s ease, transform 0.2s ease;
    cursor: pointer;
}

.gallery-popup-output-image.loaded {
    opacity: 1;
}

.gallery-popup-output-image.loaded:hover {
    transform: scale(1.02);
}

.gallery-popup-click-hint {
    position: absolute;
    bottom: 1rem;
    right: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.85rem;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    border-radius: 8px;
    color: var(--gallery-text);
    font-size: 0.75rem;
    font-weight: 500;
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 0.3s ease, transform 0.3s ease;
    pointer-events: none;
}

.gallery-popup-click-hint svg {
    width: 16px;
    height: 16px;
}

.gallery-popup-click-hint.visible {
    opacity: 1;
    transform: translateY(0);
}

.gallery-popup-output-wrapper:hover .gallery-popup-click-hint.visible {
    opacity: 0.6;
}

.gallery-popup-processing {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    padding: 3rem;
    color: var(--gallery-text-muted);
}

.gallery-popup-processing svg {
    width: 56px;
    height: 56px;
    opacity: 0.4;
}

.gallery-popup-processing span {
    font-size: 0.85rem;
    font-weight: 500;
}

.gallery-popup-spinner {
    width: 32px;
    height: 32px;
    border: 2px solid var(--gallery-border);
    border-top-color: var(--gallery-accent);
    border-radius: 50%;
    animation: gallery-spin 0.7s linear infinite;
}

.gallery-download-output-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    width: 100%;
    margin-top: 1rem;
    padding: 1rem 1.5rem;
    background: linear-gradient(135deg, var(--gallery-accent), var(--gallery-accent-secondary));
    border: none;
    border-radius: 12px;
    color: white;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.25s ease;
    box-shadow: 0 4px 20px rgba(99, 102, 241, 0.35);
}

.gallery-download-output-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 30px rgba(99, 102, 241, 0.5);
}

.gallery-download-output-btn:active {
    transform: translateY(0);
}

.gallery-download-output-btn svg {
    width: 22px;
    height: 22px;
}

.gallery-fullscreen-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.95);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    padding: 2rem;
}

.gallery-fullscreen-overlay.active {
    opacity: 1;
    visibility: visible;
}

.gallery-fullscreen-image {
    max-width: 95vw;
    max-height: 90vh;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 25px 80px rgba(0, 0, 0, 0.6);
    transform: scale(0.9);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.gallery-fullscreen-overlay.active .gallery-fullscreen-image {
    transform: scale(1);
}

.gallery-fullscreen-close {
    position: absolute;
    top: 1.5rem;
    right: 1.5rem;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.2);
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(8px);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.gallery-fullscreen-close:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.4);
    transform: scale(1.1);
}

.gallery-fullscreen-download {
    position: absolute;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.9rem 1.75rem;
    background: linear-gradient(135deg, var(--gallery-accent), var(--gallery-accent-secondary));
    border: none;
    border-radius: 50px;
    color: white;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.25s ease;
    box-shadow: 0 8px 32px rgba(99, 102, 241, 0.4);
}

.gallery-fullscreen-download:hover {
    transform: translateX(-50%) translateY(-3px);
    box-shadow: 0 12px 40px rgba(99, 102, 241, 0.55);
}

.gallery-fullscreen-download svg {
    width: 20px;
    height: 20px;
}

.gallery-empty-state {
    text-align: center;
    padding: 6rem 2rem;
    max-width: 360px;
    margin: 0 auto;
}

.gallery-empty-icon {
    width: 72px;
    height: 72px;
    margin: 0 auto 1.5rem;
    opacity: 0.25;
    color: var(--gallery-text-muted);
}

.gallery-empty-title {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--gallery-text);
    margin-bottom: 0.5rem;
}

.gallery-empty-text {
    color: var(--gallery-text-muted);
    font-size: 0.875rem;
}

@media (max-width: 768px) {
    .gallery-header {
        padding: 1.5rem;
    }

    .gallery-content {
        padding: 1.5rem;
    }

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

    .gallery-popup-inputs {
        grid-template-columns: 1fr;
    }

    .gallery-popup-header {
        padding: 1.25rem 1.5rem;
    }

    .gallery-popup-body {
        padding: 1.5rem;
    }
}
