/* MiniJavaIDE.css
 *
 * Quiet chrome, code in front. Two themes share one set of tokens:
 * <html data-theme="light|dark"> picks the values (popped-out panel windows
 * get the same attribute, so they follow the theme too).
 */

/* ---------- fonts (self-hosted, see vendor/LICENSES.txt) ---------- */
@font-face { font-family: "Atkinson Hyperlegible Next"; font-weight: 400; font-style: normal; font-display: swap;
    src: url("vendor/fonts/atkinson-hyperlegible-next-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "Atkinson Hyperlegible Next"; font-weight: 400; font-style: italic; font-display: swap;
    src: url("vendor/fonts/atkinson-hyperlegible-next-latin-400-italic.woff2") format("woff2"); }
@font-face { font-family: "Atkinson Hyperlegible Next"; font-weight: 600; font-style: normal; font-display: swap;
    src: url("vendor/fonts/atkinson-hyperlegible-next-latin-600-normal.woff2") format("woff2"); }
@font-face { font-family: "Atkinson Hyperlegible Next"; font-weight: 700; font-style: normal; font-display: swap;
    src: url("vendor/fonts/atkinson-hyperlegible-next-latin-700-normal.woff2") format("woff2"); }
@font-face { font-family: "Atkinson Hyperlegible Mono"; font-weight: 400; font-style: normal; font-display: swap;
    src: url("vendor/fonts/atkinson-hyperlegible-mono-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "Atkinson Hyperlegible Mono"; font-weight: 400; font-style: italic; font-display: swap;
    src: url("vendor/fonts/atkinson-hyperlegible-mono-latin-400-italic.woff2") format("woff2"); }
@font-face { font-family: "Atkinson Hyperlegible Mono"; font-weight: 700; font-style: normal; font-display: swap;
    src: url("vendor/fonts/atkinson-hyperlegible-mono-latin-700-normal.woff2") format("woff2"); }

/* ---------- tokens ---------- */
:root {
    --font-ui: "Atkinson Hyperlegible Next", "Segoe UI", system-ui, sans-serif;
    --font-code: "Atkinson Hyperlegible Mono", ui-monospace, "Cascadia Mono", Consolas, monospace;
    --code-size: 15px;
    --ui-size: 14px;
    --radius: 6px;
    --topbar-h: 52px;
}

:root, [data-theme="light"] {
    color-scheme: light;
    --bg: #F6F7F9;          /* chrome, panel headers */
    --panel: #FFFFFF;       /* panel bodies, editor */
    --sunken: #EEF0F4;      /* inputs, hover */
    --ink: #1D2430;
    --muted: #5B6577;
    --faint: #8A93A3;
    --line: #DDE1E8;
    --line-strong: #C7CDD8;
    --accent: #2F5BD3;      /* ballpoint blue */
    --accent-ink: #FFFFFF;
    --accent-soft: #E7EDFC;
    --run: #1F8A4C;
    --run-hover: #19743F;
    --run-soft: #E3F3EA;
    --stop: #C2362B;
    --stop-soft: #FBE9E7;
    --wait: #9A6413;
    --wait-soft: #FBF0DC;
    --selection: #C9D7FA;
    --active-line: #F3F6FC;
    --shadow: 0 10px 30px rgba(29, 36, 48, 0.14), 0 2px 6px rgba(29, 36, 48, 0.08);

    /* code colors */
    --syn-keyword: #8A3FA0;
    --syn-type: #0F6E8C;
    --syn-string: #2E7D32;
    --syn-number: #B4570B;
    --syn-comment: #6E7787;
    --syn-def: #1B4FB8;
    --syn-annotation: #8A6D00;
    --console-err: #B42F25;
    --console-warn: #8C5A0B;
    --console-echo: #2F5BD3;
}

[data-theme="dark"] {
    color-scheme: dark;
    --bg: #171B22;
    --panel: #1E232C;
    --sunken: #262C37;
    --ink: #E6E9EF;
    --muted: #9AA3B2;
    --faint: #6F7889;
    --line: #2D3440;
    --line-strong: #3B4352;
    --accent: #7FA2FF;
    --accent-ink: #10172A;
    --accent-soft: #263255;
    --run: #2C9A5A;
    --run-hover: #34AD66;
    --run-soft: #1F3A2C;
    --stop: #FF7A6E;
    --stop-soft: #43262A;
    --wait: #E5B454;
    --wait-soft: #3D3220;
    --selection: #2F4579;
    --active-line: #232A35;
    --shadow: 0 12px 34px rgba(0, 0, 0, 0.45), 0 2px 8px rgba(0, 0, 0, 0.3);

    --syn-keyword: #D7A0F0;
    --syn-type: #6FD0E8;
    --syn-string: #9CD67F;
    --syn-number: #F2A65A;
    --syn-comment: #8A93A5;
    --syn-def: #8FB0FF;
    --syn-annotation: #E3C766;
    --console-err: #FF8A80;
    --console-warn: #E5B454;
    --console-echo: #8FB0FF;
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }

html, body {
    height: 100%;
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: var(--font-ui);
    font-size: var(--ui-size);
    line-height: 1.4;
    -webkit-font-smoothing: antialiased;
}

html, body { overflow: clip; }

button, input, textarea, select { font: inherit; color: inherit; }

:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
}

[hidden] { display: none !important; }

.visually-hidden {
    position: absolute !important;
    width: 1px; height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

/* ---------- buttons ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 32px;
    padding: 0 12px;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius);
    background: var(--panel);
    color: var(--ink);
    cursor: pointer;
    white-space: nowrap;
}
.btn:hover:not(:disabled) { background: var(--sunken); }
.btn:disabled { opacity: 0.45; cursor: default; }
.btn svg { width: 16px; height: 16px; flex: none; }
.btn.small { height: 26px; padding: 0 8px; font-size: 13px; gap: 4px; }
.btn.small svg { width: 14px; height: 14px; }

.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn.primary:hover:not(:disabled) { background: var(--accent); filter: brightness(1.08); }
.btn.danger { background: var(--stop); border-color: var(--stop); color: #fff; font-weight: 600; }
[data-theme="dark"] .btn.danger { color: #2A0F0C; }
.btn.danger:hover:not(:disabled) { background: var(--stop); filter: brightness(1.08); }
.btn.quiet { border-color: transparent; background: transparent; color: var(--muted); }
.btn.quiet:hover:not(:disabled) { background: var(--sunken); color: var(--ink); }

.icon-btn {
    display: inline-grid;
    place-items: center;
    width: 30px;
    height: 30px;
    padding: 0;
    border: 1px solid transparent;
    border-radius: var(--radius);
    background: transparent;
    color: var(--muted);
    cursor: pointer;
}
.icon-btn:hover:not(:disabled) { background: var(--sunken); color: var(--ink); }
.icon-btn:disabled { opacity: 0.4; cursor: default; }
.icon-btn svg { width: 17px; height: 17px; }
.icon-btn.small { width: 24px; height: 24px; }
.icon-btn.small svg { width: 15px; height: 15px; }

/* ---------- top bar ---------- */
.topbar {
    position: relative;
    z-index: 5;
    display: flex;
    align-items: center;
    gap: 12px;
    height: var(--topbar-h);
    padding: 0 10px 0 16px;
    background: var(--bg);
    border-bottom: 1px solid var(--line);
}

.wordmark {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
    font-size: 17px;
    letter-spacing: -0.01em;
    color: var(--ink);
    white-space: nowrap;
}
.wordmark .mark {
    display: inline-grid;
    place-items: center;
    width: 26px;
    height: 26px;
    border-radius: 7px;
    background: var(--ink);
    color: var(--bg);
    font-family: var(--font-code);
    font-size: 13px;
    font-weight: 700;
}

.project-switch {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    max-width: 280px;
    height: 32px;
    padding: 0 8px 0 10px;
    border: 1px solid transparent;
    border-radius: var(--radius);
    background: transparent;
    color: var(--ink);
    font-weight: 600;
    cursor: pointer;
}
.project-switch:hover { background: var(--sunken); }
.project-switch .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.project-switch svg { width: 14px; height: 14px; color: var(--muted); flex: none; }
.topbar .divider { width: 1px; height: 22px; background: var(--line); flex: none; }

.run-controls { display: flex; align-items: center; gap: 8px; margin-left: 8px; }

.btn.run {
    height: 34px;
    padding: 0 16px 0 12px;
    border-color: var(--run);
    background: var(--run);
    color: #fff;
    font-weight: 700;
}
.btn.run:hover:not(:disabled) { background: var(--run-hover); border-color: var(--run-hover); }
.btn.run kbd { font: inherit; font-weight: 400; font-size: 12px; opacity: 0.8; }

.btn.stop { height: 34px; color: var(--stop); border-color: var(--line-strong); font-weight: 600; }
.btn.stop:not(:disabled) { border-color: var(--stop); }
.btn.stop:hover:not(:disabled) { background: var(--stop-soft); }

/* The one loud thing: what the program is doing right now */
.status-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    height: 34px;
    max-width: 380px;
    padding: 0 14px 0 12px;
    border-radius: 17px;
    border: 1px solid var(--line);
    background: var(--panel);
    color: var(--muted);
    font-weight: 600;
    white-space: nowrap;
    cursor: default;
    transition: background-color 160ms ease, border-color 160ms ease, color 160ms ease;
}
.status-pill .text { overflow: hidden; text-overflow: ellipsis; }
.status-pill .dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--faint);
    flex: none;
}
.status-pill.running { color: var(--run); border-color: var(--run); background: var(--run-soft); }
.status-pill.running .dot { background: var(--run); animation: pulse 1.1s ease-in-out infinite; }
.status-pill.waiting { color: var(--wait); border-color: var(--wait); background: var(--wait-soft); }
.status-pill.waiting .dot { background: var(--wait); animation: pulse 1.6s ease-in-out infinite; }
.status-pill.done { color: var(--ink); }
.status-pill.done .dot { background: var(--run); }
.status-pill.error { color: var(--stop); border-color: var(--stop); background: var(--stop-soft); }
.status-pill.error .dot { background: var(--stop); border-radius: 2px; }
.status-pill.stopped .dot { background: var(--muted); border-radius: 2px; }
.status-pill.linked { cursor: pointer; }
.status-pill.linked:hover .text { text-decoration: underline; text-underline-offset: 3px; }

