/* The workbench page (docs/design/web-workbench.md §2). Theme tokens only: see /themes.css. */

*, *::before, *::after { box-sizing: border-box; }
html { background: var(--bg); color: var(--text); font-family: var(--font-ui), system-ui, sans-serif; -webkit-text-size-adjust: 100%; }
body { margin: 0; min-height: 100vh; display: flex; flex-direction: column; background: var(--bg); color: var(--text); line-height: 1.5; }
a { color: var(--link); }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: var(--r-xs); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip-link { position: absolute; left: -9999px; }
.skip-link:focus { left: 1rem; top: 1rem; background: var(--surface); padding: .5rem 1rem; z-index: 10; }

/* The shell (js/workbench-shell.js): one screen, never scrolls; the modes are in the bar, on a phone along
   the bottom. */
.wb-page { height: var(--wb-h, 100dvh); min-height: 0; overflow: hidden; padding: 0 !important; position: relative; }
.wb-page .pc-tabs { display: none; } /* the site's own phone bar: the p'lisp menu has its links here */
.wb-bar { flex: none; height: 52px; display: flex; align-items: center; gap: .6rem; padding: 0 max(.75rem, env(safe-area-inset-right, 0px)) 0 max(.75rem, env(safe-area-inset-left, 0px)); background: var(--bg-alt); border-bottom: 1px solid var(--line); }
.wb-logo { font-family: var(--font-display), system-ui, sans-serif; font-size: 1.5rem; line-height: 44px; text-decoration: none; color: var(--text); white-space: nowrap; }
.wb-logo > span:first-child { color: var(--gold); }
.wb-caret { font-size: .8rem; color: var(--text-muted); }
.wb-bar button, .wb-strip button, .wb-strip select, .wb-menu button, .wb-menu select, .wb-views button { font: inherit; min-height: 2.5rem; padding: .25rem .9rem; border: 0; border-radius: var(--r-sm); background: var(--btn); color: var(--text); cursor: pointer; }
.wb-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 14rem; }
.wb-name b { font-weight: 500; }
.wb-changed { color: var(--text-muted); font-weight: 400; font-size: .85em; }
.wb-grow { flex: 1; }
.wb-bar .wb-run { background: var(--accent); color: var(--accent-ink); font-weight: 700; padding: 0 1.4rem; }
.wb-modes { position: absolute; top: 6px; left: 50%; transform: translateX(-50%); height: 40px; display: flex; gap: 2px; padding: 3px; border-radius: var(--r-md); background: var(--surface); z-index: 5; }
.wb-modes button { font: inherit; display: flex; align-items: center; gap: .45rem; padding: 0 .9rem; border: 0; border-radius: var(--r-sm); background: none; color: var(--text-muted); cursor: pointer; white-space: nowrap; }
.wb-modes button[aria-current] { background: var(--btn); color: var(--text); }
.wb-modes svg { width: 18px; height: 18px; }
#wb-leave { position: absolute; z-index: 30; left: 0; right: 0; top: 52px; transform: translateY(-120vh); border-bottom: 1px solid var(--line); box-shadow: 0 12px 30px rgb(0 0 0 / .4); }
#wb-leave.is-open { transform: none; }
#wb-leave .pc-bar { position: relative; transform: none; }
.wb-menu { position: absolute; z-index: 30; left: .5rem; top: 56px; width: min(22rem, 100vw - 1rem); max-height: calc(100% - 64px); overflow: auto; display: grid; gap: .6rem; padding: .9rem; border: 1px solid var(--line-strong); border-radius: var(--r-md); background: var(--bg-alt); box-shadow: 0 12px 30px rgb(0 0 0 / .4); }
.wb-menu[hidden] { display: none; }
.wb-menu-h { margin: .25rem 0 0; color: var(--text-muted); font-size: .85rem; }
.wb-menu select { width: 100%; background: var(--surface); }
.wb-menu-row { display: flex; gap: .5rem; }
.wb-menu-row button { flex: 1; }
.wb-menu-row { flex-wrap: wrap; }
.wb-menu-row button { white-space: nowrap; padding-inline: .5rem; }
.wb-menu-row a { flex: 1; display: inline-flex; align-items: center; justify-content: center; min-height: 2.5rem; padding-inline: .5rem; border-radius: var(--r-sm); background: var(--btn); color: var(--text); text-decoration: none; white-space: nowrap; } /* Learn and Library: links that look like the row's buttons */
/* Undo after a delete (workbench.js toast), and History (a dialog). */
.wb-toast { position: fixed; z-index: 40; left: 50%; bottom: 1.25rem; transform: translateX(-50%); display: flex; align-items: center; gap: .75rem; padding: .5rem .6rem .5rem 1rem; border-radius: var(--r-md); background: var(--surface-2); color: var(--text); border: 1px solid var(--line-strong); box-shadow: 0 12px 30px rgb(0 0 0 / .4); }
.wb-toast[hidden] { display: none; }
.wb-toast button { font: inherit; min-height: 2.5rem; padding: 0 1rem; border: 0; border-radius: var(--r-sm); background: var(--accent); color: var(--accent-ink); font-weight: 700; cursor: pointer; }
@media (max-width: 820px) { .wb-toast { top: 60px; bottom: auto; width: max-content; max-width: calc(100vw - 1rem); } } /* under the bar, clear of the keys */
.wb-history-box { width: min(34rem, 100vw - 2rem); max-height: min(36rem, 100dvh - 2rem); padding: 1rem 1.1rem; border: 1px solid var(--line-strong); border-radius: var(--r-md); background: var(--bg-alt); color: var(--text); }
.wb-history-box::backdrop { background: rgb(0 0 0 / .5); }
.wb-history-box h2 { margin: 0 0 .25rem; font-size: 1.1rem; }
.wb-history-box p { margin: 0 0 .75rem; color: var(--text-muted); font-size: .9rem; }
.wb-history-box ul { margin: 0 0 .75rem; padding: 0; list-style: none; display: grid; gap: .35rem; }
.wb-history-box { overflow-y: auto; }
.wb-sp { display: grid; grid-template-columns: minmax(0, 1fr); gap: .35rem; padding: .5rem 0 .6rem; border-bottom: 1px solid var(--line); }
.wb-sp-head { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; min-width: 0; }
.wb-sp-what { flex: 1 1 12rem; min-width: 0; font-size: .9rem; }
.wb-sp-note { margin: .35rem 0; font-size: .85rem; color: var(--text-muted); }
.wb-sp-star .wb-sp-what { font-weight: 600; }
.wb-sp-origin .wb-sp-what { color: var(--text-muted); }
.wb-sp-head input { flex: 1 1 100%; min-width: 0; font: inherit; font-size: .9rem; min-height: 2.25rem; padding: 0 .6rem; border: 1px solid var(--line-strong); border-radius: var(--r-sm); background: var(--bg); color: var(--text); }
.wb-history-box .wb-sp-starbtn { min-width: 2.5rem; padding: 0; font-size: 1.15rem; background: transparent; }
.wb-sp-star .wb-sp-starbtn { color: var(--accent); }
.wb-sp-acts { display: flex; flex-wrap: wrap; gap: .35rem; }
.wb-sp-diff p { margin: 0 0 .35rem; }
.wb-sp-diff pre { margin: 0; max-height: 14rem; overflow: auto; padding: .4rem .55rem; border-radius: var(--r-sm); background: var(--bg); font-size: .8rem; line-height: 1.45; }
.wb-sp-diff .wb-add { color: var(--teal); }
.wb-sp-diff .wb-del { color: var(--danger); text-decoration: line-through; }
.wb-sp-diff .wb-file { color: var(--text-muted); font-weight: 600; }
.wb-history-box button { font: inherit; min-height: 2.5rem; padding: 0 .8rem; border: 0; border-radius: var(--r-sm); background: var(--btn); color: var(--text); cursor: pointer; }
.wb-menu-apps { display: grid; grid-template-columns: 1fr 1fr; }
.wb-menu-apps a { padding: .6rem .25rem; color: var(--text); text-decoration: none; }
.wb-menu-apps a:hover { color: var(--link-hover); text-decoration: underline; }

