#header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

#header input {
    padding: 12px 16px;
    border-radius: var(--border-radius);
    font-size: 16px;
    background-color: var(--bg-color);
    color: var(--text-color);
}

/* grid */
.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 12px;
}

/* slot */
.file-upload {
    position: relative;
    width: 100%;
    padding-top: 50%;
    border: 2px dashed var(--half-color);
    border-radius: var(--border-radius);
    background-size: cover;
    background-position: center;
    color: var(--half-color);
    overflow: hidden;
    transition: padding-top .2s, transform .15s, box-shadow .2s;
    justify-content: center;
    align-items: center;
    cursor: pointer;
}

.file-upload.filled {
    padding-top: 100%;
}

.file-upload input[type=file] {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}

.file-upload:has(input[type="file"]:focus-visible) {
    box-shadow: var(--focus-outline);
}

/* drag-over visual */
.file-upload.drag-over,
.file-upload:hover {
    border: 2px solid var(--blue);
    outline: 2px dashed var(--blue);
    outline-offset: 2px;
    transform: scale(1.04);
    color: var(--blue);
}

.file-upload.small {
    padding: 0;
}

.file-upload.small.filled {
    padding-top: 100%;
}

.file-upload.small.drag-over,
.file-upload.small:hover {
    transform: none;
    outline: none;
    color: var(--blue);
}

#mask-input {
    display: none;
}

/* label */
.slot-label {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    pointer-events: none;
    user-select: none;
}

.file-upload.filled .slot-label {
    opacity: 0;
}

/* X button */
.x-button {
    display: none;
    position: absolute;
    font-family: var(--font-icons);
    top: 5px;
    right: 5px;
    z-index: 2;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    cursor: pointer;
    background: color-mix(in srgb, var(--text-color), transparent 50%);
    color: var(--bg-color);
    justify-content: center;
    align-items: center;
    font-size: 20px;
}

.file-upload.filled .x-button {
    display: flex;
}

.x-button:hover,
.x-button:focus {
    background: var(--red);
    color: #fff;
}

/* history */

.history-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-radius: var(--border-radius);
    background: var(--bg-color);
    cursor: pointer;
}

.disabled .history-item {
    cursor: not-allowed;
    pointer-events: none;
}

.history-item img {
    max-width: 100%;
    border-radius: var(--border-radius);
}

.disabled .history-item img {
    opacity: 0.5;
}

#options-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
    justify-content: space-between;
}

#options-bar select {
    flex: 1;
}

/* output */
#output {
    width: 100%;
    min-height: 320px;
    border-radius: var(--border-radius);
    background: var(--bg-color) center/64px no-repeat;
    display: flex;
    align-items: center;
    justify-content: center;
}

#output img {
    max-width: 100%;
    max-height: 75dvh;
    border-radius: var(--border-radius);
}

/* responsive design */
@media (max-width: 600px) {
    #header {
        flex-direction: column;
        align-items: center;
    }

    #header input {
        width: 100%;
    }
}