/* Sketch & Paint: app shell. Dark by default, light when the OS asks. */

:root {
  /* One height for the buttons and drop-down lists in panels and windows (BUG-061); pages and dialogs use the larger .button. */
  --control-h: 28px;
  /* Every slider's filled part: a skin's slider part, else the accent. */
  --slider-fill: var(--part-slider-normal-fill, var(--accent));
  --bg-app: #1e1e1e;
  --bg-panel: #2a2a2a;
  --bg-raised: #333;
  --bg-hover: #3c3c3c;
  --bg-selected: #3a4a63;
  --workspace: #181818;
  --border: #3a3a3a;
  --panel-grid: rgba(255, 255, 255, 0.09);
  --text: #e9e9e9;
  /* Dim, but readable at a glance: around 9:1 on the panels. */
  --text-dim: #b8b8b8;
  --accent: #3d8bfd;
  /* What takes away: an error, a subtracting selection, the shape builder deleting. */
  --danger: #e5534b;
  --accent-text: #fff;
  --toast-bg: rgba(20, 20, 20, 0.92);
  /* Icon families (ui/icons.js): colour says what kind of thing. */
  --fam-paint: #f2994a;
  --fam-live: #2ec4b3;
  --fam-vector: #a983ff;
  --fam-select: #55c86f;
  --fam-move: #e9bd2c;
  --fam-colour: #f06a9f;
  --fam-layer: #62a8f5;
  --fam-model: #9fb0c6;
  --fam-danger: #f0544f;

  --taskbar-h: 44px;
  --toolbar-w: 52px;
  /* The dock's width: --dock-w, set from the dockWidth setting (ui/dock-width.js, DOCK_WIDTH in constants/limits.js); this only until it is. */
  --panels-w: var(--dock-w, 312px);
  --status-h: 24px;
  --radius: 8px;
  /* Interface scale (ui/scale.js); everything but the canvas. */
  --ui-scale: 1;
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg-app: #f0f0f0;
    --bg-panel: #fafafa;
    --bg-raised: #fff;
    --bg-hover: #e8e8e8;
    --bg-selected: #dbe8ff;
    --workspace: #dcdcdc;
    --border: #d9d9d9;
    --panel-grid: rgba(0, 0, 0, 0.08);
    --text: #1f1f1f;
    --text-dim: #4f4f4f;
    --toast-bg: rgba(40, 40, 40, 0.92);
    --fam-paint: #d6700f;
    --fam-live: #0f8f81;
    --fam-vector: #7a4fe0;
    --fam-select: #26893f;
    --fam-move: #a87c00;
    --fam-colour: #c8306c;
    --fam-layer: #2a72cc;
    --fam-model: #55667d;
    --fam-danger: #d32f2f;
  }
}

:root[data-theme="light"] {
  --bg-app: #f0f0f0;
  --bg-panel: #fafafa;
  --bg-raised: #fff;
  --bg-hover: #e8e8e8;
  --bg-selected: #dbe8ff;
  --workspace: #dcdcdc;
  --border: #d9d9d9;
  --panel-grid: rgba(0, 0, 0, 0.08);
  --text: #1f1f1f;
  --text-dim: #4f4f4f;
  --toast-bg: rgba(40, 40, 40, 0.92);
  --fam-paint: #d6700f;
  --fam-live: #0f8f81;
  --fam-vector: #7a4fe0;
  --fam-select: #26893f;
  --fam-move: #a87c00;
  --fam-colour: #c8306c;
  --fam-layer: #2a72cc;
  --fam-model: #55667d;
  --fam-danger: #d32f2f;
}

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg-app);
  color: var(--text);
  font: 14px/1.4 system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
  touch-action: none;
}

button { font: inherit; color: inherit; }
h2 { margin: 0; font-size: 13px; font-weight: 600; }

/* --- layout ---------------------------------------------------------------- */

.app {
  /* The tool bar's columns of tools (ui/toolbar-width.js) widen it, each the width of one. */
  --toolbar-col: calc(var(--toolbar-w) * var(--toolbar-cols, 1) * var(--ui-scale));
  --panels-col: calc(var(--panels-w) * var(--ui-scale));
  display: grid;
  grid-template-columns: var(--toolbar-col) minmax(0, 1fr) var(--panels-col);
  grid-template-rows: calc(var(--taskbar-h) * var(--ui-scale)) minmax(0, 1fr) calc(var(--status-h) * var(--ui-scale));
  grid-template-areas:
    "taskbar taskbar taskbar"
    "toolbar stage   panels"
    "status  status  status";
  height: 100dvh;
}

.app[hidden], .home[hidden] { display: none; }
/* Hidden with Tab, or empty because both panels float (ui/dock.js): the column closes. */
.app[data-panels="hidden"], .app[data-docked="none"]:not([data-window-dock="shown"]) { --panels-col: 0px; }
.app[data-docked="none"]:not([data-window-dock="shown"]) .panels { border: 0; }

/*
 * The interface scale zooms every part of the shell, but never the stage:
 * the canvas maps its own pixels. A zoomed part's own lengths scale with it,
 * which is why the grid tracks above multiply by the scale too.
 */
.taskbar, .toolbar, .panels, .statusbar, .popover, .dialog, .context-bar, .toast, .tooltip, .home, .dock-float { zoom: var(--ui-scale); }
/* Hotbars zoom in JS: the interface scale times the bar's own size. */
.app[data-panels="hidden"] .panels { display: none; }

/* Hide the interface (ui/hide-interface.js): the canvas alone, its rows and columns closed; notices and the cursor stay. */
.is-interface-hidden .app { grid-template-columns: 0 minmax(0, 1fr) 0; grid-template-rows: 0 minmax(0, 1fr) 0; }
.is-interface-hidden :is(.taskbar, .toolbar, .panels, .statusbar, .hotbars, .float-panels, .dock-float, .touch-shortcut, .context-bar, .popover, .ruler-handle) { display: none !important; }
.interface-back { position: fixed; top: 8px; right: 8px; z-index: 95; width: 36px; height: 36px; display: grid; place-items: center; border: 1px solid var(--border); border-radius: 8px; background: var(--bg-panel); color: var(--text-dim); opacity: 0.35; cursor: pointer; transition: opacity 0.15s; }
.interface-back:hover, .interface-back:focus-visible { opacity: 1; }
.interface-back[hidden] { display: none; }

/* --- buttons --------------------------------------------------------------- */

.icon-btn, .tool-btn {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  cursor: pointer;
}
.icon-btn:hover, .tool-btn:hover { background: var(--bg-hover); }
/* A window's or a dialog's close mark, a quarter bigger; its button, so its hit box, as it was. */
.icon-btn[title^="Close"] { font-size: 125%; line-height: 1; }
.icon-btn:disabled { opacity: 0.35; cursor: default; background: transparent; }
.icon-btn svg, .tool-btn svg { width: 20px; height: 20px; }
.icon-btn--sm { width: 28px; height: 28px; }
.icon-btn--sm svg { width: 16px; height: 16px; }
/* Glyphs carry badges: they need more room than line icons to read. */
.icon-btn--sm svg.glyph { width: 21px; height: 21px; }
.icon-btn--sm:has(svg.glyph) { width: 32px; height: 32px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.tool-btn { width: 40px; height: 40px; border-radius: var(--part-tool-radius, var(--radius)); background: var(--part-tool-normal-fill, transparent); color: var(--part-tool-normal-text, inherit); }
.tool-btn:hover { background: var(--part-tool-hover-fill, var(--bg-hover)); color: var(--part-tool-hover-text, var(--part-tool-normal-text, inherit)); }
.tool-btn svg { width: 22px; height: 22px; }
.tool-btn__name { display: none; font-size: 12px; line-height: 1.15; white-space: nowrap; }
.app[data-tool-labels="both"] { --toolbar-w: 78px; }
.app[data-tool-labels="both"] .tool-btn { width: 70px; height: 48px; grid-auto-flow: row; align-content: center; gap: 3px; }
.app[data-tool-labels="both"] .tool-btn__name { display: block; }
.tool-btn svg.glyph { width: 26px; height: 26px; }
.app[data-tool-labels="names"] { --toolbar-w: 100px; }
.app[data-tool-labels="names"] .tool-btn { width: 90px; height: 36px; justify-items: start; padding: 0 10px; }
.app[data-tool-labels="names"] .tool-btn svg { display: none; }
.app[data-tool-labels="names"] .tool-btn__name { display: block; font-size: 14px; }

/* Words, not icons, on the task bar: File, Edit, Precision, Panels. */
.bar-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 12px;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
}
.bar-btn:hover:not(:disabled) { background: var(--bg-hover); }
.bar-btn:disabled { opacity: 0.4; cursor: default; }
.bar-btn.is-active { color: var(--accent); }
.bar-btn [data-icon] { display: inline-grid; }
.bar-btn svg { width: 18px; height: 18px; }
.bar-btn[hidden] { display: none; }

/* --- hotbars (ui/hotbars.js) ------------------------------------------------- */

