:root {
  --color-bg: #141414;            /* canvas */
  --color-surface: #1c1c1c;       /* panels, top bar */
  --color-border: #252525;
  --color-column-border: #2a2a2a; /* Layers and inspector edges */
  --color-inspector-border: #3a3a3a;
  --color-inspector-divider: #3a3a3a;
  --color-control-surface: #272727;
  --color-control-text: #e6e6e6;
  --color-control-label: #8c8c8c;
  --color-action-text: #d0d0d0;
  --panel-inset: 12px;
  --color-inspector-tab-active: #2a2a2a;
  --color-chip-selected: #2e2e2e;
  --color-inspector-tab-hover: #222222;
  --color-inspector-tab-muted: #8c8c8c;
  --color-icon: #8c8c8c;
  --color-divider: #2e2e2e;
  --color-text: #e0e0e0;
  --color-title: #e6e6e6;
  --color-secondary: #a3a3a3;
  --color-muted: #7a7a7a;
  --color-unit: #6b6b6b;
  --slider-track: #444444;
  --slider-fill: #bdbdbd;
  --color-neutral-focus: rgba(255, 255, 255, 0.35);
  --color-faint: #4f4f4f;
  --color-text-strong: #ffffff;   /* selected layer name */
  --color-tag-selected: #6b6b6b;  /* selected layer tag */
  --color-row-hover: rgba(255, 255, 255, 0.04);
  --color-accent: #5b9bff;
  --color-accent-soft: rgba(91, 155, 255, 0.16);
  --color-accent-hover: #6ea8ff;
  --color-accent-pressed: #4a8cf0;
  --color-focus: #5b9bff;         /* keyboard focus ring */
  --color-on-accent: #ffffff;
  --color-outline: #333333;       /* outline buttons, active tool */
  --color-outline-text: #bdbdbd;
  --color-toolbar: #1f1f1f;
  --menu-bg: #222222;
  --menu-border: #343434;
  --menu-radius: 14px;
  --menu-padding: 8px;
  --menu-gap: 0;
  --menu-shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
  --menu-item-height: 32px;
  --menu-item-radius: 8px;
  --menu-item-padding-left: 12px;
  --menu-item-padding-right: 12px;
  --menu-item-hover: #2e2e2e;
  --menu-text: #e0e0e0;
  --menu-muted: #a3a3a3;
  --menu-shortcut: #7a7a7a;
  --menu-disabled: #6b6b6b;
  --menu-divider: #383838;
  --menu-key-bg: #2c2c2c;
  --menu-key-border: #3f3f3f;
  --menu-danger: #f08a8a;
  --menu-key-size: 20px;
  --menu-key-radius: 5px;
  --menu-key-font-size: 11px;
  --color-pill: #2a2a2a;
  --color-brand-hover: #333333;
  --effects-add-bg: #2a2a2a;
  --effects-add-hover: #333333;
  --effects-section-head-height: 32px;
  --effects-add-size: 28px;
  --color-donate-bg: #17202e;
  --color-donate-hover: #1c2a3f;
  --color-donate-pressed: #213250;
  --color-stage-bg: #ffffff;
  --color-backdrop: rgb(0 0 0 / 0.6);
  --scrollbar-thumb: rgba(255, 255, 255, 0.16);
  --scrollbar-thumb-hover: rgba(255, 255, 255, 0.28);
  --scrollbar-thumb-active: rgba(255, 255, 255, 0.36);
  --scrollbar-size: 14px;
  --shadow-float: 0 6px 20px rgba(0, 0, 0, 0.35);
  --focus-ring: 2px solid var(--color-focus);
  --focus-offset: 1px;
  --transition-hover: background 120ms ease;

  --radius-sm: 6px;   /* buttons, rows */
  --radius-md: 8px;   /* switcher, menus, dialog */
  --radius-pill: 16px;
  --radius-lg: 20px;  /* canvas toolbar */

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;

  --topbar-height: 48px;
  --layers-width: 350px;          /* both widths are then set by src/columns.js */
  --layer-indent: 14px; /* per tree depth */
  --panel-width: 320px;
  --handle-hit: 7px;              /* column resize handles */
  --handle-line: 2px;
  --font-ui: Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;
}

* { box-sizing: border-box; }

html, body { height: 100%; margin: 0; }

body {
  display: flex;
  flex-direction: column;
  background: var(--color-bg);
  color: var(--color-text);
  font: 13px/1.4 var(--font-ui);
}

button { font: inherit; }

/* Shell scrollbars only; the stage is an iframe and keeps the user's page styling. */
.layers__tree { scrollbar-gutter: stable; }

@supports not selector(::-webkit-scrollbar) {
  :is(body, .shared-menu, .layers__tree, .panel, .code__body, .dialog, .dialog__preview) {
    scrollbar-width: thin;
    scrollbar-color: var(--scrollbar-thumb) transparent;
  }
}

:is(body, .shared-menu, .layers__tree, .panel, .code__body, .dialog, .dialog__preview)::-webkit-scrollbar {
  width: var(--scrollbar-size);
  height: var(--scrollbar-size);
}

