:root {
    --bg-default: #1e1e1e;
    --bg-surface: #252526;
    --bg-subdued: #2d2d30;
    --neutral-medium: #8b8b8b;
    --neutral-heavy: #cccccc;
    --neutral-trim: #3e3e42;
    --interactive-medium: #9d9d9d;
    --interactive-selected: #ffffff;
    --accent: #0a84ff;
    --accent-hover: #409cff;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: monospace;
    background-color: var(--bg-default);
    color: var(--neutral-heavy);
    height: 100vh;
    overflow: hidden;
}

.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

.app-header {
    background-color: var(--bg-default);
    border-bottom: 6px solid var(--accent-hover);
    height: 6px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.header-left,
.header-right {
    position: absolute;
    top: 17px;
    display: flex;
    align-items: center;
    gap: 12px;
    z-index: 10;
}

.header-left {
    left: 10px;
}

.header-right {
    right: 10px;
}

.title-pill {
    display: flex;
    align-items: center;
    background-color: var(--neutral-trim);
    border-radius: 12px;
    padding: 6px 12px;
}

.title-pill h1 {
    font-size: 0.9rem;
    font-weight: 400;
    line-height: 1;
    color: var(--neutral-heavy);
}

.workspace {
    flex: 1;
    overflow: hidden;
    padding-top: 47px;
}

.split-container {
    height: 100%;
    display: flex;
    background-color: var(--bg-surface);
}

.explorer-resizer {
    width: 6px;
    flex: 0 0 6px;
    background-color: var(--bg-default);
    border-right: 1px solid var(--neutral-trim);
    cursor: col-resize;
    transition: background-color 120ms ease;
}

.explorer-resizer:hover,
.explorer-resizer.dragging {
    background-color: var(--neutral-trim);
}

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

.explorer-resizer.hidden {
    display: none;
}

.repl-pane {
    width: 100%;
    min-width: 320px;
    height: 100%;
    background-color: var(--bg-subdued);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.repl-pane.full-width {
    width: 100%;
}

.file-explorer-pane {
    width: 280px;
    min-width: 220px;
    max-width: 320px;
    border-right: 1px solid var(--neutral-trim);
    background-color: var(--bg-default);
    display: flex;
    flex-direction: column;
}

.file-explorer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    border-bottom: 1px solid var(--neutral-trim);
    font-size: 0.85rem;
    color: var(--neutral-medium);
}

.file-explorer-toggle {
    border: 0;
    background-color: transparent;
    color: var(--interactive-medium);
    font-family: monospace;
    font-size: 1rem;
    min-width: 40px;
    height: 28px;
    padding: 0;
    border-radius: 0;
    cursor: pointer;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
}

.file-explorer-toggle:hover {
    color: var(--interactive-selected);
}

.file-explorer-icon {
    width: 20px;
    height: 20px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transform: translateX(3px);
}

.file-explorer-pane.collapsed .file-explorer-icon {
    transform: translateX(3px);
}

.file-explorer-icon svg {
    width: 20px;
    height: 20px;
    display: block;
}

.file-explorer-chevron {
    font-size: 1.5rem;
}

.file-explorer-refresh {
    border: 0;
    background-color: transparent;
    color: var(--interactive-medium);
    width: 28px;
    height: 28px;
    padding: 0;
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.file-explorer-refresh:hover {
    color: var(--interactive-selected);
}

.file-explorer-refresh:focus-visible {
    outline: 1px solid var(--accent);
    outline-offset: 1px;
}

.file-explorer-refresh svg {
    width: 16px;
    height: 16px;
    display: block;
}

.file-explorer-pane.collapsed {
    width: 52px;
    min-width: 52px;
    max-width: 52px;
}

.file-explorer-pane.collapsed .file-list,
.file-explorer-pane.collapsed .file-list-empty,
.file-explorer-pane.collapsed .file-list-separator,
.file-explorer-pane.collapsed .file-row,
.file-explorer-pane.collapsed .file-space-footer {
    display: none;
}

.file-explorer-pane.collapsed .file-explorer-refresh {
    display: none;
}

.file-explorer-pane.collapsed .file-explorer-header {
    justify-content: center;
    padding: 10px 0;
}

body.is-resizing-explorer,
body.is-resizing-explorer * {
    cursor: col-resize !important;
    user-select: none;
}

.file-list {
    flex: 1;
    overflow-y: auto;
    padding: 6px;
}

.file-space-footer {
    white-space: pre-line;
    cursor: pointer;
    border-top: 1px solid var(--neutral-trim);
    padding: 8px 10px;
    font-size: 0.78rem;
    color: var(--neutral-medium);
    text-transform: lowercase;
}

.file-list-empty {
    padding: 8px;
    color: var(--neutral-medium);
    font-size: 0.85rem;
}

.file-list-separator {
    height: 1px;
    background-color: var(--neutral-trim);
    margin: 6px 8px;
}

.file-row {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 6px 8px;
    border-radius: 6px;
}

.file-row:hover {
    background-color: var(--bg-surface);
}

.file-main {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    flex: 1;
}

.file-play-btn {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: 1px solid var(--neutral-trim);
    background-color: transparent;
    color: var(--interactive-medium);
    font-family: monospace;
    font-size: 0.72rem;
    line-height: 1;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    padding-left: 1px;
}

.file-play-btn:hover {
    color: var(--interactive-selected);
    border-color: var(--interactive-medium);
}

.file-play-spacer {
    width: 22px;
    height: 22px;
    flex-shrink: 0;
}

.file-label {
    font-size: 0.85rem;
    color: var(--neutral-heavy);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.file-first-pill {
    border: 0;
    background-color: var(--neutral-heavy);
    color: #000;
    font-family: monospace;
    font-size: 0.68rem;
    line-height: 1;
    padding: 4px 6px 2px;
    border-radius: 999px;
    text-transform: lowercase;
    flex-shrink: 0;
}

.file-menu-btn {
    border: 1px solid var(--neutral-trim);
    background-color: var(--bg-surface);
    color: var(--interactive-medium);
    font-family: monospace;
    font-size: 1rem;
    width: 24px;
    height: 24px;
    border-radius: 6px;
    cursor: pointer;
    line-height: 0.9;
}

.file-menu-btn:hover {
    color: var(--interactive-selected);
    border-color: var(--interactive-medium);
}

.file-menu {
    position: absolute;
    top: 30px;
    right: 8px;
    display: none;
    z-index: 20;
    min-width: 148px;
    background-color: var(--bg-surface);
    border: 1px solid var(--neutral-trim);
    border-radius: 8px;
    padding: 4px;
}

.file-menu.open {
    display: block;
}

.file-menu-item {
    width: 100%;
    text-align: left;
    border: 0;
    background: transparent;
    color: var(--neutral-heavy);
    font-family: monospace;
    font-size: 0.84rem;
    padding: 6px 8px;
    border-radius: 6px;
    cursor: pointer;
}

.file-menu-item:hover {
    background-color: var(--bg-default);
}

.repl-content {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
}

/* virtual grid: a drawer at the top of the console */
.grid-drawer {
    border-bottom: 1px solid var(--neutral-trim);
    background-color: var(--bg-default);
}

/* When the console is short (editor stacked above it), the drawers give up
   space before the output does; the input line never shrinks. */
.grid-drawer,
.midi-drawer {
    display: flex;
    flex-direction: column;
    flex: 0 1 auto;
    min-height: 0;
}

/* the grid keeps its minimum size; the MIDI list can shrink to its bar */
.grid-drawer.open {
    /* its bar plus the grid's minimum */
    min-height: 150px;
}

.midi-drawer {
    flex-shrink: 4;
    min-height: 31px;
    overflow: hidden;
}

.repl-input-container {
    flex: none;
}

.grid-drawer .midi-drawer-bar,
.midi-drawer .midi-drawer-bar {
    flex: none;
}

.grid-drawer[hidden],
.grid-drawer:not(.open) .grid-body {
    display: none;
}

/* resized from the divider under it (js/dividers.js); the grid scales to fit */
.grid-body {
    display: flex;
    justify-content: center;
    flex: 0 1 auto;
    height: 230px;
    min-height: 120px;
    max-height: 85vh;
    overflow: hidden;
    padding: 6px 12px 10px;
    container-type: size;
}

/* as large as fits while keeping keys square (--grid-ratio: columns / rows) */
.grid-cells {
    display: grid;
    /* gaps shrink with the grid, so small grids keep usable keys */
    gap: clamp(1px, 1.6cqh, 4px);
    width: min(100cqw, calc(100cqh * var(--grid-ratio, 2)));
    height: min(100cqh, calc(100cqw / var(--grid-ratio, 2)));
    touch-action: none;
    user-select: none;
}

.grid-cells.offline {
    opacity: 0.4;
}

.grid-cell {
    border-radius: 3px;
    border: 1px solid var(--neutral-trim);
    background-color: var(--bg-subdued);
    cursor: pointer;
}

.grid-cell.pressed {
    border-color: var(--accent-hover);
}

/* latched with shift-click or right-click: stays down until clicked again */
.grid-cell.held {
    border-color: var(--accent);
    box-shadow: inset 0 0 0 2px var(--accent);
}

.grid-hint {
    font-size: 0.75rem;
    color: var(--neutral-medium);
}

.grid-controls [hidden],
.grid-drawer:not(.open) .grid-controls {
    display: none;
}

/* phones: multi-touch already holds keys, and the bar has no room */
@media (max-width: 600px) {
    .grid-hint {
        display: none;
    }
}

.repl-action-btn.active {
    color: var(--interactive-selected);
    border-color: var(--accent);
}

.repl-output-area {
    position: relative;
    flex: 1;
    /* the drawers around it shrink first */
    min-height: 60px;
}

.repl-output {
    height: 100%;
    overflow-y: auto;
    padding: 16px;
    font-size: 0.9rem;
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-word;
}

.output-cleanup-btn {
    position: absolute;
    right: 12px;
    top: 12px;
    z-index: 5;
}

.repl-output a {
    color: var(--accent-hover);
}

.repl-output .output-file-link {
    text-decoration: underline dotted;
    cursor: pointer;
}

.repl-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-top: 1px solid var(--neutral-trim);
    border-bottom: 1px solid var(--neutral-trim);
    background-color: var(--bg-default);
}

.repl-actions-spacer {
    flex: 1;
}

.repl-status-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background-color: var(--bg-surface);
    border: 1px solid var(--neutral-trim);
    border-radius: 999px;
    padding: 6px 10px;
    cursor: pointer;
    transition:
        color 0.2s,
        border-color 0.2s;
}

.repl-status-pill:hover {
    color: var(--interactive-selected);
    border-color: var(--interactive-medium);
}

.header-left .repl-status-pill {
    margin-left: 2px;
}

.repl-status-indicator {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background-color: var(--neutral-medium);
}

.repl-status-indicator.connected {
    background-color: var(--accent);
}

.repl-status-text {
    font-size: 0.9rem;
    font-weight: 400;
    line-height: 1;
    color: var(--neutral-heavy);
}

.repl-connection-btn,
.repl-action-btn {
    border: 1px solid var(--neutral-trim);
    background-color: var(--bg-surface);
    color: var(--interactive-medium);
    font-family: monospace;
    font-size: 0.85rem;
    padding: 6px 10px;
    border-radius: 6px;
    cursor: pointer;
    text-decoration: none;
    transition:
        color 0.2s,
        border-color 0.2s;
}

.repl-connection-btn:hover,
.repl-action-btn:hover {
    color: var(--interactive-selected);
    border-color: var(--interactive-medium);
}

.repl-input-container {
    padding: 12px;
    background-color: var(--bg-subdued);
}

.repl-input-row {
    position: relative;
}

.repl-input-prompt {
    position: absolute;
    top: 10px;
    left: 10px;
    color: var(--neutral-medium);
    font-family: monospace;
    font-size: 0.9rem;
    line-height: 1.4;
    user-select: none;
    pointer-events: none;
}

.repl-input {
    width: 100%;
    flex: 1;
    min-height: 68px;
    max-height: 220px;
    resize: vertical;
    border: 1px solid var(--neutral-trim);
    border-radius: 8px;
    background-color: var(--bg-surface);
    color: var(--interactive-selected);
    font-family: monospace;
    font-size: 0.9rem;
    line-height: 1.4;
    padding: 10px 10px 10px 36px;
    outline: none;
}

.repl-input:focus {
    border-color: var(--accent);
}

/* --- script editor ---------------------------------------------------- */

.split-container {
    position: relative;
}

/* console + editor, side by side or stacked (editor on top) */
.work-area {
    flex: 1;
    min-width: 0;
    display: flex;
    position: relative;
}

.work-area.stacked {
    flex-direction: column;
}

.work-area.stacked .editor-pane {
    order: 0;
    min-width: 0;
    min-height: 120px;
}

.work-area.stacked .editor-resizer {
    order: 1;
    width: auto;
    height: 6px;
    flex: 0 0 6px;
    cursor: row-resize;
    border-left: 0;
    border-top: 1px solid var(--neutral-trim);
}

.work-area.stacked .repl-pane {
    order: 2;
    min-width: 0;
    min-height: 160px;
}

/* the divider under a drawer (js/dividers.js): drag to set its height */
.pane-divider {
    flex: 0 0 6px;
    height: 6px;
    cursor: row-resize;
    border-top: 1px solid var(--neutral-trim);
    background: transparent;
    touch-action: none;
}

.pane-divider:hover,
.pane-divider.dragging,
.pane-divider:focus-visible {
    background: var(--accent);
    outline: none;
}

.patch-drawer:not(.open) > .pane-divider,
.ach-drawer:not(.open) > .pane-divider,
.grid-drawer:not(.open) > .pane-divider {
    display: none;
}

body.is-resizing-editor-rows,
body.is-resizing-editor-rows * {
    cursor: row-resize !important;
    user-select: none;
}

.editor-resizer[hidden],
.editor-pane[hidden] {
    display: none;
}

/* hidden editor: a strip with the file name; click to bring it back */
.editor-expand {
    display: none;
}

.editor-pane.collapsed,
.work-area.stacked .editor-pane.collapsed {
    flex: 0 0 36px !important;
    min-width: 36px;
    min-height: 36px;
}

.editor-pane.collapsed .editor-header,
.editor-pane.collapsed .editor-host {
    display: none;
}

.editor-pane.collapsed .editor-expand {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 8px;
    width: 100%;
    height: 100%;
    padding: 12px 8px;
    border: 0;
    border-left: 1px solid var(--neutral-trim);
    background-color: var(--bg-default);
    color: var(--interactive-medium);
    font-family: monospace;
    font-size: 0.85rem;
    cursor: pointer;
    writing-mode: vertical-rl;
}

.work-area.stacked .editor-pane.collapsed .editor-expand {
    writing-mode: horizontal-tb;
    padding: 8px 12px;
    border-left: 0;
    border-bottom: 1px solid var(--neutral-trim);
}

.editor-pane.collapsed .editor-expand:hover {
    color: var(--interactive-selected);
}

/* device actions next to the connection status */
.device-menu-wrap {
    position: relative;
}

.device-menu {
    top: 36px;
    left: 0;
    right: auto;
}

.file-explorer-new {
    font-family: monospace;
    font-size: 1.3rem;
    line-height: 1;
}

.file-explorer-pane.collapsed .file-explorer-header .repl-actions-spacer {
    display: none;
}

.editor-resizer {
    border-right: 0;
    border-left: 1px solid var(--neutral-trim);
}

/* shares the space with the console until resized (then a fixed width) */
.editor-pane {
    flex: 1 1 0;
    min-width: 320px;
    display: flex;
    flex-direction: column;
    background-color: var(--bg-default);
}

.repl-pane {
    flex: 1 1 0;
}

/* the console gets narrow next to the editor */
.repl-actions {
    flex-wrap: wrap;
}

.editor-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-bottom: 1px solid var(--neutral-trim);
}