.hotbars { position: fixed; inset: 0; z-index: 50; pointer-events: none; }
.hotbar {
  --slot-size: 46px;
  position: fixed;
  display: flex;
  align-items: stretch;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: color-mix(in srgb, var(--bg-panel) 92%, transparent);
  box-shadow: 0 6px 22px rgba(0, 0, 0, 0.3);
  pointer-events: auto;
}
.hotbar__grip {
  width: 12px;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: radial-gradient(circle, var(--text-dim) 1.2px, transparent 1.6px) center / 6px 6px;
  opacity: 0.6;
  cursor: grab;
}
.hotbar[data-grip="right"] { flex-direction: row-reverse; }
.hotbar.is-locked .hotbar__grip { cursor: pointer; opacity: 0.3; }
.hotbar__slots { display: grid; gap: 4px; }
.hotbar__slot {
  --slot-color: transparent;
  position: relative;
  display: grid;
  place-items: center;
  width: var(--slot-size);
  height: var(--slot-size);
  padding: 4px;
  /* A skin's slot (js/skin-parts.js); the slot's own colour still mixed in. */
  border: 2px solid color-mix(in srgb, var(--slot-color) 85%, var(--part-slot-normal-border, var(--border)));
  border-radius: var(--part-slot-radius, 8px);
  background: color-mix(in srgb, var(--slot-color) 18%, var(--part-slot-normal-fill, var(--bg-raised)));
  border-image: var(--part-slot-normal-image, none);
  overflow: hidden;
  cursor: pointer;
}
.hotbar__slot:hover { background: color-mix(in srgb, var(--slot-color) 18%, var(--part-slot-hover-fill, var(--bg-hover))); border-color: color-mix(in srgb, var(--slot-color) 85%, var(--part-slot-hover-border, var(--part-slot-normal-border, var(--border)))); border-image: var(--part-slot-hover-image, var(--part-slot-normal-image, none)); }
.hotbar__slot svg { width: 28px; height: 28px; }
.hotbar__slot.is-empty { border-style: dashed; background: transparent; cursor: default; }
.hotbar__slot.is-active { border-color: var(--part-slot-on-border, var(--accent)); box-shadow: inset 0 0 0 1px var(--part-slot-on-border, var(--accent)), 0 0 10px color-mix(in srgb, var(--part-slot-on-border, var(--accent)) 60%, transparent); }
.hotbar__slot.is-active:not(:hover) { background: color-mix(in srgb, var(--slot-color) 18%, var(--part-slot-on-fill, var(--part-slot-normal-fill, var(--bg-raised)))); border-image: var(--part-slot-on-image, var(--part-slot-normal-image, none)); }
.hotbar__slot.is-disabled > :not(.hotbar__key) { opacity: 0.3; filter: grayscale(1); }
.hotbar__slot.is-target { border-color: var(--accent); border-style: solid; }
.hotbar__slot.is-proc { animation: proc 0.5s ease-in-out 3; }
@keyframes proc { 50% { box-shadow: 0 0 0 2px #ffd54a, 0 0 14px #ffd54a; } }
.hotbar__preview { width: 100%; height: 100%; object-fit: contain; }
.hotbar__text { font-size: 11px; line-height: 1.1; text-align: center; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; }
.hotbar__label {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 0 2px;
  background: color-mix(in srgb, var(--slot-color) 70%, rgba(0, 0, 0, 0.6));
  color: #fff;
  font-size: 10px;
  font-weight: 600;
  line-height: 13px;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
}
.hotbar__key {
  position: absolute;
  top: 1px;
  right: 3px;
  color: var(--text);
  font: 600 11px system-ui, sans-serif;
  text-shadow: 0 0 3px var(--bg-raised), 0 0 3px var(--bg-raised);
}
.hotbars.is-dropping .hotbar__slot.is-empty { border-color: var(--accent); }
body.is-carrying .hotbar__slot { outline: 2px dashed var(--accent); outline-offset: -4px; }

.slot-editor, .bar-settings { width: 260px; }
.slot-editor__field { display: flex; justify-content: space-between; align-items: center; gap: 10px; min-height: 36px; }
.slot-editor__field input, .slot-editor__field select { width: 130px; height: var(--control-h); padding: 0 8px; border: 1px solid var(--border); border-radius: 6px; background: var(--bg-raised); color: var(--text); font: inherit; -webkit-user-select: text; user-select: text; }
.slot-editor__colors { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.slot-editor__color { width: 24px; height: 24px; padding: 0; border: 2px solid var(--border); border-radius: 50%; background: var(--c); cursor: pointer; }
.slot-editor__color.is-none { background: linear-gradient(135deg, transparent 45%, var(--fam-danger) 45% 55%, transparent 55%); }
.slot-editor__color[aria-checked="true"] { border-color: var(--text); }
.slot-editor__actions { display: flex; gap: 8px; margin-top: 10px; }
.button.is-danger { color: var(--fam-danger); border-image: none; }

.action-book { display: flex; flex-direction: column; }
.window-host[hidden] { display: none; }
/* A dialog shown as a working window (dialogInWindow): the window's title and × stand in for its own. */
.app-window__body.in-dialog :is(.dialog__title, .settings__header, .help__bar h2, .help__bar [data-close]) { display: none; }
.app-window__body.in-dialog > :is(form, .help) { flex: 1 1 auto; min-height: 0; overflow: auto; }
.action-book__hint { margin: 4px 0 8px; color: var(--text-dim); }
.action-book__list { overflow-y: auto; min-height: 0; }
.action-book__item[hidden] { display: none; }
.action-book__item { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 40px; padding: 2px 6px; border: 0; border-radius: 6px; background: none; text-align: left; cursor: grab; }
.action-book__item:hover { background: var(--bg-hover); }
.action-book__text { display: flex; flex-direction: column; min-width: 0; }
.action-book__text small, .keys__label small { color: var(--text-dim); font-size: 12px; line-height: 1.3; }
.keys__label small { display: block; }
.action-book__visual { flex: none; display: grid; place-items: center; width: 34px; height: 34px; border: 1px solid var(--border); border-radius: 6px; background: var(--bg-raised); overflow: hidden; }
.action-book__visual svg { width: 22px; height: 22px; }
.action-book__visual canvas { width: 100%; height: 100%; }
.action-book__visual .hotbar__text { font-size: 9px; }

/* --- pressure profiles (ui/profiles-dialog.js) ------------------------------- */

#profiles-dialog { width: min(900px, calc(100vw - 32px)); }
.profiles { display: grid; grid-template-columns: 170px 280px 1fr; gap: 16px; align-items: start; }
.profiles__list { display: flex; flex-direction: column; gap: 2px; max-height: 330px; overflow-y: auto; }
.profiles__item { display: flex; justify-content: space-between; align-items: center; gap: 6px; min-height: 34px; padding: 0 8px; border: 0; border-radius: 6px; background: none; text-align: left; cursor: pointer; }
.profiles__item:hover { background: var(--bg-hover); }
.profiles__item[aria-selected="true"] { background: var(--bg-selected); }
.profiles__active { color: var(--accent); font-size: 12px; }
.profiles__list-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.profiles__tabs { display: flex; gap: 4px; margin: 6px 0; }
.profiles__tabs button { flex: 1; height: 30px; border: 1px solid var(--border); border-radius: 6px; background: none; cursor: pointer; }
.profiles__tabs button[aria-selected="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.profiles__weight { display: flex; align-items: center; gap: 8px; color: var(--text-dim); font-size: 12px; }
.profiles__weight[hidden] { display: none; }
.profiles__weight input { flex: 1; accent-color: var(--slider-fill); }
.curve-editor { margin-top: 6px; }
.curve-editor__canvas { display: block; width: 260px; height: 260px; touch-action: none; cursor: crosshair; }
.curve-editor__bin { padding: 8px; border: 1px dashed var(--border); border-radius: 6px; color: var(--text-dim); font-size: 12px; text-align: center; }
.curve-editor__bin.is-armed { border-color: var(--fam-danger); color: var(--fam-danger); }
.curve-editor__axes { margin: 6px 0; color: var(--text-dim); font-size: 12px; }
.profiles__test { display: flex; flex-direction: column; gap: 6px; }
.profiles__test-header { display: flex; justify-content: space-between; align-items: center; }
.profiles__test-canvas { width: 100%; height: 330px; border-radius: 8px; background: var(--bg-raised); box-shadow: inset 0 0 0 1px var(--border); touch-action: none; cursor: crosshair; }
.profiles__readout { margin: 0; color: var(--text-dim); font-size: 12px; font-variant-numeric: tabular-nums; }

/* --- settings window (ui/settings.js) ------------------------------------------ */

.dialog.dialog--settings { width: min(720px, calc(100vw - 32px)); height: min(560px, calc(100dvh / var(--ui-scale) - 48px)); padding: 0; }
.settings { display: grid; grid-template-columns: 180px 1fr; grid-template-rows: auto minmax(0, 1fr); height: 100%; }
.settings__header { grid-column: 1 / -1; display: flex; justify-content: space-between; align-items: center; padding: 14px 16px 10px 20px; border-bottom: 1px solid var(--border); }
.settings__header .dialog__title { margin: 0; }
.settings__nav { display: flex; flex-direction: column; gap: 2px; padding: 12px 8px; background: var(--bg-app); border-right: 1px solid var(--border); }
.settings__tab { height: 36px; padding: 0 12px; border: 0; border-radius: 6px; background: var(--part-tab-normal-fill, none); color: var(--part-tab-normal-text, inherit); text-align: left; font-weight: 500; cursor: pointer; }
.settings__tab:hover { background: var(--part-tab-hover-fill, var(--bg-hover)); color: var(--part-tab-hover-text, inherit); }
.settings__tab[aria-current="true"] { color: var(--part-tab-current-text, var(--accent)); background: var(--part-tab-current-fill, var(--bg-selected)); }
.settings__body { padding: 8px 20px 20px; overflow-y: auto; }
.settings__group { border-bottom: 1px solid var(--border); padding: 4px 0 10px; }
.settings__group summary { padding: 10px 0 6px; font-weight: 600; cursor: pointer; }
.settings__row { padding: 6px 0; }
.settings__field { display: flex; justify-content: space-between; align-items: center; gap: 16px; min-height: 34px; }
.settings__field select { max-width: 260px; height: 32px; padding: 0 8px; border: 1px solid var(--border); border-radius: 6px; background: var(--bg-raised); color: var(--text); font: inherit; }
.settings__field--button { justify-content: flex-start; }
.settings__field--end { justify-content: flex-end; }
.settings__range { display: flex; align-items: center; gap: 8px; }
.settings__range input { width: 180px; accent-color: var(--slider-fill); }
.settings__range output { min-width: 44px; color: var(--text-dim); font-variant-numeric: tabular-nums; }
.settings__note { margin: 2px 0 0; color: var(--text-dim); font-size: 13px; }
.settings__tools summary { padding: 8px 0; cursor: pointer; }
.settings__tools .settings__field { padding-left: 14px; }
.settings__tools select { max-width: 220px; }
.settings__count { color: var(--text-dim); font-size: 13px; }

/* --- Touch Shortcut (ui/touch-shortcut.js) ---------------------------------------- */

.touch-shortcut {
  position: absolute;
  z-index: 5;
  width: 64px;
  height: 64px;
  border: 2px solid var(--border);
  border-radius: 50%;
  background: color-mix(in srgb, var(--bg-panel) 85%, transparent);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
  zoom: var(--ui-scale);
  touch-action: none;
  cursor: pointer;
}
/* Two rings: the middle (inner, ui/touch-shortcut.js INNER_SHARE: 60% of the radius) and the outer ring around it; the one held lights. */
.touch-shortcut::after { content: ''; position: absolute; inset: 13px; border-radius: 50%; background: var(--text-dim); opacity: 0.5; }
.touch-shortcut[data-ring="outer"] { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 35%, var(--bg-panel)); }
.touch-shortcut[data-ring="inner"]::after { background: var(--accent); opacity: 1; }
.touch-shortcut.is-latched { box-shadow: 0 0 0 3px var(--accent), 0 4px 16px rgba(0, 0, 0, 0.3); }
.touch-shortcut[hidden] { display: none; }

/* Instant tooltips (ui/tooltip.js). */
.tooltip, .menu-hint {
  position: fixed;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 3px;
  max-width: 280px;
  padding: 6px 10px;
  border-radius: 6px;
  background: var(--toast-bg);
  color: #fff;
  font-size: 13px;
  pointer-events: none;
}
.tooltip[hidden], .menu-hint[hidden] { display: none; }
/* Shown as popovers, over the menus (ui/scale.js showOnTop): not where and how a popover sits by default. */
.tooltip[popover], .menu-hint[popover] { inset: auto; margin: 0; border: 0; overflow: visible; }
.tooltip__head { display: flex; align-items: center; gap: 8px; }
/* A long name wraps; the key stays whole beside it. */
.tooltip__head kbd { flex: none; white-space: nowrap; }
.tooltip small { font-size: 12px; line-height: 1.35; opacity: 0.8; }
.tooltip kbd { padding: 1px 6px; border: 1px solid rgba(255, 255, 255, 0.35); border-radius: 4px; font: 12px system-ui, sans-serif; }
.tool-btn[aria-pressed="true"], .tool-btn[aria-pressed="true"]:hover {
  background: var(--part-tool-on-fill, var(--accent));
  color: var(--part-tool-on-text, var(--accent-text));
  /* Glyphs (ui/icons.js) turn the button's text colour on the accent. */
  --glyph: currentColor;
  --glyph-detail: var(--part-tool-on-fill, var(--accent));
  --glyph-ring: var(--part-tool-on-fill, var(--accent));
}
/* A glyph's detail lines and badge ring are the colour behind it. */
.layer[aria-selected="true"] { --glyph-ring: var(--bg-selected); }

.pill {
  height: 28px;
  min-width: 58px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--bg-raised);
  cursor: pointer;
  font-variant-numeric: tabular-nums;
}
.pill:hover { background: var(--bg-hover); }
.pill[hidden] { display: none; }
/* The zoom readout typed into (ui/zoom-readout.js): the same pill, a text box for the moment. */
.zoom-entry { width: 58px; cursor: text; text-align: center; color: var(--text); font: inherit; font-variant-numeric: tabular-nums; }
.zoom-entry:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

/* --- task bar -------------------------------------------------------------- */

.taskbar {
  grid-area: taskbar;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 8px 0 14px;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
}
.taskbar__group { display: flex; align-items: center; gap: 4px; min-width: 0; }
/* On a narrow window the title and save state give way to the menus beside them, not under them. */
.taskbar__group--title { gap: 12px; flex: 1 1 0; overflow: hidden; }
.taskbar__group--title > .bar-btn { flex: none; }
@media (max-width: 1000px) {
  .taskbar .bar-btn { padding: 0 8px; }
}
.taskbar__group:last-child { flex: 1 1 0; justify-content: flex-end; }
/* Folded (ui/taskbar-fold.js): the menus and the bar's switches go into the menu (☰), which shows only then. */
.taskbar__more { display: none; }
.taskbar.is-compact .taskbar__fold { display: none; }
.taskbar.is-compact .taskbar__more { display: inline-flex; }
.taskbar__more svg { width: 20px; height: 20px; }
.doc-title {
  min-width: 0;
  max-width: 260px;
  height: 30px;
  padding: 0 8px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: none;
  color: var(--text);
  font: inherit;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: text;
}
.doc-title:hover { border-color: var(--border); }
.doc-title--editing { border-color: var(--accent); background: var(--bg-raised); -webkit-user-select: text; user-select: text; }
.save-state { min-width: 0; padding: 0; border: 0; background: none; color: var(--text-dim); font: inherit; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: default; }
.save-state[data-state="reconnect"], .save-state[data-state="unsent"] { color: var(--accent); font-weight: 600; cursor: pointer; }
.save-state[data-state="error"] { color: var(--danger); font-weight: 600; }

/* --- tool bar -------------------------------------------------------------- */

.toolbar {
  grid-area: toolbar;
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 8px 0 12px;
  background: var(--part-toolbar-normal-fill, var(--bg-panel));
  border-right: 1px solid var(--part-toolbar-normal-border, var(--border));
  overflow: hidden;
  /* A glyph's detail lines and badge ring are the colour behind it: the bar's. */
  --glyph-detail: var(--part-toolbar-normal-fill, var(--bg-panel));
  --glyph-ring: var(--part-toolbar-normal-fill, var(--bg-panel));
}
/* The tools scroll on a short screen (a phone, a landscape tablet); the foot below them (size, opacity, colour) stays put, never squeezed. */
.toolbar__tools {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  scrollbar-width: thin;
}
.toolbar__tools > *, .toolbar__foot > * { flex-shrink: 0; }
.toolbar__foot { display: flex; flex-direction: column; align-items: center; gap: 6px; flex: none; padding-top: 6px; padding-bottom: 6px;
  /* Its own stacking context: the second colour (the well's ::after, z-index -1) sits behind the colour, not behind the tool bar. */
  isolation: isolate; }
.toolbar__quick { display: flex; flex-direction: column; gap: 4px; width: 100%; padding: 0 6px; }
.quick { display: flex; flex-direction: column; align-items: center; padding: 3px 0 4px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg-raised); cursor: ns-resize; touch-action: none; -webkit-user-select: none; user-select: none; }
.quick:hover, .quick:focus-visible { border-color: var(--accent); outline: none; }
.quick[hidden], .toolbar__quick[hidden] { display: none; }
.quick__label { font-size: 10.5px; color: var(--text-dim); line-height: 1.2; }
.quick__value { font-size: 14px; font-weight: 600; font-variant-numeric: tabular-nums; line-height: 1.2; }
.quick__typed { width: 48px; font: inherit; font-size: 15px; text-align: center; padding: 2px 0; border: 1px solid var(--accent); border-radius: 4px; background: var(--bg); color: var(--text); }
/* Shorter windows: tool buttons tighten up, in two steps, so every tool fits. */
@media (max-height: 1080px) {
  .app[data-tool-labels="both"] .tool-btn { height: 40px; gap: 1px; }
  .app[data-tool-labels="both"] .tool-btn svg.glyph { width: 21px; height: 21px; }
  .app[data-tool-labels="both"] .tool-btn__name { font-size: 11px; }
  .toolbar__tools { gap: 2px; }
}
@media (max-height: 980px) {
  .tool-btn { height: 35px; }
  .app[data-tool-labels="both"] .tool-btn { height: 35px; gap: 0; }
  .app[data-tool-labels="both"] .tool-btn svg.glyph { width: 19px; height: 19px; }
  .app[data-tool-labels="both"] .tool-btn__name { font-size: 10.5px; line-height: 1.05; }
  .app[data-tool-labels="names"] .tool-btn { height: 32px; }
  .toolbar__tools { gap: 1px; }
  .toolbar { padding-top: 4px; }
}
@media (max-height: 900px) {
  .tool-btn { height: 31px; }
  .app[data-tool-labels="both"] .tool-btn { height: 30px; }
  .app[data-tool-labels="both"] .tool-btn svg.glyph { width: 16px; height: 16px; }
  .app[data-tool-labels="both"] .tool-btn__name { font-size: 10px; line-height: 1; }
  .app[data-tool-labels="names"] .tool-btn { height: 30px; }
}

.color-well {
  --swatch: #000;
  --swatch2: #fff;
  position: relative;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--swatch);
  box-shadow: 0 0 0 2px var(--bg-panel), 0 0 0 3px var(--text-dim);
  cursor: pointer;
}
/* The second colour peeks out behind the colour, bottom right. */
.color-well::after {
  content: '';
  position: absolute;
  right: -5px;
  bottom: -5px;
  z-index: -1;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--swatch2);
  box-shadow: 0 0 0 1.5px var(--bg-panel), 0 0 0 2.5px var(--text-dim);
}

/* --- colour popover -------------------------------------------------------- */

.popover {
  margin: 0;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg-panel);
  color: var(--text);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.35);
}
.popover__heading { margin: 12px 0 6px; font-size: 12px; font-weight: 600; color: var(--text-dim); }

.hex-input {
  flex: 1;
  min-width: 0;
  height: 30px;
  padding: 0 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-raised);
  color: var(--text);
  font: 13px ui-monospace, monospace;
  -webkit-user-select: text;
  user-select: text;
}

/* --- floating panels and colour pieces (ui/floating-panels.js, colour-pieces.js) --- */

/* No box of its own: each colour panel takes its depth among the windows (ui/panel-depth.js, from 55 up), not as one stack. */
.float-panels { display: contents; }
.float-panel {
  position: fixed;
  width: max-content;
  max-width: 360px;
  padding: 6px 12px 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg-panel);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.35);
  pointer-events: auto;
}
.float-panel[hidden] { display: none; }
.float-panel.is-transient { box-shadow: 0 0 0 2px var(--accent), 0 8px 28px rgba(0, 0, 0, 0.35); }
.float-panel__header { display: flex; align-items: center; gap: 2px; margin-bottom: 6px; }
.float-panel__grip { flex: 1; padding: 6px 0; font-weight: 600; cursor: grab; touch-action: none; }
.float-panel__body { display: flex; flex-direction: column; gap: 10px; align-items: stretch; }