:is(body, .shared-menu, .layers__tree, .panel, .code__body, .dialog, .dialog__preview)::-webkit-scrollbar-track,
:is(body, .shared-menu, .layers__tree, .panel, .code__body, .dialog, .dialog__preview)::-webkit-scrollbar-corner {
  background: transparent;
}

:is(body, .shared-menu, .layers__tree, .panel, .code__body, .dialog, .dialog__preview)::-webkit-scrollbar-track {
  margin-block: 6px;
}

:is(body, .shared-menu, .layers__tree, .panel, .code__body, .dialog, .dialog__preview)::-webkit-scrollbar-thumb {
  min-height: 32px;
  border: 4px solid transparent;
  border-radius: 999px;
  background: var(--scrollbar-thumb);
  background-clip: padding-box;
}

:is(body, .shared-menu, .layers__tree, .panel, .code__body, .dialog, .dialog__preview)::-webkit-scrollbar-thumb:hover {
  background-color: var(--scrollbar-thumb-hover);
}

:is(body, .shared-menu, .layers__tree, .panel, .code__body, .dialog, .dialog__preview)::-webkit-scrollbar-thumb:active {
  background-color: var(--scrollbar-thumb-active);
}

/* Top bar */

.topbar {
  position: relative;
  display: flex;
  align-items: center;
  flex: none;
  height: var(--topbar-height);
  padding: 0 var(--space-3) 0 var(--space-2);
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-inspector-border);
}

.topbar__left,
.topbar__right { position: relative; display: flex; align-items: center; min-width: 0; }
.topbar__left { gap: var(--space-3); }
.topbar__right { margin-left: auto; justify-content: flex-end; gap: var(--space-2); }
.topbar__centre { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); display: flex; align-items: center; gap: var(--space-2); width: max-content; max-width: min(calc(100% - 32px), calc(100% - 2 * max(var(--topbar-left-width, 0px), var(--topbar-right-width, 0px)) - 2 * var(--space-2) - 2 * var(--space-3))); min-width: 0; }
.topbar__centre .switcher { flex: none; }
.brand { display: flex; align-items: center; gap: var(--space-2); }
.brand--button { height: 32px; padding: 0 8px 0 6px; gap: 8px; border: 0; border-radius: var(--radius-md); background: var(--color-pill); color: inherit; cursor: pointer; transition: var(--transition-hover); }
.brand--button:hover, .brand--button[aria-expanded="true"] { background: var(--color-brand-hover); }
.brand__chevron { flex: none; opacity: .72; }

.brand__logo {
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border-radius: var(--radius-sm);
  background: var(--color-accent);
}

.brand__name { color: var(--color-title); font-size: 13px; font-weight: 600; white-space: nowrap; }

.topbar__divider { width: 1px; height: 16px; background: var(--color-inspector-border); }
.topbar__history { display: flex; align-items: center; gap: 2px; }

.icon-button {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 0;
  border-radius: var(--radius-sm);
  background: none;
  cursor: pointer;
}

.icon-button:hover:not(:disabled) { background: var(--color-pill); }
.icon-button:disabled { opacity: 0.4; cursor: default; }

/* Top-bar icon buttons: radius 6, the grey icon brightens to the title colour on hover. */
.topbar .icon-button { border-radius: var(--radius-sm); transition: var(--transition-hover); }
.topbar .icon-button:hover:not(:disabled) img { filter: brightness(0) invert(0.9); }
.topbar .icon-button:active:not(:disabled) { background: var(--color-outline); }
.topbar .icon-button--layers img { filter: brightness(0) invert(.88); }
.topbar .icon-button--layers[aria-pressed="false"] img { filter: brightness(0) invert(.48); }

/* Keyboard focus ring for the top bar and the canvas toolbar. */
.topbar button:focus-visible,
.toolbar button:focus-visible { outline: var(--focus-ring); outline-offset: var(--focus-offset); }

.topbar__note {
  min-width: 0;
  overflow: hidden;
  color: var(--color-muted);
  font-size: 11.5px;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.save-status {
  display: flex;
  align-items: center;
  flex: 0 1 auto;
  max-width: 100%;
  gap: 6px;
  color: var(--color-muted);
  font-size: 11.5px;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
}
.save-status > img { flex: none; }
#save-status-text { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.donate {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 28px;
  padding: 0 12px 0 10px;
  border: 0;
  border-radius: 6px;
  background: var(--color-donate-bg);
  color: var(--color-accent);
  font-size: 12px;
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
}

.donate:hover { background: var(--color-donate-hover); }
.donate:active { background: var(--color-donate-pressed); }
.donate:focus-visible { outline: var(--focus-ring); outline-offset: var(--focus-offset); }