.editor-title {
    font-size: 0.85rem;
    color: var(--neutral-heavy);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.editor-dirty {
    color: var(--accent-hover);
    font-size: 0.8rem;
}

.editor-dirty[hidden] {
    display: none;
}

.editor-close-btn {
    border: 0;
    background: transparent;
    color: var(--interactive-medium);
    font-family: monospace;
    font-size: 0.95rem;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    cursor: pointer;
}

.editor-close-btn:hover {
    color: var(--interactive-selected);
    background-color: var(--bg-surface);
}

/* the wrap toggle while wrapping is on */
.editor-wrap-btn.active {
    color: var(--accent-hover);
}

.editor-host {
    flex: 1;
    min-height: 0;
    display: flex;
}

.editor-host > .prism-code-editor {
    flex: 1;
    height: 100%;
    font-family: monospace;
    font-size: 0.85rem;
    line-height: 1.5;
}

/* Editor colors: diii's palette, VS Code Dark+ token colors */
.prism-code-editor {
    color-scheme: dark;
    --pce-bg: var(--bg-default);
    --pce-cursor: var(--interactive-selected);
    --pce-selection: #264f78;
    --pce-selection-match: #3a3d41;
    --pce-bg-highlight: #ffffff0a;
    --pce-line-number: #6e7681;
    --pce-guide-indent: #ffffff1a;
    --pce-scrollbar: 0, 0%, 35%;
    --pce-search-match: #623315;
    --pce-widget-bg: var(--bg-surface);
    --pce-widget-border: var(--neutral-trim);
    --pce-widget-color: var(--neutral-heavy);
    --pce-widget-color-active: var(--interactive-selected);
    --pce-widget-color-options: var(--neutral-medium);
    --pce-widget-bg-input: var(--bg-default);
    --pce-widget-bg-hover: #5a5d5e4f;
    --pce-widget-bg-active: #0a84ff40;
    --pce-widget-focus: var(--accent);
    --pce-widget-bg-error: #5a1d1d;
    --pce-widget-error: #f48771;
    color: #d4d4d4;
}

/* autocomplete list and hover help */
.prism-code-editor {
    --pce-ac-match: #18a3ff;
    --pce-tabstop: #ffffff1f;
    --pce-ac-icon-function: #dcdcaa;
    --pce-ac-icon-event: #ce9178;
    --pce-ac-icon-keyword: #569cd6;
    --pce-ac-icon-variable: #9cdcfe;
}

.pce-hover-tooltip {
    background: var(--bg-surface);
    border: 1px solid var(--neutral-trim);
    border-radius: 6px;
    padding: 6px 8px;
    color: var(--neutral-heavy);
    font-family: monospace;
    font-size: 0.8rem;
    box-shadow: 0 4px 14px #0008;
}

.api-sig {
    display: block;
    color: #dcdcaa;
    margin-bottom: 4px;
    white-space: pre-wrap;
}

.api-doc {
    color: var(--neutral-heavy);
    white-space: normal;
    line-height: 1.4;
}

/* MIDI monitor: a drawer above the button bar */
.midi-drawer {
    border-top: 1px solid var(--neutral-trim);
    background-color: var(--bg-default);
}

.midi-drawer-bar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    padding: 4px 12px;
    font-size: 0.8rem;
    color: var(--neutral-medium);
}

