.gallery-layout {
    display: grid;
    gap: 16px;
}

.gallery-upload-form {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(280px, 1fr);
    align-items: stretch;
    gap: 20px;
}

.gallery-upload-form .field {
    margin: 0;
}

.gallery-upload-drop {
    position: relative;
}

.gallery-file-input {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.gallery-drop-zone {
    display: flex;
    min-height: 260px;
    padding: 28px;
    border: 2px dashed var(--line);
    border-radius: 16px;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 10px;
    background: rgba(255, 255, 255, .035);
    cursor: pointer;
    text-align: center;
    transition: border-color .2s ease, background .2s ease, transform .2s ease;
}

.gallery-drop-zone:hover,
.gallery-drop-zone.is-drag-over {
    border-color: var(--brand);
    background: rgba(94, 234, 212, .09);
}

.gallery-drop-zone.is-drag-over {
    transform: translateY(-2px);
}

.gallery-file-input:focus-visible + .gallery-drop-zone {
    outline: 3px solid var(--brand-2);
    outline-offset: 3px;
}

.gallery-drop-title {
    color: var(--text);
    font-size: 20px;
    font-weight: 700;
}

.gallery-drop-action {
    color: var(--brand);
    font-weight: 700;
}

.gallery-drop-help,
.gallery-upload-note {
    color: var(--muted);
    font-size: 12px;
    line-height: 1.6;
}

.gallery-selected-file {
    max-width: 100%;
    margin-top: 6px;
    padding: 7px 11px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--bg-2);
    color: var(--text);
    font-size: 12px;
    overflow-wrap: anywhere;
}

.gallery-upload-controls {
    display: flex;
    min-width: 0;
    flex-direction: column;
    justify-content: center;
    gap: 14px;
}

.gallery-upload-controls .btn {
    align-self: flex-start;
}

.gallery-upload-note {
    margin: 0;
}

.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 16px;
}

.gallery-card {
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--bg-2);
}

.gallery-thumb {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 190px;
    padding: 10px;
    background: rgba(255, 255, 255, .04);
}

.gallery-thumb img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.gallery-card-body {
    display: grid;
    gap: 10px;
    padding: 14px;
}

.gallery-card-body h4 {
    margin: 0;
    overflow-wrap: anywhere;
}

.gallery-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 12px;
    color: var(--muted);
    font-size: 11px;
}

.gallery-rename-form {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
}

.gallery-empty {
    padding: 36px 16px;
    border: 1px dashed var(--line);
    border-radius: 12px;
    color: var(--muted);
    text-align: center;
}

@media (max-width: 780px) {
    .gallery-upload-form {
        grid-template-columns: 1fr;
    }

    .gallery-drop-zone {
        min-height: 180px;
        padding: 22px;
    }

    .gallery-upload-controls .btn {
        width: 100%;
    }
}

.product-gallery-field {
    border: 0;
    margin: 1.25rem 0 0;
    padding: 0;
}

.product-gallery-field legend {
    color: var(--text-1);
    font-weight: 700;
    margin-bottom: 0.65rem;
}

.product-gallery-optional {
    color: var(--muted);
    font-size: 0.75rem;
    font-weight: 500;
}

.product-gallery-options {
    display: grid;
    gap: 0.75rem;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
}

.product-gallery-option {
    align-items: center;
    background: var(--bg-1);
    border: 1px solid var(--border);
    border-radius: 10px;
    cursor: pointer;
    display: grid;
    gap: 0.45rem;
    grid-template-columns: auto 48px minmax(0, 1fr);
    min-height: 66px;
    padding: 0.55rem;
}

.product-gallery-option:has(input:checked) {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px var(--primary-light);
}

.product-gallery-option img,
.product-list-thumbnail,
.saved-product-thumbnail {
    background: var(--bg-2);
    border-radius: 8px;
    height: 48px;
    object-fit: cover;
    width: 48px;
}

.product-gallery-option > span:last-child {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.product-gallery-placeholder,
.product-image-placeholder {
    color: var(--muted);
    font-size: 0.75rem;
}

.product-gallery-none {
    grid-template-columns: auto minmax(0, 1fr);
}

.product-list-thumbnail {
    display: block;
}