@keyframes pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.35; transform: scale(0.8); }
}
@media (prefers-reduced-motion: reduce) {
    .status-pill .dot { animation: none !important; }
}

.topbar .spacer { flex: 1; }
.topbar-tools { display: flex; align-items: center; gap: 4px; }

.text-size {
    display: inline-flex;
    align-items: center;
    height: 30px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--panel);
}
.text-size button {
    width: 28px;
    height: 28px;
    border: 0;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    font-weight: 700;
    border-radius: var(--radius);
}
.text-size button:hover { color: var(--ink); background: var(--sunken); }
.text-size output { min-width: 26px; text-align: center; font-variant-numeric: tabular-nums; color: var(--ink); font-size: 13px; }

.segmented {
    display: inline-flex;
    padding: 2px;
    gap: 2px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--panel);
}
.segmented button {
    display: inline-grid;
    place-items: center;
    width: 28px;
    height: 24px;
    border: 0;
    border-radius: 4px;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
}
.segmented button svg { width: 15px; height: 15px; }
.segmented button:hover { color: var(--ink); }
.segmented button[aria-pressed="true"] { background: var(--sunken); color: var(--ink); box-shadow: inset 0 0 0 1px var(--line-strong); }

/* ---------- workspace (dockview) ---------- */
.workspace {
    position: absolute;
    inset: var(--topbar-h) 0 0 0;
    /* clip, not hidden: a panel still sizing itself, or focus moving into one, must never scroll the page and cut off the top bar */
    overflow: clip;
}