.midi-toggle {
    border: 0;
    background: transparent;
    color: var(--interactive-medium);
    font-family: monospace;
    font-size: 0.85rem;
    cursor: pointer;
    padding: 2px 0;
}

.midi-toggle:hover {
    color: var(--interactive-selected);
}

.midi-controls {
    display: flex;
    align-items: center;
    gap: 10px;
}

.midi-controls label {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    cursor: pointer;
}

.midi-controls .repl-action-btn {
    padding: 2px 8px;
    font-size: 0.78rem;
}

.midi-drawer:not(.open) .midi-controls,
.midi-drawer:not(.open) .midi-body {
    display: none;
}

.midi-note {
    padding: 6px 12px;
    font-size: 0.8rem;
    color: var(--neutral-medium);
}

.midi-note[hidden] {
    display: none;
}

/* resizable from its bottom-right corner */
.midi-body {
    display: flex;
    flex-direction: column;
    flex: 0 4 auto;
    min-height: 0;
}

.midi-list {
    /* gives up space before the grid does */
    flex: 0 4 auto;
    height: 160px;
    min-height: 50px;
    max-height: 85vh;
    overflow-y: auto;
    padding: 2px 12px 6px;
    font-size: 0.8rem;
    line-height: 1.5;
    border-top: 1px solid var(--bg-subdued);
}

