/* ═══════════════════════════════════════════
   Gallery Modal — Centered popup with blur backdrop
   Two-column layout (image left, info right)
   ═══════════════════════════════════════════ */

.gm-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 99999;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    align-items: center;
    justify-content: center;
    animation: gm-fade-in 0.2s ease;
}
.gm-overlay.open { display: flex; }

@keyframes gm-fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

.gm-container {
    display: grid;
    grid-template-columns: 55% 45%;
    width: 90vw;
    max-width: 1200px;
    height: 92vh;
    max-height: 950px;
    border-radius: 20px;
    overflow: hidden;
    box-shadow: 0 25px 80px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(255, 255, 255, 0.08);
    animation: gm-slide-up 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes gm-slide-up {
    from { opacity: 0; transform: translateY(20px) scale(0.97); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

/* ── Left Column: Image Viewer ── */
.gm-viewer {
    position: relative;
    background: #0a0a0f;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.gm-viewer img {
    max-width: 92%;
    max-height: 92%;
    object-fit: contain;
    border-radius: 8px;
    cursor: zoom-in;
    transition: transform 0.3s ease;
}
.gm-viewer img:hover {
    transform: scale(1.02);
}

.gm-compare {
    position: relative;
    width: 92%;
    height: 92%;
    max-width: 100%;
    max-height: 100%;
    overflow: hidden;
    border-radius: 8px;
    cursor: zoom-in;
    background: #050507;
}

.gm-compare-img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    max-width: none !important;
    max-height: none !important;
    object-fit: contain;
    border-radius: 0 !important;
    transform: none !important;
}

.gm-compare-after-wrap {
    position: absolute;
    inset: 0;
    width: 100%;
    overflow: hidden;
    clip-path: inset(0 50% 0 0);
}

.gm-compare-after-wrap .gm-compare-img {
    width: 100%;
}

.gm-compare-range {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: ew-resize;
    z-index: 8;
}

.gm-compare-handle {
    position: absolute;
    top: 50%;
    left: 50%;
    z-index: 7;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.9);
    background: rgba(10, 10, 15, 0.72);
    transform: translate(-50%, -50%);
    pointer-events: none;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.45);
}

.gm-compare-handle::before,
.gm-compare-handle::after {
    content: '';
    position: absolute;
    top: 50%;
    width: 7px;
    height: 7px;
    border-top: 2px solid #fff;
    border-left: 2px solid #fff;
}

.gm-compare-handle::before {
    left: 8px;
    transform: translateY(-50%) rotate(-45deg);
}

.gm-compare-handle::after {
    right: 8px;
    transform: translateY(-50%) rotate(135deg);
}

.gm-compare-label {
    position: absolute;
    top: 14px;
    z-index: 6;
    padding: 5px 9px;
    border-radius: 999px;
    background: rgba(10, 10, 15, 0.72);
    color: #fff;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0;
    pointer-events: none;
}

.gm-compare-label.left { left: 14px; }
.gm-compare-label.right { right: 14px; }

/* Close button */
.gm-close {
    position: absolute;
    top: 16px;
    left: 16px;
    z-index: 50;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    font-size: 1.1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    backdrop-filter: blur(4px);
}
.gm-close:hover { background: rgba(255, 255, 255, 0.25); }

/* Navigation arrows */
.gm-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 40;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    border: none;
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
    font-size: 1.4rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, transform 0.2s;
    backdrop-filter: blur(4px);
}
.gm-nav:hover { background: rgba(255, 255, 255, 0.2); transform: translateY(-50%) scale(1.1); }
.gm-nav.prev { left: 16px; }
.gm-nav.next { right: 16px; }
.gm-nav:disabled { opacity: 0.2; cursor: default; pointer-events: none; }

/* Bottom bar (download + share) */
.gm-bottom-bar {
    position: absolute;
    bottom: 20px;
    left: 0;
    right: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 24px;
}

.gm-bottom-btn {
    padding: 8px 18px;
    border-radius: 20px;
    border: none;
    background: rgba(40, 40, 50, 0.9);
    color: #fff;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: background 0.2s;
    backdrop-filter: blur(4px);
}
.gm-bottom-btn:hover { background: rgba(60, 60, 80, 0.95); }

/* ── Right Column: Info Panel ── */
.gm-info {
    background: #18181b;
    border-left: 1px solid rgba(255, 255, 255, 0.06);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Scrollable content area */
.gm-info-scroll {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
}

/* Header row (avatar + name + date + position) */
.gm-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
}

.gm-creator {
    display: flex;
    align-items: center;
    gap: 12px;
}

.gm-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, #7c3aed, #ec4899);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 700;
    font-size: 1rem;
    flex-shrink: 0;
}

.gm-creator-name {
    color: #fff;
    font-weight: 600;
    font-size: 0.95rem;
}

.gm-creator-date {
    color: #9ca3af;
    font-size: 0.8rem;
    margin-top: 1px;
}

.gm-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.gm-position-badge {
    background: #27272a;
    color: #fff;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.72rem;
    font-weight: 600;
}

