/* ==========================================================================
   EMBROIDERY LABS - css/editor.css
   Editor-only pieces. Loaded after css/base.css by app.html and by nothing else.
   Uses only tokens from base.css. Breakpoints: 1100px (tablet), 720px (phone).
   ========================================================================== */

html, body { height: 100%; overflow: hidden; overscroll-behavior: none; }

/* ---------- Shell ---------------------------------------------------------- */
.ed { display: grid; height: 100dvh; overflow: hidden; background: var(--bg);
  --tabs-h: 36px; --top-h: calc(var(--bar-h) + var(--tabs-h));   /* top bar + the row of design tabs */
  grid-template:
    "bar  bar  bar   bar"  var(--bar-h)
    "tabs tabs tabs  tabs" var(--tabs-h)
    "rail insp stage side" minmax(0, 1fr)
    "stat stat stat  stat" var(--status-h)
    / var(--rail-w) 272px minmax(0, 1fr) 264px; }

/* ---------- Top bar -------------------------------------------------------- */
.ed-bar { grid-area: bar; display: flex; align-items: center; gap: var(--s-2); padding: 0 var(--s-2); background: var(--panel); border-bottom: 1px solid var(--line-1); min-width: 0; }
.ed-bar > .brand { padding: 0 var(--s-1); }
.ed-bar__file { display: flex; align-items: center; gap: 2px; min-width: 0; height: var(--ctl-h); padding: 0 var(--s-2); border: 1px solid transparent; border-radius: var(--r-1); background: transparent; font-weight: 600; white-space: nowrap; overflow: hidden; }
.ed-bar__file:hover, .ed-bar__file:focus-within { border-color: var(--line-3); background: var(--raised); }
.ed-bar__file > input { all: unset; width: 14ch; min-width: 4ch; max-width: 28ch; font-weight: 600; text-overflow: ellipsis; }
@supports (field-sizing: content) { .ed-bar__file > input { width: auto; field-sizing: content; } }
.ed-bar__file > .num { color: var(--ink-3); font-size: var(--fs-1); }
.ed-bar__sep { width: 1px; align-self: stretch; background: var(--line-1); margin: 0 var(--s-1); flex: none; }
.ed-bar__spacer { flex: 1; }

/* ---------- Tool rail ------------------------------------------------------ */
.rail { grid-area: rail; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 4px 0; background: var(--panel); border-right: 1px solid var(--line-1); overflow-y: auto; scrollbar-width: none; }
.tool { position: relative; display: grid; place-items: center; flex: none; width: calc(var(--rail-w) - 8px); height: calc(var(--rail-w) - 8px); border: 1px solid transparent; border-radius: var(--r-1); background: transparent; color: var(--ink-2); cursor: pointer; }
.tool svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.tool:hover { background: var(--hover); color: var(--ink-1); }
.tool[aria-pressed="true"] { background: var(--signal-wash); color: var(--signal-text); }
.tool__key { position: absolute; right: 2px; bottom: 1px; font: 500 9px/1 var(--font-mono); opacity: .75; }
.rail__sep { width: 20px; height: 1px; margin: 4px 0; background: var(--line-1); flex: none; }
.rail__end { margin-top: auto; }
.rail__end svg { color: var(--bad); }