.wb { flex: 1; min-height: 0; display: grid; position: relative; grid-template-rows: minmax(0, 1fr); grid-template-columns: minmax(0, 1fr) var(--wb-sim-w, 400px); }
/* The line between the code and the simulator, and the bar the panel becomes (js/workbench-split.js). Code mode, wide screens. */
.wb-simbar { display: none; }
@media (min-width: 821px) {
  .wb-split { position: absolute; z-index: 4; top: 0; bottom: 0; right: var(--wb-sim-w, 400px); width: 12px; margin-right: -6px; cursor: col-resize; touch-action: none; }
  .wb-split::after { content: ""; position: absolute; top: 0; bottom: 0; left: 5px; width: 2px; background: transparent; transition: background-color .15s; }
  .wb-split:hover::after, .wb-split:focus-visible::after, .wb-resizing .wb-split::after { background: var(--accent); }
  .wb-split:focus-visible { outline: none; }
  .wb-simbar { display: none; grid-area: 1 / 2; z-index: 2; width: 100%; padding: 0; border: 0; border-left: 1px solid var(--line); background: var(--bg-alt); color: var(--text-soft); font-size: 1.8rem; line-height: 1; cursor: pointer; touch-action: none; }
  .wb-simbar:hover, .wb-simbar:focus-visible { color: var(--accent); background: var(--surface); }
  .wb-resizing, .wb-resizing * { cursor: col-resize !important; user-select: none !important; -webkit-user-select: none !important; }
  .wb-resizing iframe { pointer-events: none; }
  .wb:not([data-mode="code"]) .wb-split, .wb[data-sim="closed"] .wb-split { display: none; }
  .wb[data-mode="code"][data-sim="closed"] { grid-template-columns: minmax(0, 1fr) 28px; }
  .wb[data-mode="code"][data-sim="closed"] .wb-simbar { display: block; }
  .wb[data-mode="code"][data-sim="closed"] .wb-left { position: relative; z-index: 1; } /* over the simulator, which stays in its place */
  .wb[data-mode="code"][data-sim="closed"] .wb-target { position: absolute; top: 0; right: 0; width: var(--wb-sim-w, 400px); height: 100%; opacity: .01; pointer-events: none; }
  .wb[data-mode="code"] .wb-stage { max-width: min(var(--wb-sim-w, 400px) - 2rem, (var(--wb-h, 100dvh) - 170px) * 672 / 722.31); }
}
.wb-left { grid-area: 1 / 1; min-width: 0; min-height: 0; display: flex; flex-direction: column; background: var(--surface); border-right: 1px solid var(--line); }
.wb-target { grid-area: 1 / 2; position: relative; min-width: 0; min-height: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .75rem; padding: 1rem; background: var(--bg); overflow: hidden; }
.wb-stage { position: relative; isolation: isolate; width: 100%; max-width: min(430px, (var(--wb-h, 100dvh) - 170px) * 672 / 722.31); }
.wb-embed { max-width: none; }
.wb-views { display: flex; gap: .25rem; }
.wb-viewbar { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; justify-content: center; }
.wb-viewbar .wb-two { font: inherit; min-height: 2.5rem; padding: .25rem .9rem; border: 0; border-radius: var(--r-sm); background: var(--btn); color: var(--text); cursor: pointer; }
.wb-two[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }
/* Two players: the simulators side by side in Simulator mode, each named above it. Elsewhere player 2's runs on in its
   place, see-through, as the simulator does in Sprites mode (a hidden frame gets no animation frames). */
