/* Body & General Layout */
body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    height: 100vh;
    display: flex;
    color: #333;
    overflow: hidden;
    /* Prevent body scroll, handle panels individually */
}

.container {
    display: flex;
    width: 100%;
    height: 100%;
}

.panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 24px;
    box-sizing: border-box;
}

/* Left Panel: Input & Controls */
.left-panel {
    flex: 3;
    /* 60% Width (3:2 Ratio) */
    background-color: #f8f9fa;
    border-right: 1px solid #e9ecef;
    /* Removed max-width */
    box-shadow: 2px 0 5px rgba(0, 0, 0, 0.02);
    z-index: 10;
}

h1 {
    font-size: 1.5rem;
    margin: 0 0 1.5rem 0;
    color: #2d3436;
    font-weight: 700;
    letter-spacing: -0.5px;
}

/* Textarea */
textarea {
    /* flex: 1; Remove default flex:1 to allow manual control or multiple textareas */
    width: 100%;
    padding: 15px;
    border: 1px solid #dfe6e9;
    border-radius: 8px;
    font-size: 1rem;
    line-height: 1.6;
    resize: none;
    box-sizing: border-box;
    margin-bottom: 1.5rem;
    font-family: inherit;
    transition: border-color 0.2s, box-shadow 0.2s;
}

#source-text {
    height: 200px;
    /* Fixed height for input */
    flex: 0 0 auto;
}

/* Output Textarea */
#output-text {
    flex: 1;
    /* Take remaining space */
    margin-bottom: 0;
}

textarea:focus {
    outline: none;
    border-color: #74b9ff;
    box-shadow: 0 0 0 3px rgba(116, 185, 255, 0.1);
}

/* Primary Button */
.btn-primary {
    background-color: #0984e3;
    color: white;
    border: none;
    padding: 14px 24px;
    font-size: 1rem;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
    font-weight: 600;
    box-shadow: 0 2px 5px rgba(9, 132, 227, 0.2);
}

.btn-primary:hover {
    background-color: #0076cf;
}

.btn-primary:active {
    transform: translateY(1px);
}

.btn-primary:disabled {
    background-color: #b2bec3;
    cursor: wait;
    transform: none;
}

/* Micro Buttons (Copy, Download) */
.btn-micro {
    background-color: #e2e6ea;
    color: #4b6584;
    border: 1px solid #ced4da;
    padding: 4px 10px;
    font-size: 0.8rem;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s;
}

.btn-micro:hover {
    background-color: #d1d8e0;
    color: #2f3542;
    border-color: #a4b0be;
}

.btn-micro:active {
    background-color: #a4b0be;
    transform: translateY(1px);
}

.header-buttons {
    display: flex;
    gap: 8px;
}

/* Right Panel: Preview */
.right-panel {
    flex: 2;
    /* 40% Width (3:2 Ratio) */
    background-color: #dfe6e9;
    overflow: hidden;
    /* PREVENT SCROLLING */
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    /* Center Vertically */
    padding: 20px;
    position: relative;
}

#preview-container {
    /* Container takes full available space but centers content */
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    /* Move white bg to SVG */
    box-shadow: none;
    /* Move shadow to SVG */
    transition: opacity 0.3s;
}

/* Make SVG responsive and FIT entirely */
#preview-container svg {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    /* Auto width to maintain aspect ratio */
    height: auto;
    /* Auto height to maintain aspect ratio */
    display: block;
    background: white;
    /* Paper look */
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
    /* Shadow on paper */
}

/* Mobile Adaptation */
@media (max-width: 768px) {
    body {
        overflow-y: auto;
        /* Allow body scroll on mobile */
        height: auto;
    }

    .container {
        flex-direction: column;
        height: auto;
        background-color: #f8f9fa;
        /* Match left-panel bg */
    }

    .left-panel {
        display: contents;
        /* Flatten to allow reordering */
        /* Note: padding/bg/border on .left-panel are ignored with display: contents */
    }

    /* Re-apply styling to flattened children */
    .left-panel>header {
        order: 1;
        padding: 20px 24px 10px;
        background-color: #f8f9fa;
    }

    .right-panel {
        order: 6;
        /* Initially at bottom (after output group) */
        width: 100%;
        min-height: 300px;
        display: flex;
        /* Always visible as per new request */
        padding: 10px;
        transition: order 0.3s ease;
        /* Animate check? Order is not animatable typically, but layout changes */
    }

    .right-panel.mobile-top {
        order: 2;
        /* Move to top when content is ready */
    }

    #source-text {
        order: 3;
        margin: 0 24px 20px;
        width: calc(100% - 48px);
        /* Manual width since flex parent changed behavior */
    }

    #generate-btn {
        order: 4;
        margin: 0 24px 20px;
        width: calc(100% - 48px);
    }

    .output-group {
        order: 5;
        margin: 0 24px 40px;
        width: calc(100% - 48px);
    }

    /* Adjust header buttons for smaller screens */
    .header-buttons {
        gap: 4px;
    }

    .btn-micro {
        padding: 4px 8px;
        font-size: 0.75rem;
    }
}