/* ---------- Side panels ---------------------------------------------------- */
.pane { display: flex; flex-direction: column; min-height: 0; background: var(--panel); overflow-y: auto; scrollbar-width: thin; scrollbar-color: var(--line-2) transparent; }
.pane--insp { grid-area: insp; border-right: 1px solid var(--line-1); }
.pane--side { grid-area: side; border-left: 1px solid var(--line-1); }
.pane > .tabs { flex: none; padding: 6px var(--s-2); border-bottom: 1px solid var(--line-1); }
.pane__fill { flex: 1; min-height: 0; overflow-y: auto; }
.sec { border-bottom: 1px solid var(--line-1); }
.sec__head { position: sticky; top: 0; z-index: 1; display: flex; align-items: center; justify-content: space-between; gap: var(--s-2); width: 100%; height: 32px; padding: 0 var(--s-3); border: 0; background: var(--panel); cursor: pointer; text-align: left; }
button.sec__head::before { content: ""; width: 5px; height: 5px; border: solid var(--ink-3); border-width: 0 1.5px 1.5px 0; transform: translateY(-1px) rotate(45deg); transition: transform var(--t-1) var(--ease); }
button.sec__head[aria-expanded="false"]::before { transform: rotate(-45deg); }
.sec__head > .label { flex: 1; color: var(--ink-1); font-weight: var(--w-semi); }
.sec__head > .num { font-size: 10px; color: var(--ink-3); }
div.sec__head { cursor: default; }
.sec__body { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--s-1); padding: 0 var(--s-3) var(--s-3); }
/* property grid: the label column is fixed so every control edge lines up */
.prop { display: grid; grid-template-columns: 76px minmax(0, 1fr); align-items: center; column-gap: var(--s-2); min-height: var(--row-h); }
.prop > .seg { display: grid; width: 100%; }
.prop--stack { grid-template-columns: minmax(0, 1fr); row-gap: 2px; padding: 2px 0; }
.prop__pair { display: grid; grid-template-columns: minmax(0, 1fr) 76px; gap: var(--s-2); align-items: center; }
/* thread colour well: swatch + hex, opens the native colour picker */
.thread-well { position: relative; display: flex; align-items: center; gap: var(--s-2); height: var(--ctl-h); padding: 0 var(--s-2); border: 1px solid var(--line-2); border-radius: var(--r-1); background: var(--raised); }
.thread-well:hover { border-color: var(--ink-3); }
.thread-well:focus-within { outline: 2px solid var(--signal); outline-offset: 1px; }
.thread-well > input[type="color"] { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.thread-well > .num { font-size: var(--fs-2); text-transform: uppercase; }

/* ---------- Layer / stitch sequence list ----------------------------------- */
.layers { display: block; }
.layer { display: grid; grid-template-columns: 18px 14px 14px minmax(0, 1fr) auto auto; align-items: center; gap: var(--s-2); width: 100%; height: var(--row-h); padding: 0 var(--s-2) 0 var(--s-3); border: 0; border-bottom: 1px solid var(--line-1); background: transparent; text-align: left; cursor: pointer; font-size: var(--fs-2); }
.layer:hover { background: var(--hover); }
.layer[aria-selected="true"] { background: var(--signal-wash); }
.layer > .idx { color: var(--ink-3); font-size: 10px; text-align: right; }
.layer > .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.layer > .count { color: var(--ink-2); font-size: var(--fs-1); }
.layer__del { display: grid; place-items: center; width: 22px; height: 22px; border: 0; border-radius: var(--r-1); background: transparent; color: var(--ink-3); opacity: 0; }
.layer:hover .layer__del, .layer[aria-selected="true"] .layer__del, .layer__del:focus-visible { opacity: 1; }
.layer__del:hover { color: var(--bad); background: var(--bad-wash); }
.layer__del svg { width: 12px; height: 12px; fill: none; stroke: currentColor; stroke-width: 1.5; }
@media (pointer: coarse) { .layer__del { opacity: 1; width: 44px; height: 44px; } }
.glyph { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.25; color: var(--ink-2); }
.layers__empty { display: grid; gap: var(--s-2); justify-items: start; padding: var(--s-4) var(--s-3); color: var(--ink-2); font-size: var(--fs-2); }

/* ---------- Stat read-outs ------------------------------------------------- */
.seq { display: flex; height: 8px; margin: 0 var(--s-3) var(--s-3); border-radius: var(--r-round); background: var(--sunken); overflow: hidden; }
.seq > i { display: block; background: var(--c, var(--ink-1)); border-left: 1px solid var(--raised); min-width: 0; }
.seq > i:first-child { border-left: 0; }
.stats { display: grid; grid-template-columns: 1fr 1fr; border-top: 1px solid var(--line-1); }
.stats > div { display: grid; gap: 2px; padding: var(--s-2) var(--s-3); border-bottom: 1px solid var(--line-1); border-right: 1px solid var(--line-1); min-width: 0; }
.stats > div:nth-child(even) { border-right: 0; }
.stats .num { font-size: var(--fs-3); font-weight: 500; white-space: nowrap; }
.preview { margin: var(--s-3); border: 1px solid var(--line-1); border-radius: var(--r-1); background: var(--fabric); aspect-ratio: 1; display: grid; place-items: center; overflow: hidden; }
.preview > canvas { width: 100%; height: 100%; }

/* ---------- Stage: rulers on two edges, hoop on the work surface ----------- */
.stage { grid-area: stage; position: relative; display: grid; min-width: 0; min-height: 0;
  grid-template: "corner rx" 20px "ry view" minmax(0, 1fr) / 20px minmax(0, 1fr); }
.stage__corner { grid-area: corner; display: grid; place-items: center; padding: 0; border: 0; background: var(--panel); border-right: 1px solid var(--line-1); border-bottom: 1px solid var(--line-1); font: 600 9px/1 var(--font-ui); color: var(--ink-3); cursor: pointer; }
.stage__corner:hover { color: var(--signal-text); background: var(--hover); }
.stage__corner:focus-visible { outline-offset: -2px; }
/* Rulers: view.js sets --ox / --oy (px offset of zero), --tick (px between small ticks) and
   --major (px between long ticks). Works the same for inches and millimetres. */
.ruler-x, .ruler-y { position: relative; overflow: hidden; background-color: var(--panel); --tick: 4px; --major: 40px; }
.ruler-x { grid-area: rx; border-bottom: 1px solid var(--line-1); background-image:
  repeating-linear-gradient(90deg, var(--line-2) 0 1px, transparent 1px var(--major)),
  repeating-linear-gradient(90deg, var(--line-3) 0 1px, transparent 1px var(--tick));
  background-size: 100% 100%, 100% 5px; background-position: var(--ox, 0) 0, var(--ox, 0) 100%; background-repeat: repeat-x; }
.ruler-y { grid-area: ry; border-right: 1px solid var(--line-1); background-image:
  repeating-linear-gradient(180deg, var(--line-2) 0 1px, transparent 1px var(--major)),
  repeating-linear-gradient(180deg, var(--line-3) 0 1px, transparent 1px var(--tick));
  background-size: 100% 100%, 5px 100%; background-position: 0 var(--oy, 0), 100% var(--oy, 0); background-repeat: repeat-y; }
.ruler-x > b, .ruler-y > b { position: absolute; font: 500 9px/1 var(--font-ui); color: var(--ink-3); }
.ruler-x > b { top: 2px; } .ruler-y > b { left: 2px; writing-mode: vertical-rl; }
.ruler-x > .cursor, .ruler-y > .cursor { position: absolute; background: var(--signal); pointer-events: none; }
.ruler-x > .cursor { top: 0; bottom: 0; width: 1px; } .ruler-y > .cursor { left: 0; right: 0; height: 1px; }
.view { grid-area: view; position: relative; overflow: hidden; display: grid; place-items: center; background: var(--grid); background-color: var(--bg); touch-action: none; }
.view[data-tool="pan"] { cursor: grab; } .view[data-tool="pen"], .view[data-tool="line"], .view[data-tool="rect"], .view[data-tool="ellipse"], .view[data-tool="polygon"] { cursor: crosshair; }
/* The hoop is the fabric. Canvases are stacked inside it. */
.hoop { position: relative; background: var(--fabric); border-radius: 6px; box-shadow: 0 0 0 1px var(--line-3), 0 10px 30px rgb(43 45 49 / .08); color: var(--fabric-ink); }
.hoop > canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.hoop__dim { position: absolute; left: 0; right: 0; top: calc(100% + 8px); }
.view.is-over .hoop { box-shadow: 0 0 0 2px var(--signal); }   /* file dragged over the stage */
/* Floating zoom cluster */
.hud { position: absolute; right: var(--s-3); bottom: var(--s-3); display: flex; align-items: center; background: var(--raised); border: 1px solid var(--line-1); border-radius: var(--r-1); box-shadow: var(--shadow-soft); overflow: hidden; }
.hud > button { display: grid; place-items: center; width: var(--ctl-h); height: var(--ctl-h); border: 0; border-left: 1px solid var(--line-1); background: transparent; color: var(--ink-2); cursor: pointer; }
.hud > button:first-child { border-left: 0; }
.hud > button:hover { background: var(--hover); color: var(--ink-1); }
.hud > button svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.5; }
.hud > .num { display: flex; align-items: center; justify-content: flex-end; min-width: 52px; height: var(--ctl-h); padding: 0 var(--s-2); border-left: 1px solid var(--line-1); font-size: var(--fs-1); }
/* inside the editor the toast log lives in the stage, so it never covers a panel */
.view > .toasts { position: absolute; left: var(--s-3); bottom: var(--s-3); }

/* ---------- Status bar: a quiet strip of read-outs -------------------------- */
.status { grid-area: stat; display: flex; align-items: stretch; background: var(--panel); border-top: 1px solid var(--line-1); overflow: hidden; }
.status > * { display: flex; align-items: center; gap: 6px; padding: 0 var(--s-3); white-space: nowrap; }
.status > .grow { flex: 1; border-right: 0; }
.status > :last-child { border-right: 0; }
.status .num { font-size: var(--fs-1); }