.mj-dock {
    --dv-paneview-active-outline-color: var(--accent);
    --dv-tabs-and-actions-container-font-size: 13px;
    --dv-tabs-and-actions-container-height: 34px;
    --dv-drag-over-background-color: color-mix(in srgb, var(--accent) 22%, transparent);
    --dv-drag-over-border-color: var(--accent);
    --dv-drag-over-border: 2px solid var(--accent);
    --dv-edge-dock-indicator-color: var(--accent);
    --dv-tabs-container-scrollbar-color: var(--faint);
    --dv-icon-hover-background-color: var(--sunken);
    --dv-floating-box-shadow: var(--shadow);
    --dv-floating-border: 1px solid var(--line);
    --dv-overlay-z-index: 999;
    --dv-tab-font-size: inherit;
    --dv-border-radius: 0px;
    --dv-tab-margin: 0;
    --dv-sash-color: transparent;
    --dv-active-sash-color: var(--accent);
    --dv-active-sash-transition-duration: 0.1s;
    --dv-active-sash-transition-delay: 0.4s;
    --dv-spacing-padding: 0px;
    --dv-tab-border-radius: 0px;
    --dv-sash-border-radius: 0px;
    --dv-dropdown-border-radius: var(--radius);
    --dv-tab-close-icon-size: inherit;
    --dv-floating-group-border: none;
    --dv-floating-group-dragging-opacity: 0.5;
    --dv-floating-titlebar-height: 22px;
    --dv-floating-titlebar-background-color: var(--bg);
    --dv-floating-titlebar-border-bottom: 1px solid var(--line);

    --dv-group-view-background-color: var(--panel);
    --dv-tabs-and-actions-container-background-color: var(--bg);
    --dv-activegroup-visiblepanel-tab-background-color: var(--panel);
    --dv-activegroup-hiddenpanel-tab-background-color: var(--bg);
    --dv-inactivegroup-visiblepanel-tab-background-color: var(--panel);
    --dv-inactivegroup-hiddenpanel-tab-background-color: var(--bg);
    --dv-tab-divider-color: var(--line);
    --dv-activegroup-visiblepanel-tab-color: var(--ink);
    --dv-activegroup-hiddenpanel-tab-color: var(--muted);
    --dv-inactivegroup-visiblepanel-tab-color: var(--ink);
    --dv-inactivegroup-hiddenpanel-tab-color: var(--muted);
    --dv-separator-border: var(--line);
    --dv-paneview-header-border-color: var(--line);
    --dv-scrollbar-background-color: color-mix(in srgb, var(--ink) 25%, transparent);

    font-family: var(--font-ui);
    color: var(--ink);
}

.mj-dock .dv-tabs-and-actions-container { border-bottom: 1px solid var(--line); }
.mj-dock .dv-tab { padding: 0 2px; }
.mj-dock .dv-tab.dv-active-tab { box-shadow: inset 0 -2px 0 var(--line-strong); }
.mj-dock .dv-groupview.dv-active-group .dv-tab.dv-active-tab { box-shadow: inset 0 -2px 0 var(--accent); }
.mj-dock .dv-sash-container .dv-sash:hover { background: color-mix(in srgb, var(--accent) 40%, transparent); }

.panel-tab {
    display: flex;
    align-items: center;
    gap: 6px;
    height: 100%;
    padding: 0 8px;
    font-weight: 600;
    white-space: nowrap;
}
.panel-tab svg { width: 15px; height: 15px; color: var(--muted); }
.panel-tab .badge {
    min-width: 8px;
    height: 8px;
    border-radius: 4px;
    background: var(--wait);
}

.group-actions { display: flex; align-items: center; gap: 2px; height: 100%; padding: 0 6px; }

/* Every panel body: fills its box, scrolls inside */
.panel {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
    background: var(--panel);
    color: var(--ink);
    font-family: var(--font-ui);
    font-size: var(--ui-size);
}

.panel-toolbar {
    display: flex;
    align-items: center;
    gap: 4px;
    min-height: 38px;
    padding: 4px 8px;
    border-bottom: 1px solid var(--line);
    flex: none;
}
.panel-toolbar .spacer { flex: 1; }

.panel-empty {
    margin: auto;
    max-width: 30ch;
    padding: 24px 16px;
    color: var(--muted);
    text-align: center;
    line-height: 1.5;
}
.panel-empty strong { display: block; color: var(--ink); margin-bottom: 4px; }
.panel-empty .btn { margin-top: 12px; }

/* ---------- Files ---------- */
.files-body { flex: 1; overflow: auto; padding: 6px 0 16px; }
.files-body.drop-target { outline: 2px dashed var(--accent); outline-offset: -6px; background: var(--accent-soft); }

.file-section-title {
    display: flex;
    align-items: baseline;
    gap: 6px;
    margin: 10px 14px 4px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 600;
}
.file-section-title .count { color: var(--faint); font-weight: 400; }
.file-section-hint { margin: 2px 14px 6px; color: var(--faint); font-size: 13px; line-height: 1.4; }

.file-row {
    position: relative;
    display: flex;
    align-items: center;
    gap: 8px;
    height: 30px;
    margin: 0 6px;
    padding: 0 4px 0 8px;
    border-radius: 5px;
    cursor: pointer;
    user-select: none;
}
.file-row:hover { background: var(--sunken); }
.file-row.active { background: var(--accent-soft); }
.file-row .icon { display: inline-grid; place-items: center; width: 16px; color: var(--faint); flex: none; }
.file-row .icon svg { width: 15px; height: 15px; }
.file-row.java .icon { color: var(--syn-type); }
.file-row .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-row .main-tag {
    padding: 0 6px;
    border-radius: 9px;
    border: 1px solid var(--run);
    color: var(--run);
    font-size: 11.5px;
    font-weight: 700;
    line-height: 16px;
}
.file-row .more { opacity: 0; }
.file-row:hover .more, .file-row:focus-within .more, .file-row .more[aria-expanded="true"] { opacity: 1; }
.file-row.just-written .name::after {
    content: "written by program";
    margin-left: 8px;
    color: var(--run);
    font-size: 12px;
}

/* ---------- Editor ---------- */
.editor-tabs {
    display: flex;
    align-items: stretch;
    height: 34px;
    border-bottom: 1px solid var(--line);
    background: var(--bg);
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: thin;
    flex: none;
}
.editor-tab {
    position: relative;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 0 6px 0 12px;
    border-right: 1px solid var(--line);
    color: var(--muted);
    cursor: pointer;
    white-space: nowrap;
    user-select: none;
}
.editor-tab:hover { color: var(--ink); }
.editor-tab.active { background: var(--panel); color: var(--ink); }
.editor-tab.active::before {
    content: "";
    position: absolute;
    left: 0; right: 0; bottom: 0;
    height: 2px;
    background: var(--accent);
}
.editor-tab .main-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--run); }
.editor-tab.has-error .tab-name { text-decoration: underline wavy var(--stop); text-underline-offset: 4px; text-decoration-thickness: 1px; }
.editor-tab .close {
    display: inline-grid;
    place-items: center;
    width: 20px;
    height: 20px;
    border: 0;
    border-radius: 4px;
    background: transparent;
    color: var(--faint);
    cursor: pointer;
    visibility: hidden;
}
.editor-tab:hover .close, .editor-tab.active .close { visibility: visible; }
.editor-tab .close:hover { background: var(--sunken); color: var(--ink); }
.editor-tab .close svg { width: 12px; height: 12px; }

