* {
    box-sizing: border-box;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
}

body {
    margin: 0;
    background: #0f0f12;
    color: #e6e6eb;
    height: 100svh;
    height: 100dvh;
    overflow: hidden;
}

.layout {
    height: 100svh;
    height: 100dvh;
    display: grid;
    grid-template-columns: 1fr;
    gap: 14px;
    padding: 14px;
}

/* Desktop layout */
@media (min-width: 900px),
(max-height: 500px) {

    .layout {
        grid-template-columns: 1fr min-content;
        align-items: stretch;
    }

    .right {
        height: 100%;
        aspect-ratio: 800 / 1390;
        width: auto;
        min-width: calc(100dvh * (800 / 1390));
        max-width: 40vw;
        flex-shrink: 0;
    }

    .right>.module {
        height: 100%;
    }
}



.left {
    display: flex;
    flex-direction: column;
    gap: 14px;
    min-height: 0;
}

.right {
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.module {
    background: #16161c;
    border: 1px solid #24242b;
    border-radius: 10px;
    padding: 16px;
    position: relative;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.tab {
    position: absolute;
    top: -10px;
    left: 12px;
    background: #0f0f12;
    padding: 2px 8px;
    font-size: 12px;
    color: #a0a0ad;
    border: 1px solid #24242b;
    border-radius: 6px;
}

.key-row {
    display: flex;
    gap: 10px;
    align-items: stretch;
}

.key-row .key-input {
    flex: 1;
}

.controls {
    display: flex;
    flex-direction: row;
    gap: 8px;
    align-items: stretch;
    /* make children fill height */
    justify-content: center;
}


.control-btn {
    width: 44px;
    height: 44px;
    background: #0f0f12;
    border: 1px solid #2e2e38;
    border-radius: 8px;
    color: #e6e6eb;
    font-size: 18px;
    cursor: pointer;

    display: grid;
    place-items: center;
}

/* make buttons same height as key input */
.controls .control-btn {
    height: 100%;
    /* fill the height of controls module */
    width: auto;
    /* width = height (we’ll fix with aspect-ratio) */
    aspect-ratio: 1 / 1;
    /* square */
}


.control-btn:hover {
    background: #1e1e26;
}

.control-btn:active {
    background: #000;
}

.control-btn.play {
    color: #9ef01a;
}

.control-btn.stop {
    color: #ff5c5c;
}




/* Key input */
.key-input input {
    width: 100%;
    background: #0f0f12;
    border: 1px solid #2e2e38;
    color: #e6e6eb;
    padding: 10px 12px;
    border-radius: 6px;
    outline: none;
}

.key-input input::placeholder {
    color: #6f6f7a;
}

/* Status */
.status-text {
    font-size: 14px;
    color: #cfcfda;
}

/* Output */
.output-box {
    flex: 1;
    min-height: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #0f0f12;
    border: 2px dashed #2e2e38;
    border-radius: 8px;
    padding: 12px;
}

.output-box img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 4px;
}

.placeholder {
    color: #6f6f7a;
    text-align: center;
    font-size: 14px;
}

/* Console */
.console {
    flex: 1;
    min-height: 0;
    background: #000;
    border-radius: 8px;
    padding: 12px;
    overflow-y: auto;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 12px;
    color: #9ef01a;
}

.console-line {
    white-space: pre-wrap;
}

@media (max-width: 899px) and (min-height: 501px) {

    body {
        height: 100svh;
        height: 100dvh;
    }

    .layout {
        height: 100svh;
        height: 100dvh;
        display: flex;
        flex-direction: column;
        gap: 14px;
    }

    /* flatten left so ordering works */
    .left {
        display: contents;
    }

    .key-row {
        order: 1;
        display: flex;
    }

    .key-row .control-btn {
        flex: 0 0 auto;
    }

    /* ordering */
    .key-input {
        flex: 0 0 auto;
    }

    .left .module:nth-of-type(2) {
        order: 2;
        /* status */
        flex: 0 0 auto;
    }

    .right {
        order: 3;
        flex: 1;
        min-height: 0;
    }

    .left .module:nth-of-type(3) {
        order: 4;
        /* console */
        flex: 1;
        min-height: 0;
    }

    /* make output + console equal height */
    .right .module,
    .left .module:nth-of-type(3) {
        flex: 1;
        min-height: 0;
    }
}