/* ---------- Phone pieces (hidden on desktop) ------------------------------- */
.dock { grid-area: dock; position: relative; z-index: var(--z-dock); display: none; align-items: stretch; background: var(--panel); border-top: 1px solid var(--line-1); padding-bottom: env(safe-area-inset-bottom, 0px); }
.dock > button { flex: 1; display: grid; place-items: center; align-content: center; gap: 3px; min-width: 0; border: 0; margin: 4px 2px; border-radius: var(--r-1); background: transparent; color: var(--ink-2);
  font: var(--w-medium) 10px/1 var(--font-ui); }
.dock > button svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.5; }
.dock > [aria-pressed="true"], .dock > [aria-expanded="true"] { background: var(--signal-wash); color: var(--signal-text); }
.dock > button:focus-visible { outline-offset: -3px; }
/* Sheet. One wrapper around BOTH side panels, so nothing is duplicated or moved:
   - desktop / tablet: display: contents - the panels sit in the .ed grid as usual
   - phone: a fixed bottom sheet with three detents; data-tab picks the panel.
   JS sets data-detent ("peek" | "half" | "full") and data-tab ("insp" | "side"),
   or --sheet-h in px while the grip is dragged. */
.sheet { display: contents; }
.sheet__grip, .sheet__peek, .sheet__tabs { display: none; }
/* "More" menu: the tools that do not fit in the dock, plus Clear and Help */
.more { position: fixed; right: var(--s-2); bottom: calc(var(--dock-h) + env(safe-area-inset-bottom, 0px) + var(--s-2)); z-index: calc(var(--z-dock) + 1); display: grid; min-width: 200px; border-radius: var(--r-0); background: var(--raised); box-shadow: var(--shadow-pop); overflow: hidden; }
.more > button { display: flex; align-items: center; gap: var(--s-3); height: 44px; padding: 0 var(--s-3); border: 0; border-bottom: 1px solid var(--line-1); background: transparent; text-align: left; font: var(--w-semi) var(--fs-3)/1 var(--font-ui); }
.more > button:last-child { border-bottom: 0; }
.more > button svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.5; }
.more > button[aria-pressed="true"] { background: var(--signal-wash); color: var(--signal-text); }
.more > .more__danger { color: var(--bad); }

/* ---------- Tablet: the right panel becomes an overlay drawer -------------- */
.ed-bar__drawer { display: none; }
@media screen and (max-width: 1100px) {
  .ed { grid-template:
    "bar  bar  bar"   var(--bar-h)
    "tabs tabs tabs"  var(--tabs-h)
    "rail insp stage" minmax(0, 1fr)
    "stat stat stat"  var(--status-h)
    / var(--rail-w) 256px minmax(0, 1fr); }
  .ed-bar__drawer { display: inline-flex; }
  .pane--side { position: fixed; top: var(--top-h); bottom: var(--status-h); right: 0; width: 280px; z-index: var(--z-drawer); border-left: 1px solid var(--line-1); box-shadow: var(--shadow-sheet); transform: translateX(100%); visibility: hidden; transition: transform var(--t-3) var(--ease), visibility 0s linear var(--t-3); }
  .pane--side.is-open { transform: none; visibility: visible; transition-delay: 0s; }
}
/* ---------- Phone: canvas first, tools along the bottom, the rest in the sheet */
@media screen and (max-width: 720px) {
  .ed { grid-template: "bar" var(--bar-h) "tabs" var(--tabs-h) "stage" minmax(0, 1fr) "dock" calc(var(--dock-h) + env(safe-area-inset-bottom, 0px)) / 100%; }
  .rail, .status, .ed-bar__drawer, .ed-bar .seg, .ed-bar__state, .ed-bar__help, .ed-bar__sep, .ed-bar .brand > span, .ed-bar .filemenu { display: none; }   /* File lives in the More menu on phones */
  .ed-bar__file { flex: 1; }
  .ed-bar__file > input { flex: 1; width: auto; max-width: none; }
  .ed-bar__spacer { display: none; }
  .ed-bar .btn kbd { display: none; }
  .stage { grid-template: "view" minmax(0, 1fr) / minmax(0, 1fr); }
  .stage__corner, .ruler-x, .ruler-y { display: none; }
  .dock { display: flex; }
  .sheet { display: flex; flex-direction: column; position: fixed; left: 0; right: 0; bottom: calc(var(--dock-h) + env(safe-area-inset-bottom, 0px)); z-index: var(--z-sheet);
    height: var(--sheet-h, 60px); max-height: calc(100dvh - var(--top-h) - var(--dock-h) - env(safe-area-inset-bottom, 0px));
    background: var(--panel); border-radius: var(--r-0) var(--r-0) 0 0; box-shadow: var(--shadow-sheet); overflow: hidden; transition: height var(--t-3) var(--ease); }
  .sheet[data-detent="peek"] { --sheet-h: 60px; }
  .sheet[data-detent="half"] { --sheet-h: 46dvh; }
  .sheet[data-detent="full"] { --sheet-h: 100dvh; }
  .sheet.is-dragging { transition: none; }
  /* the grip is a 44px target: it reaches down behind the read-outs of the peek row, which let presses through */
  .sheet__grip { position: relative; display: grid; place-items: start center; width: 100%; height: 44px; margin-bottom: -28px; padding: 6px 0 0; flex: none; border: 0; background: transparent; cursor: grab; touch-action: none; }
  .sheet__grip:focus-visible { outline-offset: -3px; }
  .sheet__peek { position: relative; display: flex; align-items: center; gap: var(--s-4); height: 44px; padding: 0 var(--s-4); flex: none; overflow: hidden; pointer-events: none; }
  .sheet__peek > .btn { pointer-events: auto; }
  .sheet__tabs { display: flex; flex: none; padding: 0 var(--s-2); }
  .sheet .pane { position: static; flex: 1; width: auto; min-height: 0; border: 0; transform: none; visibility: visible; overscroll-behavior: contain; padding-bottom: var(--s-5); }
  .sheet .pane > * { flex: none; }   /* rows keep their height; the pane scrolls as one */
  .sheet .pane__fill { display: none; }
  .sheet .preview { width: 50%; align-self: center; }
  .sheet[data-tab="insp"] .pane--side, .sheet[data-tab="side"] .pane--insp { display: none; }
  .sheet[data-detent="peek"] .pane, .sheet[data-detent="peek"] .sheet__tabs { display: none; }   /* out of the tab order */
  .sheet .sec__body { padding: var(--s-3) var(--s-4); }
  .sheet .prop { grid-template-columns: 96px minmax(0, 1fr); }
  .hud { right: var(--s-2); bottom: calc(60px + var(--s-2)); }   /* clears the peek sheet */
  .view > .toasts { left: var(--s-2); right: var(--s-2); top: calc(var(--ctl-h) + 2 * var(--s-2)); bottom: auto; width: auto; max-width: none; }   /* under the view switch */
}