.editor-host { position: relative; flex: 1; min-height: 0; }
.editor-host .cm-editor { position: absolute; inset: 0; }

.editor-status {
    display: flex;
    align-items: center;
    gap: 16px;
    height: 26px;
    padding: 0 12px;
    border-top: 1px solid var(--line);
    background: var(--bg);
    color: var(--muted);
    font-size: 12.5px;
    flex: none;
    font-variant-numeric: tabular-nums;
}
.editor-status .spacer { flex: 1; }
.editor-status .save-state.pending { color: var(--wait); }
.editor-status .save-state.error { color: var(--stop); font-weight: 600; }

/* CodeMirror details the theme extension can't reach */
.cm-editor .cm-foldGutter .cm-gutterElement { opacity: 0; transition: opacity 120ms; cursor: pointer; }
.cm-editor .cm-gutters:hover .cm-foldGutter .cm-gutterElement { opacity: 1; }
.cm-editor .cm-lintRange-error {
    background-image: none;
    text-decoration: underline wavy var(--stop);
    text-decoration-thickness: 1.5px;
    text-underline-offset: 3px;
    text-decoration-skip-ink: none;
}
.cm-editor .cm-lintRange-warning {
    background-image: none;
    text-decoration: underline wavy var(--wait);
    text-decoration-thickness: 1.5px;
    text-underline-offset: 3px;
    text-decoration-skip-ink: none;
}
.cm-editor .cm-error-line { background: color-mix(in srgb, var(--stop) 9%, transparent); }
.cm-editor .cm-flash-line { animation: flash-line 1.4s ease-out; }
@keyframes flash-line {
    from { background: color-mix(in srgb, var(--accent) 28%, transparent); }
    to { background: transparent; }
}
@media (prefers-reduced-motion: reduce) {
    .cm-editor .cm-flash-line { animation: none; background: color-mix(in srgb, var(--accent) 14%, transparent); }
}

/* ---------- Console ---------- */
.console-out {
    flex: 1;
    min-height: 0;
    margin: 0;
    padding: 10px 14px 16px;
    overflow: auto;
    background: var(--panel);
    color: var(--ink);
    font-family: var(--font-code);
    font-size: var(--code-size);
    line-height: 1.45;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    tab-size: 8;
}
.console-out .stderr { color: var(--console-err); }
.console-out .warning { color: var(--console-warn); }
.console-out .stdin-echo { color: var(--console-echo); font-weight: 700; }
.console-out .note { color: var(--faint); font-style: italic; }
.console-out .src-link {
    color: inherit;
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 3px;
    cursor: pointer;
}
.console-out .src-link:hover { color: var(--accent); }
.console-placeholder { color: var(--faint); font-family: var(--font-ui); font-size: var(--ui-size); white-space: normal; }
.console-placeholder kbd {
    padding: 1px 5px;
    border: 1px solid var(--line-strong);
    border-bottom-width: 2px;
    border-radius: 4px;
    font: 12px var(--font-ui);
    color: var(--muted);
}

.console-input-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border-top: 1px solid var(--line);
    background: var(--bg);
    flex: none;
}
.console-input-row .prompt { color: var(--muted); font-family: var(--font-code); font-weight: 700; }
.console-input-row input {
    flex: 1;
    min-width: 0;
    height: 32px;
    padding: 0 10px;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius);
    background: var(--panel);
    font-family: var(--font-code);
    font-size: var(--code-size);
}
.console-input-row.waiting { background: var(--wait-soft); }
.console-input-row.waiting input { border-color: var(--wait); box-shadow: 0 0 0 2px color-mix(in srgb, var(--wait) 25%, transparent); }
.console-input-row.waiting .prompt { color: var(--wait); }

.pretyped {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 8px 10px 10px;
    border-bottom: 1px solid var(--line);
    background: var(--bg);
    flex: none;
}
.pretyped label { font-size: 13px; color: var(--muted); }
.pretyped textarea {
    height: 84px;
    min-height: 44px;
    padding: 6px 8px;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius);
    background: var(--panel);
    font-family: var(--font-code);
    font-size: calc(var(--code-size) - 1px);
    resize: vertical;
}

/* ---------- Instructions ---------- */
.instructions-body { flex: 1; overflow: auto; padding: 18px 22px 40px; }
.prose { max-width: 68ch; line-height: 1.6; font-size: 15px; }
.prose > :first-child { margin-top: 0; }
.prose h1 { font-size: 22px; line-height: 1.25; margin: 0 0 12px; }
.prose h2 { font-size: 18px; margin: 24px 0 8px; }
.prose h3 { font-size: 15.5px; margin: 20px 0 6px; }
.prose code { font-family: var(--font-code); font-size: 0.92em; padding: 1px 4px; border-radius: 4px; background: var(--sunken); }
.prose pre { padding: 10px 12px; border-radius: var(--radius); background: var(--sunken); overflow: auto; line-height: 1.45; }
.prose pre code { padding: 0; background: none; }
.prose a { color: var(--accent); }
.prose table { border-collapse: collapse; }
.prose th, .prose td { border: 1px solid var(--line); padding: 4px 8px; text-align: left; }
.prose blockquote { margin: 0; padding-left: 12px; border-left: 3px solid var(--line-strong); color: var(--muted); }

