:root {
  --bg: #f6f6f4;
  --fg: #1d1d1b;
  --muted: #6b6b66;
  --panel: #ffffff;
  --line: #d9d9d4;
  --accent: #2f6fd6;
  --error: #c0392b;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1b1b1a;
    --fg: #ececea;
    --muted: #9a9a94;
    --panel: #252524;
    --line: #3a3a38;
    --accent: #6ea2ff;
    --error: #ff7a6b;
  }
}
* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  font: 14px/1.4 system-ui, sans-serif;
  background: var(--bg);
  color: var(--fg);
}
[hidden] { display: none !important; }
/* The project's screen: its windows on a desk filling the page, its
   title floating over the corner, its configuration a drawer on the right */
#project-screen, #project, .workspace { position: fixed; inset: 0; overflow: hidden; }
/* Notices (main.ts's `notice`): errors, and things to know or decide,
   until they're dismissed; over either screen, at the top. */
#notices {
  position: fixed; top: 12px; left: 50%; transform: translateX(-50%); z-index: 150000;
  width: min(640px, calc(100% - 32px)); display: flex; flex-direction: column; gap: 6px;
}
.notice {
  display: flex; align-items: flex-start; gap: 10px; padding: 8px 8px 8px 12px;
  border: 1px solid var(--line); border-left-width: 4px; border-radius: 6px;
  background: var(--panel); color: var(--fg); box-shadow: 0 4px 16px rgba(0, 0, 0, .18);
}
.notice.error { border-left-color: var(--error); }
.notice.info { border-left-color: var(--accent, var(--muted)); }
.notice-text { flex: 1; min-width: 0; white-space: pre-wrap; overflow-wrap: anywhere; max-height: 12em; overflow: auto; }
.notice-actions { display: flex; gap: 6px; flex: none; }
.notice-actions button {
  font: inherit; padding: 2px 10px; border-radius: 6px; cursor: pointer;
  border: 1px solid var(--line); background: var(--bg); color: var(--fg);
}
.notice-dismiss {
  flex: none; width: 22px; height: 22px; padding: 0; font-size: 16px; line-height: 20px;
  border: 1px solid transparent; border-radius: 4px; background: none; color: var(--muted); cursor: pointer;
}
.notice-dismiss:hover { border-color: var(--line); color: var(--fg); }
/* (something that's happened: it goes by itself) */
.notice.passing { animation: notice-passing 4s ease-in forwards; }
@keyframes notice-passing { 0%, 80% { opacity: 1; } 100% { opacity: 0; } }
/* (the windows stack among themselves, under the title and the drawer) */
.desk { position: absolute; inset: 0; overflow: auto; z-index: 0; }

/* The project's title (main.ts): a menu, floating in the corner */
.project-title { position: absolute; top: 12px; left: 12px; z-index: 2; max-width: calc(100% - 80px); }
.project-title .window-menu-wrap { max-width: 100%; }
/* (its menu, while it's open, over everything: the editors, the drawer) */
.project-title:has([aria-expanded=true]) { z-index: 6; }
.project-title-button {
  display: flex; align-items: center; gap: 8px; max-width: 100%;
  font: 600 15px/1.3 system-ui, sans-serif; padding: 6px 12px; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--line); background: var(--panel); color: var(--fg); box-shadow: 0 2px 10px rgba(0, 0, 0, .12);
}
.project-title-button:hover, .project-title-button[aria-expanded=true] { border-color: var(--accent); }
.project-title-text { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.project-title-dot { flex: none; width: 8px; height: 8px; border-radius: 4px; background: var(--accent); }
.project-title-arrow { flex: none; font-size: 11px; color: var(--muted); }
.menu-left .window-menu { left: 0; right: auto; }
.window {
  position: absolute; display: flex; flex-direction: column;
  background: var(--panel); border: 1px solid var(--line); border-radius: 6px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, .15); overflow: hidden;
}
/* (its title bar doesn't make it wider than its body: what doesn't fit
   is cut short) */
