.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-files {
    display: grid;
    gap: 10px;
    max-height: 320px;
    overflow-y: auto;
}

.gallery-selected-row {
    display: grid;
    gap: 8px;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 10px;
}

.gallery-selected-info {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    overflow-wrap: anywhere;
}

.gallery-selected-row-header {
    display: flex;
    min-width: 0;
    align-items: flex-start;
    gap: 8px;
}

.gallery-selected-row-header .gallery-selected-info {
    flex: 1;
    min-width: 0;
}

.gallery-remove-selected {
    flex: 0 0 40px;
    width: 40px;
    height: 40px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--bg-2);
    color: var(--text);
    cursor: pointer;
    font-size: 24px;
    line-height: 1;
}

.gallery-remove-selected:hover {
    border-color: var(--danger, #f87171);
    color: var(--danger, #f87171);
}

.gallery-selected-row label {
    display: grid;
    gap: 5px;
    color: var(--muted);
    font-size: 12px;
}

.gallery-validation {
    margin: 0;
    color: var(--danger, #f87171);
    font-size: 13px;
}

.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);
    min-width: 0;
}

.gallery-thumb {
    display: block;
    height: 280px;
}

.gallery-card-body {
    display: grid;
    gap: 10px;
}

.gallery-card-body > form:last-child {
    justify-self: start;
}

.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-image-selection-summary {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.product-image-picker[hidden] {
    display: none;
}

.product-image-picker {
    margin-top: 0.75rem;
}

.product-image-picker-grid {
    margin-top: 0.75rem;
    max-height: 420px;
    overflow-y: auto;
    padding: 4px;
}

.product-image-picker-card {
    cursor: pointer;
    min-width: 0;
    position: relative;
}

.product-image-picker-card .gallery-thumb { height: 168px; }
.product-image-picker-card .image-fade-card__content { bottom: 10px; inset-inline: 10px; }
.product-image-picker-card .image-fade-card__content h4 { font-size: 12px; }
.product-image-picker-grid { grid-template-columns: repeat(auto-fill, minmax(min(100%, 180px), 1fr)); }

.product-image-picker-card[hidden] {
    display: none;
}

.product-image-picker-card:has(input:checked) {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px var(--primary-light);
}

.product-image-picker-radio {
    block-size: 1px;
    inline-size: 1px;
    opacity: 0;
    position: absolute;
}

.product-image-picker-radio:focus-visible + .gallery-thumb,
.product-image-picker-card:focus-within {
    outline: 3px solid var(--primary);
    outline-offset: 2px;
}

.product-image-picker-none { display: block; min-height: 0; }

.product-image-picker-none .gallery-card-body {
    min-height: 168px;
    align-items: center;
    display: flex;
    justify-content: center;
}

.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: 12px;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 180px), 1fr));
}

.product-gallery-option {
    background: var(--bg-2);
    border: 1px solid var(--line);
    border-radius: 14px;
    cursor: pointer;
    display: block;
    min-width: 0;
    overflow: hidden;
    position: relative;
}

.product-gallery-option:has(input:checked) {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px var(--primary-light);
}

.product-gallery-option > img {
    display: block;
    height: 168px;
    object-fit: cover;
    width: 100%;
}

.product-gallery-option > span:last-child {
    bottom: 10px;
    color: #fff;
    inset-inline: 10px;
    position: absolute;
    text-shadow: 0 1px 2px rgb(0 0 0 / .5);
    z-index: 2;
}

.product-gallery-option::after {
    background: var(--image-card-fade);
    content: "";
    inset: 25% 0 0;
    pointer-events: none;
    position: absolute;
}

.product-gallery-option:has(input:focus-visible) {
    outline: 3px solid var(--primary);
    outline-offset: 2px;
}

.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;
    overflow-wrap: anywhere;
    white-space: normal;
}

.product-gallery-placeholder,
.product-image-placeholder {
    color: var(--muted);
    font-size: 0.75rem;
}

.product-gallery-none {
    align-items: center;
    display: flex;
    justify-content: center;
    min-height: 168px;
    padding: 12px;
}

.product-gallery-none::after { display: none; }
.product-gallery-none > span:last-child { position: static; text-align: center; text-shadow: none; z-index: auto; }
.product-gallery-option input {
    block-size: 1px;
    inline-size: 1px;
    opacity: 0;
    position: absolute;
}

.product-list-thumbnail {
    display: block;
}