.gm-icon-btn {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: none;
    background: transparent;
    color: #9ca3af;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    transition: color 0.2s, background 0.2s;
}
.gm-icon-btn:hover { color: #fff; background: rgba(255, 255, 255, 0.08); }

/* Badges row */
.gm-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.gm-badge {
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 0.72rem;
    font-weight: 600;
    border: none;
}
.gm-badge.type { background: rgba(59, 130, 246, 0.15); color: #60a5fa; }
.gm-badge.model { background: #27272a; color: #d1d5db; }
.gm-badge.theme { cursor: pointer; font: inherit; }
.gm-badge.theme:hover { background: rgba(139, 92, 246, 0.24); color: #fff; }

/* Technical details */
.gm-section-title {
    color: #fff;
    font-weight: 700;
    font-size: 0.85rem;
    margin-bottom: 8px;
}

.gm-detail-row {
    display: flex;
    justify-content: space-between;
    font-size: 0.82rem;
    padding: 3px 0;
}
.gm-detail-row .label { color: #9ca3af; }
.gm-detail-row .value { color: #fff; }

.gm-character-card {
    display: grid;
    grid-template-columns: 150px 1fr;
    gap: 18px;
    align-items: center;
    padding: 12px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.035);
}

.gm-character-preview {
    width: 150px;
    height: 150px;
    padding: 0;
    border: 0;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.06);
    cursor: zoom-in;
    overflow: hidden;
}

.gm-character-preview:focus-visible {
    outline: 2px solid rgba(168, 85, 247, 0.9);
    outline-offset: 2px;
}

.gm-character-card img {
    width: 150px;
    height: 150px;
    object-fit: cover;
    display: block;
    transition: transform 0.18s ease;
}

.gm-character-preview:hover img {
    transform: scale(1.05);
}

.gm-character-title {
    color: #fff;
    font-size: 0.9rem;
    font-weight: 800;
    line-height: 1.25;
}

.gm-character-note {
    margin-top: 4px;
    color: #9ca3af;
    font-size: 0.76rem;
    line-height: 1.4;
}

/* Description — full text, no truncation */
.gm-description {
    color: #d1d5db;
    font-size: 0.82rem;
    line-height: 1.6;
    /* Clamp to ~8 lines and fade the overflow so the buttons below
       always stay visible. Click "Show more" to expand. */
    max-height: 13em;
    overflow: hidden;
    position: relative;
    mask-image: linear-gradient(180deg, #000 70%, transparent 100%);
    -webkit-mask-image: linear-gradient(180deg, #000 70%, transparent 100%);
}
.gm-description.expanded {
    max-height: none;
    mask-image: none;
    -webkit-mask-image: none;
}
.gm-description-toggle {
    display: inline-block;
    margin-top: 8px;
    padding: 4px 10px;
    font-size: 0.72rem;
    font-weight: 600;
    color: #c4b5fd;
    background: rgba(167, 139, 250, 0.12);
    border: 1px solid rgba(167, 139, 250, 0.28);
    border-radius: 999px;
    cursor: pointer;
    transition: background 0.15s ease;
}
.gm-description-toggle:hover { background: rgba(167, 139, 250, 0.22); }

.gm-badges-row {
    display: flex;
    align-items: flex-start;
    gap: 12px;
}
.gm-source-section {
    flex-shrink: 0;
}
.gm-source-thumb {
    position: relative;
    display: block;
    width: 72px;
    height: 72px;
    padding: 0;
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 8px;
    overflow: hidden;
    background: #0a0a14;
    cursor: pointer;
    transition: border-color 0.18s ease, transform 0.12s ease;
}
.gm-source-thumb:hover {
    border-color: rgba(167, 139, 250, 0.6);
}
.gm-source-thumb:active { transform: scale(0.96); }
.gm-source-thumb img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.gm-public-btn.is-public {
    background: rgba(34, 197, 94, 0.18);
    border-color: rgba(34, 197, 94, 0.5);
}
.gm-public-btn:disabled { opacity: 0.5; cursor: progress; }

.gm-source-thumb-label {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 3px 5px;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.85));
    color: #fff;
    font-size: 0.62rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    text-align: center;
    pointer-events: none;
}

/* Action buttons — flow with content */
.gm-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 4px;
    padding-bottom: 4px;
}

.gm-action-btn {
    width: 100%;
    padding: 10px 16px;
    border-radius: 10px;
    border: none;
    font-size: 0.82rem;
    font-weight: 700;
    font-family: 'Inter', sans-serif;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    color: #fff;
    transition: filter 0.2s, transform 0.15s;
}
.gm-action-btn:hover { filter: brightness(1.15); transform: translateY(-1px); }
.gm-action-btn:active { transform: translateY(0); }
.gm-action-btn:disabled { opacity: 0.55; cursor: wait; transform: none; filter: none; }

.gm-action-btn.theme-song { background: linear-gradient(135deg, #7c3aed, #3b82f6); }
.gm-action-btn.similar { background: linear-gradient(135deg, #2563eb, #3b82f6); }
.gm-action-btn.video { background: linear-gradient(135deg, #16a34a, #22c55e); }
.gm-action-btn.upscale { background: linear-gradient(135deg, #7c3aed, #a855f7); }

/* Prompt copy */
.gm-prompt-section {
    position: relative;
}
.gm-copy-btn {
    position: absolute;
    top: 0;
    right: 0;
    padding: 4px 8px;
    border-radius: 4px;
    border: none;
    background: rgba(255, 255, 255, 0.08);
    color: #9ca3af;
    font-size: 0.7rem;
    cursor: pointer;
    transition: all 0.2s;
}
.gm-copy-btn:hover { background: rgba(139, 92, 246, 0.3); color: #fff; }

/* ── Responsive ── */
@media (max-width: 900px) {
    .gm-container {
        grid-template-columns: 1fr;
        grid-template-rows: 45vh 1fr;
        width: 96vw;
        height: 92vh;
        max-height: none;
        border-radius: 14px;
    }
    .gm-viewer img { max-width: 95%; max-height: 95%; }
    .gm-info { border-left: none; border-top: 1px solid rgba(255, 255, 255, 0.06); }
}

/* Zoom overlay */
.gm-zoom-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 100001;
    background:
        radial-gradient(circle at 50% 0%, rgba(55, 65, 81, 0.28), transparent 36%),
        rgba(0, 0, 0, 0.94);
    align-items: center;
    justify-content: center;
    cursor: default;
    overflow: hidden;
    color: #fff;
}
.gm-zoom-overlay.open { display: flex; }

.gm-zoom-topbar {
    position: absolute;
    top: 18px;
    left: 20px;
    right: 20px;
    z-index: 4;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: auto;
}

.gm-zoom-title {
    display: none;
}

.gm-zoom-close {
    position: absolute;
    top: 0;
    right: 0;
    width: 40px;
    height: 40px;
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 50%;
    background: rgba(8, 8, 12, 0.68);
    color: #fff;
    font-size: 1.4rem;
    font-weight: 500;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(14px);
    pointer-events: auto;
}

.gm-zoom-close:hover {
    background: rgba(239, 68, 68, 0.25);
    border-color: rgba(248, 113, 113, 0.45);
}

.gm-zoom-stage {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 84px 24px 28px;
    cursor: grab;
    touch-action: none;
    user-select: none;
}

.gm-zoom-stage img {
    max-width: calc(100vw - 48px);
    max-height: calc(100vh - 120px);
    object-fit: contain;
    cursor: inherit;
    user-select: none;
    touch-action: none;
    transform-origin: center center;
    transition: transform 0.08s ease-out;
    will-change: transform;
}
.gm-zoom-overlay.dragging img {
    cursor: grabbing;
    transition: none;
}

.gm-zoom-overlay.dragging .gm-zoom-stage {
    cursor: grabbing;
}

.gm-zoom-toolbar {
    position: relative;
    left: auto;
    bottom: auto;
    z-index: 4;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    max-width: calc(100vw - 96px);
    padding: 8px 10px;
    border-radius: 999px;
    background: rgba(10, 10, 16, 0.78);
    border: 1px solid rgba(255, 255, 255, 0.12);
    box-shadow: 0 18px 48px rgba(0, 0, 0, 0.48);
    backdrop-filter: blur(18px);
    transform: none;
    overflow: hidden;
    pointer-events: auto;
}

.gm-zoom-group {
    display: contents;
}

.gm-zoom-btn {
    width: 36px;
    height: 34px;
    padding: 0;
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
    font-size: 1rem;
    font-weight: 800;
    font-family: inherit;
    white-space: nowrap;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    transition: background 0.16s ease, border-color 0.16s ease, transform 0.16s ease;
}

.gm-zoom-btn:hover {
    background: rgba(255, 255, 255, 0.16);
    border-color: rgba(255, 255, 255, 0.26);
    transform: translateY(-1px);
}

.gm-zoom-reset {
    width: 58px;
    font-size: 0.72rem;
}

.gm-zoom-readout {
    min-width: 54px;
    padding: 0 8px;
    color: rgba(255, 255, 255, 0.78);
    font-size: 0.78rem;
    font-weight: 900;
    text-align: center;
}

@media (max-width: 720px) {
    .gm-zoom-topbar {
        top: 10px;
        left: 10px;
        right: 10px;
    }
    .gm-zoom-title {
        display: none;
    }
    .gm-zoom-stage {
        padding: 72px 12px 18px;
    }
    .gm-zoom-stage img {
        max-width: calc(100vw - 24px);
        max-height: calc(100vh - 96px);
    }
    .gm-zoom-toolbar {
        justify-content: center;
        border-radius: 999px;
        max-width: calc(100vw - 76px);
    }
    .gm-zoom-btn {
        width: 34px;
        height: 32px;
        font-size: 0.9rem;
    }
    .gm-zoom-readout {
        min-width: 48px;
        font-size: 0.72rem;
    }
}
