.console_page {
    display: grid;
    grid-template-columns: minmax(304px, 384px) 1fr;
    gap: var(--space-gap);
    min-height: 100vh;
    min-height: 100svh;
    align-items: start;
    align-content: start; /* the row stays as tall as the console, even on tall windows */
    /* Same distances as every page; left and right it keeps to the same 1200px column */
    /* the side padding leaves exactly the content column (--column, a multiple of 8px) in the middle; in padding,
       100% means the window width, so the main's own width is min(100%, --page-width) */
    padding: calc(var(--nav-height) + var(--page-top)) calc((min(100%, var(--page-width)) - var(--column)) / 2) var(--page-bottom);
    box-sizing: border-box;
}

/* Command list: exactly as tall as the console and scrolls on its own.
   contain: size keeps its content from stretching the row, so the console sets the height. */
.commands {
    align-self: stretch;
    contain: size;
    overflow-y: auto;
    padding: var(--panel-inset);
    box-sizing: border-box;
    background-color: var(--color-card);
    border: 2px solid var(--color-line);
    border-radius: 12px;
    box-shadow: var(--shadow-hard);  /* same panel as the projects on the portfolio page */
    color: var(--color-text-soft);
}

/* "Commands" (h2) and the groups (h3) take their sizes from the type scale in general.css */
.commands h3 {
    margin-top: 32px;
}

.hint {
    margin: 0;
    font-size: var(--fs-small);
    line-height: var(--lh-small);
    color: var(--color-secondary);
}

kbd {
    padding: 0 8px;
    border-radius: 4px;
    background-color: var(--color-card-bar);
    color: var(--color-primary);
    font-family: inherit;
}

.commands ul {
    margin: 0;
    padding: 0;
    list-style: none;
}

.cmd {
    display: block;
    width: 100%;
    padding: 4px 12px;  /* with a 32px command and a 24px description: 64px, or 88px when the description wraps */
    border: 0;
    border-radius: 8px;
    background: none;
    color: inherit;
    font-family: inherit;
    text-align: left;
    cursor: pointer;
}

.cmd:focus-visible {
    background-color: var(--color-card-bar);
    outline: none;
}

@media (hover: hover) {
    .cmd:hover {
        background-color: var(--color-card-bar);
    }
}

.cmd code {
    display: block;
    font-family: inherit;
    font-size: var(--fs-text);
    line-height: 32px;
    color: var(--color-border);
    overflow-wrap: anywhere;
}

.cmd code i {
    font-style: normal;
    color: var(--color-secondary);
}

.cmd span {
    display: block;
    font-size: var(--fs-small);
    line-height: var(--lh-small);
}

.shortcuts {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 0 16px;  /* rows of 24px (--lh-small), right below each other */
    margin: 0;
    padding: 0 12px;
    font-size: var(--fs-small);
    line-height: var(--lh-small);
}

.shortcuts dt {
    color: var(--color-border);
}

.shortcuts dd {
    margin: 0;
}

/* Console: a panel with the same hard shadow as the command list */
.terminal {
    container-type: inline-size;  /* the screen takes its height from the console's width (cqw) */
    position: relative;
    display: flex;
    flex-direction: column;
    min-width: 0;
    border-radius: 12px;
    box-shadow: var(--shadow-hard);
}

.terminal_bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 32px 16px;  /* a wrapped bar: rows of 32px with 32px between, so it grows in steps of 64px */
    padding: 14px 14px 16px;  /* with the 2px top border: the 32px row starts 16px from the edge, the bar is 64px tall (the screen's height limit below counts on it) */
    background-color: var(--color-card-bar);
    border: 2px solid var(--color-line);
    border-bottom: 0;
    border-radius: 12px 12px 0 0;
}

.terminal_title {
    margin: 0;
    line-height: 32px;  /* as tall as the buttons: a wrapped bar is a multiple of 16px */
    color: var(--color-primary);
    font-size: var(--fs-h3);
}

.status {
    min-width: 0;
    line-height: 32px;
    font-size: var(--fs-text);
    color: var(--color-secondary);
    overflow-wrap: anywhere;  /* a long error message (e.g. a URL) wraps instead of widening the page */
}

.status::before {
    content: "";
    display: inline-block;
    width: 10px;
    height: 10px;
    margin-right: 8px;
    background-color: var(--color-secondary);
}