.window-title {
  contain: inline-size;
  display: flex; align-items: center; gap: 8px;
  padding: 4px 4px 4px 10px; font-size: 12px; color: var(--muted); cursor: move;
  user-select: none; border-bottom: 1px solid var(--line); touch-action: none;
}
.window-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.window-minimize {
  flex: none; width: 20px; height: 18px; padding: 0; line-height: 16px; font-size: 12px;
  border: 1px solid transparent; border-radius: 4px; background: none; color: var(--muted); cursor: pointer;
}
.window-minimize:hover { border-color: var(--line); color: var(--fg); }
/* A viewer's tool chooser, in its title bar (main.ts): its tool's name
   gets cut short only once the window's title has been */
.window-menu-wrap.tool-chooser-wrap { flex: 0 1 auto; min-width: 0; max-width: 55%; }
.tool-chooser {
  display: flex; align-items: center; gap: 4px; min-width: 0; max-width: 100%; height: 18px; padding: 0 6px;
  font: inherit; font-size: 12px; border: 1px solid var(--line); border-radius: 4px;
  background: var(--bg); color: var(--fg); cursor: pointer;
}
.tool-chooser:hover, .tool-chooser[aria-expanded=true] { border-color: var(--accent); }
.tool-chooser-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tool-chooser-arrow { flex: none; font-size: 9px; color: var(--muted); }
/* A window's menu of options (windows.ts) */
.window-menu-wrap { position: relative; flex: none; display: flex; }
.window-menu-button {
  width: 20px; height: 18px; padding: 0; line-height: 16px; font-size: 12px;
  border: 1px solid transparent; border-radius: 4px; background: none; color: var(--muted); cursor: pointer;
}
.window-menu-button:hover, .window-menu-button[aria-expanded=true] { border-color: var(--line); color: var(--fg); }
.window-menu {
  position: absolute; right: 0; top: calc(100% + 4px); z-index: 10; min-width: 200px;
  display: flex; flex-direction: column; padding: 4px; cursor: default;
  background: var(--panel); border: 1px solid var(--line); border-radius: 6px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, .18);
}
.window-menu button {
  font: inherit; font-size: 13px; text-align: left; padding: 4px 8px 4px 26px; position: relative;
  border: none; border-radius: 4px; background: none; color: var(--fg); cursor: pointer;
}
.window-menu button:hover { background: color-mix(in srgb, var(--fg) 10%, transparent); }
.window-menu button[aria-checked=true]::before { content: "✓"; position: absolute; left: 9px; }
.window-menu button { display: flex; align-items: baseline; gap: 16px; }
.window-menu button:disabled { color: var(--muted); cursor: default; background: none; }
.window-menu .menu-label { flex: 1; }
.window-menu kbd { font: inherit; font-size: 12px; color: var(--muted); }
.window-menu .menu-back { color: var(--muted); }
.window-menu .menu-separator { border: none; border-top: 1px solid var(--line); margin: 4px 6px; }
.window-menu { max-height: 70vh; overflow-y: auto; min-width: 230px; }
/* (minimized: just the title bar) */
.window.minimized .window-body, .window.minimized .window-grip { display: none; }
.window.minimized .window-title { border-bottom: none; }
.window-body { position: relative; background: #808080; }
.window-grip {
  position: absolute; right: 0; bottom: 0; width: 14px; height: 14px; cursor: nwse-resize;
  touch-action: none;
  background: linear-gradient(135deg, transparent 50%, var(--muted) 50%, var(--muted) 60%,
                              transparent 60%, transparent 75%, var(--muted) 75%, var(--muted) 85%, transparent 85%);
}
.viewer canvas { display: block; cursor: grab; touch-action: none; outline: none; }
.viewer canvas:active { cursor: grabbing; }
/* The configuration: a drawer over the right of the workspace, pulled out
   by its tab (main.ts) */
.panel {
  position: absolute; top: 0; right: 0; bottom: 0; z-index: 3;
  width: min(var(--panel-width, 320px), calc(100vw - 40px));
  background: var(--panel); border-left: 1px solid var(--line);
  transform: translateX(100%); transition: transform .2s ease-out;
}
.panel.open { transform: none; box-shadow: -6px 0 24px rgba(0, 0, 0, .15); }
/* (on a phone, it'd cover the title: it's below it) */
@media (max-width: 720px), (max-height: 480px) {
  .panel { top: 58px; border-top: 1px solid var(--line); border-top-left-radius: 8px; }
}
.panel.dragging { transition: none; }
.panel-body { height: 100%; overflow-y: auto; padding: 12px; }
.drawer-tab {
  position: absolute; right: 100%; top: 72px; z-index: 1; padding: 12px 6px;
  writing-mode: vertical-rl; transform: rotate(180deg); touch-action: none;
  font: 600 12px system-ui, sans-serif; letter-spacing: .03em; cursor: pointer;
  background: var(--panel); color: var(--fg); border: 1px solid var(--line); border-left: none;
  border-radius: 0 8px 8px 0; box-shadow: 4px 0 10px rgba(0, 0, 0, .1);
}
.drawer-tab:hover { color: var(--accent); }
.drawer-tab:focus-visible { outline: 2px solid var(--accent); }
/* (its left edge, to drag it wider or narrower, while it's out) */
.panel-grip {
  position: absolute; left: -5px; top: 0; bottom: 0; width: 10px; cursor: ew-resize; touch-action: none;
}
.panel:not(.open) .panel-grip { display: none; }
.panel-grip:hover, .panel-grip.dragging { border-left: 2px solid var(--accent); }
.panel fieldset { border: none; margin: 0; padding: 0; }
.panel legend { font-weight: 600; margin-bottom: 6px; }
.vertical { display: flex; flex-direction: column; gap: 6px; }
.horizontal { display: flex; flex-wrap: wrap; gap: 8px; }
.field { display: flex; align-items: center; gap: 8px; }
.field > span:first-child { flex: none; min-width: 7em; color: var(--muted); }
.field input[type=text], .field select {
  flex: 1; min-width: 0; font: 13px ui-monospace, monospace;
  padding: 3px 6px; border: 1px solid var(--line); border-radius: 4px; background: var(--bg); color: var(--fg);
}
.field input.invalid { border-color: var(--error); }
.field-error { color: var(--error); cursor: help; }
/* (a table: its name, what it is and its size, Export and Import) */
.table-field { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; }
.table-name { flex: none; min-width: 7em; color: var(--muted); }
.table-summary { flex: 1 1 10em; min-width: 0; font: 13px ui-monospace, monospace; }
.table-field button {
  font: inherit; padding: 2px 10px; border-radius: 6px;
  border: 1px solid var(--line); background: transparent; color: var(--fg); cursor: pointer;
}
.tab-chooser {
  width: 100%; margin-bottom: 8px; font: inherit; padding: 4px 6px;
  border: 1px solid var(--line); border-radius: 6px; background: var(--bg); color: var(--fg);
}
.viewer { position: relative; }
.viewer-error {
  position: absolute; left: 8px; right: 8px; bottom: 8px; padding: 6px 8px; border-radius: 6px;
  background: rgba(0, 0, 0, .7); color: #ffb3a8; font: 12px/1.35 ui-monospace, monospace; white-space: pre-wrap;
}
.viewer-error.warning { color: #ffd479; }
.field input[type=color] { width: 32px; height: 26px; padding: 0 2px; border: 1px solid var(--line); border-radius: 4px; background: var(--bg); }

@font-face { font-family: "DejaVu Sans"; src: url("DejaVuSans.ttf") format("truetype"); }
/* (with several viewers, the one the tool shortcuts are for) */
.window.active { border-color: var(--accent); }
.window.active .window-title { color: var(--fg); }
.viewer.tool canvas { cursor: crosshair; }
.tool-panel:not(:empty) { margin-top: 12px; padding-top: 8px; border-top: 1px solid var(--line); }
.panel button {
  font: inherit; padding: 3px 12px; border-radius: 6px; cursor: pointer;
  border: 1px solid var(--line); background: var(--bg); color: var(--fg);
}

/* A tool's handler (or the overlay) running for a while: along the bottom
   of its viewer, over the picture. */
.viewer-running {
  position: absolute; left: 0; right: 0; bottom: 0;
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; padding: 6px 10px;
  background: color-mix(in srgb, var(--panel) 92%, transparent); color: var(--fg);
  border-top: 1px solid var(--line); font-size: 13px;
}
.viewer-running[hidden] { display: none; }
/* "Show pointer position": the point under the pointer, at the bottom
   (above the running bar, while that's shown) */
.viewer-pointer {
  position: absolute; left: 50%; bottom: 8px; transform: translateX(-50%);
  max-width: calc(100% - 16px); padding: 2px 10px; border-radius: 6px; white-space: pre;
  overflow: hidden; text-overflow: ellipsis; pointer-events: none;
  background: rgba(0, 0, 0, .65); color: #fff; font: 12px/1.5 ui-monospace, "SF Mono", Menlo, monospace;
}
.viewer-pointer[hidden] { display: none; }
.viewer-running:not([hidden]) ~ .viewer-pointer { bottom: 44px; }
.viewer-running .spinner {
  display: inline-flex; align-items: center; gap: 6px;
  font-variant-numeric: tabular-nums; color: var(--muted); min-width: 4.5em;
}
.viewer-running .spinner-ring { width: 13px; height: 13px; }
.viewer-running .message { flex: 1 0 auto; white-space: nowrap; }
.viewer-running button {
  font: inherit; padding: 2px 10px; border-radius: 6px; cursor: pointer;
  border: 1px solid var(--line); background: var(--bg); color: var(--fg);
}
.viewer-running button:disabled { opacity: .5; cursor: default; }

/* The script editor (editor.ts): CodeMirror filling its window, the
   error or status under it, and its buttons. */
.script-editor { display: flex; flex-direction: column; background: var(--panel); }
.editor-text { flex: 1; min-height: 0; }
.editor-text .cm-editor { height: 100%; font: var(--editor-font-size, 13px)/1.5 var(--editor-font, monospace); }
.editor-text .cm-scroller { font-family: inherit; }
.editor-text .cm-content { caret-color: var(--fg); }
.editor-text .cm-editor.cm-focused { outline: none; }
.editor-status { padding: 4px 8px; min-height: 1.4em; font-size: 12px; color: var(--muted); white-space: nowrap;
                 overflow: hidden; text-overflow: ellipsis; border-top: 1px solid var(--line); }
.editor-status.error { color: var(--error); }
.editor-status.clickable { cursor: pointer; }
.editor-status.clickable:hover { text-decoration: underline; }
.editor-buttons { display: flex; gap: 6px; padding: 4px 8px 8px; }
.editor-buttons button {
  font: inherit; padding: 3px 12px; border-radius: 6px; cursor: pointer;
  border: 1px solid var(--line); background: var(--bg); color: var(--fg);
}
/* over the whole workspace (the viewers and the configuration), below the title */
.editor-overlay {
  position: absolute; inset: 60px 12px 12px; z-index: 4; display: flex; flex-direction: column;
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, .2); overflow: hidden;
}
.editor-header { display: flex; align-items: center; gap: 8px; padding: 6px 8px 6px 12px; border-bottom: 1px solid var(--line); }
.editor-title { flex: 1; font-weight: 600; }
.editor-close {
  font: inherit; padding: 3px 12px; border-radius: 6px; cursor: pointer;
  border: 1px solid var(--line); background: var(--bg); color: var(--fg);
}
.editor-overlay .script-editor { flex: 1; min-height: 0; }
/* (the engine's colors, Language.Editor.Highlight's classes: preferences.ts
   writes them, with the preferences' changes, and the editor's font) */
.cm-script-error { text-decoration: underline wavy var(--error); text-decoration-skip-ink: none; }
/* the bracket at the cursor and its match, or one with no match (editor.ts's bracketDecorations) */
.cm-bracket-match { background: color-mix(in srgb, var(--accent) 30%, transparent); border-radius: 2px; }
.cm-bracket-unmatched { background: color-mix(in srgb, var(--error) 25%, transparent); color: var(--error); border-radius: 2px; }
/* an error's line, marked in the gutter; and its note, under the line */
.editor-text .cm-error-gutter .cm-gutterElement { display: flex; align-items: center; justify-content: center; cursor: pointer; }
.cm-error-dot { width: 8px; height: 8px; margin: 0 3px; border-radius: 50%; background: var(--error); }
.cm-error-note-row { padding: 6px 0 4px; }
.cm-error-note { position: relative; width: fit-content; max-width: min(48em, 100%); box-sizing: border-box;
                 padding: 4px 10px; border: 1px solid var(--error); border-radius: 6px;
                 background: color-mix(in srgb, var(--error) 12%, var(--panel)); color: var(--fg);
                 white-space: pre-wrap; font-family: system-ui, sans-serif; font-size: 12px; line-height: 1.4; cursor: text; }
.cm-error-note-arrow { position: absolute; top: -6px; width: 10px; height: 10px; margin-left: -5px;
                       background: inherit; border-left: 1px solid var(--error); border-top: 1px solid var(--error);
                       transform: rotate(45deg); }
/* an escape being typed (\theta), and what it would become */
.cm-escape { outline: 1px solid var(--accent); border-radius: 2px; }
.cm-symbol-preview { padding: 3px 8px; font: 12px ui-monospace, monospace; color: var(--muted); white-space: pre; }
.cm-symbol-preview strong { color: var(--fg); }

/* A small form over a viewer (main.ts's askForm): "Jump to view", a
   colorizer's arguments. */
.viewer-form {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 5;
  width: min(320px, calc(100% - 24px)); max-height: calc(100% - 24px); overflow: auto;
  display: flex; flex-direction: column; gap: 8px; padding: 12px;
  background: var(--panel); color: var(--fg); border: 1px solid var(--line); border-radius: 8px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .25); font-size: 13px;
}
.viewer-form .form-title { font-weight: 600; }
.viewer-form .form-field { display: grid; grid-template-columns: auto 1fr; gap: 2px 8px; align-items: center; }
.viewer-form .form-field small { grid-column: 2; color: var(--muted); }
.viewer-form input { font: 12px ui-monospace, monospace; padding: 3px 6px; border: 1px solid var(--line);
                     border-radius: 4px; background: var(--bg); color: var(--fg); min-width: 0; }
