* {
    box-sizing: border-box;
}

body {
    margin: 20px;
    font-family: Arial, sans-serif;
    background: #f3f3f3;
}

.controls {
    display: flex;
    flex-wrap: wrap;
    align-items: end;
    gap: 14px;
    margin-bottom: 20px;
}

.controls label {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 13px;
}

.controls input,
.controls select,
.controls button {
    padding: 8px 10px;
    font-size: 14px;
}

.controls button {
    cursor: pointer;
}

.workspace {
    display: flex;
    gap: 24px;
    align-items: flex-start;
}

.crop-panel {
    width: 520px;
}

#cropCanvas {
    display: block;
    width: 500px;
    height: 500px;
    border: 1px solid #bbb;
    background: #eee;
    cursor: grab;
    user-select: none;
}

#cropCanvas:active {
    cursor: grabbing;
}

.hint {
    margin-top: 8px;
    font-size: 13px;
    color: #666;
}

.print-panel {
    flex: 1;
}

.page {
    width: 210mm;
    min-height: 297mm;
    padding: 10mm;
    background: white;
    border: 1px solid #bbb;

    display: flex;
    flex-wrap: wrap;
    align-content: flex-start;
    gap: 5mm;
}

.photo-item {
    position: relative;
    display: block;
    border: 1px solid #ddd;
    background: white;
}

.photo {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.photo-item.size-2x2 {
    width: 2in;
    height: 2in;
}

.photo-item.size-2x3 {
    width: 2in;
    height: 3in;
}

.photo-item.size-2x4 {
    width: 2in;
    height: 4in;
}

.photo-item.size-3x2 {
    width: 3in;
    height: 2in;
}

.photo-item.size-4x2 {
    width: 4in;
    height: 2in;
}

.photo-item.size-4x4 {
    width: 4in;
    height: 4in;
}

.remove-photo {
    position: absolute;
    top: 4px;
    right: 4px;
    display: none;
    padding: 4px 6px;
    font-size: 12px;
    border: 1px solid #999;
    background: white;
    cursor: pointer;
}

.photo-item:hover .remove-photo {
    display: block;
}

@media (max-width: 1200px) {
    .workspace {
        flex-direction: column;
    }

    .crop-panel {
        width: 100%;
    }

    .page {
        width: 100%;
        min-height: auto;
    }
}

@media print {

    body {
        margin: 0;
        background: white;
    }

    .controls,
    .crop-panel,
    .hint,
    .remove-photo {
        display: none;
    }

    .workspace {
        display: block;
    }

    .print-panel {
        width: 100%;
    }

    .page {
        width: 210mm;
        min-height: 297mm;
        margin: 0;
        padding: 10mm;
        border: none;
        gap: 5mm;
        page-break-after: always;
    }

    @page {
        size: A4;
        margin: 0;
    }
}