.midi-row {
    display: grid;
    grid-template-columns: 5.5em 4.5em 3.5em 1fr auto;
    gap: 8px;
    white-space: nowrap;
}

.midi-time,
.midi-raw {
    color: var(--neutral-medium);
}

.midi-in .midi-dir {
    color: #9cdcfe;
}

.midi-out .midi-dir {
    color: #ce9178;
}

.midi-text {
    color: var(--neutral-heavy);
    overflow: hidden;
    text-overflow: ellipsis;
}

.midi-kind-clock .midi-text,
.midi-kind-active_sensing .midi-text {
    color: var(--neutral-medium);
}

/* a newer diii was published */
.app-update-btn {
    color: #fff !important;
    background-color: var(--accent) !important;
    border-color: var(--accent) !important;
}

.app-update-btn:hover {
    background-color: var(--accent-hover) !important;
}

.app-update-btn[hidden] {
    display: none !important;
}

/* firmware version and updates */
.firmware-content {
    display: flex;
    flex-direction: column;
    width: min(620px, 100%);
    padding: 0;
}

.firmware-title {
    font-size: 0.95rem;
    font-weight: 400;
    margin: 0 !important;
}

.firmware-body {
    padding: 8px 16px 16px;
    font-size: 0.85rem;
    line-height: 1.5;
}

