/* CoachedCode
   Layout: header / [palette | tabs + blocks + code | stage + console].
   Blocks have two faces. `.face-friendly` is the plain-language look (filled, colored
   blocks); `.face-code` is the same structure set in monospace with syntax colors, so that
   as [data-fade] rises the block chrome thins out until only the code is left.
   (The levels are 1, 2, 3 and 5; see the note at the top of app.js.) */

:root {
    --bg: #EEF0F4;
    --panel: #FFFFFF;
    --ws-bg: #F8F9FB;
    --line: #DCE0E7;
    --line-soft: #EBEEF2;
    --text: #18202F;
    --muted: #5F6B7E;
    --accent: #2F5BEA;
    --accent-soft: #E6ECFF;
    --danger: #C7352B;
    --danger-soft: #FDECEA;
    --warn: #B7791F;
    --go: #1E8A4B;
    --glow: #FFD23F;
    --ui: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
    --mono: ui-monospace, "SF Mono", "Cascadia Code", Menlo, Consolas, monospace;
    --s-kw: #0B57C2;
    --s-ty: #0D7A70;
    --s-str: #B3371F;
    --s-num: #8A5A00;
    --s-cm: #6B7686;
    --s-fn: #6C3BD1;
    --s-pn: #4B5565;
    --chev-light: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%23fff' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    --chev-dark: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%235F6B7E' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
    display: grid; grid-template-rows: 52px minmax(0, 1fr);
    background: var(--bg); color: var(--text); font: 13px/1.4 var(--ui);
    overflow: hidden; -webkit-font-smoothing: antialiased;
}
button, select, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

/* ---- header ---------------------------------------------------------------------------- */