.viewer-form .form-error { color: var(--error); min-height: 1em; }
.viewer-form .form-error:empty { display: none; }
.viewer-form .form-buttons { display: flex; justify-content: flex-end; gap: 6px; }
.viewer-form .form-gap { flex: 1; }
.viewer-form button { font: inherit; padding: 3px 12px; border-radius: 6px; cursor: pointer;
                      border: 1px solid var(--line); background: var(--bg); color: var(--fg); }

/* A Shift-drag's box to zoom into (main.ts's zoomToBox) */
.zoom-box {
  position: absolute; pointer-events: none;
  border: 1px solid rgba(255, 255, 255, .9); background: rgba(80, 140, 255, .25);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, .35);
}
.zoom-box[hidden] { display: none; }

/* The autocolor editor (main.ts's autocolorElement), on the
   configuration's "Color settings" page. */
.autocolor-body { display: flex; flex-direction: column; gap: 10px; }
/* (a viewer's colorizer, on its "Color settings" page) */
.colorizer-field button { flex: none; }
.autocolor-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.autocolor-grid { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 6px 10px; align-items: center; }
.autocolor-list { display: flex; flex-direction: column; gap: 4px; border: 1px solid var(--line); border-radius: 6px; padding: 6px; }
.autocolor-entry { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 6px; align-items: center; }
.autocolor-body input[type=text] { font: 12px ui-monospace, monospace; padding: 3px 6px; min-width: 0;
                                   border: 1px solid var(--line); border-radius: 4px; background: var(--bg); color: var(--fg); }