.firmware-body p {
    color: var(--neutral-heavy) !important;
    margin: 6px 0 !important;
}

.firmware-update {
    color: var(--accent-hover) !important;
}

.firmware-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 10px 0 4px;
}

.firmware-steps {
    padding-left: 20px;
    color: var(--neutral-heavy);
}

.firmware-steps li {
    margin: 6px 0;
}

.firmware-steps .repl-action-btn {
    padding: 2px 8px;
}

/* a newer firmware release exists */
.has-update::after {
    content: ' ●';
    color: var(--accent-hover);
}

/* offline iii reference */
.reference-content {
    display: flex;
    flex-direction: column;
    width: min(760px, 100%);
    height: min(80vh, 760px);
    padding: 0;
}

.reference-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    border-bottom: 1px solid var(--neutral-trim);
}

.reference-search {
    flex: 1;
    min-width: 0;
    border: 1px solid var(--neutral-trim);
    border-radius: 6px;
    background-color: var(--bg-default);
    color: var(--interactive-selected);
    font-family: monospace;
    font-size: 0.9rem;
    padding: 6px 10px;
    outline: none;
}

.reference-search:focus {
    border-color: var(--accent);
}

.reference-list {
    flex: 1;
    overflow-y: auto;
    padding: 4px 16px 16px;
}

