.workbench {
  --wb-cols: 264px minmax(420px, 1fr) minmax(320px, .7fr);
  --wb-cols-lg: 248px minmax(380px, 1fr) minmax(300px, .7fr);
}

/* ---------- source slots A-D ---------- */
.source-card {
  display: grid;
  grid-template-columns: var(--drop-art) minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  min-height: var(--drop-h);
  padding: var(--sp-3);
  border: 1px dashed var(--line-bright);
  border-radius: 8px;
  background: var(--well);
  transition: border-color .16s ease, background .16s ease;
}
.source-card.is-drag { border-color: var(--accent); background: var(--panel-2); }
.source-card.has-file { border-style: solid; }
.source-card .drop-art b { font-family: var(--font-mono); font-size: var(--fs-lg); font-weight: 600; }
.source-meta { min-width: 0; display: grid; gap: var(--sp-2); }
.source-top { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; min-width: 0; }
.source-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: var(--fs-sm); font-weight: 600; }
.slot-role { color: var(--accent); font-size: var(--fs-3xs); }
.source-actions { display: flex; gap: var(--sp-2); min-width: 0; }
.source-load { display: inline-grid; place-items: center; flex: 1; cursor: pointer; }
.source-load:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }
.source-space { flex: 1; min-width: 0; min-height: var(--control-h-xs); padding-left: 6px; font-size: var(--fs-2xs); }
.source-remove { flex: none; width: 26px; padding: 0; font-size: var(--fs-lg); }
/* Empty slots offer "Choose image"; loaded ones the colour space and remove. */
.source-card:not(.has-file) :is(.source-space, .source-remove) { display: none; }
.source-card.has-file .source-load { display: none; }

.size-grid { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); gap: 6px; align-items: center; color: var(--dim); margin-bottom: var(--sp-2); }
.section-heading > .mono-label { margin-left: auto; color: var(--dim); }
.status-line { margin-bottom: var(--sp-3); }

/* ---------- channel pack ---------- */
.pack-body { display: grid; gap: 10px; padding: 12px; }
.preset-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; align-items: end; }
.format-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: var(--control-h-sm);
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--well);
  color: var(--muted);
  font-size: var(--fs-xs);
}
.format-chip span { color: var(--accent); font-family: var(--font-mono); font-weight: 600; }
.format-chip b { font-weight: 500; }
.mapping-list { display: grid; gap: 8px; }
.channel-card { border: 1px solid var(--line); border-radius: 8px; background: var(--panel-2); overflow: hidden; }
.channel-main {
  display: grid;
  grid-template-columns: 30px minmax(110px, 1.1fr) minmax(96px, .8fr) auto;
  gap: 8px;
  align-items: center;
  padding: 8px;
}
.channel-id {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  color: var(--accent-ink);
  font-family: var(--font-mono);
  font-size: var(--fs-md);
  font-weight: 600;
}
.channel-id.r { background: var(--chan-r); }
.channel-id.g { background: var(--chan-g); }
.channel-id.b { background: var(--chan-b); }
.channel-id.a { background: var(--chan-a); }
.channel-main select { width: 100%; min-width: 0; }
.channel-card .control-grid { --cols: 3; padding: 2px 8px 6px 46px; }

/* ---------- output preview ---------- */
#previewCanvas { object-fit: contain; }
.stage:not(.is-ready) > canvas { opacity: 0; }

.group-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.group-title { color: var(--muted); font-family: var(--font-mono); font-size: var(--fs-2xs); font-weight: 600; letter-spacing: var(--ls-caps); text-transform: uppercase; }
.pane-body .field-grid { margin-bottom: var(--sp-3); }
.pane-body .toggle-row:last-of-type { border-bottom: 1px solid var(--line); }
.pane-body .note { margin: 8px 0; min-height: 2.8em; }
.pane-body .progress { margin-top: 8px; }
.metric-grid { display: grid; grid-template-columns: repeat(3, 1fr); margin-top: 10px; border: 1px solid var(--line); border-radius: var(--radius-md); overflow: hidden; }
.metric { min-width: 0; padding: 8px; background: var(--well); }
.metric + .metric { border-left: 1px solid var(--line); }
.metric span { display: block; color: var(--dim); font-size: var(--fs-2xs); }
.metric strong { display: block; margin-top: 2px; font-family: var(--font-mono); font-size: var(--fs-sm); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(18px + env(safe-area-inset-bottom));
  z-index: 30;
  max-width: min(520px, calc(100vw - 24px));
  padding: 9px 14px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-md);
  color: var(--ink);
  background: var(--panel-2);
  box-shadow: var(--shadow);
  font-size: var(--fs-md);
  opacity: 0;
  transform: translate(-50%, 12px);
  transition: opacity .18s ease, transform .18s ease;
  pointer-events: none;
}
.toast.is-show { opacity: 1; transform: translate(-50%, 0); }
.toast.is-error { border-color: var(--error); color: var(--error); }

@media (max-width: 940px) {
  .drop-stack { grid-template-columns: 1fr; }
}
@media (max-width: 700px) {
  .drop-stack { grid-template-columns: 1fr 1fr; }
  .channel-card .control-grid { padding-left: 8px; }
}
@media (max-width: 480px) {
  .drop-stack { grid-template-columns: 1fr; }
  .preset-row { grid-template-columns: 1fr; }
  .channel-main { grid-template-columns: 30px minmax(0, 1fr); }
  .channel-main .chan-value, .channel-main .check { grid-column: 2; }
  .channel-card .control-grid { --cols: 1; }
}
