* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: Arial, sans-serif;
    background-color: #000;
    color: #fff;
    padding: 20px;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
}

h1 {
    text-align: center;
    margin-bottom: 30px;
    font-size: 2em;
}

.controls {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
    margin-bottom: 30px;
    padding: 20px;
    background: #2a2a2a;
    border-radius: 8px;
    justify-content: center;
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.control-group label {
    font-size: 0.9em;
    color: #999;
}

.control-group input,
.control-group select {
    padding: 8px 12px;
    background: #000;
    border: 1px solid #333;
    color: #fff;
    border-radius: 4px;
    font-size: 1em;
}

.control-group input:focus,
.control-group select:focus {
    outline: none;
    border-color: #666;
}

#photoUpload {
    display: none;
}

.upload-btn {
    padding: 10px 20px;
    background: #333;
    border: 1px solid #555;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.3s;
}

.upload-btn:hover {
    background: #555;
}

.action-btn {
    padding: 10px 20px;
    background: #fff;
    color: #000;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
    transition: background 0.3s;
}

.action-btn:hover {
    background: #ddd;
}

.grid {
    display: grid;
    gap: 10px;
    grid-template-columns: repeat(3, 1fr);
    background: #fff;
    padding: 10px;
    border-radius: 4px;
}

.grid-item {
    position: relative;
    background: #f0f0f0;
    border: 2px solid transparent;
    border-radius: 4px;
    overflow: hidden;
    cursor: move;
    aspect-ratio: 1;
}

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

.grid-item .controls-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    background: rgba(0, 0, 0, 0.7);
    padding: 5px;
    display: flex;
    gap: 5px;
    opacity: 0;
    transition: opacity 0.3s;
}

.grid-item:hover .controls-overlay {
    opacity: 1;
}

.grid-item button {
    padding: 5px 10px;
    background: #fff;
    color: #000;
    border: none;
    border-radius: 3px;
    cursor: pointer;
    font-size: 0.8em;
}

.grid-item button:hover {
    background: #ddd;
}

.grid-item.dragging {
    opacity: 0.5;
}

.grid-item.drag-over {
    border-color: #000;
}

.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.9);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: #2a2a2a;
    padding: 30px;
    border-radius: 8px;
    max-width: 90%;
    max-height: 90%;
    overflow: auto;
}

.modal-content h2 {
    margin-bottom: 20px;
}

#cropContainer {
    position: relative;
    display: inline-block;
    margin: 20px auto;
    background: #000;
    cursor: crosshair;
}

#cropCanvas {
    display: block;
    max-width: 800px;
    max-height: 600px;
}

.crop-selection {
    position: absolute;
    border: 2px solid #fff;
    box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.5);
    cursor: move;
}

.crop-handle {
    position: absolute;
    width: 12px;
    height: 12px;
    background: #fff;
    border: 2px solid #000;
    border-radius: 50%;
}

.crop-handle.nw { top: -6px; left: -6px; cursor: nw-resize; }
.crop-handle.ne { top: -6px; right: -6px; cursor: ne-resize; }
.crop-handle.sw { bottom: -6px; left: -6px; cursor: sw-resize; }
.crop-handle.se { bottom: -6px; right: -6px; cursor: se-resize; }
.crop-handle.n { top: -6px; left: 50%; margin-left: -6px; cursor: n-resize; }
.crop-handle.s { bottom: -6px; left: 50%; margin-left: -6px; cursor: s-resize; }
.crop-handle.w { top: 50%; left: -6px; margin-top: -6px; cursor: w-resize; }
.crop-handle.e { top: 50%; right: -6px; margin-top: -6px; cursor: e-resize; }

.modal-buttons {
    display: flex;
    gap: 10px;
    margin-top: 20px;
    justify-content: center;
}

.modal-buttons button {
    padding: 10px 30px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1em;
}

#cropSaveBtn {
    background: #fff;
    color: #000;
    font-weight: bold;
}

#cropCancelBtn {
    background: #333;
    color: #fff;
}

.preview-modal {
    max-width: 95%;
}

#previewCanvas {
    max-width: 100%;
    max-height: 70vh;
    display: block;
    margin: 20px auto;
    border: 1px solid #333;
    background: #fff;
}

#closePreviewBtn {
    display: block;
    margin: 20px auto 0;
    padding: 10px 30px;
    background: #fff;
    color: #000;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
}