.reference-group {
    margin: 16px 0 6px;
    font-size: 0.78rem;
    font-weight: 400;
    color: var(--neutral-medium);
    text-transform: lowercase;
    letter-spacing: 0.05em;
}

.reference-entry {
    padding: 6px 0;
    border-bottom: 1px solid var(--bg-subdued);
}

.reference-entry code {
    color: #dcdcaa;
    font-size: 0.88rem;
}

.reference-entry p {
    margin: 2px 0 0;
    color: var(--neutral-heavy);
    font-size: 0.82rem;
    line-height: 1.45;
}

.reference-empty {
    margin-top: 16px;
    color: var(--neutral-medium);
}

.prism-code-editor .active-line {
    --pce-line-number: var(--neutral-heavy);
}

.prism-code-editor .active-indent {
    --pce-guide-indent: #ffffff3d;
}

.prism-code-editor .token.keyword {
    color: #569cd6;
}

.prism-code-editor .token.string {
    color: #ce9178;
}

.prism-code-editor .token.number,
.prism-code-editor .token.boolean,
.prism-code-editor .token.constant {
    color: #b5cea8;
}

.prism-code-editor .token.comment {
    color: #6a9955;
}

.prism-code-editor .token.function {
    color: #dcdcaa;
}

.prism-code-editor .token.operator,
.prism-code-editor .token.punctuation {
    color: #d4d4d4;
}