/* ==========================================================================
   Added with the editor scripts (js/editor). Everything below is driven by
   state the scripts set: data-live, data-tool, is-*, [hidden], aria-*.
   ========================================================================== */

/* ---------- Live stage ------------------------------------------------------
   Once view.js runs it sets data-live on the view and places the hoop itself:
   --ox / --oy = px offset of 0 mm inside the view, --vw / --vh = view size.
   The main canvas is stretched back over the WHOLE view, so shapes, handles
   and the marquee are never cropped at the edge of the hoop. */
.view[data-live] { display: block; }
.view[data-live] > .hoop { position: absolute; left: var(--ox, 0); top: var(--oy, 0); }
.view[data-live] #main-canvas, .view[data-live] #trace-canvas { inset: auto; left: calc(-1 * var(--ox, 0px)); top: calc(-1 * var(--oy, 0px)); width: var(--vw, 100%); height: var(--vh, 100%); max-width: none; max-height: none; touch-action: none; }
#main-canvas:focus-visible { outline-offset: -3px; }
#trace-canvas { pointer-events: none; }
.hoop__dim { pointer-events: none; }
.ruler-x > b, .ruler-y > b { pointer-events: none; }
/* cursors: the select tool sets its own (move, resize) inline on the view */
.view[data-tool="eraser"] { cursor: cell; }
.view.is-panning, .view.is-panning[data-tool] { cursor: grabbing !important; }
.view.is-pan-ready { cursor: grab !important; }