.wb-p2[hidden] { display: none; }
.wb-p2 { position: absolute; top: 0; right: 0; width: 360px; opacity: .01; pointer-events: none; }
.wb-p2 iframe { pointer-events: none !important; } /* sim-box gives a live frame pointer events: not while it is see-through */
.wb[data-players="2"][data-mode="sim"] .wb-p2 iframe { pointer-events: auto !important; }
.wb[data-players="2"][data-mode="sim"] .wb-target { flex-direction: row; flex-wrap: wrap; align-content: center; column-gap: 1.5rem; }
.wb[data-players="2"][data-mode="sim"] .wb-viewbar { width: 100%; }
.wb[data-players="2"] .wb-views { display: none; }
.wb[data-players="2"][data-mode="sim"] .wb-stage, .wb[data-players="2"][data-mode="sim"] .wb-p2 { position: relative; opacity: 1; pointer-events: auto; width: calc(50% - .75rem); max-width: min(520px, (var(--wb-h, 100dvh) - 220px) * 672 / 722.31); margin-top: 1.6rem; }
.wb[data-players="2"][data-mode="sim"] .wb-stage::before, .wb[data-players="2"][data-mode="sim"] .wb-p2::before { position: absolute; z-index: 2; top: -1.6rem; left: 0; right: 0; text-align: center; color: var(--text-muted); font-size: .9rem; }
.wb[data-players="2"][data-mode="sim"] .wb-stage::before { content: "Player 1 · host"; }
.wb[data-players="2"][data-mode="sim"] .wb-p2::before { content: "Player 2 · guest"; }
.wb-views[hidden] { visibility: hidden; }
/* The views lie in one place; workbench-views.js slides them. One that is away is off the panel's side. */
.wb-board, .wb-alone { position: absolute; inset: 0; visibility: hidden; touch-action: pinch-zoom; user-select: none; -webkit-user-select: none; outline-offset: -2px; }
/* The screen alone: the lone screen of the embed (480 x 234), as wide as the panel lets it. */
.wb-alone canvas { position: absolute; left: 0; top: 50%; width: 100%; height: auto; transform: translateY(-50%); border: calc(8 / 480 * 100cqw) solid #17181a; border-radius: calc(10 / 480 * 100cqw); background: var(--lcd); image-rendering: pixelated; box-sizing: border-box; cursor: pointer; }
.wb-stage { container-type: inline-size; }
.wb-board canvas { display: block; width: 100%; height: 100%; }
.wb-trail { position: absolute; top: 12%; bottom: 14%; width: 60%; opacity: 0; }
.wb-lines { position: absolute; inset: 0; z-index: -1; pointer-events: none; }
.wb-trail i { position: absolute; height: 1px; background: rgb(128 128 134 / .4); }
.wb-said { position: absolute; z-index: 2; left: 1rem; right: 1rem; bottom: .75rem; margin: 0 auto; width: fit-content; max-width: 34rem; padding: .5rem .9rem; border-radius: var(--r-sm); background: var(--surface-2); color: var(--text); font-size: .9rem; }
.wb-said[hidden] { display: none; }
.wb-views button[aria-checked="true"] { background: var(--accent); color: var(--accent-ink); }
.wb[data-mode="sim"] { grid-template-columns: minmax(0, 1fr); }
.wb[data-mode="sim"] .wb-left { display: none; }
.wb[data-mode="sim"] .wb-target { grid-area: 1 / 1; }
.wb[data-mode="sim"] .wb-stage { max-width: min(640px, (var(--wb-h, 100dvh) - 170px) * 672 / 722.31); }
.wb:not([data-mode="sim"]) .wb-said { display: none; }
.wb[data-mode="sprites"] .wb-target { position: absolute; top: 0; right: 0; width: 400px; height: 100%; opacity: .01; pointer-events: none; }
.wb[data-mode="sprites"] { grid-template-columns: minmax(0, 2fr) minmax(0, 3fr); }
.wb[data-mode="sprites"] .wb-sprites { grid-area: 1 / 2; }
.wb[data-mode="sound"] { grid-template-columns: minmax(0, 1fr); }
.wb[data-mode="sound"] .wb-left { display: none; }
.wb[data-mode="sound"] .wb-target { position: absolute; top: 0; right: 0; width: 400px; height: 100%; opacity: .01; pointer-events: none; }
.wb[data-mode="sound"] .wb-sounds { grid-area: 1 / 1; z-index: 1; }
.wb-strip { flex: none; display: flex; align-items: center; gap: .5rem; padding: .3rem .6rem; border-top: 1px solid var(--line); background: var(--bg-alt); }
.wb-strip button, .wb-strip select { min-height: 2rem; padding: .1rem .7rem; background: none; color: var(--text-muted); border-radius: var(--r-xs); max-width: 11rem; }
.wb-strip button[aria-expanded="true"] { background: var(--btn); color: var(--text); }
#btn-repl::after { content: " ▴"; }
#btn-repl[aria-expanded="true"]::after { content: " ▾"; }
.wb-keys { display: none; }

.wb-editor { flex: 1; min-height: 0; display: flex; background: var(--surface); overflow: hidden; }
.wb-editor-host { flex: 1; min-width: 0; min-height: 0; overflow: auto; }
/* A part file's bar (CADR-0178): what it is, and its two ways on, Update and Remix part. */
.wb-part-lock { position: sticky; top: 0; z-index: 3; display: flex; flex-wrap: wrap; align-items: center; gap: .4rem .6rem; padding: .45rem .75rem; border-bottom: 1px solid var(--line); background: var(--bg-alt); color: var(--text-muted); font-size: .9rem; }
.wb-part-lock[hidden] { display: none; }
.wb-part-lock-what { flex: 1 1 100%; min-width: 0; overflow-wrap: anywhere; }
.wb-part-lock button { font: inherit; min-height: 2.25rem; padding: .1rem .75rem; border: 1px solid var(--line); border-radius: var(--r-xs); background: var(--surface); color: var(--text); cursor: pointer; }
.wb-part-lock-nudge { animation: wb-part-nudge .35s ease-out; }
@keyframes wb-part-nudge { 0%, 100% { transform: none; } 30% { transform: translateX(-4px); } 60% { transform: translateX(4px); } }
@media (prefers-reduced-motion: reduce) { .wb-part-lock-nudge { animation: none; } }
/* The program's files, flat (js/file-list.js): left of the code; on a phone a row above it, from the second file on. */
.wb-files { flex: none; width: 8.5rem; min-height: 0; display: flex; flex-direction: column; overflow: auto; padding: .5rem; border-right: 1px solid var(--line); background: var(--bg-alt); }
.wb-files ul { margin: 0; padding: 0; list-style: none; }
.wb-files button { font: inherit; font-size: .9rem; min-height: 2.25rem; padding: .1rem .6rem; border: 0; border-radius: var(--r-xs); background: none; color: var(--text-muted); cursor: pointer; white-space: nowrap; }
.wb-files li button { width: 100%; text-align: left; overflow: hidden; text-overflow: ellipsis; font-family: var(--font-mono), ui-monospace, monospace; }
.wb-files button:hover { color: var(--text); }
.wb-files [aria-current] { background: var(--btn); color: var(--text); }
.wb-files-row { display: flex; flex-direction: column; align-items: flex-start; margin-top: .5rem; padding-top: .5rem; border-top: 1px solid var(--line); }
@media (max-width: 820px) {
  .wb-editor { flex-direction: column; }
  .wb-files { width: auto; flex-direction: row; overflow-x: auto; overflow-y: hidden; padding: 0 .5rem; border-right: 0; border-bottom: 1px solid var(--line); }
  .wb-files[data-count="1"] > ul, .wb-files[data-count="1"] > .wb-files-row { display: none; }
  .wb-files[data-count="1"]:not(:has(> .wb-deps:not([hidden]))) { display: none; } /* one file and no Uses: no row at all */
  .wb-deps { margin: 0 0 0 auto; padding: 0; border: 0; display: flex; align-items: center; gap: .3rem; }
  .wb-files ul, .wb-files-row { display: flex; flex-direction: row; margin: 0; padding: 0; border: 0; }
  .wb-files button { min-height: 44px; }
}
.wb-editor-host .cm-editor { height: 100%; }
.wb-pre, .wb-editor-host .cm-content, .wb-editor-host .cm-gutters { font-family: var(--font-mono), ui-monospace, monospace; font-size: .95rem; }
.wb-pre { margin: 0; padding: .75rem 1rem; white-space: pre-wrap; }
.wb-pre, .wb-editor-host, .wb-repl { font-variant-ligatures: none; }

/* The editor in the site theme (the bundle gives token classes, CADR-0060). */
.wb-editor-host .cm-editor { background: var(--surface); color: var(--text); }
.wb-editor-host .cm-gutters { background: var(--surface-2); color: var(--text-muted); border-right: 1px solid var(--line); }
.wb-editor-host .cm-activeLine { background: color-mix(in srgb, var(--accent) 7%, transparent); }
.wb-editor-host .cm-activeLineGutter { background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--text-soft); }
.wb-editor-host .cm-cursor { border-left-color: var(--accent); }
.wb-editor-host .cm-selectionBackground, .wb-editor-host .cm-focused .cm-selectionBackground { background: color-mix(in srgb, var(--accent) 28%, transparent) !important; }
.wb-editor-host .cm-matchingBracket { background: color-mix(in srgb, var(--teal) 30%, transparent); outline: 1px solid var(--teal); }
.wb-editor-host .cm-focused { outline: none; }
.wb-editor-host:focus-within { box-shadow: inset 0 0 0 2px var(--accent); }
.tok-comment { color: var(--text-muted); font-style: italic; }
.tok-keyword, .tok-definitionKeyword { color: var(--accent); }
.tok-string, .tok-string2 { color: var(--warm-text); }
.tok-number, .tok-bool, .tok-atom { color: var(--teal-text); }
.tok-variableName.tok-definition, .tok-function, .tok-definition { color: var(--link); }
.tok-operator, .tok-punctuation, .tok-bracket { color: var(--text-soft); }
.tok-meta, .tok-typeName, .tok-className { color: var(--teal); }

