/*
 * NICOCO STUDIO — shared look: Windows 95 outside, terminal inside.
 *
 *   Windows  = everything you click or that holds things: windows, title
 *              bars, menus, toolbars, buttons, fields, status bars.
 *   Terminal = everything you look at or read: canvases, lists, value
 *              readouts, help text. Black ink, mono type, phosphor colour.
 *
 * A tool picks its category on <body data-category="…">, which sets the
 * title-bar colour and the phosphor colour. Nothing else varies per tool.
 *
 * Every class is prefixed s- so tools can adopt it one piece at a time
 * without colliding with their own .panel / .btn / .toolbar rules.
 * Behaviour (dragging windows, menus, taskbar) lives in shared-studio.js.
 */

/* ══════════════════════════════════════
   TOKENS
══════════════════════════════════════ */
:root {
    /* Windows face */
    --s-face:        #c0c0c0;
    --s-face-hover:  #d4d4d4;
    --s-face-down:   #b8b8b8;
    --s-hi:          #ffffff;
    --s-lo:          #808080;
    --s-dark:        #404040;
    --s-text:        #000000;
    --s-text-off:    #808080;
    --s-field:       #ffffff;
    --s-ui-font:     'MS Sans Serif', 'Microsoft Sans Serif', Tahoma, Arial, sans-serif;

    /* Bevels, as border-color lists (top right bottom left) */
    --s-raised:      var(--s-hi) var(--s-dark) var(--s-dark) var(--s-hi);
    --s-raised-soft: var(--s-hi) var(--s-lo) var(--s-lo) var(--s-hi);
    --s-sunken:      var(--s-lo) var(--s-hi) var(--s-hi) var(--s-lo);
    --s-drop:        2px 2px 0 #000;

    /* Terminal */
    --s-ink:         #07070b;
    --s-ink-2:       #11111a;
    --s-ink-line:    #24242e;
    --s-ink-dim:     #6c6c7a;
    --s-ink-text:    #d8d8e4;
    --s-mono:        ui-monospace, 'Cascadia Mono', Menlo, Consolas, 'Courier New', monospace;

    --s-desk:        #07070b;
    --s-taskbar-h:   28px;

    /* Category — overridden below. Default is classic navy. */
    --s-title:       #000080;
    --s-title-2:     #1084d0;
    --s-phosphor:    #9fb4ff;
    --s-on-phosphor: #07070b;
    --s-danger:      #cc0000;
    --s-ok:          #008000;
}

