/* Shared interface styles, lifted from Blockmerge (index.html) so the two apps look and behave alike.
   Interface palette: --bg / --fg (fixed). Artwork palette: --art-* (set by the color pickers). */
  :root {
    --bg: #101323;   /* interface background (fixed) */
    --fg: #FCFCFD;   /* interface text + accents (fixed) */
    --art-bg: #101323;   /* canvas background (color picker) */
    --art-fg: #FCFCFD;   /* shape color (color picker) */
    --art-surface: color-mix(in srgb, var(--art-fg) 5%, var(--art-bg));
    --art-line: color-mix(in srgb, var(--art-fg) 12%, var(--art-bg));
    /* grid dots + guides depend only on the canvas background, never the shape color.
       setColors() recomputes them for each background so they always have the same
       contrast as on the default canvas (these are the default-canvas values). */
    --art-track: color-mix(in srgb, #ffffff 17%, var(--art-bg));
    --art-major: color-mix(in srgb, #ffffff 34%, var(--art-bg));
    --grid-line: color-mix(in srgb, #ffffff 8%, var(--art-bg));        /* Lines grid: every cell */
    --grid-line-major: color-mix(in srgb, #ffffff 18%, var(--art-bg)); /* Lines grid: every 4th */
    --grid-line-soft: color-mix(in srgb, #ffffff 11%, var(--art-bg));  /* Hybrid: every 4th */
    --art-muted: color-mix(in srgb, var(--art-fg) 55%, var(--art-bg));
    --surface: color-mix(in srgb, var(--fg) 4%, var(--bg));
    --surface-hover: color-mix(in srgb, var(--fg) 9%, var(--bg));
    --raised: color-mix(in srgb, var(--fg) 7%, var(--bg));
    --line: color-mix(in srgb, var(--fg) 10%, var(--bg));
    --track: color-mix(in srgb, var(--fg) 16%, var(--bg));
    --muted: color-mix(in srgb, var(--fg) 52%, var(--bg));
    --fg-hover: color-mix(in srgb, var(--fg) 86%, var(--bg));
    --sel: #4c8dff;  /* selection outlines in Select mode */
    --guide: #ff5238; /* alignment guides while dragging in Select mode */
    --font: "Inter Tight", "Helvetica Neue", Helvetica, Arial, sans-serif;
  }
  * { box-sizing: border-box; margin: 0; padding: 0; }
  html, body { height: 100%; }
  body {
    background: var(--bg);
    color: var(--fg);
    font-family: var(--font);
    -webkit-font-smoothing: antialiased;
    overflow: hidden;
  }
  button, select, input { font: inherit; color: inherit; }
  :focus-visible { outline: 2px solid var(--fg); outline-offset: 2px; }
  .hidden { display: none !important; }

  /* ---------- layout: canvas on top, dock along the bottom ---------- */
  .app { display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) auto; height: 100%; padding: 16px; gap: 12px; }
  .stage {
    position: relative; min-height: 0;
    background: var(--art-bg); color: var(--art-fg); border: 1px solid var(--line); border-radius: 16px; overflow: hidden;
  }

  /* ---------- dock ---------- */
  .dock { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 8px; }
  .group {
    position: relative; display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 2px; min-height: 44px; max-width: 100%; padding: 4px;
    background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
    transition: opacity .15s;
  }
  .group .sep { width: 1px; height: 20px; margin: 0 4px; background: var(--line); }
  .group.is-disabled { opacity: .4; pointer-events: none; }
  .btn {
    position: relative; display: grid; place-items: center; width: 36px; height: 34px;
    border: 0; border-radius: 8px; background: transparent; color: var(--muted); cursor: pointer;
    transition: background-color .12s, color .12s;
  }
  .btn:hover { background: var(--surface-hover); color: var(--fg); }
  .btn[aria-pressed="true"] { background: var(--fg); color: var(--bg); }
  .btn:disabled { opacity: .35; cursor: not-allowed; background: transparent; color: var(--muted); }
  .btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
  .btn svg .dot { fill: currentColor; stroke: none; }

  /* tooltips sit above the dock */
  [data-tip]::after {
    content: attr(data-tip); position: absolute; bottom: calc(100% + 10px); left: 50%; transform: translateX(-50%);
    white-space: nowrap; padding: 5px 8px; border-radius: 6px; font-size: 12px; font-weight: 500;
    background: var(--fg); color: var(--bg); opacity: 0; pointer-events: none; transition: opacity .12s; z-index: 20;
  }
  [data-tip]:hover::after, [data-tip]:focus-visible::after { opacity: 1; transition-delay: .35s; }
  [data-tip][aria-expanded="true"]::after { display: none; }

  .slider { position: relative; display: flex; align-items: center; gap: 6px; height: 34px; padding: 0 6px; font-size: 12px; color: var(--muted); }
  .slider .name { font-weight: 600; width: 1ch; }
  .slider .name.icon { width: 12px; height: 12px; display: grid; }
  .slider .name.icon svg { width: 12px; height: 12px; fill: currentColor; }
  .slider output { min-width: 3ch; font-variant-numeric: tabular-nums; color: var(--fg); font-weight: 500; }
  .slider input[type="range"] {
    -webkit-appearance: none; appearance: none; width: 60px; height: 4px; border-radius: 4px; cursor: pointer;
    background: var(--track) linear-gradient(var(--fg), var(--fg)) no-repeat; background-size: 50% 100%;
  }
  .slider input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none; width: 16px; height: 16px; border-radius: 50%;
    background: var(--fg); border: 3px solid var(--bg); box-shadow: 0 0 0 1px var(--fg);
  }
  .slider input[type="range"]::-moz-range-thumb {
    width: 10px; height: 10px; border-radius: 50%;
    background: var(--fg); border: 3px solid var(--bg); box-shadow: 0 0 0 1px var(--fg);
  }

  /* dock swatches: open the color picker */
  .swatch-btn {
    position: relative; display: grid; place-items: center; width: 36px; height: 34px; padding: 0;
    border: 0; border-radius: 8px; background: transparent; cursor: pointer; transition: background-color .15s;
  }
  .swatch-btn:hover, .swatch-btn[aria-expanded="true"] { background: var(--surface-hover); }
  .swatch-btn .dot { width: 22px; height: 22px; border-radius: 50%; border: 1px solid var(--track); }

  /* ---------- color picker (a plain-JS take on the WunderUI ColorPicker: same layout,
     sizes and behavior, drawn in the Blockmerge interface palette) ---------- */
  .cp {
    --ease: cubic-bezier(.22, 1, .36, 1);
    position: absolute; bottom: calc(100% + 10px); right: 0; z-index: 30;
    width: 296px; max-width: calc(100vw - 32px); display: flex; flex-direction: column; gap: 16px; padding: 16px;
    border: 1px solid var(--line); border-radius: 16px; background: var(--raised); color: var(--fg);
    box-shadow: 0 8px 16px rgb(0 0 0 / .12), 0 18px 40px rgb(0 0 0 / .32);
  }
  .cp-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
  .cp-title { font-size: 14px; font-weight: 500; }
  .cp-icon {
    flex: none; display: grid; place-items: center; width: 32px; height: 32px; padding: 0;
    border: 1px solid transparent; border-radius: 8px; background: transparent; color: var(--fg); cursor: pointer;
    transition: background-color .15s var(--ease), transform .15s var(--ease);
  }
  .cp-icon:hover { background: var(--surface-hover); }
  .cp-icon:active { transform: scale(.97); }
  .cp-icon svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
  .cp-area {
    position: relative; width: 100%; aspect-ratio: 3 / 2; border-radius: 12px; cursor: crosshair; touch-action: none; outline: none;
  }
  .cp-track { position: relative; height: 8px; border-radius: 999px; cursor: pointer; touch-action: none; outline: none;
    background: linear-gradient(to right, #f00, #ff0, #0f0, #0ff, #00f, #f0f, #f00); }
  .cp-area:focus-visible, .cp-track:focus-visible { box-shadow: 0 0 0 2px var(--raised), 0 0 0 4px var(--fg); }
  .cp-thumb {
    position: absolute; width: 14px; height: 14px; transform: translate(-50%, -50%); pointer-events: none;
    border: 2px solid #fff; border-radius: 50%; box-shadow: 0 1px 3px rgb(0 0 0 / .35);
  }
  .cp-track .cp-thumb { top: 50%; }
  .cp-row { display: flex; align-items: center; gap: 12px; }
  .cp-tracks { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 12px; padding: 4px 0; }
  .cp-value { display: flex; align-items: center; gap: 8px; }
  /* format dropdown: WunderUI NativeSelect (trigger + popup with a check on the chosen item) */
  .cp-format { position: relative; flex: none; width: 80px; height: 36px; }
  .cp-format-trigger {
    display: flex; align-items: center; justify-content: space-between; gap: 8px; width: 100%; height: 100%;
    padding: 0 8px 0 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface);
    color: var(--fg); font-size: 13px; cursor: pointer; outline: none; transition: border-color .15s var(--ease);
  }
  .cp-format-trigger:focus-visible, .cp-format-trigger[aria-expanded="true"] { border-color: var(--fg); }
  .cp-format-trigger svg { flex: none; width: 16px; height: 16px; fill: none; stroke: var(--muted); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
  .cp-menu {
    position: absolute; top: calc(100% + 4px); left: 0; z-index: 2; min-width: 128px; padding: 4px; outline: none;
    border-radius: 12px; background: color-mix(in srgb, var(--fg) 9%, var(--bg)); color: var(--fg);
    box-shadow: 0 0 0 1px color-mix(in srgb, var(--fg) 10%, transparent), 0 4px 8px rgb(0 0 0 / .1), 0 12px 28px rgb(0 0 0 / .3);
    transform-origin: top left; opacity: 0; visibility: hidden; transform: translateY(-4px) scale(.96);
    transition: opacity .15s cubic-bezier(.4, 0, 1, 1), transform .15s cubic-bezier(.4, 0, 1, 1), visibility 0s linear .15s;
  }
  .cp-menu[data-open="true"] {
    opacity: 1; visibility: visible; transform: none;
    transition: opacity .25s var(--ease), transform .25s var(--ease), visibility 0s;
  }
  .cp-option {
    position: relative; display: flex; align-items: center; padding: 6px 32px 6px 8px; border-radius: 8px;
    font-size: 14px; line-height: 20px; cursor: default; user-select: none;
  }
  .cp-option[data-highlighted] { background: color-mix(in srgb, var(--fg) 14%, var(--bg)); }
  .cp-option svg { position: absolute; right: 8px; width: 16px; height: 16px; visibility: hidden;
    fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
  .cp-option[aria-selected="true"] svg { visibility: visible; }
  @media (prefers-reduced-motion: reduce) { .cp-menu, .cp-menu[data-open="true"] { transition: none; } }
  .cp-fields {
    flex: 1; min-width: 0; display: flex; height: 36px; overflow: hidden;
    border: 1px solid var(--line); border-radius: 8px; background: var(--surface);
  }
  .cp-fields:focus-within { border-color: var(--fg); }
  .cp-fields input {
    flex: 1; min-width: 0; height: 100%; border: 0; border-right: 1px solid var(--line); background: transparent;
    text-align: center; font-size: 13px; font-variant-numeric: tabular-nums; color: var(--fg); outline: none;
  }
  .cp-fields input:last-child { border-right: 0; }
  .cp-fields input:focus { background: var(--surface-hover); }
  .cp-fields input.upper { text-transform: uppercase; }
  .cp-saved { display: flex; flex-direction: column; gap: 8px; }
  .cp-saved-head { display: flex; align-items: center; justify-content: space-between; }
  .cp-saved-head p { font-size: 12px; font-weight: 500; color: color-mix(in srgb, var(--fg) 80%, var(--bg)); }
  .cp-swatches { display: flex; flex-wrap: wrap; justify-content: space-between; row-gap: 6px; }
  .cp-swatch {
    display: grid; place-items: center; width: 24px; height: 24px; padding: 0; border: 0; border-radius: 50%;
    background: transparent; cursor: pointer; outline: none; transition: box-shadow .15s var(--ease);
  }
  .cp-swatch span {
    width: 20px; height: 20px; border-radius: 50%; box-shadow: inset 0 0 0 1px rgb(255 255 255 / .12);
    transition: width .15s var(--ease), height .15s var(--ease);
  }
  .cp-swatch[aria-selected="true"], .cp-swatch:focus-visible { box-shadow: 0 0 0 2px var(--swatch); }
  .cp-swatch[aria-selected="true"] span { width: 16px; height: 16px; }

  .primary {
    display: flex; align-items: center; gap: 6px; height: 34px; padding: 0 12px 0 14px; border: 0; border-radius: 8px;
    background: var(--fg); color: var(--bg); font-size: 13px; font-weight: 600; letter-spacing: -0.01em; cursor: pointer;
    transition: background-color .12s;
  }
  .primary:hover { background: var(--fg-hover); }
  .primary svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

  /* ---------- popovers (export, shortcuts) ---------- */
  .popover {
    position: absolute; bottom: calc(100% + 10px); right: 0; z-index: 30; min-width: 232px; padding: 6px;
    background: var(--raised); border: 1px solid var(--line); border-radius: 12px;
    box-shadow: 0 16px 40px rgba(0, 0, 0, .35);
  }
  .menu-item {
    display: flex; align-items: center; justify-content: space-between; gap: 16px; width: 100%;
    padding: 8px 10px; border: 0; border-radius: 8px; background: transparent; cursor: pointer;
    font-size: 13px; font-weight: 500; text-align: left;
  }
  .menu-item:hover { background: var(--surface-hover); }
  .menu-item small { white-space: nowrap; }
  #export-menu { min-width: 304px; }
  .dd { --ease: cubic-bezier(.22, 1, .36, 1); width: 96px; height: 30px; }
  .dd .cp-format-trigger { font-size: 12px; font-weight: 500; }
  .dd .cp-menu { left: auto; right: 0; min-width: 120px; }
  .cp-menu.up { top: auto; bottom: calc(100% + 4px); transform-origin: bottom right; transform: translateY(4px) scale(.96); }
  .cp-menu.up[data-open="true"] { transform: none; }
  .menu-item small { color: var(--muted); font-size: 12px; font-weight: 500; font-family: inherit; }
  .menu-sep { height: 1px; margin: 6px 4px; background: var(--line); }
  .check { display: flex; align-items: center; gap: 10px; padding: 8px 10px; font-size: 13px; font-weight: 500; cursor: pointer; border-radius: 8px; }
  .check:hover { background: var(--surface-hover); }
  /* checkbox: WunderUI's Checkbox, in plain CSS on the native input: the box fills, then the tick
     draws itself in (stroke-dashoffset); unchecking reverses quickly */
  .check { position: relative; --ease-entrance: cubic-bezier(.22, 1, .36, 1); }
  .check input { position: absolute; width: 1px; height: 1px; margin: 0; opacity: 0; pointer-events: none; }
  .cbx {
    position: relative; flex: none; display: grid; place-items: center; width: 16px; height: 16px; border-radius: 4px;
    border: 1px solid color-mix(in srgb, var(--fg) 30%, var(--bg)); background: color-mix(in srgb, var(--fg) 6%, transparent); color: var(--bg);
    transition: background-color 150ms var(--ease-entrance), border-color 150ms var(--ease-entrance);
  }
  .check:hover input:not(:checked) + .cbx { border-color: var(--fg); }
  .check input:focus-visible + .cbx { border-color: var(--fg); box-shadow: 0 0 0 2px color-mix(in srgb, var(--fg) 30%, transparent); }
  .check input:checked + .cbx { background: var(--fg); border-color: var(--fg); }
  .cbx svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; opacity: 0; transition: opacity 150ms var(--ease-entrance); }
  .cbx path { stroke-dasharray: 23; stroke-dashoffset: -23; transition: stroke-dashoffset 150ms var(--ease-entrance); }
  .check input:checked + .cbx svg { opacity: 1; }
  .check input:checked + .cbx path { stroke-dashoffset: 0; transition-duration: 350ms; }
  @media (prefers-reduced-motion: reduce) { .cbx, .cbx svg, .cbx path { transition: none; } }
  .menu-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; height: 34px; padding: 0 10px; font-size: 13px; font-weight: 500; }
  .menu-ctl { display: flex; align-items: center; gap: 8px; }
  .menu-ctl input[type="range"] {
    -webkit-appearance: none; appearance: none; width: 96px; height: 4px; border-radius: 4px; cursor: pointer;
    background: var(--track) linear-gradient(var(--fg), var(--fg)) no-repeat; background-size: 15% 100%;
  }
  .menu-ctl input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 14px; height: 14px; border-radius: 50%; background: var(--fg); border: 3px solid var(--raised); box-shadow: 0 0 0 1px var(--fg); }
  .menu-ctl input[type="range"]::-moz-range-thumb { width: 8px; height: 8px; border-radius: 50%; background: var(--fg); border: 3px solid var(--raised); box-shadow: 0 0 0 1px var(--fg); }
  .menu-ctl output { min-width: 2.5ch; text-align: right; font-variant-numeric: tabular-nums; color: var(--muted); font-size: 12px; }
  .menu-row select {
    height: 26px; padding: 0 6px; border-radius: 6px; border: 1px solid var(--line); background: var(--surface);
    color: var(--fg); font: 500 12px var(--font); cursor: pointer;
  }
  /* shortcuts: a sheet centered over the app (not pinned to its small dock button), grouped,
     two columns where there's room */
  .shortcuts {
    position: fixed; left: 50%; top: 50%; right: auto; bottom: auto; transform: translate(-50%, -50%); z-index: 40;
    width: min(760px, calc(100vw - 32px)); max-height: calc(100vh - 48px); overflow-y: auto; padding: 18px 22px 20px;
    border-radius: 16px; box-shadow: 0 24px 64px rgba(0, 0, 0, .45);
  }
  .shortcuts-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
  .shortcuts h2 { font-size: 15px; font-weight: 600; }
  .shortcuts-close { display: grid; place-items: center; width: 28px; height: 28px; padding: 0; border: 0; border-radius: 8px; background: transparent; color: var(--muted); cursor: pointer; }
  .shortcuts-close:hover { background: var(--surface-hover); color: var(--fg); }
  .shortcuts-close svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
  .shortcuts-cols { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px 36px; }
  @media (max-width: 640px) { .shortcuts-cols { grid-template-columns: 1fr; } }
  .shortcuts h3 { margin: 0 0 6px; font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
  .shortcuts dl { display: flex; flex-direction: column; }
  .sc-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 30px; padding: 3px 0; border-bottom: 1px solid var(--line); }
  .sc-row:last-child { border-bottom: 0; }
  .sc-row dt { font-size: 13px; color: var(--fg); }
  .sc-row dd { flex: none; display: flex; align-items: center; gap: 3px; }
  .shortcuts kbd {
    display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 5px;
    border: 1px solid var(--line); background: var(--surface); color: var(--fg); font: 500 11px var(--font); white-space: nowrap;
  }
  .sc-row .sep { padding: 0 2px; font-size: 11px; color: var(--muted); }

/* ---------- start page (from Blockmerge) ---------- */
  /* ---------- picker: always fits the stage, never scrolls ---------- */
  .picker {
    position: absolute; inset: 0; overflow: hidden; text-align: center;
    display: flex; flex-direction: column; align-items: center;
    background: var(--bg); color: var(--fg); /* interface colors; only the tiles preview the artwork colors */
    padding: clamp(16px, 6vh, 64px) 24px clamp(16px, 4vh, 40px);
  }
  .picker h1 {
    font-size: clamp(26px, min(4vw, 6.5vh), 64px); font-weight: 500; letter-spacing: -0.035em; line-height: 1;
    margin-bottom: .3em;
  }
  .picker p { font-size: clamp(14px, min(1.4vw, 2.2vh), 20px); line-height: 1.4; color: var(--muted); }
  /* the grid takes whatever height is left; layoutGrid() picks the column count that
     gives the biggest tiles for the space (3 x 3 on squarish screens, 5 x 2 on wide short ones) */
  .grid {
    flex: 1 1 0; min-height: 0; width: 100%; max-width: 600px; margin-top: clamp(12px, 4vh, 48px);
    display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); grid-template-rows: repeat(3, minmax(0, 1fr));
    gap: clamp(6px, 2.5vh, 32px) 16px;
  }
  /* your drawings: one row that scrolls sideways, so the start page itself never scrolls */
  .library { --lib: clamp(52px, 9vh, 76px); flex: none; width: 100%; max-width: 720px; margin-top: clamp(12px, 3vh, 32px); }
  .library-head { display: flex; justify-content: space-between; align-items: baseline; margin: 0 2px 8px; font-size: 12px; font-weight: 600; color: var(--muted); }
  .library-head .count { font-weight: 500; }
  .library-row {
    display: flex; gap: 12px; justify-content: safe center; overflow-x: auto; overflow-y: hidden;
    padding: 2px 2px 8px; scroll-snap-type: x proximity; scrollbar-width: thin; scrollbar-color: var(--track) transparent;
  }
  .lib-card { position: relative; flex: none; width: calc(var(--lib) + 8px); display: flex; flex-direction: column; align-items: center; gap: 6px; scroll-snap-align: start; }
  .lib-open {
    width: var(--lib); height: var(--lib); padding: 0; display: grid; place-items: center; cursor: pointer;
    border-radius: 12px; background: var(--art-bg); border: 1px solid var(--line); transition: border-color .12s, transform .12s;
  }
  .lib-open:hover { border-color: var(--muted); transform: translateY(-2px); }
  .lib-open svg { width: 72%; height: 72%; }
  .lib-name {
    max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    font-size: 12px; font-weight: 500; line-height: 16px; color: var(--muted); cursor: text;
  }
  .lib-card:hover .lib-name { color: var(--fg); }
  .lib-rename {
    width: calc(var(--lib) + 24px); height: 20px; padding: 0 6px; border-radius: 6px; text-align: center;
    border: 1px solid var(--fg); background: var(--surface); color: var(--fg); font: 500 12px var(--font); outline: none;
  }
  .lib-more {
    position: absolute; top: 4px; right: 8px; width: 22px; height: 22px; padding: 0; display: grid; place-items: center;
    border-radius: 6px; border: 1px solid var(--line); background: var(--raised); color: var(--fg); cursor: pointer;
    opacity: 0; transition: opacity .12s;
  }
  .lib-more svg { width: 14px; height: 14px; fill: currentColor; }
  .lib-card:hover .lib-more, .lib-more:focus-visible, .lib-more[aria-expanded="true"] { opacity: 1; }
  @media (hover: none) { .lib-more { opacity: 1; } }
  .lib-menu { position: fixed; bottom: auto; right: auto; min-width: 168px; text-align: left; }
  .menu-item.danger { color: #ff6b5e; }
  .menu-item.danger.confirm { background: color-mix(in srgb, #ff6b5e 16%, transparent); }
  .picker-actions { flex: none; display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 8px; margin-top: clamp(10px, 2.5vh, 24px); }
  .shuffle {
    display: inline-flex; align-items: center; gap: 8px; height: 34px; padding: 0 14px 0 11px;
    border: 1px solid var(--line); border-radius: 999px; background: var(--surface); cursor: pointer;
    font-size: 13px; font-weight: 600; color: var(--fg); transition: background-color .12s, transform .12s;
  }
  .shuffle:hover { background: var(--surface-hover); }
  .shuffle:active { transform: scale(.97); }
  .shuffle svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; transition: transform .35s; }
  .shuffle svg .pip { fill: currentColor; stroke: none; }
  .shuffle:hover svg { transform: rotate(-12deg); }
  .shuffle kbd { font-family: inherit; font-size: 11px; font-weight: 600; color: var(--muted); padding: 1px 5px; border: 1px solid var(--line); border-radius: 4px; }
  .originals {
    height: 34px; padding: 0 10px; border: 0; border-radius: 999px; background: none; cursor: pointer;
    font-size: 13px; font-weight: 500; color: var(--muted);
  }
  .originals:hover { color: var(--fg); background: var(--surface); }
  @keyframes tile-in { from { opacity: 0; transform: scale(.82); } to { opacity: 1; transform: none; } }
  .thumb.pop .box { animation: tile-in .32s cubic-bezier(.2, .9, .3, 1.2) both; animation-delay: var(--delay, 0ms); }
  @media (prefers-reduced-motion: reduce) { .thumb.pop .box { animation: none; } }
  /* each cell is a size container, so the tile scales to whatever room the cell has */
  .thumb {
    container-type: size; min-width: 0; min-height: 0;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    border: 0; background: none; border-radius: 14px;
    pointer-events: none; /* the cell can be much taller than the card: only the square takes clicks */
  }
  .thumb .box { pointer-events: auto; cursor: pointer; }
  .thumb:focus-visible { outline: none; }
  .thumb:focus-visible .box { outline: 2px solid var(--fg); outline-offset: 3px; }
  .thumb .box {
    --tile: min(160px, 100cqw, calc(100cqh - 28px));
    width: var(--tile); height: var(--tile); flex: none;
    border-radius: 14px; display: grid; place-items: center;
    background: var(--art-bg); /* a little preview of the canvas */
    border: 1px solid transparent; transition: background-color .12s, border-color .12s, transform .12s;
  }
  .thumb .box svg { width: 60%; height: 60%; }
  .thumb:hover .box { background: var(--art-surface); border-color: var(--line); transform: translateY(-2px); }
  .thumb .name {
    max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    margin-top: 8px; font-size: 13px; font-weight: 500; line-height: 1.15; color: var(--muted); transition: color .12s;
  }
  .thumb:hover .name { color: var(--fg); }
  .picker :focus-visible { outline-color: var(--fg); }
  @media (max-height: 520px) {
    .picker p { display: none; }
  }