/* ---------- Graphics ---------- */
.graphics-body {
    flex: 1;
    min-height: 0;
    overflow: auto;
    display: flex;
    background:
        linear-gradient(var(--line) 1px, transparent 1px) 0 0 / 24px 24px,
        linear-gradient(90deg, var(--line) 1px, transparent 1px) 0 0 / 24px 24px,
        var(--panel);
}
.graphics-body .panel-empty { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); max-width: 40ch; }
.graphics-example {
    margin: 12px 0 0;
    padding: 8px 10px;
    border-radius: 6px;
    background: var(--sunken);
    color: var(--ink);
    font-family: var(--font-code);
    font-size: 12.5px;
    line-height: 1.45;
    text-align: left;
    white-space: pre;
    overflow: auto;
}
.graphics-pictures {
    margin: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 18px;
}
.sketch-figure { margin: 0; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.sketch-frame { line-height: 0; box-shadow: 0 0 0 1px var(--line-strong), var(--shadow); }
.sketch-canvas { display: block; background: #fff; cursor: crosshair; }
.sketch-figure figcaption { display: flex; align-items: center; gap: 4px; color: var(--muted); font-size: 12.5px; }
.graphics-coords { color: var(--muted); font-family: var(--font-code); font-size: 12.5px; padding-left: 4px; min-width: 12ch; }

/* a test's drawing: expected next to what the student's program drew */
.drawing-compare { display: flex; flex-wrap: wrap; gap: 14px; margin: 8px 0; }
.drawing-compare > div { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.drawing-compare .sketch-canvas { cursor: default; max-width: 100%; height: auto !important; }
.drawing-compare .sketch-frame { max-width: 100%; }
.drawing-none { color: var(--muted); font-style: italic; }

/* ---------- menus, dialogs, toasts ---------- */
.menu {
    position: fixed;
    z-index: 1000;
    min-width: 190px;
    padding: 5px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    box-shadow: var(--shadow);
}
.menu button {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    height: 32px;
    padding: 0 10px;
    border: 0;
    border-radius: 5px;
    background: transparent;
    text-align: left;
    cursor: pointer;
}
.menu button:hover, .menu button:focus-visible { background: var(--sunken); outline: none; }
.menu button svg { width: 15px; height: 15px; color: var(--muted); }
.menu button.danger { color: var(--stop); }
.menu button.danger svg { color: var(--stop); }
.menu hr { margin: 4px 2px; border: 0; border-top: 1px solid var(--line); }

dialog.mj-dialog {
    width: min(440px, calc(100vw - 32px));
    padding: 0;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--panel);
    color: var(--ink);
    box-shadow: var(--shadow);
}
dialog.mj-dialog.wide { width: min(760px, calc(100vw - 32px)); }
dialog.mj-dialog::backdrop { background: rgba(15, 20, 28, 0.45); }
.mj-dialog form { display: flex; flex-direction: column; gap: 12px; padding: 20px; margin: 0; }
.mj-dialog h2 { margin: 0; font-size: 18px; }
.mj-dialog p { margin: 0; color: var(--muted); line-height: 1.5; }
.mj-dialog label { display: flex; flex-direction: column; gap: 6px; font-weight: 600; font-size: 13.5px; }
.mj-dialog input[type="text"] {
    height: 36px;
    padding: 0 10px;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius);
    background: var(--panel);
    font-weight: 400;
}
.mj-dialog .problem { min-height: 1.4em; margin-top: -4px; color: var(--stop); font-size: 13.5px; }
.mj-dialog .field-label { font-weight: 600; font-size: 13.5px; margin-top: -2px; }
.mj-dialog .choices { display: flex; flex-direction: column; gap: 6px; }
.mj-dialog .choices label { flex-direction: row; align-items: flex-start; gap: 10px; font-weight: 400; padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--radius); cursor: pointer; }
.mj-dialog .choices label:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.mj-dialog .choices input { margin-top: 3px; }
.mj-dialog .choices .choice-title { font-weight: 600; }
.mj-dialog .choices .choice-hint { display: block; color: var(--muted); font-size: 13px; }
.mj-dialog .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 6px; }
.mj-dialog ul { margin: 0; padding-left: 18px; color: var(--muted); }

.versions { display: grid; grid-template-columns: 220px 1fr; gap: 12px; min-height: 320px; }
.versions .list { display: flex; flex-direction: column; gap: 2px; max-height: 420px; overflow: auto; }
.versions .list button {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 1px;
    padding: 7px 10px;
    border: 1px solid transparent;
    border-radius: var(--radius);
    background: transparent;
    text-align: left;
    cursor: pointer;
}
.versions .list button:hover { background: var(--sunken); }
.versions .list button[aria-selected="true"] { border-color: var(--accent); background: var(--accent-soft); }
.versions .list .when { font-weight: 600; }
.versions .list .size { color: var(--muted); font-size: 12.5px; }
.versions pre {
    margin: 0;
    max-height: 420px;
    padding: 10px 12px;
    overflow: auto;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--bg);
    font-family: var(--font-code);
    font-size: 13px;
    line-height: 1.45;
}

.toasts {
    position: fixed;
    z-index: 1100;
    right: 16px;
    bottom: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-width: min(420px, calc(100vw - 32px));
}
.toast {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 12px 10px 14px;
    border: 1px solid var(--line);
    border-left: 4px solid var(--accent);
    border-radius: 8px;
    background: var(--panel);
    box-shadow: var(--shadow);
    line-height: 1.45;
}
.toast.error { border-left-color: var(--stop); }
.toast.warning { border-left-color: var(--wait); }
.toast .msg { flex: 1; }
.toast .icon-btn { margin: -4px -6px -4px 0; }

/* ---------- Projects home ---------- */
body.home-open .run-controls { visibility: hidden; }
body.home-open .topbar-tools .text-size, body.home-open #resetLayout { display: none; }
.home {
    position: absolute;
    inset: var(--topbar-h) 0 0 0;
    z-index: 900;   /* above dockview's sashes and overlays */
    overflow: auto;
    background: var(--bg);
}
.home-inner { max-width: 880px; margin: 0 auto; padding: 36px 24px 64px; }
.home-head { display: flex; align-items: flex-end; gap: 12px; margin-bottom: 18px; }
.home-head h1 { margin: 0; font-size: 26px; letter-spacing: -0.01em; }
.home-head .spacer { flex: 1; }
.home-back { margin-bottom: 18px; }