.wb-screen { display: flex; flex-direction: column; justify-content: space-between; padding: .4rem .6rem; background: var(--lcd); color: var(--lcd-ink); border-radius: var(--r-sm); font-family: var(--font-lcd), var(--font-mono), monospace; font-size: .95rem; }
.wb-screen-line1 { opacity: .8; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wb-screen-line2 { align-self: flex-end; font-size: 1.15rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
/* Vi mode (GRW1-T5): the toggle, the add-on's fat cursor and its mode line, in theme tokens. */
/* The Clojure editing set (workbench.js): a small panel over the strip. */
.wb-left { position: relative; z-index: 1; } /* a stacking context: the editor's layers (the Vi mode line, z 300) stay under the menus; its tooltips still pass over the simulator */
.wb-prefs { position: absolute; z-index: 6; right: .5rem; bottom: 3rem; width: min(22rem, calc(100% - 1rem)); display: grid; gap: .55rem; padding: .8rem .9rem; border: 1px solid var(--line-strong); border-radius: var(--r-md); background: var(--bg-alt); box-shadow: 0 12px 30px rgb(0 0 0 / .4); }
.wb-prefs[hidden] { display: none; }
.wb-prefs-h { margin: 0; font-weight: 600; }
.wb-prefs label { display: flex; gap: .6rem; align-items: flex-start; cursor: pointer; }
.wb-prefs input { width: 1.2rem; height: 1.2rem; margin: .15rem 0 0; accent-color: var(--accent); flex: none; }
.wb-prefs small { display: block; color: var(--text-muted); font-size: .82rem; }
.wb-prefs #btn-vim { justify-self: start; font: inherit; min-height: 2.25rem; padding: 0 .8rem; border: 1px solid var(--line-strong); border-radius: var(--r-sm); background: var(--surface-2); color: var(--text); cursor: pointer; }
#btn-editor[aria-expanded="true"] { background: var(--btn); color: var(--text); }
/* Rainbow brackets (the editor's cm-rb-0 … 5), from the theme's colours. */
.wb-editor-host .cm-rb-0 { color: var(--accent); }
.wb-editor-host .cm-rb-1 { color: var(--teal-text); }
.wb-editor-host .cm-rb-2 { color: var(--warm-text); }
.wb-editor-host .cm-rb-3 { color: var(--link); }
.wb-editor-host .cm-rb-4 { color: var(--gold); }
.wb-editor-host .cm-rb-5 { color: var(--text-soft); }
#btn-vim[aria-pressed="true"] { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
/* !important: the add-on sets the fat cursor in a Prec.highest theme, which a plain rule loses to. */
.wb-editor-host .cm-fat-cursor { background: color-mix(in srgb, var(--accent) 70%, transparent) !important; color: var(--accent-ink) !important; }
.wb-editor-host .cm-panels { background: var(--surface-2); color: var(--text-muted); border-top: 1px solid var(--line); font-family: var(--font-mono), ui-monospace, monospace; }
.wb-editor-host .cm-vim-panel input { background: transparent; color: var(--text); border: 0; font: inherit; }
.btn-accent { background: var(--accent) !important; color: var(--accent-ink) !important; border-color: transparent !important; font-weight: 600; }
.wb-status { flex: 1; min-width: 0; margin: 0; color: var(--text-muted); font-size: .9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* The sprites in the program (sprites.js). Hidden, its row is empty. */
.wb-sprites { position: relative; z-index: 1; min-width: 0; min-height: 0; display: flex; flex-direction: column; overflow: auto; background: var(--surface); padding: .9rem; }
.wb-sprites[hidden] { display: none; }
.wb-sprites-h { margin: 0 0 .5rem; font-size: 1rem; }
.wb-sprites-none { margin: 0; color: var(--text-muted); overflow-wrap: anywhere; }
.wb-sprite-grid { display: flex; flex-wrap: wrap; gap: .5rem; margin: 0; padding: 0; list-style: none; }
.wb-sprite { font: inherit; display: flex; flex-direction: column; align-items: flex-start; gap: .15rem; min-width: 5rem; min-height: 3rem; padding: .5rem; border: 1px solid var(--line-strong); border-radius: var(--r-sm); background: var(--surface-2); color: var(--text); cursor: pointer; }
.wb-sprites-list { flex: none; max-height: 30%; overflow: auto; }
.wb-sprite-new { justify-content: center; color: var(--text-muted); border-style: dashed; }
.wb-sprite[aria-pressed="true"] { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.wb-sprite:hover { border-color: var(--accent); }
.wb-sprite canvas { max-width: 100%; height: auto; image-rendering: pixelated; }
.wb-sprite-name { overflow-wrap: anywhere; text-align: left; font-family: var(--font-mono), ui-monospace, monospace; font-size: .9rem; }
.wb-sprite-note { color: var(--text-muted); font-size: .8rem; text-align: left; max-width: 16rem; }
.wb-sprite.is-bad .wb-sprite-note { color: var(--warm-text); }
/* Sound mode (js/sound-mode.js): the list, the grid, the knobs. */
.wb-sounds { position: relative; min-width: 0; min-height: 0; display: grid; grid-template-columns: 15rem minmax(0, 1fr); background: var(--surface); }
.wb-sounds[hidden] { display: none; }
.wb-sounds button, .wb-sounds input[type="text"] { font: inherit; min-height: 2.5rem; padding: .2rem .8rem; border: 1px solid var(--line-strong); border-radius: var(--r-sm); background: var(--surface-2); color: var(--text); }
.wb-sounds button { cursor: pointer; }
.wb-sounds input[type="text"] { font: 16px var(--font-mono), ui-monospace, monospace; width: 10rem; }
.wb-sounds button[aria-pressed="true"] { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.wb-snd-list { min-height: 0; overflow: auto; padding: .9rem; border-right: 1px solid var(--line); }
.wb-snd-h { margin: 0 0 .5rem; font-size: 1rem; }
.wb-snd-items { display: grid; gap: .4rem; }
.wb-snd-item { text-align: left; font-family: var(--font-mono), ui-monospace, monospace; overflow-wrap: anywhere; }
.wb-snd-bank summary { padding: .5rem 0; cursor: pointer; }
.wb-snd-bankname { flex: 1; font-family: var(--font-mono), ui-monospace, monospace; }
.wb-snd-bank .wb-snd-row { flex-wrap: nowrap; margin-bottom: .3rem; }
.wb-snd-main { min-width: 0; min-height: 0; display: flex; flex-direction: column; gap: .5rem; padding: .75rem .9rem; }
.wb-snd-main > [hidden] { display: none; }
.wb-snd-row { flex: none; display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; }
.wb-snd-play { min-width: 6.5rem; font-weight: 600; }
.wb-snd-voices .has-notes::after { content: " •"; color: var(--accent); }
.wb-snd-len { min-width: 5rem; text-align: center; color: var(--text-muted); }
.wb-snd-tools button:nth-of-type(4) { margin-left: auto; }
.wb-snd-knob { display: flex; align-items: center; gap: .5rem; color: var(--text-muted); font-size: .9rem; }
.wb-snd-knob input { accent-color: var(--accent); min-height: 2rem; }
.wb-snd-knob output { color: var(--text); min-width: 1.5rem; }
.wb-snd-name { color: var(--text-muted); font-size: .9rem; }
.wb-snd-knobs { gap: .5rem 1.2rem; min-height: 2.5rem; }
.wb-snd-roll { flex: 1; min-height: 8rem; overflow: auto; border: 1px solid var(--line-strong); border-radius: var(--r-sm); background: var(--bg); }
.wb-snd-sheet { position: relative; display: flex; width: max-content; }
.wb-snd-keys { position: sticky; left: 0; z-index: 2; border-right: 1px solid var(--line-strong); }
.wb-snd-grid { display: block; cursor: crosshair; outline-offset: -2px; touch-action: pan-x pan-y; user-select: none; -webkit-user-select: none; }
.wb-snd-head { position: absolute; left: 44px; top: 0; bottom: 0; width: 2px; background: var(--gold); pointer-events: none; }
.wb-snd-head[hidden] { display: none; }
.wb-snd-note { position: absolute; right: 1rem; bottom: .75rem; margin: 0; padding: .4rem .8rem; border-radius: var(--r-sm); background: var(--surface-2); }
.wb-snd-note:empty { display: none; }
.wb-spred-host { flex: 1; min-height: 0; display: flex; }
.wb-spred { flex: 1; min-width: 0; min-height: 0; padding-top: .6rem; color: var(--text); display: grid; gap: .5rem .75rem; grid-template-columns: minmax(0, 1fr) 13rem; grid-template-rows: auto minmax(0, 1fr); grid-template-areas: "head head" "main anim"; }
.wb-spred[hidden] { display: none; }
.wb-spred-name { width: 8.5rem; font-family: var(--font-mono), ui-monospace, monospace; }
.wb-spred-size { width: 4rem; }
.wb-spred input { font-size: 16px; min-height: 2.5rem; padding: .2rem .5rem; border: 1px solid var(--line-strong); border-radius: var(--r-sm); background: var(--bg); color: var(--text); }
.wb-spred-label { color: var(--text-muted); }
.wb-spred button { font: inherit; min-width: 2.75rem; min-height: 2.75rem; padding: .25rem .75rem; border-radius: var(--r-sm); border: 1px solid var(--line-strong); background: var(--surface-2); color: var(--text); cursor: pointer; touch-action: manipulation; }
.wb-spred button:disabled { opacity: .45; cursor: default; }
.wb-spred button[aria-pressed="true"] { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.wb-spred-head { grid-area: head; display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; min-width: 0; }
.wb-spred-title { flex: 1; min-width: 0; margin: 0; font-size: 1rem; overflow-wrap: anywhere; }
.wb-spred-main { grid-area: main; display: flex; flex-direction: column; gap: .5rem; min-width: 0; min-height: 0; }
.wb-spred-view { flex: 1; min-height: 0; overflow: auto; display: flex; }
.wb-spred-canvas { flex: none; margin: auto; image-rendering: pixelated; cursor: crosshair; user-select: none; -webkit-user-select: none; }
.wb-spred-nav, .wb-spred-tools, .wb-spred-row { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: .5rem; }
.wb-spred-frame { min-width: 8.5rem; text-align: center; }
.wb-spred .wb-spred-arrow { min-width: 4.5rem; min-height: 3rem; }
.wb-spred-note { margin: 0; min-height: 1.3em; text-align: center; font-size: .85rem; color: var(--text-muted); }
.wb-spred-anim { grid-area: anim; min-width: 0; min-height: 0; overflow: auto; display: flex; flex-direction: column; gap: .5rem; }
.wb-spred-anim h3 { margin: .25rem 0 0; font-size: .85rem; color: var(--text-muted); }
.wb-spred-preview { align-self: center; max-width: 100%; max-height: 8rem; image-rendering: pixelated; }
.wb-spred-hz { font: inherit; font-size: 16px; width: 4.5rem; min-height: 2.75rem; padding: .25rem .5rem; border: 1px solid var(--line-strong); border-radius: var(--r-sm); background: var(--bg); color: var(--text); }
.wb-spred-seq { display: flex; flex-wrap: wrap; gap: .35rem; align-items: center; }
.wb-spred-none { color: var(--text-muted); font-size: .85rem; }
.wb-spred.is-broken .wb-spred-canvas { opacity: .5; cursor: not-allowed; }
@media (max-width: 820px) {
  .wb[data-mode="sprites"] { grid-template-columns: minmax(0, 1fr); }
  .wb-spred button { min-height: 2.5rem; padding: .2rem .6rem; }
  .wb-spred .wb-spred-arrow { min-height: 2.5rem; }
  .wb-sprites { padding: .5rem .6rem; }
  .wb-sprites-h { display: none; }
  .wb-sprites-list { max-height: none; }
  .wb-sprite-grid { flex-wrap: nowrap; overflow-x: auto; padding-bottom: .3rem; }
  .wb-sprite-grid li { flex: none; max-width: 11rem; }
  .wb-sprite-grid li:has(.wb-sprite-new) { order: -1; }
  .wb-spred-title { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .wb-sprite canvas { max-height: 4.5rem; object-fit: contain; }
  .wb-spred-host { flex: none; }
  .wb-spred { grid-template-columns: minmax(0, 1fr); grid-template-rows: repeat(3, max-content); grid-template-areas: "main" "head" "anim"; align-content: start; }
  .wb-spred-view { flex: none; height: min(100vw, 44dvh); }
  .wb-spred-anim { overflow: visible; }
}

.wb-repl[hidden] { display: none; }
.wb-repl { flex: none; height: min(34%, 20rem); display: flex; flex-direction: column; min-height: 0; border-top: 1px solid var(--line); background: var(--surface); font-family: var(--font-mono), ui-monospace, monospace; font-size: .95rem; }
.wb-history { flex: 1; min-height: 0; overflow: auto; margin: 0; padding: .5rem .75rem; list-style: none; }
.wb-history li { white-space: pre-wrap; word-break: break-word; }
.wb-history .in::before { content: "user=> "; color: var(--text-muted); }
.wb-history .err { color: var(--warm-text); }
.wb-editor-host .cm-help { max-width: 34rem; padding: .4rem .6rem; white-space: pre-wrap; font: .85rem/1.45 var(--font-mono), ui-monospace, monospace; }
.wb-editor-host .cm-tooltip-autocomplete > ul { font-family: var(--font-mono), ui-monospace, monospace; }
.wb-editor-host .cm-tooltip-autocomplete > ul > li[aria-selected] { background: var(--accent); color: var(--accent-ink); }
.wb-editor-host .cm-completionInfo { max-width: 30rem; padding: .4rem .6rem; white-space: pre-wrap; font: .82rem/1.45 var(--font-mono), ui-monospace, monospace; background: var(--surface-2); color: var(--text); border: 1px solid var(--line-strong); }
.wb-editor-host .cm-completionInfo, .wb-editor-host .cm-help { overflow-wrap: anywhere; }
@media (max-width: 820px) { .wb-editor-host .cm-completionInfo { max-width: calc(100vw - 1.5rem); } }
.wb-editor-host .cm-completionDetail { margin-left: .6rem; color: var(--text-muted); font-style: normal; }
.wb-editor-host .cm-panel.cm-search { padding: .4rem .6rem; font: inherit; font-size: .9rem; }
.wb-editor-host .cm-panel.cm-search input, .wb-editor-host .cm-panel.cm-search button { font: inherit; font-size: .9rem; min-height: 2rem; border: 1px solid var(--line-strong); border-radius: var(--r-xs); background: var(--surface); color: var(--text); }
@media (pointer: coarse) { .wb-editor-host .cm-panel.cm-search input { font-size: 16px; } } /* iOS zooms into a smaller field */
.wb-editor-host .cm-searchMatch { background: color-mix(in srgb, var(--teal) 30%, transparent); }
.wb-editor-host .cm-searchMatch-selected { background: color-mix(in srgb, var(--accent) 40%, transparent); }
.wb-editor-host .cm-selectionMatch { background: color-mix(in srgb, var(--teal) 16%, transparent); }
.wb-err-go { font: inherit; font-size: .85rem; margin-left: .3rem; padding: 0 .5rem; min-height: 1.6rem; border: 1px solid var(--line-strong); border-radius: var(--r-xs); background: var(--surface-2); color: var(--text); cursor: pointer; }
/* An error marked in the code (the editor's `mark`, CodeMirror lint) in the site's theme. */
.wb-editor-host .cm-lintRange-error { background-color: color-mix(in srgb, var(--warm-text) 22%, transparent); }
.wb-editor-host .cm-tooltip { background: var(--surface-2); color: var(--text); border: 1px solid var(--line-strong); }
.wb-editor-host .cm-diagnostic-error { border-left-color: var(--warm-text); }
.wb-editor-host .cm-gutter-lint { width: 1em; }
.wb-history .note { color: var(--text-muted); font-style: italic; }
.wb-input { display: flex; align-items: center; gap: .5rem; border-top: 1px solid var(--line); padding: .4rem .75rem; }
.wb-prompt { color: var(--text-muted); }
.wb-input input { flex: 1; min-width: 0; font: inherit; color: var(--text); background: transparent; border: 0; padding: .25rem 0; }
.wb-input input:focus-visible { outline: none; }
.wb-input:focus-within { box-shadow: inset 0 0 0 2px var(--accent); }

/* A phone: one thing on the screen; the modes along the bottom. */
@media (max-width: 820px) {
  .wb-caret, .wb-strip .wb-picker, #btn-vim { display: none; } /* Vi keys need a keyboard */
  .wb-prefs { bottom: 2.75rem; }
  .wb-bar { gap: .4rem; }
  .wb-name { max-width: 8.5rem; }
  .wb-modes { position: static; transform: none; flex: none; height: auto; display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 0; padding: 0 0 env(safe-area-inset-bottom, 0px); border-radius: 0; background: var(--bg-alt); border-top: 1px solid var(--line); }
  .wb-modes button { flex-direction: column; justify-content: center; gap: 2px; min-height: 54px; padding: 0; font-size: .75rem; border-radius: 0; }
  .wb-modes button[aria-current] { background: none; color: var(--accent); }
  .wb-modes svg { width: 20px; height: 20px; }
  .wb { grid-template-columns: minmax(0, 1fr); }
  .wb-split, .wb-simbar { display: none; }
  .wb-left { border: 0; }
  /* The simulator stays alive in the code's cell, UNDER the code (z 0 < .wb-left's 1): on top, even at
     opacity .01, inert and pointer-events: none, iOS Safari gave it the swipe and the code would not scroll. */
  .wb-target, .wb[data-mode="sprites"] .wb-target { grid-area: 1 / 1; position: relative; width: auto; height: auto; z-index: 0; opacity: .01; pointer-events: none; background: none; }
  .wb[data-mode="sim"] .wb-target { opacity: 1; pointer-events: auto; background: var(--bg); }
  .wb-stage, .wb[data-mode="sim"] .wb-stage { max-width: min(430px, (var(--wb-h, 100dvh) - 210px) * 672 / 722.31); }
  .wb[data-mode="sprites"] .wb-left { display: none; }
  .wb[data-mode="sprites"] .wb-sprites { grid-area: 1 / 1; z-index: 2; }
  .wb[data-mode="sound"] .wb-target { grid-area: 1 / 1; position: relative; width: auto; height: auto; }
  .wb[data-mode="sound"] .wb-sounds { z-index: 2; }
  .wb-sounds { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); }
  .wb-snd-list { border: 0; border-bottom: 1px solid var(--line); padding: .5rem .6rem; max-height: 45vh; }
  .wb-snd-h { display: none; }
  .wb-snd-items { display: flex; gap: .4rem; overflow-x: auto; align-items: flex-start; }
  .wb-snd-items button { flex: none; }
  .wb-snd-bank { flex: none; min-width: 11rem; }
  .wb-snd-main { padding: .5rem .6rem; overflow: auto; }
  .wb-snd-roll { flex: 1 0 15rem; }
  .wb-sounds .wb-snd-row > button { padding: .2rem .55rem; }
  .wb-sounds .wb-snd-tools { flex-wrap: nowrap; }
  .wb-snd-len { min-width: 4.4rem; font-size: .9rem; }
  .wb-snd-knob { flex-wrap: wrap; }
  /* Find and replace, small enough for a phone: the field, next, previous, replace; the options stay on a computer. */
  .wb-editor-host .cm-panel.cm-search { display: flex; flex-wrap: wrap; gap: .3rem; padding: .35rem 2rem .35rem .5rem; }
  .wb-editor-host .cm-panel.cm-search br, .wb-editor-host .cm-panel.cm-search label, .wb-editor-host .cm-panel.cm-search button[name="select"] { display: none; }
  .wb-editor-host .cm-panel.cm-search input[name="search"], .wb-editor-host .cm-panel.cm-search input[name="replace"] { flex: 1 1 9rem; min-width: 0; font-size: 16px; }
  .wb-editor-host .cm-panel.cm-search button { margin: 0; padding: 0 .55rem; min-height: 2.25rem; }
  .wb-keys { flex: none; display: flex; gap: 4px; padding: 5px 6px; background: var(--bg-alt); border-top: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
  .wb-keys::-webkit-scrollbar { display: none; }
  .wb-keys button { flex: 1 0 30px; min-width: 30px; height: 40px; padding: 0; border: 0; border-radius: var(--r-sm); background: var(--btn); color: var(--text); font: 1rem var(--font-mono), ui-monospace, monospace; }
  .wb-keys .is-eval { flex-basis: 52px; position: sticky; right: 0; box-shadow: -6px 0 6px var(--bg-alt); color: var(--accent); font: 500 .9rem var(--font-ui), sans-serif; }
  .wb-editor-host .cm-content, .wb-editor-host .cm-gutters, .wb-input input { font-size: 16px; }
  /* More of the code on a phone: a narrow line-number gutter, a short REPL drawer that grows with its lines. */
  .wb-editor-host .cm-gutters { font-size: 12px; }
  .wb-editor-host .cm-lineNumbers .cm-gutterElement { padding: 0 3px 0 2px; min-width: 2ch; }
  .wb-editor-host .cm-content { padding-left: 2px; }
  .wb-repl { height: auto; max-height: 34%; }
  .wb-history { min-height: 2.5rem; }
  #wb-leave .pc-nav { display: flex; overflow: visible; flex-direction: column; }
  #wb-leave .pc-inner { flex-wrap: wrap; }
}
#wb-leave .pc-brand { display: none; }
#wb-leave .pc-nav { margin-right: auto; }
/* A phone on its side: the code keeps its room. */
@media (max-height: 480px) {
  .wb-keys { display: none; }
  .wb-repl { height: 45%; max-height: 45%; }
  .wb-bar { height: 44px; }
  .wb-modes button { flex-direction: row; min-height: 38px; gap: .4rem; }
}
/* The spam check for Save screen (WS-WEB-19): Cloudflare shows it only when a person must act. */
.wb-check { position: fixed; top: 3.5rem; right: 1rem; z-index: 30; }
.wb-check:empty { display: none; }
/* What the program uses (CADR-0203, TB-15): its native parts under the file list, each a link to the Library. */
.wb-deps { margin-top: auto; padding-top: .5rem; border-top: 1px solid var(--line); display: grid; gap: .2rem; }
.wb-deps[hidden] { display: none; }
.wb-deps h3 { margin: 0; font-size: .75rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; }
.wb-dep { font: .9rem var(--font-mono), ui-monospace, monospace; color: var(--text); text-decoration: none; padding: .2rem .6rem; border-radius: var(--r-xs); }
.wb-dep:hover { background: var(--btn); }
.wb-dep small { font-family: var(--font-ui, inherit); color: var(--text-muted); }