.wheel { --hue: 0; position: relative; width: 220px; height: 220px; align-self: center; touch-action: none; cursor: crosshair; }
.wheel:not(.has-ring) { width: auto; }
.wheel__ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: conic-gradient(hsl(0 100% 50%), hsl(60 100% 50%), hsl(120 100% 50%), hsl(180 100% 50%), hsl(240 100% 50%), hsl(300 100% 50%), hsl(360 100% 50%));
  /* A thick ring: and the whole area outside the square grabs hue. */
  -webkit-mask: radial-gradient(circle, transparent calc(50% - 27px), #000 calc(50% - 26px));
  mask: radial-gradient(circle, transparent calc(50% - 27px), #000 calc(50% - 26px));
}
.wheel__hue-mark { position: absolute; left: -11px; top: -11px; width: 22px; height: 22px; border: 3px solid #fff; border-radius: 50%; box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.5); pointer-events: none; }
.wheel__square {
  position: absolute;
  inset: 52px;
  border-radius: 6px;
  background: linear-gradient(to top, #000, transparent), linear-gradient(to right, #fff, hsl(calc(var(--hue) * 1deg) 100% 50%));
}
.wheel:not(.has-ring) .wheel__square { inset: 0; }
.wheel__sv-mark { position: absolute; width: 20px; height: 20px; margin: -10px 0 0 -10px; border: 3px solid #fff; border-radius: 50%; box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.5); pointer-events: none; }
.wheel__centre { position: absolute; inset: 64px; border-radius: 50%; box-shadow: inset 0 0 0 1px rgba(127, 127, 127, 0.5); }

.cgroup { display: flex; flex-direction: column; gap: 8px; }
.cslider { display: flex; flex-direction: column; gap: 4px; width: 240px; }
.cslider__head { display: flex; justify-content: space-between; align-items: center; color: var(--text-dim); }
.cslider__value { width: 58px; height: 26px; padding: 0 6px; border: 1px solid var(--border); border-radius: 6px; background: var(--bg-raised); color: var(--text); font: inherit; text-align: right; -webkit-user-select: text; user-select: text; }
.cslider__track { position: relative; height: 28px; border-radius: 14px; box-shadow: inset 0 0 0 1px rgba(127, 127, 127, 0.4); touch-action: none; cursor: pointer; }
.cslider__thumb { position: absolute; top: 50%; width: 26px; height: 26px; margin: -13px 0 0 -13px; border: 3px solid #fff; border-radius: 50%; box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.5); pointer-events: none; }
.chex { display: flex; align-items: center; gap: 8px; color: var(--text-dim); }
.crecents { display: flex; flex-wrap: wrap; gap: 6px; max-width: 240px; }
/* A colour chosen anywhere but the colour in hand: a swatch, and the chooser beside it (Milestone 87). */
.colour-swatch { width: 28px; height: 28px; padding: 0; border: 0; border-radius: 6px; background: var(--c, transparent); box-shadow: inset 0 0 0 1px rgba(127, 127, 127, 0.5); cursor: pointer; flex: none; }
.colour-popover { display: grid; gap: 10px; width: 260px; }
.colour-popover:not(:popover-open) { display: none; }
.colour-popover__pick { justify-self: end; }
.crecents__swatch, .crecents__add { width: 32px; height: 32px; padding: 0; border: 0; border-radius: 6px; box-shadow: inset 0 0 0 1px rgba(127, 127, 127, 0.5); cursor: pointer; }
.crecents__add { background: var(--bg-raised); font-size: 18px; }

.cboard__area { position: relative; border-radius: 10px; background: color-mix(in srgb, var(--bg-raised) 70%, #d8d2c8); box-shadow: inset 0 0 0 1px var(--border); overflow: hidden; touch-action: none; }
/* While a blob is dragged it may leave the board (to remove it, or onto a hotbar slot). */
.cboard__area.is-dragging { overflow: visible; }
.cboard__blob {
  position: absolute;
  padding: 0;
  border: 0;
  background: radial-gradient(circle at 35% 30%, color-mix(in srgb, var(--c) 75%, #fff), var(--c) 55%, color-mix(in srgb, var(--c) 85%, #000));
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
  cursor: pointer;
  touch-action: none;
}
.cboard__blob.is-current { outline: 3px solid var(--accent); outline-offset: 2px; }
.cboard__blob.is-dragging { z-index: 2; opacity: 0.85; cursor: grabbing; }
.cboard__name { position: absolute; left: 50%; top: 100%; translate: -50% 2px; padding: 0 4px; border-radius: 4px; background: rgba(0, 0, 0, 0.6); color: #fff; font-size: 11px; white-space: nowrap; pointer-events: none; }
.cboard__handle { position: absolute; z-index: 3; width: 18px; height: 18px; margin: -9px 0 0 -9px; border: 2px solid #fff; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.4); cursor: nwse-resize; touch-action: none; }
.cboard__handle[hidden] { display: none; }
.cboard__empty { margin: 0; padding: 40px 24px; color: var(--text-dim); text-align: center; }
.cboard__bar { display: flex; gap: 6px; margin-top: 8px; }
.blob-editor { width: 280px; }
.blob-editor__sizes { display: flex; gap: 4px; }
.blob-editor__save { display: flex; gap: 6px; margin-bottom: 8px; }
.blob-editor__save input { flex: 1; height: 30px; padding: 0 8px; border: 1px solid var(--border); border-radius: 6px; background: var(--bg-raised); color: var(--text); font: inherit; }
.blob-editor__set { display: flex; justify-content: space-between; align-items: center; gap: 6px; min-height: 36px; }
.blob-editor__set > span:last-child { display: flex; gap: 4px; }
.blob-editor__import { display: flex; flex-wrap: wrap; gap: 6px; }
.hotbar__colour { width: 100%; height: 100%; border-radius: 6px; box-shadow: inset 0 0 0 1px rgba(127, 127, 127, 0.5); }

/* Left-handed: tool bar on the right, panels on the left. */
.app[data-toolbar-side="right"] {
  grid-template-columns: var(--panels-col) minmax(0, 1fr) var(--toolbar-col);
  grid-template-areas:
    "taskbar taskbar taskbar"
    "panels  stage   toolbar"
    "status  status  status";
}
.app[data-toolbar-side="right"] .toolbar { border-right: 0; border-left: 1px solid var(--part-toolbar-normal-border, var(--border)); }
.app[data-toolbar-side="right"] .panels { border-left: 0; border-right: 1px solid var(--border); }
/* Panels beside the tool bar: both under one hand. */
.app[data-panels-side="beside"] {
  grid-template-columns: var(--toolbar-col) var(--panels-col) minmax(0, 1fr);
  grid-template-areas:
    "taskbar taskbar taskbar"
    "toolbar panels  stage"
    "status  status  status";
}
.app[data-panels-side="beside"] .panels { border-left: 0; border-right: 1px solid var(--border); }
.app[data-panels-side="beside"][data-toolbar-side="right"] {
  grid-template-columns: minmax(0, 1fr) var(--panels-col) var(--toolbar-col);
  grid-template-areas:
    "taskbar taskbar taskbar"
    "stage   panels  toolbar"
    "status  status  status";
}
.app[data-panels-side="beside"][data-toolbar-side="right"] .panels { border-right: 0; border-left: 1px solid var(--border); }

/* A side panel floating over the canvas (ui/dock.js): dragged by its header, resized at its foot. */
.dock-float {
  position: fixed;
  /* The back of the band; its place front to back is set by ui/panel-depth.js. */
  z-index: 55;
  display: flex;
  flex-direction: column;
  width: var(--panels-w);
  min-height: 160px;
  max-height: calc(100dvh / var(--ui-scale) - 16px);
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
  overflow: hidden;
}
.dock-float[hidden], .dock-float.is-hidden { display: none; }
/* Properties for a tool with nothing to set: not there at all, docked or floating. */
.panel.is-empty, .dock-float:has(> .panel.is-empty) { display: none; }
.dock-float > .panel { flex: 1 1 auto; max-height: none; min-height: 0; border: 0; }
.dock-float .panel__header { cursor: grab; touch-action: none; }
.dock-btn { margin-left: auto; }
.panel-frame__buttons:not([hidden]) + .dock-btn { margin-left: 2px; }
.panel__header .panel-frame__buttons { display: flex; gap: 2px; margin-left: auto; }
.panel-frame__buttons[hidden] { display: none; }
.panel-frame__buttons .is-on { color: var(--accent); }

/* The panel frame (ui/panel-frame.js): resized at its edges, faded in and out, locked. */
.panel-frame {
  transition: opacity 0.14s ease, display 0.14s allow-discrete;
}
/* Hotbars are drawn afresh as tools change: they don't fade in each time. */
@starting-style { .panel-frame:not(.hotbar) { opacity: 0; } }
.hotbar.panel-frame { transition: none; }
.panel-frame[hidden], .panel-frame.is-hidden { opacity: 0; }
.panel-frame.is-locked .panel__header { cursor: default; }
.panel-frame__edge { position: absolute; z-index: 2; touch-action: none; }
.panel-frame__edge[hidden] { display: none; }
.panel-frame__edge--right { top: 0; right: 0; bottom: var(--grip); width: var(--grip); cursor: ew-resize; }
.panel-frame__edge--bottom { left: 0; right: var(--grip); bottom: 0; height: var(--grip); cursor: ns-resize; }
.panel-frame__edge--corner { right: 0; bottom: 0; width: calc(var(--grip) * 2); height: calc(var(--grip) * 2); cursor: nwse-resize; }
@media (prefers-reduced-motion: reduce) { .panel-frame { transition: none; } }
/* The grid panels snap to, faded in over the canvas area while one moves. */
.panel-grid {
  position: fixed;
  z-index: 29;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s ease;
  background-image: linear-gradient(to right, var(--panel-grid) 1px, transparent 1px), linear-gradient(to bottom, var(--panel-grid) 1px, transparent 1px);
  /* Its own layer, drawn once: fading in changes only its opacity (ui/panel-frame.js). */
  will-change: opacity;
  contain: strict;
}
.panel-grid.is-visible { opacity: 1; }

/* Working windows (ui/windows.js): floating in a frame like a panel's, or docked as tabs in the column. */
.app-window { width: auto; min-width: 280px; min-height: 200px; z-index: 55; }
.app-window__bar { gap: 2px; }
.app-window__bar h2 { flex: 1; margin: 0; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.app-window__body { flex: 1 1 auto; min-height: 0; overflow: auto; container-type: inline-size; }
/* Narrow (docked in the column, or a small frame): two-pane windows stack. */
@container (max-width: 520px) {
  .app-window__body .gradients, .app-window__body .cast-window { grid-template-columns: minmax(0, 1fr); }
  .app-window__body .gradients__list { max-height: 30vh; }
}
.app-window__body[hidden] { display: none; }
.window-dock { flex: 1.4 1 0; min-height: 260px; border-top: 1px solid var(--border); }
.panel-look > form { padding: 12px 18px 16px; }
.window-dock[hidden] { display: none; }
.window-dock__tabs { justify-content: flex-start; gap: 2px; padding: 0 4px; overflow-x: auto; }
.window-dock__tab { flex: none; height: 30px; padding: 0 10px; border: 0; border-radius: 6px; background: var(--part-tab-normal-fill, none); color: var(--part-tab-normal-text, var(--text-dim)); font: inherit; font-size: 13px; cursor: pointer; white-space: nowrap; }
.window-dock__tab:hover:not(.is-current) { background: var(--part-tab-hover-fill, none); color: var(--part-tab-hover-text, var(--part-tab-normal-text, var(--text-dim))); }
.window-dock__tab.is-current { background: var(--part-tab-current-fill, var(--bg-raised)); color: var(--part-tab-current-text, var(--text)); font-weight: 600; }
.window-dock__actions { position: sticky; right: 0; display: flex; gap: 2px; margin-left: auto; padding-left: 4px; background: var(--bg-panel); }
.window-dock__body { flex: 1 1 0; min-height: 0; display: flex; flex-direction: column; }
.window-dock__body > .app-window__body { flex: 1 1 0; }
/* A floating window dragged over the column: let go to dock it there. */
.panels.is-target { box-shadow: inset 0 0 0 2px var(--accent); }
.panel__header h2 + .panel__meta + .dock-btn, .panel__actions + .dock-btn { margin-left: 2px; }

/* --- stage ----------------------------------------------------------------- */

.stage {
  grid-area: stage;
  position: relative;
  overflow: hidden;
  background: var(--workspace);
}
.stage canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

/* --- panels ---------------------------------------------------------------- */

.panels {
  grid-area: panels;
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--bg-panel);
  border-left: 1px solid var(--part-panel-normal-border, var(--border));
  overflow: hidden;
  position: relative;
}
/* The dock's edge beside the canvas, dragged to change its width (ui/dock-width.js); the line shows where it will go. */
.dock-grip { position: absolute; top: 0; bottom: 0; z-index: 5; width: 6px; cursor: col-resize; touch-action: none; }
.dock-grip[data-side="left"] { left: 0; }
.dock-grip[data-side="right"] { right: 0; }
.dock-grip:hover, .dock-grip:focus-visible { background: color-mix(in srgb, var(--accent) 35%, transparent); outline: none; }
.app[data-toolbar-cols="2"] .toolbar__tools { display: grid; grid-template-columns: repeat(2, auto); justify-content: center; align-content: start; }
/* The tool bar's edge beside the canvas: dragged, it snaps between one column of tools and two (ui/toolbar-width.js). */
.toolbar { position: relative; }
.toolbar-grip { position: absolute; top: 0; bottom: 0; z-index: 5; width: 6px; cursor: col-resize; touch-action: none; }
.toolbar-grip[data-side="left"] { left: 0; }
.toolbar-grip[data-side="right"] { right: 0; }
.toolbar-grip[hidden] { display: none; }
.toolbar-grip:hover, .toolbar-grip:focus-visible { background: color-mix(in srgb, var(--accent) 35%, transparent); outline: none; }
.dock-grip__line { position: fixed; top: 0; bottom: 0; z-index: 90; width: 2px; margin-left: -1px; background: var(--accent); pointer-events: none; }
/* A skin's panel (js/skin-parts.js): its header and the lines between panels. */
.panel { display: flex; flex-direction: column; border-bottom: 1px solid var(--part-panel-normal-border, var(--border)); }
.panel--grow { flex: 1 1 0; min-height: 200px; border-bottom: 0; }
/* Properties scrolls within at most ~half the column; Layers gets the rest. */
.panel--scroll { flex: 0 1 auto; min-height: 0; max-height: 45%; overflow-y: auto; }
.panel--scroll .panel__header { position: sticky; top: 0; z-index: 1; background: var(--part-panel-normal-header, var(--bg-panel)); }
.panel__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 40px;
  padding: 0 8px 0 14px;
  background: var(--part-panel-normal-header, transparent);
  color: var(--part-panel-normal-header-text, inherit);
}
.panel__meta { color: var(--text-dim); font-size: 13px; }
.panel__body { padding: 4px 14px 12px; }
.panel__hint { margin: 0; color: var(--text-dim); }

.field {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 2px 8px;
  margin-bottom: 10px;
}
.field output { color: var(--text-dim); font-variant-numeric: tabular-nums; }
.field output.is-typeable { cursor: text; border-radius: 4px; padding: 0 4px; margin-right: -4px; }
.field output.is-typeable:hover { background: var(--bg-raised); color: var(--text); }
.field__typed { width: 72px; font: inherit; font-size: 15px; text-align: right; padding: 3px 6px; border: 1px solid var(--accent); border-radius: 4px; background: var(--bg); color: var(--text); }
.field input[type="range"] { grid-column: 1 / -1; width: 100%; margin: 4px 0 0; accent-color: var(--slider-fill); }
/* A menu sits beside its label when it fits, below it when it doesn't, never wider than the panel (BUG-038). */
.field--select { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; }
.field--select select { min-width: 0; max-width: 100%; }
.field select {
  height: var(--control-h);
  padding: 0 6px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-raised);
  color: var(--text);
  font: inherit;
}

.preset-list { display: flex; flex-direction: column; gap: 2px; margin: 0 -6px 12px; }
.preset {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 40px;
  padding: 0 6px;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  text-align: left;
  cursor: pointer;
}
.preset:hover { background: var(--bg-hover); }
.preset[aria-selected="true"] { background: var(--bg-selected); }
.preset__name { flex: 0 0 96px; overflow: hidden; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-height: 1.2; }
/* A set's heading in the preset list: tap to fold the set away. */
.preset-set { display: flex; align-items: center; gap: 6px; margin-top: 6px; padding: 4px 6px; border: 0; background: none; color: var(--text-dim); font: inherit; font-size: 12px; font-weight: 600; text-align: left; cursor: pointer; }
.preset-set::before { content: '▾'; display: inline-block; width: 10px; transition: transform 0.15s; }
.preset-set[aria-expanded="false"]::before { transform: rotate(-90deg); }
.preset-set:hover { color: var(--text); }
.preset-set__count { margin-left: auto; font-weight: 400; font-variant-numeric: tabular-nums; }
.preset__preview { flex: 1; min-width: 0; height: 32px; }

.panel__actions { display: flex; gap: 2px; }
/* A panel's own buttons, in a row below its title row (ui/dock.js), so the title row has room for the frame's. */
.panel__tools { display: flex; flex-wrap: wrap; gap: 2px; padding: 0 8px 4px 10px; }
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.layer-props {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 14px 8px;
}
.layer-props select {
  flex: 0 0 104px;
  height: var(--control-h);
  padding: 0 4px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-raised);
  color: var(--text);
  font: inherit;
}
.layer-surface[hidden] { display: none; }
/* The Layers panel filtered (ui/layer-list.js, row 157): the funnel lit while filtering, the bar under the header. */
.layer-filter-btn.is-on { color: var(--accent); }
.layer-filter { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 0 14px 8px; }
.layer-filter[hidden] { display: none; }
.layer-filter select, .layer-filter__name { height: var(--control-h); padding: 0 6px; border: 1px solid var(--border); border-radius: 6px; background: var(--bg-raised); color: var(--text); font: inherit; }
.layer-filter__value { display: flex; flex: 1 1 140px; min-width: 0; }
.layer-filter__value > select, .layer-filter__name { flex: 1; min-width: 0; }
.layer-filter__kinds { display: flex; flex-wrap: wrap; gap: 4px; }
/* The kinds, a row of chips, take a line of their own under Filter by. */
.layer-filter__value:has(.layer-filter__kinds) { flex-basis: 100%; }
.layer-filter__by { flex: 0 0 auto; }
/* A group shown only for what it holds: dimmed, so the layers that match stand out. */
.layer.is-context { opacity: 0.55; }
.layer-list__none { padding: 12px 14px; color: var(--text-dim); font-size: 13px; }
.layer-surface span { color: var(--text-dim); font-size: 12px; }
.layer-surface select { flex: 1; }
.layer-props__opacity { flex: 1; display: flex; align-items: center; gap: 6px; min-width: 0; }
.layer-props__opacity input { flex: 1; min-width: 0; accent-color: var(--slider-fill); }
.layer-props__opacity output { width: 36px; text-align: right; color: var(--text-dim); font-variant-numeric: tabular-nums; }

.layer-list {
  position: relative;
  flex: 1;
  list-style: none;
  margin: 0;
  padding: 0 6px 8px;
  overflow-y: auto;
  touch-action: pan-y;
}
.layer {
  --depth: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  height: 44px;
  padding: 0 4px 0 calc(var(--depth) * 16px);
  border-radius: var(--radius);
  cursor: default;
}
.layer:hover { background: var(--bg-hover); }
.layer__undo { display: flex; flex: none; }
.layer__undo .icon-btn { width: 22px; }
.layer__undo .icon-btn:disabled { opacity: 0.3; }
.panel__actions .layer-redo { margin-right: 6px; }
.layer[aria-selected="true"] { background: var(--bg-selected); }
.layer.is-current { box-shadow: inset 3px 0 0 var(--accent); }
/* A layer's colour tag (row 170): the row pale with it, more so while chosen (row 156); a band behind the eye and down the row's edge. */
.layer[data-tag] { background: linear-gradient(to left, var(--layer-tag) 4px, color-mix(in srgb, var(--layer-tag) 14%, transparent) 4px); }
.layer[data-tag]:hover { background: linear-gradient(to left, var(--layer-tag) 4px, color-mix(in srgb, var(--layer-tag) 24%, var(--bg-hover)) 4px); }
.layer[data-tag][aria-selected="true"] { background: linear-gradient(to left, var(--layer-tag) 4px, color-mix(in srgb, var(--layer-tag) 40%, var(--bg-selected)) 4px); }
.layer[data-tag] [data-layer-action="visibility"] { background: var(--layer-tag); border-radius: 6px; }
.layer[data-tag="light"] [data-layer-action="visibility"] { color: #000; }
.layer[data-tag="dark"] [data-layer-action="visibility"] { color: #fff; }
.layer.is-hidden .layer__text, .layer.is-hidden .layer__thumb { opacity: 0.45; }
.layer.is-dragging { opacity: 0.4; }
.layer.is-clipped { padding-left: calc(var(--depth) * 16px + 12px); }
.layer__clip { color: var(--accent); }
.layer.is-drop-into { box-shadow: inset 0 0 0 2px var(--accent); }

.layer__twisty {
  flex: 0 0 18px;
  display: grid;
  place-items: center;
  width: 18px;
  height: 28px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--text-dim);
  cursor: pointer;
}
.layer__twisty svg { width: 14px; height: 14px; transition: transform 0.12s; }
.layer[aria-expanded="true"] .layer__twisty svg { transform: rotate(90deg); }

.layer__thumb {
  position: relative;
  flex: 0 0 40px;
  height: 30px;
  border-radius: 3px;
  overflow: hidden;
  /* Checkerboard behind transparent pixels. */
  background: repeating-conic-gradient(#c8c8c8 0 25%, #fff 0 50%) 0 0 / 8px 8px;
  box-shadow: 0 0 0 1px var(--border);
  touch-action: none;
  cursor: grab;
}
.layer__thumb canvas { display: block; width: 100%; height: 100%; }
.layer__mask {
  position: relative;
  flex: 0 0 40px;
  height: 30px;
  border-radius: 3px;
  overflow: hidden;
  box-shadow: 0 0 0 1px var(--border);
  cursor: pointer;
}
.layer__mask canvas { display: block; width: 100%; height: 100%; }
.layer__thumb--adjust { display: grid; place-items: center; background: var(--bg-raised); }
.layer__thumb--adjust canvas { display: none; }
.layer__adjust-icon { display: grid; width: 22px; height: 22px; }
.layer__adjust-icon svg { width: 100%; height: 100%; }
.layer-adjust { padding: 6px 12px 8px; border-bottom: 1px solid var(--border); }
.layer-adjust__title { margin: 0 0 4px; font-weight: 600; font-size: 13px; }
/* Paint on a 3D model: its texture layers, under the layer list's controls. */
.texture-layers__list { list-style: none; margin: 4px 0; padding: 0; max-height: 160px; overflow-y: auto; border: 1px solid var(--border); border-radius: 6px; }
.texture-layers__list:empty { display: none; }
.texture-layer { display: flex; align-items: center; gap: 6px; min-height: 30px; padding: 0 6px; font-size: 13px; cursor: pointer; }
.texture-layer[aria-selected="true"] { background: var(--accent-soft, rgba(80, 140, 255, 0.16)); }
.texture-layer.is-hidden .texture-layer__name { opacity: 0.5; }
.texture-layer__name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.texture-layer__chips { display: flex; gap: 2px; }
.texture-layer__chip { width: 16px; height: 16px; border-radius: 3px; font-size: 10px; line-height: 16px; text-align: center; color: var(--text-dim); border: 1px solid var(--border); }
.texture-layer__chip { padding: 0; background: none; cursor: pointer; }
.texture-layer__chip.is-on { color: var(--text); border-color: var(--accent); }
.texture-layer__chip.is-current { background: var(--accent); color: #fff; }
.texture-layers__note { margin: 4px 0; font-size: 12px; color: var(--text-dim); }
.texture-layers__buttons { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; align-items: center; }
.layer-adjust__row { display: grid; grid-template-columns: 76px minmax(0, 1fr) 44px; align-items: center; gap: 8px; min-height: 30px; font-size: 13px; }
.layer-adjust__row[hidden] { display: none; }
.layer-adjust__row input { min-width: 0; width: 100%; }
.layer-adjust__row select { min-width: 0; width: 100%; grid-column: span 2; }
.layer-adjust__row input[type="color"] { width: 44px; height: 26px; padding: 0; border: 1px solid var(--border); border-radius: 4px; background: none; }
.effects { width: 300px; max-height: calc(100vh / var(--ui-scale, 1) - 80px); overflow-y: auto; padding: 10px 12px; position: fixed; inset: auto; }
.effects__title { margin: 0 0 6px; font-weight: 600; }
.comps__hint { margin: 0 0 8px; font-size: 12px; color: var(--text-dim); }
.comps__list { list-style: none; margin: 0 0 8px; padding: 0; max-height: 50vh; overflow-y: auto; }
.comps__item { display: flex; align-items: center; gap: 6px; padding: 2px 4px; border-radius: 8px; }
.comps__item.is-current { background: var(--bg-selected); }
.comps__name { flex: 1; min-width: 0; height: 32px; padding: 0 6px; border: 0; background: none; color: inherit; font: inherit; text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: pointer; }
.comps__item.is-current .comps__name { font-weight: 600; }
/* Renaming keeps the row as it was: the field takes the name's place and no more (BUG-062). */
.comps__item .layer__rename { flex: 1; width: auto; min-width: 0; }
.snapshots__brush { display: grid; width: 20px; height: 20px; flex: none; }
.snapshots__brush svg { width: 100%; height: 100%; }
.snapshots__time { color: var(--text-dim); font-size: 12px; font-variant-numeric: tabular-nums; }
#snapshots-popover.popover { width: 360px; }
/* Its title is the window's: not repeated inside. */
.app-window__body > .window-host .precision__title { display: none; }
.effects__none { margin: 4px 0; color: var(--text-dim); }
/* A popover's box hosted in a working window (ui/windows.js, hostInWindow): it fills the window instead of keeping a popover's width. */
.app-window__body > .window-host { position: static; width: auto; max-width: none; max-height: none; overflow: visible; padding: 8px 12px 12px; }
.comps__empty { padding: 8px 4px; color: var(--text-dim); font-size: 13px; }
.comps__actions { display: flex; align-items: center; justify-content: flex-end; gap: 6px; }
.effects__kind { padding: 6px 0; border-top: 1px solid var(--border); }
.effects__kind:not(.is-on) .layer-adjust__row { opacity: 0.55; }
.effects__head { display: flex; align-items: center; gap: 8px; min-height: 30px; }
.effects__head label { display: flex; flex: 1; align-items: center; gap: 8px; }
.layer-adjust__curves { padding: 4px 0; }
.curves__tabs { display: flex; gap: 4px; margin-bottom: 6px; }
.curves__tab { flex: 1; min-height: 26px; border: 1px solid var(--border); border-radius: 4px; background: none; font-size: 12px; cursor: pointer; }
.curves__tab[aria-selected="true"] { border-color: var(--accent); background: var(--accent); color: var(--accent-text); }
.curves__canvas { display: block; width: 196px; height: 196px; max-width: 100%; aspect-ratio: 1; border: 1px solid var(--border); border-radius: 4px; touch-action: none; cursor: crosshair; }
.layer-adjust__row output { text-align: right; color: var(--text-dim); font-variant-numeric: tabular-nums; }
/* What the brush paints: the layer or its mask. */
.layer__thumb.is-target, .layer__mask.is-target { box-shadow: 0 0 0 2px var(--accent); }
/* A switched-off mask is crossed out in red. */
.layer__mask.is-off::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(to top right, transparent calc(50% - 1.5px), #e5484d calc(50% - 1.5px), #e5484d calc(50% + 1.5px), transparent calc(50% + 1.5px));
}
.layer__badge {
  position: absolute;
  right: 1px;
  bottom: 1px;
  display: grid;
  place-items: center;
  width: 16px;
  height: 16px;
  border-radius: 3px;
  background: var(--bg-panel);
}
.layer__badge svg { width: 14px; height: 14px; }

.layer__text { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.layer__name, .layer__meta { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.layer__meta { color: var(--text-dim); font-size: 12px; }
.layer__meta:empty { display: none; }
.layer__lock { color: var(--text-dim); }
.layer__rename {
  width: 100%;
  height: 26px;
  padding: 0 6px;
  border: 1px solid var(--accent);
  border-radius: 4px;
  background: var(--bg-raised);
  color: var(--text);
  font: inherit;
  -webkit-user-select: text;
  user-select: text;
}

.drop-indicator {
  --depth: 0;
  position: absolute;
  left: calc(6px + var(--depth) * 16px);
  right: 6px;
  height: 2px;
  border-radius: 1px;
  background: var(--accent);
  pointer-events: none;
}

.layer-actions {
  display: flex;
  justify-content: space-between;
  padding: 6px 10px;
  border-top: 1px solid var(--border);
}
.layer-actions [aria-pressed="true"] { color: var(--accent); }

.menu { padding: 6px; min-width: 210px; background: var(--part-menu-normal-fill, var(--bg-panel)); border-color: var(--part-menu-border, var(--border)); border-radius: var(--part-menu-radius, 12px); position: fixed; inset: auto; margin: 0; max-height: calc(100dvh / var(--ui-scale) - 16px); overflow-y: auto; }
.menu hr { border: 0; border-top: 1px solid var(--border); margin: 6px 0; }
.menu__check { display: none; width: 1.1em; flex: none; color: var(--accent); }
.menu--checks .menu__check { display: inline-block; }
.menu__label { flex: 1; text-align: left; }
/* A layer colour beside its name; empty, a ring (No colour). Never the theme's colours: the tag's own. */
.menu__swatch { flex: none; width: 12px; height: 12px; margin-right: -8px; border-radius: 3px; box-shadow: inset 0 0 0 1px var(--border); }
.menu__arrow { color: var(--text-dim); margin-left: 12px; }
.menu__heading { margin: 6px 10px 2px; font-size: 12px; color: var(--text-dim); }
.menu__item:focus-visible, .menu__item:focus { outline: none; background: var(--part-menu-hover-fill, var(--bg-hover)); color: var(--part-menu-hover-text, var(--part-menu-normal-text, var(--text))); }
.menu-hint { max-width: 280px; pointer-events: none; z-index: 1000; }
.menu__item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  width: 100%;
  height: 32px;
  padding: 0 10px;
  border: 0;
  border-radius: 6px;
  background: none;
  color: var(--part-menu-normal-text, var(--text));
  text-align: left;
  cursor: pointer;
}
.menu__item:hover:not(:disabled) { background: var(--part-menu-hover-fill, var(--bg-hover)); color: var(--part-menu-hover-text, var(--part-menu-normal-text, var(--text))); }
.menu__item:disabled { opacity: 0.4; cursor: default; }
.menu__item.is-danger, .menu__item.is-danger:hover, .menu__item.is-danger:focus { color: var(--fam-danger); }
.menu__item kbd { color: var(--text-dim); font: 12px system-ui, sans-serif; }

/* --- precision panel and symmetry guides ------------------------------------- */

.precision { position: fixed; inset: auto; width: 290px; max-height: calc(100dvh / var(--ui-scale) - 80px); overflow-y: auto; }
.precision__title { margin: 0 0 8px; font-size: 15px; font-weight: 600; }
.precision__section { border-top: 1px solid var(--border); padding: 6px 0; }
.precision__section > summary { padding: 4px 0; font-weight: 600; cursor: pointer; }
.precision__choices { display: flex; gap: 18px; padding: 4px 0 8px; }
.precision__choices label { display: flex; align-items: center; gap: 6px; }
.precision__field { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 36px; }
.precision__field select { min-width: 130px; }
.precision__field--range input[type="range"] { flex: 1; max-width: 150px; }
.precision__inside { padding-left: 14px; }
.precision__inside .precision__field { white-space: nowrap; }
.precision__inside .precision__field input[type="range"] { max-width: 110px; min-width: 0; }
.precision__inside .precision__field output { min-width: 5ch; }
.precision__field output { min-width: 3ch; text-align: right; color: var(--text-dim); font-variant-numeric: tabular-nums; }
.precision__number { display: flex; align-items: center; gap: 4px; color: var(--text-dim); }
.precision__number input { width: 72px; }
.precision__check { display: flex; align-items: center; gap: 8px; min-height: 36px; }
.precision__edit { width: 100%; justify-content: center; margin: 4px 0; }
.precision__edit[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.precision__colors { display: flex; gap: 8px; }
.precision__colors input[type="color"] { width: 34px; height: 30px; padding: 0; border: 1px solid var(--border); border-radius: 6px; background: none; }
.precision[data-grid-type="graph"] .precision__perspective,
.precision[data-grid-type="perspective"] .precision__graph { display: none; }
.precision[data-grid-type="graph"] [name="gridColor1"] { display: none; }
.switch-row, .switch-row__label { display: flex; justify-content: space-between; align-items: center; gap: 12px; min-height: 32px; }
.switch-row__label { flex: 1; }
input[type="range"] { accent-color: var(--slider-fill); }
/* A skin's scroll bar colours (both or neither: skin-parts.js); without them each property is unset and the browser's own show. */
* { scrollbar-color: var(--part-scrollbar-normal-thumb) var(--part-scrollbar-normal-track); }
/* Every tick box is a switch, as everywhere in the app (no browser checkboxes). */
.switch, input[type="checkbox"] {
  appearance: none;
  flex: none;
  position: relative;
  width: 34px;
  height: 20px;
  margin: 0;
  border-radius: 10px;
  background: var(--part-switch-off-fill, var(--border));
  cursor: pointer;
  transition: background 0.15s;
}
.switch::after, input[type="checkbox"]::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--part-switch-off-knob, #fff);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
  transition: translate 0.15s;
}
.switch:checked, input[type="checkbox"]:checked { background: var(--part-switch-on-fill, var(--accent)); }
.switch:checked::after, input[type="checkbox"]:checked::after { translate: 14px 0; background: var(--part-switch-on-knob, #fff); }
input[type="checkbox"]:disabled { opacity: 0.45; cursor: default; }
input[type="checkbox"]:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
/* Number boxes: the browser's spin arrows hidden, the app's own − and + beside them (ui/number-steps.js). */
input[type="number"] { appearance: textfield; -moz-appearance: textfield; }
input[type="number"]::-webkit-inner-spin-button, input[type="number"]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.number-steps { display: inline-flex; align-items: stretch; gap: 2px; }
.number-steps__btn { flex: none; min-width: 28px; padding: 0 6px; border: 1px solid var(--border); border-radius: 6px; background: var(--bg-raised); color: var(--text); font: inherit; font-size: 16px; line-height: 1; cursor: pointer; }
.number-steps__btn:hover { background: var(--bg-hover); }
.number-steps input[type="number"] { text-align: center; }
.symmetry-presets { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.symmetry-presets__tile {
  aspect-ratio: 1;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: none;
  color: var(--text);
  cursor: pointer;
}
.symmetry-presets__tile:hover { background: var(--bg-hover); }
.symmetry-presets__tile[aria-checked="true"] { background: var(--accent); border-color: var(--accent); color: #fff; }
.symmetry-presets__tile svg { width: 100%; height: 100%; display: block; overflow: hidden; }
.symmetry-presets__guides { stroke: currentColor; stroke-width: 0.5; opacity: 0.35; }
.symmetry-presets__motif { fill: none; stroke: currentColor; stroke-width: 1.1; stroke-linecap: round; stroke-linejoin: round; }

.symmetry-handle {
  position: absolute;
  left: -9px;
  top: -9px;
  width: 18px;
  height: 18px;
  padding: 0;
  border: 2px solid #fff;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.45);
  cursor: move;
  touch-action: none;
}
.symmetry-handle--rotate { width: 14px; height: 14px; left: -7px; top: -7px; cursor: grab; }
.symmetry-handle[hidden] { display: none; }
.vanishing-handle {
  position: absolute;
  left: -11px;
  top: -11px;
  width: 22px;
  height: 22px;
  padding: 0;
  border: 3px solid #fff;
  border-radius: 50% 50% 50% 0;
  rotate: -45deg;
  background: var(--c, var(--accent));
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.5);
  cursor: move;
  touch-action: none;
}
.vanishing-handle--set { width: 16px; height: 16px; left: -8px; top: -8px; border-radius: 3px; rotate: 45deg; background: #fff; border-color: #333; }
.vanishing-handle[hidden] { display: none; }
.ruler-handle {
  position: absolute;
  left: -9px;
  top: -9px;
  width: 18px;
  height: 18px;
  padding: 0;
  border: 2px solid #fff;
  border-radius: 50%;
  background: #7a4fe0;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.5);
  cursor: move;
  touch-action: none;
}
.ruler-handle--turn, .ruler-handle--major, .ruler-handle--minor, .ruler-handle--size { width: 14px; height: 14px; left: -7px; top: -7px; background: #fff; border-color: #7a4fe0; cursor: grab; }
/* The blower on its stand (ui/blower-stand.js): its nozzle moves it, its arrow's end turns and sizes it, × stops it. */
.blower-handle--turn { width: 14px; height: 14px; left: -7px; top: -7px; background: #fff; border-color: #7a4fe0; cursor: grab; }
.blower-handle--stop { width: 22px; height: 22px; left: -11px; top: -11px; background: var(--bg-panel); border-color: var(--border); color: var(--text); font-size: 15px; line-height: 1; cursor: pointer; }
.blower-handle[hidden] { display: none; }
.curve-handle--anchor { width: 12px; height: 12px; left: -6px; top: -6px; }
.curve-handle--width { width: 10px; height: 10px; left: -5px; top: -5px; border-radius: 2px; background: #fff; border-color: #7a4fe0; cursor: grab; }
.curve-edit-bar { position: absolute; bottom: 12px; left: 16px; right: 16px; margin-inline: auto; width: fit-content; z-index: 5; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 6px 8px 6px 12px; border-radius: 8px; background: var(--bg-panel); border: 1px solid var(--border); box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25); zoom: var(--ui-scale); font-size: 13px; }
.curve-edit-bar[hidden] { display: none; }
.curve-edit-bar .button[aria-pressed="true"] { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 18%, var(--bg-panel)); }
.rulers__add { display: flex; flex-wrap: wrap; gap: 6px; padding: 4px 0 8px; }
.rulers__list { margin: 4px 0; padding: 0; list-style: none; }
.rulers__list li { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.rulers__list .switch-row { flex: 1; }
.rulers__sides { width: 52px; }
/* A French curve's shape and Flip, and Keep on a curve ruler, on a line of their own. */
.rulers__french { display: flex; gap: 6px; flex-basis: 100%; padding-left: 4px; }
.rulers__french select { flex: 1; min-width: 0; }
.rulers__flip[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); }

/* --- context bar ------------------------------------------------------------ */

.context-bar {
  position: absolute;
  /* Above the hotbars (50): moved anywhere, it may land on one and must still be reached; floating panels and windows (55 up, ui/panel-depth.js) stay above it. */
  z-index: 52;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  display: flex;
  gap: 4px;
  max-width: calc(100% - 24px);
  padding: 5px;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 22px;
  background: var(--bg-panel);
  box-shadow: 0 6px 22px rgba(0, 0, 0, 0.3);
}
.context-bar[hidden] { display: none; }
/* Its own actions, beside the grip and the turn button (ui/context-bar.js). */
.context-bar__actions { display: flex; gap: 4px; }
.context-bar__grip, .context-bar__turn { flex: none; display: grid; place-items: center; width: 28px; height: 32px; padding: 0; border: 0; border-radius: 16px; background: transparent; color: var(--text-dim); cursor: pointer; }
.context-bar__grip { cursor: grab; }
.context-bar__grip:hover, .context-bar__turn:hover { background: var(--bg-hover); color: var(--text); }
.context-bar__grip svg, .context-bar__turn svg { width: 16px; height: 16px; }
.context-bar.is-dragging { cursor: grabbing; opacity: 0.85; }
.context-bar.is-dragging .context-bar__grip { cursor: grabbing; }
/* Rulers along the canvas's edges (ui/edge-rulers.js), over the picture's top and left. */
.edge-ruler { position: absolute; top: 0; left: 0; z-index: 2; cursor: default; touch-action: none; }
.edge-ruler[hidden], .edge-ruler__corner[hidden] { display: none; }
.edge-ruler--top { border-bottom: 1px solid var(--border); }
.edge-ruler--left { border-right: 1px solid var(--border); }
.edge-ruler__corner { position: absolute; top: 0; left: 0; z-index: 3; width: 20px; height: 20px; background: var(--bg-panel); border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); }
/* A flat texture's document: what it is, and the way back to the model. */
.flat-bar {
  position: absolute;
  right: 12px;
  bottom: 12px;
  zoom: var(--ui-scale);
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: calc(100% - 24px);
  padding: 5px 5px 5px 14px;
  border: 1px solid var(--border);
  border-radius: 22px;
  background: var(--bg-panel);
  box-shadow: 0 6px 22px rgba(0, 0, 0, 0.3);
  font-size: 13px;
}
.context-bar__btn {
  flex: none;
  height: 32px;
  padding: 0 14px;
  border: 0;
  border-radius: 16px;
  background: transparent;
  white-space: nowrap;
  cursor: pointer;
}
.context-bar__btn:hover:not(:disabled) { background: var(--bg-hover); }
.context-bar__btn:disabled { opacity: 0.4; cursor: default; }
.context-bar__btn.is-primary { background: var(--accent); color: var(--accent-text); }
.context-bar__btn[aria-pressed="true"] { box-shadow: inset 0 0 0 1.5px var(--accent); color: var(--accent); }

/* --- status bar and toast -------------------------------------------------- */

.statusbar {
  grid-area: status;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 14px;
  font-size: 12px;
  color: var(--text-dim);
  background: var(--bg-panel);
  border-top: 1px solid var(--border);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
}
#status-position { margin-left: auto; }
/* The stance engaged (ui/stance-status.js): marked, so it's seen. */
.statusbar__stance { margin-left: 12px; padding: 0 8px; border-radius: 8px; background: color-mix(in srgb, var(--accent) 22%, transparent); color: var(--text); }
.statusbar__stance[hidden] { display: none; }

.toast {
  position: fixed;
  /* Above hotbars and every floating panel (ui/panel-depth.js: 55 up). */
  z-index: 95;
  left: 50%;
  bottom: calc(var(--status-h) + 76px);
  transform: translate(-50%, 8px);
  padding: 8px 14px;
  border-radius: 18px;
  background: var(--toast-bg);
  color: #fff;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s, transform 0.15s;
}
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }

/* --- dialogs ------------------------------------------------------------------ */

.dialog {
  width: min(420px, calc(100vw - 32px));
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--bg-panel);
  color: var(--text);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4);
}
.dialog--wide { width: min(760px, calc(100vw - 32px)); max-height: calc(100dvh / var(--ui-scale) - 48px); }
.dialog--wide .legend { max-height: calc(100dvh / var(--ui-scale) - 240px); overflow-y: auto; }
.dialog--wide .legend:focus { outline: none; }
.keys__set { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 8px; }
.keys__set [hidden] { display: none; }
.keys__set label { display: flex; align-items: center; gap: 8px; min-width: 0; }
.keys__set select { min-width: 0; max-width: 100%; height: var(--control-h); padding: 0 8px; border: 1px solid var(--border); border-radius: 6px; background: var(--bg-raised); color: var(--text); font: inherit; }
.keys__search { width: 100%; height: 34px; margin-bottom: 4px; padding: 0 10px; border: 1px solid var(--border); border-radius: 6px; background: var(--bg-raised); color: var(--text); font: inherit; -webkit-user-select: text; user-select: text; }
.keys__list { max-height: calc(100dvh / var(--ui-scale) - 300px); overflow-y: auto; }
.keys__row { display: grid; grid-template-columns: 1fr 170px 170px; align-items: center; gap: 8px; min-height: 36px; }
.keys__row:hover { background: var(--bg-hover); border-radius: 6px; }
.keys__label { padding-left: 6px; }
.keys__cell { display: flex; align-items: center; gap: 2px; }
.keys__key { flex: 1; height: 30px; border: 1px solid var(--border); border-radius: 6px; background: var(--bg-raised); cursor: pointer; font-variant-numeric: tabular-nums; }
.keys__key.is-empty { color: var(--text-dim); }
.keys__key.is-capturing { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }
.keys__clear { width: 24px; height: 30px; border: 0; background: none; color: var(--text-dim); cursor: pointer; font-size: 16px; }
.keys__clear:disabled { visibility: hidden; }
.keys__status { min-height: 20px; margin: 8px 0 0; color: var(--text-dim); }
.keys__spacer { flex: 1; }
.legend__heading { margin: 16px 0 8px; font-size: 13px; color: var(--text-dim); }
.legend__grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 6px 16px; }
.legend__item { display: flex; align-items: center; gap: 10px; min-height: 36px; }
.legend__item svg { flex: none; width: 30px; height: 30px; }
.dialog::backdrop { background: rgba(0, 0, 0, 0.35); }
/* The app's own message, question and text boxes (ui/ask.js). */
.dialog.dialog--ask { width: min(380px, calc(100vw - 32px)); }
.ask__message { margin: 0; line-height: 1.45; white-space: pre-line; overflow-wrap: anywhere; }
.ask__field { width: 100%; height: 34px; margin-top: 12px; padding: 0 10px; border: 1px solid var(--border); border-radius: 6px; background: var(--bg-raised); color: var(--text); font: inherit; -webkit-user-select: text; user-select: text; }
.dialog--ask .dialog__actions { flex-wrap: wrap; }
.dialog__title { margin: 0 0 6px; font-size: 16px; }
.dialog__note { margin: 0 0 16px; color: var(--text-dim); }
/* What Canvas size would take away (ui/dialogs.js): said before it's done. */
.dialog__losses { margin: 12px 0 0; color: var(--danger); }
.dialog__losses[hidden] { display: none; }
.dialog__row { display: flex; flex-wrap: wrap; gap: 12px; }
.dialog__row label, .dialog__field { display: flex; align-items: center; gap: 8px; }
.dialog__field { justify-content: space-between; margin-bottom: 14px; }
.dialog input[type="number"], .dialog select {
  height: 32px;
  padding: 0 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-raised);
  color: var(--text);
  font: inherit;
}
.dialog input[type="number"] { width: 90px; -webkit-user-select: text; user-select: text; }
.dialog__check { display: flex; align-items: center; gap: 8px; margin: 14px 0; }
.dialog__actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.button.is-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); border-image: none; }
.anchor { margin: 0; padding: 0; border: 0; }
.anchor legend { margin-bottom: 8px; color: var(--text-dim); }
.anchor__grid { display: grid; grid-template-columns: repeat(3, 28px); gap: 4px; }
.anchor__grid input {
  width: 28px;
  height: 28px;
  margin: 0;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg-raised);
  appearance: none;
  cursor: pointer;
}
.anchor__grid input:checked { background: var(--accent); border-color: var(--accent); }

.link-btn {
  margin: 2px 0 6px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--accent);
  cursor: pointer;
}
.link-btn:disabled { color: var(--text-dim); opacity: 0.6; cursor: default; }
.preset__edited { display: inline-block; width: 6px; height: 6px; margin-left: 6px; border-radius: 50%; background: var(--accent); vertical-align: middle; }
.preset__edited[hidden] { display: none; }

/* --- home screen ------------------------------------------------------------- */

.home {
  height: calc(100dvh / var(--ui-scale));
  overflow-y: auto;
  padding: 0 max(16px, env(safe-area-inset-left)) 48px;
  touch-action: pan-y;
}
.home.is-dropping { outline: 3px dashed var(--accent); outline-offset: -8px; }
.home__section { max-width: 1200px; margin: 24px auto 0; }
/* A rule above each place documents live (and the server's own facts), so they read as separate. */
#home-libraries > .home__section { padding-top: 24px; border-top: 1px solid var(--border); }
.home-footer { max-width: 1200px; margin: 48px auto 0; padding: 24px 0 8px; border-top: 1px solid var(--border); display: flex; flex-wrap: wrap; gap: 24px 48px; font-size: 13px; color: var(--text-dim); }
.home-footer__made { flex: 1 1 260px; }
.home-footer__made strong { color: var(--text); }
.home-footer__made p { margin: 4px 0 0; }
.home-footer__links { display: flex; flex-direction: column; gap: 8px; min-width: 140px; }
.home-footer__links h2 { margin: 0 0 4px; font-size: 13px; color: var(--text); }
.home-footer__links a { color: inherit; text-decoration: none; }
.home-footer__links a:hover { color: var(--text); text-decoration: underline; }
.home__presets { display: grid; grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); gap: 10px; }
.preset-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 14px 8px 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg-panel);
  cursor: pointer;
  position: relative;
}
.preset-card:hover { border-color: var(--accent); }
.preset-card__shape { display: block; min-height: 8px; margin: 0 0 4px; border: 2px solid var(--text-dim); border-radius: 3px; background: var(--bg-raised); }
.preset-card__label { font-weight: 600; }
.preset-card__size { color: var(--text-dim); font-size: 13px; font-variant-numeric: tabular-nums; }
.home__custom { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 12px; color: var(--text-dim); }
.home__custom label { display: flex; align-items: center; gap: 6px; }
.home__custom label[hidden] { display: none; }
.home__custom input {
  width: 84px;
  height: 32px;
  padding: 0 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-raised);
  color: var(--text);
  font: inherit;
  -webkit-user-select: text;
  user-select: text;
}
/* A button's own display would otherwise outrank the hidden attribute: hidden means not there. */
.button[hidden] { display: none; }
.button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 34px;
  padding: 0 14px;
  /* A skin's button (js/skin-parts.js): each state's fill, border and words, else the app's own. */
  border: 1px solid var(--part-button-normal-border, var(--border));
  border-radius: var(--part-button-radius, 17px);
  background: var(--part-button-normal-fill, var(--bg-raised));
  color: var(--part-button-normal-text, inherit);
  border-image: var(--part-button-normal-image, none);
  font: inherit;
  text-decoration: none;
  cursor: pointer;
}
/* In a panel, a working window (docked or floating) or a popover every button is the same size. */
.panel .button, .app-window .button, .popover .button { height: var(--control-h); padding: 0 10px; font-size: 13px; }
.button:hover { border-color: var(--part-button-hover-border, var(--accent)); }
/* Primary and danger buttons keep the app's look: the main choice and the dangerous one always told apart. */
.button:not(.is-primary, .is-danger):hover:not(:disabled) { background: var(--part-button-hover-fill, var(--part-button-normal-fill, var(--bg-raised))); color: var(--part-button-hover-text, var(--part-button-normal-text, inherit)); border-image: var(--part-button-hover-image, var(--part-button-normal-image, none)); }
.button:not(.is-primary, .is-danger):active:not(:disabled) { background: var(--part-button-pressed-fill, var(--part-button-hover-fill, var(--part-button-normal-fill, var(--bg-raised)))); border-color: var(--part-button-pressed-border, var(--part-button-hover-border, var(--accent))); color: var(--part-button-pressed-text, var(--part-button-hover-text, var(--part-button-normal-text, inherit))); border-image: var(--part-button-pressed-image, var(--part-button-hover-image, var(--part-button-normal-image, none))); }
.button:disabled { opacity: 0.45; cursor: default; }
.button:disabled:hover { border-color: var(--part-button-normal-border, var(--border)); }
.button [data-icon] { display: inline-grid; }
.button svg { width: 18px; height: 18px; }
/* Cards on every page (card() in ui/page.js): the picture 4:3, then the name, facts, a badge and the card's buttons; as many across as fit. */
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; margin: 0; padding: 0; list-style: none; }
.card-grid--small { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }
.card { overflow: hidden; border: 1px solid var(--border); border-radius: 12px; background: var(--bg-panel); }
.card__picture { display: grid; place-items: center; aspect-ratio: 4 / 3; padding: 10px; background: var(--workspace); }
.card__picture img { max-width: 100%; max-height: 100%; box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3); }
.card__info { display: flex; align-items: center; gap: 2px; padding: 8px 6px 8px 12px; }
.card__text { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.card__name { font-weight: 600; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.card__facts { color: var(--text-dim); font-size: 13px; }
.card__badge { color: var(--accent); font-size: 12px; }
.card__actions { display: flex; flex-shrink: 0; gap: 2px; }
/* Buttons with words (the admin Showcase's Accept, Reject, Remove) go on a row of their own, under the name. */
.card__actions:has(.button) { flex-basis: 100%; flex-shrink: 1; flex-wrap: wrap; gap: 6px; padding-top: 6px; }
.card__info:has(.button) { flex-wrap: wrap; }
/* Icons on a line of their own (the documents' cards): left to right, spaced, ⋯ at the far end. */
.card--actions-row .card__info { flex-direction: column; align-items: stretch; padding-right: 8px; }
.card--actions-row .card__actions { gap: 8px; padding-top: 6px; margin-left: -6px; }
.card--actions-row .card__actions [data-card="more"] { margin-left: auto; }
/* A picture alone (the showcase on the home screen): it fills the card, and grows a little under the pointer. */
.card--picture .card__picture { display: block; padding: 0; background: var(--bg-raised); }
.card--picture .card__picture img { display: block; width: 100%; height: auto; max-height: none; aspect-ratio: 4 / 3; object-fit: cover; box-shadow: none; transition: transform 0.2s; }
.card--picture .card__picture:hover img, .card--picture .card__picture:focus-visible img { transform: scale(1.03); }
.home__status {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  padding: 8px 14px;
  border-radius: 18px;
  background: var(--toast-bg);
  color: #fff;
}

/* --- small screens --------------------------------------------------------- */

@media (max-width: 760px) {
  :root { --panels-w: 220px; }
  .dock-grip, .toolbar-grip { display: none; }
}

/* --- accounts (ui/account.js) ---------------------------------------------- */

.signin { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px; }
.signin label { display: flex; flex-direction: column; gap: 4px; color: var(--text-dim); font-size: 13px; }
.signin input {
  width: 200px;
  height: 34px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-raised);
  color: var(--text);
  font: inherit;
  font-size: 15px;
  -webkit-user-select: text;
  user-select: text;
}
.signin input[name="code"] { width: 140px; font-variant-numeric: tabular-nums; letter-spacing: 0.08em; }
.signin__error { flex-basis: 100%; margin: 0; color: var(--fam-danger); font-weight: 600; }
.signin__note { flex-basis: 100%; margin: 4px 0 0; }
.dialog--signup .signin__error { margin: 8px 0 0; }
.code-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  margin: 8px 0 14px;
  padding: 20px;
  border: 2px dashed var(--border);
  border-radius: 12px;
}
.code-card__user { color: var(--text-dim); font-size: 16px; }
.code-card__code { font: 600 36px ui-monospace, monospace; letter-spacing: 0.06em; font-variant-numeric: tabular-nums; -webkit-user-select: all; user-select: all; }
.code-card__keep { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: 12px 0 4px; }
.account__section { padding: 12px 0; border-top: 1px solid var(--border); }
.account__section:first-of-type { border-top: 0; }
.account__section h3 { margin: 0 0 6px; font-size: 13px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.04em; }
.account__buttons { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.account__meter { height: 8px; border-radius: 4px; background: var(--bg-raised); overflow: hidden; }
.account__meter span { display: block; height: 100%; background: var(--accent); }
.account__qr { margin-top: 10px; }
.account__qr svg { display: block; width: 220px; height: 220px; border-radius: 8px; }
.account__qr code, .account__invite code { word-break: break-all; -webkit-user-select: all; user-select: all; }
.account__devices { margin: 0; padding: 0; list-style: none; }
.account__devices li { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 6px 0; }
.account__devices .dialog__note { margin: 0; }
.dialog--account { overflow-y: auto; }
.dialog--versions { width: min(560px, calc(100vw - 32px)); }
/* Where your space went (ui/storage-chart.js): a bar per document, its file and its earlier versions, largest first. */
.dialog--storage { width: min(640px, calc(100vw - 32px)); }
.storage { --storage-current: var(--accent); --storage-earlier: color-mix(in srgb, var(--accent) 45%, var(--bg-panel)); max-height: calc(100dvh / var(--ui-scale) - 220px); overflow-y: auto; margin-bottom: 8px; }
.storage__meter-words { margin: 0 0 6px; }
.storage__meter { display: block; height: 10px; border-radius: 5px; background: var(--bg-raised); border: 1px solid var(--border); overflow: hidden; }
.storage__meter > span { display: block; min-width: 3px; height: 100%; background: var(--storage-current); border-radius: 4px; }
.storage__legend { display: flex; align-items: center; gap: 6px; margin: 10px 0 4px; color: var(--text-dim); font-size: 12px; }
.storage__key { width: 12px; height: 12px; border-radius: 3px; flex: none; }
.storage__key + .storage__key, .storage__legend .storage__key:not(:first-child) { margin-left: 10px; }
.storage__key--current { background: var(--storage-current); }
.storage__key--earlier { background: var(--storage-earlier); }
.storage__heading { margin: 14px 0 4px; font-size: 12px; font-weight: 600; color: var(--text-dim); }
.storage__list, .storage__versions { margin: 0; padding: 0; list-style: none; }
.storage__row, .storage__version { display: grid; grid-template-columns: minmax(0, 1fr) minmax(80px, 2fr) 64px; align-items: center; gap: 10px; width: 100%; padding: 5px 4px; border: 0; border-radius: 6px; background: none; color: var(--text); font: inherit; text-align: left; }
.storage__row { cursor: pointer; }
.storage__row:disabled { cursor: default; opacity: 1; }
.storage__row:hover:not(:disabled) { background: var(--bg-hover); }
.storage__note { grid-column: 1 / -1; margin-top: -2px; color: var(--text-dim); font-size: 11px; }
.storage__version { color: var(--text-dim); font-size: 12px; }
.storage__versions .storage__version { grid-template-columns: minmax(0, 1fr) minmax(80px, 2fr) 64px auto; }
.storage__delete { padding: 2px 8px; font-size: 11px; }
.storage__all { display: flex; justify-content: flex-end; padding: 2px 4px; }
/* Indented by its words alone, so its bar starts where its document's does. */
.storage__versions .storage__name { padding-left: 16px; }
.storage__name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.storage__size { text-align: right; font-variant-numeric: tabular-nums; }
/* The bar's parts side by side, the surface showing between them; each end rounded. */
.storage__bar { display: flex; gap: 2px; height: 12px; }
.storage__bar > span { min-width: 2px; height: 100%; border-radius: 4px; }
.storage__current { background: var(--storage-current); }
.storage__earlier { background: var(--storage-earlier); }
.versions { max-height: calc(100dvh / var(--ui-scale) - 240px); margin: 0 0 8px; padding: 0; overflow-y: auto; list-style: none; }
.versions li { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 0; border-top: 1px solid var(--border); }
.versions li:first-child { border-top: 0; }
.versions .dialog__note { margin: 0; }
/* An earlier version's small picture, its time beside it; the larger one shows beside it on hover or a tap. */
.versions li > span:nth-child(2) { flex: 1; min-width: 0; }
.versions__thumb { position: relative; display: grid; place-items: center; flex: none; width: 48px; height: 48px; border-radius: 6px; background: var(--workspace); cursor: zoom-in; }
.versions__thumb[hidden] { display: none; }
.versions__thumb > img:first-child { max-width: 100%; max-height: 100%; }
.versions__peek { position: fixed; z-index: 2; max-width: 240px; max-height: 240px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg-raised); box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3); pointer-events: none; }
.versions__peek[hidden] { display: none; }
.versions__buttons { display: flex; gap: 6px; flex-shrink: 0; }