/* ---------- Top bar: export split button + format menu ---------------------- */
/* BASE-CANDIDATE: .split (a primary button with a "more" arrow) and .menu (a small popup of role=menuitem buttons) */
.split { position: relative; display: inline-flex; flex: none; }
.split > .btn:first-child { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.split > .split__more { width: 24px; min-width: 24px; margin-left: 1px; border-top-left-radius: 0; border-bottom-left-radius: 0; }
.split > .btn[aria-disabled="true"] + .split__more { margin-left: -1px; }
.menu { position: absolute; top: calc(100% + 4px); right: 0; z-index: var(--z-tip); display: grid; min-width: 240px; padding: 4px; border-radius: 12px; background: var(--raised); box-shadow: var(--shadow-pop); }
.menu > button { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: baseline; gap: 2px var(--s-3); padding: 7px var(--s-2); border: 0; border-radius: var(--r-1); background: transparent; color: var(--ink-1); text-align: left; cursor: pointer; font: var(--w-semi) var(--fs-2)/1.2 var(--font-ui); }
.menu > button > small { grid-column: 1 / -1; color: var(--ink-3); font-weight: 400; font-size: var(--fs-1); }
.menu > button > .num { color: var(--ink-3); font-size: var(--fs-1); }
.menu > button:hover, .menu > button:focus-visible { background: var(--hover); }
.menu > button:focus-visible { outline-offset: -2px; }
.menu--left { right: auto; left: 0; }
.menu > button > .num { justify-self: end; }
.filemenu { position: relative; display: inline-flex; flex: none; }
.filemenu > .btn { padding: 0 var(--s-2); }
.tag.is-busy { border-style: dashed; }

/* ---------- Properties: controls that do nothing for the selection ---------- */
.prop.is-off > .label { color: var(--ink-3); }
.prop.is-off .slider { opacity: .35; cursor: not-allowed; }
.prop.is-off .input-unit { border-color: var(--line-1); background: transparent; }
.prop.is-off .input-unit > input { color: var(--ink-3); cursor: not-allowed; }
.prop.is-off .seg { opacity: .55; }
.seg > button[disabled] { color: var(--ink-3); cursor: not-allowed; background: transparent; box-shadow: none; }
.sec__head > .num#insp-target { max-width: 60%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Sewing order: header tools, drag to reorder, rename, flags ------ */
.sec__tools { display: inline-flex; gap: 2px; margin-right: -6px; }
.mini { display: grid; place-items: center; width: 22px; height: 22px; padding: 0; border: 1px solid transparent; border-radius: var(--r-1); background: transparent; color: var(--ink-2); cursor: pointer; }
.mini svg { width: 12px; height: 12px; fill: none; stroke: currentColor; stroke-width: 1.5; }
.mini:hover { background: var(--hover); color: var(--ink-1); }
.mini[disabled] { color: var(--line-2); cursor: not-allowed; background: transparent; }
.layers { max-height: 46vh; overflow-y: auto; scrollbar-width: thin; scrollbar-color: var(--line-2) transparent; }
/* a long sewing order must not squash the preview and read-outs under it: the list gives way, then the panel scrolls */
.pane--side > .sec__head, .pane--side > .preview, .pane--side > .seq, .pane--side > .stats, .pane--side > .warns { flex: none; }
.pane--side > .layers { flex: 0 1 auto; min-height: 112px; }
.layer { position: relative; user-select: none; -webkit-user-select: none; touch-action: pan-y; }
.layer:focus-visible { outline-offset: -2px; }
.layer.is-dragging { opacity: .45; }
.layer.is-drop-before::before, .layer.is-drop-after::after { content: ""; position: absolute; left: 0; right: 0; height: 2px; background: var(--signal); pointer-events: none; }
.layer.is-drop-before::before { top: -1px; }
.layer.is-drop-after::after { bottom: -1px; }
.layers.is-sorting, .layers.is-sorting .layer { cursor: grabbing; }
.layer > .count { display: inline-flex; align-items: center; gap: 4px; }
.layer > .name[data-editing] { visibility: hidden; }
.layer__rename { position: absolute; left: 68px; right: 6px; top: 3px; bottom: 3px; padding: 0 4px; border: 1px solid var(--signal); border-radius: var(--r-2); background: var(--raised); color: var(--ink-1); font: 500 var(--fs-2)/1 var(--font-ui); min-width: 0; }
.flag { display: inline-grid; place-items: center; width: 12px; height: 12px; border-radius: 50%; background: var(--warn); color: var(--raised); font: 700 9px/1 var(--font-ui); flex: none; }
.flag--error { background: var(--bad); }
.layers__empty[hidden] { display: none; }

/* ---------- Groups in the sewing order: a row with a caret, its shapes indented under it ---------- */
.layer--group { grid-template-columns: 18px 14px minmax(0, 1fr) auto auto; }
.layer--group > .name { font-weight: var(--w-semi); }
.layer--group > .glyph--group { color: var(--ink-3); }
.layer__caret { display: grid; place-items: center; width: 18px; height: 22px; padding: 0; border: 0; border-radius: var(--r-2); background: transparent; color: var(--ink-3); cursor: pointer; }
.layer__caret:hover { background: var(--hover); color: var(--ink-1); }
.layer__caret svg { width: 12px; height: 12px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.layer__ungroup:hover { color: var(--ink-1); background: var(--hover); }
.layer__ungroup svg { stroke-dasharray: 2 1.5; }
.layer--child { padding-left: calc(var(--s-3) + 14px); background-image: linear-gradient(var(--line-3), var(--line-3)); background-size: 1px 100%; background-position: calc(var(--s-3) + 5px) 0; background-repeat: no-repeat; }
.layer--child.is-in-picked { background: color-mix(in srgb, var(--signal) 7%, var(--raised)); }
.layer--child.is-in-picked:hover { background: var(--hover); }
.layer--group[aria-selected="true"] .layer__del { opacity: 1; }
.layer--group .layer__rename { left: 44px; }
.layer--child .layer__rename { left: 82px; }
.layer.is-drop-in::before, .layer.is-drop-in.is-drop-after::after { left: calc(var(--s-3) + 14px); }
@media (pointer: coarse) { .layer__caret { width: 18px; height: 44px; } }

/* ---------- Engine warnings under the stats ---------------------------------- */
.warns { display: grid; border-top: 1px solid var(--line-1); }
.warn { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: var(--s-2); align-items: start; width: 100%; padding: var(--s-2) var(--s-3); border: 0; border-bottom: 1px solid var(--line-1); background: transparent; color: var(--ink-2); text-align: left; font-size: var(--fs-1); line-height: 1.35; }
.warn:last-child { border-bottom: 0; }
button.warn { cursor: pointer; }
button.warn:hover { background: var(--hover); color: var(--ink-1); }
button.warn:focus-visible { outline-offset: -2px; }
.warn > .flag { margin-top: 1px; }
.warn--info > .flag { background: var(--ink-3); }
.warn b { color: var(--ink-1); font-weight: 600; }

/* ---------- Phone: keep the bar inside 390px ---------------------------------- */
@media screen and (max-width: 720px) {
  .ed-bar { gap: var(--s-1); padding: 0 var(--s-1); }
  .ed-bar__file { padding: 0 var(--s-1); }
  .ed-bar__file > input { min-width: 0; }
  .menu { position: fixed; top: calc(var(--bar-h) + 4px); right: var(--s-2); left: var(--s-2); min-width: 0; }
  .layers { max-height: none; }
  .more[hidden] { display: none; }
}

/* ==========================================================================
   Part 2: file import, picture to trace, playback, empty state, help,
   phone / tablet fit. Same rule as above: only tokens, only state set by JS.
   ========================================================================== */

/* ---------- Top bar: keep every control at tablet widths ---------------------- */
/* the saved tag gives way first: when it no longer fits it wraps out of sight */
.ed-bar__state { display: flex; flex-wrap: wrap; align-items: center; flex: 0 1000 auto; min-width: 0; height: 18px; overflow: hidden; }
.ed-bar__state::before { content: ""; width: 0; height: 18px; }
.ed-bar .seg, .ed-bar > .btn { flex: none; }
@media (pointer: coarse) {
  .split > .split__more { width: 44px; min-width: 44px; }
  .ed-bar > .brand { justify-content: center; min-width: 44px; min-height: 44px; }
  .mini { width: 44px; height: 44px; }
  .prop__pair { grid-template-columns: minmax(0, 1fr) 88px; }
}

/* ---------- Stage: view switch (phone), playback, empty hoop ------------------ */
.view__mode { position: absolute; left: var(--s-2); top: var(--s-2); }
.play { position: absolute; left: 50%; top: var(--s-3); transform: translateX(-50%); display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: var(--s-2); width: min(520px, calc(100% - 2 * var(--s-3))); padding: var(--s-1) var(--s-2) var(--s-1) var(--s-1); border: 1px solid var(--line-1); border-radius: 12px; background: var(--raised); box-shadow: var(--shadow-soft); }
.play[hidden] { display: none; }
.play > .num { min-width: 15ch; text-align: right; white-space: nowrap; font-size: var(--fs-1); }
.play__stop, .play [aria-pressed="true"] .play__go { display: none; }
.play [aria-pressed="true"] .play__stop { display: inline; }
.hoop__empty { position: absolute; inset: 0; align-content: center; padding: var(--s-3); border: 0; background: none; color: inherit; pointer-events: none; }
.hoop__empty[hidden] { display: none; }
.hoop__empty > strong { color: inherit; }
.hoop__empty-row { display: flex; flex-wrap: wrap; justify-content: center; gap: var(--s-2); }
.hoop__empty .btn { pointer-events: auto; }

/* ---------- Properties: picture to trace --------------------------------------- */
.trace { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--s-1); }
.trace[hidden] { display: none; }
.trace__row { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-2); }
/* turn the picture into stitches: a soft card on top of the picture controls */
.stitchify { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--s-2); margin-bottom: var(--s-2); padding: var(--s-3); border: 1px solid var(--line-1); border-radius: var(--r-0); background: var(--raised); }
.stitchify > .prop { min-height: 0; }
.stitchify__count { display: grid; grid-template-columns: minmax(0, 1fr) 7ch; align-items: center; gap: var(--s-2); }
.stitchify__count > .num { text-align: right; white-space: nowrap; font-size: var(--fs-1); color: var(--ink-2); }
.stitchify .slider.is-auto { opacity: .6; }
.stitchify__auto { min-height: 0; font-size: var(--fs-2); color: var(--ink-2); }
.stitchify__swatches { display: flex; flex-wrap: wrap; gap: var(--s-1); }
.stitchify__swatches[hidden] { display: none; }
.stitchify__swatch { display: inline-flex; align-items: center; gap: 6px; max-width: 100%; height: 24px; padding: 0 var(--s-2) 0 6px; border-radius: var(--r-round); background: var(--sunken); font-size: var(--fs-1); color: var(--ink-2); }
.stitchify__name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stitchify__meta { font-size: var(--fs-1); color: var(--ink-2); }
.stitchify__meta[hidden], .stitchify > .field__hint[hidden] { display: none; }
.stitchify > .field__hint.is-bad { color: var(--bad); }
.stitchify__busy { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; gap: var(--s-2); }
.stitchify__busy[hidden] { display: none; }
.stitchify__busy > .num { font-size: var(--fs-1); color: var(--ink-2); white-space: nowrap; }
.stitchify__busy > .btn { height: 24px; padding: 0 var(--s-2); }
.stitchify__bar { display: block; height: 4px; border-radius: var(--r-round); background: var(--sunken); overflow: hidden; }
.stitchify__bar > span { display: block; width: 4%; height: 100%; border-radius: inherit; background: var(--signal); transition: width var(--t-2) var(--ease); }
@media (prefers-reduced-motion: reduce) { .stitchify__bar > span { transition: none; } }
@media (pointer: coarse) { .stitchify__busy > .btn { height: 44px; } }
.prop__pair > .num { text-align: right; white-space: nowrap; font-size: var(--fs-1); }