.invite { height: 28px; padding: 0 12px; border: 0; border-radius: var(--radius-sm); background: var(--color-pill); color: #d0d0d0; font: 500 12px var(--font-ui); white-space: nowrap; cursor: default; }
.invite:hover { background: var(--color-brand-hover); }
.invite:focus-visible { outline: var(--focus-ring); outline-offset: var(--focus-offset); }

/* Project switcher */

.switcher {
  display: flex;
  align-items: center;
  gap: 6px;
  max-width: 360px;
  height: 32px;
  padding: 0 var(--space-2) 0 var(--space-3);
  border: 0;
  border-radius: var(--radius-md);
  background: none;
  color: var(--color-text);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition-hover);
}

.switcher:hover,
.switcher[aria-expanded="true"] { background: var(--color-pill); color: var(--color-title); }
.switcher:hover img,
.switcher[aria-expanded="true"] img { filter: brightness(0) invert(0.9); }
.switcher:active { background: var(--color-outline); }
.switcher__name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Shared editor menus */

.shared-menu {
  position: fixed;
  z-index: 30;
  display: flex;
  flex-direction: column;
  gap: var(--menu-gap);
  min-width: 200px;
  max-width: calc(100vw - 16px);
  max-height: calc(100vh - 16px);
  padding: var(--menu-padding);
  overflow: auto;
  border: 1px solid var(--menu-border);
  border-radius: var(--menu-radius);
  background: var(--menu-bg);
  box-shadow: var(--menu-shadow);
  color: var(--menu-text);
  font: 400 13px Inter, var(--font-ui);
}
.shared-menu--no-shadow, .shared-menu--no-shadow .shared-menu--submenu { box-shadow: none; }
.shared-menu[hidden] { display: none; }
.shared-menu--submenu { position: fixed; z-index: 31; }
.menu__chevron { flex: none; color: var(--menu-shortcut); }

.menu__item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  height: var(--menu-item-height);
  padding: 0 var(--menu-item-padding-right) 0 var(--menu-item-padding-left);
  border: 0;
  border-radius: var(--menu-item-radius);
  background: none;
  color: var(--menu-text);
  font-size: 13px;
  font-weight: 500;
  text-align: left;
  white-space: nowrap;
  cursor: pointer;
}

.menu__item:hover:not(:disabled):not([aria-disabled="true"]) { background: var(--menu-item-hover); }
.shared-menu .menu__item:focus-visible { outline: none; background: var(--menu-item-hover); }
.menu__item:disabled, .menu__item[aria-disabled="true"] { color: var(--menu-disabled); cursor: default; }
.menu__item--danger { color: var(--menu-danger); }
.menu__icon { display: grid; place-items: center; flex: 0 0 16px; width: 16px; height: 16px; color: var(--menu-muted); }
.menu__icon svg, .menu__icon img { display: block; width: 16px; height: 16px; }
.menu__icon img { filter: brightness(0) invert(0.64); }
.menu__item:hover:not(:disabled):not([aria-disabled="true"]) .menu__icon { color: var(--menu-text); }
.menu__item:hover:not(:disabled):not([aria-disabled="true"]) .menu__icon img { filter: brightness(0) invert(1); }
.menu__label { flex: 1; }
.menu__key { color: var(--menu-muted); font: 11.5px var(--font-ui); }

.shared-menu .menu__key { display: inline; padding: 0; border: 0; background: none; color: var(--menu-shortcut); font: 500 12px Inter, var(--font-ui); }
.menu__check { flex: none; color: var(--menu-shortcut); }

.menu__divider { flex: none; height: 1px; margin: 8px 12px; background: var(--menu-divider); }
.menu__item[aria-haspopup="menu"] { padding-right: 8px; }
.shared-menu[aria-label="New from template"] { width: 200px; min-width: 0; }
.shared-menu[aria-label="Open recent"] { width: 280px; min-width: 0; }
.menu__remove { flex: none; display: grid; place-items: center; width: 18px; height: 18px; border-radius: var(--menu-item-radius); color: var(--menu-muted); font-size: 15px; line-height: 1; }
.menu__remove:hover { background: var(--menu-item-hover); color: var(--menu-text); }
.menu__item:has(.menu__remove) .menu__label { overflow: hidden; text-overflow: ellipsis; }

/* Workspace: Layers | canvas | inspector */

.workspace { display: flex; flex: 1; min-height: 0; }

.layers {
  display: flex;
  flex-direction: column;
  width: var(--layers-width);
  flex: none;
  padding: var(--space-2) 0 var(--space-2) var(--space-2);
  background: var(--color-surface);
  border-right: 1px solid var(--color-column-border);
}

/* Layers: header, search, tree (rows from src/layers.js) */

.layers__head {
  display: flex;
  align-items: center;
  flex: none;
  height: 36px;
  padding: 0 var(--space-2) 0 var(--space-1);
}

.layers__title {
  flex: 1;
  margin: 0;
  color: var(--color-text);
  font-size: 13px;
  font-weight: 500;
}

.layers__head .icon-button[aria-pressed="true"] { background: var(--color-pill); }