.autocolor-row input[type=text] { flex: 1; }
.autocolor-body input[type=color] { width: 36px; height: 24px; padding: 0 2px; border: 1px solid var(--line); border-radius: 4px; background: var(--bg); }
.autocolor-body button, .autocolor-body select { font: inherit; padding: 3px 10px; border-radius: 6px; cursor: pointer;
                                                  border: 1px solid var(--line); background: var(--bg); color: var(--fg); }
.autocolor-status { color: var(--error); min-height: 1.2em; margin: 0; }
.autocolor-status:empty { display: none; }
.autocolor-empty { color: var(--muted); margin: 4px; }

/* A question over the whole page (main.ts's askSaveTables) */
.page-dialog {
  position: fixed; inset: 0; z-index: 200000; display: flex; align-items: center; justify-content: center;
  background: rgba(0, 0, 0, .25); padding: 16px;
}
.page-dialog-box {
  width: min(460px, 100%); display: flex; flex-direction: column; gap: 8px; padding: 14px 16px;
  background: var(--panel); color: var(--fg); border: 1px solid var(--line); border-radius: 8px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, .3); font-size: 13px;
}
.page-dialog-box p { margin: 0; }
.page-dialog-box ul { margin: 0; padding-left: 20px; font: 12px ui-monospace, monospace; }
.page-dialog-box .form-title { font-weight: 600; }
.page-dialog-box .form-buttons { display: flex; gap: 6px; }
.page-dialog-box .form-gap { flex: 1; }
.page-dialog-box button { font: inherit; padding: 3px 12px; border-radius: 6px; cursor: pointer;
                          border: 1px solid var(--line); background: var(--bg); color: var(--fg); }