.prism-code-editor .token.bracket-level-0,
.prism-code-editor .token.bracket-level-3 {
    color: #ffd700;
}

.prism-code-editor .token.bracket-level-1,
.prism-code-editor .token.bracket-level-4 {
    color: #da70d6;
}

.prism-code-editor .token.bracket-level-2,
.prism-code-editor .token.bracket-level-5 {
    color: #179fff;
}

.prism-code-editor .active-bracket {
    box-shadow: inset 0 0 0 1px #888888;
}

.prism-code-editor .word-matches span {
    box-shadow: inset 0 0 0 9in #ffffff14;
}

.modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 16px;
}

.modal-content {
    width: min(700px, 100%);
    max-height: 90vh;
    overflow: auto;
    background: var(--bg-surface);
    border: 1px solid var(--neutral-trim);
    border-radius: 12px;
    padding: 16px;
}

.modal-content h2 {
    font-size: 1rem;
    margin-bottom: 8px;
}

.modal-content p {
    color: var(--neutral-medium);
    margin-bottom: 8px;
}

/* drag files over the page, then upload progress */
.upload-modal {
    pointer-events: none; /* drag events keep reaching the body */
}

.upload-content {
    width: min(420px, 100%);
    text-align: center;
    padding: 24px;
}

.upload-modal.dragging .upload-content {
    border: 2px dashed var(--accent);
}

.upload-modal.dragging .upload-progress {
    display: none;
}

.upload-content p {
    overflow-wrap: anywhere;
}

.upload-progress {
    height: 6px;
    margin-top: 12px;
    border-radius: 3px;
    background-color: var(--bg-subdued);
    overflow: hidden;
}

.upload-progress-bar {
    height: 100%;
    width: 0;
    background-color: var(--accent);
    transition: width 0.1s linear;
}

.upload-modal.failed .upload-progress-bar {
    background-color: #d9534f;
}

.modal-btn {
    border: 1px solid var(--neutral-trim);
    background-color: var(--bg-default);
    color: var(--interactive-medium);
    font-family: monospace;
    padding: 6px 12px;
    border-radius: 6px;
    cursor: pointer;
}

@media (max-width: 900px) {
    .header-left,
    .header-right {
        top: 10px;
        gap: 8px;
    }

    .workspace {
        padding-top: 42px;
    }

    .repl-actions {
        flex-wrap: wrap;
    }

    .file-explorer-pane {
        width: 220px;
        min-width: 180px;
    }

    /* no room for two panes: the editor covers the console until hidden */
    .editor-pane:not(.collapsed) {
        position: absolute;
        inset: 0;
        z-index: 30;
        min-width: 0;
    }

    .editor-resizer {
        display: none;
    }
}