/* Second view (ui/second-view.js) */
.second-view { display: grid; place-items: center; padding: 4px; }
.second-view__canvas { display: block; border-radius: 4px; background: var(--workspace); cursor: grab; touch-action: none; }

/* Navigator (ui/navigator.js) */
.navigator { display: grid; place-items: center; padding: 4px; }
.navigator__canvas { display: block; border-radius: 4px; background: repeating-conic-gradient(var(--bg-raised) 0 25%, var(--bg-panel) 0 50%) 0 0 / 12px 12px; cursor: crosshair; touch-action: none; }
/* The Info piece: label and value rows, numbers in step. */
.info { display: grid; gap: 3px; min-width: 210px; padding: 4px 6px; font-size: 12px; }
.info__row { display: flex; justify-content: space-between; gap: 12px; }
.info__label { color: var(--text-dim); }
.info__value { display: inline-flex; align-items: center; gap: 6px; font-variant-numeric: tabular-nums; white-space: pre; }
.info__swatch { width: 12px; height: 12px; border-radius: 3px; border: 1px solid var(--border); }
/* The level piece: a dish the ball rolls in, which way the paper slopes. */
.level { display: grid; justify-items: center; gap: 6px; padding: 4px; }
.level__dish { display: block; border-radius: 50%; background: var(--bg-raised); cursor: crosshair; touch-action: none; }
.level__foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; width: 100%; font-size: 12px; }

