html {
    overflow-y: scroll; /* Always show vertical scrollbar to prevent layout shifts */
}

body {
    font-family: "Arial", sans-serif;
    margin: 0;
    padding: 0;
    background-color: #f4f7f6;
    color: #333;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    min-height: 100vh;
    /* Removed width: 100vw; and overflow-x: hidden; diagnostics that caused issues */
}

#app {
    background-color: #ffffff;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    margin: 20px auto;
    padding: 40px; /* Increased padding for more internal space */
    width: 85vw; /* Set width to 85% of viewport width */
    /* Removed max-width to allow it to scale freely with the viewport */
    box-sizing: border-box; /* Ensure padding/border are included in element's total width */
}

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

.editor-container {
    display: flex;
    gap: 20px;
    margin-bottom: 20px;
    /* Removed flex-wrap to keep side-by-side layout, accepting potential horizontal overflow */
    /* This ensures boxes are always vertically aligned as requested */
}

.input-section,
.output-section {
    flex: 1;
    min-width: 300px; /* Ensure a minimum width before content is compressed */
}

textarea {
    width: 100%;
    height: 400px;
    padding: 15px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-family: "Consolas", "Monaco", monospace;
    font-size: 1em;
    /* Removed resize: vertical; from generic textarea */
    box-sizing: border-box;
    background-color: #fdfdfd;
    color: #333;
    transition: border-color 0.3s ease;
}

textarea:focus {
    border-color: #4caf50;
    outline: none;
}

.controls {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-bottom: 20px;
    flex-wrap: wrap; /* Keep this to wrap buttons on small screens */
}

button {
    background-color: #4caf50;
    color: white;
    padding: 12px 25px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1.1em;
    transition:
        background-color 0.3s ease,
        transform 0.2s ease;
}

button:hover {
    background-color: #45a049;
    transform: translateY(-2px);
}

button:active {
    transform: translateY(0);
}

.validation-message {
    text-align: center;
    padding: 15px;
    margin-top: 20px;
    border-radius: 6px;
    font-size: 1.1em;
    font-weight: bold;
    box-sizing: border-box;
    max-width: 100%;
    min-height: 2.5em; /* Reserve vertical space even when hidden */
    visibility: hidden; /* Hide without removing from flow */
    opacity: 0; /* For smooth transition on visibility */
    transition:
        opacity 0.3s ease,
        visibility 0.3s ease;
}

.validation-message.visible {
    visibility: visible;
    opacity: 1;
}

.validation-message.success {
    background-color: #e6ffe6;
    color: #28a745;
    border: 1px solid #28a745;
}

.validation-message.error {
    background-color: #ffe6e6;
    color: #dc3545;
    border: 1px solid #dc3545;
}

.error-details {
    margin-top: 10px;
    font-size: 0.9em;
    color: #666;
    white-space: pre-wrap;
    overflow-wrap: break-word; /* Ensures long words break to prevent horizontal overflow */
    font-family: "Consolas", "Monaco", monospace;
    max-height: 150px;
    overflow-y: auto;
    background-color: #f8f8f8;
    padding: 10px;
    border-radius: 4px;
    border: 1px solid #eee;
    box-sizing: border-box;
    max-width: 100%;
    min-height: 1em; /* Reserve space for error details */
    visibility: hidden; /* Hide without removing from flow */
    opacity: 0; /* For smooth transition on visibility */
    transition:
        opacity 0.3s ease,
        visibility 0.3s ease;
}

.error-details.visible {
    visibility: visible;
    opacity: 1;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    /* .editor-container no longer has flex-direction: column; as per request */

    .input-section,
    .output-section {
        min-width: unset; /* Allow them to shrink further on smaller screens */
    }

    textarea {
        height: 300px;
    }

    #app {
        margin: 15px;
        padding: 25px;
    }
}

@media (max-width: 480px) {
    h1 {
        font-size: 1.8em;
    }

    button {
        padding: 10px 20px;
        font-size: 1em;
    }

    .controls {
        gap: 10px;
    }
}

.resizable-textarea {
    resize: vertical;
}