.project-list { border: 1px solid var(--line); border-radius: 10px; background: var(--panel); overflow: hidden; }
.project-row {
    display: grid;
    grid-template-columns: 1fr 90px 150px 40px;
    align-items: center;
    gap: 12px;
    min-height: 56px;
    padding: 0 10px 0 18px;
    border-top: 1px solid var(--line);
}
.project-row:first-child { border-top: 0; }
.project-row:hover { background: var(--active-line); }
.project-row .open {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    min-width: 0;
    padding: 8px 0;
    border: 0;
    background: transparent;
    text-align: left;
    cursor: pointer;
}
.project-row .open .title { font-weight: 700; font-size: 15.5px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.project-row .open:hover .title { color: var(--accent); }
.project-row .open .current { color: var(--run); font-size: 12.5px; font-weight: 600; }
.project-row .meta { color: var(--muted); font-size: 13.5px; font-variant-numeric: tabular-nums; }
.examples { margin-top: 32px; }
.examples h2 { font-size: 1.1rem; margin: 0 0 4px; }
.project-row.example-row { grid-template-columns: 1fr auto; padding: 10px 14px 10px 18px; }
.example-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.example-text .title { font-weight: 600; }
.home-empty { padding: 48px 24px; text-align: center; color: var(--muted); }
.home-note { margin-top: 18px; color: var(--muted); font-size: 13.5px; line-height: 1.5; max-width: 68ch; }

@media (max-width: 640px) {
    .project-row { grid-template-columns: 1fr 40px; }
    .project-row .meta { display: none; }
}

/* Narrow windows: tools collapse first */
@media (max-width: 1000px) {
    .text-size, .wordmark .word { display: none; }
}
@media (max-width: 760px) {
    .run-controls .btn.run kbd, .status-pill { max-width: 160px; }
    .topbar-tools .segmented { display: none; }
}

/* Popped-out panel windows */
body.popout { overflow: hidden; background: var(--panel); }

/* ======================================================================
   Assignments (student side)
   ====================================================================== */

.toast.success { border-left-color: var(--run); }

/* Check and Submit sit beside Run, only in assignment mode */
.btn.check, .btn.submit { height: 34px; font-weight: 600; }
.btn.check { border-color: var(--accent); color: var(--accent); }
.btn.check:hover:not(:disabled) { background: var(--accent-soft); }
.btn.submit { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.submit:hover:not(:disabled) { background: var(--accent); filter: brightness(1.08); }
.btn.check[hidden], .btn.submit[hidden] { display: none; }

/* Locked code: grey, with the student's own parts standing out */
.cm-locked-line { background: color-mix(in srgb, var(--ink) 5%, var(--panel)); color: var(--muted); }
.cm-locked-line .cm-line, .cm-line.cm-locked-line { color: var(--muted); }
.cm-region-marker { font-size: 0.86em; }
/* The student's own parts: a tinted band with a clear label above and below */
.cm-region-line { background: color-mix(in srgb, var(--accent) 9%, var(--panel)); box-shadow: inset 4px 0 0 var(--accent); color: var(--ink); }
.cm-locked-line.cm-region-start, .cm-locked-line.cm-region-end { background: color-mix(in srgb, var(--accent) 20%, var(--panel)); box-shadow: inset 4px 0 0 var(--accent); color: var(--ink); }
.cm-region-start { border-top: 1px solid var(--accent); padding-top: 3px; padding-bottom: 3px; }
.cm-region-end { border-bottom: 1px solid var(--accent); }
.cm-region-banner.start { display: inline-flex; gap: 10px; align-items: baseline; font-family: var(--font-ui); color: var(--ink); }
.cm-region-banner.start strong { font-size: 1.05em; }
.cm-region-banner.start span { color: var(--muted); }
.cm-region-banner.end { font-family: var(--font-ui); color: var(--muted); font-size: 0.95em; }
/* Code the teacher chose not to show */
.cm-hidden-code { margin: 2px 0; padding: 4px 12px; font-family: var(--font-ui); font-style: italic; color: var(--muted);
    background: color-mix(in srgb, var(--ink) 5%, var(--panel)); border: 1px dashed var(--line-strong); border-radius: 4px; }
.cm-all-locked .cm-line { background: color-mix(in srgb, var(--ink) 5%, var(--panel)); }
.cm-all-locked .cm-content { cursor: default; }
.lock-note { color: var(--wait); font-weight: 600; margin-left: 12px; }
.editor-tab .tab-lock { display: inline-grid; place-items: center; width: 13px; color: var(--faint); }
.editor-tab .tab-lock svg { width: 12px; height: 12px; }

.assignment-facts { color: var(--muted); font-size: 13px; margin-bottom: 10px; }

/* ---------- Results ---------- */
.results-body { flex: 1; overflow: auto; padding: 14px 16px 32px; }
.results-head { display: flex; align-items: center; gap: 16px; margin-bottom: 12px; flex-wrap: wrap; }
.score-total { display: flex; align-items: baseline; gap: 10px; }
.score-number { font-size: 30px; font-weight: 700; letter-spacing: -0.01em; font-variant-numeric: tabular-nums; }
.score-label { color: var(--muted); font-size: 15px; }
.score-context { color: var(--muted); max-width: 40ch; }
.results-running { padding: 28px 8px; text-align: center; color: var(--muted); }
.results-problem, .results-compile {
    border: 1px solid var(--stop); background: var(--stop-soft); border-radius: var(--radius);
    padding: 12px 14px; margin-bottom: 14px; line-height: 1.5;
}
.results-problem strong, .results-compile strong { display: block; color: var(--stop); margin-bottom: 2px; }
.results-compile pre { margin: 10px 0; padding: 8px 10px; background: var(--panel); border-radius: 4px;
    font-family: var(--font-code); font-size: 13px; overflow: auto; white-space: pre; }

.part-list { display: grid; gap: 6px; margin: 4px 0 16px; }
.part-row { display: grid; grid-template-columns: minmax(70px, 120px) 1fr auto; align-items: center; gap: 10px; }
.part-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.part-bar { height: 8px; border-radius: 4px; background: var(--sunken); overflow: hidden; }
.part-bar .fill { display: block; height: 100%; background: var(--accent); }
.part-bar .fill.full { background: var(--run); }
.part-score { font-variant-numeric: tabular-nums; color: var(--muted); min-width: 4.5ch; text-align: right; }

.test-list { display: grid; gap: 4px; }
.test-part { margin: 12px 0 2px; font-weight: 600; color: var(--muted); font-size: 13px; }
.test-row { border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); }
.test-row.pass { border-color: color-mix(in srgb, var(--run) 40%, var(--line)); }
.test-row.fail { border-color: color-mix(in srgb, var(--stop) 45%, var(--line)); }
.hidden-summary { display: flex; align-items: flex-start; gap: 10px; margin-top: 8px; padding: 8px 10px; border: 1px dashed var(--line); border-radius: var(--radius); line-height: 1.45; }
.hidden-summary.fail { border-color: color-mix(in srgb, var(--stop) 45%, var(--line)); }
.test-summary { display: flex; align-items: center; gap: 10px; padding: 7px 10px; cursor: pointer; list-style: none; }
.test-summary::-webkit-details-marker { display: none; }
.test-summary:hover { background: var(--sunken); }
.status-icon { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; flex: none; }
.status-icon svg { width: 14px; height: 14px; stroke-width: 2.4; }
.status-icon.pass { background: var(--run-soft); color: var(--run); }
.status-icon.fail { background: var(--stop-soft); color: var(--stop); }
.status-icon.warn { background: var(--wait-soft); color: var(--wait); }
.test-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.test-status { color: var(--muted); font-size: 13px; }
.test-points { font-variant-numeric: tabular-nums; color: var(--muted); min-width: 4.5ch; text-align: right; }
.test-body { padding: 4px 12px 12px 42px; line-height: 1.5; }
.test-body p { margin: 6px 0; }
.test-body pre { margin: 6px 0; padding: 6px 8px; background: var(--sunken); border-radius: 4px; font-family: var(--font-code);
    font-size: 13px; overflow: auto; white-space: pre-wrap; word-break: break-word; }
.test-body .compare { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.test-body .compare-label { font-size: 12px; color: var(--muted); }
.test-body .hint { color: var(--ink); background: var(--accent-soft); border-radius: 4px; padding: 6px 8px; }

.attempts { margin-top: 24px; border-top: 1px solid var(--line); padding-top: 12px; }
.attempts h3 { margin: 0 0 4px; font-size: 14px; }
.attempts p { margin: 4px 0; color: var(--muted); }
.attempts .score-of-record { color: var(--ink); }
.attempt-list { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 2px; }
.attempt-list li { display: flex; align-items: center; gap: 12px; padding: 3px 6px; border-radius: 4px; }
.attempt-list li.counts { background: var(--accent-soft); }
.attempt-score { font-variant-numeric: tabular-nums; font-weight: 600; min-width: 7ch; }
.attempt-time { color: var(--muted); flex: 1; }
.counts-tag { font-size: 12px; color: var(--accent); font-weight: 600; }

/* Projects page: assignment projects and the sample list */
.project-row .tag { font-size: 12px; color: var(--accent); background: var(--accent-soft); border-radius: 10px; padding: 1px 8px; margin-left: 8px; }

.sample-assignments { margin-top: 36px; }
.sample-assignments h2 { font-size: 18px; margin: 0 0 8px; }
.sample-row { display: flex; align-items: center; gap: 14px; padding: 10px 4px; border-top: 1px solid var(--line); }
.sample-row:first-of-type { border-top: 0; }
.sample-text { flex: 1; min-width: 0; display: grid; gap: 2px; }
.sample-text span { color: var(--muted); }

/* ---------- Teacher tools ---------- */
.teacher-home .project-row { grid-template-columns: 1fr 80px 90px 40px; }
.editor-inner { max-width: 1180px; margin: 0 auto; padding: 20px 24px 64px; }
.editor-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.editor-head .home-back { margin: 0; }
.editor-head .spacer { flex: 1; }
.editor-title { margin: 0; font-size: 22px; letter-spacing: -0.01em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 40ch; }
.save-status { color: var(--muted); font-size: 13px; min-width: 7ch; text-align: right; }
.save-status.error { color: var(--stop); font-weight: 600; }

.tab-list { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 18px; flex-wrap: wrap; }
.tab-list .tab { border: 0; background: transparent; color: var(--muted); font: inherit; font-weight: 600; padding: 9px 14px;
    border-bottom: 3px solid transparent; margin-bottom: -1px; cursor: pointer; white-space: nowrap; }
.tab-list .tab:hover { color: var(--ink); }
.tab-list .tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.tab-list .tab:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; border-radius: 4px; }

.teacher-editor input[type=text], .teacher-editor input[type=number], .teacher-editor select, .teacher-editor textarea {
    width: 100%; box-sizing: border-box; font: inherit; color: var(--ink); background: var(--panel);
    border: 1px solid var(--line-strong); border-radius: var(--radius); padding: 6px 9px; }
.teacher-editor textarea { resize: vertical; line-height: 1.45; }
.teacher-editor textarea.mono, .teacher-editor input.mono, .instructions-text { font-family: var(--font-code); font-size: 13.5px; }
.teacher-editor input:focus-visible, .teacher-editor select:focus-visible, .teacher-editor textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 16px 18px; margin-bottom: 16px; max-width: 820px; }
.card h2 { margin: 0 0 10px; font-size: 17px; }
.field { display: grid; gap: 4px; margin-bottom: 12px; align-content: start; }
.field > label, .label-row label { font-weight: 600; font-size: 13.5px; }
.field-hint { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.45; }
.field-note.warn { color: var(--wait); background: var(--wait-soft); padding: 6px 10px; border-radius: 6px; }
.field-row { display: flex; gap: 12px; flex-wrap: wrap; }
.field-row > .field { flex: 1 1 200px; }
.field.narrow { flex: 0 0 110px; }
.field.grow { flex: 3 1 260px; }
.label-row { display: flex; align-items: center; gap: 8px; }
.label-row .spacer, .test-nav-head .spacer, .file-head .spacer, .test-form-head .spacer { flex: 1; }
.check-row { display: flex; gap: 8px; align-items: flex-start; margin: 8px 0; cursor: pointer; }
.check-row input { margin-top: 3px; }
.check-row small { display: block; color: var(--muted); font-size: 12.5px; }
.danger-text { color: var(--stop) !important; }
.button-row { display: flex; gap: 8px; flex-wrap: wrap; }