.layers__search {
  flex: none;
  height: 28px;
  margin: var(--space-1) var(--space-2) var(--space-2) 0;
  padding: 0 var(--space-2);
  border: 1px solid var(--color-divider);
  border-radius: var(--radius-sm);
  background: var(--color-bg);
  color: var(--color-text);
  font: 12px var(--font-ui);
}

.layers__search[hidden] { display: none; }
.layers__search:focus { outline: none; border-color: var(--color-accent); }

.layers__tree {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-height: 0;
  overflow-y: auto;
}

.layer {
  display: flex;
  align-items: center;
  flex: none;
  gap: 6px;
  height: 30px;
  margin-right: var(--space-2);
  padding: 0 var(--space-2) 0 calc(var(--space-1) + var(--layer-indent) * var(--depth, 0));
  border-radius: var(--radius-sm);
  cursor: default;
}

.layer:hover { background: var(--color-row-hover); }
.layer.is-selected { background: var(--color-accent-soft); }

.layer__chev { display: grid; place-items: center; flex: none; width: 12px; height: 12px; cursor: pointer; }
.layer__icon, .layer__spark { flex: none; }
.layer__spark[hidden] { display: none; }

.layer__name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  color: var(--color-secondary);
  font-size: 11.5px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.layer--root .layer__name { font-weight: 500; }
.layer.is-selected .layer__name { color: var(--color-text-strong); }

.layer__tag { flex: none; color: var(--color-faint); font: 10px var(--font-mono); }
.layer.is-selected .layer__tag { color: var(--color-tag-selected); }

/* Column resize handles (src/columns.js): a zero-width item between two columns with an
   invisible hit zone over the border. The line shows on hover, drag and keyboard focus. */

.col-handle {
  position: relative;
  z-index: 16; /* above the selection overlay and the canvas toolbar, below the menus */
  flex: none;
  width: 0;
  outline: none;
}

.col-handle::before,
.col-handle::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
}

.col-handle::before {
  left: calc(var(--handle-hit) / -2);
  width: var(--handle-hit);
  cursor: col-resize;
}

.col-handle::after {
  left: calc(var(--handle-line) / -2);
  width: var(--handle-line);
  background: var(--color-accent);
  opacity: 0;
  pointer-events: none;
}

.col-handle:hover::after,
.col-handle:focus-visible::after,
.col-handle.is-dragging::after { opacity: 1; }

/* While dragging, the stage must not catch the pointer and nothing gets text-selected. */
.is-resizing { cursor: col-resize; user-select: none; }
.is-resizing .stage__frame { pointer-events: none; }
.is-hand .stage-canvas, .is-hand .stage-canvas * { cursor: grab !important; }
.is-panning, .is-panning * { cursor: grabbing !important; user-select: none; }
.is-panning .stage__frame { pointer-events: none; }

.stage {
  position: relative;
  flex: 1;
  min-width: 0;
  min-height: 0;
  background: var(--color-bg);
}

.stage-canvas {
  position: absolute;
  inset: 0;
  overflow: auto;
  display: flex;
  justify-content: safe center;
  align-items: flex-start;
}

.stage-zoom { position: relative; flex: none; transform-origin: top left; }

.stage__frame {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
  background: var(--color-stage-bg);
}

.stage-overlay--hidden { visibility: hidden; }

/* Canvas toolbar */

.toolbar {
  position: absolute;
  bottom: 10px;
  left: 50%;
  z-index: 15; /* above the selection overlay (select.js) */
  display: flex;
  align-items: center;
  gap: 2px;
  padding: var(--space-1);
  transform: translateX(-50%);
  border: 1px solid var(--color-divider);
  border-radius: var(--radius-lg);
  background: var(--color-toolbar);
  box-shadow: var(--shadow-float);
}

.tool {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 0;
  border-radius: var(--radius-pill);
  background: none;
  cursor: pointer;
  transition: var(--transition-hover);
}

.tool:hover { background: var(--color-pill); }
.tool:hover img { filter: brightness(0) invert(0.9); }
.tool:active,
.tool[aria-pressed="true"] { background: var(--color-outline); }
.tool--outlines:active,
.tool--outlines[aria-pressed="true"] { background: none; }

/* Select / Hand icons: white when on, grey when off; a hovered off one lights up. */
.tool--mode img { filter: brightness(0) invert(1); opacity: 0.55; }
.tool--mode:hover img { filter: brightness(0) invert(0.9); opacity: 1; }
.tool--mode[aria-pressed="true"] img { filter: brightness(0) invert(1); opacity: 1; }
.tool--outlines img { filter: brightness(0) invert(0.55); }
.tool--outlines.is-outlines-on img { filter: brightness(0) invert(1); }
.tool--outlines:hover img { filter: brightness(0) invert(0.9); }
.tool--outlines.is-outlines-on:hover img { filter: brightness(0) invert(1); }

.toolbar__divider { width: 1px; height: 18px; margin: 0 var(--space-1); background: var(--color-outline); }