.status[data-state="busy"]::before { background-color: #F2C94C; }
.status[data-state="on"]::before { background-color: var(--color-live); }
.status[data-state="error"] { color: var(--color-accent); }
.status[data-state="error"]::before { background-color: var(--color-accent); }

.bar_buttons {
    display: flex;
    gap: 8px;
    margin-left: auto;
}

.bar_button {
    min-height: 32px;  /* like the chips */
    padding: 0 16px;
    line-height: 32px;
    border: 0;
    border-radius: 8px;
    background-color: var(--color-line);
    color: var(--color-primary);
    font-family: inherit;
    font-size: var(--fs-text);
    cursor: pointer;
}

@media (hover: hover) {
    .bar_button:hover {
        filter: brightness(1.2);
    }
}

.screen {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    /* About 4:3 of the console's width, but it has to fit the window (nav, top gap, 64px title bar, bottom gap)
       so the page does not scroll; rounded down to the 8px grid */
    height: round(down, min(75cqw, 100vh - var(--nav-height) - var(--page-top) - 64px - var(--page-bottom)), 16px);
    height: round(down, min(75cqw, 100svh - var(--nav-height) - var(--page-top) - 64px - var(--page-bottom)), 16px);
    min-height: 360px;
    box-sizing: border-box;
    overflow: hidden;
    background-color: #000000;
    border: 2px solid var(--color-line);
    border-radius: 0 0 12px 12px;
}

/* v86 writes text mode into this div and graphics mode into the canvas */
/* Each row is as tall as the font's glyphs, so a row's background never covers the row above */
.screen_text {
    white-space: pre;
    font: 15px monospace;
    line-height: 18px;
}

.screen_text > div {
    height: 18px;
}

/* 1px taller than the row: the next row covers it, which hides seams from the scaling */
.screen_text span {
    display: inline-block;
    height: 19px;
    vertical-align: top;
}

#screen_container canvas {
    image-rendering: pixelated;
}

#screen_container {
    flex: none;
}

/* Keyboard for touch screens: a text field that types into the console, shown only on
   devices without a mouse (phones, tablets), where the on-screen keyboard needs a field to open for */
.touch_input {
    display: none;
    gap: 8px;
    padding: 8px;
    background-color: var(--color-page);
    border: 2px solid var(--color-line);
    border-top: 0;
    border-radius: 0 0 12px 12px;
}

@media (pointer: coarse) {
    .touch_input {
        display: flex;
    }

    .screen {
        border-radius: 0;
    }
}

.touch_input input {
    flex: 1;
    min-width: 0;
    min-height: 44px;
    padding: 4px 12px;
    border: 2px solid var(--color-line);
    border-radius: 8px;
    background-color: #000000;
    color: #FFFFFF;  /* part of the black terminal, in both themes */
    font: 20px monospace;
}

.touch_input input:focus {
    outline: none;
    border-color: var(--color-border);
}

.touch_input button {
    min-width: 44px;
}

/* Sits below the console without adding to its height, so the command list ends with the screen */
.terminal_note {
    position: absolute;
    top: 100%;
    left: 4px;
    margin: 16px 0 0;
    font-size: var(--fs-small);
    line-height: var(--lh-small);
    color: var(--color-secondary);
}

.terminal_note a {
    color: var(--color-border);
}

/* Fullscreen: the console fills the whole display, the bar stays for the Exit/Restart buttons */
.terminal:fullscreen {
    padding: 0;
    border-radius: 0;
    box-shadow: none;
    background-color: #000000;
}

.terminal:fullscreen .terminal_bar {
    border-radius: 0;
}

.terminal:fullscreen .screen {
    flex: 1;
    height: auto;
    max-height: none;
    min-height: 0;
    border-radius: 0;
}

.terminal:fullscreen .touch_input {
    border-radius: 0;
}

.terminal:fullscreen .terminal_note {
    display: none;
}

/* Narrow screens and tablets: console on top, full width, the command list below it */
@media screen and (max-width: 1000px) {
    .console_page {
        grid-template-columns: 1fr;
        padding-top: calc(var(--nav-height) + var(--page-top));  /* below the nav, which is still at the top here */
        padding-bottom: var(--page-bottom);
    }

    .terminal {
        order: -1;
    }

    .commands {
        align-self: auto;
        contain: none;
        overflow: visible;
    }

    .screen {
        /* Width decides the size; on short screens the height caps it */
        height: round(down, min(75cqw, 75vh), 16px);
        height: round(down, min(75cqw, 75svh), 16px);
        min-height: 0;
    }

    .terminal_note {
        position: static;
        margin: 16px 0 0;
    }
}

/* Phones: <main> is the scroll area between the top of the screen and the tab bar (see general.css) */
@media screen and (max-width: 760px) {
    .console_page {
        min-height: 0;
        padding-top: calc(64px + var(--page-top));  /* the row the light/dark switch floats in, then the usual gap */
    }
}