/* ---------- Help ------------------------------------------------------------------ */
.help { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--s-3); }
.help__keys td { height: auto; padding: var(--s-1) var(--s-2); }
.help__keys td:first-child { width: 1%; }
.help__keys td:last-child { white-space: normal; }

/* ---------- Notched screens --------------------------------------------------------- */
.ed { box-sizing: border-box; padding: env(safe-area-inset-top, 0px) env(safe-area-inset-right, 0px) env(safe-area-inset-bottom, 0px) env(safe-area-inset-left, 0px); }

@media screen and (max-width: 1100px) {
  .ed-bar { gap: var(--s-1); }
  .ed-bar .brand > span, .ed-bar__sep, .ed-bar .btn kbd { display: none; }
  .ed-bar__file { flex: 0 1 auto; min-width: 9ch; }
  .ed-bar__file > input { min-width: 0; }
  .pane--side { top: calc(var(--top-h) + env(safe-area-inset-top, 0px)); bottom: calc(var(--status-h) + env(safe-area-inset-bottom, 0px)); right: env(safe-area-inset-right, 0px); }
}
@media screen and (max-width: 720px) {
  .ed { padding-bottom: 0; }   /* the dock carries the bottom inset itself */
  .ed-bar__state, .ed-bar__file > .num { display: none; }   /* the Export button already names the format */
  .ed-bar > .brand { flex: none; }
  .ed-bar__file { flex: 1; min-width: 0; }
  .menu { top: calc(var(--bar-h) + env(safe-area-inset-top, 0px) + 4px); }
  .sheet { left: env(safe-area-inset-left, 0px); right: env(safe-area-inset-right, 0px); max-height: calc(100dvh - var(--top-h) - var(--dock-h) - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px)); }
  .sheet[data-detent="half"] ~ .stage .hud { bottom: calc(46dvh + var(--s-2)); }   /* stays above the open sheet */
  .more { right: calc(var(--s-2) + env(safe-area-inset-right, 0px)); max-height: calc(100dvh - var(--top-h) - var(--dock-h) - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px) - 2 * var(--s-2)); overflow-y: auto; }
  .play { left: var(--s-2); right: var(--s-2); top: calc(var(--ctl-h) + 2 * var(--s-2)); width: auto; transform: none; }
  .view.is-stitch > .toasts { top: calc(2 * var(--ctl-h) + 4 * var(--s-2)); }   /* under the playback bar */
}

.hoop-custom { display: grid; gap: var(--s-1); }
.hoop-custom[hidden] { display: none; }
.prop[hidden] { display: none; }

/* ---------- Small switch row (Show grid) -------------------------------------------- */
.prop > .check-row { min-height: var(--row-h); font-size: var(--fs-2); color: var(--ink-2); }

/* ==========================================================================
   Design tabs and the Mockup view (js/editor/tabs.js, js/editor/mockup.js)
   ========================================================================== */

