/*
 * Vectura Studio — skin/components.css
 *
 * Skin-agnostic component structure: layout, geometry, typography, transitions.
 * Palette tokens (--ui-*) come from per-skin files (./meridian-dark.css, etc.).
 *
 * Sourced verbatim from docs/design/themes-mockup.html (lines 87–842), with two edits:
 *   1. Motion @keyframes blocks moved to ./motion.css.
 *   2. Per-mode palette blocks ([data-mode="dark"|"light"]) moved to per-skin files;
 *      mockup [data-mode="..."] selectors are not used here — palette tokens are
 *      written to :root via the active <link rel="stylesheet" id="active-skin">.
 *
 * NOTE: the mockup defined html/body background, font-family etc. on the document.
 * The current Vectura body uses Tailwind utility classes that bind to the same
 * variables (`bg-vectura-bg`, `text-vectura-text`); these declarations re-establish
 * the variable-driven base in case Tailwind classes are absent on a node.
 */

/* ── BASE ────────────────────────────────────────────────────── */
[data-ui-skin] body {
  font-family: var(--font-ui);
  font-size: var(--font-size-base);
  color: var(--ui-text);
  -webkit-font-smoothing: antialiased;
}

/* ── CHEVRON (unified disclosure indicator) ──────────────────────
 * Single Lucide chevron-down (path "m6 9 6 6 6-6" in 24x24).
 * Use --chevron-svg as a mask source; color via background-color.
 * Rotation conveys direction: 0deg=down, -90deg=right, 180deg=up, 90deg=left. */
:root {
  --chevron-svg: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><path d='m6 9 6 6 6-6'/></svg>");
}
.chev {
  display: inline-block;
  width: 12px; height: 12px;
  background-color: currentColor;
  -webkit-mask: var(--chevron-svg) center / contain no-repeat;
  mask: var(--chevron-svg) center / contain no-repeat;
  transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ── HEADER ──────────────────────────────────────────────────── */
.app-header {
  display: flex; align-items: center; justify-content: space-between;
  height: 38px; padding: 0 14px;
  background: var(--ui-panel);
  border-bottom: 1px solid var(--ui-border);
  flex-shrink: 0; z-index: 200; position: relative; gap: 10px;
  transition: background 0.2s, border-color 0.2s;
}
.brand { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.brand-sq {
  width: 11px; height: 11px;
  background: var(--ui-accent);
  border-radius: var(--radius-sm);
  flex-shrink: 0;
  box-shadow: 0 0 8px var(--ui-accent-2);
  transition: background 0.2s, box-shadow 0.2s;
}
.brand-name {
  font-weight: 700; letter-spacing: 0.05em; font-size: 12px;
  color: var(--ui-accent); white-space: nowrap;
  font-family: var(--font-mono);
  transition: color 0.2s;
}
.brand-sub { font-weight: 300; color: var(--ui-muted); letter-spacing: 0; }

/* ── MENUS ───────────────────────────────────────────────────── */
.menubar { display: flex; align-items: stretch; position: relative; gap: 1px; }
.menu-item { position: relative; display: flex; align-items: stretch; }
.menu-trigger {
  background: none; border: none; color: var(--ui-text-2);
  font-family: var(--font-ui); font-size: var(--font-size-sm); font-weight: 500;
  padding: 0 10px; cursor: pointer; letter-spacing: 0;
  transition: background 0.1s, color 0.1s; white-space: nowrap;
  display: flex; align-items: center; border-radius: var(--radius-sm);
}
.menu-trigger:hover { background: var(--ui-ctrl-hov); color: var(--ui-text); }
.menu-trigger.open { background: var(--ui-ctrl-hov); color: var(--ui-accent); }

.menu-dropdown {
  position: absolute; top: calc(100% + 5px); left: 0;
  min-width: 244px;
  background: var(--ui-panel);
  border: 1px solid var(--ui-border-hi);
  border-top: 3px solid var(--ui-accent);
  border-radius: 0 var(--radius-md) var(--radius-md) var(--radius-md);
  box-shadow: var(--shadow-lg);
  z-index: 9999; display: none; overflow: hidden;
}
.menu-dropdown.open { display: block; }

.menu-entry {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 14px;
  min-height: var(--row-height);
  cursor: pointer; gap: 20px;
  font-size: var(--font-size-sm); font-weight: 500;
  font-family: var(--font-ui);
  color: var(--ui-text);
  transition: background 0.07s, color 0.07s; white-space: nowrap;
}
.menu-entry:hover { background: var(--ui-accent-2); color: var(--ui-accent); }
.menu-entry.dim { opacity: 0.35; cursor: default; pointer-events: none; }
.msc {
  font-size: var(--font-size-xs); color: var(--ui-muted);
  font-family: var(--font-mono); letter-spacing: 0.04em; flex-shrink: 0;
}
.menu-sep { height: 1px; background: var(--ui-border); margin: 3px 0; }
.menu-cat {
  padding: 5px 14px 2px;
  font-size: 9px; letter-spacing: 0.1em;
  text-transform: uppercase; color: var(--ui-muted);
  font-family: var(--font-mono);
}
.menu-check {
  width: 14px; height: 14px; display: flex; align-items: center;
  justify-content: center; font-size: 10px; color: var(--ui-accent); flex-shrink: 0;
  margin-right: 2px;
}

.header-right { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.hdr-status {
  font-size: var(--font-size-xs); letter-spacing: 0.08em;
  color: var(--ui-muted); text-transform: uppercase; font-family: var(--font-mono);
}
.hdr-btn {
  height: 26px; padding: 0 10px;
  background: var(--ui-ctrl); border: 1px solid var(--ui-border);
  border-radius: var(--radius-md); color: var(--ui-text-2);
  font-family: var(--font-ui); font-size: var(--font-size-xs); font-weight: 500;
  cursor: pointer; display: flex; align-items: center; gap: 4px;
  transition: background 0.1s, border-color 0.1s, color 0.1s;
}
.hdr-btn:hover { background: var(--ui-ctrl-hov); border-color: var(--ui-border-hi); color: var(--ui-accent); }
.hdr-btn.is-danger { background: var(--ui-danger); border-color: var(--ui-danger); color: var(--ui-on-danger); }
@media (hover: hover) {
  .hdr-btn.is-danger:hover { opacity: 0.88; color: var(--ui-on-danger); }
}

/* ── MAIN LAYOUT ─────────────────────────────────────────────── */
.app-main { display: flex; flex: 1; overflow: hidden; }

/* ── LEFT PANE ───────────────────────────────────────────────── */
.pane-left {
  width: var(--pane-left-width); flex-shrink: 0;
  background: var(--ui-panel);
  border-right: none;
  box-shadow: var(--shadow-pane);
  display: flex; flex-direction: column; overflow: hidden;
  transition: background 0.2s, box-shadow 0.2s;
  z-index: 10; position: relative;
}
.pane-hdr {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 var(--spacing-md);
  height: 36px;
  border-bottom: 1px solid var(--ui-border); flex-shrink: 0;
  background: var(--ui-panel-alt);
}
.pane-title {
  font-size: 13px; font-weight: 700; letter-spacing: 0; text-transform: none;
  color: var(--ui-accent); font-family: var(--font-ui); transition: color 0.2s;
}
.pane-meta {
  font-size: var(--font-size-xs); color: var(--ui-muted);
  letter-spacing: 0.04em; font-family: var(--font-mono);
}
.pane-toggle {
  background: none; border: none; color: var(--ui-muted);
  cursor: pointer; font-size: 10px; padding: 3px; border-radius: var(--radius-sm);
  transition: color 0.1s;
}
.pane-toggle:hover { color: var(--ui-text); }
.pane-body { flex: 1; overflow-y: auto; overflow-x: hidden; }
.pane-body::-webkit-scrollbar { width: 3px; }
.pane-body::-webkit-scrollbar-thumb { background: var(--ui-border-hi); border-radius: 2px; }

/* Pre-Tailwind color fallbacks: [data-ui-skin] specificity (0,2,0) beats Tailwind's
   (0,1,0), so these fire from the first paint before the CDN MutationObserver runs.
   Colors match each skin's palette exactly — no visual difference once Tailwind loads. */
[data-ui-skin] .text-vectura-accent { color: var(--ui-accent); }
[data-ui-skin] .text-vectura-muted  { color: var(--ui-muted); }
[data-ui-skin] .text-vectura-text   { color: var(--ui-text); }

/* ── SECTIONS ────────────────────────────────────────────────── */
.sect { border-bottom: 1px solid var(--ui-border); }
.sect-hdr {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 var(--spacing-md);
  min-height: var(--row-height);
  background: var(--ui-panel-alt); border: none; width: 100%;
  cursor: pointer; color: var(--ui-text-2);
  font-family: var(--font-ui); font-size: var(--font-size-sm); font-weight: 600;
  letter-spacing: 0; text-transform: none; text-align: left;
  transition: background 0.1s, color 0.1s; position: relative;
}
.sect-hdr:hover { background: var(--ui-ctrl-hov); color: var(--ui-text); }
/* Meridian left-accent bar — required parity detail (mockup line 247–256). */
.sect-hdr::before {
  content: ''; display: block;
  width: 3px; height: 14px;
  background: var(--ui-accent);
  border-radius: 2px; flex-shrink: 0;
  margin-right: var(--spacing-sm);
  opacity: 0.45; transition: opacity 0.15s;
}
@media (hover: hover) {
  .sect-hdr:hover::before { opacity: 1; }
}
.sect-arrow {
  width: 20px; height: 20px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}
.sect-arrow::before {
  content: ''; display: block;
  width: 12px; height: 12px;
  background-color: var(--ui-muted);
  -webkit-mask: var(--chevron-svg) center / contain no-repeat;
  mask: var(--chevron-svg) center / contain no-repeat;
  transform: rotate(0deg);
  transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1), background-color 0.12s;
}
.sect-arrow.down::before {
  transform: rotate(180deg);
}
.sect-hdr:hover .sect-arrow::before,
.right-sect-hdr:hover .sect-arrow::before {
  background-color: var(--ui-text-2);
}
.sect-body {
  padding: var(--spacing-sm) var(--spacing-md);
  display: flex; flex-direction: column; gap: var(--spacing-sm);
}

/* ── FORM CONTROLS ───────────────────────────────────────────── */
.ctrl-grp { display: flex; flex-direction: column; gap: var(--spacing-xs); }
.ctrl-lbl {
  font-size: var(--font-size-sm); font-weight: 500;
  letter-spacing: 0; text-transform: none;
  color: var(--ui-text-2); font-family: var(--font-ui);
}
.ctrl-sel, .ctrl-inp {
  background: var(--ui-ctrl); border: 1px solid var(--ui-border);
  color: var(--ui-text); font-family: var(--font-ui);
  font-size: var(--font-size-sm); font-weight: 400;
  padding: 0 var(--spacing-sm);
  height: var(--row-height);
  border-radius: var(--radius-sm);
  width: 100%; outline: none;
  transition: border-color 0.12s, box-shadow 0.12s;
}
.ctrl-sel:hover, .ctrl-inp:hover { border-color: var(--ui-border-hi); }
.ctrl-sel { -webkit-appearance: none; -moz-appearance: none; appearance: none; padding-right: 28px; }
.ctrl-sel:focus, .ctrl-inp:focus { border-color: var(--ui-accent); box-shadow: 0 0 0 3px var(--ui-accent-2); }
.ctrl-sel-wrap { position: relative; width: 100%; }
.ctrl-sel-wrap .ctrl-sel { width: 100%; }
.ctrl-sel-wrap::after {
  content: ''; position: absolute; right: 8px; top: 50%;
  width: 12px; height: 12px;
  background-color: var(--ui-muted);
  -webkit-mask: var(--chevron-svg) center / contain no-repeat;
  mask: var(--chevron-svg) center / contain no-repeat;
  transform: translateY(-50%);
  pointer-events: none;
  transition: background-color 0.12s;
}
.ctrl-sel-wrap:hover::after, .ctrl-sel-wrap:focus-within::after {
  background-color: var(--ui-accent);
}
.ctrl-2col { display: grid; grid-template-columns: 1fr 1fr; gap: var(--spacing-sm); }
.ctrl-sub-lbl {
  font-size: var(--font-size-xs); color: var(--ui-muted);
  letter-spacing: 0; margin-bottom: var(--spacing-xs);
  font-family: var(--font-ui); font-weight: 500;
}
.ctrl-row { display: flex; align-items: center; justify-content: space-between; gap: var(--spacing-sm); }
.info-badge {
  font-size: 9px; color: var(--ui-muted);
  border: 1px solid var(--ui-border); border-radius: 50%;
  width: 14px; height: 14px; display: inline-flex; align-items: center; justify-content: center;
  cursor: default; flex-shrink: 0; line-height: 1; font-family: var(--font-mono);
  transition: color 0.1s, border-color 0.1s;
}
.sect-hdr:hover .info-badge { color: var(--ui-accent); border-color: var(--ui-accent); }

/* ── SEGMENTED CONTROL ───────────────────────────────────────── */
.seg-ctrl {
  display: flex; background: var(--ui-ctrl);
  border: 1px solid var(--ui-border); border-radius: var(--radius-sm);
  overflow: hidden;
}
.seg-opt {
  flex: 1; display: flex; align-items: center; justify-content: center;
  padding: 0 var(--spacing-xs); height: var(--row-height);
  background: none; border: none; border-left: 1px solid var(--ui-border);
  color: var(--ui-text-2); font-family: var(--font-ui);
  font-size: var(--font-size-xs); font-weight: 500;
  cursor: pointer; transition: background 0.1s, color 0.1s; white-space: nowrap;
}
.seg-opt:first-child { border-left: none; }
.seg-opt.active { background: var(--ui-accent); color: var(--ui-on-accent); border-color: var(--ui-accent); }
.seg-opt:not(.active):hover { background: var(--ui-ctrl-hov); color: var(--ui-text); }
/* Classic accents are near-white (#fafafa) — use a dark label so text is legible. */
:root[data-ui-skin^="classic"] .seg-opt.active { color: var(--ui-bg); }

/* ── TOGGLE BUTTON GROUP ─────────────────────────────────────── */
.tog-grp { display: flex; gap: var(--spacing-xs); }
.tog-btn {
  height: var(--row-height); padding: 0 var(--spacing-sm);
  background: var(--ui-ctrl); border: 1px solid var(--ui-border);
  color: var(--ui-text-2); font-family: var(--font-ui);
  font-size: var(--font-size-xs); font-weight: 500;
  border-radius: var(--radius-sm); cursor: pointer;
  transition: background 0.1s, border-color 0.1s, color 0.1s; white-space: nowrap;
}
.tog-btn.active { background: var(--ui-accent-2); border-color: var(--ui-accent); color: var(--ui-accent); }
.tog-btn:not(.active):hover { border-color: var(--ui-border-hi); color: var(--ui-text); }

/* ── PILL TOGGLE SWITCH ──────────────────────────────────────── */
.sw-toggle {
  position: relative; display: inline-flex; width: 30px; height: 16px; flex-shrink: 0; cursor: pointer;
}
.sw-toggle input { opacity: 0; width: 0; height: 0; position: absolute; }
.sw-track {
  position: absolute; inset: 0;
  background: var(--ui-border); border-radius: 9999px;
  transition: background 0.15s;
}
.sw-toggle input:checked ~ .sw-track { background: var(--ui-accent); }
.sw-thumb {
  position: absolute; top: 2px; left: 2px;
  width: 12px; height: 12px;
  background: #fff; border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
  transition: transform 0.15s cubic-bezier(0.4, 0, 0.2, 1);
  pointer-events: none;
}
.sw-toggle input:checked ~ .sw-thumb { transform: translateX(14px); }

/* sw-toggle: on Classic-family themes restore native checkbox, hide visual spans.
   Meridian-family skin ids are `dark`/`lark`/`light` (unprefixed) and
   `meridian-*` aliases — the pill renders for all of them. */
:root[data-ui-skin^="classic"] .sw-track,
:root[data-ui-skin^="classic"] .sw-thumb { display: none; }
:root[data-ui-skin^="classic"] .sw-toggle { display: inline; width: auto; height: auto; }
:root[data-ui-skin^="classic"] .sw-toggle > input[type="checkbox"] {
  opacity: 1; width: auto; height: auto; position: static;
}

/* ── ANGLE CONTROL ───────────────────────────────────────────── */
.angle-ctrl { display: flex; align-items: center; gap: var(--spacing-sm); }
.angle-dial { width: 38px; height: 38px; flex-shrink: 0; cursor: grab; }
/* Scope SVG dial size to beat legacy CSS which also sets width. */
[data-ui-skin] .angle-ctrl .angle-dial { width: 38px; height: 38px; background: none; border: none; }
.dial-ring { fill: none; stroke: var(--ui-border); stroke-width: 1.5; }
.dial-ring-inner { fill: none; stroke: var(--ui-border); stroke-width: 1; opacity: 0.4; }
.dial-tick { stroke: var(--ui-border); stroke-width: 1; }
.dial-needle { stroke: var(--ui-accent); stroke-width: 1.5; stroke-linecap: round; }
.dial-center { fill: var(--ui-ctrl); stroke: var(--ui-accent); stroke-width: 1.5; }
.dial-handle { fill: var(--ui-accent); }
.angle-inp-wrap {
  display: flex; align-items: center; gap: 3px;
  background: var(--ui-ctrl); border: 1px solid var(--ui-border);
  border-radius: var(--radius-sm);
  padding: 0 var(--spacing-sm); height: var(--row-height);
  transition: border-color 0.12s, box-shadow 0.12s;
  /* The chip must never be squeezed by flex in narrow (~290px) panels. */
  flex-shrink: 0;
}
.angle-inp-wrap:focus-within { border-color: var(--ui-accent); box-shadow: 0 0 0 3px var(--ui-accent-2); }
.angle-inp {
  background: none; border: none; outline: none;
  color: var(--ui-text); font-family: var(--font-mono);
  /* 40px fits three tabular digits ("180", "360") — 34px clipped the last
     digit at --font-size-sm mono (scrollWidth 36px). */
  font-size: var(--font-size-sm); width: 40px; text-align: right;
  font-variant-numeric: tabular-nums;
}
.angle-unit { color: var(--ui-muted); font-size: var(--font-size-xs); font-family: var(--font-mono); }

/* ── NUMBER STEPPER ──────────────────────────────────────────── */
.num-step {
  display: flex; align-items: stretch;
  background: var(--ui-ctrl); border: 1px solid var(--ui-border);
  border-radius: var(--radius-sm); overflow: hidden;
  height: var(--row-height);
  transition: border-color 0.12s;
}
.num-step:focus-within { border-color: var(--ui-accent); }
.num-step-inp {
  flex: 1; background: none; border: none; outline: none;
  text-align: center; color: var(--ui-text);
  font-family: var(--font-mono); font-size: var(--font-size-sm);
  font-variant-numeric: tabular-nums; min-width: 0;
}
.num-step-btn {
  width: 22px; background: none; border: none;
  border-left: 1px solid var(--ui-border);
  color: var(--ui-muted); cursor: pointer; font-size: 10px;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.08s, color 0.08s;
}
.num-step-btn:first-child { border-left: none; border-right: 1px solid var(--ui-border); }
.num-step-btn:hover { background: var(--ui-ctrl-hov); color: var(--ui-accent); }

/* ── SLIDERS ─────────────────────────────────────────────────── */
.slider-row { display: flex; align-items: center; gap: var(--spacing-sm); }

/*
 * Scoped to [data-ui-skin] so specificity (0,0,2,0) beats the legacy
 * input[type='range'] reset in legacy CSS.
 */
[data-ui-skin] .ctrl-slider {
  -webkit-appearance: none;
  appearance: none;
  flex: 1;
  height: 4px;
  border-radius: 2px;
  cursor: pointer;
  outline: none;
  background: linear-gradient(to right,
    var(--slider-start) 0%,
    var(--ui-accent) var(--fill, 0%),
    var(--ui-border) var(--fill, 0%) 100%
  );
}
/* Clear the legacy runnable-track so our input background shows through.
 * height: 4px (not 0) keeps the track height matching the gradient fill so
 * the 14px thumb centers correctly on the visible 4px track. */
[data-ui-skin] .ctrl-slider::-webkit-slider-runnable-track {
  background: transparent;
  height: 4px;
}
[data-ui-skin] .ctrl-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--ui-accent);
  border: 2.5px solid var(--ui-panel);
  box-shadow: 0 0 0 1.5px var(--ui-accent);
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.15s ease;
}
[data-ui-skin] .ctrl-slider:hover::-webkit-slider-thumb {
  transform: scale(1.18);
  box-shadow: 0 0 0 4px var(--ui-accent-2);
}
[data-ui-skin] .ctrl-slider:active::-webkit-slider-thumb {
  transform: scale(1.02);
  box-shadow: 0 0 0 2px var(--ui-accent-2);
}
[data-ui-skin] .ctrl-slider::-moz-range-thumb {
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--ui-accent);
  border: 2.5px solid var(--ui-panel);
  box-shadow: 0 0 0 1.5px var(--ui-accent);
  cursor: pointer;
}
[data-ui-skin] .ctrl-slider::-moz-range-track { height: 4px; border-radius: 2px; background: var(--ui-border); }
[data-ui-skin] .ctrl-slider::-moz-range-progress {
  height: 4px; border-radius: 2px 0 0 2px;
  background: linear-gradient(to right, var(--slider-start), var(--ui-accent));
}
[data-ui-skin] .ctrl-slider.just-released::-webkit-slider-thumb {
  animation: thumb-release var(--motion-thumb-release-dur) var(--motion-thumb-release-ease) forwards;
}

.sld-fx-wrap {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
}
.sld-fx-wrap .ctrl-slider,
.sld-fx-wrap .pen-sld {
  flex: 1;
  width: 100%;
}
.sld-fx-wrap::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 0;
  transform: translateY(-50%);
  height: 4px;
  width: var(--fill, 0%);
  border-radius: 2px;
  pointer-events: none;
  z-index: 2;
  opacity: 0;
  background: linear-gradient(to right, var(--ui-accent) 0%, #fff 100%);
}
.sld-fx-wrap:has(.pen-sld)::after { height: 3px; }
.sld-fx-wrap.fx-active::after {
  animation: fx-pulse-fill var(--motion-slider-pulse-dur) var(--motion-slider-pulse-ease) forwards;
}

.btn-pulse {
  animation: btn-press var(--motion-btn-fade-dur) var(--motion-btn-fade-ease) forwards !important;
}

.angle-dial.is-dragging .dial-handle {
  filter: drop-shadow(0 0 4px var(--ui-accent));
}
.angle-dial.is-dragging .dial-needle {
  stroke: var(--ui-accent);
  stroke-width: 2;
}

.slider-val {
  font-size: var(--font-size-xs); color: var(--ui-accent);
  min-width: 30px; max-width: 46px; text-align: right;
  font-family: var(--font-mono); font-variant-numeric: tabular-nums;
  background: none; border: 1px solid transparent; outline: none;
  padding: 1px 3px; border-radius: var(--radius-sm);
  cursor: default;
  transition: background 0.12s, border-color 0.12s, box-shadow 0.12s;
}
.slider-val:hover {
  background: var(--ui-ctrl); border-color: var(--ui-border); cursor: text;
}
.slider-val:focus {
  background: var(--ui-ctrl);
  border-color: var(--ui-accent);
  box-shadow: 0 0 0 3px var(--ui-accent-2);
  cursor: text;
}

/* Value chip inside a slider row — matches .slider-val appearance. */
[data-ui-skin] .slider-row .value-chip {
  font-size: var(--font-size-xs); color: var(--ui-accent);
  min-width: 30px; max-width: 46px; text-align: right;
  font-family: var(--font-mono); font-variant-numeric: tabular-nums;
  background: none; border: 1px solid transparent; outline: none;
  padding: 1px 3px; border-radius: var(--radius-sm);
  cursor: default;
  transition: background 0.12s, border-color 0.12s, box-shadow 0.12s;
  white-space: nowrap;
}
[data-ui-skin] .slider-row .value-chip:hover {
  background: var(--ui-ctrl); border-color: var(--ui-border); cursor: pointer;
}

/* ── WORKSPACE ───────────────────────────────────────────────── */
.workspace-shell {
  flex: 1; display: flex; flex-direction: column; overflow: hidden;
  background: var(--ui-workspace); position: relative;
  transition: background 0.2s;
}
.workspace-area {
  flex: 1; display: flex; align-items: center; justify-content: center;
  overflow: hidden; position: relative;
}

/* ── TOOLBAR ─────────────────────────────────────────────────── */
[data-ui-skin] .tool-bar {
  position: absolute; left: 10px; top: 50%;
  transform: translateY(-50%); z-index: 5;
  display: flex; flex-direction: column; gap: 3px;
  padding: var(--spacing-sm);
  background: var(--ui-panel); border: 1px solid var(--ui-border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-md);
  transition: background 0.2s, border-color 0.2s;
  max-height: calc(100% - 20px);
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
}
[data-ui-skin] .tool-bar::-webkit-scrollbar { width: 4px; }
[data-ui-skin] .tool-bar::-webkit-scrollbar-thumb { background: var(--ui-border); border-radius: 2px; }

/* ── TOOLBAR DOCK ─────────────────────────────────────────────── */
.toolbar-drag-handle {
  cursor: grab;
  display: flex; align-items: center; justify-content: center;
  width: 100%; height: 14px;
  color: var(--ui-muted); opacity: 0.45;
  user-select: none; flex-shrink: 0; margin-bottom: 1px;
  overflow: hidden;
  transform-origin: center top;
  transition:
    height 0.34s cubic-bezier(0.34, 1.56, 0.64, 1),
    margin 0.34s cubic-bezier(0.34, 1.56, 0.64, 1),
    transform 0.34s cubic-bezier(0.34, 1.56, 0.64, 1),
    opacity 0.16s ease-out;
}
@media (hover: hover) {
  .toolbar-drag-handle:hover { opacity: 0.8; }
}
.toolbar-drag-handle:active { cursor: grabbing; }
.toolbar-drag-handle .handle-vert { display: none; }

/* Pinned + floating: collapse the drag handle so the toolbar's top edge
   sits closer to the first tool icon. Snappy-elastic via back-ease bezier. */
.tool-bar.toolbar-locked:not([class*="toolbar-docked"]) .toolbar-drag-handle {
  height: 0;
  margin-top: -2px;
  margin-bottom: 0;
  transform: scaleY(0.4);
  opacity: 0;
  pointer-events: none;
}

/* Footer: pin/pop-out section, bleeds to toolbar edges with own bg.
   Sized to fit three small buttons within the tool-btn column width. */
.toolbar-footer {
  display: flex; justify-content: center; align-items: center;
  gap: 0; flex-shrink: 0;
  margin-top: 4px;
  margin-left: calc(-1 * var(--spacing-sm));
  margin-right: calc(-1 * var(--spacing-sm));
  margin-bottom: calc(-1 * var(--spacing-sm));
  padding: 4px 2px;
  border-top: 1px solid var(--ui-border);
  background: var(--ui-ctrl-hov);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}
/* Inter-button spacing via margin (not flex gap) so collapsed buttons
   contribute zero space when locked and the pin centers cleanly. */
.toolbar-footer > button + button { margin-left: 2px; }

/* Footer buttons: tight outline icons, sized so 3 fit inside the 30px column */
.toolbar-pin-btn,
.toolbar-home-btn,
.toolbar-rotate-btn,
.toolbar-popout-btn {
  box-sizing: border-box;
  width: 13px; height: 13px; min-width: 13px; min-height: 13px;
  padding: 0; background: none;
  border: 1px solid var(--ui-border);
  border-radius: 3px; cursor: pointer;
  color: var(--ui-muted);
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
  transition:
    width 0.32s cubic-bezier(0.34, 1.56, 0.64, 1),
    min-width 0.32s cubic-bezier(0.34, 1.56, 0.64, 1),
    height 0.32s cubic-bezier(0.34, 1.56, 0.64, 1),
    min-height 0.32s cubic-bezier(0.34, 1.56, 0.64, 1),
    margin-left 0.32s cubic-bezier(0.34, 1.56, 0.64, 1),
    margin-top 0.32s cubic-bezier(0.34, 1.56, 0.64, 1),
    border-width 0.24s ease,
    transform 0.32s cubic-bezier(0.34, 1.56, 0.64, 1),
    opacity 0.22s ease,
    border-color 0.12s, color 0.12s;
}

/* Pinned: hide home + rotate, center the pin. Buttons collapse on both
   axes so the pin centers cleanly in either footer orientation. */
.tool-bar.toolbar-locked:not([class*="toolbar-docked"]) .toolbar-home-btn,
.tool-bar.toolbar-locked:not([class*="toolbar-docked"]) .toolbar-rotate-btn {
  width: 0; min-width: 0;
  height: 0; min-height: 0;
  margin-left: 0; margin-top: 0;
  border-width: 0;
  opacity: 0;
  transform: scale(0.4);
  pointer-events: none;
}
.toolbar-pin-btn svg,
.toolbar-home-btn svg,
.toolbar-rotate-btn svg,
.toolbar-popout-btn svg { width: 8px; height: 8px; }
.toolbar-pin-btn:hover,
.toolbar-home-btn:hover,
.toolbar-rotate-btn:hover,
.toolbar-popout-btn:hover { border-color: var(--ui-text); color: var(--ui-text); }
.toolbar-pin-btn.active,
.toolbar-rotate-btn.active { border-color: var(--ui-accent); color: var(--ui-accent); }

/* Visibility: pin/home/rotate show when floating; pop-out shows when docked */
.toolbar-footer .toolbar-popout-btn { display: none; }
[class*="toolbar-docked"] .toolbar-footer .toolbar-pin-btn,
[class*="toolbar-docked"] .toolbar-footer .toolbar-home-btn,
[class*="toolbar-docked"] .toolbar-footer .toolbar-rotate-btn { display: none; }
[class*="toolbar-docked"] .toolbar-footer .toolbar-popout-btn { display: flex; }

/* Docked footer: drop decorative treatment, center the button */
[class*="toolbar-docked"] .toolbar-footer {
  margin: 4px 0 0;
  padding: 5px 0;
  border-radius: 0;
  background: transparent;
  justify-content: center;
}

/* Footer flows inline at end of horizontal docked bars */
.toolbar-docked-top .toolbar-footer,
.toolbar-docked-bottom .toolbar-footer {
  flex-direction: row; align-self: stretch; align-items: center;
  margin: 0 calc(-1 * var(--spacing-sm)) 0 4px;
  padding: 0 var(--spacing-sm) 0 8px;
  border-top: none; border-left: 1px solid var(--ui-border);
  border-radius: 0; background: transparent;
}

/* Docked vertical (left / right) */
[data-ui-skin] .toolbar-docked-left,
[data-ui-skin] .toolbar-docked-right {
  position: absolute !important;
  top: 0 !important; transform: none !important;
  height: 100% !important; max-height: 100%;
  flex-direction: column; align-items: center; justify-content: center;
  border-radius: 0; padding: var(--spacing-sm);
  overflow-y: auto; overflow-x: hidden;
}
[data-ui-skin] .toolbar-docked-left  { left: 0 !important; right: unset !important; border-right: 1px solid var(--ui-border); }
[data-ui-skin] .toolbar-docked-right { right: 0 !important; left: unset !important; border-left: 1px solid var(--ui-border); }

/* Docked horizontal (top / bottom) */
[data-ui-skin] .toolbar-docked-top,
[data-ui-skin] .toolbar-docked-bottom {
  position: absolute !important;
  left: 0 !important; transform: none !important;
  width: 100% !important; max-height: none !important;
  min-height: calc(var(--row-height) + var(--spacing-sm) * 2);
  flex-direction: row; flex-wrap: nowrap; align-items: center; justify-content: center;
  border-radius: 0; padding: 4px var(--spacing-sm);
  overflow-x: auto; overflow-y: hidden;
}
[data-ui-skin] .toolbar-docked-top    { top: 0 !important; bottom: unset !important; border-bottom: 1px solid var(--ui-border); }
[data-ui-skin] .toolbar-docked-bottom { bottom: 0 !important; top: unset !important; border-top: 1px solid var(--ui-border); }

/* Dividers flip to vertical in horizontal bars */
[data-ui-skin] .toolbar-docked-top .tool-divider,
[data-ui-skin] .toolbar-docked-bottom .tool-divider {
  width: 1px; height: 22px;
  border: none; background: var(--ui-border);
  margin: 0 2px; align-self: center; flex-shrink: 0;
}

/* Horizontal dock: handle becomes a compact left-edge grip; swap to 2-col × 3-row portrait dots */
[data-ui-skin] .toolbar-docked-top .toolbar-drag-handle,
[data-ui-skin] .toolbar-docked-bottom .toolbar-drag-handle {
  width: 14px; height: auto;
  margin: 0 4px 0 0;
  align-self: stretch;
  flex-shrink: 0;
}
[data-ui-skin] .toolbar-docked-top .toolbar-drag-handle .handle-horiz,
[data-ui-skin] .toolbar-docked-bottom .toolbar-drag-handle .handle-horiz { display: none; }
[data-ui-skin] .toolbar-docked-top .toolbar-drag-handle .handle-vert,
[data-ui-skin] .toolbar-docked-bottom .toolbar-drag-handle .handle-vert { display: block; }

/* ── Floating horizontal: rotate the floating toolbar to a horizontal bar ── */
[data-ui-skin] .tool-bar.toolbar-floating-horizontal:not([class*="toolbar-docked"]) {
  flex-direction: row; align-items: center;
  max-height: none; max-width: calc(100% - 20px);
  overflow-x: auto; overflow-y: hidden;
}
[data-ui-skin] .tool-bar.toolbar-floating-horizontal:not([class*="toolbar-docked"]) .tool-divider {
  width: 1px; height: 22px;
  margin: 0 2px; align-self: center; flex-shrink: 0;
}
[data-ui-skin] .tool-bar.toolbar-floating-horizontal:not([class*="toolbar-docked"]) .toolbar-drag-handle {
  width: 14px; height: auto;
  margin: 0 4px 0 0;
  align-self: stretch; flex-shrink: 0;
}
[data-ui-skin] .tool-bar.toolbar-floating-horizontal:not([class*="toolbar-docked"]) .toolbar-drag-handle .handle-horiz { display: none; }
[data-ui-skin] .tool-bar.toolbar-floating-horizontal:not([class*="toolbar-docked"]) .toolbar-drag-handle .handle-vert  { display: block; }
[data-ui-skin] .tool-bar.toolbar-floating-horizontal:not([class*="toolbar-docked"]) .toolbar-footer {
  flex-direction: column; align-self: stretch;
  align-items: center; justify-content: center;
  margin: calc(-1 * var(--spacing-sm)) calc(-1 * var(--spacing-sm)) calc(-1 * var(--spacing-sm)) 4px;
  padding: 2px 4px;
  border-top: none; border-left: 1px solid var(--ui-border);
  border-radius: 0 var(--radius-lg) var(--radius-lg) 0;
}
/* Vertical-stacked footer: spacing rotates from horizontal to vertical so the
   pin centers cleanly when home/rotate collapse out in the locked state. */
[data-ui-skin] .tool-bar.toolbar-floating-horizontal:not([class*="toolbar-docked"]) .toolbar-footer > button + button {
  margin-left: 0; margin-top: 2px;
}

/* Snap zone overlays — injected by JS into #viewport-container */
.toolbar-snap-zone {
  position: absolute; pointer-events: none; z-index: 4;
  background: var(--ui-accent); opacity: 0;
  transition: opacity 0.15s;
}
.toolbar-snap-zone.snap-active { opacity: 0.12; }
.toolbar-snap-zone-left   { left: 0;    top: 0;   width: 48px; height: 100%; }
.toolbar-snap-zone-right  { right: 0;   top: 0;   width: 48px; height: 100%; }
.toolbar-snap-zone-top    { top: 0;     left: 0;  width: 100%; height: 48px; }
.toolbar-snap-zone-bottom { bottom: 0;  left: 0;  width: 100%; height: 48px; }

#viewport-container { transition: padding 0.15s; }

.tool-btn {
  width: var(--row-height); height: var(--row-height);
  min-width: 30px; min-height: 30px;
  display: flex; align-items: center; justify-content: center;
  background: none; border: 1px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer; color: var(--ui-muted);
  transition: background-color 0.12s, color 0.12s, border-color 0.12s, box-shadow 0.12s;
}
.tool-btn:hover { background: var(--ui-ctrl-hov); color: var(--ui-text); }
.tool-btn.active {
  background: var(--ui-accent-2); border-color: var(--ui-accent);
  color: var(--ui-accent);
  box-shadow: 0 0 0 1px var(--ui-accent-2);
}
.tool-divider { height: 1px; background: var(--ui-border); margin: 1px 0; }

/* ── PAPER ───────────────────────────────────────────────────── */
.paper-doc {
  background: #fff; border: 1px solid rgba(0, 0, 0, 0.12);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.28), 0 2px 6px rgba(0, 0, 0, 0.14);
  width: 300px; height: 420px;
  display: flex; align-items: center; justify-content: center;
  color: #1a1a1a; position: relative; z-index: 2; border-radius: 2px;
}
.paper-doc svg { width: 88%; height: 88%; }

/* ── BOTTOM PANE ─────────────────────────────────────────────── */
.bottom-pane {
  height: var(--bottom-pane-height); border-top: 1px solid var(--ui-border);
  background: var(--ui-panel); display: flex; flex-direction: column; flex-shrink: 0;
  transition: background 0.2s, border-color 0.2s;
}
.bottom-hdr {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 var(--spacing-md);
  height: 30px;
  border-bottom: 1px solid var(--ui-border); background: var(--ui-panel-alt); flex-shrink: 0;
}
.bottom-body {
  flex: 1; padding: var(--spacing-sm) var(--spacing-md);
  display: flex; gap: var(--spacing-sm); overflow: hidden;
}
.formula-block { flex: 1; display: flex; flex-direction: column; gap: var(--spacing-xs); }
.formula-eq {
  background: var(--ui-panel-alt); border: 1px solid var(--ui-border);
  border-radius: var(--radius-sm);
  padding: 6px var(--spacing-sm);
  font-family: var(--font-mono); font-size: 11px; color: var(--ui-formula);
  display: flex; flex-direction: column; gap: 2px;
}
.formula-accent { color: var(--ui-accent); font-weight: 500; }
.formula-params { display: grid; grid-template-columns: 1fr 1fr 1fr 1fr; gap: var(--spacing-xs); }
.formula-param {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--ui-panel-alt); border: 1px solid var(--ui-border);
  border-radius: var(--radius-sm);
  padding: 3px var(--spacing-sm);
  font-family: var(--font-mono); font-size: 10px;
}
.f-key { color: var(--ui-muted); }
.f-val { color: var(--ui-accent); font-variant-numeric: tabular-nums; }

/* ── RIGHT PANE ──────────────────────────────────────────────── */
.pane-right {
  width: var(--pane-right-width); flex-shrink: 0;
  background: var(--ui-panel); border-left: 1px solid var(--ui-border);
  display: flex; flex-direction: column; overflow: hidden;
  transition: background 0.2s, border-color 0.2s;
}
.right-sect-hdr {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 var(--spacing-md);
  min-height: var(--row-height);
  background: var(--ui-panel-alt); border: none; width: 100%; cursor: pointer;
  color: var(--ui-text-2); font-family: var(--font-ui);
  font-size: var(--font-size-sm); font-weight: 600; letter-spacing: 0;
  text-transform: none; text-align: left;
  border-bottom: 1px solid var(--ui-border);
  transition: background 0.1s;
}
.right-sect-hdr:hover { background: var(--ui-ctrl-hov); }

/* ── TABS ────────────────────────────────────────────────────── */
.tab-bar {
  display: flex; align-items: center;
  border-bottom: 1px solid var(--ui-border);
  background: var(--ui-panel-alt); flex-shrink: 0;
}
.tab-btn {
  flex: 1; height: 34px; background: none; border: none; border-bottom: 2px solid transparent;
  color: var(--ui-text-2); font-family: var(--font-ui);
  font-size: var(--font-size-sm); font-weight: 600;
  cursor: pointer; position: relative; margin-bottom: -1px;
  transition: color 0.12s, border-color 0.12s, background 0.1s;
}
.tab-btn:hover { color: var(--ui-text); background: var(--ui-ctrl-hov); }
.tab-btn.active { color: var(--ui-accent); border-bottom-color: var(--ui-accent); }
.tab-panel { display: none; flex: 1; flex-direction: column; overflow: hidden; min-height: 0; }
.tab-panel.active { display: flex; }
.tab-panel-hdr {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 var(--spacing-sm) 0 var(--spacing-md);
  height: 30px; flex-shrink: 0;
  border-bottom: 1px solid var(--ui-border);
  background: var(--ui-panel);
}
.tab-panel-meta { font-size: var(--font-size-xs); color: var(--ui-muted); font-family: var(--font-mono); }

/* Layers */
.layer-list {
  display: flex; flex-direction: column; gap: var(--spacing-xs);
  padding: var(--spacing-xs) var(--spacing-sm);
}
.layer-item {
  display: flex; align-items: center; gap: var(--spacing-sm);
  padding: var(--spacing-xs) var(--spacing-sm);
  min-height: var(--row-height);
  border-radius: var(--radius-md); border: 1px solid transparent;
  cursor: pointer; transition: background 0.1s;
}
.layer-item:hover { background: var(--ui-ctrl-hov); }
.layer-item.active { background: var(--ui-ctrl); border-color: var(--ui-border); }
.layer-item.dim { opacity: 0.4; }
.layer-bar { width: 3px; height: 22px; border-radius: 2px; flex-shrink: 0; }
.layer-name {
  flex: 1; font-size: var(--font-size-sm);
  color: var(--ui-text); font-family: var(--font-ui); font-weight: 500;
}
.layer-tag {
  font-size: 9px; letter-spacing: 0.06em;
  color: var(--ui-accent); text-transform: uppercase;
  background: var(--ui-accent-2);
  border-radius: 9999px; padding: 2px 8px; font-family: var(--font-mono);
}
.layer-acts { display: flex; gap: 2px; }
.layer-act {
  background: none; border: none; color: var(--ui-muted); cursor: pointer;
  font-size: 11px; width: 22px; height: 22px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm); transition: color 0.1s, background 0.1s;
}
.layer-act:hover { color: var(--ui-accent); background: var(--ui-accent-2); }

/* Pens */
.pens-bar {
  display: flex; align-items: center; gap: var(--spacing-sm);
  padding: var(--spacing-sm) var(--spacing-md);
  border-bottom: 1px solid var(--ui-border);
}
.palette-btn {
  flex: 1; background: var(--ui-ctrl); border: 1px solid var(--ui-border);
  color: var(--ui-text-2); font-family: var(--font-ui); font-weight: 500;
  font-size: var(--font-size-xs);
  padding: 0 var(--spacing-sm); height: var(--row-height);
  border-radius: var(--radius-sm); cursor: pointer; text-align: left;
  transition: border-color 0.1s;
}
.palette-btn:hover { border-color: var(--ui-border-hi); }
.add-btn {
  background: var(--ui-accent); color: var(--ui-on-accent); border: none;
  font-family: var(--font-ui); font-weight: 600;
  font-size: var(--font-size-xs);
  padding: 0 var(--spacing-sm); height: 24px;
  border-radius: var(--radius-sm); cursor: pointer;
  transition: opacity 0.1s; white-space: nowrap;
}
@media (hover: hover) {
  .add-btn:hover { opacity: 0.88; }
}

.pen-list {
  display: flex; flex-direction: column; gap: 1px;
  padding: var(--spacing-xs) var(--spacing-md);
}
.pen-item {
  display: flex; align-items: center; gap: var(--spacing-sm);
  padding: 2px 0; min-height: var(--row-height);
}
.pen-dot { width: 13px; height: 13px; border-radius: 50%; border: 1px solid rgba(0, 0, 0, 0.2); flex-shrink: 0; }
.pen-nm {
  font-size: var(--font-size-xs); color: var(--ui-text-2);
  width: 32px; flex-shrink: 0; font-family: var(--font-mono);
}

[data-ui-skin] .pen-sld {
  flex: 1;
  -webkit-appearance: none; appearance: none;
  height: 3px; border-radius: 2px; cursor: pointer; outline: none;
  background: linear-gradient(to right,
    var(--slider-start) 0%,
    var(--ui-accent) var(--fill, 0%),
    var(--ui-border) var(--fill, 0%) 100%
  );
}
[data-ui-skin] .pen-sld::-webkit-slider-runnable-track { background: transparent; height: 0; }
[data-ui-skin] .pen-sld::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 11px; height: 11px; border-radius: 50%;
  background: var(--ui-accent); border: 2px solid var(--ui-panel);
  box-shadow: 0 0 0 1px var(--ui-accent);
  cursor: pointer; transition: transform 0.1s;
}
[data-ui-skin] .pen-sld:hover::-webkit-slider-thumb { transform: scale(1.18); }
[data-ui-skin] .pen-sld::-moz-range-thumb {
  width: 11px; height: 11px; border-radius: 50%;
  background: var(--ui-accent); border: 2px solid var(--ui-panel);
}
[data-ui-skin] .pen-sld::-moz-range-track { height: 3px; background: var(--ui-border); border-radius: 2px; }
[data-ui-skin] .pen-sld::-moz-range-progress {
  height: 3px; border-radius: 2px 0 0 2px;
  background: linear-gradient(to right, var(--slider-start), var(--ui-accent));
}
.pen-w {
  font-size: var(--font-size-xs); color: var(--ui-muted);
  width: 26px; text-align: right; font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

/* Stats */
.stats-box { padding: var(--spacing-sm) var(--spacing-md); }
.stats-ttl {
  font-size: var(--font-size-xs); letter-spacing: 0;
  text-transform: none; color: var(--ui-muted);
  margin-bottom: var(--spacing-sm); font-family: var(--font-ui); font-weight: 600;
}
.stats-grid { display: grid; grid-template-columns: auto 1fr; gap: 3px var(--spacing-sm); align-items: center; }
.s-key { font-size: var(--font-size-xs); color: var(--ui-muted); }
.s-val {
  font-size: var(--font-size-xs); color: var(--ui-accent);
  font-family: var(--font-mono); font-variant-numeric: tabular-nums;
}
.bg-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--spacing-sm) var(--spacing-md);
  border-bottom: 1px solid var(--ui-border); min-height: var(--row-height);
}
.bg-lbl {
  font-size: var(--font-size-xs); color: var(--ui-muted);
  letter-spacing: 0; text-transform: none; font-weight: 500;
}
.bg-sw {
  width: 16px; height: 16px; border-radius: var(--radius-sm);
  border: 1px solid var(--ui-border); background: #fff;
}

/* ─── Phase 4: Petal Designer chrome re-skin ───────────────────────────────
 * Scoped to [data-ui-skin] so classic skins keep today's styles.
 * Pure additive — no JS changes; the petal-designer chrome class names
 * (.petal-designer-header, .petal-designer-title, .petal-tool-btn, etc.)
 * are unchanged in src/ui/ui-petal-designer.js.
 */
[data-ui-skin] .petal-designer-window {
  background: var(--ui-panel);
  border: 1px solid var(--ui-border);
  border-radius: var(--radius-md);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.32);
  font-family: var(--font-ui);
}
[data-ui-skin] .petal-designer-inline {
  background: var(--ui-panel);
  border: 1px solid var(--ui-border);
  border-radius: var(--radius-md);
}
[data-ui-skin] .petal-designer-header {
  background: var(--ui-panel-alt);
  border-bottom: 1px solid var(--ui-border);
  padding: 8px 12px;
  font-family: var(--font-ui);
}
[data-ui-skin] .petal-designer-title {
  font-size: var(--font-size-xs);
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--ui-accent);
  font-weight: 600;
}
[data-ui-skin] .petal-tool-btn,
[data-ui-skin] .petal-close,
[data-ui-skin] .petal-popout,
[data-ui-skin] .petal-popin,
[data-ui-skin] .petal-hist,
[data-ui-skin] .petal-copy-btn {
  border: 1px solid var(--ui-border);
  background: var(--ui-ctrl);
  color: var(--ui-text);
  border-radius: var(--radius-sm);
  font-family: var(--font-ui);
  font-size: var(--font-size-xs);
  height: 26px;
  min-width: 26px;
  padding: 0 8px;
  transition: background 120ms ease, border-color 120ms ease, color 120ms ease;
}
[data-ui-skin] .petal-tool-btn:hover,
[data-ui-skin] .petal-close:hover,
[data-ui-skin] .petal-popout:hover,
[data-ui-skin] .petal-popin:hover,
[data-ui-skin] .petal-hist:hover,
[data-ui-skin] .petal-copy-btn:hover {
  background: var(--ui-ctrl-hov);
  border-color: var(--ui-border-hi);
  color: var(--ui-accent);
}
[data-ui-skin] .petal-tool-btn.active {
  background: var(--ui-accent-2);
  border-color: var(--ui-accent);
  color: var(--ui-accent);
}
[data-ui-skin] .petal-designer-controls,
[data-ui-skin] .petal-designer-structure,
[data-ui-skin] .petal-designer-transition {
  background: var(--ui-panel);
  border-bottom: 1px solid var(--ui-border);
}
[data-ui-skin] .petal-designer-controls label,
[data-ui-skin] .petal-designer-structure label,
[data-ui-skin] .petal-slider-label > span:first-child {
  color: var(--ui-muted);
  font-family: var(--font-ui);
  font-size: var(--font-size-xs);
  letter-spacing: 0.04em;
  text-transform: none;
  font-weight: 500;
}
[data-ui-skin] .petal-slider-value {
  color: var(--ui-accent);
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}
[data-ui-skin] .petal-designer-controls select,
[data-ui-skin] .petal-designer-structure select,
[data-ui-skin] .petal-slider-label > select {
  background: var(--ui-ctrl);
  border: 1px solid var(--ui-border);
  color: var(--ui-text);
  border-radius: var(--radius-sm);
}
[data-ui-skin] .petal-designer-shading-title {
  color: var(--ui-text);
  font-family: var(--font-ui);
  letter-spacing: 0.16em;
  font-weight: 600;
}
[data-ui-skin] .petal-profile-editor-card {
  background: var(--ui-panel-alt);
  border: 1px solid var(--ui-border);
  border-radius: var(--radius-sm);
}
[data-ui-skin] .petal-profile-editor-card.is-active {
  border-color: var(--ui-accent);
}
[data-ui-skin] .petal-profile-editor-card-title {
  color: var(--ui-accent);
  font-family: var(--font-ui);
  font-weight: 600;
}
[data-ui-skin] .petal-shade-toggle input {
  accent-color: var(--ui-accent);
}

/* Visual petal-profile gallery — thumbnail strip replacing the name select */
.petal-profile-thumbs {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 4px;
}
.petal-profile-thumb {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 3px 1px 2px;
  background: var(--ui-panel-alt, transparent);
  border: 1px solid var(--ui-border, #2a2f3a);
  border-radius: var(--radius-sm, 3px);
  cursor: pointer;
  transition: border-color 120ms ease, background 120ms ease;
}
.petal-profile-thumb:hover {
  border-color: var(--ui-accent-muted, var(--ui-accent, #67e8f9));
}
.petal-profile-thumb.active {
  border-color: var(--ui-accent, #67e8f9);
  background: var(--ui-accent-soft, rgba(103, 232, 249, 0.08));
}
.petal-profile-thumb canvas {
  display: block;
  width: 100%;
  height: auto;
}
.petal-profile-thumb-name {
  font-size: 8px;
  line-height: 1.1;
  letter-spacing: 0.04em;
  color: var(--ui-text-muted, #8b93a7);
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.petal-profile-thumb.active .petal-profile-thumb-name {
  color: var(--ui-accent, #67e8f9);
}

/* ─── Phase 4: Pattern Designer chrome re-skin ─────────────────────────── */
[data-ui-skin] .pattern-designer-modal,
[data-ui-skin] .pattern-designer-inline {
  background: var(--ui-panel);
  border: 1px solid var(--ui-border);
  border-radius: var(--radius-md);
  font-family: var(--font-ui);
}
[data-ui-skin] .pattern-designer-header,
[data-ui-skin] .pd-header {
  background: var(--ui-panel-alt);
  border-bottom: 1px solid var(--ui-border);
  padding: 8px 12px;
}
[data-ui-skin] .pattern-designer-title,
[data-ui-skin] .pd-title {
  color: var(--ui-accent);
  font-family: var(--font-ui);
  font-size: var(--font-size-xs);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  font-weight: 600;
}
[data-ui-skin] .pd-tool-btn,
[data-ui-skin] .pd-action-btn,
[data-ui-skin] .pd-fill-btn {
  border: 1px solid var(--ui-border);
  background: var(--ui-ctrl);
  color: var(--ui-text);
  border-radius: var(--radius-sm);
  font-family: var(--font-ui);
  font-size: var(--font-size-xs);
  height: 26px;
  min-width: 26px;
  padding: 0 8px;
  transition: background 120ms ease, border-color 120ms ease, color 120ms ease;
}
[data-ui-skin] .pd-tool-btn:hover,
[data-ui-skin] .pd-action-btn:hover,
[data-ui-skin] .pd-fill-btn:hover {
  background: var(--ui-ctrl-hov);
  border-color: var(--ui-border-hi);
  color: var(--ui-accent);
}
[data-ui-skin] .pd-tool-btn.active,
[data-ui-skin] .pd-fill-btn.active {
  background: var(--ui-accent-2);
  border-color: var(--ui-accent);
  color: var(--ui-accent);
}
[data-ui-skin] .pd-status,
[data-ui-skin] .pattern-designer-status {
  background: var(--ui-panel-alt);
  color: var(--ui-muted);
  font-family: var(--font-mono);
  font-size: var(--font-size-xs);
  border-top: 1px solid var(--ui-border);
}
[data-ui-skin] .pd-validation-header,
[data-ui-skin] .pattern-designer-validation-header {
  color: var(--ui-text);
  font-family: var(--font-ui);
  font-weight: 600;
  letter-spacing: 0.12em;
}

/* ─── Phase 4: Touch modifier bar chrome re-skin ──────────────────────── */
[data-ui-skin] #touch-modifier-bar,
[data-ui-skin] .touch-modifier-bar {
  background: var(--ui-panel-alt);
  border-top: 1px solid var(--ui-border);
  font-family: var(--font-ui);
}
[data-ui-skin] .touch-modifier-bar button,
[data-ui-skin] #touch-modifier-bar button {
  border: 1px solid var(--ui-border);
  background: var(--ui-ctrl);
  color: var(--ui-text);
  border-radius: var(--radius-sm);
  font-family: var(--font-ui);
  font-size: var(--font-size-xs);
  transition: background 120ms ease, border-color 120ms ease, color 120ms ease;
}
/* TUX-036: hover only where a real hover exists; a touch tap leaves :hover stuck. */
@media (hover: hover) {
  [data-ui-skin] .touch-modifier-bar button:hover,
  [data-ui-skin] #touch-modifier-bar button:hover {
    background: var(--ui-ctrl-hov);
    border-color: var(--ui-border-hi);
    color: var(--ui-accent);
  }
} /* TUX-036 */
[data-ui-skin] .touch-modifier-bar button.active,
[data-ui-skin] #touch-modifier-bar button.active {
  background: var(--ui-accent-2);
  border-color: var(--ui-accent);
  color: var(--ui-accent);
}

/* ──────────────────────────────────────────────────────────────────────
 * UNIVERSAL SHELL RE-SKIN — applies to every active skin via [data-ui-skin]
 *
 * The mockup at docs/design/themes-mockup.html defines the canonical chrome
 * for Vectura Studio: section headers with a left accent bar, Space Grotesk
 * UI / JetBrains Mono numerics, sentence-case section titles, 30px row
 * height, 4/8/12 radius scale, slim panel shadows. This block maps that
 * styling onto the live DOM classes (top-menu-*, pane-*,
 * left-panel-section-*, lvl-*, pen-*, bottom-pane-*, etc.) and applies it
 * to ALL skins so classic-dark, classic-light, lark, and the meridian-*
 * variants share one chrome vocabulary — only the palette tokens differ.
 *
 * Specificity note: the [data-ui-skin] attribute selector beats the bare
 * class selectors in legacy CSS that come later in load order, so these
 * rules win without !important.
 * ────────────────────────────────────────────────────────────────────── */

/* ─── Typography: Space Grotesk for UI, JetBrains Mono for numerics ──── */
[data-ui-skin] body,
[data-ui-skin] button,
[data-ui-skin] input,
[data-ui-skin] select,
[data-ui-skin] textarea {
  font-family: var(--font-ui);
}
/* Surfaces that must stay mono per the mockup. */
[data-ui-skin] .top-menu-shortcut,
[data-ui-skin] .pane-meta,
[data-ui-skin] #status-bar,
[data-ui-skin] #formula-display,
[data-ui-skin] .formula-text,
[data-ui-skin] #formula-seed-display,
[data-ui-skin] #stat-dist,
[data-ui-skin] #stat-lines,
[data-ui-skin] #stat-time,
[data-ui-skin] .palette-toggle,
[data-ui-skin] .pen-nm,
[data-ui-skin] .pen-w,
[data-ui-skin] .lvl-status-bar {
  font-family: var(--font-mono);
}

/* ─── Drawing-order (plot progress) slider ───────────────────────────── */
[data-ui-skin] .draw-order-bar {
  flex: 0 0 auto;
  padding: 7px 12px 10px;
  border-top: 1px solid var(--ui-border);
  background: var(--ui-panel);
}
/* Hidden while the canvas is blank — the draw-order reveal has nothing to
   scrub through until at least one layer exists. */
[data-ui-skin] .draw-order-bar.hidden { display: none; }
[data-ui-skin] .draw-order-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 5px;
}
[data-ui-skin] .draw-order-label {
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ui-muted);
}
[data-ui-skin] .draw-order-value {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--ui-accent);
  font-variant-numeric: tabular-nums;
}
[data-ui-skin] .draw-order-head-right {
  display: flex;
  align-items: center;
  gap: 7px;
}
[data-ui-skin] .draw-order-settings {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  padding: 0;
  border: none;
  border-radius: 4px;
  background: transparent;
  color: var(--ui-muted);
  cursor: pointer;
  transition: color 0.12s ease, background 0.12s ease;
}
[data-ui-skin] .draw-order-settings:hover {
  color: var(--ui-accent);
  background: var(--ui-border);
}
/* Eye toggle: shows/hides the line-sort overlay order. Closed + grey by default;
   open with a start→end print-order gradient outline when enabled. */
[data-ui-skin] .draw-order-overlay-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  padding: 0;
  border: none;
  border-radius: 4px;
  background: transparent;
  color: var(--ui-muted);
  cursor: pointer;
  transition: color 0.12s ease, background 0.12s ease;
}
[data-ui-skin] .draw-order-overlay-toggle:hover {
  background: var(--ui-border);
  color: var(--ui-text-2);
}
[data-ui-skin] .draw-order-overlay-toggle .eye-open {
  display: none;
}
[data-ui-skin] .draw-order-overlay-toggle .eye-closed {
  display: inline;
}
[data-ui-skin] .draw-order-overlay-toggle.is-on .eye-open {
  display: inline;
  stroke: url(#draw-order-eye-grad);
}
[data-ui-skin] .draw-order-overlay-toggle.is-on .eye-closed {
  display: none;
}
[data-ui-skin] .draw-order-overlay-toggle.is-on:hover {
  background: var(--ui-border);
}
/* Start / End anchors under the bar, so the gradient direction (print order) reads
   clearly: Start at the left edge of the track, End at the right. */
/* Single meta row: Start … distance | lines | time … End, all on one line.
   Start/End anchor the gradient ends; the plot estimate sits centred between. */
[data-ui-skin] .draw-order-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-top: 4px;
  font-family: var(--font-mono);
  color: var(--ui-muted);
}
[data-ui-skin] .draw-order-end {
  flex: 0 0 auto;
  font-size: 8px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
/* Plot estimate readout: distance | lines | time, pipe-separated, small + muted. */
[data-ui-skin] .draw-order-stats {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  font-size: 8px;
  letter-spacing: 0.02em;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
[data-ui-skin] .draw-order-stat-sep {
  color: var(--ui-border);
}
/* Plot-physics readout (Phase 4A Inc-2, K-05): read-only per-pen lifts /
   travel / est. time table in the Document Overview pane, plus a document
   total and a sub-resolution (min-segment / min-gap) warning. Purely a
   readout — it never affects emitted geometry. */
[data-ui-skin] .plot-physics-readout {
  margin-top: 0;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}
[data-ui-skin] .plot-physics-readout:empty {
  display: none;
}
[data-ui-skin] .plot-physics-head {
  font-size: 9px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ui-muted);
  margin-bottom: 4px;
}
[data-ui-skin] .plot-physics-total {
  margin-top: 3px;
  padding-top: 3px;
  border-top: 1px solid var(--ui-border);
}
[data-ui-skin] .plot-physics-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto auto;
  align-items: center;
  gap: 8px;
  font-size: 10px;
  color: var(--ui-text);
  padding: 1px 0;
}
[data-ui-skin] .plot-physics-pen {
  display: flex;
  align-items: center;
  gap: 5px;
  min-width: 0;
}
[data-ui-skin] .plot-physics-pen-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
[data-ui-skin] .plot-physics-swatch {
  flex: 0 0 auto;
  width: 8px;
  height: 8px;
  border-radius: 2px;
  /* A brighter outer border (matches .pen-loupe-swatch) defines the chip
     against the dark panel — the default palette's white pen was edgeless on
     it — and an inset ring bounds light fills from within. */
  border: 1px solid var(--ui-border-hi);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.35);
}
[data-ui-skin] .plot-physics-swatch-total {
  background: linear-gradient(90deg, #38bdf8 0%, #f59e0b 100%);
}
[data-ui-skin] .plot-physics-cell {
  text-align: right;
  white-space: nowrap;
  color: var(--ui-accent);
}
[data-ui-skin] .plot-physics-cell small {
  margin-left: 2px;
  font-size: 8px;
  color: var(--ui-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
[data-ui-skin] .plot-physics-warn {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 5px;
  font-size: 9px;
  color: var(--ui-danger);
}
[data-ui-skin] .plot-physics-warn-icon {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--ui-danger);
  color: var(--ui-on-danger);
  font-weight: 700;
  font-size: 9px;
}
/* Low-profile track carrying a vivid plot-progress gradient. The filled portion is
   painted with a left-anchored gradient via a CSS var the JS updates on input. */
[data-ui-skin] .draw-order-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 6px;
  outline: none;
  cursor: pointer;
  --draw-order-fill: 100%;
  /* The full start→end print-order gradient is painted across the WHOLE track width,
     and the fill simply reveals the left part of it — an opaque track-coloured cap
     covers the unfilled right portion. So colours map to absolute plot position
     rather than a squeezed copy of the whole gradient. JS updates the two stops via
     --draw-order-start / --draw-order-end and the reveal via --draw-order-fill. */
  background:
    linear-gradient(var(--ui-border), var(--ui-border)) no-repeat,
    linear-gradient(90deg,
      var(--draw-order-start, #38bdf8) 0%, var(--draw-order-end, #f59e0b) 100%)
      no-repeat,
    var(--ui-border);
  background-size:
    calc(100% - var(--draw-order-fill)) 100%,
    100% 100%,
    100% 100%;
  background-position: right center, left center, left center;
}
/* Suppress the global 2px runnable-track line so only the gradient (painted on the
   input itself) shows — otherwise a blue-grey bar bisects the slider. */
[data-ui-skin] .draw-order-slider::-webkit-slider-runnable-track {
  background: transparent;
  height: 6px;
  border: none;
}
[data-ui-skin] .draw-order-slider::-moz-range-track {
  background: transparent;
  height: 6px;
  border: none;
}
[data-ui-skin] .draw-order-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--ui-text, #fff);
  /* Ring + glow tinted with the gradient colour at the current stop (JS sets
     --draw-order-halo), so the handle reads as the colour being plotted right now. */
  border: 2px solid var(--draw-order-halo, var(--ui-accent));
  box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.35),
    0 0 7px 1px var(--draw-order-halo, var(--ui-accent));
  transition: transform 0.08s ease, border-color 0.08s ease, box-shadow 0.08s ease;
  /* Centre the 13px thumb on the 6px track (overrides the global -5px tuned for 2px). */
  margin-top: -3.5px;
}
[data-ui-skin] .draw-order-slider::-webkit-slider-thumb:hover {
  transform: scale(1.18);
}
[data-ui-skin] .draw-order-slider::-moz-range-thumb {
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--ui-text, #fff);
  border: 2px solid var(--draw-order-halo, var(--ui-accent));
  box-shadow: 0 0 7px 1px var(--draw-order-halo, var(--ui-accent));
}
/* Below 100% the handle becomes a rounded "play" triangle (more left to reveal).
   JS (refreshDrawOrderHalo/updateDrawOrderThumbShape) bakes the fill/ring into the
   --draw-order-thumb-icon SVG so they hug the triangle exactly like the circle's
   border hugs the circle — a plain border-radius can't do that for a non-circular
   shape on a single pseudo-element. The triangle fills its own viewBox edge-to-edge
   (like border-radius:50% fills the circle's box) so there's no dead transparent
   margin for the track underneath to peek through at low values. `border-radius: 0`
   is NOT optional here — the base rule's 50% (for the circle) otherwise survives
   the cascade and clips this background-image into a circle, chopping the
   triangle's base corners off into a rounded mask. The glow itself is a
   `filter: drop-shadow` (unlike box-shadow/background-image it isn't clipped to the
   box, so it can bleed the same way the circle's box-shadow glow does) tied to the
   same --draw-order-halo colour the ring uses. Sized to 85% of what the CIRCLE looks
   like mid-hover (13px * 1.18 * 0.85 ≈ 22px) as its resting size, so the SAME
   `:hover` scale(1.18) rule above grows it further from there, matching the
   circle's hover behaviour. */
[data-ui-skin] .draw-order-slider.is-progress::-webkit-slider-thumb {
  width: 22px;
  height: 22px;
  margin-top: -8px;
  border-radius: 0;
  background: transparent;
  background-image: var(--draw-order-thumb-icon);
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  border: none;
  box-shadow: none;
  filter: drop-shadow(0 0 5px var(--draw-order-halo, var(--ui-accent)));
}
[data-ui-skin] .draw-order-slider.is-progress::-moz-range-thumb {
  width: 22px;
  height: 22px;
  border-radius: 0;
  background: transparent;
  background-image: var(--draw-order-thumb-icon);
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  border: none;
  box-shadow: none;
  filter: drop-shadow(0 0 5px var(--draw-order-halo, var(--ui-accent)));
}

/* ─── Header & brand ─────────────────────────────────────────────────── */
[data-ui-skin] #app-header {
  height: 38px;
  padding: 0 14px;
  background: var(--ui-panel);
  border-bottom: 1px solid var(--ui-border);
}
[data-ui-skin] #app-header .header-main {
  height: 38px;
  min-height: 38px;
  gap: 10px;
}
[data-ui-skin] #app-header .header-brand-menu > div:first-child {
  /* Brand square */
  width: 11px;
  height: 11px;
  background: var(--ui-accent);
  border-radius: var(--radius-sm);
  box-shadow: 0 0 8px var(--ui-accent-2);
}
[data-ui-skin] #app-header h1 {
  font-family: var(--font-mono);
  font-weight: 700;
  letter-spacing: 0.05em;
  font-size: 12px;
  color: var(--ui-accent);
}
[data-ui-skin] #app-header h1 span {
  font-weight: 300;
  color: var(--ui-muted);
  letter-spacing: 0;
}
[data-ui-skin] .header-menu-divider {
  width: 1px;
  height: 16px;
  background: var(--ui-border);
  margin: 0 4px;
}
[data-ui-skin] #status-bar {
  font-size: var(--font-size-xs);
  letter-spacing: 0.08em;
  color: var(--ui-muted);
  text-transform: uppercase;
}

/* ─── Top menubar — flat triggers, accent-topped panels ──────────────── */
[data-ui-skin] .top-menubar {
  gap: 1px;
  margin-left: 0;
}
[data-ui-skin] .top-menu-trigger {
  background: none;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--ui-text-2);
  font-family: var(--font-ui);
  font-size: var(--font-size-sm);
  font-weight: 500;
  letter-spacing: 0;
  padding: 4px 10px;
  height: 26px;
  transition: background 0.1s, color 0.1s;
}
[data-ui-skin] .top-menu-trigger:hover {
  background: var(--ui-ctrl-hov);
  border-color: transparent;
  color: var(--ui-text);
}
[data-ui-skin] .top-menu-trigger[aria-expanded="true"],
[data-ui-skin] .top-menu-trigger.open {
  background: var(--ui-ctrl-hov);
  border-color: transparent;
  color: var(--ui-accent);
}
[data-ui-skin] .top-menu-panel {
  top: calc(100% + 5px);
  min-width: 244px;
  padding: 0;
  background: var(--ui-panel);
  border: 1px solid var(--ui-border-hi);
  border-top: 3px solid var(--ui-accent);
  border-radius: 0 var(--radius-md) var(--radius-md) var(--radius-md);
  box-shadow: var(--shadow-lg);
}
[data-ui-skin] .top-menu-item {
  border: none;
  padding: 0 14px;
  min-height: var(--row-height);
  font-size: var(--font-size-sm);
  font-weight: 500;
  font-family: var(--font-ui);
  color: var(--ui-text);
  gap: 20px;
  transition: background 0.07s, color 0.07s;
}
[data-ui-skin] .top-menu-item:hover:not(:disabled) {
  background: var(--ui-accent-2);
  border-color: transparent;
  color: var(--ui-accent);
}
[data-ui-skin] .top-menu-shortcut {
  font-size: var(--font-size-xs);
  color: var(--ui-muted);
  letter-spacing: 0.04em;
}
[data-ui-skin] .top-menu-sep {
  border-top: 1px solid var(--ui-border);
  margin: 3px 0;
}

/* ─── Pane chrome ────────────────────────────────────────────────────── */
[data-ui-skin] .pane-left,
[data-ui-skin] .pane-right {
  background: var(--ui-panel);
  box-shadow: var(--shadow-pane);
}
[data-ui-skin] .pane-right {
  border-left: 1px solid var(--ui-border);
  box-shadow: none;
}
[data-ui-skin] .pane-left {
  border-right: none;
}
[data-ui-skin] .pane-header {
  height: 36px;
  padding: 0 var(--spacing-md);
  border-bottom: 1px solid var(--ui-border);
  background: var(--ui-panel);
}
[data-ui-skin] #right-pane .pane-header {
  background: var(--ui-panel);
  padding-left: 44px;
}
[data-ui-skin] .pane-title {
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: none;
  color: var(--ui-accent);
}
[data-ui-skin] .pane-meta {
  font-size: var(--font-size-xs);
  color: var(--ui-muted);
  letter-spacing: 0.04em;
}
[data-ui-skin] .pane-toggle {
  width: 28px;
  height: 28px;
  padding: 5px;
  border: none;
  background: none;
  border-radius: var(--radius-sm);
  color: var(--ui-muted);
  font-size: 10px;
}
[data-ui-skin] .pane-toggle:hover {
  border: none;
  color: var(--ui-text);
  background: transparent;
}

/* ─── Left panel collapsible sections ────────────────────────────────── */
[data-ui-skin] .left-panel-sections {
  gap: 0;
  padding: 0;
}
[data-ui-skin] #left-panel-content > .left-panel-sections,
[data-ui-skin] .pane-body > .left-panel-sections,
[data-ui-skin] .pane-body .p-4.left-panel-sections {
  padding: 0;
}
[data-ui-skin] .left-panel-section {
  border: none;
  border-bottom: 1px solid var(--ui-border);
  background: transparent;
}
[data-ui-skin] .left-panel-section-header {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--ui-panel-alt);
  border: none;
  padding: 0 var(--spacing-md);
  min-height: var(--row-height);
  cursor: pointer;
  text-align: left;
  font-family: var(--font-ui);
  font-size: var(--font-size-sm);
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
  color: var(--ui-text-2);
  transition: background 0.1s, color 0.1s;
}
[data-ui-skin] .left-panel-section-header:hover {
  background: var(--ui-ctrl-hov);
  color: var(--ui-text);
}
[data-ui-skin] .left-panel-section-header::before {
  content: '';
  display: block;
  width: 3px;
  height: 14px;
  background: var(--ui-accent);
  border-radius: 2px;
  flex-shrink: 0;
  margin-right: var(--spacing-sm);
  opacity: 0.45;
  transition: opacity 0.15s;
}
@media (hover: hover) {
  [data-ui-skin] .left-panel-section-header:hover::before {
  opacity: 1;
}
}
[data-ui-skin] .left-panel-section-title {
  font-size: var(--font-size-sm);
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
  color: inherit;
}
[data-ui-skin] .left-panel-section-toggle {
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  transform: none;
  flex-shrink: 0;
}
[data-ui-skin] .left-panel-section-toggle::before {
  content: '';
  display: block;
  width: 12px;
  height: 12px;
  background-color: var(--ui-muted);
  -webkit-mask: var(--chevron-svg) center / contain no-repeat;
  mask: var(--chevron-svg) center / contain no-repeat;
  transform: rotate(0deg);
  transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1), background-color 0.12s;
}
[data-ui-skin] .left-panel-section[aria-expanded="true"] .left-panel-section-toggle::before,
[data-ui-skin] .left-panel-section:not(.collapsed) .left-panel-section-toggle::before {
  transform: rotate(180deg);
}
[data-ui-skin] .left-panel-section-header:hover .left-panel-section-toggle::before {
  background-color: var(--ui-text-2);
}
[data-ui-skin] .left-panel-section-body {
  padding: var(--spacing-sm) var(--spacing-md);
  display: flex;
  flex-direction: column;
  gap: var(--spacing-sm);
}

/* Nested global-section headers (inside sections) — same accent-bar style */
[data-ui-skin] .global-section {
  margin: 0;
  padding-top: 0;
  border-top: none;
}
[data-ui-skin] .global-section-header {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--ui-panel-alt);
  border: none;
  border-radius: var(--radius-sm);
  padding: 0 var(--spacing-sm);
  min-height: var(--row-height);
  cursor: pointer;
  text-align: left;
  font-family: var(--font-ui);
  font-size: var(--font-size-sm);
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
  color: var(--ui-text-2);
}
[data-ui-skin] .global-section-header:hover {
  background: var(--ui-ctrl-hov);
  color: var(--ui-text);
}
[data-ui-skin] .global-section-title {
  font-size: var(--font-size-sm);
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
  color: inherit;
}
[data-ui-skin] .global-section-toggle {
  width: 20px;
  height: 20px;
  transform: none;
  display: flex;
  align-items: center;
  justify-content: center;
}
[data-ui-skin] .global-section-toggle::before {
  content: '';
  display: block;
  width: 12px;
  height: 12px;
  background-color: var(--ui-muted);
  -webkit-mask: var(--chevron-svg) center / contain no-repeat;
  mask: var(--chevron-svg) center / contain no-repeat;
  transform: rotate(0deg);
  transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1), background-color 0.12s;
}
[data-ui-skin] .global-section:not(.collapsed) .global-section-toggle::before {
  transform: rotate(180deg);
}
[data-ui-skin] .global-section-body {
  padding: var(--spacing-sm) 0 0;
}

/* ─── Form controls (inputs, selects, labels) ────────────────────────── */
[data-ui-skin] .control-label {
  display: block;
  font-family: var(--font-ui);
  font-size: var(--font-size-sm);
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
  color: var(--ui-text-2);
  margin-bottom: var(--spacing-xs);
}

/* "Moved off its default" marker. A parameter can be set without the user ever
   touching it — by the factory preset, by a mode cascade on a toggle, or by a saved
   document — and until now nothing said so. The dot marks any control that is not at
   the value a brand-new layer of this type would have; clicking it resets that one
   control. Deliberately quiet: it should read as a footnote when you go looking, not
   as an error when you don't. */
[data-ui-skin] .control-modified {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 12px;
  height: 12px;
  padding: 0;
  margin-left: var(--spacing-xs, 4px);
  vertical-align: middle;
  background: none;
  border: 0;
  border-radius: 50%;
  cursor: pointer;
  line-height: 0;
}
[data-ui-skin] .control-modified::before {
  content: '';
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--ui-accent);
  opacity: 0.75;
  transition: opacity 120ms ease, transform 120ms ease;
}
[data-ui-skin] .control-modified:focus-visible::before {
  opacity: 1;
  transform: scale(1.5);
}
@media (hover: hover) {
  [data-ui-skin] .control-modified:hover::before {
  opacity: 1;
  transform: scale(1.5);
}
}
[data-ui-skin] .control-modified:focus-visible {
  outline: 1px solid var(--ui-accent);
  outline-offset: 1px;
}
@media (prefers-reduced-motion: reduce) {
  [data-ui-skin] .control-modified::before { transition: none; }
}
[data-ui-skin] .control-group {
  margin-bottom: var(--spacing-md);
  padding-bottom: var(--spacing-md);
  border-bottom: 1px solid var(--ui-border);
}
[data-ui-skin] .control-group:last-child {
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 0;
}

[data-ui-skin] .theme-family-toggle {
  border-radius: var(--radius-sm);
  overflow: hidden;
}
[data-ui-skin] .theme-family-option {
  background: transparent;
  cursor: pointer;
  font-family: var(--font-ui);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  transition: background 0.12s, color 0.12s;
}
[data-ui-skin] .theme-family-option:hover {
  background: var(--ui-ctrl-hov);
}
[data-ui-skin] .theme-family-option.is-active {
  background: var(--ui-accent);
  color: var(--ui-bg);
}
[data-ui-skin] .theme-family-option.is-active:hover {
  background: var(--ui-accent);
}

/* Tailwind-styled inputs in left panel: bg-vectura-bg + border-vectura-border + p-1/p-2 + text-xs */
[data-ui-skin] .pane-left input[type="text"],
[data-ui-skin] .pane-left input[type="number"],
[data-ui-skin] .pane-left input[type="email"],
[data-ui-skin] .pane-left select,
[data-ui-skin] #left-panel-content input[type="text"],
[data-ui-skin] #left-panel-content input[type="number"],
[data-ui-skin] #left-panel-content select,
[data-ui-skin] #left-panel-content textarea {
  background: var(--ui-ctrl);
  border: 1px solid var(--ui-border);
  color: var(--ui-text);
  font-family: var(--font-ui);
  font-size: var(--font-size-sm);
  font-weight: 400;
  padding: 0 var(--spacing-sm);
  height: var(--row-height);
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color 0.12s, box-shadow 0.12s;
}
[data-ui-skin] .pane-left input[type="text"]:hover,
[data-ui-skin] .pane-left input[type="number"]:hover,
[data-ui-skin] .pane-left select:hover,
[data-ui-skin] #left-panel-content input[type="text"]:hover,
[data-ui-skin] #left-panel-content input[type="number"]:hover,
[data-ui-skin] #left-panel-content select:hover {
  border-color: var(--ui-border-hi);
}
[data-ui-skin] .pane-left input[type="text"]:focus,
[data-ui-skin] .pane-left input[type="number"]:focus,
[data-ui-skin] .pane-left select:focus,
[data-ui-skin] #left-panel-content input[type="text"]:focus,
[data-ui-skin] #left-panel-content input[type="number"]:focus,
[data-ui-skin] #left-panel-content select:focus {
  border-color: var(--ui-accent);
  box-shadow: 0 0 0 3px var(--ui-accent-2);
}

/* Numeric inputs: tabular-nums + mono in mockup */
[data-ui-skin] .pane-left input[type="number"],
[data-ui-skin] #left-panel-content input[type="number"] {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

/* Algorithm trigger button — round, ctrl bg, accent on hover */
[data-ui-skin] .gm-trigger {
  background: var(--ui-ctrl);
  border: 1px solid var(--ui-border);
  border-radius: var(--radius-sm);
  height: var(--row-height);
  padding: 0 var(--spacing-sm);
  color: var(--ui-text);
  font-family: var(--font-ui);
  font-size: var(--font-size-sm);
  transition: border-color 0.12s, background 0.12s;
}
[data-ui-skin] .gm-trigger:hover:not(.disabled) {
  border-color: var(--ui-border-hi);
  background: var(--ui-ctrl-hov);
}
[data-ui-skin] #algo-about {
  background: var(--ui-panel-alt);
  border: 1px solid var(--ui-border);
  border-radius: var(--radius-sm);
}

/* Info badge (i circle) */
[data-ui-skin] .info-btn {
  width: 14px;
  height: 14px;
  font-size: 9px;
  border: 1px solid var(--ui-border);
  border-radius: 50%;
  background: transparent;
  color: var(--ui-muted);
  font-family: var(--font-mono);
  padding: 0;
  margin-left: 6px;
  line-height: 1;
}
[data-ui-skin] .left-panel-section-header:hover .info-btn,
[data-ui-skin] .global-section-header:hover .info-btn {
  color: var(--ui-accent);
  border-color: var(--ui-accent);
}

/* ─── Right pane tabs ────────────────────────────────────────────────── */
[data-ui-skin] .right-pane-tabs {
  background: transparent;
  border-bottom: 1px solid var(--ui-border);
}
[data-ui-skin] .right-pane-tab {
  height: 34px;
  background: var(--ui-panel-alt);
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--ui-text-2);
  font-family: var(--font-ui);
  font-size: var(--font-size-sm);
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
  margin-bottom: -1px;
  transition: color 0.12s, border-color 0.12s, background 0.1s;
}
[data-ui-skin] .right-pane-tab:hover {
  color: var(--ui-text);
  background: var(--ui-ctrl-hov);
}
[data-ui-skin] .right-pane-tab.active {
  color: var(--ui-accent);
  border-bottom-color: var(--ui-accent);
  background: var(--ui-panel);
}

/* ─── Layer search bar & add button ─────────────────────────────────── */
[data-ui-skin] .lvl-search-bar {
  padding: var(--spacing-sm) var(--spacing-md);
  background: var(--ui-panel);
  border-bottom: 1px solid var(--ui-border);
  gap: var(--spacing-sm);
}
[data-ui-skin] .lvl-search-wrap {
  background: var(--ui-ctrl);
  border: 1px solid var(--ui-border);
  border-radius: var(--radius-sm);
  padding: 0 var(--spacing-sm);
  height: var(--row-height);
  gap: 6px;
  min-width: 0;
  overflow: hidden;
  transition: border-color 0.12s, box-shadow 0.12s;
}
[data-ui-skin] .lvl-search-wrap:focus-within {
  border-color: var(--ui-accent);
  box-shadow: 0 0 0 3px var(--ui-accent-2);
}
[data-ui-skin] .lvl-search-bar .lvl-search-input {
  font-family: var(--font-ui);
  font-size: var(--font-size-sm);
  color: var(--ui-text);
  background: var(--ui-ctrl);
  min-width: 0;
  width: 0;
}
[data-ui-skin] .lvl-search-bar .lvl-search-input::placeholder {
  color: var(--ui-muted);
}
[data-ui-skin] .lvl-filter-btn {
  background: var(--ui-ctrl);
  border: 1px solid var(--ui-border);
  border-radius: var(--radius-sm);
  color: var(--ui-muted);
  height: var(--row-height);
  padding: 0 var(--spacing-sm);
  flex-shrink: 0;
  position: relative;
  z-index: 1;
  transition: border-color 0.12s, color 0.12s;
}
[data-ui-skin] .lvl-filter-btn:hover {
  border-color: var(--ui-border-hi);
  color: var(--ui-accent);
}
[data-ui-skin] .lvl-add-btn {
  height: 24px;
  padding: 0 var(--spacing-sm);
  background: var(--ui-accent);
  border: none;
  border-radius: var(--radius-sm);
  color: var(--ui-on-accent);
  font-family: var(--font-ui);
  font-size: var(--font-size-xs);
  font-weight: 600;
  gap: 4px;
  transition: opacity 0.1s, filter 0.1s;
}
@media (hover: hover) {
  [data-ui-skin] .lvl-add-btn:hover {
  background: var(--ui-accent);
  border: none;
  color: var(--ui-on-accent);
  filter: brightness(1.05);
  opacity: 0.92;
}
}
[data-ui-skin] .lvl-add-wrap {
  flex-shrink: 0;
  position: relative;
}
[data-ui-skin] .lvl-add-menu,
[data-ui-skin] .lvl-filter-menu,
[data-ui-skin] .lvl-algo-submenu,
[data-ui-skin] .algo-draw-picker,
[data-ui-skin] .gm-module-menu {
  background: var(--ui-panel);
  border: 1px solid var(--ui-border-hi);
  border-top: 3px solid var(--ui-accent);
  border-radius: 0 var(--radius-md) var(--radius-md) var(--radius-md);
  box-shadow: var(--shadow-lg);
}
[data-ui-skin] .lvl-add-item {
  font-family: var(--font-ui);
  font-size: var(--font-size-sm);
  font-weight: 500;
  padding: 0 14px;
  min-height: var(--row-height);
  color: var(--ui-text);
  display: flex;
  align-items: center;
  transition: background 0.07s, color 0.07s;
}
[data-ui-skin] .lvl-add-item:hover {
  background: var(--ui-accent-2);
  color: var(--ui-accent);
}
[data-ui-skin] .algo-pick-item,
[data-ui-skin] .lvl-algo-sub-item {
  font-family: var(--font-ui);
  font-size: var(--font-size-sm);
  font-weight: 500;
  color: var(--ui-text);
}
[data-ui-skin] .algo-pick-item:hover,
[data-ui-skin] .lvl-algo-sub-item:hover {
  background: var(--ui-accent-2);
  color: var(--ui-accent);
  border-color: var(--ui-accent);
}
[data-ui-skin] .lvl-algo-sub-item.gm-item-active {
  background: var(--ui-accent-2);
  color: var(--ui-accent);
}
[data-ui-skin] .lvl-status-bar {
  font-size: var(--font-size-xs);
  color: var(--ui-muted);
  letter-spacing: 0.04em;
}

/* ─── Pens panel ─────────────────────────────────────────────────────── */
[data-ui-skin] .palette-toggle {
  background: var(--ui-ctrl);
  border: 1px solid var(--ui-border);
  border-radius: var(--radius-sm);
  height: var(--row-height);
  padding: 0 var(--spacing-sm);
  color: var(--ui-text-2);
  font-family: var(--font-ui);
  font-size: var(--font-size-xs);
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
  transition: border-color 0.1s;
}
[data-ui-skin] .palette-toggle:hover {
  border-color: var(--ui-border-hi);
}
[data-ui-skin] .palette-menu {
  background: var(--ui-panel);
  border: 1px solid var(--ui-border-hi);
  border-radius: var(--radius-md);
  padding: var(--spacing-sm);
  box-shadow: var(--shadow-lg);
}
[data-ui-skin] .palette-search {
  background: var(--ui-ctrl);
  border: 1px solid var(--ui-border);
  border-radius: var(--radius-sm);
  padding: 0 var(--spacing-sm);
  height: var(--row-height);
  color: var(--ui-text);
  font-family: var(--font-ui);
  font-size: var(--font-size-sm);
}
[data-ui-skin] .palette-search:focus {
  border-color: var(--ui-accent);
  box-shadow: 0 0 0 3px var(--ui-accent-2);
  outline: none;
}
[data-ui-skin] #btn-add-pen {
  background: var(--ui-accent);
  border: none;
  color: var(--ui-on-accent);
  font-family: var(--font-ui);
  font-weight: 600;
  font-size: var(--font-size-xs);
  padding: 0 var(--spacing-sm);
  height: 24px;
  border-radius: var(--radius-sm);
  letter-spacing: 0;
  text-transform: none;
  transition: opacity 0.1s;
}
@media (hover: hover) {
  [data-ui-skin] #btn-add-pen:hover {
  background: var(--ui-accent);
  color: var(--ui-on-accent);
  opacity: 0.88;
}
}

/* ─── Bottom pane (formula display + stats) ──────────────────────────── */
[data-ui-skin] #bottom-pane,
[data-ui-skin] .bottom-pane {
  background: var(--ui-panel);
  border-top: 1px solid var(--ui-border);
}
[data-ui-skin] .bottom-pane-header {
  height: 30px;
  padding: 0 var(--spacing-md);
  border-bottom: 1px solid var(--ui-border);
  background: var(--ui-panel-alt);
  display: flex;
  align-items: center;
}
[data-ui-skin] .bottom-pane-header > span {
  font-family: var(--font-mono);
  font-size: var(--font-size-xs);
  letter-spacing: 0.08em;
  color: var(--ui-muted);
}
[data-ui-skin] .bottom-pane-body {
  padding: var(--spacing-sm) var(--spacing-md);
}
[data-ui-skin] #formula-display,
[data-ui-skin] .formula-text {
  background: var(--ui-panel-alt);
  border: 1px solid var(--ui-border);
  border-radius: var(--radius-sm);
  padding: 6px var(--spacing-sm);
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ui-formula);
}
[data-ui-skin] #formula-seed-display {
  font-family: var(--font-mono);
  font-size: var(--font-size-xs);
  color: var(--ui-accent);
}
[data-ui-skin] #stat-dist,
[data-ui-skin] #stat-lines,
[data-ui-skin] #stat-time {
  color: var(--ui-accent);
  font-variant-numeric: tabular-nums;
}

/* ─── Theme toggle button — round, panel bg ──────────────────────────── */
[data-ui-skin] .theme-toggle {
  height: 26px;
  width: 26px;
  background: var(--ui-ctrl);
  border: 1px solid var(--ui-border);
  border-radius: 9999px;
  color: var(--ui-text-2);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.1s, border-color 0.1s, color 0.1s;
}
[data-ui-skin] .theme-toggle:hover {
  background: var(--ui-ctrl-hov);
  border-color: var(--ui-border-hi);
  color: var(--ui-accent);
}

/* ─── Noise Rack & Parameter Controls ────────────────────────────────────
 * Overrides legacy CSS rules that use hard-coded colors (#ef4444 red,
 * --color-* variables) for noise cards, angle dials, and control rows.
 * All selectors are scoped to [data-ui-skin] for skin-only activation.
 * ────────────────────────────────────────────────────────────────────── */

/* ── Div-based angle dial (noise-rack-panel, algo-config-panel) ──────── */
/* Different from SVG angle-ctrl; uses .angle-control > .angle-dial > .angle-indicator */
[data-ui-skin] .angle-control {
  display: flex; align-items: center; gap: var(--spacing-sm);
}
[data-ui-skin] .angle-control .angle-dial {
  position: relative;
  width: 56px; height: 56px;
  border-radius: 50%;
  border: 1.5px solid var(--ui-border);
  background: var(--ui-ctrl);
  cursor: pointer; flex-shrink: 0;
  transition: border-color 0.12s;
}
[data-ui-skin] .angle-control .angle-dial:hover { border-color: var(--ui-border-hi); }
[data-ui-skin] .angle-control .angle-indicator {
  position: absolute; left: 50%; top: 50%;
  transform: rotate(var(--angle, 0deg));
  transform-origin: center center;
}
/* Needle — was hardcoded red in legacy CSS */
[data-ui-skin] .angle-control .angle-indicator::before {
  content: ''; position: absolute;
  width: 2px; height: 20px;
  background: var(--ui-accent);
  border-radius: 999px;
  transform: translate(-1px, -20px);
}
/* Handle dot — was hardcoded red in legacy CSS */
[data-ui-skin] .angle-control .angle-indicator::after {
  content: ''; position: absolute;
  width: 6px; height: 6px;
  background: var(--ui-accent);
  border-radius: 50%;
  transform: translate(-3px, -28px);
}

/* ── Light Position pad (XY trackpad) ────────────────────────────────── */
[data-ui-skin] .light-pad {
  position: relative;
  width: 84px; height: 84px;
  border: 1.5px solid var(--ui-border);
  border-radius: var(--radius-sm, 4px);
  background: var(--ui-ctrl);
  cursor: crosshair;
  flex-shrink: 0;
  transition: border-color 0.12s;
  touch-action: none;
}
[data-ui-skin] .light-pad:hover { border-color: var(--ui-border-hi); }
/* The circular guide marks the unit disk (corners clamp to grazing light). */
[data-ui-skin] .light-pad .light-pad-disk {
  position: absolute; inset: 6px;
  border: 1px dashed var(--ui-border);
  border-radius: 50%;
  pointer-events: none;
}
/* Centre cross-hair. */
[data-ui-skin] .light-pad::before,
[data-ui-skin] .light-pad::after {
  content: ''; position: absolute;
  background: var(--ui-border);
  pointer-events: none;
}
[data-ui-skin] .light-pad::before { left: 50%; top: 12%; bottom: 12%; width: 1px; transform: translateX(-0.5px); }
[data-ui-skin] .light-pad::after { top: 50%; left: 12%; right: 12%; height: 1px; transform: translateY(-0.5px); }
[data-ui-skin] .light-pad .light-pad-handle {
  position: absolute;
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--ui-accent);
  box-shadow: 0 0 0 2px var(--ui-ctrl);
  transform: translate(-50%, -50%);
  pointer-events: none;
}

/* ── Noise list container & header ───────────────────────────────────── */
[data-ui-skin] .noise-list {
  display: flex; flex-direction: column; gap: var(--spacing-sm);
  border: none; border-radius: 0; padding: 0; background: none;
}
[data-ui-skin] .noise-list-header {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--spacing-sm); margin-bottom: var(--spacing-xs);
}
[data-ui-skin] .noise-list-header > span {
  font-size: var(--font-size-xs); text-transform: uppercase;
  letter-spacing: 0.12em; color: var(--ui-muted);
  font-family: var(--font-mono); font-weight: 500;
}
[data-ui-skin] .noise-add {
  height: 26px; padding: 0 var(--spacing-sm);
  background: none; border: 1px solid var(--ui-border);
  border-radius: var(--radius-sm);
  color: var(--ui-accent); font-family: var(--font-ui);
  font-size: var(--font-size-xs); font-weight: 500;
  cursor: pointer; white-space: nowrap;
  transition: background 0.1s, border-color 0.1s;
}
[data-ui-skin] .noise-add:hover { background: var(--ui-ctrl); border-color: var(--ui-accent); }

/* ── Noise card ──────────────────────────────────────────────────────── */
[data-ui-skin] .noise-card {
  border: 1px solid var(--ui-border); border-radius: var(--radius-md);
  padding: var(--spacing-sm); background: var(--ui-ctrl);
  container-type: inline-size;
  container-name: noise-card;
}
[data-ui-skin] .noise-header {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--spacing-sm); margin-bottom: var(--spacing-sm);
}
[data-ui-skin] .noise-title {
  font-size: var(--font-size-xs); letter-spacing: 0.10em;
  text-transform: uppercase; color: var(--ui-text-2);
  font-family: var(--font-mono); font-weight: 500;
}
[data-ui-skin] .noise-actions { display: flex; align-items: center; gap: var(--spacing-xs); }
[data-ui-skin] .noise-grip {
  display: grid; grid-template-columns: repeat(2, 4px);
  grid-template-rows: repeat(3, 4px); gap: 2px; padding: 2px;
  cursor: grab; flex-shrink: 0;
}
[data-ui-skin] .noise-grip .dot { width: 3px; height: 3px; border-radius: 50%; background: var(--ui-muted); }
[data-ui-skin] .noise-grip:active { cursor: grabbing; }
[data-ui-skin] .noise-card.dragging { opacity: 0.6; transform: translateY(-2px); }
[data-ui-skin] .noise-drop-indicator { height: 2px; border-radius: 999px; background: var(--ui-accent); margin: 4px 0; }
[data-ui-skin] .noise-disabled { opacity: 0.5; }

/* ── Noise toggle — pill switch (CSS-only, no JS needed) ─────────────── */
/* The noise-rack uses <label class="noise-toggle"><input type="checkbox">.
 * ::after = pill track, ::before = thumb. pointer-events:none on both so
 * clicks pass through to the label → checkbox, preserving native toggle. */
[data-ui-skin] .noise-toggle {
  position: relative; display: inline-flex;
  width: 30px; height: 16px; flex-shrink: 0; cursor: pointer;
  align-items: center; gap: 0;
}
[data-ui-skin] .noise-toggle input {
  opacity: 0; width: 0; height: 0; position: absolute;
  accent-color: initial; /* reset the legacy #ef4444 accent */
}
/* Track */
[data-ui-skin] .noise-toggle::after {
  content: ''; position: absolute; inset: 0;
  background: var(--ui-border); border-radius: 9999px;
  transition: background 0.15s; pointer-events: none;
}
[data-ui-skin] .noise-toggle:has(input:checked)::after { background: var(--ui-accent); }
/* Thumb */
[data-ui-skin] .noise-toggle::before {
  content: ''; position: absolute; top: 2px; left: 2px;
  width: 12px; height: 12px;
  background: #fff; border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
  transition: transform 0.15s cubic-bezier(0.4, 0, 0.2, 1);
  pointer-events: none; z-index: 1;
}
[data-ui-skin] .noise-toggle:has(input:checked)::before { transform: translateX(14px); }

/* ── Opt-toggle — pill + label row ──────────────────────────────────── */
[data-ui-skin] .opt-toggle {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 10px; color: var(--ui-muted); cursor: pointer;
}

/* ── Noise delete button ─────────────────────────────────────────────── */
/* Legacy color: #ef4444 (red text). Override to muted with danger on hover. */
[data-ui-skin] .noise-delete {
  border: 1px solid var(--ui-border); border-radius: var(--radius-sm);
  padding: 1px 5px; font-size: 11px;
  color: var(--ui-muted); background: transparent; cursor: pointer;
  transition: background 0.1s, color 0.1s, border-color 0.1s;
}
[data-ui-skin] .noise-delete:hover { background: var(--ui-danger); color: var(--ui-on-danger); border-color: var(--ui-danger); }

/* ── Noise reset / randomize buttons ─────────────────────────────────── */
[data-ui-skin] .noise-reset,
[data-ui-skin] .noise-rand {
  height: 22px; padding: 0 var(--spacing-sm);
  background: none; border: 1px solid var(--ui-border); border-radius: var(--radius-sm);
  color: var(--ui-muted); font-family: var(--font-ui);
  font-size: var(--font-size-xs); font-weight: 500;
  cursor: pointer; white-space: nowrap;
  transition: background 0.1s, border-color 0.1s, color 0.1s;
}
[data-ui-skin] .noise-reset:hover:not(:disabled),
[data-ui-skin] .noise-rand:hover:not(:disabled) { background: var(--ui-ctrl); border-color: var(--ui-border-hi); color: var(--ui-text); }
[data-ui-skin] .noise-reset:disabled,
[data-ui-skin] .noise-rand:disabled { opacity: 0.35; cursor: not-allowed; }

/* ── Randomize Params magic button ───────────────────────────────────── */
[data-ui-skin] #btn-randomize-params {
  border-color: rgba(217, 70, 239, 1);
  color: #c4a8e0;
  background: transparent;
  position: relative;
  overflow: visible;
  transition: box-shadow 0.25s, color 0.25s, background 0.15s;
  box-shadow: none;
}
[data-ui-skin] #btn-randomize-params::before {
  content: '✦';
  margin-right: 5px;
  font-size: 10px;
  display: inline;
}
[data-ui-skin] #btn-randomize-params:hover {
  border-color: rgba(217, 70, 239, 1);
  animation: rand-glow-pulse 2s ease-in-out infinite;
  color: #d8b4fe;
  background: rgba(217, 70, 239, 0.05) !important;
}
[data-ui-skin] #btn-randomize-params:active { transform: scale(0.97); }
[data-ui-skin] #btn-randomize-params:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  box-shadow: none;
  border-color: var(--ui-border);
  color: var(--ui-muted);
}

/* Spark overlay particles — fixed-position spans appended to <body> on click. */
.rand-spark-overlay {
  position: fixed;
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--spark-color, rgba(217, 70, 239, 0.9));
  pointer-events: none;
  z-index: 9999;
  animation: rand-spark-fly 0.5s ease-out forwards;
}

/* ── Noise control rows (individual parameter rows inside a card) ─────── */
[data-ui-skin] .noise-control { display: flex; flex-direction: column; gap: var(--spacing-xs); }

/* Range inputs inside noise-control use class="w-full" (not ctrl-slider).
 * Apply full Meridian slider treatment via the type selector. */
[data-ui-skin] .noise-control input[type="range"] {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 4px; border-radius: 2px;
  cursor: pointer; outline: none;
  background: linear-gradient(to right,
    var(--slider-start) 0%,
    var(--ui-accent)    var(--fill, 0%),
    var(--ui-border)    var(--fill, 0%) 100%
  );
}
[data-ui-skin] .noise-control input[type="range"]::-webkit-slider-runnable-track { background: transparent; height: 4px; }
[data-ui-skin] .noise-control input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--ui-accent); border: 2.5px solid var(--ui-panel);
  box-shadow: 0 0 0 1.5px var(--ui-accent); cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.15s ease;
}
[data-ui-skin] .noise-control input[type="range"]:hover::-webkit-slider-thumb {
  transform: scale(1.18); box-shadow: 0 0 0 4px var(--ui-accent-2);
}
[data-ui-skin] .noise-control input[type="range"]:active::-webkit-slider-thumb {
  transform: scale(1.02); box-shadow: 0 0 0 2px var(--ui-accent-2);
}
[data-ui-skin] .noise-control input[type="range"]::-moz-range-thumb {
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--ui-accent); border: 2.5px solid var(--ui-panel);
  box-shadow: 0 0 0 1.5px var(--ui-accent); cursor: pointer;
}
[data-ui-skin] .noise-control input[type="range"]::-moz-range-track { height: 4px; border-radius: 2px; background: var(--ui-border); }
[data-ui-skin] .noise-control input[type="range"]::-moz-range-progress {
  height: 4px; border-radius: 2px 0 0 2px;
  background: linear-gradient(to right, var(--slider-start), var(--ui-accent));
}

/* Select inside noise-control — appearance reset + pseudo-element chevron.
 * :has(select) scopes the chevron only to controls that contain a select,
 * so angle-dial controls (no <select> inside) are not affected. */
[data-ui-skin] .noise-control select { -webkit-appearance: none; -moz-appearance: none; appearance: none; padding-right: 28px; }
[data-ui-skin] .noise-control:has(select) { position: relative; }
[data-ui-skin] .noise-control:has(select)::after {
  content: ''; position: absolute; right: 10px; bottom: 12px;
  width: 6px; height: 6px;
  border-right: 2px solid var(--ui-muted); border-bottom: 2px solid var(--ui-muted);
  border-radius: 1px; transform: rotate(45deg); pointer-events: none;
  transition: border-color 0.12s;
}
[data-ui-skin] .noise-control:has(select):hover::after { border-color: var(--ui-accent); }

/* ─── Welcome panel typography ───────────────────────────────────────── */
[data-ui-skin] #left-welcome-intro p,
[data-ui-skin] #left-welcome-intro li,
[data-ui-skin] #left-welcome-select p {
  font-family: var(--font-ui);
}
[data-ui-skin] #left-welcome-intro p:first-child {
  /* "Welcome" eyebrow — keep mono for the all-caps label */
  font-family: var(--font-mono);
  letter-spacing: 0.1em;
}

/* ─── Welcome pane "Take the tour" CTA ───────────────────────────────── */
[data-ui-skin] .welcome-tour-cta {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--ui-border);
}

[data-ui-skin] .welcome-tour-btn-wrap {
  display: inline-block;
  background: linear-gradient(90deg, var(--ui-accent) 0%, #22d3ee 100%);
  border-radius: 999px;
  padding: 1px;
  cursor: pointer;
  transition: box-shadow 0.35s ease;
}

[data-ui-skin] .welcome-tour-btn-wrap:hover {
  box-shadow: 0 0 0 3px rgba(78, 158, 225, 0.16), 0 0 20px rgba(78, 158, 225, 0.32);
}

[data-ui-skin] .welcome-tour-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--ui-panel);
  border-radius: 999px;
  padding: 5px 15px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ui-text-2);
  border: none;
  cursor: pointer;
  white-space: nowrap;
  letter-spacing: 0.02em;
  transition: background 0.38s ease, color 0.28s ease;
}

[data-ui-skin] .welcome-tour-btn-wrap:hover .welcome-tour-btn {
  background: transparent;
  color: #fff;
}

/* ── VECTURA MODAL (modern overlay primitive) ─────────────────── */
.vectura-modal {
  background: var(--ui-panel);
  border: 1px solid var(--ui-border-hi);
  border-radius: var(--radius-lg, 8px);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.5);
  width: min(420px, calc(100vw - 32px));
  max-height: calc(100vh - 64px); max-height: calc(var(--app-vh) - 64px);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.vectura-modal-hdr {
  padding: 14px 18px 10px;
  border-bottom: 1px solid var(--ui-border);
  flex-shrink: 0;
}
.vectura-modal-hdr h2 {
  margin: 0;
  font-family: var(--font-ui);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--ui-accent);
}
.vectura-modal-body {
  padding: 16px 18px;
  overflow-y: auto;
  flex: 1;
}

/* ── VECTURA DIALOG (confirm/cancel wrapper) ──────────────────── */
.vectura-dialog-msg {
  margin: 0 0 16px;
  font-family: var(--font-ui);
  font-size: var(--font-size-xs);
  color: var(--ui-text-2);
  line-height: 1.5;
}
.vectura-dialog-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding-top: 4px;
}

/* ============================================================
 * Mirror panel (v2). Self-scoped under .mp-root.
 * All hues are tokenized + tinted off --mp-type-color which
 * the JS sets to the active mirror type hue (line/radial/arc/wall).
 * ============================================================ */
.mp-root {
  --mp-type-color: var(--ui-accent);
  --mirror-line-hue: #4e9ee1;
  --mirror-radial-hue: #c084fc;
  --mirror-arc-hue: #f0a85f;
  --mirror-wall-hue: #5cd99a;
  display: flex; flex-direction: column;
  gap: 10px;
}

/* ── Stack section ── */
.mp-root .mp-stack { display: flex; flex-direction: column; }
.mp-root .mp-stack-hdr {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 0 8px;
}
.mp-root .mp-stack-lbl {
  font-size: var(--font-size-xs);
  color: var(--ui-text-2);
  font-weight: 700; letter-spacing: 0.08em;
  text-transform: uppercase;
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--font-ui);
}
.mp-root .mp-stack-count {
  font-family: var(--font-mono); color: var(--mp-type-color);
  font-weight: 700;
  padding: 1px 6px;
  background: color-mix(in srgb, var(--mp-type-color) 18%, transparent);
  border-radius: 9999px;
  font-size: 10px;
}
.mp-root .mp-stack-list {
  display: flex; flex-direction: column;
  gap: 4px;
}

/* ── Stack row ── */
.mp-root .mp-row {
  display: grid;
  grid-template-columns: 36px 1fr auto;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  background: var(--ui-panel-alt, var(--ui-ctrl));
  border: 1px solid var(--ui-border);
  border-left: 3px solid var(--mp-row-color, var(--ui-accent));
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
}
.mp-root .mp-row:hover { background: var(--ui-ctrl-hov, var(--ui-ctrl)); }
.mp-root .mp-row.is-selected {
  background: var(--ui-ctrl-hov, var(--ui-ctrl));
  box-shadow: 0 0 0 1px var(--mp-row-color, var(--ui-accent));
}
.mp-root .mp-row.is-disabled .mp-row-thumb,
.mp-root .mp-row.is-disabled .mp-row-meta { opacity: 0.45; }
.mp-root .mp-row-thumb {
  width: 36px; aspect-ratio: 1.4;
  background: var(--ui-bg);
  border: 1px solid var(--ui-border);
  border-radius: 3px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; padding: 0; cursor: pointer;
}
.mp-root .mp-row-thumb svg { width: 80%; height: 80%; }
.mp-root .mp-row-meta { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.mp-root .mp-row-name {
  font-size: 12px; font-weight: 600; color: var(--ui-text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  display: flex; align-items: center; gap: 6px;
}
.mp-root .mp-row-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--mp-row-color, var(--ui-accent));
  box-shadow: 0 0 4px var(--mp-row-color, var(--ui-accent));
  flex-shrink: 0;
}
.mp-root .mp-row-summary {
  font-size: 9.5px; color: var(--ui-muted);
  font-family: var(--font-mono); letter-spacing: 0.04em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  text-transform: uppercase;
}
.mp-root .mp-row-actions { display: flex; gap: 1px; }
.mp-root .mp-icon-btn {
  width: 22px; height: 22px;
  background: none; border: none; padding: 0;
  color: var(--ui-muted); cursor: pointer;
  border-radius: var(--radius-sm);
  display: inline-flex; align-items: center; justify-content: center;
  transition: background 0.1s, color 0.1s;
}
.mp-root .mp-icon-btn:hover { background: var(--ui-ctrl-hov, var(--ui-ctrl)); color: var(--ui-text); }
.mp-root .mp-icon-btn.active { color: var(--ui-accent); }
.mp-root .mp-icon-btn.mp-icon-danger:hover { color: var(--ui-danger); }
.mp-root .mp-icon-btn svg {
  width: 14px; height: 14px;
  stroke: currentColor; fill: none;
  stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round;
}

/* ── Add-mirror button ── */
.mp-root .mp-stack-add {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px;
  background: transparent;
  border: 1px dashed var(--ui-border);
  border-radius: var(--radius-sm);
  color: var(--ui-text-2);
  font-family: var(--font-ui);
  font-size: var(--font-size-sm); font-weight: 600;
  cursor: pointer;
  transition: background-color 0.12s, color 0.12s, border-color 0.12s;
  letter-spacing: 0.02em;
  margin-top: 2px;
}
.mp-root .mp-stack-add:hover {
  border-color: var(--mp-type-color); color: var(--mp-type-color);
  background: color-mix(in srgb, var(--mp-type-color) 12%, transparent);
}
.mp-root .mp-stack-add.is-active {
  border-style: solid;
  border-color: var(--mp-type-color);
  color: var(--mp-type-color);
  background: color-mix(in srgb, var(--mp-type-color) 12%, transparent);
}
.mp-root .mp-stack-add svg {
  width: 12px; height: 12px;
  stroke: currentColor; fill: none;
  stroke-width: 2; stroke-linecap: round;
}

/* ── Editor ── */
.mp-root .mp-editor {
  background: var(--ui-panel-alt, var(--ui-ctrl));
  border: 1px solid var(--ui-border);
  border-radius: var(--radius-md);
  display: flex; flex-direction: column;
  overflow: hidden;
}
.mp-root .mp-editor-hdr {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--spacing-sm);
  padding: 8px var(--spacing-md);
  min-height: 52px;
  background: linear-gradient(90deg,
    color-mix(in srgb, var(--mp-type-color) 14%, transparent) 0%,
    color-mix(in srgb, var(--mp-type-color) 6%, transparent) 100%);
  border-bottom: 1px solid color-mix(in srgb, var(--mp-type-color) 35%, var(--ui-border));
  position: relative;
  transition: background 0.14s;
}
.mp-root .mp-editor-hdr.is-clickable { cursor: pointer; }
.mp-root .mp-editor-hdr.is-clickable:hover {
  background: linear-gradient(90deg,
    color-mix(in srgb, var(--mp-type-color) 22%, transparent) 0%,
    color-mix(in srgb, var(--mp-type-color) 12%, transparent) 100%);
}
.mp-root .mp-editor-hdr.is-picker {
  background: linear-gradient(90deg,
    color-mix(in srgb, var(--ui-accent) 22%, transparent) 0%,
    color-mix(in srgb, var(--ui-accent) 12%, transparent) 100%);
  border-bottom-color: var(--ui-accent);
}
.mp-root .mp-editor-hdr-left {
  display: flex; flex-direction: column; gap: 3px;
  min-width: 0;
}
.mp-root .mp-step-tag {
  font-family: var(--font-mono);
  font-size: 9px;
  color: color-mix(in srgb, var(--mp-type-color) 70%, var(--ui-text-2));
  letter-spacing: 0.14em;
  font-weight: 700;
  text-transform: uppercase;
}
.mp-root .mp-editor-hdr.is-picker .mp-step-tag { color: var(--ui-accent); }
.mp-root .mp-type-chip {
  display: flex; align-items: center; gap: 8px;
  font-size: 14px; font-weight: 700;
  color: var(--mp-type-color);
  letter-spacing: -0.01em;
}
.mp-root .mp-editor-hdr.is-picker .mp-type-chip { color: var(--ui-accent); }
.mp-root .mp-chip-dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 8px currentColor;
}
.mp-root .mp-change-cta {
  display: inline-flex; align-items: center; gap: 6px;
  height: 30px; padding: 0 12px;
  border: 0;
  border-radius: 9999px;
  background: var(--mp-type-color);
  color: #141417;
  font-family: var(--font-ui);
  font-size: 11.5px; font-weight: 700;
  letter-spacing: 0.02em;
  cursor: pointer;
  box-shadow:
    0 0 0 1px color-mix(in srgb, var(--mp-type-color) 50%, transparent),
    0 4px 14px color-mix(in srgb, var(--mp-type-color) 30%, transparent);
  transition: transform 0.12s, box-shadow 0.12s, background 0.12s;
  flex-shrink: 0;
}
.mp-root .mp-change-cta:hover {
  transform: translateY(-1px);
  background: color-mix(in srgb, white 12%, var(--mp-type-color));
}
.mp-root .mp-change-cta:active { transform: translateY(0); }
.mp-root .mp-change-cta svg {
  width: 14px; height: 14px;
  stroke: currentColor; fill: none;
  stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round;
}
.mp-root .mp-change-cta.is-cancel {
  background: var(--ui-danger); color: var(--ui-on-danger);
  box-shadow:
    0 0 0 1px color-mix(in srgb, var(--ui-danger) 50%, transparent),
    0 4px 14px color-mix(in srgb, var(--ui-danger) 30%, transparent);
}
.mp-root .mp-editor-body {
  padding: var(--spacing-md, 12px);
  display: flex; flex-direction: column;
  gap: var(--spacing-md, 12px);
  position: relative;
}
.mp-root .mp-editor-body.is-locked {
  opacity: 0.45;
  pointer-events: none;
  user-select: none;
}
.mp-root .mp-editor-hdr.is-locked .mp-change-cta {
  opacity: 0.45;
  pointer-events: none;
}

/* ── 4-up type picker ── */
.mp-root .mp-picker-wrap { display: flex; flex-direction: column; gap: var(--spacing-md, 12px); }
.mp-root .mp-picker-prompt {
  color: var(--ui-text-2);
  font-size: var(--font-size-sm);
  line-height: 1.45;
}
.mp-root .mp-picker-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
}
.mp-root .mp-type-card {
  position: relative; text-align: left;
  background: var(--ui-panel-alt, var(--ui-ctrl));
  border: 1px solid var(--ui-border);
  border-radius: var(--radius-md);
  padding: 10px 8px 8px;
  cursor: pointer;
  transition: background-color 0.14s, color 0.14s, border-color 0.14s, transform 0.14s;
  overflow: hidden;
  color: inherit;
}
.mp-root .mp-type-card:hover {
  transform: translateY(-1px);
  border-color: var(--mp-card-color, var(--ui-accent));
}
.mp-root .mp-type-card.is-current {
  background: linear-gradient(180deg,
    color-mix(in srgb, var(--mp-card-color, var(--ui-accent)) 14%, transparent) 0%,
    transparent 80%);
  box-shadow: 0 0 0 1px var(--mp-card-color, var(--ui-accent)) inset;
}
.mp-root .mp-type-preview {
  width: 100%; aspect-ratio: 1.6;
  background: var(--ui-bg);
  border: 1px solid var(--ui-border);
  border-radius: var(--radius-sm);
  margin-bottom: 6px;
  display: flex; align-items: center; justify-content: center;
}
.mp-root .mp-type-preview svg { width: 80%; height: 80%; }
.mp-root .mp-type-name {
  font-size: 12px; font-weight: 700;
  color: var(--ui-text);
  display: flex; align-items: center; gap: 6px;
}
.mp-root .mp-type-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--mp-card-color, var(--ui-accent));
  box-shadow: 0 0 6px var(--mp-card-color, var(--ui-accent));
}
.mp-root .mp-type-tag {
  font-size: var(--font-size-xs);
  color: var(--ui-muted);
  margin-top: 2px;
  line-height: 1.35;
}
.mp-root .mp-current-marker {
  position: absolute; top: 6px; right: 6px;
  font-family: var(--font-mono);
  font-size: 8px;
  letter-spacing: 0.08em;
  padding: 2px 6px;
  background: var(--mp-card-color, var(--ui-accent));
  color: #1a1a1a;
  font-weight: 700;
  border-radius: 9999px;
  display: none;
}
.mp-root .mp-type-card.is-current .mp-current-marker { display: inline-flex; }

/* ── Common control bits ── */
.mp-root .mp-ctrl-grp { display: flex; flex-direction: column; gap: 4px; }
.mp-root .mp-ctrl-lbl {
  font-size: var(--font-size-sm); font-weight: 500;
  color: var(--ui-text-2);
  display: flex; align-items: center; gap: 6px;
}
.mp-root .mp-val-tag {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: var(--font-size-xs);
  color: var(--mp-type-color);
  font-variant-numeric: tabular-nums;
}
.mp-root .mp-ctrl-row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

/* Locked control (e.g. tile-height/angle on square/hex wallpaper groups) */
.mp-root .mp-ctrl-grp.is-locked { opacity: 0.45; }
.mp-root .mp-ctrl-grp.is-locked .mp-slider { cursor: not-allowed; pointer-events: none; }
.mp-root .mp-lock-hint {
  margin-left: 6px;
  font-size: var(--font-size-xs);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ui-text-3, var(--ui-text-2));
  font-weight: 500;
}

/* sliders */
.mp-root .mp-slider {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 4px; border-radius: 2px;
  cursor: pointer; outline: none;
  background: linear-gradient(to right,
    var(--mp-type-color) 0%,
    var(--mp-type-color) var(--fill, 50%),
    var(--ui-border) var(--fill, 50%) 100%);
}
.mp-root .mp-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--mp-type-color);
  border: 2.5px solid var(--ui-panel, var(--ui-bg));
  box-shadow: 0 0 0 1.5px var(--mp-type-color);
  cursor: pointer;
}
.mp-root .mp-slider::-moz-range-thumb {
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--mp-type-color);
  border: 2.5px solid var(--ui-panel, var(--ui-bg));
  box-shadow: 0 0 0 1.5px var(--mp-type-color);
  cursor: pointer;
}

/* mode tile 3-up */
.mp-root .mp-mode-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.mp-root .mp-mode-tile {
  background: var(--ui-ctrl);
  border: 1px solid var(--ui-border);
  border-radius: var(--radius-sm);
  padding: 6px 4px 4px;
  cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  transition: background-color 0.12s, color 0.12s, border-color 0.12s;
  color: var(--ui-text-2);
}
.mp-root .mp-mode-tile:hover { border-color: var(--ui-border-hi, var(--ui-border)); }
.mp-root .mp-mode-tile.active {
  border-color: var(--mp-type-color);
  background: color-mix(in srgb, var(--mp-type-color) 14%, var(--ui-ctrl));
  color: var(--mp-type-color);
}
.mp-root .mp-mode-tile svg {
  width: 32px; height: 32px;
  stroke-width: 1.4; fill: none;
}
.mp-root .mp-mode-tile .mp-mt-name {
  font-size: var(--font-size-xs); font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.04em;
}

/* angle dial */
.mp-root .mp-dial-row {
  display: grid; grid-template-columns: 56px 1fr; gap: 10px;
  align-items: center;
}
.mp-root .mp-dial {
  position: relative;
  width: 50px; height: 50px;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 50%, var(--ui-panel, var(--ui-ctrl)) 0%, var(--ui-bg) 75%);
  border: 1px solid var(--ui-border);
  display: flex; align-items: center; justify-content: center;
  cursor: grab;
  touch-action: none;
  user-select: none;
}
.mp-root .mp-dial.is-dragging { cursor: grabbing; }
.mp-root .mp-dial-row.is-locked .mp-dial {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
}
.mp-root .mp-dial::after {
  content: ''; position: absolute; inset: 5px;
  border-radius: 50%;
  border: 1px dashed var(--ui-border-hi, var(--ui-border));
  pointer-events: none;
}
.mp-root .mp-dial-pin {
  position: absolute;
  width: 2px; height: 20px;
  background: var(--mp-type-color);
  top: 50%; left: 50%;
  transform-origin: 50% 100%;
  transform: translate(-50%, -100%) rotate(var(--angle, 0deg));
  border-radius: 2px;
  box-shadow: 0 0 6px var(--mp-type-color);
  pointer-events: none;
}
.mp-root .mp-dial-knob {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--ui-text);
  z-index: 2; pointer-events: none;
}
.mp-root .mp-dial-tick {
  position: absolute;
  width: 1px; height: 4px;
  background: var(--ui-border-hi, var(--ui-border));
  top: 50%; left: 50%;
  transform-origin: 50% 50%;
  transform: translate(-50%, -50%) rotate(0deg) translateY(-21px);
  pointer-events: none;
}
.mp-root .mp-dial-tick.mp-tick-90  { transform: translate(-50%, -50%) rotate(90deg)  translateY(-21px); }
.mp-root .mp-dial-tick.mp-tick-180 { transform: translate(-50%, -50%) rotate(180deg) translateY(-21px); }
.mp-root .mp-dial-tick.mp-tick-270 { transform: translate(-50%, -50%) rotate(270deg) translateY(-21px); }

/* side tiles (binary pair) */
.mp-root .mp-side-row { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.mp-root .mp-side-tile {
  background: var(--ui-ctrl);
  border: 1px solid var(--ui-border);
  border-radius: var(--radius-sm);
  padding: 6px;
  cursor: pointer;
  display: grid; grid-template-columns: 28px 1fr; gap: 8px;
  align-items: center;
  transition: background-color 0.12s, color 0.12s, border-color 0.12s;
  color: var(--ui-text-2);
}
.mp-root .mp-side-tile:hover { border-color: var(--ui-border-hi, var(--ui-border)); }
.mp-root .mp-side-tile.active {
  border-color: var(--mp-type-color);
  background: color-mix(in srgb, var(--mp-type-color) 14%, var(--ui-ctrl));
  color: var(--mp-type-color);
}
.mp-root .mp-side-tile svg { width: 24px; height: 24px; stroke-width: 1.4; fill: none; }
.mp-root .mp-side-tile .mp-st-name {
  font-size: 11px; font-weight: 600;
}
.mp-root .mp-side-tile--text { grid-template-columns: 1fr; padding: 8px 6px; }
.mp-root .mp-side-tile--text .mp-st-name { text-align: center; }

/* wallpaper atlas */
.mp-root .mp-atlas-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 0 4px;
  margin-top: 4px;
  border-top: 1px solid var(--ui-border);
}
.mp-root .mp-atlas-head:first-of-type { border-top: 0; padding-top: 0; margin-top: 0; }
.mp-root .mp-ash-title {
  font-size: var(--font-size-xs); font-weight: 700;
  color: var(--ui-text-2);
  letter-spacing: 0.08em; text-transform: uppercase;
  display: inline-flex; align-items: center; gap: 6px;
}
.mp-root .mp-ash-count {
  font-family: var(--font-mono); font-size: var(--font-size-xs);
  color: var(--ui-muted);
}
.mp-root .mp-atlas-head.is-active-family .mp-ash-title,
.mp-root .mp-atlas-head.is-active-family .mp-ash-count { color: var(--mirror-wall-hue); }
.mp-root .mp-atlas-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px;
}
.mp-root .mp-atlas-cell {
  aspect-ratio: 1;
  background: var(--ui-bg);
  border: 1px solid var(--ui-border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  position: relative;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
  transition: background-color 0.12s, color 0.12s, border-color 0.12s, box-shadow 0.12s, transform 0.12s;
  color: var(--ui-text-2);
  padding: 0;
}
.mp-root .mp-atlas-cell:hover {
  border-color: var(--ui-border-hi, var(--ui-border));
  transform: scale(1.04);
  z-index: 1;
}
.mp-root .mp-atlas-cell.active {
  border-color: var(--mirror-wall-hue);
  box-shadow: 0 0 0 1px var(--mirror-wall-hue) inset, 0 0 14px rgba(92, 217, 154, 0.18);
  color: var(--mirror-wall-hue);
}
.mp-root .mp-atlas-cell svg {
  width: 100%; height: 100%;
  stroke: currentColor; stroke-width: 1; fill: currentColor;
  fill-opacity: 0.85;
}
.mp-root .mp-atlas-cell .mp-ac-code {
  position: absolute; bottom: 1px; right: 3px;
  font-family: var(--font-mono); font-size: 8px;
  color: var(--ui-muted);
}
.mp-root .mp-atlas-cell.active .mp-ac-code { color: var(--mirror-wall-hue); }

/* wallpaper composable-symmetry chip rows (lattice / rotation / mirrors) */
.mp-root .mp-chip-row {
  display: flex; flex-wrap: wrap; gap: 4px;
}
.mp-root .mp-chip {
  font-size: 11px; font-weight: 600;
  background: var(--ui-ctrl);
  border: 1px solid var(--ui-border);
  border-radius: var(--radius-sm);
  color: var(--ui-text-2);
  padding: 4px 8px;
  cursor: pointer;
  transition: background-color 0.12s, color 0.12s, border-color 0.12s;
}
.mp-root .mp-chip:hover:not(:disabled) { border-color: var(--ui-border-hi, var(--ui-border)); }
.mp-root .mp-chip.is-active {
  border-color: var(--mp-type-color);
  background: color-mix(in srgb, var(--mp-type-color) 14%, var(--ui-ctrl));
  color: var(--mp-type-color);
}
.mp-root .mp-chip:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.mp-root .mp-wall-desc {
  font-size: var(--font-size-xs);
  color: var(--ui-muted);
  padding: 4px 0 0;
  line-height: 1.35;
}
.mp-root .mp-wall-badge {
  font-family: var(--font-mono);
  font-size: var(--font-size-xs);
  color: var(--mirror-wall-hue);
  text-align: right;
  padding-top: 2px;
}

/* ═══════════════════════════════════════════════════════════════════════════
   Morph modifier panel
   Mirrors the mirror panel's control vocabulary (chips, sliders, switches) but
   scoped to .morph-panel. Accent derives from the active theme's vectura accent.
   ═══════════════════════════════════════════════════════════════════════════ */
.morph-panel {
  --morph-accent: rgb(var(--vectura-accent-rgb, 78 158 225));
  display: flex; flex-direction: column; gap: 12px;
  padding: 2px 0;
}

/* live child-count header */
.morph-panel .morph-count {
  display: flex; flex-direction: column; gap: 4px;
  padding: 8px 10px;
  background: color-mix(in srgb, var(--morph-accent) 7%, var(--ui-ctrl));
  border: 1px solid color-mix(in srgb, var(--morph-accent) 22%, var(--ui-border));
  border-radius: var(--radius-sm);
}
.morph-panel .morph-count-text {
  font-size: var(--font-size-sm); font-weight: 600;
  color: var(--ui-text-2);
}
.morph-panel .morph-callout {
  font-size: var(--font-size-sm);
  color: var(--ui-muted);
  line-height: 1.4;
}
.morph-panel .morph-warn {
  font-size: var(--font-size-xs);
  color: #e6a23c;
  line-height: 1.35;
}

/* titled groups */
.morph-panel .morph-group {
  display: flex; flex-direction: column; gap: 10px;
  padding: 10px;
  background: var(--ui-ctrl);
  border: 1px solid var(--ui-border);
  border-radius: var(--radius-sm);
}
.morph-panel .morph-group-title {
  font-size: var(--font-size-xs); font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--morph-accent);
  padding-bottom: 2px;
  border-bottom: 1px solid color-mix(in srgb, var(--morph-accent) 18%, transparent);
}

/* per-control section */
.morph-panel .morph-section { display: flex; flex-direction: column; gap: 5px; }
.morph-panel .morph-label {
  font-size: var(--font-size-sm); font-weight: 500;
  color: var(--ui-text-2);
  display: flex; align-items: center; gap: 6px;
}
.morph-panel .morph-value {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: var(--font-size-xs);
  color: var(--morph-accent);
  font-variant-numeric: tabular-nums;
}
.morph-panel .morph-hint {
  font-size: var(--font-size-xs);
  color: var(--ui-muted);
  line-height: 1.35;
}

/* sliders */
.morph-panel .morph-slider {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 4px; border-radius: 2px;
  cursor: pointer; outline: none;
  background: var(--ui-border);
}
.morph-panel .morph-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--morph-accent);
  border: 2.5px solid var(--ui-panel, var(--ui-ctrl));
  box-shadow: 0 0 0 1.5px var(--morph-accent);
  cursor: pointer;
}
.morph-panel .morph-slider::-moz-range-thumb {
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--morph-accent);
  border: 2.5px solid var(--ui-panel, var(--ui-ctrl));
  box-shadow: 0 0 0 1.5px var(--morph-accent);
  cursor: pointer;
}

/* chip rows */
.morph-panel .morph-easing-chips,
.morph-panel .morph-sequence-chips,
.morph-panel .morph-correspondence-chips,
.morph-panel .morph-multipath-chips {
  display: flex; flex-wrap: wrap; gap: 4px;
}
.morph-panel .morph-chip {
  font-size: 11px; font-weight: 600;
  background: var(--ui-ctrl);
  border: 1px solid var(--ui-border);
  border-radius: var(--radius-sm);
  color: var(--ui-text-2);
  padding: 4px 8px;
  cursor: pointer;
  transition: background-color 0.12s, color 0.12s, border-color 0.12s;
}
.morph-panel .morph-chip:hover { border-color: var(--ui-border-hi, var(--ui-border)); }
.morph-panel .morph-chip.active {
  border-color: var(--morph-accent);
  background: color-mix(in srgb, var(--morph-accent) 14%, var(--ui-ctrl));
  color: var(--morph-accent);
}

/* dropdowns */
.morph-panel .morph-select {
  width: 100%;
  font-size: var(--font-size-sm);
  background: var(--ui-ctrl);
  border: 1px solid var(--ui-border);
  border-radius: var(--radius-sm);
  color: var(--ui-text-2);
  padding: 5px 8px;
  cursor: pointer;
  transition: border-color 0.12s;
}
.morph-panel .morph-select:hover { border-color: var(--ui-border-hi, var(--ui-border)); }
.morph-panel .morph-select:focus { outline: none; border-color: var(--morph-accent); }

/* switch-style toggles */
.morph-panel .morph-switch-row { gap: 4px; }
.morph-panel .morph-switch-head {
  display: flex; align-items: center; gap: 8px;
}
.morph-panel .morph-switch-head .morph-label { flex: 1; }
.morph-panel .morph-toggle {
  position: relative;
  width: 34px; height: 18px;
  flex-shrink: 0;
  border-radius: 9999px;
  border: 1px solid var(--ui-border);
  background: var(--ui-border);
  cursor: pointer;
  padding: 0;
  transition: background-color 0.16s, border-color 0.16s;
}
.morph-panel .morph-toggle .morph-toggle-knob {
  position: absolute;
  top: 50%; left: 2px;
  width: 12px; height: 12px;
  border-radius: 50%;
  background: var(--ui-panel, #fff);
  transform: translateY(-50%);
  transition: left 0.16s;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}
.morph-panel .morph-toggle.active {
  background: var(--morph-accent);
  border-color: var(--morph-accent);
}
.morph-panel .morph-toggle.active .morph-toggle-knob { left: 18px; }
.morph-panel .morph-toggle:focus-visible { outline: 2px solid var(--morph-accent); outline-offset: 2px; }

/* info trigger + popover */
.mp-root .mp-info-trigger {
  width: 14px; height: 14px;
  border: 1px solid color-mix(in srgb, var(--mp-type-color) 40%, var(--ui-border));
  border-radius: 50%;
  background: color-mix(in srgb, var(--mp-type-color) 14%, var(--ui-ctrl));
  color: var(--mp-type-color);
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer;
  padding: 0;
  transition: background-color 0.14s, color 0.14s, border-color 0.14s;
  flex-shrink: 0;
}
.mp-root .mp-info-trigger:hover {
  background: var(--mp-type-color);
  color: #141417;
  border-color: var(--mp-type-color);
}
.mp-root .mp-info-backdrop {
  position: absolute; inset: 0;
  background: rgba(8, 8, 10, 0.65);
  backdrop-filter: blur(2px);
  z-index: 40;
  display: none;
  cursor: pointer;
}
.mp-root .mp-info-backdrop.is-open { display: block; }
.mp-root .mp-info-popover {
  position: absolute;
  top: 12px; left: 12px; right: 12px;
  z-index: 50;
  background: var(--ui-panel, var(--ui-ctrl));
  border: 1px solid color-mix(in srgb, var(--mp-type-color) 35%, var(--ui-border));
  border-left: 3px solid var(--mp-type-color);
  border-radius: var(--radius-md);
  box-shadow: 0 12px 36px rgba(0,0,0,0.6);
  padding: 12px 14px 14px;
  font-size: var(--font-size-sm);
  color: var(--ui-text-2);
  line-height: 1.55;
  display: none;
  max-height: calc(100% - 24px);
  overflow-y: auto;
}
.mp-root .mp-info-popover.is-open { display: block; }
.mp-root .mp-ip-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--ui-border);
}
.mp-root .mp-ip-title-tag {
  display: block;
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.12em;
  color: var(--mp-type-color);
  font-weight: 700;
  text-transform: uppercase;
  margin-bottom: 3px;
}
.mp-root .mp-ip-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--ui-text);
}
.mp-root .mp-ip-close {
  width: 22px; height: 22px;
  background: var(--ui-ctrl);
  border: 1px solid var(--ui-border);
  border-radius: 50%;
  color: var(--ui-text-2);
  cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0;
  flex-shrink: 0;
  transition: background-color 0.12s, color 0.12s, border-color 0.12s;
}
.mp-root .mp-ip-close:hover {
  background: var(--ui-danger); border-color: var(--ui-danger); color: var(--ui-on-danger);
}
.mp-root .mp-ip-close svg {
  width: 10px; height: 10px;
  stroke: currentColor; fill: none;
  stroke-width: 2.4; stroke-linecap: round;
}
.mp-root .mp-ip-body p { margin: 0; }
.mp-root .mp-ip-body p + p { margin-top: 6px; }
.mp-root .mp-ip-body strong { color: var(--ui-text); font-weight: 600; }
.mp-root .mp-ip-body em { color: var(--ui-text-2); font-style: italic; }
.mp-root .mp-ip-body code {
  font-family: var(--font-mono); font-size: 10.5px;
  background: color-mix(in srgb, var(--mp-type-color) 14%, var(--ui-ctrl));
  border: 1px solid color-mix(in srgb, var(--mp-type-color) 35%, var(--ui-border));
  border-radius: 3px;
  padding: 0 4px;
  color: var(--mp-type-color);
  margin: 0 1px;
}
.mp-root .mp-ip-note {
  margin-top: 10px;
  padding: 6px 8px;
  background: color-mix(in srgb, var(--mp-type-color) 8%, var(--ui-panel-alt, var(--ui-ctrl)));
  border-left: 2px solid color-mix(in srgb, var(--mp-type-color) 60%, transparent);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: var(--font-size-xs);
  color: var(--ui-text-2);
  line-height: 1.45;
}
.mp-root .mp-ip-key {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--ui-border);
  display: flex; flex-direction: column;
  gap: 6px;
}
.mp-root .mp-ip-key h5 {
  margin: 0 0 4px;
  font-size: var(--font-size-xs);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ui-muted);
  font-weight: 700;
}
.mp-root .mp-ip-key-row {
  display: grid;
  grid-template-columns: 58px 36px 1fr;
  gap: 8px;
  align-items: center;
  font-size: var(--font-size-xs);
  color: var(--ui-text-2);
  line-height: 1.4;
}
.mp-root .mp-ip-key-code {
  font-family: var(--font-mono);
  font-size: 10.5px;
  background: color-mix(in srgb, var(--mp-type-color) 14%, var(--ui-ctrl));
  border: 1px solid color-mix(in srgb, var(--mp-type-color) 35%, var(--ui-border));
  border-radius: 3px;
  padding: 1px 4px;
  color: var(--mp-type-color);
  text-align: center;
  white-space: nowrap;
  font-weight: 700;
}
.mp-root .mp-ip-key-svg {
  width: 36px; height: 24px;
  stroke: var(--mp-type-color);
  stroke-width: 1.4;
  fill: none;
  border: 1px solid var(--ui-border);
  border-radius: 3px;
  background: var(--ui-bg);
  padding: 2px;
}

/* ── Wallpaper Styles/Build mode toggle ───────────────────────────────────── */
.mp-root .mp-wallmode {
  display: inline-flex;
  gap: 2px;
  padding: 2px;
  background: var(--ui-ctrl);
  border: 1px solid var(--ui-border);
  border-radius: var(--radius-md);
  align-self: flex-start;
}
.mp-root .mp-wallmode-btn {
  font-size: 11px; font-weight: 600;
  padding: 4px 12px;
  border: none; border-radius: var(--radius-sm);
  background: transparent;
  color: var(--ui-text-2);
  cursor: pointer;
  transition: background-color 0.12s, color 0.12s;
}
.mp-root .mp-wallmode-btn.is-active {
  background: color-mix(in srgb, var(--mp-type-color) 18%, var(--ui-ctrl));
  color: var(--mp-type-color);
}

/* ── Wallpaper Styles gallery (cards + dice) ──────────────────────────────── */
.mp-root .mp-wallgrid-bar {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
.mp-root .mp-wallgrid-dice {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 600;
  padding: 6px 12px;
  border: 1px solid color-mix(in srgb, var(--mp-type-color) 40%, var(--ui-border));
  border-radius: var(--radius-md);
  background: color-mix(in srgb, var(--mp-type-color) 12%, var(--ui-ctrl));
  color: var(--mp-type-color);
  cursor: pointer;
  transition: background-color 0.14s, border-color 0.14s, transform 0.08s;
}
.mp-root .mp-wallgrid-dice:hover {
  background: color-mix(in srgb, var(--mp-type-color) 22%, var(--ui-ctrl));
}
.mp-root .mp-wallgrid-dice:active { transform: scale(0.96); }
.mp-root .mp-wallgrid-dice-glyph { font-size: 15px; line-height: 1; }
.mp-root .mp-wallgrid-dice-hint {
  font-size: var(--font-size-xs);
  color: var(--ui-muted);
}
.mp-root .mp-wallgrid-section {
  font-size: 10px; font-weight: 700;
  letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--ui-text-2, var(--ui-muted));
  margin-top: 2px;
}
.mp-root .mp-wallgrid {
  container-type: inline-size;
  container-name: mp-wallgrid;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}
/* Responsive grid via container query (panel width, not viewport). */
@container mp-wallgrid (min-width: 300px) {
  .mp-root .mp-wallgrid { grid-template-columns: repeat(4, 1fr); }
}
@container mp-wallgrid (min-width: 420px) {
  .mp-root .mp-wallgrid { grid-template-columns: repeat(5, 1fr); }
}
.mp-root .mp-stylecard {
  position: relative;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 6px 4px 5px;
  background: var(--ui-ctrl);
  border: 1px solid var(--ui-border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--ui-text-2);
  transition: border-color 0.12s, background-color 0.12s, box-shadow 0.12s, transform 0.08s;
}
.mp-root .mp-stylecard:hover { border-color: var(--ui-border-hi, var(--ui-border)); }
.mp-root .mp-stylecard:active { transform: scale(0.97); }
.mp-root .mp-stylecard:focus-visible {
  outline: 2px solid var(--mp-type-color);
  outline-offset: 2px;
}
.mp-root .mp-stylecard.is-active {
  border-color: var(--mp-type-color);
  background: color-mix(in srgb, var(--mp-type-color) 16%, var(--ui-ctrl));
  box-shadow: 0 0 0 1px var(--mp-type-color), 0 0 9px -3px var(--mp-type-color);
}
/* Unmistakable "selected" badge on the active card. */
.mp-root .mp-stylecard.is-active::after {
  content: '✓';
  position: absolute; top: 4px; right: 4px;
  width: 14px; height: 14px;
  font-size: 10px; line-height: 14px; font-weight: 700; text-align: center;
  border-radius: 50%;
  background: var(--mp-type-color);
  color: var(--ui-bg);
  pointer-events: none;
}
.mp-root .mp-stylecard--preset {
  border-color: color-mix(in srgb, var(--mp-type-color) 30%, var(--ui-border));
}
.mp-root .mp-stylecard-thumb {
  width: 100%; aspect-ratio: 1 / 1;
  border-radius: 4px;
  overflow: hidden;
  background: var(--ui-bg);
  display: block;
}
.mp-root .mp-stylecard-thumb canvas { display: block; width: 100%; height: 100%; }
.mp-root .mp-stylecard-name {
  font-size: 10px; font-weight: 600;
  text-align: center; line-height: 1.2;
  color: var(--ui-text);
}
.mp-root .mp-stylecard-sub {
  font-size: 9px;
  letter-spacing: 0.04em;
  color: var(--ui-text-2, var(--ui-muted));
  text-align: center; line-height: 1.2;
}

/* ── Harmonograph/Pendula preset dropdown ─────────────────────────────────
   Compact trigger + grouped popover that replaces the former card gallery for
   the harmonograph + pendula studios. Each option renders a 28 px figure
   thumbnail; groups follow the craft-ladder order (Classic → Detuned →
   Evolving). Tokens-only. */
.hg-preset-dropdown-wrap { position: relative; margin-bottom: 8px; display: flex; align-items: center; gap: 6px; }

.hg-preset-trigger {
  display: flex; align-items: center; gap: 8px;
  width: 100%; height: var(--row-height, 28px);
  padding: 0 8px;
  background: var(--ui-ctrl);
  border: 1px solid var(--ui-border);
  border-radius: var(--radius-sm);
  cursor: pointer; color: var(--ui-text);
  transition: border-color 0.12s;
}
.hg-preset-trigger:hover { border-color: var(--ui-border-hi, var(--ui-border)); }
.hg-preset-trigger[aria-expanded="true"] { border-color: var(--ui-accent); }
.hg-preset-trigger:focus-visible { outline: 2px solid var(--ui-accent); outline-offset: 2px; }

.hg-preset-trigger-thumb {
  flex: none; width: 28px; height: 28px;
  border-radius: 3px; background: var(--ui-bg);
}
.hg-preset-trigger-label {
  flex: 1; text-align: left;
  font-size: var(--font-sm, 11px);
}
.hg-preset-chevron {
  flex: none; width: 10px; height: 6px;
  opacity: 0.5; transition: transform 0.15s;
}
.hg-preset-trigger[aria-expanded="true"] .hg-preset-chevron { transform: rotate(180deg); }

.hg-preset-popover {
  position: absolute; z-index: 200;
  top: calc(100% + 4px); left: 0; right: 0;
  background: var(--ui-panel, var(--ui-bg));
  border: 1px solid var(--ui-border);
  border-radius: var(--radius-sm);
  box-shadow: 0 6px 20px rgba(0,0,0,.35);
  max-height: 260px; overflow-y: auto;
  padding: 4px 0;
}

.hg-preset-group { display: flex; flex-direction: column; }
.hg-preset-group-title {
  font-size: 10px; font-weight: 700;
  letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--ui-text-2, var(--ui-muted));
  padding: 6px 10px 3px;
}

.hg-preset-option {
  display: flex; align-items: center; gap: 8px;
  width: 100%; padding: 5px 10px;
  background: none; border: none; cursor: pointer;
  font-size: var(--font-sm, 11px); text-align: left;
  color: var(--ui-text);
  transition: background-color 0.08s;
}
.hg-preset-option:hover { background: var(--ui-hover, rgba(255,255,255,0.06)); }
.hg-preset-option.is-active { color: var(--ui-accent); }
.hg-preset-option:focus-visible { outline: 2px solid var(--ui-accent); outline-offset: -2px; }

.hg-preset-option-thumb {
  flex: none; width: 28px; height: 28px;
  border-radius: 3px; background: var(--ui-bg); display: block;
}
.hg-preset-option-thumb--placeholder { opacity: 0; }
.hg-preset-option-label { flex: 1; }

.hg-preset-delete {
  flex: none; display: none; align-items: center; justify-content: center;
  width: 18px; height: 18px; padding: 0; border: none; border-radius: 3px;
  background: transparent; color: var(--ui-muted, #888); cursor: pointer;
  opacity: 0.6;
}
.hg-preset-delete svg { width: 10px; height: 10px; display: block; }
@media (hover: hover) {
  .hg-preset-option:hover .hg-preset-delete { display: flex; }
  .hg-preset-delete:hover { color: var(--ui-accent); opacity: 1; }
} /* TUX-036 */

/* Dev-only inline group reassignment select. Doubles as a visible group label at
   rest (low opacity); brightens on row hover/focus. Sits before the delete X. */
.hg-preset-group-select {
  flex: none; max-width: 96px;
  padding: 1px 4px; border-radius: 3px;
  border: 1px solid var(--ui-border, rgba(255,255,255,0.12));
  background: var(--ui-bg); color: var(--ui-muted, #888);
  font-size: var(--font-size-xs, 11px); line-height: 1.4;
  cursor: pointer; opacity: 0.55;
  transition: opacity 0.08s, color 0.15s, border-color 0.15s;
}
.hg-preset-group-select:focus { opacity: 1; }
@media (hover: hover) {
  .hg-preset-option:hover .hg-preset-group-select { opacity: 1; }
  .hg-preset-group-select:hover { color: var(--ui-text); border-color: var(--ui-accent); }
} /* TUX-036 */

/* Revert-to-default control: shares the delete button's sizing/hover-reveal but
   reads as a restore (neutral hover), not a destructive action. */
@media (hover: hover) {
  .hg-preset-revert:hover { color: var(--ui-text); opacity: 1; }
} /* TUX-036 */

/* Dev-only "Set as Default" star button. Gold hover signals constructive action. */
.hg-preset-set-default {
  flex: none; display: none; align-items: center; justify-content: center;
  width: 18px; height: 18px; padding: 0; border: none; border-radius: 3px;
  background: transparent; color: var(--ui-muted, #888); cursor: pointer;
  opacity: 0.6;
}
.hg-preset-set-default svg { width: 10px; height: 10px; display: block; }
@media (hover: hover) {
  .hg-preset-option:hover .hg-preset-set-default { display: flex; }
  .hg-preset-set-default:hover { color: #c8a84b; opacity: 1; }
} /* TUX-036 */

.hg-preset-import {
  display: block; width: 100%; padding: 6px 10px; margin-top: 4px;
  border: 1px dashed var(--ui-border, rgba(255,255,255,0.12));
  border-radius: 4px; background: transparent;
  color: var(--ui-muted, #888); font-size: var(--font-size-xs, 11px);
  text-align: center; cursor: pointer; transition: color 0.15s, border-color 0.15s;
}
.hg-preset-import:hover {
  color: var(--ui-accent); border-color: var(--ui-accent);
}

/* ── Save pip + Save Preset modal ──────────────────────────────────────────── */
/* The dirty-state save affordance: a colored disk that appears beside the preset
   trigger the instant the layer diverges from its named preset. */
.hg-preset-save-pip {
  flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; padding: 0;
  border: 1px solid var(--ui-accent);
  border-radius: var(--radius-sm);
  background: var(--ui-accent); color: var(--ui-on-accent);
  cursor: pointer;
  transition: opacity 0.12s, transform 0.12s;
}
.hg-preset-save-pip svg { width: 15px; height: 15px; display: block; }
@media (hover: hover) {
  .hg-preset-save-pip:hover { opacity: 0.88; }
}
.hg-preset-save-pip:focus-visible { outline: 2px solid var(--ui-accent); outline-offset: 2px; }
.hg-preset-save-pip[hidden] { display: none; }

.preset-save-body { display: flex; flex-direction: column; gap: 12px; min-width: 280px; }
.preset-save-preview { display: flex; justify-content: center; }
.preset-save-preview-thumb {
  width: 96px; height: 96px; border-radius: var(--radius-sm);
  background: var(--ui-bg); border: 1px solid var(--ui-border);
}
.preset-save-field { display: flex; flex-direction: column; gap: 4px; }
.preset-save-label { font-size: var(--font-sm, 11px); color: var(--ui-text-2, var(--ui-muted)); }
.preset-save-input {
  width: 100%; height: 30px; padding: 0 8px; box-sizing: border-box;
  background: var(--ui-ctrl); border: 1px solid var(--ui-border);
  border-radius: var(--radius-sm); color: var(--ui-text);
  font-size: var(--font-sm, 12px);
}
.preset-save-input:focus { outline: none; border-color: var(--ui-accent); box-shadow: 0 0 0 3px var(--ui-accent-2); }
.preset-save-seg { width: 100%; }
.preset-save-dest { width: 100%; }
.preset-save-note { margin: 0; font-size: var(--font-size-xs, 10px); color: var(--ui-muted, #888); }
.preset-save-footer { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }
.preset-save-confirm[disabled] { opacity: 0.5; cursor: not-allowed; }

/* Settings hint copy (e.g. Developer mode explainer). */
.ctrl-hint { margin: 4px 0 0; font-size: var(--font-size-xs, 10px); color: var(--ui-muted, #888); line-height: 1.4; }

/* Preset Storage settings section (Phase 2 — folder persistence). */
.preset-storage-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.preset-storage-folder-row { display: flex; align-items: center; gap: 8px; margin-top: 6px; }
.preset-storage-folder-name { font-size: var(--font-sm, 12px); color: var(--ui-text); font-weight: 600; }
.preset-storage-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.preset-storage-dot.is-live { background: var(--ui-success, #3fb950); }
.preset-storage-dot.is-paused { background: var(--ui-warning, #d29922); }
/* Bundle Export/Import is demoted beneath the live-sync headline. */
.preset-storage-secondary { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--ui-border); }
.preset-storage-secondary-hint { margin: 0; text-transform: uppercase; letter-spacing: 0.04em; font-size: 10px; opacity: 0.7; }

/* Touch: dock the Save Preset modal as a bottom sheet and pin Save above the
   name input so the on-screen keyboard never covers the commit action. */
@media (pointer: coarse) {
  .vectura-modal-backdrop { align-items: flex-end !important; }
  .vectura-modal { width: 100%; max-width: 100%; border-radius: 12px 12px 0 0; }
}

/* ── Snapping feedback (auto-changed chips + transient line) ───────────────── */
.mp-root .mp-snap-line {
  font-size: var(--font-size-xs);
  color: var(--mp-type-color);
  background: color-mix(in srgb, var(--mp-type-color) 10%, transparent);
  border-left: 2px solid var(--mp-type-color);
  border-radius: 3px;
  padding: 5px 8px;
  line-height: 1.35;
}
.mp-root .mp-wall-badge-id {
  font-family: var(--font-mono);
  opacity: 0.7;
}
.mp-root .mp-lock-note {
  font-size: var(--font-size-xs);
  color: var(--ui-muted);
  line-height: 1.35;
  margin-top: 4px;
}

/* Mirror panel — reorder drag + multiplier warning */
.mp-root .mp-stack-warn {
  font-family: var(--font-mono); font-size: 9px;
  letter-spacing: 0.04em;
  color: var(--ui-danger);
  border: 1px solid color-mix(in srgb, var(--ui-danger) 40%, transparent);
  background: color-mix(in srgb, var(--ui-danger) 14%, transparent);
  border-radius: 4px;
  padding: 1px 5px;
  margin-left: 4px;
  text-transform: uppercase;
  font-weight: 700;
}
.mp-root .mp-row { cursor: grab; }
.mp-root .mp-row[draggable="true"]:active { cursor: grabbing; }
.mp-root .mp-row--dragging {
  opacity: 0.5;
  outline: 1px dashed var(--mp-row-color, var(--ui-accent));
}
.mp-root .mp-drop-indicator {
  height: 2px;
  border-radius: 999px;
  background: var(--ui-accent);
  margin: 2px 0;
  box-shadow: 0 0 4px var(--ui-accent);
  pointer-events: none;
}

/* === Migrated from legacy CSS (Unit 2.1: Align / Pathfinder / Paint Bucket panels, 2026-05-20) === */
/* Align / Distribute panel (multi-selection pane) */
.align-panel {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.align-panel-row {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.align-panel-row + .align-panel-row {
  padding-top: 0.6rem;
  border-top: 1px solid var(--ui-border, rgb(255 255 255 / 0.08));
}

.align-panel-label {
  font-size: 11px;
  color: var(--ui-muted, #94a3b8);
  margin: 0;
  letter-spacing: 0.02em;
}

.align-panel-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 4px;
  align-items: center;
}

.align-panel-spacer {
  display: block;
  height: 1px;
}

.align-panel-spacing,
.align-panel-target {
  display: flex;
  align-items: center;
  gap: 4px;
}

.align-panel-target {
  width: 100%;
}

.align-panel-target .align-target-btn {
  flex: 1;
}

.align-spacing-slider-wrap {
  flex: 1;
  min-width: 0;
}

.align-spacing-slider-wrap .ctrl-slider:disabled,
#align-spacing-chip:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.align-btn,
.align-target-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 28px;
  background: var(--ui-bg, #0b0f1a);
  border: 1px solid var(--ui-border, rgb(255 255 255 / 0.1));
  color: var(--ui-text, #cbd5e1);
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease;
  padding: 0;
}

.align-btn:hover,
.align-target-btn:hover {
  background: var(--ui-border, rgb(255 255 255 / 0.08));
  color: var(--ui-accent, #d946ef);
}

.align-btn:active,
.align-target-btn:active {
  transform: translateY(0.5px);
}

.align-btn:disabled,
.align-target-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.align-target-btn[aria-pressed="true"] {
  background: var(--ui-border, rgb(255 255 255 / 0.18));
  color: var(--ui-accent, #d946ef);
  border-color: var(--ui-accent, #d946ef);
}

.align-panel-hint {
  font-size: 10.5px;
  color: var(--ui-muted, #94a3b8);
  margin: 0;
  line-height: 1.4;
  min-height: 1.2em;
}

@keyframes align-panel-flash {
  0%, 100% { box-shadow: none; }
  50% { box-shadow: inset 0 0 0 2px var(--ui-accent, #d946ef); }
}

.align-panel-flash {
  animation: align-panel-flash 0.6s ease;
}

/* ── Pathfinder panel ─────────────────────────────────────────────────── */
.pathfinder-panel {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin-top: 0.85rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--ui-border, rgb(255 255 255 / 0.08));
}

.pathfinder-panel-modes {
  display: inline-flex;
  align-self: flex-start;
  gap: 1px;
  background: var(--ui-border, rgb(255 255 255 / 0.08));
  border: 1px solid var(--ui-border, rgb(255 255 255 / 0.1));
  border-radius: 4px;
  padding: 1px;
}

.pf-mode-btn {
  padding: 3px 9px;
  background: transparent;
  border: 0;
  color: var(--ui-muted, #94a3b8);
  font-size: 10.5px;
  letter-spacing: 0.02em;
  cursor: pointer;
  border-radius: 3px;
  transition: background 0.12s ease, color 0.12s ease;
}

.pf-mode-btn:hover {
  color: var(--ui-text, #cbd5e1);
}

.pf-mode-btn[aria-pressed="true"] {
  background: var(--ui-bg, #0b0f1a);
  color: var(--ui-accent, #d946ef);
  box-shadow: inset 0 0 0 1px var(--ui-accent, #d946ef);
}

.pathfinder-panel-row {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.pathfinder-panel-row + .pathfinder-panel-row {
  padding-top: 0.5rem;
  border-top: 1px solid var(--ui-border, rgb(255 255 255 / 0.06));
}

.pathfinder-panel-label {
  font-size: 11px;
  color: var(--ui-muted, #94a3b8);
  margin: 0;
  letter-spacing: 0.02em;
}

.pathfinder-panel-shape-modes {
  display: flex;
  gap: 6px;
  align-items: stretch;
}

.pathfinder-panel-shape-modes .pathfinder-panel-grid {
  flex: 1;
}

.pathfinder-panel-grid {
  display: grid;
  gap: 4px;
  align-items: center;
}

.pathfinder-panel-grid-shape-modes {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.pathfinder-panel-grid-pathfinders {
  grid-template-columns: repeat(6, minmax(0, 1fr));
}

.pf-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 28px;
  background: var(--ui-bg, #0b0f1a);
  border: 1px solid var(--ui-border, rgb(255 255 255 / 0.1));
  color: var(--ui-text, #cbd5e1);
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease;
  padding: 0;
}

.pf-btn:hover:not(:disabled) {
  background: var(--ui-border, rgb(255 255 255 / 0.08));
  color: var(--ui-accent, #d946ef);
}

.pf-btn:active:not(:disabled) {
  transform: translateY(0.5px);
}

.pf-btn:disabled {
  opacity: 0.32;
  cursor: not-allowed;
}

.pf-btn[aria-pressed="true"] {
  background: var(--ui-border, rgb(255 255 255 / 0.18));
  color: var(--ui-accent, #d946ef);
  border-color: var(--ui-accent, #d946ef);
}

.pf-expand-btn {
  padding: 0 12px;
  height: 28px;
  background: var(--ui-bg, #0b0f1a);
  border: 1px solid var(--ui-border, rgb(255 255 255 / 0.1));
  color: var(--ui-text, #cbd5e1);
  font-size: 11px;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease;
}

.pf-expand-btn:hover:not(:disabled) {
  background: var(--ui-border, rgb(255 255 255 / 0.08));
  color: var(--ui-accent, #d946ef);
  border-color: var(--ui-accent, #d946ef);
}

.pf-expand-btn:disabled {
  opacity: 0.32;
  cursor: not-allowed;
}

.pathfinder-panel-hint {
  font-size: 10.5px;
  color: var(--ui-muted, #94a3b8);
  margin: 0;
  line-height: 1.4;
  min-height: 1.2em;
}

/* ── Paint Bucket panel ───────────────────────────────────────────────── */
.paint-bucket-panel {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 0.4rem 0;
}

.paint-bucket-section {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

/* Dividers between consecutive sections — agnostic to a status chip sibling
   inserted at the top of the panel. */
.paint-bucket-section + .paint-bucket-section {
  padding-top: 0.5rem;
  border-top: 1px solid var(--ui-border, rgb(255 255 255 / 0.06));
}

.paint-bucket-status-chip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.35rem 0.5rem 0.4rem;
  border-radius: 6px;
  background: rgba(34, 197, 94, 0.12);
  border: 1px solid rgba(34, 197, 94, 0.45);
  color: var(--ui-text, #e2e8f0);
  font-size: 11.5px;
}

.paint-bucket-status-chip[hidden] {
  display: none;
}

.paint-bucket-status-chip-text {
  letter-spacing: 0.02em;
}

.paint-bucket-status-chip-done {
  appearance: none;
  background: rgba(34, 197, 94, 0.7);
  color: #04130a;
  border: 0;
  border-radius: 4px;
  padding: 0.15rem 0.55rem;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
}

.paint-bucket-status-chip-done:hover {
  background: rgba(34, 197, 94, 0.92);
}

.paint-bucket-status-chip-done:focus-visible {
  outline: 2px solid rgba(34, 197, 94, 0.95);
  outline-offset: 1px;
}

.paint-bucket-section-label {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--ui-muted, #94a3b8);
  margin: 0;
}

.paint-bucket-expand-btn {
  appearance: none;
  width: 100%;
  background: rgba(99, 102, 241, 0.18);
  color: var(--ui-text, #e5e7eb);
  border: 1px solid rgba(99, 102, 241, 0.45);
  border-radius: 4px;
  padding: 0.4rem 0.6rem;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease, opacity 0.12s ease;
}

.paint-bucket-expand-btn:hover:not(:disabled) {
  background: rgba(99, 102, 241, 0.32);
  border-color: rgba(99, 102, 241, 0.7);
}

.paint-bucket-expand-btn:focus-visible {
  outline: 2px solid rgba(99, 102, 241, 0.8);
  outline-offset: 1px;
}

.paint-bucket-expand-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.paint-bucket-sample-empty {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 0.6rem 0.65rem 0.7rem;
  border-radius: 6px;
  background: rgba(59, 130, 246, 0.10);
  border: 1px solid rgba(59, 130, 246, 0.40);
  color: var(--ui-text, #e2e8f0);
}

.paint-bucket-sample-empty[hidden] {
  display: none;
}

.paint-bucket-sample-title {
  margin: 0;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--ui-text, #e2e8f0);
}

.paint-bucket-sample-hint {
  margin: 0;
  font-size: 11.5px;
  line-height: 1.4;
  color: var(--ui-muted, #94a3b8);
}

/* While the sampling-empty notice is showing, hide the regular panel content
   so the user only sees the prompt. Released when meta is released. */
.paint-bucket-panel.is-sampling-empty > :not(#paint-bucket-sample-empty) {
  display: none !important;
}

.paint-bucket-variant-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 4px;
}

.pb-variant-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 30px;
  background: var(--ui-bg, #0b0f1a);
  border: 1px solid var(--ui-border, rgb(255 255 255 / 0.10));
  color: var(--ui-text, #cbd5e1);
  cursor: pointer;
  padding: 0;
  border-radius: 3px;
  transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}

.pb-variant-btn:hover {
  background: var(--ui-border, rgb(255 255 255 / 0.08));
  color: var(--ui-accent, #d946ef);
}

.pb-variant-btn.active,
.pb-variant-btn[aria-pressed="true"] {
  background: var(--ui-bg, #0b0f1a);
  color: var(--ui-accent, #d946ef);
  box-shadow: inset 0 0 0 1px var(--ui-accent, #d946ef);
}

.pb-variant-text {
  font-size: 9px;
  text-transform: uppercase;
}

.paint-bucket-row {
  display: grid;
  grid-template-columns: 70px 1fr 40px;
  align-items: center;
  gap: 6px;
}

.paint-bucket-row .paint-bucket-slider-wrap {
  min-width: 0;
}

.paint-bucket-row select.paint-bucket-select {
  grid-column: 2 / span 2;
}

.paint-bucket-label {
  font-size: 11px;
  color: var(--ui-muted, #94a3b8);
  letter-spacing: 0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.paint-bucket-select {
  width: 100%;
  background: var(--ui-bg, #0b0f1a);
  border: 1px solid var(--ui-border, rgb(255 255 255 / 0.10));
  color: var(--ui-text, #cbd5e1);
  padding: 3px 6px;
  font-size: 11px;
  border-radius: 3px;
}

.paint-bucket-panel-hint {
  font-size: 10.5px;
  color: var(--ui-muted, #94a3b8);
  margin: 0;
  line-height: 1.4;
  min-height: 1.2em;
}

.paint-bucket-row-scope {
  align-items: center;
}

.pb-scope-toggle {
  display: inline-flex;
  gap: 1px;
  background: var(--ui-border, rgb(255 255 255 / 0.08));
  border: 1px solid var(--ui-border, rgb(255 255 255 / 0.1));
  border-radius: 4px;
  padding: 1px;
}

.pb-scope-btn {
  padding: 3px 9px;
  background: transparent;
  border: 0;
  color: var(--ui-muted, #94a3b8);
  font-size: 10.5px;
  letter-spacing: 0.02em;
  cursor: pointer;
  border-radius: 3px;
  transition: background 0.12s ease, color 0.12s ease;
}

.pb-scope-btn:hover {
  color: var(--ui-text, #cbd5e1);
}

.pb-scope-btn[aria-pressed="true"] {
  background: var(--ui-bg, #0b0f1a);
  color: var(--ui-accent, #d946ef);
  box-shadow: inset 0 0 0 1px var(--ui-accent, #d946ef);
}

.paint-bucket-hint-inline {
  font-size: 10.5px;
  color: var(--ui-muted, #94a3b8);
  margin: 0.2rem 0 0;
  line-height: 1.4;
  font-style: italic;
}

.layer-item.active {
  border-left: 4px solid var(--ui-accent);
  background-color: rgb(var(--vectura-border-rgb) / 0.5);
}

.layer-item {
  user-select: none;
}

.layer-item.selected {
  border-color: var(--ui-accent);
}

.layer-item:focus-visible {
  outline: 2px solid var(--ui-accent);
  outline-offset: -2px;
}

.layer-mini-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 2px 6px;
  border: 1px solid var(--ui-border);
  border-radius: 9999px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--ui-muted);
  background: rgb(var(--vectura-bg-rgb) / 0.72);
}

.layer-mini-badge--mask {
  color: #67e8f9;
  border-color: rgba(103, 232, 249, 0.35);
}

.layer-group {
  background: var(--ui-panel-alt);
  border-style: dashed;
}

.group-drop-target {
  border-color: var(--ui-accent);
  box-shadow: inset 0 0 0 1px rgb(var(--vectura-accent-rgb) / 0.6);
}

.layer-sub {
  padding-left: 0;
}

.layer-grip--spacer {
  display: inline-block;
  width: 14px;
  height: 14px;
}

.group-toggle {
  width: 18px;
  height: 18px;
  border: 1px solid var(--ui-border);
  border-radius: 4px;
  background: var(--ui-bg);
  color: var(--ui-text-2);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
}

.group-toggle:hover {
  color: var(--ui-accent);
  border-color: var(--ui-accent);
}

.layer-grip {
  display: grid;
  grid-template-columns: repeat(2, 4px);
  grid-template-rows: repeat(3, 4px);
  gap: 2px;
  padding: 2px;
  cursor: grab;
}

.layer-grip .dot {
  width: 3px;
  height: 3px;
  border-radius: 9999px;
  background: var(--ui-muted);
}

.pen-assign {
  position: relative;
  width: 20px;
  height: 20px;
  margin-right: 4px;
}

.pen-pill {
  width: 100%;
  height: 100%;
  border: none;
  padding: 0;
  background: transparent;
  cursor: pointer;
}

.pen-menu {
  position: absolute;
  right: 0;
  top: 24px;
  min-width: 160px;
  background: var(--ui-bg);
  border: 1px solid var(--ui-border);
  padding: 6px;
  z-index: 30;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.pen-menu.hidden {
  display: none;
}

[data-ui-skin='light'] .layer-mini-badge--mask {
  color: #155e75;
  border-color: rgba(21, 94, 117, 0.35);
  background: rgba(14, 116, 144, 0.1);
}

[data-ui-skin='light'] {
  --lvl-cyan: #0284c7;
  --lvl-cyan45: rgba(2, 132, 199, 0.45);
}

/* === Migrated from legacy CSS (Unit 2.2a: right-pane tabs + bottom-pane shell + noise-card container queries, 2026-05-20) === */
/* ── Right pane: Layers / Pens tabs (live in pane header) ────── */
.right-pane-tabs {
  display: flex;
  flex: 1;
  align-self: stretch;
  background: transparent;
}
.right-pane-tab {
  flex: 1;
  padding: 0 10px;
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ui-muted);
  background: transparent;
  border: 0;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
}
.right-pane-tab:hover {
  color: var(--ui-text);
}
.right-pane-tab.active {
  color: var(--ui-accent);
  border-bottom-color: var(--ui-accent);
}
.lvl-add-wrap {
  position: relative; z-index: 1; flex-shrink: 0;
}
.lvl-add-btn-icon {
  background: #38bdf8;
  border: 1px solid #38bdf8;
  border-radius: 4px;
  color: var(--ui-bg);
  cursor: pointer;
  padding: 4px 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color .12s, border-color .12s, background .12s;
}
.lvl-add-btn-icon:hover {
  background: #7dd3fc;
  border-color: #7dd3fc;
  color: var(--ui-bg);
}
.right-tab-panel {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}
.right-tab-panel.hidden {
  display: none;
}

/* ── Bottom pane: 2-column grid (formula | background) ───────── */
.bottom-pane-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  align-items: start;
}
.bottom-pane-grid > * {
  min-width: 0;
}
.bottom-pane-bg-slot {
  padding: 4px 0;
  /* Stat grid on top, Plot Physics table below, both right-aligned in one
     column — a row layout put the table on top of the stat values. */
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
}
.bottom-pane-bg-slot > .plot-physics-readout {
  width: 100%;
  max-width: 420px;
}

.pen-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px;
  background: transparent;
  border: 1px solid transparent;
  color: var(--ui-text);
  text-align: left;
  font-size: 0.75rem;
}

.pen-option:hover {
  border-color: var(--ui-border-hi);
  background: var(--ui-panel);
}

.pen-option.active {
  border-color: var(--ui-accent);
}

.pen-option .pen-icon {
  width: 16px;
  height: 16px;
}

.pen-icon {
  width: 100%;
  height: 100%;
  border-radius: 9999px;
  border: 1px solid var(--ui-border);
  position: relative;
  background: var(--ui-text);
}

.pen-icon::after {
  content: '';
  position: absolute;
  inset: 50% auto auto 50%;
  width: calc(2px + var(--pen-width, 0.3) * 6px);
  height: calc(2px + var(--pen-width, 0.3) * 6px);
  transform: translate(-50%, -50%);
  border-radius: 9999px;
  background: currentColor;
}

.pen-assign .pen-icon {
  color: var(--ui-text);
}

.pen-select {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.pen-list .pen-icon {
  border-color: var(--ui-border-hi);
}

.pen-item .pen-icon {
  flex: 0 0 26px;
  width: 26px;
  height: 26px;
}

.pen-item {
  gap: 8px;
}

.pen-width {
  width: 90px;
}

.pen-width-value {
  width: 42px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.pen-grip {
  display: grid;
  grid-template-columns: repeat(2, 4px);
  grid-template-rows: repeat(3, 4px);
  gap: 2px;
  padding: 2px;
  cursor: grab;
}

.pen-grip:active {
  cursor: grabbing;
}

.pen-grip .dot {
  width: 3px;
  height: 3px;
  border-radius: 9999px;
  background: var(--ui-muted);
}

.formula-text {
  color: var(--ui-formula);
  font-variant-ligatures: none;
}

.formula-block {
  display: flex;
  flex-direction: column;
  gap: 12px;
  position: relative;
}

/* Copy button: top-right of the formula block; copies the full model text. */
.formula-copy-btn {
  position: absolute;
  top: 6px;
  right: 6px;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 7px;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ui-muted);
  background: var(--ui-panel);
  border: 1px solid var(--ui-border);
  border-radius: 4px;
  cursor: pointer;
  /* No CSS transition: a transitionend here (e.g. on a theme/color change)
     makes the canvas HUD schedule a frame, which breaks the Start Page's
     no-idle-rAF budget. */
}
.formula-copy-btn:hover,
.formula-copy-btn:focus-visible {
  color: var(--ui-text);
  border-color: var(--ui-border-hi);
}
.formula-copy-btn[data-state="copied"] {
  color: var(--ui-accent);
  border-color: var(--ui-accent);
}
.formula-copy-btn[data-state="failed"] {
  color: var(--ui-danger);
  border-color: var(--ui-danger);
}
/* Keep the first formula line clear of the button. */
.formula-block > .formula-equation {
  padding-right: 84px;
}

.formula-equation,
.formula-values {
  background: rgb(var(--vectura-bg-rgb) / 0.72);
  border: 1px solid var(--ui-border);
  border-radius: 8px;
  padding: 8px 10px;
}

.formula-line {
  white-space: pre-wrap;
  overflow-wrap: break-word;
}

.formula-values-title {
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 10px;
  color: var(--ui-muted);
  margin-bottom: 6px;
}

.formula-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 2px 0;
}

.formula-key {
  color: var(--ui-text-2);
  flex: 0 0 auto;
}

/* Long values (JSON blobs like N1.imageEffects) wrap inside the row instead
   of widening the whole bottom pane. */
.formula-val {
  color: var(--ui-formula);
  text-align: right;
  min-width: 0;
  overflow-wrap: anywhere;
}

.pendulum-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.pendulum-list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.pendulum-card {
  border: 1px solid var(--ui-border);
  border-radius: 10px;
  padding: 10px;
  background: var(--ui-ctrl);
}

.pendulum-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.pendulum-title {
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ui-text-2);
}

.pendulum-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.pendulum-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 10px;
  color: var(--ui-text-2);
}

.pendulum-toggle input {
  accent-color: #ef4444;
}

.pendulum-delete {
  border: 1px solid var(--ui-border);
  border-radius: 6px;
  padding: 2px 6px;
  font-size: 12px;
  color: #ef4444;
  background: transparent;
}

.pendulum-delete:hover {
  background: var(--ui-border);
}

.pendulum-controls {
  display: grid;
  gap: 10px;
  grid-template-columns: 1fr;
}

/* Pluck Pad — promoted drag-vector control (drag length = amplitude, drag
   angle = release direction). */
.pendulum-pad-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: center;
  margin: 4px 0 10px;
}

.pendulum-pluck-pad {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.pendulum-pad-row .pendulum-pluck-pad {
  margin: 0;
}

.pendulum-pluck-pad .pluck-pad-label {
  display: flex;
  align-items: center;
  gap: 6px;
  align-self: flex-start;
}

.pendulum-pluck-pad .pluck-pad-canvas {
  width: 92px;
  height: 92px;
  border: 1px solid var(--ui-border);
  border-radius: 10px;
  background: var(--ui-ctrl-2, var(--ui-ctrl));
  cursor: crosshair;
  touch-action: none;
}

/* A control + its per-param padlock laid out side by side. */
.pendulum-control-row {
  display: flex;
  align-items: flex-start;
  gap: 6px;
}

.pendulum-control-row > .pendulum-control {
  flex: 1 1 auto;
  min-width: 0;
}

.pendulum-param-lock {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  margin-top: 1px;
  border: 1px solid var(--ui-border);
  border-radius: 6px;
  color: var(--ui-text-2);
  background: transparent;
  cursor: pointer;
}

.pendulum-param-lock:hover {
  background: var(--ui-border);
  color: var(--ui-text);
}

.pendulum-param-lock.is-locked {
  color: var(--ui-accent);
  border-color: var(--ui-accent);
}

/* Advanced disclosure holding the numeric amp/phase source-of-truth controls. */
.pendulum-advanced {
  margin-top: 6px;
}

.pendulum-advanced > .pendulum-advanced-summary {
  cursor: pointer;
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ui-text-2);
  padding: 4px 0;
  list-style: none;
}

.pendulum-advanced > .pendulum-advanced-summary::-webkit-details-marker {
  display: none;
}

.pendulum-advanced > .pendulum-advanced-summary::before {
  content: '▸';
  display: inline-block;
  margin-right: 6px;
  transition: transform 0.15s ease;
}

.pendulum-advanced[open] > .pendulum-advanced-summary::before {
  transform: rotate(90deg);
}

.pendulum-advanced > .noise-controls {
  display: grid;
  gap: 10px;
  margin-top: 6px;
}

.harmonograph-plotter {
  border: 1px solid var(--ui-border);
  border-radius: 10px;
  padding: 10px;
  background: var(--ui-ctrl);
  display: grid;
  gap: 8px;
}

.harmonograph-plotter-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  touch-action: none;
}

.harmonograph-plotter-head-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.harmonograph-plotter-popout,
.harmonograph-plotter-popin {
  border: 1px solid var(--ui-border);
  background: var(--ui-ctrl);
  color: var(--ui-text);
  min-width: 26px;
  height: 26px;
  border-radius: 6px;
  font-size: 12px;
  line-height: 1;
  padding: 0 6px;
  cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
}

.harmonograph-plotter-popout:hover,
.harmonograph-plotter-popin:hover {
  border-color: var(--ui-accent);
  color: var(--ui-accent);
}

.harmonograph-plotter-canvas {
  width: 100%;
  max-width: 240px;
  height: auto;
  border: 1px solid var(--ui-border);
  border-radius: 8px;
  background: #101115;
}

/* Floating (popped-out) Virtual Plotter window: a fixed, draggable container
 * over the canvas. `resize: both` provides robust user resizing watched by a
 * ResizeObserver that re-renders the figure crisp at the new size. The header
 * is the drag handle. */
.harmonograph-plotter-float {
  position: fixed;
  z-index: 95;
  width: 320px;
  min-width: 200px;
  min-height: 240px;
  resize: both;
  overflow: hidden;
  border: 1px solid var(--ui-border-hi);
  border-radius: 12px;
  background: var(--ui-panel-alt);
  box-shadow: 0 24px 64px rgb(var(--vectura-bg-rgb) / 0.6);
}

.harmonograph-plotter-float.dragging {
  cursor: grabbing;
}

/* When floating, the widget fills the resizable container and its canvas grows
 * to the container width (overriding the docked max-width:240px cap). */
.harmonograph-plotter-floating {
  margin-bottom: 0;
  border: none;
  border-radius: 12px;
  height: 100%;
}

.harmonograph-plotter-floating .harmonograph-plotter-head {
  cursor: grab;
}

.harmonograph-plotter-floating .harmonograph-plotter-canvas {
  max-width: none;
}

/* Panel slot placeholder shown while the plotter is popped out. */
.harmonograph-plotter-placeholder {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border: 1px dashed var(--ui-border);
  border-radius: 10px;
  padding: 10px;
  background: var(--ui-ctrl);
}

.harmonograph-plotter-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.harmonograph-plotter-range {
  width: 100%;
}

/* Plot-range (start/stop) dual-thumb slider. Two <input type="range"> are
 * stacked over a shared track; the inputs have pointer-events:none so they
 * don't block each other, and only their thumbs re-enable pointer events so
 * both handles stay grabbable. The fill shows the selected [start,end] band. */
.harmonograph-plotter-plotrange-row .harmonograph-plotter-plotrange-val {
  color: var(--ui-accent);
  font-variant-numeric: tabular-nums;
}
.harmonograph-plotter-plotrange {
  position: relative;
  width: 100%;
  height: 18px;
  display: flex;
  align-items: center;
}
.harmonograph-plotter-plotrange .hp-plotrange-track {
  position: absolute;
  left: 0;
  right: 0;
  height: 3px;
  border-radius: 3px;
  background: var(--ui-border);
}
.harmonograph-plotter-plotrange .hp-plotrange-fill {
  position: absolute;
  top: 0;
  height: 100%;
  border-radius: 3px;
  background: var(--ui-accent);
  opacity: 0.7;
}
.harmonograph-plotter-plotrange input[type='range'] {
  position: absolute;
  left: 0;
  width: 100%;
  margin: 0;
  background: transparent;
  pointer-events: none;
  -webkit-appearance: none;
  appearance: none;
}
.harmonograph-plotter-plotrange input[type='range']::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  pointer-events: auto;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--ui-bg);
  border: 2px solid var(--ui-accent);
  cursor: pointer;
}
.harmonograph-plotter-plotrange input[type='range']::-moz-range-thumb {
  pointer-events: auto;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--ui-bg);
  border: 2px solid var(--ui-accent);
  cursor: pointer;
}
.harmonograph-plotter-plotrange input[type='range']::-moz-range-track {
  background: transparent;
}

/* Motion Rack — macro value knob + draw-your-own LFO curve editor. The cards
 * carry inline utility classes like the rest of the rack; these rules only add
 * what utilities can't express (a delimiting frame on the draw surface, and
 * touch-action so a pointer-drag shapes the curve instead of scrolling). */
.motion-macro-value {
  width: 100%;
  accent-color: var(--ui-accent);
  cursor: pointer;
}
.motion-drawn-editor {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.motion-drawn-canvas {
  display: block;
  width: 220px;
  max-width: 100%;
  border: 1px solid var(--ui-border);
  border-radius: 6px;
  background: var(--plotter-bg, #101115);
  cursor: crosshair;
  touch-action: none;
}


/* === Migrated from legacy CSS (Unit 2.2b: wave/noise + step dots + export modal scaffold + info popover, 2026-05-20) === */

/* Container-query 2-col layout — responds to noise-card width, not viewport.
 * Threshold sized so labels like "Blend Mode" / "Field Weight" stop wrapping
 * and value chips don't collide with the adjacent column's content. */
@container noise-card (min-width: 380px) {
  .pendulum-controls {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* Allow flex children inside narrow controls to shrink below their content
 * width. Without this, the right-aligned value chip can bleed into the
 * neighboring grid cell when the column is tight. */
.pendulum-controls .noise-control > .flex,
.pendulum-controls .noise-control > .flex > .flex {
  min-width: 0;
}
.pendulum-controls .noise-control .control-label {
  min-width: 0;
  overflow-wrap: anywhere;
}

.noise-controls {
  display: grid;
  gap: 10px;
  grid-template-columns: 1fr;
}

@container noise-card (min-width: 380px) {
  .noise-controls {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.pendulum-disabled {
  opacity: 0.6;
}

.noise-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  border: 1px solid var(--ui-border);
  border-radius: 10px;
  padding: 12px;
  background: var(--ui-ctrl);
}

.image-effects {
  margin-top: 8px;
  border: 1px dashed var(--ui-border);
  border-radius: 8px;
  padding: 8px;
  background: var(--ui-panel-alt);
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  grid-column: 1 / -1;
}

.image-effects-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.image-effect-card {
  border: 1px solid #24252b;
  border-radius: 8px;
  padding: 8px;
  background: var(--ui-panel-alt);
  width: 100%;
  container-type: inline-size;
  container-name: noise-card;
}

.image-effect-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
}

.image-effect-title {
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ui-text-2);
}

.image-effect-card.dragging {
  opacity: 0.6;
  transform: translateY(-2px);
}

.image-effect-drop-indicator {
  height: 2px;
  border-radius: 999px;
  background: var(--ui-accent);
  margin: 4px 0;
}

.noise-list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.noise-card {
  border: 1px solid var(--ui-border);
  border-radius: 10px;
  padding: 10px;
  background: var(--ui-workspace);
}

.noise-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.noise-title {
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ui-text-2);
}

.noise-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.noise-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 10px;
  color: var(--ui-text-2);
}

.noise-toggle input {
  accent-color: #ef4444;
}

.noise-delete {
  border: 1px solid var(--ui-border);
  border-radius: 6px;
  padding: 2px 6px;
  font-size: 12px;
  color: #ef4444;
  background: transparent;
}

.noise-delete:hover {
  background: var(--ui-border);
}

.noise-grip {
  display: grid;
  grid-template-columns: repeat(2, 4px);
  grid-template-rows: repeat(3, 4px);
  gap: 2px;
  padding: 2px;
  cursor: grab;
}

.noise-grip .dot {
  width: 3px;
  height: 3px;
  border-radius: 9999px;
  background: var(--ui-muted);
}

.noise-grip:active {
  cursor: grabbing;
}

.noise-card.dragging {
  opacity: 0.6;
  transform: translateY(-2px);
}

.noise-drop-indicator {
  height: 2px;
  border-radius: 999px;
  background: var(--ui-accent);
  margin: 4px 0;
}

.noise-image-block {
  grid-column: 1 / -1;
}

.noise-disabled {
  opacity: 0.6;
}

.angle-disabled {
  opacity: 0.6;
  pointer-events: none;
}

.color-swatch {
  width: 18px;
  height: 18px;
  border-radius: 4px;
  border: 1px solid var(--ui-border);
  display: inline-block;
}

.color-modal {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.color-sv-wrapper {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  max-height: 240px;
  border-radius: 10px;
  overflow: hidden;
  touch-action: none;
  cursor: crosshair;
}

.color-sv-canvas {
  width: 100%;
  height: 100%;
  display: block;
}

.color-sv-cursor {
  position: absolute;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2.5px solid #fff;
  box-shadow: 0 1px 5px rgba(0, 0, 0, 0.55);
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.color-hue-wrapper {
  position: relative;
  width: 100%;
  height: 32px;
  border-radius: 16px;
  overflow: visible;
  touch-action: none;
  cursor: ew-resize;
}

.color-hue-canvas {
  width: 100%;
  height: 100%;
  display: block;
  border-radius: 16px;
}

.color-hue-cursor {
  position: absolute;
  top: 50%;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 3px solid #fff;
  box-shadow: 0 1px 5px rgba(0, 0, 0, 0.45);
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.color-hex-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.color-preview-swatch {
  width: 46px;
  height: 46px;
  border-radius: 10px;
  border: 1px solid var(--ui-border);
  flex: 0 0 auto;
}

.color-hex-input-wrap {
  display: flex;
  align-items: center;
  flex: 1;
  height: 46px;
  background: var(--ui-panel-alt);
  border: 1px solid var(--ui-border);
  border-radius: 10px;
  padding: 0 14px;
  gap: 3px;
}

.color-hex-symbol {
  color: var(--ui-muted);
  font-family: monospace;
  font-size: 17px;
  line-height: 1;
  user-select: none;
}

.color-modal-hex {
  border: none;
  background: transparent;
  color: var(--ui-text);
  font-family: monospace;
  font-size: 17px;
  width: 100%;
  outline: none;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.color-modal-actions {
  display: flex;
  gap: 10px;
}

.color-modal-actions button {
  flex: 1;
  height: 46px;
  border: 1px solid var(--ui-border);
  background: var(--ui-panel-alt);
  color: var(--ui-text);
  font-size: 15px;
  border-radius: 10px;
  cursor: pointer;
}

.color-modal-apply {
  background: #ef4444 !important;
  color: var(--ui-on-danger) !important;
  border-color: #ef4444 !important;
  font-weight: 600;
}

.color-modal-cancel:hover {
  border-color: var(--ui-accent);
  color: var(--ui-accent);
}

.pane {
  width: var(--pane-left-width);
  flex: 0 0 auto;
  transition: width 0.2s ease;
  overflow: hidden;
}

.pane-header {
  position: relative;
}

.pane-header-left {
  padding-right: 48px;
}

.pane-header-right {
  padding-left: 48px;
}

.pane-header-left .pane-meta {
  margin-right: 32px;
}

.pane-header-right .pane-title {
  margin-left: 24px;
}

.pane-toggle {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 24px;
  height: 24px;
  border: 1px solid var(--ui-border);
  border-radius: 9999px;
  background: var(--ui-bg);
  color: var(--ui-text-2);
  font-size: 12px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1), color 0.2s ease, border-color 0.2s ease;
}

.pane-toggle:hover {
  color: var(--ui-accent);
  border-color: var(--ui-accent);
}

.pane-toggle-left {
  right: 8px;
}

.pane-toggle-right {
  left: 8px;
}

.pane-toggle-bottom {
  left: 50%;
  right: auto;
  transform: translate(-50%, -50%);
}

.pane-left {
  width: var(--pane-left-width);
}

.pane-right {
  width: var(--pane-right-width);
}

.pane-body {
  min-height: 0;
}

.right-panel-section-scroll {
  min-height: 0;
}

#pens-section {
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 3 1 0%;
  overflow: hidden;
}

#pens-section:has(#pens-global-section.collapsed) {
  flex: 0 0 auto;
}

#pens-global-section {
  margin: 0;
  padding-top: 0;
  border-top: none;
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1 1 0%;
}

#pens-global-section.collapsed {
  flex: 0 0 auto;
}

#pens-section-body {
  min-height: 0;
  display: flex;
  flex-direction: column;
  flex: 1 1 0%;
  overflow: hidden;
}

#pens-section-body > div:not(#pen-list) {
  flex-shrink: 0;
}

#pen-list {
  min-height: 0;
  overflow-y: auto;
  padding-right: 2px;
  flex: 1 1 0%;
}

#auto-colorization-wrap {
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1 1 0%;
  overflow: hidden;
}

#auto-colorization-wrap:has(#auto-colorization-section.collapsed) {
  flex: 0 0 auto;
}

.pane-collapsed {
  width: var(--pane-collapsed-width);
}

.auto-collapsed .pane:not(.pane-force-open) {
  width: var(--pane-collapsed-width);
}

.pane-collapsed .pane-body,
.auto-collapsed .pane:not(.pane-force-open) .pane-body {
  display: none;
}

.pane-collapsed .pane-title,
.pane-collapsed .pane-meta,
.auto-collapsed .pane:not(.pane-force-open) .pane-title,
.auto-collapsed .pane:not(.pane-force-open) .pane-meta {
  display: none;
}

.pane-collapsed .pane-header button:not(.pane-toggle),
.auto-collapsed .pane:not(.pane-force-open) .pane-header button:not(.pane-toggle) {
  display: none;
}

.pane-collapsed .pane-toggle,
.auto-collapsed .pane:not(.pane-force-open) .pane-toggle {
  transform: translateY(-50%) rotate(180deg);
}

.pane-resizer {
  width: 6px;
  flex: 0 0 auto;
  cursor: col-resize;
  touch-action: none; /* Q27: pointer-event drag, a finger on the strip must not pan the page */
  background: transparent;
  position: relative;
  z-index: 15;
}

.pane-resizer::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--ui-panel);
  opacity: 0;
  transition: opacity 0.2s ease;
}

.pane-resizer.active::before {
  opacity: 0.6;
}

@media (hover: hover) {
  .pane-resizer:hover::before {
  opacity: 0.6;
}
}

.bottom-pane {
  height: var(--bottom-pane-height);
  transition: height 0.2s ease;
  overflow: hidden;
  position: relative;
}

.bottom-pane-header {
  position: relative;
}

.bottom-pane-footer {
  margin-top: auto;
}

.bottom-pane-collapsed {
  height: 36px;
}

.bottom-pane-collapsed .bottom-pane-body,
.bottom-pane-collapsed .bottom-pane-footer {
  display: none;
}

.bottom-pane-collapsed .pane-toggle-bottom {
  transform: translate(-50%, -50%) rotate(180deg);
}

.bottom-resizer {
  height: 6px;
  cursor: row-resize;
  touch-action: none; /* Q27 */
  background: transparent;
  position: relative;
  z-index: 25;
}

.bottom-resizer::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--ui-panel);
  opacity: 0;
  transition: opacity 0.2s ease;
}

.bottom-resizer.active::before {
  opacity: 0.6;
}

@media (hover: hover) {
  .bottom-resizer:hover::before {
  opacity: 0.6;
}
}

/* Q27 (round 2): a finger needs a bigger hit strip than the 6 px bar. Chromium retargets a touch on a thin
 * element to the nearest node with a mouse handler (the canvas); the resizers now carry a no-op mousedown
 * handler (workspace.js, bottom-pane.js), which keeps a finger on the 6 px bar, plus a 24 px strip (the §1.5 floor)
 * around the middle of the bar. The strips stay clear of everything tappable and of the canvas share:
 * - side resizers: the element is 24 px wide with negative margins (7 px over the pane edge, the 6 px bar and 11 px over
 *   the canvas edge), so layout is unchanged. Only the bar spans the full height. The 24 px strip is a 120 px window
 *   around the vertical centre of the bar: it is far below the pane toggles and costs the canvas share 0.1 point (iPad
 *   landscape docked stays 45.9 against the 45 floor). Its edges are measured, not guessed: the canvas part ends where the
 *   floating tool rail begins (10 px from the canvas edge, the rail's own padding holds the 11th px), and the pane part
 *   is 7 px because a Paint Bucket angle chip, the Scene3D law-info buttons and the Layers rows reach to 7 px, 7 px and
 *   11 px of the pane edge with a 44 px hit area that a wider bite would cut below 44. The element stops above the
 *   bottom safe-area band;
 * - bottom resizer: reaches DOWN into the empty bottom pane header (labels only), never up over the canvas, the
 *   canvas HUD or the tool rail's overflow button, so a canvas tap above the bar still reaches the canvas
 *   (TUX-051). The clip-path leaves a notch for the centred pane toggle.
 * [data-touch-target] marks the three bars for the touch audit (they are aria-hidden and have no pointer cursor).
 * Mouse layouts (pointer: fine) keep the bare 6 px bar. */
@media (pointer: coarse) {
  #left-resizer,
  #right-resizer {
    --rz-top: calc(50% - 60px);
    --rz-bot: calc(50% + 60px);
    width: 24px;
    margin-bottom: var(--safe-bottom, 0px);
  }
  #left-resizer {
    margin-inline: -7px -11px;
    clip-path: polygon(7px 0, 13px 0, 13px var(--rz-top), 100% var(--rz-top), 100% var(--rz-bot), 13px var(--rz-bot), 13px 100%, 7px 100%, 7px var(--rz-bot), 0 var(--rz-bot), 0 var(--rz-top), 7px var(--rz-top));
  }
  #right-resizer {
    margin-inline: -11px -7px;
    clip-path: polygon(11px 0, 17px 0, 17px var(--rz-top), 100% var(--rz-top), 100% var(--rz-bot), 17px var(--rz-bot), 17px 100%, 11px 100%, 11px var(--rz-bot), 0 var(--rz-bot), 0 var(--rz-top), 11px var(--rz-top));
  }
  #left-resizer::before { inset: 0 auto 0 7px; width: 6px; }
  #right-resizer::before { inset: 0 auto 0 11px; width: 6px; }
  .bottom-resizer::after {
    content: '';
    position: absolute;
    inset-inline: 0;
    inset-block: 0 -38px;
    clip-path: polygon(0 0, 100% 0, 100% 100%, calc(50% + 26px) 100%, calc(50% + 26px) 6px, calc(50% - 26px) 6px, calc(50% - 26px) 100%, 0 100%);
  }
}

.layer-grip {
  width: 14px;
  color: var(--ui-muted);
  cursor: grab;
  font-size: 10px;
  letter-spacing: 1px;
  user-select: none;
}

.layer-item.dragging {
  opacity: 0.6;
  transform: translateY(-2px);
}

.layer-drop-indicator {
  height: 2px;
  background: var(--ui-accent);
  margin: 6px 0;
  border-radius: 9999px;
}

#algo-sticky {
  background: var(--ui-panel);
}

.dual-range {
  position: relative;
  height: 20px;
}

.dual-range input[type='range'] {
  position: absolute;
  left: 0;
  top: 8px;
  width: 100%;
  margin: 0;
}

#modal-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgb(var(--vectura-bg-rgb) / 0.65);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  z-index: 100;
}

#modal-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.modal-card {
  width: min(560px, calc(100% - 32px));
  max-height: 80vh;
  overflow: auto;
  background: var(--ui-panel);
  border: 1px solid var(--ui-border);
  padding: 16px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
}

.modal-card.modal-card--export {
  width: max(80vw, 1080px);
  height: max(80vh, 720px);
  max-width: calc(100vw - 32px);
  max-height: calc(100vh - 32px); max-height: calc(var(--app-vh) - 32px);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  padding: 0;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.modal-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  color: var(--ui-accent);
}

.modal-close {
  border: 1px solid var(--ui-border);
  background: var(--ui-bg);
  color: var(--ui-muted);
  width: 24px;
  height: 24px;
  border-radius: 9999px;
  cursor: pointer;
}

.modal-close:hover {
  color: var(--ui-accent);
  border-color: var(--ui-accent);
}

.modal-card--export .modal-header {
  margin: 0;
  padding: 16px 18px 12px;
  border-bottom: 1px solid var(--ui-border);
}

.modal-card--export .modal-body {
  min-height: 0;
  flex: 1;
  display: flex;
}

.modal-text {
  font-size: 12px;
  line-height: 1.6;
  color: var(--ui-text-2);
  margin-bottom: 12px;
}

.modal-illustrations {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.modal-illustrations.scrollable {
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  max-height: 360px;
  overflow: auto;
  padding-right: 4px;
}

.modal-illustration {
  border: 1px solid var(--ui-border);
  padding: 10px;
  background: var(--ui-bg);
}

.modal-illustration svg {
  width: 100%;
  height: auto;
  display: block;
}

.modal-ill-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  color: var(--ui-muted);
  margin-bottom: 6px;
}

.modal-ill-desc {
  font-size: 10px;
  line-height: 1.4;
  color: var(--ui-text-2);
  margin-bottom: 8px;
}

.modal-section {
  margin-bottom: 16px;
}

.export-modal {
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1;
  width: 100%;
}

.export-modal-body {
  display: flex;
  flex: 1;
  min-height: 0;
  width: 100%;
}

.export-modal-preview {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(circle at top right, rgb(var(--vectura-border-rgb) / 0.18), transparent 40%),
    linear-gradient(180deg, rgb(var(--vectura-bg-rgb) / 0.94), rgb(var(--vectura-bg-rgb) / 0.98));
  border-left: 1px solid var(--ui-border);
}

.export-modal-nav {
  flex: 0 0 188px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 14px 8px;
  background: var(--ui-panel);
  border-right: 1px solid var(--ui-border);
  overflow-y: auto;
}

.export-nav-group {
  font-size: 9px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ui-muted);
  padding: 12px 12px 6px;
}

.export-nav-group:first-child {
  padding-top: 4px;
}

.export-nav-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  background: transparent;
  border: 1px solid transparent;
  color: var(--ui-text-2);
  font-size: 12px;
  letter-spacing: 0.02em;
  cursor: pointer;
  text-align: left;
  width: 100%;
  transition: background-color 0.12s ease, color 0.12s ease, border-color 0.12s ease;
}

.export-nav-item:hover {
  background: var(--ui-ctrl-hov);
  color: var(--ui-text);
}

.export-nav-item.is-active {
  background: rgb(var(--vectura-accent-rgb) / 0.12);
  color: var(--ui-accent);
  border-color: rgb(var(--vectura-accent-rgb) / 0.35);
}

.export-nav-label {
  flex: 1;
  min-width: 0;
}

.export-nav-dot {
  width: 7px;
  height: 7px;
  border-radius: 9999px;
  background: transparent;
  transition: background-color 0.15s ease, box-shadow 0.15s ease;
  flex-shrink: 0;
}

/*
 * Three-state dot:
 *   bypassed → grey  (step disabled)
 *   applied  → green (step on, defaults)
 *   modified → orange (step on, user-edited)
 * No dot for sections without an apply concept (Output, Stats).
 */
.export-nav-item[data-dot-state="bypassed"] .export-nav-dot {
  background: var(--ui-muted, #71717a);
}

.export-nav-item[data-dot-state="applied"] .export-nav-dot {
  background: #34d399;
  box-shadow: 0 0 6px rgba(52, 211, 153, 0.5);
}

.export-nav-item[data-dot-state="modified"] .export-nav-dot {
  background: #60a5fa;
  box-shadow: 0 0 6px rgba(96, 165, 250, 0.5);
}

.export-nav-item[data-dot-state="increasing"] .export-nav-dot {
  background: #f97316;
  box-shadow: 0 0 6px rgba(249, 115, 22, 0.5);
}

.export-preview-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--ui-border);
}

.export-preview-toolbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.export-preview-toolbar button,
.export-modal-footer button,
.export-settings-section-summary {
  border: 1px solid var(--ui-border);
  background: var(--ui-panel-alt);
  color: var(--ui-text);
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.export-preview-toolbar button,
.export-modal-footer button {
  padding: 7px 12px;
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.export-preview-toolbar button:hover,
.export-modal-footer button:hover,
.export-settings-section-summary:hover {
  background: var(--ui-ctrl-hov);
  border-color: var(--ui-border-hi);
}

.export-preview-toolbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.export-preview-mode-label {
  font-size: 11px;
  color: var(--ui-text-2);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  white-space: nowrap;
}

.export-preview-stage {
  position: relative;
  flex: 1;
  min-height: 0;
  padding: 16px;
}

.export-preview-canvas-wrap {
  position: relative;
  width: 100%;
  height: 100%;
  border: 1px solid var(--ui-border);
  background:
    linear-gradient(45deg, rgb(var(--vectura-border-rgb) / 0.18) 25%, transparent 25%, transparent 75%, rgb(var(--vectura-border-rgb) / 0.18) 75%),
    linear-gradient(45deg, rgb(var(--vectura-border-rgb) / 0.18) 25%, transparent 25%, transparent 75%, rgb(var(--vectura-border-rgb) / 0.18) 75%),
    var(--ui-workspace);
  background-size: 24px 24px;
  background-position: 0 0, 12px 12px;
  overflow: hidden;
  cursor: grab;
}

.export-preview-canvas-wrap.is-dragging {
  cursor: grabbing;
}

.export-preview-canvas {
  width: 100%;
  height: 100%;
  display: block;
}

.export-preview-legend {
  position: absolute;
  left: 20px;
  bottom: 18px;
  width: min(260px, calc(100% - 40px));
  border: 1px solid var(--ui-border);
  background: rgb(var(--vectura-panel-rgb) / 0.94);
  backdrop-filter: blur(10px);
  padding: 10px 12px;
  pointer-events: none;
}

.export-preview-legend.hidden {
  display: none;
}

.export-preview-legend-title {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--ui-accent);
  margin-bottom: 8px;
}

.export-preview-legend-gradient {
  position: relative;
  width: 100%;
  height: 8px;
  border-radius: 9999px;
  border: 1px solid rgb(var(--vectura-border-rgb) / 0.8);
}

.export-preview-legend-labels {
  margin-top: 6px;
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 10px;
  color: var(--ui-text-2);
}

.export-preview-legend-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.export-preview-legend-row .export-preview-legend-title {
  margin-bottom: 0;
}

.export-legend-gear-btn {
  background: none;
  border: 1px solid var(--ui-border);
  color: var(--ui-muted);
  width: 22px;
  height: 22px;
  border-radius: 4px;
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s ease, border-color 0.15s ease;
  pointer-events: auto;
  flex-shrink: 0;
}

.export-legend-gear-btn:hover {
  color: var(--ui-accent);
  border-color: var(--ui-accent);
}

/* Line Sort legend Play/Pause + gradient playhead */
.export-legend-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}
.export-legend-play-btn.is-playing {
  color: var(--ui-accent);
  border-color: var(--ui-accent);
}
.export-legend-play-btn .pause-icon,
.export-legend-play-btn.is-playing .play-icon,
[data-ui-skin] .draw-order-play .pause-icon,
[data-ui-skin] .draw-order-play.is-playing .play-icon {
  display: none;
}
.export-legend-play-btn.is-playing .pause-icon,
[data-ui-skin] .draw-order-play.is-playing .pause-icon {
  display: inline;
}
[data-ui-skin] .draw-order-play.is-playing {
  color: var(--ui-accent);
}
.export-preview-legend-playhead {
  position: absolute;
  top: 50%;
  width: 10px;
  height: 10px;
  border-radius: 9999px;
  background: var(--ui-text, #fff);
  box-shadow: 0 0 0 2px rgb(var(--vectura-panel-rgb) / 0.9);
  transform: translate(-50%, -50%);
  pointer-events: none;
}
.export-preview-legend-playhead.hidden {
  display: none;
}

.export-legend-settings {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--ui-border);
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: auto;
}

.export-legend-settings.hidden {
  display: none;
}

.export-legend-setting {
  display: flex;
  align-items: center;
  gap: 8px;
}

.export-legend-setting-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ui-muted);
  white-space: nowrap;
  min-width: 76px;
}

.export-legend-setting .color-thickness-pill {
  min-height: 20px;
  min-width: 60px;
  max-width: 80px;
  font-size: 9px;
  border-radius: 9999px;
  text-align: center;
  padding: 2px 8px;
}

.export-legend-setting input[type="range"] {
  flex: 1;
  min-width: 0;
}

.export-preview-mode-select {
  border: 1px solid var(--ui-border);
  background: var(--ui-panel-alt);
  color: var(--ui-text);
  padding: 6px 10px;
  font-size: 11px;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

.export-preview-mode-select:hover {
  background: var(--ui-ctrl-hov);
  border-color: var(--ui-border-hi);
}

.export-preview-mode-select:focus {
  outline: none;
  border-color: var(--ui-accent);
}

.export-info-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 13px;
  height: 13px;
  border: 1px solid var(--ui-border);
  border-radius: 9999px;
  margin-left: 4px;
  font-size: 9px;
  line-height: 1;
  color: var(--ui-muted);
  background: var(--ui-panel);
  cursor: pointer;
  vertical-align: middle;
  padding: 0;
  box-sizing: content-box;
  flex-shrink: 0;
  transition: color 0.15s ease, border-color 0.15s ease, background-color 0.15s ease;
}

.export-info-btn:hover {
  color: var(--ui-accent);
  border-color: var(--ui-accent);
}

.export-info-btn.active {
  color: var(--ui-accent);
  border-color: var(--ui-accent);
  background: rgb(var(--vectura-accent-rgb) / 0.1);
}

/*
 * Info popover: floats above the modal anchored to its (i) button. Lives on
 * document.body so it escapes all section/flex clipping. JS positions
 * `left/top` based on the button's bounding rect.
 */
.export-info-popover {
  position: fixed;
  z-index: 9999;
  max-width: 280px;
  min-width: 180px;
  padding: 10px 12px;
  font-size: 11px;
  line-height: 1.55;
  color: var(--ui-text-2);
  background: var(--ui-panel, var(--ui-panel-alt, #1c1c1f));
  border: 1px solid var(--ui-border);
  border-left: 2px solid var(--ui-accent);
  border-radius: var(--radius-sm, 4px);
  box-shadow: 0 8px 24px rgb(0 0 0 / 0.45);
  pointer-events: auto;
}

.export-info-popover-title {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--ui-text);
  margin-bottom: 4px;
}

.export-info-popover-body {
  color: var(--ui-text-2);
}

.export-modal-settings .control-label:has(.export-info-btn) {
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
}

.export-modal-settings {
  flex: 0 0 380px;
  min-width: 320px;
  max-width: 460px;
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--ui-panel-alt, var(--ui-panel));
}

/*
 * Impact Preview pane — pinned to the bottom of the settings column, below
 * the scroll area. Replaces the legacy Stats section (which has been removed
 * from the sidebar) and gives the user a live readout of how their settings
 * affect the export. Updates on every input/change inside any section.
 */
.export-impact-preview {
  flex-shrink: 0;
  border-top: 1px solid var(--ui-border);
  padding: 14px 16px 16px;
  background: rgb(var(--vectura-bg-rgb, 9 9 11) / 0.4);
}

.export-impact-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.export-impact-head h4 {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ui-muted);
  margin: 0;
  flex: 1;
}

.export-impact-actions:empty {
  display: none;
}

.export-impact-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1px;
  background: var(--ui-border);
  border: 1px solid var(--ui-border);
  border-radius: var(--radius-sm, 4px);
  overflow: hidden;
}

.export-impact-cell {
  background: var(--ui-panel-alt);
  padding: 9px 10px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.export-impact-label {
  font-size: 9px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ui-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.export-impact-val {
  font-size: 15px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--ui-text);
  line-height: 1.1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.export-impact-val.accent {
  color: var(--ui-accent);
}

.export-impact-val small {
  font-size: 9px;
  font-weight: 400;
  color: var(--ui-muted);
  margin-left: 2px;
}

.export-impact-delta {
  font-size: 9px;
  letter-spacing: 0.04em;
  color: var(--ui-muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  min-height: 11px;
}

.export-impact-delta[data-trend="down"] {
  color: #34d399;
}

.export-impact-delta[data-trend="up"] {
  color: #f97316;
}

.export-impact-delta:empty::before {
  content: '\00a0';
}

@media (max-width: 1100px) {
  .export-impact-preview {
    display: none;
  }
}

.export-settings-scroll {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 0;
  display: flex;
  flex-direction: column;
}

/*
 * Sidebar layout: each .export-settings-section is a full-screen "tab".
 * Only the .is-active section is rendered; the rest stay in the DOM (so live
 * controls keep their event bindings) but are display:none.
 */
.export-settings-section {
  display: none;
  flex-direction: column;
  padding: 18px 20px 20px;
  gap: 14px;
}

.export-settings-section.is-active {
  display: flex;
}

.export-settings-section-head {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  border-bottom: 1px solid var(--ui-border);
  padding-bottom: 12px;
}

.export-settings-section-head-text {
  flex: 1;
  min-width: 0;
}

.export-settings-section-head-actions {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  padding-top: 2px;
}

.export-settings-section-head-actions:empty {
  display: none;
}

.export-settings-section-head h3 {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--ui-text);
  margin: 0 0 4px;
}

.export-settings-section-head p {
  font-size: 11px;
  line-height: 1.55;
  color: var(--ui-text-2);
  margin: 0;
}

.export-section-apply {
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ui-text-2);
}

.export-settings-section-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
}


/* === Migrated from legacy CSS (Unit 2.2c: export modal optimization cards + per-card layout + info-btn, 2026-05-20) === */

/*
 * Inside the modal, optimization cards are now 1-per-tab with the title +
 * Apply lifted into the section head. Strip the card chrome so each tab
 * feels flush instead of nested-card-in-card.
 */
.export-modal-settings .optimization-card {
  background: transparent;
  border: none;
  padding: 0;
  margin: 0;
}

.export-modal-settings .optimization-card .optimization-controls {
  padding: 0;
}

/*
 * Toggle-row alignment: harmonize Export Optimized (in .optimization-row)
 * with Remove Hidden Geometry / Plotter Optimization (in .optimization-control)
 * so every toggle row reads:
 *   [label] [info-i]                          [toggle]
 *
 * The default `.optimization-row > :last-child { flex: 1 }` rule was written
 * for selects and full-width inputs; it stretches a fixed-width pill toggle
 * to fill the row. Override for .sw-toggle specifically.
 */
.export-modal-settings .optimization-row {
  align-items: center;
  gap: 12px;
}


.export-modal-settings .optimization-row > .sw-toggle {
  flex: 0 0 auto;
  margin-left: auto;
  align-self: center;
}

.export-modal-settings .optimization-row > .control-label,
.export-modal-settings .optimization-row > label:first-child {
  flex: 0 0 auto;
}

/*
 * Two-line .optimization-control with a sw-toggle (Remove Hidden Geometry,
 * Plotter Optimization) collapses to a single row.
 */
.export-modal-settings .optimization-control:has(> .sw-toggle) {
  display: flex;
  align-items: center;
  gap: 12px;
}

.export-modal-settings .optimization-control:has(> .sw-toggle) > div {
  flex: 1;
  min-width: 0;
  margin-bottom: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  justify-content: flex-start;
}

/* Drop the redundant ON/OFF status text — toggle visual conveys it. */
.export-modal-settings .optimization-control:has(> .sw-toggle) > div > span {
  display: none;
}

.export-modal-settings .optimization-control:has(> .sw-toggle) > .sw-toggle {
  flex: 0 0 auto;
  margin-left: auto;
  align-self: center;
}

/*
 * Info-i sits flush against the label text it documents. The default
 * `margin-left: 4px` in .export-info-btn already does this; keep it tight
 * and ensure it doesn't pick up any flex stretching from parent rows.
 */
.export-modal-settings .export-info-btn {
  flex: 0 0 auto;
}

/*
 * Match the rest of the app's corner rounding. The skin tokens use
 * --radius-sm: 4px for inputs and buttons; apply that scope-locally so we
 * don't disturb other contexts.
 */
.export-modal-settings select,
.export-modal-settings input[type="text"],
.export-modal-settings input[type="number"],
.export-modal-settings .value-chip,
.export-modal-settings .ctrl-slider,
.export-modal-settings button:not(.export-primary):not(.sw-toggle):not(.optimization-grip):not(.export-info-btn) {
  border-radius: var(--radius-sm, 4px);
}

.export-modal-footer button {
  border-radius: var(--radius-sm, 4px);
}

.export-preview-toolbar button,
.export-preview-mode-select {
  border-radius: var(--radius-sm, 4px);
}

.export-modal-settings .optimization-panel {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.export-modal-settings .optimization-row {
  align-items: flex-start;
}

/*
 * Stretch the trailing input/select to fill the row — but exclude .sw-toggle,
 * which has its own fixed pill geometry and should sit on the right via the
 * harmonized toggle-row rules above.
 */
.export-modal-settings .optimization-row > :last-child:not(.sw-toggle) {
  flex: 1;
  min-width: 0;
}

.export-modal-settings .optimization-controls {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.export-modal-footer {
  border-top: 1px solid var(--ui-border);
  padding: 12px 16px;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  background: var(--ui-panel);
}

.export-modal-footer .export-primary {
  background: var(--ui-accent);
  color: var(--ui-bg);
  border-color: var(--ui-accent);
}

.export-modal-footer .export-primary:hover {
  background: rgb(var(--vectura-accent-rgb) / 0.86);
}

@media (max-width: 1100px) {
  .modal-card.modal-card--export {
    width: calc(100vw - 24px);
    height: calc(100vh - 24px); height: calc(var(--app-vh) - 24px);
  }

  .export-modal-body {
    flex-direction: column;
  }

  .export-modal-nav {
    flex: 0 0 auto;
    flex-direction: row;
    flex-wrap: wrap;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 8px;
    gap: 4px;
    border-right: none;
    border-bottom: 1px solid var(--ui-border);
  }

  .export-nav-group {
    display: none;
  }

  .export-nav-item {
    width: auto;
    flex: 0 0 auto;
    padding: 7px 10px;
    border-radius: 4px;
  }

  .export-modal-preview {
    min-height: 280px;
    border-left: none;
    border-bottom: 1px solid var(--ui-border);
    order: -1;
  }

  .export-modal-settings {
    flex: 1 1 auto;
    width: 100%;
    min-width: 0;
    max-width: none;
    max-height: 48%;
  }
}

.petal-designer-window {
  position: fixed;
  z-index: 95;
  width: min(720px, calc(100vw - 32px));
  max-height: calc(100vh - 32px); max-height: calc(var(--app-vh) - 32px);
  overflow: auto;
  border: 1px solid var(--ui-border-hi);
  border-radius: 14px;
  background-color: var(--ui-panel-alt);
  background-image:
    radial-gradient(circle at top right, rgba(56, 189, 248, 0.12), transparent 48%),
    linear-gradient(rgb(var(--vectura-panel-rgb) / 0.92), rgb(var(--vectura-bg-rgb) / 0.95)),
    linear-gradient(0deg, rgba(148, 163, 184, 0.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(148, 163, 184, 0.08) 1px, transparent 1px);
  background-size: auto, auto, 20px 20px, 20px 20px;
  box-shadow: 0 28px 80px rgb(var(--vectura-bg-rgb) / 0.7);
  backdrop-filter: blur(2px);
}

.petal-designer-window.dragging {
  cursor: grabbing;
}

.petal-designer-inline-wrap {
  width: 100%;
}

.petal-designer-inline {
  position: relative;
  left: auto !important;
  top: auto !important;
  width: 100%;
  max-height: none;
  overflow: hidden;
  z-index: 1;
  box-shadow: 0 14px 34px rgb(var(--vectura-bg-rgb) / 0.45);
}

.petal-designer-inline .petal-designer-header {
  cursor: default;
  position: static;
}

.petal-designer-inline.focused {
  border-color: #22d3ee;
  box-shadow: 0 0 0 1px rgba(34, 211, 238, 0.55), 0 14px 34px rgb(var(--vectura-bg-rgb) / 0.45);
}

.petal-designer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px 12px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--ui-border-hi);
  background: rgb(var(--vectura-bg-rgb) / 0.86);
  cursor: grab;
  position: sticky;
  top: 0;
  z-index: 2;
  touch-action: none;
}

.petal-designer-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  color: #bae6fd;
  white-space: nowrap;
}

.petal-designer-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

/* Pen/edit tools sit directly above the visualizer canvas. */
.petal-designer-tools {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}

.petal-tool-btn,
.petal-close,
.petal-popout,
.petal-popin,
.petal-hist,
.petal-copy-btn {
  border: 1px solid var(--ui-border-hi);
  background: var(--ui-panel-alt);
  color: var(--ui-text);
  min-width: 28px;
  height: 28px;
  border-radius: 8px;
  font-size: 11px;
  line-height: 1;
  padding: 0 8px;
  flex-shrink: 0;
}

.petal-tool-btn:hover,
.petal-close:hover,
.petal-popout:hover,
.petal-popin:hover,
.petal-hist:hover,
.petal-copy-btn:hover {
  border-color: #67e8f9;
  color: #cffafe;
}

.petal-tool-btn.active {
  border-color: #22d3ee;
  color: #22d3ee;
  background: rgba(34, 211, 238, 0.12);
}

.petal-designer-controls {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px;
  align-items: end;
  padding: 12px;
  border-bottom: 1px solid var(--ui-border-hi);
  background: rgb(var(--vectura-bg-rgb) / 0.74);
}

.petal-designer-controls label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--ui-muted);
}

.petal-designer-controls select {
  border: 1px solid var(--ui-border-hi);
  background: var(--ui-bg);
  color: var(--ui-text);
  padding: 6px 8px;
  font-size: 11px;
}

.petal-shade-toggle {
  flex-direction: row !important;
  align-items: center;
  justify-content: flex-start;
  align-self: center;
}

.petal-shade-toggle input {
  accent-color: #22d3ee;
}

.petal-designer-structure {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
  align-items: end;
  padding: 10px 12px;
  border-bottom: 1px solid var(--ui-border-hi);
  background: rgb(var(--vectura-bg-rgb) / 0.68);
}

.petal-designer-structure label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ui-muted);
}

.petal-designer-structure select {
  border: 1px solid var(--ui-border-hi);
  background: var(--ui-bg);
  color: var(--ui-text);
  padding: 6px 8px;
  font-size: 11px;
}

.petal-designer-transition {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  align-items: end;
  padding: 10px 12px;
  border-bottom: 1px solid var(--ui-border-hi);
  background: rgb(var(--vectura-bg-rgb) / 0.62);
}

.petal-designer-transition label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ui-muted);
}

.petal-transition-lock {
  flex-direction: row !important;
  align-items: center;
  gap: 8px;
  align-self: center;
}

.petal-transition-lock input {
  accent-color: #22d3ee;
}

.petal-designer-transition input[type='range'] {
  width: 100%;
}

.petal-designer-visualizer {
  padding: 12px;
  border-top: 1px solid var(--ui-border-hi);
  background: rgb(var(--vectura-bg-rgb) / 0.62);
}

.petal-visualizer-mode {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1 1 auto;
  min-width: 0;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--ui-muted);
}

.petal-visualizer-mode > span {
  white-space: nowrap;
  flex-shrink: 0;
}

.petal-visualizer-mode select {
  border: 1px solid var(--ui-border-hi);
  background: var(--ui-bg);
  color: var(--ui-text);
  padding: 6px 8px;
  font-size: 11px;
  min-width: 0;
  max-width: 100%;
  text-overflow: ellipsis;
  overflow: hidden;
}

.petal-designer-grid {
  padding: 12px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.petal-designer-grid.is-side-by-side {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.petal-cell {
  border: 1px solid var(--ui-border-hi);
  border-radius: 10px;
  padding: 10px;
  background: rgb(var(--vectura-bg-rgb) / 0.72);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.petal-cell-title {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: #7dd3fc;
}

.petal-cell canvas {
  width: 100%;
  max-width: 100%;
  border: 1px solid var(--ui-border-hi);
  border-radius: 8px;
  background: var(--ui-panel-alt);
  display: block;
  touch-action: none;
}

.petal-designer-profile-editor {
  padding: 12px;
  border-top: 1px solid var(--ui-border-hi);
  background: rgb(var(--vectura-bg-rgb) / 0.62);
}

/* Profile editor shows ONE side at a time; the Inner|Outer toggle picks which.
   Both cards stay mounted (their thumbnail canvases / sliders stay live) and the
   inactive one is hidden. There is no global `.hidden` rule, so this explicit,
   higher-specificity rule is what actually hides the card. */
.petal-profile-editor-stack {
  display: grid;
  gap: 10px;
}

.petal-profile-editor-card.hidden {
  display: none;
}

.petal-profile-side-toggle {
  display: inline-flex;
  border: 1px solid var(--ui-border-hi);
  border-radius: 8px;
  overflow: hidden;
}

.petal-profile-side-btn {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--ui-text-muted, #8b93a7);
  font: inherit;
  font-size: 11px;
  padding: 4px 14px;
  cursor: pointer;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  transition: background 120ms ease, color 120ms ease;
}

.petal-profile-side-btn + .petal-profile-side-btn {
  border-left: 1px solid var(--ui-border-hi);
}

.petal-profile-side-btn:hover {
  color: #cbd5e1;
}

.petal-profile-side-btn.is-active {
  background: rgba(34, 211, 238, 0.16);
  color: #7dd3fc;
}

.petal-profile-side-toggle.is-locked {
  opacity: 0.5;
  pointer-events: none;
}

.petal-profile-editor-card {
  border: 1px solid var(--ui-border-hi);
  border-radius: 10px;
  padding: 10px;
  background: rgb(var(--vectura-bg-rgb) / 0.72);
  display: grid;
  gap: 8px;
}

.petal-profile-editor-card.is-active {
  border-color: #22d3ee;
  box-shadow: 0 0 0 1px rgba(34, 211, 238, 0.3);
}

.petal-profile-editor-card-title {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: #7dd3fc;
}

.petal-profile-editor-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.petal-profile-editor-footer {
  margin-top: 10px;
  display: flex;
  justify-content: flex-end;
}

/* Named petal profile thumbnail strip inside the profile editor cards */
.petal-ring-shape-selector {
  display: grid;
  gap: 6px;
}

.petal-ring-shape-selector-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ui-text-muted, #8b93a7);
}

.petal-profile-editor-thumbs {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 3px;
}

/* Advanced per-ring param accordion */
.petal-ring-param-accordion {
  border: 1px solid var(--ui-border-hi, rgba(255,255,255,0.08));
  border-radius: 6px;
  overflow: hidden;
}

.petal-ring-param-accordion-summary {
  padding: 5px 8px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ui-text-muted, #8b93a7);
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 4px;
  user-select: none;
}

.petal-ring-param-accordion-summary::-webkit-details-marker { display: none; }
.petal-ring-param-accordion-summary::before {
  content: '▶';
  font-size: 7px;
  transition: transform 120ms ease;
}
.petal-ring-param-accordion[open] .petal-ring-param-accordion-summary::before {
  transform: rotate(90deg);
}

.petal-ring-param-stack {
  padding: 6px 8px 8px;
  display: grid;
  gap: 2px;
  border-top: 1px solid var(--ui-border-hi, rgba(255,255,255,0.08));
}

.petal-ring-param-row {
  font-size: 10px;
}

.petal-designer-shading {
  padding: 12px;
  border-top: 1px solid var(--ui-border-hi);
  background: rgb(var(--vectura-bg-rgb) / 0.62);
}

.petal-designer-shading-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}

.petal-designer-shading-title {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: #7dd3fc;
  white-space: nowrap;
}

.petal-designer-shading-stack {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.petal-designer-randomness {
  margin: 0 12px 12px;
  border: 1px solid var(--ui-border-hi);
  border-radius: 10px;
  background: rgb(var(--vectura-bg-rgb) / 0.62);
}

.petal-designer-randomness summary {
  padding: 10px 12px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: #7dd3fc;
  cursor: pointer;
  list-style: none;
}

.petal-designer-randomness summary::-webkit-details-marker {
  display: none;
}

.petal-designer-randomness-stack {
  padding: 0 12px 12px;
  display: grid;
  gap: 8px;
}

.petal-slider-label {
  display: grid !important;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas:
    'label value'
    'input input';
  align-items: center;
  gap: 5px 8px !important;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ui-muted);
}

.petal-slider-label > span:first-child {
  grid-area: label;
}

.petal-slider-label .petal-slider-value {
  grid-area: value;
  font-size: 10px;
  color: #67e8f9;
  font-variant-numeric: tabular-nums;
}

.petal-slider-label > input,
.petal-slider-label > select {
  grid-area: input;
}

.petal-slider-label > select {
  border: 1px solid var(--ui-border-hi);
  background: var(--ui-bg);
  color: var(--ui-text);
  padding: 6px 8px;
  font-size: 11px;
}

.petal-shade-controls {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 8px;
}

.petal-shade-controls label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 10px;
  color: var(--ui-muted);
}


.info-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border: 1px solid var(--ui-border);
  border-radius: 9999px;
  margin-left: 6px;
  font-size: 10px;
  line-height: 1;
  color: var(--ui-muted);
  background: var(--ui-panel);
  cursor: pointer;
  vertical-align: middle;
  padding: 4px;
  box-sizing: content-box;
}

.info-btn:hover {
  color: var(--ui-accent);
  border-color: var(--ui-accent);
}


/* === Migrated from legacy CSS (Unit 2.3: Layers Panel V8 + algo dropdown + touch-tablet variant + right-pane title bar, 2026-05-20) === */
/* Note: [data-theme='light'] rewritten to [data-ui-skin='light'] during move (19 selectors). */


/* ── Layers Panel V8 ─────────────────────────────────────────── */

.lvl-layer-list {
  flex: 1; overflow-y: auto; padding: 4px;
  scrollbar-width: thin; scrollbar-color: var(--ui-border) transparent;
}
.lvl-layer-list::-webkit-scrollbar { width: 4px }
.lvl-layer-list::-webkit-scrollbar-thumb { background: var(--ui-border); border-radius: 2px }

.lvl-search-bar {
  display: flex; align-items: center; gap: 4px; padding: 6px 8px;
  border-bottom: 1px solid var(--ui-border); background: var(--ui-panel-alt);
  flex-shrink: 0; position: relative;
}
.lvl-search-wrap {
  flex: 1; display: flex; align-items: center; gap: 6px; min-width: 0;
  background: var(--ui-panel-alt); border: 1px solid var(--ui-border);
  border-radius: 4px; padding: 4px 8px; overflow: hidden;
}
.lvl-search-wrap svg { flex-shrink: 0; color: var(--ui-muted) }
.lvl-search-input {
  flex: 1; background: none; border: none; outline: none;
  color: var(--ui-text); font-family: inherit; font-size: 11px;
}
.lvl-search-input::placeholder { color: var(--ui-border-hi) }
.lvl-filter-btn {
  background: none; border: 1px solid var(--ui-border); border-radius: 4px;
  color: var(--ui-muted); cursor: pointer; padding: 4px 7px; flex-shrink: 0;
  display: flex; align-items: center; transition: color .12s, border-color .12s;
  position: relative; z-index: 1;
}
.lvl-filter-btn:hover { color: var(--ui-text); border-color: var(--ui-border-hi) }
.lvl-filter-btn.active { color: var(--lvl-cyan); border-color: var(--lvl-cyan) }
.lvl-filter-menu {
  position: absolute; top: calc(100% + 4px); right: 8px; width: 164px;
  background: var(--ui-panel-alt); border: 1px solid var(--ui-border);
  border-radius: 6px; z-index: 200; overflow: hidden; box-shadow: 0 4px 16px rgba(0,0,0,.6);
}
.lvl-filter-menu.hidden { display: none }
.lvl-filter-opt {
  padding: 7px 12px; cursor: pointer; display: flex; align-items: center;
  gap: 8px; font-size: 11px; transition: background .1s; color: var(--ui-muted);
}
.lvl-filter-opt:hover { background: rgba(255,255,255,.05); color: var(--ui-text) }
.lvl-filter-opt.sel { color: var(--lvl-cyan) }

.lvl-add-btn {
  height: 22px; padding: 0 8px; background: #38bdf8; border: 1px solid #38bdf8;
  border-radius: 4px; color: var(--ui-bg);
  cursor: pointer; font-family: inherit; font-size: 10px;
  display: flex; align-items: center; gap: 4px; transition: color .12s, background .12s, filter .12s;
}
.lvl-add-btn:hover { color: var(--ui-bg); background: #38bdf8; filter: brightness(1.15); border-color: #38bdf8 }
.lvl-add-menu {
  position: absolute; top: calc(100% + 6px); right: 0; width: 200px;
  background: var(--ui-panel-alt); border: 1px solid var(--ui-border);
  border-radius: 6px; z-index: 1500; overflow: visible; box-shadow: 0 4px 20px rgba(0,0,0,.7);
}
.lvl-add-item:first-child { border-radius: 6px 6px 0 0; }
.lvl-add-item:last-child { border-radius: 0 0 6px 6px; }
.lvl-add-menu.hidden { display: none }
.lvl-add-item {
  padding: 8px 12px; cursor: pointer; font-size: 11px; color: var(--ui-text);
  display: flex; align-items: center; justify-content: flex-start; gap: 6px;
  transition: background .1s, color .1s;
}
.lvl-add-item:hover { background: rgba(255,255,255,.05); color: var(--ui-text) }
.lvl-am-hint { font-size: 9px; color: var(--ui-border-hi); letter-spacing: .04em }
.lvl-add-sep { height: 1px; background: var(--ui-border); margin: 2px 0 }
.lvl-am-arrow { font-size: 12px; color: var(--ui-border-hi); line-height: 1; }
.lvl-algo-submenu {
  display: none; position: fixed; width: 180px;
  background: var(--ui-panel-alt); border: 1px solid var(--ui-border);
  border-radius: 6px; z-index: 9998;
  max-height: calc(100vh - 16px); max-height: calc(var(--app-vh) - 16px); overflow-y: auto; overflow-x: hidden;
  overscroll-behavior: contain;
  box-shadow: 0 4px 20px rgba(0,0,0,.7);
}
.lvl-algo-sub-item {
  padding: 6px 10px; cursor: pointer; font-size: 11px; color: var(--ui-text);
  display: flex; align-items: center; gap: 7px;
  border: 1px solid transparent;
  transition: background .1s, color .1s, border-color .1s;
}
.lvl-algo-sub-item:hover {
  background: rgba(56, 189, 248, 0.12);
  color: #38bdf8;
  border-color: #38bdf8;
}
.lvl-algo-sub-ico { flex-shrink: 0; display: flex; align-items: center; }
.algo-group-div {
  padding: 4px 10px 2px;
  font-size: 9px; font-weight: 600; letter-spacing: .07em; text-transform: uppercase;
  color: var(--ui-border-hi); pointer-events: none; user-select: none;
}
.algo-group-sep { margin-top: 3px; padding-top: 5px; border-top: 1px solid var(--ui-border); }
.algo-draw-picker {
  position: fixed; z-index: 9999; width: 175px;
  background: var(--ui-panel-alt); border: 1px solid var(--ui-border);
  border-radius: 6px;
  max-height: calc(100vh - 16px); max-height: calc(var(--app-vh) - 16px); overflow-y: auto; overflow-x: hidden;
  overscroll-behavior: contain;
  box-shadow: 0 4px 20px rgba(0,0,0,.7);
}
.algo-draw-picker.hidden { display: none }
.algo-pick-item {
  padding: 6px 10px; cursor: pointer; font-size: 11px; color: var(--ui-text);
  display: flex; align-items: center; gap: 7px;
  transition: background .1s, color .1s;
}
.algo-pick-item:hover { background: rgba(255,255,255,.05); color: var(--ui-text) }

/* Algorithm module custom dropdown */
.gm-trigger { cursor: pointer; transition: border-color .15s; outline: none; }
.gm-trigger:hover:not(.gm-trigger-disabled) { border-color: #38bdf8; }
.gm-trigger:focus:not(.gm-trigger-disabled) { border-color: #38bdf8; }
.gm-trigger.gm-trigger-disabled { cursor: default; opacity: 0.6; pointer-events: none; }
.gm-module-menu {
  position: fixed; z-index: 9999;
  background: var(--ui-panel-alt); border: 1px solid var(--ui-border);
  border-radius: 6px; overflow-y: auto; max-height: 280px;
  box-shadow: 0 4px 20px rgba(0,0,0,.7);
}
.gm-module-menu.hidden { display: none; }
.lvl-algo-sub-item.gm-item-active { background: rgba(56,189,248,.08); color: #38bdf8; }
[data-ui-skin='light'] .gm-trigger:hover:not(.gm-trigger-disabled),
[data-ui-skin='light'] .gm-trigger:focus:not(.gm-trigger-disabled) { border-color: #0284c7; }
[data-ui-skin='light'] .lvl-algo-sub-item.gm-item-active { background: rgba(56,189,248,.12); color: #0284c7; }

.lvl-card {
  position: relative; border-radius: 4px; margin: 1px 0;
  transition: background .1s; cursor: pointer; user-select: none;
}
.lvl-card:hover { background: rgba(255,255,255,.04) }
.lvl-card.is-active { box-shadow: inset 0 0 0 1.5px var(--ui-accent); background: rgba(255,255,255,.12) }
.lvl-card.is-selected:not(.is-active) { box-shadow: inset 0 0 0 1px rgba(250,250,250,.45); background: rgba(255,255,255,.08) }
.lvl-card.is-hidden { opacity: .38 }
.lvl-card.is-locked .lvl-acts { opacity: .3; pointer-events: none }
.lvl-list-multi .lvl-card.is-selected .lvl-acts,
.lvl-list-multi .lvl-grp-hdr.is-selected .lvl-grp-acts { opacity: 0 !important; pointer-events: none }

.lvl-card-inner { display: flex; align-items: stretch }
.lvl-caret-zone {
  width: 16px; flex-shrink: 0; display: flex;
  align-items: flex-start; justify-content: center; padding-top: 6px;
}
.lvl-clr-bar { width: 4px; flex-shrink: 0; border-radius: 2px; margin: 3px 5px 3px 0 }
.lvl-card-body { flex: 1; display: flex; flex-direction: column; min-width: 0 }
.lvl-r1 { display: flex; align-items: center; height: 26px; padding-right: 6px; gap: 3px }
.lvl-r2 {
  display: flex; align-items: center; height: 20px; padding-right: 6px; gap: 3px;
  border-top: 1px solid rgba(39,39,42,.7);
}
.lvl-algo-label {
  font-size: 9px; color: var(--ui-border-hi);
  text-transform: uppercase; letter-spacing: .06em; flex: 1;
}
.lvl-name {
  flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  font-size: 11.5px; color: var(--ui-text); min-width: 0;
}
.lvl-card.is-hidden .lvl-name { color: var(--ui-muted) }
.lvl-pen-dot {
  width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0;
  border: 1px solid rgba(255,255,255,.15); cursor: pointer;
}
.lvl-aico {
  width: 14px; height: 14px; display: flex; align-items: center;
  justify-content: center; flex-shrink: 0; color: var(--ui-muted);
}
.lvl-ib {
  width: 20px; height: 20px; display: flex; align-items: center; justify-content: center;
  border-radius: 3px; border: none; background: none; color: var(--ui-muted);
  cursor: pointer; flex-shrink: 0; transition: color .12s, background .12s;
}
.lvl-ib:hover { color: var(--ui-text); background: rgba(255,255,255,.07) }
.lvl-ib.vis-off { opacity: .4 }
.lvl-ib.lk-on  { color: #fbbf24 }
.lvl-ib.lk-anc { color: var(--ui-border-hi); opacity: .7 }
.lvl-ib.lk-off { color: var(--ui-border-hi) }
.lvl-acts { display: flex; align-items: center; gap: 1px; opacity: 0; transition: opacity .15s }
.lvl-card.is-active .lvl-acts { opacity: 1 }
@media (hover: hover) { .lvl-card:hover .lvl-acts { opacity: 1 } } /* TUX-036 */
.lvl-ab {
  width: 18px; height: 18px; display: flex; align-items: center; justify-content: center;
  border-radius: 3px; border: none; background: none; color: var(--ui-muted);
  cursor: pointer; transition: color .12s, background .12s; flex-shrink: 0;
}
.lvl-ab:hover { color: var(--ui-text); background: rgba(255,255,255,.08) }
.lvl-ab.del:hover { color: #f87171 }
.lvl-ab.mask-btn { color: rgba(255,255,255,.35) }
.lvl-ab.mask-btn:hover { color: var(--lvl-cyan); background: rgba(103,232,249,.1) }
.lvl-ab.mask-btn.is-src { color: var(--lvl-cyan) }
.lvl-ab.mask-btn.is-src:hover { color: rgb(var(--vectura-danger-rgb)); background: rgba(248,113,113,.1) }
@keyframes mask-drop-arm {
  0%   { transform: scale(1);    filter: drop-shadow(0 0 0px  rgba(103,232,249,0));                                                           color: rgba(103,232,249,.5); }
  18%  { transform: scale(1.75); filter: drop-shadow(0 0 4px  rgba(103,232,249,1));                                                           color: #67e8f9; }
  42%  { transform: scale(1.45); filter: drop-shadow(0 0 8px  rgba(103,232,249,.85)) drop-shadow(0 0 18px rgba(103,232,249,.5));               color: #67e8f9; }
  68%  { transform: scale(1.1);  filter: drop-shadow(0 0 12px rgba(103,232,249,.45)) drop-shadow(0 0 28px rgba(103,232,249,.18));              color: #67e8f9; }
  100% { transform: scale(1);    filter: drop-shadow(0 0 4px  rgba(103,232,249,.2));                                                           color: #67e8f9; }
}
.lvl-ab.mask-btn.mask-drop-armed {
  animation: mask-drop-arm 0.6s cubic-bezier(0.34,1.56,0.64,1) forwards;
  pointer-events: none;
}
.lvl-ab.mask-outline-btn { color: rgba(103,232,249,.45) }
.lvl-ab.mask-outline-btn:hover { color: var(--lvl-cyan); background: rgba(103,232,249,.1) }
.lvl-ab.mask-outline-btn.is-hidden { color: var(--lvl-cyan) }
.lvl-ab.mask-outline-btn.is-hidden:hover { color: var(--lvl-cyan); background: rgba(103,232,249,.2) }
[data-ui-skin='light'] .lvl-ab.mask-outline-btn { color: rgba(2,132,199,.5) }
[data-ui-skin='light'] .lvl-ab.mask-outline-btn.is-hidden { color: var(--lvl-cyan) }

.lvl-grp-hdr {
  display: flex; align-items: stretch; border-radius: 4px; margin: 1px 0;
  transition: background .1s; cursor: pointer; user-select: none; min-height: 30px;
}
.lvl-grp-hdr:hover { background: rgba(255,255,255,.04) }
.lvl-grp-hdr.is-active { box-shadow: inset 0 0 0 1.5px var(--ui-accent); background: rgba(255,255,255,.12) }
.lvl-grp-hdr.is-selected:not(.is-active) { box-shadow: inset 0 0 0 1px rgba(250,250,250,.45); background: rgba(255,255,255,.08) }
.lvl-grp-hdr.is-hidden { opacity: .38 }
.lvl-grp-content {
  flex: 1; display: flex; align-items: center; gap: 3px;
  padding-right: 6px; min-width: 0; height: 30px;
}
.lvl-grp-name {
  flex: 1; font-size: 11.5px; font-weight: 500; color: var(--ui-text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0;
}
.lvl-grp-hdr.modifier .lvl-grp-name { color: var(--lvl-cyan) }
.lvl-grp-hdr.modifier.mod-off .lvl-grp-name { color: var(--ui-border-hi) }
.lvl-grp-acts { display: flex; align-items: center; gap: 1px; opacity: 0; transition: opacity .12s }
.lvl-grp-hdr.is-active .lvl-grp-acts { opacity: 1 }
@media (hover: hover) { .lvl-grp-hdr:hover .lvl-grp-acts { opacity: 1 } } /* TUX-036 */
/* 3D Scene rows host seven action icons; laid out beside the name they squeeze it to "3D Scen…".
   Float the strip over the row's right edge instead, so the name keeps the full width until an icon is wanted. */
.lvl-grp-hdr.scene-grp .lvl-grp-content { position: relative }
.lvl-grp-hdr.scene-grp .lvl-grp-acts {
  position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
  padding-left: 14px; border-radius: 4px;
  background: linear-gradient(to right, transparent, var(--ui-panel) 14px);
}
/* Reserve the strip's width only while it is shown, so the name is never covered. */
/* A scene row keeps its whole name until the pointer or keyboard focus is on it; only then do the
   actions appear (selected-but-idle rows stay clean). Devices without hover keep the old behavior. */
@media (hover: hover) {
  .lvl-grp-hdr.scene-grp.is-active:not(:hover):not(:focus-within) .lvl-grp-acts { opacity: 0; pointer-events: none }
  .lvl-grp-hdr.scene-grp:hover .lvl-grp-name,
  .lvl-grp-hdr.scene-grp:focus-within .lvl-grp-name { padding-right: 112px }
  .lvl-grp-hdr.scene-grp:focus-within .lvl-grp-acts { opacity: 1; pointer-events: auto }
}
@media (hover: none) { .lvl-grp-hdr.scene-grp.is-active .lvl-grp-name { padding-right: 112px } }
/* A refused scene drop (light or ground outside its scene): red dashed outline, no insertion line. */
.lvl-drop-refuse { outline: 1.5px dashed #f87171; outline-offset: -2px; cursor: not-allowed }
.lvl-caret {
  display: flex; align-items: center; justify-content: center;
  color: var(--ui-border-hi); transition: transform .15s; width: 14px; height: 14px;
}
.lvl-caret.open { transform: rotate(90deg) }

.lvl-tree-children { padding-left: 16px }
.lvl-tree-cwrap { position: relative }
.lvl-tree-cwrap::before {
  content: ''; position: absolute; left: -8px; top: 0; bottom: 0;
  width: 1px; background: var(--lvl-b2); pointer-events: none;
}
.lvl-tree-cwrap:first-child::before { top: -16px }
.lvl-tree-cwrap:last-child::before { bottom: calc(100% - 15px) }
.lvl-tree-cwrap::after {
  content: ''; position: absolute; left: -8px; top: 15px;
  width: 8px; height: 1px; background: var(--lvl-b2); pointer-events: none;
}

.lvl-card.masked-v2 {
  margin: 1px 0 1px 20px;
  border-left: 2px dashed var(--lvl-cyan45);
  border-radius: 0 4px 4px 0;
}
.lvl-mask-nest { padding-left: 20px } /* one level of nested clipping mask */
.lvl-card.masked-v2 .lvl-r1 { padding-left: 6px }
.lvl-card.masked-v2 .lvl-r2 { padding-left: 6px }
.lvl-grp-hdr.masked-v2 {
  margin-left: 20px;
  border-left: 2px dashed var(--lvl-cyan45);
  border-radius: 0 4px 4px 0;
}
.lvl-card.dragging, .lvl-grp-hdr.dragging { opacity: .28 }

.lvl-drop-before { box-shadow: 0 -2px 0 var(--lvl-cyan) !important }
.lvl-drop-after  { box-shadow: 0 2px 0 var(--lvl-cyan) !important }
.lvl-drop-into   { box-shadow: inset 0 0 0 1.5px var(--lvl-cyan) !important }
.lvl-drop-mask   { box-shadow: inset 0 0 0 2px var(--lvl-cyan) !important; background: rgba(103,232,249,.06) !important }
.lvl-s-hint { color: var(--lvl-cyan); font-style: italic; padding: 0 2px }

.lvl-grp-exit-zone {
  height: 10px; position: relative; cursor: default; margin-top: 2px;
  margin-left: -16px; /* extend to group-header width, negating lvl-tree-children padding */
}
.lvl-grp-exit-zone.lvl-drop-exit { background: rgba(103,232,249,.10) }
.lvl-grp-exit-zone.lvl-drop-exit::after {
  content: ''; position: absolute; left: 0; right: 0; top: 0; height: 2px; background: var(--lvl-cyan);
}

.lvl-status-bar {
  border-top: 1px solid var(--ui-border); font-size: 10px;
  display: flex; align-items: center; flex-shrink: 0;
  background: var(--ui-panel-alt); min-height: 32px;
  padding: 0 8px; gap: 0; font-family: inherit;
}
.lvl-sb-idle { color: var(--ui-border-hi); padding: 0 2px }
.lvl-sb-sel-label { color: var(--lvl-cyan); font-weight: 500; white-space: nowrap; flex-shrink: 0; padding: 0 2px }
.lvl-sb-sep { width: 1px; height: 14px; background: var(--ui-border); flex-shrink: 0; margin: 0 5px }
.lvl-sb-cmds { display: flex; align-items: center; gap: 1px; flex-shrink: 0 }
.lvl-sb-spacer { flex: 1; min-width: 4px }
.lvl-sb-total { color: var(--ui-border-hi); font-size: 10px; white-space: nowrap; padding: 0 2px }
.lvl-cb {
  width: 20px; height: 20px; display: flex; align-items: center; justify-content: center;
  border-radius: 3px; border: none; background: none; color: var(--ui-muted);
  cursor: pointer; transition: color .12s, background .12s; flex-shrink: 0;
}
.lvl-cb:hover { color: var(--ui-text); background: rgba(255,255,255,.08) }
.lvl-cb.del:hover { color: #f87171 }
.lvl-cb.mask-btn { color: rgba(103,232,249,.5) }
.lvl-cb.mask-btn:hover { color: var(--lvl-cyan); background: rgba(103,232,249,.1) }
.lvl-cb.mask-btn.ineligible { color: rgba(255,255,255,.18); cursor: not-allowed }
.lvl-cb.mask-btn.ineligible:hover { background: none; color: rgba(255,255,255,.18) }
.lvl-cb:disabled, .lvl-cb.unavailable { color: rgba(255,255,255,.18); cursor: not-allowed }
.lvl-cb:disabled:hover, .lvl-cb.unavailable:hover { background: none; color: rgba(255,255,255,.18) }

.lvl-ren-inp {
  flex: 1; background: rgba(255,255,255,.09); border: 1px solid var(--lvl-cyan);
  border-radius: 3px; color: var(--ui-text); font-family: inherit;
  font-size: 11.5px; padding: 1px 4px; outline: none; min-width: 0;
}

.lvl-card .pen-assign {
  position: absolute; right: 6px; top: 3px;
  width: 0; height: 0; overflow: visible;
}
.lvl-card .pen-pill { display: none }
.lvl-card .pen-menu { right: -6px; top: 20px }

[data-ui-skin='light'] .lvl-card:hover,
[data-ui-skin='light'] .lvl-grp-hdr:hover { background: rgba(0,0,0,.04) }
[data-ui-skin='light'] .lvl-card.is-active,
[data-ui-skin='light'] .lvl-grp-hdr.is-active { box-shadow: inset 0 0 0 1.5px rgba(0,0,0,.4); background: rgba(0,0,0,.10) }
[data-ui-skin='light'] .lvl-card.is-selected:not(.is-active),
[data-ui-skin='light'] .lvl-grp-hdr.is-selected:not(.is-active) { box-shadow: inset 0 0 0 1px rgba(0,0,0,.2); background: rgba(0,0,0,.07) }
[data-ui-skin='light'] .lvl-r2 { border-top-color: rgba(0,0,0,.1) }
[data-ui-skin='light'] .lvl-tree-cwrap::before,
[data-ui-skin='light'] .lvl-tree-cwrap::after { background: var(--ui-border) }
[data-ui-skin='light'] .lvl-filter-opt:hover,
[data-ui-skin='light'] .lvl-add-item:hover { background: rgba(0,0,0,.04) }
[data-ui-skin='light'] .lvl-algo-sub-item:hover { background: rgba(56, 189, 248, 0.12); color: #0284c7; border-color: #38bdf8 }
[data-ui-skin='light'] .algo-pick-item:hover { background: rgba(0,0,0,.04) }
[data-ui-skin='light'] .lvl-pen-dot { border-color: rgba(0,0,0,.2) }

/* ── Right-pane title bar: match v8 mockup compact header ─── */
#right-pane .pane-header {
  height: 36px;
  min-height: 36px;
  padding: 0 8px 0 48px;
  background: var(--ui-panel-alt);
}
#right-pane .pane-header .pane-title {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.1em;
  color: var(--ui-muted);
  text-transform: uppercase;
  flex: 1;
  margin-left: 0;
}

/* ── End Layers Panel V8 ─────────────────────────────────────── */

/* === Migrated from legacy CSS (Unit 2.4: Document Setup + drawer + layer-bar palette picker, 2026-05-20) === */

.settings-panel {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  width: var(--pane-left-width);
  display: flex;
  flex-direction: column;
  background: var(--ui-panel, var(--ui-panel));
  border-right: 1px solid var(--ui-border, var(--ui-border));
  box-shadow: var(--shadow-pane, 4px 0 24px rgba(0, 0, 0, 0.35));
  transform: translateX(-100%);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 40;
  pointer-events: none;
}

.mobile-layout .settings-panel {
  z-index: 90;
}

.settings-panel.open {
  transform: translateX(0);
  pointer-events: auto;
}

/* Var 01 drawer — body scroll + Meridian-component glue.
   Sections inside .settings-panel-body inherit `.sect`/`.sect-hdr`/`.sect-body`
   from src/ui/skin/components.css; rules below only cover row/trail helpers
   that don't have a global home yet. */
.settings-panel-body {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
}
.settings-panel-body::-webkit-scrollbar { width: 3px; }
.settings-panel-body::-webkit-scrollbar-thumb {
  background: var(--ui-border-hi, var(--ui-border-hi));
  border-radius: 2px;
}
.settings-panel .ctrl-row-trail {
  display: inline-flex;
  align-items: center;
  gap: var(--spacing-sm, 8px);
}
.settings-panel .ctrl-trail-hint {
  font-size: var(--font-size-xs, 10px);
  color: var(--ui-muted, var(--ui-muted));
  font-family: var(--font-ui, inherit);
}
.settings-panel .num-step--narrow { width: 100px; flex: 0 0 100px; }
.settings-panel .slider-val-inp {
  height: var(--row-height, 30px);
  width: 64px;
  background: var(--ui-ctrl, var(--ui-ctrl));
  border: 1px solid var(--ui-border, var(--ui-border));
  color: var(--ui-text, var(--ui-text));
  font-family: var(--font-mono, monospace);
  font-variant-numeric: tabular-nums;
  font-size: var(--font-size-sm, 11px);
  text-align: right;
  border-radius: var(--radius-sm, 4px);
  outline: none;
  padding: 0 var(--spacing-sm, 8px);
  transition: border-color 0.12s, box-shadow 0.12s;
}
.settings-panel .slider-val-inp:focus {
  border-color: var(--ui-accent, var(--ui-accent));
  box-shadow: 0 0 0 3px var(--ui-accent-2, rgba(78, 158, 225, 0.12));
}

/* Collapse/expand animation for Document Setup sections */
.settings-panel [data-sect-body] {
  transition: max-height 0.28s cubic-bezier(0.4, 0, 0.2, 1),
              padding-top 0.28s cubic-bezier(0.4, 0, 0.2, 1),
              padding-bottom 0.28s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Per-section accent bar colors in Document Setup.
   JS drives --sect-bar from the active UI Color Palette via _updateLBPTrigger;
   these are the Prism-palette fallbacks shown before JS runs. */
.sect--color-theme   { --sect-bar: #A78BFA; }
.sect--color-paper   { --sect-bar: #60A5FA; }
.sect--color-margins { --sect-bar: #34D399; }
.sect--color-guides  { --sect-bar: #F59E0B; }
.sect--color-3d      { --sect-bar: #22D3EE; }
.sect--color-bg      { --sect-bar: #EC4899; }
.sect--color-plotter { --sect-bar: #FB923C; }
.sect--color-palette { --sect-bar: #A78BFA; }
.sect--color-history { --sect-bar: #60A5FA; }
.sect[class*="sect--color-"] .sect-hdr::before { background: var(--sect-bar, var(--ui-accent)); opacity: 0.8; }
@media (hover: hover) {
  .sect[class*="sect--color-"] .sect-hdr:hover::before { opacity: 1; }
}

/* Close affordance — circular outline button with a left-facing chevron,
   visually matching the .pane-toggle handles on the left/right panes but
   anchored inside the `.pane-hdr` flex row instead of free-floating midway
   up the panel. */
.settings-panel-close {
  width: 24px;
  height: 24px;
  border: 1px solid var(--ui-border, var(--ui-border));
  border-radius: 9999px;
  background: var(--ui-ctrl, var(--ui-bg));
  color: var(--ui-text-2, var(--ui-text-2));
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}
.settings-panel-close:hover {
  color: var(--ui-accent, var(--ui-accent));
  border-color: var(--ui-accent, var(--ui-accent));
}
.settings-panel-close:focus-visible {
  outline: 2px solid var(--ui-accent, var(--ui-accent));
  outline-offset: 2px;
}

.pane :is(select, input[type='text'], input[type='number'], input[type='search']),
.settings-panel :is(select, input[type='text'], input[type='number'], input[type='search']),
.modal-card :is(select, input[type='text'], input[type='number'], input[type='search']) {
  background: var(--ui-ctrl);
  color: var(--ui-text);
}

/* ── Layer bar palette picker ─────────────────────────── */
.palette-picker-wrap { position: relative; }
.palette-picker-trigger {
  display: flex; align-items: center; gap: 6px; cursor: pointer;
  border: 1px solid var(--ui-border); padding: 5px 8px;
  background: var(--ui-ctrl); font-size: 11px; color: var(--ui-text);
  user-select: none;
}
.palette-picker-trigger:hover { border-color: var(--ui-accent); }
.palette-picker-arrow {
  margin-left: auto;
  display: inline-block;
  width: 12px;
  height: 12px;
  background-color: currentColor;
  -webkit-mask: var(--chevron-svg) center / contain no-repeat;
  mask: var(--chevron-svg) center / contain no-repeat;
  opacity: 0.5;
  font-size: 0;
}
.palette-picker-menu {
  position: absolute; top: 100%; left: 0; right: 0; z-index: 200;
  background: var(--ui-panel); border: 1px solid var(--ui-border);
  max-height: 260px; overflow-y: auto;
}
.palette-picker-menu.hidden { display: none; }
.palette-picker-row {
  display: flex; align-items: center; gap: 8px; padding: 6px 8px;
  cursor: pointer; font-size: 11px; color: var(--ui-text);
}
.palette-picker-row:hover,
.palette-picker-row.is-active { background: var(--ui-border); }
.palette-picker-label { min-width: 72px; flex-shrink: 0; }
.palette-picker-swatches { display: flex; gap: 2px; }
.palette-swatch { width: 10px; height: 10px; border-radius: 2px; flex-shrink: 0; }
.palette-picker-note { font-size: 10px; opacity: .5; font-style: italic; }

#app-header {
  position: relative;
  z-index: 220;
  overflow: visible;
}

.header-main {
  min-height: 30px;
  overflow: visible;
}

.header-brand-menu {
  flex: 1 1 auto;
  min-width: 0;
  overflow: visible;
}

.header-menu-divider {
  width: 1px;
  height: 20px;
  margin-left: 8px;
  margin-right: 6px;
  background: var(--ui-border);
  flex: 0 0 auto;
}

.top-menubar {
  display: flex;
  align-items: center;
  flex: 1 1 auto;
  min-width: 0;
  gap: 8px;
  overflow: visible;
  white-space: nowrap;
  margin-left: 2px;
  position: relative;
  z-index: 260;
}

.top-menu {
  position: relative;
  flex: 0 0 auto;
}

.top-menu-trigger {
  border: 1px solid var(--ui-border);
  background: var(--ui-panel-alt);
  color: var(--ui-text-2);
  padding: 5px 9px;
  font-size: 11px;
  line-height: 1.2;
  letter-spacing: 0.03em;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
}

.top-menu-trigger::after {
  content: '';
  display: inline-block;
  width: 10px;
  height: 10px;
  background-color: var(--ui-muted);
  -webkit-mask: var(--chevron-svg) center / contain no-repeat;
  mask: var(--chevron-svg) center / contain no-repeat;
  transition: background-color 0.15s ease;
}
.top-menu-trigger:hover::after,
.top-menu-trigger.open::after,
.top-menu-trigger[aria-expanded="true"]::after {
  background-color: var(--ui-accent);
}

.top-menu-trigger:hover,
.top-menu-trigger.open {
  border-color: var(--ui-accent);
  color: var(--ui-accent);
  background: var(--ui-panel);
  outline: none;
}

.top-menu-trigger:focus-visible {
  border-color: var(--ui-accent);
  color: var(--ui-accent);
  background: var(--ui-panel);
  outline: 2px solid var(--ui-accent);
  outline-offset: 2px;
}

.top-menu-trigger:hover::after,
.top-menu-trigger:focus-visible::after,
.top-menu-trigger.open::after {
  color: var(--ui-accent);
}

.top-menu-panel {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  min-width: 228px;
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  border: 1px solid var(--ui-border);
  background: var(--ui-bg);
  box-shadow: 0 16px 30px rgba(0, 0, 0, 0.45);
  z-index: 1400;
  opacity: 0;
  transform: translateY(-4px);
  pointer-events: none;
  transition: opacity 0.12s ease, transform 0.12s ease;
}

.top-menu-panel.open {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.top-menu-item {
  width: 100%;
  border: 1px solid transparent;
  background: transparent;
  color: var(--ui-text-2);
  text-align: left;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 11px;
  line-height: 1.3;
  padding: 7px 8px;
}

.top-menu-shortcut {
  color: var(--ui-muted);
  font-size: 10px;
  line-height: 1;
  white-space: nowrap;
}

.top-menu-item:hover {
  border-color: var(--ui-border-hi);
  background: var(--ui-panel);
  color: var(--ui-accent);
  outline: none;
}

.top-menu-item:focus-visible {
  border-color: var(--ui-border-hi);
  background: var(--ui-panel);
  color: var(--ui-accent);
  outline: 2px solid var(--ui-accent);
  outline-offset: 2px;
}

.top-menu-item:hover .top-menu-shortcut,
.top-menu-item:focus-visible .top-menu-shortcut {
  color: var(--ui-text-2);
}

.top-menu-item-primary {
  color: var(--ui-accent);
}

.top-menu-item:disabled,
.top-menu-item[disabled] {
  color: var(--ui-muted);
  opacity: 0.55;
  cursor: not-allowed;
  pointer-events: none;
}

.top-menu-item:disabled .top-menu-shortcut,
.top-menu-item[disabled] .top-menu-shortcut {
  color: var(--ui-muted);
}

.top-menu-sep {
  border: none;
  border-top: 1px solid var(--ui-border);
  margin: 4px 0;
}

.optimization-overlay-legend {
  position: absolute;
  right: 12px;
  bottom: 12px;
  width: 220px;
  border: 1px solid var(--ui-border);
  background: rgb(var(--vectura-bg-rgb) / 0.94);
  padding: 8px 10px;
  z-index: 60;
  pointer-events: none;
}

.optimization-overlay-legend-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}
.optimization-overlay-legend-title {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ui-text-2);
}
/* The legend is pointer-events:none so it never blocks the canvas; re-enable
   pointer events on the gear alone so it stays clickable (matches the export
   menu's legend gear). */
.optimization-overlay-legend-settings {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  padding: 0;
  border: none;
  border-radius: 4px;
  background: transparent;
  color: var(--ui-text-2);
  cursor: pointer;
  pointer-events: auto;
  transition: color 0.12s ease, background 0.12s ease;
}
.optimization-overlay-legend-settings:hover {
  color: var(--ui-accent);
  background: var(--ui-border);
}

.optimization-overlay-legend-gradient {
  height: 8px;
  border: 1px solid var(--ui-border-hi);
  margin-bottom: 4px;
}

.optimization-overlay-legend-labels {
  display: flex;
  justify-content: space-between;
  font-size: 9px;
  color: var(--ui-text-2);
}
/* Inline color/thickness dialogue toggled by the legend gear (mirrors the export
   menu's legend settings). pointer-events:auto because the legend itself is
   pass-through. */
.optimization-overlay-legend-settings-panel {
  pointer-events: auto;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--ui-border);
  display: flex;
  flex-direction: column;
  gap: 7px;
}
.optimization-overlay-legend-setting {
  display: flex;
  align-items: center;
  gap: 8px;
}
.optimization-overlay-legend-setting-label {
  flex: 0 0 78px;
  font-size: 10px;
  color: var(--ui-text-2);
}
.optimization-overlay-legend-setting .color-thickness-pill {
  flex: 1 1 auto;
  min-width: 0;
  padding: 2px 6px;
  border: 1px solid var(--ui-border-hi);
  border-radius: 4px;
  cursor: pointer;
  text-align: center;
}
.optimization-overlay-legend-setting input[type="range"] {
  flex: 1 1 auto;
  min-width: 0;
}

.color-thickness-control {
  display: grid;
  grid-template-columns: minmax(90px, 1fr) minmax(130px, 1fr) auto;
  gap: 8px;
  align-items: end;
}

.color-thickness-pill {
  min-height: 24px;
  color: var(--ui-bg);
  width: 100%;
  text-align: center;
  border-radius: 9999px;
  overflow: hidden;
}

.color-thickness-size {
  display: grid;
  grid-template-columns: minmax(80px, 1fr) auto auto;
  gap: 6px;
  align-items: center;
}

.line-style-control {
  display: grid;
  grid-template-columns: minmax(90px, 1fr) minmax(150px, 1fr) minmax(86px, auto) auto;
  gap: 8px;
  align-items: end;
}

.style-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.style-field-label {
  font-size: 9px;
  line-height: 1;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ui-muted);
}

.style-field > .color-thickness-pill,
.style-field > input[type='number'],
.style-field > button,
.style-field > .color-thickness-size {
  min-height: 24px;
}

/* Document Setup panel — narrow (290px) layout overrides.
   The default 4-col grid for .line-style-control overflows here, so we stack
   Color and Thickness full width and put Separation/Reset side-by-side beneath.
   Also aligns inputs/buttons to the parameter-pane corner rounding. */
#settings-panel .line-style-control,
#settings-panel .color-thickness-control {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 10px 8px;
}
#settings-panel .line-style-control > .style-field:nth-child(1),
#settings-panel .line-style-control > .style-field:nth-child(2),
#settings-panel .color-thickness-control > .style-field:nth-child(1),
#settings-panel .color-thickness-control > .style-field:nth-child(2) {
  grid-column: 1 / -1;
}
#settings-panel .color-thickness-control > .style-field:nth-child(3) {
  grid-column: 2;
}
#settings-panel .color-thickness-size {
  grid-template-columns: minmax(0, 1fr) auto auto;
}
#settings-panel input[type='number'],
#settings-panel input[type='text'],
#settings-panel select,
#settings-panel .style-field > button,
#settings-panel #btn-clear-preferences,
#settings-panel .theme-family-toggle,
#settings-panel .palette-picker-trigger,
#settings-panel .palette-picker-menu {
  border-radius: var(--radius-sm, 4px);
}
#settings-panel .theme-family-toggle { overflow: hidden; }

#grid-settings-panel input[type='number'],
#grid-settings-panel input[type='text'],
#grid-settings-panel select {
  border-radius: var(--radius-sm, 4px);
}
#grid-settings-panel .color-thickness-pill {
  border-radius: 9999px;
  font-size: var(--font-size-xs, 10px);
  font-family: var(--font-mono, monospace);
  font-variant-numeric: tabular-nums;
}

/* === Migrated from legacy CSS (Unit 2.5: Mobile shell + touch ergonomics + Pattern Designer Inline Panel, 2026-05-20) === */

@media (max-width: 1024px) {
  .tool-bar {
    top: 12px;
    bottom: auto;
    left: 50%;
    transform: translateX(-50%);
    flex-direction: row;
    max-width: calc(100vw - 24px);
    overflow-x: auto;
    overflow-y: hidden;
    padding: 8px;
  }

  .tool-group {
    flex-direction: row;
  }

  .tool-divider {
    width: 1px;
    height: 24px;
    margin: 0 4px;
  }

  .tool-submenu {
    left: 0;
    top: -44px;
    flex-direction: row;
  }

  .touch-modifier-bar {
    left: 50%;
    top: 66px;
    bottom: auto;
    transform: translateX(-50%);
    max-width: calc(100vw - 24px);
    justify-content: center;
  }

  .bottom-pane:not(.bottom-pane-collapsed) {
    height: min(40vh, 260px);
  }
}

/* TUX-006: keyed on the JS layout class (phone/tablet), not viewport width.
 * Bare selectors are wrapped in :where() so they keep the cascade weight of the
 * deleted @media (max-width: 900px) block (e.g. #id = 1,0,0; .x = 0,1,0). */
:root:where(:has(body.mobile-layout)) {
  --pane-left-width: min(88vw, 340px);
  --pane-right-width: min(88vw, 340px);
  --pane-collapsed-width: 40px;
}

:where(body.mobile-layout) #app-header {
  padding-left: 10px;
  padding-right: 10px;
}

:where(body.mobile-layout) .header-main {
  align-items: flex-start;
}

:where(body.mobile-layout) .top-menubar {
  gap: 10px;
  padding-top: 0;
}

:where(body.mobile-layout) .pane-resizer,
:where(body.mobile-layout) .bottom-resizer {
  display: none;
}

:where(body.mobile-layout) .mobile-pane-handle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.mobile-layout .pane {
  position: absolute;
  top: 0;
  /* Reserve room for the pinned modifier bar at the viewport bottom
   * (44px button + 12px padding + safe-area inset). Without this the
   * drawer extends under the modifier bar and the bar's higher z-index
   * intercepts clicks on the bottom of pane content. */
  bottom: var(--bottom-chrome-h, calc(56px + var(--safe-bottom))); /* TUX-005: measured by workspace.js */
  /* Must sit above #bottom-pane (z-index 50 in mobile-layout) so the
   * bottom-pane drawer does not intercept clicks on right-pane content
   * (Pens tab, auto-colorization header, etc.) at tablet-touch widths. */
  z-index: 55;
  max-width: calc(100vw - 18px);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.45);
}

.mobile-layout .pane-left {
  left: 0;
  border-right-width: 1px;
}

.mobile-layout .pane-right {
  right: 0;
  border-left-width: 1px;
}

.mobile-layout .right-panel-section-scroll {
  max-height: min(22vh, 180px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.mobile-layout .right-panel-section-primary {
  max-height: min(42vh, 320px);
}

.mobile-layout #pens-section,
.mobile-layout #auto-colorization-wrap {
  max-height: none;
}

.mobile-layout .auto-collapsed .pane:not(.pane-force-open),
.mobile-layout .pane.pane-collapsed {
  width: var(--pane-collapsed-width);
  box-shadow: none;
}

/* ─────────────────────────────────────────────────────────────
   Mobile shell layout: top app bar → canvas → bottom pane → modifier bar.
   Modifier bar is pinned to viewport bottom and always reachable;
   bottom pane sits above it (does not cover it).
   ───────────────────────────────────────────────────────────── */

body.mobile-layout #tool-bar {
  position: static;
  top: auto;
  left: auto;
  right: auto;
  bottom: auto;
  transform: none;
  order: 1;
  width: 100%;
  max-width: none;
  flex-direction: row;
  /* Wrap onto a second row at iPhone-mini widths instead of horizontally
     scrolling — keeps every primary tool reachable in one tap. */
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  row-gap: 6px;
  column-gap: 6px;
  overflow-x: visible;
  overflow-y: hidden;
  max-height: none;
  padding: 8px 12px;
  /* TUX-005: no top inset here; #app-header carries it. */
  padding-left: calc(12px + var(--safe-left));
  padding-right: calc(12px + var(--safe-right));
  border: none;
  border-radius: 0;
  border-bottom: 1px solid var(--ui-border);
  background: var(--ui-panel);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
  flex-shrink: 0;
}

/* Phone widths (auto-collapsed, < 640px): panes shrink to drawer slivers
   (z:55). Bump the toolbar above the slivers so the leftmost/rightmost
   tool buttons aren't occluded by the pane edges. At tablet widths
   (640–900px) the panes are fully shown, not slivers, so the toolbar
   must stay below them or it will paint over right-pane content like
   the Add Layer button. */
body.mobile-layout.auto-collapsed #tool-bar {
  z-index: 60;
}

/* When a side pane is force-opened (full drawer), it should cover the
   toolbar — the user is interacting with the pane, not the bar. */
body.mobile-layout.auto-collapsed .pane.pane-force-open {
  z-index: 70;
}

/* Lock standard tool buttons to a 44×44 hit target — never shrink to fit. */
body.mobile-layout #tool-bar > .tool-btn,
body.mobile-layout #tool-bar > .tool-group > .tool-btn {
  flex-shrink: 0;
}

body.mobile-layout #viewport-container {
  order: 2;
  flex: 1 1 auto;
  min-height: 0;
}

body.mobile-layout #bottom-pane {
  order: 3;
  position: relative;
  z-index: 50;
  padding-bottom: 0;
  flex-shrink: 0;
}

body.mobile-layout #bottom-pane .bottom-pane-header {
  height: 32px;
  min-height: 32px;
  padding: 0 12px;
  flex-shrink: 0;
}

body.mobile-layout #bottom-pane .bottom-pane-header > span {
  display: none;
}

body.mobile-layout #bottom-pane.bottom-pane-collapsed {
  height: 32px;
}

body.mobile-layout #bottom-pane:not(.bottom-pane-collapsed) {
  height: min(38vh, 280px);
}

body.mobile-layout #touch-modifier-bar {
  position: static;
  left: auto;
  top: auto;
  right: auto;
  bottom: auto;
  transform: none;
  order: 4;
  width: 100%;
  max-width: none;
  box-sizing: border-box;
  display: flex;
  flex-wrap: nowrap;
  align-items: stretch;
  justify-content: stretch;
  gap: 6px;
  padding: 6px 8px;
  /* TUX-005: the bottom inset goes on the bottom-most chrome only (see the TUX-005 block at the end). */
  padding-bottom: 6px;
  padding-left: calc(8px + var(--safe-left));
  padding-right: calc(8px + var(--safe-right));
  border: none;
  border-radius: 0;
  border-top: 1px solid var(--ui-border);
  background: var(--ui-panel);
  box-shadow: 0 -2px 6px rgba(0, 0, 0, 0.25);
  flex-shrink: 0;
  z-index: 60;
}

body.mobile-layout #touch-modifier-bar.hidden {
  display: flex;
}

body.mobile-layout #touch-modifier-bar .touch-mod-btn {
  flex: 1 1 0;
  min-width: 0;
  height: 44px;
  padding: 0 8px;
  font-size: 12px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

body.mobile-layout #btn-mobile-pane-bottom {
  display: none;
}

/* Drawer backdrop — visible only when a pane drawer is open in mobile-layout. */
:where(body.mobile-layout) .mobile-pane-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 54;
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease;
}

body.mobile-layout .mobile-pane-backdrop.visible {
  opacity: 1;
  pointer-events: auto;
}

body:not(.mobile-layout) .mobile-pane-backdrop {
  display: none;
}

/* Phone-only (TUX-001: keyed on body.phone-layout, not width, so iPhone landscape gets glyphs too). */
body.phone-layout #touch-modifier-bar .touch-mod-btn .touch-mod-label {
  display: none;
}

body.phone-layout #touch-modifier-bar .touch-mod-btn::before {
  font-size: 18px;
  line-height: 1;
  font-weight: 600;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI Symbol', system-ui, sans-serif;
}

body.phone-layout #touch-modifier-bar .touch-mod-btn[data-touch-mod="shift"]::before { content: "\21E7"; }
body.phone-layout #touch-modifier-bar .touch-mod-btn[data-touch-mod="alt"]::before { content: "\2325"; }
body.phone-layout #touch-modifier-bar .touch-mod-btn[data-touch-mod="meta"]::before { content: "\2318"; }
body.phone-layout #touch-modifier-bar .touch-mod-btn[data-touch-mod="ctrl"]::before { content: "\2303"; }
body.phone-layout #touch-modifier-bar .touch-mod-btn[data-touch-mod="pan"]::before { content: "\270B"; }

/* Touch-device tap ergonomics — applies on any coarse pointer device. */
@media (pointer: coarse) {
  button,
  .tool-btn,
  .touch-mod-btn,
  .mobile-pane-handle {
    -webkit-tap-highlight-color: transparent;
    -webkit-user-select: none;
    user-select: none;
    touch-action: manipulation;
  }
}

@media (max-width: 640px) {
  .header-menu-divider {
    margin-left: 4px;
    margin-right: 2px;
  }

  #status-bar {
    display: none;
  }

  .top-menu-trigger {
    font-size: 10px;
    padding: 5px 7px;
  }

  .top-menu-item {
    font-size: 10px;
    padding: 7px;
  }
}
.layer-grip:active {
  cursor: grabbing;
}

.palette-toggle {
  font-size: 10px;
  padding: 4px 8px;
  border: 1px solid var(--ui-border);
  color: var(--ui-text-2);
  background: var(--ui-bg);
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

.palette-toggle:hover {
  color: var(--ui-accent);
  border-color: var(--ui-accent);
}

.palette-menu {
  position: absolute;
  top: 100%;
  left: 0;
  margin-top: 6px;
  width: 220px;
  background: var(--ui-bg);
  border: 1px solid var(--ui-border);
  padding: 8px;
  z-index: 30;
  box-shadow: var(--shadow-panel);
}

.palette-search {
  width: 100%;
  background: var(--ui-panel);
  border: 1px solid var(--ui-border);
  padding: 6px 8px;
  font-size: 10px;
  color: var(--ui-text);
  margin-bottom: 8px;
}

.palette-options {
  max-height: 220px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.palette-option {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 6px;
  border: 1px solid transparent;
  font-size: 10px;
  color: var(--ui-text-2);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  cursor: pointer;
}

.palette-option:hover,
.palette-option.active {
  border-color: var(--ui-accent);
  color: var(--ui-accent);
}

.palette-swatch {
  display: grid;
  grid-template-columns: repeat(5, 8px);
  gap: 2px;
}

.palette-swatch span {
  width: 8px;
  height: 8px;
  border-radius: 2px;
  display: block;
}

.pen-remove {
  border: 1px solid var(--ui-border);
  background: var(--ui-bg);
  color: var(--ui-muted);
  width: 18px;
  height: 18px;
  border-radius: 9999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
}

.pen-remove:hover {
  color: var(--ui-accent);
  border-color: var(--ui-accent);
}

.noise-dropzone {
  border: 1px dashed var(--ui-border-hi);
  background: var(--ui-panel-alt);
  color: var(--ui-text-2);
  font-size: 12px;
  padding: 24px 12px;
  text-align: center;
  border-radius: 10px;
}

.noise-dropzone.active {
  border-color: var(--ui-accent);
  color: var(--ui-accent);
}

.angle-control {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* auto-fit lets the grid respond to its own width (side panel can be
 * narrowed independently of the viewport), so columns collapse from 3 → 2 → 1
 * once items can no longer fit at the minmax floor. */
.control-inline-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 12px;
}

.control-inline-item,
.angle-item {
  margin-bottom: 0;
}

.control-inline-row .control-inline-item:last-child input[type='checkbox'] {
  margin-top: 6px;
}

.masking-controls {
  margin-bottom: 16px;
  border: 1px solid var(--ui-border);
  background: rgb(var(--vectura-bg-rgb) / 0.72);
}

.masking-controls__summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  list-style: none;
  cursor: pointer;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--ui-text);
}

.masking-controls__summary::-webkit-details-marker {
  display: none;
}

.masking-controls__body {
  padding: 0 12px 12px;
}


.angle-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.angle-dial {
  position: relative;
  width: 56px;
  height: 56px;
  border-radius: 999px;
  border: 1px solid var(--ui-border);
  background: var(--ui-ctrl);
  cursor: pointer;
  flex-shrink: 0;
}

.angle-dial:hover {
  border-color: var(--ui-border-hi);
}

.angle-indicator {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: rotate(var(--angle));
  transform-origin: center center;
}

.angle-indicator::before {
  content: '';
  position: absolute;
  width: 2px;
  height: 20px;
  background: #ef4444;
  border-radius: 999px;
  transform: translate(-1px, -20px);
}

.angle-indicator::after {
  content: '';
  position: absolute;
  width: 6px;
  height: 6px;
  background: #ef4444;
  border-radius: 999px;
  transform: translate(-3px, -28px);
}

.inline-value-input {
  position: absolute;
  z-index: 10;
  background: var(--ui-panel-alt);
  border: 1px solid var(--ui-border);
  color: #ef4444;
  font-size: 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New', monospace;
  padding: 2px 6px;
  text-align: right;
  border-radius: 4px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
}

.global-section {
  margin: 1.5rem 0 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--ui-border);
}

.global-section-header {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--ui-panel-alt);
  border: none;
  padding: 0 0 0.5rem;
  cursor: pointer;
  text-align: left;
}

.global-section-title {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ui-text-2);
}

.global-section-toggle {
  width: 14px;
  height: 14px;
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.global-section-toggle::before {
  content: '';
  display: block;
  width: 12px;
  height: 12px;
  background-color: var(--ui-text-2);
  -webkit-mask: var(--chevron-svg) center / contain no-repeat;
  mask: var(--chevron-svg) center / contain no-repeat;
  transform: rotate(180deg);
  transition: transform 0.2s ease, background-color 0.15s ease;
}

.global-section.collapsed .global-section-toggle::before {
  transform: rotate(0deg);
}

.global-section-body {
  padding-top: 0.25rem;
}

.algo-param-group {
  margin: 1.5rem 0 0;
  padding-top: 0.75rem;
  border-top: none;
}

.algo-param-group-header {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(180, 83, 9, 0.09);
  border: none;
  border-left: 2px solid #b45309;
  padding: 0.25rem 0.4rem 0.25rem 0.5rem;
  cursor: pointer;
  text-align: left;
  border-radius: 2px;
}

.algo-param-group-title {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #d97706;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.algo-param-group-title svg {
  flex-shrink: 0;
  opacity: 0.75;
}

.algo-param-group-toggle {
  width: 14px;
  height: 14px;
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.algo-param-group-toggle::before {
  content: '';
  display: block;
  width: 12px;
  height: 12px;
  background-color: #d97706;
  -webkit-mask: var(--chevron-svg) center / contain no-repeat;
  mask: var(--chevron-svg) center / contain no-repeat;
  transform: rotate(180deg);
  transition: transform 0.2s ease;
}

.algo-param-group.collapsed .algo-param-group-toggle::before {
  transform: rotate(0deg);
}

.algo-param-group-body {
  padding-top: 0.25rem;
  border-left: 2px solid #b45309;
  padding-left: 0.5rem;
}

.optimization-panel {
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--ui-border);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.optimization-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.optimization-row .control-label {
  margin-bottom: 0;
  font-size: 0.7rem;
}

.optimization-overlay {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.optimization-actions {
  display: flex;
  justify-content: flex-end;
}

.opt-reset {
  width: 100%;
  font-size: 0.7rem;
  border: 1px solid var(--ui-border);
  padding: 0.4rem 0.5rem;
  color: var(--ui-text);
  background: transparent;
  cursor: pointer;
}

.opt-reset:hover {
  background: var(--ui-border);
}

.optimization-stats {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.optimization-stat-row {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
}

.optimization-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.optimization-card {
  border: 1px solid var(--ui-border);
  padding: 0.5rem;
  background: var(--ui-panel-alt);
}

.optimization-card.dragging {
  opacity: 0.6;
}

.optimization-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.35rem;
}

.optimization-card-title {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.7rem;
  color: var(--ui-text);
  min-width: 0;
}

.optimization-card-title > span {
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
}

.optimization-card-actions {
  display: flex;
  gap: 0.5rem;
  font-size: 0.6rem;
  color: var(--ui-text-2);
}

.opt-toggle {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.optimization-grip {
  background: transparent;
  border: none;
  display: grid;
  grid-template-columns: repeat(2, 4px);
  gap: 2px;
  padding: 2px;
  cursor: grab;
}

.optimization-grip .dot {
  width: 3px;
  height: 3px;
  background: var(--ui-border-hi);
  border-radius: 999px;
}

.optimization-grip:active {
  cursor: grabbing;
}

.optimization-drop-indicator {
  height: 4px;
  border-radius: 999px;
  background: #38bdf8;
  opacity: 0.8;
  margin: 2px 0;
}

.optimization-controls.is-disabled {
  opacity: 0.6;
  pointer-events: none;
}

.noise-image-row {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
}

.noise-image-left {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  min-width: 120px;
}

.noise-image-right {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  min-width: 0;
}

.noise-image-preview {
  width: 200px;
  height: 200px;
  border: 1px solid var(--ui-border);
  border-radius: 6px;
  background: var(--ui-panel-alt);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  cursor: pointer;
  position: relative;
}

.noise-image-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.noise-image-clear {
  position: absolute;
  top: 6px;
  right: 8px;
  z-index: 2;
}

.noise-image-preview.active {
  border-color: var(--ui-accent);
}

.noise-dropzone.compact {
  min-height: 64px;
  font-size: 10px;
  padding: 10px;
}

.layer-name-input,
.pen-name-input {
  user-select: text;
}

/* Pattern Designer Inline Panel */
.pattern-designer-inline-wrap {
  width: 100%;
}

.pattern-designer-inline {
  width: 100%;
  padding: 8px 4px 4px;
  border-top: 1px solid var(--vectura-border);
}

.pd-tool-btn {
  border: 1px solid var(--ui-border-hi);
  background: var(--ui-panel-alt);
  color: var(--ui-text);
  width: 24px;
  height: 24px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
}

.pd-tool-btn:hover {
  border-color: #67e8f9;
  color: #cffafe;
}

.pd-tool-btn.active {
  border-color: #22d3ee;
  color: #22d3ee;
  background: rgba(34, 211, 238, 0.12);
}

/* Touch devices: suppress iOS long-press text selection and callout menu */
@media (pointer: coarse) {
  html, body {
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
  }
  input, textarea, [contenteditable] {
    -webkit-user-select: text;
    user-select: text;
  }
  /* Remove iOS 300ms click delay on layer cards so double-tap rename fires within the detection window */
  .lvl-card, .lvl-card-inner, .lvl-grp-hdr {
    touch-action: manipulation;
  }
  /* Ensure buttons reliably receive tap events even when an ancestor has user-select: none.
     Without this, iOS may not deliver click events on buttons inside a user-select:none tree. */
  button {
    touch-action: manipulation;
  }
}


/* === Migrated from legacy CSS (Unit 2.6: base/root + theme-toggle + chevron + tour + tutorials + help guide modal, 2026-05-20) === */
/* Note: 3 .theme-toggle[data-theme='X'] selectors rewritten to [data-active-icon='X'] (paired with src/ui/shell/theme-switcher.js dataset write rename). */

/* CSS-3 closure (2026-05-20): the legacy `:root { … }` skin-fallback block
 * that lived here was deleted. Its skin-palette tokens (--render-*,
 * --designer-*, --plotter-*, --vectura-*-rgb, --shadow-panel, --shadow-float)
 * now live inside each per-skin file (classic-{dark,light,lark}.css and
 * meridian-{dark,light,lark}.css). Structural tokens it also carried
 * (--pane-*, --bottom-pane-height, --lvl-*, color-scheme default) moved to
 * `tokens.css`, which is the canonical home for skin-agnostic CSS variables.
 */

body {
  background-color: var(--ui-bg);
  color: var(--ui-text);
  overflow: hidden;
}

html,
body {
  color-scheme: inherit;
}

body {
  transition: background-color 0.18s ease, color 0.18s ease;
}

.workspace-shell {
  background: var(--ui-workspace);
}

.header-status-actions {
  min-width: 0;
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  padding: 0;
  border: 1px solid var(--ui-border);
  border-radius: 9999px;
  background: var(--ui-panel-alt);
  color: var(--ui-text);
  font-size: 12px;
  line-height: 1;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.theme-toggle:hover {
  background: var(--ui-ctrl-hov);
  border-color: var(--ui-border-hi);
}

.theme-toggle:focus-visible {
  outline: 2px solid rgb(var(--vectura-accent-rgb) / 0.4);
  outline-offset: 2px;
}

.theme-toggle-icon {
  display: none;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  line-height: 1;
}

.theme-toggle__classic {
  display: block;
  width: 1.05rem;
  height: 1.05rem;
}

.theme-toggle__moon {
  display: block;
  width: 1rem;
  height: 1rem;
}

.theme-toggle__lark {
  display: block;
  width: 1rem;
  height: 1rem;
}

.theme-toggle[data-active-icon='light'] .theme-toggle-icon--light,
.theme-toggle[data-active-icon='dark'] .theme-toggle-icon--dark,
.theme-toggle[data-active-icon='lark'] .theme-toggle-icon--lark,
.theme-toggle[data-active-icon='system'] .theme-toggle-icon--system {
  display: inline-flex;
}

.theme-toggle__system {
  display: block;
  width: 1.05rem;
  height: 1.05rem;
}

::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: var(--ui-panel);
}
::-webkit-scrollbar-thumb {
  background: var(--ui-border-hi);
}
::-webkit-scrollbar-thumb:hover {
  background: var(--ui-border-hi);
}

input[type='range'] {
  -webkit-appearance: none;
  background: transparent;
}
input[type='range']::-webkit-slider-thumb {
  -webkit-appearance: none;
  height: 12px;
  width: 12px;
  background: var(--ui-accent);
  cursor: pointer;
  margin-top: -5px;
  border: 1px solid var(--ui-bg);
}
input[type='range']::-webkit-slider-runnable-track {
  width: 100%;
  height: 2px;
  cursor: pointer;
  background: var(--ui-border-hi);
}

input[type='color'] {
  -webkit-appearance: none;
  border: none;
  width: 100%;
  height: 100%;
  padding: 0;
  background: transparent;
  cursor: pointer;
}
input[type='color']::-webkit-color-swatch-wrapper {
  padding: 0;
}
input[type='color']::-webkit-color-swatch {
  border: none;
  border-radius: 9999px;
}

.paper-texture {
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 400 400' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)' opacity='0.05'/%3E%3C/svg%3E");
  pointer-events: none;
}

.tool-bar {
  position: absolute;
  top: 20px;
  left: 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px 8px;
  background: var(--ui-panel-alt);
  border: 1px solid var(--ui-border);
  border-radius: 12px;
  z-index: 30;
  box-shadow: var(--shadow-panel);
  max-height: calc(100% - 40px);
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
}
.tool-bar:empty { visibility: hidden; }
.tool-bar::-webkit-scrollbar { width: 4px; }
.tool-bar::-webkit-scrollbar-thumb { background: var(--ui-border-hi); border-radius: 2px; }

.mobile-pane-handle {
  display: none;
  position: fixed;
  z-index: 70;
  border: 1px solid var(--ui-border-hi);
  background: rgb(var(--vectura-bg-rgb) / 0.94);
  color: var(--ui-text-2);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  padding: 8px 7px;
}

.mobile-pane-handle-left,
.mobile-pane-handle-right {
  top: 52%;
  transform: translateY(-50%);
  writing-mode: vertical-rl;
}

.mobile-pane-handle-left {
  left: 0;
  border-left: none;
  border-radius: 0 8px 8px 0;
}

.mobile-pane-handle-right {
  right: 0;
  border-right: none;
  border-radius: 8px 0 0 8px;
}

.mobile-pane-handle-bottom {
  bottom: 10px;
  right: 10px;
  border-radius: 9999px;
  padding: 6px 11px;
}

#main-canvas {
  touch-action: none;
}

.touch-modifier-bar {
  position: absolute;
  left: 76px;
  top: 20px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px;
  border: 1px solid var(--ui-border);
  border-radius: 12px;
  background: rgb(var(--vectura-panel-rgb) / 0.95);
  z-index: 30;
  box-shadow: var(--shadow-panel);
}

.touch-mod-btn {
  border: 1px solid var(--ui-border);
  border-radius: 8px;
  min-width: 44px;
  height: 30px;
  padding: 0 10px;
  color: var(--ui-text-2);
  background: var(--ui-bg);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.touch-mod-btn.active {
  color: #67e8f9;
  border-color: #155e75;
  background: #082f49;
}

.tool-btn {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  border: 1px solid var(--ui-border);
  background: var(--ui-ctrl);
  color: var(--ui-text);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.tool-icon {
  width: 16px;
  height: 16px;
  display: block;
}

.tool-btn:hover {
  background: var(--ui-ctrl-hov);
  color: var(--ui-accent);
}

.tool-btn:focus-visible {
  outline: 2px solid var(--ui-accent);
  outline-offset: 2px;
}

.tool-btn.active {
  border-color: #38bdf8;
  color: #38bdf8;
  background: rgba(56, 189, 248, 0.1);
}

.tool-divider {
  height: 1px;
  width: 100%;
  background: var(--ui-border);
  margin: 2px 0;
}

.tool-group {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: center;
}

.tool-submenu {
  position: absolute;
  left: 44px;
  top: 0;
  display: none;
  flex-direction: column;
  gap: 4px;
  padding: 6px;
  border-radius: 12px;
  border: 1px solid var(--ui-border);
  background: var(--ui-panel-alt);
  box-shadow: var(--shadow-float);
  z-index: 40;
}

.tool-submenu.open {
  display: flex;
}

.tool-sub-btn {
  width: 28px;
  height: 28px;
  border-radius: 9px;
  border: 1px solid var(--ui-border);
  background: var(--ui-panel-alt);
  color: var(--ui-text-2);
  font-size: 0.65rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.tool-sub-btn svg {
  width: 16px;
  height: 16px;
}

.tool-sub-btn:hover {
  color: var(--ui-accent);
  background: var(--ui-ctrl-hov);
}

.tool-sub-btn.hover {
  color: var(--ui-accent);
  background: var(--ui-ctrl-hov);
  border-color: #38bdf8;
}

.tool-sub-btn.active {
  border-color: #38bdf8;
  color: #38bdf8;
  background: rgba(56, 189, 248, 0.12);
}

.tool-btn.hidden {
  display: none;
}

.drag-value-tooltip {
  position: fixed;
  display: none;
  pointer-events: none;
  z-index: 1000;
  /* Measurement chip: a light-gray rounded box with dark,
     two-line text (X/Y or dX/dY). `white-space: pre` renders the newline the
     readout embeds between the two axes. */
  font-size: 11px;
  line-height: 1.35;
  font-family: var(--font-ui, system-ui, -apple-system, sans-serif);
  color: #2b2b30;
  background: rgba(233, 233, 236, 0.96);
  padding: 4px 8px;
  border-radius: 4px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.28);
  white-space: pre;
  user-select: none;
}

.drag-anchor-label {
  position: fixed;
  display: none;
  pointer-events: none;
  z-index: 1001;
  /* Pink feature label pinned at the point (e.g. "anchor"), shown on select/hover
     but not while dragging. */
  font-size: 11px;
  line-height: 1.2;
  font-family: var(--font-ui, system-ui, -apple-system, sans-serif);
  color: #f472b6;
  white-space: nowrap;
  user-select: none;
}

.fill-loupe {
  position: fixed;
  display: none;
  pointer-events: none;
  z-index: 1000;
  width: 0;
  height: 0;
}
.fill-loupe-bucket {
  position: absolute;
  left: 0;
  top: 0;
  width: 28px;
  height: 28px;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.5));
}
.fill-loupe-bucket svg {
  width: 28px;
  height: 28px;
  display: block;
}
.fill-loupe-magnifier {
  position: absolute;
  width: 96px;
  height: 96px;
  border-radius: 50%;
  border: 2px solid #38bdf8;
  background: var(--ui-panel-alt, #111);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
}

.control-group {
  margin-bottom: 1.5rem;
  border-bottom: 1px solid var(--ui-border);
  padding-bottom: 1.5rem;
}

.control-label {
  display: block;
  font-size: 0.75rem;
  line-height: 1rem;
  color: var(--ui-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.5rem;
}

.value-chip {
  background: transparent;
  border: none;
  padding: 0;
  cursor: pointer;
}

.value-input.hidden {
  display: none;
}

.control-section {
  margin: 1.5rem 0 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--ui-border);
}

.control-section-title {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ui-text-2);
}

.left-panel-sections {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.left-panel-section {
  border: 1px solid var(--ui-border);
  background: var(--ui-panel-alt);
}

.left-panel-section-header {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--ui-panel-alt);
  border: none;
  border-bottom: 1px solid var(--ui-border);
  padding: 0.65rem 0.75rem;
  cursor: pointer;
  text-align: left;
}

.left-panel-section-title {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ui-text-2);
}

.left-panel-section-toggle {
  width: 14px;
  height: 14px;
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.left-panel-section-toggle::before {
  content: '';
  display: block;
  width: 12px;
  height: 12px;
  background-color: var(--ui-text-2);
  -webkit-mask: var(--chevron-svg) center / contain no-repeat;
  mask: var(--chevron-svg) center / contain no-repeat;
  transform: rotate(180deg);
  transition: transform 0.2s ease, background-color 0.15s ease;
}

.left-panel-section.collapsed .left-panel-section-toggle::before {
  transform: rotate(0deg);
}

.left-panel-section-body {
  padding: 0.75rem;
}

#algo-about {
  background: var(--ui-panel);
}



/* ── Submenu chevron badge — direction-aware ──────────────────────────── */
.tool-btn[data-has-submenu] {
  position: relative;
}
.tool-btn[data-has-submenu]::after {
  content: '';
  position: absolute;
  bottom: 2px;
  right: 2px;
  width: 8px;
  height: 8px;
  background-color: currentColor;
  -webkit-mask: var(--chevron-svg) center / contain no-repeat;
  mask: var(--chevron-svg) center / contain no-repeat;
  /* default: pointing right (chevron-down rotated -90°); transitions on dock change */
  transform: rotate(-90deg);
  opacity: 0.55;
  pointer-events: none;
  transition: transform 0.2s ease;
}
/* pointing right — menu opens to the right */
.tool-btn[data-has-submenu][data-submenu-dir="right"]::after  { transform: rotate(-90deg); }
/* pointing down — menu opens below */
.tool-btn[data-has-submenu][data-submenu-dir="below"]::after  { transform: rotate(0deg); }
/* pointing up — menu opens above (e.g. bottom-docked toolbar) */
.tool-btn[data-has-submenu][data-submenu-dir="above"]::after  { transform: rotate(180deg); }
/* pointing left — menu opens to the left (e.g. right-docked toolbar) */
.tool-btn[data-has-submenu][data-submenu-dir="left"]::after   { transform: rotate(90deg); }

/* ── Welcome tour popover ─────────────────────────────────────────────── */
.tutorial-popover {
  position: fixed;
  z-index: 10001;
  width: 270px;
  max-width: calc(100vw - 16px);
  background: var(--ui-panel);
  border: 1px solid var(--ui-border);
  border-radius: 8px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.55);
  padding: 14px 16px 12px;
  font-size: 13px;
  line-height: 1.5;
  color: var(--ui-text, inherit);
}
.tutorial-popover[aria-hidden="true"] {
  display: none;
}

.tutorial-arrow {
  position: absolute;
  width: 10px;
  height: 18px;
  overflow: hidden;
  pointer-events: none;
}
.tutorial-arrow::before {
  content: '';
  position: absolute;
  width: 12px;
  height: 12px;
  background: var(--ui-panel);
  border: 1px solid var(--ui-border);
  transform: rotate(45deg);
}

.tutorial-popover[data-placement="right"] .tutorial-arrow {
  left: -10px;
  top: 50%;
  transform: translateY(-50%);
}
.tutorial-popover[data-placement="right"] .tutorial-arrow::before {
  top: 3px;
  left: 5px;
}

.tutorial-popover[data-placement="left"] .tutorial-arrow {
  right: -10px;
  top: 50%;
  transform: translateY(-50%);
}
.tutorial-popover[data-placement="left"] .tutorial-arrow::before {
  top: 3px;
  right: 5px;
}

.tutorial-popover[data-placement="bottom"] .tutorial-arrow {
  top: -10px;
  left: 50%;
  transform: translateX(-50%);
  width: 18px;
  height: 10px;
}
.tutorial-popover[data-placement="bottom"] .tutorial-arrow::before {
  top: 5px;
  left: 3px;
}

.tutorial-popover[data-placement="top"] .tutorial-arrow {
  bottom: -10px;
  left: 50%;
  transform: translateX(-50%);
  width: 18px;
  height: 10px;
}
.tutorial-popover[data-placement="top"] .tutorial-arrow::before {
  bottom: 5px;
  left: 3px;
}

.tutorial-popover[data-placement="center"] .tutorial-arrow,
.tutorial-popover[data-placement="over"] .tutorial-arrow,
.tutorial-popover[data-placement="left-bottom"] .tutorial-arrow {
  display: none;
}

/* Movable popover — drag from header/title to reposition. */
.tutorial-popover.is-movable .tutorial-meta,
.tutorial-popover.is-movable .tutorial-title {
  cursor: grab;
  user-select: none;
}
.tutorial-popover.is-movable.is-dragging {
  cursor: grabbing;
}
.tutorial-popover.is-movable.is-dragging .tutorial-meta,
.tutorial-popover.is-movable.is-dragging .tutorial-title {
  cursor: grabbing;
}
.tutorial-popover.is-dragging {
  transition: none;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.7);
}

.tutorial-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}
.tutorial-step-num {
  font-size: 10px;
  opacity: 0.45;
  letter-spacing: 0.05em;
}
.tutorial-close {
  background: none;
  border: none;
  cursor: pointer;
  opacity: 0.4;
  font-size: 12px;
  padding: 0;
  line-height: 1;
  color: inherit;
}
@media (hover: hover) {
  .tutorial-close:hover {
  opacity: 0.9;
}
}
.tutorial-title {
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--ui-text, inherit);
}
.tutorial-body {
  font-size: 12px;
  line-height: 1.55;
  opacity: 0.75;
  margin-bottom: 14px;
}
.tutorial-body b {
  opacity: 1;
  font-weight: 600;
  color: var(--ui-accent);
}
.tutorial-wait {
  font-size: 11px;
  font-style: italic;
  opacity: 0.6;
  margin: -6px 0 12px 0;
  line-height: 1.4;
}
.tutorial-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.tutorial-dots {
  display: flex;
  gap: 5px;
  flex: 1;
  justify-content: center;
}
.tutorial-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.2;
  transition: opacity 0.15s;
}
.tutorial-dot.active {
  opacity: 0.85;
}
.tutorial-btn {
  background: none;
  border: 1px solid var(--ui-border);
  border-radius: 4px;
  padding: 0;
  width: 28px;
  height: 26px;
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
  color: inherit;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.tutorial-btn--next {
  background: var(--ui-accent);
  border-color: transparent;
  color: var(--ui-bg);
}
@media (hover: hover) {
  .tutorial-btn--next:hover {
  opacity: 0.85;
}
}
.tutorial-btn--back {
  opacity: 0.45;
  border-color: transparent;
}
@media (hover: hover) {
  .tutorial-btn--back:hover {
  opacity: 0.75;
}
}
.tutorial-sq-panel {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid color-mix(in srgb, currentColor 12%, transparent);
}
.tutorial-sq-label {
  font-size: 10px;
  opacity: 0.55;
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.tutorial-sq-cards {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.tutorial-sq-card {
  flex: 1;
  min-width: 70px;
  background: none;
  border: 1px solid var(--ui-border);
  border-radius: 4px;
  padding: 6px 4px;
  font-size: 10px;
  cursor: pointer;
  color: inherit;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  opacity: 0.7;
  transition: opacity 0.15s, border-color 0.15s;
}
@media (hover: hover) {
  .tutorial-sq-card:hover {
  opacity: 1;
  border-color: var(--ui-accent);
}
}
.tutorial-sq-icon {
  font-size: 14px;
  line-height: 1;
}
.tutorial-sq-name {
  font-size: 10px;
  text-align: center;
  line-height: 1.2;
}
.tutorial-sq-card.is-done {
  border-color: var(--ui-accent);
  opacity: 1;
}
.tutorial-sq-card.is-done .tutorial-sq-name::after {
  content: ' ✓';
  color: var(--ui-accent);
}
.tutorial-cta-row {
  display: flex;
  gap: 8px;
  margin-top: 14px;
  justify-content: flex-end;
  flex-wrap: wrap;
}
.tutorial-cta-btn {
  background: none;
  border: 1px solid var(--ui-border);
  border-radius: 4px;
  padding: 6px 12px;
  font: inherit;
  font-size: 12px;
  cursor: pointer;
  color: inherit;
  white-space: nowrap;
  transition: opacity 0.15s, background 0.15s, border-color 0.15s;
}
.tutorial-cta-primary {
  background: var(--ui-accent);
  border-color: transparent;
  color: var(--ui-bg);
  font-weight: 600;
}
@media (hover: hover) {
  .tutorial-cta-primary:hover {
  opacity: 0.85;
}
}
.tutorial-cta-secondary {
  opacity: 0.7;
}
@media (hover: hover) {
  .tutorial-cta-secondary:hover {
  opacity: 1;
  border-color: var(--ui-accent);
}
}

/* ── Tutorial highlight + focus indicators ───────────────────────────── */
.tutorial-highlight {
  position: fixed;
  z-index: 10000;
  pointer-events: none;
  border: 2px solid var(--ui-accent);
  border-radius: 6px;
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--ui-accent) 35%, transparent),
              0 0 24px color-mix(in srgb, var(--ui-accent) 60%, transparent);
  opacity: 0;
  transition: opacity 0.4s ease, left 0.18s ease, top 0.18s ease,
              width 0.18s ease, height 0.18s ease;
}
.tutorial-highlight.is-visible {
  opacity: 1;
}
.tutorial-highlight.is-pulse {
  animation: tutorialPulse 1.6s ease-in-out infinite;
}
@keyframes tutorialPulse {
  0%, 100% {
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--ui-accent) 35%, transparent),
                0 0 18px color-mix(in srgb, var(--ui-accent) 50%, transparent);
  }
  50% {
    box-shadow: 0 0 0 8px color-mix(in srgb, var(--ui-accent) 50%, transparent),
                0 0 32px color-mix(in srgb, var(--ui-accent) 80%, transparent);
  }
}

.tutorial-circle {
  position: fixed;
  z-index: 9989;
  pointer-events: none;
  border: 2px dashed var(--ui-accent);
  border-radius: 50%;
  opacity: 0;
  animation: tutorialCircleFade 2.4s ease-in-out infinite;
}
@keyframes tutorialCircleFade {
  0%   { opacity: 0;    transform: scale(0.85); }
  35%  { opacity: 0.85; transform: scale(1.0); }
  65%  { opacity: 0.85; transform: scale(1.0); }
  100% { opacity: 0;    transform: scale(1.15); }
}

/* Inline icon glyphs inside tutorial body */
.tutorial-icon-inline {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  vertical-align: -2px;
  width: 14px;
  height: 14px;
  color: var(--ui-accent);
  margin: 0 1px;
}
.tutorial-icon-inline svg {
  width: 100%;
  height: 100%;
}

/* ── Help guide: kbd badges ───────────────────────────────────────────── */
kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  padding: 2px 6px;
  background: var(--ui-bg);
  border: 1px solid var(--ui-border);
  border-bottom: 3px solid rgba(0, 0, 0, 0.35);
  border-radius: 4px;
  font-size: 11px;
  font-family: inherit;
  letter-spacing: 0.02em;
  user-select: none;
  white-space: nowrap;
  color: var(--ui-text, inherit);
}

/* ── Help guide: modal variant ────────────────────────────────────────── */
/* ── Help Guide modal ────────────────────────────────────────── */
.modal-card--help {
  width: min(820px, calc(100% - 32px));
}

.help-wrap {
  display: flex;
  flex-direction: column;
  gap: 0;
}

/* ── Toolbar (tabs + platform toggle) ────────────────────────── */
.help-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border-bottom: 1px solid var(--ui-border);
  padding-bottom: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.help-tabs {
  display: flex;
  gap: 3px;
  flex-wrap: wrap;
}

.help-tab-btn {
  padding: 4px 11px;
  border-radius: 4px;
  font-size: 11px;
  background: none;
  border: 1px solid transparent;
  cursor: pointer;
  opacity: 0.55;
  color: inherit;
  transition: opacity 0.1s, background 0.1s;
}
@media (hover: hover) {
  .help-tab-btn:hover { opacity: 0.85; }
}
.help-tab-btn.active {
  background: rgb(var(--vectura-accent-rgb, 99 179 237) / 0.12);
  border-color: var(--ui-accent);
  opacity: 1;
  color: var(--ui-accent);
}

.help-platform-toggle {
  display: flex;
  border: 1px solid var(--ui-border);
  border-radius: 5px;
  overflow: hidden;
  flex-shrink: 0;
}
.help-platform-btn {
  padding: 3px 10px;
  font-size: 11px;
  background: none;
  border: none;
  cursor: pointer;
  opacity: 0.45;
  color: inherit;
}
.help-platform-btn.active {
  background: var(--ui-border);
  opacity: 1;
}

/* ── Panels ──────────────────────────────────────────────────── */
.help-panel { min-height: 200px; }

/* ── Quick-start hero grid ───────────────────────────────────── */
.help-qs-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 7px;
  margin-bottom: 20px;
}

.help-qs-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 6px;
  border: 1px solid var(--ui-border);
  background: var(--ui-bg);
  transition: border-color 0.15s;
}
.help-qs-card:hover { border-color: var(--ui-accent); }

.help-qs-keys {
  display: flex;
  gap: 3px;
  flex-shrink: 0;
  min-width: 54px;
  justify-content: flex-end;
}
.help-qs-label {
  font-size: 12px;
  opacity: 0.8;
}
.help-qs-sublabel {
  font-size: 10px;
  opacity: 0.45;
  margin-top: 1px;
}

/* ── Getting-started steps ───────────────────────────────────── */
.help-steps-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  opacity: 0.35;
  margin-bottom: 8px;
}

.help-steps {
  list-style: none;
  counter-reset: help-step;
  padding: 0;
  margin: 0 0 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.help-step {
  counter-increment: help-step;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 6px;
  border: 1px solid var(--ui-border);
  background: var(--ui-bg);
}
.help-step::before {
  content: counter(help-step);
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--ui-border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  opacity: 0.7;
  line-height: 18px;
  text-align: center;
}

.help-step-body {
  font-size: 12px;
  line-height: 1.5;
  opacity: 0.8;
}

/* ── Callout / tip box ───────────────────────────────────────── */
.help-callout {
  font-size: 11.5px;
  line-height: 1.6;
  border-radius: 6px;
  border: 1px solid var(--ui-border);
  padding: 10px 13px;
  margin-top: 14px;
  opacity: 0.75;
  background: var(--ui-panel-alt);
}
.help-callout--info {
  border-left: 3px solid rgb(var(--vectura-accent-rgb) / 0.45);
  padding-left: 11px;
}
.help-callout-list {
  margin: 7px 0 2px;
  padding-left: 18px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.help-callout-list li { font-size: 11.5px; }

/* ── Keyboard shortcut table ─────────────────────────────────── */
.help-kbd-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
.help-kbd-table td { padding: 4px 6px; vertical-align: middle; }

.help-row { border-radius: 4px; }
.help-row:hover td { background: var(--ui-border); }
.help-row:hover td:first-child { border-radius: 4px 0 0 4px; }
.help-row:hover td:last-child  { border-radius: 0 4px 4px 0; }

.help-row-keys {
  white-space: nowrap;
  text-align: right;
  width: 140px;
  padding-right: 10px;
}
.help-row-desc { opacity: 0.75; }
.help-row-note {
  font-size: 10px;
  opacity: 0.38;
  text-align: right;
  padding-left: 8px;
  white-space: nowrap;
}

.help-section-row td { padding: 0; }
.help-section-hdr {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  opacity: 0.35;
  padding: 14px 6px 4px !important;
}

/* ── Mouse / gesture labels ──────────────────────────────────── */
.help-mouse {
  font-size: 11px;
  opacity: 0.65;
  font-style: italic;
}
.help-plus {
  opacity: 0.35;
  padding: 0 2px;
}

/* ── Accordion (details/summary) ─────────────────────────────── */
.help-accordion {
  border: 1px solid var(--ui-border);
  border-radius: 6px;
  margin-bottom: 6px;
  overflow: hidden;
}
.help-accordion[open] { border-color: var(--ui-border-hi); }

.help-accordion-summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 7px 10px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  opacity: 0.5;
  user-select: none;
  transition: opacity 0.12s, background 0.12s;
}
.help-accordion-summary::-webkit-details-marker { display: none; }
.help-accordion-summary::before {
  content: '';
  display: inline-block;
  width: 12px;
  height: 12px;
  background-color: currentColor;
  -webkit-mask: var(--chevron-svg) center / contain no-repeat;
  mask: var(--chevron-svg) center / contain no-repeat;
  transform: rotate(0deg);
  transition: transform 0.15s ease;
  opacity: 0.7;
}
.help-accordion[open] .help-accordion-summary {
  opacity: 0.85;
  background: var(--ui-panel-alt);
  border-bottom: 1px solid var(--ui-border);
}
.help-accordion[open] .help-accordion-summary::before { transform: rotate(180deg); }
@media (hover: hover) {
  .help-accordion-summary:hover { opacity: 0.85; background: var(--ui-panel-alt); }
}

.help-accordion-body { padding: 4px 4px 6px; }

/* ── Algorithm table ─────────────────────────────────────────── */
.help-algo-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  margin-bottom: 2px;
}
.help-algo-table th {
  text-align: left;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  opacity: 0.35;
  padding: 4px 8px 8px;
  border-bottom: 1px solid var(--ui-border);
}
.help-algo-table td { padding: 6px 8px; vertical-align: middle; }
.help-algo-table tbody tr { border-bottom: 1px solid rgb(var(--vectura-border-rgb) / 0.4); }
.help-algo-table tbody tr:hover td { background: var(--ui-panel-alt); }
.help-algo-table tbody tr:last-child { border-bottom: none; }

.help-algo-name {
  font-weight: 600;
  white-space: nowrap;
  opacity: 0.85;
  width: 110px;
}
.help-algo-desc {
  opacity: 0.65;
  line-height: 1.4;
}

/* ── Category badges ─────────────────────────────────────────── */
.help-badge {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 3px;
  font-size: 9.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  white-space: nowrap;
  opacity: 0.8;
}
.help-badge--particle    { background: rgb(239 68  68  / 0.14); color: #f87171; }
.help-badge--math        { background: rgb(99  102 241 / 0.14); color: #a5b4fc; }
.help-badge--field       { background: rgb(20  184 166 / 0.14); color: #5eead4; }
.help-badge--botanical   { background: rgb(34  197 94  / 0.14); color: #86efac; }
.help-badge--structural  { background: rgb(234 179 8   / 0.14); color: #fde047; }

/* ------------------------------------------------------------------
 * Utilities (CSS-10, audit-2026-05-20 follow-up)
 * ------------------------------------------------------------------
 * `.is-hidden` is a display-none utility class introduced to replace
 * inline `style="display:none"` declarations in index.html. Inline
 * styles fight CSS specificity; a utility class with !important is
 * easier to override deliberately than ad-hoc inline styles.
 *
 * Scope note: the `.is-hidden` token is ALSO used as a state modifier
 * on `.lvl-card`, `.lvl-grp-hdr`, and `.lvl-ab.mask-outline-btn` in
 * the layers panel, where it means "the layer is toggled off" and
 * applies `opacity: .38` — those rows must remain visible. The
 * :not() guards below keep the layer-panel modifier semantics intact.
 * ------------------------------------------------------------------ */
.is-hidden:not(.lvl-card):not(.lvl-grp-hdr):not(.mask-outline-btn) {
  display: none !important;
}

/* ------------------------------------------------------------------
 * Raster-Plane — source widget + paint modal (v1.1.97)
 * ------------------------------------------------------------------
 * The inline `imageSource` control: live preview, preset gallery,
 * Import/Paint actions. The paint modal: full-size brush canvas.
 * ------------------------------------------------------------------ */
.image-source-widget {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.image-source-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.image-source-popout-toggle {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  padding: 3px;
  border: 1px solid var(--ui-border);
  border-radius: 5px;
  background: var(--ui-ctrl);
  color: var(--ui-muted);
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}
.image-source-popout-toggle:hover {
  background: var(--ui-ctrl-hov);
  border-color: var(--ui-border-hi);
  color: var(--ui-accent);
}
.image-source-popout-toggle svg { width: 100%; height: 100%; }
/* Floating ("popped out") image-source pane — fixed overlay above the canvas
   and panels (z 200) but below modals/toasts (z 1000+). Dragged by its header. */
.image-source-popout {
  position: fixed;
  z-index: 200;
  width: 232px;
  padding: 12px;
  background: var(--ui-panel);
  border: 1px solid var(--ui-border-hi);
  border-radius: 10px;
  box-shadow: 0 10px 34px rgba(0, 0, 0, 0.45);
}
.image-source-popout .image-source-header.is-drag-handle {
  cursor: move;
  user-select: none;
  touch-action: none;
}
.image-source-docked-placeholder {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  border: 1px dashed var(--ui-border);
  border-radius: 8px;
}
.image-source-btn.is-dock {
  flex: 0 0 auto;
  padding: 4px 10px;
}
.image-source-name {
  max-width: 60%;
}
/* Source preset picker — reuses the universal .hg-preset-* dropdown skin; this
   wrapper just guarantees it spans the panel width above the source preview. */
.image-source-preset-dropdown {
  width: 100%;
}
.image-source-preview {
  display: flex;
  justify-content: center;
  border: 1px solid var(--ui-border);
  background: var(--ui-panel-alt);
  border-radius: 8px;
  padding: 6px;
}
.image-source-preview canvas {
  width: 132px;
  height: 132px;
  image-rendering: auto;
  border-radius: 4px;
}
.image-source-actions {
  display: flex;
  gap: 6px;
}
.image-source-import-area {
  display: flex;
  align-items: center;
  gap: 6px;
}
.image-source-import-area .noise-dropzone.compact {
  flex: 1;
}
.image-source-btn {
  border: 1px solid var(--ui-border);
  background: var(--ui-ctrl);
  color: var(--ui-text);
  font-size: 11px;
  padding: 5px 8px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}
.image-source-btn:hover {
  background: var(--ui-ctrl-hov);
  border-color: var(--ui-border-hi);
  color: var(--ui-accent);
}
.image-source-gallery-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ui-muted);
}
.image-source-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(54px, 1fr));
  gap: 6px;
}
.image-source-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  border: 1px solid var(--ui-border);
  background: var(--ui-panel-alt);
  border-radius: 6px;
  padding: 4px 2px;
  cursor: pointer;
  transition: border-color 0.12s, background 0.12s;
}
.image-source-tile:hover {
  border-color: var(--ui-border-hi);
  background: var(--ui-ctrl-hov);
}
.image-source-tile.is-active {
  border-color: var(--ui-accent);
  box-shadow: 0 0 0 1px var(--ui-accent) inset;
}
.image-source-tile canvas {
  width: 44px;
  height: 44px;
  border-radius: 3px;
  display: block;
}
.image-source-tile-cap {
  font-size: 9px;
  color: var(--ui-text-2);
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Paint modal */
.modal-card--paint .modal-body {
  max-width: none;
}
.image-paint-modal {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 420px;
}
.image-paint-toolbar {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.image-paint-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.image-paint-cap {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ui-muted);
  min-width: 42px;
}
.image-paint-ops {
  flex-wrap: wrap;
}
.ip-swatch {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid var(--ui-border);
  cursor: pointer;
  padding: 0;
}
.ip-swatch.is-active {
  border-color: var(--ui-accent);
  box-shadow: 0 0 0 2px var(--ui-accent);
}
.ip-brush {
  flex: 1;
}
.ip-op {
  border: 1px solid var(--ui-border);
  background: var(--ui-ctrl);
  color: var(--ui-text);
  font-size: 11px;
  padding: 4px 8px;
  border-radius: 6px;
  cursor: pointer;
}
.ip-op:hover {
  background: var(--ui-ctrl-hov);
  border-color: var(--ui-border-hi);
}
.image-paint-canvas-wrap {
  display: flex;
  justify-content: center;
  background: var(--ui-panel-alt);
  border: 1px solid var(--ui-border);
  border-radius: 8px;
  padding: 8px;
}
.image-paint-canvas {
  width: 384px;
  height: 384px;
  max-width: 70vh;
  max-height: 70vh;
  touch-action: none;
  cursor: crosshair;
  border-radius: 4px;
  background: #fff;
}
.image-paint-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}
.image-paint-cancel,
.image-paint-apply {
  border: 1px solid var(--ui-border);
  font-size: 12px;
  padding: 6px 16px;
  border-radius: 6px;
  cursor: pointer;
}
.image-paint-cancel {
  background: var(--ui-ctrl);
  color: var(--ui-text);
}
.image-paint-apply {
  background: var(--ui-accent);
  color: var(--ui-on-accent);
  border-color: var(--ui-accent);
}

/* ============================================================================
   VECTURA TEXT PANEL (vtp-*)
   Ported from design-explorations/text-panel-synthesis.html.
   Every bespoke class is prefixed `vtp-` to avoid colliding with the app's
   existing .tab/.specimen/.scrub/.seg-ctrl/.sw-toggle/.reveal rules.
   Mounts inside #dynamic-controls (left pane ~290px) -> .vtp-panel is fluid.
   Renders under all 7 skins — colors are driven by skin tokens (var(--ui-*)),
   composited with color-mix() where a token needs alpha. No new tokens introduced.
   Deliberate non-token literals, each vetted for legibility on every skin:
     - select chevrons hardcode a neutral mid-gray (#909097): a native <select>
       cannot host a per-arrow mask/currentColor, and mid-gray reads on both light
       and dark control surfaces.
     - the favorite star uses a fixed gold (#e6b450) as a universal rating affordance.
     - decorative <=4% white sheens and the xypad knob's black drop-shadow degrade
       gracefully (invisible on light skins, subtle texture/shadow on dark).
   ============================================================================ */

/* global scrub guard — namespaced because it lands on <body>, not a vtp node */
body.vtp-is-scrubbing { cursor: ew-resize !important; }
body.vtp-is-scrubbing * { cursor: ew-resize !important; user-select: none !important; -webkit-user-select: none !important; }

.vtp-mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

/* ---------- panel shell ---------- */
.vtp-panel {
  width: 100%; background: var(--ui-panel);
  border: 1px solid var(--ui-border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg); overflow: hidden;
  font-family: var(--font-ui); font-size: var(--font-size-base); line-height: 1.4;
  color: var(--ui-text);
}
.vtp-titlebar {
  display: flex; align-items: center; gap: 8px;
  padding: 11px 12px 10px; border-bottom: 1px solid var(--ui-border);
  background: linear-gradient(180deg, var(--ui-ctrl-hov), var(--ui-panel));
}
.vtp-titlebar .vtp-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ui-accent); box-shadow: 0 0 7px var(--ui-accent); }
.vtp-titlebar h1 { font-size: 13px; font-weight: 700; margin: 0; letter-spacing: .2px; }
.vtp-titlebar .vtp-sub { margin-left: auto; font-size: var(--font-size-xs); color: var(--ui-muted); }

/* ---------- specimen (R2) — also the editable text field ---------- */
.vtp-specimen { border-bottom: 1px solid var(--ui-border); background: linear-gradient(180deg, var(--ui-bg), var(--ui-panel-alt)); }
.vtp-spec-head {
  display: flex; align-items: center; gap: 6px; padding: 5px 10px;
  font-size: var(--font-size-xs); color: var(--ui-text-2);
}
.vtp-spec-head-btn {
  flex: 0 0 auto; display: flex; align-items: center; gap: 6px; cursor: pointer; user-select: none;
  font-family: inherit; font-size: var(--font-size-xs); color: var(--ui-text-2); background: none; border: none; padding: 0; text-align: left;
}
.vtp-spec-head-btn:hover { color: var(--ui-text); }
.vtp-spec-head-btn:focus-visible { outline: 2px solid var(--ui-accent); outline-offset: 2px; border-radius: var(--radius-sm); }
.vtp-spec-head .vtp-chev { transition: transform .22s cubic-bezier(.22, 1, .36, 1); font-size: 9px; color: var(--ui-muted); }
.vtp-specimen.collapsed .vtp-chev { transform: rotate(-90deg); }
.vtp-spec-head .vtp-lbl { font-weight: 600; letter-spacing: .4px; text-transform: uppercase; }
.vtp-spec-pill-head { margin-left: auto; }
.vtp-spec-body { display: grid; grid-template-rows: 1fr; transition: grid-template-rows .24s cubic-bezier(.22, 1, .36, 1); }
.vtp-specimen.collapsed .vtp-spec-body { grid-template-rows: 0fr; }
.vtp-spec-inner { overflow: hidden; min-height: 0; }
.vtp-spec-stage {
  height: 78px; display: flex; align-items: center; justify-content: center; overflow: hidden;
  padding: 6px 10px; position: relative;
  background:
    linear-gradient(0deg, var(--ui-accent-2), transparent),
    repeating-linear-gradient(0deg, transparent, transparent 13px, rgba(255, 255, 255, .02) 13px, rgba(255, 255, 255, .02) 14px);
}
.vtp-guide-svg { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; overflow: visible; z-index: 0; }
.vtp-spec-text {
  color: var(--ui-text); white-space: pre; text-align: center; line-height: 1; position: relative; z-index: 1;
  /* fixed neutral preview face (NOT --font-ui): JS swaps font-family to the chosen
     typeface at runtime; 'Inter' is only the fallback shown before a face loads. */
  font-family: 'Inter', system-ui, sans-serif; font-weight: 600; font-size: 34px;
  transition: letter-spacing .08s, font-size .08s, transform .12s, -webkit-text-stroke-width .12s;
  cursor: text; outline: none; caret-color: var(--ui-accent);
}
.vtp-spec-text:focus { outline: 1px solid var(--ui-accent-2); outline-offset: 6px; border-radius: 2px; }
.vtp-spec-cap {
  display: flex; align-items: center; gap: 8px; padding: 4px 10px 6px;
  font-size: 9px; color: var(--ui-muted); border-top: 1px solid var(--ui-border);
}
.vtp-spec-cap .vtp-face { color: var(--ui-text-2); font-weight: 600; }
.vtp-spec-cap .vtp-dim { margin-left: auto; }
.vtp-guide-pick {
  height: 18px; background: var(--ui-ctrl); color: var(--ui-text-2);
  border: 1px solid var(--ui-border); border-radius: var(--radius-sm);
  font-family: inherit; font-size: 9px; font-weight: 600; letter-spacing: .2px;
  padding: 0 17px 0 7px; appearance: none; cursor: pointer;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 10 10'><path d='M2 3.5L5 6.5L8 3.5' stroke='%23909097' stroke-width='1.4' fill='none' stroke-linecap='round' stroke-linejoin='round'/></svg>");
  background-repeat: no-repeat; background-position: right 5px center; transition: .13s;
}
.vtp-guide-pick:hover { color: var(--ui-text); border-color: var(--ui-border-hi); }
.vtp-guide-pick:focus { outline: none; border-color: var(--ui-accent); box-shadow: 0 0 0 2px var(--ui-accent-2); }

/* ---------- context strip (R1a) ---------- */
.vtp-ctx-strip {
  display: flex; align-items: center; gap: 7px; padding: 6px 10px;
  border-bottom: 1px solid var(--ui-border); background: var(--ui-panel-alt); font-size: var(--font-size-xs);
}
.vtp-ctx-strip .vtp-ctx-face { color: var(--ui-text-2); }
.vtp-ctx-strip .vtp-ctx-face b { color: var(--ui-text); font-weight: 600; }
.vtp-chip {
  margin-left: auto; display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 8px; border-radius: 999px; font-size: 9px; font-weight: 600; letter-spacing: .3px;
  border: 1px solid var(--ui-border-hi);
}
.vtp-chip .vtp-pip { width: 6px; height: 6px; border-radius: 50%; }
.vtp-chip.outline { background: var(--ui-accent-2); color: var(--ui-accent); border-color: color-mix(in srgb, var(--ui-accent) 40%, transparent); }
.vtp-chip.outline .vtp-pip { background: var(--ui-accent); box-shadow: 0 0 5px var(--ui-accent); }
.vtp-chip.stroke { background: color-mix(in srgb, var(--ui-danger) 10%, transparent); color: var(--ui-danger); border-color: color-mix(in srgb, var(--ui-danger) 40%, transparent); }
.vtp-chip.stroke .vtp-pip { background: var(--ui-danger); box-shadow: 0 0 5px var(--ui-danger); }

/* ---------- tab bar (R1) ---------- */
.vtp-tabbar { display: flex; gap: 3px; padding: 7px 8px; background: var(--ui-panel); border-bottom: 1px solid var(--ui-border); }
.vtp-tab {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 6px 2px 5px; border-radius: var(--radius-sm); cursor: pointer;
  color: var(--ui-muted); background: transparent; border: 1px solid transparent;
  font-size: var(--font-size-xs); font-weight: 600; transition: .13s; position: relative;
  font-family: inherit;
}
.vtp-tab svg { width: 15px; height: 15px; stroke: currentColor; fill: none; stroke-width: 1.6; }
.vtp-tab:hover { color: var(--ui-text-2); background: var(--ui-ctrl); }
.vtp-tab:focus-visible { outline: 2px solid var(--ui-accent); outline-offset: 1px; }
.vtp-tab.active { color: var(--ui-on-accent); background: var(--ui-accent); box-shadow: 0 2px 8px color-mix(in srgb, var(--ui-accent) 35%, transparent); }
.vtp-tab.disabled { opacity: .42; cursor: not-allowed; }

/* ---------- tab body ---------- */
.vtp-tab-body { padding: 11px 12px 14px; min-height: 120px; }
.vtp-tab-heading {
  display: flex; align-items: center; gap: 7px; margin: -2px 0 11px;
  font-size: var(--font-size-sm); font-weight: 600; color: var(--ui-text);
}
.vtp-tab-heading svg { width: 14px; height: 14px; stroke: var(--ui-accent); fill: none; stroke-width: 1.6; }
.vtp-tab-heading .vtp-h-sub { margin-left: auto; font-size: 9px; color: var(--ui-muted); font-weight: 400; }
.vtp-page { display: none; }
.vtp-page.active { display: block; animation: vtp-fade .18s ease; }
@keyframes vtp-fade { from { opacity: 0; transform: translateY(3px); } to { opacity: 1; transform: none; } }

/* ---------- generic rows ---------- */
.vtp-grp-label { font-size: 9px; font-weight: 600; text-transform: uppercase; letter-spacing: .6px; color: var(--ui-muted); margin: 13px 0 7px; display: flex; align-items: center; gap: 6px; }
.vtp-grp-label::before { content: ""; width: 3px; height: 11px; border-radius: 2px; background: var(--ui-accent); opacity: .55; }
.vtp-grp-label:first-child { margin-top: 0; }
.vtp-grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
/* allow 1fr tracks + scrub fields to shrink so the right column wraps cleanly */
.vtp-grid2 > * { min-width: 0; }
.vtp-field-block { margin-bottom: 7px; }

/* combo / select */
.vtp-vselect {
  width: 100%; height: var(--row-height); background: var(--ui-ctrl); color: var(--ui-text);
  border: 1px solid var(--ui-border); border-radius: var(--radius-sm);
  padding: 0 28px 0 9px; font-family: var(--font-ui); font-size: var(--font-size-sm);
  appearance: none; cursor: pointer;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 10 10'><path d='M2 3.5L5 6.5L8 3.5' stroke='%23909097' stroke-width='1.4' fill='none' stroke-linecap='round' stroke-linejoin='round'/></svg>");
  background-repeat: no-repeat; background-position: right 9px center;
  transition: .14s;
}
.vtp-vselect:focus { outline: none; border-color: var(--ui-accent); box-shadow: 0 0 0 3px var(--ui-accent-2); }
.vtp-field-cap { font-size: 9px; color: var(--ui-muted); margin: 0 0 4px 1px; display: flex; align-items: center; gap: 5px; }

/* ---------- SCRUBBY numeric field (R4) ---------- */
.vtp-scrub {
  display: flex; align-items: stretch; height: var(--row-height); min-width: 0; background: var(--ui-ctrl);
  border: 1px solid var(--ui-border); border-radius: var(--radius-sm); overflow: hidden;
  transition: border-color .14s, box-shadow .14s;
}
.vtp-scrub:focus-within { border-color: var(--ui-accent); box-shadow: 0 0 0 3px var(--ui-accent-2); }
.vtp-scrub.scrubbing { border-color: var(--slider-start); box-shadow: 0 0 0 3px color-mix(in srgb, var(--slider-start) 18%, transparent); }
.vtp-scrub.disabled { opacity: .45; pointer-events: none; }
.vtp-scrub-handle {
  display: flex; align-items: center; gap: 4px; padding: 0 6px 0 7px;
  cursor: ew-resize; user-select: none; -webkit-user-select: none; touch-action: none;
  border-right: 1px solid var(--ui-border);
  background: var(--ui-panel-alt); position: relative;
}
.vtp-scrub-handle:hover { background: var(--ui-ctrl-hov); }
.vtp-scrub-handle .vtp-gicon { width: 15px; height: 15px; display: flex; align-items: center; justify-content: center; color: var(--ui-text-2); pointer-events: none; }
.vtp-scrub-handle .vtp-gicon svg { width: 15px; height: 15px; stroke: currentColor; fill: none; stroke-width: 1.5; }
.vtp-scrub-handle .vtp-gicon .vtp-ftxt { font-size: 9px; font-weight: 700; font-family: var(--font-mono); letter-spacing: -.5px; }
.vtp-scrub-steppers { display: flex; flex-direction: column; width: 14px; border-right: 1px solid var(--ui-border); background: var(--ui-panel-alt); }
.vtp-scrub-steppers button {
  flex: 1; border: none; background: transparent; color: var(--ui-muted); cursor: pointer;
  display: flex; align-items: center; justify-content: center; padding: 0; line-height: 0;
}
.vtp-scrub-steppers button:hover { color: var(--ui-accent); background: var(--ui-ctrl-hov); }
.vtp-scrub-steppers button:focus-visible { outline: 2px solid var(--ui-accent); outline-offset: -2px; }
.vtp-scrub-steppers button:first-child { border-bottom: 1px solid var(--ui-border); }
.vtp-scrub-steppers svg { width: 8px; height: 8px; }
.vtp-scrub input {
  flex: 1; min-width: 0; border: none; background: transparent; color: var(--ui-text);
  font-family: var(--font-mono); font-size: var(--font-size-sm); text-align: right; padding: 0 4px 0 7px;
  font-variant-numeric: tabular-nums;
}
.vtp-scrub input:focus { outline: none; }
.vtp-scrub .vtp-unit { display: flex; align-items: center; padding: 0 7px 0 0; color: var(--ui-muted); font-size: 9px; font-family: var(--font-mono); }
.vtp-scrub-preset {
  border: none; border-left: 1px solid var(--ui-border); background: var(--ui-panel-alt);
  color: var(--ui-muted); cursor: pointer; width: 18px; display: flex; align-items: center; justify-content: center;
}
.vtp-scrub-preset:hover { color: var(--ui-accent); background: var(--ui-ctrl-hov); }
.vtp-scrub-preset:focus-visible { outline: 2px solid var(--ui-accent); outline-offset: -2px; }
.vtp-scrub-preset svg { width: 9px; height: 9px; }
.vtp-scrub-name { font-size: 9px; color: var(--ui-muted); margin: 0 0 4px 1px; cursor: ew-resize; user-select: none; -webkit-user-select: none; touch-action: none; display: inline-flex; align-items: center; gap: 4px; }
.vtp-scrub-name:hover { color: var(--ui-text-2); }
.vtp-scrub-name .vtp-drag-hint { opacity: .5; font-size: 8px; }

/* ---------- toggle (R-FUNCTIONAL) ---------- */
.vtp-row-toggle { display: flex; align-items: center; gap: 8px; min-height: var(--row-height); padding: 2px 0; }
.vtp-row-toggle .vtp-rt-label { font-size: var(--font-size-sm); color: var(--ui-text); }
.vtp-row-toggle .vtp-rt-sub { font-size: 9px; color: var(--ui-muted); }
.vtp-sw-toggle {
  margin-left: auto; width: 30px; height: 16px; border-radius: 999px; background: var(--ui-border);
  border: 1px solid var(--ui-border); position: relative; cursor: pointer; flex: none; transition: .16s; padding: 0;
}
.vtp-sw-toggle:focus-visible { outline: 2px solid var(--ui-accent); outline-offset: 2px; }
.vtp-sw-toggle .vtp-knob { position: absolute; top: 1px; left: 1px; width: 12px; height: 12px; border-radius: 50%; background: var(--ui-on-accent); transition: transform .16s cubic-bezier(.22, 1, .36, 1); box-shadow: var(--shadow-sm); }
.vtp-sw-toggle.on { background: var(--ui-accent); border-color: var(--ui-accent); }
.vtp-sw-toggle.on .vtp-knob { transform: translateX(14px); }

/* ---------- segmented (R3,R6,align) ---------- */
.vtp-seg-ctrl { display: flex; background: var(--ui-ctrl); border: 1px solid var(--ui-border); border-radius: var(--radius-sm); overflow: hidden; }
.vtp-seg-ctrl button {
  flex: 1; border: none; background: transparent; color: var(--ui-text-2); cursor: pointer;
  padding: 6px 4px; font-family: var(--font-ui); font-size: var(--font-size-xs); font-weight: 600;
  display: flex; align-items: center; justify-content: center; gap: 4px; transition: .12s; border-right: 1px solid var(--ui-border);
}
.vtp-seg-ctrl button:last-child { border-right: none; }
.vtp-seg-ctrl button svg { width: 13px; height: 13px; stroke: currentColor; fill: none; stroke-width: 1.6; }
.vtp-seg-ctrl button:hover { background: var(--ui-ctrl-hov); color: var(--ui-text); }
.vtp-seg-ctrl button:focus-visible { outline: 2px solid var(--ui-accent); outline-offset: -2px; }
.vtp-seg-ctrl button.active { background: var(--ui-accent); color: var(--ui-on-accent); }

/* style button row (caps etc) */
.vtp-glyph-row { display: flex; gap: 4px; flex-wrap: wrap; }
.vtp-glyph-btn {
  width: 30px; height: 28px; border-radius: var(--radius-sm); border: 1px solid var(--ui-border);
  background: var(--ui-ctrl); color: var(--ui-text-2); cursor: pointer;
  display: flex; align-items: center; justify-content: center; font-size: var(--font-size-sm); transition: .12s; position: relative;
  font-family: inherit;
}
.vtp-glyph-btn:hover { background: var(--ui-ctrl-hov); color: var(--ui-text); border-color: var(--ui-border-hi); }
.vtp-glyph-btn:focus-visible { outline: 2px solid var(--ui-accent); outline-offset: 1px; }
.vtp-glyph-btn.active { background: var(--ui-accent-2); border-color: var(--ui-accent); color: var(--ui-accent); }
/* Multi-part style-button glyphs: an inline-block wrapper restores inline flow
   inside the flex button so vertical-align lifts/drops the super/subscript and
   keeps the small-cap on the baseline. */
.vtp-glyph-btn .vtp-gl { display: inline-block; line-height: 1; white-space: nowrap; }
.vtp-glyph-btn .vtp-smc { font-size: 0.72em; vertical-align: baseline; margin-left: 0.5px; }
.vtp-glyph-btn .vtp-sup { font-size: 0.66em; vertical-align: super; margin-left: 0.5px; }
.vtp-glyph-btn .vtp-sub { font-size: 0.66em; vertical-align: sub; margin-left: 0.5px; }

/* align 7-row */
.vtp-align7 { display: flex; gap: 3px; }
.vtp-align7 .vtp-glyph-btn { flex: 1; width: auto; }
.vtp-align7 svg { width: 15px; height: 13px; stroke: currentColor; fill: none; stroke-width: 1.5; }

/* ---------- reveal animation ---------- */
.vtp-reveal { display: grid; grid-template-rows: 0fr; transition: grid-template-rows .22s cubic-bezier(.22, 1, .36, 1), opacity .2s; opacity: 0; }
.vtp-reveal.open { grid-template-rows: 1fr; opacity: 1; }
.vtp-reveal > .vtp-reveal-inner { overflow: hidden; min-height: 0; }
.vtp-reveal.open > .vtp-reveal-inner { padding-top: 2px; }

/* ---------- disabled / reason banner ---------- */
.vtp-reason {
  display: flex; gap: 8px; align-items: flex-start; padding: 9px 10px; border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--ui-danger) 8%, transparent); border: 1px solid color-mix(in srgb, var(--ui-danger) 28%, transparent); font-size: var(--font-size-xs); color: var(--ui-danger); line-height: 1.45;
}
.vtp-reason svg { width: 14px; height: 14px; flex: none; stroke: var(--ui-danger); fill: none; stroke-width: 1.7; margin-top: 1px; }
.vtp-reason b { color: var(--ui-text); }
.vtp-disabled-area { opacity: .4; pointer-events: none; filter: grayscale(.3); margin-top: 10px; }

/* thickening mode visual hints */
.vtp-thick-seg button { flex-direction: column; gap: 3px; padding: 6px 2px; font-size: 9px; }
.vtp-thick-seg button .vtp-hint { width: 26px; height: 8px; }
.vtp-thick-seg button .vtp-hint svg { width: 26px; height: 8px; stroke: currentColor; fill: none; stroke-width: 1.3; }

/* opentype feature buttons */
.vtp-ot-row { display: flex; flex-wrap: wrap; gap: 4px; }
.vtp-ot-btn {
  padding: 4px 8px; border-radius: var(--radius-sm); border: 1px solid var(--ui-border);
  background: var(--ui-ctrl); color: var(--ui-text-2); font-size: 9px; cursor: pointer; transition: .12s; font-weight: 600;
  font-family: inherit;
}
.vtp-ot-btn:hover { background: var(--ui-ctrl-hov); color: var(--ui-text); }
.vtp-ot-btn:focus-visible { outline: 2px solid var(--ui-accent); outline-offset: 1px; }
.vtp-ot-btn.active { background: var(--ui-accent-2); border-color: var(--ui-accent); color: var(--ui-accent); }
.vtp-ot-btn.locked { opacity: .4; cursor: not-allowed; }

.vtp-checkrow { display: flex; align-items: center; gap: 8px; font-size: var(--font-size-xs); color: var(--ui-text-2); cursor: pointer; margin-top: 9px; user-select: none; }
.vtp-checkrow:focus-visible { outline: 2px solid var(--ui-accent); outline-offset: 2px; border-radius: var(--radius-sm); }
.vtp-vcheck { width: 15px; height: 15px; border-radius: 3px; border: 1px solid var(--ui-border); background: var(--ui-ctrl); display: flex; align-items: center; justify-content: center; flex: none; transition: .12s; }
.vtp-vcheck svg { width: 9px; height: 9px; stroke: var(--ui-on-accent); fill: none; stroke-width: 2; opacity: 0; transition: .12s; }
.vtp-checkrow.on .vtp-vcheck { background: var(--ui-accent); border-color: var(--ui-accent); }
.vtp-checkrow.on .vtp-vcheck svg { opacity: 1; }

/* ---------- circular XY pad (fill offset) ---------- */
.vtp-xypad {
  position: relative; width: 86px; height: 86px; border-radius: 50%;
  background: var(--ui-ctrl); border: 1px solid var(--ui-border);
  margin: 3px auto 0; cursor: crosshair; touch-action: none;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .02);
}
.vtp-xypad:hover { border-color: var(--ui-border-hi); }
.vtp-xypad:focus-visible { outline: 2px solid var(--ui-accent); outline-offset: 2px; }
.vtp-xypad-cross::before, .vtp-xypad-cross::after { content: ""; position: absolute; background: var(--ui-border); }
.vtp-xypad-cross::before { left: 50%; top: 9%; bottom: 9%; width: 1px; transform: translateX(-.5px); }
.vtp-xypad-cross::after { top: 50%; left: 9%; right: 9%; height: 1px; transform: translateY(-.5px); }
.vtp-xypad-rim { position: absolute; inset: 12px; border-radius: 50%; border: 1px dashed var(--ui-border); }
.vtp-xypad-knob {
  position: absolute; width: 11px; height: 11px; border-radius: 50%;
  background: var(--ui-accent); border: 2px solid var(--ui-panel);
  left: 50%; top: 50%; transform: translate(-50%, -50%);
  box-shadow: 0 0 0 1px var(--ui-accent), 0 1px 3px rgba(0, 0, 0, .5); pointer-events: none; transition: box-shadow .12s;
}
.vtp-xypad.off .vtp-xypad-knob { background: var(--ui-muted); box-shadow: 0 0 0 1px var(--ui-border); }
.vtp-xypad-read { text-align: center; font-family: var(--font-mono); font-size: 9px; color: var(--ui-muted); margin-top: 5px; }

/* Shared UI.XYPad host (e.g. the Scene 3D Wrap origin row): pad above its readout, centred in the control column. */
.vtp-xypad-wrap { display: flex; flex-direction: column; align-items: center; width: 100%; }

/* Fill-offset pad + vertical max-offset slider, laid out side by side. */
.vtp-xypad-row { display: flex; align-items: center; justify-content: center; gap: 16px; margin-top: 3px; }
.vtp-xypad-row .vtp-xypad { margin: 0; }
.vtp-xypad-max { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px; height: 86px; }
.vtp-vslider-vert {
  writing-mode: vertical-lr; direction: rtl;
  flex: 1 1 auto; width: 4px; min-height: 0; height: auto; align-self: stretch;
}
.vtp-xypad-max .vtp-vchip { min-width: 0; text-align: center; }
.vtp-xypad-max-unit { font-family: var(--font-mono); font-size: 8px; color: var(--ui-muted); letter-spacing: .04em; }

/* Fill angle radial dial mount — centre the reusable AngleDial component. */
.vtp-angle-mount { display: flex; justify-content: center; margin-top: 3px; }

.vtp-hr { height: 1px; background: var(--ui-border); margin: 13px -12px; }
.vtp-info-i { width: 13px; height: 13px; border-radius: 50%; border: 1px solid var(--ui-border-hi); color: var(--ui-muted); font-size: 8px; display: inline-flex; align-items: center; justify-content: center; cursor: help; font-style: italic; font-family: var(--font-mono); }

/* slider for fill density etc — thumb pseudo-rules scoped under [data-ui-skin] per convention */
.vtp-vslider-wrap { display: flex; align-items: center; gap: 9px; height: var(--row-height); }
.vtp-vslider { flex: 1; -webkit-appearance: none; appearance: none; height: 4px; border-radius: 2px; background: var(--ui-border); outline: none; }
.vtp-vslider:focus-visible { box-shadow: 0 0 0 3px var(--ui-accent-2); }
[data-ui-skin] .vtp-vslider::-webkit-slider-thumb { -webkit-appearance: none; width: 14px; height: 14px; border-radius: 50%; background: var(--ui-accent); border: 2.5px solid var(--ui-panel); cursor: pointer; transition: transform .12s; box-shadow: 0 0 0 0 var(--ui-accent-2); }
[data-ui-skin] .vtp-vslider:hover::-webkit-slider-thumb { transform: scale(1.18); box-shadow: 0 0 0 4px var(--ui-accent-2); }
[data-ui-skin] .vtp-vslider::-moz-range-thumb { width: 14px; height: 14px; border-radius: 50%; background: var(--ui-accent); border: 2.5px solid var(--ui-panel); cursor: pointer; }
.vtp-vchip { font-family: var(--font-mono); font-size: var(--font-size-xs); color: var(--ui-accent); min-width: 34px; text-align: right; }

/* ---------- fill-line preview overlay (real hatch/dots clipped to glyphs) ---------- */
.vtp-fill-svg { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; overflow: visible; transform-origin: center; z-index: 2; }
.vtp-outline-svg { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; overflow: visible; transform-origin: center; z-index: 3; }
/* preview tool pills (top-right of the specimen stage) */
.vtp-spec-tools { position: absolute; top: 7px; right: 13px; z-index: 5; display: flex; flex-direction: column; gap: 5px; align-items: flex-end; }
.vtp-spec-pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 8px 3px 7px; border-radius: 999px; font-family: inherit; font-size: 9px; font-weight: 600;
  background: color-mix(in srgb, var(--ui-panel) 72%, transparent); border: 1px solid var(--ui-border-hi); color: var(--ui-text-2);
  cursor: pointer; -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); transition: .13s; letter-spacing: .2px;
}
.vtp-spec-pill:hover { color: var(--ui-text); border-color: var(--ui-accent); }
.vtp-spec-pill:focus-visible { outline: 2px solid var(--ui-accent); outline-offset: 1px; }
.vtp-spec-pill.on { color: var(--ui-accent); border-color: color-mix(in srgb, var(--ui-accent) 55%, transparent); background: var(--ui-accent-2); }
.vtp-spec-pill .vtp-dotp { width: 6px; height: 6px; border-radius: 50%; background: currentColor; box-shadow: 0 0 5px currentColor; }
/* the fill-lines pill only appears when fill is active */
.vtp-fill-toggle { display: none; }
.vtp-fill-toggle.show { display: inline-flex; }
.vtp-fill-legend {
  position: absolute; left: 13px; bottom: 7px; z-index: 4; display: none; align-items: center; gap: 9px;
  font-family: var(--font-mono); font-size: 8px; color: var(--ui-muted); letter-spacing: .2px; pointer-events: none;
  background: color-mix(in srgb, var(--ui-panel) 55%, transparent); padding: 2px 7px; border-radius: 999px; -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px);
}
.vtp-fill-legend.show { display: flex; }
.vtp-fill-legend i { width: 6px; height: 6px; border-radius: 50%; display: inline-block; margin-right: 3px; vertical-align: middle; }

.vtp-foot { margin-top: 13px; font-size: 8px; color: var(--ui-muted); text-align: center; letter-spacing: .3px; }
.vtp-sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); border: 0; }

/* ---------- font picker (names rendered in their own face; popover at body level) ---------- */
.vtp-fontpick-trigger {
  width: 100%; height: var(--row-height); display: flex; align-items: center; gap: 8px;
  background: var(--ui-ctrl); color: var(--ui-text);
  border: 1px solid var(--ui-border); border-radius: var(--radius-sm);
  padding: 0 9px; cursor: pointer; font-family: inherit; font-size: 14px; text-align: left; transition: .14s;
}
.vtp-fontpick-trigger:hover { background: var(--ui-ctrl-hov); }
.vtp-fontpick-trigger[aria-expanded="true"], .vtp-fontpick-trigger:focus-visible { outline: none; border-color: var(--ui-accent); box-shadow: 0 0 0 3px var(--ui-accent-2); }
.vtp-fontpick-trigger .vtp-fp-name { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; line-height: 1; }
.vtp-fontpick-trigger .vtp-fp-tagmini { font-size: 8px; color: var(--ui-muted); text-transform: uppercase; letter-spacing: .4px; flex: none; font-family: var(--font-mono); }
.vtp-fontpick-trigger .vtp-fp-chev { width: 10px; height: 10px; color: var(--ui-muted); flex: none; }

.vtp-fp-pop {
  position: fixed; z-index: 10000; width: 300px; background: var(--ui-panel);
  border: 1px solid var(--ui-border-hi); border-radius: var(--radius-md); box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column; overflow: hidden;
  opacity: 0; transform: translateY(-4px); pointer-events: none; transition: opacity .14s, transform .14s;
}
.vtp-fp-pop.open { opacity: 1; transform: none; pointer-events: auto; }
.vtp-fp-search { display: flex; align-items: center; gap: 7px; padding: 8px; border-bottom: 1px solid var(--ui-border); background: var(--ui-panel-alt); }
.vtp-fp-search svg { width: 13px; height: 13px; stroke: var(--ui-muted); fill: none; stroke-width: 1.7; flex: none; }
.vtp-fp-search input {
  flex: 1; border: 1px solid var(--ui-border); background: var(--ui-ctrl); color: var(--ui-text);
  font-family: var(--font-ui); font-size: var(--font-size-sm); padding: 6px 8px; border-radius: var(--radius-sm);
}
.vtp-fp-search input:focus { outline: none; border-color: var(--ui-accent); box-shadow: 0 0 0 3px var(--ui-accent-2); }
.vtp-fp-tags { display: flex; flex-wrap: wrap; gap: 5px; padding: 8px; border-bottom: 1px solid var(--ui-border); background: var(--ui-panel-alt); }
.vtp-fp-chip {
  font-family: inherit; font-size: 9px; font-weight: 600; letter-spacing: .3px; text-transform: uppercase;
  padding: 4px 9px; border-radius: 999px; border: 1px solid var(--ui-border-hi);
  background: var(--ui-ctrl); color: var(--ui-text-2); cursor: pointer; transition: .12s;
}
.vtp-fp-chip:hover { color: var(--ui-text); border-color: var(--ui-accent); }
.vtp-fp-chip:focus-visible { outline: 2px solid var(--ui-accent); outline-offset: 1px; }
.vtp-fp-chip.on { background: var(--ui-accent); border-color: var(--ui-accent); color: var(--ui-on-accent); }
.vtp-fp-list { overflow-y: auto; max-height: 280px; padding: 4px; scrollbar-width: thin; }
.vtp-fp-sec { font-size: 9px; font-weight: 600; text-transform: uppercase; letter-spacing: .6px; color: var(--ui-muted); padding: 9px 8px 4px; display: flex; align-items: center; gap: 5px; }
.vtp-fp-sec::before { content: ""; width: 3px; height: 9px; border-radius: 2px; background: var(--ui-accent); opacity: .5; }
.vtp-fp-opt { display: flex; align-items: center; gap: 8px; padding: 7px 8px; border-radius: var(--radius-sm); cursor: pointer; color: var(--ui-text); }
.vtp-fp-opt:hover, .vtp-fp-opt.active { background: var(--ui-ctrl-hov); }
.vtp-fp-opt.sel { background: var(--ui-accent-2); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--ui-accent) 35%, transparent); }
.vtp-fp-opt .vtp-fp-opt-name { flex: 1; font-size: 16px; line-height: 1.15; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* Built-in single-stroke faces preview as inline SVG drawn from the actual
   StrokeFont outline (not a CSS font), so the menu matches the plotted glyphs. */
.vtp-fp-opt-svg { display: block; height: 15px; width: auto; max-width: 100%; }
.vtp-fp-opt .vtp-fp-tag { font-size: 8px; color: var(--ui-muted); text-transform: uppercase; letter-spacing: .4px; flex: none; font-family: var(--font-mono); }
.vtp-fp-star { flex: none; width: 20px; height: 20px; display: flex; align-items: center; justify-content: center; border: none; background: none; cursor: pointer; color: var(--ui-border-hi); padding: 0; border-radius: 4px; }
.vtp-fp-star:hover { color: var(--ui-accent); background: var(--ui-ctrl); }
.vtp-fp-star.on { color: #e6b450; }
.vtp-fp-star svg { width: 14px; height: 14px; }
.vtp-fp-load { display: flex; align-items: center; gap: 8px; padding: 9px; margin: 6px 4px; border-radius: var(--radius-sm); background: var(--ui-accent-2); color: var(--ui-accent); font-size: var(--font-size-sm); cursor: pointer; border: 1px dashed color-mix(in srgb, var(--ui-accent) 40%, transparent); }
.vtp-fp-load:hover { background: color-mix(in srgb, var(--ui-accent) 18%, transparent); }
.vtp-fp-load svg { width: 14px; height: 14px; stroke: currentColor; fill: none; stroke-width: 1.7; flex: none; }
.vtp-fp-load b { font-weight: 600; color: var(--ui-text); }
.vtp-fp-empty { padding: 16px 10px; text-align: center; color: var(--ui-muted); font-size: var(--font-size-xs); line-height: 1.5; }

/* ---------- reduced motion (scoped to the panel + its body-level popover) ---------- */
@media (prefers-reduced-motion: reduce) {
  .vtp-panel *, .vtp-fp-pop * { transition-duration: .01ms !important; }
}
/* ============================================================================
   END VECTURA TEXT PANEL (vtp-*)
   ============================================================================ */

/* ============================================================================
   STR: Stroke Options panel (src/ui/panels/stroke-options.js)
   Reusable stroke-editing surface — weight / cap / corner+limit / align / dash.
   Mounts in the config appearance area now; Phase 2 re-hosts it in the Task
   Bar popover. One delimited block per the CSS funneling rule.
   ============================================================================ */
.stroke-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: var(--font-size-sm);
  color: var(--ui-text);
}
.stroke-options .stroke-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 26px;
}
.stroke-options .stroke-row-label {
  flex: 0 0 auto;
  min-width: 78px;
  color: var(--ui-text-2);
  font-size: var(--font-size-xs);
}
.stroke-options .stroke-field {
  width: 56px;
  height: 24px;
  padding: 0 6px;
  border: 1px solid var(--ui-border);
  border-radius: var(--radius-sm);
  background: var(--ui-ctrl);
  color: var(--ui-text);
  font-family: var(--font-mono);
  font-size: var(--font-size-xs);
  text-align: right;
}
.stroke-options .stroke-field:focus {
  outline: none;
  border-color: var(--ui-accent);
}
.stroke-options .stroke-field:disabled {
  opacity: .4;
  cursor: not-allowed;
}
.stroke-options .stroke-stepper {
  width: 22px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--ui-border);
  border-radius: var(--radius-sm);
  background: var(--ui-ctrl);
  color: var(--ui-text);
  cursor: pointer;
  line-height: 1;
  padding: 0;
}
.stroke-options .stroke-stepper:hover { background: var(--ui-ctrl-hov); }
.stroke-options .stroke-unit {
  color: var(--ui-muted);
  font-size: var(--font-size-xs);
  font-family: var(--font-mono);
}
.stroke-options .stroke-preset {
  height: 24px;
  border: 1px solid var(--ui-border);
  border-radius: var(--radius-sm);
  background: var(--ui-ctrl);
  color: var(--ui-text);
  font-size: var(--font-size-xs);
  margin-left: auto;
  max-width: 96px;
}
.stroke-options .stroke-toggle-group {
  display: inline-flex;
  gap: 4px;
}
.stroke-options .stroke-toggle {
  width: 30px;
  height: 26px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--ui-border);
  border-radius: var(--radius-sm);
  background: var(--ui-ctrl);
  color: var(--ui-text-2);
  cursor: pointer;
  padding: 0;
}
.stroke-options .stroke-toggle:hover { background: var(--ui-ctrl-hov); }
.stroke-options .stroke-toggle svg {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.stroke-options .stroke-toggle.is-active {
  border-color: var(--ui-accent);
  background: var(--ui-accent-2);
  color: var(--ui-accent);
}
/* sf-w4 — Stroke Fill Style row. Four TEXT toggles (there is no icon
   vocabulary for a fill path pattern), so they size to their label and the
   row wraps instead of overflowing the Stroke Options popover. Disabled is
   the resting state for the 37 fill styles that build no ribbon, so it has to
   read as clearly greyed rather than merely un-clickable. */
.stroke-options .stroke-row-strokefill { flex-wrap: wrap; }
.stroke-options .stroke-row-strokefill .stroke-toggle-group { flex-wrap: wrap; }
.stroke-options .stroke-toggle.is-text {
  width: auto;
  min-width: 30px;
  padding: 0 8px;
  font-size: var(--font-size-xs);
  white-space: nowrap;
}
.stroke-options .stroke-toggle:disabled {
  opacity: .4;
  cursor: not-allowed;
  /* Kills the :hover background above (which still fires on a disabled
     button) AND lets the hover fall through to the ROW, so the row's
     `title` — the reason the control is off — is what a user actually
     sees. A disabled button never shows its own title. */
  pointer-events: none;
}
.stroke-options .stroke-row.is-disabled .stroke-row-label { opacity: .4; }
.stroke-options .stroke-limit {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
}
.stroke-options .stroke-limit-label {
  color: var(--ui-text-2);
  font-size: var(--font-size-xs);
}
.stroke-options .stroke-limit.is-disabled { opacity: .4; }
.stroke-options .stroke-row-dash {
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
}
.stroke-options .stroke-dash-head {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
}
.stroke-options .stroke-dash-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 4px;
}
.stroke-options .stroke-dash-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}
.stroke-options .stroke-dash-field {
  width: 100%;
  text-align: center;
}
.stroke-options .stroke-dash-label {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: .4px;
  color: var(--ui-muted);
  padding: 1px 4px;
  border-radius: var(--radius-sm);
}
.stroke-options .stroke-dash-label.is-focused {
  background: var(--ui-accent-2);
  color: var(--ui-accent);
}
.stroke-options .stroke-dash-grid.is-disabled { opacity: .5; }

/* prefers-reduced-motion: this component has no animations, but honour the
   contract for any hover transitions inherited from tokens. */
@media (prefers-reduced-motion: reduce) {
  .stroke-options * { transition-duration: .01ms !important; }
}
/* ============================================================================
   END STR: Stroke Options panel
   ============================================================================ */

/* ============================================================================
   COL: PEN PICKER POPOVER + PEN CHIP (pen-pick-*, pen-chip)
   Tools Parity Phase 1 Lane D — anchored pen picker
   (src/ui/panels/pen-picker-popover.js). Reuses .pen-icon and the
   color-picker scaffold classes (.color-sv-*, .color-hue-*, .color-hex-*).
   ============================================================================ */
.pen-pick-pop {
  position: fixed; z-index: 10000; width: 264px; background: var(--ui-panel);
  border: 1px solid var(--ui-border-hi); border-radius: var(--radius-md); box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column; overflow: hidden;
  font-size: var(--font-size-xs); color: var(--ui-text);
}
.pen-pick-header {
  display: flex; align-items: center; gap: 8px; padding: 8px 10px;
  border-bottom: 1px solid var(--ui-border);
}
.pen-pick-current {
  position: relative; flex: none; width: 22px; height: 22px;
}
.pen-pick-current .pen-icon { width: 100%; height: 100%; border-color: var(--ui-border-hi); }
.pen-pick-current .pen-pick-mixed-badge,
.pen-chip .pen-chip-mixed {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-weight: 700; color: var(--ui-text); pointer-events: none;
}
.pen-pick-current:not(.mixed) .pen-pick-mixed-badge { display: none; }
.pen-pick-tabs { display: flex; flex: 1; gap: 2px; }
.pen-pick-tab {
  flex: 1; padding: 5px 8px; background: transparent; border: 1px solid transparent;
  border-radius: var(--radius-sm); color: var(--ui-muted); cursor: pointer;
  font-size: var(--font-size-xs); transition: color .12s, background .12s;
}
.pen-pick-tab:hover { color: var(--ui-text); background: var(--ui-ctrl); }
.pen-pick-tab.active { color: var(--ui-accent); background: var(--ui-accent-2); border-color: color-mix(in srgb, var(--ui-accent) 35%, transparent); }
.pen-pick-eyedropper {
  flex: none; width: 24px; height: 24px; display: flex; align-items: center; justify-content: center;
  background: transparent; border: 1px solid transparent; border-radius: var(--radius-sm);
  color: var(--ui-muted); cursor: pointer; padding: 0;
}
.pen-pick-eyedropper:hover { color: var(--ui-text); background: var(--ui-ctrl); }
.pen-pick-eyedropper.active { color: var(--ui-accent); border-color: var(--ui-accent); }
.pen-pick-body { display: flex; flex-direction: column; gap: 8px; padding: 8px; }
.pen-pick-body.hidden { display: none; }
.pen-pick-list { display: flex; flex-direction: column; gap: 2px; max-height: 240px; overflow-y: auto; }
.pen-pick-row {
  display: flex; align-items: center; gap: 8px; padding: 6px;
  background: transparent; border: 1px solid transparent; border-radius: var(--radius-sm);
  color: var(--ui-text); text-align: left; cursor: pointer; font-size: var(--font-size-xs);
}
.pen-pick-row:hover { border-color: var(--ui-border-hi); background: var(--ui-ctrl); }
.pen-pick-row.active { border-color: var(--ui-accent); }
.pen-pick-row .pen-icon { flex: 0 0 18px; width: 18px; height: 18px; border-color: var(--ui-border-hi); }
.pen-pick-row-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pen-pick-row-width { flex: none; color: var(--ui-muted); font-variant-numeric: tabular-nums; font-family: var(--font-mono); font-size: 10px; }
.pen-pick-mixer { display: flex; flex-direction: column; gap: 10px; }
.pen-pick-field { display: flex; flex-direction: column; gap: 4px; }
.pen-pick-field-label { color: var(--ui-muted); font-size: 10px; text-transform: uppercase; letter-spacing: .4px; }
.pen-pick-name {
  width: 100%; padding: 6px 8px; background: var(--ui-ctrl); border: 1px solid var(--ui-border);
  border-radius: var(--radius-sm); color: var(--ui-text); font-size: var(--font-size-xs);
}
.pen-pick-name:focus { outline: none; border-color: var(--ui-accent); }
.pen-pick-width-wrap { display: flex; align-items: center; gap: 8px; }
.pen-pick-width { flex: 1; }
/* Editable numeric width readout (docked Pens panel parity): reads as a
   quiet value until hovered/focused, then as a textbox. */
.pen-pick-width-value {
  flex: none; width: 52px; padding: 2px 4px; text-align: right;
  color: var(--ui-muted); font-variant-numeric: tabular-nums; font-size: 10px;
  background: transparent; border: 1px solid transparent; border-radius: var(--radius-sm);
  -moz-appearance: textfield; appearance: textfield;
}
.pen-pick-width-value::-webkit-outer-spin-button,
.pen-pick-width-value::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.pen-pick-width-value:hover { border-color: var(--ui-border); }
.pen-pick-width-value:focus { outline: none; border-color: var(--ui-accent); color: var(--ui-text); }
.pen-pick-add {
  padding: 7px 10px; background: var(--ui-accent-2); color: var(--ui-accent);
  border: 1px dashed color-mix(in srgb, var(--ui-accent) 40%, transparent); border-radius: var(--radius-sm);
  cursor: pointer; font-size: var(--font-size-xs);
}
.pen-pick-add:hover { background: color-mix(in srgb, var(--ui-accent) 18%, transparent); }
.pen-pick-pop.sampling { outline: 1px dashed var(--ui-accent); }

/* COL-4b eyedropper: while sampling the canvas cursor is an
   eyedropper (hotspot at the tip) and a magnifier loupe follows the pointer —
   zoomed canvas view, center reticle on the exact sample point, ring + label
   tinted with the pen/color a click would grab. */
.pen-eyedropper-cursor {
  cursor: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path d="M20.7 3.3a2.4 2.4 0 0 0-3.4 0l-2.8 2.8-1-1-1.4 1.4 1 1L4 16.6V20h3.4l9.1-9.1 1 1 1.4-1.4-1-1 2.8-2.8a2.4 2.4 0 0 0 0-3.4z" fill="white" stroke="black" stroke-width="1.4"/></svg>') 4 20, crosshair;
}
.pen-loupe {
  position: fixed; z-index: 10001; width: 110px; height: 110px;
  border-radius: 50%; border: 3px solid var(--loupe-color, var(--ui-border-hi));
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(0, 0, 0, 0.6);
  pointer-events: none; display: none;
}
.pen-loupe.visible { display: block; }
.pen-loupe-canvas {
  position: absolute; inset: 0; width: 100%; height: 100%;
  border-radius: 50%; display: block; background: var(--render-canvas, #111);
}
.pen-loupe-reticle {
  position: absolute; left: 50%; top: 50%; width: 12px; height: 12px;
  transform: translate(-50%, -50%);
}
.pen-loupe-reticle::before,
.pen-loupe-reticle::after {
  content: ""; position: absolute; background: #fff; mix-blend-mode: difference;
}
.pen-loupe-reticle::before { left: 50%; top: 0; width: 1px; height: 100%; transform: translateX(-50%); }
.pen-loupe-reticle::after { top: 50%; left: 0; height: 1px; width: 100%; transform: translateY(-50%); }
.pen-loupe-label {
  position: absolute; top: calc(100% + 8px); left: 50%; transform: translateX(-50%);
  display: flex; align-items: center; gap: 6px; padding: 3px 8px;
  background: var(--ui-panel); border: 1px solid var(--ui-border); border-radius: var(--radius-sm);
  color: var(--ui-text); font-size: 10px; white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.pen-loupe-swatch {
  flex: none; width: 10px; height: 10px; border-radius: 3px;
  border: 1px solid var(--ui-border-hi);
}
.pen-loupe:not(.hit) .pen-loupe-label { display: none; }

/* COL-3 pen chip — Phase 2 Task Bar mounts this standalone component. */
.pen-chip {
  position: relative; display: inline-flex; align-items: center; justify-content: center;
  width: 24px; height: 24px; padding: 2px; background: transparent;
  border: 1px solid var(--ui-border); border-radius: var(--radius-sm); cursor: pointer;
}
.pen-chip:hover { border-color: var(--ui-border-hi); background: var(--ui-ctrl); }
.pen-chip .pen-chip-swatch { display: block; width: 16px; height: 16px; }
.pen-chip .pen-icon { width: 100%; height: 100%; border-color: var(--ui-border-hi); }
.pen-chip:not(.mixed) .pen-chip-mixed { display: none; }
.pen-chip.mixed .pen-icon { background: transparent; }

@media (prefers-reduced-motion: reduce) {
  .pen-pick-pop *, .pen-chip { transition-duration: .01ms !important; }
}
/* Pen picker footer: opens Pen Studio */
.pen-pick-footer { display: flex; padding-top: 6px; border-top: 1px solid var(--ui-border); }
.pen-pick-studio { flex: 1; height: 28px; border: 0; border-radius: var(--radius-sm); background: var(--ui-ctrl); color: var(--ui-text); font: 500 12px/1 var(--font-ui); cursor: pointer; }
.pen-pick-studio:hover { background: var(--ui-ctrl-hov); }
.pen-pick-studio:focus-visible { outline: 2px solid var(--ui-accent); outline-offset: 1px; }
body.touch-ui .pen-pick-studio { min-height: var(--touch-target-min); }

/* ============================================================================
   END COL: PEN PICKER POPOVER
   ============================================================================ */

/* ============================================================================
   PEN MODELS: pen-row model chip / size / ink button, model picker + ink
   settings popovers (src/ui/panels/pens-panel.js,
   src/ui/panels/ink-settings-popover.js), Pen Picker New Pen model select.
   ============================================================================ */
/* Line 1 (.pen-line) keeps today's [grip][icon][name] + [swatch][weight]
   [value][remove]; the model row is line 2. Items never shrink below their
   content. */
.pen-item { flex-wrap: wrap; flex-shrink: 0; }
.pen-line { flex: 1 1 100%; min-width: 0; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.pen-row-c {
  flex: 1 1 100%; display: flex; align-items: center; gap: 6px;
  min-width: 0; padding: 0 0 2px 34px;
}
.pen-model-chip {
  flex: 0 1 auto; min-width: 0; max-width: 60%; height: 20px; padding: 0 8px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  background: var(--ui-ctrl); color: var(--ui-text); border: 1px solid var(--ui-border);
  border-radius: 9999px; font-size: 10px; cursor: pointer;
}
.pen-model-chip.is-plain { color: var(--ui-muted); background: transparent; }
.pen-model-chip:hover { border-color: var(--ui-border-hi); }
.pen-model-chip:focus-visible, .pen-ink-btn:focus-visible { outline: 1px solid var(--ui-accent); outline-offset: 1px; }
.pen-size {
  flex: 0 1 auto; min-width: 0; max-width: 40%; height: 20px; padding: 0 4px;
  background: var(--ui-ctrl); color: var(--ui-text); border: 1px solid var(--ui-border);
  border-radius: var(--radius-sm); font-size: 10px;
}
.pen-size[hidden] { display: none; }
.pen-ink-btn {
  position: relative; flex: none; margin-left: auto; width: 22px; height: 20px; padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
  background: transparent; color: var(--ui-muted); border: 1px solid transparent;
  border-radius: var(--radius-sm); cursor: pointer;
}
.pen-ink-btn:hover { color: var(--ui-text); border-color: var(--ui-border); }
/* A dot when the pen carries ink overrides. */
.pen-ink-btn.has-overrides::after {
  content: ''; position: absolute; top: 2px; right: 2px; width: 5px; height: 5px;
  border-radius: 50%; background: var(--ui-accent);
}

.ink-pop {
  position: fixed; z-index: 10000; width: 300px; max-height: min(560px, calc(100vh - 16px)); max-height: min(560px, calc(100dvh - 16px));
  display: flex; flex-direction: column; overflow: hidden;
  background: var(--ui-panel); color: var(--ui-text); font-size: var(--font-size-xs);
  border: 1px solid var(--ui-border-hi); border-radius: var(--radius-md); box-shadow: var(--shadow-lg);
}
.ink-pop.as-sheet {
  left: 0; right: 0; bottom: 0; top: auto; width: auto; max-height: 75vh;
  border-radius: var(--radius-md) var(--radius-md) 0 0; padding-bottom: var(--safe-bottom, 0px);
}
.ink-pop-head {
  display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-bottom: 1px solid var(--ui-border);
}
.ink-pop-title { flex: 1; min-width: 0; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ink-pop-sub { margin-left: 6px; font-weight: 400; color: var(--ui-muted); }
.ink-pop-close {
  flex: none; width: 24px; height: 24px; padding: 0; background: transparent; color: var(--ui-muted);
  border: 1px solid transparent; border-radius: var(--radius-sm); cursor: pointer;
}
.ink-pop-close:hover { color: var(--ui-text); border-color: var(--ui-border); }
.ink-pop-search {
  margin: 8px 10px 4px; padding: 5px 8px; background: var(--ui-ctrl); color: var(--ui-text);
  border: 1px solid var(--ui-border); border-radius: var(--radius-sm); font-size: var(--font-size-xs);
}
.ink-pop-search:focus { outline: none; border-color: var(--ui-accent); }
.ink-pop-list { flex: 1; min-height: 0; overflow-y: auto; padding: 4px 6px 8px; display: flex; flex-direction: column; gap: 2px; }
.ink-model-group {
  padding: 8px 4px 2px; color: var(--ui-muted); font-size: 10px; text-transform: uppercase; letter-spacing: .4px;
}
.ink-model-row {
  display: flex; align-items: center; gap: 8px; width: 100%; padding: 4px 6px; text-align: left;
  background: transparent; color: var(--ui-text); border: 1px solid transparent;
  border-radius: var(--radius-sm); cursor: pointer; font-size: var(--font-size-xs);
}
.ink-model-row:hover { background: var(--ui-ctrl); border-color: var(--ui-border-hi); }
.ink-model-row.active { border-color: var(--ui-accent); }
.ink-model-row.kbd-active { background: var(--ui-ctrl); outline: 1px solid var(--ui-accent); outline-offset: -1px; }
.ink-note-warn { color: var(--ui-text); }
.ink-model-row:focus-visible { outline: 1px solid var(--ui-accent); outline-offset: -1px; }
.ink-model-sample {
  flex: none; width: 88px; height: 22px; border-radius: 3px; border: 1px solid var(--ui-border);
}
.ink-model-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.ink-model-name, .ink-model-sub { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ink-model-sub { color: var(--ui-muted); font-size: 10px; font-variant-numeric: tabular-nums; }
.ink-model-approx {
  flex: none; padding: 0 5px; border: 1px solid var(--ui-border); border-radius: 9999px;
  color: var(--ui-muted); font-size: 9px; line-height: 14px;
}
.ink-model-empty { padding: 12px; color: var(--ui-muted); text-align: center; }
.ink-pop-body { overflow-y: auto; padding: 8px 10px 10px; display: flex; flex-direction: column; gap: 8px; }
/* Rows never shrink in the scrolling body (a wrapped swatch row overlapped the next row on phones). */
.ink-pop-body > * { flex-shrink: 0; }
.ink-row { display: flex; align-items: center; gap: 8px; min-height: 22px; }
.ink-row-label { flex: 0 0 92px; color: var(--ui-muted); }
.ink-model-btn, .ink-size {
  flex: 1; min-width: 0; height: 22px; padding: 0 8px; text-align: left;
  background: var(--ui-ctrl); color: var(--ui-text); border: 1px solid var(--ui-border);
  border-radius: var(--radius-sm); font-size: var(--font-size-xs); cursor: pointer;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.ink-model-btn:hover { border-color: var(--ui-border-hi); }
.ink-row-colours { align-items: flex-start; }
.ink-swatches { flex: 1; display: flex; flex-wrap: wrap; gap: 4px; }
.ink-swatch {
  width: 18px; height: 18px; padding: 0; border-radius: 50%; cursor: pointer;
  background: var(--swatch); border: 1px solid var(--ui-border-hi);
}
.ink-swatch.active { box-shadow: 0 0 0 2px var(--ui-panel), 0 0 0 3px var(--ui-accent); }
.ink-slider { flex: 1; min-width: 0; }
.ink-slider-value { flex: 0 0 46px; text-align: right; color: var(--ui-muted); font-variant-numeric: tabular-nums; }
.ink-slider-row.changed .ink-slider-value { color: var(--ui-accent); }
.ink-actions { display: flex; justify-content: flex-end; }
.ink-reset {
  padding: 4px 10px; background: transparent; color: var(--ui-text); border: 1px solid var(--ui-border);
  border-radius: var(--radius-sm); cursor: pointer; font-size: var(--font-size-xs);
}
.ink-reset:hover:not(:disabled) { border-color: var(--ui-accent); color: var(--ui-accent); }
.ink-reset:disabled { opacity: .45; cursor: default; }
.ink-note { margin: 0; color: var(--ui-muted); font-size: 10px; line-height: 1.4; }
.pen-pick-model {
  width: 100%; padding: 5px 6px; background: var(--ui-ctrl); color: var(--ui-text);
  border: 1px solid var(--ui-border); border-radius: var(--radius-sm); font-size: var(--font-size-xs);
}

/* Touch: every new control is a finger tall (≥ 44 px), the popovers are sheets. */
@media (pointer: coarse) {
  /* The touch pen card (TUX-041) orders the line-1 controls itself. */
  [data-ui-skin] .pen-item .pen-line { display: contents; }
  [data-ui-skin] .pen-item .pen-row-c { order: 8; flex: 1 1 100%; padding: 0 0 4px; gap: 4px; }
  [data-ui-skin] .pen-item :is(.pen-model-chip, .pen-size, .pen-ink-btn) {
    min-height: var(--touch-target-min); height: var(--touch-target-min); font-size: var(--font-size-xs);
  }
  [data-ui-skin] .pen-item .pen-ink-btn { min-width: var(--touch-target-min); width: var(--touch-target-min); }
  [data-ui-skin] .pen-item .pen-model-chip { flex: 1 1 0; min-width: var(--touch-target-min); max-width: none; }
  [data-ui-skin] .pen-item .pen-size { flex: 1 1 0; min-width: calc(2 * var(--touch-target-min)); max-width: none; }
  .ink-pop :is(.ink-pop-close, .ink-model-btn, .ink-size, .ink-reset, .ink-pop-search, .ink-model-row) {
    min-height: var(--touch-target-min);
  }
  .ink-pop .ink-pop-close { min-width: var(--touch-target-min); }
  .ink-pop .ink-row { min-height: var(--touch-target-min); }
  .ink-pop .ink-slider { min-height: var(--touch-target-min); }
  .ink-pop .ink-swatch { width: var(--touch-target-min); height: var(--touch-target-min); }
  .pen-pick-model { min-height: var(--touch-target-min); }
}
@media (prefers-reduced-motion: reduce) {
  .ink-pop * { transition-duration: .01ms !important; }
}
/* ============================================================================
   END PEN MODELS
   ============================================================================ */

/* ============================================================================
   SPECIAL INKS: Special inks strip (ink settings + Pen Picker New Pen tab),
   My pens popover, Pens header ⋯ button, "Lights off" canvas chip
   (src/ui/panels/ink-settings-popover.js, pen-picker-popover.js,
   pens-panel.js, src/render/renderer.js). Swatch looks hint at the ink; the
   canvas preview draws the real effect.
   ============================================================================ */
.ink-row-fx { align-items: flex-start; }
.fx-strip { flex: 1; min-width: 0; display: flex; flex-wrap: wrap; align-items: flex-start; gap: 6px 8px; }
.fx-group { display: flex; flex-direction: column; gap: 2px; }
.fx-group-label { color: var(--ui-muted); font-size: 9px; text-transform: uppercase; letter-spacing: .3px; }
.fx-swatches { display: flex; flex-wrap: wrap; gap: 4px; }
.fx-swatch {
  position: relative; width: 18px; height: 18px; padding: 0; border-radius: 50%; cursor: pointer;
  background: var(--swatch, var(--ui-ctrl)); border: 1px solid var(--ui-border-hi);
}
.fx-swatch.active, .fx-swatch[aria-pressed="true"] { box-shadow: 0 0 0 2px var(--ui-panel), 0 0 0 3px var(--ui-accent); }
.fx-swatch:focus-visible { outline: 1px solid var(--ui-accent); outline-offset: 2px; }
.fx-swatch.fx-none {
  align-self: flex-end; background: transparent;
  background-image: linear-gradient(135deg, transparent 45%, var(--ui-muted) 45%, var(--ui-muted) 55%, transparent 55%);
}
/* Metallic: a polished bar of the colour. Dual metallic: base → second colour. */
:is(.fx-swatch, .ink-swatch).fx-metallic {
  background: linear-gradient(135deg, color-mix(in srgb, var(--swatch) 55%, black) 0%, var(--swatch) 36%,
    color-mix(in srgb, var(--swatch) 25%, white) 50%, var(--swatch) 64%, color-mix(in srgb, var(--swatch) 60%, black) 100%);
}
:is(.fx-swatch, .ink-swatch).fx-dual-metallic {
  background: linear-gradient(135deg, var(--swatch) 0%, var(--swatch) 40%, color-mix(in srgb, var(--swatch2) 40%, white) 55%, var(--swatch2) 100%);
}
/* Neon: the colour glows a little. */
:is(.fx-swatch, .ink-swatch).fx-fluorescent { box-shadow: 0 0 5px 1px color-mix(in srgb, var(--swatch) 70%, transparent); }
:is(.fx-swatch, .ink-swatch).fx-fluorescent.active { box-shadow: 0 0 0 2px var(--ui-panel), 0 0 0 3px var(--ui-accent), 0 0 6px 2px var(--swatch); }
/* Glow in the dark: the pale day colour with its emission colour as a ring. */
:is(.fx-swatch, .ink-swatch).fx-glow { background: radial-gradient(circle, var(--swatch) 45%, var(--swatch2) 100%); }
/* Glitter: speckles over the tint. */
:is(.fx-swatch, .ink-swatch).fx-glitter {
  background:
    radial-gradient(circle at 30% 30%, white 0 1px, transparent 1.5px),
    radial-gradient(circle at 70% 55%, white 0 1px, transparent 1.5px),
    radial-gradient(circle at 45% 78%, white 0 0.8px, transparent 1.3px),
    var(--swatch);
}
:is(.fx-swatch, .ink-swatch).fx-white { background: var(--swatch); border-color: var(--ui-border-hi); box-shadow: inset 0 0 0 3px color-mix(in srgb, var(--swatch) 80%, black); }
.ink-actions { flex-wrap: wrap; gap: 6px; }
.ink-save-lib, .ink-export-pen, .ink-lib-export-all {
  padding: 4px 10px; background: transparent; color: var(--ui-text); border: 1px solid var(--ui-border);
  border-radius: var(--radius-sm); cursor: pointer; font-size: var(--font-size-xs);
}
.ink-save-lib:hover, .ink-export-pen:hover, .ink-lib-export-all:hover:not(:disabled) { border-color: var(--ui-accent); color: var(--ui-accent); }
.ink-lib-export-all:disabled { opacity: .45; cursor: default; }
.pen-pick-fx-field { display: flex; flex-direction: column; gap: 4px; }
/* My pens popover rows. */
.ink-lib-row { display: flex; align-items: center; gap: 8px; padding: 4px 6px; border-radius: var(--radius-sm); }
.ink-lib-row:hover { background: var(--ui-ctrl); }
.ink-lib-actions { flex: none; display: flex; gap: 2px; }
.ink-lib-btn {
  width: 24px; height: 24px; padding: 0; background: transparent; color: var(--ui-muted);
  border: 1px solid transparent; border-radius: var(--radius-sm); cursor: pointer; font-size: 12px;
}
.ink-lib-btn:hover { color: var(--ui-text); border-color: var(--ui-border); }
.ink-lib-btn:focus-visible { outline: 1px solid var(--ui-accent); outline-offset: -1px; }
.ink-lib-foot { padding: 6px 10px 10px; border-top: 1px solid var(--ui-border); }
/* Pens header ⋯ (Export / Import / My pens). */
.pens-more-btn {
  width: 24px; height: 22px; padding: 0; background: transparent; color: var(--ui-muted);
  border: 1px solid var(--ui-border); cursor: pointer; font-size: 12px; line-height: 1;
}
.pens-more-btn:hover { color: var(--ui-text); border-color: var(--ui-border-hi); }
.pens-more-btn:focus-visible { outline: 1px solid var(--ui-accent); outline-offset: 1px; }
/* "Lights off" chip, bottom centre of the canvas. */
.lights-off-chip {
  position: absolute; left: 50%; bottom: 16px; transform: translateX(-50%); z-index: 40;
  display: inline-flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 6px 14px; min-height: 32px;
  background: color-mix(in srgb, var(--ui-panel) 88%, transparent); color: var(--ui-text);
  border: 1px solid var(--ui-border-hi); border-radius: 9999px; box-shadow: var(--shadow-lg);
  font-size: var(--font-size-xs); cursor: pointer;
}
.lights-off-chip[hidden], .lights-off-chip-note[hidden] { display: none; }
.lights-off-chip:hover { border-color: var(--ui-accent); }
.lights-off-chip:focus-visible { outline: 2px solid var(--ui-accent); outline-offset: 2px; }
.lights-off-chip-note { color: var(--ui-muted); font-size: 10px; }
/* Phones: the bottom of the canvas belongs to the zoom controls — the chip
   sits at the top centre instead (the canvas area is already below the
   safe-area-aware header, so no inset is needed here). */
@media (max-width: 640px), (pointer: coarse) and (max-height: 500px) {
  .lights-off-chip {
    top: 12px; bottom: auto;
    max-width: calc(100% - 24px); text-align: center; white-space: normal;
  }
}
@media (pointer: coarse) {
  .ink-pop .fx-swatch, .pen-pick-fx .fx-swatch { width: var(--touch-target-min); height: var(--touch-target-min); }
  .ink-pop :is(.ink-save-lib, .ink-export-pen, .ink-lib-export-all, .ink-lib-btn) { min-height: var(--touch-target-min); min-width: var(--touch-target-min); }
  [data-ui-skin] .pens-more-btn { min-width: var(--touch-target-min); min-height: var(--touch-target-min); }
  .lights-off-chip { min-height: var(--touch-target-min); }
}
/* ============================================================================
   END SPECIAL INKS
   ============================================================================ */

/* ============================================================================
   HUD: hint bar, readouts & canvas toast (Lane F HUD-1…4)
   Markup: #hud-bar strip at the bottom of .workspace-shell (index.html);
   #canvas-toast pill inside #viewport-container. Logic: src/ui/shell/hint-bar.js;
   copy/timings: src/config/hints.js. Motion rules live in motion.css.
   ============================================================================ */
.hud-bar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 16px;
  min-height: 26px;
  padding: 3px 12px;
  background: var(--ui-panel, #252525);
  border-top: 1px solid var(--ui-border, #363636);
  color: var(--ui-muted, #686868);
  font-size: var(--font-size-xs, 10px);
  z-index: 5;
}
/* The hints region keeps the legacy #status-bar id (relocated from the header).
   Undo the header-era mono/uppercase treatment for hint prose. */
[data-ui-skin] .hud-bar #status-bar {
  font-family: var(--font-ui, system-ui, sans-serif);
  text-transform: none;
  letter-spacing: 0;
}
.hud-hints {
  flex: 1 1 auto;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
/* HUD-1 drag clearing / HUD-4 preference: hide the text, keep the layout. */
.hud-hints.is-hidden {
  visibility: hidden;
}
.hud-hint-seg strong {
  color: var(--ui-text, #e0e0e0);
  font-weight: 600;
}
.hud-hint-sep {
  margin: 0 8px;
  opacity: 0.5;
}
.hud-readouts {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-left: auto;
  font-family: var(--font-mono, monospace);
  white-space: nowrap;
}
/* Fixed-ish zoom width so live zoom updates don't jitter the row. */
.hud-readout-zoom {
  min-width: 44px;
  text-align: right;
}
/* Mobile layout reorders .workspace-shell children with explicit flex order
   (tool-bar 1 → viewport 2 → bottom-pane 3 → touch-modifier-bar 4); keep the
   HUD strip at the very bottom there too. */
body.mobile-layout .hud-bar {
  order: 5;
}
@media (max-width: 640px) {
  /* Match the legacy #status-bar phone behavior: no HUD strip on phones. */
  .hud-bar {
    display: none;
  }
}

/* HUD-3: transient toast pill, top-center of the canvas. Non-interactive. */
.canvas-toast {
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translate(-50%, -4px);
  max-width: min(70%, 420px);
  padding: 5px 14px;
  border-radius: 999px;
  background: var(--ui-panel, #252525);
  border: 1px solid var(--ui-border, #363636);
  color: var(--ui-text, #e0e0e0);
  font-family: var(--font-ui, system-ui, sans-serif);
  font-size: var(--font-size-sm, 11px);
  line-height: 1.4;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  z-index: 40;
}
.canvas-toast.is-visible {
  opacity: 1;
  visibility: visible;
  transform: translate(-50%, 0);
}
/* ============================================================================
   END HUD (Lane F)
   ============================================================================ */

/* ============================================================================
   TB: Contextual Task Bar (Tools Parity, Phase 2 Lane G — TB-1…8)
   Markup: .ctxbar pill mounted into #viewport-container by
   src/ui/shell/context-bar.js. Copy/icons/timings: src/config/context-bar.js.
   Show/hide + pulse motion live in motion.css. Styling matches the floating
   tool rail family (dark pill, skin tokens).
   ============================================================================ */
.ctxbar {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 35;
  display: flex;
  align-items: stretch;
  gap: 2px;
  padding: 3px 4px;
  max-width: calc(100% - 16px);
  background: var(--ui-panel, #252525);
  border: 1px solid var(--ui-border, #363636);
  border-radius: var(--radius-lg, 12px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.30);
  color: var(--ui-text, #e0e0e0);
  font-family: var(--font-ui, system-ui, sans-serif);
  font-size: var(--font-size-sm, 11px);
  /* Hidden until shouldShow() flips .is-visible (never steals focus). */
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}
.ctxbar.is-visible {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}
/* Left vertical drag handle (grip). */
.ctxbar-handle {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--ui-muted, #686868);
  cursor: grab;
  border-radius: var(--radius-sm, 4px);
  opacity: 0.6;
}
@media (hover: hover) {
  .ctxbar-handle:hover { opacity: 0.95; }
}
.ctxbar-handle:active { cursor: grabbing; }
.ctxbar-handle svg { width: 12px; height: 16px; }
/* Content host (sub-modes fill this). */
.ctxbar-content {
  display: flex;
  align-items: center;
  gap: 2px;
  min-height: 26px;
}
/* Buttons — icon or icon+label pills. */
.ctxbar-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 26px;
  padding: 0 7px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm, 4px);
  background: transparent;
  color: var(--ui-text, #e0e0e0);
  font-size: var(--font-size-sm, 11px);
  line-height: 1;
  cursor: pointer;
  white-space: nowrap;
}
.ctxbar-btn:hover:not(.is-disabled) {
  background: var(--ui-ctrl, #2c2c2c);
  border-color: var(--ui-border-hi, #484848);
}
.ctxbar-btn:focus-visible {
  outline: 2px solid var(--ui-accent, #4e9ee1);
  outline-offset: 1px;
}
.ctxbar-btn.is-active {
  background: var(--ui-ctrl, #2c2c2c);
  border-color: var(--ui-border-hi, #484848);
}
.ctxbar-btn.is-disabled {
  opacity: 0.4;
  cursor: default;
}
.ctxbar-btn--labeled { padding: 0 9px; }
.ctxbar-ico { display: inline-flex; width: 16px; height: 16px; }
.ctxbar-ico svg { width: 16px; height: 16px; }
.ctxbar-label { font-weight: 500; }
/* Separator-ish spacing for the anchor verb group (TB-6). */
.ctxbar-anchor-verb + .ctxbar-anchor-verb { margin-left: 0; }
/* Overflow (…) + menu (TB-2). */
.ctxbar-overflow-wrap { position: relative; display: flex; align-items: center; }
.ctxbar-overflow { padding: 0 6px; }
.ctxbar-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 176px;
  display: none;
  flex-direction: column;
  padding: 4px;
  background: var(--ui-panel, #252525);
  border: 1px solid var(--ui-border, #363636);
  border-radius: var(--radius-md, 8px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  z-index: 6;
}
.ctxbar-menu.is-open { display: flex; }
.ctxbar-menu-item {
  text-align: left;
  padding: 6px 10px;
  border: none;
  background: transparent;
  color: var(--ui-text, #e0e0e0);
  font-size: var(--font-size-sm, 11px);
  border-radius: var(--radius-sm, 4px);
  cursor: pointer;
}
.ctxbar-menu-item:hover { background: var(--ui-ctrl, #2c2c2c); }
.ctxbar-menu-item--extra { color: var(--ui-accent, #4e9ee1); }
/* Align flyout (TB-5). */
.ctxbar-align-wrap { position: relative; display: inline-flex; align-items: center; }
.ctxbar-align-flyout {
  position: absolute;
  top: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  display: none;
  flex-direction: column;
  gap: 8px;
  padding: 8px;
  background: var(--ui-panel, #252525);
  border: 1px solid var(--ui-border, #363636);
  border-radius: var(--radius-md, 8px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  z-index: 6;
}
.ctxbar-align-flyout.is-open { display: flex; }
/* Direction-aware flyouts. Every dropdown in the contextual task bar opens AWAY
   from whichever viewport edge the bar is nearest, so the menu has the best
   chance of being seen in its entirety. `ctxbar-flyout-up` is stamped on each
   flyout by the bar's shared direction pass; the `.ctxbar-menus-up` bar-level
   rule below covers content rebuilt between ticks so nothing can flash the
   wrong way for a frame. Both set the same geometry, so order is immaterial.
   The overflow (...) menu (`.ctxbar-menu`) shares this exact rule — it is
   stamped with the same `ctxbar-flyout-up` class by the same JS pass, so it
   always opens the same direction as the bar's other menus instead of being
   pinned open in a fixed direction of its own. */
.ctxbar-align-flyout.ctxbar-flyout-up,
.ctxbar-menu.ctxbar-flyout-up,
.ctxbar.ctxbar-menus-up .ctxbar-align-flyout,
.ctxbar.ctxbar-menus-up .ctxbar-menu {
  top: auto;
  bottom: calc(100% + 6px);
}
/* Never let a menu run off-screen: the bar publishes the room available on the
   side it opens toward as `--ctxbar-menu-space` (inherited by every flyout),
   and each flyout caps itself to it. The per-type caps below fold it into their
   own `min()` rather than relying on a separate rule — a later same-specificity
   `max-height` would otherwise win the cascade and silently drop the clamp. */
.ctxbar-align-flyout,
.ctxbar-menu {
  max-height: var(--ctxbar-menu-space, var(--app-vh));
  overflow-y: auto;
}
.ctxbar-align-group-label {
  font-size: var(--font-size-xs, 10px);
  color: var(--ui-muted, #686868);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 4px;
}
.ctxbar-align-row { display: flex; gap: 2px; }
.ctxbar-align-btn { padding: 0 5px; }
/* Algorithm-layer flyouts (TB-4b): a scrollable vertical list of menu items
   (switch-algorithm can run ~25 entries; presets vary). Reuses the align-flyout
   box; items stretch full-width and left-align like a native menu. */
.ctxbar-algo-flyout {
  gap: 1px;
  max-height: min(320px, var(--ctxbar-menu-space, var(--app-vh)));
  overflow-y: auto;
  min-width: 148px;
}
.ctxbar-algo-flyout .ctxbar-menu-item { width: 100%; }
.ctxbar-algo-flyout .ctxbar-align-group-label { margin-top: 4px; }
.ctxbar-algo-flyout .ctxbar-align-group-label:first-child { margin-top: 0; }
/* Algorithm switcher rows reuse the shared lvl-algo-sub-item/algo-group-div
   markup (same as the Add Layer submenu + left-pane module dropdown). */
.ctxbar-algo-flyout .algo-group-div { margin-top: 4px; }
.ctxbar-algo-flyout .algo-group-div:first-child { margin-top: 0; }
.ctxbar-algo-menu-wrap .ctxbar-text-field { max-width: 150px; }
.ctxbar-algo-field .lvl-algo-sub-ico { margin-right: 5px; }
/* fs-s1 — the Shape pill went icon-only (no visible label): drop the wide
   label-sized max-width/padding built for text and match .ctxbar-btn's tight
   icon padding instead. Same specificity + later in source than the rule
   above, so it wins. */
.ctxbar-algo-menu-wrap .ctxbar-scene-shape { max-width: none; padding: 0 7px; }
.ctxbar-scene-shape .lvl-algo-sub-ico { margin-right: 4px; }
/* Scene-object persistent flyouts (ask #8): Style / Shadow / Highlight / X-ray.
   A vertical stack of label + control rows; reuses the align-flyout box (open
   state, up/down flip inherited). Scrolls when tall so it never clips. */
.ctxbar-scene-flyout {
  gap: 6px;
  min-width: 232px;
  max-height: min(60vh, var(--ctxbar-menu-space, var(--app-vh)));
  overflow-y: auto;
}
.ctxbar-fly-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
/* sf-w4 — a flyout row whose control is inert for the current selection (e.g.
   Stroke Fill under a monowidth or three-pen Fill Style). It STAYS in place so
   nothing below it jumps; the row greys out and carries the reason as its
   `title`. The control itself is `disabled`, so the row keeps the hover that
   surfaces that tooltip. */
.ctxbar-fly-row.is-disabled { opacity: .45; }
.ctxbar-fly-label {
  font-size: var(--font-size-xs, 11px);
  color: var(--ui-muted, #9a9a9a);
  white-space: nowrap;
  flex: 0 0 auto;
}
.ctxbar-fly-ctl {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  justify-content: flex-end;
}
.ctxbar-fly-ctl > * { max-width: 100%; }
/* U5b-5 — every scene flyout row is narrow (`.ctxbar-scene-flyout` is
   min-width: 232px) and a native <select> clips an overflowing label
   mid-word with no ellipsis by default (e.g. "Duty Cycle · Constant" →
   "Duty Cycle · Constar" in the Shadow flyout's Fill Style row). Give every
   flyout select proper overflow treatment instead of a raw cut. Scoped to
   `.ctxbar-fly-ctl` so the docked panel's own (wider) selects, which do not
   clip, are untouched. */
.ctxbar-fly-ctl .ctrl-sel {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
/* Multi-select "Mixed" state: the selected objects disagree on this control.
   The sentinel option / blanked chip already communicate it; the muted italic
   accent keeps the surface from reading as a real shared value. */
.ctxbar-fly-ctl.ctxbar-fly-mixed .ctrl-sel,
.ctxbar-fly-ctl.ctxbar-fly-mixed .seg-ctrl .seg-opt.active,
.ctxbar-fly-ctl.ctxbar-fly-mixed .slider-val,
.ctxbar-fly-ctl.ctxbar-fly-mixed .angle-inp {
  color: var(--ui-muted, #9a9a9a);
  font-style: italic;
}
.ctxbar-fly-ctl.ctxbar-fly-mixed .slider-val::placeholder,
.ctxbar-fly-ctl.ctxbar-fly-mixed .angle-inp::placeholder {
  color: var(--ui-muted, #9a9a9a);
  font-style: italic;
  opacity: 1;
}
.ctxbar-fly-subhead {
  font-size: var(--font-size-xs, 10px);
  color: var(--ui-muted, #686868);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-top: 4px;
  padding-top: 6px;
  border-top: 1px solid var(--ui-border, #363636);
}
.ctxbar-fly-note {
  font-size: var(--font-size-xs, 10px);
  color: var(--ui-muted, #686868);
  font-style: italic;
}
/* U9 — the Fill Style caveat: a measured warning on a demoted library law, not
   ordinary help text. Token-coloured so both themes read it. */
.ctxbar-fly-note.is-caveat {
  color: var(--ui-danger);
  font-style: normal;
  border-left: 2px solid color-mix(in srgb, var(--ui-danger) 45%, transparent);
  padding-left: 6px;
}
/* U5 — an explanatory caveat ("this is intended, not a defect"): calm
   informational style matching the panel's help text, with a neutral rule.
   Shared with the docked panel's `.vs3-lawnote.is-info`. Only a genuine
   limitation keeps the red `.is-caveat` warning above. */
.ctxbar-fly-note.is-info,
.vs3-lawnote.is-info {
  color: var(--ui-text-2, var(--ui-muted, #8a8a8a));
  font-style: normal;
  border-left: 2px solid var(--ui-border, #363636);
  padding-left: 6px;
}
/* U12 D1/D2 — the faceted-primitive orientation line: box/plane/solid have no
   chart, so most Fill Style options are no-ops there (greyed out above). A
   different colour from .is-caveat (which is a measured law caveat) so the two
   do not read as the same kind of warning. */
.ctxbar-fly-note.is-faceted {
  color: var(--ui-warning, #d29922);
  font-style: normal;
  border-left: 2px solid color-mix(in srgb, var(--ui-warning, #d29922) 45%, transparent);
  padding-left: 6px;
}
/* fs-y1 Job 1 — the ctxbar Style/Shadow flyouts' Fill Style (i). The docked
   panel's `.vs3-lawinfo-pop` floats a positioned popover, which does not work
   in a 232px-wide flyout: `.ctxbar-scene-flyout` sets `overflow-y: auto`,
   which per spec also computes `overflow-x` to `auto` (not `visible`), so a
   floating popover would get clipped/scrolled instead of shown. This box
   renders INLINE in the flyout's own vertical flow instead — display swaps
   on `.is-open` (JS-toggled by the (i) click) so it always fits the column
   and never needs its own positioning. Its paragraphs reuse `.vs3-lawnote`
   (same look as the docked panel's popover text) — one visual language for
   the info panel across both surfaces, only the container differs. The `i`
   button itself reuses `.vs3-lawinfo-btn` (components.css, above) verbatim.*/
.ctxbar-fly-lawinfo {
  display: none;
  margin: 2px 0 4px;
}
.ctxbar-fly-lawinfo.is-open { display: block; }
.ctxbar-fly-lawinfo .vs3-lawnote:last-child { margin-bottom: 0; }
.ctxbar-fly-reset { width: 100%; justify-content: center; }
.ctxbar-scene-menu-wrap .ctxbar-scene-field { max-width: 140px; }
/* fs-s1 — Style/Shadow/Highlight pills went icon-only (no visible label):
   drop the label-sized max-width/padding for .ctxbar-btn's tight icon
   padding. Same specificity + later in source than the rule above, wins. */
.ctxbar-scene-menu-wrap .ctxbar-scene-style,
.ctxbar-scene-menu-wrap .ctxbar-scene-shadow,
.ctxbar-scene-menu-wrap .ctxbar-scene-highlight {
  max-width: none;
  padding: 0 7px;
}
.ctxbar-scene-style .lvl-algo-sub-ico,
.ctxbar-scene-shadow .lvl-algo-sub-ico,
.ctxbar-scene-highlight .lvl-algo-sub-ico {
  margin-right: 4px;
}
/* I20 scoped scene pen chip + its pen-list flyout (writes byObject/byFace, never
   the layer pen). The chip reuses the shared .pen-chip look; the flyout reuses
   the scene-flyout box with compact swatch rows. */
.ctxbar-scene-pen-flyout { min-width: 168px; padding: 4px; }
.ctxbar-scene-pen-row {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  text-align: left;
}
.ctxbar-scene-pen-sw {
  flex: 0 0 14px;
  width: 14px;
  height: 14px;
  border-radius: 3px;
  border: 1px solid var(--ui-border-hi, #4a4a4a);
  background-clip: padding-box;
}
.ctxbar-scene-pen-name { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ctxbar-scene-pen-row.is-active { color: var(--ui-accent, #4e9ee1); }
/* Add Layer dropdown (idle TB-3) reuses the same field/flyout markup. */
.ctxbar-add-layer-field .lvl-algo-sub-ico { margin-right: 5px; }
/* Add Layer drill-down rows: distinct class from `.ctxbar-menu-item` so the
   overflow ⋯ menu's unscoped `.ctxbar-menu-item` queries don't pick these up
   (both render in the idle state). Same look as `.ctxbar-menu-item`. */
.ctxbar-add-layer-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 6px 10px;
  border: none;
  background: transparent;
  color: var(--ui-text, #e0e0e0);
  font-size: var(--font-size-sm, 11px);
  border-radius: var(--radius-sm, 4px);
  cursor: pointer;
}
.ctxbar-add-layer-item:hover { background: var(--ui-ctrl, #2c2c2c); }
/* Text controls (TB-7). */
.ctxbar-text-field {
  display: inline-flex;
  align-items: center;
  height: 26px;
  max-width: 140px;
  padding: 0 8px;
  border: 1px solid var(--ui-border, #363636);
  border-radius: var(--radius-sm, 4px);
  background: var(--ui-ctrl, #2c2c2c);
  color: var(--ui-text, #e0e0e0);
  font-size: var(--font-size-sm, 11px);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
}
.ctxbar-text-family { max-width: 150px; }
/* Labeled dropdown pills (family/style): truncate the label, keep the caret. */
.ctxbar-text-field .ctxbar-text-fieldlabel {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ctxbar-text-field .ctxbar-text-caret {
  flex: 0 0 auto;
  margin-left: 5px;
  font-size: 9px;
  line-height: 1;
  opacity: 0.7;
}
@media (hover: hover) {
  .ctxbar-text-field:hover .ctxbar-text-caret { opacity: 1; }
}
/* The caret pivots (rotates through 180°) rather than swapping glyphs, so it
   reads as the same arrow turning over. Applied to both caret flavours — the
   pill carets and the standalone size-presets chevron — and driven from either
   the per-element `ctxbar-caret-up` stamp or the bar-level `.ctxbar-menus-up`
   state, whichever lands first. The rotation is the STATE, not decoration: it
   is declared here unconditionally so reduced motion can drop the transition
   (motion.css) without ever leaving an arrow pointing the wrong way. */
.ctxbar-text-caret,
.ctxbar-text-size-caret {
  transform-origin: 50% 50%;
}
.ctxbar-text-caret.ctxbar-caret-up,
.ctxbar-text-size-caret.ctxbar-caret-up,
.ctxbar.ctxbar-menus-up .ctxbar-text-caret,
.ctxbar.ctxbar-menus-up .ctxbar-text-size-caret {
  transform: rotate(180deg);
}
.ctxbar-text-size {
  width: 58px;
  height: 26px;
  padding: 0 6px;
  border: 1px solid var(--ui-border, #363636);
  border-radius: var(--radius-sm, 4px);
  background: var(--ui-ctrl, #2c2c2c);
  color: var(--ui-text, #e0e0e0);
  font-size: var(--font-size-sm, 11px);
}
.ctxbar-text-field:focus-visible,
.ctxbar-text-size:focus-visible {
  outline: 2px solid var(--ui-accent, #4e9ee1);
  outline-offset: 1px;
}
/* Hide the task bar on phones (matches the HUD strip behavior). */
@media (max-width: 640px) {
  .ctxbar { display: none; }
}
/* ============================================================================
   END TB (Lane G)
   ============================================================================ */

/* ============================================================================
   TB sub-modes & Shape Properties (Phase 2, Lane H — TB-9/10/11, SHP-1/2)
   Sub-mode controls live inside Lane G's dark task-bar pill (light-on-dark);
   popovers/badge are standalone surfaces on the skin panel tokens.
   ============================================================================ */

/* Sub-mode content morphed into the bar's content host (TB-9). */
.ctxbar-submode {
  display: flex;
  align-items: center;
  gap: var(--spacing-xs, 6px);
  color: var(--ui-on-accent, #fff);
}
.ctxbar-submode-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: inherit;
  opacity: 0.85;
}
.ctxbar-slider {
  flex: 1 1 120px;
  min-width: 90px;
  accent-color: var(--ui-accent, #4c8bf5);
  cursor: pointer;
}
.ctxbar-field {
  width: 46px;
  text-align: right;
  background: rgba(255, 255, 255, 0.12);
  color: inherit;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: var(--radius-sm, 4px);
  font: var(--font-size-xs, 11px) var(--font-mono, monospace);
  padding: 2px 4px;
}
.ctxbar-unit {
  font-size: var(--font-size-xs, 11px);
  opacity: 0.7;
}
.ctxbar-stepper,
.ctxbar-overflow,
.ctxbar-auto-smooth,
.ctxbar-submode-exit {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  color: inherit;
  background: rgba(255, 255, 255, 0.10);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: var(--radius-sm, 4px);
  cursor: pointer;
  font-size: var(--font-size-xs, 11px);
  line-height: 1;
}
.ctxbar-stepper:hover,
.ctxbar-overflow:hover,
.ctxbar-auto-smooth:hover,
.ctxbar-submode-exit:hover { background: rgba(255, 255, 255, 0.18); }
.ctxbar-auto-smooth,
.ctxbar-submode-exit { padding: 0 10px; font-weight: 600; }
.ctxbar-submode-exit.is-done {
  background: var(--ui-accent, #4c8bf5);
  border-color: var(--ui-accent, #4c8bf5);
  color: var(--ui-on-accent, #fff);
}
.ctxbar-wave-min { opacity: 0.7; }
.ctxbar-wave-max { opacity: 0.9; }
.ctxbar-wave-sharp { opacity: 0.7; }
/* Nothing left to reduce (e.g. a triangle): the slider has no travel. */
.ctxbar-slider:disabled,
.ctxbar-auto-smooth:disabled {
  cursor: not-allowed;
  opacity: 0.4;
}
.ctxbar-simplify.is-unreducible .ctxbar-submode-icon { opacity: 0.4; }

/* Standalone anchored popovers + menu (STR-2 host, "…" menu). */
.ctxbar-popover {
  z-index: 2147483000;
  background: var(--ui-panel, #23262e);
  color: var(--ui-text, #e6e8ec);
  border: 1px solid var(--ui-border, rgba(255, 255, 255, 0.12));
  border-radius: var(--radius-md, 8px);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  font-family: var(--font-ui, system-ui, sans-serif);
  font-size: var(--font-size-sm, 12px);
  padding: 8px;
}
.ctxbar-menu { padding: 4px; min-width: 160px; }
.ctxbar-menu-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 6px 10px;
  background: transparent;
  border: 0;
  color: inherit;
  border-radius: var(--radius-sm, 4px);
  cursor: pointer;
  font-size: var(--font-size-sm, 12px);
}
.ctxbar-menu-item:hover { background: var(--ui-ctrl-hov, rgba(255, 255, 255, 0.08)); }

/* Simplify percentage badge anchored below the selection (TB-11). */
.ctxbar-simplify-badge {
  z-index: 2147483000;
  background: var(--ui-panel-alt, #2c303a);
  color: var(--ui-text, #e6e8ec);
  border: 1px solid var(--ui-border, rgba(255, 255, 255, 0.12));
  border-radius: var(--radius-sm, 4px);
  padding: 2px 8px;
  font: var(--font-size-xs, 11px) var(--font-mono, monospace);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.3);
  pointer-events: none;
  white-space: nowrap;
}

/* Shape Properties popover (SHP-1/2). */
.shape-props-popover { min-width: 220px; position: relative; }
.shape-props-title {
  font-weight: 600;
  font-size: var(--font-size-sm, 12px);
  margin-bottom: 8px;
  padding-right: 18px;
}
.shape-props-row { margin: 8px 0; }
.shape-props-label {
  display: block;
  font-size: var(--font-size-xs, 11px);
  color: var(--ui-text-2, #a7adb8);
  margin-bottom: 4px;
}
.shape-props-control {
  display: flex;
  align-items: center;
  gap: var(--spacing-xs, 6px);
}
.shape-props-icon { display: inline-flex; color: var(--ui-text-2, #a7adb8); }
.shape-props-slider {
  flex: 1 1 auto;
  accent-color: var(--ui-accent, #4c8bf5);
  cursor: pointer;
}
.shape-props-field {
  width: 52px;
  text-align: right;
  background: var(--ui-ctrl, rgba(255, 255, 255, 0.06));
  color: var(--ui-text, #e6e8ec);
  border: 1px solid var(--ui-border, rgba(255, 255, 255, 0.14));
  border-radius: var(--radius-sm, 4px);
  font: var(--font-size-xs, 11px) var(--font-mono, monospace);
  padding: 3px 5px;
  cursor: ew-resize;
}
.shape-props-sides-field { width: 40px; cursor: text; }
.shape-props-unit { font-size: var(--font-size-xs, 11px); color: var(--ui-text-2, #a7adb8); }
.shape-props-stepper {
  min-width: 22px;
  height: 22px;
  padding: 0;
  background: var(--ui-ctrl, rgba(255, 255, 255, 0.06));
  color: var(--ui-text, #e6e8ec);
  border: 1px solid var(--ui-border, rgba(255, 255, 255, 0.14));
  border-radius: var(--radius-sm, 4px);
  cursor: pointer;
  line-height: 1;
}
.shape-props-stepper:hover { background: var(--ui-ctrl-hov, rgba(255, 255, 255, 0.10)); }
.shape-props-close {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 18px;
  height: 18px;
  padding: 0;
  background: transparent;
  border: 0;
  color: var(--ui-text-2, #a7adb8);
  cursor: pointer;
  font-size: 15px;
  line-height: 1;
}
.shape-props-close:hover { color: var(--ui-text, #e6e8ec); }

/* Corners dialog (double-click a Live Corner widget). Shares the
   shape-props-popover shell; adds the three corner-style toggle buttons. */
.corners-popover { min-width: 200px; }
.corners-style-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 26px;
  padding: 0;
  background: var(--ui-ctrl, rgba(255, 255, 255, 0.06));
  color: var(--ui-text-2, #a7adb8);
  border: 1px solid var(--ui-border, rgba(255, 255, 255, 0.14));
  border-radius: var(--radius-sm, 4px);
  cursor: pointer;
}
.corners-style-btn:hover {
  background: var(--ui-ctrl-hov, rgba(255, 255, 255, 0.10));
  color: var(--ui-text, #e6e8ec);
}
.corners-style-btn.is-active {
  background: var(--ui-ctrl-hov, rgba(255, 255, 255, 0.10));
  border-color: var(--ui-accent, #4c8bf5);
  color: var(--ui-text, #e6e8ec);
}
.corners-radius-field { cursor: text; }
/* ============================================================================
   END TB sub-modes & Shape Properties (Lane H)
   ============================================================================ */

/* === ISO: isolation breadcrumb bar + edge indicator (Phase 2 Lane I — ISO-1/2) ===
   Both surfaces self-mount into #viewport-container via
   src/ui/shell/breadcrumb-bar.js and are shown only while isolation is active
   (`.is-visible`). Motion/transition rules live in motion.css. */

/* ISO-2: thin top-edge isolation accent line. */
.iso-edge-indicator {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: var(--iso-edge-height, 2px);
  background: var(--iso-edge-color, #2680eb);
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  z-index: 42;
}
.iso-edge-indicator.is-visible {
  opacity: 1;
  visibility: visible;
}

/* ISO-1: breadcrumb strip. */
.iso-breadcrumb {
  position: absolute;
  top: var(--iso-edge-height, 2px);
  left: 0;
  right: 0;
  min-height: var(--iso-bc-height, 30px);
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 10px;
  background: color-mix(in srgb, var(--ui-panel, #252525) 92%, transparent);
  border-bottom: 1px solid var(--ui-border, #363636);
  color: var(--ui-text, #e0e0e0);
  font-family: var(--font-ui, system-ui, sans-serif);
  font-size: var(--font-size-sm, 11px);
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  z-index: 41;
}
.iso-breadcrumb.is-visible {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.iso-bc-back {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  padding: 0;
  border: 1px solid var(--ui-border, #363636);
  border-radius: var(--radius-sm, 4px);
  background: var(--ui-ctrl, #303030);
  color: var(--ui-text, #e0e0e0);
  cursor: pointer;
}
.iso-bc-back:hover {
  background: var(--ui-ctrl-hov, #3a3a3a);
  border-color: var(--ui-border-hi, #4a4a4a);
}
.iso-bc-back:focus-visible {
  outline: 2px solid var(--iso-edge-color, #2680eb);
  outline-offset: 1px;
}
.iso-bc-back-svg {
  width: 14px;
  height: 14px;
}

.iso-bc-trail {
  display: flex;
  align-items: center;
  gap: 4px;
  margin: 0;
  padding: 0;
  list-style: none;
  min-width: 0;
  overflow: hidden;
}
.iso-bc-item {
  display: inline-flex;
  min-width: 0;
}
.iso-bc-sep {
  flex: none;
  color: var(--ui-muted, #8a8a8a);
  user-select: none;
}
.iso-bc-crumb {
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 2px 6px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm, 4px);
  background: none;
  color: var(--ui-text-2, var(--ui-muted, #b0b0b0));
  font: inherit;
  cursor: pointer;
}
.iso-bc-crumb:hover:not(.iso-bc-current) {
  color: var(--ui-text, #e0e0e0);
  background: var(--ui-ctrl, #303030);
}
.iso-bc-crumb:focus-visible {
  outline: 2px solid var(--iso-edge-color, #2680eb);
  outline-offset: 1px;
}
.iso-bc-crumb.iso-bc-current {
  color: var(--ui-text, #e0e0e0);
  font-weight: 600;
  cursor: default;
}
/* ============================================================================
   END ISO (Lane I)
   ============================================================================ */

/* ============================================================================
   TK: Transform panel — true X/Y/W/H, link W/H, Flip H/V (Phase 3 Lane K,
   SEL-5 / SEL-6 / SG-6). Injected by src/ui/panels/transform-panel.js.
   ============================================================================ */
#transform-bbox-controls .tk-link-btn,
#transform-bbox-controls .tk-flip-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--ui-text-2, var(--ui-muted, #b0b0b0));
  background: var(--vectura-border, var(--ui-ctrl, #303030));
  border: 1px solid var(--vectura-border, transparent);
  border-radius: var(--radius-sm, 3px);
  cursor: pointer;
  transition: color 120ms ease, background 120ms ease, border-color 120ms ease;
}
#transform-bbox-controls .tk-link-btn {
  width: 26px;
  height: 26px;
  padding: 0;
}
#transform-bbox-controls .tk-flip-btn {
  flex: 1 1 0;
  gap: 6px;
  height: 26px;
  padding: 0 8px;
}
#transform-bbox-controls .tk-link-btn:hover:not(:disabled),
#transform-bbox-controls .tk-flip-btn:hover:not(:disabled) {
  color: var(--vectura-accent, #2680eb);
  border-color: var(--vectura-accent, #2680eb);
}
#transform-bbox-controls .tk-link-btn[aria-pressed="true"] {
  color: var(--vectura-accent, #2680eb);
  border-color: var(--vectura-accent, #2680eb);
}
#transform-bbox-controls .tk-flip-btn:focus-visible,
#transform-bbox-controls .tk-link-btn:focus-visible {
  outline: 2px solid var(--vectura-accent, #2680eb);
  outline-offset: 1px;
}
#transform-bbox-controls .tk-link-btn:disabled,
#transform-bbox-controls .tk-flip-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
/* ============================================================================
   END TK (Lane K)
   ============================================================================ */

/* ============================================================================
   TXT (Lane J) — font hover-preview highlight, filter clear (×), size presets
   TXT-3/4/5. Appended block; tokens from tokens.css.
   ============================================================================ */
/* Filter clear (×) affordance — shown only while the search has a query. */
.vtp-fp-clear {
  flex: none; width: 20px; height: 20px; display: none; align-items: center; justify-content: center;
  border: none; background: none; cursor: pointer; color: var(--ui-muted); padding: 0; border-radius: 4px;
}
.vtp-fp-clear.show { display: flex; }
.vtp-fp-clear:hover { color: var(--ui-text); background: var(--ui-ctrl-hov); }
.vtp-fp-clear:focus-visible { outline: 2px solid var(--ui-accent); outline-offset: 1px; }
.vtp-fp-clear svg { width: 10px; height: 10px; }
/* Row being live-previewed on canvas (hover dwell settled). */
.vtp-fp-opt.previewing { box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--ui-accent) 55%, transparent); }

/* Size preset dropdown (TXT-5) — body-level menu of quick sizes. */
.vtp-size-pop {
  position: fixed; z-index: 10001; background: var(--ui-panel);
  border: 1px solid var(--ui-border-hi); border-radius: var(--radius-md); box-shadow: var(--shadow-lg);
  padding: 4px; max-height: 260px; overflow-y: auto; scrollbar-width: thin;
  display: flex; flex-direction: column; gap: 1px;
  opacity: 0; transform: translateY(-4px); transition: opacity .12s, transform .12s;
}
.vtp-size-pop.open { opacity: 1; transform: none; }
.vtp-size-opt {
  border: none; background: none; color: var(--ui-text); cursor: pointer; text-align: right;
  font-family: var(--font-mono); font-size: var(--font-size-sm); font-variant-numeric: tabular-nums;
  padding: 5px 10px; border-radius: var(--radius-sm);
}
.vtp-size-opt:hover, .vtp-size-opt.active { background: var(--ui-ctrl-hov); color: var(--ui-text); }
.vtp-size-opt.sel { background: var(--ui-accent-2); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--ui-accent) 35%, transparent); }
.vtp-size-opt:focus-visible { outline: 2px solid var(--ui-accent); outline-offset: -2px; }
@media (prefers-reduced-motion: reduce) {
  .vtp-size-pop { transition-duration: .01ms; }
}
/* ============================================================================
   END TXT (Lane J)
   ============================================================================ */

/* ============================================================================
   TLD: All Tools drawer (Lane L — TLD-1/2)
   Overflow "…" rail affordance opens a non-modal inventory drawer grouped by
   category, with a grid/list view toggle and docked-slot cross-highlighting.
   ============================================================================ */
.tool-overflow-btn svg { width: 16px; height: 16px; }

.tool-drawer {
  position: fixed;
  top: 0; left: 0;
  width: 264px;
  max-height: min(72vh, 640px);
  display: flex; flex-direction: column;
  padding: 0;
  border-radius: 12px;
  border: 1px solid var(--ui-border);
  background: var(--ui-panel-alt);
  box-shadow: var(--shadow-float);
  z-index: 45;
  overflow: hidden;
}
.tool-drawer.hidden { display: none; }

.tool-drawer-header {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--spacing-sm);
  padding: 8px 10px;
  border-bottom: 1px solid var(--ui-border);
  background: var(--ui-panel);
  flex-shrink: 0;
}
.tool-drawer-title {
  font-size: 12px; font-weight: 600; color: var(--ui-text);
  letter-spacing: 0.02em;
}
.tool-drawer-view-toggle {
  display: inline-flex; gap: 2px;
  padding: 2px;
  border-radius: 8px;
  border: 1px solid var(--ui-border);
  background: var(--ui-panel-alt);
}
.tool-drawer-view-btn {
  width: 24px; height: 22px;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid transparent; border-radius: 6px;
  background: none; cursor: pointer; color: var(--ui-muted);
  transition: background-color 0.12s, color 0.12s, border-color 0.12s;
}
.tool-drawer-view-btn svg { width: 14px; height: 14px; }
.tool-drawer-view-btn:hover { background: var(--ui-ctrl-hov); color: var(--ui-text); }
.tool-drawer-view-btn.active {
  background: var(--ui-accent-2); border-color: var(--ui-accent); color: var(--ui-accent);
}

.tool-drawer-body {
  flex: 1; min-height: 0;
  overflow-y: auto; overflow-x: hidden;
  padding: 8px 10px 12px;
  display: flex; flex-direction: column; gap: 12px;
}

.tool-drawer-category { display: flex; flex-direction: column; gap: 6px; }
.tool-drawer-category-label {
  font-size: 10px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--ui-muted);
}

.tool-drawer-items { display: flex; }
/* Grid view (default): compact icon buttons; labels collapse to tooltips. */
.tool-drawer[data-view="grid"] .tool-drawer-items {
  flex-wrap: wrap; gap: 4px;
}
.tool-drawer[data-view="grid"] .tool-drawer-item-label { display: none; }
.tool-drawer[data-view="grid"] .tool-drawer-item {
  width: 34px; height: 34px; justify-content: center;
}
/* List view: full-width rows with icon + name. */
.tool-drawer[data-view="list"] .tool-drawer-items {
  flex-direction: column; gap: 2px;
}
.tool-drawer[data-view="list"] .tool-drawer-item {
  width: 100%; height: 30px; justify-content: flex-start; gap: 8px; padding: 0 8px;
}

.tool-drawer-item {
  display: inline-flex; align-items: center;
  border: 1px solid transparent; border-radius: 8px;
  background: none; cursor: pointer; color: var(--ui-muted);
  transition: background-color 0.12s, color 0.12s, border-color 0.12s;
}
.tool-drawer-item:hover { background: var(--ui-ctrl-hov); color: var(--ui-text); }
.tool-drawer-item.active {
  background: var(--ui-accent-2); border-color: var(--ui-accent); color: var(--ui-accent);
}
.tool-drawer-item-icon { display: inline-flex; align-items: center; justify-content: center; }
.tool-drawer-item-icon svg { width: 18px; height: 18px; }
.tool-drawer-item-label {
  font-size: 12px; color: inherit; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
}

/* TLD-2: cross-highlight ring on the rail slot the hovered entry lives in. */
.tool-drawer-rail-highlight {
  box-shadow: 0 0 0 2px var(--ui-accent);
  border-radius: var(--radius-sm);
}
/* ============================================================================
   END TLD (Lane L)
   ============================================================================ */

/* ============================================================================
   MSC-1 (Lane M): mixed-value indicators
   A multi-selection with differing stroke weights blanks the field and shows a
   muted "mixed" placeholder instead of a misleading single value. Mirrors the
   Pen Picker's "?" mixed badge treatment (COL-2/3).
   ============================================================================ */
.stroke-field.is-mixed,
.ctxbar-field.is-mixed {
  font-style: italic;
}
.stroke-field.is-mixed::placeholder,
.ctxbar-field.is-mixed::placeholder {
  color: var(--ui-text-2, var(--ui-muted, #b0b0b0));
  font-style: italic;
  opacity: 1;
}
/* ============================================================================
   END MSC-1 (Lane M)
   ============================================================================ */
/* ============================================================================
   CTX-1 (Lane M): canvas right-click context menu
   Self-mounted verb menu (Duplicate/Delete, Undo/Redo, Group/Ungroup, Isolate,
   Simplify/Smooth, Flip H/V, Transform). Fixed-positioned, body-appended.
   ============================================================================ */
.canvas-ctx-menu {
  position: fixed;
  z-index: 4000;
  min-width: 168px;
  padding: 4px;
  background: var(--ui-panel, var(--ui-bg, #1c1c1c));
  border: 1px solid var(--ui-border, #3a3a3a);
  border-radius: 6px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.45);
  font-size: 12px;
  user-select: none;
}
.canvas-ctx-item {
  display: block;
  width: 100%;
  padding: 5px 10px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--ui-text, #e0e0e0);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.canvas-ctx-item:hover:not(.is-disabled),
.canvas-ctx-item:focus-visible:not(.is-disabled) {
  background: var(--ui-accent, #2680eb);
  color: var(--ui-on-accent, #fff);
  outline: none;
}
.canvas-ctx-item.is-disabled {
  color: var(--ui-text-2, var(--ui-muted, #7a7a7a));
  cursor: default;
}
.canvas-ctx-sep {
  height: 1px;
  margin: 4px 6px;
  background: var(--ui-border, #3a3a3a);
}
/* ============================================================================
   END CTX-1 (Lane M)
   ============================================================================ */

/* ============================================================================
   P3-INT: Task Bar size-preset caret (integrator wiring — TB-7 → Lane J
   TextPanel.openSizePresets). Small dropdown affordance beside the size field.
   ============================================================================ */
.ctxbar-text-size-caret {
  height: 26px;
  min-width: 18px;
  margin-left: -2px;
  padding: 0 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--ui-border, #363636);
  border-left: none;
  border-radius: 0 var(--radius-sm, 4px) var(--radius-sm, 4px) 0;
  background: var(--ui-ctrl, #2c2c2c);
  color: var(--ui-text-2, var(--ui-muted, #b0b0b0));
  font-size: 10px;
  line-height: 1;
  cursor: pointer;
}
.ctxbar-text-size-caret:hover { color: var(--ui-accent, #4e9ee1); }
.ctxbar-text-size-caret:focus-visible {
  outline: 2px solid var(--ui-accent, #4e9ee1);
  outline-offset: 1px;
}
/* ============================================================================
   END P3-INT
   ============================================================================ */

/* ============================================================================
   VECTURA SCENE PANEL (vs3-*) — bespoke 3D Scene panel for scene3d layers
   (src/ui/panels/scene3d-panel.js). Fluid inside the ~290px #dynamic-controls
   pane; tokens only, light + dark safe. Shelf collapses to icon-only tiles at
   narrow container widths (container-query precedent: text panel / left pane).
   ============================================================================ */
.vs3-panel {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-md, 12px);
  min-width: 0;
}
.vs3-page { display: none; min-width: 0; }
.vs3-page.active { display: flex; flex-direction: column; gap: var(--spacing-md, 12px); }
.vs3-placeholder,
.vs3-empty {
  margin: 4px 0;
  font-size: 11px;
  color: var(--ui-text-2, var(--ui-muted, #8a8a8a));
}
.vs3-foot {
  margin-top: 4px;
  font-size: 9px;
  letter-spacing: 0.14em;
  text-align: center;
  color: var(--ui-text-2, var(--ui-muted, #6e6e6e));
  opacity: 0.7;
}

/* ── Shelf ─────────────────────────────────────────────────────────────── */
.vs3-shelf {
  container-type: inline-size;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
  gap: 6px;
  padding: 2px 0;
}
.vs3-shelf-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  width: 100%;
  padding: 8px 4px 6px;
  border: 1px solid var(--ui-border, #363636);
  border-radius: var(--radius-sm, 4px);
  background: var(--ui-ctrl, #2c2c2c);
  color: var(--ui-text, #e0e0e0);
  font-size: 10px;
  line-height: 1.1;
  cursor: pointer;
  min-width: 0;
}
.vs3-shelf-btn:hover:not(:disabled) {
  border-color: var(--ui-accent, #4e9ee1);
  color: var(--ui-accent, #4e9ee1);
}
.vs3-shelf-btn:focus-visible {
  outline: 2px solid var(--ui-accent, #4e9ee1);
  outline-offset: 1px;
}
.vs3-shelf-btn:disabled,
.vs3-shelf-btn.is-stub {
  opacity: 0.45;
  cursor: not-allowed;
}
.vs3-shelf-icon { display: inline-flex; width: 18px; height: 18px; }
.vs3-shelf-icon svg { width: 100%; height: 100%; }
.vs3-shelf-label {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
/* Narrow pane: shelf tiles collapse to icon-only. */
@container (max-width: 240px) {
  .vs3-shelf-label { display: none; }
  .vs3-shelf-btn { padding: 7px 2px; }
}

/* More… flyout (toolbar sub-tool pattern, panel-local) */
.vs3-more { position: relative; display: flex; min-width: 0; }
.vs3-more .vs3-more-btn { flex: 1 1 auto; border-radius: var(--radius-sm, 4px) 0 0 var(--radius-sm, 4px); }
.vs3-more-caret {
  flex: 0 0 auto;
  width: 16px;
  border: 1px solid var(--ui-border, #363636);
  border-left: none;
  border-radius: 0 var(--radius-sm, 4px) var(--radius-sm, 4px) 0;
  background: var(--ui-ctrl, #2c2c2c);
  color: var(--ui-text-2, var(--ui-muted, #8a8a8a));
  font-size: 8px;
  cursor: pointer;
  padding: 0;
}
.vs3-more-caret:hover { color: var(--ui-accent, #4e9ee1); }
.vs3-more-caret:focus-visible {
  outline: 2px solid var(--ui-accent, #4e9ee1);
  outline-offset: 1px;
}
.vs3-more-menu {
  /* Portaled to <body> and positioned with fixed coords in JS so it escapes the
     Add Objects section's overflow:hidden clip. top/left are set inline. */
  display: none;
  position: fixed;
  z-index: 4000;
  min-width: 148px;
  padding: 4px;
  border: 1px solid var(--ui-border, #363636);
  border-radius: var(--radius-sm, 4px);
  background: var(--ui-panel, #232323);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
}
.vs3-more-menu.open { display: block; }
.vs3-more-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 5px 8px;
  border: 0;
  border-radius: 3px;
  background: transparent;
  color: var(--ui-text, #e0e0e0);
  font-size: 11px;
  text-align: left;
  cursor: pointer;
}
.vs3-more-item:hover,
.vs3-more-item:focus-visible {
  background: var(--ui-accent, #2680eb);
  color: var(--ui-on-accent, #fff);
  outline: none;
}

/* ── Scene tree ────────────────────────────────────────────────────────── */
.vs3-tree { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.vs3-tree-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 6px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm, 4px);
  cursor: pointer;
  min-width: 0;
}
.vs3-tree-row:hover { background: var(--ui-ctrl, rgba(128, 128, 128, 0.12)); }
.vs3-tree-row.selected {
  border-color: var(--ui-accent, #4e9ee1);
  background: color-mix(in srgb, var(--ui-accent, #4e9ee1) 14%, transparent);
}
.vs3-tree-name {
  flex: 1 1 auto;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 11px;
  color: var(--ui-text, #e0e0e0);
}
/* CSG role badge on a scene-tree row (Increment 1). A wired hole reads accent;
   an ungrouped (inert) hole is muted with a trailing '?' to flag it. */
.vs3-tree-role {
  flex: 0 0 auto;
  margin: 0 4px;
  padding: 0 5px;
  height: 15px;
  display: inline-flex;
  align-items: center;
  border-radius: 7px;
  font-size: 9px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ui-accent, #4e9ee1);
  background: color-mix(in srgb, var(--ui-accent, #4e9ee1) 16%, transparent);
}
.vs3-tree-role.vs3-tree-role-inert {
  color: var(--ui-text-2, var(--ui-muted, #8a8a8a));
  background: var(--ui-ctrl, rgba(128, 128, 128, 0.14));
}
/* Group-membership badge in the object tree (op glyph of the owning group). */
.vs3-tree-grp {
  flex: 0 0 auto;
  margin: 0 2px;
  width: 16px;
  height: 15px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  font-size: 11px;
  color: var(--ui-accent, #4e9ee1);
  background: color-mix(in srgb, var(--ui-accent, #4e9ee1) 14%, transparent);
}
/* ── Boolean Groups section (Increment 3 grouping UI) ─────────────────────── */
.vs3-groups {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.vs3-grp-card {
  border: 1px solid var(--ui-border, rgba(128, 128, 128, 0.35));
  border-radius: 6px;
  padding: 6px 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: color-mix(in srgb, var(--ui-accent, #4e9ee1) 4%, transparent);
}
.vs3-grp-nested {
  margin-left: 14px;
  border-left: 2px solid color-mix(in srgb, var(--ui-accent, #4e9ee1) 40%, transparent);
}
.vs3-grp-head {
  display: flex;
  align-items: center;
  gap: 6px;
}
.vs3-grp-name {
  flex: 1 1 auto;
  min-width: 0;
  padding: 2px 5px;
  border: 1px solid transparent;
  border-radius: 4px;
  background: var(--ui-ctrl, rgba(128, 128, 128, 0.1));
  color: var(--ui-text, inherit);
  font-size: 12px;
  font-weight: 600;
}
.vs3-grp-name:focus {
  outline: none;
  border-color: var(--ui-accent, #4e9ee1);
}
.vs3-grp-del {
  flex: 0 0 auto;
  width: 20px;
  height: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 3px;
  background: transparent;
  color: var(--ui-text-2, var(--ui-muted, #8a8a8a));
  font-size: 10px;
  cursor: pointer;
}
.vs3-grp-del:hover { color: var(--ui-danger, #e5484d); }
.vs3-grp-op {
  display: flex;
  align-items: center;
  gap: 6px;
}
.vs3-grp-op-lbl {
  flex: 0 0 auto;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ui-text-2, var(--ui-muted, #8a8a8a));
}
.vs3-grp-op .vs3-ctl { flex: 1 1 auto; }
.vs3-grp-kids {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.vs3-grp-kid {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 2px 4px;
  border-radius: 4px;
  background: var(--ui-ctrl, rgba(128, 128, 128, 0.08));
}
.vs3-grp-kid-name {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 11px;
}
.vs3-grp-kid-role { flex: 0 0 auto; }
.vs3-grp-kid-btn {
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 3px;
  background: transparent;
  color: var(--ui-text-2, var(--ui-muted, #8a8a8a));
  font-size: 11px;
  cursor: pointer;
}
.vs3-grp-kid-btn:hover:not(:disabled) { color: var(--ui-accent, #4e9ee1); }
.vs3-grp-kid-btn:disabled { opacity: 0.3; cursor: default; }
.vs3-grp-kid-rm:hover:not(:disabled) { color: var(--ui-danger, #e5484d); }
.vs3-grp-empty {
  margin: 0;
  padding: 2px 4px;
  font-size: 11px;
  font-style: italic;
  color: var(--ui-text-2, var(--ui-muted, #8a8a8a));
}
.vs3-grp-add { margin-top: 2px; }
.vs3-grp-new {
  align-self: flex-start;
  border: 1px dashed var(--ui-border, rgba(128, 128, 128, 0.35));
  border-radius: 4px;
  background: transparent;
  color: var(--ui-text-2, var(--ui-muted, #8a8a8a));
  font-size: 11px;
  line-height: 1.6;
  padding: 2px 10px;
  cursor: pointer;
}
.vs3-grp-new:hover {
  color: var(--ui-accent, #4e9ee1);
  border-color: var(--ui-accent, #4e9ee1);
}
.vs3-tree-vis,
.vs3-tree-del {
  flex: 0 0 auto;
  width: 20px;
  height: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 3px;
  background: transparent;
  color: var(--ui-text-2, var(--ui-muted, #8a8a8a));
  font-size: 10px;
  cursor: pointer;
  padding: 0;
}
.vs3-tree-vis:hover { color: var(--ui-accent, #4e9ee1); }
.vs3-tree-vis[data-visibility="xray"] { color: var(--ui-accent, #4e9ee1); }
.vs3-tree-del:hover { color: var(--ui-danger, #e5484d); }
/* Add-light action strip (not a selectable row) — small ghost buttons. */
.vs3-tree-addlight {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 4px 6px 2px;
}
.vs3-tree-addbtn {
  flex: 0 0 auto;
  border: 1px dashed var(--ui-border, rgba(128, 128, 128, 0.35));
  border-radius: 4px;
  background: transparent;
  color: var(--ui-text-2, var(--ui-muted, #8a8a8a));
  font-size: 11px;
  line-height: 1.6;
  padding: 1px 8px;
  cursor: pointer;
}
.vs3-tree-addbtn:hover {
  color: var(--ui-accent, #4e9ee1);
  border-color: var(--ui-accent, #4e9ee1);
}
.vs3-light-reset-row {
  justify-content: flex-end;
}
.vs3-light-reset {
  border: 1px solid var(--ui-border, rgba(128, 128, 128, 0.35));
  border-radius: 4px;
  background: transparent;
  color: var(--ui-text-2, var(--ui-muted, #8a8a8a));
  font-size: 11px;
  line-height: 1.6;
  padding: 2px 10px;
  cursor: pointer;
}
.vs3-light-reset:hover {
  color: var(--ui-accent, #4e9ee1);
  border-color: var(--ui-accent, #4e9ee1);
}
.vs3-rename {
  width: 100%;
  min-width: 0;
  padding: 1px 4px;
  border: 1px solid var(--ui-accent, #4e9ee1);
  border-radius: 3px;
  background: var(--ui-panel, #1e1e1e);
  color: var(--ui-text, #e0e0e0);
  font: inherit;
  font-size: 11px;
}

/* ── Inspector + Style rows ────────────────────────────────────────────── */
.vs3-inspector,
.vs3-style { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.vs3-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.vs3-lbl {
  /* 74px, not 58: "Cross density" and "Band profile" were cut to "Cross den…" (U6). */
  flex: 0 0 74px;
  font-size: 10px;
  color: var(--ui-text-2, var(--ui-muted, #9a9a9a));
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.vs3-ctl { flex: 1 1 auto; min-width: 0; }
/* sf-w4 — an inspector row whose control is inert for the current selection
   (e.g. Stroke Fill under a monowidth or three-pen Fill Style). It stays in
   place so nothing below it jumps; the whole row greys out and carries the
   reason as its tooltip. The control itself is `disabled`, so pointer-events
   stay off it without disabling the row's own title. */
.vs3-row.is-disabled { opacity: .45; }
/* Scene 3D panel value chips: a signed one-decimal value ("-55.0") must fit
 * whole, including while it is being edited. Scoped to this panel only. */
[data-ui-skin] .vs3-panel .slider-row .slider-val {
  min-width: 54px;
  max-width: 56px;
  padding-left: 4px;
  padding-right: 4px;
  box-sizing: border-box;
}
/* Boolean group: which shape is cut from which, with a one-click Swap. */
.vs3-bool-formulaRow {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 6px 0 2px;
}
.vs3-bool-formula {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 12px;
  color: var(--ui-text, inherit);
  overflow-wrap: anywhere;
}
.vs3-bool-swap {
  flex: 0 0 auto;
  border: 1px solid var(--ui-border, rgba(128, 128, 128, 0.35));
  border-radius: 4px;
  background: transparent;
  color: var(--ui-text-2, var(--ui-muted, #8a8a8a));
  font-size: 11px;
  line-height: 1.6;
  padding: 2px 10px;
  cursor: pointer;
}
.vs3-bool-swap:hover { color: var(--ui-accent, #4e9ee1); border-color: var(--ui-accent, #4e9ee1); }
.vs3-bool-swap[hidden], .vs3-bool-formula[hidden] { display: none; }
.vs3-ctl .slider-row { width: 100%; }
/* Section sub-heading inside the inspector (e.g. the Phase 5 Shadow group). */
.vs3-subhead {
  margin: 6px 0 2px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ui-text-2, var(--ui-muted, #9a9a9a));
  border-top: 1px solid var(--ui-border, #363636);
  padding-top: 8px;
}
/* Linked slider pair (scene3d Ground → Size): the rows on the left, a lock
   on the right joined to both rows by a thin bracket, so the link reads as
   belonging to exactly those two controls. */
.vs3-linked {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 22px;
  column-gap: 4px;
  align-items: stretch;
}
.vs3-linked-rows { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.vs3-link {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}
.vs3-link::before,
.vs3-link::after {
  content: "";
  position: absolute;
  left: 4px;
  right: 50%;
  border: 1px solid var(--ui-border, #363636);
  border-left: 0;
  height: calc(50% - 14px);
}
.vs3-link::before { top: 9px; border-bottom: 0; border-top-right-radius: 3px; }
.vs3-link::after { bottom: 9px; border-top: 0; border-bottom-right-radius: 3px; }
.vs3-link:has(.vs3-link-btn.is-on)::before,
.vs3-link:has(.vs3-link-btn.is-on)::after { border-color: var(--ui-accent, #4e9ee1); }
.vs3-link-btn {
  position: relative;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: var(--radius-sm, 4px);
  background: var(--ui-panel, #1e1e1e);
  color: var(--ui-text-2, var(--ui-muted, #9a9a9a));
  cursor: pointer;
}
.vs3-link-btn:hover { color: var(--ui-text, #e0e0e0); border-color: var(--ui-border, #363636); }
.vs3-link-btn.is-on { color: var(--ui-accent, #4e9ee1); }
.vs3-link-btn:focus-visible { outline: none; border-color: var(--ui-accent, #4e9ee1); }
.vs3-size-actions { justify-content: flex-end; gap: 6px; }
.vs3-size-action {
  border: 1px solid var(--ui-border, rgba(128, 128, 128, 0.35));
  border-radius: var(--radius-sm, 4px);
  background: transparent;
  color: var(--ui-text-2, var(--ui-muted, #8a8a8a));
  font: inherit;
  font-size: 11px;
  line-height: 1.6;
  padding: 2px 10px;
  cursor: pointer;
}
.vs3-size-action:hover { color: var(--ui-text, #e0e0e0); border-color: var(--ui-text-2, #8a8a8a); }
.vs3-size-action.is-primary { color: var(--ui-accent, #4e9ee1); border-color: var(--ui-accent, #4e9ee1); }
.vs3-size-action:focus-visible { outline: none; box-shadow: 0 0 0 2px var(--ui-accent, #4e9ee1); }
/* Emissive sub-controls (Phase 7): the glow settings revealed when an object's
   Emissive toggle is On — indented + rule to read as a nested group. */
.vs3-emissive-controls {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 4px 0 2px;
  padding-left: 8px;
  border-left: 2px solid var(--ui-border, #363636);
}
.vs3-name-input {
  flex: 1 1 auto;
  min-width: 0;
  padding: 3px 6px;
  border: 1px solid var(--ui-border, #363636);
  border-radius: var(--radius-sm, 4px);
  background: var(--ui-ctrl, #2c2c2c);
  color: var(--ui-text, #e0e0e0);
  font: inherit;
  font-size: 11px;
}
.vs3-name-input:focus-visible {
  outline: none;
  border-color: var(--ui-accent, #4e9ee1);
}

/* ── Style tab chrome ──────────────────────────────────────────────────── */
.vs3-style-scope {
  font-size: 11px;
  font-weight: 600;
  color: var(--ui-text, #e0e0e0);
}
/* Fill Style (tone law) description block, scene3d Style tab — U9. Muted
   caption lines under the picker; `.is-caveat` is the measured warning a
   demoted library law carries and must not read as ordinary help text. Both
   colours come from tokens, so both themes are covered. */
.vs3-lawnote {
  margin: 2px 0 4px;
  font-size: 10px;
  line-height: 1.35;
  color: var(--ui-text-2, var(--ui-muted, #8a8a8a));
}
.vs3-lawnote.is-caveat {
  color: var(--ui-danger);
  border-left: 2px solid color-mix(in srgb, var(--ui-danger) 45%, transparent);
  padding-left: 6px;
}
/* U12 D1/D2 — the faceted-primitive orientation line, same rule as the ctxbar
   flyout's `.ctxbar-fly-note.is-faceted`: a different colour from `.is-caveat`
   (a measured law caveat) so the two do not read as the same warning kind. */
.vs3-lawnote.is-faceted {
  color: var(--ui-warning, #d29922);
  border-left: 2px solid color-mix(in srgb, var(--ui-warning, #d29922) 45%, transparent);
  padding-left: 6px;
}
/* fs-m2 Job 2 — the Fill Style (i) info affordance. The mechanism/strengths/
   weaknesses paragraph used to always print under the picker and dominated
   the panel; it now lives in `.vs3-lawinfo-pop`, revealed on hover OR
   keyboard focus via `:hover`/`:focus-within` — the same idiom
   `.ctrl-sel-wrap`'s dropdown caret already uses above. The caveat is
   deliberately NOT in here (see `.vs3-lawnote.is-caveat`, appended as a
   sibling of the row) — a demoted law's warning must stay visible without a
   hover. `aria-describedby` on the button keeps the popover screen-reader
   reachable independent of its visual state. */
.vs3-lawinfo-wrap { position: relative; display: inline-flex; flex: 0 0 auto; }
.vs3-lawinfo-btn {
  font-size: 9px; color: var(--ui-muted); background: none;
  border: 1px solid var(--ui-border); border-radius: 50%;
  width: 14px; height: 14px; display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer; padding: 0; line-height: 1; font-family: var(--font-mono);
  transition: color 0.1s, border-color 0.1s;
}
.vs3-lawinfo-btn:hover, .vs3-lawinfo-btn:focus-visible {
  color: var(--ui-accent); border-color: var(--ui-accent);
}
.vs3-lawinfo-pop {
  position: absolute; top: 100%; right: 0; z-index: 40; margin-top: 4px;
  width: 240px; max-width: 70vw;
  background: var(--ui-panel, #252525); border: 1px solid var(--ui-border);
  border-radius: var(--radius-sm); padding: var(--spacing-sm);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
  opacity: 0; visibility: hidden; pointer-events: none;
  transition: opacity 0.12s, visibility 0s linear 0.12s;
}
.vs3-lawinfo-wrap:focus-within .vs3-lawinfo-pop,
.vs3-lawinfo-pop.is-open {
  opacity: 1; visibility: visible; pointer-events: auto; transition-delay: 0s;
}
@media (hover: hover) {
  .vs3-lawinfo-wrap:hover .vs3-lawinfo-pop {
  opacity: 1; visibility: visible; pointer-events: auto; transition-delay: 0s;
}
}
.vs3-lawinfo-pop .vs3-lawnote:last-child { margin-bottom: 0; }
/* X-ray control group header (scene3d Style tab, Phase 6). */
.vs3-xray-hdr,
.vs3-hl-hdr {
  margin-top: 8px;
  padding-top: 6px;
  border-top: 1px solid var(--ui-border, #3a3a3a);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ui-text-2, var(--ui-muted, #8a8a8a));
}
/* X-ray group note — shown in place of the back-face rows when the object's
   mapper renders no surface fill (None / Wireframe / Contour slice), where
   x-ray output is identical to solid. Rows are removed, not disabled. */
.vs3-xray-note {
  margin: 4px 0 2px;
  font-size: 10px;
  line-height: 1.4;
  font-style: italic;
  color: var(--ui-text-2, var(--ui-muted, #8a8a8a));
}
/* Edge Styles (C-06) — per-edge-class sub-label between the section header and
   that class's Pen / Weight / Dash rows. Lighter than the section header. */
.vs3-edge-cls {
  margin-top: 6px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--ui-text-2, var(--ui-muted, #8a8a8a));
}
.vs3-prov-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  align-self: flex-start;
  padding: 2px 8px;
  border: 1px solid var(--ui-accent, #4e9ee1);
  border-radius: 999px;
  background: color-mix(in srgb, var(--ui-accent, #4e9ee1) 12%, transparent);
  color: var(--ui-accent, #4e9ee1);
  font-size: 10px;
}
.vs3-prov-chip.is-inherited {
  border-color: var(--ui-border, #3a3a3a);
  background: transparent;
  color: var(--ui-text-2, var(--ui-muted, #8a8a8a));
}
.vs3-prov-clear {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: inherit;
  font-size: 9px;
  cursor: pointer;
  padding: 0;
}
.vs3-prov-clear:hover { color: var(--ui-danger, #e5484d); }
/* ============================================================================
   END VECTURA SCENE PANEL (vs3-*)
   ============================================================================ */

/* ============================================================================
   DIVISIONS EDITOR (Phase 4A Inc-1) — the FillControlSurface `divisions`
   section. Mounted sectionsOnly in the ctxbar Stroke Options popover; scoped
   so it never leaks into the fill-variant surface.
   ============================================================================ */
.fcs-divisions { display: flex; flex-direction: column; gap: 8px; }
.fcs-divisions-head { display: flex; align-items: center; }
.fcs-divisions-enable { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.fcs-divisions-title { font-weight: 600; font-size: 12px; letter-spacing: 0.02em; }
.fcs-divisions-body { display: flex; flex-direction: column; gap: 8px; }
.fcs-divisions-body.is-disabled { opacity: 0.5; }
.fcs-divisions-row { display: flex; align-items: center; gap: 8px; }
.fcs-divisions-label { flex: 0 0 auto; font-size: 11px; color: var(--ui-muted, #9aa0a6); }
.fcs-divisions-num {
  width: 68px; padding: 3px 6px; font-size: 12px;
  background: var(--ui-input-bg, #1b1d21); color: var(--ui-fg, #e8eaed);
  border: 1px solid var(--ui-border, #34363b); border-radius: 4px;
}
.fcs-divisions-classes { display: flex; flex-direction: column; gap: 6px; }
.fcs-divisions-class {
  padding: 6px; border: 1px solid var(--ui-border, #34363b); border-radius: 6px;
  background: var(--ui-surface-2, rgba(255, 255, 255, 0.02));
}
.fcs-divisions-class .fcs-divisions-num { width: 56px; }
.fcs-divisions-swatch {
  flex: 0 0 auto; width: 14px; height: 14px; border-radius: 3px;
  border: 1px solid var(--ui-border, #34363b);
}
.fcs-divisions-pen { flex: 1 1 auto; min-width: 70px; }
.fcs-divisions-pen .ctrl-sel-wrap { width: 100%; }
.fcs-divisions-gap { display: flex; align-items: center; gap: 4px; font-size: 11px; cursor: pointer; }
.fcs-divisions-acts { display: flex; align-items: center; gap: 2px; margin-left: auto; }
.fcs-divisions-act {
  width: 20px; height: 20px; display: inline-flex; align-items: center; justify-content: center;
  font-size: 11px; line-height: 1; background: transparent; color: var(--ui-fg, #e8eaed);
  border: 1px solid var(--ui-border, #34363b); border-radius: 4px; cursor: pointer;
}
.fcs-divisions-act:disabled { opacity: 0.35; cursor: default; }
.fcs-divisions-remove:hover:not(:disabled) { color: var(--ui-danger, #e5484d); border-color: var(--ui-danger, #e5484d); }
.fcs-divisions-add {
  align-self: flex-start; padding: 4px 10px; font-size: 11px;
  background: transparent; color: var(--ui-accent, #6ea8fe);
  border: 1px dashed var(--ui-border, #34363b); border-radius: 4px; cursor: pointer;
}
.fcs-divisions-add:disabled { opacity: 0.4; cursor: default; }
.fcs-divisions-hint { font-size: 11px; color: var(--ui-muted, #9aa0a6); margin: 2px 0; }
/* Deferred grammar (Inc-3): pen/phase mode selects, seed, per-class weight. */
.fcs-divisions-modes-row { flex-wrap: wrap; }
.fcs-divisions-select { flex: 1 1 90px; min-width: 80px; }
.fcs-divisions-select .ctrl-sel-wrap,
.fcs-divisions-select .ctrl-sel { width: 100%; }
.fcs-divisions-seed-row .fcs-divisions-num { width: 72px; }
.fcs-divisions-weight { display: flex; align-items: center; gap: 3px; font-size: 11px; color: var(--ui-muted, #9aa0a6); }
.fcs-divisions-weight .fcs-divisions-num { width: 42px; }
.ctxbar-divisions-host {
  margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--ui-border, #34363b);
}

/* U4b — Seed greyed when no fill in the scene draws from it. The (i) beside the
   "No effect for this style" line holds the reason (click-driven popover). */
#seed-controls.is-seed-inert #inp-seed,
#seed-controls.is-seed-inert #btn-rand-seed { opacity: .45; cursor: not-allowed; }
#seed-controls .seed-inert-info { position: relative; }

/* === TUX-028: text input proxy === */
/* Hidden textarea that owns the soft keyboard during touch/pen Type sessions.
   opacity:0 (never display/visibility/off-screen) so iOS still focuses it and
   page scroll offsets stay 0; the controller parks it at the caret inside the
   canvas rect. 16px font prevents iOS focus-zoom. */
[data-ui-skin] textarea[data-text-proxy].text-input-proxy,
textarea[data-text-proxy].text-input-proxy {
  position: fixed; left: 0; top: 0; z-index: 1;
  width: 1em; height: 1em; min-height: 0; margin: 0; padding: 0; border: 0;
  font-size: 16px; line-height: 1;
  opacity: 0; color: transparent; background: transparent; caret-color: transparent;
  outline: none; box-shadow: none; resize: none; overflow: hidden;
  pointer-events: none; -webkit-user-select: text; user-select: text;
}
/* === /TUX-028 === */

/* === TUX-006: touch sizing keys on pointer type === */
body.touch-ui .tool-btn {
  width: 44px;
  height: 44px;
}
/* === /TUX-006 === */
/* === TUX-012: layer rows on coarse pointers ===
 * Replaces the old "2x Layer cards" block (min-width:600px, 18px names, 36px actions).
 * Keyed on the touch row template: layers-panel.js adds .lvl-touch-row only when
 * `(pointer: coarse)` matches or body.touch-ui is set, so width never decides.
 * Row 1 = [grip][name][⋯]; row 2 = [eye][lock][pen dot][icon + label] (cards) or
 * [caret][eye][lock][icon + label] (group / modifier / scene headers).
 * Hit areas are 44 px (var(--touch-target-min)); the pane is never widened. */
@media (pointer: coarse) {
  .lvl-tree-children { padding-left: 16px }
  .lvl-grp-exit-zone { margin-left: -16px }
}
body.touch-ui .lvl-tree-children { padding-left: 16px }
body.touch-ui .lvl-grp-exit-zone { margin-left: -16px }

.lvl-touch-row .lvl-clr-bar { width: 6px; margin: 4px 0; align-self: stretch }
.lvl-touch-row .lvl-card-body { min-width: 0 }
.lvl-touch-row .lvl-r1 {
  height: 48px; padding: 0 4px 0 0; gap: 4px; min-width: 0; box-sizing: border-box;
}
.lvl-touch-row .lvl-r2 {
  height: 44px; padding: 0 4px 0 0; gap: 0; min-width: 0; box-sizing: border-box;
}
.lvl-card.masked-v2.lvl-touch-row .lvl-r1,
.lvl-card.masked-v2.lvl-touch-row .lvl-r2 { padding-left: 0 }
.lvl-touch-row .lvl-grip {
  width: var(--touch-target-min, 44px); height: var(--touch-target-min, 44px);
  flex: 0 0 var(--touch-target-min, 44px); display: flex; align-items: center; justify-content: center;
  color: var(--ui-muted); cursor: grab; touch-action: none;
  -webkit-touch-callout: none; user-select: none; -webkit-user-select: none;
}
.lvl-touch-row .lvl-grip[aria-disabled='true'] { opacity: .35; cursor: default }
.lvl-touch-row .lvl-grip svg { width: 20px; height: 20px; pointer-events: none }
.lvl-touch-row .lvl-ab.lvl-more {
  width: var(--touch-target-min, 44px); height: var(--touch-target-min, 44px);
  flex: 0 0 var(--touch-target-min, 44px); opacity: 1; border-radius: 6px;
}
.lvl-touch-row .lvl-ab.lvl-more svg { width: 22px; height: 22px }
.lvl-touch-row .lvl-ib {
  width: var(--touch-target-min, 44px); height: var(--touch-target-min, 44px);
  flex: 0 0 var(--touch-target-min, 44px); border-radius: 6px;
}
.lvl-touch-row .lvl-ib svg { width: 22px; height: 22px }
.lvl-touch-row .lvl-caret-zone {
  width: var(--touch-target-min, 44px); height: var(--touch-target-min, 44px);
  flex: 0 0 var(--touch-target-min, 44px); padding: 0; align-items: center;
}
.lvl-touch-row .lvl-caret { width: var(--touch-target-min, 44px); height: var(--touch-target-min, 44px) }
.lvl-touch-row .lvl-caret svg { width: 20px; height: 20px }
/* Pen dot: 20 px visual, 44 px hit area through ::before; neighbouring hit areas abut, never overlap. */
.lvl-touch-row .lvl-pen-dot {
  position: relative; width: 20px; height: 20px; margin: 0 12px; flex: 0 0 20px; box-sizing: border-box;
}
.lvl-touch-row .lvl-pen-dot::before {
  content: ''; position: absolute; inset: -13px; border-radius: 6px;
}
.lvl-touch-row .lvl-aico { width: 24px; height: 24px; flex: 0 0 24px; margin: 0 4px 0 0 }
.lvl-touch-row .lvl-aico svg { width: 20px; height: 20px }
.lvl-touch-row .lvl-name,
.lvl-touch-row .lvl-grp-name { font-size: 16px; flex: 1 1 auto; min-width: 0 }
.lvl-touch-row .lvl-algo-label {
  font-size: 13px; text-transform: none; letter-spacing: 0; color: var(--ui-muted);
  flex: 1 1 0; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.lvl-grp-hdr.lvl-touch-row { min-height: 0 }
.lvl-touch-row .lvl-grp-content {
  flex: 1 1 auto; flex-direction: column; align-items: stretch; gap: 0;
  height: auto; min-width: 0; padding: 0;
}
/* The ⋯ menu must fit the viewport on short screens and give rows finger height. */
.lvl-ctx-menu { max-height: calc(100vh - 12px); max-height: calc(100dvh - 12px); overflow-y: auto; overscroll-behavior: contain }
@media (pointer: coarse) {
  .lvl-ctx-menu .menu-entry { min-height: var(--touch-target-min, 44px) }
}
body.touch-ui .lvl-ctx-menu .menu-entry { min-height: var(--touch-target-min, 44px) }

/* === TUX-029: text-content field ===
   Multi-line "Text" field in the Type tab. Beats the older
   `[data-ui-skin] #left-panel-content textarea` rule (fixed row height, small
   font) and keeps >= 16px so iOS never zooms on focus. */
[data-ui-skin] #left-panel-content .vtp-panel textarea.vtp-text-field,
[data-ui-skin] .vtp-panel textarea.vtp-text-field,
.vtp-panel textarea.vtp-text-field {
  display: block;
  box-sizing: border-box;
  width: 100%;
  height: auto;
  min-height: calc(3 * 1.35em + 2 * var(--spacing-sm, 8px));
  padding: var(--spacing-sm, 8px);
  font-family: var(--font-ui);
  font-size: max(16px, var(--font-size-sm, 13px));
  line-height: 1.35;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  overflow-y: auto;
  resize: vertical;
  background: var(--ui-ctrl);
  color: var(--ui-text);
  border: 1px solid var(--ui-border);
  border-radius: var(--radius-sm);
  outline: none;
  -webkit-user-select: text;
  user-select: text;
}
[data-ui-skin] #left-panel-content .vtp-panel textarea.vtp-text-field:focus,
[data-ui-skin] .vtp-panel textarea.vtp-text-field:focus {
  border-color: var(--ui-accent);
  box-shadow: 0 0 0 3px var(--ui-accent-2);
}
/* === /TUX-029 === */

/* === TUX-032: keyboard inset ===
 * --kb-inset is written by src/ui/keyboard-inset.js (0 unless an editable has focus).
 * Scroll containers gain bottom room only while the keyboard is open, so the last fields of a
 * pane can scroll above it. Sheets and popovers read the same variable: the modal lane
 * (TUX-046 Sheet / TUX-049) must keep consuming --kb-inset. */
html.kb-open .pane-body,
html.kb-open #left-panel-content,
html.kb-open .export-settings-scroll {
  padding-bottom: var(--kb-inset);
  scroll-padding-bottom: calc(var(--kb-inset) + 8px);
}
@media (pointer: coarse) {
  /* Save Preset bottom sheet (rule above uses !important on align-items): lift it by the inset. */
  html.kb-open .vectura-modal-backdrop { padding-bottom: var(--kb-inset); box-sizing: border-box; }
  html.kb-open .vectura-modal { max-height: calc(100% - 8px); }
  /* iOS zooms inputs under 16px on focus, which would zero the inset (page zoom). */
  .vtp-fp-search input { font-size: 16px; }
}
/* Font picker popover: the list scrolls inside the popover cap that positionPop() sets. */
.vtp-fp-pop .vtp-fp-list { flex: 1 1 auto; min-height: 0; }
.vtp-fp-pop .vtp-fp-search, .vtp-fp-pop .vtp-fp-tags { flex: none; }
/* Pinned popover with the keyboard open (landscape): compact header so the list keeps >= 3 rows where they fit. */
.vtp-fp-pop.kb-compact .vtp-fp-tags { display: none; }
.vtp-fp-pop.kb-compact .vtp-fp-search { padding: 0 8px; }
.vtp-fp-pop.kb-compact .vtp-fp-search input { padding-block: 0; min-height: 24px; height: 24px; box-sizing: border-box; }
.vtp-fp-pop.kb-compact .vtp-fp-list { padding: 0 2px; }
.vtp-fp-pop.kb-compact .vtp-fp-opt { padding: 0 8px; min-height: 24px; }
.vtp-fp-pop.kb-compact .vtp-fp-sec { padding-block: 2px; }
/* TUX-032 review: the compact typing header keeps the 24 px absolute floor (3 rows still fit at 874x330); without the
 * keyboard the rows and the search field are 44 px finger targets on a coarse pointer. */
@media (pointer: coarse) {
  .vtp-fp-pop:not(.kb-compact) .vtp-fp-opt { min-height: var(--touch-target-min); box-sizing: border-box; }
  .vtp-fp-pop:not(.kb-compact) .vtp-fp-search input { min-height: var(--touch-target-min); box-sizing: border-box; }
}
/* === /TUX-032 === */
/* === TUX-042: text-entry >= 16px on coarse pointers ===
 * iOS Safari zooms the page when a focused field computes below 16px. !important is the only
 * way to beat the inline font-size:10px on the Text panel selects (ui-text-panel.js) and the
 * skin rules at (0,2,0)-(0,3,0) in one place. [contenteditable] is deliberately NOT listed:
 * the .vtp-spec-text specimen is 34px by design. Keyed on the pointer, never on width. */
@media (pointer: coarse) {
  :is(input:not([type]), input[type="text"], input[type="number"], input[type="search"],
      input[type="email"], input[type="password"], input[type="url"], input[type="tel"],
      select, textarea) {
    font-size: max(var(--input-font-touch), 1em) !important;
  }
}
/* === END TUX-042 === */

/* === TUX-041: touch target token (owned surfaces: layers pane, left pane, pens rows, modifier bar) ===
 * Every rule is keyed on (pointer: coarse); desktop is unchanged. Sizes only (no !important):
 * min-width/min-height where the visual may grow, a centred ::before extension where the
 * visual must stay small. Selectors carry [data-ui-skin] + a pane id to beat the skin rules.
 * Remaining slices (menus, header, toolbar, ctxbar, Text panel, modals, sliders) are open
 * ratchet work; see docs/touch-audit/changelog-fragments/TUX-041.md. */
@media (pointer: coarse) {
  /* Rows and boxes that can simply grow. */
  [data-ui-skin] #left-pane :is(.left-panel-section-header, .global-section-header, .hg-preset-trigger,
    #generator-module-trigger, select:not(.sr-only), button.w-full, input.w-full, .noise-add,
    .noise-reset, .noise-rand, .slider-val, .slider-val-inp, .angle-inp-wrap, .paint-bucket-select) {
    min-height: var(--touch-target-min);
    box-sizing: border-box;
  }
  /* WebKit ignores min-height on some native selects, so selects also get an explicit height. */
  [data-ui-skin] #left-pane select:not(.sr-only) { height: var(--touch-target-min); }
  [data-ui-skin] .touch-mod-btn { min-height: var(--touch-target-min); }
  [data-ui-skin] #right-pane .right-pane-tab { min-height: var(--touch-target-min); }
  [data-ui-skin] #right-pane .lvl-search-wrap { min-height: var(--touch-target-min); height: auto; }
  [data-ui-skin] #right-pane .lvl-search-bar .lvl-search-input,
  [data-ui-skin] #right-pane .lvl-filter-btn,
  [data-ui-skin] #right-pane .lvl-add-btn {
    min-height: var(--touch-target-min);
  }
  [data-ui-skin] #right-pane .lvl-filter-btn { min-width: var(--touch-target-min); }
  [data-ui-skin] #right-pane .lvl-add-btn { min-width: var(--touch-target-min); }
  /* Draw-order icons keep their 18px visual (the bar must stay short on landscape phones); a
   * 44px ::before owns the touch and 26px gaps keep neighbouring hit areas abutting. */
  [data-ui-skin] #right-pane .draw-order-head-right { gap: 26px; }
  [data-ui-skin] #right-pane :is(.draw-order-settings, .draw-order-overlay-toggle) { position: relative; }
  [data-ui-skin] #right-pane :is(.draw-order-settings, .draw-order-overlay-toggle)::before {
    content: ''; position: absolute; left: 50%; top: 50%;
    width: var(--touch-target-min); height: var(--touch-target-min); transform: translate(-50%, -50%);
  }
  .hg-preset-save-pip { width: var(--touch-target-min); height: var(--touch-target-min); }
  .hg-preset-save-pip svg { width: 18px; height: 18px; }

  /* Value chips: self-contained boxes sized for 16px mono text ("0.125" fits). TUX-043 puts the
   * 44px slider band beside them. */
  [data-ui-skin] #left-pane :is(.slider-val, .slider-val-inp),
  [data-ui-skin] #left-pane .slider-row .value-chip {
    width: calc(6ch + 2 * var(--spacing-sm, 8px));
    min-width: calc(6ch + 2 * var(--spacing-sm, 8px));
    max-width: none;
    flex: 0 0 auto;
    padding: 0 var(--spacing-sm, 8px);
    text-align: right;
  }

  /* WebKit number spinners eat the chip's digits; touch has no use for them. */
  [data-ui-skin] :is(#left-pane, .settings-panel) input.slider-val-inp { -webkit-appearance: textfield; appearance: textfield; -moz-appearance: textfield; }
  [data-ui-skin] :is(#left-pane, .settings-panel) input.slider-val-inp::-webkit-inner-spin-button,
  [data-ui-skin] :is(#left-pane, .settings-panel) input.slider-val-inp::-webkit-outer-spin-button { -webkit-appearance: none; appearance: none; margin: 0; display: none; }

  /* Small visuals keep their size; a centred 44px ::before owns the touch. */
  [data-ui-skin] #left-pane :is(.info-btn, .noise-grip) {
    position: relative;
  }
  [data-ui-skin] #left-pane :is(.info-btn, .noise-grip)::before,
  [data-ui-skin] #left-pane .sw-toggle::before {
    content: ''; position: absolute; left: 50%; top: 50%;
    width: var(--touch-target-min); height: var(--touch-target-min);
    transform: translate(-50%, -50%);
  }
  /* The label row that holds an info button is one finger tall so the extension never reaches
   * the control below. */
  [data-ui-skin] #left-pane :has(> .info-btn) {
    display: flex; min-height: var(--touch-target-min); align-items: center;
  }
  /* An info button that ends its row keeps half a finger free after it, so the 44 px extension stays inside the row
   * however wide the label renders (Linux text is wider; a long label pushed the button against the pane resizer). The
   * label wraps instead. The visual is 14 px + 1 px borders = 16 px, so the room after it is 44 / 2 - 8 px. */
  [data-ui-skin] #left-pane :has(> .info-btn) > .info-btn:last-child {
    margin-right: calc(var(--touch-target-min) / 2 - 8px);
    flex: 0 0 auto;
  }
  /* A justify-between row whose left child holds the label + info button: centre the value tag
   * on the same line as the label instead of letting it float to the top of the 44px row. */
  [data-ui-skin] #left-pane :is(.flex, [class*="justify-between"]):has(> * > .info-btn) { align-items: center; }
  /* The angle chip is the wrapper (border + degree sign); the input inside stays borderless. */
  [data-ui-skin] #left-pane .angle-inp-wrap { min-height: var(--touch-target-min); box-sizing: border-box; }
  [data-ui-skin] #left-pane .angle-inp-wrap .angle-inp { width: 48px; min-height: var(--touch-target-min); height: 100%; padding: 0; border: 0; background: transparent; box-shadow: none; }
  [data-ui-skin] #left-pane .noise-actions { gap: 0; }
  [data-ui-skin] #left-pane .noise-actions .sw-toggle { margin: 0 7px; }
  [data-ui-skin] #left-pane .noise-delete {
    min-width: var(--touch-target-min); min-height: var(--touch-target-min);
  }
  [data-ui-skin] #left-pane .angle-ctrl .angle-dial,
  [data-ui-skin] #left-pane .angle-dial {
    width: var(--touch-target-min); height: var(--touch-target-min);
  }
  [data-ui-skin] #left-pane .sw-toggle { position: relative; }
  /* A parameter switch that sits under its label row (algo-config checkbox def) shares the line with the label instead, so the
   * pair is one finger-tall row and the switch's 44 px ::before stays inside it. Stacked, the label row above and the next
   * control below both covered part of the extension (Flat Top/Bottom measured 44 x 34 on iPhone landscape). */
  [data-ui-skin] #left-pane :is(.mb-4, .noise-control):has(> .sw-toggle) {
    display: flex; flex-direction: row; align-items: center; justify-content: space-between; gap: 0; min-height: var(--touch-target-min);
  }
  [data-ui-skin] #left-pane :is(.mb-4, .noise-control):has(> .sw-toggle) > :not(.sw-toggle) { flex: 1 1 auto; min-width: 0; margin-bottom: 0; }
  [data-ui-skin] #left-pane :is(.mb-4, .noise-control):has(> .sw-toggle) > .sw-toggle { margin: 0 7px; }

  /* On short coarse viewports (landscape phones) the header, search bar and draw-order bar used
   * to squeeze the list to a sliver. The list keeps room for two finger-tall rows and the tab
   * panel scrolls instead. */
  [data-ui-skin] #right-pane .right-tab-panel { overflow-y: auto; }
  [data-ui-skin] #right-pane #layer-list { flex-shrink: 0; min-height: calc(2 * var(--touch-target-min) + 12px); }

  /* Touch scrolls by drag and iOS overlays its scrollbars; a classic 4-6px bar would steal the
   * right edge of the row's last (44px) button. */
  [data-ui-skin] #right-pane #layer-list { scrollbar-width: none; }
  [data-ui-skin] #right-pane #layer-list::-webkit-scrollbar { display: none; }

  /* Pens tab: its sections stack at natural height and the tab panel scrolls, so short landscape
   * phones never squeeze the pen rows to a sliver. */
  [data-ui-skin] #right-pane .right-tab-panel:not(.hidden)#right-tab-panel-pens { display: block; }
  [data-ui-skin] #right-pane #pen-list { overflow: visible; }

  /* The modifier bar overlays the bottom of the pane; leave room so the last control scrolls clear. */
  [data-ui-skin] #left-panel-content { padding-bottom: 72px; }

  /* Settings panel (Document Setup and canvas settings): same chip and row sizing. */
  /* The 24px close icon keeps its visual; a centred 44px ::before owns the touch. */
  [data-ui-skin] .settings-panel > .pane-hdr { min-height: calc(var(--touch-target-min) + 10px); box-sizing: border-box; }
  [data-ui-skin] .settings-panel .settings-panel-close { position: relative; }
  [data-ui-skin] .settings-panel .settings-panel-close::before {
    content: ''; position: absolute; left: 50%; top: 50%;
    width: var(--touch-target-min); height: var(--touch-target-min); transform: translate(-50%, -50%);
  }
  [data-ui-skin] .settings-panel :is(.slider-val-inp, select.ctrl-sel, .sect-hdr) {
    min-height: var(--touch-target-min); box-sizing: border-box;
  }
  /* 16px "Balanced" overflowed the 120px inline-width select wrap; min-width beats the inline width. */
  [data-ui-skin] .settings-panel .ctrl-sel-wrap { min-width: 160px; }
  [data-ui-skin] .settings-panel .slider-val-inp {
    width: calc(6ch + 2 * var(--spacing-sm, 8px)); min-width: calc(6ch + 2 * var(--spacing-sm, 8px));
  }

  /* Pens rows: two finger-tall lines. Line 1 = [grip][name][remove], line 2 = [swatch][weight]
   * [value]. The two flex groups dissolve (display: contents) and order places the items; the
   * ::after forces the line break. The round .pen-icon is hidden (the swatch carries the colour). */
  [data-ui-skin] .pen-item {
    flex-wrap: wrap; align-items: center; gap: 0; padding: 0 var(--spacing-sm, 8px); flex-shrink: 0;
  }
  [data-ui-skin] .pen-item::after { content: ''; flex: 0 0 100%; height: 0; order: 3; }
  [data-ui-skin] .pen-item :is(.pen-row-a, .pen-row-b) { display: contents; }
  [data-ui-skin] .pen-item .pen-icon { display: none; }
  [data-ui-skin] .pen-item .pen-grip {
    order: 1; flex: 0 0 var(--touch-target-min); width: var(--touch-target-min);
    height: var(--touch-target-min); place-content: center; margin: 0;
  }
  [data-ui-skin] .pen-item .pen-name-input {
    order: 2; flex: 1 1 0; min-width: 0; width: auto; min-height: var(--touch-target-min);
  }
  [data-ui-skin] .pen-item .pen-remove {
    order: 3; position: relative; margin: 13px; flex: 0 0 18px;
  }
  [data-ui-skin] .pen-item .pen-remove::before {
    content: ""; position: absolute; inset: -14px;
  }
  [data-ui-skin] .pen-item .pen-swatch {
    order: 4; position: relative; flex: 0 0 var(--touch-target-min);
    width: var(--touch-target-min); height: var(--touch-target-min);
    margin: 0; border: 0; border-radius: 0; overflow: visible;
  }
  /* The native colour input IS the visible swatch (a 22 px circle in the 44 px box). It was opacity 0 over a painted ::before,
   * which the touch audit counts as a ghost target. */
  [data-ui-skin] .pen-item .pen-swatch::before { content: none; }
  [data-ui-skin] .pen-item .pen-swatch .pen-color {
    position: absolute; inset: 0; width: 100%; height: 100%; opacity: 1; cursor: pointer;
    padding: 0; border: 0; background: transparent; -webkit-appearance: none; appearance: none;
  }
  [data-ui-skin] .pen-item .pen-swatch .pen-color::-webkit-color-swatch-wrapper { padding: 11px; }
  [data-ui-skin] .pen-item .pen-swatch .pen-color::-webkit-color-swatch { border: 1px solid var(--ui-border-hi); border-radius: 50%; }
  [data-ui-skin] .pen-item .pen-swatch .pen-color::-moz-color-swatch { border: 1px solid var(--ui-border-hi); border-radius: 50%; }
  [data-ui-skin] .pen-item .pen-width { order: 5; flex: 1 1 0; min-width: var(--touch-target-min); width: auto; margin: 0 var(--spacing-sm, 8px); }
  [data-ui-skin] .pen-item .pen-width-value {
    order: 6; flex: 0 0 auto; width: calc(6ch + 2 * var(--spacing-sm, 8px)); min-width: 0;
    min-height: var(--touch-target-min); padding: 0 var(--spacing-sm, 8px);
  }
  /* One shared row background: the name input and value chip drop their own fill (the skin gives
   * inputs a lighter panel colour that read as a patchwork) and keep a hairline underline. */
  [data-ui-skin] .pen-item :is(.pen-name-input, .pen-width-value) {
    background: transparent; border: 0; border-bottom: 1px solid var(--ui-border); border-radius: 0;
  }
  /* WebKit draws native number spinners that eat the chip's digits; touch has no use for them. */
  [data-ui-skin] .pen-item .pen-width-value { -webkit-appearance: textfield; appearance: textfield; -moz-appearance: textfield; }
  [data-ui-skin] .pen-item .pen-width-value::-webkit-inner-spin-button,
  [data-ui-skin] .pen-item .pen-width-value::-webkit-outer-spin-button { -webkit-appearance: none; appearance: none; margin: 0; display: none; }
}
/* === END TUX-041 === */

/* === TUX-001: phone header, hamburger menu sheet and direct actions === */
.header-phone-btn, .header-phone-actions { display: none; }
body.phone-layout #app-header { max-width: 100%; overflow-x: clip; }
.top-menu-quick-row, .top-menu-theme-row, .top-menu-docsetup-row { display: none; }
body.phone-layout .top-menu-quick-row { display: flex; align-items: stretch; }
body.phone-layout .top-menu-theme-row, body.phone-layout .top-menu-docsetup-row { display: flex; }
body.phone-layout #top-menubar .top-menu-quick-row > .top-menu-docsetup-row { flex: 1 1 auto; width: auto; min-width: 0; }
/* Short phone landscape has room for 6 rows, not 7: the pinned Document Setup row is dropped and Theme returns to the end of the sheet.
 * Document Setup stays under File there (Q23 covers phones with a normal height). */
body.phone-layout.phone-short #top-menubar .top-menu-quick-row { order: 99; }
body.phone-layout.phone-short #top-menubar .top-menu-docsetup-row { display: none; }
body.phone-layout #top-menubar .top-menu-quick-row > .top-menu-theme-row { flex: 0 0 auto; width: auto; border-left-width: 1px; }
body.phone-layout #app-header .header-phone-actions { display: inline-flex; gap: 2px; align-items: center; }
body.phone-layout #app-header .header-phone-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 44px; height: 44px; padding: 0; box-sizing: border-box;
  border: 1px solid var(--ui-border); background: var(--ui-panel-alt); color: var(--ui-text-2);
}
body.phone-layout #app-header .header-phone-btn.is-disabled { opacity: 0.4; }
body.phone-layout #app-header .header-brand-menu { gap: 6px; flex: 1 1 0; min-width: 0; }
body.phone-layout #app-header .header-brand-menu h1 { font-size: 12px; overflow: hidden; text-overflow: clip; min-width: 0; }
body.phone-layout #app-header .header-brand-mark,
body.phone-layout #app-header .header-menu-divider,
body.phone-layout #app-header #theme-toggle { display: none; }
body.phone-layout #app-header .header-status-actions { gap: 0; }
body.phone-layout #top-menubar { display: none; }
body.phone-layout.phone-menu-open #top-menubar {
  display: flex; flex-direction: column; align-items: stretch; gap: 0;
  position: fixed; left: 0; right: 0; top: var(--phone-menu-top, 56px); margin: 0;
  max-height: calc(100vh - var(--phone-menu-top, 56px)); max-height: calc(100dvh - var(--phone-menu-top, 56px));
  overflow-y: auto; overscroll-behavior: contain; white-space: normal;
  padding: 4px max(0px, var(--safe-right)) max(4px, var(--safe-bottom)) max(0px, var(--safe-left));
  background: var(--ui-bg); border-bottom: 1px solid var(--ui-border); box-shadow: 0 16px 30px rgba(0, 0, 0, 0.45);
  z-index: 1500;
}
body.phone-layout #top-menubar .top-menu { position: static; display: block; width: 100%; }
body.phone-layout #top-menubar .top-menu-trigger {
  width: 100%; min-height: 44px; justify-content: flex-start; font-size: 14px; padding: 0 16px;
  box-sizing: border-box; border-width: 0 0 1px; background: transparent;
}
body.phone-layout #top-menubar .top-menu-panel {
  display: none; position: static; min-width: 0; width: 100%; box-sizing: border-box;
  box-shadow: none; border: 0; padding: 0; transform: none; transition: none;
}
body.phone-layout #top-menubar .top-menu-panel.open { display: flex; opacity: 1; pointer-events: auto; }
body.phone-layout #top-menubar .top-menu-item { min-height: 44px; font-size: 14px; padding: 0 16px; box-sizing: border-box; }
/* Drill-down: with a sub-level open, show only that panel. */
body.phone-layout #top-menubar:has(.top-menu-panel.open) .top-menu-trigger,
body.phone-layout #top-menubar:has(.top-menu-panel.open) .top-menu-quick-row { display: none; }
body.phone-layout #top-menubar:has(.top-menu-panel.open) .top-menu:not(:has(.top-menu-panel.open)) { display: none; }
/* Review fix (874x330): an open sub-level taller than the sheet is clamped to it and scrolls itself, so the sheet never scrolls
 * the sub-level out from under the cue. data-scroll-cue (utils.scrollCue, bound in header.js) draws sticky fades that take no taps. */
body.phone-layout #top-menubar:has(.top-menu-panel.open) { overflow-y: hidden; }
body.phone-layout #top-menubar .top-menu:has(> .top-menu-panel.open) { display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0; }
body.phone-layout #top-menubar .top-menu-panel.open { flex-direction: column; flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
body.phone-layout #top-menubar .top-menu-panel.open > .top-menu-item { flex: none; }
body.touch-ui.phone-layout #top-menubar .top-menu-panel.open::before,
body.touch-ui.phone-layout #top-menubar .top-menu-panel.open::after {
  content: ''; display: block; position: sticky; flex: none; height: 28px; pointer-events: none; z-index: 3;
  opacity: 0; transition: opacity 120ms ease;
}
body.touch-ui.phone-layout #top-menubar .top-menu-panel.open::before { order: -1; top: 0; margin-bottom: -28px; background: linear-gradient(to bottom, var(--ui-bg) 15%, transparent); }
body.touch-ui.phone-layout #top-menubar .top-menu-panel.open::after { order: 99; bottom: 0; margin-top: -28px; background: linear-gradient(to top, var(--ui-bg) 15%, transparent); }
body.touch-ui.phone-layout #top-menubar .top-menu-panel.open[data-scroll-cue~="above"]::before,
body.touch-ui.phone-layout #top-menubar .top-menu-panel.open[data-scroll-cue~="below"]::after { opacity: 1; }
body.phone-layout #top-menubar .top-menu-back { font-weight: 600; color: var(--ui-text-2); }
.top-menu-back { display: none; }
body.phone-layout #top-menubar .top-menu-back { display: flex; align-items: center; }
/* === end TUX-001 === */

/* === TUX-013: compact one-row tool rail ===
 * Static-rail layouts only: phone-layout, and tablet-layout on a coarse pointer.
 * touch-wide and desktop keep the floating rail, drag handle and footer (TUX-016/041 own their sizing).
 * Which slots stay on the rail comes from Vectura.TOOL_RAIL (src/config/tool-drawer.js);
 * toolbar.js marks the rest `.rail-overflowed`. Budget: tablet <= 64 px, phone <= 52 px (border counted).
 * No var(--safe-top) here: TUX-005 owns the top inset on #app-header.
 * TODO(TUX-041): replace the literal 44px with the shared touch-target token once it lands. */
body.touch-ui.tablet-layout #tool-bar,
body.phone-layout #tool-bar {
  flex-wrap: nowrap;
  justify-content: flex-start;
  align-items: center;
  column-gap: 6px;
  row-gap: 0;
  overflow-x: hidden;
  overflow-y: hidden;
  box-sizing: border-box;
  padding: 8px 12px;
  padding-left: calc(12px + var(--safe-left));
  padding-right: calc(12px + var(--safe-right));
}
body.phone-layout #tool-bar {
  padding-top: 4px;
  padding-bottom: 3px; /* 4 + 44 + 3 + 1 px border = 52 */
}
body.touch-ui.tablet-layout #tool-bar { padding-top: 8px; padding-bottom: 8px; }
body.touch-ui.tablet-layout #tool-bar .toolbar-footer,
body.touch-ui.tablet-layout #tool-bar .toolbar-drag-handle,
body.phone-layout #tool-bar .toolbar-footer,
body.phone-layout #tool-bar .toolbar-drag-handle { display: none; }
body.touch-ui.tablet-layout #tool-bar .rail-overflowed,
body.phone-layout #tool-bar .rail-overflowed { display: none; }
body.touch-ui.tablet-layout #tool-bar .tool-group,
body.phone-layout #tool-bar .tool-group { flex-direction: row; flex: 0 0 auto; }
body.touch-ui.tablet-layout #tool-bar > .tool-divider {
  width: 1px; height: 24px; margin: 0 2px; flex: 0 0 1px; align-self: center;
}
body.phone-layout #tool-bar > .tool-divider { display: none; }
body.touch-ui.tablet-layout #tool-bar #tool-overflow-btn,
body.phone-layout #tool-bar #tool-overflow-btn { margin-left: auto; order: 999; flex: 0 0 auto; }
/* Collapsed-pane slivers (40 px, z 55) overlay the rail ends once a finger collapses a pane on
 * tablet and wide-phone layouts (body is not .auto-collapsed there, so the rail stays at z 5).
 * Inset the rail's inline padding by the sliver width so Select and the overflow button stay
 * hittable. Narrow phones (.auto-collapsed) already lift the rail to z 60 above the slivers. */
body.touch-ui.tablet-layout #tool-bar,
body.phone-layout:not(.auto-collapsed) #tool-bar {
  padding-left: calc(var(--pane-collapsed-width, 40px) + 4px + var(--safe-left));
  padding-right: calc(var(--pane-collapsed-width, 40px) + 4px + var(--safe-right));
}
/* === /TUX-013 === */
/* === TUX-034: touch hold + context menus ===
   Scoped to .menu-dropdown.is-context-menu and .canvas-ctx-menu. The header menubar shares
   bare .menu-dropdown / .menu-entry: never restyle those here. */
.touch-hold-ring {
  position: fixed; z-index: 10000; pointer-events: none;
  width: var(--touch-hold-ring-size); height: var(--touch-hold-ring-size);
  margin: calc(var(--touch-hold-ring-size) / -2) 0 0 calc(var(--touch-hold-ring-size) / -2);
  border: 3px solid var(--touch-hold-ring-color); border-radius: 50%;
  box-sizing: border-box; overflow: hidden;
}
.touch-hold-ring-fill {
  position: absolute; inset: 0; border-radius: 50%;
  background: var(--touch-hold-ring-fill); transform-origin: 50% 50%;
}
/* A card hold must show no native callout, selection or drag lift (clause 16). */
.lvl-card, .lvl-grp-hdr {
  -webkit-touch-callout: none; -webkit-user-select: none; user-select: none;
}
.menu-dropdown.is-context-menu { overflow-y: auto; overscroll-behavior: contain; }
@media (pointer: coarse) {
  .menu-dropdown.is-context-menu {
    max-height: calc(100vh - var(--safe-top) - var(--safe-bottom) - 16px);
    max-height: calc(100dvh - var(--safe-top) - var(--safe-bottom) - 16px);
    overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch;
  }
  .menu-dropdown.is-context-menu .menu-entry { min-height: var(--touch-target-min); }
  .canvas-ctx-menu {
    max-height: calc(100vh - var(--safe-top) - var(--safe-bottom) - 16px);
    max-height: calc(100dvh - var(--safe-top) - var(--safe-bottom) - 16px);
    overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch;
  }
  .canvas-ctx-item { min-height: var(--touch-target-min); padding-top: 0; padding-bottom: 0; display: flex; align-items: center; }
}
/* TUX-012 review: scroll-edge fades on a scrolling context menu. data-scroll-cue (utils.scrollCue) lists the edges that
 * still hide rows, so a menu that fits shows nothing. Sticky pseudo-elements overlay the first/last rows; they take no taps. */
.menu-dropdown.is-context-menu::before, .menu-dropdown.is-context-menu::after,
.canvas-ctx-menu::before, .canvas-ctx-menu::after {
  content: ''; display: block; position: sticky; height: 28px; pointer-events: none; z-index: 2;
  opacity: 0; transition: opacity 120ms ease;
}
.menu-dropdown.is-context-menu::before, .canvas-ctx-menu::before {
  top: 0; margin-bottom: -28px; background: linear-gradient(to bottom, var(--ui-panel) 15%, transparent);
}
.menu-dropdown.is-context-menu::after, .canvas-ctx-menu::after {
  bottom: 0; margin-top: -28px; background: linear-gradient(to top, var(--ui-panel) 15%, transparent);
}
.menu-dropdown.is-context-menu[data-scroll-cue~="above"]::before, .canvas-ctx-menu[data-scroll-cue~="above"]::before,
.menu-dropdown.is-context-menu[data-scroll-cue~="below"]::after, .canvas-ctx-menu[data-scroll-cue~="below"]::after { opacity: 1; }
/* === END TUX-034 === */

/* === TUX-015: all tools drawer (touch) === */
/* Stacking applies to every pointer: the drawer is a body-level popover and must sit above the rail and panes. */
.tool-drawer { z-index: var(--z-tool-drawer, 80); }
@media (pointer: coarse) {
  .tool-drawer-body { overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
  .tool-drawer[data-view="grid"] .tool-drawer-item { width: var(--touch-target-min, 44px); height: var(--touch-target-min, 44px); }
  .tool-drawer[data-view="list"] .tool-drawer-item { min-height: var(--touch-target-min, 44px); height: var(--touch-target-min, 44px); }
  .tool-drawer-view-btn { width: var(--touch-target-min, 44px); height: var(--touch-target-min, 44px); }
}
body.touch-ui .tool-drawer-body { overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
body.touch-ui .tool-drawer[data-view="grid"] .tool-drawer-item { width: var(--touch-target-min, 44px); height: var(--touch-target-min, 44px); }
body.touch-ui .tool-drawer[data-view="list"] .tool-drawer-item { min-height: var(--touch-target-min, 44px); height: var(--touch-target-min, 44px); }
body.touch-ui .tool-drawer-view-btn { width: var(--touch-target-min, 44px); height: var(--touch-target-min, 44px); }
/* === END TUX-015 === */

/* === TUX-035: add-layer touch drill-down === */
/* Touch taps "Algorithm Layer" and the add menu swaps to the algorithm list (JS: shortcuts.js).
   Scoped to #layer-add-menu so the shared .lvl-algo-sub-item (context bar, header fly-outs) is untouched. */
#layer-add-menu .lvl-add-back,
#layer-add-menu .lvl-add-drill-list { display: none; }
#layer-add-menu.is-drill > .lvl-add-item:not(.lvl-add-back) { display: none; }
#layer-add-menu.is-drill > .lvl-add-back {
  display: flex;
  align-items: center;
  min-height: var(--touch-target-min);
  border-radius: 6px 6px 0 0;
  border-bottom: 1px solid var(--ui-border);
  color: var(--ui-accent);
}
#layer-add-menu.is-drill > .lvl-add-drill-list {
  display: block;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
  border-radius: 0 0 6px 6px;
}
#layer-add-menu.is-drill .lvl-algo-sub-item {
  min-height: var(--touch-target-min);
  padding: 0 12px;
  box-sizing: border-box;
}
@media (pointer: coarse) {
  #layer-add-menu > .lvl-add-item { min-height: var(--touch-target-min); }
}
#layer-add-menu.is-touch > .lvl-add-item { min-height: var(--touch-target-min); }
/* === /TUX-035 === */

/* === TUX-016: toolbar footer + drag handles touch-safe ===
 * (A) Anchored rail (body.mobile-layout, position: static): nothing can be dragged, so the
 *     handle and the footer never render, for every pointer type. TUX-016 owns this rule;
 *     TUX-013 requirement 4 is satisfied here.
 * (B) Floating rail on a primary coarse pointer: the 13px footer buttons do not render (undock by
 *     dragging the handle; pin is ignored by toolbar.js), and both handles are 44px finger targets
 *     with touch-action: none so a one-finger drag moves the bar and never scrolls or cancels.
 * Keyed on (pointer: coarse), the same signal as body.touch-ui. Not on any-pointer: a touch-screen
 * laptop keeps the mouse UI. */
body.mobile-layout #tool-bar .toolbar-drag-handle,
body.mobile-layout #tool-bar .toolbar-footer { display: none; }

@media (pointer: coarse) {
  #tool-bar .toolbar-footer { display: none; }

  .tool-bar .toolbar-drag-handle,
  .ctxbar .ctxbar-handle { touch-action: none; }

  /* Toolbar grip, vertical rail: full rail width, 44px tall (real box; the rail scrolls and the
     handle clips overflow, so a ::before extender would be cut off). */
  .tool-bar .toolbar-drag-handle {
    box-sizing: border-box;
    height: var(--touch-target-min, 44px);
    min-height: var(--touch-target-min, 44px);
    width: calc(100% + 2 * var(--spacing-sm));
    margin: calc(-1 * var(--spacing-sm)) calc(-1 * var(--spacing-sm)) 1px;
  }
  /* Horizontal variants: a 44px-wide vertical strip at the leading edge. */
  [data-ui-skin] .toolbar-docked-top .toolbar-drag-handle,
  [data-ui-skin] .toolbar-docked-bottom .toolbar-drag-handle,
  [data-ui-skin] .tool-bar.toolbar-floating-horizontal:not([class*="toolbar-docked"]) .toolbar-drag-handle {
    width: var(--touch-target-min, 44px);
    min-width: var(--touch-target-min, 44px);
    height: auto;
    min-height: var(--touch-target-min, 44px);
    margin: 0 4px 0 0;
  }
  /* A persisted lock must never hide the grip or make it inert on touch. */
  .tool-bar.toolbar-locked:not([class*="toolbar-docked"]) .toolbar-drag-handle {
    height: var(--touch-target-min, 44px);
    margin: calc(-1 * var(--spacing-sm)) calc(-1 * var(--spacing-sm)) 1px;
    opacity: 0.45;
    transform: none;
    pointer-events: auto;
  }

  /* Context bar grip: 44px wide real box. TUX-041 B2 (Q19): the bar is 52px tall on touch, so the grip stretches to a real
     44px box and needs no ::before extender (it overlapped the canvas handles above and below the bar). */
  .ctxbar .ctxbar-handle {
    position: relative;
    width: var(--touch-target-min, 44px);
    min-width: var(--touch-target-min, 44px);
  }
}
/* === END TUX-016 === */

/* === TUX-016 (fix round): touch modifier bar clears a top-docked toolbar ===
 * Finger-docking the rail at the top is reachable now that the drag is not cancelled. The floating
 * modifier bar (top: 58-66px of the shell) then sat on the docked bar and swallowed taps on every
 * tool. toolbar.js publishes the docked height as --toolbar-dock-top-h on the shell. The anchored
 * layout (mobile-layout) keeps its static, ordered bar. */
body:not(.mobile-layout) .workspace-shell:has(> #tool-bar.toolbar-docked-top) > #touch-modifier-bar {
  top: calc(var(--toolbar-dock-top-h, 56px) + 8px);
}
/* === END TUX-016 fix round === */

/* === TUX-036: hidden-but-tappable actions === */
/* Pointer-events follow the opacity:1 states for every input type, so a strip that is
   transparent can never take a tap (a finger tap lands on the card and selects it). */
.lvl-acts, .lvl-grp-acts { pointer-events: none; }
.lvl-card.is-active .lvl-acts,
.lvl-grp-hdr.is-active .lvl-grp-acts { pointer-events: auto; }
@media (hover: hover) {
  .lvl-card:hover .lvl-acts,
  .lvl-grp-hdr:hover .lvl-grp-acts { pointer-events: auto; }
}
/* Locked and multi-select states keep winning (same specificity as the is-active rule above). */
.lvl-card.is-locked .lvl-acts { pointer-events: none; }
.lvl-list-multi .lvl-card.is-selected .lvl-acts,
.lvl-list-multi .lvl-grp-hdr.is-selected .lvl-grp-acts { pointer-events: none; }

/* Requirement 5: keep Delete away from its neighbour. Margin only; sizing belongs to TUX-041. */
@media (pointer: coarse) {
  .lvl-acts > .lvl-ab.del,
  .lvl-grp-acts > .lvl-ab.del { margin-inline-start: 8px; }
}

/* Preset gallery on devices without hover: row controls are always shown. */
@media (hover: none) {
  .hg-preset-delete,
  .hg-preset-set-default { display: flex; opacity: 1; }
  .hg-preset-group-select { opacity: 1; }
}
/* Two-step touch Delete: the first tap arms the button. */
.hg-preset-delete.is-armed {
  width: auto; min-width: 18px; padding: 0 6px;
  color: #fff; background: rgb(var(--vectura-danger-rgb, 239 68 68)); opacity: 1;
  font-size: var(--font-size-xs, 11px); line-height: 18px; white-space: nowrap;
}
/* === /TUX-036 === */

/* === TUX-043: sliders ===
 * Finger-sized range inputs on coarse pointers. The <input> box itself is 44px tall (the audit
 * measures the box; a wrapper band or overlay would read as "covered"). The visible 4px track
 * (pen: 3px) is the ::-webkit-slider-runnable-track, centred in that box by the UA; the 28px
 * thumb is re-centred with a logical margin so vertical ranges (writing-mode) work too.
 * Fill colours come from the inherited --fill / --slider-start / --tux-fill-color vars.
 * Specificity: [data-ui-skin] input[type=range]:not(.tux-nope) is (0,3,1) and the pseudo rules
 * (0,3,2), so they beat every per-class slider rule earlier in this file. They tie only with
 * `.noise-control input[type=range]` and win by coming later. Desktop (mouse) is unchanged.
 * touch-action: pan-y keeps vertical scrolling native; Vectura.UI.RangeTouch (slider.js)
 * owns the sideways drag. */
@media (pointer: coarse) {
  [data-ui-skin] input[type='range']:not(.tux-nope) {
    -webkit-appearance: none; appearance: none;
    box-sizing: border-box;
    block-size: var(--touch-target-min); min-block-size: var(--touch-target-min);
    margin-block: 0;
    padding: 0;
    touch-action: pan-y;
    background: transparent;
    border-radius: 0;
    --tux-track: var(--touch-slider-track);
  }
  [data-ui-skin] input[type='range']:not(.tux-nope)::-webkit-slider-runnable-track {
    block-size: var(--tux-track);
    border-radius: 2px;
    background: linear-gradient(to right,
      var(--slider-start, var(--tux-fill-color, var(--ui-accent))) 0%,
      var(--tux-fill-color, var(--ui-accent)) var(--fill, 0%),
      var(--ui-border) var(--fill, 0%) 100%);
  }
  [data-ui-skin] input[type='range']:not(.tux-nope)::-webkit-slider-thumb {
    -webkit-appearance: none; appearance: none;
    box-sizing: border-box;
    inline-size: var(--touch-slider-thumb); block-size: var(--touch-slider-thumb);
    width: var(--touch-slider-thumb); height: var(--touch-slider-thumb);
    margin-block-start: calc((var(--tux-track) - var(--touch-slider-thumb)) / 2);
    margin-top: calc((var(--tux-track) - var(--touch-slider-thumb)) / 2);
    border-radius: 50%;
  }
  [data-ui-skin] input[type='range']:not(.tux-nope)::-moz-range-thumb {
    box-sizing: border-box; width: var(--touch-slider-thumb); height: var(--touch-slider-thumb); border-radius: 50%;
  }
  /* Per-class variants of the visual only. */
  [data-ui-skin] input.pen-sld[type='range']:not(.tux-nope) { --tux-track: var(--touch-slider-track-pen); }
  [data-ui-skin] .mp-root input.mp-slider[type='range']:not(.tux-nope) { --tux-fill-color: var(--mp-type-color); }
  [data-ui-skin] .morph-panel input.morph-slider[type='range']:not(.tux-nope) { --tux-fill-color: var(--morph-accent); }
  /* Draw-order: gradient reveal track, 6px, white thumb with a tinted halo ring. */
  [data-ui-skin] input.draw-order-slider[type='range']:not(.tux-nope) { --tux-track: 6px; }
  [data-ui-skin] input.draw-order-slider[type='range']:not(.tux-nope)::-webkit-slider-runnable-track {
    border-radius: 6px;
    background:
      linear-gradient(var(--ui-border), var(--ui-border)) right center / calc(100% - var(--draw-order-fill, 100%)) 100% no-repeat,
      linear-gradient(90deg, var(--draw-order-start, #38bdf8) 0%, var(--draw-order-end, #f59e0b) 100%) left center / 100% 100% no-repeat,
      var(--ui-border);
  }
  [data-ui-skin] input.draw-order-slider[type='range']:not(.tux-nope)::-webkit-slider-thumb { border-width: 3px; }
  [data-ui-skin] input.draw-order-slider.is-progress[type='range']:not(.tux-nope)::-webkit-slider-thumb {
    border-width: 0; border-radius: 0; margin-block-start: calc((6px - var(--touch-slider-thumb)) / 2);
  }
  /* Stacked dual ranges (plot range): the container grows to the 44px box; the shared track
   * and fill are re-centred; inputs paint nothing themselves. */
  .harmonograph-plotter-plotrange { height: var(--touch-target-min); }
  .harmonograph-plotter-plotrange .hp-plotrange-fill { top: calc(50% - 9px); height: 18px; }
  [data-ui-skin] .harmonograph-plotter-plotrange input[type='range']:not(.tux-nope)::-webkit-slider-runnable-track { background: transparent; }
  .dual-range { height: var(--touch-target-min); }
  .dual-range input[type='range'] { top: 0; }
  /* Vertical range (Text panel max offset): 44px wide, pans sideways, length from its flex row. */
  [data-ui-skin] input.vtp-vslider-vert[type='range']:not(.tux-nope) {
    width: var(--touch-target-min); min-width: var(--touch-target-min); touch-action: pan-x;
  }
  .vtp-xypad-max { height: 120px; }
  /* Layout: the row is as tall as its slider; chips stay 44px beside it. */
  .vtp-vslider-wrap { height: auto; min-height: var(--touch-target-min); }
}
/* TUX-043 fix round: draw-order footer on short coarse viewports (iPhone landscape).
 * The pane reserved only 56px for the modifier bar, but the bar is 57px and the HUD strip adds
 * 27px more (shown above 640px), so the pane ran 28px under the bar and the bar covered the
 * bottom of the draw-order slider (elementFromPoint at the track centre hit the bar). Reserve
 * the real chrome, and on short viewports tighten the Layers tab above the draw-order band so the 44px
 * slider and its thumb are on screen without scrolling. */
@media (pointer: coarse) and (min-width: 641px) {
  body.mobile-layout .pane { bottom: calc(84px + var(--safe-bottom, 0px)); }
}
@media (pointer: coarse) and (max-height: 520px) {
  /* Pull the 44px slider up above the modifier bar: drop the idle status strip and the head gap.
   * The 14px top padding keeps the 44px eye/gear hit boxes (TUX-041) off the last layer row:
   * band top 237, head centre 261, slider 271-315 in the 318px-high scroller. */
  [data-ui-skin] #right-pane .draw-order-bar { padding-top: 14px; }
  [data-ui-skin] #right-pane .draw-order-bar .draw-order-head { margin-bottom: 0; }
  [data-ui-skin] #right-pane #layer-status-bar:has(> .lvl-sb-idle) { min-height: 0; height: 0; padding-block: 0; overflow: hidden; border: 0; }
}
/* TUX-036 / TUX-041: the multi-select command strip wraps inside the pane. Every button is a 44 px
 * target, Delete keeps 8 px from Duplicate, and nothing pans sideways (the old pan hid Duplicate and
 * Delete off-screen with no cue). The strip grows taller instead; the label takes the first row. */
@media (pointer: coarse) {
  [data-ui-skin] #right-pane #layer-status-bar:not(:has(> .lvl-sb-idle)) {
    flex-wrap: wrap; align-items: center; justify-content: flex-start; row-gap: 2px; column-gap: 0;
    padding: 4px; overflow: visible; touch-action: auto;
  }
  [data-ui-skin] #right-pane #layer-status-bar .lvl-sb-sel-label { flex: 1 0 100%; padding: 2px 4px 0; }
  [data-ui-skin] #right-pane #layer-status-bar .lvl-sb-sep,
  [data-ui-skin] #right-pane #layer-status-bar .lvl-sb-spacer,
  [data-ui-skin] #right-pane #layer-status-bar .lvl-sb-total { display: none; }
  [data-ui-skin] #right-pane #layer-status-bar .lvl-sb-cmds { flex-wrap: wrap; flex-shrink: 1; gap: 4px; max-width: 100%; }
  [data-ui-skin] #right-pane #layer-status-bar .lvl-cb {
    width: var(--touch-target-min); height: var(--touch-target-min); min-width: var(--touch-target-min);
  }
  [data-ui-skin] #right-pane #layer-status-bar .lvl-cb.del { margin-inline-start: 4px; }
  [data-ui-skin] #right-pane #layer-status-bar .lvl-cb svg { width: 20px; height: 20px; }
}
/* Short landscape (iPhone, 330-402 px): with several layers selected the list gives up its 100 px floor
 * (about one row stays) so the 44 px strip stays inside the pane instead of below its fold. */
@media (pointer: coarse) and (max-height: 520px) {
  [data-ui-skin] #right-pane #layer-list.lvl-list-multi { min-height: 52px; }
}
/* === END TUX-043 === */

/* === TUX-046: modal sheet ===
 * Contract for the legacy #modal-overlay sheet (Export, Help, info, colour picker).
 * Slots: .vt-sheet (card), .vt-sheet__header, .vt-sheet__body, .vt-sheet__footer.
 *   header and footer are flex:none. Only the body scrolls. TUX-026 and TUX-049 reuse the slots.
 * Keys: body.touch-ui (any coarse pointer, set by TUX-006) for coarse sizing and the pinned
 *   layout. body.phone-layout for the full-screen sheet. Never key on width alone. The one
 *   max-width: 1100px query below mirrors the existing Export column-layout breakpoint.
 * Z-band: #modal-overlay sits at 900. It must stay in 221-999: above #app-header (220), below
 *   .vectura-modal-backdrop and the drag tooltip (1000+).
 * Safe area: var(--safe-*), defined by TUX-005 in tokens.css.
 * Sheet heights use % of the fixed overlay, never vh (vh includes the iOS toolbar).
 */
#modal-overlay { z-index: 900; }

body.touch-ui .vt-sheet {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  max-height: calc(100% - 32px - var(--safe-top) - var(--safe-bottom));
}
body.touch-ui .vt-sheet__header { flex: none; }
body.touch-ui .vt-sheet__body {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}
body.touch-ui .vt-sheet__footer { flex: none; }
/* The Export body hosts its own panes; the scroll happens inside it (see max-width block). */
body.touch-ui .modal-card--export .vt-sheet__body { overflow: hidden; }

/* Close: keep the 24px visual, extend the hit area to the touch minimum. */
body.touch-ui .modal-close { position: relative; flex: none; }
body.touch-ui .modal-close::before {
  content: '';
  position: absolute;
  left: 50%;
  top: 50%;
  width: var(--touch-target-min, 44px);
  height: var(--touch-target-min, 44px);
  transform: translate(-50%, -50%);
}

/* Footer buttons and Export nav tabs meet the touch minimum. */
body.touch-ui .export-modal-footer button,
body.touch-ui .color-modal-actions button {
  min-height: var(--touch-target-min, 44px);
  min-width: var(--touch-target-min, 44px);
}
body.touch-ui .export-modal-nav {
  min-height: var(--touch-target-min, 44px);
}
body.touch-ui .export-nav-item { min-height: var(--touch-target-min, 44px); }

/* Colour picker actions stay reachable while the body scrolls. */
body.touch-ui .color-modal-actions {
  position: sticky;
  bottom: 0;
  background: var(--ui-panel);
  padding-top: 8px;
}

/* Export column layout (existing 1100px breakpoint): the pane stack scrolls, the nav keeps its size. */
@media (max-width: 1100px) {
  body.touch-ui .export-modal-body {
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
  }
  body.touch-ui .export-modal-body > * { flex-shrink: 0; }
  /* flex: none lives here only. On wide layouts the nav is a 188px side column and must keep its basis. */
  body.touch-ui .export-modal-nav {
    flex: none;
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
  }
  body.touch-ui .export-modal-settings {
    flex: 0 0 auto;
    max-width: none;
    width: 100%;
    min-width: 0;
  }
  /* The nav sticks to the top of the scrolling pane stack; the preview gets a fixed height. */
  body.touch-ui .export-modal-nav {
    order: -2;
    position: sticky;
    top: 0;
    z-index: 2;
  }
  body.touch-ui .export-modal-preview { flex: 0 0 auto; height: 220px; min-height: 0; }
}

/* Phone: full-screen sheet inside the safe area, no backdrop. */
body.phone-layout #modal-overlay .modal-card,
body.phone-layout #modal-overlay .modal-card.modal-card--export {
  position: fixed;
  top: var(--safe-top);
  right: var(--safe-right);
  bottom: var(--safe-bottom);
  left: var(--safe-left);
  width: auto;
  height: auto;
  max-width: none;
  max-height: none;
  margin: 0;
  border-radius: 0;
}
/* Save Preset sheet (.vectura-modal, built by UI.overlays.Modal). Same slots as #modal-overlay.
 * modal.js tags .vt-sheet / __header / __body / __footer. Coarse sizing keys on body.touch-ui. */
body.touch-ui .vectura-modal.vt-sheet {
  max-height: calc(100% - var(--safe-top) - var(--safe-bottom));
}
body.touch-ui .vectura-modal.vt-sheet > .vt-sheet__header { flex: none; }
body.touch-ui .vectura-modal.vt-sheet > .vt-sheet__body {
  flex: 1 1 auto;
  min-height: 0;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}
/* The actions row stays in view while the body scrolls (it is ordered first on touch). */
body.touch-ui .vectura-modal .preset-save-footer.vt-sheet__footer {
  position: sticky;
  top: 0;
  z-index: 1;
  flex: none;
  background: var(--ui-panel);
  padding-bottom: 8px;
}
body.touch-ui .vectura-modal .vt-sheet__footer button {
  min-height: var(--touch-target-min, 44px);
  min-width: var(--touch-target-min, 44px);
}
/* Phone: the Save Preset sheet fills the screen inside the safe area. No backdrop remains to tap,
 * so Cancel (>= 44px) is the close. The keyboard inset (--kb-inset) keeps the field above the keys. */
body.phone-layout .vectura-modal-backdrop > .vectura-modal.vt-sheet:has(.preset-save-footer) {
  position: fixed;
  top: var(--safe-top);
  right: var(--safe-right);
  bottom: calc(var(--safe-bottom) + var(--kb-inset, 0px));
  left: var(--safe-left);
  width: auto;
  height: auto;
  max-width: none;
  max-height: none;
  margin: 0;
  border-radius: 0;
}

/* Document Setup (#settings-panel). A drawer on tablets; on phones a full-screen sheet inside the
 * safe area with a pinned header (.pane-hdr + close) and a scrolling body. It opens above the
 * app header, within the 221-999 band. */
#settings-panel > .pane-hdr { flex: none; }
body.touch-ui #settings-panel .settings-panel-body {
  min-height: 0;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}
body.phone-layout #settings-panel {
  position: fixed;
  top: var(--safe-top);
  right: var(--safe-right);
  bottom: calc(var(--safe-bottom) + var(--kb-inset, 0px));
  left: var(--safe-left);
  width: auto;
  height: auto;
  max-width: none;
  border: 0;
  z-index: 900;
}
/* === END TUX-046 === */

/* === TUX-022: fill scope chips === */
/* Scope up/down chips in the fill context bar (coarse pointer only, rendered by
   Vectura.UI.PaintBucketScopeChips). Beats `.ctxbar-btn` (26 px) on specificity. */
.ctxbar-fill-scope {
  display: flex;
  align-items: center;
  gap: 4px;
}
.ctxbar .ctxbar-btn.ctxbar-fill-scope-btn {
  min-width: var(--touch-target-min, 44px);
  min-height: var(--touch-target-min, 44px);
  height: var(--touch-target-min, 44px);
  padding: 0 12px;
  justify-content: center;
  font-size: var(--font-size-md, 13px);
  touch-action: manipulation;
}
.ctxbar-fill-scope-readout {
  min-width: 56px;
  text-align: center;
  color: var(--ui-muted, #9a9a9a);
  font-size: var(--font-size-sm, 11px);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
/* The generic phone rule hides .ctxbar at <= 640px; the touch fill chips must stay reachable. */
@media (max-width: 640px) {
  .ctxbar.ctxbar--fill { display: flex; }
}
/* === END TUX-022 === */

/* === TUX-002: fixed, non-scrolling shell ===
 * The app is a fixed-size shell. The page itself must never scroll, rubber-band or pull to refresh.
 * body IS the app wrapper (the Tailwind h-screen class was removed from index.html). Height comes
 * from --app-vh (dynamic viewport). Only inner scroll regions scroll. */
html, body { overflow: hidden; overscroll-behavior: none; }
html { height: 100%; }
body { position: fixed; top: 0; left: 0; right: 0; height: var(--app-vh); width: 100%; }

/* Scroll-region rule (single list). Every element that scrolls on its own must contain its
 * overscroll so a swipe at the end of the list never chains to the page. New scrollers join here.
 * No universal * rule: it would also kill nested scroll-chaining on desktop. The body prefix
 * out-ranks the runtime Tailwind overflow utilities. */
body .pane-body, body .overflow-y-auto, body .overflow-auto,
body .tool-bar, body .toolbar-docked-left, body .toolbar-docked-right, body .tool-drawer-body,
body .vectura-modal-body, body .modal-card, body .modal-illustrations.scrollable,
body .export-modal-nav, body .export-settings-scroll, body .petal-designer-window,
body .lvl-layer-list, body #pen-list, body .pen-pick-list, body .vtp-fp-list, body .palette-options,
body .gm-module-menu, body .settings-panel-body, body .right-panel-section-scroll,
body .palette-picker-menu, body .hg-preset-popover, body .mp-root .mp-info-popover,
body .ctxbar-menu, body .ctxbar-align-flyout, body .ctxbar-algo-flyout, body .ctxbar-scene-flyout,
body .vtp-size-pop, body .lvl-algo-submenu, body .algo-draw-picker {
  overscroll-behavior: contain;
}
/* === END TUX-002 === */

/* === TUX-003: no page zoom on chrome ===
 * Pinch on panels, toolbars and modals must not zoom the page. touch-action only affects touch
 * input, so mouse and trackpad are unchanged. Surfaces that own a pinch (canvas, designers) opt in
 * with [data-touch-zoom]; ui-touch.js installGestureZoomGuard() reads the same selector for the
 * WebKit gesture* events. */
html, body { touch-action: pan-x pan-y; }
[data-touch-zoom] { touch-action: none; }
/* === END TUX-003 === */

/* === TUX-005: safe-area insets ===
 * Outside any width media query: iPad landscape (1210 px) needs the same rules as the phones.
 * Header: wins over the older #app-header rules. [data-ui-skin] #app-header (1,1,0) at the
 * "Header & brand" block beats the dead :where(body.mobile-layout) #app-header padding (1,0,0).
 * The height grows by the inset, otherwise the padding would eat the 38 px content box and
 * .header-main would overflow onto the toolbar. */
[data-ui-skin] #app-header {
  box-sizing: border-box;
  height: calc(38px + var(--safe-top));
  padding-top: var(--safe-top);
  padding-left: calc(14px + var(--safe-left));
  padding-right: calc(14px + var(--safe-right));
}
/* Bottom inset sits on the bottom-most visible in-flow chrome only. #hud-bar is that strip while it
 * shows (it hides under 640 px wide); below that the modifier bar is the bottom-most strip. */
.hud-bar {
  padding-bottom: calc(3px + var(--safe-bottom));
}
body.mobile-layout .hud-bar {
  padding-left: calc(12px + var(--safe-left));
  padding-right: calc(12px + var(--safe-right));
}
@media (max-width: 640px) {
  body.mobile-layout #touch-modifier-bar {
    padding-bottom: calc(6px + var(--safe-bottom));
  }
}
/* Drawers in mobile-layout: the pane background reaches the screen edge, its content clears the
 * side inset. The widths grow by the inset so the open and the collapsed pane keep their sizes. */
body.mobile-layout .pane-left {
  padding-left: var(--safe-left);
  width: calc(var(--pane-left-width) + var(--safe-left));
}
body.mobile-layout .pane-right {
  padding-right: var(--safe-right);
  width: calc(var(--pane-right-width) + var(--safe-right));
}
/* Collapsed slivers keep their 40 px width and shift inward by the inset. The inset band stays
 * transparent, so the canvas keeps its width and the sliver controls clear the notch. */
body.mobile-layout .pane-left.pane-collapsed,
body.mobile-layout.auto-collapsed .pane-left:not(.pane-force-open) {
  width: var(--pane-collapsed-width);
  left: var(--safe-left);
  padding-left: 0;
}
body.mobile-layout .pane-right.pane-collapsed,
body.mobile-layout.auto-collapsed .pane-right:not(.pane-force-open) {
  width: var(--pane-collapsed-width);
  right: var(--safe-right);
  padding-right: 0;
}
/* Docked panes (touch-wide / desktop) end at the screen bottom: the scrolling bodies keep the last
 * row above the home indicator. TUX-032 owns the keyboard-open padding, so it stays untouched. */
html:not(.kb-open) body:not(.mobile-layout) .right-tab-panel {
  padding-bottom: var(--safe-bottom);
}
/* Phone header: TUX-001 puts 44 px action buttons in the header, which the 38 px base cannot hold
 * (they overflowed 3 px onto the toolbar). The phone header is 44 px of content plus the inset. */
body.phone-layout #app-header {
  height: calc(44px + var(--safe-top));
}
body.phone-layout #app-header .header-main {
  height: 44px;
  min-height: 44px;
}
/* Bottom inset fallback: with the modifier bar hidden (!showBar) and #hud-bar display:none (<= 640 px)
 * no chrome strip carries the inset. The shell then reserves it itself. */
@media (max-width: 640px) {
  body.mobile-layout:has(#touch-modifier-bar.hidden) .workspace-shell {
    padding-bottom: var(--safe-bottom);
    box-sizing: border-box;
  }
}
/* TUX-005: the phone Document Setup sheet is position:fixed with left:var(--safe-left), so the base
 * translateX(-100%) parks it with its right edge at the inset (62 px on iPhone landscape): the closed
 * drawer and its close button painted in the left band. Shift by the inset too, and hide it. */
body.phone-layout #settings-panel:not(.open) {
  transform: translateX(calc(-100% - var(--safe-left)));
  visibility: hidden;
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), visibility 0s linear 0.3s;
}
body.phone-layout #settings-panel.open {
  transform: translateX(0);
  visibility: visible;
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), visibility 0s;
}
/* === END TUX-005 === */

/* === TUX-007: phone landscape canvas ===
 * Short coarse-pointer phones (iPhone landscape, 874x402 and 874x330). Every rule is keyed on
 * body.phone-layout.phone-short (set by Vectura.LayoutClassifier, the only short-height decision).
 * Two classes plus an id outrank the single-class `body.mobile-layout #...` rules earlier in this
 * file, and this block sits last, so each override below wins on specificity AND order.
 * Nothing is hidden: the rail, modifier bar, formula pane and zoom readout stay reachable. */
body.phone-layout.phone-short {
  --tux7-rail-h: 52px;
  --tux7-sliver: var(--pane-collapsed-width, 40px);
  /* Height of the HUD strip above the bottom inset; an open pane stops above it (TUX-005 E). */
  --tux7-hud-h: 24px;
}
/* Rail: ONE horizontal row <= 52 px. Beats `body.mobile-layout #tool-bar` (static, flex-wrap, full
 * width) and any persisted vertical/docked class. Extra tools sit under All Tools (TUX-013). */
body.phone-layout.phone-short #tool-bar {
  position: static;
  flex-direction: row;
  flex-wrap: nowrap;
  justify-content: flex-start;
  align-items: center;
  /* The rail sits BETWEEN the two pane slivers (and the insets) so the sliver toggles stay tappable. */
  width: auto;
  margin-left: calc(var(--safe-left) + var(--tux7-sliver));
  margin-right: calc(var(--safe-right) + var(--tux7-sliver));
  max-width: none;
  height: var(--tux7-rail-h);
  max-height: var(--tux7-rail-h);
  box-sizing: border-box;
  /* 52 px = 4 + 44 + 3 padding + 1 px border: the 44 px buttons land on whole pixels. */
  padding: 4px 6px 3px;
  /* One overflow model: TUX-013 marks extra tools .rail-overflowed (display:none) and All Tools lists them. */
  overflow-x: hidden;
  overflow-y: hidden;
  scrollbar-width: none;
}
/* Modifier bar: a slim column on the right edge, left of the right pane sliver. Beats
 * `body.mobile-layout #touch-modifier-bar` (static, full width, order 4) and the `.hidden` override
 * that forces display:flex. Behavior and labels are unchanged (TUX-045 owns the redesign). */
body.phone-layout.phone-short #touch-modifier-bar {
  position: absolute;
  top: calc(var(--tux7-rail-h) + 2px);
  right: calc(var(--safe-right) + var(--tux7-sliver) + 6px);
  bottom: auto;
  left: auto;
  /* Two columns x 3 rows of 44 px buttons (138 px): 5 x 44 px in one column is 220 px, more than the
   * ~211 px free at 874x330, so a single column would push Pan under the home-indicator band. The
   * max-height also subtracts the bottom inset, so the grid can never reach it. */
  display: grid;
  grid-template-columns: repeat(2, 46px);
  grid-auto-rows: 44px;
  width: auto;
  max-height: calc(100% - var(--tux7-rail-h) - 4px - var(--safe-bottom));
  gap: 0;
  padding: 2px;
  border: 1px solid var(--ui-border);
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  overflow-y: auto;
  scrollbar-width: none;
  /* Above the pane backdrop (--z-backdrop, 65) and below the open pane (--z-drawer, 70): the modifier keys
   * stay tappable while a pane is open (TUX-041, TUX-045 req 2: latch Multi-select, then tap a row). */
  z-index: calc(var(--z-backdrop) + 1);
}
/* An open right pane (.pane-force-open, 258 px wide) would sit on the column, so the column hops to the
 * left edge, clear of the collapsed left sliver. Only one pane opens at a time on a phone. */
body.phone-layout.phone-short:has(.pane-right.pane-force-open) #touch-modifier-bar {
  right: auto;
  left: calc(var(--safe-left) + var(--tux7-sliver) + 6px);
}
body.phone-layout.phone-short #touch-modifier-bar .touch-mod-btn {
  flex: 0 0 44px;
  width: 46px;
  height: 44px;
  padding: 0;
}
/* Formula pane: no reserved row. Collapsed it is a 48x48 chip over the canvas bottom-left, inside the
 * left sliver and the inset; expanded it is an overlay sheet. Beats `body.mobile-layout #bottom-pane`
 * (relative, order 3, 32 px / 38vh height). */
body.phone-layout.phone-short #bottom-pane {
  position: absolute;
  left: calc(var(--safe-left) + var(--tux7-sliver) + 8px);
  bottom: calc(8px + var(--safe-bottom));
  z-index: 46;
  border: 1px solid var(--ui-border);
  border-radius: 12px;
}
body.phone-layout.phone-short #bottom-pane.bottom-pane-collapsed {
  width: 48px;
  height: 48px;
}
body.phone-layout.phone-short #bottom-pane.bottom-pane-collapsed .bottom-pane-header {
  position: static;
  width: 48px;
  height: 48px;
  min-height: 48px;
  padding: 0;
  border: 0;
  background: transparent;
}
body.phone-layout.phone-short #bottom-pane.bottom-pane-collapsed .pane-toggle-bottom {
  position: absolute;
  inset: 0;
  left: 0;
  width: 48px;
  height: 48px;
  /* Keep the collapsed rotation (down chevron turned up = expand); base rule's translate is dropped. */
  transform: rotate(180deg);
  display: flex;
  align-items: center;
  justify-content: center;
}
body.phone-layout.phone-short #bottom-pane:not(.bottom-pane-collapsed) {
  left: calc(var(--safe-left) + var(--tux7-sliver) + 8px);
  /* End left of the modifier column (2 x 46 px + gap/padding = 98 px, 6 px from the sliver) so the
   * column never covers the sheet's stats. */
  right: calc(var(--safe-right) + var(--tux7-sliver) + 6px + 98px + 8px);
  width: auto;
  height: min(60%, 220px);
}
/* Batch R: the canvas HUD (3 view buttons, right offset = sliver + 8 px) sits on the bottom row, so the
 * open sheet also ends left of it. Without this the sheet covered Zoom Out (iPhone landscape, 46x46 under the sheet).
 * Batch R2: the HUD width is one token (3 x 44 px buttons, no gap, no padding, 1 px border = 134 px); the sheet and the status strip derive from it. */
body.phone-layout.phone-short.touch-ui { --canvas-hud-w: 134px; }
body.phone-layout.phone-short.touch-ui #bottom-pane:not(.bottom-pane-collapsed) {
  right: calc(var(--safe-right) + var(--pane-collapsed-width, 40px) + 8px + var(--canvas-hud-w, 134px) + 8px);
}
/* Status strip: an overlay, not a row. It keeps the hints and the zoom readout (pointer-events none, so it
 * never intercepts a canvas touch). It sits between the formula chip and the right sliver and, like any
 * bottom chrome, carries the bottom inset in its own padding (TUX-005 contract). */
body.phone-layout.phone-short .hud-bar {
  position: absolute;
  left: calc(var(--safe-left) + var(--tux7-sliver) + 64px);
  right: calc(var(--safe-right) + var(--tux7-sliver) + 64px);
  bottom: 0;
  min-height: 0;
  padding: 2px 8px calc(2px + var(--safe-bottom));
  border: 0;
  border-radius: 8px 8px 0 0;
  background: color-mix(in srgb, var(--ui-panel) 80%, transparent);
  pointer-events: none;
  z-index: 44;
}
/* Side panes: the 84 px bottom reserve (`@media (pointer: coarse) and (min-width: 641px) body.mobile-layout
 * .pane`) cleared the old full-width modifier bar and HUD row. Both now float over the canvas, so an
 * open pane runs to the bottom inset and the draw-order slider keeps its 44 px hit area. Two classes
 * plus one class outrank that rule, and this block is last. */
body.phone-layout.phone-short .pane.pane-force-open {
  bottom: calc(var(--safe-bottom, 0px) + var(--tux7-hud-h));
}
/* === END TUX-007 === */
/* === TUX-046 (integration fix): colour modal clears the close hit area ===
   The close ::before is 44px around a 24px button, so it reaches 10px below the header.
   The positioned .color-sv-wrapper started 8px below and won the hit test for 2px.
   Pad the colour body so the picker starts outside the close target. */
body.touch-ui .modal-card .color-modal { padding-top: 4px; }
/* === END TUX-046 (integration fix) === */

/* === TUX-041 slice B3: modals ===
 * Every interactive target in a modal (Export, Help, Document Setup, colour picker, Save Preset, info and confirm sheets) has a
 * hit area of at least --touch-target-min on coarse pointers. Boxes that can grow get a real min-height. The small round
 * visuals (info buttons, toggles, the legend gear) keep their size and get a centred 44 px ::before. The row that holds one is
 * a finger tall, so the extension never reaches the row above or below. Keyed on body.touch-ui (a coarse pointer), never on
 * width. Desktop is unchanged. The scope list is the modal roots: #modal-overlay, #settings-panel, .vectura-modal. */
body.touch-ui :is(#modal-overlay, #settings-panel, .vectura-modal) :is(button, [role="button"], select, textarea, summary,
  input:is([type="text"], [type="number"], [type="search"], [type="email"], [type="url"], :not([type]))):not(
  .sw-toggle, .info-btn, .export-info-btn, .export-legend-gear-btn, .modal-close, .sr-only) {
  min-height: var(--touch-target-min);
  box-sizing: border-box;
}
/* WebKit ignores min-height on some native selects, so they also get an explicit height. */
body.touch-ui :is(#modal-overlay, #settings-panel, .vectura-modal) select:not(.sr-only) { height: var(--touch-target-min); }
/* Icon-only steppers and tab strips are a finger wide too. */
body.touch-ui :is(#modal-overlay, #settings-panel, .vectura-modal) :is(.num-step-btn, .help-tab-btn, .help-platform-btn, .opt-reset, .export-preview-toolbar button) { min-width: var(--touch-target-min); }
/* The number stepper is a fixed 28 px box that clips its buttons; it grows to a finger. The narrow variant (100 px) leaves
 * 10 px for the number once two 44 px buttons sit in it, so it widens to fit. */
body.touch-ui :is(#modal-overlay, #settings-panel, .vectura-modal) .num-step { height: auto; min-height: var(--touch-target-min); }
/* The stepper buttons keep a finger width when a narrow row squeezes the field (Undo steps in the Document Setup column). */
body.touch-ui :is(#modal-overlay, #settings-panel, .vectura-modal) .num-step-btn { flex: 0 0 var(--touch-target-min); }
body.touch-ui :is(#modal-overlay, #settings-panel, .vectura-modal) .num-step--narrow { width: calc(2 * var(--touch-target-min) + 64px); flex: 0 0 calc(2 * var(--touch-target-min) + 64px); }
/* The close ::before reaches 10 px below the header. The tabs (opacity < 1 stacks them above it) started 8 px below, so they took
 * 2 px of it. Four more pixels of padding keep the close target whole. */
body.touch-ui #modal-overlay .help-wrap { padding-top: 4px; }
/* Help tabs may wrap rather than clip: seven 44 px tabs do not fit on a phone in one row. */
body.touch-ui #modal-overlay .help-tabs { flex-wrap: wrap; }
/* The 290 px Document Setup column seats Margin Line Gap in half a row: its slider shrank to 26 px, a thumb with no track.
 * On touch the field takes the whole row, so the slider keeps a usable width. */
body.touch-ui #settings-panel .line-style-control > .style-field:nth-child(3) { grid-column: 1 / -1; }
/* Small visuals keep their size; a centred 44 px ::before owns the touch. */
body.touch-ui :is(#modal-overlay, #settings-panel, .vectura-modal) :is(.info-btn, .export-info-btn, .export-legend-gear-btn, .sw-toggle) { position: relative; }
body.touch-ui :is(#modal-overlay, #settings-panel, .vectura-modal) :is(.info-btn, .export-info-btn, .export-legend-gear-btn, .sw-toggle)::before {
  content: ''; position: absolute; left: 50%; top: 50%;
  width: var(--touch-target-min); height: var(--touch-target-min);
  transform: translate(-50%, -50%);
}
/* The row that holds an extended visual is one finger tall, so the extension stays inside it. */
body.touch-ui :is(#modal-overlay, #settings-panel, .vectura-modal) :is(.ctrl-row, .ctrl-lbl, .optimization-row, .optimization-control, .control-label, .flex):has(> :is(.sw-toggle, .info-btn, .export-info-btn)),
body.touch-ui :is(#modal-overlay, #settings-panel, .vectura-modal) :is(.control-label, .flex, [class*="justify-between"]):has(> * > :is(.info-btn, .export-info-btn)) {
  min-height: var(--touch-target-min);
  align-items: center;
}
/* The legend covers most of a short phone preview. It only informs, so a pinch or pan starts through it; the gear stays tappable. */
body.touch-ui #modal-overlay .export-preview-legend { pointer-events: none; }
body.touch-ui #modal-overlay .export-preview-legend .export-legend-gear-btn { pointer-events: auto; }
/* Play + gear each carry a centred 44 px ::before over a 22 px box. On touch the legend sits over the
 * middle of a phone's preview, so the two buttons go to the row's ends (Play left of the title, gear
 * right) and the pass-through title stays in the middle: a one-finger pan started over the legend
 * centre still reaches the canvas, and the two hit areas never touch. */
body.touch-ui #modal-overlay .export-preview-legend .export-legend-actions { display: contents; }
body.touch-ui #modal-overlay .export-preview-legend .export-legend-play-btn { order: -1; }
/* === END TUX-041 slice B3 === */

/* === TUX-047: touch zoom surfaces === */
.export-preview-canvas-wrap[data-touch-zoom] {
  touch-action: none;
}
/* === END TUX-047 === */

/* === TUX-026: Petal Designer touch sizing and phone sheet ===
 * Selectors carry the [data-ui-skin] prefix plus .petal-designer-window so they beat the skin rule
 * `[data-ui-skin] .petal-tool-btn, .petal-close, ... { height: 26px; min-width: 26px }` (specificity 0,2,0).
 * Coarse sizing keys on the pointer type, never on width. The phone sheet keys on the layout classifier
 * class (TUX-006). Desktop (fine pointer, non-phone) is unchanged. */
@media (pointer: coarse) {
  [data-ui-skin] .petal-designer-window .petal-tool-btn,
  [data-ui-skin] .petal-designer-window .petal-close,
  [data-ui-skin] .petal-designer-window .petal-popout,
  [data-ui-skin] .petal-designer-window .petal-popin,
  [data-ui-skin] .petal-designer-window .petal-hist,
  [data-ui-skin] .petal-designer-window .petal-copy-btn {
    min-width: var(--touch-target-min, 44px);
    min-height: var(--touch-target-min, 44px);
    height: auto;
  }
  [data-ui-skin] .petal-designer-window .petal-designer-actions { gap: 6px; }
  /* A finger drags the pop-out window by its header (not on the phone sheet, which cannot move). */
  body:not(.phone-layout) .petal-designer-window:not(.petal-designer-inline) .petal-designer-header {
    touch-action: none;
  }
}
/* Phone: the pop-out is a full-screen sheet inside the safe area. The header stays pinned; the body scrolls. */
body.phone-layout #petal-designer-window.petal-designer-window:not(.petal-designer-inline) {
  position: fixed;
  top: var(--safe-top, 0px);
  right: var(--safe-right, 0px);
  bottom: var(--safe-bottom, 0px);
  left: var(--safe-left, 0px);
  width: auto;
  height: auto;
  max-width: none;
  max-height: none;
  margin: 0;
  border-radius: 0;
  border: 0;
  z-index: var(--z-floating-sheet, 850);
  overflow-y: auto;
  overscroll-behavior: contain;
}
body.phone-layout #petal-designer-window .petal-designer-header {
  position: sticky;
  top: 0;
  z-index: 2;
}
/* Batch R2 / TUX-020: Undo / Redo in the pop-out window header. The window covers the canvas HUD and the phone header, so this
 * pair is the finger-reachable history control while it is open. Touch only; a mouse keeps Cmd+Z and the menus. */
.petal-designer-window .petal-hist { display: none; }
body.touch-ui .petal-designer-window:not(.petal-designer-inline) .petal-hist { display: inline-flex; align-items: center; justify-content: center; }
.petal-designer-window .petal-hist:disabled { opacity: 0.4; }
/* === END TUX-026 === */
/* === TUX-027: mirror row actions (touch) ===
 * Disable / Lock / Delete get a >= 44px hit box on touch-ui. Specificity (0,4,1) beats the
 * (0,2,0) `.mp-root .mp-icon-btn` 22px rule above. The gap keeps the hit rects apart. */
/* Three 44px buttons beside the thumb leave the name ~52px wide in a 290px pane. The actions drop
 * to their own right-aligned line so the name keeps >= 96px (no viewport media query, Q1). */
body.touch-ui .mp-root .mp-row { grid-template-columns: 36px minmax(0, 1fr); }
body.touch-ui .mp-root .mp-row-name-text { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
body.touch-ui .mp-root .mp-row-actions { grid-column: 1 / -1; justify-content: flex-end; gap: 2px; }
body.touch-ui .mp-root .mp-row-actions .mp-icon-btn {
  width: var(--touch-target-min); height: var(--touch-target-min);
  min-width: var(--touch-target-min); min-height: var(--touch-target-min);
}
/* === END TUX-027 === */

/* === TUX-049: Save Preset sheet touch sizing + keyboard lift ===
 * 046 owns the sheet frame and the lift (html.kb-open pads the backdrop by --kb-inset). This block
 * only sizes the controls and keeps the actions row BELOW the name field, pinned to the bottom of the
 * scrolling body (the old order:-1 rule is deleted). Cancel stays first in the DOM, Save is last. */
@media (pointer: coarse) {
  body.touch-ui .vectura-modal .preset-save-footer.vt-sheet__footer {
    order: 0;
    flex-direction: row;
    justify-content: flex-end;
    top: auto;
    bottom: 0;
    padding: 8px 0 0;
  }
  .preset-save-footer button { min-height: 44px; min-width: 44px; padding-inline: 16px; }
  /* Children keep their size and the body scrolls (flex-shrink squeezed the mode buttons to 33px). */
  .preset-save-body { scroll-padding-bottom: 64px; }
  .preset-save-body > * { flex-shrink: 0; }
  .preset-save-input { height: 44px; font-size: 16px; }
  .preset-save-seg .seg-opt { min-height: 44px; }
  .preset-save-body select.ctrl-sel { min-height: 44px; font-size: 16px; }
  /* The Overwrite confirmation Dialog shares these buttons. */
  .vectura-dialog-footer button { min-height: 44px; min-width: 44px; }
  /* iPhone landscape with the keyboard open: only the name field, mode and actions stay. */
  .preset-save-sheet.is-kb-short .preset-save-preview,
  .preset-save-sheet.is-kb-short .preset-save-note { display: none; }
}
/* === END TUX-049 === */

/* === TUX-037: undo toast === */
/* Host placement moved out of inline styles. Default = today's desktop values. */
.vectura-toast-action {
  flex: none;
  font: inherit;
  font-weight: 600;
  color: var(--ui-accent, #4e9ee1);
  background: transparent;
  border: 1px solid var(--ui-border, #333);
  border-radius: var(--radius-sm, 4px);
  padding: 4px 12px;
  cursor: pointer;
}
.vectura-toast-action:focus-visible {
  outline: 2px solid var(--ui-accent, #4e9ee1);
  outline-offset: 2px;
}
.vectura-toast-action:disabled {
  opacity: 0.5;
  cursor: default;
}
@media (pointer: coarse) {
  .vectura-toast-action {
    min-width: 44px;
    min-height: 44px;
  }
}
/* Phone: keep the toast host below the header so header actions stay tappable. */
body.phone-layout #vectura-toast-host { top: calc(44px + var(--safe-top) + 8px); }
/* === END TUX-037 === */

/* === TUX-030: pen draft chips ===
 * The pen-draft state of the context bar (Done / Remove Last Anchor / Cancel). The phone rule above
 * hides the whole bar at <=640px; a draft still needs its controls there, so this block (later, and
 * (0,2,0) against (0,1,0)) shows it. Chips get a 44px finger target on a coarse pointer. */
@media (max-width: 640px) {
  .ctxbar.ctxbar--pen-draft { display: flex; }
}
.ctxbar-btn.ctxbar-pen-chip[aria-disabled="true"] { opacity: 0.45; }
/* The draft bar holds only the three chips: no drag grip (it never chases the selection) and no
 * overflow menu (neither is a finger-sized control, and a draft has nothing to overflow). */
.ctxbar.ctxbar--pen-draft .ctxbar-handle,
.ctxbar.ctxbar--pen-draft .ctxbar-overflow-wrap { display: none; }
.ctxbar.ctxbar--pen-draft { padding: 0; flex-wrap: wrap; justify-content: center; }
.ctxbar.ctxbar--pen-draft .ctxbar-content { flex-wrap: wrap; justify-content: center; gap: 2px; }
@media (pointer: coarse) {
  .ctxbar .ctxbar-btn.ctxbar-pen-chip {
    min-height: var(--touch-target-min, 44px);
    min-width: var(--touch-target-min, 44px);
    padding: 0 12px;
    font-size: 14px;
  }
}
/* === END TUX-030 === */

/* === TUX-031: isolation exit + arrange ===
 * The isolation back arrow is the touch equivalent of Escape. A real 44px box on a coarse pointer
 * (a ::before extender would be clipped by the viewport at the top edge). */
@media (pointer: coarse) {
  .iso-breadcrumb .iso-bc-back {
    width: var(--touch-target-min, 44px);
    height: var(--touch-target-min, 44px);
  }
  .iso-breadcrumb .iso-bc-back .iso-bc-back-svg { width: 22px; height: 22px; }
  /* Panes that overlay the viewport (portrait) must not bury the control. */
  .iso-breadcrumb {
    left: var(--iso-bc-inset-l, 0px);
    right: var(--iso-bc-inset-r, 0px);
  }
}
/* === END TUX-031 === */
/* === TUX-008: tablet drawers + closed panes ===
 * One model (src/ui/shell/pane-state.js, applied by workspace.js):
 *   touch-wide  docked, open by default, width capped at TOUCH_LAYOUT.maxDockedPaneWidth.
 *   tablet      drawer. Closed = .pane-collapsed with ZERO canvas footprint. Open = .pane-drawer-open.
 *   phone       unchanged: .auto-collapsed slivers (TUX-011 owns the sliver) and .pane-force-open.
 * Tablet rules need body.touch-ui: a fine pointer at 540-900 px keeps the old overlay panes.
 * The old rules to beat: body.mobile-layout .pane-left.pane-collapsed (0,3,1), .mobile-layout .pane (0,2,0),
 * and the unscoped .mobile-pane-handle { display: none } at the end of the legacy block. */

/* Backdrop sits above the tool rail (z 60) and the modifier bar, below the open drawer. */
body.mobile-layout .mobile-pane-backdrop {
  z-index: var(--z-backdrop);
}

/* Closed tablet pane: nothing to see, nothing to hit, no canvas lost. */
body.tablet-layout.touch-ui .pane.pane-collapsed {
  width: 0;
  min-width: 0;
  padding: 0;
  border-width: 0;
  overflow: hidden;
  visibility: hidden;
  pointer-events: none;
  box-shadow: none;
}

/* Open tablet drawer: above the backdrop. The width comes from the .mobile-layout rules. */
body.tablet-layout.touch-ui .pane.pane-drawer-open {
  z-index: var(--z-drawer);
  visibility: visible;
  pointer-events: auto;
}

/* Interim openers (TUX-010 restyles and labels them). 44 px wide, header-band tall plus a 44 px hit area, never over the
 * canvas or a tool button. Every pane control inside a closed pane is unreachable, so these are the
 * only finger path to the Generator and Layers panels on a tablet. */
body.tablet-layout.touch-ui .mobile-pane-handle-left,
body.tablet-layout.touch-ui .mobile-pane-handle-right {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  position: fixed;
  top: var(--safe-top, 0px);
  bottom: auto;
  width: 44px;
  height: var(--touch-target-min, 44px); /* the header band (Q18: 44 px on touch-ui tablets) */
  padding: 0;
  transform: none;
  writing-mode: horizontal-tb;
  font-size: 0;
  line-height: 0;
  letter-spacing: 0;
  border: 1px solid var(--ui-border-hi);
  border-radius: 10px;
  z-index: var(--z-pane-opener);
}
body.tablet-layout.touch-ui .mobile-pane-handle-left {
  left: auto;
  right: calc(100px + var(--safe-right, 0px));
}
body.tablet-layout.touch-ui .mobile-pane-handle-right {
  right: calc(52px + var(--safe-right, 0px));
}
/* A panel glyph: an outlined box with the drawer side filled. */
body.tablet-layout.touch-ui .mobile-pane-handle-left::before,
body.tablet-layout.touch-ui .mobile-pane-handle-right::before {
  content: '';
  display: block;
  width: 22px;
  height: 16px;
  box-sizing: border-box;
  border: 2px solid currentColor;
  border-radius: 3px;
}
body.tablet-layout.touch-ui .mobile-pane-handle-left::before {
  background: linear-gradient(to right, currentColor 0 38%, transparent 38%);
}
body.tablet-layout.touch-ui .mobile-pane-handle-right::before {
  background: linear-gradient(to left, currentColor 0 38%, transparent 38%);
}
/* Hit area: 44 x 45, extending past the header into the rail's top padding (no tool button there). */
body.tablet-layout.touch-ui .mobile-pane-handle-left::after,
body.tablet-layout.touch-ui .mobile-pane-handle-right::after {
  content: '';
  position: absolute;
  inset: -3px 0 -4px;
}
body.tablet-layout.touch-ui:has(#left-pane.pane-drawer-open) .mobile-pane-handle-left,
body.tablet-layout.touch-ui:has(#right-pane.pane-drawer-open) .mobile-pane-handle-right {
  color: var(--ui-accent, currentColor);
  border-color: var(--ui-accent, var(--ui-border-hi));
}

/* While a tablet drawer is open the header (menus and the two openers) stays above the backdrop, so the
 * other opener swaps drawers in one tap. The drawer starts below the header, so nothing overlaps. */
body.tablet-layout.touch-ui:has(.pane-drawer-open) #app-header {
  z-index: calc(var(--z-backdrop) + 1);
}

/* touch-wide: docked panes never exceed the cap, even when a desktop session saved 520 px.
 * --touch-wide-pane-max / --touch-wide-pane-max-right are pushed from TOUCH_LAYOUT by workspace.js; the saved
 * width is never rewritten. A collapsed pane keeps its rail width. */
body.touch-wide-layout .pane-left:not(.pane-collapsed) {
  width: min(var(--pane-left-width), var(--touch-wide-pane-max, 260px));
}
body.touch-wide-layout .pane-right:not(.pane-collapsed) {
  width: min(var(--pane-right-width), var(--touch-wide-pane-max-right, 200px));
}
/* touch-wide collapsed rail: 36 px instead of the 56 px desktop rail, and no 6 px resizer strip beside it
 * (the strip is a mouse drag handle and eats canvas). Measured on the 48-cell grid at 1210 px: rail
 * 56 -> 72.1 %, 44 -> 72.5 %, 40 -> 74.0 %, 36 -> 77.6 %. The floor is 75 %. The 28 px toggle fits the
 * rail; TUX-010 grows its hit area past the rail edge, not the rail. */
:root:has(body.touch-wide-layout) {
  --pane-collapsed-width: 36px;
}
body.touch-wide-layout:has(#left-pane.pane-collapsed) #left-resizer,
body.touch-wide-layout:has(#right-pane.pane-collapsed) #right-resizer {
  display: none;
}
/* The modifier bar (Shift/Alt/Pan latches) stays tappable while a tablet drawer is open: multi-select
   in the Layers drawer needs the Shift latch. Above the backdrop, below the drawer. */
body.tablet-layout #touch-modifier-bar {
  z-index: calc(var(--z-backdrop) + 1);
}

/* touch-wide, Layers pane capped at ~200 px (45 % canvas floor): the search field takes its own row so the
 * input stays >= 44 px wide and finger-focusable; filter and Add Layer share the row below (TUX-008 fix round 3). */
body.touch-wide-layout #right-pane .lvl-search-bar { flex-wrap: wrap; }
body.touch-wide-layout #right-pane .lvl-search-bar .lvl-search-wrap { flex: 1 0 100%; min-width: 0; }
body.touch-wide-layout #right-pane .lvl-search-bar .lvl-search-input { min-width: 0; flex: 1 1 auto; width: 100%; }
body.touch-wide-layout #right-pane .lvl-search-bar .lvl-add-wrap { flex: 1 1 0; min-width: 0; margin-left: 0; }
/* Draw Order header: the 44 px-pitch button group moves to its own row so no control passes the pane edge. */
body.touch-wide-layout #right-pane .draw-order-head { flex-wrap: wrap; row-gap: 14px; }
body.touch-wide-layout #right-pane .draw-order-head-right { flex: 1 0 100%; justify-content: space-between; gap: 0; padding: 0 4px; }
/* === END TUX-008 === */

/* === TUX-010/011: pane controls, drawers, slivers ===
 * Older rules these beat (grep before changing): :8520 .mobile-layout .pane (z 55), :8568-8619 slivers and
 * backdrop z 54, :8717-8735 backdrop, :9565-9600 unscoped .mobile-pane-handle, TUX-008 block above.
 * Visibility keys on a layout class; sizes key on body.touch-ui, so desktop and fine-pointer narrow windows keep
 * today's 24/28 px chevrons. */

/* Phone header openers: Generator and Layers. Same 44 px box as the other header buttons (TUX-001). */
body.phone-layout #app-header .header-pane-btn[aria-expanded="true"] {
  color: var(--ui-accent, currentColor);
  border-color: var(--ui-accent, var(--ui-border-hi));
}
/* An open phone drawer: the header stays above the backdrop so both openers keep working (one-tap swap). */
body.phone-layout:has(.pane.pane-force-open) #app-header {
  z-index: var(--z-phone-header);
}

/* Backdrop: a tap target for iOS Safari (cursor:pointer), above the tool rail, below the open drawer. */
body.mobile-layout .mobile-pane-backdrop {
  z-index: var(--z-backdrop);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
body.mobile-layout .pane.pane-force-open,
body.tablet-layout.touch-ui .pane.pane-drawer-open {
  z-index: var(--z-drawer);
}

/* Closed phone pane on a touch device: no 40 px sliver. Off screen, not hit-testable, not visible.
 * (transform + visibility, never display:none, so a later transition stays possible.) The header
 * buttons are the only open targets. A fine-pointer narrow window keeps its sliver. */
body.phone-layout.touch-ui.auto-collapsed .pane:not(.pane-force-open) {
  visibility: hidden;
  pointer-events: none;
  box-shadow: none;
}
body.phone-layout.touch-ui.auto-collapsed .pane-left:not(.pane-force-open) {
  transform: translateX(calc(-100% - var(--safe-left, 0px) - 2px));
}
body.phone-layout.touch-ui.auto-collapsed .pane-right:not(.pane-force-open) {
  transform: translateX(calc(100% + var(--safe-right, 0px) + 2px));
}

/* Tablet edge handles: 48 wide, header-band tall, glyph plus accessible label (aria-label). The TUX-008 ::after
 * extender gives the 45 px tall finger target. */
body.tablet-layout.touch-ui .mobile-pane-handle-left,
body.tablet-layout.touch-ui .mobile-pane-handle-right {
  box-sizing: border-box;
  width: calc(var(--touch-target-min, 44px) + 4px); /* 48: the 2 px hit probe grid reads a 44 px box as 43 */
  height: var(--touch-target-min, 44px); /* the header band is 44 px (Q18), so the box is the finger target */
  top: var(--safe-top, 0px);
  z-index: var(--z-pane-opener);
}
/* The modifier bar (Shift/Alt latches) stays tappable above the backdrop on phone and tablet; the drawer ends above it. */
body.mobile-layout #touch-modifier-bar {
  z-index: calc(var(--z-backdrop) + 1);
}
/* Header buttons never shrink below 44 px when the two pane buttons join the phone action group. */
body.phone-layout #app-header .header-phone-btn { flex: 0 0 auto; }
/* Finger target: 48 x 45. The header sits at the top edge, so the extender grows downward only (into the rail's
 * 8 px top padding, which holds no tool button). The TUX-008 inset of -3px at the top is clipped by the screen. */
body.tablet-layout.touch-ui .mobile-pane-handle-left::after,
body.tablet-layout.touch-ui .mobile-pane-handle-right::after {
  inset: 0 0 -2px; /* Q18: the box is 44 px; 2 px of slack for the 2 px hit-probe grid */
}
/* The bottom handle belongs to TUX-051 and stays hidden in every layout. */
body #btn-mobile-pane-bottom,
body.mobile-layout #btn-mobile-pane-bottom {
  display: none;
}

/* Close / collapse chevrons: 44 x 44 on every touch layout. */
body.touch-ui .pane-toggle-left,
body.touch-ui .pane-toggle-right {
  width: var(--touch-target-min, 44px);
  height: var(--touch-target-min, 44px);
}
body.touch-ui .pane-toggle-left { right: 4px; }
body.touch-ui .pane-toggle-right { left: 4px; }
body.touch-ui .pane-header-right .pane-title { margin-left: 52px; }
/* The header must be as tall as the chevron, or the pane body paints over its bottom edge. */
body.touch-ui .pane-header,
body.touch-ui #left-pane .pane-header,
body.touch-ui #right-pane .pane-header {
  height: calc(var(--touch-target-min, 44px) + 4px);
  min-height: calc(var(--touch-target-min, 44px) + 4px);
  box-sizing: border-box;
}

/* touch-wide collapsed rail (36 px, TUX-008). The button fills the rail and its ::before reaches 10 px
 * past the rail edge onto the canvas, so the finger target is 44 px wide without a wider rail (a 44 px
 * rail would push the canvas share under the 75 % floor). The glyph rotates, not the button, so the
 * extension keeps pointing at the canvas. */
body.touch-wide-layout.touch-ui .pane.pane-collapsed {
  overflow: visible;
  z-index: var(--z-pane);
}
body.touch-wide-layout.touch-ui .pane-collapsed .pane-toggle {
  width: var(--pane-collapsed-width, 36px);
  height: var(--touch-target-min, 44px);
  left: 0;
  right: 0;
  border-radius: 0;
  transform: translateY(-50%);
}
body.touch-wide-layout.touch-ui .pane-collapsed .pane-toggle::before {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
}
body.touch-wide-layout.touch-ui .pane-left.pane-collapsed .pane-toggle::before { left: 0; right: -10px; }
body.touch-wide-layout.touch-ui .pane-right.pane-collapsed .pane-toggle::before { right: 0; left: -10px; }
/* Followup B5: the collapsed header held its 44 px padding and the 52 px tab margin open, so it ran 17 px past the screen edge.
 * It is as wide as the rail now; the chevron's ::before still reaches 10 px onto the canvas for the 44 px finger target. */
body.touch-wide-layout.touch-ui .pane-collapsed .pane-header,
body.touch-wide-layout.touch-ui #right-pane.pane-collapsed .pane-header,
[data-ui-skin] body.touch-wide-layout.touch-ui #right-pane.pane-collapsed .pane-header,
body.touch-wide-layout.touch-ui[data-ui-skin] #right-pane.pane-collapsed .pane-header {
  padding-left: 0;
  padding-right: 0;
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
}
body.touch-wide-layout.touch-ui .pane-collapsed .pane-header .right-pane-tabs { display: none; }
body.touch-wide-layout.touch-ui .pane-toggle svg { transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1); }
body.touch-wide-layout.touch-ui .pane-collapsed .pane-toggle svg { transform: rotate(180deg); }
/* === END TUX-010/011 === */

/* === TUX-010: tab strip clear of the 44 px right chevron ===
 * The right pane chevron sits at left:4px and is 44 px wide (to x=48 of the pane). The tab strip used to start
 * at ~x=44, so a tap on the left edge of the first tab hit the chevron and collapsed the pane. */
/* The header padding clears the chevron (left 4 px + 44 px) and the strip starts 8 px after it. The margin used to add the
 * chevron width on top of a 44 px header padding, which left 95 px for both tabs on touch-wide: wider Linux text overflowed
 * the pane. min-width 0 lets the tabs share the strip instead of pushing it past the pane edge. */
body.touch-ui #right-pane .pane-header-right { padding-left: calc(var(--touch-target-min, 44px) + 4px); }
body.touch-ui #right-pane .right-pane-tabs {
  margin-left: 8px;
  min-width: 0;
}
/* === END TUX-010 tabs === */

/* === TUX-014: touch tool sub-menus === */
/* Menus are portaled to <body>, so selectors target .tool-submenu / .tool-sub-btn directly. */
.tool-sub-label { display: none; }

@media (pointer: coarse) {
  .tool-submenu {
    /* Above the collapsed right-pane sliver (z 55) so rows stay hittable edge to edge. */
    z-index: 60;
    flex-direction: column;
    gap: 4px;
    -webkit-touch-callout: none;
    user-select: none;
    -webkit-user-select: none;
  }
  .tool-submenu .tool-sub-btn {
    min-width: 44px;
    min-height: 44px;
    width: auto;
    height: auto;
    justify-content: flex-start;
    gap: 8px;
    padding: 0 12px;
    white-space: nowrap;
    -webkit-touch-callout: none;
    user-select: none;
    -webkit-user-select: none;
  }
  .tool-submenu .tool-sub-btn .tool-sub-label {
    display: inline;
    font-size: var(--font-size-sm, 12px);
    font-weight: 500;
    pointer-events: none;
  }
  .tool-submenu .tool-sub-btn svg { flex: none; pointer-events: none; }
  [data-ui-skin] .algo-draw-picker .algo-pick-item,
  .algo-draw-picker .algo-pick-item {
    min-height: 44px;
    -webkit-touch-callout: none;
    user-select: none;
    -webkit-user-select: none;
  }
  .tool-btn[data-has-submenu] {
    -webkit-touch-callout: none;
    user-select: none;
    -webkit-user-select: none;
  }
  .algo-draw-picker { touch-action: pan-y; }
}
/* === END TUX-014 === */

/* === TUX-020: canvas HUD ===
 * Undo / Redo / Zoom Out / Zoom In / Fit for fingers (src/render/canvas-hud.js), mounted bottom-right
 * in #viewport-container. Only under body.touch-ui; never on a fine pointer. The container ignores
 * pointers so the canvas stays reachable around it; the buttons take them. 44 px targets.
 * Phone layout: Undo / Redo live in the header (TUX-001), so only the view buttons show here.
 * Stays below the modifier column (61), panes (70) and modals (900). */
.canvas-hud { display: none; }
body.touch-ui .canvas-hud {
  display: flex;
  align-items: center;
  gap: 2px;
  position: absolute;
  right: calc(var(--safe-right, 0px) + 8px);
  bottom: calc(var(--safe-bottom, 0px) + 8px);
  padding: 2px;
  background: var(--ui-panel, #252525);
  border: 1px solid var(--ui-border, #363636);
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  z-index: 40;
  pointer-events: none;
}
.canvas-hud .canvas-hud-btn {
  pointer-events: auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  /* 46 px: the hit-area probe measures 2 px steps, so a 44 px box can read 43. */
  min-width: 46px;
  min-height: 46px;
  width: 46px;
  height: 46px;
  padding: 0;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--ui-text, #e6e6e6);
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.canvas-hud .canvas-hud-btn:active { background: var(--ui-hover, rgba(255, 255, 255, 0.12)); }
.canvas-hud .canvas-hud-btn:disabled { opacity: 0.4; }
.canvas-hud .canvas-hud-sep {
  flex: 0 0 1px;
  align-self: stretch;
  margin: 6px 2px;
  background: var(--ui-border, #363636);
}
/* Phone panes collapse to slivers that overlay the canvas edges; the HUD clears the right one. */
body.phone-layout.touch-ui .canvas-hud {
  right: calc(var(--safe-right, 0px) + var(--pane-collapsed-width, 40px) + 8px);
}
body.phone-layout .canvas-hud .canvas-hud-history,
body.phone-layout .canvas-hud .canvas-hud-sep { display: none; }
/* Batch R: phone landscape is 402 px tall, so the three view buttons are exactly 44 px with no gap (they were 46 px + 2 px gaps and
 * cost 2 points of canvas share). The 46 px size existed for the 2 px probe step; the audit still reads 44 here. */
body.phone-layout.phone-short.touch-ui .canvas-hud .canvas-hud-btn { min-width: 44px; min-height: 44px; width: 44px; height: 44px; }
body.phone-layout.phone-short.touch-ui .canvas-hud { gap: 0; padding: 0; border-radius: 10px; }
/* === END TUX-020 === */

/* === TUX-020: phone-short status strip clears the HUD ===
 * On phone landscape the status strip (#hud-bar) is an overlay at the bottom edge and reached under the
 * canvas HUD, so the zoom and rotation readouts drew inside the HUD box. The strip now ends left of the HUD:
 * HUD right offset + the HUD width token (--canvas-hud-w, 134 px) + an 8 px gap. */
body.phone-layout.phone-short .hud-bar {
  right: calc(var(--safe-right, 0px) + var(--pane-collapsed-width, 40px) + 8px + var(--canvas-hud-w, 134px) + 8px);
}
/* === END TUX-020 (strip) === */

/* === TUX-022: fill bar clears the canvas HUD ===
 * The HUD (z 40) sat on top of the fill bar (z 35) and covered the Scope chip on iPhone portrait
 * (Zoom In over Scope ▼). While the fill bar is mounted the HUD rides above it. */
body.touch-ui #viewport-container:has(.ctxbar.ctxbar--fill) .canvas-hud {
  bottom: calc(var(--safe-bottom, 0px) + 8px + 52px + 8px);
}
/* Batch R: the fill bar rides the bottom edge (context-bar.js, top = viewport height - bar - pad) and ignored the bottom
 * safe-area inset, so on iPhone landscape (21 px home-indicator band) it sat inside the band. Lift it by the inset. */
body.touch-ui .ctxbar.ctxbar--fill { margin-top: calc(-1 * var(--safe-bottom, 0px)); }
/* === Batch R: Scene3D panel finger targets (wcag258Fail 1 -> 7 on iPad portrait) ===
 * The caret (16 px wide), the visibility / delete toggles (20x20) and the add-light chips (22 px tall, 6 px apart) were under
 * the 24 px floor with no spacing exception. On a coarse pointer each gets a 24 px hit area. The toggles and chips use a
 * ::before extension, because growing their boxes pushed a section header of the scrolling panel below the fold
 * (reachable 89 -> 88 on touch-wide). 44 px is the sweep target (TUX-041 group 9). */
@media (pointer: coarse) {
  .vs3-more-caret { width: var(--touch-target-floor, 24px); }
  .vs3-tree-vis, .vs3-tree-del, .vs3-tree-addbtn { position: relative; }
  .vs3-tree-vis::before, .vs3-tree-del::before { content: ''; position: absolute; inset: -2px; }
  .vs3-tree-addbtn::before { content: ''; position: absolute; inset: -2px 0; }
}
/* === END TUX-022 === */
/* === TUX-001: narrow mouse windows (500-640 px) keep every header control on-screen === */
@media (max-width: 640px) {
  body:not(.phone-layout) #app-header .header-brand-menu h1,
  body:not(.phone-layout) #app-header .header-menu-divider { display: none; }
  body:not(.phone-layout) #app-header .header-brand-menu { gap: 4px; }
  body:not(.phone-layout) #app-header .top-menubar { gap: 0; }
  body:not(.phone-layout) #app-header .top-menu-trigger { padding-left: 6px; padding-right: 6px; }
  body:not(.phone-layout) #app-header .header-right { gap: 4px; }
}
/* === END TUX-001 === */

/* === TUX-038: value entry + reset hold + motion points ===
 * Older rules checked: .value-chip (9837, transparent button), .inline-value-input (absolute, single field),
 * .motion-drawn-canvas (5353, already touch-action:none), .menu-dropdown.is-context-menu (44 px rows on coarse).
 * Touch sizing is gated on (pointer: coarse), so the 1600 x 1000 desktop view does not change. */

/* Dual value editor (min / max) that replaces the comma-parsed field on the legacy rangeDual chip. */
/* The editor shrinks to the row it replaces the chip in (min-width 0; each input gives up width down to its
 * min-width): at a fixed 2 x 5.5em it ran 47 px past the row on a touch pane, under the pane edge with Linux fonts. */
.dual-value-editor {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
}
.dual-value-input {
  flex: 0 1 5.5em;
  width: 5.5em;
  min-width: 0;
  box-sizing: border-box;
  background: var(--ui-panel-alt);
  border: 1px solid var(--ui-border);
  color: var(--ui-text);
  font-family: inherit;
  font-size: 12px;
  padding: 2px 6px;
  text-align: right;
  border-radius: 4px;
}
.dual-value-dash { color: var(--ui-muted); }

/* Drawn-curve point buttons: shown by the rack only while a point is selected on a coarse pointer. */
.motion-point-actions { display: flex; gap: 8px; margin-top: 6px; }
.motion-point-actions[hidden] { display: none; }
.motion-point-actions button {
  border: 1px solid var(--ui-border);
  background: var(--ui-panel-alt);
  color: var(--ui-text);
  font-size: 11px;
  padding: 4px 10px;
  border-radius: 6px;
}
.motion-point-actions button:disabled { opacity: 0.4; }

@media (pointer: coarse) {
  .dual-value-input { min-height: var(--touch-target-min, 44px); font-size: 16px; } /* 16 px: no iOS focus zoom */
  .motion-point-actions button {
    min-width: var(--touch-target-min, 44px);
    min-height: var(--touch-target-min, 44px);
    flex: 1 1 0;
    font-size: 14px;
  }
  /* The reset hold target: no iOS text-selection loupe or callout on a long-press of a label. */
  .control-label,
  .mp-ctrl-lbl,
  .vtp-scrub-name,
  .vtp-field-cap label,
  [data-reset-hold] {
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
  }
}
/* === END TUX-038 === */

/* === TUX-044: reorder grips + angle dial ===
 * The grips and the dial own their finger drag: touch-action none keeps the browser from
 * panning the pane. Unscoped (0,1,0) beats the `button` rules. Hit boxes extend with a ::before
 * so the 14x20 visual stays. The extension goes left and up/down only, away from the title,
 * toggle and delete buttons. */
.noise-grip, .pen-grip, .optimization-grip, .mp-row-grip, .angle-dial { touch-action: none; }
.mp-root .mp-row-grip {
  background: transparent; border: none; padding: 2px; cursor: grab;
  display: grid; grid-template-columns: repeat(2, 4px); gap: 2px; place-content: center;
  align-self: center; justify-self: start; position: relative;
}
.mp-root .mp-row-grip .dot { width: 3px; height: 3px; border-radius: 50%; background: var(--ui-muted); }
.mp-root .mp-row-grip:active { cursor: grabbing; }
.mp-root .mp-row { grid-template-columns: auto 36px 1fr auto; }
.mp-root .mp-row.dragging { opacity: 0.6; box-shadow: 0 6px 16px rgba(0, 0, 0, 0.35); transform: scale(1.01); }
.noise-card.dragging, .image-effect-card.dragging, .optimization-card.dragging { box-shadow: 0 6px 16px rgba(0, 0, 0, 0.35); }
@media (pointer: coarse) {
  .optimization-grip, .mp-row-grip { position: relative; }
  .optimization-grip::before, .mp-root .mp-row-grip::before {
    content: ''; position: absolute; left: 50%; top: 50%;
    width: var(--touch-target-min); height: var(--touch-target-min);
    transform: translate(-50%, -50%);
  }
}
body.touch-ui .mp-root .mp-row { grid-template-columns: auto 36px minmax(0, 1fr); }
body.touch-ui .optimization-grip, body.touch-ui .mp-root .mp-row-grip { position: relative; }
body.touch-ui .optimization-grip::before, body.touch-ui .mp-root .mp-row-grip::before {
  content: ''; position: absolute; left: 50%; top: 50%;
  width: var(--touch-target-min); height: var(--touch-target-min);
  transform: translate(-50%, -50%);
}
/* === END TUX-044 === */

/* === TUX-010: toast clear of the tablet header band ===
   The tablet drawer handles sit in the top-right band. A plain toast must not cover them (req 4). */
body.tablet-layout #vectura-toast-host { top: calc(44px + var(--safe-top, 0px) + 8px); }
/* === END TUX-010 toast === */

/* === TUX-010: toast clear of the touch-wide pane chevrons ===
   The pane chevrons sit at y 40-84 in the top-right. A wrapping toast must start below them (req 4). */
body.touch-wide-layout #vectura-toast-host { top: calc(84px + var(--safe-top, 0px) + 8px); }
/* === END TUX-010 toast touch-wide === */

/* === TUX-045: touch modifier tasks (Multi-select, Constrain, Duplicate, Pan) ===
   The bar is built by ui-touch.js from Vectura.TOUCH_MODIFIERS. A button is icon + full name; on a
   phone it is icon + short label. latched = pressed for the next gesture, locked = lock glyph. */
[data-ui-skin] .touch-mod-btn,
.touch-mod-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 44px;
  min-height: 44px;
  min-width: 44px;
  text-transform: none;
  letter-spacing: 0;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
.touch-mod-btn .touch-mod-icon { display: inline-flex; flex: 0 0 auto; }
.touch-mod-btn .touch-mod-short { display: none; }
.touch-mod-btn .touch-mod-lock {
  display: none;
  position: absolute;
  top: 3px;
  right: 4px;
  line-height: 0;
  color: var(--ui-accent);
}
.touch-mod-btn[data-state="locked"] .touch-mod-lock { display: inline-flex; }
[data-ui-skin] #touch-modifier-bar .touch-mod-btn[data-state="latched"],
[data-ui-skin] #touch-modifier-bar .touch-mod-btn[data-state="locked"] {
  background: var(--ui-accent-2);
  border-color: var(--ui-accent);
  color: var(--ui-accent);
}
[data-ui-skin] #touch-modifier-bar .touch-mod-btn[data-state="locked"] {
  box-shadow: inset 0 0 0 2px var(--ui-accent);
}
/* Phone: icon over a short label. The old keyboard-glyph ::before rules no longer apply. */
body.phone-layout #touch-modifier-bar .touch-mod-btn[data-touch-mod]::before { content: none; display: none; }
body.phone-layout #touch-modifier-bar .touch-mod-btn {
  flex-direction: column;
  gap: 1px;
  font-size: 10px;
  padding: 0 2px;
}
body.phone-layout #touch-modifier-bar .touch-mod-btn .touch-mod-label { display: none; }
body.phone-layout #touch-modifier-bar .touch-mod-btn .touch-mod-short { display: block; line-height: 1; }
body.phone-layout #touch-modifier-bar .touch-mod-btn .touch-mod-icon svg { width: 18px; height: 18px; }
/* iPhone landscape: one trailing column (TUX-007 placement kept; four tasks fit one 46 px column). */
body.phone-layout.phone-short #touch-modifier-bar {
  grid-template-columns: 46px;
  row-gap: 2px;
  max-height: calc(100% - var(--tux7-rail-h) - 4px - var(--safe-bottom));
}
/* The bar is for touch-capable devices. A mouse-only narrow window hides it (beats the forced flex). */
body.mobile-layout #touch-modifier-bar.hidden,
body.phone-layout.phone-short #touch-modifier-bar.hidden,
body.tablet-layout #touch-modifier-bar.hidden { display: none; }

.touch-mod-badge {
  position: absolute;
  top: var(--touch-mod-badge-top);
  left: var(--touch-mod-badge-left);
  z-index: 40;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  max-width: calc(100% - var(--touch-mod-badge-left) - 8px - 160px);
  pointer-events: none;
}
.touch-mod-badge[hidden] { display: none; }
.touch-mod-chip {
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid var(--ui-accent);
  background: var(--ui-panel);
  color: var(--ui-accent);
  font: 600 11px/1.2 var(--font-ui);
}
.touch-mod-chip[data-state="locked"] {
  background: var(--ui-accent);
  color: var(--ui-panel);
}
/* === END TUX-045 === */

/* === TUX-045: badge placement on touch-wide ===
   The bar floats top-left of the canvas there (absolute, left 76 px). The badge sits below it, right of the rail. */
body.touch-wide-layout .touch-mod-badge {
  top: calc(var(--touch-mod-badge-top) + 82px + var(--toolbar-dock-top-h, 0px));
  left: calc(var(--touch-mod-badge-left) + 76px);
}
/* The floating touch-wide bar covers canvas: short labels keep its footprint at or below the old five-key bar. */
/* Fixed-width keys: the bar's canvas footprint must not follow text metrics (Linux renders the short labels 1-3 px
 * wider, which put the both-collapsed canvas share under its 75 % floor). 60 px holds the 20 px icon, the gap and a
 * short label up to 30 px. */
body.touch-wide-layout #touch-modifier-bar .touch-mod-btn { padding: 0 2px; gap: 4px; flex: 0 0 60px; width: 60px; min-width: 0; box-sizing: border-box; }
body.touch-wide-layout #touch-modifier-bar .touch-mod-btn .touch-mod-label { display: none; }
body.touch-wide-layout #touch-modifier-bar .touch-mod-btn .touch-mod-short { display: block; }
body.touch-wide-layout #touch-modifier-bar { padding: 4px; gap: 4px; }
/* === END TUX-045 badge === */

/* === TUX-051: bottom pane touch toggle === */
/* Coarse pointers: the collapsed bottom pane grows to 45 px (44 px + 1 px border) so the chevron is a 44 x 44 target
 * (overflow:hidden on the pane clips any ::after extension, so the box itself must be 44 px).
 * The phone-short FAB (48 x 48, body.phone-layout.phone-short) has higher specificity and is untouched. */
@media (pointer: coarse) {
  body #bottom-pane.bottom-pane-collapsed,
  body.mobile-layout #bottom-pane.bottom-pane-collapsed {
    height: calc(var(--touch-bottom-collapsed-h, 44px) + var(--safe-bottom, 0px));
    box-sizing: border-box;
    border-top-width: 0;
    padding-bottom: var(--safe-bottom, 0px);
  }
  body #bottom-pane.bottom-pane-collapsed .bottom-pane-header,
  body.mobile-layout #bottom-pane.bottom-pane-collapsed .bottom-pane-header {
    height: var(--touch-bottom-collapsed-h, 44px);
    min-height: var(--touch-bottom-collapsed-h, 44px);
  }
  body #bottom-pane.bottom-pane-collapsed .pane-toggle-bottom,
  body.mobile-layout #bottom-pane.bottom-pane-collapsed .pane-toggle-bottom {
    top: 0;
    width: var(--touch-target-min, 44px);
    height: var(--touch-target-min, 44px);
    transform: translateX(-50%) rotate(180deg);
  }
}
/* Batch R: touch-wide only (iPad landscape, wide coarse windows). The status strip sits right under the pane there; on a phone it is
 * hidden, and on iPad portrait the modifier bar (z 60) sits under the pane, so those keep the 44 px row.
 * The 44 px chevron overhangs the 40 px pane by 4 px and sits over the status strip's top edge (z above the strip's 5).
 * The pane row itself is 40 px, so the canvas keeps the share it had before TUX-051 (coarseWide 49.7 -> 47.7 with a 44 px row). */
@media (pointer: coarse) {
  body.touch-wide-layout.touch-ui #bottom-pane.bottom-pane-collapsed {
    overflow: visible;
    position: relative;
    z-index: 6;
  }
}
/* === END TUX-051 === */

/* === TUX-048: toast placement ===
 * Desktop (default) keeps the former inline look and the top-right anchor (pixel-identical).
 * body.touch-ui (TUX-006) docks the host bottom-centre, inside the safe area, above the bottom chrome
 * (toast.js sets --toast-bottom from the measured chrome) and above every modal layer (max 10001).
 * Gate = body.touch-ui only: never width, mobile-layout or (pointer: coarse) (WebKit desktop reports no touch points).
 * Beats TUX-037/TUX-010 `body.*-layout #vectura-toast-host { top }` (same specificity, later in the file). */
#vectura-toast-host {
  position: fixed;
  top: var(--toast-edge);
  right: var(--toast-edge);
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: var(--z-toast);
  pointer-events: none;
}
#vectura-toast-host .vectura-toast {
  pointer-events: auto;
  padding: 8px 14px;
  min-width: 200px;
  max-width: 320px;
  background: var(--ui-panel, #252525);
  color: var(--ui-text, #e0e0e0);
  border: 1px solid var(--ui-border, #333);
  border-left: 3px solid var(--ui-accent, #4e9ee1);
  border-radius: var(--radius-sm, 4px);
  font-family: var(--font-ui, system-ui, sans-serif);
  font-size: var(--font-size-sm, 11px);
  line-height: 1.4;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.35);
  cursor: pointer;
}
#vectura-toast-host .vectura-toast.has-action {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: default;
}
#vectura-toast-host .vectura-toast-msg { flex: 1 1 auto; }
body.touch-ui #vectura-toast-host {
  top: auto;
  right: auto;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(var(--toast-bottom, 0px) + var(--toast-chrome-gap) + var(--safe-bottom));
  width: max-content;
  max-width: calc(100% - 2 * var(--toast-edge) - var(--safe-left) - var(--safe-right));
  align-items: center;
  flex-direction: column-reverse;
}
/* At most the desktop 320 px (and never wider than the host): toast.js clears bottom chrome within 168 px of the centre
 * line, so a toast wider than 336 px could sit on a strip it did not count. With the cap the placement no longer depends
 * on how wide the text renders (a long message on Linux spanned the collapsed bottom pane on iPhone landscape). */
body.touch-ui #vectura-toast-host .vectura-toast {
  max-width: min(100%, 320px);
  min-width: 0;
}
body.touch-ui #vectura-toast-host .vectura-toast:not(.is-actionable) { pointer-events: none; }
/* === END TUX-048 === */

/* Start Page: the header (rail toggle, settings, motion, theme) lives at the top right, exactly where toasts anchor.
 * While the page is open toasts dock bottom-right instead, so they never cover those controls and the pointer
 * that just clicked one is not parked on the toast (hover pauses its auto-dismiss). Touch already docks at the bottom. */
html[data-start-page="open"] body:not(.touch-ui) #vectura-toast-host {
  top: auto;
  bottom: var(--toast-edge);
  right: var(--toast-edge);
  flex-direction: column-reverse;
}

/* === TUX-052 === Help Touch page: stack the gesture rows on narrow screens */
@media (max-width: 700px) {
  .help-panel[data-panel="touch"] .help-kbd-table,
  .help-panel[data-panel="touch"] .help-kbd-table tbody { display: block; }
  .help-panel[data-panel="touch"] .help-row {
    display: grid;
    grid-template-columns: 1fr;
    gap: 2px;
    padding: 8px 0;
    border-bottom: 1px solid var(--help-border, rgba(255, 255, 255, 0.08));
  }
  .help-panel[data-panel="touch"] .help-row td { display: block; width: auto; text-align: left; padding: 0; white-space: normal; }
}

/* === TUX-052b === Help tab/platform buttons meet the 44px touch target */
body.touch-ui .help-tab-btn,
body.touch-ui .help-platform-btn {
  min-height: 44px;
  min-width: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
/* === END TUX-052b === */
/* === TUX-041 / TUX-043: draw-order head clears the 44 px slider (integration fix) ===
 * TUX-041 gives the 18 px eye and gear icons a 44 px ::before (13 px past the icon on each side);
 * TUX-043 makes the draw-order slider a 44 px band. With the 5 px head margin the icon hit boxes
 * covered the top 7 px of the slider, and the gear box (centre 21 px from the pane edge) was clipped
 * to 43 px. The margin applies on every touch layout (touch-wide wraps the head but kept the 5 px margin);
 * the 4 px inset only off touch-wide, which has its own. Short viewports (max-height: 520px) set the head
 * margin to 0 above; this later rule (higher specificity) restores the clearance. */
@media (pointer: coarse) {
  body.touch-ui #right-pane .draw-order-bar .draw-order-head { margin-bottom: 14px; }
  body.touch-ui:not(.touch-wide-layout) #right-pane .draw-order-head-right { padding-right: 4px; }
  /* Four head icons (Play, eye, palette, gear) need 4 x 44 px of hit area, more than the head row has
   * beside the label (the row overflowed: label wrapped, outer ::before clipped to 36-43 px).
   * Touch layouts other than touch-wide keep the head ONE row (a second row cost the layer list the
   * height TUX-033 @needs-tall-pane relies on): the label is visually hidden (screen readers still
   * read it) and the readout + four icons spread across the row. The 4 px side inset keeps the outer
   * ::before inside the pane. */
  body.touch-ui:not(.touch-wide-layout) #right-pane .draw-order-label {
    position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
  }
  body.touch-ui:not(.touch-wide-layout) #right-pane .draw-order-head-right { flex: 1 1 auto; justify-content: space-between; gap: 0; padding: 0 4px; }
  /* touch-wide-layout already wrapped the head into two rows (its pane can be 200 px wide, too narrow for
   * a readout plus four 44 px icons): the label and the % readout share the top row and the four icons
   * spread across the row below. `display: contents` lifts the readout and icons into the head's flex
   * line; the head-right ::before is a zero-height full-width line break whose 14 px height is the gap. */
  body.touch-ui.touch-wide-layout #right-pane .draw-order-head { flex-wrap: wrap; justify-content: space-between; row-gap: 0; padding: 0 4px; }
  body.touch-ui.touch-wide-layout #right-pane .draw-order-head-right { display: contents; }
  body.touch-ui.touch-wide-layout #right-pane .draw-order-head-right::before { content: ''; order: 2; flex: 0 0 100%; height: 14px; }
  body.touch-ui.touch-wide-layout #right-pane .draw-order-label { order: 0; white-space: nowrap; }
  body.touch-ui.touch-wide-layout #right-pane .draw-order-value { order: 1; }
  body.touch-ui.touch-wide-layout #right-pane .draw-order-head-right > button { order: 3; }
}
/* Short coarse viewports (landscape phones) cannot afford a second row above the 44 px slider band (it
 * was clipped to 40 px), even in touch-wide-layout: one row, label visually hidden, no line break. */
@media (pointer: coarse) and (max-height: 520px) {
  body.touch-ui.touch-wide-layout #right-pane .draw-order-head { flex-wrap: nowrap; }
  body.touch-ui.touch-wide-layout #right-pane .draw-order-head-right::before { display: none; }
  body.touch-ui.touch-wide-layout #right-pane .draw-order-label {
    position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
  }
}
/* === END TUX-041 / TUX-043 draw-order head === */

/* === TUX-020 / TUX-030: pen draft bar clears the canvas HUD (integration fix) ===
 * The pen-draft context bar (Done / Remove Last Anchor / Cancel, 46 px tall at bottom 4 px) is centred
 * and ran under the bottom-right HUD (z 40): Cancel resolved to the HUD history or view buttons on
 * iPad landscape, iPhone portrait and touch-coarse-wide. Same treatment as the TUX-022 fill bar: while
 * the draft bar is mounted the HUD rides above it. */
body.touch-ui #viewport-container:has(.ctxbar.ctxbar--pen-draft) .canvas-hud {
  bottom: calc(var(--safe-bottom, 0px) + 8px + 52px + 8px);
}
/* === END TUX-020 / TUX-030 === */

/* === TUX-045 / TUX-020: very short phone landscape keeps two modifier columns (integration fix) ===
 * TUX-045 moved the iPhone-landscape modifier bar to one 46 px column (4 x 44 px + gaps = about 188 px).
 * At 874 x 330 (Safari with browser chrome) that column ran down into the bottom-right canvas HUD
 * (Fit hit area 33 px, HUD overlapped the bar). TUX-007 sized this layout as two columns for that reason.
 * Below 361 px tall the four tasks sit in a 2 x 2 grid (about 96 px tall), clear of the HUD. */
@media (max-height: 360px) {
  body.phone-layout.phone-short #touch-modifier-bar { grid-template-columns: repeat(2, 46px); column-gap: 2px; }
}
/* === END TUX-045 / TUX-020 === */

/* === TUX-008 / TUX-011: WebKit drawer content restyle (integration fix) ===
 * A closed tablet pane is `visibility: hidden` (TUX-011) and its content inherits that. When the drawer
 * opens, WebKit does not always re-resolve the inherited value on children whose style was computed while
 * the pane was hidden (for example the Generator sections rebuilt after a layer load): getComputedStyle
 * keeps `hidden` on `.left-panel-sections` and most `.left-panel-section` rows of an open drawer. This
 * rule names the open drawer's direct body children, so the class change re-resolves them. Grandchildren
 * then inherit `visible`. No direct `.pane-body` child relies on `visibility: hidden` (they use display). */
body.tablet-layout.touch-ui .pane.pane-drawer-open .pane-body > * { visibility: visible; }
/* === END TUX-008 / TUX-011 WebKit drawer content restyle === */

/* === TUX-020 / TUX-011: the canvas HUD steps aside under a drawer backdrop or a modal (integration fix) ===
 * Under the open-drawer backdrop (TUX-011) or a modal the HUD buttons cannot take a tap (the backdrop
 * or the modal does; history is a no-op under a modal), so they must not show as live controls there.
 * visibility (not display) keeps the HUD's box, so nothing reflows when it returns. */
body.touch-ui:not(.tablet-layout):has(#mobile-pane-backdrop.visible) .canvas-hud,
body.touch-ui:has(#modal-overlay.open) .canvas-hud,
body.touch-ui:has(.vectura-modal-backdrop[style*="flex"]) .canvas-hud {
  visibility: hidden;
}
body.touch-ui:not(.tablet-layout):has(#mobile-pane-backdrop.visible) .canvas-hud .canvas-hud-btn,
body.touch-ui:has(#modal-overlay.open) .canvas-hud .canvas-hud-btn,
body.touch-ui:has(.vectura-modal-backdrop[style*="flex"]) .canvas-hud .canvas-hud-btn {
  pointer-events: none;
}
/* Batch R: canvas-hud.js marks a button another layer covers at its centre (Petal Designer window, formula sheet). */
.canvas-hud .canvas-hud-btn[data-covered] { visibility: hidden; pointer-events: none; transition: none; }
/* Tablet (no header Undo): the HUD stays reachable under an open drawer (batch 1, journey J12). It rides above the
 * backdrop (the modifier bar does the same) and hops to the left edge when the right drawer would cover it. A
 * modal still hides it (rule above). */
body.tablet-layout.touch-ui:has(#mobile-pane-backdrop.visible) .canvas-hud {
  z-index: calc(var(--z-backdrop) + 1);
}
body.tablet-layout.touch-ui:has(#right-pane.pane-drawer-open) .canvas-hud {
  right: auto;
  left: calc(var(--safe-left, 0px) + 8px);
}
/* Batch R: phone sheets (the Document Setup panel, a #modal-overlay card) fill the screen inside the safe area. The HUD and
 * the header action buttons under them are covered and cannot take a tap, so they step aside the same way. The header band
 * keeps its box (visibility), so nothing reflows when the sheet closes. */
body.phone-layout.touch-ui:has(#settings-panel.open) .canvas-hud,
body.phone-layout.touch-ui:has(#settings-panel.open) .canvas-hud .canvas-hud-btn {
  visibility: hidden;
  pointer-events: none;
}
body.phone-layout.touch-ui:has(#modal-overlay.open) #app-header button,
body.phone-layout.touch-ui:has(#settings-panel.open) #app-header button {
  visibility: hidden;
}
/* === END TUX-020 / TUX-011 HUD step-aside === */

/* === TUX-012: the touch row menu shows the full layer name (Jay, 2026-10-12) ===
 * The header wraps instead of truncating, so a long name stays readable in full. */
.lvl-ctx-menu.is-touch .menu-cat {
  white-space: normal;
  overflow-wrap: anywhere;
  max-width: min(320px, calc(100vw - 24px));
  text-transform: none;
}
/* === END TUX-012 === */

/* === TUX-058 batch 3: text panel specimen head and docked-pane safe band ===
 * The specimen header toggle and the outline pill were 14-21 px tall (WCAG 2.5.8 fail on iPad portrait). They keep their look and
 * take a 44 px hit area through ::before (TUX-041 req 3). On a docked iPad landscape pane the pane reaches the screen edge, so its bottom band
 * (the home-indicator strip) holds content that an unprotected select straddled: the pane now pads by the inset. */
body.touch-ui .vtp-spec-head-btn,
body.touch-ui .vtp-spec-pill-head { position: relative; }
body.touch-ui .vtp-spec-head-btn::before,
body.touch-ui .vtp-spec-pill-head::before {
  content: ''; position: absolute; left: -4px; right: -4px; top: 50%; height: var(--touch-target-min); transform: translateY(-50%);
}
@media (pointer: coarse) {
  body.touch-wide-layout #left-pane,
  body.touch-wide-layout #right-pane { padding-bottom: var(--safe-bottom, 0px); }
}
/* === END TUX-058 batch 3 === */

/* === TUX-058 batch R3 (Q17): iPad landscape canvas share ===
 * With both panes collapsed the bottom stack took 73 px of the canvas (6 px #bottom-resizer, 40 px collapsed formula row, 27 px status
 * strip), which left the canvas at 73.6 % against the 75 % of section 1.5. On touch-wide the status strip becomes a non-interactive
 * overlay on the bottom edge of the canvas (as on phone landscape): it keeps the hints and the readouts, takes no row, and has a
 * translucent background so the text stays legible over the paper. It sits right after the viewport in the flex column (order 1; the
 * resizer and the pane move to order 2) and pulls itself up by its own height. Nothing in the strip is interactive (hint text and
 * three readouts). The resizer has no use while the bottom pane is collapsed, so touch-ui hides it then. */
body.touch-wide-layout.touch-ui .hud-bar {
  order: 1;
  position: relative;
  box-sizing: border-box;
  height: 18px; /* Q18 (Jay, 2026-10-14): 18 px, was 22 px */
  min-height: 0;
  margin-top: -18px;
  /* ends left of the canvas HUD (251 px wide, 8 px from the canvas edge) */
  margin-right: calc(var(--safe-right, 0px) + 8px + var(--canvas-hud-w-wide, 251px) + 8px);
  padding: 1px 12px;
  border-top: 0;
  background: color-mix(in srgb, var(--ui-panel) 78%, transparent);
  pointer-events: none;
  z-index: 5;
}
body.touch-wide-layout.touch-ui #bottom-resizer,
body.touch-wide-layout.touch-ui #bottom-pane { order: 2; }
body.touch-ui #bottom-resizer:has(+ #bottom-pane.bottom-pane-collapsed) { display: none; }
/* === END TUX-058 batch R3 === */

/* === TUX-058 batch R3b (Q17): honest iPad landscape canvas share ===
 * The overlay strip is 78 % opaque, so the artwork under it is mostly hidden and the audit now counts that band as not canvas
 * (both collapsed: 76.9 % -> 74.5 %). To get back to 75 % the touch-wide collapsed formula row is 40 px (the 44 px token stays for
 * iPad portrait and phones). The 44 px chevron overhangs the row by 4 px upward, into the pointer-events:none strip, so its hit
 * area stays 44 px and the strip loses nothing (it is not interactive). The strip is 22 px (was 26): its 11 px text still fits. */
@media (pointer: coarse) {
  body.touch-wide-layout.touch-ui #bottom-pane.bottom-pane-collapsed {
    height: calc(var(--touch-wide-bottom-collapsed-h, 36px) + var(--safe-bottom, 0px));
  }
  body.touch-wide-layout.touch-ui #bottom-pane.bottom-pane-collapsed .bottom-pane-header {
    height: var(--touch-wide-bottom-collapsed-h, 36px);
    min-height: var(--touch-wide-bottom-collapsed-h, 36px);
  }
  body.touch-wide-layout.touch-ui #bottom-pane.bottom-pane-collapsed .pane-toggle-bottom {
    top: calc(var(--touch-wide-bottom-collapsed-h, 36px) - var(--touch-target-min, 44px));
  }
}
/* Q18 (Jay, 2026-10-14) supersedes the numbers above: the header grows 38 -> 44 px, so the collapsed formula row is 36 px (the
 * 44 px chevron overhangs it by 8 px into the strip) and the status strip is 18 px. Touch-wide only. */
/* === END TUX-058 batch R3b === */

/* === TUX-041 slice B1: header ===
 * Q18 (Jay, 2026-10-14): the tablet and touch-wide header band is 44 px (phones already are). Every header control and every
 * header menu item has a 44 x 44 hit area on touch. The triggers and the theme toggle keep their 26 px pill: an invisible ::before
 * (the accent underline already owns ::after) widens the hit area to the token. The triggers touch side by side, so the
 * expansion is vertical only. The theme toggle's 44 px box ends 3 px clear of the pane opener beside it.
 * Gate: body.touch-ui (the pointer: coarse signal) and not a phone. Desktop keeps the 38 px header. */
body.touch-ui:not(.phone-layout) #app-header {
  height: calc(var(--touch-target-min) + var(--safe-top));
}
body.touch-ui:not(.phone-layout) #app-header .header-main {
  height: var(--touch-target-min);
  min-height: var(--touch-target-min);
}
body.touch-ui:not(.phone-layout) #top-menubar .top-menu-trigger {
  position: relative;
}
body.touch-ui:not(.phone-layout) #top-menubar .top-menu-trigger::before {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  height: var(--touch-target-min);
  transform: translateY(-50%);
}
body.touch-ui:not(.phone-layout) #app-header .theme-toggle {
  position: relative;
}
body.touch-ui:not(.phone-layout) #app-header .theme-toggle::before {
  content: '';
  position: absolute;
  left: 50%;
  top: 50%;
  width: var(--touch-target-min);
  height: var(--touch-target-min);
  transform: translate(-50%, -50%);
}
/* The panel hangs from the bottom of the (26 px) trigger: 9 px puts its top edge on the 44 px header band's bottom edge. */
body.touch-ui:not(.phone-layout) #top-menubar .top-menu-panel {
  top: calc(100% + 9px);
  max-height: calc(var(--app-vh) - var(--touch-target-min) - var(--safe-top) - var(--safe-bottom) - 8px);
  overflow-y: auto;
  overscroll-behavior: contain;
}
body.touch-ui:not(.phone-layout) #top-menubar .top-menu-item {
  min-height: var(--touch-target-min);
  box-sizing: border-box;
}
/* Welcome pane CTA: the gradient wrap follows the button (1 px ring). The wrap is not a control, so it keeps the default cursor. */
@media (pointer: coarse) {
  [data-ui-skin] .welcome-tour-btn-wrap { cursor: auto; }
  [data-ui-skin] .welcome-tour-btn {
    min-height: var(--touch-target-min);
    box-sizing: border-box;
    justify-content: center;
  }
}
/* === END TUX-041 slice B1 === */

/* === TUX-041 slice B2: canvas context bar ===
 * Q19 (Jay, 2026-10-14): on touch the context bar grows to 52 px (44 px controls, 3 px padding, 1 px border) so every
 * control inside has a real 44 x 44 box. No ::before expansion is used: the controls sit side by side with 2 px gaps and
 * the bar floats over the canvas, so an invisible extension would steal pixels from neighbours or the canvas.
 * Text-entry controls are 16 px so iOS does not zoom on focus. Gate: body.touch-ui (the pointer: coarse signal).
 * Desktop keeps the 26 px controls. */
body.touch-ui .ctxbar-content { min-height: var(--touch-target-min); }
body.touch-ui .ctxbar .ctxbar-btn,
body.touch-ui .ctxbar .ctxbar-text-field,
body.touch-ui .ctxbar .ctxbar-text-size,
body.touch-ui .ctxbar .ctxbar-stepper,
body.touch-ui .ctxbar .ctxbar-overflow,
body.touch-ui .ctxbar .ctxbar-auto-smooth,
body.touch-ui .ctxbar .ctxbar-submode-exit,
body.touch-ui .ctxbar .ctxbar-field {
  box-sizing: border-box;
  min-height: var(--touch-target-min);
  height: var(--touch-target-min);
}
body.touch-ui .ctxbar .ctxbar-btn,
body.touch-ui .ctxbar .ctxbar-stepper,
body.touch-ui .ctxbar .ctxbar-overflow,
body.touch-ui .ctxbar .ctxbar-text-size-caret {
  min-width: var(--touch-target-min);
  justify-content: center;
}
body.touch-ui .ctxbar .ctxbar-text-size,
body.touch-ui .ctxbar .ctxbar-field { font-size: 16px; }
body.touch-ui .ctxbar .ctxbar-text-size-caret {
  box-sizing: border-box;
  min-height: var(--touch-target-min);
}
body.touch-ui .ctxbar .pen-chip {
  box-sizing: border-box;
  width: var(--touch-target-min);
  height: var(--touch-target-min);
}
body.touch-ui .ctxbar .ctxbar-slider { min-height: var(--touch-target-min); }
/* The More menu has six 44 px rows: on a short phone landscape it scrolls instead of running off the screen. */
body.touch-ui .ctxbar .ctxbar-menu {
  /* Folds the bar's published --ctxbar-menu-space clamp into the cap (a bare 60 % rule outranked it and let the menu run
     off a 330 px screen). */
  max-height: min(calc(var(--app-vh) * 0.6), var(--ctxbar-menu-space, var(--app-vh)));
  overflow-y: auto;
  overscroll-behavior: contain;
}
body.touch-ui .ctxbar .ctxbar-menu-item,
body.touch-ui .ctxbar .ctxbar-add-layer-item {
  box-sizing: border-box;
  min-height: var(--touch-target-min);
}
/* === END TUX-041 slice B2 === */

/* === TUX-041 slice B2b: touch-wide context bar is 44 px tall (Q19b) ===
 * Q19 allows UP TO 52 px. On touch-wide (iPad landscape, both panes collapsed) the 52 px bar left only 74.7 % honest canvas
 * share against the 75 % gate (TUX-008, TUX-010). Here the bar drops its 3 px vertical padding and its 1 px border, so the 44 px
 * controls fill it edge to edge (44 px tall). The border becomes a 1 px ring drawn with box-shadow, which takes no layout
 * space. Every control keeps its 44 x 44 box; gaps between controls stay 2 px, so no hit areas touch or overlap.
 * Other layouts (iPad portrait, phones, desktop) keep the 52 px bar. */
body.touch-wide-layout.touch-ui .ctxbar {
  padding: 0 2px;
  border-width: 0;
  box-shadow: 0 0 0 1px var(--ui-border, #363636), 0 6px 20px rgba(0, 0, 0, 0.30);
}
/* === END TUX-041 slice B2b === */

/* === TUX-012 follow-up: scroll cue on the context bar More menu ===
 * data-scroll-cue (utils.scrollCue, bound when the menu opens) lists the edges that still hide rows. The fades are sticky,
 * take no taps, and show nothing when the menu fits. */
.ctxbar-menu::before, .ctxbar-menu::after {
  content: ''; display: block; position: sticky; flex: none; height: 28px; pointer-events: none; z-index: 2;
  opacity: 0; transition: opacity 120ms ease;
}
.ctxbar-menu::before { top: 0; margin-bottom: -28px; background: linear-gradient(to bottom, var(--ui-panel) 15%, transparent); }
.ctxbar-menu::after { bottom: 0; margin-top: -28px; background: linear-gradient(to top, var(--ui-panel) 15%, transparent); }
.ctxbar-menu[data-scroll-cue~="above"]::before,
.ctxbar-menu[data-scroll-cue~="below"]::after { opacity: 1; }
/* === END TUX-012 follow-up === */

/* === TUX-041 slice B4: side panels ===
 * Every interactive target in the left pane (generator params, transform, fill controls, text panel, mirror modifier), the right
 * pane (pens, layers) and the bottom pane has a hit area of at least --touch-target-min on coarse pointers. Boxes that can grow get a
 * real min-height; the small visuals (switches, info dots) keep their size and take a centred ::before. Rules are keyed on
 * body.touch-ui (a coarse pointer), never on width, and carry a pane id so they beat the skin's [data-ui-skin] #id rules.
 * Desktop is unchanged. Scene3D and the Petal Designer are slice B5. */
/* Every other button, summary and text field in the left pane (algorithm sections, add/delete rows, tool strips, lock dots, pop-out
 * buttons) is at least a finger in both axes. Scene3D and the Petal Designer (slice B5) and the visuals that carry their own
 * ::before extension are left out. */
body.touch-ui #left-pane :is(button, summary, [role="button"], input:is([type="text"], [type="number"], [type="search"], :not([type]))):not(
  .info-btn, .mp-info-trigger, .noise-grip, .vtp-sw-toggle, .sr-only, .pane-toggle, :is(.vs3-panel, [class*="petal-"]) *) {
  min-height: var(--touch-target-min);
  min-width: var(--touch-target-min);
  box-sizing: border-box;
}
/* Right pane: the same finger-tall floor for the pens tab (palette list, auto-colourisation fields) and the layer search/filter. Layer
 * rows keep their own sizing (they pass already). The small switch, the info dot and the raw checkbox keep their visual and take a
 * centred 44 px ::before; the row that holds one is a finger tall, so the extension never reaches the row above or below. */
body.touch-ui #right-pane :is(button, summary, [role="button"], input:is([type="text"], [type="number"], [type="search"], :not([type]))):not(
  .info-btn, .sw-toggle, .sr-only, .draw-order-settings, .draw-order-overlay-toggle, .pen-remove, .pane-toggle, #layer-list *) {
  min-height: var(--touch-target-min);
  min-width: var(--touch-target-min);
  box-sizing: border-box;
}
body.touch-ui #right-pane select:not(.sr-only) { height: var(--touch-target-min); box-sizing: border-box; }
body.touch-ui #right-pane :is(.info-btn, .sw-toggle, input[type="checkbox"]:not(.sr-only)) { position: relative; }
body.touch-ui #right-pane :is(.info-btn, .sw-toggle, input[type="checkbox"]:not(.sr-only))::before {
  content: ''; position: absolute; left: 50%; top: 50%;
  width: var(--touch-target-min); height: var(--touch-target-min); transform: translate(-50%, -50%);
}
body.touch-ui #right-pane :is(.flex, .control-label, .ctrl-row):has(> :is(.sw-toggle, .info-btn, input[type="checkbox"])) { min-height: var(--touch-target-min); }
/* A docked iPad pane (200 px) makes a pen card 153 px wide (129 px of content): swatch, value and remove take it all and squeeze the
 * weight slider to 14 px. Under 150 px of content the slider moves to its own row. Wider cards (187 px of content and up) keep one row. */
body.touch-ui #right-pane .pen-item { container-type: inline-size; container-name: pen-item; }
@container pen-item (max-width: 150px) {
  body.touch-ui #right-pane .pen-item .pen-row-b { flex-wrap: wrap; }
  body.touch-ui #right-pane .pen-item .pen-width { order: 7; flex: 1 1 100%; margin: 0; }
}
/* TUX-042 (batch G): in the 200 px pane the grip (44) and remove (44) leave the name 41 px, and 16 px text needs about 90.
 * Narrow cards give the name its own full line above [grip][remove]. */
@container pen-item (max-width: 150px) {
  body.touch-ui #right-pane [data-ui-skin] .pen-item .pen-name-input,
  body.touch-ui #right-pane .pen-item .pen-name-input { order: 0; flex: 1 1 100%; }
}
/* The plotter heads, the plot-range row and the motion rack head seat an info dot (44 px ::before, 14 px past its edge) beside a 44 px
 * button or slider: 16 px keeps their hit areas apart. */
body.touch-ui #left-pane :is(.harmonograph-plotter-head, .harmonograph-plotter-row) { gap: 18px; }
body.touch-ui #left-pane .harmonograph-plotter-head > * { flex-shrink: 0; }
body.touch-ui #left-pane .harmonograph-plotter-head { padding-right: 16px; } /* keeps the last info dot's 44 px reach inside the pane */
/* Pendulum card header (title, trace, Active switch, delete) and the 7 alignment buttons wrap instead of running off the pane. */
body.touch-ui #left-pane :is(.pendulum-header, .pendulum-actions) { flex-wrap: wrap; }
body.touch-ui .vtp-panel .vtp-align7 { flex-wrap: wrap; }
body.touch-ui #left-pane .harmonograph-plotter-head { flex-wrap: wrap; }
/* Pens tab: section headers, palette picker, Add. */
body.touch-ui #right-pane :is(#pens-section-header, #auto-colorization-header) { min-height: var(--touch-target-min); box-sizing: border-box; }
body.touch-ui #right-pane :is(#palette-toggle, #btn-add-pen) { height: var(--touch-target-min); min-width: var(--touch-target-min); box-sizing: border-box; }
/* Left pane buttons that sat at 24-36 px. */
body.touch-ui #left-pane :is(#btn-randomize-params, #paint-bucket-expand-btn, #dynamic-controls .mb-4.grid > button) { min-height: var(--touch-target-min); box-sizing: border-box; }
body.touch-ui #transform-bbox-controls .tk-flip-btn { height: var(--touch-target-min); }
body.touch-ui #transform-bbox-controls .tk-link-btn { width: var(--touch-target-min); height: var(--touch-target-min); }
/* Fill type grid: whole-finger cells, wrapping to more rows (5 across in a 290 px pane). */
body.touch-ui .paint-bucket-variant-grid { grid-template-columns: repeat(auto-fill, minmax(var(--touch-target-min), 1fr)); }
body.touch-ui .pb-variant-btn { height: var(--touch-target-min); min-width: var(--touch-target-min); }
/* Generator picker rows (the shared .lvl-algo-sub-item stays 34 px in the context bar fly-outs). */
body.touch-ui #gm-module-menu .lvl-algo-sub-item { min-height: var(--touch-target-min); box-sizing: border-box; }
/* The formula pane header is a finger tall when the pane is open (the pane height is fixed, so the canvas share does not change). */
body.touch-ui #bottom-pane:not(.bottom-pane-collapsed) .bottom-pane-header { height: var(--touch-target-min); min-height: var(--touch-target-min); }
body.touch-ui #bottom-pane:not(.bottom-pane-collapsed) .pane-toggle-bottom { width: var(--touch-target-min); height: var(--touch-target-min); }
/* Text panel. Fields take a whole row (a half row cannot seat a 44 px handle, the value and a 44 px preset chevron). */
body.touch-ui .vtp-panel .vtp-grid2 { grid-template-columns: 1fr; }
body.touch-ui .vtp-panel .vtp-spec-head { min-height: var(--touch-target-min); box-sizing: border-box; }
body.touch-ui .vtp-panel :is(.vtp-spec-head-btn, .vtp-spec-pill-head, .vtp-fontpick-trigger, .vtp-vselect, .vtp-ot-btn, .vtp-seg-ctrl button) {
  min-height: var(--touch-target-min); box-sizing: border-box;
}
body.touch-ui .vtp-panel .vtp-vselect { height: var(--touch-target-min); }
body.touch-ui .vtp-panel .vtp-glyph-btn { width: var(--touch-target-min); height: var(--touch-target-min); }
body.touch-ui .vtp-panel .vtp-align7 .vtp-glyph-btn { width: auto; flex: 1 0 var(--touch-target-min); min-width: var(--touch-target-min); }
body.touch-ui .vtp-panel .vtp-scrub { height: calc(var(--touch-target-min) + 2px); } /* + the 1 px border, so the inside is 44 */
body.touch-ui .vtp-panel .vtp-scrub-handle { min-width: var(--touch-target-min); box-sizing: border-box; justify-content: center; }
body.touch-ui .vtp-panel .vtp-scrub input { font-size: 16px; }
/* The stepper pair lies side by side: two stacked 44 px buttons would make the field 88 px tall. */
body.touch-ui .vtp-panel .vtp-scrub-steppers { flex-direction: row; width: auto; }
body.touch-ui .vtp-panel .vtp-scrub-steppers button { min-width: var(--touch-target-min); }
body.touch-ui .vtp-panel .vtp-scrub-steppers button:first-child { border-bottom: 0; border-right: 1px solid var(--ui-border); }
body.touch-ui .vtp-panel .vtp-scrub-preset { min-width: var(--touch-target-min); }
body.touch-ui .vtp-panel .vtp-row-toggle { min-height: var(--touch-target-min); }
body.touch-ui .vtp-panel .vtp-sw-toggle::before {
  content: ''; position: absolute; left: 50%; top: 50%;
  width: var(--touch-target-min); height: var(--touch-target-min); transform: translate(-50%, -50%);
}
/* Align / Distribute (multi-selection): three buttons a row (seven 44 px columns do not fit), the spacers drop out, and the spacing field
 * takes the row under the two spacing buttons and the slider. */
body.touch-ui #left-pane .align-panel-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
body.touch-ui #left-pane .align-panel-spacer { display: none; }
body.touch-ui #left-pane :is(.align-btn, .align-target-btn) { height: var(--touch-target-min); }
body.touch-ui #left-pane .align-panel-spacing { display: grid; grid-template-columns: var(--touch-target-min) var(--touch-target-min) minmax(0, 1fr); }
body.touch-ui #left-pane .align-panel-spacing > #align-spacing-chip { grid-column: 1 / -1; width: 100%; max-width: none; }
/* The shared floating menu (layer filter, row menus) has finger-tall entries and scrolls when it is taller than the screen. */
body.touch-ui .menu-dropdown .menu-entry { min-height: var(--touch-target-min); box-sizing: border-box; }
body.touch-ui .menu-dropdown {
  max-height: calc(var(--app-vh) - var(--safe-top, 0px) - var(--safe-bottom, 0px) - 16px);
  overflow-y: auto; overscroll-behavior: contain;
}
/* Pathfinder: buttons wrap to as many 60 px cells as fit (six 44 px columns do not fit a 200 px docked pane). */
body.touch-ui #left-pane :is(.pathfinder-panel-grid-shape-modes, .pathfinder-panel-grid-pathfinders) { grid-template-columns: repeat(auto-fill, minmax(60px, 1fr)); }
body.touch-ui #left-pane .pathfinder-panel-shape-modes { flex-wrap: wrap; }
body.touch-ui #left-pane :is(.pf-btn, .pf-mode-btn, .pf-expand-btn) { height: var(--touch-target-min); }
/* Mirror modifier panel. */
body.touch-ui .mp-root :is(.mp-stack-add, .mp-change-cta, .mp-side-tile) { min-height: var(--touch-target-min); box-sizing: border-box; }
body.touch-ui .mp-root .mp-change-cta { height: var(--touch-target-min); }
body.touch-ui .mp-root .mp-row { grid-template-columns: var(--touch-target-min) 1fr auto; }
body.touch-ui .mp-root .mp-row-thumb { width: var(--touch-target-min); height: var(--touch-target-min); aspect-ratio: auto; }
body.touch-ui .mp-root .mp-ctrl-row-2 { grid-template-columns: 1fr; }
body.touch-ui .mp-root .mp-info-trigger { position: relative; }
body.touch-ui .mp-root .mp-info-trigger::before {
  content: ''; position: absolute; left: 50%; top: 50%;
  width: var(--touch-target-min); height: var(--touch-target-min); transform: translate(-50%, -50%);
}
body.touch-ui .mp-root .mp-ctrl-lbl:has(> .mp-info-trigger) { min-height: var(--touch-target-min); }
/* === END TUX-041 slice B4 === */

/* === TUX-046 follow-up: scroll cue on long modals ===
 * data-scroll-cue (utils.scrollCue) lists the edges that still hide controls in the Export settings column and the Document Setup
 * form. The fades are sticky, take no taps, and show nothing when everything fits. Touch only. */
body.touch-ui :is(.export-settings-scroll, .settings-panel-body)::before,
body.touch-ui :is(.export-settings-scroll, .settings-panel-body)::after {
  content: ''; display: block; position: sticky; flex: none; height: 28px; pointer-events: none; z-index: 3;
  opacity: 0; transition: opacity 120ms ease;
}
body.touch-ui :is(.export-settings-scroll, .settings-panel-body)::before { top: 0; margin-bottom: -28px; background: linear-gradient(to bottom, var(--ui-panel) 15%, transparent); }
body.touch-ui :is(.export-settings-scroll, .settings-panel-body)::after { bottom: 0; margin-top: -28px; background: linear-gradient(to top, var(--ui-panel) 15%, transparent); }
body.touch-ui :is(.export-settings-scroll, .settings-panel-body)[data-scroll-cue~="above"]::before,
body.touch-ui :is(.export-settings-scroll, .settings-panel-body)[data-scroll-cue~="below"]::after { opacity: 1; }
/* === END TUX-046 follow-up === */

/* === TUX-041 Q22: scroll cue on pane bodies ===
 * data-scroll-cue (utils.scrollCue.bindPanes) lists the edges that still hide controls in the left pane, the right pane tabs, the
 * formula pane and the tool drawer. Controls below the fold count as reachable by scrolling, so the fold needs a cue. The fades are
 * sticky, take no taps, add no net height and show nothing when everything fits. Touch only. */
body.touch-ui :is(#left-panel-content, .right-tab-panel, .bottom-pane-body, .tool-drawer-body)::before,
body.touch-ui :is(#left-panel-content, .right-tab-panel, .bottom-pane-body, .tool-drawer-body)::after {
  content: ''; display: block; position: sticky; flex: none; height: 28px; pointer-events: none; z-index: 3;
  opacity: 0; transition: opacity 120ms ease;
}
body.touch-ui :is(#left-panel-content, .right-tab-panel, .bottom-pane-body, .tool-drawer-body)::before { top: 0; margin-bottom: -28px; background: linear-gradient(to bottom, var(--ui-panel) 15%, transparent); }
body.touch-ui :is(#left-panel-content, .right-tab-panel, .bottom-pane-body, .tool-drawer-body)::after { bottom: 0; margin-top: -28px; background: linear-gradient(to top, var(--ui-panel) 15%, transparent); }
body.touch-ui .tool-drawer-body::before { margin-bottom: -40px; }
body.touch-ui .tool-drawer-body::after { margin-top: -40px; }
body.touch-ui :is(#left-panel-content, .right-tab-panel, .bottom-pane-body, .tool-drawer-body)[data-scroll-cue~="above"]::before,
body.touch-ui :is(#left-panel-content, .right-tab-panel, .bottom-pane-body, .tool-drawer-body)[data-scroll-cue~="below"]::after { opacity: 1; }
/* === END TUX-041 Q22 === */

/* === TUX-041 slice B5: Scene3D, Petal Designer, Pattern designer ===
 * Every target on these three surfaces is at least --touch-target-min in both axes on coarse pointers. Boxes grow for real where the
 * layout can take it; the small visuals (info dots, switches) keep their size and take a centred ::before inside a 44 px row.
 * The Batch R 24 px ::before extensions on the Scene3D tree buttons are replaced by real boxes (a ::before that overhangs a
 * neighbour steals its pixels). Keyed on body.touch-ui, never on width. Desktop is unchanged. */
/* Scene3D */
body.touch-ui .vs3-panel :is(.tab-btn, .sect-hdr, .seg-opt, .tog-btn, .vs3-shelf-btn, .vs3-more-btn, .vs3-grp-new, .vs3-grp-del, .vs3-light-reset,
  .vs3-tree-addbtn, .vs3-name-input, .vs3-grp-name, .vs3-rename, .vs3-tree-row) {
  min-height: var(--touch-target-min); box-sizing: border-box;
}
body.touch-ui .vs3-panel :is(.seg-opt, .tog-btn, .vs3-tree-addbtn, .vs3-grp-new, .vs3-grp-del) { min-width: var(--touch-target-min); }
body.touch-ui .vs3-more-menu .vs3-more-item { min-height: var(--touch-target-min); box-sizing: border-box; }
body.touch-ui .vs3-more-menu { max-height: calc(var(--app-vh) - 8px); overflow-y: auto; overscroll-behavior: contain; }
body.touch-ui .vs3-panel .tog-grp { flex-wrap: wrap; }
/* +1 px: the shelf columns are fractional (1fr), and a caret of exactly 44 px can lose a pixel to the edge it sits on. */
body.touch-ui .vs3-more-caret { width: calc(var(--touch-target-min) + 1px); min-height: var(--touch-target-min); }
body.touch-ui .vs3-panel :is(.vs3-tree-vis, .vs3-tree-del, .vs3-grp-kid-btn) {
  width: var(--touch-target-min); height: var(--touch-target-min); min-width: var(--touch-target-min);
}
body.touch-ui .vs3-panel :is(.vs3-tree-vis, .vs3-tree-del, .vs3-tree-addbtn)::before { content: none; }
body.touch-ui .vs3-panel .vs3-tree-addlight { gap: 8px; }
body.touch-ui .vs3-panel .vs3-tree-row { align-items: center; }
body.touch-ui .vs3-panel .vs3-grp-kid { min-height: var(--touch-target-min); }
body.touch-ui .vs3-panel .vs3-row { min-height: var(--touch-target-min); }
body.touch-ui .vs3-panel .vs3-name-input { width: 100%; max-width: 100%; font-size: 16px; }
/* Main widened .vs3-lbl from 58 to 74 px (U6) so long labels are not cut. On touch that took 16 px from every slider track
   and left WebKit iPad landscape tracks at 42 px. Touch keeps the 58 px column and wraps a long label onto a second line
   inside the 44 px row instead, so the full label still shows. */
body.touch-ui .vs3-panel .vs3-lbl { flex-basis: 58px; white-space: normal; overflow-wrap: break-word; line-height: 1.2; }
/* A 4-option switch needs 4 x 44 px: the label takes its own line so the control gets the whole row. */
body.touch-ui .vs3-panel .vs3-row:has(.seg-ctrl > .seg-opt:nth-child(4)) { flex-wrap: wrap; }
body.touch-ui .vs3-panel .vs3-row:has(.seg-ctrl > .seg-opt:nth-child(4)) > .vs3-lbl { flex: 1 0 100%; }
/* A switch row that also carries an (i) (Bands, Shadows land on objects, ...): main widened .vs3-lbl to 74 px (U6), so label +
   switch + a 44 px (i) no longer fit one line of a narrow pane, and the (i)'s 44 px ::before overhung the last option. On touch
   the label and the (i) share line 1 (the (i) in its own 44 px slot), and the switch takes line 2 at full width. */
body.touch-ui .vs3-panel .vs3-row:has(> .vs3-ctl > :is(.seg-ctrl, .slider-row)):has(> .vs3-lawinfo-wrap) { flex-wrap: wrap; }
body.touch-ui .vs3-panel .vs3-row:has(> .vs3-ctl > :is(.seg-ctrl, .slider-row)):has(> .vs3-lawinfo-wrap) > .vs3-lbl { flex: 1 0 calc(100% - var(--touch-target-min) - 18px); order: 0; }
body.touch-ui .vs3-panel .vs3-row:has(> .vs3-ctl > :is(.seg-ctrl, .slider-row)) > .vs3-lawinfo-wrap {
  order: 1; flex: 0 0 var(--touch-target-min); min-height: var(--touch-target-min); align-items: center; justify-content: center;
}
body.touch-ui .vs3-panel .vs3-row:has(> .vs3-ctl > :is(.seg-ctrl, .slider-row)):has(> .vs3-lawinfo-wrap) > .vs3-ctl { order: 2; flex-basis: 100%; }
/* The More... split button takes two shelf cells: a 44 px caret beside the main button in one cell would squeeze it to 32 px. */
body.touch-ui .vs3-shelf .vs3-more { grid-column: span 2; }
body.touch-ui .vs3-panel .vs3-lawinfo-wrap { margin-right: 10px; } /* keeps the 44 px reach off the pane scrollbar */
body.touch-ui .vs3-panel .sw-toggle { position: relative; }
body.touch-ui .vs3-panel .sw-toggle::before {
  content: ''; position: absolute; left: 50%; top: 50%;
  width: var(--touch-target-min); height: var(--touch-target-min); transform: translate(-50%, -50%);
}
/* The info dot ("About ...") keeps its small look and takes a 44 px ::before; its row is a finger tall. */
body.touch-ui .vs3-panel .vs3-lawinfo-btn { position: relative; }
body.touch-ui .vs3-panel .vs3-lawinfo-btn::before {
  content: ''; position: absolute; left: 50%; top: 50%;
  width: var(--touch-target-min); height: var(--touch-target-min); transform: translate(-50%, -50%);
}
body.touch-ui .vs3-panel :is(.vs3-lbl, .vs3-subhead, .vs3-hl-hdr):has(.vs3-lawinfo-btn) { min-height: var(--touch-target-min); }
/* Petal Designer (inline in the left pane and the pop-out window) */
body.touch-ui :is(.petal-designer-window, .petal-designer-inline) :is(.petal-profile-side-btn, .petal-ring-param-accordion-summary, .petal-designer-randomness summary, .petal-slider-label > select, .petal-profile-editor-actions button,
  .petal-designer-structure input, .petal-designer-structure select, .petal-visualizer-mode select, .petal-designer-transition select) {
  min-height: var(--touch-target-min); min-width: var(--touch-target-min); box-sizing: border-box;
}
body.touch-ui :is(.petal-designer-window, .petal-designer-inline) :is(.petal-designer-structure input, .petal-designer-structure select, .petal-visualizer-mode select) { font-size: 16px; }
/* WebKit ignores min-height on a native select: it needs a height. */
body.touch-ui :is(.petal-designer-window, .petal-designer-inline) :is(.petal-designer-structure select, .petal-visualizer-mode select, .petal-slider-label > select, .petal-designer-transition select) { height: var(--touch-target-min); }
body.touch-ui :is(.petal-designer-window, .petal-designer-inline) :is(.petal-profile-editor-thumbs, .petal-profile-thumbs) {
  grid-template-columns: repeat(auto-fill, minmax(var(--touch-target-min), 1fr));
}
body.touch-ui :is(.petal-designer-window, .petal-designer-inline) :is(.petal-profile-editor-thumbs, .petal-profile-thumbs) > button { min-width: var(--touch-target-min); min-height: var(--touch-target-min); }
body.touch-ui :is(.petal-designer-window, .petal-designer-inline) .petal-transition-lock { min-height: var(--touch-target-min); }
body.touch-ui :is(.petal-designer-window, .petal-designer-inline) :is(.petal-transition-lock, .petal-shade-toggle) :is(.sw-toggle, input[type="checkbox"]) { position: relative; }
body.touch-ui :is(.petal-designer-window, .petal-designer-inline) :is(.petal-transition-lock, .petal-shade-toggle) :is(.sw-toggle, input[type="checkbox"])::before {
  content: ''; position: absolute; left: 50%; top: 50%;
  width: var(--touch-target-min); height: var(--touch-target-min); transform: translate(-50%, -50%);
}
/* The pop-out window floats over the canvas HUD and covers part of it, so the half-covered zoom buttons would be half dead: the HUD
 * steps aside while the window is open (the window itself is the active surface; undo / redo live in its header, TUX-020). */
body.touch-ui:has(#petal-designer-window:not(.petal-designer-inline)) .canvas-hud { display: none; }
/* Pattern designer: its header row holds three buttons and the shared tool strip (8 x 44 px), which ran past the pane edge. Both rows wrap. */
body.touch-ui .pattern-designer-inline .pd-header-row { flex-wrap: wrap; row-gap: 6px; }
body.touch-ui .pattern-designer-inline .pd-header-actions { flex-wrap: wrap; row-gap: 6px; justify-content: flex-end; }
/* A tablet drawer (Document Setup) slid over the left 14 px of the tool rail and took 5 px of every rail button: the rail rides above it. */
body.touch-ui:not(.phone-layout):has(.settings-panel.open) #tool-bar { z-index: 41; }
/* ...and the 14 px of drawer under the rail stay empty, so the rail never steals a control's reach. */
body.touch-ui:not(.phone-layout) .settings-panel-body { padding-right: 16px; box-sizing: border-box; }
/* Generator picker on a short screen: the list scrolls, so the hidden edge gets a fade (utils.scrollCue, bound when the list opens). */
body.touch-ui #gm-module-menu::before, body.touch-ui #gm-module-menu::after {
  content: ''; display: block; position: sticky; flex: none; height: 28px; pointer-events: none; z-index: 2;
  opacity: 0; transition: opacity 120ms ease;
}
body.touch-ui #gm-module-menu::before { top: 0; margin-bottom: -28px; background: linear-gradient(to bottom, var(--ui-panel) 15%, transparent); }
body.touch-ui #gm-module-menu::after { bottom: 0; margin-top: -28px; background: linear-gradient(to top, var(--ui-panel) 15%, transparent); }
body.touch-ui #gm-module-menu[data-scroll-cue~="above"]::before,
body.touch-ui #gm-module-menu[data-scroll-cue~="below"]::after { opacity: 1; }
/* Collapsed touch-wide rail: the chevron fills the 36 px rail (its own ::before reaches 10 px onto the canvas). Its box had grown to 44 px,
 * so 8 px more of it lay over the canvas (792 px2 instead of 440) and took the iPad landscape share to 74.999 % (the right chevron even ran 17 px off screen). The hit area stays 46 px wide. */
/* B4's pane rule (#left-pane button { min-width: 44px }, specificity with an id) is what grew it; the rule now skips .pane-toggle too. */
body.touch-wide-layout.touch-ui :is(#left-pane, #right-pane).pane-collapsed .pane-toggle { width: auto; min-width: 0; }
/* === END TUX-041 slice B5 === */

/* === TUX-031 (batch G): a drawn shape keeps its Shape Properties button on phones ===
 * The generic phone rule hides .ctxbar at <= 640px. A phone user then cannot reach polygon sides or corner radius after the draw.
 * Only the shape context shows the bar there: showing it for every selection covered the canvas (honest share 75 -> 69 %) and a
 * 20 px grip fell under 44 px. The bar floats over the canvas, hides itself without a context, and has no grip, like the pen draft. */
@media (max-width: 640px) {
  body.touch-ui .ctxbar.ctxbar--shape { display: flex; }
  body.touch-ui .ctxbar.ctxbar--shape .ctxbar-handle { display: none; }
  body.touch-ui .ctxbar.ctxbar--shape .ctxbar-content { flex: 1 1 auto; min-width: 0; overflow-x: auto; scrollbar-width: none; overscroll-behavior-x: contain; }
  body.touch-ui .ctxbar.ctxbar--shape .ctxbar-content::-webkit-scrollbar { display: none; }
  body.touch-ui .ctxbar.ctxbar--shape .ctxbar-overflow-wrap { flex: 0 0 auto; }
}
/* === END TUX-031 (batch G) === */

/* === TUX-050 (batch G): Paper size stays on screen on the shortest phone landscape ===
 * At 874 x 330 the Theme section pushed the Paper size select under the window edge. Paper holds the primary
 * control, so on a short touch viewport it goes first. */
@media (max-height: 360px) {
  body.touch-ui #settings-panel .settings-panel-body { display: flex; flex-direction: column; }
  body.touch-ui #settings-panel .settings-panel-body > .sect--color-paper { order: -1; }
}
/* === END TUX-050 (batch G) === */

/* === Export legend gear above the footer on the shortest phone landscape (followups B3 b) ===
 * At 874 x 330 the preview stage runs under the pinned modal footer, and the legend (anchored to the stage bottom) put its
 * gear under the footer. On short touch screens the legend anchors to the stage top, which stays in the visible band. */
@media (max-height: 400px) {
  body.touch-ui .export-preview-legend { top: 12px; bottom: auto; }
}
/* === END export legend gear === */

/* Paper panel (paper selector) — src/ui/panels/paper-panel.js.
   The Paper section sits above Pens in the right pane's Pen / Paper tab. */
#paper-global-section {
  flex: 0 0 auto;
  margin-bottom: var(--spacing-md);
}
[data-ui-skin] #paper-section-header .paper-default-badge {
  margin-left: auto;
  margin-right: var(--spacing-xs);
  padding: 1px 6px;
  border-radius: var(--radius-sm);
  background: var(--ui-accent-2);
  color: var(--ui-accent);
  font-size: var(--font-size-xs);
  font-weight: 600;
}
[data-ui-skin] #paper-section-header .paper-default-badge[hidden] {
  display: none;
}
.paper-swatch-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(56px, 1fr));
  gap: var(--spacing-xs);
}
[data-ui-skin] .paper-swatch {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  min-width: 44px;
  min-height: 44px;
  padding: 4px 2px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--ui-text-2);
  cursor: pointer;
  transition: border-color 0.12s, background-color 0.12s;
}
[data-ui-skin] .paper-swatch:hover {
  background: var(--ui-ctrl-hov);
  color: var(--ui-text);
}
[data-ui-skin] .paper-swatch:focus-visible {
  outline: 2px solid var(--ui-accent);
  outline-offset: 1px;
}
[data-ui-skin] .paper-swatch.active {
  border-color: var(--ui-accent);
  background: var(--ui-accent-2);
  color: var(--ui-text);
}
.paper-swatch-thumb {
  display: block;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  background-size: cover;
  background-position: center;
  box-shadow: inset 0 0 0 1px var(--ui-border-hi);
}
[data-ui-skin] .paper-swatch-label {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: var(--font-ui);
  font-size: var(--font-size-xs);
  line-height: 1.2;
}
[data-ui-skin] .paper-current {
  margin: var(--spacing-sm) 0 var(--spacing-xs);
  font-family: var(--font-ui);
  font-size: var(--font-size-xs);
  color: var(--ui-muted);
  min-height: 1.2em;
}
.paper-row {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  min-height: var(--row-height);
}
[data-ui-skin] .paper-row-label {
  flex: 0 0 64px;
  font-family: var(--font-ui);
  font-size: var(--font-size-sm);
  color: var(--ui-text-2);
}
.paper-row .paper-slider {
  flex: 1 1 auto;
  min-width: 0;
}
[data-ui-skin] .paper-row .paper-slider:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
[data-ui-skin] .paper-slider-value {
  flex: 0 0 38px;
  text-align: right;
  font-size: var(--font-size-xs);
  color: var(--ui-muted);
  font-variant-numeric: tabular-nums;
}
[data-ui-skin] #right-pane #paper-section-body .paper-color-pill.value-chip {
  margin-left: auto;
  flex: 0 0 auto;
  min-width: 92px;
  padding: 0 10px;
  white-space: nowrap;
}
.paper-actions {
  display: flex;
  gap: var(--spacing-xs);
  margin-top: var(--spacing-sm);
}
[data-ui-skin] .paper-action-btn {
  flex: 1 1 0;
  min-height: var(--row-height);
  padding: 0 var(--spacing-sm);
  border: 1px solid var(--ui-border);
  border-radius: var(--radius-sm);
  background: var(--ui-ctrl);
  color: var(--ui-text-2);
  font-family: var(--font-ui);
  font-size: var(--font-size-sm);
  cursor: pointer;
  transition: border-color 0.12s, background-color 0.12s, color 0.12s;
}
[data-ui-skin] .paper-action-btn:hover:not(:disabled) {
  border-color: var(--ui-accent);
  color: var(--ui-text);
}
[data-ui-skin] .paper-action-btn:disabled {
  opacity: 0.45;
  cursor: default;
}
[data-ui-skin] .paper-note {
  margin: var(--spacing-xs) 0 0;
  font-size: var(--font-size-xs);
  color: var(--ui-muted);
}
body.touch-ui #right-pane .paper-action-btn,
body.touch-ui #right-pane #paper-section-header,
body.touch-ui #right-pane .paper-row,
body.touch-ui #right-pane .paper-color-pill,
body.touch-ui #right-pane .paper-slider {
  min-height: var(--touch-target-min);
}
/* A slider track is a 44 px target in width too: WebKit's wider label metrics squeezed it to 43 px, so the label yields
 * (it wraps) before the track does. */
body.touch-ui #right-pane .paper-row .paper-slider { min-width: var(--touch-target-min); }
body.touch-ui #right-pane .paper-row .paper-row-label { flex: 0 1 64px; min-width: 0; overflow-wrap: anywhere; }
/* Custom papers ("My papers"): custom swatches follow the built-ins in the
   same radiogroup; each carries a ⋯ actions button. */
.paper-swatch-wrap {
  position: relative;
  display: flex;
  min-width: 0;
}
.paper-swatch-wrap > .paper-swatch {
  flex: 1 1 auto;
  min-width: 44px;
}
[data-ui-skin] .paper-swatch.is-custom .paper-swatch-thumb {
  box-shadow: inset 0 0 0 1px var(--ui-border-hi), inset 0 -3px 0 0 var(--ui-accent);
}
[data-ui-skin] .paper-swatch-wrap.is-from-file .paper-swatch-label {
  font-style: italic;
}
[data-ui-skin] .paper-swatch-more {
  position: absolute;
  top: 0;
  right: 0;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 1px solid var(--ui-border);
  border-radius: var(--radius-sm);
  background: var(--ui-panel, var(--ui-ctrl));
  color: var(--ui-text-2);
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
  transition: opacity 0.12s, border-color 0.12s, color 0.12s;
}
/* With a hover-capable pointer the ⋯ stays quiet until the swatch is
   hovered, focused or checked; without one it is always shown. */
@media (hover: hover) {
  [data-ui-skin] .paper-swatch-wrap .paper-swatch-more {
    opacity: 0;
  }
  [data-ui-skin] .paper-swatch-wrap:hover .paper-swatch-more,
  [data-ui-skin] .paper-swatch-wrap:focus-within .paper-swatch-more,
  [data-ui-skin] .paper-swatch-wrap.active .paper-swatch-more {
    opacity: 1;
  }
}
[data-ui-skin] .paper-swatch-more:hover,
[data-ui-skin] .paper-swatch-more:focus-visible {
  border-color: var(--ui-accent);
  color: var(--ui-text);
  outline: none;
}
.paper-custom-bar {
  display: flex;
  gap: var(--spacing-xs);
  margin-top: var(--spacing-xs);
}
.paper-custom-bar .paper-save-custom {
  flex: 1 1 auto;
  text-align: left;
}
[data-ui-skin] .paper-icon-btn {
  flex: 0 0 auto;
  min-width: var(--row-height);
  min-height: var(--row-height);
  padding: 0;
  border: 1px solid var(--ui-border);
  border-radius: var(--radius-sm);
  background: var(--ui-ctrl);
  color: var(--ui-text-2);
  font-size: var(--font-size-sm);
  cursor: pointer;
}
[data-ui-skin] .paper-icon-btn:hover,
[data-ui-skin] .paper-icon-btn:focus-visible {
  border-color: var(--ui-accent);
  color: var(--ui-text);
}
.paper-custom-status {
  display: flex;
  align-items: center;
  gap: var(--spacing-xs);
  margin-bottom: var(--spacing-xs);
}
.paper-custom-status[hidden] {
  display: none;
}
[data-ui-skin] .paper-custom-status-text {
  flex: 1 1 auto;
  min-width: 0;
  font-size: var(--font-size-xs);
  color: var(--ui-muted);
}
.paper-custom-status .paper-custom-status-btn {
  flex: 0 0 auto;
}
.paper-custom-status .paper-custom-status-btn[hidden] {
  display: none;
}
.paper-advanced {
  margin-top: var(--spacing-sm);
}
.paper-advanced[hidden] {
  display: none;
}
[data-ui-skin] .paper-advanced-summary {
  display: flex;
  align-items: center;
  min-height: var(--row-height);
  font-family: var(--font-ui);
  font-size: var(--font-size-sm);
  color: var(--ui-text-2);
  cursor: pointer;
  list-style: none;
}
.paper-advanced-summary::-webkit-details-marker {
  display: none;
}
.paper-advanced-summary::before {
  content: '';
  width: 0;
  height: 0;
  margin-right: var(--spacing-xs);
  border-style: solid;
  border-width: 4px 0 4px 6px;
  border-color: transparent transparent transparent currentColor;
  transition: transform 0.12s;
}
.paper-advanced[open] > .paper-advanced-summary::before {
  transform: rotate(90deg);
}
[data-ui-skin] .paper-advanced-summary:focus-visible {
  outline: 2px solid var(--ui-accent);
  outline-offset: 1px;
}
.paper-advanced-body .paper-row-label {
  flex-basis: 80px;
}
.paper-advanced-body .paper-param-value {
  flex-basis: 52px;
}
/* Touch: the ⋯ is a full 44 px target beside the swatch (the custom swatch
   spans two grid columns), always visible. */
body.touch-ui #right-pane .paper-swatch-wrap.is-custom {
  grid-column: span 2;
  gap: 2px;
}
body.touch-ui #right-pane .paper-swatch-more {
  position: static;
  flex: 0 0 auto;
  align-self: center;
  width: var(--touch-target-min);
  height: var(--touch-target-min);
  font-size: var(--font-size-md, 16px);
  opacity: 1;
}
body.touch-ui #right-pane .paper-icon-btn,
body.touch-ui #right-pane .paper-advanced-summary {
  min-height: var(--touch-target-min);
  min-width: var(--touch-target-min);
}
/* Image papers: texture button, attribution, import dialog, search sheet
   (src/ui/panels/paper-texture-import.js). */
.paper-custom-bar .paper-texture-btn {
  flex: 0 0 auto;
}
[data-ui-skin] .paper-attribution {
  margin: 0 0 var(--spacing-xs);
  font-size: var(--font-size-xs);
  color: var(--ui-muted);
  overflow-wrap: anywhere;
}
.paper-attribution[hidden] {
  display: none;
}
[data-ui-skin] .paper-attribution a {
  color: var(--ui-accent);
}
.paper-import-dialog,
.paper-search-sheet {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-xs);
  min-width: 0;
}
.paper-import-preview {
  height: 120px;
  border-radius: var(--radius-sm);
  background-color: var(--ui-ctrl);
  background-size: cover;
  background-position: center;
  box-shadow: inset 0 0 0 1px var(--ui-border-hi);
}
[data-ui-skin] .paper-import-label {
  font-size: var(--font-size-xs);
  color: var(--ui-text-2);
}
.paper-import-row {
  display: flex;
  align-items: center;
  gap: var(--spacing-xs);
  min-width: 0;
}
[data-ui-skin] .paper-import-input {
  min-height: var(--row-height);
  min-width: 0;
  flex: 1 1 auto;
  padding: 0 var(--spacing-sm);
  border: 1px solid var(--ui-border);
  border-radius: var(--radius-sm);
  background: var(--ui-bg, var(--ui-ctrl));
  color: var(--ui-text);
  font-family: var(--font-ui);
  font-size: var(--font-size-sm);
}
.paper-import-row .paper-import-scale {
  flex: 0 0 96px;
}
[data-ui-skin] .paper-import-height-name {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: var(--font-size-xs);
  color: var(--ui-muted);
}
.paper-import-row .paper-action-btn {
  flex: 0 0 auto;
}
[data-ui-skin] .paper-import-status {
  margin: 0;
  min-height: 1.2em;
  font-size: var(--font-size-xs);
  color: var(--ui-muted);
}
[data-ui-skin] .paper-import-status.is-error {
  color: var(--ui-danger, #e5484d);
}
.paper-search-chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--spacing-xs);
}
[data-ui-skin] .paper-search-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: var(--row-height);
  padding: 0 var(--spacing-sm);
  border: 1px solid var(--ui-border);
  border-radius: 999px;
  background: var(--ui-ctrl);
  color: var(--ui-text-2);
  font-size: var(--font-size-xs);
  cursor: pointer;
}
[data-ui-skin] .paper-search-chip[aria-pressed="true"] {
  border-color: var(--ui-accent);
  background: var(--ui-accent-2);
  color: var(--ui-text);
}
[data-ui-skin] .paper-licence-badge {
  display: inline-block;
  padding: 0 5px;
  border-radius: var(--radius-sm);
  background: var(--ui-ctrl-hov, var(--ui-ctrl));
  color: var(--ui-text-2);
  font-size: 10px;
  line-height: 16px;
  font-weight: 600;
  white-space: nowrap;
}
[data-ui-skin] .paper-search-status {
  margin: 0;
  font-size: var(--font-size-xs);
  color: var(--ui-muted);
}
.paper-search-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(132px, 1fr));
  gap: var(--spacing-sm);
  max-height: min(56vh, 520px);
  overflow-y: auto;
}
[data-ui-skin] .paper-search-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  padding: 6px;
  border: 1px solid var(--ui-border);
  border-radius: var(--radius-sm);
  background: var(--ui-ctrl);
}
.paper-search-thumb {
  display: block;
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: var(--radius-sm);
  background: var(--ui-bg, #111);
}
[data-ui-skin] .paper-search-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: var(--font-size-sm);
  color: var(--ui-text);
}
[data-ui-skin] .paper-search-meta {
  font-size: var(--font-size-xs);
  color: var(--ui-muted);
}
.paper-search-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.paper-search-actions .paper-action-btn {
  flex: 1 1 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}
[data-ui-skin] .paper-search-note {
  margin: 0;
  font-size: var(--font-size-xs);
  color: var(--ui-muted);
}
.paper-search-note:empty {
  display: none;
}
body.touch-ui .paper-search-chip,
body.touch-ui .paper-import-input,
body.touch-ui .paper-import-dialog .paper-action-btn,
body.touch-ui .paper-search-actions .paper-action-btn,
body.touch-ui .paper-import-footer button {
  min-height: var(--touch-target-min);
}
/* Document Setup "Default paper" row (src/ui/modals/document-setup.js). */
.default-paper-block {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-xs);
  padding: var(--spacing-xs) 0 var(--spacing-sm);
}
.default-paper-controls {
  display: flex;
  align-items: center;
  gap: var(--spacing-xs);
}
.default-paper-controls .ctrl-sel-wrap {
  flex: 1 1 auto;
  min-width: 0;
}
.default-paper-controls .value-chip {
  flex: 0 0 auto;
  min-width: 76px;
}
/* Touch: the longest paper name ("No default (follow theme)", "Cold-press watercolor") does not fit beside the colour chip
 * in the 290 px column, so the select takes the whole row and the chip wraps below it. */
body.touch-ui .default-paper-controls { flex-wrap: wrap; }
body.touch-ui .default-paper-controls .ctrl-sel-wrap { flex: 1 1 100%; }
[data-ui-skin] .default-paper-hint {
  margin: 0;
  font-size: var(--font-size-xs);
  color: var(--ui-muted);
}
.default-paper-block .default-paper-apply {
  align-self: flex-start;
}
/* Touch: the label that carries the Info button is one finger tall (the button's centred 44 px ::before stays inside it),
 * and the select takes the whole row so the longest paper name is not clipped beside the colour chip. */
body.touch-ui :is(#settings-panel, .default-paper-block) .ctrl-lbl:has(> .info-btn) {
  display: flex; align-items: center; min-height: var(--touch-target-min);
  padding-right: calc(var(--touch-target-min) / 2); /* the button's 44 px ::before stays inside the label, off the control beside it */
}
body.touch-ui .default-paper-controls { flex-wrap: wrap; }
body.touch-ui .default-paper-controls .ctrl-sel-wrap { flex: 1 1 100%; }

/* ============================================================================
 * Start Page (P0 shell) — overlay above the editor. `.sp-` prefix.
 * Meridian tokens only, so every skin / brightness inherits its own palette.
 * ========================================================================== */
.sp {
  position: fixed;
  inset: 0;
  z-index: 900;
  display: flex;
  flex-direction: column;
  background: var(--ui-bg);
  color: var(--ui-text);
  font-family: var(--font-ui);
  font-size: 12px;
  line-height: 1.45;
  container-type: inline-size;
  container-name: sp;
  animation: sp-in 320ms cubic-bezier(0.2, 0.7, 0.2, 1);
}
.sp[hidden] { display: none; }
/* Boot guard (start-page/boot.js): on a launch that will show the page, the editor is never painted first. Only the
 * page-colored ground shows until the page has mounted and settled (start-page.js removes data-sp-boot). */
html[data-sp-boot] { background: var(--ui-bg); }
html[data-sp-boot] body { visibility: hidden; }
html[data-sp-boot] .sp, .sp[data-no-fx] { animation: none; }
/* The first render of the page: the body stays blank (page ground) until the cover, plates and picks are laid out. */
.sp[data-settling] .sp-body, .sp[data-settling] #sp-colo-wrap { visibility: hidden; }
.sp kbd {
  font: 500 10px/1 var(--font-mono);
  color: var(--ui-text-2);
  letter-spacing: 0.02em;
  font-variant-numeric: tabular-nums;
  background: none;
  border: 0;
  box-shadow: none;
  padding: 0;
}
:where(.sp) button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
.sp :focus-visible { outline: 2px solid var(--ui-accent); outline-offset: 2px; border-radius: 3px; }

/* header */
.sp-hdr {
  position: relative;
  height: 38px;
  flex: none;
  display: flex;
  align-items: center;
  gap: 0;
  padding: 0 12px 0 14px;
  background: var(--ui-panel);
  border-bottom: 1px solid var(--ui-border);
}
.sp-brand { display: flex; align-items: center; gap: 10px; height: 28px; padding: 0 6px 0 0; border-radius: var(--radius-sm); }
.sp-mark { width: 16px; height: 16px; background: var(--ui-accent); flex: none; }
.sp-wm { font: 700 12px/1 var(--font-mono); letter-spacing: 0.14em; color: var(--ui-accent); white-space: nowrap; }
.sp-wm i { font-style: normal; font-weight: 300; color: var(--ui-text-2); }
.sp-spacer { flex: 1; }
.sp-today { font: 400 11px/1 var(--font-mono); color: var(--ui-muted); margin-right: 14px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.sp-hdr-tools { display: inline-flex; align-items: center; gap: 6px; }
.sp-hdr-tools:not(:empty) { margin-right: 8px; }
.sp-hdr-tools .sp-hbtn[hidden] { display: none; }
.sp-back {
  display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 10px; margin-right: 12px;
  border: 1px solid var(--ui-border-hi); border-radius: var(--radius-sm); background: var(--ui-ctrl);
  font-size: 11px; font-weight: 500; white-space: nowrap;
  transition: border-color var(--dur-fast, 150ms), color var(--dur-fast, 150ms);
}
.sp-back[hidden] { display: none; }
.sp-back:hover { border-color: var(--ui-accent); color: var(--ui-accent); }
.sp-theme {
  width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; flex: none;
  border: 1px solid var(--ui-border); color: var(--ui-text-2);
}
.sp-theme:hover { background: var(--ui-ctrl-hov); color: var(--ui-text); }
.sp-theme .sun, .sp-theme .sp-ico-sun-moon { display: none; }
.sp[data-light="true"] .sp-theme .sun { display: block; }
.sp[data-light="true"] .sp-theme .moon { display: none; }
/* System state: Lucide sun-moon replaces the moon/sun pair. */
.sp-theme[data-mode="system"] .moon, .sp-theme[data-mode="system"] .sun { display: none !important; }
.sp-theme[data-mode="system"] .sp-ico-sun-moon { display: block; width: 14px; height: 14px; }

/* body */
.sp-body { flex: 1; display: flex; min-height: 0; }
.sp-scroll { flex: 1; min-width: 0; overflow: auto; overflow-x: hidden; }
.sp-main { --sp-gut: 36px; padding: 0 var(--sp-gut) 48px; min-height: 100%; display: flex; flex-direction: column; justify-content: flex-start; position: relative; }
.sp-empty { max-width: 520px; padding: 48px 0; }
.sp-eyebrow { font: 500 10px/1 var(--font-mono); letter-spacing: 0.18em; text-transform: uppercase; color: var(--ui-muted); }
.sp-empty h2 { margin: 14px 0 10px; font-size: 26px; line-height: 1.15; font-weight: 600; letter-spacing: -0.01em; }
.sp-empty p { margin: 0; color: var(--ui-text-2); font-size: 13px; line-height: 1.6; }

/* rail */
.sp-rail {
  flex: none; width: 288px; display: flex; flex-direction: column; min-height: 0; overflow: hidden;
  background: var(--ui-panel); border-left: 1px solid var(--ui-border);
  transition: width 340ms cubic-bezier(0.2, 0.7, 0.2, 1), opacity 240ms ease, border-color 340ms ease;
}
.sp-rail > * { min-width: 288px; box-sizing: border-box; }
.sp[data-rail="closed"] .sp-rail {
  width: 0; opacity: 0; border-left-width: 0; visibility: hidden;
  transition: width 340ms cubic-bezier(0.2, 0.7, 0.2, 1), opacity 240ms ease, visibility 0s linear 340ms;
}
.sp-sec { padding: 16px 18px 14px; border-bottom: 1px solid var(--ui-border); }
.sp-recent { flex: 1; overflow: auto; min-height: 0; border-bottom: 0; }
.sp-h { display: flex; align-items: center; min-height: 12px; margin-bottom: 11px; }
.sp-h2 { margin-top: 14px; }
.sp-lbl { font: 500 10px/1 var(--font-mono); letter-spacing: 0.18em; text-transform: uppercase; color: var(--ui-muted); }
.sp-aside { margin-left: auto; }
/* 2.5.8: the Clear links (rail and colophon strip) keep their look but get a 24px hit area. */
[data-act="clear-recent"] { display: inline-flex; align-items: center; justify-content: center; min-height: 24px; min-width: 24px; padding: 0 4px; }
.sp-aside button { font-size: 11px; color: var(--ui-text-2); border-bottom: 1px dotted currentColor; }
.sp-aside button:hover { color: var(--ui-danger); }
.sp-primary, .sp-line {
  width: 100%; height: 38px; display: flex; align-items: center; gap: 10px; padding: 0 12px;
  border-radius: var(--radius-sm); font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden;
  transition: filter var(--dur-fast, 150ms), border-color var(--dur-fast, 150ms);
}
.sp-primary { background: var(--ui-accent); color: var(--ui-on-accent, #fff); }
.sp-primary:hover { filter: brightness(1.08); }
.sp-primary kbd { margin-left: auto; color: color-mix(in srgb, var(--ui-on-accent, #fff) 78%, transparent); }
.sp-line { border: 1px solid var(--ui-border-hi); background: var(--ui-ctrl); font-weight: 500; margin-top: 10px; }
.sp-line:hover { border-color: var(--ui-accent); }
.sp-line kbd { margin-left: auto; }
.sp-paper { margin-top: 10px; }
.sp-chips { display: flex; gap: 4px; }
.sp-chips button {
  flex: 1; height: 24px; border: 1px solid var(--ui-border); border-radius: var(--radius-sm);
  font: 500 10px/1 var(--font-mono); color: var(--ui-muted);
  transition: color var(--dur-fast, 150ms), border-color var(--dur-fast, 150ms);
}
.sp-chips button:hover { color: var(--ui-text); border-color: var(--ui-border-hi); }
.sp-chips button[aria-checked="true"] { color: var(--ui-accent-text, var(--ui-accent)); border-color: var(--ui-accent); background: var(--ui-accent-2); }
.sp-cap { margin-top: 6px; font: 400 10px/1.4 var(--font-mono); color: var(--ui-muted); }

/* resume + recent rows */
.sp-cont { display: block; width: 100%; text-align: left; border-radius: 4px; margin-bottom: 10px; }
.sp-cth {
  display: block; height: 128px; position: relative; overflow: hidden; border: 1px solid var(--ui-border); border-radius: 2px;
  background: var(--ui-ctrl); transition: border-color var(--dur, 200ms), box-shadow var(--dur, 200ms);
}
.sp-cth img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.sp-cont:hover .sp-cth { border-color: var(--ui-accent); }
.sp-cont:focus-visible { outline: none; }
.sp-cont:focus-visible .sp-cth { outline: none; border-color: var(--ui-accent); box-shadow: inset 0 0 0 2px var(--ui-accent); }
.sp-cth kbd { position: absolute; right: 7px; top: 7px; z-index: 1; background: var(--ui-panel); padding: 3px 5px; border-radius: 3px; }
.sp-go {
  position: absolute; z-index: 1; left: 7px; top: 7px; font: 500 9.5px/1 var(--font-mono); letter-spacing: 0.14em;
  text-transform: uppercase; color: var(--ui-accent); background: var(--ui-panel); padding: 4px 6px; border-radius: 3px;
}
.sp-cont .sp-nm { display: block; margin-top: 8px; font-size: 12.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sp-cont .sp-mt { display: block; margin-top: 2px; }
.sp-row {
  position: relative; display: flex; align-items: center; gap: 10px; padding: 5px 8px; border-radius: var(--radius-sm);
  text-align: left; width: 100%; transition: background var(--dur-fast, 150ms);
}
.sp-row:hover, .sp-row:focus-visible { background: var(--ui-ctrl-hov); outline: none; }
.sp-row:focus-visible { box-shadow: inset 0 0 0 2px var(--ui-accent); }
.sp-thumb {
  position: relative; display: block; width: 36px; height: 36px; flex: none; overflow: hidden; border-radius: 2px;
  background: var(--ui-ctrl); border: 1px solid var(--ui-border);
}
.sp-thumb img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.sp-tx { min-width: 0; flex: 1; }
.sp-nm { display: block; font-size: 12px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; line-height: 1.3; }
.sp-mt { display: block; font: 400 10px/1.4 var(--font-mono); color: var(--ui-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-variant-numeric: tabular-nums; }
.sp-none { padding: 6px 0 4px; color: var(--ui-muted); font-size: 12px; line-height: 1.55; }
.sp-none b { display: block; color: var(--ui-text-2); font-weight: 600; margin-bottom: 4px; }

/* footer: launch preference */
.sp-foot { padding: 12px 18px 14px; border-top: 1px solid var(--ui-border); }
.sp-foot p { margin: 6px 0 0 22px; font-size: 10.5px; color: var(--ui-muted); line-height: 1.5; }
.sp-chk { display: flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 500; cursor: pointer; position: relative; line-height: 1.3; }
.sp-chk input { position: absolute; left: 0; top: 50%; transform: translateY(-50%); z-index: 1; opacity: 0; width: 14px; height: 14px; margin: 0; cursor: pointer; }
.sp-box {
  width: 14px; height: 14px; flex: none; border: 1px solid var(--ui-border-hi); border-radius: 3px; background: var(--ui-ctrl);
  display: grid; place-items: center; transition: background var(--dur-fast, 150ms), border-color var(--dur-fast, 150ms);
}
.sp-chk input:checked + .sp-box { background: var(--ui-accent); border-color: var(--ui-accent); }
.sp-chk input:checked + .sp-box::after {
  content: ""; width: 7px; height: 4px; border-left: 2px solid var(--ui-on-accent, #fff); border-bottom: 2px solid var(--ui-on-accent, #fff);
  transform: rotate(-45deg) translate(1px, -1px);
}
.sp-chk input:focus-visible + .sp-box { outline: 2px solid var(--ui-accent); outline-offset: 2px; }

/* narrow (container <= 900 px): the rail gives way to the colophon strip, which is then the only form */
@container sp (max-width: 900px) {
  .sp-rail { display: none; }
  .sp-main { --sp-gut: 18px; }
  .sp-today { display: none; }
}
@container sp (max-width: 460px) {
  .sp-back span:last-child { display: none; }
  .sp-back { padding: 0 8px; }
  .sp-co-btn kbd { display: none; }
}

/* File > Open Recent submenu */
.top-menu-sub { position: relative; }
.top-menu-sub > .top-menu-item .top-menu-chevron { margin-left: auto; opacity: 0.6; }
.top-menu-subpanel {
  position: absolute; top: -6px; left: calc(100% + 4px); min-width: 340px; padding: 6px; display: flex; flex-direction: column; gap: 2px;
  background: var(--ui-panel); border: 1px solid var(--ui-border-hi); border-radius: var(--radius-md); box-shadow: var(--shadow-lg); z-index: 1410;
}
.top-menu-subpanel[hidden] { display: none; }
.top-menu-sub-title { font: 500 9.5px/1 var(--font-mono); letter-spacing: 0.14em; color: var(--ui-muted); padding: 8px 10px 6px; text-transform: uppercase; }
.top-menu-recent { min-height: 42px; }
.top-menu-recent .recent-lead { display: flex; align-items: center; gap: 10px; min-width: 0; }
.top-menu-recent .sp-thumb { width: 30px; height: 30px; }
.top-menu-recent .recent-text { display: flex; flex-direction: column; gap: 3px; min-width: 0; text-align: left; }
.top-menu-recent .recent-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 210px; line-height: 1.2; }
.top-menu-recent .recent-meta { font: 400 10px/1.2 var(--font-mono); color: var(--ui-muted); white-space: nowrap; }
body.phone-layout #top-menubar .top-menu-subpanel {
  position: static; min-width: 0; width: 100%; box-sizing: border-box; box-shadow: none; border: 0; border-radius: 0; padding: 0 0 0 12px;
}
body.phone-layout #top-menubar .top-menu-recent .recent-name { max-width: 55vw; }

/* Editor wordmark: the way back to the Start Page. Looks like the old plain heading text. */
.wordmark-btn {
  font: inherit; letter-spacing: inherit; color: inherit; background: none; border: 0; padding: 0; margin: 0;
  cursor: pointer; border-radius: var(--radius-sm);
}
.wordmark-btn:hover { filter: brightness(1.15); }
.wordmark-btn:focus-visible { outline: 2px solid var(--ui-accent); outline-offset: 3px; }
/* The header is 44 px tall on touch: the wordmark takes the whole band as its hit area. */
body.touch-ui .wordmark-btn { display: inline-flex; align-items: center; min-height: var(--touch-target-min); min-width: var(--touch-target-min); }
@media (pointer: coarse) {
  .sp-chips button { height: 44px; }
  .sp-primary, .sp-line { height: 48px; }
  .sp-row { min-height: 52px; }
  .sp-back, .sp-theme { min-width: 44px; min-height: 44px; }
  .sp-hdr { height: 48px; }
  .sp-aside button { min-height: 44px; padding: 0 6px; }
}
/* ===== Start Page — art (src/ui/start-page/ink.js) ===== */
/* Tile: paper background from a colorway, art layer inset by --sp-pad. Recolor = custom properties only. */
.sp-ink {
  position: relative;
  overflow: hidden;
  contain: paint;
  background-color: var(--sp-paper, #fbfaf6);
  box-shadow: 0 0 0 1px var(--ui-border);
}
.sp-ink-art {
  position: absolute;
  inset: var(--sp-pad, 8%);
}
.sp-ink-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  overflow: visible;
  color: var(--sp-ink);
  stroke-width: var(--sp-lw, 0.6px);
  stroke-opacity: var(--sp-alpha, 1);
  stroke-linecap: round;
  stroke-linejoin: round;
}
.sp-ink-svg g { stroke: currentColor; }
.sp-ink[data-sp-duo] .sp-ink-svg g { stroke: var(--sp-stroke); }
.sp-ink-svg path,
.sp-ink-svg circle,
.sp-ink-svg polyline,
.sp-ink-svg polygon,
.sp-ink-svg line { vector-effect: non-scaling-stroke; }
.sp-ink-svg [style*="--sp-w"] { stroke-width: calc(var(--sp-lw, 0.6px) * var(--sp-w)); }
/* Large pieces: a device-pixel canvas (sized in JS) tinted in place. Plain element, no mask. */
.sp-ink-canvas,
.sp-ink-draw {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  pointer-events: none;
}
/* Draw-in: the finished art hides while the plot canvas draws over it. */
.sp-ink-drawing .sp-ink-svg,
.sp-ink-drawing .sp-ink-canvas { opacity: 0; }
/* Art-filled word: real text stays for layout and assistive tech; the canvas paints the fill. */
.sp-word {
  position: relative;
  display: block;
  white-space: nowrap;
  overflow: visible;
}
.sp-word-text {
  display: inline-block;
  line-height: 1;
}
.sp-word-on .sp-word-text { color: transparent; }
.sp-word-fill {
  position: absolute;
  pointer-events: none;
}
.sp-word-line { position: absolute; pointer-events: none; }
/* ===== END Start Page — art ===== */

/* ============================================================================
 * Start Page (P1) - header tools, cover, color controls, settings, colophon strip. `.sp-` prefix.
 * ========================================================================== */
.sp-sr { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.sp-micro { font: 500 9.5px/1 var(--font-mono); letter-spacing: 0.18em; text-transform: uppercase; color: var(--ui-muted); }
.sp-ico { width: 16px; height: 16px; flex: none; }
.sp-hbtn {
  width: 28px; height: 28px; border-radius: var(--radius-sm); display: grid; place-items: center; flex: none;
  color: var(--ui-text-2); transition: background var(--dur-fast, 150ms), color var(--dur-fast, 150ms);
}
.sp-hbtn:hover, #sp-settings-btn[aria-expanded="true"] { background: var(--ui-ctrl-hov); color: var(--ui-text); }
#sp-settings-btn[aria-expanded="true"] { color: var(--ui-accent); }
.sp-hbtn#sp-motion-btn[aria-pressed="true"] { color: var(--ui-accent); }

/* cover chrome */
.sp-cover { position: relative; padding: 20px 0 16px; }
.sp-cv-top {
  display: flex; justify-content: space-between; align-items: center; gap: 16px; min-height: 26px; position: relative; z-index: 3;
  font: 500 9.5px/1 var(--font-mono); letter-spacing: 0.16em; text-transform: uppercase; color: var(--ui-muted);
}
.sp-cv-kick { display: flex; align-items: center; gap: 10px; white-space: nowrap; position: relative; }
.sp-cv-end { display: flex; align-items: center; gap: 14px; min-width: 0; }
.sp-cv-info { text-align: right; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.sp-cv-info b { color: var(--ui-text); font-weight: 600; }
.sp-cv-stage { position: relative; margin-top: 8px; }
.sp-cv-who { padding: 4px 0 0; }
.sp-cv-who:empty { display: none; }

/* cover word custom input (Start Page settings > Cover) */
.sp-wp-form { display: flex; gap: 8px; margin-top: 8px; }
.sp-wp-form[hidden] { display: none; }
.sp-wp-input { flex: 1; min-width: 0; height: 28px; padding: 0 8px; background: var(--ui-ctrl); color: var(--ui-text); border: 1px solid var(--ui-border-hi); border-radius: var(--radius-sm); font: 500 12px/1 var(--font-ui); }
.sp-wp-input:focus { outline: 2px solid var(--ui-accent); outline-offset: 1px; }

/* (1) Name in Ink */
.sp-word-wrap { position: relative; }
.sp-wline + .sp-wline { margin-top: 4px; }
.sp-word-row { display: flex; align-items: flex-end; white-space: nowrap; width: max-content; max-width: none; line-height: 1; font-family: var(--font-ui); font-weight: 700; }
.sp-lt { position: relative; display: inline-block; line-height: 1; border-radius: 2px; cursor: pointer; padding: 0; }
.sp-lt .sp-word { display: inline-block; font-size: inherit; }
/* Letters are never a solid placeholder: the hairline outline (canvas) leads, then the art plots inside the glyphs. */
.sp-lt .sp-vw, .sp-lt .sp-vw .sp-word-text { color: transparent; }
.sp-lt .sp-vw.sp-ink-error .sp-word-text { color: color-mix(in srgb, var(--sp-ph, var(--ui-text-2)) 55%, var(--ui-text-2)); }
.sp-lt:focus-visible { outline: 2px solid var(--ui-accent); outline-offset: 4px; }
.sp-gap { display: inline-block; width: 0.28em; }
.sp-pre { opacity: 0; }
.sp-key-row { position: relative; height: 30px; border-top: 1px solid var(--ui-border); margin-top: 4px; }
.sp-kk {
  position: absolute; top: 0; display: flex; align-items: center; gap: 7px; height: 22px; padding: 0 2px; transform: translateX(-50%);
  font: 400 9.5px/1 var(--font-mono); letter-spacing: 0.06em; color: var(--ui-muted); white-space: nowrap; transition: opacity 200ms ease, color 200ms ease;
}
.sp-kk::before { content: ""; position: absolute; left: 50%; top: -1px; width: 1px; height: 6px; background: var(--ui-border-hi); }
.sp-kk b { font-weight: 500; padding-top: 9px; font-variant-numeric: tabular-nums; }
.sp-kk .sp-sw2, .sp-kk .t, .sp-kk .m { display: none; }
/* At rest the key row is just its rule: no numbers or ticks under the letters. Only the hovered/focused key shows. */
.sp-kk:not(.on) { visibility: hidden; }
.sp-key-row.act .sp-kk { opacity: 0.28; }
.sp-key-row .sp-kk.on { opacity: 1; color: var(--ui-text); z-index: 2; background: var(--ui-bg); padding: 0 8px 0 6px; gap: 8px; transform: none; }
.sp-kk.on::before { display: none; }
.sp-kk.on b { padding-top: 0; color: var(--ui-accent); }
.sp-sw2 { display: inline-block; width: 14px; height: 14px; border-radius: 2px; background: var(--p, var(--ui-ctrl)); box-shadow: inset 0 0 0 1px rgba(128, 128, 128, 0.35); position: relative; overflow: hidden; flex: none; }
.sp-sw2::after { content: ""; position: absolute; left: -3px; right: -3px; top: 50%; height: 2px; margin-top: -1px; background: var(--i, currentColor); transform: rotate(-38deg); }
.sp-kk.on .sp-sw2 { display: block; }
.sp-kk.on .t { display: inline; font: 500 12px/1 var(--font-ui); letter-spacing: 0; color: var(--ui-text); }
.sp-kk.on .m { display: inline; color: var(--ui-text-2); }
.sp-bar { position: absolute; top: -1px; height: 2px; background: var(--ui-accent); opacity: 0; transition: opacity 150ms ease, left 200ms ease, width 200ms ease; }
.sp-key-row.act .sp-bar { opacity: 1; }

/* (2) Cover Specimen */
.sp-xc-h { margin: 0; font: inherit; }
.sp-xc-word { display: block; width: 100%; margin: 10px 0 0 -4px; padding: 0; border: 0; background: none; text-align: left; font: 700 200px/1 var(--font-ui); letter-spacing: normal; color: var(--ui-text); cursor: pointer; }
.sp-xc-word:focus-visible { outline: 2px solid var(--ui-accent); outline-offset: 6px; }
.sp-xc-cap { display: flex; align-items: center; gap: 8px; margin: 10px 0 0; font: 400 10.5px/1.3 var(--font-mono); color: var(--ui-muted); }
.sp-xc-cap b { color: var(--ui-text-2); font-weight: 500; }

/* (3) Portfolio band: bleeds to the column edges */
.sp-pf {
  height: 300px; margin: 0 calc(var(--sp-gut) * -1); border-top: 1px solid var(--ui-border); box-shadow: none;
}
.sp-pf.sp-ink > .sp-ink-art { inset: 0 0 0 24%; }
/* The art dissolves into the paper under the text with a gradient OVERLAY element (no CSS mask on art):
 * it covers the first 22% of the art box (the art box starts at 24% of the band). */
.sp-pf-fade { position: absolute; z-index: 1; top: 0; bottom: 0; left: 24%; width: 16.72%; pointer-events: none; background: linear-gradient(90deg, var(--sp-paper, transparent), transparent); }
.sp-pf-in { position: absolute; z-index: 2; left: var(--sp-gut); top: 22px; bottom: 24px; max-width: 700px; color: var(--sp-text, var(--ui-text)); display: flex; flex-direction: column; }
.sp-pf-eyebrow { font: 500 10px/1 var(--font-mono); letter-spacing: 0.18em; text-transform: uppercase; opacity: 0.7; }
.sp-pf-who { margin-top: 10px; }
.sp-pf .sp-cv-word, .sp-pf .sp-name { margin: 0 0 0 -2px; font: 600 54px/1 var(--font-ui); letter-spacing: -0.045em; color: inherit; }
.sp-pf .sp-name { font-weight: 300; letter-spacing: -0.04em; }
.sp-pf .sp-line-text { margin: 10px 0 0; font-size: 13.5px; line-height: 1.5; color: inherit; opacity: 0.85; max-width: 400px; }
.sp-pf-cap {
  position: absolute; z-index: 2; right: var(--sp-gut); bottom: 16px; display: inline-flex; align-items: center; gap: 8px; padding: 6px 9px 6px 7px; border-radius: 3px;
  font: 400 10.5px/1 var(--font-mono); color: var(--sp-text, var(--ui-text)); background: color-mix(in srgb, var(--sp-paper, #000) 82%, transparent) !important;
}
.sp-pf-cap em { font-style: normal; opacity: 0.7; }
.sp-pf-cap b { font-weight: 600; }

/* identity: click to edit */
.sp-editable { margin: 0; }
.sp-name { font: 300 30px/1.12 var(--font-ui); letter-spacing: -0.02em; width: max-content; max-width: 100%; }
.sp-line-text { margin: 6px 0 0; color: var(--ui-text-2); font-size: 13px; line-height: 1.55; max-width: 62ch; }
.sp-edit-btn { font: inherit; letter-spacing: inherit; color: inherit; text-align: left; border-radius: 3px; cursor: text; max-width: 100%; }
.sp-edit-btn:hover { box-shadow: 0 0 0 1px var(--ui-border-hi); }
.sp-edit-btn.is-placeholder { opacity: 0.55; }
.sp-line-text .sp-edit-btn.is-placeholder { font-style: italic; }
.sp-edit-input { font: inherit; letter-spacing: inherit; color: inherit; width: min(100%, 560px); background: var(--ui-ctrl); border: 1px solid var(--ui-accent); border-radius: 3px; padding: 0 6px; }
.sp-edit-input:focus { outline: none; box-shadow: 0 0 0 2px var(--ui-accent-2, transparent); }

/* empty cover */
.sp-cover-empty-word { margin: 6px 0 0 -2px; font: 700 clamp(64px, 16vw, 200px)/1 var(--font-ui); color: transparent; -webkit-text-stroke: 1.5px var(--ui-border-hi); letter-spacing: normal; }
.sp-cover-empty p { margin: 10px 0 0; max-width: 56ch; color: var(--ui-text-2); font-size: 13px; line-height: 1.6; }

/* color controls under the cover */
.sp-ctl-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.sp-seg { display: inline-flex; border: 1px solid var(--ui-border-hi); border-radius: var(--radius-sm); overflow: hidden; background: var(--ui-ctrl); }
.sp-seg button { height: 26px; padding: 0 11px; font-size: 11.5px; font-weight: 500; color: var(--ui-text-2); position: relative; transition: background var(--dur-fast, 150ms), color var(--dur-fast, 150ms); }
.sp-seg button + button { border-left: 1px solid var(--ui-border); }
.sp-seg button:hover { color: var(--ui-text); }
.sp-seg button[aria-checked="true"] { background: var(--ui-ctrl-hov); color: var(--ui-text); font-weight: 600; }
.sp-seg button[aria-checked="true"]::after { content: ""; position: absolute; left: 10px; right: 10px; bottom: 3px; height: 2px; background: var(--ui-accent); }
.sp-seg button:focus-visible { outline-offset: -2px; }
.sp-dice { display: inline-flex; align-items: center; gap: 8px; height: 28px; padding: 0 10px; border: 1px solid var(--ui-border-hi) !important; border-radius: var(--radius-sm); background: var(--ui-ctrl) !important; color: var(--ui-text-2); font: 500 10.5px/1 var(--font-mono); letter-spacing: 0.08em; }
.sp-dice:hover { border-color: var(--ui-accent) !important; color: var(--ui-text); }
.sp-dice.is-random { color: var(--ui-accent-text, var(--ui-accent)); border-color: var(--ui-accent) !important; }
/* The seed is text: keep it at full strength (4.5:1); the idle state reads from the muted token, not from opacity. */
.sp-dice:not(.is-random) .sp-seed { color: var(--ui-text-2); }
.sp-dice-ico { display: inline-grid; }
.sp-dice-ico .sp-ico { width: 14px; height: 14px; }
.sp-sw { display: inline-flex; align-items: center; gap: 4px; margin-left: 2px; }
.sp-sw i { width: 14px; height: 16px; border-radius: 2px; background: var(--p); position: relative; overflow: hidden; box-shadow: inset 0 0 0 1px rgba(128, 128, 128, 0.35); }
.sp-sw i::after { content: ""; position: absolute; left: -3px; right: -3px; top: 50%; height: 2px; margin-top: -1px; background: linear-gradient(90deg, var(--i), var(--i2)); transform: rotate(-38deg); }
.sp-sw b { font: 400 10px/1 var(--font-mono); color: var(--ui-muted); margin-left: 3px; }
.sp-own-note { flex-basis: 100%; font: 400 10.5px/1.4 var(--font-mono); color: var(--ui-muted); }

/* settings popover */
.sp-settings {
  position: absolute; z-index: 30; top: 42px; right: 12px; width: min(400px, calc(100% - 24px)); max-height: calc(100% - 54px); overflow: auto; padding: 14px 16px 12px;
  background: var(--ui-panel); border: 1px solid var(--ui-border-hi); border-top: 2px solid var(--ui-accent); border-radius: var(--radius-md); box-shadow: var(--shadow-lg);
}
.sp-settings[hidden] { display: none; }
.sp-settings h2 { margin: 0; font-size: 13px; font-weight: 600; }
.sp-set-sub { margin: 3px 0 10px; font: 400 10px/1.2 var(--font-mono); color: var(--ui-muted); }
.sp-set-sec { padding: 12px 0 8px; border-top: 1px solid var(--ui-border); }
.sp-set-sec[hidden] { display: none; }
.sp-set-sec .sp-micro { display: block; margin-bottom: 10px; }
.sp-styles { display: flex; flex-direction: column; gap: 6px; }
.sp-style { display: flex; gap: 12px; align-items: center; width: 100%; padding: 8px; text-align: left; border: 1px solid var(--ui-border); border-radius: var(--radius-sm); background: var(--ui-ctrl); transition: border-color var(--dur-fast, 150ms); }
.sp-style:hover { border-color: var(--ui-border-hi); }
.sp-style[aria-checked="true"] { border-color: var(--ui-accent); background: var(--ui-accent-2); }
.sp-style-art { flex: none; width: 62px; height: 40px; border-radius: 2px; overflow: hidden; background: #1c1c1e; color: #888; display: block; }
.sp-style-art svg { width: 100%; height: 100%; display: block; }
.sp-style-tx { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.sp-style-tx b { font-size: 12px; font-weight: 600; }
.sp-style-tx b em { margin-left: 8px; font: 500 9px/1 var(--font-mono); font-style: normal; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ui-accent-text, var(--ui-accent)); }
.sp-style-tx > span { font-size: 11px; line-height: 1.4; color: var(--ui-text-2); }
.sp-set-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 30px; font-size: 12px; font-weight: 500; }
.sp-switch { position: relative; width: 30px; height: 18px; border-radius: 9px; flex: none; background: var(--ui-border-hi) !important; transition: background var(--dur-fast, 150ms); }
.sp-switch[aria-checked="true"] { background: var(--ui-accent) !important; }
.sp-switch-knob { position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: #fff; transition: transform var(--dur-fast, 150ms); }
.sp-switch[aria-checked="true"] .sp-switch-knob { transform: translateX(12px); }
.sp-switch[aria-checked="true"] .sp-switch-knob { background: var(--sp-knob-on, #fff); }
.sp-set-label { display: block; font-size: 12px; font-weight: 500; }
.sp-set-label-gap { margin-top: 14px; margin-bottom: 8px; }
.sp-switch:disabled { opacity: 0.45; cursor: not-allowed; }
.sp-set-help { margin: 8px 0 0; font-size: 10.5px; line-height: 1.5; color: var(--ui-muted); }

/* colophon strip: the rail collapsed (or the page narrow) */
.sp-colo-wrap { display: grid; grid-template-rows: 0fr; background: var(--ui-panel); position: relative; z-index: 6; visibility: hidden; transition: grid-template-rows 340ms cubic-bezier(0.2, 0.7, 0.2, 1), visibility 0s linear 340ms; flex: none; }
.sp-colo-in { min-height: 0; overflow: hidden; }
.sp[data-rail="closed"] .sp-colo-wrap { grid-template-rows: 1fr; visibility: visible; border-bottom: 1px solid var(--ui-border); transition: grid-template-rows 340ms cubic-bezier(0.2, 0.7, 0.2, 1), visibility 0s; }
@container sp (max-width: 900px) {
  .sp-colo-wrap { grid-template-rows: 1fr; visibility: visible; border-bottom: 1px solid var(--ui-border); transition: none; }
}
.sp-colo { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 22px; align-items: start; padding: 10px 36px 11px 36px; opacity: 0; transform: translateY(-6px); transition: opacity 260ms ease 60ms, transform 340ms cubic-bezier(0.2, 0.7, 0.2, 1); }
.sp[data-rail="closed"] .sp-colo { opacity: 1; transform: none; }
.sp-co-acts { display: flex; gap: 6px; align-items: center; padding-top: 16px; flex-wrap: wrap; }
.sp-co-btn { height: 28px; padding: 0 10px; border-radius: var(--radius-sm); border: 1px solid var(--ui-border-hi) !important; background: var(--ui-ctrl) !important; font-size: 11.5px; font-weight: 500; display: inline-flex; align-items: center; gap: 7px; white-space: nowrap; transition: border-color var(--dur-fast, 150ms), filter var(--dur-fast, 150ms); }
.sp-co-btn:hover { border-color: var(--ui-accent) !important; }
.sp-co-btn:focus-visible { outline: none; border-color: var(--ui-accent) !important; box-shadow: inset 0 0 0 2px var(--ui-accent); }
.sp-co-btn kbd { font-size: 9.5px; }
.sp-co-btn.pri { background: var(--ui-accent) !important; border-color: var(--ui-accent) !important; color: var(--ui-on-accent, #fff); }
.sp-co-btn.pri kbd { color: color-mix(in srgb, var(--ui-on-accent, #fff) 78%, transparent); }
.sp-co-btn.pri:hover { filter: brightness(1.08); }
.sp-co-btn.res b { font: 500 10.5px/1 var(--font-mono); max-width: 180px; overflow: hidden; text-overflow: ellipsis; }
.sp-co-btn.res .k { color: var(--ui-accent-text, var(--ui-accent)); }
.sp-co-list { min-width: 0; }
.sp-co-h { display: flex; gap: 10px; align-items: baseline; font: 500 9.5px/1 var(--font-mono); letter-spacing: 0.16em; text-transform: uppercase; color: var(--ui-muted); margin-bottom: 5px; }
.sp-co-h b { color: var(--ui-text); font-weight: 600; }
.sp-co-h .grow { flex: 1; }
.sp-co-h button { letter-spacing: 0.08em; color: var(--ui-text-2); }
.sp-co-h button:hover { color: var(--ui-danger); }
.sp-co-rows { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 22px; }
@container sp (min-width: 1280px) { .sp-co-rows { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.sp-co-row { width: 100%; display: grid; grid-template-columns: 18px 22px minmax(0, 1fr) auto; gap: 8px; align-items: center; height: 29px; border-top: 1px solid var(--ui-border); text-align: left; padding: 0 2px; font-size: 11.5px; transition: background var(--dur-fast, 150ms); }
.sp-co-rows li:nth-child(-n+2) .sp-co-row { border-top-color: var(--ui-border-hi); }
@container sp (min-width: 1280px) { .sp-co-rows li:nth-child(-n+4) .sp-co-row { border-top-color: var(--ui-border-hi); } }
.sp-co-row:hover, .sp-co-row:focus-visible { background: var(--ui-ctrl-hov); outline: none; }
.sp-co-row:focus-visible { box-shadow: inset 0 0 0 2px var(--ui-accent); }
.sp-co-row .n { font: 400 9.5px/1 var(--font-mono); color: var(--ui-muted); font-variant-numeric: tabular-nums; }
.sp-co-row .sp-thumb { width: 22px; height: 22px; }
.sp-co-row .nm { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; font-weight: 500; }
.sp-co-row .nm i { font: 400 9.5px/1 var(--font-mono); font-style: normal; color: var(--ui-muted); margin-left: 6px; }
.sp-co-empty { font-size: 11.5px; color: var(--ui-muted); padding: 6px 0; }
@container sp (max-width: 900px) {
  .sp-colo { grid-template-columns: minmax(0, 1fr); gap: 10px; padding: 10px 18px 12px; opacity: 1; transform: none; }
  .sp-co-acts { padding-top: 0; }
  .sp-co-rows { grid-auto-flow: column; grid-template-columns: none; grid-auto-columns: 230px; overflow-x: auto; padding-bottom: 4px; }
  .sp-co-rows li:nth-child(-n+2) .sp-co-row { border-top-color: var(--ui-border); }
  .sp-cv-info { display: none; }
  .sp-ctl-row { gap: 8px; }
  .sp-settings { right: 8px; }
}
@media (pointer: coarse) {
  .sp-hbtn { min-width: 44px; min-height: 44px; }
  .sp-seg button { height: 40px; }
  .sp-dice, .sp-co-btn { min-height: 40px; min-width: 40px; }
  .sp-co-row { height: 44px; }
  .sp-co-btn kbd { display: none; }
  .sp-switch { width: 44px; height: 26px; border-radius: 13px; }
  .sp-switch-knob { width: 20px; height: 20px; top: 3px; left: 3px; }
  .sp-switch[aria-checked="true"] .sp-switch-knob { transform: translateX(18px); }
}

/* Start Page: thumbnails tinted into the work's colorway (rail rows, colophon rows, Resume) */
.sp-thumb .sp-tint, .sp-cth .sp-tint { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }

/* ===== Start Page — Plates (P2) ===== */
/* Plate layouts (src/ui/start-page/plates/layouts.js): every plate is a sheet on its own ground, colors in --spl-* */
/* ===================================================================================================
   Start Page plate layouts (src/ui/start-page/plates/layouts.js). Folded in from the staging file.
   components.css. A plate is a sheet on its own ground; display type and art are in the pen color.
   Colors come from --spl-* custom properties set on each .spl (StartPagePlateType.plateVars).
   =================================================================================================== */
.spl{
  --spl-px:clamp(16px,2.1vw,30px);
  container-type:inline-size;container-name:spl;
  position:relative;margin:0;padding:20px var(--spl-px) 30px;border-radius:2px;
  background:var(--spl-paper);color:var(--spl-text);
  font:400 12px/1.45 var(--font-ui,'Space Grotesk',system-ui,sans-serif);
  box-shadow:0 0 0 1px color-mix(in srgb,var(--spl-text) 14%,transparent);
  transition:background-color 460ms var(--ease,ease),color 460ms var(--ease,ease);
}
.spl *{box-sizing:border-box}
.spl :focus-visible{outline:2px solid var(--spl-text);outline-offset:2px}
.spl-mono,.spl-h,.spl-spec,.spl-spm-label,.spl-spm-meta,.spl-wf-px,.spl-wf-pen,.spl-stg-i figcaption,.spl-dt-lab,.spl-g4-n,.spl-pq footer,.spl-wrap-txt .al,.spl-3dhint{font-family:var(--font-mono,'JetBrains Mono',ui-monospace,monospace)}

/* header */
.spl-h{display:flex;align-items:center;gap:14px;min-height:40px;margin-bottom:20px;padding-bottom:12px;border-bottom:1px solid var(--spl-line);
  font-size:9.5px;line-height:1;letter-spacing:.14em;text-transform:uppercase;color:var(--spl-mute)}
.spl-no{white-space:nowrap}.spl-no b{color:var(--spl-text);font-weight:600}
.spl-hs{display:inline-flex;align-items:center;gap:7px;min-width:0;margin-left:auto}
.spl-hs>span{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;min-width:0}
.spl-sw{width:10px;height:13px;border-radius:1.5px;flex:none;position:relative;overflow:hidden;background:var(--spl-paper);box-shadow:inset 0 0 0 1px var(--spl-line)}
.spl-sw::after{content:"";position:absolute;left:-3px;right:-3px;top:50%;height:2px;margin-top:-1px;background:var(--spl-ink);transform:rotate(-40deg)}
.spl-tools{display:inline-flex;align-items:center;gap:6px;flex:none}
.spl-tools:empty{display:none}

/* body, art, type */
.spl-b{position:relative}
.spl-print,.spl-crop{display:block;position:relative;overflow:hidden;min-width:0}
.spl-print{aspect-ratio:var(--ar,4/3)}
.spl-print.framed{box-shadow:0 0 0 1px var(--spl-line)}
.spl-print[data-3d][data-hint]::after{content:attr(data-hint);position:absolute;left:50%;bottom:8px;transform:translateX(-50%);font:400 10px/1 var(--font-mono,monospace);letter-spacing:.06em;color:var(--spl-mute);pointer-events:none;opacity:.8}
.spl-crop{box-shadow:0 0 0 1px var(--spl-line)}
.spl-title{margin:0;font:300 28px/1.12 var(--font-ui,'Space Grotesk',system-ui,sans-serif);letter-spacing:-.02em;color:var(--spl-text)}
.spl-note{margin:10px 0 0;font-size:12.5px;line-height:1.6;max-width:52ch;color:var(--spl-text);overflow-wrap:anywhere}
.spl-spec{display:grid;grid-template-columns:auto minmax(0,1fr);gap:5px 16px;margin:18px 0 0;font-size:10.5px;line-height:1.35}
.spl-spec dt{margin:0;padding-top:1px;font-size:9px;letter-spacing:.12em;text-transform:uppercase;color:var(--spl-mute)}
.spl-spec dd{margin:0;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;color:var(--spl-text);font-variant-numeric:tabular-nums}
.spl-acts{display:flex;flex-wrap:wrap;gap:8px;margin-top:20px}
.spl-acts:empty{display:none}
.spl-btn{height:30px;padding:0 12px;display:inline-flex;align-items:center;gap:7px;border-radius:var(--radius-sm,4px);font:500 12px/1 var(--font-ui,'Space Grotesk',system-ui,sans-serif);white-space:nowrap;cursor:pointer;
  border:1px solid color-mix(in srgb,var(--spl-text) 42%,transparent);background:transparent;color:var(--spl-text)}
.spl-btn:hover{border-color:var(--spl-text)}
.spl-btn-p{background:var(--spl-text);color:var(--spl-paper);border-color:var(--spl-text)}
.spl-btn-p:hover{filter:brightness(1.08)}

/* display words: SVG text from the real ink box. Width and height are caps; the glyphs scale with "meet", so nothing clips. */
.spl-hw,.spl-vw{display:block;min-width:0;color:var(--spl-ink)}
.spl-hword,.spl-vword{display:block;overflow:visible}
.spl-hword text,.spl-vword text{fill:currentColor}
.spl-hword{width:100%;height:auto;max-width:var(--spl-mw,100%)}
.spl-vw{align-self:stretch;min-height:140px;position:relative;--spl-vh:320px;width:min(150px,calc(var(--spl-vh) * var(--spl-vr,.3)))}
/* The column's width is definite (height x the word's aspect, capped); the SVG just fills it. A height:100%/width:auto SVG in an
   auto grid column collapsed to 0 on iPad Safari, leaving the letters spilling out behind the art. */
.spl-vword{position:absolute;inset:0;width:100%;height:100%}
.spl-hw.inv{color:var(--spl-paper)}
.spl-hw.num{color:var(--spl-ink)}

/* vertical word / spec sheet */
.spl-lay-vertical-word .spl-vw{--spl-vh:min(520px,62vh)}
.spl-lay-spec-sheet .spl-vw{--spl-vh:min(500px,60vh)}
.spl-lay-words-both-sides .spl-vw{--spl-vh:min(460px,56vh)}
.spl-lay-vertical-word .spl-b,.spl-lay-spec-sheet .spl-b{display:grid;grid-template-columns:auto minmax(0,1fr) minmax(240px,300px);gap:30px;align-items:stretch;height:min(520px,62vh);min-height:380px}
.spl-lay-spec-sheet .spl-b{align-items:center;height:min(500px,60vh)}
.spl-lay-vertical-word .spl-print,.spl-lay-spec-sheet .spl-print{height:100%;width:100%;aspect-ratio:auto}
.spl-lay-vertical-word .spl-cap{display:flex;flex-direction:column;justify-content:flex-end;min-width:0}
.spl-lay-spec-sheet .spl-cap{min-width:0}
/* text wrap: the art sits in a disc and the copy flows around it */
.spl-lay-text-wrap .spl-b{display:flow-root}
.spl-disc{float:left;position:relative;width:min(400px,42%);aspect-ratio:1;margin:0 34px 14px 0;border-radius:50%;shape-outside:circle(50%);shape-margin:14px;background:var(--spl-disc);transition:background-color 460ms var(--ease,ease)}
.spl-disc .spl-print{position:absolute;inset:0;width:100%;height:100%;aspect-ratio:auto;border-radius:50%;overflow:hidden;box-shadow:none}
.spl-disc .spl-print[data-3d]::after{display:none}
.spl-3dhint{position:absolute;left:50%;bottom:7%;z-index:2;transform:translateX(-50%);font-size:10px;letter-spacing:.06em;color:color-mix(in srgb,var(--spl-mute) 55%,var(--spl-text));white-space:nowrap}
.spl-wrap-txt{margin:6px 0 0;font:400 25px/1.42 var(--font-ui,'Space Grotesk',system-ui,sans-serif);letter-spacing:-.01em;color:var(--spl-text);overflow-wrap:anywhere}
.spl-wrap-txt b{font-weight:600}
.spl-wrap-txt .al{margin:0 10px 0 8px;font-size:10px;font-weight:500;letter-spacing:.14em;text-transform:uppercase;color:var(--spl-acc);vertical-align:4px}
.spl-wrap-txt .fact{color:var(--spl-mute)}
/* waterfall */
.spl-lay-waterfall .spl-b{display:grid;grid-template-columns:minmax(0,1.25fr) minmax(0,1fr);gap:40px;align-items:start}
.spl-wf-row{display:grid;grid-template-columns:44px minmax(0,1fr) 58px 64px;gap:14px;align-items:center;padding:6px 0;border-bottom:1px solid var(--spl-line)}
.spl-wf-row:first-child{border-top:1px solid var(--spl-line)}
.spl-wf-px,.spl-wf-pen{font-size:9.5px;letter-spacing:.06em;color:var(--spl-mute)}
.spl-wf-pen{text-align:right;white-space:nowrap}
.spl-wf-row:last-child .spl-wf-pen{color:var(--spl-acc)}
.spl-wf-w{display:block;min-width:0;color:var(--spl-ink);padding:.02em 0 .1em}
.spl-wf-w .spl-hword{width:auto;height:calc(var(--s,1)*min(104px,16cqi));max-width:100%}
.spl-wf-mini{display:block;width:64px;height:48px;box-shadow:0 0 0 1px var(--spl-line)}
.spl-wf-side .spl-cap{margin-top:14px}
/* knockout: a pen-color band with the word cut from the paper and the art plotted inside it */
.spl-ko-band{margin:0 calc(-1*var(--spl-px));padding:18px var(--spl-px) 22px;background:var(--spl-ink)}
.spl-ko-word{margin:0 0 0 -4px;color:var(--spl-paper);font:700 clamp(40px,12cqi,230px)/1 var(--font-ui,'Space Grotesk',system-ui,sans-serif);letter-spacing:-.05em;white-space:nowrap}
.spl-ko-foot{display:grid;grid-template-columns:150px minmax(0,1.3fr) minmax(200px,260px) auto;gap:20px 30px;align-items:center;margin-top:20px}
.spl-ko-foot .spl-spec{margin:0}
.spl-ko-acts{flex-direction:column;align-items:stretch;margin:0}
/* full sheet */
.spl-lay-full-sheet .spl-b{display:grid;grid-template-columns:minmax(0,1fr) minmax(220px,280px);gap:34px;align-items:end}
.spl-lay-full-sheet .spl-print{width:100%;max-height:560px}
.spl-sheet-cap .spl-hw{margin-bottom:14px}
/* full bleed + pen-color caption band */
.spl-lay-full-bleed-band{padding-bottom:0;overflow:hidden}
.spl-bleed-art{position:relative;margin:0 calc(-1*var(--spl-px));height:min(500px,58vh);min-height:320px}
.spl-bleed-art .spl-print{position:absolute;inset:0;width:100%;height:100%;aspect-ratio:auto}
.spl-cband{margin:0 calc(-1*var(--spl-px));padding:18px var(--spl-px) 22px;background:var(--spl-ink);color:var(--spl-band-on,var(--spl-inv));display:grid;grid-template-columns:auto minmax(0,1fr) minmax(200px,260px) auto;gap:16px 28px;align-items:center}
.spl-cband .spl-hw{color:var(--spl-paper)}
.spl-band-w{min-width:0;max-width:340px}
.spl-cband .spl-title,.spl-cband .spl-note,.spl-cband .spl-spec dd{color:var(--spl-band-on,var(--spl-inv))}
.spl-cband .spl-spec dt{color:color-mix(in srgb,var(--spl-band-on,var(--spl-inv)) 78%,var(--spl-ink))}
.spl-cband .spl-note{margin-top:6px}
.spl-cband .spl-spec,.spl-cband .spl-acts{margin:0}
.spl-cband .spl-btn-p{background:var(--spl-band-on,var(--spl-inv));color:var(--spl-band-rep,var(--spl-ink));border-color:var(--spl-band-on,var(--spl-inv))}
.spl-cband .spl-btn-s{color:var(--spl-band-on,var(--spl-inv));border-color:color-mix(in srgb,var(--spl-band-on,var(--spl-inv)) 45%,transparent)}
/* diptych */
.spl-lay-diptych .spl-b{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1fr)}
.spl-dip-l{padding-right:30px;border-right:1px solid var(--spl-line)}
.spl-dip-l .spl-print{width:100%;aspect-ratio:1}
.spl-dip-r{padding-left:30px;display:flex;flex-direction:column;justify-content:space-between;gap:20px;min-width:0}
/* specimen with a ruled frame */
.spl-lay-specimen-frame .spl-b{display:flex;flex-direction:column;align-items:center;text-align:center}
.spl-spm-label{margin-bottom:14px;font-size:9.5px;letter-spacing:.2em;text-transform:uppercase;color:var(--spl-acc)}
.spl-spm-frame{position:relative;width:min(560px,70%);aspect-ratio:4/3;padding:14px;border:1px solid var(--spl-text);outline:1px solid var(--spl-line);outline-offset:6px}
.spl-spm-frame .spl-print{position:absolute;inset:14px;width:auto;height:auto;aspect-ratio:auto}
.spl-lay-specimen-frame .spl-title{margin-top:26px}
.spl-lay-specimen-frame .spl-note{margin-left:auto;margin-right:auto}
.spl-spm-meta{display:flex;flex-wrap:wrap;justify-content:center;gap:4px 16px;margin-top:12px;font-size:10px;color:var(--spl-mute)}
.spl-spm-meta span+span::before{content:"\00b7";margin-right:16px}
.spl-lay-specimen-frame .spl-acts{justify-content:center}
/* big numeral */
.spl-lay-big-numeral .spl-b{display:grid;grid-template-columns:minmax(220px,.8fr) minmax(0,1.2fr);gap:34px;align-items:stretch}
.spl-num-col{display:flex;flex-direction:column;justify-content:space-between;gap:20px;min-width:0}
.spl-lay-big-numeral .spl-print{width:100%;align-self:center}
/* words on both sides */
.spl-lay-words-both-sides .spl-b{display:grid;grid-template-columns:auto minmax(0,1fr) auto;grid-template-rows:min(460px,56vh) auto;gap:22px 28px;align-items:stretch}
.spl-vb-mid{position:relative;min-width:0}
.spl-vb-mid .spl-print{position:absolute;inset:0;width:100%;height:100%;aspect-ratio:auto}
.spl-vb-cap{grid-column:1/-1;display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1.2fr) auto auto;gap:20px 30px;align-items:end;padding-top:16px;border-top:1px solid var(--spl-line)}
.spl-vb-cap .spl-note,.spl-vb-cap .spl-spec,.spl-vb-cap .spl-acts{margin:0}
/* plot stages */
.spl-stg{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:16px}
.spl-stg-i{margin:0;min-width:0}
.spl-stage,.spl-stg-i .spl-print{display:block;width:100%;aspect-ratio:4/3;box-shadow:0 0 0 1px var(--spl-line)}
.spl-stg-i figcaption{margin-top:8px;font-size:9.5px;letter-spacing:.12em;text-transform:uppercase;color:var(--spl-mute)}
.spl-stg-i:last-child figcaption{color:var(--spl-acc)}
.spl-stg-cap{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1.3fr) minmax(200px,260px) auto;gap:20px 30px;align-items:end;margin-top:20px;padding-top:16px;border-top:1px solid var(--spl-line)}
.spl-stg-cap .spl-note,.spl-stg-cap .spl-spec,.spl-stg-cap .spl-acts{margin:0}
/* knockout title over art */
.spl-kt-art{position:relative;margin:0 calc(-1*var(--spl-px));height:min(500px,60vh);min-height:320px;overflow:hidden}
.spl-kt-art .spl-print{position:absolute;inset:0 0 18% 0;width:100%;height:auto;aspect-ratio:auto}
.spl-kt-band{position:absolute;left:0;right:0;bottom:0;padding:14px var(--spl-px) 16px;background:var(--spl-ink)}
.spl-kt-foot{display:grid;grid-template-columns:minmax(0,1.3fr) minmax(200px,260px) auto;gap:20px 30px;align-items:end;margin-top:20px}
.spl-kt-foot .spl-spec,.spl-kt-foot .spl-acts{margin:0}
/* detail + full */
.spl-lay-detail-full .spl-b{display:grid;grid-template-columns:minmax(0,1.5fr) minmax(240px,1fr);gap:30px}
.spl-dt-big{position:relative}
.spl-dt-big .spl-crop{aspect-ratio:4/3;width:100%}
.spl-dt-lab,.spl-g4-n{position:absolute;left:10px;top:10px;z-index:2;padding:4px 7px;border-radius:2px;font-size:9.5px;letter-spacing:.14em;text-transform:uppercase;background:var(--spl-paper);color:var(--spl-acc)}
.spl-dt-full{position:relative}
.spl-dt-full .spl-print{width:100%}
.spl-dt-mark{position:absolute;pointer-events:none;border:1.5px solid var(--spl-acc);width:calc(100%/var(--z));height:calc(100%/var(--z));left:calc((var(--x) - .5/var(--z))*100%);top:calc((var(--y) - .5/var(--z))*100%)}
.spl-dt-side .spl-cap{margin-top:16px}
/* four crops */
.spl-lay-four-crops .spl-b{display:grid;grid-template-columns:minmax(0,1.3fr) minmax(240px,1fr);gap:30px}
.spl-g4{display:grid;grid-template-columns:1fr 1fr;gap:10px}
.spl-g4-c{position:relative}
.spl-g4-c .spl-crop{aspect-ratio:1;width:100%}
.spl-g4-full{width:56%}
.spl-g4-side .spl-cap{margin-top:16px}
/* pull quote */
.spl-lay-pull-quote .spl-b{display:grid;grid-template-columns:minmax(0,1.6fr) minmax(220px,1fr);gap:40px;align-items:end}
.spl-pq{margin:0}
.spl-pq p{margin:0;font:300 38px/1.22 var(--font-ui,'Space Grotesk',system-ui,sans-serif);letter-spacing:-.02em;text-indent:-.42em;color:var(--spl-ink);overflow-wrap:anywhere}
.spl-pq footer{margin-top:20px;font-size:10px;letter-spacing:.14em;text-transform:uppercase;color:var(--spl-acc)}
.spl-pq-side .spl-print{width:100%}

/* container-query responsiveness (the plate, not the viewport) */
@container spl (max-width:1060px){
  .spl-cband{grid-template-columns:auto minmax(0,1fr) auto}.spl-cband .spl-spec{display:none}
  .spl-stg-cap{grid-template-columns:minmax(0,1fr) minmax(0,1.3fr) auto}.spl-stg-cap .spl-spec{display:none}
  .spl-vb-cap{grid-template-columns:minmax(0,1fr) minmax(0,1.2fr) auto}.spl-vb-cap .spl-spec{display:none}
  .spl-pq p{font-size:32px}
}
@container spl (max-width:900px){
  .spl-lay-detail-full .spl-b,.spl-lay-four-crops .spl-b,.spl-lay-pull-quote .spl-b{grid-template-columns:1fr}
  .spl-g4-full{width:40%}
  .spl-kt-foot{grid-template-columns:minmax(0,1fr) auto}.spl-kt-foot .spl-spec{display:none}
  .spl-ko-foot{grid-template-columns:150px minmax(0,1fr) auto}.spl-ko-foot .spl-spec{display:none}
}
@container spl (max-width:640px){
  .spl-h{flex-wrap:wrap;row-gap:8px}.spl-hs{margin-left:0;flex-basis:100%;order:3}
  .spl-lay-vertical-word .spl-b,.spl-lay-spec-sheet .spl-b{display:grid;grid-template-columns:auto minmax(0,1fr);height:auto;min-height:0}
  .spl-lay-vertical-word .spl-print,.spl-lay-spec-sheet .spl-print{height:auto;aspect-ratio:var(--ar,4/3)}
  .spl-lay-vertical-word .spl-cap,.spl-lay-spec-sheet .spl-cap{grid-column:1/-1}
  .spl-lay-vertical-word .spl-vw,.spl-lay-spec-sheet .spl-vw{max-height:320px}
  .spl-vw{width:min(58px,calc(320px * var(--spl-vr,.3)))}
  .spl-title{font-size:24px}
  .spl-bleed-art{height:auto;min-height:0;aspect-ratio:4/3}
  .spl-cband{grid-template-columns:1fr;gap:12px}
  .spl-lay-diptych .spl-b{grid-template-columns:1fr}.spl-dip-l{padding:0 0 18px;border-right:0;border-bottom:1px solid var(--spl-line)}.spl-dip-r{padding:18px 0 0}
  .spl-spm-frame{width:100%}
  .spl-lay-big-numeral .spl-b{grid-template-columns:1fr}.spl-num-col{display:contents}.spl-lay-big-numeral .spl-hw{order:-1}
  .spl-lay-words-both-sides .spl-b{grid-template-columns:auto minmax(0,1fr);grid-template-rows:auto auto}
  .spl-vw.vr{display:none}.spl-vb-mid{aspect-ratio:var(--ar,4/3);width:100%}.spl-vb-cap{grid-template-columns:1fr}
  .spl-lay-waterfall .spl-b{grid-template-columns:1fr;gap:24px}
  .spl-wf-row{grid-template-columns:36px minmax(0,1fr) 56px;gap:8px}.spl-wf-mini{display:none}
  .spl-lay-full-sheet .spl-b{grid-template-columns:1fr;gap:20px}
  .spl-stg{grid-template-columns:1fr 1fr}.spl-stg-cap{grid-template-columns:1fr}
  .spl-kt-art{height:auto;min-height:0;aspect-ratio:3/4}.spl-kt-foot{grid-template-columns:1fr}
  .spl-ko-foot{grid-template-columns:1fr}.spl-ko-foot .spl-print{width:150px}
  .spl-g4-full{width:60%}
  .spl-pq p{font-size:24px}
  .spl-wrap-txt{font-size:20px}
  .spl-disc{width:min(52%,260px);margin-right:18px}
}

/* Plates section (src/ui/start-page/plates/section.js) */
.sp-plates { padding: 34px 0 8px; }
.sp-pl-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px 20px; flex-wrap: wrap; }
.sp-pl-titles { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; min-width: 0; }
.sp-pl-title { margin: 0; font: 300 26px/1.1 var(--font-ui); letter-spacing: -0.02em; color: var(--ui-text); }
.sp-pl-count { font: 500 10px/1 var(--font-mono); letter-spacing: 0.12em; text-transform: uppercase; color: var(--ui-muted); }
.sp-pl-explain { margin: 10px 0 18px; max-width: 70ch; color: var(--ui-text-2); font-size: 12px; line-height: 1.55; }
.sp-pl-tools { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; position: relative; }
.sp-pl-btn { display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 11px; border: 1px solid var(--ui-border-hi); border-radius: var(--radius-sm); background: var(--ui-ctrl); color: var(--ui-text-2); font-size: 11.5px; font-weight: 500; }
.sp-pl-btn:hover { color: var(--ui-text); background: var(--ui-ctrl-hov); }
.sp-pl-btn[aria-pressed="true"] { color: var(--ui-text); border-color: var(--ui-accent); }
.sp-pl-btn[hidden], .sp-pl-show[hidden] { display: none; }
.sp-pl-show { display: inline-flex; align-items: center; gap: 7px; font: 500 10px/1 var(--font-mono); letter-spacing: 0.12em; text-transform: uppercase; color: var(--ui-muted); }
.sp-pl-show select { height: 28px; padding: 0 8px; border: 1px solid var(--ui-border-hi); border-radius: var(--radius-sm); background: var(--ui-ctrl); color: var(--ui-text); font: 500 11.5px/1 var(--font-ui); letter-spacing: 0; text-transform: none; }
.sp-pl-menu { position: absolute; z-index: 20; top: 32px; left: 0; min-width: 200px; max-height: 260px; overflow: auto; padding: 4px; display: flex; flex-direction: column; border: 1px solid var(--ui-border-hi); border-radius: var(--radius-sm); background: var(--ui-bg-2, var(--ui-bg)); box-shadow: 0 10px 28px rgba(0, 0, 0, 0.28); }
.sp-pl-menu[hidden] { display: none; }
.sp-pl-menu button { text-align: left; padding: 7px 10px; border-radius: 3px; font-size: 12px; color: var(--ui-text-2); }
.sp-pl-menu-h { padding: 8px 10px 4px; font: 600 10px/1 var(--font-mono, monospace); letter-spacing: .12em; text-transform: uppercase; color: var(--ui-text-3, var(--ui-text-2)); border-top: 1px solid var(--ui-border); margin-top: 4px; }
.sp-pl-menu button:hover, .sp-pl-menu button:focus-visible { background: var(--ui-ctrl-hov); color: var(--ui-text); }
.sp-pl-empty { display: grid; gap: 6px; padding: 28px 22px; margin: 16px 0; border: 1px dashed var(--ui-border-hi); border-radius: var(--radius-sm); color: var(--ui-text-2); font-size: 12.5px; line-height: 1.55; }
.sp-pl-empty b { color: var(--ui-text); font-weight: 600; font-size: 14px; }
.sp-pl-empty a { color: var(--ui-accent); text-underline-offset: 3px; }
.sp-pl-empty[hidden], .sp-pl-more[hidden], .sp-pl-explain[hidden] { display: none; }
.sp-pl-list { display: flex; flex-direction: column; }
.sp-pl-list[data-arranging="true"] > .sp-pl { display: none; }
/* a plate row collapses with grid-template-rows (no display:none <-> max-height swap) */
.sp-pl { display: grid; grid-template-rows: 1fr; opacity: 1; visibility: visible; }
.sp-pl-in { --sp-pl-pad: 28px; box-sizing: border-box; min-height: 0; min-width: 0; overflow: clip; overflow-clip-margin: 6px; padding-bottom: var(--sp-pl-pad); }
.sp-pl[data-off] { grid-template-rows: 0fr; opacity: 0; visibility: hidden; }
.sp-pl[data-state="idle"] .sp-pl-in, .sp-pl[data-state="error"] .sp-pl-in { min-height: var(--sp-pl-h, 0); }
/* --sp-pl-h is the dropped plate's whole box (padding included): .sp-pl-in is border-box, so the placeholder takes it minus that padding and the two agree in both box-sizing modes */
.sp-pl-ph { box-sizing: border-box; min-height: calc(var(--sp-pl-h, 308px) - var(--sp-pl-pad)); background: var(--sp-ph-paper, transparent); display: flex; align-items: flex-start; padding: 18px var(--spl-px, 24px); border-radius: 2px; box-shadow: 0 0 0 1px var(--ui-border); font: 500 9.5px/1 var(--font-mono); letter-spacing: 0.14em; text-transform: uppercase; color: var(--ui-muted); }
.sp-pl-ph[style*="--sp-ph-ink"] { color: color-mix(in srgb, var(--sp-ph-ink) 60%, transparent); }
.sp-pl[data-off] .sp-pl-ph { min-height: 0; }
.sp-pl-missing { display: grid; justify-items: start; gap: 6px; padding: 22px; border: 1px dashed var(--ui-border-hi); border-radius: var(--radius-sm); color: var(--ui-text-2); font-size: 12.5px; line-height: 1.55; }
.sp-pl-missing b { color: var(--ui-text); font-weight: 600; font-size: 14px; }
.sp-pl-more { margin: 4px 0 0; font: 400 11px/1.4 var(--font-mono); color: var(--ui-muted); }
.sp-pl-lnk { color: var(--ui-accent-text, var(--ui-accent)); text-decoration: underline; text-underline-offset: 3px; font: inherit; display: inline-block; min-height: 24px; min-width: 24px; padding: 4px 2px; vertical-align: middle; }
.sp-pl-art { cursor: pointer; }
.sp-pl[data-editing] .sp-pl-art { cursor: default; }
/* tools inside a plate header, inked to the stock */
.spl-tools .sp-pl-tool { display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 9px; border: 1px solid color-mix(in srgb, var(--spl-text) 34%, transparent); border-radius: var(--radius-sm, 4px); background: transparent; color: var(--spl-text); font: 500 10.5px/1 var(--font-ui, system-ui); letter-spacing: 0; text-transform: none; white-space: nowrap; cursor: pointer; }
.spl-tools .sp-pl-tool:hover { border-color: var(--spl-text); }
.spl-tools .sp-pl-tool svg { flex: none; }
/* the (i) after an example plate's name: a floating note, so it never shifts the header row */
.spl-no .sp-pl-info { position: relative; display: inline-flex; vertical-align: middle; margin-left: 8px; }
.sp-pl-info-btn { display: inline-flex; align-items: center; justify-content: center; width: 24px; height: 24px; padding: 0; border: 0; border-radius: 50%; background: transparent; color: var(--spl-text); opacity: .75; cursor: pointer; }
.sp-pl-info[data-open] .sp-pl-info-btn { opacity: 1; }
@media (hover: hover) { .sp-pl-info-btn:hover { opacity: 1; } }
.sp-pl-info-btn:focus-visible { outline: 2px solid var(--spl-text); outline-offset: 1px; opacity: 1; }
.sp-pl-info-tip { position: absolute; z-index: 30; top: calc(100% + 6px); left: -8px; width: max-content; max-width: min(260px, 70vw); padding: 8px 10px; border: 1px solid var(--ui-border-hi, #444); border-radius: var(--radius-sm, 4px); background: var(--ui-panel, #252525); color: var(--ui-text, #e0e0e0); box-shadow: 0 8px 24px rgba(0, 0, 0, 0.32); font: 400 11.5px/1.45 var(--font-ui, system-ui, sans-serif); letter-spacing: 0; text-transform: none; white-space: normal; opacity: 0; visibility: hidden; pointer-events: none; transition: opacity .12s, visibility 0s linear .12s; }
.sp-pl-info[data-open] .sp-pl-info-tip { opacity: 1; visibility: visible; transition-delay: 0s; }
/* The (i) after the EXAMPLES count in the Plates header: holds the examples explainer (hover / focus / click). */
.sp-pl-titles { position: relative; }
.sp-pl-titles .sp-pl-info { position: static; display: inline-flex; align-self: center; margin-left: -8px; }
.sp-pl-titles .sp-pl-info[hidden] { display: none; }
.sp-pl-titles .sp-pl-info-btn { color: var(--ui-muted); }
.sp-pl-titles .sp-pl-info-btn:focus-visible { outline-color: var(--ui-accent); }
.sp-pl-titles .sp-pl-info-tip { box-sizing: border-box; top: calc(100% + 6px); left: 0; max-width: min(360px, calc(100vw - 32px)); font-size: 12px; line-height: 1.5; }
@media (prefers-reduced-motion: reduce) { .sp-pl-info-tip { transition: none; } }
@container spl (max-width: 560px) { .spl-tools .sp-pl-tool span { display: none; } .spl-tools .sp-pl-tool { width: 28px; padding: 0; justify-content: center; } }
/* ===== END Start Page — Plates ===== */

/* ===== Start Page — plate editor, arrange, fan, use-as-cover (P2) ===== */
.spe{
  container-type:inline-size;container-name:spe;
  margin:10px 0 0;padding:16px clamp(12px,2vw,20px) 14px;border:1px solid var(--ui-border);border-radius:var(--radius-md,6px);
  background:var(--ui-panel);color:var(--ui-text);font:400 12px/1.45 var(--font-ui,system-ui,sans-serif);
}
.spe *{box-sizing:border-box}
.spe :focus-visible{outline:2px solid var(--ui-accent);outline-offset:2px}
.spe-h{display:flex;align-items:center;flex-wrap:wrap;gap:6px 14px;margin-bottom:12px}
.spe-h-t{font-weight:600;letter-spacing:.02em}
.spe-h-s{color:var(--ui-muted);font-size:11px;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.spe-grow{flex:1}
.spe-grid{display:grid;grid-template-columns:minmax(0,1fr);gap:0 28px}
@container spe (min-width:760px){.spe-grid{grid-template-columns:minmax(0,1fr) minmax(0,1fr)}}
.spe-col{display:flex;flex-direction:column;min-width:0}

/* sections: native details, so the keyboard and screen readers get it for free */
.spe-sec{border-top:1px solid var(--ui-border)}
.spe-sec:last-child{border-bottom:1px solid var(--ui-border)}
.spe-sec-h{display:flex;align-items:baseline;gap:10px;padding:9px 2px;cursor:pointer;list-style:none;font:600 10px/1.3 var(--font-mono,monospace);letter-spacing:.12em;text-transform:uppercase;color:var(--ui-text-2)}
.spe-sec-h::-webkit-details-marker{display:none}
.spe-sec-h::before{content:"";width:6px;height:6px;flex:none;border-right:1.5px solid currentColor;border-bottom:1.5px solid currentColor;transform:translateY(-1px) rotate(-45deg);transition:transform 160ms var(--ease,ease)}
.spe-sec[open]>.spe-sec-h::before{transform:translateY(-2px) rotate(45deg)}
.spe-sec-h em{font:400 10.5px/1.3 var(--font-ui,system-ui,sans-serif);letter-spacing:0;text-transform:none;font-style:normal;color:var(--ui-muted)}
.spe-sec-b{display:flex;flex-direction:column;gap:14px;padding:4px 2px 16px}

.spe-f{display:flex;flex-direction:column;gap:6px}
.spe-l{font:600 10px/1.3 var(--font-mono,monospace);letter-spacing:.1em;text-transform:uppercase;color:var(--ui-text-2)}
.spe-l em,.spe-l-hint{font:400 10.5px/1.3 var(--font-mono,monospace);letter-spacing:0;text-transform:none;font-style:normal;color:var(--ui-accent-text,var(--ui-accent));margin-left:6px}
.spe-in{width:100%;min-height:34px;padding:7px 10px;border:1px solid var(--ui-border);border-radius:var(--radius-sm,4px);background:var(--ui-ctrl);color:var(--ui-text);font:inherit;font-size:13px}
textarea.spe-in{resize:vertical;line-height:1.5}
.spe-in:hover{border-color:var(--ui-border-hi)}
.spe-in:focus{border-color:var(--ui-accent);box-shadow:0 0 0 3px var(--ui-accent-2);outline:0}
.spe-sugs{display:flex;flex-wrap:wrap;align-items:center;gap:6px}
.spe-chip,.spe-pchip,.spe-btn,.spe-pt{display:inline-flex;align-items:center;gap:6px;min-height:26px;padding:3px 10px;border:1px solid var(--ui-border);border-radius:999px;background:transparent;color:var(--ui-text-2);font:400 11px/1.2 var(--font-ui,system-ui,sans-serif);cursor:pointer}
.spe-chip:hover,.spe-pchip:hover,.spe-btn:hover,.spe-pt:hover{border-color:var(--ui-border-hi);color:var(--ui-text)}
.spe-chip-k{font:500 9px/1 var(--font-mono,monospace);letter-spacing:.1em;text-transform:uppercase;color:var(--ui-accent-text,var(--ui-accent))}
.spe-chip-l{font-size:11px;color:var(--ui-text-2)}
.spe-btn{border-radius:var(--radius-sm,4px);min-height:30px;padding:0 12px;color:var(--ui-text)}
.spe-btn[disabled]{opacity:.45;cursor:not-allowed}
.spe-btn-p{background:var(--ui-accent);border-color:var(--ui-accent);color:var(--ui-on-accent,#fff)}
.spe-btn-p:hover{filter:brightness(1.08);color:var(--ui-on-accent,#fff)}
.spe-btn[aria-pressed="true"],.spe-pt[aria-pressed="true"],.spe-pchip[aria-checked="true"]{border-color:var(--ui-accent);background:var(--ui-accent-2);color:var(--ui-text)}
.spe-lnk{display:inline-flex;align-items:center;min-height:24px;min-width:24px;padding:2px 0;border:0;background:none;color:var(--ui-accent-text,var(--ui-accent));font:inherit;font-size:11px;text-decoration:underline;text-underline-offset:3px;cursor:pointer}
.spe-lnk[disabled]{opacity:.4;cursor:default;text-decoration:none}
.spe-lnk-d{color:var(--ui-danger-text,var(--ui-danger))}

/* layout radiogroup */
.spe-lays{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:6px}
@container spe (max-width:520px){.spe-lays{grid-template-columns:repeat(2,minmax(0,1fr))}}
.spe-lay{position:relative;display:flex;flex-direction:column;align-items:center;gap:4px;padding:8px 4px 6px;border:1px solid var(--ui-border);border-radius:var(--radius-sm,4px);background:transparent;color:var(--ui-text-2);font:400 10.5px/1.2 var(--font-ui,system-ui,sans-serif);cursor:pointer}
.spe-lay-g{display:block;width:100%}.spe-lay svg{display:block;width:100%;height:26px}
.spe-lay:hover{border-color:var(--ui-border-hi);color:var(--ui-text)}
.spe-lay[aria-checked="true"]{border-color:var(--ui-accent);background:var(--ui-accent-2);color:var(--ui-text)}
.spe-lay-sg{position:absolute;top:2px;right:3px;font:500 8px/1 var(--font-mono,monospace);letter-spacing:.1em;text-transform:uppercase;color:var(--ui-accent-text,var(--ui-accent))}

/* colorway picker */
.spe-pal{display:flex;flex-direction:column;gap:10px}
.spe-pal-top{display:flex;flex-wrap:wrap;gap:6px}
.spe-sw-auto,.spe-sw-own{width:14px;height:14px;border-radius:50%;flex:none;background:conic-gradient(#d9480f,#9c7a00,#2b8a3e,#1864ab,#6741d9,#d9480f)}
.spe-sw-own{background:linear-gradient(135deg,var(--ui-text-2) 50%,var(--ui-border-hi) 50%)}
.spe-pal-g{display:flex;flex-direction:column;gap:5px}
.spe-pal-gl{font:500 9.5px/1 var(--font-mono,monospace);letter-spacing:.14em;text-transform:uppercase;color:var(--ui-muted)}
.spe-pal-sw{display:flex;flex-wrap:wrap;gap:5px}
.spe-swb{width:30px;height:22px;padding:0;border:1px solid var(--ui-border-hi);border-radius:3px;background:linear-gradient(135deg,var(--g) 0 58%,var(--i) 58% 100%);cursor:pointer}
.spe-swb[aria-checked="true"]{box-shadow:0 0 0 2px var(--ui-panel),0 0 0 4px var(--ui-accent)}
.spe-now{font:400 10px/1.3 var(--font-mono,monospace);color:var(--ui-text-2)}
.spe-advice{font-size:11px;color:var(--ui-text-2)}
.spe-warn{color:var(--ui-danger);font-size:11px}
.spe-ok{color:var(--ui-muted);font-size:10.5px}

/* manual colors */
.spe-mc{display:flex;flex-direction:column;gap:8px;padding:10px;border:1px solid var(--ui-border);border-radius:var(--radius-sm,4px)}
.spe-mc-h{display:flex;align-items:center;gap:10px;font-size:11px;color:var(--ui-text-2)}
.spe-mc-h b{font-weight:600;color:var(--ui-text)}
.spe-mc[hidden]{display:none}
.spe-mc-hint{margin:2px 0 6px;font-size:10.5px;line-height:1.35;color:var(--ui-text-2)}
.spe-mc-cul{display:inline-flex;align-items:center;gap:6px;margin-left:auto}
.spe-mc-cu{width:32px;height:22px;padding:0;border:1px solid var(--ui-border-hi);border-radius:3px;background:none}
.spe-mc-g{display:flex;flex-wrap:wrap;align-items:center;gap:6px 8px}
.spe-mc-auto{height:24px;padding:0 10px;border:1px solid var(--ui-border);border-radius:999px;background:transparent;color:var(--ui-text-2);font-size:10.5px;cursor:pointer}
.spe-mc-auto[aria-checked="true"],.spe-mc-sp[aria-checked="true"]{border-color:var(--ui-accent);background:var(--ui-accent-2);color:var(--ui-text)}
.spe-mc-sws{display:flex;flex-wrap:wrap;gap:4px;flex-basis:100%;order:2}
.spe-mc-sps{display:flex;flex-wrap:wrap;gap:5px;flex-basis:100%;order:3}
.spe-mc-sw{width:18px;height:18px;padding:0;border:0;border-radius:3px;background:var(--c);box-shadow:inset 0 0 0 1px rgba(128,128,128,.4);cursor:pointer}
.spe-mc-sw[aria-checked="true"]{box-shadow:0 0 0 2px var(--ui-panel),0 0 0 4px var(--ui-accent)}
.spe-mc-sp{display:inline-flex;align-items:center;gap:6px;height:24px;padding:0 9px 0 4px;border:1px solid var(--ui-border);border-radius:999px;background:transparent;color:var(--ui-text-2);font-size:10.5px;cursor:pointer}
.spe-mc-sp i{width:16px;height:16px;border-radius:50%;background:var(--f);box-shadow:inset 0 0 0 1px rgba(128,128,128,.35)}
.spe-contrast{min-height:16px}

/* framing */
.spe-fr-row{display:flex;flex-wrap:wrap;gap:8px 14px;align-items:center}
.spe-fr-ctl{display:flex;flex-wrap:wrap;align-items:center;gap:8px 14px}
.spe-fr-ctl[hidden]{display:none}
.spe-seg{display:inline-flex;gap:0}
.spe-seg .spe-pt{border-radius:0;margin-left:-1px}
.spe-seg .spe-pt:first-child{border-radius:999px 0 0 999px;margin-left:0}
.spe-seg .spe-pt:last-child{border-radius:0 999px 999px 0}
.spe-fr-z{display:inline-flex;align-items:center;gap:8px;font-size:11px;color:var(--ui-text-2)}
.spe-fr-z input{width:130px;accent-color:var(--ui-accent)}
.spe-fr-z output{min-width:3.6em;font:500 10px/1 var(--font-mono,monospace)}
.spe-fr-hint{margin:0;font:400 9.5px/1.5 var(--font-mono,monospace);color:var(--ui-muted)}
/* the print being framed: dashed clip outline, grab cursor, no page scroll while dragging */
.spl-print.spe-framing{outline:2px dashed var(--ui-accent,#4a9eff);outline-offset:3px;cursor:grab;touch-action:none;z-index:2}
.spl-print.spe-framing:active{cursor:grabbing}
.spl-print.spe-framing:focus-visible{outline:2px dashed var(--ui-accent,#4a9eff);outline-offset:3px}

/* motion + footer */
.spe-mo{display:flex;align-items:center;gap:8px;font-size:11px;color:var(--ui-text-2)}
.spe-sel{height:28px;padding:0 6px;border:1px solid var(--ui-border);border-radius:var(--radius-sm,4px);background:var(--ui-ctrl);color:var(--ui-text);font:inherit}
.spe-foot{display:flex;flex-wrap:wrap;align-items:center;gap:8px 18px;margin-top:12px}
.spe-keys{font:400 10px/1.3 var(--font-mono,monospace);color:var(--ui-muted)}
@media (max-width:760px){.spe-mc-cul{margin-left:0}.spe-keys{display:none}.spe-fr-z input{width:100px}}

/* ---- special fills on a plate (StartPagePlateColors.apply) ---- */
.spl[data-bgfill]{background:var(--spl-bg-fill)}
.spl[data-txfill] :is(.spl-title,.spl-note,.spl-wrap-txt,.spl-spec dd,.spl-pq p){background:var(--spl-tx-fill);-webkit-background-clip:text;background-clip:text;-webkit-text-fill-color:transparent;color:transparent}
.spl[data-artfill] .spl-hword text,.spl[data-artfill] .spl-vword text{fill:var(--spl-word-fill,currentColor)}
/* Manual Band (secondary ground) and Title (display word): independent of the art fill, Auto when the attributes are absent. */
.spl[data-band] :is(.spl-cband,.spl-ko-band,.spl-kt-band){background:var(--spl-band)}
.spl[data-title] :is(.spl-hword,.spl-vword) text{fill:var(--spl-title)}
/* ---------- Arrange mode: one row per plate, on its own paper ---------- */
[data-arranging="true"] > :not(.sp-arr) { display: none !important; }
.sp-arr { display: flex; flex-direction: column; gap: 10px; container-type: inline-size; container-name: sp-arr; }
.sp-arr-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; }
.sp-arr-lead { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.sp-arr-title { font: 500 12px/1.2 var(--font-ui, system-ui, sans-serif); color: var(--ui-text); }
.sp-arr-hint { font: 400 10.5px/1.4 var(--font-mono, ui-monospace, monospace); color: var(--ui-text-2); }
.sp-arr-acts { display: inline-flex; gap: 8px; flex-wrap: wrap; }
.sp-arr-btn { height: 28px; padding: 0 11px; border-radius: var(--radius-sm, 4px); border: 1px solid var(--ui-border-hi); background: var(--ui-panel, transparent); color: var(--ui-text); font: 500 11px/1 var(--font-ui, system-ui, sans-serif); cursor: pointer; }
.sp-arr-btn:hover { border-color: var(--ui-accent); color: var(--ui-accent); }
.sp-arr-btn:focus-visible { outline: 2px solid var(--ui-accent); outline-offset: 2px; }
.sp-arr-done { background: var(--ui-accent); border-color: var(--ui-accent); color: var(--ui-on-accent, #fff); }
.sp-arr-done:hover { color: var(--ui-on-accent, #fff); filter: brightness(1.08); }

.sp-arr-list { position: relative; display: flex; flex-direction: column; gap: 6px; }
.sp-arr-row {
  --spa-paper: #f4efe6; --spa-ink: #111; --spa-text: #111;
  position: relative; display: flex; align-items: center; gap: 12px; min-height: 54px; padding: 10px 14px; border-radius: 2px;
  background: var(--spa-paper); color: var(--spa-text);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--spa-text) 16%, transparent);
  font: 400 12px/1.3 var(--font-ui, system-ui, sans-serif);
  touch-action: pan-y;
}
.sp-arr-row:focus-visible { outline: 2px solid var(--ui-accent); outline-offset: 3px; }
.sp-arr-row[data-hidden="true"] { opacity: .62; }
.sp-arr-row.dragging { z-index: 20; opacity: .96; box-shadow: 0 0 0 1px var(--ui-accent), 0 18px 40px -12px rgba(0, 0, 0, .75); transition: none; }
.sp-arr-list.dnd .sp-arr-row:not(.dragging) { transition: transform 200ms var(--ease, ease); }
.sp-arr-grip {
  width: 32px; height: 32px; flex: none; display: grid; place-items: center; border-radius: var(--radius-sm, 4px); cursor: grab;
  border: 1px solid color-mix(in srgb, var(--spa-text) 30%, transparent); background: transparent; color: var(--spa-text); touch-action: none;
}
.sp-arr-grip:active { cursor: grabbing; }
.sp-arr-grip:focus-visible, .sp-arr-mv:focus-visible { outline: 2px solid var(--spa-text); outline-offset: 2px; }
.sp-arr-dots { width: 10px; height: 14px; background: radial-gradient(circle, currentColor 1.3px, transparent 1.6px) 0 0 / 5px 5px; }
.sp-arr-no { font: 500 9.5px/1 var(--font-mono, ui-monospace, monospace); letter-spacing: .14em; text-transform: uppercase; color: color-mix(in srgb, var(--spa-text) 62%, transparent); white-space: nowrap; }
.sp-arr-name { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; font-size: 14px; color: var(--spa-text); }
.sp-arr-hid { font: 400 9.5px/1 var(--font-mono, ui-monospace, monospace); letter-spacing: .08em; text-transform: uppercase; padding: 4px 7px; border-radius: 3px; border: 1px dashed color-mix(in srgb, var(--spa-text) 50%, transparent); white-space: nowrap; }
.sp-arr-sw { width: 22px; height: 14px; flex: none; border-radius: 2px; position: relative; overflow: hidden; background: var(--spa-paper); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--spa-text) 28%, transparent); }
.sp-arr-sw::after { content: ""; position: absolute; left: -3px; right: -3px; top: 50%; height: 2px; margin-top: -1px; background: var(--spa-ink); transform: rotate(-30deg); }
.sp-arr-mvs { display: inline-flex; gap: 4px; flex: none; }
.sp-arr-mv { width: 28px; height: 28px; display: grid; place-items: center; border-radius: var(--radius-sm, 4px); border: 1px solid color-mix(in srgb, var(--spa-text) 30%, transparent); background: transparent; color: var(--spa-text); font: 500 13px/1 var(--font-ui, system-ui, sans-serif); cursor: pointer; }
.sp-arr-mv:hover:not(:disabled) { border-color: var(--spa-text); }
.sp-arr-mv:disabled { opacity: .3; cursor: default; }
.sp-arr-drop { position: absolute; left: -6px; right: -6px; height: 3px; margin-top: -1.5px; border-radius: 2px; background: var(--ui-accent); z-index: 30; pointer-events: none; box-shadow: 0 0 0 3px var(--ui-accent-2, rgba(38, 128, 235, .35)); }
.sp-arr-drop[hidden] { display: none; }
.sp-arr-drop::before { content: ""; position: absolute; left: -4px; top: -3.5px; width: 10px; height: 10px; border-radius: 50%; background: var(--ui-accent); }
.sp-arr-drop::after { content: attr(data-label); position: absolute; right: 8px; top: -24px; font: 500 9.5px/1 var(--font-mono, ui-monospace, monospace); letter-spacing: .08em; padding: 4px 7px; border-radius: 3px; background: var(--ui-accent); color: #fff; white-space: nowrap; }
@media (pointer: coarse) {
  .sp-arr-grip { width: 44px; height: 44px; }
  .sp-arr-mv, .sp-arr-btn { width: 44px; height: 44px; }
  .sp-arr-btn { width: auto; padding: 0 14px; }
  .sp-arr-row { min-height: 64px; }
}
@container sp-arr (max-width: 520px) {
  .sp-arr-sw, .sp-arr-hint { display: none; }
  .sp-arr-row { gap: 8px; padding: 8px 10px; }
  .sp-arr-no { letter-spacing: .06em; }
  .sp-arr-grip, .sp-arr-mv { width: 40px; height: 40px; }
  .sp-arr-row[data-hidden="true"] { padding-bottom: 22px; }
  .sp-arr-hid { position: absolute; left: 58px; bottom: 5px; padding: 2px 5px; font-size: 8px; }
}

/* ---------- Colorways fan ---------- */
.sp-fan { position: fixed; inset: 0; z-index: 950; /* above .sp (900) */ --w: 200px; --h: 150px; }
.sp-fan-scrim { position: absolute; inset: 0; background: color-mix(in srgb, var(--ui-bg) 62%, transparent); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); opacity: 0; transition: opacity 260ms var(--ease, ease); }
.sp-fan.open .sp-fan-scrim { opacity: 1; }
.sp-fan-head { position: absolute; transform: translate(-50%, -100%); display: flex; flex-wrap: wrap; align-items: baseline; justify-content: center; gap: 4px 10px; width: max-content; line-height: 1.3; font: 400 10.5px/1.3 var(--font-mono, ui-monospace, monospace); color: var(--ui-text-2); opacity: 0; transition: opacity 260ms var(--ease, ease) 120ms; max-width: calc(100vw - 32px); }
.sp-fan-head b { font: 500 14px/1 var(--font-ui, system-ui, sans-serif); color: var(--ui-text); }
.sp-fan-head span { min-width: 0; overflow-wrap: anywhere; }
.sp-fan.open .sp-fan-head { opacity: 1; }
.sp-fan-card {
  position: absolute; left: 0; top: 0; width: var(--w); padding: 0; border: 0; background: none; text-align: left; cursor: pointer; --lift: 0px; --hs: 1;
  transform: translate(var(--x, 0), var(--y, 0)) rotate(var(--r, 0deg)) translateY(var(--lift)) scale(calc(var(--s, 1) * var(--hs))); transform-origin: 50% 100%;
  transition: transform 420ms cubic-bezier(.2, .8, .2, 1), opacity 200ms var(--ease, ease);
}
.sp-fan.closing .sp-fan-card { transition-duration: 240ms; opacity: 0; }
.sp-fan.closing .sp-fan-scrim { opacity: 0; }
.sp-fan-sheet { position: relative; display: block; width: var(--w); height: var(--h); border-radius: 1px; box-shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 14px 30px -14px rgba(0, 0, 0, .7); transition: box-shadow 260ms var(--ease, ease); }
.sp-fan-art { position: absolute; inset: 0; display: block; }
.sp-fan-cap { display: flex; flex-wrap: wrap; gap: 1px 7px; align-items: baseline; margin-top: 9px; font: 400 9.5px/1.3 var(--font-mono, ui-monospace, monospace); color: var(--ui-text-2); overflow-wrap: anywhere; opacity: 0; transition: opacity 220ms var(--ease, ease) 260ms; }
.sp-fan-cap span { min-width: 0; }
.sp-fan-cap b { font-weight: 500; color: var(--ui-text); letter-spacing: .08em; }
.sp-fan.open .sp-fan-cap { opacity: 1; }
.sp-fan-card:hover, .sp-fan-card:focus-visible { --lift: -12px; --hs: 1.04; z-index: 20 !important; transition-delay: 0ms !important; }
.sp-fan-card:hover .sp-fan-sheet, .sp-fan-card:focus-visible .sp-fan-sheet { box-shadow: 0 2px 4px rgba(0, 0, 0, .3), 0 24px 40px -16px rgba(0, 0, 0, .8); }
.sp-fan-card:focus-visible { outline: none; }
.sp-fan-card:focus-visible .sp-fan-sheet { outline: 2px solid var(--ui-accent); outline-offset: 4px; }
.sp-fan.still .sp-fan-card, .sp-fan.still .sp-fan-scrim, .sp-fan.still .sp-fan-head, .sp-fan.still .sp-fan-cap { transition: none !important; }

/* ---------- Use as cover ---------- */
.sp-lt.sp-lt-new { box-shadow: 0 0 0 2px var(--ui-accent); transition: box-shadow 900ms var(--ease, ease); }
.sp-pf.sp-pf-old { position: absolute; top: 0; left: 0; z-index: 2; pointer-events: none; opacity: 1; transition: opacity 420ms var(--ease, ease); }

/* ===== Start Page - P3: hover effects, lift cards, studio picks, community, live 3D, motion settings ===== */
/* ---------- WebGL hover effects: the surface sits inside the hovered art element, above the ink layer ---------- */
.sp-hfx-wrap { position: absolute; inset: 0; z-index: 1; pointer-events: none; overflow: hidden; border-radius: inherit; visibility: hidden; }
.sp-hfx-wrap.on { visibility: visible; }
.sp-hfx-surface, .sp-hfx-wrap > canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.sp-hfx-wrap.xfade { opacity: 0; }
.sp-hfx-wrap.xfade.in { opacity: 1; }
.sp-hfx-wrap.still { opacity: 0; }
.sp-hfx-wrap.still.still-in { opacity: 1; }
:root[data-sp-motion="still"] .sp-hfx-wrap:not(.still) { display: none; }

/* ---------- Lift & tilt ---------- */
.sp-hfx-lift .sp-ink-art { transition: none; transform-origin: 50% 50%; }
.sp-hfx-lift { box-shadow: 0 22px 44px -22px rgba(0, 0, 0, 0.6); }
.sp-hfx-tilt-glare { position: absolute; inset: 0; z-index: 3; pointer-events: none; border-radius: inherit; opacity: 0;
  background: radial-gradient(60% 50% at var(--gx, 50%) var(--gy, 30%), rgba(255, 255, 255, 0.22), rgba(255, 255, 255, 0) 70%); mix-blend-mode: soft-light; }

/* ---------- Glare sweep ---------- */
.sp-hfx-glare { position: absolute; inset: 0; z-index: 3; pointer-events: none; overflow: hidden; border-radius: inherit; }
.sp-hfx-glare::before { content: ""; position: absolute; top: -20%; bottom: -20%; left: -60%; width: 45%; opacity: 0;
  background: linear-gradient(100deg, transparent 0, rgba(255, 255, 255, 0.08) 30%, rgba(255, 255, 255, 0.42) 50%, rgba(255, 255, 255, 0.08) 70%, transparent 100%);
  mix-blend-mode: screen; transform: translateX(0) skewX(-14deg); }
:root[data-sp-motion="still"] :is(.sp-hfx-glare, .sp-hfx-tilt-glare) { display: none; }
@media (prefers-reduced-motion: reduce) { :is(.sp-hfx-glare, .sp-hfx-tilt-glare) { display: none; } }

/* ---------- lift card (N3): pointer tilt, broad subtle glare, darker soft shadow, no light box ---------- */
.sp-lift { position: relative; display: block; width: 100%; padding: 0; border: 0; background: none; border-radius: 2px; cursor: pointer; text-align: left; -webkit-tap-highlight-color: transparent; }
.sp-lift-in { position: relative; display: block; width: 100%; height: 100%; border-radius: inherit; transform-origin: 50% 50%; backface-visibility: hidden; }
.sp-lift-in > .sp-ink { border-radius: inherit; }
.sp-lift-sh { position: absolute; inset: 7% 6% 1%; border-radius: 6px; background: var(--sp-lift-sh, rgba(0, 0, 0, 0.8)); filter: blur(22px); opacity: 0; pointer-events: none; transform-origin: 50% 40%; }
.sp-lift-sh::after { content: ""; position: absolute; inset: 14% 10% 4%; border-radius: inherit; background: var(--sp-lift-sh2, rgba(0, 0, 0, 0.58)); filter: blur(9px); }
.sp-lift-gl { position: absolute; inset: 0; overflow: hidden; pointer-events: none; border-radius: inherit; z-index: 3; }
.sp-lift-gl > i { position: absolute; left: 50%; top: 50%; width: 260%; aspect-ratio: 1; margin-left: -130%; transform-origin: 50% 50%; opacity: 0; translate: 0 -50%; border-radius: 50%;
  background: radial-gradient(closest-side, rgba(255, 255, 255, 0.12) 0, rgba(255, 255, 255, 0.105) 12%, rgba(255, 255, 255, 0.075) 28%, rgba(255, 255, 255, 0.04) 46%, rgba(255, 255, 255, 0.015) 66%, rgba(255, 255, 255, 0) 86%); }
.sp-lift-live { z-index: 4; }
.sp-lift-live .sp-lift-in, .sp-lift-live .sp-lift-gl > i, .sp-lift-live .sp-lift-sh { will-change: transform, opacity; }
.sp-lift:focus-visible { outline: none; }
.sp-lift:focus-visible .sp-lift-in { outline: 2px solid var(--ui-accent); outline-offset: 5px; }
:root[data-theme="light"] .sp-lift { --sp-lift-sh: rgba(20, 16, 10, 0.42); --sp-lift-sh2: rgba(20, 16, 10, 0.3); }
@media (prefers-color-scheme: light) { :root:not([data-theme="dark"]) .sp-lift { --sp-lift-sh: rgba(20, 16, 10, 0.42); --sp-lift-sh2: rgba(20, 16, 10, 0.3); } }
:root[data-sp-motion="still"] .sp-lift-gl { display: none; }
@media (prefers-reduced-motion: reduce) { .sp-lift-gl { display: none; } }

/* ---------- Studio picks ---------- */
.sp-picks { padding: 34px 0 6px; border-top: 1px solid var(--ui-border); margin-top: 28px; scroll-margin-top: 16px; }
.sp-sec-head { margin-bottom: 20px; }
.sp-sec-title { margin: 8px 0 0; font: 500 20px/1.1 var(--font-ui); letter-spacing: -0.015em; color: var(--ui-text); }
.sp-picks-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 30px 24px; }
.sp-pick { min-width: 0; }
.sp-pick-card { aspect-ratio: 4 / 3; }
.sp-pick-art { position: absolute; inset: 0; border-radius: inherit; overflow: hidden; }
.sp-pick-art.sp-ink { box-shadow: 0 0 0 1px var(--ui-border); }
.sp-pick-name, .sp-pick-meta, .sp-pick-acts, .sp-cm-label { position: relative; z-index: 5; }
.sp-pick-name { margin: 12px 0 2px; font-size: 13px; font-weight: 600; color: var(--ui-text); }
.sp-pick-meta { margin: 2px 0 0; font: 400 10.5px/1.4 var(--font-mono); color: var(--ui-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sp-pick-acts { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.sp-pick-btn { height: 28px; padding: 0 10px; font-size: 11.5px; font-weight: 500; color: var(--ui-text); background: var(--ui-ctrl); border: 1px solid var(--ui-border); border-radius: var(--radius-sm); cursor: pointer; transition: border-color var(--dur-fast, 150ms), background-color var(--dur-fast, 150ms); }
.sp-pick-btn:hover { border-color: var(--ui-border-hi); }
.sp-pick-btn-primary { color: var(--ui-on-accent); background: var(--ui-accent); border-color: var(--ui-accent); }
.sp-pick-btn:focus-visible { outline: 2px solid var(--ui-accent); outline-offset: 2px; }
.sp-picks-empty { margin: 0; font-size: 12.5px; color: var(--ui-text-2); }

/* ---------- Community: coming later ---------- */
.sp-community { padding: 34px 0 6px; border-top: 1px solid var(--ui-border); margin-top: 28px; }
.sp-cm-grid { display: grid; grid-template-columns: minmax(240px, 360px) minmax(0, 1fr); gap: 40px; align-items: center; }
.sp-cm-line { margin: 10px 0 14px; font-size: 12.5px; line-height: 1.6; color: var(--ui-text-2); }
.sp-cm-switch { display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%; max-width: 320px; min-height: 36px; padding: 4px 12px; font-size: 12px; font-weight: 500; color: var(--ui-text); background: none; border: 1px solid var(--ui-border); border-radius: var(--radius-sm); cursor: pointer; text-align: left; }
.sp-cm-switch:focus-visible { outline: 2px solid var(--ui-accent); outline-offset: 2px; }
.sp-cm-switch[aria-checked="true"] .sp-switch { background: var(--ui-accent) !important; }
.sp-cm-switch[aria-checked="true"] .sp-switch-knob { transform: translateX(12px); }
.sp-cm-status { min-height: 1.4em; margin: 8px 0 0; font-size: 11px; color: var(--ui-muted); }
.sp-cm-row { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 18px; }
.sp-cm-slot { min-width: 0; }
.sp-cm-card { aspect-ratio: 4 / 3; cursor: default; }
button.sp-cm-card { cursor: pointer; }
.sp-cm-art { position: absolute; inset: 0; border-radius: inherit; overflow: hidden; }
.sp-cm-label { display: block; margin-top: 10px; font: 400 10px/1.35 var(--font-mono); color: var(--ui-muted); }
.sp-cm-empty { aspect-ratio: 4 / 3; border: 1px dashed var(--ui-border-hi); border-radius: 2px; display: grid; place-items: center; }
.sp-cm-empty i { width: 22px; height: 1px; background: var(--ui-border-hi); }

@media (max-width: 1100px) {
  .sp-picks-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .sp-cm-grid { grid-template-columns: 1fr; gap: 16px; }
  .sp-cm-status:empty { display: none; }
}
@media (max-width: 640px) {
  .sp-cm-row { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 22px 16px; }
  .sp-pick-btn { height: 36px; }
  .sp-cm-switch { min-height: 44px; }
}

/* settings popover: Art animates in / Hover effect */
.sp-set-pick { display: flex; gap: 8px; align-items: center; margin-top: 8px; }
.sp-set-select { flex: 1; min-width: 0; height: 30px; padding: 0 8px; font: inherit; font-size: 12px; color: var(--ui-text); background: var(--ui-ctrl); border: 1px solid var(--ui-border); border-radius: var(--radius-sm); }
.sp-set-dev { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; margin-top: 10px; padding: 8px; border: 1px dashed var(--ui-border-hi); border-radius: var(--radius-sm); }
.sp-set-dev[hidden] { display: none; }
.sp-set-dev .sp-dev-badge { font: 600 9px/1 var(--font-mono); letter-spacing: 0.14em; text-transform: uppercase; color: var(--ui-accent); }
.sp-set-check { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--ui-text); cursor: pointer; }
.sp-set-size { gap: 10px; }
.sp-set-range { flex: 1; min-width: 0; accent-color: var(--ui-accent); }
.sp-set-range:disabled, .sp-set-select:disabled { opacity: 0.55; cursor: not-allowed; }
.sp-set-out { flex: none; min-width: 3.2em; text-align: right; font: 500 11px/1 var(--font-mono); color: var(--ui-text-2); font-variant-numeric: tabular-nums; }
.sp-set-select:focus-visible, .sp-set-btn:focus-visible { outline: 2px solid var(--ui-accent); outline-offset: 2px; }
.sp-set-btn { height: 30px; padding: 0 12px; font-size: 12px; font-weight: 500; color: var(--ui-text); background: var(--ui-ctrl); border: 1px solid var(--ui-border); border-radius: var(--radius-sm); cursor: pointer; }
.sp-set-btn:hover { border-color: var(--ui-border-hi); }

/* settings popover: Cover art (per-letter / per-cover piece select + colorway swatches) */
.sp-set-coverart { margin-top: 2px; }
.sp-cvart-help { margin-top: 0; }
.sp-cvart-list { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; max-height: 260px; overflow: auto; padding-right: 2px; }
.sp-cvart-list[hidden], .sp-cvart-empty[hidden] { display: none; }
.sp-cvart-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "label label" "sel cw"; align-items: center; gap: 4px 8px; }
.sp-cvart-label { grid-area: label; font: 400 10px/1.2 var(--font-mono); color: var(--ui-muted); }
.sp-cvart-sel { grid-area: sel; }
.sp-cvart-cw { grid-area: cw; display: inline-flex; gap: 4px; }
.sp-cvart-sw { position: relative; width: 22px; height: 22px; padding: 0; border-radius: 3px; background: var(--p, var(--ui-ctrl)); box-shadow: inset 0 0 0 1px rgba(128, 128, 128, 0.35); overflow: hidden; cursor: pointer; flex: none; }
.sp-cvart-sw i { position: absolute; left: 50%; top: 50%; width: 8px; height: 8px; margin: -4px 0 0 -4px; border-radius: 50%; background: var(--i, currentColor); }
.sp-cvart-sw[aria-checked="true"] { box-shadow: 0 0 0 2px var(--ui-panel), 0 0 0 4px var(--ui-accent); }
.sp-cvart-sw:focus-visible { outline: 2px solid var(--ui-accent); outline-offset: 3px; }
.sp-cvart-foot { margin-top: 10px; }
.sp-cvart-reset:disabled { opacity: 0.45; cursor: not-allowed; }
@media (pointer: coarse) {
  .sp-cvart-sw { width: 32px; height: 32px; }
  .sp-cvart-sw i { width: 12px; height: 12px; margin: -6px 0 0 -6px; }
}

.spl-edit-replay { margin-top: 8px; }
/* live 3D models (StartPageOrbit3D) on the Portfolio band and on plates */
.sp-pf .sp-pf-3d { position: absolute; inset: 0 0 0 24%; z-index: 0; }
.sp-pf[data-live="3d"] .sp-pf-in { pointer-events: none; }
.sp-pf[data-live="3d"] .sp-pf-in :is(button, input, a) { pointer-events: auto; }
.spl-print[data-3d].vorbit { box-shadow: none; outline: none; border: 0; }
.spl-print[data-3d].vorbit::after { display: none; }
.spl-disc .vorbit, .spl-disc .vorbit > canvas { border: 0; outline: 0; box-shadow: none; }
/* ===== END Start Page - P3 ===== */
/* ===== END Start Page — plate editor, arrange, fan ===== */

/* Start Page skip link: first stop in the page, visible only while focused. */
.sp-skip { position: absolute; left: 8px; top: 8px; z-index: 5; padding: 6px 12px; border-radius: var(--radius-sm); background: var(--ui-accent); color: var(--ui-on-accent, #fff); font: 500 12px/1.2 var(--font-ui); transform: translateY(-200%); }
.sp-skip:focus-visible { transform: none; }

/* Start Page Developer Mode (src/ui/start-page/plates/dev-tools.js): the curator's bar, dialogs and the header badge. Exists only while Developer Mode is on. */
.sp-dev { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; margin: 0 0 14px; padding: 10px 12px; border: 1px dashed var(--ui-accent); border-radius: var(--radius-sm); background: color-mix(in srgb, var(--ui-accent) 8%, transparent); color: var(--ui-text-2); font-size: 12px; }
.sp-dev-badge { padding: 3px 8px; border-radius: 999px; background: var(--ui-accent); color: var(--ui-accent-contrast, #fff); font: 600 10px/1.2 var(--font-mono, monospace); letter-spacing: .1em; text-transform: uppercase; white-space: nowrap; }
.sp-dev-copy { flex: 1 1 260px; min-width: 0; }
.sp-dev-tools { display: inline-flex; flex-wrap: wrap; gap: 6px; }
.sp-dev-status { flex-basis: 100%; font: 400 11px/1.4 var(--font-mono, monospace); color: var(--ui-muted, var(--ui-text-2)); }
.sp-dev-btn:disabled { opacity: .45; cursor: default; }
.sp-dev-dlg { margin: 0 0 14px; border: 1px solid var(--ui-border-hi); border-radius: var(--radius-sm); background: var(--ui-bg-2, var(--ui-bg)); color: var(--ui-text); box-shadow: 0 10px 28px rgba(0, 0, 0, .22); }
.sp-dev-dlg-h { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 12px; border-bottom: 1px solid var(--ui-border); font-size: 13px; }
.sp-dev-dlg-b { display: flex; flex-direction: column; gap: 10px; padding: 12px; }
.sp-dev-search { width: 100%; height: 30px; padding: 0 10px; border: 1px solid var(--ui-border-hi); border-radius: var(--radius-sm); background: var(--ui-ctrl); color: var(--ui-text); font-size: 12px; }
.sp-dev-list { display: flex; flex-direction: column; max-height: 280px; overflow: auto; border: 1px solid var(--ui-border); border-radius: var(--radius-sm); }
.sp-dev-opt { display: flex; justify-content: space-between; gap: 12px; padding: 7px 10px; text-align: left; font-size: 12px; color: var(--ui-text-2); }
.sp-dev-opt b { font-weight: 600; color: var(--ui-text); }
.sp-dev-opt span { font: 400 10.5px/1.4 var(--font-mono, monospace); color: var(--ui-muted, var(--ui-text-2)); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sp-dev-opt:hover, .sp-dev-opt:focus-visible { background: var(--ui-ctrl-hov); }
.sp-dev-more, .sp-dev-help, .sp-dev-note { margin: 0; padding: 6px 10px; font-size: 11.5px; line-height: 1.5; color: var(--ui-text-2); }
.sp-dev-help, .sp-dev-note { padding: 0; }
.sp-dev-out { width: 100%; box-sizing: border-box; padding: 10px; border: 1px solid var(--ui-border-hi); border-radius: var(--radius-sm); background: var(--ui-ctrl); color: var(--ui-text); font: 400 11px/1.55 var(--font-mono, monospace); resize: vertical; white-space: pre; overflow: auto; }
.sp-dev-row { display: flex; flex-wrap: wrap; gap: 8px; }
.sp-dev-primary { border-color: var(--ui-accent); color: var(--ui-text); }
.sp-dev-pill { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 1; pointer-events: none; display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 10px; border: 1px dashed var(--ui-accent); border-radius: 999px; background: color-mix(in srgb, var(--ui-accent) 12%, transparent); color: var(--ui-text); font: 600 10px/1 var(--font-mono, monospace); letter-spacing: .1em; text-transform: uppercase; white-space: nowrap; }
.sp-dev-pill[hidden] { display: none; }
/* too narrow to centre the pill without touching the brand or the right-hand tools: it gives way (the Developer Mode bar below the header still says so) */
@container sp (max-width: 560px) {
  .sp-dev-pill { display: none; }
}
.spe-sec[hidden], .spe-f[hidden], .spe-pchip[hidden] { display: none; }

/* ═══════════════════════════════════════════════════════════════════════
   PEN STUDIO (pen-studio-*): boxes | lab | pair modal, built by
   UI.PenStudio (src/ui/pen-studio/*). Dark three-column modal, ~1440x1000
   max, fluid below; columns stack under ~900px (container query on the
   shell); body.touch-ui is a full-screen sheet with >=44px targets.
   ═══════════════════════════════════════════════════════════════════════ */
.pen-studio-backdrop { padding: 16px; box-sizing: border-box; }
.vectura-modal.pen-studio {
  --ps-warn: var(--ui-warn, #e8b25a);
  --ps-ok: var(--ui-ok, #7bc98f);
  width: min(1440px, calc(100vw - 32px));
  max-width: none;
  height: min(1000px, calc(100vh - 32px)); height: min(1000px, calc(var(--app-vh) - 32px));
  max-height: none;
  background: var(--ui-panel-alt);
  color: var(--ui-text);
  font-family: var(--font-ui);
}
.vectura-modal.pen-studio > .vectura-modal-body { padding: 0; display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
.pen-studio-shell { position: relative; flex: 1; min-height: 0; display: flex; flex-direction: column; container: pen-studio / inline-size; }
.pen-studio-top { flex: none; display: flex; align-items: center; gap: 14px; padding: 0 24px; min-height: 60px; border-bottom: 1px solid var(--ui-border); }
.pen-studio-titles { flex: 1; min-width: 0; display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; }
.pen-studio-title { margin: 0; font-size: 22px; font-weight: 600; }
.pen-studio-subtitle { margin: 0; font-size: 14px; color: var(--ui-text-2); }
.pen-studio-cols { flex: 1; min-height: 0; display: flex; }

/* buttons + shared controls */
.pen-studio-btn { height: 30px; padding: 0 12px; border: 0; border-radius: var(--radius-sm); background: var(--ui-ctrl); color: var(--ui-text); font: 500 12px/1 var(--font-ui); cursor: pointer; white-space: nowrap; }
.pen-studio-btn:hover:not(:disabled) { background: var(--ui-ctrl-hov); }
.pen-studio-btn.primary, .pen-studio-btn.is-primary { background: var(--ui-accent); color: var(--ui-bg); font-weight: 600; }
.pen-studio-btn.primary:hover:not(:disabled), .pen-studio-btn.is-primary:hover:not(:disabled) { background: var(--ui-accent); filter: brightness(1.12); }
.pen-studio-btn:disabled { opacity: 0.45; cursor: default; }
.pen-studio :is(button, input, select, textarea, canvas):focus-visible,
.pen-studio :is(.pen-studio-editable):focus-visible { outline: 2px solid var(--ui-accent); outline-offset: 1px; }
.pen-studio input[type="range"] { accent-color: var(--ui-accent); width: 100%; }
.pen-studio-swatch { display: inline-block; width: 22px; height: 22px; flex: none; border-radius: 50%; box-shadow: 0 0 0 1px var(--ui-border-hi, rgba(255, 255, 255, 0.35)), inset 0 0 0 1px rgba(255, 255, 255, 0.3); }
.pen-studio-empty, .pen-studio-lab-empty, .pen-studio-pair-empty { margin: 0; padding: 16px; font-size: 12px; color: var(--ui-muted); }
.pen-studio-lab-empty:empty, .pen-studio-pair-empty:empty { display: none; }

/* column 1: boxes */
.pen-studio-boxes { flex: none; width: clamp(200px, 24cqw, 270px); min-width: 200px; box-sizing: border-box; display: flex; flex-direction: column; gap: 6px; padding: 12px 10px; background: var(--ui-panel); border-right: 1px solid var(--ui-border); min-height: 0; overflow: hidden; }
.pen-studio-boxes-view { display: flex; flex-direction: column; gap: 6px; flex: 1; min-height: 0; }
.pen-studio-boxes-head { display: flex; flex-direction: column; gap: 6px; }
.pen-studio-boxes-title { margin: 0; padding: 0 4px; font: 400 10px/1 var(--font-mono); letter-spacing: 0.1em; color: var(--ui-text-2); }
.pen-studio-boxes-actions { display: flex; gap: 6px; }
.pen-studio-boxes-actions .pen-studio-btn { flex: 1; height: 30px; }
.pen-studio-box-list { flex: 1; min-height: 0; overflow: auto; display: flex; flex-direction: column; gap: 4px; }
.pen-studio-box { display: flex; flex-direction: column; border-bottom: 1px solid var(--ui-border); padding-bottom: 4px; }
.pen-studio-box-head { display: flex; align-items: center; flex-wrap: nowrap; gap: 0; min-height: 30px; }
.pen-studio-box-toggle { flex: 1 1 0; min-width: 0; min-height: 28px; border: 0; border-radius: var(--radius-sm); background: transparent; color: var(--ui-text); font: 600 12px/1.2 var(--font-ui); display: flex; align-items: center; gap: 6px; padding: 2px 4px; text-align: left; cursor: pointer; }
.pen-studio-box-toggle:hover, .pen-studio-box-pin:hover, .pen-studio-box-export:hover, .pen-studio-box-delete:hover, .pen-studio-box-add:hover, .pen-studio-row-main:hover { background: var(--ui-ctrl-hov); }
.pen-studio-chev { color: var(--ui-text-2); font-size: 9px; width: 10px; }
.pen-studio-box-name { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow-wrap: anywhere; }
.pen-studio-box-count { flex: none; white-space: nowrap; font-weight: 400; color: var(--ui-text-2); }
.pen-studio-box-count::before { content: "· "; }
.pen-studio-box-pin, .pen-studio-box-export, .pen-studio-box-delete, .pen-studio-box-add { border: 0; border-radius: var(--radius-sm); background: transparent; color: var(--ui-text-2); font: 400 12px/1 var(--font-ui); cursor: pointer; }
.pen-studio-box-pin, .pen-studio-box-delete { width: 26px; height: 26px; }
.pen-studio-box-pin[aria-pressed="true"] { color: var(--ps-warn); }
.pen-studio-box-export { width: 26px; height: 26px; }
.pen-studio-box-delete.is-armed { width: auto; padding: 0 6px; background: var(--ui-danger); color: var(--ui-bg); }
.pen-studio-box-add { display: block; width: 26px; height: 26px; margin: 0; padding: 0; text-align: center; color: var(--ui-accent); }
.pen-studio-box-empty { margin: 0; padding: 4px 12px; font-size: 11px; color: var(--ui-muted); }
.pen-studio-rows { list-style: none; margin: 0; padding: 0 0 0 6px; display: flex; flex-direction: column; gap: 1px; }
.pen-studio-row { display: flex; align-items: center; gap: 2px; border-radius: var(--radius-sm); }
.pen-studio-row.is-selected { background: var(--ui-accent-2); box-shadow: inset 0 0 0 1px var(--ui-accent); }
.pen-studio-row-main { flex: 1; min-width: 0; min-height: 30px; border: 0; border-radius: var(--radius-sm); background: transparent; color: var(--ui-text); font: 400 12px/1 var(--font-ui); display: flex; align-items: center; gap: 8px; padding: 2px 6px; text-align: left; cursor: pointer; }
.pen-studio-row-main .pen-studio-swatch { width: 14px; height: 14px; }
.pen-studio-row-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow-wrap: anywhere; line-height: 1.2; }
.pen-studio-row-note { font: 400 10px/1 var(--font-mono); color: var(--ui-text-2); white-space: nowrap; }
.pen-studio-row-note.is-unsaved { color: var(--ps-warn); }
.pen-studio-row-note.is-faint { color: var(--ui-muted); }
.pen-studio-row-remove { width: 22px; height: 22px; border: 0; border-radius: var(--radius-sm); background: transparent; color: var(--ui-muted); cursor: pointer; }
.pen-studio-row-remove:hover { color: var(--ui-danger); }
.pen-studio-edit, .pen-studio-field input[type="text"], .pen-studio-field select, .pen-studio-textarea, .pen-studio-move {
  box-sizing: border-box; height: 28px; padding: 0 6px; background: var(--ui-ctrl); color: var(--ui-text); border: 1px solid var(--ui-border); border-radius: var(--radius-sm); font: 400 12px/1 var(--font-ui);
}
.pen-studio-row-edit { flex: 1; min-width: 0; margin: 0 4px; border-color: var(--ui-accent); }

/* column 2: header + lab */
.pen-studio-main { flex: 1 1 700px; min-width: 0; max-width: 760px; box-sizing: border-box; padding: 14px 20px; display: flex; flex-direction: column; gap: 10px; border-right: 1px solid var(--ui-border); min-height: 0; overflow: auto; }
.pen-studio-head { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; }
.pen-studio-head-text { flex: 1; min-width: 160px; display: flex; flex-direction: column; gap: 2px; }
.pen-studio-name-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.pen-studio-name { font-size: 20px; font-weight: 600; }
.pen-studio-desc { font-size: 12px; color: var(--ui-text-2); }
.pen-studio-editable { border: 0; background: transparent; color: inherit; font-family: inherit; text-align: left; padding: 2px 4px; border-radius: var(--radius-sm); cursor: text; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pen-studio-editable:hover { background: var(--ui-ctrl-hov); box-shadow: inset 0 -1px 0 var(--ui-accent); }
.pen-studio-badge { font: 400 10px/1 var(--font-mono); color: var(--ui-text-2); border: 1px solid var(--ui-border-hi); border-radius: 999px; padding: 3px 7px; }
.pen-studio-unsaved { font: 400 10px/1 var(--font-mono); color: var(--ui-bg); background: var(--ps-warn); border-radius: 3px; padding: 2px 6px; }
.pen-studio-head-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.pen-studio-move { max-width: 160px; }
.pen-studio-note { flex: 1 0 100%; font-size: 11px; color: var(--ps-ok); }
.pen-studio-note.tone-warn { color: var(--ps-warn); }
.pen-studio-lab-host[hidden], .pen-studio-pair-host[hidden], .pen-studio-overlay-host[hidden] { display: none; }
.pen-studio-lab { display: flex; flex-direction: column; flex: 1 0 auto; min-height: auto; }
.pen-studio-lab-body { display: flex; flex-direction: column; gap: 8px; flex: 1 0 auto; min-height: auto; }
.pen-studio-sizes { display: flex; flex-direction: column; gap: 6px; }
.pen-studio-sizes-head { font-size: 11px; color: var(--ui-text-2); }
.pen-studio-sizes-row { display: flex; flex-wrap: wrap; gap: 6px; }
.pen-studio-sizes-src { font-size: 10.5px; color: var(--ui-text-2); }
.pen-studio-sizes-src[hidden] { display: none; }
.pen-studio-sizes-row .pen-studio-size { display: flex; flex-direction: column; align-items: flex-start; gap: 3px; text-align: left; border: 0; border-radius: 5px; background: var(--ui-ctrl); color: var(--ui-text); font: 400 11px/1.2 var(--font-mono); padding: 6px 9px; cursor: pointer; }
.pen-studio-size-line.is-sub { font-size: 10px; color: var(--ui-text-2); }
.pen-studio-size.is-owned { background: var(--ui-accent-2); }
.pen-studio-size.is-testing { box-shadow: 0 0 0 2px var(--ui-accent); }
.pen-studio-papers-wrap { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.pen-studio-papers-head { font: 400 10px/1 var(--font-mono); letter-spacing: 0.1em; color: var(--ui-text-2); }
.pen-studio-papers { display: grid; grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); gap: 6px; flex: 1 1 100%; min-width: 0; }
.pen-studio-paper { display: inline-flex; align-items: center; gap: 6px; min-width: 0; height: 28px; padding: 0 8px 0 4px; border: 0; border-radius: 999px; background: var(--ui-ctrl); color: var(--ui-text); font: 400 11px/1 var(--font-ui); cursor: pointer; }
.pen-studio-paper[aria-pressed="true"] { box-shadow: 0 0 0 2px var(--ui-accent); }
.pen-studio-paper-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pen-studio-paper-note { flex: none; }
.pen-studio-paper-swatch { flex: none; width: 18px; height: 18px; border-radius: 50%; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.25); }
.pen-studio-paper-note { font: 400 9.5px/1 var(--font-mono); color: var(--ui-text-2); }
.pen-studio-view-toggle { display: flex; background: var(--ui-panel); border-radius: 999px; padding: 2px; margin-left: auto; }
.pen-studio-view-btn { height: 24px; padding: 0 12px; border: 0; border-radius: 999px; background: transparent; color: var(--ui-text); font: 400 11px/1 var(--font-ui); cursor: pointer; }
.pen-studio-view-btn[aria-pressed="true"] { background: var(--ui-accent-2); box-shadow: inset 0 0 0 1px var(--ui-accent); }
.pen-studio-strips { display: flex; flex-direction: column; gap: 2px; border-radius: var(--radius-sm); overflow: hidden; }
.pen-studio-strips[hidden], .pen-studio-matrix[hidden] { display: none; }
.pen-studio-strip { display: flex; flex-direction: column; gap: 2px; }
.pen-studio-strip-head { display: flex; justify-content: space-between; gap: 10px; font-size: 11px; color: var(--ui-text-2); }
.pen-studio-strip-value { font: 400 10px/1.2 var(--font-mono); }
.pen-studio-strip-canvas { width: 100%; height: 42px; }
.pen-studio-matrix-cell { height: 30px; }
.pen-studio-strip-canvas, .pen-studio-weave-canvas { display: block; max-width: 100%; min-width: 0; border-radius: 3px; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08); }
.pen-studio-matrix { display: flex; flex-direction: column; gap: 3px; }
.pen-studio-matrix-row { display: grid; grid-template-columns: 96px repeat(4, minmax(0, 1fr)); gap: 4px; align-items: center; border: 0; border-radius: var(--radius-sm); padding: 2px; background: transparent; color: var(--ui-text); font: 400 11px/1.1 var(--font-ui); text-align: left; cursor: pointer; position: relative; }
.pen-studio-matrix-row:hover { background: var(--ui-ctrl-hov); }
.pen-studio-matrix-row.is-selected { background: var(--ui-accent-2); }
.pen-studio-matrix-name { grid-column: 1; grid-row: 1; align-self: start; }
.pen-studio-matrix-cell { width: 100%; min-width: 0; border-radius: 3px; display: block; }
.pen-studio-matrix-note { grid-column: 1; grid-row: 1; align-self: end; font: 400 9.5px/1 var(--font-mono); color: var(--ui-text-2); }
.pen-studio-matrix-note.is-warn { color: var(--ps-warn); }
.pen-studio-sliders { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px 16px; margin-top: auto; padding-top: 8px; border-top: 1px solid var(--ui-border); }
.pen-studio-slider { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.pen-studio-slider-head { display: flex; align-items: baseline; gap: 6px; }
.pen-studio-slider-label { font-size: 11px; font-weight: 600; }
.pen-studio-slider-value { margin-left: auto; font: 400 10px/1 var(--font-mono); color: var(--ui-text-2); }
.pen-studio-slider-value.is-draft { color: var(--ps-warn); }
.pen-studio-slider-value.is-saved { color: var(--ui-accent); }
.pen-studio-slider-ev { font-size: 9.5px; line-height: 1.3; color: var(--ui-muted); }
.pen-studio-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; position: sticky; bottom: -14px; z-index: 1; margin: 0 -20px -14px; padding: 8px 20px; background: var(--ui-panel-alt); border-top: 1px solid var(--ui-border); }

/* column 3: pair */
.pen-studio-pair-host { flex: 1 1 320px; min-width: 260px; box-sizing: border-box; padding: 14px 18px; overflow: auto; min-height: 0; }
.pen-studio-pair { display: flex; flex-direction: column; gap: 10px; }
.pen-studio-pair-body { display: flex; flex-direction: column; gap: 10px; }
.pen-studio-pair-head { display: grid; grid-template-columns: 1fr auto; column-gap: 8px; align-items: center; }
.pen-studio-pair-title { font: 400 10px/1 var(--font-mono); letter-spacing: 0.1em; color: var(--ui-text-2); }
.pen-studio-pair-sub { grid-column: 1; font-size: 10.5px; color: var(--ui-muted); }
.pen-studio-random { grid-column: 2; grid-row: 1 / span 2; }
.pen-studio-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.pen-studio-chip { display: inline-flex; align-items: center; gap: 6px; max-width: 100%; padding: 4px 8px 4px 4px; border: 0; border-radius: 999px; background: var(--ui-ctrl); color: var(--ui-text); font: 400 11px/1 var(--font-ui); cursor: pointer; }
.pen-studio-chip:hover { background: var(--ui-ctrl-hov); }
.pen-studio-chip.is-selected { box-shadow: 0 0 0 2px var(--ui-accent); }
.pen-studio-chip-swatch { width: 18px; height: 18px; flex: none; border-radius: 50%; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.25); }
.pen-studio-chip-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pen-studio-chip-kind { font: 400 9.5px/1 var(--font-mono); color: var(--ui-text-2); }
.pen-studio-pair-contrast { font: 400 10px/1.3 var(--font-mono); color: var(--ui-text-2); }
.pen-studio-pair-note { font-size: 11px; line-height: 1.4; color: var(--ui-text-2); }
.pen-studio-pair-note.is-ok { color: var(--ps-ok); }
.pen-studio-pair-note.is-warn { color: var(--ps-warn); }
.pen-studio-lines { display: flex; align-items: center; gap: 8px; }
.pen-studio-lines-label { font-size: 11px; font-weight: 600; }
.pen-studio-lines-value { font: 400 10px/1 var(--font-mono); color: var(--ui-text-2); min-width: 1.5ch; }
.pen-studio-weaves { display: flex; gap: 6px; flex-wrap: wrap; }
.pen-studio-weave-btn { height: 26px; padding: 0 10px; border: 0; border-radius: 999px; background: var(--ui-ctrl); color: var(--ui-text); font: 400 11px/1 var(--font-ui); cursor: pointer; }
.pen-studio-weave-btn.is-selected { box-shadow: 0 0 0 2px var(--ui-accent); }

/* dialogs (add / export / import / save as new) */
.pen-studio-overlay-host { position: absolute; inset: 0; z-index: 2; }
.pen-studio-scrim { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; padding: 16px; background: rgba(0, 0, 0, 0.55); }
.pen-studio-dialog { width: min(460px, 100%); max-height: 100%; overflow: auto; box-sizing: border-box; padding: 16px 18px; display: flex; flex-direction: column; gap: 10px; background: var(--ui-panel); border: 1px solid var(--ui-border-hi); border-radius: var(--radius-lg, 8px); box-shadow: 0 24px 64px rgba(0, 0, 0, 0.5); }
.pen-studio-dialog-title { margin: 0; font-size: 16px; font-weight: 600; }
.pen-studio-dialog-sub { margin: 0; font-size: 12px; line-height: 1.45; color: var(--ui-text-2); }
.pen-studio-dialog-body { display: flex; flex-direction: column; gap: 10px; }
.pen-studio-dialog-foot { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.pen-studio-field { display: flex; flex-direction: column; gap: 4px; }
.pen-studio-field-label { font: 400 10px/1 var(--font-mono); letter-spacing: 0.08em; text-transform: uppercase; color: var(--ui-text-2); }
.pen-studio-field :is(input[type="text"], select) { width: 100%; }
.pen-studio-textarea { width: 100%; min-height: 160px; height: auto; padding: 8px; font: 400 11px/1.5 var(--font-mono); resize: vertical; }
.pen-studio-colors, .pen-studio-swatches { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.pen-studio-color { width: 24px; height: 24px; padding: 0; border: 0; border-radius: 50%; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.3); cursor: pointer; }
.pen-studio-color.is-on { box-shadow: 0 0 0 2px var(--ui-panel), 0 0 0 4px var(--ui-accent); }
.pen-studio-color-custom { width: 32px; height: 26px; padding: 0; border: 1px solid var(--ui-border); border-radius: var(--radius-sm); background: transparent; cursor: pointer; }
.pen-studio-dialog .pen-studio-sizes { flex-direction: row; flex-wrap: wrap; gap: 6px; }
.pen-studio-dialog .pen-studio-size { border: 0; border-radius: 5px; background: var(--ui-ctrl); color: var(--ui-text); font: 400 11px/1 var(--font-mono); padding: 6px 9px; cursor: pointer; }
.pen-studio-dialog .pen-studio-size.is-on { background: var(--ui-accent-2); box-shadow: inset 0 0 0 1px var(--ui-accent); }
.pen-studio-fit-warn { margin: 0; font-size: 11px; color: var(--ps-warn); }
.pen-studio-fit-warn[hidden], .pen-studio-error[hidden], .pen-studio-msg[hidden] { display: none; }
.pen-studio-error { margin: 0; font-size: 11px; color: var(--ui-danger); }
.pen-studio-msg { margin: 0; font-size: 11px; color: var(--ui-text-2); }
.pen-studio-file { font-size: 11px; color: var(--ui-text-2); max-width: 100%; }

/* medium (~1024): boxes | lab on top, the pair column stacks under the lab */
@container pen-studio (max-width: 1100px) {
  .pen-studio-top { flex-wrap: wrap; row-gap: 4px; padding: 8px 20px; }
  .pen-studio-cols { display: grid; grid-template-columns: minmax(200px, 24cqw) minmax(0, 1fr); grid-template-rows: max-content max-content; overflow: auto; align-items: start; }
  .pen-studio-boxes { grid-column: 1; grid-row: 1 / span 2; width: auto; align-self: stretch; }
  .pen-studio-main { grid-column: 2; grid-row: 1; flex: none; min-height: auto; max-width: none; border-right: 0; border-bottom: 1px solid var(--ui-border); overflow: visible; }
  .pen-studio-actions { bottom: 0; }
  .pen-studio-pair-host { grid-column: 2; grid-row: 2; flex: none; min-height: auto; min-width: 0; overflow: visible; }
}

/* narrow: stack the three columns (the shell is the container) */
@container pen-studio (max-width: 900px) {
  .pen-studio-top { padding: 8px 16px; }
  .pen-studio-subtitle { display: none; }
  .pen-studio-cols { display: flex; flex-direction: column; overflow: auto; }
  .pen-studio-boxes { flex: none; grid-column: auto; grid-row: auto; width: auto; max-height: 240px; border-right: 0; border-bottom: 1px solid var(--ui-border); }
  .pen-studio-main { flex: none; min-height: auto; max-width: none; border-right: 0; border-bottom: 1px solid var(--ui-border); overflow: visible; padding: 12px 16px; }
  .pen-studio-main, .pen-studio-pair-host { grid-column: auto; grid-row: auto; }
  .pen-studio-pair-host { flex: none; min-height: auto; min-width: 0; overflow: visible; padding: 12px 16px; }
  .pen-studio-sliders { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@container pen-studio (max-width: 520px) {
  .pen-studio-sliders { grid-template-columns: minmax(0, 1fr); }
  .pen-studio-matrix-row { grid-template-columns: 72px repeat(4, minmax(0, 1fr)); }
}

/* touch: full-screen sheet, >=44px targets */
body.touch-ui .pen-studio-backdrop { padding: 0; align-items: stretch !important; }
body.touch-ui .vectura-modal.pen-studio { width: 100%; max-width: 100%; height: 100%; max-height: 100%; border-radius: 0; }
body.touch-ui .pen-studio :is(.pen-studio-btn, .pen-studio-box-toggle, .pen-studio-box-pin, .pen-studio-box-export, .pen-studio-box-delete, .pen-studio-box-add, .pen-studio-row-main, .pen-studio-row-remove, .pen-studio-size, .pen-studio-paper, .pen-studio-view-btn, .pen-studio-weave-btn, .pen-studio-chip, .pen-studio-matrix-row, .pen-studio-editable, .pen-studio-edit, .pen-studio-move, .pen-studio-color, .pen-studio-field :is(input[type="text"], select)) { min-height: var(--touch-target-min); min-width: var(--touch-target-min); }
body.touch-ui .pen-studio :is(.pen-studio-color) { width: var(--touch-target-min); height: var(--touch-target-min); }
body.touch-ui .pen-studio input[type="range"] { min-height: var(--touch-target-min); }
body.touch-ui .pen-studio .pen-studio-box .pen-studio-box-head :is(.pen-studio-box-pin, .pen-studio-box-export, .pen-studio-box-delete, .pen-studio-box-add) { min-width: 30px; width: 30px; padding: 0; }
body.touch-ui .pen-studio .pen-studio-box .pen-studio-box-head .pen-studio-box-toggle { min-width: 0; }
body.touch-ui .pen-studio .pen-studio-box .pen-studio-box-head .pen-studio-box-delete.is-armed { width: auto; padding: 0 6px; }
body.touch-ui .pen-studio .pen-studio-matrix-row { min-height: calc(var(--touch-target-min) + 4px); }

@media (prefers-reduced-motion: reduce) {
  .pen-studio, .pen-studio * { transition: none !important; animation: none !important; }
}
/* END PEN STUDIO */

/* A 3D Scene's 2D Pos / Scale / Rotation do nothing (only its Seed is real). */
#algorithm-transform-section.is-seed-only #algorithm-transform-body > :not(#seed-controls) { display: none !important; }

/* W3-D: read-only Level S / Level F hint under the Lock marks to surface row. */
.vs3-markspace-hint { margin: -2px 0 6px; padding: 0 2px; font-size: 11px; line-height: 1.3; color: var(--text-dim, var(--text-muted, inherit)); opacity: 0.85; }
.vs3-markspace-hint[data-level-s="1"]::before { content: "\2713\00a0"; }
.vs3-row.vs3-row-long-lbl .vs3-lbl { white-space: normal; overflow-wrap: break-word; line-height: 1.2; }

/* ==== Send to Plotter (shell) ====
 * Connect / Setup / Plot tabs and the panel shell (src/ui/modals/send-to-plotter.js). The Machine and
 * Console tabs style themselves. Visual language follows the Mirror panel: picture cards
 * (.stp-card mirrors .mp-type-card), a per-card category color via --stp-card-color, toggle groups.
 * Layout is container-driven (the dialog, not the viewport) and fits 1280x800 and 1024 wide. */
.vectura-modal.stp-dialog {
  --stp-ok: var(--ui-ok, #7bc98f);
  --stp-warn: var(--ui-warn, #e8b25a);
  /* Distance-readable scale: the user may stand a few steps from the screen. Everything below keys off these. */
  --stp-font: 18px; --stp-font-small: 16px; --stp-font-heading: 24px; --stp-font-readout: 24px; --stp-font-pill: 19px;
  --stp-hit: 52px; --stp-stop-h: 64px; --stp-dial: 280px; --stp-dir-hit: 64px; --stp-gap: 14px; --stp-rail: 190px;
  width: min(1500px, 96vw);
  height: 92vh; height: calc(var(--app-vh) * 0.92);
  max-width: none;
  max-height: none;
  background: var(--ui-panel-alt, var(--ui-panel));
  color: var(--ui-text);
  font-family: var(--font-ui);
}
.vectura-modal.stp-dialog > .stp-modal-body { padding: 0; display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
.stp-root { container: stp / inline-size; flex: 1; min-height: 0; display: flex; flex-direction: column; font-size: var(--stp-font); line-height: 1.4; }
.stp-root [hidden] { display: none !important; }
.stp-head { position: relative; flex: none; display: flex; align-items: center; flex-wrap: nowrap; gap: 12px; padding: 8px 16px; overflow: hidden; border-bottom: 1px solid var(--ui-border); }
.stp-title { margin: 0; font-size: var(--stp-font-small); font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase; color: var(--ui-accent); }
.stp-profile-name { color: var(--ui-text-2); font-size: var(--stp-font); }
.stp-spacer { flex: 1; }
.stp-pill { flex: none; display: inline-flex; align-items: center; gap: 10px; min-height: 40px; padding: 0 18px; border-radius: 9999px; font-size: var(--stp-font-pill); font-weight: 700; background: var(--ui-ctrl); border: 1px solid var(--ui-border); color: var(--ui-text-2); }
.stp-pill::before { content: ''; width: 14px; height: 14px; border-radius: 50%; background: var(--ui-muted); }
.stp-pill.is-idle::before, .stp-pill.is-jogging::before { background: var(--stp-ok); }
.stp-pill.is-running::before { background: var(--ui-accent); }
.stp-pill.is-paused::before, .stp-pill.is-penChange::before, .stp-pill.is-stopping::before, .stp-pill.is-connecting::before { background: var(--stp-warn); }
.stp-pill.is-alarm::before, .stp-pill.is-error::before { background: var(--ui-danger); }
.stp-pill.is-alarm, .stp-pill.is-error { color: var(--ui-danger-text, var(--ui-danger)); border-color: var(--ui-danger); }
.stp-confirm { flex-basis: 100%; display: flex; align-items: center; flex-wrap: wrap; gap: 10px; padding: 12px 14px; border: 1px solid var(--stp-warn); border-radius: var(--radius-md); background: color-mix(in srgb, var(--stp-warn) 12%, transparent); font-size: var(--stp-font); }
.stp-confirm span { flex: 1; min-width: 200px; }

.stp-btn { min-height: var(--stp-hit); padding: 0 22px; border: 1px solid var(--ui-border); border-radius: var(--radius-md); background: var(--ui-ctrl); color: var(--ui-text); font: 600 var(--stp-font)/1.2 var(--font-ui); cursor: pointer; white-space: nowrap; transition: background-color 0.14s, border-color 0.14s, color 0.14s; }
.stp-btn:hover:not(:disabled) { background: var(--ui-ctrl-hov); border-color: var(--ui-border-hi); }
.stp-btn:disabled { opacity: 0.45; cursor: default; }
.stp-btn.is-primary { background: var(--ui-accent); color: var(--ui-on-accent, var(--ui-bg)); border-color: var(--ui-accent); font-weight: 600; }
.stp-btn.is-primary:hover:not(:disabled) { background: var(--ui-accent); filter: brightness(1.1); }
.stp-btn.is-warn { border-color: color-mix(in srgb, var(--ui-danger) 55%, var(--ui-border)); color: var(--ui-danger-text, var(--ui-danger)); }
.stp-btn.is-link { min-height: var(--stp-hit); padding: 0 6px; border: 0; background: transparent; color: var(--ui-accent-text, var(--ui-accent)); text-decoration: underline; }
.stp-btn.stp-icon { min-width: var(--stp-hit); padding: 0; }
.stp-btn.stp-stop-big { background: var(--ui-danger); border-color: var(--ui-danger); color: var(--ui-on-danger, #fff); font-weight: 700; letter-spacing: 0.04em; }
/* Emergency stop: neutral outline until motion is possible/in progress, then large red. */
.stp-btn.stp-stop { flex: none; min-height: var(--stp-stop-h); padding: 0 26px; font-size: var(--stp-font); font-weight: 800; letter-spacing: 0.05em; background: transparent; border: 2px solid var(--ui-danger); color: var(--ui-danger-text, var(--ui-danger)); }
.stp-btn.stp-stop.is-armed { background: var(--ui-danger); color: var(--ui-on-danger, #fff); font-size: calc(var(--stp-font) + 2px); }
.stp-btn.stp-stop-big { min-height: var(--stp-stop-h); flex: 1; font-size: var(--stp-font-heading); }
.stp-btn.stp-stop.is-armed:hover:not(:disabled), .stp-btn.stp-stop-big:hover:not(:disabled) { background: var(--ui-danger); filter: brightness(1.12); }
.stp-btn.stp-start { min-height: 88px; width: 100%; padding: 0 36px; font-size: 28px; font-weight: 800; }
.stp-btn:focus-visible, .stp-tab:focus-visible, .stp-card:focus-visible, .stp-rotcard:focus-visible, .stp-in:focus-visible { outline: 2px solid var(--ui-accent); outline-offset: 1px; }
.stp-btnrow { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin: 12px 0; }

.stp-runbar { flex: none; display: flex; align-items: center; gap: 16px; padding: 12px 20px; border-bottom: 1px solid var(--ui-border); background: color-mix(in srgb, var(--ui-accent) 6%, transparent); }
.stp-runbar .stp-bar { flex: 1; }
.stp-runtext { font-family: var(--font-mono); font-size: var(--stp-font-readout); font-weight: 600; color: var(--ui-text-2); white-space: nowrap; }
.stp-bar { height: 16px; border-radius: 9999px; background: var(--ui-ctrl); border: 1px solid var(--ui-border); overflow: hidden; }
.stp-bar.is-big { height: 24px; margin: 14px 0; }
.stp-bar-fill { height: 100%; background: var(--ui-accent); transition: width 0.2s linear; }

.stp-main { flex: 1; min-height: 0; display: flex; }
.stp-rail { flex: none; width: var(--stp-rail); display: flex; flex-direction: column; gap: 6px; padding: 12px 10px; border-right: 1px solid var(--ui-border); }
.stp-tab { display: flex; align-items: center; gap: 10px; text-align: left; min-height: var(--stp-hit); padding: 0 16px; border: 0; border-radius: var(--radius-md); background: transparent; color: var(--ui-text-2); font: 600 var(--stp-font)/1.2 var(--font-ui); cursor: pointer; transition: background-color 0.14s, color 0.14s; }
.stp-tab:hover { background: var(--ui-ctrl-hov); color: var(--ui-text); }
.stp-tab.is-active { background: var(--ui-ctrl); color: var(--ui-text); box-shadow: inset 4px 0 0 var(--ui-accent); }
.stp-stage { flex: 1; min-width: 0; min-height: 0; position: relative; }
.stp-pane { position: absolute; inset: 0; display: flex; min-height: 0; }
.stp-tool-host { flex: 1; min-width: 0; min-height: 0; overflow: auto; padding: 18px 22px; box-sizing: border-box; }
.stp-placeholder { margin: auto; color: var(--ui-muted); font-size: var(--stp-font); }
.stp-scroll { overflow-y: auto; overflow-x: hidden; min-height: 0; padding: 18px 22px; }

.stp-setup, .stp-plot { flex: 1; min-width: 0; display: grid; grid-template-columns: minmax(340px, 42%) minmax(0, 1fr); }
.stp-controls, .stp-plotcol { border-right: 1px solid var(--ui-border); }
.stp-previewcol { display: flex; flex-direction: column; gap: 8px; min-width: 0; min-height: 0; padding: 12px 14px; }
.stp-previewbar { flex: none; display: flex; align-items: center; gap: 10px; }
.stp-inline { display: inline-flex; align-items: center; gap: 12px; min-height: var(--stp-hit); color: var(--ui-text-2); }
.stp-canvas-wrap { flex: 1; min-height: 200px; position: relative; border: 1px solid var(--ui-border); border-radius: var(--radius-md); background: var(--ui-bg); overflow: hidden; }
.stp-canvas { position: absolute; inset: 0; display: block; }
.stp-oob { display: none; font-size: var(--stp-font); padding: 12px 14px; border: 1px solid var(--ui-danger); border-radius: var(--radius-md); background: color-mix(in srgb, var(--ui-danger) 12%, transparent); color: var(--ui-danger-text, var(--ui-danger)); }
.stp-oob.is-visible { display: block; }

.stp-connect { flex: 1; max-width: 920px; }
.stp-sec { margin: 0 0 18px; }
.stp-sec-h { margin: 0 0 8px; font-size: 15px; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ui-text-2); }
.stp-sub { margin: 18px 0 8px; font-size: var(--stp-font-heading); font-weight: 600; color: var(--ui-text); }
.stp-hint { display: block; margin: 6px 0; color: var(--ui-muted); font-size: var(--stp-font-small); line-height: 1.45; }
.stp-note { margin: 12px 0; padding: 12px 14px; font-size: var(--stp-font); border: 1px solid var(--ui-border); border-radius: var(--radius-md); background: var(--ui-ctrl); line-height: 1.45; }
.stp-note.is-warn { border-color: var(--stp-warn); background: color-mix(in srgb, var(--stp-warn) 10%, transparent); }
.stp-note.is-error { border-color: var(--ui-danger); background: color-mix(in srgb, var(--ui-danger) 10%, transparent); color: var(--ui-danger-text, var(--ui-danger)); }
.stp-note.is-ok { border-color: var(--stp-ok); background: color-mix(in srgb, var(--stp-ok) 10%, transparent); }

.stp-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; align-items: stretch; }
.stp-card { position: relative; min-width: 0; text-align: left; display: flex; flex-direction: column; gap: 4px; min-height: var(--stp-hit); padding: 14px 12px 12px; background: var(--ui-panel-alt, var(--ui-ctrl)); border: 1px solid var(--ui-border); border-radius: var(--radius-md); color: inherit; cursor: pointer; overflow: hidden; transition: background-color 0.14s, border-color 0.14s, transform 0.14s; }
.stp-card:hover:not(:disabled) { transform: translateY(-1px); border-color: var(--stp-card-color, var(--ui-accent)); }
.stp-card:disabled { opacity: 0.5; cursor: default; }
.stp-card.is-current { background: linear-gradient(180deg, color-mix(in srgb, var(--stp-card-color, var(--ui-accent)) 14%, transparent) 0%, transparent 80%); box-shadow: 0 0 0 1px var(--stp-card-color, var(--ui-accent)) inset; }
.stp-card-preview { display: flex; align-items: center; justify-content: center; height: 72px; margin-bottom: 4px; background: var(--ui-bg); border: 1px solid var(--ui-border); border-radius: var(--radius-sm); color: var(--stp-card-color, var(--ui-accent)); }
.stp-card-preview svg { width: 78%; height: 78%; }
.stp-card-name { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow: hidden; min-height: 2.6em; line-height: 1.3; font-size: var(--stp-font); font-weight: 700; color: var(--ui-text); overflow-wrap: anywhere; }
.stp-card-dot { display: inline-block; vertical-align: middle; margin-right: 8px; width: 12px; height: 12px; border-radius: 50%; background: var(--stp-card-color, var(--ui-accent)); box-shadow: 0 0 6px var(--stp-card-color, var(--ui-accent)); }
.stp-card-tag { font-size: var(--stp-font-small); color: var(--ui-muted); line-height: 1.35; }
.stp-badge { align-self: flex-start; margin-top: auto; padding: 3px 10px; border-radius: 9999px; font-size: var(--stp-font-small); font-weight: 700; border: 1px solid var(--stp-card-color, var(--ui-border)); color: var(--stp-card-color, var(--ui-text-2)); }
.stp-current-marker { position: absolute; top: 6px; right: 6px; display: none; padding: 4px 8px; border-radius: 9999px; background: var(--stp-card-color, var(--ui-accent)); color: #1a1a1a; font: 700 15px/1 var(--font-mono); letter-spacing: 0.08em; }
.stp-card.is-current .stp-current-marker { display: inline-flex; }

.stp-details { margin: 8px 0; }
.stp-details > summary { cursor: pointer; display: flex; align-items: center; min-height: var(--stp-hit); color: var(--ui-text-2); font-weight: 500; }
.stp-editgrid, .stp-fields, .stp-pen-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px 14px; margin: 12px 0; }
.stp-field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.stp-field.is-wide { grid-column: 1 / -1; }
.stp-field-lbl { font-size: var(--stp-font-small); color: var(--ui-text-2); }
.stp-in { width: 100%; box-sizing: border-box; min-height: var(--stp-hit); padding: 0 12px; border: 1px solid var(--ui-border-hi, var(--ui-border)); border-radius: var(--radius-md); background: var(--ui-bg); color: var(--ui-text); font: var(--stp-font) var(--font-ui); }
textarea.stp-in { height: auto; padding: 10px 12px; font-family: var(--font-mono); resize: vertical; }
.stp-errors { margin-top: 6px; }
.stp-error { color: var(--ui-danger-text, var(--ui-danger)); font-size: var(--stp-font-small); }
.stp-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding: 10px 0; min-height: var(--stp-hit); }
.stp-row-lbl { display: flex; flex-direction: column; min-width: 0; color: var(--ui-text); }
.stp-fw { border-collapse: collapse; margin: 12px 0; font-size: var(--stp-font-small); }
.stp-fw th { text-align: left; padding: 4px 20px 4px 0; color: var(--ui-text-2); font-weight: 500; }
.stp-fw td { padding: 4px 0; font-family: var(--font-mono); }
.stp-sim { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--ui-border); }
.stp-simspeed { display: flex; align-items: center; gap: 14px; min-height: var(--stp-hit); color: var(--ui-text-2); }
.stp-simspeed input { flex: 0 1 220px; }
.stp-speed { font-family: var(--font-mono); min-width: 64px; font-size: var(--stp-font-readout); }
.stp-connected { margin: 6px 0 12px; font-weight: 700; font-size: var(--stp-font-heading); }

.stp-rotcards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.stp-rotcard { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; min-height: calc(var(--stp-hit) + 36px); padding: 10px 4px; border: 1px solid var(--ui-border); border-radius: var(--radius-md); background: var(--ui-panel-alt, var(--ui-ctrl)); color: var(--ui-text-2); font-size: var(--stp-font-small); font-weight: 600; cursor: pointer; transition: background-color 0.14s, border-color 0.14s, color 0.14s; }
.stp-rotcard svg { width: 48px; height: 48px; }
.stp-rotcard:hover { border-color: var(--ui-accent); }
.stp-rotcard.is-current { color: var(--ui-text); border-color: var(--ui-accent); box-shadow: 0 0 0 1px var(--ui-accent) inset; }

.stp-pen { margin: 0 0 12px; padding: 12px 14px; border: 1px solid var(--ui-border); border-radius: var(--radius-md); background: var(--ui-panel-alt, var(--ui-ctrl)); }
.stp-pen.is-off { opacity: 0.55; }
.stp-pen-head { display: flex; align-items: center; gap: 12px; min-height: var(--stp-hit); }
.stp-pen-name { font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stp-swatch { display: inline-block; width: 22px; height: 22px; border-radius: 50%; border: 1px solid var(--ui-border-hi); flex: none; vertical-align: middle; }
.stp-swatch.is-big { width: 36px; height: 36px; }
.stp-statlist { display: grid; grid-template-columns: auto 1fr; gap: 6px 20px; margin: 10px 0; }
.stp-statlist dt { color: var(--ui-text-2); }
.stp-statlist dd { margin: 0; font-family: var(--font-mono); }

.stp-checklist { list-style: none; margin: 8px 0; padding: 0; }
.stp-check { display: flex; align-items: center; gap: 12px; padding: 6px 0; }
.stp-check-mark { width: 26px; font-size: var(--stp-font-heading); text-align: center; font-weight: 700; }
.stp-check.is-ok .stp-check-mark { color: var(--stp-ok); }
.stp-check.is-bad .stp-check-mark { color: var(--ui-danger-text, var(--ui-danger)); }
.stp-why { margin: 8px 0 14px; padding-left: 24px; color: var(--ui-text-2); font-size: var(--stp-font-small); }
.stp-summary { margin: 0 0 8px; color: var(--ui-text-2); }
.stp-runstats { display: flex; flex-wrap: wrap; gap: 6px 24px; font-family: var(--font-mono); font-size: var(--stp-font-readout); margin-bottom: 12px; }
.stp-runpen { font-family: var(--font-ui); }
.stp-pencard, .stp-resume { margin: 16px 0; padding: 18px; font-size: var(--stp-font); border: 1px solid var(--stp-warn); border-radius: var(--radius-md); background: color-mix(in srgb, var(--stp-warn) 8%, transparent); }
.stp-pc-pen { display: flex; align-items: center; gap: 14px; margin: 10px 0; font-size: var(--stp-font-heading); }
.stp-resume-msg { margin: 6px 0 12px; }

@container stp (max-width: 860px) {
  .stp-main { flex-direction: column; }
  .stp-rail { flex-direction: row; width: auto; padding: 8px 10px; border-right: 0; border-bottom: 1px solid var(--ui-border); overflow-x: auto; }
  .stp-tab { flex: 1 0 auto; text-align: center; padding: 0 14px; box-shadow: none; }
  .stp-tab.is-active { box-shadow: inset 0 -4px 0 var(--ui-accent); }
  .stp-setup, .stp-plot { display: flex; flex-direction: column; overflow-y: auto; }
  .stp-controls, .stp-plotcol { overflow: visible; border-right: 0; flex: none; }
  .stp-previewcol { order: -1; flex: none; height: 300px; }
  .stp-rail-div { width: 1px; height: auto; margin: 4px 6px; }
  .stp-tab-sub { display: none; }
  .stp-rotcards { grid-template-columns: repeat(2, 1fr); }
}
/* ==== end Send to Plotter (shell) ==== */
/* ==== Send to Plotter (machine tools) ==== */
.stp-mt-root {
  --stp-mt-color: var(--ui-accent);
  display: flex; flex-direction: column; gap: calc(var(--stp-gap) + 6px);
  container-type: inline-size;
  font-family: var(--font-ui); font-size: var(--stp-font); color: var(--ui-text);
}
.stp-mt-root [hidden] { display: none !important; }
.stp-mt-sec { display: flex; flex-direction: column; gap: var(--stp-gap); }
.stp-mt-sec-hdr {
  margin: 0; font-size: var(--stp-font-small); font-weight: 700;
  letter-spacing: 0.06em; text-transform: uppercase; color: var(--ui-muted);
}
.stp-mt-row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--stp-gap); }
.stp-mt-hint { margin: 0; font-size: var(--stp-font-small); color: var(--ui-muted); line-height: 1.4; }
.stp-mt-reason { font-size: var(--stp-font); color: var(--ui-text-2); }

.stp-mt-btn {
  min-height: var(--stp-hit); padding: 0 22px;
  background: var(--ui-ctrl); border: 1px solid var(--ui-border); border-radius: var(--radius-md);
  color: var(--ui-text); font-family: var(--font-ui); font-size: var(--stp-font); font-weight: 600;
  cursor: pointer;
  transition: background-color 0.12s, border-color 0.12s, color 0.12s, opacity 0.12s;
}
.stp-mt-btn:hover:not(:disabled) { border-color: var(--stp-mt-color); background: var(--ui-ctrl-hov, var(--ui-ctrl)); }
.stp-mt-btn:focus-visible, .stp-mt-dir:focus-visible, .stp-mt-card:focus-visible, .stp-mt-dial:focus-visible {
  outline: 2px solid var(--ui-accent); outline-offset: 2px;
}
.stp-mt-btn:disabled, .stp-mt-dir:disabled, .stp-mt-card:disabled { opacity: 0.45; cursor: not-allowed; }
.stp-mt-btn.is-primary { background: var(--ui-accent); border-color: var(--ui-accent); color: var(--ui-on-accent); }
.stp-mt-btn.is-danger { background: var(--ui-danger); border-color: var(--ui-danger); color: var(--ui-on-danger); }
.stp-mt-btn.is-compact { min-width: var(--stp-hit); padding: 0 14px; font-family: var(--font-mono); }

.stp-mt-msg {
  padding: 12px 16px; border-radius: var(--radius-md);
  border: 1px solid var(--ui-border); background: var(--ui-panel-alt, var(--ui-ctrl));
  font-size: var(--stp-font); line-height: 1.45;
}
.stp-mt-msg.is-error { border-color: var(--ui-danger); color: var(--ui-danger-text, var(--ui-danger)); }
.stp-mt-msg.is-warn { border-color: var(--ui-warning, var(--ui-accent)); }
.stp-mt-msg.is-ok { border-color: var(--ui-success, var(--ui-accent)); }

.stp-mt-alarm {
  display: flex; flex-direction: column; gap: var(--stp-gap);
  padding: 18px; border-radius: var(--radius-md);
  border: 2px solid var(--ui-danger);
  background: color-mix(in srgb, var(--ui-danger) 12%, transparent);
}
.stp-mt-alarm-text { margin: 0; font-size: var(--stp-font); line-height: 1.45; }
.stp-mt-alarm .stp-mt-btn { align-self: flex-start; }

.stp-mt-readout { display: flex; flex-direction: column; gap: 6px; font-family: var(--font-mono); font-size: var(--stp-font-readout); font-weight: 600; }
.stp-mt-readout-row { display: flex; flex-wrap: wrap; align-items: baseline; gap: 14px; }
.stp-mt-readout-lbl { width: 84px; color: var(--ui-muted); }
.stp-mt-readout-axis { color: var(--ui-muted); }
.stp-mt-readout-val { min-width: 96px; color: var(--ui-text); }

.stp-mt-jog { display: flex; flex-wrap: wrap; gap: 28px; align-items: flex-start; }
.stp-mt-jog-side { display: flex; flex-direction: column; gap: var(--stp-gap); min-width: 200px; max-width: 340px; flex: 0 1 320px; }
.stp-mt-dial {
  position: relative; width: var(--stp-dial); height: var(--stp-dial); flex: none;
  display: grid; grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(3, 1fr);
  border-radius: 50%; overflow: hidden;
  background: radial-gradient(circle at 50% 50%, var(--ui-panel, var(--ui-ctrl)) 0%, var(--ui-bg) 78%);
  border: 1px solid var(--ui-border);
  touch-action: none; user-select: none;
}
.stp-mt-dial::after {
  content: ''; position: absolute; inset: 24px; border-radius: 50%;
  border: 1px dashed var(--ui-border-hi, var(--ui-border)); pointer-events: none;
}
.stp-mt-dial-hub, .stp-mt-dial-stop { grid-area: 2 / 2; align-self: center; justify-self: center; }
.stp-mt-dial-hub { width: 18px; height: 18px; border-radius: 50%; background: var(--stp-mt-color); box-shadow: 0 0 6px var(--stp-mt-color); }
/* octagonal stop sign: replaces the hub while anything moves */
.stp-mt-dial-stop { z-index: 3; width: 112px; height: 112px; padding: 0; border: 0; background: transparent; cursor: pointer; touch-action: none; filter: drop-shadow(0 0 8px color-mix(in srgb, #d4111b 70%, transparent)); }
.stp-mt-dial-stop svg { width: 100%; height: 100%; display: block; pointer-events: none; }
.stp-mt-dial-stop:hover { filter: brightness(1.12) drop-shadow(0 0 10px #d4111b); }
.stp-mt-dial-stop:focus-visible { outline: 3px solid #fff; outline-offset: 2px; border-radius: 12px; }
.stp-mt-dir {
  display: flex; align-items: center; justify-content: center;
  background: transparent; border: 0; color: var(--ui-text-2); cursor: pointer; padding: 0;
  touch-action: none;
  transition: background-color 0.12s, color 0.12s;
}
.stp-mt-dir:hover:not(:disabled) { background: color-mix(in srgb, var(--stp-mt-color) 18%, transparent); color: var(--stp-mt-color); }
.stp-mt-dir:active:not(:disabled) { background: color-mix(in srgb, var(--stp-mt-color) 32%, transparent); }
.stp-mt-dir svg { width: 28px; height: 28px; transform: rotate(var(--stp-mt-rot, 0deg)); pointer-events: none; }
.stp-mt-dir { min-width: var(--stp-dir-hit); min-height: var(--stp-dir-hit); }
.stp-root input[type="checkbox"] { width: 28px; height: 28px; accent-color: var(--ui-accent); flex: none; }
.stp-mt-dir-nw { grid-area: 1 / 1; } .stp-mt-dir-n { grid-area: 1 / 2; } .stp-mt-dir-ne { grid-area: 1 / 3; }
.stp-mt-dir-w { grid-area: 2 / 1; } .stp-mt-dir-e { grid-area: 2 / 3; }
.stp-mt-dir-sw { grid-area: 3 / 1; } .stp-mt-dir-s { grid-area: 3 / 2; } .stp-mt-dir-se { grid-area: 3 / 3; }
.stp-mt-limit {
  padding: 10px 14px; border-radius: var(--radius-md); font-size: var(--stp-font-small);
  border: 1px solid var(--ui-warning, var(--ui-accent));
  background: color-mix(in srgb, var(--ui-warning, var(--ui-accent)) 14%, transparent);
}

.stp-mt-field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.stp-mt-field-lbl { font-size: var(--stp-font-small); color: var(--ui-muted); }
.stp-mt-num, .stp-mt-console-input {
  min-height: var(--stp-hit); padding: 0 14px;
  background: var(--ui-ctrl); border: 1px solid var(--ui-border); border-radius: var(--radius-md);
  color: var(--ui-text); font-family: var(--font-mono); font-size: var(--stp-font);
}
.stp-mt-num { width: 100%; max-width: 220px; box-sizing: border-box; }
.stp-mt-num:focus-visible, .stp-mt-console-input:focus-visible { outline: 2px solid var(--ui-accent); outline-offset: 1px; }
.stp-mt-zfield { flex-direction: row; align-items: center; flex-wrap: wrap; gap: var(--stp-gap); }
.stp-mt-range { flex: 1; min-width: 160px; min-height: var(--stp-hit); accent-color: var(--stp-mt-color); }
/* pen-height slider: big thumb, fat track (distance-readable) */
.stp-mt-range { -webkit-appearance: none; appearance: none; background: transparent; }
.stp-mt-range::-webkit-slider-runnable-track { height: 10px; border-radius: 9999px; background: var(--ui-ctrl-hov, var(--ui-ctrl)); border: 1px solid var(--ui-border-hi, var(--ui-border)); }
.stp-mt-range::-webkit-slider-thumb { -webkit-appearance: none; appearance: none; width: 32px; height: 32px; margin-top: -12px; border-radius: 50%; background: var(--stp-mt-color); border: 3px solid var(--ui-bg); box-shadow: 0 0 0 1px var(--stp-mt-color); cursor: pointer; }
.stp-mt-range::-moz-range-track { height: 10px; border-radius: 9999px; background: var(--ui-ctrl-hov, var(--ui-ctrl)); border: 1px solid var(--ui-border-hi, var(--ui-border)); }
.stp-mt-range::-moz-range-thumb { width: 28px; height: 28px; border-radius: 50%; background: var(--stp-mt-color); border: 3px solid var(--ui-bg); cursor: pointer; }

.stp-mt-confirm {
  display: flex; flex-wrap: wrap; align-items: center; gap: var(--stp-gap);
  padding: 14px; border: 1px solid var(--ui-danger); border-radius: var(--radius-md);
  font-size: var(--stp-font);
}

/* calibration picture cards (Mirror picker language) */
.stp-mt-cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--stp-gap); }
@container (min-width: 1100px) {
  .stp-mt-cards { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
.stp-mt-card {
  position: relative; min-width: 0; text-align: left; display: flex; flex-direction: column; gap: 8px; min-height: var(--stp-hit);
  padding: 12px; color: inherit; cursor: pointer; overflow: hidden;
  background: var(--ui-panel-alt, var(--ui-ctrl)); border: 1px solid var(--ui-border); border-radius: var(--radius-md);
  transition: background-color 0.14s, border-color 0.14s, transform 0.14s;
}
.stp-mt-card:hover:not(:disabled) { transform: translateY(-1px); border-color: var(--stp-mt-color); }
.stp-mt-card.is-done { box-shadow: 0 0 0 1px var(--stp-mt-color) inset; }
.stp-mt-card-pic {
  display: flex; align-items: center; justify-content: center; height: 100px; min-width: 0; overflow: hidden;
  background: var(--ui-bg); border: 1px solid var(--ui-border); border-radius: var(--radius-sm);
  color: var(--stp-mt-color);
}
.stp-mt-card-pic svg { height: 80%; width: auto; max-width: 80%; }
.stp-mt-card-name { font-size: var(--stp-font); font-weight: 700; }
.stp-mt-card-tag { font-size: var(--stp-font-small); color: var(--ui-muted); line-height: 1.35; overflow-wrap: anywhere; }
.stp-mt-card-badge {
  position: absolute; top: 16px; right: 16px; padding: 4px 10px; border-radius: 9999px;
  font-size: var(--stp-font-small); font-weight: 700;
  background: var(--stp-mt-color); color: var(--ui-on-accent);
}
.stp-mt-card:not(.is-done) .stp-mt-card-badge { background: var(--ui-ctrl); color: var(--ui-muted); border: 1px solid var(--ui-border); }

.stp-mt-wiz {
  display: flex; flex-direction: column; gap: var(--stp-gap);
  padding: 22px; border-radius: var(--radius-md);
  border: 1px solid color-mix(in srgb, var(--stp-mt-color) 40%, var(--ui-border));
  background: linear-gradient(180deg, color-mix(in srgb, var(--stp-mt-color) 8%, transparent) 0%, transparent 80%);
}
.stp-mt-wiz-head { display: flex; flex-direction: column; gap: 2px; }
.stp-mt-wiz-step { font-size: var(--stp-font-small); color: var(--ui-muted); }
.stp-mt-wiz-title { font-size: var(--stp-font-heading); font-weight: 700; line-height: 1.25; }
.stp-mt-wiz-text, .stp-mt-wiz-extra { margin: 0; font-size: var(--stp-font); line-height: 1.5; color: var(--ui-text-2); }
.stp-mt-wiz-extra { font-family: var(--font-mono); }
.stp-mt-wiz-error { margin: 0; font-size: var(--stp-font); color: var(--ui-danger-text, var(--ui-danger)); }
.stp-mt-wiz-actions { display: flex; flex-wrap: wrap; gap: var(--stp-gap); }

/* console */
.stp-mt-chip { min-height: var(--stp-hit); }
.stp-mt-check { display: inline-flex; align-items: center; gap: 10px; min-height: var(--stp-hit); padding: 0 6px; cursor: pointer; font-size: var(--stp-font-small); color: var(--ui-text-2); }
.stp-mt-log {
  height: 340px; min-height: 160px; overflow-y: auto; resize: vertical;
  padding: 10px 14px;
  background: var(--ui-bg); border: 1px solid var(--ui-border); border-radius: var(--radius-sm);
  font-family: var(--font-mono); font-size: var(--stp-font-small); line-height: 1.5;
}
.stp-mt-line { display: flex; gap: var(--spacing-sm); white-space: pre-wrap; overflow-wrap: anywhere; }
.stp-mt-line-tag { flex: none; width: 1ch; color: var(--ui-muted); }
.stp-mt-line.is-tx .stp-mt-line-text { color: var(--stp-mt-color); }
.stp-mt-line.is-rx .stp-mt-line-text { color: var(--ui-text); }
.stp-mt-line.is-info .stp-mt-line-text { color: var(--ui-muted); }
.stp-mt-line.is-warn .stp-mt-line-text { color: var(--ui-warning, var(--ui-text)); }
.stp-mt-line.is-error .stp-mt-line-text { color: var(--ui-danger-text, var(--ui-danger)); }
.stp-mt-log.is-hide-tx .is-tx, .stp-mt-log.is-hide-rx .is-rx, .stp-mt-log.is-hide-info .is-info,
.stp-mt-log.is-hide-warn .is-warn, .stp-mt-log.is-hide-error .is-error { display: none; }
.stp-mt-console-form { display: flex; gap: var(--stp-gap); }
.stp-mt-console-input { flex: 1; min-width: 0; }
.stp-mt-adv { display: flex; flex-direction: column; gap: var(--stp-gap); padding-top: var(--stp-gap); border-top: 1px solid var(--ui-border); }
.stp-mt-adv-confirm { display: flex; flex-wrap: wrap; align-items: center; gap: var(--stp-gap); }
.stp-mt-switch { display: inline-flex; align-items: center; gap: 14px; min-height: var(--stp-hit); font-size: var(--stp-font); cursor: pointer; }
.stp-mt-switch input { position: absolute; opacity: 0; pointer-events: none; }
.stp-mt-switch-track {
  position: relative; width: 56px; height: 30px; flex: none; border-radius: 9999px;
  background: var(--ui-ctrl); border: 1px solid var(--ui-border);
  transition: background-color 0.14s, border-color 0.14s;
}
.stp-mt-switch-track::after {
  content: ''; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%;
  background: var(--ui-text-2); transition: transform 0.14s, background-color 0.14s;
}
.stp-mt-switch input:checked + .stp-mt-switch-track { background: var(--ui-danger); border-color: var(--ui-danger); }
.stp-mt-switch input:checked + .stp-mt-switch-track::after { transform: translateX(26px); background: var(--ui-on-danger); }
.stp-mt-switch input:focus-visible + .stp-mt-switch-track { outline: 2px solid var(--ui-accent); outline-offset: 2px; }
.stp-mt-switch input:disabled ~ * { opacity: 0.5; }
@media (prefers-reduced-motion: reduce) {
  .stp-mt-btn, .stp-mt-dir, .stp-mt-card, .stp-mt-switch-track, .stp-mt-switch-track::after { transition: none; }
}

/* ==== Send to Plotter: v2 guided flow (docs/plotter-send-spec.md section 12) ==== */
/* rail: numbered tabs with status glyphs, divider, Console (Advanced) */
.stp-tab-num { flex: none; width: 30px; height: 30px; display: inline-flex; align-items: center; justify-content: center; border-radius: 50%; border: 1px solid var(--ui-border-hi, var(--ui-border)); font: 700 15px/1 var(--font-mono); }
.stp-tab-lbl { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.stp-tab-sub { font-size: 15px; font-weight: 500; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ui-muted); }
.stp-tab-glyph { flex: none; width: 22px; text-align: center; font-weight: 800; color: var(--ui-muted); }
.stp-tab[data-status="done"] .stp-tab-glyph { color: var(--stp-ok); }
.stp-tab[data-status="attention"] .stp-tab-glyph { color: var(--ui-accent); }
.stp-tab[data-status="attention"] .stp-tab-num { border-color: var(--ui-accent); color: var(--ui-accent); }
.stp-tab[data-status="idle"] { opacity: 0.62; }
.stp-tab.is-active[data-status="idle"] { opacity: 1; }
.stp-rail-div { flex: none; height: 1px; margin: 6px 10px; background: var(--ui-border); }
/* header readout */
.stp-readout { flex: none; display: inline-flex; gap: 14px; font-family: var(--font-mono); font-size: 17px; font-weight: 600; color: var(--ui-text); white-space: nowrap; }
.stp-ro-cell { display: inline-flex; gap: 6px; }
.stp-ro-ax { color: var(--ui-muted); }
.stp-ro-val { min-width: 5.2ch; text-align: right; }
.stp-hdr-conn { flex: none; }
.stp-head .stp-title, .stp-head .stp-profile-name { flex: none; white-space: nowrap; }
.stp-head .stp-profile-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; flex: 0 1 auto; }
/* next-step banner */
.stp-banner { flex: none; display: flex; flex-direction: column; gap: 6px; padding: 8px 16px; border-bottom: 1px solid var(--ui-border); background: color-mix(in srgb, var(--ui-accent) 5%, transparent); }
.stp-banner .stp-confirm { margin: 0; }
.stp-step { display: flex; align-items: center; gap: 14px; min-height: var(--stp-hit); }
.stp-step-lbl { flex: none; font-size: 15px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ui-accent-text, var(--ui-accent)); }
.stp-step-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.stp-step-text { min-width: 0; font-size: 19px; font-weight: 600; line-height: 1.3; }
.stp-step-note { font-size: var(--stp-font-small); color: var(--ui-muted); line-height: 1.3; opacity: 1; transition: opacity 0.4s ease; }
.stp-step-note.is-fading { opacity: 0; }
.stp-step-note.is-persist { color: var(--ui-danger-text, var(--ui-danger)); font-weight: 600; }
.stp-lastport { margin: 6px 0; font-family: var(--font-mono); font-size: var(--stp-font); color: var(--ui-text-2); }
.stp-step.is-alarm .stp-step-text, .stp-step.is-wco .stp-step-text { color: var(--ui-danger-text, var(--ui-danger)); }
.stp-banner-err { display: flex; align-items: center; gap: 12px; padding: 8px 12px; border: 1px solid var(--ui-danger); border-radius: var(--radius-md); background: color-mix(in srgb, var(--ui-danger) 10%, transparent); color: var(--ui-danger-text, var(--ui-danger)); }
.stp-banner-err span { flex: 1; }
/* visually hidden aria-live region; the visible transient note is .stp-step-note inside the banner */
.stp-root .sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.stp-corner { padding: 10px 14px; border: 2px solid var(--stp-warn); border-radius: var(--radius-md); background: color-mix(in srgb, var(--stp-warn) 10%, transparent); }
.stp-corner-q { font-size: 20px; }
.stp-corner .stp-btnrow { margin: 6px 0 0; }
.stp-corner-steps { margin: 6px 0 0; padding-left: 26px; }
/* collapsed Advanced sections */
.stp-adv { margin: 10px 0; border-top: 1px solid var(--ui-border); }
.stp-adv > summary { color: var(--ui-text-2); font-weight: 600; font-size: var(--stp-font-small); letter-spacing: 0.06em; text-transform: uppercase; cursor: pointer; }
.stp-sub-lbl { margin: 10px 0 0; font-size: var(--stp-font-small); font-weight: 600; color: var(--ui-text-2); }
/* selected profile row */
.stp-selrow { display: flex; align-items: center; flex-wrap: nowrap; min-width: 0; gap: 12px; padding: 8px 12px; border: 1px solid var(--stp-card-color, var(--ui-border)); border-radius: var(--radius-md); background: var(--ui-panel-alt, var(--ui-ctrl)); }
.stp-selrow-icon { width: 56px; height: 34px; color: var(--stp-card-color, var(--ui-accent)); }
.stp-selrow-icon svg { width: 100%; height: 100%; }
.stp-selrow-name { flex: none; font-weight: 700; font-size: var(--stp-font); white-space: nowrap; }
.stp-selrow > * { min-width: 0; }
.stp-selrow-icon, .stp-selrow .stp-badge, .stp-selrow-actions { flex: none; }
.stp-selrow-size { flex: 0 1 auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stp-selrow-actions { display: flex; align-items: center; gap: 8px; }
.stp-selrow .stp-spacer { flex: 1 1 0; min-width: 0; }
.stp-origin-reminder { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; margin-top: 8px; padding: 8px 12px; border: 1px solid var(--ui-accent); border-radius: var(--radius-md); background: color-mix(in srgb, var(--ui-accent) 12%, transparent); }
.stp-origin-reminder-text { flex: 1 1 320px; font-size: var(--stp-font); }
.stp-selrow .stp-badge { margin-top: 0; align-self: center; }
.stp-pen-grid.is-primary { grid-template-columns: repeat(2, minmax(0, 1fr)); margin: 6px 0; }
.stp-pen { padding: 8px 12px; margin-bottom: 8px; }
.stp-pen .stp-adv { margin: 4px 0 0; }
.stp-plotcol .stp-sec { margin-bottom: 10px; }
/* Machine tab: primary block in one view */
.stp-mt-root { gap: 12px; }
.stp-mt-sec { gap: 10px; }
.stp-mt-jog { gap: 22px; }
.stp-mt-steps { display: flex; gap: 8px; }
.stp-mt-steps .tog-btn { flex: 1; min-width: 64px; min-height: 52px; padding: 0 12px; font-size: 18px; font-weight: 700; }
.stp-mt-origin-row .stp-mt-btn.is-primary { flex: 1 1 100%; }
.stp-mt-advsec, .stp-mt-calsec { border-top: 1px solid var(--ui-border); padding-top: 4px; }
.stp-mt-advsec > summary, .stp-mt-calsec > summary { min-height: var(--stp-hit); display: flex; align-items: center; cursor: pointer; color: var(--ui-text-2); font-weight: 600; font-size: var(--stp-font-small); letter-spacing: 0.06em; text-transform: uppercase; }
.stp-mt-advsec[open] { display: flex; flex-direction: column; gap: 10px; }
@media (prefers-reduced-motion: reduce) { .stp-mt-dial-stop { filter: none; } }
/* header: Moving pill (pulsing dot), origin chip */
.stp-pill.is-moving { color: var(--ui-text); border-color: var(--ui-accent); background: color-mix(in srgb, var(--ui-accent) 14%, var(--ui-ctrl)); }
.stp-pill.is-moving::before { background: var(--ui-accent); animation: stp-pulse 1s ease-in-out infinite; }
@keyframes stp-pulse { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: 0.35; transform: scale(0.78); } }
@media (prefers-reduced-motion: reduce) { .stp-pill.is-moving::before { animation: none; } .stp-step-note { transition: none; } }
.stp-chip { flex: none; display: inline-flex; align-items: center; min-height: 36px; padding: 0 14px; border-radius: 9999px; font-size: var(--stp-font-small); font-weight: 700; white-space: nowrap; border: 1px solid var(--ui-border); background: var(--ui-ctrl); color: var(--ui-text-2); }
.stp-chip.is-set { color: var(--stp-ok); border-color: var(--stp-ok); }
/* every collapsed disclosure: visible chevron, full-row 52px hit target, hover */
.stp-root details > summary { list-style: none; position: relative; display: flex; align-items: center; gap: 12px; min-height: var(--stp-hit); box-sizing: border-box; padding: 0 12px; border-radius: var(--radius-md); cursor: pointer; user-select: none; transition: background-color 0.14s, color 0.14s; }
.stp-root details > summary::-webkit-details-marker { display: none; }
.stp-root details > summary::marker { content: ''; }
.stp-root details > summary::before { content: '\25B8'; flex: none; width: 1em; text-align: center; font-size: 18px; line-height: 1; color: var(--ui-accent-text, var(--ui-accent)); }
.stp-root details[open] > summary::before { content: '\25BE'; }
.stp-root details > summary:hover { background: var(--ui-ctrl-hov, var(--ui-ctrl)); color: var(--ui-text); }
.stp-root details > summary:focus-visible { outline: 2px solid var(--ui-accent); outline-offset: 1px; }
/* Setup placement: tall mode control, three compact number inputs in one row */
.stp-root .tog-grp { gap: 6px; }
.stp-root .tog-btn { min-height: var(--stp-hit); height: var(--stp-hit); padding: 0 18px; font-size: 17px; font-weight: 600; flex: 1 1 0; }
.stp-placerow { display: grid; grid-template-columns: repeat(3, minmax(0, 140px)); gap: 12px; margin: 12px 0; }
.stp-placerow .stp-in { max-width: 140px; }
/* shared switches: big enough to hit */
.stp-root .sw-toggle { width: 56px; height: 32px; margin: 10px 0; }
.stp-root .sw-thumb { top: 4px; left: 4px; width: 24px; height: 24px; }
.stp-root .sw-toggle input:checked ~ .sw-thumb { transform: translateX(24px); }
@container stp (max-width: 860px) { .stp-rail-div { width: 1px; height: auto; margin: 4px 6px; } .stp-tab-sub { display: none; } .stp-head { overflow-x: auto; } }
/* ==== end Send to Plotter ==== */

/* Send to Plotter: manufacturer specs dialog (read-only) and the card info button */
.stp-root { position: relative; }
.stp-cardwrap { position: relative; display: flex; min-width: 0; }
.stp-cardwrap > .stp-card { flex: 1; min-width: 0; }
.stp-card-specs { position: absolute; top: 4px; right: 4px; min-width: 36px; min-height: 36px; border: 1px solid var(--ui-border); border-radius: 50%; background: var(--ui-panel, var(--ui-ctrl)); color: var(--ui-text-2); font-size: 18px; line-height: 1; cursor: pointer; }
.stp-card-specs:hover, .stp-card-specs:focus-visible { border-color: var(--ui-accent); color: var(--ui-text); }
.stp-specs { position: absolute; inset: 0; z-index: 30; display: flex; align-items: stretch; justify-content: center; padding: 16px; background: rgba(0, 0, 0, 0.55); }
.stp-specs-card { display: flex; flex-direction: column; width: min(100%, 1000px); min-height: 0; background: var(--ui-panel, var(--ui-bg)); border: 1px solid var(--ui-border); border-radius: var(--radius-md); }
.stp-specs-head { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-bottom: 1px solid var(--ui-border); }
.stp-specs-title { font-size: calc(var(--stp-font) + 2px); }
.stp-spec-body { flex: 1; min-height: 0; overflow: auto; padding: 8px 16px 16px; }
.stp-spec-h { margin: 14px 0 6px; font-size: 15px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ui-text-2); }
.stp-spec-list { font-size: 16px; display: grid; grid-template-columns: minmax(180px, 1fr) 2fr; gap: 6px 16px; margin: 0; }
.stp-spec-list dt { font-size: 15px; color: var(--ui-text-2); }
.stp-spec-list dd { margin: 0; color: var(--ui-text); }
.stp-spec-speeds { width: 100%; font-size: 16px; border-collapse: collapse; }
.stp-spec-val { white-space: nowrap; }
.stp-spec-speeds th, .stp-spec-speeds td { padding: 6px 8px; border-bottom: 1px solid var(--ui-border); text-align: left; vertical-align: top; }
.stp-spec-speeds td span, .stp-spec-speeds th span { display: block; }
.stp-spec-speeds tr.is-closest { background: color-mix(in srgb, var(--ui-accent) 14%, transparent); }
.stp-spec-closest { color: var(--ui-accent-text, var(--ui-accent)); font-weight: 600; }
.stp-hs-badge { border-color: var(--ui-warn, var(--ui-accent)); }
.stp-pen-preset { min-height: var(--stp-hit); }