.fullscreen-hint {
  position: absolute;
  top: var(--space-4);
  left: 50%;
  z-index: 18;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px var(--space-3);
  transform: translate(-50%, -6px);
  border: 1px solid var(--color-inspector-border);
  border-radius: var(--radius-lg);
  background: var(--color-toolbar);
  color: var(--color-text);
  box-shadow: var(--shadow-float);
  font-size: 12px;
  font-weight: 500;
  line-height: 20px;
  white-space: nowrap;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 300ms ease, transform 300ms ease, visibility 0s linear 300ms;
}
.fullscreen-hint .menu__key { display: inline-grid; place-items: center; min-width: var(--menu-key-size); height: var(--menu-key-size); padding: 0 4px; border: 1px solid var(--menu-key-border); border-radius: var(--menu-key-radius); background: var(--menu-key-bg); color: var(--menu-muted); font-size: var(--menu-key-font-size); font-weight: 500; }
.is-fullscreen .fullscreen-hint.is-visible {
  transform: translate(-50%, 0);
  opacity: 1;
  visibility: visible;
  transition: opacity 150ms ease, transform 150ms ease, visibility 0s;
}
.fullscreen-exit {
  position: absolute;
  top: var(--space-4);
  right: var(--space-4);
  z-index: 19;
  display: none;
  width: 32px;
  height: 32px;
  place-items: center;
  padding: 0;
  border: 1px solid var(--color-inspector-border);
  border-radius: 50%;
  background: var(--color-toolbar);
  color: var(--color-secondary);
  box-shadow: var(--shadow-float);
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transition: opacity 150ms ease;
}
.fullscreen-exit:hover { color: var(--color-text); }
.is-fullscreen .fullscreen-exit { display: grid; }
.is-fullscreen .fullscreen-exit:focus-visible { outline: var(--focus-ring); outline-offset: var(--focus-offset); }
body.fullscreen-pointer-top .fullscreen-exit,
.is-fullscreen .fullscreen-exit:focus-visible { opacity: 1; pointer-events: auto; }
@media (prefers-reduced-motion: reduce) {
  .fullscreen-hint, .fullscreen-exit { transition: none; }
}

.size-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 var(--space-3) 0 10px;
  border-radius: var(--radius-pill);
  background: var(--color-pill);
  color: var(--color-text);
  font-size: 13px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.zoom-control {
  position: relative;
  display: flex;
  align-items: center;
  height: 32px;
  border-radius: var(--radius-pill);
  background: var(--color-pill);
}
.zoom-control__button, .zoom-control__level {
  display: grid;
  place-items: center;
  height: 32px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--color-title);
  cursor: pointer;
}
.zoom-control__button { width: 28px; }
.zoom-control__button { color: var(--color-icon); }
.zoom-control__button:hover:not(:disabled) { color: var(--color-text-strong); }
.zoom-control__button:disabled { color: var(--color-faint); }
.zoom-control__level { width: 44px; font: 500 13px var(--font-ui); font-variant-numeric: tabular-nums; }
.zoom-control__button:hover:not(:disabled), .zoom-control__level:hover { background: var(--color-outline); }
.zoom-control__button:first-child { border-radius: var(--radius-pill) 0 0 var(--radius-pill); }
.zoom-control__button:last-of-type { border-radius: 0 var(--radius-pill) var(--radius-pill) 0; }
.zoom-control__button:disabled { cursor: default; }

/* Fullscreen: only the stage, filling the window; Esc returns. */
.is-fullscreen .topbar,
.is-fullscreen .layers,
.is-fullscreen .panel,
.is-fullscreen .col-handle,
.is-fullscreen .toolbar { display: none; }

/* Focus mode: hide the two side columns and their resize handles. */
.is-focus .layers,
.is-focus .panel,
.is-focus .col-handle { display: none; }

/* A persisted Layers preference, independent of temporary focus mode. */
.layers-hidden .layers,
.layers-hidden #layers-handle { display: none; }

/* Inspector */

.panel {
  display: flex;
  flex-direction: column;
  gap: 0;
  width: var(--panel-width);
  flex: none;
  padding: var(--space-2) 0;
  background: var(--color-surface);
  border-left: 1px solid var(--color-inspector-border);
  overflow-y: auto;
}

.inspector__header { display: flex; flex-direction: column; flex: none; }

.inspector__tabs {
  display: flex;
  flex: none;
  gap: 2px;
  padding: 0 var(--panel-inset);
  margin: 0 0 8px;
}

.inspector__tab {
  height: 30px;
  padding: 0 12px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--color-inspector-tab-muted);
  font: 500 13px var(--font-ui);
  cursor: pointer;
}

.inspector__tab[aria-selected="true"] { background: var(--color-inspector-tab-active); color: var(--color-title); }
.inspector__tab:hover { background: var(--color-inspector-tab-hover); color: var(--color-title); }
.inspector__tab[aria-selected="true"]:hover { background: var(--color-inspector-tab-active); }
.inspector__tab:focus-visible { outline: 2px solid var(--color-neutral-focus); outline-offset: 1px; }