/* One colour pair per category: deep for title bars, bright for ink. */
[data-category="image"]      { --s-title: #5c4a00; --s-title-2: #b39400; --s-phosphor: #ffe66d; }
[data-category="body"]       { --s-title: #7a0f3c; --s-title-2: #d9467f; --s-phosphor: #ff6b9d; }
[data-category="motion"]     { --s-title: #00505e; --s-title-2: #0097b2; --s-phosphor: #00d9ff; }
[data-category="generative"] { --s-title: #00512b; --s-title-2: #00a25a; --s-phosphor: #00ff88; }
[data-category="3d"]         { --s-title: #7a3600; --s-title-2: #d46a12; --s-phosphor: #ff8c42; }
/* The studio itself (homepage): neutral, so colour only ever means a category. */
[data-category="studio"]     { --s-title: #26262e; --s-title-2: #5c5c6a; --s-phosphor: #e9e9f4; }

/* ══════════════════════════════════════
   BASE
══════════════════════════════════════ */
body.s-studio {
    margin: 0;
    background: var(--s-desk);
    font: 11px/1.35 var(--s-ui-font);
    color: var(--s-text);
    user-select: none;
}
.s-studio *, .s-studio *::before, .s-studio *::after { box-sizing: border-box; }
.s-studio button, .s-studio select, .s-studio input { font: inherit; }

.s-desktop { position: fixed; inset: 0 0 var(--s-taskbar-h); overflow: hidden; }

/* ══════════════════════════════════════
   BUTTONS
══════════════════════════════════════ */
.s-btn {
    background: var(--s-face);
    border: 2px solid; border-color: var(--s-raised);
    color: var(--s-text);
    padding: 3px 10px;
    cursor: pointer;
    white-space: nowrap;
}
.s-btn:hover:not(:disabled) { background: var(--s-face-hover); }
.s-btn:active:not(:disabled), .s-btn.on, .s-btn.active {
    border-color: var(--s-sunken);
    background: var(--s-face-down);
    padding: 4px 9px 2px 11px;
}
.s-btn:disabled { color: var(--s-text-off); text-shadow: 1px 1px 0 var(--s-hi); cursor: default; }
.s-btn:focus-visible { outline: 1px dotted var(--s-text); outline-offset: -5px; }

.s-btn-sm { padding: 1px 6px; font-size: 10px; }
.s-btn-sm:active:not(:disabled) { padding: 2px 5px 0 7px; }
.s-btn-block { width: 100%; padding: 5px 0; font-weight: bold; }
.s-btn-block:active:not(:disabled) { padding: 6px 0 4px; }
/* The one main action of a window: a phosphor key on a grey keyboard. */
.s-btn-primary { font-weight: bold; color: var(--s-on-phosphor); background: var(--s-phosphor); }
.s-btn-primary:hover:not(:disabled),
.s-btn-primary:active:not(:disabled) { background: var(--s-phosphor); filter: brightness(1.08); }

/* ══════════════════════════════════════
   WINDOWS
══════════════════════════════════════ */
.s-win {
    position: absolute; min-width: 200px; min-height: 120px;
    display: flex; flex-direction: column;
    background: var(--s-face);
    border: 2px solid; border-color: var(--s-raised);
    box-shadow: var(--s-drop);
    z-index: 100;
}
.s-win.active { z-index: 200; }
.s-win.minimized { display: none !important; }

.s-win-titlebar {
    height: 22px; flex-shrink: 0;
    display: flex; align-items: center; gap: 4px;
    padding: 2px 3px;
    background: linear-gradient(90deg, #808080, #b5b5b5);
    cursor: move;
}
.s-win.active .s-win-titlebar { background: linear-gradient(90deg, var(--s-title), var(--s-title-2)); }

/* Top-left window icon — in the main window it's the way home. */
.s-win-icon {
    width: 16px; height: 16px; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    color: #fff; text-decoration: none; cursor: pointer;
}
.s-win-icon svg { width: 14px; height: 14px; stroke: currentColor; fill: none; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.s-win-icon:hover { background: rgba(255, 255, 255, 0.2); }
.s-win-icon:focus-visible { outline: 1px dotted #fff; }

.s-win-title {
    flex: 1; min-width: 0;
    font-weight: bold; color: #fff; letter-spacing: 0.3px;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.s-win-controls { display: flex; gap: 2px; }
.s-win-btn {
    width: 16px; height: 14px; padding: 0;
    display: flex; align-items: center; justify-content: center;
    font: bold 9px/1 var(--s-ui-font); color: var(--s-text);
    background: var(--s-face);
    border: 1px solid; border-color: var(--s-raised);
    cursor: pointer;
}
.s-win-btn:active { border-color: var(--s-sunken); }
.s-win-close { margin-left: 2px; }

.s-win-body { flex: 1; min-height: 0; overflow: hidden; display: flex; flex-direction: column; }

.s-win-resize {
    position: absolute; right: 0; bottom: 0; width: 12px; height: 12px;
    cursor: se-resize;
    background:
        linear-gradient(135deg, transparent 30%, var(--s-lo) 30%, var(--s-lo) 45%, transparent 45%),
        linear-gradient(135deg, transparent 55%, var(--s-lo) 55%, var(--s-lo) 70%, transparent 70%),
        linear-gradient(135deg, transparent 75%, var(--s-lo) 75%);
}

/* ══════════════════════════════════════
   MENU BAR
══════════════════════════════════════ */
.s-menubar {
    display: flex; padding: 1px 2px; flex-shrink: 0;
    position: relative; z-index: 20;
    background: var(--s-face);
    border-bottom: 1px solid var(--s-lo);
    box-shadow: 0 1px 0 var(--s-hi);
}
.s-menu { position: relative; }
.s-menu-title {
    background: transparent; border: 1px solid transparent;
    color: var(--s-text); padding: 2px 7px; cursor: default;
}
.s-menu-title:hover { border-color: var(--s-raised-soft); }
.s-menu.open .s-menu-title { border-color: var(--s-sunken); }

.s-menu-list {
    display: none; flex-direction: column;
    position: absolute; top: 100%; left: 0; min-width: 190px;
    padding: 2px;
    background: var(--s-face);
    border: 2px solid; border-color: var(--s-raised);
    box-shadow: var(--s-drop);
}
.s-menu.open .s-menu-list { display: flex; }

.s-menu-item {
    position: relative;
    display: flex; justify-content: space-between; align-items: center; gap: 18px;
    background: transparent; border: none; text-align: left;
    color: var(--s-text); padding: 3px 10px 3px 18px;
    cursor: default; white-space: nowrap; text-decoration: none;
}
.s-menu-item:hover:not(:disabled), .s-menu-item:focus-visible {
    background: var(--s-title); color: #fff; outline: none;
}
.s-menu-item:disabled { color: var(--s-text-off); text-shadow: 1px 1px 0 var(--s-hi); }
.s-menu-item.checked::before { content: '✓'; position: absolute; left: 7px; }
.s-menu-key { color: inherit; opacity: 0.75; }
.s-menu-sep { margin: 3px 2px; border-top: 1px solid var(--s-lo); border-bottom: 1px solid var(--s-hi); }
.s-menu-hint { font-size: 10px; color: #606060; padding: 2px 10px 3px 18px; }

/* ══════════════════════════════════════
   TOOLBAR
══════════════════════════════════════ */
.s-toolbar {
    display: flex; align-items: center; gap: 2px; flex-shrink: 0;
    padding: 3px 4px;
    background: var(--s-face);
    border-bottom: 1px solid var(--s-lo);
    box-shadow: 0 1px 0 var(--s-hi);
}
.s-tool-btn {
    height: 22px; padding: 0 7px;
    background: transparent; border: 1px solid transparent;
    color: var(--s-text); cursor: pointer; white-space: nowrap;
}
.s-tool-btn.s-tool-sq { width: 22px; padding: 0; font-size: 13px; }
.s-tool-btn:hover:not(:disabled) { border-color: var(--s-raised-soft); }
.s-tool-btn:active:not(:disabled), .s-tool-btn.on, .s-tool-btn.active { border-color: var(--s-sunken); background: var(--s-face-hover); }
.s-tool-btn.on, .s-tool-btn.active { background-image: repeating-conic-gradient(var(--s-face) 0 25%, var(--s-hi) 0 50%); background-size: 2px 2px; }
.s-tool-btn:disabled { color: var(--s-text-off); text-shadow: 1px 1px 0 var(--s-hi); cursor: default; }
/* The window's main action — export — wears the category phosphor. */
.s-tool-btn.s-tool-primary {
    font-weight: bold; color: var(--s-on-phosphor);
    background: var(--s-phosphor);
    border: 2px solid; border-color: var(--s-raised);
}
.s-tool-btn.s-tool-primary:hover:not(:disabled) { border-color: var(--s-raised); filter: brightness(1.08); }
.s-tool-btn.s-tool-primary:active:not(:disabled) { border-color: var(--s-sunken); background: var(--s-phosphor); }
.s-tool-sep { width: 2px; height: 18px; margin: 0 3px; border-left: 1px solid var(--s-lo); border-right: 1px solid var(--s-hi); }
.s-tool-spacer { flex: 1; }

/* ══════════════════════════════════════
   PANELS
══════════════════════════════════════ */
.s-panel {
    display: flex; flex-direction: column; min-height: 0;
    background: var(--s-face);
    border: 1px solid; border-color: var(--s-sunken);
}
.s-panel-head {
    flex-shrink: 0;
    padding: 3px 8px;
    font-size: 10px; font-weight: bold; letter-spacing: 0.5px; color: #fff;
    background: var(--s-lo);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.s-panel-head.s-panel-head-active { background: var(--s-title); }

/* Grey sub-header inside a panel: "LAYERS  [Clear]" */
.s-section {
    display: flex; align-items: center; justify-content: space-between; flex-shrink: 0;
    padding: 3px 8px;
    font-size: 9px; font-weight: bold; letter-spacing: 0.6px; color: var(--s-dark);
    background: var(--s-face-down);
    border-top: 1px solid var(--s-hi); border-bottom: 1px solid var(--s-lo);
}

/* Windows tab strip: <div class="s-tabstrip"><button class="active">… */
.s-tabstrip { display: flex; flex-shrink: 0; padding: 4px 4px 0; border-bottom: 2px solid var(--s-hi); }
.s-tabstrip > button {
    position: relative; top: 2px;
    padding: 3px 12px; margin-right: -1px; cursor: pointer;
    color: var(--s-text); background: var(--s-face);
    border: 2px solid; border-color: var(--s-hi) var(--s-dark) transparent var(--s-hi);
}
.s-tabstrip > button.active { z-index: 1; margin-top: -2px; padding-bottom: 5px; font-weight: bold; }
.s-tabstrip > button:focus-visible { outline: 1px dotted var(--s-text); outline-offset: -4px; }

/* ══════════════════════════════════════
   TERMINAL SURFACES
══════════════════════════════════════ */
/* A sunken black well — canvases, lists, logs. */
.s-well {
    background: var(--s-ink);
    color: var(--s-ink-text);
    font-family: var(--s-mono);
    border: 2px solid; border-color: var(--s-sunken);
}
.s-well-empty {
    padding: 16px 12px; text-align: center; line-height: 1.8;
    font-family: var(--s-mono); font-size: 11px; color: var(--s-ink-dim);
}
.s-well-empty::before { content: '> '; color: var(--s-phosphor); }

/* A list row inside a well. Selected = phosphor bar. */
.s-row {
    display: flex; align-items: center; height: 22px; padding: 0 4px;
    border-bottom: 1px solid var(--s-ink-line);
    color: var(--s-ink-text); cursor: pointer;
}
.s-row:hover { background: var(--s-ink-2); }
.s-row.selected { background: var(--s-phosphor); color: var(--s-on-phosphor); }

/* Small value readout: "0.60" in a black inset. */
.s-readout {
    min-width: 36px; padding: 0 4px; text-align: right;
    font: 10px/14px var(--s-mono);
    color: var(--s-phosphor);
    background: var(--s-ink);
    border: 1px solid; border-color: var(--s-sunken);
}

/* Reading text, terminal style — help windows, logs. */
.s-term {
    padding: 10px 12px; overflow-y: auto; user-select: text;
    font: 11px/1.75 var(--s-mono);
    color: var(--s-ink-text);
    background: var(--s-ink);
}
.s-term h3 {
    margin: 10px 0 4px; font-size: 11px; font-weight: bold;
    color: var(--s-phosphor); letter-spacing: 0.5px;
}
.s-term h3::before { content: '## '; color: var(--s-ink-dim); }
.s-term h3:first-child { margin-top: 0; }
.s-term b { color: #fff; }

.s-kbd {
    padding: 0 4px;
    font: 10px var(--s-mono); color: var(--s-text);
    background: var(--s-face);
    border: 1px solid; border-color: var(--s-raised);
}

/* ══════════════════════════════════════
   FORM CONTROLS
══════════════════════════════════════ */
.s-input, .s-select {
    min-width: 0;
    padding: 2px 4px;
    color: var(--s-text); background: var(--s-field);
    border: 2px solid; border-color: var(--s-sunken);
    outline: none;
}
.s-input { user-select: text; }
.s-select { cursor: pointer; }
.s-select option { background: var(--s-field); }

.s-slider {
    -webkit-appearance: none; appearance: none;
    width: 100%; height: 16px; margin: 0;
    background: transparent; outline: none; cursor: pointer;
}
.s-slider::-webkit-slider-runnable-track {
    height: 4px; background: var(--s-ink);
    border: 1px solid; border-color: var(--s-sunken);
}
.s-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 11px; height: 20px; margin-top: -9px;
    background: var(--s-face);
    border: 2px solid; border-color: var(--s-raised);
}
.s-slider::-moz-range-track { height: 4px; background: var(--s-ink); border: 1px solid; border-color: var(--s-sunken); }
.s-slider::-moz-range-thumb { width: 7px; height: 16px; border-radius: 0; background: var(--s-face); border: 2px solid; border-color: var(--s-raised); }
.s-slider:focus-visible::-webkit-slider-thumb { outline: 1px dotted var(--s-text); }

.s-check { display: flex; align-items: center; gap: 6px; cursor: pointer; }
.s-check input[type="checkbox"] {
    appearance: none; -webkit-appearance: none;
    width: 13px; height: 13px; margin: 0; flex-shrink: 0;
    display: grid; place-content: center; cursor: pointer;
    background: var(--s-field);
    border: 1px solid; border-color: var(--s-sunken);
    box-shadow: inset 1px 1px 0 var(--s-dark), inset -1px -1px 0 #dfdfdf;
}
.s-check input[type="checkbox"]:checked::after {
    content: ''; width: 7px; height: 7px; background: var(--s-text);
    clip-path: polygon(14% 44%, 0 59%, 40% 100%, 100% 21%, 86% 7%, 40% 72%);
}
.s-check input[type="checkbox"]:focus-visible { outline: 1px dotted var(--s-text); outline-offset: 2px; }

/* Progress bar: phosphor blocks marching through a black well. */
.s-progress {
    width: 200px; height: 18px; padding: 2px; overflow: hidden;
    background: var(--s-ink);
    border: 2px solid; border-color: var(--s-sunken);
}
.s-progress > span {
    display: block; height: 100%;
    background: repeating-linear-gradient(90deg, var(--s-phosphor) 0 10px, transparent 10px 13px);
    background-size: 300% 100%;
    animation: s-progress 1s steps(8) infinite;
}
@keyframes s-progress { to { background-position: -100% 0; } }

/* ══════════════════════════════════════
   STATUS BAR
══════════════════════════════════════ */
.s-statusbar { display: flex; gap: 2px; padding: 2px; flex-shrink: 0; background: var(--s-face); }
.s-status-field {
    min-width: 70px; padding: 1px 6px;
    font-size: 10px; color: var(--s-text);
    border: 1px solid; border-color: var(--s-sunken);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.s-status-grow { flex: 1; min-width: 0; }
/* Live numbers in the status bar read like the terminal. */
.s-status-mono { font-family: var(--s-mono); color: var(--s-phosphor); background: var(--s-ink); }

/* ══════════════════════════════════════
   TASKBAR + STUDIO MENU   (built by shared-studio.js)
══════════════════════════════════════ */
.s-taskbar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 5000;
    height: var(--s-taskbar-h);
    display: flex; align-items: center; gap: 2px; padding: 2px 4px;
    background: var(--s-face);
    border-top: 2px solid var(--s-hi);
    box-shadow: inset 0 1px 0 #dfdfdf;
}
.s-start-btn {
    height: 22px; display: flex; align-items: center; gap: 5px;
    padding: 2px 8px; font-weight: bold; letter-spacing: 0.5px;
}
.s-start-btn:active:not(:disabled), .s-start-btn.on { padding: 3px 7px 1px 9px; }
/* Studio logo: one bar per tool category, in its colour. */
.s-start-logo { height: 13px; display: flex; align-items: flex-end; gap: 1px; }
.s-start-logo span { width: 3px; height: 100%; border: 1px solid rgba(0, 0, 0, 0.55); }
.s-start-logo span:nth-child(2n) { height: 70%; }

.s-taskbar-sep { width: 2px; height: 20px; margin: 0 2px; border-left: 1px solid var(--s-lo); border-right: 1px solid var(--s-hi); }
.s-taskbar-windows { flex: 1; min-width: 0; display: flex; gap: 3px; align-items: center; }
.s-taskbar-btn {
    height: 22px; max-width: 160px; padding: 0 8px;
    overflow: hidden; text-overflow: ellipsis; text-align: left;
}
.s-taskbar-btn.active { font-weight: bold; }
.s-clock {
    height: 22px; display: flex; align-items: center; padding: 0 10px;
    font-family: var(--s-mono); font-size: 11px; color: var(--s-phosphor);
    background: var(--s-ink);
    border: 1px solid; border-color: var(--s-sunken);
}

.s-start-menu {
    display: none; position: fixed; left: 2px; bottom: var(--s-taskbar-h); z-index: 6000;
    min-width: 210px; padding-left: 24px;
    background: var(--s-face);
    border: 2px solid; border-color: var(--s-raised);
    box-shadow: var(--s-drop);
}
.s-start-menu.open { display: block; }
.s-start-band {
    position: absolute; left: 0; top: 0; bottom: 0; width: 22px;
    display: flex; align-items: flex-end; justify-content: center; padding-bottom: 8px;
    background: linear-gradient(0deg, var(--s-title), #000);
    color: #fff; font-weight: bold; font-size: 13px; letter-spacing: 2px;
    writing-mode: vertical-rl; transform: rotate(180deg);
}
.s-start-band b { color: var(--s-phosphor); }
.s-start-items { display: flex; flex-direction: column; padding: 2px 0; }
.s-start-menu .s-menu-item { padding: 5px 12px 5px 10px; justify-content: flex-start; gap: 8px; cursor: pointer; }
.s-start-menu .s-menu-item.current { font-weight: bold; }
.s-start-menu .s-menu-sep { margin: 3px 0; }
.s-start-dot { width: 9px; height: 9px; flex-shrink: 0; border: 1px solid #000; }

/* ══════════════════════════════════════
   CAMERA STAGE — hand-tracked tools
   The camera fills the screen; the UI floats over it. Buttons get a
   .hover class from the app while a fingertip rests on them.
══════════════════════════════════════ */
/* Floating tool palette: a small Windows window (MS Paint style).
   Use with .s-win.active for the title bar colour. */
.s-palette { position: absolute; min-width: 0; min-height: 0; padding: 0 0 3px; }
.s-palette-row { display: flex; align-items: center; gap: 3px; padding: 3px 3px 0; }
.s-palette-sep { width: 2px; align-self: stretch; margin: 2px 2px; border-left: 1px solid var(--s-lo); border-right: 1px solid var(--s-hi); }

.s-palette-btn {
    flex-shrink: 0; min-width: 44px; height: 44px; padding: 2px 3px;
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
    font-size: 9px; letter-spacing: 0.3px; color: var(--s-text);
    background: var(--s-face);
    border: 2px solid; border-color: var(--s-raised);
    cursor: pointer;
}
.s-palette-btn svg { width: 20px; height: 20px; stroke: currentColor; flex-shrink: 0; }
.s-palette-btn:hover { background: var(--s-face-hover); }
.s-palette-btn.active, .s-palette-btn.on {
    border-color: var(--s-sunken);
    background-image: repeating-conic-gradient(var(--s-face) 0 25%, var(--s-hi) 0 50%);
    background-size: 2px 2px;
}
/* Fingertip resting on a control: phosphor focus ring. */
.s-palette-btn.hover, .s-btn.hover, .s-hover-ring.hover,
.s-studio .dwell-hover {
    outline: 2px solid var(--s-phosphor); outline-offset: 1px;
    box-shadow: 0 0 0 4px rgba(0, 0, 0, 0.6);
}

/* Terminal chip floating over the camera: status, hints, toasts. */
.s-hud {
    padding: 4px 9px;
    font: 11px/1.6 var(--s-mono); color: var(--s-ink-text);
    background: rgba(7, 7, 11, 0.88);
    border: 1px solid var(--s-ink-line);
}
.s-hud b { color: var(--s-phosphor); font-weight: normal; }

/* Full-screen dim layer that centres a dialog. */
.s-overlay {
    position: fixed; inset: 0; z-index: 4000; padding: 16px;
    display: flex; align-items: center; justify-content: center;
    background: rgba(0, 0, 0, 0.6);
}
.s-overlay.hidden { display: none; }
/* A Windows dialog that isn't dragged: use with .s-win.active. */
.s-dialog { position: relative; min-width: 260px; min-height: 0; max-width: min(460px, 100%); }
.s-dialog-body { display: flex; flex-direction: column; gap: 6px; padding: 10px; }
.s-dialog-body .s-term { margin: 0 0 4px; border: 2px solid; border-color: var(--s-sunken); }

/* ══════════════════════════════════════
   MOBILE: TAB BAR + SHEET
   Phones get one layout: title bar, canvas, a sheet that shows one
   panel at a time, and a tab bar that picks the panel.
   StudioUI.mountMobileTabs() builds the tab bar and tags the sections.
══════════════════════════════════════ */
:root { --s-tabbar-h: 52px; }
.s-tabbar, .s-mobile-only { display: none; }
@media (max-width: 768px) {
    .s-taskbar, .s-start-menu { display: none !important; }
    .s-desktop { bottom: 0; }
    .s-studio:has(.s-tabbar) .s-desktop { bottom: calc(var(--s-tabbar-h) + env(safe-area-inset-bottom)); }
    .s-mobile-only { display: revert; }
    .s-desktop-only { display: none !important; }

    /* Every window button (close, minimise) is finger-sized on phones,
       including tools' own pop-ups. */
    .s-win-btn { width: 36px; height: 30px; font-size: 14px; }
    .s-win-btn svg { width: 14px; height: 14px; }
    .s-win-titlebar:has(.s-win-btn) { min-height: 36px; }

    /* Dialogs (StudioUI.openDialog) fit the phone screen and stay put
       when the page scrolls, so their close button is always reachable. */
    .s-win[data-placed]:not(.s-win-phone):not(.s-phone-panel) {
        position: fixed !important;
        max-width: calc(100vw - 16px); max-height: calc(100vh - 16px); max-height: calc(100dvh - 16px);
        min-width: 0;
        z-index: 6000;
    }
    .s-win[data-placed]:not(.s-win-phone):not(.s-phone-panel) .s-win-titlebar { min-height: 36px; font-size: 13px; }
    .s-win[data-placed]:not(.s-win-phone):not(.s-phone-panel) .s-win-btn { width: 36px; height: 30px; font-size: 14px; }
    .s-win[data-placed]:not(.s-win-phone):not(.s-phone-panel) .s-win-body { overflow-y: auto; }
    .s-win[data-placed]:not(.s-win-phone):not(.s-phone-panel) .s-win-controls { display: flex !important; }

    /* A tool's main window takes the whole phone screen. */
    .s-win.s-win-phone {
        position: fixed !important;
        inset: 0 0 calc(var(--s-tabbar-h) + env(safe-area-inset-bottom)) 0 !important;
        width: auto !important; height: auto !important;
        min-width: 0; min-height: 0;
        border: none; box-shadow: none;
    }
    .s-win-phone .s-win-titlebar { min-height: 36px; padding: 3px 4px 3px 6px; font-size: 13px; }
    .s-win-phone .s-win-btn { width: 36px; height: 32px; font-size: 14px; }
    /* Home link in phone title bars and phone panels: a finger-sized target. */
    :is(.s-win-phone, .s-phone-panel, .s-palette) .s-win-icon { width: 32px; height: 32px; margin: -4px 0 -4px -4px; }
    :is(.s-win-phone, .s-phone-panel, .s-palette) .s-win-icon svg { width: 16px; height: 16px; }
    .s-win-phone .s-statusbar { font-size: 11px; }

    .s-tabbar {
        display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 5000;
        height: calc(var(--s-tabbar-h) + env(safe-area-inset-bottom));
        padding-bottom: env(safe-area-inset-bottom);
        background: var(--s-face);
        border-top: 2px solid var(--s-hi);
        box-shadow: 0 -1px 0 var(--s-lo);
    }
    .s-tab {
        flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
        padding: 4px 0; line-height: 1;
        font: 11px var(--s-ui-font); color: var(--s-text);
        background: var(--s-face); border: none; border-right: 1px solid #b0b0b0;
        cursor: pointer;
    }
    .s-tab:last-child { border-right: none; }
    .s-tab-icon { font-size: 17px; line-height: 1; }
    .s-tab.active { background: var(--s-title); color: #fff; }
    .s-tab:not(.active):active { background: #b0b0b0; }
    .s-tab-primary:not(.active) .s-tab-icon { color: var(--s-on-phosphor); background: var(--s-phosphor); padding: 2px 6px; }

    /* The sheet: sits under the canvas in the window's flow, so the
       canvas shrinks instead of being covered. Closed = gone. */
    .s-sheet {
        display: none !important;
        flex: none; position: relative;
        max-height: 46vh; max-height: 46dvh;
        overflow-x: hidden !important; overflow-y: auto !important;
        overscroll-behavior: contain; -webkit-overflow-scrolling: touch; touch-action: pan-y;
        width: auto !important; transform: none !important;
        border: none; border-top: 2px solid var(--s-hi);
        box-shadow: 0 -1px 0 var(--s-lo);
        background: var(--s-face);
    }
    .s-sheet.open { display: block !important; }
    .s-sheet.tall { max-height: 78vh; max-height: 78dvh; }
    .s-sheet-handle {
        position: sticky; top: 0; z-index: 1;
        display: flex; align-items: center; gap: 8px;
        width: 100%; height: 34px; padding: 0 10px;
        font: bold 12px var(--s-ui-font); color: var(--s-text); text-align: left;
        background: var(--s-face); border: none; border-bottom: 1px solid #b0b0b0;
        cursor: pointer;
    }
    .s-sheet-handle::after {
        content: ''; order: -1; width: 28px; height: 4px; flex: none;
        background: var(--s-lo); box-shadow: 0 1px 0 var(--s-hi);
    }
    .s-sheet-handle span { flex: 1; }
    .s-sheet-handle small { font-weight: normal; color: var(--s-text-off); }
    .s-sheet [data-mtab].s-mtab-off { display: none !important; }

    /* Finger-sized controls inside sheets and phone panels: same look, chunkier. */
    :is(.s-sheet, .s-phone-panel) { font-size: 13px; }
    :is(.s-sheet, .s-phone-panel) .s-section { font-size: 11px; padding-top: 4px; padding-bottom: 4px; }
    :is(.s-sheet, .s-phone-panel) .s-btn, :is(.s-sheet, .s-phone-panel) .s-btn-sm { min-height: 40px; padding: 4px 10px; font-size: 13px; }
    :is(.s-sheet, .s-phone-panel) .s-btn-sm:active:not(:disabled), :is(.s-sheet, .s-phone-panel) .s-btn.active { padding: 5px 9px 3px 11px; }
    :is(.s-sheet, .s-phone-panel) .s-input, :is(.s-sheet, .s-phone-panel) .s-select { min-height: 40px; font-size: 16px; }
    :is(.s-sheet, .s-phone-panel) .s-readout { font-size: 12px; }
    :is(.s-sheet, .s-phone-panel) .s-slider { height: 36px; touch-action: pan-y; }
    :is(.s-sheet, .s-phone-panel) .s-slider::-webkit-slider-runnable-track { height: 6px; }
    :is(.s-sheet, .s-phone-panel) .s-slider::-webkit-slider-thumb { width: 22px; height: 30px; margin-top: -13px; }
    :is(.s-sheet, .s-phone-panel) .s-slider::-moz-range-thumb { width: 18px; height: 26px; }
    :is(.s-sheet, .s-phone-panel) .s-check { min-height: 40px; font-size: 13px; }
    :is(.s-sheet, .s-phone-panel) .s-check input[type="checkbox"] { width: 20px; height: 20px; }
    :is(.s-sheet, .s-phone-panel) .s-check input[type="checkbox"]:checked::after { width: 12px; height: 12px; }

    /* Floating tool panels (the synths) become bottom sheets on phones:
       StudioUI.mountPhonePanels() shows one at a time from the tab bar. */
    .s-win.s-phone-panel { display: none !important; }
    .s-win.s-phone-panel.phone-open {
        display: flex !important;
        position: fixed !important;
        left: 0 !important; right: 0 !important; top: auto !important;
        bottom: calc(var(--s-tabbar-h) + env(safe-area-inset-bottom)) !important;
        width: auto !important; height: auto !important; min-width: 0;
        max-height: 50vh; max-height: 50dvh;
        z-index: 4500 !important;
        border-left: none; border-right: none;
    }
    .s-phone-panel .s-win-controls, .s-phone-panel .s-win-resize { display: none; }
    .s-phone-panel .s-win-titlebar { min-height: 32px; font-size: 13px; }
    .s-phone-panel.phone-open .s-win-body { overflow-y: auto; overscroll-behavior: contain; }
    a.s-tab { text-decoration: none; }

}

/* ══════════════════════════════════════
   SCROLLBARS
══════════════════════════════════════ */
.s-studio ::-webkit-scrollbar { width: 16px; height: 16px; }
.s-studio ::-webkit-scrollbar-track { background: var(--s-face); background-image: repeating-conic-gradient(var(--s-face) 0 25%, var(--s-hi) 0 50%); background-size: 2px 2px; }
.s-studio ::-webkit-scrollbar-thumb,
.s-studio ::-webkit-scrollbar-button {
    background: var(--s-face);
    border: 2px solid; border-color: var(--s-raised);
}
.s-studio ::-webkit-scrollbar-button { display: block; height: 16px; width: 16px; }
.s-studio ::-webkit-scrollbar-corner { background: var(--s-face); }
/* Inside terminal wells the scrollbar goes dark too. */
.s-studio .s-well::-webkit-scrollbar-track,
.s-studio .s-term::-webkit-scrollbar-track { background: var(--s-ink); }
.s-studio .s-well::-webkit-scrollbar-thumb,
.s-studio .s-term::-webkit-scrollbar-thumb { background: var(--s-ink-2); border-color: var(--s-ink-line) #000 #000 var(--s-ink-line); }
.s-studio .s-well::-webkit-scrollbar-button,
.s-studio .s-term::-webkit-scrollbar-button { display: none; }

/* ══════════════════════════════════════
   STUDIO CLIPBOARD (send menu + toast from shared-clipboard-ui.js)
   — restyled here so tools on the shared look get it for free.
══════════════════════════════════════ */
.s-studio .studio-send-menu {
    padding: 2px; border-radius: 0;
    background: var(--s-face);
    border: 2px solid; border-color: var(--s-raised);
    box-shadow: var(--s-drop);
}
.s-studio .studio-send-menu button {
    border-radius: 0; padding: 4px 10px 4px 18px;
    color: var(--s-text); font: 11px var(--s-ui-font);
}
.s-studio .studio-send-menu button:hover { background: var(--s-title); color: #fff; }
.s-studio .studio-send-menu button small { color: inherit; opacity: 0.7; font-size: 10px; }
.s-studio .studio-toast {
    border-radius: 0; padding: 8px 10px;
    font: 11px var(--s-mono); color: var(--s-ink-text);
    background: var(--s-ink);
    border: 2px solid; border-color: var(--s-raised);
    box-shadow: var(--s-drop);
    bottom: calc(var(--s-taskbar-h) + 12px);
}
.s-studio .studio-toast::before { content: '>'; color: var(--s-phosphor); }
.s-studio .studio-toast img { border-radius: 0; }
.s-studio .studio-toast button {
    border-radius: 0; color: var(--s-text); font: 11px var(--s-ui-font);
    background: var(--s-face);
    border: 2px solid; border-color: var(--s-raised);
}
.s-studio .studio-toast button:hover { background: var(--s-face-hover); }