.part-edit { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; margin-bottom: 10px; background: var(--bg); }
.part-edit-head { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.part-edit-head .field { margin-bottom: 6px; }
.region-picks { display: flex; flex-wrap: wrap; gap: 4px 18px; }

.split { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; align-items: start; }
.instructions-text { min-height: 60vh; }
.instructions-preview { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 8px 22px 22px; min-height: 40vh; }
@media (max-width: 800px) { .split { grid-template-columns: 1fr; } }

.code-tab { display: grid; grid-template-columns: 220px 1fr; gap: 20px; align-items: start; }
.file-list { display: grid; gap: 4px; align-content: start; }
.file-list h3 { margin: 12px 0 2px; font-size: 13px; color: var(--muted); }
.file-list h3:first-child { margin-top: 0; }
.file-item { text-align: left; border: 1px solid transparent; background: transparent; color: var(--ink); font: inherit; padding: 5px 9px; border-radius: 6px; cursor: pointer; font-family: var(--font-code); font-size: 13px; overflow: hidden; text-overflow: ellipsis; }
.file-item:hover { background: var(--sunken); }
.file-item.active { background: var(--accent-soft); border-color: var(--accent); }
.file-list .btn { justify-self: start; margin-top: 4px; }
.file-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.file-head h2 { margin: 0; font-size: 18px; font-family: var(--font-code); }
.file-messages { list-style: none; margin: 0 0 10px; padding: 0; display: grid; gap: 4px; }
.file-messages li { padding: 6px 10px; border-radius: 6px; font-size: 13.5px; line-height: 1.4; }
.file-messages li.error { background: var(--stop-soft); color: var(--console-err); }
.file-messages li.warning { background: var(--wait-soft); color: var(--console-warn); }
.file-messages small { opacity: 0.8; }
.region-summary { color: var(--muted); margin-bottom: 10px; }
.code-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
.code-pair section { min-width: 0; }
.code-pair h3 { margin: 0; font-size: 14px; }
.box-tools { display: flex; gap: 6px; flex-wrap: wrap; margin: 6px 0; min-height: 26px; }
@media (max-width: 1000px) { .code-pair, .code-tab { grid-template-columns: 1fr; } }

.code-box { border: 1px solid var(--line-strong); border-radius: var(--radius); background: var(--panel); overflow: hidden; }
.code-box .cm-editor { min-height: calc(var(--min-lines, 3) * 1.55em + 12px); max-height: calc(var(--max-lines, 40) * 1.55em + 12px); font-size: 13.5px; }
.code-box .cm-scroller { overflow: auto; font-family: var(--font-code); }
.code-box .cm-editor.cm-focused { outline: 2px solid var(--accent); outline-offset: -1px; }

.tests-tab { display: grid; grid-template-columns: 300px 1fr; gap: 20px; align-items: start; }
.test-nav-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.test-nav-head h2, .test-form-head h2 { margin: 0; font-size: 17px; }
.test-edit-list { border: 1px solid var(--line); border-radius: 8px; background: var(--panel); overflow: hidden; }
.test-edit-row { display: flex; align-items: center; border-top: 1px solid var(--line); padding-right: 4px; }
.test-edit-row:first-child { border-top: 0; }
.test-pick { flex: 1; min-width: 0; display: grid; grid-template-columns: 1fr auto; gap: 0 8px; text-align: left; border: 0; background: transparent; font: inherit; color: var(--ink); padding: 8px 10px; cursor: pointer; }
.test-pick:hover { background: var(--active-line); }
.test-pick.active { background: var(--accent-soft); }
.test-pick-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.test-pick-meta { grid-column: 1; color: var(--muted); font-size: 12.5px; }
.test-pick-points { grid-row: 1; grid-column: 2; color: var(--muted); font-variant-numeric: tabular-nums; font-size: 13px; }
.test-total { margin-top: 8px; }
.test-form { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 16px 18px; min-width: 0; }
.test-form-head { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.more { margin: 10px 0; }
.more summary { cursor: pointer; font-weight: 600; }
.try-one { margin-top: 18px; padding-top: 12px; border-top: 1px solid var(--line); }
.try-one h3 { margin: 0 0 8px; font-size: 14px; }
.try-result { margin-top: 10px; }
.try-status { font-weight: 700; margin: 0 0 6px; }
.try-status.pass { color: var(--run); }
.try-status:not(.pass) { color: var(--console-err); }
.try-result pre, .try-out pre { margin: 6px 0; padding: 6px 8px; background: var(--sunken); border-radius: 4px; font-family: var(--font-code); font-size: 13px; overflow: auto; white-space: pre-wrap; }
.try-result .compare { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.try-result .compare-label { font-size: 12px; color: var(--muted); }
@media (max-width: 900px) { .tests-tab { grid-template-columns: 1fr; } }

.result-table { width: 100%; border-collapse: collapse; }
.result-table td { padding: 6px 8px; border-top: 1px solid var(--line); }
.result-table td.num { text-align: right; font-variant-numeric: tabular-nums; }
.result-table tr.pass td:nth-child(2) { color: var(--run); }
.result-table tr:not(.pass) td:nth-child(2) { color: var(--console-err); }

/* Preview as a student: a clear way back to the editor */
.btn.exit-preview { height: 34px; font-weight: 600; border-color: var(--wait); color: var(--wait); background: var(--wait-soft); white-space: nowrap; }
.btn.exit-preview:hover { background: var(--wait-soft); filter: brightness(0.97); }
.btn.exit-preview[hidden] { display: none; }
body.previewing .topbar { box-shadow: inset 0 -3px 0 var(--wait); }

/* In an assignment, students Run their program as usual, then Check and Submit */

body.assignment-mode .status-pill { display: none; }

/* exercise.html: a coding exercise opened from Mathesis */
.hosted-info { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.hosted-status { font-size: 12px; color: var(--muted); white-space: nowrap; padding: 2px 8px; border-radius: 99px; }
.hosted-status:empty { display: none; }
.hosted-status.ok { color: var(--run); background: var(--run-soft); }
.hosted-status.error { color: var(--stop); background: var(--stop-soft); }
body[data-page="exercise"] #projectButton:disabled { cursor: default; opacity: 1; color: inherit; }
.exercise-stop { position: fixed; inset: 56px 0 0; display: grid; place-items: center; padding: 24px; }
.exercise-stop-card { max-width: 520px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 24px 28px; }
.exercise-stop-card h1 { margin: 0 0 8px; font-size: 22px; }
.exercise-stop-card p { margin: 0; line-height: 1.5; color: var(--muted); }
/* Mathesis keeps the attempts; this browser's list would be incomplete */
body[data-page="exercise"] .results-panel .attempts { display: none; }

/* regrade.html */
body[data-page="regrade"] { overflow: auto; }
.regrade { display: grid; place-items: start center; padding: 40px 20px; }
.regrade-card { width: min(640px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 24px 28px; line-height: 1.5; }
.regrade-card h1 { margin: 0 0 8px; font-size: 22px; }
.regrade-card progress { width: 100%; height: 10px; margin: 8px 0 14px; }
#rgStatus.ok { color: var(--run); }
#rgStatus.error { color: var(--stop); }
.regrade-card .btn { display: inline-flex; margin-top: 12px; text-decoration: none; }
.drawing-pictures { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.drawing-preview { margin-top: 8px; }