.inspector__divider { flex: none; height: 1px; background: var(--color-inspector-divider); }
.inspector__content { padding: 0 var(--panel-inset) var(--space-4); }
.inspector__content[hidden] { display: none; }
.effects-section__head { height: 48px; margin: 0; display: flex; align-items: center; justify-content: space-between; }
.effects-section__title { color: var(--color-title); font-size: 13px; font-weight: 500; }
.effects-section__add { display: grid; place-items: center; width: var(--effects-add-size); height: 28px; padding: 0; border: 0; border-radius: 0; background: none; cursor: pointer; }
.effects-section__add:hover:not(:disabled) { background: none; }
.effects-section__add:hover:not(:disabled) .effects-section__add-icon { filter: brightness(0) invert(.9); }
.effects-section__add:focus-visible { outline: 2px solid var(--color-neutral-focus); outline-offset: var(--focus-offset); }
.effects-section__add:disabled { cursor: default; }
.effects-section__add-icon { width: 16px; height: 16px; filter: brightness(0) invert(.55); }
.effects-section__add:disabled .effects-section__add-icon { filter: brightness(0) invert(.31); }
.effects-section__divider { height: 1px; margin: 0 calc(-1 * var(--panel-inset)); background: var(--color-inspector-divider); }
.effects-section__divider + .panel__hint { margin-top: 12px; }
.inspector__exports { display: flex; flex-direction: column; align-items: stretch; gap: var(--space-2); padding-top: var(--panel-inset); }
.inspector__exports .button { text-align: left; }
.inspector__exports #save { display: flex; justify-content: space-between; align-items: center; }

.panel__title { display: flex; align-items: center; height: 24px; margin: 0; color: var(--color-title); font-size: 12px; font-weight: 500; }

.panel__hint { margin: 0; color: var(--color-muted); }

/* Effect list */

.effects { list-style: none; margin: 0 0 var(--space-5); padding: 0; }

.effects__item {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  width: 100%;
  margin-bottom: var(--space-1);
  padding: var(--space-2) 10px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: none;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.effects__item:hover:not(:disabled) { background: var(--color-pill); }
.effects__item[aria-pressed="true"] { border-color: var(--color-inspector-border); background: var(--color-inspector-tab-active); }
.effects__item:focus-visible { outline: 2px solid var(--color-neutral-focus); outline-offset: 1px; }
.effects__item:disabled { cursor: default; color: var(--color-faint); }
.effects__reason { color: var(--color-muted); font-size: 12px; }

/* Controls */

.panel__controls { padding-top: 0; padding-bottom: 14px; }

.control { display: grid; grid-template-columns: minmax(0, 1fr) 150px; align-items: center; column-gap: 8px; min-height: 30px; margin: 0 0 10px; }
.control__head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); }

.control__label { display: block; min-width: 0; margin: 0; padding-left: 12px; overflow: hidden; color: var(--color-control-label); font-size: 12px; font-weight: 400; white-space: nowrap; text-overflow: ellipsis; }
.control > .control__label { align-self: start; height: 30px; display: flex; align-items: center; }
.control__inputs { display: flex; min-width: 0; flex-direction: column; gap: 10px; }
.control__inputs--number { flex-direction: row; align-items: center; gap: 10px; }
.control__color { width: 100%; height: 32px; padding: 0 8px; display: flex; align-items: center; gap: 8px; color: var(--color-title); background: var(--color-field); border: 1px solid var(--color-control-border); border-radius: var(--radius-control); cursor: pointer; }
.control__color-swatch { width: 14px; height: 14px; border: 1px solid var(--color-control-border); border-radius: 3px; }
.control__color-swatch { cursor: pointer; flex: none; }
.control__color-hex { flex: 1; min-width: 0; padding: 0; color: inherit; font: inherit; font-size: 12px; font-weight: 500; background: transparent; border: 0; outline: 0; }
.control__color-input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.menu__group-label { padding: 6px 12px 2px; color: var(--menu-disabled); font-size: 10px; font-weight: 500; }
.control__color:focus-within { outline: 2px solid var(--color-neutral-focus); outline-offset: var(--focus-offset); }

.control__number {
  display: flex;
  align-items: center;
  box-sizing: border-box;
  width: 62px;
  height: 30px;
  justify-content: space-between;
  gap: 3px;
  padding: 0 8px 0 10px;
  border-radius: 8px;
  background: var(--color-control-surface);
}
.control__number:focus-within { outline: 2px solid var(--color-neutral-focus); outline-offset: 2px; }

.control__number input,
.control__select {
  height: 30px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--color-control-text);
  font: 500 12px var(--font-ui);
}

.control__number input { width: 100%; min-width: 0; height: 100%; text-align: left; font-size: 12px; font-variant-numeric: tabular-nums; outline: 0; }
.control__number input::-webkit-inner-spin-button, .control__number input::-webkit-outer-spin-button { appearance: none; margin: 0; }
.control__unit { flex: none; color: var(--color-unit); font-size: 10px; font-weight: 400; }