/* Reference images (ui/reference.js) */
.reference { display: grid; gap: 6px; padding: 4px; }
.reference__view { display: block; border-radius: 4px; background: var(--bg-raised); cursor: crosshair; touch-action: none; }
.reference__empty { display: none; margin: 0; max-width: 260px; font-size: 12px; color: var(--text-dim); }
.reference.is-empty .reference__view { height: 60px !important; }
.reference.is-empty .reference__empty { display: block; }
.reference__bar { display: flex; align-items: center; gap: 2px; }
.reference__name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; color: var(--text-dim); }

/* Folding groups of tool settings (Tip, Dynamics) */
.field-group { border-top: 1px solid var(--border); margin-top: 6px; }
.field-group > summary { padding: 8px 0 4px; font-size: 13px; font-weight: 600; color: var(--text-dim); cursor: pointer; list-style-position: inside; }

/* The brush editor bar and popover (ui/brush-editor.js) */
.brush-editor { display: grid; gap: 6px; margin: 4px 0 8px; }
.brush-editor__tags { display: flex; flex-wrap: wrap; gap: 4px; }
/* A chip, wherever it is (brush tags, preset filters, the home screen's collections): pressed shows it's on. */
.chip { height: 24px; padding: 0 10px; border: 1px solid var(--border); border-radius: 12px; background: none; color: var(--text); font: inherit; font-size: 12px; cursor: pointer; }
.chip.is-on, .chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.brush-editor__actions { display: flex; flex-wrap: wrap; gap: 2px 10px; }
.brush-editor__actions .link-btn:disabled { opacity: 0.4; }
.brush-edit { width: 300px; position: fixed; inset: auto; }
.brush-edit__row { display: grid; grid-template-columns: 56px 1fr; align-items: center; gap: 8px; margin-bottom: 8px; font-size: 13px; }
.brush-edit__row input { height: 30px; padding: 0 8px; border: 1px solid var(--border); border-radius: 6px; background: var(--bg-raised); color: var(--text); font: inherit; }