.top { display: flex; align-items: center; gap: 12px; padding: 0 14px; background: var(--panel); border-bottom: 1px solid var(--line); min-width: 0; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 650; font-size: 15px; letter-spacing: -.01em; white-space: nowrap; }
.proj-name { width: 170px; min-width: 80px; padding: 5px 8px; border: 1px solid transparent; border-radius: 6px; background: transparent; font-weight: 500; text-overflow: ellipsis; }
.proj-name:hover { border-color: var(--line); }
.proj-name:focus { border-color: var(--accent); background: #fff; outline: none; }
.grow { flex: 1 1 0; min-width: 0; }
.field { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12px; white-space: nowrap; }
.field select { padding: 5px 24px 5px 9px; border: 1px solid var(--line); border-radius: 6px; background: #fff var(--chev-dark) no-repeat right 8px center / 9px; appearance: none; color: var(--text); font-weight: 600; font-size: 13px; }
.fade { display: flex; padding: 2px; border: 1px solid var(--line); border-radius: 999px; background: var(--bg); }
.fade button { padding: 4px 11px; border: 0; border-radius: 999px; background: transparent; color: var(--muted); font-size: 12px; font-weight: 550; white-space: nowrap; }
.fade button:hover { color: var(--text); }
.fade button.past { color: var(--accent); }
.fade button.on { background: var(--accent); color: #fff; }
.actions { display: flex; align-items: center; gap: 6px; }
.actions button { padding: 5px 11px; border: 1px solid var(--line); border-radius: 6px; background: #fff; font-weight: 550; white-space: nowrap; }
.actions button:hover:not(:disabled) { background: var(--bg); }
.actions button:disabled { opacity: .4; cursor: default; }
.actions button.primary { border-color: var(--accent); background: var(--accent); color: #fff; }
.actions button.primary:hover { background: #2549C4; }
.actions button.icon { display: grid; place-items: center; width: 30px; height: 30px; padding: 0; }

/* ---- page layout ----------------------------------------------------------------------- */

.layout { --pal-w: 372px; --right-w: 400px; display: grid; grid-template-columns: min(var(--pal-w), 46vw) minmax(0, 1fr) min(var(--right-w), 46vw); min-height: 0; }

/* Dragging happens all over the chrome; none of it should ever turn into a text selection.
   Text that is being typed, and output worth copying, stays selectable. */
.top, .palette, .tab-row, .ws, .stage-bar, .side-tabs { user-select: none; -webkit-user-select: none; }
.ws [contenteditable], .palette input, .top input { user-select: text; -webkit-user-select: text; }

/* The dividers beside the palette and the stage. */
.splitter { position: absolute; top: 0; bottom: 0; right: -4px; z-index: 20; width: 8px; cursor: col-resize; touch-action: none; }
.splitter.at-left { right: auto; left: -4px; }
.splitter::after { content: ''; position: absolute; top: 0; bottom: 0; left: 3px; width: 2px; background: transparent; transition: background .12s; }
.splitter:hover::after, .splitter:focus-visible::after, body.is-resizing .splitter:active::after { background: var(--accent); }
.splitter:focus-visible { outline: none; }
body.is-resizing, body.is-resizing * { cursor: col-resize !important; user-select: none; -webkit-user-select: none; }
.center { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; min-width: 0; min-height: 0; }
.panes { display: grid; grid-template-columns: minmax(0, 1fr); min-height: 0; border-top: 1px solid var(--line); }
.layout[data-fade="3"] .panes { grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); }
.layout[data-fade="1"] .code-pane, .layout[data-fade="2"] .code-pane { display: none; }
.layout[data-fade="5"] .ws-pane { display: none; }
.ws-pane { display: grid; grid-template-rows: auto minmax(0, 1fr); min-width: 0; min-height: 0; background: var(--ws-bg); }
.ws { position: relative; overflow: auto; padding: 18px 22px 120px; }
.ws.stale { opacity: .5; }
.stale { display: flex; align-items: center; gap: 10px; padding: 7px 14px; background: #FFF6DB; border-bottom: 1px solid #F0DCA0; color: #6B4E00; font-size: 12px; }
.stale button { padding: 2px 9px; border: 1px solid #D9BE6B; border-radius: 5px; background: #fff; }

/* ---- tabs ------------------------------------------------------------------------------ */

.tab-row { display: flex; align-items: flex-end; gap: 12px; padding: 8px 12px 0; min-width: 0; }
/* The strip overlaps the line under it by a pixel, as one piece: every tab is a whole number of
   pixels tall and none is taller than its box, so the part that scrolls sideways has no room to
   move up or down. */
.tabs { display: flex; align-items: flex-end; min-width: 0; margin-bottom: -1px; }
/* The app and the program stay put on the left; the other tabs scroll beside them. */
.tabs-pinned, .tabs-rest { display: flex; align-items: flex-end; gap: 2px; }
.tabs-pinned { flex: none; }
.tabs-rest { min-width: 0; overflow-x: auto; overflow-y: hidden; scrollbar-width: none; }
.tabs-rest::-webkit-scrollbar { display: none; }
.tabs-rest.more-left { -webkit-mask-image: linear-gradient(to right, transparent, #000 16px); mask-image: linear-gradient(to right, transparent, #000 16px); }
.tabs-rest.more-right { -webkit-mask-image: linear-gradient(to left, transparent, #000 16px); mask-image: linear-gradient(to left, transparent, #000 16px); }
.tabs-rest.more-left.more-right { -webkit-mask-image: linear-gradient(to right, transparent, #000 16px, #000 calc(100% - 16px), transparent); mask-image: linear-gradient(to right, transparent, #000 16px, #000 calc(100% - 16px), transparent); }
.tabs.has-rest .tabs-pinned::after { content: ''; flex: none; align-self: center; width: 1px; height: 18px; margin: 0 5px 0 3px; background: var(--line); }
.tabs:not(.has-rest) .tabs-rest { margin-left: 2px; }
.tab { display: flex; align-items: center; gap: 7px; padding: 6px 11px; border: 1px solid transparent; border-bottom: 0; border-radius: 7px 7px 0 0; background: transparent; color: var(--muted); font-weight: 550; line-height: 18px; white-space: nowrap; }
.tab:hover { color: var(--text); background: rgba(255, 255, 255, .6); }
.tab.on { background: var(--ws-bg); border-color: var(--line); color: var(--text); }
.layout[data-fade="5"] .tab.on { background: #fff; }
.tab .dot { width: 8px; height: 8px; border-radius: 50%; background: #55617A; }
.tab.k-main .dot { background: #A06E00; border-radius: 2px; }
.tab.k-interface .dot { background: transparent; box-shadow: inset 0 0 0 2px #7A5AE0; }
.tab.is-app .dot { background: #A06E00; }
.tab .badge { min-width: 16px; padding: 0 4px; border-radius: 8px; background: var(--danger); color: #fff; font-size: 10.5px; line-height: 16px; text-align: center; }
.tab .close { position: relative; flex: none; width: 16px; height: 16px; margin: 0 -5px 0 1px; border-radius: 4px; color: var(--muted); opacity: 0; }
.tab .close::before, .tab .close::after { content: ''; position: absolute; left: 3.5px; top: 7.25px; width: 9px; height: 1.5px; border-radius: 1px; background: currentColor; transform: rotate(45deg); }
.tab .close::after { transform: rotate(-45deg); }
.tab:hover .close, .tab.on .close { opacity: .7; }
.tab .close:hover { background: var(--line); opacity: 1; }
.tab.add { padding: 4px 10px; font-size: 16px; line-height: 18px; }
.fade-about { flex: 1; padding-bottom: 7px; color: var(--muted); font-size: 12px; text-align: right; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---- palette ---------------------------------------------------------------------------
   Search, then the categories, then the blocks of one category (or the search results)
   across the full width, so that long blocks fit without scrolling sideways. */

.palette { position: relative; display: grid; grid-template: auto auto minmax(0, 1fr) auto / minmax(0, 1fr); min-height: 0; background: var(--panel); border-right: 1px solid var(--line); }
.pal-search { display: flex; align-items: center; gap: 7px; height: 32px; margin: 10px 10px 8px; padding: 0 9px; border: 1px solid var(--line); border-radius: 8px; background: var(--ws-bg); color: var(--muted); cursor: text; }
.pal-search:focus-within { border-color: var(--accent); background: #fff; box-shadow: 0 0 0 3px var(--accent-soft); }
.pal-search svg { flex: none; }
.pal-search input { flex: 1; min-width: 0; padding: 0; border: 0; outline: 0; background: transparent; color: var(--text); font-size: 13px; appearance: none; }
.pal-search input::placeholder { color: var(--muted); }
.pal-search kbd { flex: none; min-width: 18px; padding: 0 5px; border: 1px solid var(--line); border-radius: 4px; background: #fff; font: 600 11px/16px var(--ui); text-align: center; }
.pal-search:focus-within kbd, .pal-search input:not(:placeholder-shown) + kbd { display: none; }
#cats { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 1px 4px; padding: 0 10px 8px; border-bottom: 1px solid var(--line-soft); }
.cat { display: flex; align-items: center; gap: 7px; min-width: 0; padding: 4px 8px; border: 0; border-radius: 6px; background: transparent; color: var(--text); font-size: 12px; font-weight: 500; text-align: left; white-space: nowrap; }
.cat:hover { background: var(--bg); }
.cat.on { background: color-mix(in srgb, var(--c) 15%, #fff); font-weight: 650; }
.cat .dot { flex: none; width: 10px; height: 10px; border-radius: 50%; background: var(--c); }
#palItems { overflow: auto; padding: 8px 12px 40px; }
#palItems h4 { margin: 14px 0 4px; color: var(--muted); font-size: 11px; font-weight: 600; }
#palItems h4:first-child { margin-top: 2px; }
.pal-count { margin: 2px 0 8px; color: var(--muted); font-size: 12px; line-height: 1.45; }
.hint { margin: 6px 0; color: var(--muted); font-size: 12px; font-weight: 400; line-height: 1.45; }
.pal-item { width: max-content; margin: 7px 0; border-radius: 9px; cursor: grab; }
.pal-item:hover .blk:not(.blk .blk) { filter: brightness(1.07); }
.pal-item.key { outline: 2px solid var(--accent); outline-offset: 3px; }
.pal-item .blk { margin: 0 !important; max-width: none; }
.pal-item .row, .pal-item .blk.expr { flex-wrap: nowrap; }
.palette .body { min-width: 64px !important; min-height: 14px !important; }
.palette .blk.unit, .palette .blk.member { min-width: 0 !important; }
.pal-foot { padding: 7px 12px; border-top: 1px solid var(--line-soft); color: var(--muted); font-size: 11.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---- blocks: structure shared by both faces -------------------------------------------- */

.blk { --c: #55617A; }
.c-motion { --c: #3A6FE0; } .c-looks { --c: #7A5AE0; } .c-sound { --c: #B8468F; } .c-pen { --c: #0A8778; } .c-events { --c: #A06E00; }
.c-control { --c: #C25E0A; } .c-sensing { --c: #1580AE; } .c-operators { --c: #2C8440; } .c-text { --c: #557F1A; }
.c-variables { --c: #D5483B; } .c-lists { --c: #B5561F; } .c-objects { --c: #B43F8E; } .c-methods { --c: #C2356B; }
.c-structure { --c: #55617A; } .c-comment { --c: #7C8696; } .c-plain { --c: #7C8696; }

.row { display: flex; align-items: center; flex-wrap: wrap; }
.slot, .grp, .fixed { display: inline-flex; align-items: center; }
.flat { display: contents; }
.tok { white-space: pre; }
.blk.stmt, .blk.member { width: fit-content; max-width: 100%; cursor: grab; }
.blk.expr { display: inline-flex; align-items: center; flex-wrap: wrap; cursor: grab; }
.blk[data-drag="no"] { cursor: default; }
.body { cursor: default; }
.edit, .lit, .hole { outline: none; }
.edit.editable, .lit.editable, .hole.editable { cursor: text; }
.edit.src:not(:focus) { cursor: grab; }
.blk select { appearance: none; border: 0; margin: 0; cursor: pointer; field-sizing: content; }
.ruler { position: absolute; top: -99px; left: -9999px; visibility: hidden; white-space: pre; }
.blk select option, .blk select optgroup { background: #fff; color: var(--text); font: 13px var(--ui); }

.mini { flex: none; height: 17px; padding: 0 6px; border: 0; border-radius: 9px; font: 600 11px/17px var(--ui); white-space: nowrap; opacity: 0; transition: opacity .12s; }
.blk:hover > .row > .mini, .blk:hover > .row > .grp > .mini, .blk:hover > .row > .grp > .grp > .mini, .blk:hover > .row > .slot > .mini,
.blk:hover > .row > .flat > .mini, .blk:hover > .row > .flat > .slot > .mini,
.blk.expr:hover > .mini, .blk.expr:hover > .slot > .mini, .blk.expr:hover > .grp > .mini,
.row.pseudo:hover > .mini, .mini:focus-visible { opacity: .75; }
.mini:hover { opacity: 1 !important; }

.blk.selected { outline: 2px solid #F5B301; outline-offset: 1px; }
.slot.active > .lit, .slot.active > .hole { outline: 2px solid #F5B301; outline-offset: 1px; }
.slot.will-fill > .lit, .slot.will-fill > .hole { outline: 2px dashed var(--accent); outline-offset: 1px; }
.blk.linked { outline: 2px dashed var(--accent); outline-offset: 1px; }
.has-warning { box-shadow: 0 0 0 2px #E0A100 !important; }
.has-error { box-shadow: 0 0 0 2px var(--danger), 0 0 0 5px rgba(199, 53, 43, .18) !important; }
.blk.running { box-shadow: 0 0 0 2px var(--glow), 0 0 12px 3px rgba(255, 210, 63, .7) !important; }
.blk.drag-source { opacity: .3; }
.slot.drop-hover > .lit, .slot.drop-hover > .hole, .slot.drop-hover > select { box-shadow: 0 0 0 3px var(--glow) !important; }
.drop-line { position: absolute; z-index: 5; height: 4px; border-radius: 2px; background: var(--accent); box-shadow: 0 0 0 2px rgba(47, 91, 234, .25); pointer-events: none; }
.drag-layer { position: fixed; top: 0; left: 0; z-index: 1000; pointer-events: none; opacity: .93; filter: drop-shadow(0 8px 14px rgba(16, 24, 40, .28)); will-change: transform; }
.drag-layer.will-delete { opacity: .4; filter: grayscale(1); }
.drag-layer .blk { margin: 0 !important; }
body.is-dragging, body.is-dragging * { cursor: grabbing !important; user-select: none; }

/* ---- the friendly face ----------------------------------------------------------------- */

.face-friendly .blk { font: 500 13px/1.35 var(--ui); }
.face-friendly .row { gap: 3px 6px; min-height: 26px; }
.face-friendly .tok.t-sp { display: none; }
.face-friendly .tok.t-ty, .face-friendly .tok.t-fn { font-weight: 700; }
.face-friendly .slot, .face-friendly .grp { gap: 4px; }

/* Every block has an edge in a darker shade of its own color, so that it is plain where one
   ends and the next begins even when two of the same color touch. */
.face-friendly .blk { --paint: var(--c); --edge: color-mix(in srgb, var(--c) 62%, #000); }
.face-friendly .blk.stmt, .face-friendly .blk.member {
    margin: 3px 0; padding: 3px 10px; border-radius: 8px; background: var(--paint); color: #fff;
    box-shadow: inset 0 0 0 1.25px var(--edge);
}
.face-friendly .blk.member { padding: 5px 10px 7px; border-radius: 10px; }
.face-friendly .blk.member > .row:first-child { min-height: 30px; }
.face-friendly .blk.hat { padding: 5px 10px 7px; border-radius: 14px 14px 10px 10px; }
.face-friendly .blk.k-comment { background: #FFF6CC; color: #5C4A00; box-shadow: inset 0 0 0 1px #E8D48A; font-weight: 400; }
/* Blocks in a script lock together, as in Scratch. Each has a tab on its bottom edge that
   sits in the top of the block below it, and a block that holds others wraps round them
   like a C, with a tab of its own plugged into the first one. */
.face-friendly .blk.stmt { position: relative; }
.face-friendly .body > .blk.stmt { margin: 0; border-radius: 5px; }
.face-friendly .blk.stmt:not(.hat):not(.k-comment):not(.k-return):not(.k-break):not(.k-continue)::after,
.face-friendly .body > .blk.stmt:first-child:not(.k-comment)::before {
    content: ''; position: absolute; z-index: 1; left: 14px; width: 20px; height: 7px; border-radius: 0 0 6px 6px; pointer-events: none;
}
/* (A tab starts just inside its own block, covering the block's edge there, and carries the
   edge on round its sides and bottom.) */
.face-friendly .blk.stmt:not(.hat):not(.k-comment):not(.k-return):not(.k-break):not(.k-continue)::after {
    bottom: -5px; background: var(--paint); box-shadow: inset 1.25px 0 0 var(--edge), inset -1.25px 0 0 var(--edge), inset 0 -1.25px 0 var(--edge);
}
.face-friendly .body > .blk.stmt:first-child:not(.k-comment)::before {
    top: -2px; background: var(--holder); box-shadow: inset 1.25px 0 0 var(--holder-edge), inset -1.25px 0 0 var(--holder-edge), inset 0 -1.25px 0 var(--holder-edge);
}
.face-friendly .body > .blk.k-comment { margin: 0; border-radius: 4px; }
.face-friendly .blk.selected, .face-friendly .has-error, .face-friendly .has-warning, .face-friendly .blk.running { z-index: 2; }
.face-friendly .body {
    --holder: var(--paint); --holder-edge: var(--edge);
    min-width: 170px; min-height: 30px; margin: 4px -10px 4px 14px; padding: 0 0 6px; border-radius: 6px 0 0 6px;
    background: var(--ws-bg); box-shadow: inset 1.25px 1.25px 0 var(--edge), inset 0 -1.25px 0 var(--edge);
}
.face-friendly .body.flat { min-width: 0; min-height: 0; margin: 0; padding: 0; background: none; box-shadow: none; }
.face-friendly .gap { height: 8px; }
.face-friendly .row.pseudo { padding: 2px 10px; border-radius: 8px; background: #E3E6EC; color: var(--text); width: fit-content; margin: 3px 0; }

.face-friendly .blk.expr { gap: 3px 5px; min-height: 22px; padding: 1px 9px; border-radius: 12px; background: var(--paint); color: #fff; box-shadow: inset 0 0 0 1.5px rgba(0, 0, 0, .2); }
.face-friendly .blk.expr.k-bin, .face-friendly .blk.expr.k-un { border-radius: 5px; }

/* True-or-false values have pointed ends, and so do the slots that expect one. The six-sided
   shape is painted as a background (a middle and four corner triangles), so the box itself
   stays a rectangle and the marks for selection and errors still fit round it. */
.face-friendly .blk.expr.is-bool, .face-friendly .hole.is-bool {
    --point: 10px;
    border-radius: 0; box-shadow: none;
    background:
        linear-gradient(to bottom right, transparent 49%, var(--fill) 50.5%) left top / var(--point) 50% no-repeat,
        linear-gradient(to top right, transparent 49%, var(--fill) 50.5%) left bottom / var(--point) 50% no-repeat,
        linear-gradient(to bottom left, transparent 49%, var(--fill) 50.5%) right top / var(--point) 50% no-repeat,
        linear-gradient(to top left, transparent 49%, var(--fill) 50.5%) right bottom / var(--point) 50% no-repeat,
        linear-gradient(var(--fill), var(--fill)) center / calc(100% - 2 * var(--point) + 1px) 100% no-repeat;
}
/* A soft edge that follows the six-sided shape, so that one inside another of the same color still shows. */
.face-friendly .blk.expr.is-bool { --fill: var(--paint); padding: 1px 15px; filter: drop-shadow(0 0 .7px rgba(0, 0, 0, .7)); }
.face-friendly .hole.is-bool { --fill: rgba(0, 0, 0, .27); min-width: 44px; padding: 0 15px; }
.face-friendly .hole.is-bool:focus { --fill: #fff; }


.face-friendly .lit, .face-friendly .hole {
    display: inline-block; min-width: 22px; min-height: 20px; padding: 0 8px; border-radius: 10px;
    background: #fff; color: var(--text); font-weight: 500; line-height: 20px; text-align: center; white-space: pre;
}
.face-friendly .lit-str { border-radius: 4px; text-align: left; }
/* A text that names a sound, costume, backdrop or key has a small arrow that opens the list of them. */
.lit-menu { flex: none; margin: 0; padding: 0 4px; border: 0; font: 600 10px/20px var(--ui); cursor: pointer; }
.face-friendly .slot.has-choices { gap: 0; }
.face-friendly .slot.has-choices > .lit-str { border-radius: 4px 0 0 4px; padding-right: 5px; }
.face-friendly .lit-menu { height: 20px; border-radius: 0 4px 4px 0; background: #fff; color: var(--muted); box-shadow: inset 1px 0 0 var(--line); }
.face-friendly button.lit-menu:hover { background: var(--accent-soft); color: var(--accent); }
.face-code .lit-menu { height: auto; background: transparent; color: var(--muted); line-height: 1.3; opacity: .55; }
.face-code button.lit-menu:hover { opacity: 1; }
.face-friendly .hole { min-width: 30px; background: rgba(0, 0, 0, .27); box-shadow: inset 0 1px 2px rgba(0, 0, 0, .3); }
.face-friendly .hole:focus { background: #fff; }
/* An empty slot says what belongs in it. */
.face-friendly .hole:empty::before { content: attr(data-hint); color: rgba(255, 255, 255, .82); font-weight: 400; font-size: 12px; }
.face-friendly .hole:empty:focus::before { color: #98A2B3; }
.face-friendly .edit { min-width: 14px; padding: 0 6px; border-radius: 5px; background: rgba(0, 0, 0, .2); font-weight: 650; white-space: pre; }
.face-friendly .edit:focus { background: #fff; color: var(--text); }
.face-friendly .blk select { padding: 1px 17px 1px 6px; border-radius: 5px; background: rgba(0, 0, 0, .2) var(--chev-light) no-repeat right 5px center / 8px; color: inherit; font: inherit; font-weight: 650; }
.face-friendly .blk select.lit-bool { padding-left: 9px; border-radius: 10px; background-color: #fff; background-image: var(--chev-dark); color: var(--text); font-weight: 500; }
.face-friendly .blk select.is-none { width: 18px; padding: 1px 0; color: transparent; background-position: center; }
.face-friendly .blk select.adder { width: auto; padding: 1px 17px 1px 6px; color: inherit; background-position: right 5px center; opacity: .75; font-weight: 500; }
.face-friendly .mini { background: rgba(255, 255, 255, .92); color: var(--text); }
.face-friendly .k-comment .edit { background: transparent; font-weight: 400; }

/* A class is drawn as a card holding its members; the program tab has no frame at all. */
.face-friendly .blk.unit.k-class, .face-friendly .blk.unit.k-interface {
    width: fit-content; min-width: 440px; max-width: 100%; padding: 8px 14px 14px; border: 1px solid var(--line); border-top: 4px solid var(--c);
    border-radius: 10px; background: #fff; color: var(--text); box-shadow: 0 1px 2px rgba(16, 24, 40, .06);
}
.face-friendly .blk.unit > .row { min-height: 36px; font-size: 15px; font-weight: 600; }
.face-friendly .blk.unit > .row > .edit, .face-friendly .blk.unit > .row .g-supers .tok.t-ty { background: color-mix(in srgb, var(--c) 13%, #fff); color: var(--text); }
.face-friendly .blk.unit > .row .g-supers .tok.t-ty { padding: 0 6px; border-radius: 5px; }
.face-friendly .blk.unit > .row select { background-color: color-mix(in srgb, var(--c) 13%, #fff); background-image: var(--chev-dark); color: var(--text); }
.face-friendly .blk.unit > .row .mini { background: var(--bg); }
.face-friendly .blk.unit > .body { min-width: 400px; min-height: 70px; margin: 6px 0 0; padding: 0; background: none; box-shadow: none; }
.face-friendly .blk.unit > .body.is-empty > .empty::before, .face-friendly .blk.hat > .body.is-empty > .empty::before { content: 'Drag blocks here'; color: #98A2B3; font-weight: 400; line-height: 22px; }
.face-friendly .blk.unit.k-main > .body { min-width: 0; min-height: 0; margin: 0; }

/* ---- the code face --------------------------------------------------------------------- */

.face-code .blk { font: 12.5px/1.55 var(--mono); color: var(--text); }
.face-code .row { min-height: 21px; flex-wrap: nowrap; }
.face-code .blk.stmt, .face-code .blk.member, .face-code .blk.unit { max-width: none; }
.face-code .tok.t-kw, .face-code .t-kw { color: var(--s-kw); }
.face-code .tok.t-ty, .face-code .t-ty { color: var(--s-ty); }
.face-code .tok.t-fn, .face-code .t-fn { color: var(--s-fn); }
.face-code .tok.t-str, .face-code .t-str { color: var(--s-str); }
.face-code .tok.t-num { color: var(--s-num); }
.face-code .tok.t-cm, .face-code .t-cm { color: var(--s-cm); font-style: italic; }
.face-code .tok.t-pn, .face-code .tok.t-op { color: var(--s-pn); }
.face-code .tok.t-err { color: var(--danger); font-weight: 700; }
.face-code .tok.ghost { opacity: .75; }

.face-code .blk.stmt, .face-code .blk.member {
    margin: 2px 0; padding: 0 9px 0 7px; border-left: 3px solid var(--c); border-radius: 3px 6px 6px 3px;
    background: color-mix(in srgb, var(--c) 9%, #fff);
}
/* Nested lines sit exactly four characters in from their parent, as they do in the source. */
.face-code .body { min-width: 22ch; min-height: 21px; margin-left: calc(4ch - 10px); }
.face-code .body.flat { min-width: 0; margin-left: 0; }
.face-code .body.is-empty > .empty { padding-left: 10px; color: var(--s-kw); opacity: .55; min-height: 21px; }
.face-code .body[data-kind="func"].is-empty > .empty { min-height: 0; }
.face-code .gap { height: 1.55em; }
.face-code .row.pseudo { padding: 0 9px 0 10px; }
.face-code .blk.unit { padding: 0; }
.face-code .blk.unit > .row { padding-left: 10px; }
.face-code .blk.unit.k-main > .row { padding-left: 10px; }

.face-code .blk.expr { flex-wrap: nowrap; margin: 0 1px; padding: 0 3px; border-radius: 4px; background: color-mix(in srgb, var(--c) 17%, #fff); }
.face-code .lit { display: inline-block; min-width: 1ch; white-space: pre; color: var(--s-num); border-bottom: 1px dotted currentColor; line-height: 1.3; }
.face-code .lit-str { color: var(--s-str); }
.face-code .lit-str::before, .face-code .lit-str::after { content: '"'; }
.face-code .hole { display: inline-block; min-width: 3ch; min-height: 17px; padding: 0 2px; border: 1px dashed var(--danger); border-radius: 3px; background: var(--danger-soft); }
.face-code .edit { display: inline-block; min-width: 1ch; white-space: pre; border-radius: 2px; }
.face-code .edit.editable:hover { background: rgba(47, 91, 234, .12); }
.face-code .edit:focus, .face-code .lit:focus, .face-code .hole:focus { background: #FFF3BF; border-color: transparent; }
.face-code .blk select { padding: 0 11px 0 0; background: transparent var(--chev-dark) no-repeat right 1px center / 7px; font: inherit; }
.face-code .blk select.t-kw, .face-code .blk select.lit-bool { color: var(--s-kw); }
.face-code .blk select.t-op { color: var(--s-pn); }
.face-code .blk select.is-none { width: 0; margin: 0; padding: 0; color: transparent; background-position: center; opacity: .6; }
.face-code .blk:hover > .row > select.is-none, .face-code .blk:hover > .row > .grp > select.is-none, .face-code .blk select.is-none:focus { width: 11px; margin-right: 3px; }
.face-code .blk select.adder { width: auto; padding: 0 11px 0 4px; color: var(--muted); background-position: right 1px center; font-family: var(--ui); font-size: 11px; }
/* Controls that are not part of the code take no room until the line is pointed at, so the
   blocks line up character for character with the source. */
.face-code .mini { width: 0; margin: 0; padding: 0; overflow: hidden; background: rgba(24, 32, 47, .09); color: var(--muted); }
.face-code .blk:hover > .row > .mini, .face-code .blk:hover > .row > .grp > .mini, .face-code .blk:hover > .row > .grp > .grp > .mini,
.face-code .blk:hover > .row > .slot > .mini, .face-code .blk:hover > .row > .flat > .mini, .face-code .blk:hover > .row > .flat > .slot > .mini,
.face-code .blk.expr:hover > .mini, .face-code .blk.expr:hover > .slot > .mini, .face-code .blk.expr:hover > .grp > .mini,
.face-code .row.pseudo:hover > .mini, .face-code .mini:focus-visible { width: auto; margin-left: 5px; padding: 0 6px; }

/* ---- blocks with code -------------------------------------------------------------------
   The second level. The blocks keep the shapes of the plain-language face (they are drawn
   by its rules above), but what is written on them is the code itself, set as code is set:
   one typeface, nothing spaced out, text in its code colors. The blocks are made paler so
   that the code is what is read. */
.face-friendly.with-code .blk { --paint: color-mix(in srgb, var(--c) 26%, #fff); --edge: color-mix(in srgb, var(--c) 78%, #fff); font: 500 12.5px/1.45 var(--mono); }
.face-friendly.with-code .blk.stmt, .face-friendly.with-code .blk.member { color: var(--text); }
.face-friendly.with-code .blk.expr { --paint: color-mix(in srgb, var(--c) 46%, #fff); color: var(--text); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--c) 60%, #fff); }
.face-friendly.with-code .blk.expr.is-bool { box-shadow: none; filter: drop-shadow(0 0 .6px color-mix(in srgb, var(--c) 80%, #000)); }
.face-friendly.with-code .row, .face-friendly.with-code .slot, .face-friendly.with-code .grp, .face-friendly.with-code .blk.expr { gap: 0; }
.face-friendly.with-code .tok.t-sp { display: inline; }
.face-friendly.with-code .tok.t-ty, .face-friendly.with-code .tok.t-fn { font-weight: 600; }
.face-friendly.with-code .tok.t-kw, .face-friendly.with-code .t-kw { color: var(--s-kw); }
.face-friendly.with-code .tok.t-ty, .face-friendly.with-code .t-ty { color: var(--s-ty); }
.face-friendly.with-code .tok.t-fn, .face-friendly.with-code .t-fn { color: var(--s-fn); }
.face-friendly.with-code .tok.t-str, .face-friendly.with-code .t-str { color: var(--s-str); }
.face-friendly.with-code .tok.t-num { color: var(--s-num); }
.face-friendly.with-code .tok.t-pn, .face-friendly.with-code .tok.t-op { color: var(--s-pn); }
.face-friendly.with-code .tok.ghost { opacity: .7; }
.face-friendly.with-code .lit { min-width: 2ch; padding: 0 6px; color: var(--s-num); font-weight: 500; }
.face-friendly.with-code .lit-str { color: var(--s-str); }
.face-friendly.with-code .lit-str::before, .face-friendly.with-code .lit-str::after { content: '"'; }
.face-friendly.with-code .edit { padding: 0 4px; background: rgba(24, 32, 47, .07); font-weight: 600; }
.face-friendly.with-code .hole { background: rgba(24, 32, 47, .13); box-shadow: inset 0 1px 2px rgba(24, 32, 47, .16); }
.face-friendly.with-code .hole.is-bool { --fill: rgba(24, 32, 47, .13); box-shadow: none; }
.face-friendly.with-code .hole:focus, .face-friendly.with-code .hole.is-bool:focus { background: #fff; --fill: #fff; }
.face-friendly.with-code .hole:empty::before { color: rgba(24, 32, 47, .5); font-family: var(--ui); }
.face-friendly.with-code .blk select { padding: 0 15px 0 4px; background-color: rgba(24, 32, 47, .07); background-image: var(--chev-dark); font-weight: 600; }
.face-friendly.with-code .blk select.t-kw, .face-friendly.with-code .blk select.lit-bool { color: var(--s-kw); }
.face-friendly.with-code .blk select.t-op { color: var(--s-pn); }
.face-friendly.with-code .blk select.is-none { width: 16px; padding: 0; color: transparent; background-color: transparent; background-position: center; opacity: .55; }
.face-friendly.with-code .blk select.adder { font-family: var(--ui); font-weight: 500; }
.face-friendly.with-code .blk.unit > .row { font: 600 13.5px/1.4 var(--mono); }
.face-friendly.with-code .blk.k-comment { font-family: var(--mono); }

/* ---- code panel ------------------------------------------------------------------------ */

.code-pane { display: grid; grid-template-rows: auto minmax(0, 1fr); min-width: 0; min-height: 0; background: #fff; border-left: 1px solid var(--line); }
.layout[data-fade="5"] .code-pane { border-left: 0; }
.code-head { display: flex; align-items: center; justify-content: space-between; padding: 6px 14px; border-bottom: 1px solid var(--line-soft); color: var(--muted); font: 600 12px var(--mono); }
.code-head .mode { font: 500 11px var(--ui); }
.code { min-height: 0; overflow: hidden; }
.code-scroll { display: grid; grid-template-columns: auto minmax(0, 1fr); align-content: start; height: 100%; overflow: auto; font: 12.5px/1.6 var(--mono); }
.gutter { min-height: 100%; padding: 10px 8px 40px 12px; border-right: 1px solid var(--line-soft); background: #FAFBFC; color: #A3ABB8; text-align: right; user-select: none; }
.gutter .ln.err { margin: 0 -4px; padding: 0 4px; border-radius: 3px; background: var(--danger); color: #fff; }
.code-body { position: relative; min-width: max-content; }
.hl { min-height: 100%; margin: 0; padding: 10px 16px 40px; font: inherit; white-space: pre; tab-size: 4; }
.hl .t-kw { color: var(--s-kw); } .hl .t-ty { color: var(--s-ty); } .hl .t-fn { color: var(--s-fn); } .hl .t-str { color: var(--s-str); }
.hl .t-num { color: var(--s-num); } .hl .t-cm { color: var(--s-cm); font-style: italic; } .hl .t-pn, .hl .t-op { color: var(--s-pn); }
.hl .t-err { color: var(--danger); font-weight: 700; }
.hl .linked { background: var(--accent-soft); }
.hl .run { background: #FFEFA8; }
.hl .warn { text-decoration: underline wavy #E0A100; text-underline-offset: 3px; }
.hl .err { background: var(--danger-soft); text-decoration: underline wavy var(--danger); text-underline-offset: 3px; }
.code .input { display: none; position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; padding: 10px 16px 40px; border: 0; outline: none; resize: none; overflow: hidden;
    background: transparent; color: transparent; caret-color: var(--text); font: inherit; white-space: pre; tab-size: 4; }
.code.is-editable .input { display: block; }
.code .input::selection { background: rgba(47, 91, 234, .25); }

/* ---- problems -------------------------------------------------------------------------- */

.problems { max-height: 132px; overflow: auto; border-top: 1px solid var(--line); background: #fff; }
.problems .head { position: sticky; top: 0; padding: 5px 14px; background: #fff; border-bottom: 1px solid var(--line-soft); color: var(--danger); font-size: 11.5px; font-weight: 700; }
.problem { display: flex; gap: 10px; width: 100%; padding: 4px 14px; border: 0; background: transparent; text-align: left; font-size: 12.5px; line-height: 1.4; }
.problem:hover { background: var(--bg); }
.problem .where { flex: none; min-width: 84px; color: var(--muted); font-weight: 600; }
.problem.error .msg::before { content: '●  '; color: var(--danger); font-size: 9px; vertical-align: 1px; }
.problem.warning .msg::before { content: '●  '; color: #E0A100; font-size: 9px; vertical-align: 1px; }

/* ---- stage, console, objects ----------------------------------------------------------- */

.right { position: relative; display: grid; grid-template-rows: auto auto auto auto minmax(0, 1fr); gap: 8px; min-height: 0; padding: 10px 12px 0; background: var(--panel); border-left: 1px solid var(--line); }
.stage-bar { display: flex; align-items: center; gap: 8px; }
.stage-bar button { flex: none; padding: 5px 11px; border: 1px solid var(--line); border-radius: 6px; background: #fff; font-weight: 650; white-space: nowrap; }
.stage-bar .run { border-color: var(--go); background: var(--go); color: #fff; }
.stage-bar .run:hover { background: #18723E; }
.stage-bar .run.on { box-shadow: 0 0 0 3px rgba(30, 138, 75, .25); }
.stage-bar .stop:hover { border-color: var(--danger); color: var(--danger); }
.status { flex: 0 1 auto; min-width: 0; margin-left: auto; overflow: hidden; color: var(--muted); font-size: 12px; white-space: nowrap; text-overflow: ellipsis; }
.status[data-state="running"] { color: var(--go); font-weight: 600; }
.status[data-state="error"] { color: var(--danger); font-weight: 600; }
.stage-wrap { position: relative; overflow: hidden; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
#stage { display: block; width: 100%; aspect-ratio: 4 / 3; }
.ask { position: absolute; left: 8px; right: 8px; bottom: 8px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: rgba(255, 255, 255, .97); box-shadow: 0 4px 14px rgba(16, 24, 40, .16); }
.ask label { display: block; margin-bottom: 5px; font-weight: 600; }
.ask div { display: flex; gap: 6px; }
.ask input { flex: 1; min-width: 0; padding: 5px 8px; border: 1px solid var(--line); border-radius: 6px; }
.ask button { padding: 5px 12px; border: 0; border-radius: 6px; background: var(--accent); color: #fff; font-weight: 650; }
.side-tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); }
.side-tabs button { padding: 5px 11px; margin-bottom: -1px; border: 0; border-bottom: 2px solid transparent; background: transparent; color: var(--muted); font-weight: 600; }
.side-tabs button.on { border-bottom-color: var(--accent); color: var(--text); }
.console, .objects { min-height: 0; overflow: auto; padding: 4px 2px 14px; }
.console { font: 12.5px/1.5 var(--mono); }
.console .line { padding: 0 4px; white-space: pre-wrap; overflow-wrap: anywhere; }
.console .line.error { margin: 3px 0; padding: 4px 8px; border-radius: 6px; background: var(--danger-soft); color: var(--danger); }
.console .line.link { cursor: pointer; }
.obj { margin: 6px 0; padding: 6px 9px; border: 1px solid var(--line); border-radius: 8px; }
.obj-head { display: flex; align-items: baseline; gap: 6px; margin-bottom: 3px; }
.obj .cls { font-weight: 700; }
.obj .id { color: var(--muted); font-size: 11.5px; }
.obj .field { display: flex; justify-content: space-between; gap: 10px; font: 12px/1.55 var(--mono); }
.obj .fname { color: var(--muted); }
.obj .field.private .fname::before { content: '🔒 '; font-size: 10px; }
.obj .fval { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---- menus and toasts ------------------------------------------------------------------ */

.menu { position: fixed; z-index: 900; display: flex; flex-direction: column; min-width: 230px; max-width: 360px; max-height: 70vh; overflow: auto; padding: 5px; border: 1px solid var(--line); border-radius: 9px; background: #fff; box-shadow: 0 12px 32px rgba(16, 24, 40, .18); }
.menu button { display: flex; flex-direction: column; gap: 1px; padding: 7px 10px; border: 0; border-radius: 6px; background: transparent; text-align: left; }
.menu button:hover { background: var(--accent-soft); }
.menu .title { font-weight: 650; }
.menu .about { color: var(--muted); font-size: 12px; line-height: 1.35; }
/* The notice for a page whose script never started. It needs no script itself: it comes in by
   itself after a few seconds, and the editor removes it the moment it is up. */
.boot { position: fixed; inset: 0; z-index: 900; display: grid; place-items: center; padding: 24px; pointer-events: none; opacity: 0; animation: boot-in .3s ease-out 6s forwards; }
.boot p { max-width: 400px; margin: 0; padding: 16px 20px; border: 1px solid var(--line); border-radius: 10px; background: #fff; box-shadow: 0 10px 30px rgba(20, 30, 60, .12); color: var(--text); font-size: 13px; line-height: 1.5; pointer-events: auto; }
.boot a { display: inline-block; margin-top: 6px; color: var(--accent, #2F5BEA); font-weight: 600; }
@keyframes boot-in { to { opacity: 1; } }
.toasts { position: fixed; left: 50%; bottom: 22px; z-index: 950; display: flex; flex-direction: column; align-items: center; gap: 8px; transform: translateX(-50%); pointer-events: none; }
.toast { max-width: 560px; padding: 9px 15px; border-radius: 8px; background: #1F2937; color: #fff; font-size: 13px; line-height: 1.4; box-shadow: 0 8px 22px rgba(16, 24, 40, .3); }

@media (max-width: 1360px) {
    .layout { --pal-w: 320px; --right-w: 340px; }
    .proj-name { width: 120px; }
    .field { font-size: 0; }
}

/* ---- account, save state and windows ---------------------------------------------------- */

.save-state { flex: 0 1 auto; min-width: 0; overflow: hidden; color: var(--muted); font-size: 12px; white-space: nowrap; text-overflow: ellipsis; }
.save-state.bad { color: var(--danger); font-weight: 600; }
.actions button.account.signed { display: grid; place-items: center; width: 30px; height: 30px; padding: 0; border-color: transparent; border-radius: 50%; background: #1F2937; color: #fff; font-weight: 650; }
.actions button.account.signed:hover { background: #374151; }

.dialog { width: min(420px, calc(100vw - 32px)); max-height: calc(100vh - 48px); padding: 0; border: 1px solid var(--line); border-radius: 12px; background: #fff; color: var(--text); box-shadow: 0 24px 60px rgba(16, 24, 40, .28); }
.dialog::backdrop { background: rgba(16, 24, 40, .42); }
.dialog-form { display: flex; flex-direction: column; gap: 12px; padding: 20px 22px 18px; }
.dialog h2 { margin: 0; font-size: 16px; font-weight: 650; letter-spacing: -.01em; }
.dialog-msg { margin: -4px 0 0; color: var(--muted); line-height: 1.5; }
.dialog-field { display: flex; flex-direction: column; gap: 4px; font-size: 12px; font-weight: 600; }
.dialog-field input { padding: 7px 9px; border: 1px solid var(--line); border-radius: 7px; font-size: 14px; font-weight: 400; }
.dialog-field input:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
.dialog-check { display: flex; align-items: center; gap: 8px; }
.dialog-hint { margin: -8px 0 0; color: var(--muted); font-size: 11.5px; line-height: 1.4; }
/* The check that a person is signing up: its widget is 65px high once it has loaded. */
.captcha { min-height: 65px; color: var(--muted); font-size: 12px; line-height: 1.4; }
.dialog-error { margin: 0; padding: 7px 10px; border-radius: 7px; background: var(--danger-soft); color: var(--danger); line-height: 1.4; }
.dialog-points { margin: 0; padding-left: 18px; line-height: 1.5; max-height: 40vh; overflow: auto; }
.dialog-points li + li { margin-top: 5px; }
.dialog-buttons { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }
.dialog button { padding: 6px 13px; border: 1px solid var(--line); border-radius: 7px; background: #fff; font-weight: 600; white-space: nowrap; }
.dialog button:hover:not(:disabled) { background: var(--bg); }
.dialog button:disabled { opacity: .5; cursor: default; }
.dialog button.primary { border-color: var(--accent); background: var(--accent); color: #fff; }
.dialog button.primary:hover:not(:disabled) { background: #2549C4; }
.dialog button.danger { border-color: var(--danger); background: var(--danger); color: #fff; }
.dialog button.danger:hover:not(:disabled) { background: #A82B23; }
.dialog button.link { align-self: center; padding: 2px 4px; border: 0; background: none; color: var(--accent); font-weight: 500; }
.dialog button.link:hover { background: none; text-decoration: underline; }

/* The Projects window. */
.dialog.library { width: min(880px, calc(100vw - 32px)); height: min(620px, calc(100vh - 48px)); }
.lib-frame { display: grid; grid-template-rows: auto minmax(0, 1fr); height: 100%; }
.lib-head { display: flex; align-items: center; gap: 8px; padding: 14px 16px 14px 20px; border-bottom: 1px solid var(--line); }
.lib-head h2 { margin-right: 10px; }
.dialog button.lib-close { width: 30px; height: 30px; padding: 0; border-color: transparent; font-size: 20px; line-height: 1; color: var(--muted); }
.lib-body { display: grid; grid-template-columns: 200px minmax(0, 1fr); min-height: 0; }
.lib-guest { grid-column: 1 / -1; align-self: center; justify-self: center; max-width: 420px; padding: 24px; text-align: center; }
.lib-guest h3 { margin: 0 0 8px; font-size: 16px; }
.lib-guest p { margin: 0 0 16px; color: var(--muted); line-height: 1.55; }
.lib-guest .dialog-buttons { justify-content: center; }
.lib-folders { display: flex; flex-direction: column; gap: 1px; padding: 12px 8px; overflow: auto; border-right: 1px solid var(--line-soft); background: var(--ws-bg); }
.dialog button.lib-folder { display: flex; justify-content: space-between; gap: 8px; padding: 6px 10px; border: 0; background: transparent; font-weight: 500; text-align: left; }
.dialog button.lib-folder:hover { background: var(--line-soft); }
.dialog button.lib-folder.on { background: var(--accent-soft); color: var(--accent); font-weight: 650; }
.lib-folder .name { overflow: hidden; text-overflow: ellipsis; }
.lib-folder .count { color: var(--muted); font-weight: 400; }
.lib-tip { margin: 12px 10px 0; color: var(--muted); font-size: 11.5px; line-height: 1.45; }
.lib-main { display: grid; grid-template-rows: auto minmax(0, 1fr); min-height: 0; }
.lib-tools { display: flex; gap: 8px; padding: 12px 16px 8px; }
.lib-tools input { flex: 1; min-width: 0; padding: 6px 10px; border: 1px solid var(--line); border-radius: 7px; }
.lib-tools select { padding: 6px 8px; border: 1px solid var(--line); border-radius: 7px; background: #fff; }
.lib-tools input:focus, .lib-tools select:focus { border-color: var(--accent); outline: none; }
.lib-list { overflow: auto; padding: 0 8px 12px; }
.lib-empty { margin: 28px 16px; color: var(--muted); text-align: center; line-height: 1.5; }
.lib-empty.error { color: var(--danger); }
.lib-row { display: grid; grid-template-columns: minmax(0, 1fr) 62px 120px 110px 30px; align-items: center; gap: 8px; padding: 0 4px 0 0; border-radius: 8px; }
.lib-row:hover { background: var(--ws-bg); }
.lib-row.current { background: var(--accent-soft); }
.dialog button.lib-open { display: flex; align-items: center; gap: 8px; min-width: 0; padding: 9px 10px; border: 0; background: transparent; font-weight: 600; text-align: left; }
.dialog button.lib-open:hover { background: transparent; color: var(--accent); }
.lib-open .name { overflow: hidden; text-overflow: ellipsis; }
.lib-open .tag { flex: none; padding: 1px 7px; border-radius: 9px; background: var(--accent); color: #fff; font-size: 10.5px; font-weight: 600; }
.lib-open .tag.linked { background: #DDF5E6; color: #17663A; }
.lib-lang, .lib-in, .lib-when { overflow: hidden; color: var(--muted); font-size: 12px; white-space: nowrap; text-overflow: ellipsis; }
.dialog button.lib-more { width: 28px; height: 28px; padding: 0; border-color: transparent; background: transparent; font-size: 16px; line-height: 1; color: var(--muted); }
.dialog button.lib-more:hover { background: var(--line); color: var(--text); }
.dialog .menu button { border: 0; font-weight: 400; white-space: normal; }
.dialog .menu button:hover { background: var(--accent-soft); }
.dialog .toasts { z-index: 2000; }

/* ---- costumes and sounds ---------------------------------------------------------------- */

.dialog.media { width: min(1100px, calc(100vw - 32px)); height: min(860px, calc(100vh - 32px)); }
.media-frame { display: grid; grid-template-rows: auto minmax(0, 1fr); height: 100%; }
.media-tabs { display: flex; gap: 4px; }
.dialog button.media-tab { padding: 6px 14px; border-color: transparent; background: transparent; color: var(--muted); font-size: 14px; }
.dialog button.media-tab.on { background: var(--accent-soft); color: var(--accent); }
.media-body { display: grid; grid-template-columns: 236px minmax(0, 1fr); min-height: 0; }
.media-list { display: grid; grid-template-rows: minmax(0, 1fr) auto; min-height: 0; border-right: 1px solid var(--line-soft); background: var(--ws-bg); }
.media-items { overflow: auto; padding: 10px 8px; }
.media-item { display: grid; grid-template-columns: 48px minmax(0, 1fr) 22px 22px; align-items: center; gap: 6px; padding: 5px 6px; border: 1px solid transparent; border-radius: 9px; }
.media-item.on { border-color: var(--accent); background: #fff; }
.dialog button.media-pick { width: 48px; height: 48px; padding: 2px; border: 1px solid var(--line); border-radius: 7px; background: #fff; overflow: hidden; }
.media-badge { display: grid; place-items: center; width: 100%; height: 100%; }
.media-badge img { max-width: 100%; max-height: 100%; }
.media-badge .note { font-size: 18px; line-height: 1; color: #B8468F; }
.media-badge .len { color: var(--muted); font-size: 10.5px; font-weight: 500; }
.media-of { display: flex; align-items: center; gap: 7px; margin-left: 6px; color: var(--muted); }
.media-class { padding: 5px 8px; border: 1px solid var(--line); border-radius: 7px; background: #fff; color: var(--text); font-weight: 650; }
.media-mode { display: flex; align-items: center; justify-content: space-between; gap: 12px; color: var(--muted); font-size: 12px; }
.dialog .media-mode button { padding: 4px 10px; font-weight: 500; }

/* Everything: the whole project's costumes and sounds, and where each is used. */
.media-body.is-all { grid-template-columns: minmax(0, 1fr); }
.media-all { overflow: auto; padding: 14px 20px 20px; }
.all-summary { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 6px; color: var(--muted); }
.all-class { margin-top: 14px; }
.all-class h3 { display: flex; align-items: baseline; gap: 10px; margin: 0 0 4px; font-size: 14px; }
.dialog button.all-title { padding: 0; font-size: 14px; font-weight: 650; }
.all-kind { color: var(--muted); font-size: 12px; font-weight: 400; }
.all-row { display: grid; grid-template-columns: 40px minmax(90px, 200px) 74px minmax(0, 1fr) 30px; align-items: center; gap: 10px; padding: 3px 6px; border-radius: 8px; }
.all-row:hover { background: var(--ws-bg); }
.all-row .media-badge { width: 40px; height: 40px; border: 1px solid var(--line); border-radius: 6px; background: #fff; overflow: hidden; }
.all-name { overflow: hidden; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.all-what { color: var(--muted); font-size: 12px; }
.all-uses { display: flex; flex-wrap: wrap; gap: 2px 12px; min-width: 0; }
.all-uses button.link { padding: 0; text-align: left; white-space: normal; }
.all-none { padding: 1px 8px; border-radius: 9px; background: #FFF1D6; color: #8A5A00; font-size: 12px; font-weight: 600; }
.dialog button.all-trash { width: 28px; height: 28px; padding: 0; border-color: transparent; color: var(--muted);
    background: transparent url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M3 4.5h10M6.5 4.5V3h3v1.5M4.5 4.5l.6 8.5h5.8l.6-8.5M6.8 7v4M9.2 7v4' fill='none' stroke='%235F6B7E' stroke-width='1.4' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / 16px no-repeat; }
.dialog button.all-trash:hover { background-color: var(--danger-soft); }
.all-note { margin: 16px 0 0; color: var(--muted); font-size: 12px; }
.media-name { min-width: 0; padding: 4px 6px; border: 1px solid transparent; border-radius: 6px; background: transparent; font-weight: 600; text-overflow: ellipsis; }
.media-name:hover { border-color: var(--line); }
.media-name:focus { border-color: var(--accent); background: #fff; outline: none; }
.dialog button.media-small { width: 22px; height: 22px; padding: 0; border-color: transparent; background: transparent; color: var(--muted); font-size: 14px; line-height: 1; opacity: 0; }
.media-item:hover .media-small, .media-item.on .media-small, .media-small:focus-visible { opacity: 1; }
.dialog button.media-small:hover { background: var(--line); color: var(--text); }
.media-add { display: flex; flex-wrap: wrap; gap: 6px; padding: 10px; border-top: 1px solid var(--line-soft); }
.dialog button.recording { border-color: var(--danger); background: var(--danger); color: #fff; }
.media-edit { display: flex; flex-direction: column; gap: 10px; min-width: 0; min-height: 0; padding: 12px 16px 14px; overflow: auto; }
.media-empty { max-width: 460px; margin: auto; color: var(--muted); text-align: center; line-height: 1.55; }
.media-use { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.45; }

.paint { display: flex; flex-direction: column; gap: 10px; min-height: 0; }
.paint-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; }
.paint-group { display: flex; align-items: center; gap: 4px; }
.dialog button.paint-tool { display: grid; place-items: center; width: 30px; height: 30px; padding: 0; }
.dialog button.paint-tool.on { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.dialog button.paint-text { padding: 5px 9px; font-weight: 500; }
.dialog button.paint-swatch { width: 20px; height: 20px; padding: 0; border: 1px solid rgba(16, 24, 40, .25); border-radius: 50%; }
.dialog button.paint-swatch.on { box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--accent); }
.paint-custom { width: 28px; height: 24px; padding: 0; border: 1px solid var(--line); border-radius: 6px; background: #fff; }
.paint-size, .paint-check { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12px; }
.paint-size input { width: 90px; }
/* The canvas shows what is see-through as a checkerboard, and where the costume's center is. */
/* (Its width is set by the window, in media.js, to whatever room there is: it must never be
   squeezed, or part of the canvas, and with it the middle, would be out of sight.) */
.paint-frame { position: relative; flex: none; align-self: center; width: min(100%, 640px); border: 1px solid var(--line); border-radius: 6px; overflow: hidden;
    background: repeating-conic-gradient(#EEF0F4 0% 25%, #fff 0% 50%) 0 0 / 20px 20px; }
.paint-frame::before, .paint-frame::after { content: ''; position: absolute; background: rgba(47, 91, 234, .45); pointer-events: none; }
.paint-frame::before { left: calc(50% - 8px); top: 50%; width: 16px; height: 1px; }
.paint-frame::after { top: calc(50% - 8px); left: 50%; width: 1px; height: 16px; }
.paint-canvas { display: block; width: 100%; aspect-ratio: 4 / 3; cursor: crosshair; touch-action: none; }

.soundedit { display: flex; flex-direction: column; gap: 10px; }
.wave { display: block; width: 100%; height: 190px; border: 1px solid var(--line); border-radius: 8px; background: var(--ws-bg); cursor: text; touch-action: none; }
.sound-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.sound-row.effects button { font-weight: 500; }
.wave-info { margin-left: 6px; color: var(--muted); font-size: 12px; }
.sound-hint { margin: 0; color: var(--muted); font-size: 12px; }
.stage-bar #costumes, .stage-bar #sounds { font-weight: 550; }

/* In the plain-language face a block is never broken across lines: a long one makes the
   workspace scroll sideways instead, as in Scratch, so that shapes keep their shape. */
.face-friendly .row, .face-friendly .blk.expr { flex-wrap: nowrap; }
.face-friendly .blk.stmt, .face-friendly .blk.member, .face-friendly .blk.unit.k-class, .face-friendly .blk.unit.k-interface { max-width: none; }
.face-friendly .tok, .face-friendly .edit, .face-friendly .lit { white-space: pre; }

/* ---- finding a class, and laying the stage out ------------------------------------------ */

/* The button before the tabs that lists them all (it is not itself a tab). */
.tab-list { display: flex; flex: none; align-self: flex-end; margin: 0 -8px 2px 0; padding: 7px 8px; border: 1px solid transparent; border-radius: 7px; background: transparent; color: var(--muted); }
.tab-list:hover { background: rgba(255, 255, 255, .7); border-color: var(--line); color: var(--text); }
.menu-find { margin: 2px 2px 5px; padding: 6px 9px; border: 1px solid var(--line); border-radius: 6px; font-size: 13px; }
.menu-find:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
.menu button:focus-visible { background: var(--accent-soft); outline: none; }

/* The strip of sprite classes under the stage: each can be dragged onto the stage. */
.sprites { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 4px; max-height: 142px; overflow: auto; user-select: none; -webkit-user-select: none; }
/* The line between the stage and the strip: how to lay the stage out, or what is selected on it and what can be done with that. */
.under-stage { display: grid; gap: 3px; min-width: 0; }
.stage-line { display: flex; align-items: center; min-height: 24px; min-width: 0; font-size: 11.5px; }
.stage-hint { overflow: hidden; color: var(--muted); white-space: nowrap; text-overflow: ellipsis; }
.stage-sel { display: flex; align-items: center; gap: 6px; min-width: 0; flex: 1; }
.stage-sel[hidden], .stage-hint[hidden] { display: none; }
.stage-sel-text { flex: 1; min-width: 0; overflow: hidden; font-weight: 600; white-space: nowrap; text-overflow: ellipsis; font-variant-numeric: tabular-nums; }
.stage-sel button { flex: none; padding: 2px 9px; border: 1px solid var(--line); border-radius: 6px; background: #fff; font-size: 11.5px; font-weight: 600; }
.stage-sel button:hover { border-color: var(--accent); color: var(--accent); }
.stage-sel button.danger:hover { border-color: var(--danger); color: var(--danger); }
#stage:focus { outline: none; }
#stage:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.sprite-card { display: flex; flex-direction: column; align-items: center; gap: 1px; width: 62px; padding: 3px 2px; border: 1px solid transparent; border-radius: 8px; background: transparent; cursor: grab; touch-action: none; }
.sprite-card:hover { background: var(--bg); }
.sprite-card.on { border-color: var(--accent); background: var(--accent-soft); }
.sprite-thumb { width: 36px; height: 36px; pointer-events: none; }
.sprite-name { max-width: 100%; overflow: hidden; font-size: 10.5px; font-weight: 550; white-space: nowrap; text-overflow: ellipsis; pointer-events: none; }
.sprite-ghost { position: fixed; top: 0; left: 0; z-index: 1000; border-color: var(--accent); background: #fff; box-shadow: 0 8px 18px rgba(16, 24, 40, .25); opacity: .92; pointer-events: none; }
.stage-chip { position: absolute; top: 8px; right: 8px; padding: 4px 10px; border: 1px solid var(--line); border-radius: 999px; background: rgba(255, 255, 255, .95); font-size: 12px; font-weight: 600; box-shadow: 0 2px 6px rgba(16, 24, 40, .16); }
.stage-chip:hover { border-color: var(--accent); color: var(--accent); }

/* ---- the showcase: sending a project in, and reviewing what has been sent in ----------------- */

.account.has-waiting { position: relative; }
.account.has-waiting::after { content: ''; position: absolute; top: -3px; right: -3px; width: 10px; height: 10px; border: 2px solid var(--panel); border-radius: 50%; background: var(--danger); }
.dialog.shown-list { width: min(720px, calc(100vw - 32px)); }
.shown-rows { display: grid; gap: 10px; max-height: min(60vh, 560px); margin: 4px 0 2px; overflow: auto; }
.shown-row { display: grid; grid-template-columns: 132px minmax(0, 1fr); gap: 12px; padding: 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--ws-bg); }
.shown-row img, .shown-row .no-picture { width: 132px; aspect-ratio: 4 / 3; border: 1px solid var(--line-soft); border-radius: 6px; background: #fff; object-fit: cover; }
.shown-title { font-weight: 650; font-size: 14px; }
.shown-meta { color: var(--muted); font-size: 12px; }
.shown-about { margin: 5px 0 8px; line-height: 1.45; }
.shown-note { margin: 0 0 8px; padding: 6px 9px; border-radius: 6px; background: #fff; box-shadow: inset 0 0 0 1px var(--line); font-size: 12.5px; }
.shown-acts { display: flex; flex-wrap: wrap; gap: 6px; }
.shown-acts button, .shown-acts a { padding: 4px 11px; border: 1px solid var(--line); border-radius: 6px; background: #fff; color: var(--text); font-size: 12.5px; font-weight: 600; text-decoration: none; }
.shown-acts button:hover, .shown-acts a:hover { border-color: var(--accent); color: var(--accent); }
.shown-acts button.go { border-color: var(--go); background: var(--go); color: #fff; }
.shown-acts button.danger:hover { border-color: var(--danger); color: var(--danger); }
.shown-status { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 11.5px; font-weight: 650; }
.shown-status.s-pending { background: #FFF3BF; color: #7A5A00; }
.shown-status.s-approved { background: #DDF5E6; color: #17663A; }
.shown-status.s-rejected { background: var(--danger-soft); color: var(--danger); }
.shown-empty { margin: 8px 0; color: var(--muted); }
/* The accounts window, for those who run the site: the same rows, without a picture. */
.shown-row.person { grid-template-columns: minmax(0, 1fr) auto; align-items: center; padding: 8px 10px; }
.shown-row.person .shown-meta { overflow-wrap: anywhere; }
.shown-row.person .shown-acts { justify-content: flex-end; }
.shown-status.s-plain { background: var(--line-soft); color: var(--muted); }
/* (A row of these on every line: they are quiet until pointed at.) */
.people .shown-acts button.danger { border-color: var(--line); background: #fff; color: var(--danger); }
.people .shown-acts button.danger:hover:not(:disabled) { border-color: var(--danger); background: var(--danger-soft); }
.people .shown-rows { max-height: min(40vh, 400px); }
.people-find, .people-add input { box-sizing: border-box; padding: 7px 10px; border: 1px solid var(--line); border-radius: 7px; background: #fff; color: var(--text); font: inherit; }
.people-find { width: 100%; margin-top: 2px; }
.people-find:focus, .people-add input:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
.people-count { margin: -2px 0 0; }
.people-head { margin: 8px 0 -4px; font-size: 13px; font-weight: 650; }
.people-bans { display: grid; gap: 8px; max-height: 22vh; overflow: auto; }
.people-add { flex-wrap: nowrap; }
.people-add input { flex: 1; min-width: 0; }

/* ---- sharing a project with a link ------------------------------------------------------ */

.dialog.share { width: min(520px, calc(100vw - 32px)); }
.share-body { display: flex; flex-direction: column; gap: 12px; }
.share-body .dialog-msg { margin: 0; }
.share-row { display: flex; gap: 8px; }
.share-link { flex: 1; min-width: 0; padding: 7px 9px; border: 1px solid var(--line); border-radius: 7px; background: var(--ws-bg); font: 12.5px var(--mono); }
.share-link:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
.share-see { align-self: flex-start; color: var(--accent); font-weight: 600; }
.dialog button.share-off { color: var(--danger); }
.dialog button.share-off:hover:not(:disabled) { border-color: var(--danger); background: var(--danger-soft); }