.page-dialog-box button:focus-visible { outline: 2px solid var(--accent); }

/* Capturing pictures and movies (capture.ts), in a page dialog */
.page-dialog-box.movie-dialog { width: min(620px, 100%); }
.movie-script { width: 100%; box-sizing: border-box; font: 12px/1.5 ui-monospace, "SF Mono", Menlo, monospace;
                padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--bg); color: var(--fg); resize: vertical; }
.capture-grid { display: grid; grid-template-columns: auto 6em auto 6em; gap: 6px 10px; align-items: center; }
.page-dialog-box input[type=text] { font: 12px ui-monospace, monospace; padding: 3px 6px; min-width: 0;
                                    border: 1px solid var(--line); border-radius: 4px; background: var(--bg); color: var(--fg); }
.page-dialog-box .form-field { display: grid; grid-template-columns: auto 1fr; gap: 8px; align-items: center; }
.page-dialog-box .form-error { color: var(--error); min-height: 1em; white-space: pre-wrap; }
.page-dialog-box .form-error:empty { display: none; }
.page-dialog-box progress { width: 100%; }
.capture-check { display: flex; align-items: center; gap: 4px; }

/* The library, as the welcome screen (welcome.ts): the sections, the
   chosen one's projects as a grid, and the chosen project's details; on a
   narrow screen, the sections as chips over the grid, and the details a
   sheet from the bottom. */