/* Page layouts (ui/page-layouts.js) */
.page-layouts { width: 360px; max-height: calc(100vh / var(--ui-scale, 1) - 80px); overflow-y: auto; position: fixed; inset: auto; }
.page-layouts__grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-bottom: 6px; }
.page-layouts__item { position: relative; }
.page-layouts__item .icon-btn { position: absolute; top: 0; right: 0; }
.page-layouts__tile { display: grid; justify-items: center; gap: 3px; width: 100%; padding: 6px 2px; border: 1px solid var(--border); border-radius: 8px; background: none; color: var(--text); font: inherit; font-size: 11px; line-height: 1.2; cursor: pointer; }
.page-layouts__tile:hover { border-color: var(--accent); }
.page-layouts__grid .comps__empty { grid-column: 1 / -1; }
.page-layouts__set > summary { cursor: pointer; list-style-position: inside; }
.page-layouts__item.is-other-shape .page-layouts__tile { border-style: dashed; }
.page-layouts__item.is-other-shape .page-layouts__tile svg { opacity: 0.6; }
.page-layouts__own { margin: 4px 0; }
.page-layouts__path { stroke: var(--accent); fill: var(--accent); stroke-width: 1; opacity: 0.75; }

/* Properties: a row of command buttons (text styles). */
.field--buttons { display: flex; flex-wrap: wrap; gap: 6px; }
.field--note { display: grid; gap: 6px; }

/* Typing text over the canvas (tools/text.js): set like the text, no box of its own. */
.text-editor {
  position: fixed;
  z-index: 30;
  margin: 0;
  padding: 0;
  border: 1px dashed var(--accent);
  background: transparent;
  color: inherit;
  resize: none;
  overflow: hidden;
  outline: none;
  white-space: pre-wrap;
}

/* Home: your own sizes, the sort menu, collections. */
.preset-card__remove { position: absolute; top: 4px; right: 6px; width: 18px; height: 18px; border-radius: 50%; color: var(--text-dim); line-height: 18px; text-align: center; }
.preset-card__remove:hover { background: var(--bg-hover); color: var(--fam-danger); }
.preset-card__rename { position: absolute; top: 4px; right: 26px; display: grid; place-items: center; width: 18px; height: 18px; border-radius: 50%; color: var(--text-dim); }
.preset-card__rename svg { width: 14px; height: 14px; }
.preset-card__rename:hover { background: var(--bg-hover); color: var(--text); }
.preset-card__turn { position: absolute; top: 4px; left: 6px; display: grid; place-items: center; width: 18px; height: 18px; border-radius: 50%; color: var(--text-dim); }
.preset-card__turn svg { width: 14px; height: 14px; }
.preset-card__turn:hover { background: var(--bg-hover); color: var(--text); }
.preset-card__turn.is-on { color: var(--accent); }
.home__sizes-none { grid-column: 1 / -1; margin: 8px 0; color: var(--text-dim); }
.home__chips, .home__size-filters { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 10px; }
.doc-card.is-chosen { outline: 3px solid var(--accent); outline-offset: 2px; }
.home__chosen { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); display: flex; align-items: center; gap: 10px; padding: 8px 12px; border: 1px solid var(--border); border-radius: 12px; background: var(--bg-panel); box-shadow: 0 6px 24px rgba(0, 0, 0, 0.25); }
.home__chosen[hidden] { display: none; }
.home__chosen { flex-wrap: wrap; justify-content: center; max-width: calc(100vw - 32px); }
/* A press and hold on a card's picture chooses it (ui/home-choose.js): not the phone's own link menu or text selection. */
.doc-card .card__picture { -webkit-touch-callout: none; user-select: none; }
/* A picture in a linked folder (ui/home-sections.js): not a document yet, so dashed and drawn back, with Import and Delete only. */
.doc-card--import { border-style: dashed; }
.doc-card--import .card__picture { position: relative; cursor: default; }
.doc-card--import .card__picture img { opacity: 0.7; filter: grayscale(0.35); }
.doc-card--import .card__badge { color: var(--text-dim); }
/* Imported on this device: a thin bar along the foot of the picture, green, or amber when the file has changed since. */
.doc-card[data-imported] .card__picture::after { content: ''; position: absolute; left: 0; right: 0; bottom: 0; height: 4px; background: var(--fam-select); }
.doc-card[data-imported="changed"] .card__picture::after { background: var(--fam-move); }
.doc-card[data-imported="imported"] .card__badge { color: var(--fam-select); }
.doc-card[data-imported="changed"] .card__badge { color: var(--fam-move); }

/* --- macros and layouts windows (ui/routines.js) --------------------------- */

.menu__note { max-width: 260px; margin: 2px 10px 6px; font-size: 12px; color: var(--text-dim); }
.routines li.routine { display: block; }
.routine__head { display: flex; align-items: center; gap: 6px; }
.routine__name { flex: 1; min-width: 0; padding: 4px 6px; font: inherit; border: 1px solid var(--border); border-radius: 6px; background: var(--bg); color: var(--text); }
.routine__steps { margin: 6px 0; padding-left: 22px; }
.routine__steps li { display: flex; align-items: center; gap: 4px; padding: 2px 0; border: 0; }
.routine__steps li span { flex: 1; }
.routine__steps .button { min-width: 0; padding: 0 6px; height: 24px; }
.routine__add { width: 100%; }
.routines__extra { flex: 1; }

/* --- canvas projection window (ui/projection.js) --------------------------- */