.control__slider { width: 78px; min-width: 0; height: 30px; margin: 0; appearance: none; background: transparent; cursor: pointer; }
.control__slider::-webkit-slider-runnable-track { height: 2px; border-radius: 1px; background: linear-gradient(to right, var(--slider-fill) 0 var(--range-progress, 0%), var(--slider-track) var(--range-progress, 0%) 100%); }
.control__slider::-moz-range-track { height: 2px; border-radius: 1px; background: var(--slider-track); }
.control__slider::-moz-range-progress { height: 2px; border-radius: 1px; background: var(--slider-fill); }
.control__slider::-webkit-slider-thumb { width: 12px; height: 12px; margin-top: -5px; appearance: none; border: 0; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .4); }
.control__slider::-moz-range-thumb { width: 12px; height: 12px; border: 0; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .4); }
.control__slider:focus-visible { outline: none; }
.control__slider:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 2px var(--color-neutral-focus), 0 1px 3px rgba(0, 0, 0, .4); }
.control__slider:focus-visible::-moz-range-thumb { box-shadow: 0 0 0 2px var(--color-neutral-focus), 0 1px 3px rgba(0, 0, 0, .4); }

.control__select { width: 100%; min-width: 0; }
.control__dropdown { display: flex; align-items: center; justify-content: space-between; padding: 0 8px 0 10px; border-radius: 8px; background: var(--color-control-surface); cursor: pointer; text-align: left; }
.control__dropdown-value { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.control__chevron { flex: none; color: var(--color-control-label); }

.segmented {
  display: flex;
  flex-wrap: nowrap;
  width: 150px;
  height: 30px;
  min-width: 0;
  padding: 2px;
  border: 0;
  border-radius: 8px;
  background: var(--color-control-surface);
  overflow: hidden;
}
.segmented--directions { display: grid; grid-auto-columns: minmax(0, 1fr); grid-auto-flow: column; }
.segmented--directions .segmented__item { display: grid; place-items: center; min-width: 0; padding: 0; color: var(--color-control-label); }
.segmented--directions .segmented__item.is-active { background: #3d3d3d; color: var(--color-control-text); }

.segmented[hidden] { display: none; }

.segmented__item {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  padding: var(--space-1) var(--space-2);
  border: 0;
  border-radius: var(--radius-sm);
  background: none;
  color: var(--color-muted);
  font: inherit;
  cursor: pointer;
}

.segmented__item[aria-pressed="true"] { background: var(--color-outline); color: var(--color-text); }

/* Buttons */

.panel__actions { display: flex; gap: 6px; padding-top: 6px; }

.button {
  min-height: 28px;
  padding: var(--space-1) var(--space-3);
  border: 1px solid var(--color-outline);
  border-radius: var(--radius-sm);
  background: none;
  color: var(--color-outline-text);
  font: inherit;
  cursor: pointer;
}

.panel__controls .panel__actions .button {
  height: 28px;
  min-height: 28px;
  padding: 0 12px;
  border: 0;
  border-radius: 7px;
  background: var(--color-control-surface);
  color: var(--color-action-text);
  font: 500 12px var(--font-ui);
  font-size: 12px;
  cursor: pointer;
}

.button:hover:not(:disabled) { border-color: var(--color-muted); color: var(--color-text); }
.panel__controls .panel__actions .button:hover:not(:disabled) { border-color: transparent; }
.panel__controls .panel__actions .button--primary { background: var(--color-accent); color: var(--color-on-accent); }
.panel__controls .panel__actions .button--primary:hover:not(:disabled) { border-color: var(--color-accent); color: var(--color-on-accent); filter: brightness(1.08); }
.panel__controls :is(.button, .control__dropdown, .segmented__item):focus-visible { outline: 2px solid var(--color-neutral-focus); outline-offset: 1px; }
.panel :focus-visible:not(.button--primary) { outline-color: var(--color-neutral-focus); }
.button:disabled { opacity: 0.4; cursor: default; }

.button--primary {
  border-color: var(--color-accent);
  background: var(--color-accent);
  color: var(--color-on-accent);
  font-weight: 500;
}

.button--primary:hover:not(:disabled) { border-color: var(--color-accent); color: var(--color-on-accent); filter: brightness(1.08); }

/* On this page */

.applied { margin: 0 calc(-1 * var(--panel-inset)); padding: 0 var(--panel-inset); border-top: 0; }
.applied__head { display: flex; align-items: center; justify-content: space-between; height: 48px; margin-bottom: 0; }
.applied__title { margin: 0; font-size: 13px; font-weight: 500; color: var(--color-title); }
.applied__play { display: inline-flex; align-items: center; gap: 5px; padding: 0; border: 0; background: none; color: var(--color-control-label); font: 500 12px var(--font-ui); cursor: pointer; }
.applied__play:hover:not(:disabled) { color: var(--color-title); }
.applied__play:disabled { color: var(--color-faint); cursor: default; }
.applied__play:focus-visible, .applied__remove:focus-visible, .applied__pick:focus-visible { outline: 2px solid var(--color-neutral-focus); outline-offset: var(--focus-offset); }
.applied__play svg { width: 12px; height: 12px; }
.applied__list { display: flex; flex-direction: column; gap: 10px; list-style: none; margin: 0; padding: 0 0 14px; }
.applied__item { display: grid; grid-template-columns: minmax(0, 1fr) 150px; align-items: center; gap: 8px; min-width: 0; cursor: pointer; }

.applied__pick {
  display: flex;
  align-items: center;
  min-width: 0;
  height: 30px;
  padding: 0 0 0 12px;
  background: none;
  color: var(--color-control-label);
  font: 400 12px var(--font-ui);
  text-align: left;
  cursor: pointer;
}

.applied__pick:hover, .applied__pick.is-selected { color: var(--color-control-label); }
.applied__item:has(.applied__pick.is-selected) .applied__chip { background: var(--color-chip-selected); }
.applied__name { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.applied__item[data-missing="true"] { cursor: default; }

.applied__chip {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 150px;
  min-width: 0;
  height: 30px;
  padding: 0 8px 0 10px;
  border-radius: var(--radius-md);
  background: var(--color-control-surface);
}

.applied__effect { flex: 1; min-width: 0; overflow: hidden; color: var(--color-control-text); font: 500 12px var(--font-ui); text-overflow: ellipsis; white-space: nowrap; }

.applied__remove {
  display: grid;
  place-items: center;
  flex: none;
  width: 16px;
  height: 20px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--color-control-label);
  cursor: pointer;
}

.applied__remove:hover { color: var(--color-title); }
.applied__remove svg { flex: none; }
.applied > .panel__hint { padding: 0 0 14px; color: var(--color-control-label); font-size: 12px; }

/* Code block */

.code { margin-top: var(--space-4); padding-top: var(--space-4); border-top: 1px solid var(--color-divider); }

.code__head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: var(--space-2); }
.code__title { margin: 0; font-size: inherit; font-weight: 600; }
.code__kind { color: var(--color-muted); font-size: 12px; }
.code__note { margin: 0 0 var(--space-2); color: var(--color-muted); font-size: 12px; }
.code__note[hidden] { display: none; }

.code__body {
  max-height: 240px;
  margin: 0 0 var(--space-3);
  padding: var(--space-2) var(--space-3);
  overflow-x: hidden;
  overflow-y: auto;
  border: 1px solid var(--color-divider);
  border-radius: var(--radius-sm);
  background: var(--color-bg);
  font: 12px/1.5 var(--font-mono);
  tab-size: 2;
}

.code__body code { white-space: pre-wrap; overflow-wrap: anywhere; }

/* Export dialog */

.dialog {
  width: min(720px, calc(100vw - var(--space-5) * 2));
  max-height: calc(100vh - var(--space-5) * 2);
  padding: 0;
  border: 1px solid var(--color-divider);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  color: var(--color-text);
  box-shadow: var(--shadow-float);
  overflow: auto;
}

.dialog::backdrop { background: var(--color-backdrop); }
.dialog__body { padding: var(--space-4); }
.dialog__actions { display: flex; justify-content: flex-end; gap: var(--space-2); margin-top: var(--space-4); }
.dialog__head { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--space-3); }
.dialog__title { margin: 0; font-size: 15px; font-weight: 600; }
.dialog__option { margin-bottom: var(--space-4); padding: var(--space-3); border: 1px solid var(--color-divider); border-radius: var(--radius-sm); }
.dialog__option:last-child { margin-bottom: 0; }
.dialog__heading { margin: 0 0 var(--space-1); font-size: inherit; font-weight: 600; }
.dialog__line { margin: 0 0 var(--space-3); color: var(--color-muted); font-size: 12px; }
.shortcuts__list { display: grid; grid-template-columns: 1fr auto; gap: var(--space-2) var(--space-4); margin: 0; }
.shortcuts__list dt { color: var(--color-secondary); }
.shortcuts__list dd { margin: 0; color: var(--color-title); font: 12px/1.5 var(--font-mono); }

.dialog__preview {
  max-height: 240px;
  margin: 0 0 var(--space-3);
  padding: var(--space-2) var(--space-3);
  overflow: auto;
  border: 1px solid var(--color-divider);
  border-radius: var(--radius-sm);
  background: var(--color-bg);
  font: 12px/1.5 var(--font-mono);
  white-space: pre-wrap;
}

.segmented--export { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); margin-bottom: var(--space-3); }

.dialog--narrow { width: min(440px, calc(100vw - var(--space-5) * 2)); }
.dialog__field { display: flex; gap: var(--space-2); }
.dialog__input {
  flex: 1; min-width: 0; padding: var(--space-2) var(--space-3);
  border: 1px solid var(--color-divider); border-radius: var(--radius-sm);
  background: var(--color-bg); color: var(--color-text); font: 12px/1.5 var(--font-mono);
}

.dialog__copy { width: 100%; padding: var(--space-3); font-size: 14px; }
