/* Apply predictable sizing to every element. */
* {
    box-sizing: border-box;
}

/* Define the overall page appearance. */
body {
    margin: 0;
    padding: 24px;
    background: #eef2f7;
    color: #1e293b;
    font-family: Arial, Helvetica, sans-serif;
}

/* Center the application and restrict its maximum width. */
.application-container {
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
    overflow: hidden;
    background: #ffffff;
    border: 1px solid #dbe3ed;
    border-radius: 14px;
    box-shadow: 0 8px 28px rgba(15, 23, 42, 0.08);
}

/* Style the application heading area. */
.application-header {
    padding: 24px;
    background: #172b45;
    color: #ffffff;
    text-align: center;
}

/* Format the main heading. */
.application-header h1 {
    margin: 0 0 8px;
    font-size: clamp(24px, 4vw, 34px);
}

/* Format the heading description. */
.application-header p {
    margin: 0;
    color: #d5e0ee;
    line-height: 1.6;
}

/* Arrange preview panels and controls in a responsive grid. */
.workspace {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 300px;
    gap: 18px;
    padding: 20px;
    align-items: start;
}

/* Style each preview and controls panel. */
.preview-panel,
.controls-panel {
    min-width: 0;
    padding: 16px;
    border: 1px solid #dbe3ed;
    border-radius: 10px;
    background: #ffffff;
}

/* Format section headings. */
.preview-panel h2,
.controls-panel h2 {
    margin: 0 0 16px;
    font-size: 18px;
}

/* Give image previews a neutral background. */
.image-frame {
    position: relative;
    display: flex;
    min-height: 260px;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    background: #f1f5f9;
    border: 1px dashed #cbd5e1;
    border-radius: 8px;
}

/* Display the original image without cropping it. */
#originalImage {
    display: none;
    width: 100%;
    height: auto;
    max-height: 650px;
    object-fit: contain;
}

/* Display the drawing canvas at its natural aspect ratio. */
#pencilCanvas {
    display: none;
    width: 100%;
    height: auto;
    object-fit: contain;
}

/* Format the placeholder messages. */
.placeholder {
    max-width: 260px;
    padding: 20px;
    color: #64748b;
    text-align: center;
    line-height: 1.6;
}

/* Arrange the controls vertically. */
.controls-panel {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Style form labels. */
.controls-panel label {
    margin-top: 4px;
    font-size: 14px;
    font-weight: 700;
}

/* Style file inputs and selection controls. */
.controls-panel input[type="file"],
.controls-panel select {
    width: 100%;
    min-height: 42px;
    padding: 9px;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    background: #ffffff;
    color: #1e293b;
}

/* Make range sliders fill the available width. */
.controls-panel input[type="range"] {
    width: 100%;
    accent-color: #2563eb;
    cursor: pointer;
}

/* Give action buttons a consistent appearance. */
.controls-panel button {
    width: 100%;
    min-height: 44px;
    padding: 12px;
    border: none;
    border-radius: 7px;
    background: #2563eb;
    color: #ffffff;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.2s ease, transform 0.2s ease;
}

/* Change the appearance when the pointer hovers over a button. */
.controls-panel button:hover:not(:disabled) {
    background: #1d4ed8;
    transform: translateY(-1px);
}

/* Visually disable unavailable actions. */
.controls-panel button:disabled {
    background: #94a3b8;
    cursor: not-allowed;
    transform: none;
}

/* Distinguish secondary actions from primary actions. */
.controls-panel .secondary-button {
    background: #475569;
}

/* Change the secondary button hover color. */
.controls-panel .secondary-button:hover:not(:disabled) {
    background: #334155;
}

/* Keep the status message readable. */
#statusMessage {
    min-height: 38px;
    margin: 4px 0 0;
    color: #475569;
    font-size: 13px;
    line-height: 1.5;
    overflow-wrap: anywhere;
}

/* Style the footer. */
.application-footer {
    padding: 16px;
    border-top: 1px solid #e2e8f0;
    color: #64748b;
    text-align: center;
    font-size: 13px;
}

/* Remove unnecessary footer spacing. */
.application-footer p {
    margin: 0;
}

/* Adjust the layout for medium-sized screens. */
@media (max-width: 1050px) {
    .workspace {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .controls-panel {
        grid-column: 1 / -1;
    }

    .image-frame {
        min-height: 220px;
    }
}

/* Adjust the layout for mobile phones. */
@media (max-width: 650px) {
    body {
        padding: 10px;
    }

    .application-header {
        padding: 20px 14px;
    }

    .workspace {
        grid-template-columns: minmax(0, 1fr);
        gap: 14px;
        padding: 12px;
    }

    .controls-panel {
        grid-column: auto;
    }

    .preview-panel,
    .controls-panel {
        padding: 12px;
    }

    .image-frame {
        min-height: 180px;
    }
}