#welcome { height: 100vh; height: 100dvh; }
.welcome { display: flex; flex-direction: column; height: 100%; padding: 12px 20px 8px; gap: 10px; }
.welcome-header { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.welcome-header h1 { margin: 0; font-size: 22px; }
.welcome-gap { flex: 1; }
.welcome button {
  font: inherit; padding: 4px 12px; border-radius: 6px; cursor: pointer;
  border: 1px solid var(--line); background: var(--panel); color: var(--fg);
}
.welcome button:focus-visible, .welcome-grid:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.welcome-panes {
  flex: 1; min-height: 0; display: grid; gap: 12px;
  grid-template-columns: minmax(170px, 220px) minmax(0, 1fr) minmax(260px, 340px);
}
.welcome-sections {
  display: flex; flex-direction: column; gap: 2px; overflow-y: auto; padding: 2px;
}
.welcome .welcome-sections button {
  text-align: left; border-color: transparent; background: none; padding: 6px 10px;
}
.welcome .welcome-sections button:hover { background: var(--panel); }
/* a line between groups of sections (after the starting points) */
.welcome .welcome-sections button.divided { margin-top: 9px; position: relative; }
.welcome .welcome-sections button.divided::before { content: ""; position: absolute; left: 4px; right: 4px; top: -6px; border-top: 1px solid var(--line); }
.welcome .welcome-sections button[aria-current=true] { background: var(--accent); border-color: var(--accent); color: white; }
.welcome-grid {
  list-style: none; margin: 0; padding: 8px; overflow-y: auto; align-content: start;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(148px, 1fr)); gap: 8px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px;
}
.welcome-tile {
  display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 8px 6px;
  border-radius: 8px; cursor: pointer; user-select: none; -webkit-user-select: none;
}
.welcome-tile:hover { background: color-mix(in srgb, var(--fg) 6%, transparent); }
.welcome-tile[aria-selected=true] { background: color-mix(in srgb, var(--accent) 22%, transparent); }
.welcome-tile img, .welcome-no-preview {
  width: 128px; height: 128px; max-width: 100%; object-fit: contain; border-radius: 4px;
}
.welcome-no-preview { background: color-mix(in srgb, var(--fg) 8%, transparent); }
.welcome-tile-title {
  text-align: center; font-size: 13px; line-height: 1.3;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.welcome-details {
  overflow-y: auto; display: flex; flex-direction: column; gap: 10px; padding: 12px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px;
}
.welcome-details h2 { margin: 0; font-size: 17px; }
/* (at the size it was made, as in the grid: scaled up, it's blurry) */
.welcome-preview { width: 128px; height: 128px; object-fit: contain; align-self: center; border-radius: 4px; }
.welcome-description { color: var(--fg); }
.welcome-description p { margin: 0 0 8px; white-space: pre-line; }
.welcome .welcome-open { align-self: flex-start; background: var(--accent); border-color: var(--accent); color: white; padding: 5px 18px; }
.welcome .welcome-open:disabled { opacity: .7; cursor: default; }
.welcome-empty { color: var(--muted); margin: 0; }
.welcome-sheet-close { display: none; }
.welcome-hint { margin: 0; font-size: 12px; color: var(--muted); text-align: center; }
.welcome.opening .welcome-grid { opacity: .6; }
@media (max-width: 1000px) {
  .welcome-panes { grid-template-columns: minmax(150px, 190px) minmax(0, 1fr) minmax(220px, 280px); }
}
@media (max-width: 720px) {
  .welcome { padding: 10px 12px 6px; }
  .welcome-header { flex-wrap: nowrap; gap: 6px; }
  .welcome-header h1 { font-size: 18px; white-space: nowrap; }
  .welcome-name { flex-direction: column; align-items: flex-start; gap: 0; }
  .welcome-version { font-size: 10px; }
  .welcome-header button { font-size: 13px; padding: 4px 9px; white-space: nowrap; }
  .welcome-panes { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); gap: 8px; }
  .welcome-sections { flex-direction: row; overflow-x: auto; overflow-y: hidden; scrollbar-width: none; }
  .welcome .welcome-sections button {
    flex: none; white-space: nowrap; border: 1px solid var(--line); border-radius: 16px; padding: 4px 12px; background: var(--panel);
  }
  .welcome .welcome-sections button.divided { margin-top: 0; margin-left: 9px; }
  .welcome .welcome-sections button.divided::before { top: 4px; bottom: 4px; left: -7px; right: auto; border-top: none; border-left: 1px solid var(--line); }
  .welcome-grid { grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); padding: 6px; gap: 4px; }
  .welcome-tile img, .welcome-no-preview { width: 96px; height: 96px; }
  .welcome-tile-title { font-size: 12px; }
  .welcome-details {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 1000; max-height: 75vh; max-height: 75dvh;
    border-radius: 14px 14px 0 0; border-bottom: none; padding: 16px 16px calc(16px + env(safe-area-inset-bottom));
    box-shadow: 0 -6px 28px rgba(0, 0, 0, .25);
    transform: translateY(105%); transition: transform .22s ease-out, visibility .22s; visibility: hidden;
  }
  .welcome.sheet-open .welcome-details { transform: none; visibility: visible; }
  .welcome .welcome-sheet-close {
    display: block; position: absolute; top: 8px; right: 8px; width: 30px; height: 30px; padding: 0;
    font-size: 18px; line-height: 26px; border-radius: 15px;
  }
  .welcome-hint { display: none; }
}