body.projection { margin: 0; overflow: hidden; background: var(--workspace); color: var(--text); font: 14px/1.4 system-ui, sans-serif; }
body.projection .projection__view { position: fixed; inset: 0; }
.projection__corner { position: fixed; right: 12px; bottom: 12px; display: flex; gap: 6px; opacity: 0; transition: opacity 0.2s; }
.projection__corner button { padding: 4px 10px; border: 0; border-radius: 6px; background: rgba(0, 0, 0, 0.45); color: #fff; font: inherit; font-size: 12px; cursor: pointer; }
body.projection:hover .projection__corner { opacity: 1; }
.projection__note { margin: 40vh auto 0; max-width: 420px; text-align: center; color: var(--text-dim); }

/* --- Help and the guide (ui/help.js) ---------------------------------------- */

.dialog.dialog--help { width: min(980px, calc(100vw - 32px)); height: min(760px, calc(100dvh / var(--ui-scale) - 48px)); padding: 0; display: flex; flex-direction: column; }
.dialog--help:not([open]) { display: none; }
.help__bar { display: flex; align-items: center; gap: 12px; padding: 10px 12px 10px 18px; border-bottom: 1px solid var(--border); }
.help__bar h2 { font-size: 15px; }
.help__full { margin-left: auto; color: var(--accent); font-size: 13px; }
.help { display: grid; grid-template-columns: 210px minmax(0, 1fr); flex: 1; min-height: 0; }
.help__nav { display: flex; flex-direction: column; gap: 1px; padding: 10px 8px; overflow-y: auto; border-right: 1px solid var(--border); }
.help__nav button { padding: 6px 10px; border: 0; border-radius: 6px; background: none; color: var(--text); text-align: left; font-size: 13px; cursor: pointer; }
.help__nav button:hover { background: var(--bg-raised); }
.help__nav button[aria-current="true"] { background: var(--accent); color: #fff; }
.help__page { overflow-y: auto; padding: 8px 28px 40px; }
/* Help as a working window: the pages beside the text when it's wide, a strip across the top when it's docked narrow. */
.app-window__body.in-dialog { container-type: inline-size; }
.in-dialog .help__bar { padding: 4px 12px; border: 0; justify-content: flex-end; }
@container (max-width: 560px) {
  .help { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); }
  .help__nav { flex-direction: row; overflow-x: auto; overflow-y: hidden; padding: 6px 8px; border-right: 0; border-bottom: 1px solid var(--border); }
  .help__nav button { flex: none; white-space: nowrap; }
  .help__page { padding: 8px 14px 32px; }
  /* Settings docked: its sections a row of tabs across the top, each row's control under its label. */
  .settings { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto auto minmax(0, 1fr); }
  .settings__nav { flex-direction: row; padding: 6px 8px; border-right: 0; border-bottom: 1px solid var(--border); }
  .settings__tab { flex: none; height: 30px; }
  .settings__body { padding: 4px 12px 16px; }
  .settings__field { flex-wrap: wrap; gap: 4px 12px; }
}
.help__note { color: var(--text-dim); }
@media (max-width: 640px) { .help { grid-template-columns: 1fr; } .help__nav { display: none; } }

/* Guide pages: readable prose. */
.guide { font-size: 15px; line-height: 1.55; color: var(--text); max-width: 760px; }
.guide h1 { font-size: 26px; margin: 18px 0 10px; }
.guide h2 { font-size: 19px; margin: 26px 0 8px; }
.guide h3 { font-size: 16px; margin: 20px 0 6px; }
.guide p, .guide ul, .guide ol { margin: 8px 0; }
.guide ul, .guide ol { padding-left: 22px; }
.guide li { margin: 3px 0; }
.guide code { padding: 1px 5px; border-radius: 4px; background: var(--bg-raised); font: 0.9em ui-monospace, SFMono-Regular, Menlo, monospace; }
.guide a { color: var(--accent); }
.guide table { border-collapse: collapse; margin: 10px 0; font-size: 14px; }
.guide th, .guide td { padding: 6px 10px; border: 1px solid var(--border); text-align: left; vertical-align: top; }
.guide th { background: var(--bg-raised); }

/* Every page besides the editor (ui/page.js; docs/design/pages.md): the body, the bar, the main part, the status line, "nothing here". */
body.page { margin: 0; height: 100dvh; display: flex; flex-direction: column; background: var(--bg-panel); color: var(--text); font: 14px/1.4 system-ui, sans-serif; }
.page-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 8px 16px; border-bottom: 1px solid var(--border); font-weight: 600; }
.page-bar a { color: inherit; text-decoration: none; }
.page-bar__home { height: 30px; font-weight: 400; }
.page-bar__name { margin: 0; font-size: inherit; font-weight: 600; }
.page-bar__title { color: var(--text-dim); font-weight: 400; }
.page-bar .page-bar__tools { margin-left: auto; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; color: var(--text); font-weight: 400; }
.page-bar__find { display: flex; align-items: center; gap: 8px; font-weight: 400; }
/* The bar's fields (Find, the home screen's order) stand as tall as its buttons. */
.page-bar__find input,
.page-bar select { height: 34px; padding: 0 12px; border: 1px solid var(--border); border-radius: 17px; background: var(--bg-raised); color: var(--text); font: inherit; }
.page-bar__find input { width: 14em; max-width: 40vw; }
.page-bar__find input:focus-visible,
.page-bar select:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
/* The home screen's bar: the app's name is its title, larger, the bar as wide as the sections under it. */
.page-bar--home { max-width: 1200px; margin: 0 auto; padding: 16px 0 12px; }
.page-bar--home .page-bar__name { font-size: 22px; }
.page__main { flex: 1; min-height: 0; }
.page-status { margin: 0; color: var(--text-dim); }
.page-status.is-problem { color: var(--danger); }
.page-empty { grid-column: 1 / -1; margin: 0; color: var(--text-dim); }
/* A section of a page (section() in ui/page.js): one heading, its actions beside it, a note, the body. */
.page-section__head { display: flex; align-items: center; gap: 8px; margin: 0 0 12px; }
.page-section__title { flex: 1; margin: 0; font-size: 13px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.04em; }
.page-section__actions { display: flex; flex-wrap: wrap; gap: 6px; }
/* The grip a home screen section is dragged by, signed in (ui/home-order.js). */
.page-section__grip { cursor: grab; touch-action: none; color: var(--text-dim); margin-inline-start: -6px; }
.page-section__grip:active { cursor: grabbing; }
.page-section.is-dragging { opacity: 0.6; outline: 2px dashed var(--accent); outline-offset: 4px; border-radius: 8px; }
.page-section__actions .button { height: 28px; padding: 0 10px; font-size: 13px; }
.page-section__note { margin: -6px 0 12px; color: var(--text-dim); font-size: 13px; }
/* The owner's message of the day: above the home screen's footer (ui/home-motd.js), and as it shows on the admin page. */
.home-motd { max-width: 1200px; margin: 32px auto 0; box-sizing: border-box; padding: 14px 18px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg-panel); color: var(--text); line-height: 1.5; }
.home-motd > :first-child { margin-top: 0; }
.home-motd > :last-child { margin-bottom: 0; }
.home-motd h1, .home-motd h2, .home-motd h3 { margin: 0.6em 0 0.3em; font-size: 1.15em; }
.home-motd a { color: var(--accent); }
.admin-motd__text { width: 100%; box-sizing: border-box; font: inherit; font-family: ui-monospace, monospace; padding: 8px; background: var(--bg-raised); color: var(--text); border: 1px solid var(--border); border-radius: 6px; resize: vertical; }
.admin-motd__buttons { display: flex; gap: 8px; margin: 8px 0; }
.admin-motd__shown[hidden] { display: none; }
.admin .page-section { margin-top: 16px; }
/* Sections one after another on a page are ruled apart, as the home screen's homes are. */
.admin .page-section + .page-section { padding-top: 16px; border-top: 1px solid var(--border); }
.admin { display: flex; flex-direction: column; gap: 12px; padding: 16px 18px; }
.admin__scroll { flex: 1; min-height: 0; overflow: auto; }
/* Tables on every page (table() in ui/page.js): headers that sort, the row's buttons last. */
.page-table { flex: 1; min-height: 0; overflow: auto; }
.page-table table { border-collapse: collapse; width: 100%; font-size: 13px; }
.page-table th, .page-table td { padding: 6px 10px; border-bottom: 1px solid var(--border); text-align: left; white-space: nowrap; }
.page-table th { position: sticky; top: 0; background: var(--bg-panel); }
.page-table th button { all: unset; cursor: pointer; font-weight: 600; }
.page-table th[aria-sort="ascending"] button::after { content: ' ▲'; }
.page-table th[aria-sort="descending"] button::after { content: ' ▼'; }
.page-table__actions { display: flex; gap: 4px; }
.admin__here { color: var(--accent); font-weight: 600; }
/* The zoom and pan component (ui/zoom-pan.js): a picture in a box, placed by a transform from its top-left corner. */
.zoom-pan { position: relative; overflow: hidden; touch-action: none; cursor: grab; outline-offset: -2px; -webkit-user-select: none; user-select: none; }
.zoom-pan.is-fitted { cursor: zoom-in; }
.zoom-pan:active { cursor: grabbing; }
.zoom-pan__picture { position: absolute; left: 0; top: 0; max-width: none; max-height: none; transform-origin: 0 0; pointer-events: none; }

/* Choosing the part the home screen shows (ui/showcase-choose.js): a box the shape of a piece there (4:3, as SHOWCASE_FRONT). */
.dialog.showcase-choose { width: min(560px, calc(100vw - 32px)); }
.showcase-choose__view { width: 100%; aspect-ratio: 4 / 3; margin: 8px 0 4px; border-radius: 8px; background: var(--workspace); box-shadow: inset 0 0 0 1px var(--border); }

.showcase-artist { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 10px; padding: 12px 16px; }
.showcase-artist__count { text-align: center; }
.showcase-artist__stage { flex: 1; min-height: 0; display: flex; align-items: center; gap: 8px; }
.showcase-artist__view { flex: 1; min-width: 0; align-self: stretch; }
/* Half as large again as a page's buttons, their arrows much larger. */
.showcase-artist__step { min-width: 54px; min-height: 66px; font-size: 40px; line-height: 1; }
.showcase-artist__thumbs { display: flex; gap: 8px; justify-content: center; margin: 0; padding: 0; list-style: none; overflow-x: auto; }
.showcase-artist__thumbs button { padding: 0; border: 2px solid transparent; border-radius: 6px; background: none; cursor: pointer; }
.showcase-artist__thumbs button[aria-current="true"] { border-color: var(--accent); }
.showcase-artist__thumbs img { display: block; height: 56px; width: auto; border-radius: 4px; }
@media (max-width: 600px) { .showcase-artist__step { display: none; } }
.showcase-admin { overflow: auto; }
.assets-page__kind h3 { font-size: 13px; margin: 12px 0 4px; color: var(--text-dim); }
.assets-page__list, .assets-page__kind ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.assets-page__list li, .assets-page__kind li { display: flex; align-items: center; justify-content: space-between; gap: 12px; max-width: 520px; }
.assets-page__changed { display: inline-flex; vertical-align: -3px; color: var(--danger); }
.assets-page__changed svg { width: 16px; height: 16px; }
.assets-page__trust { display: inline-flex; vertical-align: -3px; color: var(--text-dim); }
.assets-page__trust svg { width: 16px; height: 16px; }
.assets-page__trust[data-trust="trusted"] { color: var(--fam-select); }

/* --- organising brushes (brush-order.js) ----------------------------------- */

