body {
    font-family: sans-serif;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px;
}

.controls {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    align-items: center;
    margin-bottom: 20px;
    padding: 15px;
    border: 1px solid #ccc;
    border-radius: 5px;
}

.controls label, .controls fieldset {
    margin-right: 5px;
}

.controls fieldset {
    border: none;
    padding: 0;
    margin: 0;
    display: flex;
    gap: 10px;
}

#downloadArea {
    margin: 15px 0;
    text-align: center;
    padding: 10px;
    background-color: #f8f8f8;
    border-radius: 5px;
    width: 90%;
    max-width: 1200px;
}

#downloadLink {
    display: inline-block;
    padding: 10px 20px;
    background-color: #4CAF50;
    color: white;
    text-decoration: none;
    border-radius: 4px;
    font-weight: bold;
}

#downloadLink:hover {
    background-color: #45a049;
}

.preview-area {
    margin-top: 20px;
    width: 90%;
    max-width: 1200px;
    border: 1px solid #ccc;
    position: relative;
    overflow: hidden;
    -webkit-user-select: none;
    user-select: none;
}

#imageContainer {
    position: relative;
    width: fit-content;
    margin: auto;
    cursor: grab;
    touch-action: none;
    -webkit-user-select: none;
    user-select: none;
    padding-bottom: 40px;
}

#uploadedImage {
    display: block; /* Remove extra space below image */
    max-width: 100%; /* Ensure image fits within preview area width */
    height: auto;
}

#cropGrid {
    position: absolute;
    top: 0;
    left: 0;
    box-sizing: border-box;
    outline: none;
    pointer-events: none;
    overflow: visible;
}

.slide-grid {
    position: absolute;
    box-sizing: border-box;
    border: 2px solid rgba(255, 0, 0, 0.7);
    background: none;
    pointer-events: none;
}

.slide-divider {
    position: absolute;
    top: 0;
    width: 1px;
    height: 100%;
    background: repeating-linear-gradient(
        to bottom,
        rgba(255,0,0,0.5),
        rgba(255,0,0,0.5) 4px,
        transparent 4px,
        transparent 8px
    );
    z-index: 2;
    pointer-events: none;
}

.subgrid-line {
    position: absolute;
    background: rgba(255,0,0,0.15);
    z-index: 1;
    pointer-events: none;
}

.subgrid-line.horizontal {
    height: 1px;
    width: 100%;
}

.subgrid-line.vertical {
    width: 1px;
    height: 100%;
}

button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Hide the default file input */
input[type="file"] {
   /* Add styling later if desired, e.g., replace with a custom button */
}

/* --- Resize Handle Styles --- */
.resize-handle {
    position: absolute;
    width: 16px;
    height: 16px;
    background-color: rgba(255, 0, 0, 0.8);
    border: 2px solid rgba(255, 255, 255, 0.9);
    border-radius: 2px;
    box-sizing: border-box;
    transform: translate(-50%, -50%);
    z-index: 10;
    pointer-events: auto;
}

/* Hide resize handles on mobile devices */
@media (hover: none) and (pointer: coarse) {
    .resize-handle {
        display: none;
    }
}

.handle-tl {
    top: 0;
    left: 0;
    cursor: nwse-resize;
}

.handle-tr {
    top: 0;
    right: 0;
    transform: translate(50%, -50%); /* Adjust transform for right side */
    cursor: nesw-resize;
}

.handle-bl {
    bottom: 0;
    left: 0;
    transform: translate(-50%, 50%); /* Adjust transform for bottom side */
    cursor: nesw-resize;
}

.handle-br {
    bottom: 0;
    right: 0;
    transform: translate(50%, 50%); /* Adjust transform for corner */
    cursor: nwse-resize;
}

.handle-t {
    top: 0;
    left: 50%;
    cursor: ns-resize;
}

.handle-b {
    bottom: 0;
    left: 50%;
    transform: translate(-50%, 50%); /* Adjust transform for bottom side */
    cursor: ns-resize;
}

.handle-l {
    top: 50%;
    left: 0;
    transform: translate(-50%, -50%); /* Adjust transform for left side */
    cursor: ew-resize;
}

.handle-r {
    top: 50%;
    right: 0;
    transform: translate(50%, -50%); /* Adjust transform for right side */
    cursor: ew-resize;
}
/* --------------------------- */ 

.mobile-unsupported-popup,
#mobileUnsupported {
    display: none;
}

.slide-label {
    font-family: monospace;
    margin-top: 2px;
    text-shadow: 0 1px 2px #000;
    position: absolute;
    pointer-events: none;
    white-space: nowrap;
} 