/* Workspace: files | stage over terminal | coach */

.app {
    display: grid;
    grid-template-rows: var(--topbar-h) 1fr;
    height: 100vh;
    height: 100dvh;
}

/* ---- top bar ---- */
.topbar {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 0 12px 0 14px;
    border-bottom: 1px solid var(--rule);
    background: var(--panel);
    min-width: 0;
}

.wordmark {
    display: flex;
    align-items: center;
    gap: 9px;
    margin: 0;
    font-size: 16px;
    font-weight: 700;
    letter-spacing: -0.01em;
    white-space: nowrap;
}

.wordmark svg {
    width: 26px;
    height: 26px;
}

.wordmark .mono {
    font-weight: 600;
    color: var(--ink-2);
}

/* world switch: two tabs like a notebook's tabbed dividers */
.worlds {
    display: flex;
    align-self: stretch;
    gap: 2px;
    margin-left: 4px;
}

.worlds button {
    position: relative;
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 0 14px;
    border: none;
    background: transparent;
    color: var(--ink-2);
    font-size: 13px;
    font-weight: 600;
}

.worlds button::after {
    content: '';
    position: absolute;
    left: 10px;
    right: 10px;
    bottom: -1px;
    height: 3px;
    border-radius: 2px 2px 0 0;
    background: transparent;
}

.worlds button[aria-pressed="true"] {
    color: var(--ink);
}

.worlds button[aria-pressed="true"]::after {
    background: var(--ink);
}

.worlds button:hover {
    color: var(--ink);
}

.worlds .net {
    padding: 1px 6px;
    border-radius: 9px;
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.net.real {
    border: 1px solid var(--rule-strong);
    color: var(--ink-2);
}

.net.sim {
    border: 1px dashed var(--sim);
    background: var(--hatch-sim);
    color: var(--sim);
}

.mission-crumb {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    color: var(--ink-2);
    font-size: 13px;
}


.topbar .spacer {
    flex: 1;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 4px;
}

.lang-switch {
    display: flex;
    border: 1px solid var(--rule-strong);
    border-radius: var(--radius);
    overflow: hidden;
}

.lang-switch button {
    height: 28px;
    padding: 0 9px;
    border: none;
    background: var(--sheet);
    color: var(--ink-3);
    font-size: 12px;
    font-weight: 700;
}

.lang-switch button[aria-pressed="true"] {
    background: var(--ink);
    color: var(--ink-inverse);
}

/* ---- workspace grid ---- */
.workspace {
    display: grid;
    grid-template-columns: var(--files-w, 232px) minmax(0, 1fr) var(--coach-w, 372px);
    min-height: 0;
}

.pane {
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
    background: var(--panel);
}

.pane-files {
    border-right: 1px solid var(--rule);
}

.pane-coach {
    border-left: 1px solid var(--rule);
}

.pane-head {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 40px;
    padding: 0 var(--pane-pad);
    border-bottom: 1px solid var(--rule);
}

.pane-head .label {
    flex: 1;
}

.pane-body {
    flex: 1;
    min-height: 0;
    overflow: auto;
}

.pane-center {
    display: grid;
    grid-template-rows: minmax(120px, var(--stage-h, var(--stage-default, 46%))) 6px minmax(160px, 1fr);
    min-width: 0;
    min-height: 0;
    background: var(--paper);
}

.splitter {
    position: relative;
    cursor: row-resize;
    background: var(--paper);
    border-top: 1px solid var(--rule);
    border-bottom: 1px solid var(--rule);
}

.splitter::after {
    content: '';
    position: absolute;
    left: 50%;
    top: 1px;
    width: 36px;
    height: 2px;
    margin-left: -18px;
    border-radius: 2px;
    background: var(--rule-strong);
}

.splitter:hover::after,
.splitter.dragging::after {
    background: var(--ink-3);
}

/* the terminal can be maximised; the stage then collapses */
.pane-center.term-max {
    grid-template-rows: 0 0 1fr;
}

.pane-center.term-max .stage,
.pane-center.term-max .splitter {
    display: none;
}

/* ---- mobile tabs (hidden on large screens) ---- */
.mobile-tabs {
    display: none;
}

@media (max-width: 1180px) {
    .workspace {
        grid-template-columns: minmax(0, 1fr) var(--coach-w, 340px);
    }

    .pane-files {
        position: fixed;
        top: var(--topbar-h);
        bottom: 0;
        left: 0;
        z-index: 40;
        width: 280px;
        transform: translateX(-100%);
        transition: transform 0.18s ease;
        box-shadow: var(--shadow-pop);
    }

    .app.files-open .pane-files {
        transform: none;
    }

    .mission-crumb .progress-dots {
        display: none;
    }
}

@media (max-width: 860px) {
    :root {
        --topbar-h: 46px;
    }

    .workspace {
        grid-template-columns: 1fr;
        grid-template-rows: 1fr auto;
    }

    .pane-coach,
    .pane-center {
        grid-column: 1;
        grid-row: 1;
    }

    /* the terminal needs the room on a phone (the on-screen keyboard takes half the screen) */
    .pane-center {
        --stage-default: 30%;
    }

    .app[data-mobile-tab="coach"] .pane-center,
    .app:not([data-mobile-tab="coach"]) .pane-coach {
        display: none;
    }

    .pane-coach {
        border-left: none;
    }

    .mobile-tabs {
        display: flex;
        grid-row: 2;
        border-top: 1px solid var(--rule);
        background: var(--panel);
    }

    .mobile-tabs button {
        flex: 1;
        height: 44px;
        border: none;
        background: transparent;
        color: var(--ink-2);
        font-weight: 600;
    }

    .mobile-tabs button[aria-pressed="true"] {
        color: var(--ink);
        box-shadow: inset 0 3px 0 var(--ink);
    }

    .wordmark .mono,
    .mission-crumb {
        display: none;
    }

    .worlds button {
        padding: 0 9px;
    }

    .worlds .net {
        display: none;
    }
}

/* ---- boot screen and fatal errors ---- */
.boot {
    display: grid;
    place-items: center;
    height: 100vh;
    color: var(--ink-3);
}

.boot-name {
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.boot-error {
    max-width: 640px;
    margin: 12vh auto;
    padding: 0 20px;
}

.boot-error h1 {
    font-size: 20px;
}

.boot-error pre {
    overflow: auto;
    padding: 12px;
    background: var(--panel);
    font-size: 12px;
}

/* ---- phones: only the essentials in the top bar; the rest is in the settings dialog ---- */
.more-btn {
    display: none !important;
}

@media (max-width: 600px) {
    .topbar {
        gap: 6px;
        padding: 0 6px;
    }

    .wordmark > span,
    .undo-label,
    .topbar-actions .lang-switch,
    .topbar-actions .theme-btn,
    .topbar-actions .reset-btn {
        display: none;
    }

    .more-btn {
        display: inline-flex !important;
    }

    .worlds {
        margin-left: 0;
    }

    .worlds button {
        gap: 5px;
        padding: 0 7px;
    }

    .topbar-actions .btn {
        padding: 0;
        width: 30px;
        justify-content: center;
    }
}

.settings-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 0;
    border-top: 1px solid var(--rule);
}

.settings-row:last-of-type {
    border-bottom: 1px solid var(--rule);
    margin-bottom: 16px;
}
