.gallery {
    --gallery-columns: 2;
    display: grid;
    grid-template-columns: repeat(var(--gallery-columns), minmax(0, 1fr));
    gap: 8px;
    width: 100%;
    touch-action: pan-y;
}

.media-card {
    width: 100%;
    aspect-ratio: 1 / 1;
    border-radius: 16px;
    border: none;
    background: transparent;
    box-shadow: 0 10px 22px rgba(0, 0, 0, 0.18);
    overflow: hidden;
    position: relative;
}

.media-card.is-pending .media-thumb {
    cursor: default;
}

.media-card.is-pending {
    position: relative;
}

.pending-badge {
    position: absolute;
    top: 8px;
    right: 8px;
    z-index: 2;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #f59e42;
    pointer-events: none;
    box-shadow: 0 0 10px rgba(245, 158, 66, 0.5), 0 2px 6px rgba(0, 0, 0, 0.3);
}

.video-badge {
    position: absolute;
    bottom: 6px;
    left: 6px;
    z-index: 2;
    display: flex;
    align-items: center;
    gap: 3px;
    padding: 2px 6px;
    border-radius: 6px;
    background: rgba(0, 0, 0, 0.55);
    color: #fff;
    font-size: 11px;
    font-weight: 600;
    line-height: 1.2;
    letter-spacing: 0.3px;
    pointer-events: none;
    font-variant-numeric: tabular-nums;
}

.video-badge-icon {
    width: 10px;
    height: 10px;
    flex-shrink: 0;
}

.media-thumb {
    display: block;
    width: 100%;
    height: 100%;
    border: 0;
    border-radius: inherit;
    background: transparent;
    padding: 0;
    cursor: pointer;
    overflow: hidden;
}

.media-thumb img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.scroll-sentinel {
    grid-column: 1 / -1;
    height: 1px;
    display: block;
    visibility: hidden;
    pointer-events: none;
}

@media (min-width: 700px) {
    .gallery {
        --gallery-columns: 3;
        gap: 10px;
    }
}

@media (min-width: 980px) {
    .gallery {
        --gallery-columns: 5;
        gap: 12px;
    }
}

/* ─── Upload Sheet ─────────────────────────────────────────────────────── */

.upload-sheet-overlay {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    background: rgba(4, 10, 20, 0.62);
    backdrop-filter: blur(6px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 260ms ease;
}

.upload-sheet-overlay.visible {
    opacity: 1;
    pointer-events: auto;
}

.upload-sheet {
    width: min(100%, 480px);
    max-height: 88vh;
    display: flex;
    flex-direction: column;
    border-radius: 24px 24px 0 0;
    background:
        linear-gradient(180deg, rgba(14, 25, 42, 0.98), rgba(10, 18, 30, 0.98));
    border: 1px solid rgba(163, 184, 208, 0.12);
    border-bottom: none;
    box-shadow: 0 -8px 40px rgba(0, 0, 0, 0.4);
    transform: translateY(100%);
    transition: transform 320ms cubic-bezier(0.32, 0.72, 0, 1);
}

.upload-sheet.visible {
    transform: translateY(0);
}

.upload-sheet-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 18px 12px;
    flex-shrink: 0;
}

.upload-sheet-title {
    font-size: 1.1rem;
    font-weight: 760;
    color: #dce6f2;
    letter-spacing: -0.01em;
}

.upload-sheet-close {
    appearance: none;
    border: none;
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-muted);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    font-size: 1.3rem;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 140ms ease, color 140ms ease;
}

.upload-sheet-close:hover {
    background: rgba(255, 255, 255, 0.12);
    color: var(--text);
}

.upload-sheet-close.is-disabled {
    opacity: 0.3;
    pointer-events: none;
}

.upload-sheet-list {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 0 16px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.upload-sheet-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 8px;
    border-radius: 14px;
    transition: background 200ms ease, opacity 300ms ease;
}

.upload-sheet-item.is-done {
    opacity: 0.5;
}

.upload-sheet-item.is-error {
    background: rgba(255, 107, 107, 0.06);
}

/* Poster */

.upload-sheet-poster {
    width: 48px;
    height: 48px;
    border-radius: 10px;
    overflow: hidden;
    flex-shrink: 0;
    background: rgba(255, 255, 255, 0.04);
}

.upload-sheet-poster-img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.upload-sheet-poster-fallback {
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(94, 167, 255, 0.12);
    color: rgba(94, 167, 255, 0.6);
}

.upload-sheet-poster-fallback svg {
    width: 22px;
    height: 22px;
}

/* Info */

.upload-sheet-info {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.upload-sheet-filename {
    font-size: 0.88rem;
    font-weight: 600;
    color: #dce6f2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.upload-sheet-status {
    font-size: 0.78rem;
    font-weight: 500;
    line-height: 1.2;
}

.upload-sheet-status.is-queued {
    color: var(--text-muted);
}

.upload-sheet-status.is-uploading {
    color: #8fd2ff;
}

.upload-sheet-status.is-confirming {
    color: #c4b5fd;
}

.upload-sheet-status.is-done {
    color: #6ee7b7;
}

.upload-sheet-status.is-error {
    color: #ff8a8a;
}

/* Ring */

.upload-sheet-ring {
    width: 32px;
    height: 32px;
    flex-shrink: 0;
}

.upload-sheet-ring-svg {
    display: block;
    width: 100%;
    height: 100%;
}

.upload-sheet-ring-track {
    fill: none;
    stroke: rgba(255, 255, 255, 0.08);
    stroke-width: 2.5;
}

.upload-sheet-ring-track.is-done {
    stroke: rgba(110, 231, 183, 0.2);
}

.upload-sheet-ring-track.is-error {
    stroke: rgba(255, 138, 138, 0.2);
}

.upload-sheet-ring-fill {
    fill: none;
    stroke: #8fd2ff;
    stroke-width: 2.5;
    stroke-linecap: round;
    stroke-dasharray: 81.68; /* 2 * π * 13 */
    stroke-dashoffset: calc(81.68 - (81.68 * var(--progress, 0)) / 100);
    transform: rotate(-90deg);
    transform-origin: center;
    transition: stroke-dashoffset 300ms ease;
}

.upload-sheet-check {
    fill: none;
    stroke: #6ee7b7;
    stroke-width: 2.5;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.upload-sheet-cross {
    stroke: #ff8a8a;
    stroke-width: 2.5;
    stroke-linecap: round;
}

/* Footer */

.upload-sheet-footer {
    padding: 12px 18px 18px;
    text-align: center;
    font-size: 0.78rem;
    color: var(--text-muted);
    flex-shrink: 0;
    transition: color 300ms ease;
}

.upload-sheet-footer.is-done {
    color: #6ee7b7;
}