/* "Loading the library…", until it's loaded */
.welcome-loading { grid-column: 1 / -1; color: var(--muted); padding: 8px; }

/* Edit project details (main.ts's showDetails) */
.page-dialog-box.details-dialog { width: min(520px, 100%); }
.details-field { display: flex; flex-direction: column; gap: 4px; }
.details-description { width: 100%; box-sizing: border-box; font: inherit; padding: 6px 8px; resize: vertical;
                       border: 1px solid var(--line); border-radius: 6px; background: var(--bg); color: var(--fg); }
.details-preview { width: 128px; height: 128px; object-fit: contain; align-self: center; border-radius: 4px; }
.details-no-preview, .details-file { color: var(--muted); }
.details-file { font-size: 12px; overflow-wrap: anywhere; }

/* Copy link, where the clipboard can't be written: the link, to copy */
.link-text { width: 100%; box-sizing: border-box; font: 12px/1.4 ui-monospace, monospace; padding: 6px 8px; resize: vertical;
             border: 1px solid var(--line); border-radius: 6px; background: var(--bg); color: var(--fg); word-break: break-all; }

/* Preferences (preferences-dialog.ts), in a page dialog */
.page-dialog-box.prefs-dialog { width: min(600px, 100%); max-height: calc(100dvh - 32px); }
.prefs-body { overflow: auto; min-height: 0; flex: 1; }
.page-dialog-box .tab-chooser { width: auto; align-self: flex-start; margin: 0; padding: 3px 6px; border-radius: 6px; }
.prefs-pane { display: flex; flex-direction: column; gap: 8px; padding: 4px 2px; }
.prefs-label { font-weight: 600; margin-top: 4px; }
.prefs-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.prefs-row input[type=text] { flex: 1 1 12em; }
.page-dialog-box .prefs-size { width: 5em; font: 12px ui-monospace, monospace; padding: 3px 6px; border: 1px solid var(--line);
                               border-radius: 4px; background: var(--bg); color: var(--fg); }