.preset-filter { display: flex; flex-wrap: wrap; gap: 4px; margin: 2px 0 6px; }
.preset.is-hidden { opacity: 0.45; }
.preset__star { margin-right: 4px; color: #e0a800; }
.preset.is-drop-before { box-shadow: inset 0 3px 0 var(--accent); }

/* --- the cast (ui/cast.js) ---------------------------------------------------- */

.cast { display: flex; flex-direction: column; gap: 8px; width: 260px; padding: 4px 2px; max-height: 420px; overflow-y: auto; }
.cast__subject h3 { margin: 0 0 4px; font-size: 13px; }
.cast__subject.is-own { padding: 6px; margin: -2px; border-radius: 8px; background: var(--bg-raised); }
.cast__tag { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-dim); }
.cast__tag select { flex: 1; }
.cast__subject h3 span { color: var(--text-dim); font-weight: 400; font-size: 12px; }
.cast__materials { display: flex; flex-wrap: wrap; gap: 4px; }
.cast__material { display: flex; align-items: center; gap: 5px; padding: 3px 8px 3px 4px; border: 1px solid var(--border); border-radius: 14px; background: none; color: var(--text); font: inherit; font-size: 12px; cursor: pointer; }
.cast__material span { width: 16px; height: 16px; border-radius: 50%; box-shadow: inset 0 0 0 1px rgba(127, 127, 127, 0.5); }
.cast__material.is-on { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.cast__empty { margin: 0; color: var(--text-dim); font-size: 12px; }
.cast__edit { align-self: flex-start; }
.dialog.dialog--cast { width: min(820px, calc(100vw - 32px)); height: min(640px, calc(100dvh / var(--ui-scale) - 48px)); padding: 0; display: flex; flex-direction: column; }
.dialog--cast:not([open]) { display: none; }
.cast-window { display: grid; grid-template-columns: 240px minmax(0, 1fr); flex: 1; min-height: 0; }
.cast-window__list { display: flex; flex-direction: column; gap: 4px; padding: 10px; overflow-y: auto; border-right: 1px solid var(--border); }
.cast-window__open { padding: 6px 10px; border: 0; border-radius: 6px; background: none; color: var(--text); text-align: left; font: inherit; font-size: 13px; cursor: pointer; }
.cast-window__open:hover { background: var(--bg-hover); }
.cast-window__open[aria-current="true"] { background: var(--bg-selected); font-weight: 600; }
.cast-window__list > .button { justify-content: flex-start; }
.cast-window__list textarea, .cast-window__subject textarea { width: 100%; box-sizing: border-box; font: inherit; font-size: 13px; padding: 6px 8px; border: 1px solid var(--border); border-radius: 6px; background: var(--bg-raised); color: var(--text); resize: vertical; }
.cast-window__scene { display: flex; flex-direction: column; gap: 2px; font-size: 12px; color: var(--text-dim); }
.cast-window__scene input, .cast-window__name, .cast-window__materials input:not([type="color"]), .cast-window select, .cast__tag select { height: 28px; padding: 0 8px; font: inherit; font-size: 13px; border: 1px solid var(--border); border-radius: 6px; background: var(--bg-raised); color: var(--text); }
.cast-window__name { height: 32px; }
.cast-window__remove { flex: none; width: 36px; height: 36px; }
.cast-window__remove svg { width: 24px; height: 24px; }
.cast-window__subject { padding: 12px 16px; overflow-y: auto; }
.cast-window__row { display: flex; gap: 8px; }
.cast-window__name { flex: 1; font-size: 15px; font-weight: 600; }
.cast-window__materials { list-style: none; margin: 0 0 6px; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.cast-window__materials li { display: flex; align-items: center; gap: 6px; }
.cast-window__materials input:not([type="color"]) { flex: 1; min-width: 0; }
.cast-window__carries { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 13px; }
.curves { padding: 12px 18px 16px; }
/* The Stances window (ui/stances-window.js): a block per stance, its settings one to a line. */
.stances { padding: 10px 12px; font-size: 13px; }
.stances .dialog__note { margin: 0; }
.stances__name, .stances__field select { height: 28px; padding: 0 8px; border: 1px solid var(--border); border-radius: 6px; background: var(--bg-raised); color: var(--text); font: inherit; }
.stances__name { -webkit-user-select: text; user-select: text; }
.stances__field select { min-width: 0; max-width: 60%; }
.stances__head .button { flex: none; height: 28px; padding: 0 10px; }
.stances__list { list-style: none; margin: 8px 0; padding: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; }
.stances__row { display: grid; grid-template-columns: minmax(0, 1fr); gap: 6px; min-width: 0; padding: 8px; border: 1px solid var(--border); border-radius: 8px; }
.stances__head { display: flex; align-items: center; gap: 6px; }
.stances__name { flex: 1; min-width: 0; }
.stances__field { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 13px; }
.stances__value { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.stances__value input { flex: 1; }
.stances__value span { min-width: 4em; text-align: right; font-variant-numeric: tabular-nums; }
.stances__check { display: flex; align-items: center; gap: 6px; font-size: 13px; }
.curves__list { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 4px; }
.curves__row { display: flex; align-items: center; gap: 8px; }
.curves__row.is-hidden { opacity: 0.55; }
.curves__picture { width: 44px; height: 44px; flex: none; fill: color-mix(in srgb, var(--accent) 25%, transparent); stroke: var(--text); stroke-width: 0.02; }
.curves__name { flex: 1; min-width: 0; }
.curve-builder__pieces { margin: 8px 0; padding-left: 20px; display: grid; gap: 6px; }
.curve-builder__pieces li, .curve-builder__row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.curve-builder input[type="number"] { width: 70px; }
.curve-builder__row { margin: 8px 0; }
.curve-builder__preview.curves__picture { display: block; width: 100%; max-width: 320px; height: 200px; margin: 8px auto; }
.curve-builder__preview svg { width: 100%; height: 100%; }
.curve-builder__preview polygon { fill: color-mix(in srgb, var(--accent) 25%, transparent); stroke: var(--text); stroke-width: 0.006; }
.curves__name small { color: var(--text-dim); }
.curves__actions { display: flex; gap: 4px; flex: none; }
.cast-window__actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }

/* --- line styles (ui/line-styles.js) ---------------------------------------- */

.dialog--styles:not([open]) { display: none; }
.dialog.dialog--styles { padding: 0; }
.styles { padding: 12px 18px 16px; }
.styles__pick, .styles__name { display: flex; align-items: center; gap: 8px; margin: 10px 0; font-size: 13px; }
.styles__pick select { flex: 1; }
.styles__name input { flex: 1; padding: 4px 6px; font: inherit; border: 1px solid var(--border); border-radius: 6px; background: var(--bg); color: var(--text); }
.styles__table { border-collapse: collapse; width: 100%; font-size: 13px; }
.styles__table th, .styles__table td { padding: 4px 6px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
.styles__table input[type="number"] { width: 64px; padding: 2px 4px; font: inherit; border: 1px solid var(--border); border-radius: 4px; background: var(--bg); color: var(--text); }
.styles__colour { display: flex; align-items: center; gap: 4px; }

/* --- gradients (ui/gradients.js) ------------------------------------------- */

.dialog--gradients:not([open]) { display: none; }
.dialog.dialog--gradients { padding: 0; }
.gradients { display: grid; grid-template-columns: minmax(180px, 240px) minmax(0, 1fr); gap: 16px; padding: 12px 18px 16px; }
.gradients__list { list-style: none; margin: 0; padding: 0; max-height: 60vh; overflow: auto; display: grid; gap: 4px; align-content: start; }
.gradients__item { display: grid; grid-template-columns: 56px minmax(0, 1fr) auto; align-items: center; gap: 8px; width: 100%; padding: 4px 6px; border: 1px solid transparent; border-radius: 6px; background: none; color: var(--text); font: inherit; font-size: 13px; text-align: left; cursor: pointer; }
.gradients__item:hover { background: var(--bg-hover, rgba(127, 127, 127, 0.12)); }
.gradients__item.is-current { border-color: var(--accent); }
.gradients__item small { color: var(--text-dim); }
/* A gradient over a checkerboard, so its transparency shows. */
.gradients__swatch, .gradients__strip {
  background: var(--g), repeating-conic-gradient(#c8c8c8 0 25%, #fff 0 50%) 0 0 / 10px 10px;
  border: 1px solid var(--border);
  border-radius: 4px;
}
.gradients__swatch { height: 20px; }
.gradients__name { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.gradients__name input { flex: 1; padding: 4px 6px; font: inherit; border: 1px solid var(--border); border-radius: 6px; background: var(--bg); color: var(--text); }
.gradients__strip-box { margin: 14px 10px 8px; }
.gradients__strip { height: 40px; }
.gradients__row { position: relative; height: 22px; cursor: copy; }
.gradients__stop {
  position: absolute;
  top: 3px;
  width: 16px;
  height: 16px;
  margin-left: -8px;
  border: 2px solid var(--text);
  border-radius: 3px;
  background: var(--stop);
  cursor: grab;
  touch-action: none;
}
.gradients__stop.is-current { outline: 2px solid var(--accent); outline-offset: 1px; }
.gradients__stop-editor { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; margin: 8px 0; font-size: 13px; }
.gradients__stop-editor input[type="number"] { width: 56px; padding: 2px 4px; font: inherit; border: 1px solid var(--border); border-radius: 4px; background: var(--bg); color: var(--text); }
.gradients__stop-editor input[type="color"] { width: 36px; height: 24px; padding: 0; border: 1px solid var(--border); border-radius: 4px; background: none; }
@media (max-width: 640px) {
  .gradients { grid-template-columns: minmax(0, 1fr); }
  .gradients__list { max-height: 30vh; }
}

/* --- splash screen (ui/splash.js) ------------------------------------------ */

.splash {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  background: var(--bg-app);
  /* The pen and keys go through to the app: the splash only fades. */
  pointer-events: none;
  animation: splash-in 150ms ease-out;
  transition: opacity 300ms ease;
}
.splash[hidden] { display: none; }
.splash[data-state="leaving"] { opacity: 0; }
.splash[data-state="about"] { background: rgba(0, 0, 0, 0.45); pointer-events: auto; animation: none; }
@keyframes splash-in { from { opacity: 0; } }
.splash__card {
  zoom: var(--ui-scale);
  display: grid;
  justify-items: center;
  gap: 6px;
  width: min(360px, calc(100vw - 32px));
  padding: 32px 24px 24px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--bg-panel) center / cover no-repeat;
  color: var(--text);
  text-align: center;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4);
}
.splash__card p { margin: 0; }
.splash__name { font-size: 26px; font-weight: 600; }
.splash__version { color: var(--text-dim); font-variant-numeric: tabular-nums; }
.splash__about { margin-top: 8px !important; color: var(--text-dim); }
.splash__actions { display: flex; gap: 8px; margin-top: 12px !important; }
.splash:not([data-state="about"]) .splash__about,
.splash:not([data-state="about"]) .splash__actions { display: none; }
/* With the artwork in, it carries the name: the version and year sit over it. */
.splash[data-art] .splash__icon,
.splash[data-art] .splash__name { visibility: hidden; }

/* The GPU renderer's 2D overlays (render/pixi-renderer.js): over the view, letting the pen through. */
.stage canvas.stage__overlay { pointer-events: none; }

/* The Sidepiece (./?sidepiece, ui/sidepiece.js): a phone's worth of big buttons. */
/* The page is a flex column: fill its width and scroll, rather than shrink to the buttons. */
.sidepiece { flex: 1; min-height: 0; overflow-y: auto; box-sizing: border-box; width: 100%; max-width: 720px; margin: 0 auto; padding: 12px 16px 16px; display: flex; flex-direction: column; gap: 14px; }
.sidepiece__status { margin: 0; color: var(--text-dim); }
.sidepiece__choices { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; }
.sidepiece__choices select { max-width: 60vw; }
.sidepiece__note { margin: 0; }
.sidepiece__hosts { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.sidepiece__hosts p { margin: 0; width: 100%; }
/* The pad takes the room the page leaves, and scrolls itself (one scrollbar, not the page's as well).
   Its scrollbar's room is kept whether it shows or not, so the layout's width never changes as it
   comes and goes (BUG-053: the width flickered, with a horizontal scrollbar at times). */
.sidepiece__pad { flex: 1 1 auto; min-height: 320px; overflow-x: hidden; overflow-y: auto; scrollbar-gutter: stable; }
/* A layout's controls (ui/sidepiece-pad.js): its own colours and pictures where it has them, the theme's where it doesn't. */
.sidepiece-pad { display: block; touch-action: none; user-select: none; -webkit-user-select: none; }
.sidepiece-control { cursor: pointer; outline: none; }
.sidepiece-control__shape { fill: var(--bg-raised); stroke: var(--border); stroke-width: 1; }
.sidepiece-control__label { fill: var(--text); font: 15px system-ui, sans-serif; pointer-events: none; }
.sidepiece-control__fill { fill: var(--accent); opacity: 0.35; pointer-events: none; }
.sidepiece-control__knob line { stroke: var(--text); stroke-width: 3; stroke-linecap: round; }
.sidepiece-control[data-pictures] .sidepiece-control__shape { fill: none; stroke: none; }
.sidepiece-control.is-active .sidepiece-control__shape { stroke: var(--accent); stroke-width: 3; }
/* Pressed: shown by the page itself, at once, whatever the network. */
.sidepiece-control.is-pressed .sidepiece-control__shape { fill: var(--bg-hover); }
.sidepiece-control.is-pressed .sidepiece-control__image { filter: brightness(0.85); }
.sidepiece-control.is-disabled { opacity: 0.4; cursor: default; }
.sidepiece-control:focus-visible .sidepiece-control__shape { stroke: var(--accent); stroke-dasharray: 4 3; }
.sidepiece__refused { margin: 0; color: var(--danger); }
.sidepiece__timing { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; margin: 0; color: var(--text-dim); font-size: 13px; }
.sidepiece__timing dd { margin: 0; font-variant-numeric: tabular-nums; }
.sidepiece-stats { width: min(560px, calc(100vw - 32px)); box-sizing: border-box; padding: 16px; border: 1px solid var(--border); border-radius: 12px; background: var(--bg-raised); color: var(--text); box-shadow: 0 8px 32px rgb(0 0 0 / 0.25); }
.sidepiece-stats__title { margin: 0 0 12px; font-size: 17px; }
.sidepiece-stats .sidepiece__timing { color: var(--text); }
.sidepiece-devices { padding: 8px 12px 12px; }
.painting { padding: 8px 12px 12px; }
.painting__intro { margin: 0 0 8px; color: var(--text-dim); font-size: 13px; }
.painting__dish { display: block; margin: 4px auto 8px; touch-action: none; cursor: grab; border-radius: 50%; }
.painting__dish:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.painting__rim { fill: var(--bg-selected); stroke: var(--border); stroke-width: 2; }
.painting__overhead { fill: var(--text-dim); }
.painting__ray { stroke: var(--accent); stroke-width: 2; stroke-dasharray: 3 3; }
.painting__light { fill: var(--accent); stroke: var(--bg-panel); stroke-width: 2; }
.painting__heading { margin: 12px 0 4px; font-size: 13px; }
.painting__field { display: flex; flex-direction: column; gap: 2px; margin: 4px 0; }
.undo-history__intro { margin: 0 0 8px; color: var(--text-dim); font-size: 13px; }
.undo-history__list { margin: 0; padding: 0; list-style: none; }
.undo-history__step { display: flex; flex-direction: column; align-items: flex-start; gap: 1px; width: 100%; min-height: 36px; padding: 4px 8px; border: 0; border-radius: 8px; background: none; color: inherit; font: inherit; text-align: left; cursor: pointer; }
.undo-history__step:hover { background: var(--bg-hover, rgba(127, 127, 127, 0.12)); }
.undo-history__step.is-current { background: var(--bg-selected); font-weight: 600; }
.undo-history__step.is-undone { color: var(--text-dim); opacity: 0.6; }
.undo-history__step.is-unkept .undo-history__label { font-style: italic; }
.undo-history__label { font-size: 13px; }
.undo-history__targets { max-width: 100%; overflow: hidden; color: var(--text-dim); font-size: 11px; font-weight: 400; text-overflow: ellipsis; white-space: nowrap; }
.undo-history__row, .undo-history__start { display: flex; align-items: center; gap: 4px; }
.undo-history__row .undo-history__step, .undo-history__start .undo-history__step { flex: 1; min-width: 0; }
.undo-history__source { display: grid; place-items: center; flex: none; width: 24px; height: 24px; padding: 0; border: 1px solid transparent; border-radius: 6px; background: none; color: inherit; cursor: pointer; }
.undo-history__source:hover, .undo-history__source:focus-visible { border-color: var(--border); }
.undo-history__source svg { width: 18px; height: 18px; }
.undo-history__take-back { flex: none; height: 26px; padding: 0 8px; border: 1px solid var(--border); border-radius: 6px; background: none; color: inherit; font: inherit; font-size: 11px; cursor: pointer; opacity: 0; }
.undo-history__row:hover .undo-history__take-back:not(:disabled), .undo-history__take-back:focus-visible { opacity: 1; }
.undo-history__row:hover .undo-history__take-back:disabled { opacity: 0.4; cursor: default; }
.undo-history__filter { display: flex; align-items: center; gap: 6px; margin: 0 0 6px; font-size: 13px; }
.undo-history__why { max-width: 100%; color: var(--text-dim); font-size: 11px; font-style: italic; font-weight: 400; white-space: normal; }
.undo-history__heading { margin: 14px 0 4px; font-size: 13px; }
.undo-history__branch { flex: 1; min-width: 0; padding: 4px 8px; font-size: 12px; }
.undo-history__barrier { margin: 6px 0; padding: 6px 8px; border-top: 1px dashed var(--border); color: var(--text-dim); font-size: 11px; }
.sidepiece-devices__qr { display: grid; justify-items: start; gap: 8px; margin: 8px 0; }
.sidepiece-devices__qr svg { display: block; width: 200px; height: 200px; border-radius: 8px; }
.sidepiece-devices__intro { margin: 0 0 8px; color: var(--text-dim); font-size: 13px; }
.sidepiece-devices__device + .sidepiece-devices__device { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border); }
.sidepiece-devices__name { margin: 0 0 6px; font-size: 14px; }
.sidepiece-stats__chart { display: block; width: 100%; height: 80px; margin-top: 12px; border-bottom: 1px solid var(--border); }
.sidepiece-stats__line { fill: none; stroke-width: 2; vector-effect: non-scaling-stroke; }
.sidepiece-stats__line[data-line="relay"] { stroke: var(--text-dim); }
.sidepiece-stats__line[data-line="host"] { stroke: var(--accent); }
.sidepiece-stats__key { display: flex; flex-wrap: wrap; gap: 4px 14px; margin: 6px 0 0; color: var(--text-dim); font-size: 12px; }
.sidepiece-stats__key [data-key]::before { content: ''; display: inline-block; width: 12px; height: 2px; margin-right: 6px; vertical-align: middle; background: currentColor; }
.sidepiece-stats__key [data-key="host"] { color: var(--accent); }
.sidepiece-stats__key [data-key="top"]::before { content: none; }
.timelapse__mark img { max-width: 120px; max-height: 48px; object-fit: contain; background: repeating-conic-gradient(var(--border) 0 25%, transparent 0 50%) 0 0 / 12px 12px; }
.timelapse__mark .dialog__note { margin: 0; flex: 1; }

/* A long press shows itself (input/press-ring.js): a ring at the finger that fills before the press acts. */
.press-ring { position: fixed; z-index: 1000; width: var(--press-size); height: var(--press-size); translate: -50% -50%; pointer-events: none; }
.press-ring svg { width: 100%; height: 100%; rotate: -90deg; }
.press-ring circle { fill: none; stroke-width: 3; }
.press-ring__track { stroke: color-mix(in srgb, var(--bg-panel) 70%, transparent); }
.press-ring__fill { stroke: var(--accent); stroke-dasharray: 100; stroke-dashoffset: 100; animation: press-ring-fill var(--press-ms) linear forwards; }
@keyframes press-ring-fill { to { stroke-dashoffset: 0; } }
@media (prefers-reduced-motion: reduce) { .press-ring__fill { animation: none; stroke-dashoffset: 0; opacity: 0.6; } }

/* --- Undo's stack and what a step changed (ui/step-stack.js, ui/step-compare.js) --- */
.step-compare { display: grid; width: 100%; height: 100%; place-items: center; }
.step-compare__frame { position: relative; display: grid; max-width: 100%; max-height: 100%; }
.step-compare__picture { display: block; max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 3px; outline: 1px solid var(--border); background: var(--workspace); }
.step-compare__ants { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; pointer-events: none; }
.step-compare__ants path { fill: none; stroke-width: 1.5px; vector-effect: non-scaling-stroke; }
.step-compare__ants-under { stroke: #fff; }
.step-compare__ants-over { stroke: #000; stroke-dasharray: 4 4; animation: step-ants 0.6s linear infinite; }
@keyframes step-ants { to { stroke-dashoffset: -8; } }
.step-compare.is-pair { grid-template-columns: 1fr 1fr; gap: 3px; }
.step-compare__half { display: grid; gap: 1px; min-width: 0; margin: 0; justify-items: center; }
.step-compare__half figcaption { color: var(--text-dim); font-size: 9px; line-height: 1; }
.step-stack { position: fixed; inset: 0; z-index: 900; }
.step-stack__card { --scale: 1; position: absolute; display: grid; width: var(--card); height: var(--card); padding: 3px; border: 1px solid var(--border); border-radius: 6px; background: var(--bg-raised); color: var(--text); font: inherit; cursor: pointer; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.45); opacity: 0; scale: 0.3; transition: scale 0.12s ease-out, opacity 0.18s ease-out var(--delay), translate 0.18s ease-out var(--delay); }
.step-stack.is-open .step-stack__card { opacity: 1; scale: var(--scale); }
.step-stack__card.is-near, .step-stack__card:focus-visible { z-index: 2; border-color: var(--accent); }
.step-stack__face { display: grid; min-width: 0; min-height: 0; overflow: hidden; }
.step-stack__label { position: absolute; top: 50%; max-width: 150px; padding: 2px 6px; overflow: hidden; border-radius: 4px; background: var(--toast-bg); color: #fff; font-size: 11px; text-overflow: ellipsis; white-space: nowrap; translate: 0 -50%; scale: calc(1 / var(--scale)); pointer-events: none; }
.step-stack[data-labels="left"] .step-stack__label { right: calc(100% + 6px); transform-origin: right center; }
.step-stack[data-labels="right"] .step-stack__label { left: calc(100% + 6px); transform-origin: left center; }
.step-stack[data-labels="above"] .step-stack__label { top: auto; bottom: calc(100% + 4px); left: 50%; translate: -50% 0; transform-origin: bottom center; }
.step-stack[data-labels="below"] .step-stack__label { top: calc(100% + 4px); left: 50%; translate: -50% 0; transform-origin: top center; }
.step-stack[data-labels="above"] .step-stack__card:not(.is-near) .step-stack__label, .step-stack[data-labels="below"] .step-stack__card:not(.is-near) .step-stack__label { display: none; }
.step-stack__closer { position: absolute; z-index: 1; top: 2px; right: 2px; display: none; place-items: center; width: 14px; height: 14px; padding: 1px; border-radius: 4px; background: var(--toast-bg); color: #fff; scale: calc(1 / var(--scale)); transform-origin: top right; cursor: zoom-in; }
.step-stack__card.is-near .step-stack__closer { display: grid; width: 24px; height: 24px; scale: calc(1.2 / var(--scale)); }
.step-stack__closer svg { width: 100%; height: 100%; }
.step-compare__large { position: relative; }
.step-compare__large .step-compare__picture { width: 100%; height: 100%; max-width: none; max-height: none; border-radius: 0; }
.dialog.stack-closer { width: min(92vw, 1200px); height: min(88vh, 900px); padding: 12px; }
.stack-closer__head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.stack-closer__head .dialog__title { margin: 0; }
.stack-closer__view { height: calc(100% - 48px); border-radius: 6px; background: var(--workspace); }
.step-stack__more { place-items: center; padding: 4px; color: var(--text-dim); font-size: 10px; line-height: 1.2; text-align: center; }
.undo-history__peek { position: fixed; z-index: 900; display: grid; gap: 8px; width: 220px; padding: 8px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg-raised); box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5); pointer-events: none; }
.undo-history__peek h4 { margin: 0 0 4px; color: var(--text-dim); font-size: 11px; font-weight: 600; }
.undo-history__peek p { margin: 0; color: var(--text-dim); font-size: 12px; }
.undo-history__peek .step-compare { height: auto; }
@media (prefers-reduced-motion: reduce) { .step-compare__ants-over { animation: none; } .step-stack__card { transition: none; } }

/* --- Colourise (ui/colorize-window.js) --------------------------------------- */
.colorize { display: flex; flex-direction: column; gap: 8px; padding: 10px 12px; font-size: 13px; }
.colorize__fact { margin: 0; color: var(--text-dim); }
.colorize__fact span { color: var(--text); font-weight: 600; margin-inline-end: 4px; }
.colorize__row { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 30px; }
.colorize__range { display: flex; align-items: center; gap: 8px; }
.colorize__range input { width: 120px; }
.colorize__range output { min-width: 44px; text-align: right; font-variant-numeric: tabular-nums; }
.colorize__row select { height: 28px; border: 1px solid var(--border); border-radius: 6px; background: var(--bg-raised); color: var(--text); font: inherit; }
.colorize__note { margin: -4px 0 0; color: var(--text-dim); font-size: 12px; }
.colorize__actions { display: flex; justify-content: flex-end; margin-top: 4px; }
.page-layouts__tile.is-current { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.comic-lines__modulation { display: grid; grid-template-columns: 1fr 1fr auto; gap: 4px 6px; align-items: center; margin-bottom: 8px; }
.comic-lines__modulation .curves { grid-column: 1 / -1; }
.comic-lines__grid { grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)); }
.comic-lines__grid svg { max-width: 100%; height: auto; }
.tone__tile img { background: #fff; border-radius: 3px; max-width: 100%; height: auto; }
.tone__lattices { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; margin: 6px 0; }
.tone__lattices .is-current { border-color: var(--accent); color: var(--accent); }
.link-btn[hidden] { display: none; }

/* Every drop-down has one look (the owner, November 2026): a field's border, radius and colours where a
   context gives none, and the app's own chevron, drawn in the text's colour, never the browser's arrow
   (which sat apart from the rest and out of line). Last in the file, so its chevron and the room for it
   win over a context's padding and background shorthand; a context's size and colours still hold. */
:where(select) {
  height: 32px;
  padding: 0 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background-color: var(--bg-raised);
  color: var(--text);
  font: inherit;
}
select:not([multiple]):not([size]) {
  appearance: none;
  padding-right: 28px;
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%), linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: calc(100% - 16px) 55%, calc(100% - 11px) 55%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  cursor: pointer;
}
select:not([multiple]):not([size]):disabled { cursor: default; opacity: 0.6; }