/* ---------- Row of design tabs ------------------------------------------------------ */
.dtabs-row { grid-area: tabs; display: flex; align-items: center; gap: var(--s-1); min-width: 0; padding: 0 var(--s-2); background: var(--bg); border-bottom: 1px solid var(--line-1); }
.dtabs { display: flex; align-items: center; gap: 2px; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.dtabs::-webkit-scrollbar { display: none; }
.dtab { display: flex; align-items: center; gap: 2px; flex: 0 1 auto; min-width: 72px; max-width: 200px; height: 28px; padding: 0 2px 0 var(--s-3); border-radius: var(--r-1); color: var(--ink-2); cursor: pointer; user-select: none; -webkit-user-select: none;
  font: var(--w-medium) var(--fs-2)/1 var(--font-ui); transition: background var(--t-1) var(--ease), color var(--t-1) var(--ease); }
.dtab:hover { background: var(--hover); color: var(--ink-1); }
.dtab[aria-selected="true"] { background: var(--raised); color: var(--ink-1); box-shadow: var(--shadow-soft), 0 0 0 1px var(--line-1); }
.dtab:focus-visible { outline-offset: -2px; }
.dtab__name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dtab__x { display: grid; place-items: center; flex: none; width: 22px; height: 22px; padding: 0; border: 0; border-radius: var(--r-2); background: transparent; color: var(--ink-3); cursor: pointer; opacity: 0; }
.dtab:hover .dtab__x, .dtab[aria-selected="true"] .dtab__x, .dtab__x:focus-visible { opacity: 1; }
.dtab__x:hover { background: var(--sunken); color: var(--ink-1); }
.dtab__x svg, .dtab-add svg { width: 12px; height: 12px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; }
.dtab-add { display: grid; place-items: center; flex: none; width: 28px; height: 28px; padding: 0; border: 0; border-radius: var(--r-1); background: transparent; color: var(--ink-2); cursor: pointer; }
.dtab-add:hover { background: var(--hover); color: var(--ink-1); }
.dtab-add[disabled] { opacity: .4; cursor: not-allowed; }
.dtabs-row > .grow { flex: 1; }
.dtab-mock { flex: none; height: 28px; gap: 6px; }
.dtab-mock[aria-pressed="true"] { background: var(--signal-wash); color: var(--signal-text); }
@media (pointer: coarse) { .ed { --tabs-h: 48px; } .dtab, .dtab-add, .dtab-mock { height: 40px; } .dtab__x { opacity: 1; width: 32px; height: 32px; } }

/* ---------- Mockup view: takes the place of the editor below the tabs ------------------ */
.mock { grid-column: 1 / -1; grid-row: 3 / -1; display: grid; grid-template-columns: 272px minmax(0, 1fr) 264px; min-height: 0; background: var(--bg); }
.mock[hidden] { display: none; }
.ed.is-mock > .rail, .ed.is-mock > .sheet, .ed.is-mock > .stage, .ed.is-mock > .status, .ed.is-mock > .dock { display: none; }
.ed.is-mock #btn-undo, .ed.is-mock #btn-redo, .ed.is-mock #btn-drawer { visibility: hidden; }
.mock__left { border-right: 1px solid var(--line-1); }
.mock__right { border-left: 1px solid var(--line-1); }
.mock .pane > .sec__head, .mock .pane > .sec, .mock .pane > .mock__foot { flex: none; }
/* the stage is the picture: white, like the file that is downloaded */
.mock__stage { position: relative; min-width: 0; min-height: 0; overflow: hidden; background: #FFFFFF; touch-action: none; }
.mock__stage > canvas { position: absolute; inset: 0; width: 100%; height: 100%; max-width: none; cursor: grab; }
.mock__stage > canvas:focus, .mock__stage > canvas:focus-visible { outline: none; }   /* the dashed box round the picked design shows where the keys go */
.mock__busy { position: absolute; left: 50%; top: var(--s-3); transform: translateX(-50%); padding: 6px var(--s-3); border-radius: var(--r-round); background: var(--ink-1); color: var(--ink-inv); font-size: var(--fs-2); white-space: nowrap; pointer-events: none; }
.mock__busy[hidden] { display: none; }
.mock__chips { display: grid; grid-template-columns: repeat(9, minmax(0, 1fr)); gap: 6px; padding: 2px 0 var(--s-1); }
.mock__chip { width: 100%; aspect-ratio: 1; padding: 0; border: 1px solid var(--line-2); border-radius: 50%; background: var(--c, #888); cursor: pointer; }
.mock__chip:hover { transform: scale(1.08); }
.mock__chip[aria-pressed="true"] { box-shadow: 0 0 0 2px var(--panel), 0 0 0 4px var(--signal); }
.mock__side { color: var(--ink-3); font-size: var(--fs-1); }
.mock__layers { flex: none; }
.mock__item { display: flex; align-items: center; gap: var(--s-2); min-height: 40px; padding: 4px var(--s-2) 4px var(--s-3); border-bottom: 1px solid var(--line-1); background: var(--panel); font-size: var(--fs-2); cursor: pointer; user-select: none; -webkit-user-select: none; position: relative; }
.mock__item:hover { background: var(--hover); }
.mock__item[aria-selected="true"] { background: var(--signal-wash); }
.mock__item:focus-visible { outline-offset: -2px; }
.mock__item > .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.mock__item > .num { color: var(--ink-2); font-size: var(--fs-1); white-space: nowrap; }
.mock__item.is-hidden > .name, .mock__item.is-hidden > .mock__thumb { opacity: .45; }
.mock__item.is-drag { z-index: 2; box-shadow: var(--shadow-pop); border-radius: var(--r-1); cursor: grabbing; }
.mock__item.drop-before::before, .mock__item.drop-after::after { content: ""; position: absolute; left: var(--s-2); right: var(--s-2); height: 2px; border-radius: 2px; background: var(--signal); pointer-events: none; }
.mock__item.drop-before::before { top: -1px; }
.mock__item.drop-after::after { bottom: -1px; }
.mock__layers.is-sorting .mock__item:not(.is-drag) { transition: none; }
.mock__thumb { flex: none; width: 28px; height: 28px; border-radius: var(--r-2); background: var(--sunken); }
.mock__grip { display: none; flex: none; width: 16px; height: 32px; margin-left: -6px; place-items: center; color: var(--ink-3); touch-action: none; cursor: grab; }
.mock__grip svg { width: 8px; height: 12px; fill: currentColor; }
.mock__eye[aria-pressed="false"] { color: var(--ink-3); }
.mock__rot { display: grid; grid-template-columns: minmax(0, 1fr) 56px 22px; gap: 6px; align-items: center; }
.mock__rot > .input-unit > span { padding: 0 5px; }
.mock__rot > .mini:disabled { opacity: .4; cursor: default; }
.mock__rot > .mini:disabled:hover { background: transparent; color: var(--ink-2); }
.mock__props.is-off .prop > .label { color: var(--ink-3); }
.mock__img-props[hidden] { display: none; }
.mock__img-props .seg > button { padding: 0 4px; }
.mock__add-img { justify-content: space-between; }
.mock__add-img > svg { width: 14px; height: 14px; fill: none; stroke: var(--signal-text); stroke-width: 1.3; stroke-linejoin: round; }
.mock__stage.is-over::after { content: ""; position: absolute; inset: var(--s-2); border: 2px dashed var(--signal); border-radius: var(--r-0); background: color-mix(in srgb, var(--signal) 6%, transparent); pointer-events: none; }
@media (pointer: coarse) { .mock__grip { display: grid; } .mock__item { min-height: 48px; } }
.mock__empty { padding: var(--s-3); color: var(--ink-2); font-size: var(--fs-2); }
.mock__empty[hidden] { display: none; }
.mock__adds { display: grid; gap: var(--s-1); }
.mock__adds:empty { display: none; }
.mock__add { justify-content: space-between; font-weight: 500; }
.mock__add > span { overflow: hidden; text-overflow: ellipsis; }
.mock__add > small { color: var(--signal-text); font-size: var(--fs-1); font-weight: 600; }
.mock__add[aria-disabled="true"] { opacity: .55; cursor: not-allowed; }
.mock__add[aria-disabled="true"] > small { color: var(--ink-3); }
.mock__foot { display: grid; gap: var(--s-2); margin-top: auto; padding: var(--s-3); border-top: 1px solid var(--line-1); }
.mock__dl { display: flex; }
.mock__dl > .btn:first-child { flex: 1; }
.mock__dl > .split__more { width: var(--ctl-h); min-width: var(--ctl-h); }
.mock__menu { position: absolute; top: auto; bottom: calc(100% + 4px); left: 0; right: 0; min-width: 0; }   /* opens upward: it sits at the foot of the panel */
@media screen and (max-width: 1100px) { .mock { grid-template-columns: 240px minmax(0, 1fr) 232px; } }
@media screen and (max-width: 720px) {
  /* one column: the garment first, the controls under it; the whole view scrolls */
  .mock { display: flex; flex-direction: column; overflow-y: auto; overscroll-behavior: contain; }
  .mock[hidden] { display: none; }
  .mock__stage { order: -1; flex: none; height: 54dvh; }
  .mock__left, .mock__right { flex: none; min-height: auto; overflow: visible; border: 0; border-top: 1px solid var(--line-1); }
  .mock .sec__head { position: static; }
  .mock__foot { margin-top: 0; padding-bottom: calc(var(--s-3) + env(safe-area-inset-bottom, 0px)); }
  .mock__menu { position: absolute; top: auto; bottom: calc(100% + 4px); left: 0; right: 0; }
  .dtab-mock > span { display: none; }
}

/* ---------- Picture to SVG studio (js/editor/vectorize.js) ---------- */
.vz { width: min(1180px, calc(100vw - 32px)); height: min(780px, calc(100dvh - 32px)); max-height: none; }
.vz .dialog__head { padding-left: var(--s-4); }
.vz__headr { display: flex; align-items: center; gap: var(--s-1); }
.vz__body { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) 300px; }
.vz__main { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--bg); }
.vz__bar { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2); padding: var(--s-3) var(--s-3) var(--s-2); }
.vz__tools > button { padding: 0 var(--s-2); }
.vz__tools svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.vz__brush { display: inline-flex; align-items: center; width: 120px; }
.vz__brush[hidden] { display: none; }
.vz__spacer { flex: 1; }
.vz__stage { position: relative; flex: 1; min-height: 0; margin: 0 var(--s-3); border-radius: var(--r-0); background: var(--sunken); overflow: hidden; }
.vz__stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; }
.vz__stage[data-tool="brush"] canvas { cursor: none; }
.vz__stage[data-tool="shape"] canvas { cursor: pointer; }
.vz__stage.is-over { box-shadow: inset 0 0 0 2px var(--signal); }
.vz__drop { position: absolute; inset: var(--s-4); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--s-1); border: 1.5px dashed var(--line-3); border-radius: var(--r-0); background: color-mix(in srgb, var(--raised) 55%, transparent); color: var(--ink-2); font: inherit; cursor: pointer; }
.vz__drop:hover { border-color: var(--signal); color: var(--ink-1); }
.vz__drop[hidden] { display: none; }
.vz__drop-big { font-size: var(--fs-4); font-weight: var(--w-medium); color: var(--ink-1); }
.vz__drop-small { font-size: var(--fs-2); color: var(--ink-3); }
.vz__status { display: flex; align-items: center; gap: var(--s-3); min-height: 44px; padding: var(--s-2) var(--s-4); font-size: var(--fs-2); color: var(--ink-2); }
.vz__meta[hidden], .vz__note[hidden], .vz__busy[hidden] { display: none; }
.vz__busy { display: inline-flex; align-items: center; gap: var(--s-2); }
.vz__progress { display: block; width: 120px; height: 4px; border-radius: var(--r-round); background: var(--sunken); overflow: hidden; }
.vz__progress > i { display: block; height: 100%; width: 4%; border-radius: var(--r-round); background: var(--signal); transition: width var(--t-2) var(--ease); }
.vz__note { color: var(--ink-3); }
.vz__note.is-bad { color: var(--bad); }
.vz__side { display: flex; flex-direction: column; gap: var(--s-5); min-height: 0; padding: var(--s-4); overflow: auto; border-left: 1px solid var(--line-1); background: var(--panel); }
.vz__sec { display: flex; flex-direction: column; gap: var(--s-2); }
.vz__sec > .label { color: var(--ink-1); }
.vz__auto { min-height: 0; font-size: var(--fs-2); color: var(--ink-2); }
.vz__count { display: grid; grid-template-columns: minmax(0, 1fr) 7ch; align-items: center; gap: var(--s-2); }
.vz__count > .num { text-align: right; white-space: nowrap; font-size: var(--fs-2); color: var(--ink-2); }
.vz .slider.is-auto { opacity: .6; }
.vz__colors { display: flex; flex-direction: column; gap: 2px; margin-top: var(--s-1); }
.vz__colors[hidden] { display: none; }
.vz__color { display: grid; grid-template-columns: auto auto minmax(0, 1fr) auto; align-items: center; gap: var(--s-2); min-height: 36px; padding: 0 var(--s-1) 0 var(--s-2); border-radius: var(--r-1); }
.vz__color:hover { background: var(--hover); }
.vz__color.is-off .vz__swatch, .vz__color.is-off .vz__name { opacity: .4; }
.vz__color.is-off .vz__thread { text-decoration: line-through; }
.vz__swatch { position: relative; display: block; width: 22px; height: 22px; border-radius: 50%; background: var(--c, #888); box-shadow: 0 0 0 1px var(--raised), 0 0 0 2px var(--line-3); cursor: pointer; }
.vz__swatch:hover { box-shadow: 0 0 0 1px var(--raised), 0 0 0 2px var(--signal); }
.vz__swatch > input { position: absolute; inset: 0; width: 100%; height: 100%; padding: 0; border: 0; opacity: 0; cursor: pointer; }
.vz__swatch:focus-within { outline: 2px solid var(--signal); outline-offset: 2px; }
.vz__name { display: flex; align-items: baseline; gap: var(--s-2); min-width: 0; font-size: var(--fs-2); }
.vz__thread { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink-1); }
.vz__share { flex: none; font-size: var(--fs-1); color: var(--ink-3); }
.vz__merge { -webkit-appearance: none; appearance: none; width: 26px; height: 26px; padding: 0; border: 1px solid transparent; border-radius: var(--r-2); background: transparent url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%2394918B' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 3.5h3.5L10 8h3M3 12.5h3.5L10 8M11 6l2 2-2 2'/%3E%3C/svg%3E") center / 16px no-repeat; color: transparent; font: inherit; font-size: var(--fs-2); cursor: pointer; }
.vz__merge option { color: var(--ink-1); background: var(--raised); }
.vz__merge:hover, .vz__merge:focus-visible { border-color: var(--line-3); background-color: var(--raised); }
.vz__color.is-merged .vz__merge { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%233F6184' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 3.5h3.5L10 8h3M3 12.5h3.5L10 8M11 6l2 2-2 2'/%3E%3C/svg%3E"); background-color: var(--signal-wash); }
.vz__into { flex: none; font-size: var(--fs-1); color: var(--signal-text); white-space: nowrap; }
.vz__foot .vz__ref { margin-right: auto; }
@media (max-width: 720px) {
  .vz, .dialog.vz { width: 100%; max-width: 100%; height: 100dvh; max-height: 100dvh; margin: 0; border-radius: 0; }
  .vz__body { display: flex; flex-direction: column; overflow: auto; }
  .vz__main { flex: none; height: 50dvh; }
  .vz__bar { padding: var(--s-2); gap: var(--s-1); }
  .vz__stage { margin: 0 var(--s-2); }
  .vz__brush { width: 96px; }
  .vz__status { padding: var(--s-2) var(--s-3); min-height: 40px; }
  .vz__side { flex: none; overflow: visible; border-left: 0; border-top: 1px solid var(--line-1); gap: var(--s-4); }
  .vz__foot { flex-wrap: wrap; }
  .vz__foot .vz__ref { flex-basis: 100%; margin-right: 0; order: 3; }
}
