:root {
    --bg: #0b0f14;
    --panel: #071021;
    --muted: #9aa7b2;
    --accent: #39d0ff;
    --accent-dark: #1da3d5;
}

* {
    box-sizing: border-box;
}

/* MODIFICATION: Lock the main page view */
html, body {
    height: 100%;
    overflow: hidden; /* Prevents the main page from scrolling */
}

body {
    margin: 0;
    padding: 0;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, 'Roboto Mono', monospace;
    background: linear-gradient(180deg, #02040a 0%, #071024 100%);
    color: #e6f3f7;
    
    /* MODIFICATION: Center the app perfectly in the viewport */
    display: flex;
    align-items: center;
    justify-content: center;
}

.app {
    max-width: 1100px;
    width: calc(100% - 48px); /* Give some margin on smaller screens */
    margin: 24px;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 10px 40px rgba(2, 8, 23, .7);
    border: 1px solid rgba(57, 208, 255, 0.1);
}

.app-header {
    background: linear-gradient(90deg, rgba(57, 208, 255, 0.06), rgba(57, 255, 214, 0.02));
    padding: 14px 18px;
    font-weight: 700;
    color: var(--accent);
    font-size: 18px;
    border-bottom: 1px solid rgba(57, 208, 255, 0.1);
}

.layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 18px;
    padding: 18px;
    background: var(--bg);
}

.terminal {
    background: linear-gradient(180deg, rgba(0, 0, 0, 0.25), rgba(0, 0, 0, 0.15));
    border-radius: 8px;
    padding: 12px;
    display: flex;
    flex-direction: column;
    /* We set a max-height to ensure the layout doesn't break on tall screens */
    max-height: 520px; 
    min-height: 360px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.terminal-inner {
    flex: 1;
    background: rgba(0, 0, 0, 0.35);
    border-radius: 6px;
    padding: 12px;
    overflow: auto; /* This is CRITICAL: it enables scrolling ONLY here */
    font-size: 13px;
    line-height: 1.5;
    color: #a8dede;
    cursor: text;
}

.terminal-inner .line {
    white-space: pre-wrap;
    word-break: break-all;
}

.cursor {
    display: inline-block;
    width: 10px;
    height: 16px;
    background: var(--accent);
    margin-left: 6px;
    vertical-align: text-bottom;
    animation: blink 1s steps(2) infinite;
}

@keyframes blink {
    50% {
        opacity: 0;
    }
}

.terminal-controls {
    display: flex;
    gap: 12px;
    align-items: center;
    padding-top: 12px;
    font-size: 14px;
}

button {
    background-color: var(--accent);
    color: var(--bg);
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    font-weight: 700;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

button:hover {
    background-color: var(--accent-dark);
}

input[type=range] {
    accent-color: var(--accent);
    flex: 1;
}

input[type="file"] {
    display: none;
}
.file-upload-label {
    background-color: rgba(255,255,255,0.08);
    color: var(--muted);
    border: 1px solid rgba(255,255,255,0.1);
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    transition: background-color 0.2s ease;
}
.file-upload-label:hover {
     background-color: rgba(255,255,255,0.15);
     color: white;
}


.preview {
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.02), rgba(0, 0, 0, 0.02));
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    padding: 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 360px;
    position: relative;
}

.preview:not(.has-image)::before {
    content: 'Awaiting image...';
    color: var(--muted);
    font-size: 14px;
    position: absolute;
}

#previewCanvas {
    background: var(--panel);
    image-rendering: pixelated;
    border: 1px solid rgba(255, 255, 255, 0.03);
    max-width: 100%;
    height: auto;
    max-height: 450px;
}

.preview-caption {
    margin-top: 10px;
    color: var(--muted);
    font-size: 13px;
}

.app-footer {
    padding: 12px 18px;
    background: linear-gradient(90deg, rgba(57, 208, 255, 0.02), rgba(57, 255, 214, 0.01));
    border-top: 1px solid rgba(57, 208, 255, 0.1);
    font-size: 13px;
    color: var(--muted);
}


@media (max-width: 800px) {
    .layout {
        grid-template-columns: 1fr;
    }
    .app {
        margin: 12px;
        width: calc(100% - 24px);
    }
    body {
        align-items: flex-start; /* On mobile, don't center vertically */
    }
}