.prefs-row input[type=range] { flex: 1 1 12em; max-width: 280px; }
.prefs-percent { min-width: 3em; font-variant-numeric: tabular-nums; }
.prefs-order { margin: 0; padding-left: 1.6em; display: flex; flex-direction: column; gap: 4px; }
.prefs-order li span { display: inline-block; min-width: 16em; }
.prefs-order button { margin-left: 4px; }
.prefs-check { display: flex; gap: 8px; align-items: baseline; }
.prefs-hint, .prefs-note { color: var(--muted); font-size: 12px; }
.page-dialog-box select { font: inherit; padding: 2px 4px; border: 1px solid var(--line); border-radius: 4px;
                          background: var(--bg); color: var(--fg); max-width: 100%; }
.prefs-colors { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: 6px; padding: 4px 0; }
.prefs-color-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 8px;
                   padding: 2px 8px; }
.prefs-sample { font: var(--editor-font-size, 13px)/1.5 var(--editor-font, monospace); padding: 0 2px;
                overflow-wrap: anywhere; justify-self: start; }
.prefs-color-controls { display: flex; align-items: center; gap: 4px; }
.prefs-color-controls input[type=color] { width: 28px; height: 24px; padding: 0; border: 1px solid var(--line);
                                          border-radius: 4px; background: none; cursor: pointer; }
.page-dialog-box .prefs-toggle { width: 26px; padding: 2px 0; }
@media (max-width: 480px) {
  .page-dialog-box .prefs-toggle { width: 22px; }
  .page-dialog-box .prefs-color-controls button:last-child { padding: 3px 6px; }
}
.page-dialog-box .prefs-toggle[aria-pressed=true] { background: var(--accent); border-color: var(--accent); color: white; }
.prefs-bold { font-weight: 700; }
.prefs-italic { font-style: italic; }
.prefs-underline { text-decoration: underline; }
.page-dialog-box button:disabled { opacity: .5; cursor: default; }
.welcome .welcome-preferences { font-size: 16px; padding: 2px 8px; }

/* the script editor's gutters: line numbers, and folds */
.editor-text .cm-gutters { background: var(--panel); color: var(--muted); border-right: 1px solid var(--line); }
.editor-text .cm-foldGutter .cm-gutterElement { cursor: pointer; padding: 0 4px; }
.editor-text .cm-foldPlaceholder { background: color-mix(in srgb, var(--fg) 10%, transparent); border: 1px solid var(--line);
                                   color: var(--muted); border-radius: 3px; padding: 0 4px; margin: 0 2px; }
.capture-inset { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.capture-inset select:disabled { opacity: .5; }
/* (its title, and which FractalStream it is, after it; under it, on a phone) */
.welcome-name { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.welcome-version { font-size: 12px; color: var(--muted); user-select: all; white-space: nowrap; }

/* Opening a project (setOpening in main.ts): this in the library's place,
   from the start for a link the page's loaded with (index.html), or after
   a moment for a project that's slow to open; until it's open (or it
   fails, back to the library). */
#project-loading { display: none; }
.loading-project body:not(.in-project) #welcome { display: none; }
.loading-project body:not(.in-project) #project-loading {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  height: 100vh; height: 100dvh; color: var(--muted); font-size: 15px;
}
/* A turning ring: the loading screen's, and a running tool's (main.ts). */
.spinner-ring {
  flex: none; width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid var(--line); border-top-color: var(--accent);
  animation: spinner-turn 0.9s linear infinite;
}
@keyframes spinner-turn { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner-ring { animation-duration: 3s; } }

/* a backend that can't draw anything here (why is its hover text) */
.prefs-order .unavailable { opacity: 0.5; }
