/*
 * The tool workbench.
 *
 * Three columns on a desktop — categories, operations, work — collapsing to
 * two stages on a phone, because a three-pane layout at 380px is three
 * unusable panes. `[data-stage]` on the root is what switches between them:
 * the list until an operation is chosen, then the panel with a way back.
 */

/* Wider than a reading page: three columns and a two-pane panel need it. */
.workbench-shell {
  width: min(100% - (2 * var(--gutter)), var(--shell-wide));
  padding-block: var(--space-5) var(--space-8);
}

.workbench {
  display: grid;
  grid-template-columns: 12rem minmax(0, 22rem) minmax(0, 1fr);
  gap: var(--space-5);
  align-items: start;
}

/* ------------------------------------------------------------------ rail */

.workbench-rail {
  position: sticky;
  top: calc(var(--header-height) + 1.25rem);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.workbench-rail__item {
  display: flex;
  gap: var(--space-3);
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 0.75rem;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--color-text-soft);
  font-size: var(--text-sm);
  text-align: left;
  cursor: pointer;
  transition: background-color var(--duration-fast) ease, color var(--duration-fast) ease;
}

.workbench-rail__item:hover {
  background: var(--color-surface);
  color: var(--color-text);
}

.workbench-rail__item[aria-pressed="true"] {
  background: var(--color-accent-wash);
  color: var(--color-accent);
  font-weight: 500;
}

.workbench-rail__count {
  color: var(--color-text-faint);
  font-size: var(--text-xs);
  font-variant-numeric: tabular-nums;
}

.workbench-rail__item[aria-pressed="true"] .workbench-rail__count {
  color: inherit;
}

.workbench-rail__divider {
  height: 1px;
  margin: var(--space-2) 0.75rem;
  background: var(--color-line);
}

.workbench-rail__item[hidden] {
  display: none;
}

/* ------------------------------------------------------------------ list */

.workbench-search {
  position: relative;
  margin-bottom: var(--space-3);
}

.workbench-search__icon {
  position: absolute;
  z-index: 1;
  top: 50%;
  left: 1rem;
  width: 1.1rem;
  height: 1.1rem;
  color: var(--color-text-muted);
  transform: translateY(-50%);
  transition: color var(--duration-fast) ease, transform var(--dur-normal) var(--ease-spring);
  pointer-events: none;
}

.workbench-search:focus-within .workbench-search__icon {
  color: var(--color-accent);
  transform: translateY(-50%) scale(1.08);
}

.workbench-search input {
  width: 100%;
  height: 2.75rem;
  padding: 0 var(--space-4) 0 2.7rem;
  border: 1px solid var(--color-line);
  border-radius: 999px;
  background: var(--color-surface);
  color: var(--color-text);
  font-size: var(--text-sm);
  transition: border-color var(--duration-fast) ease;
}

.workbench-search input:hover {
  border-color: var(--color-rule);
}

.workbench-count {
  margin: 0 0 var(--space-2);
  padding-inline: var(--space-3);
  color: var(--color-text-faint);
  font-size: var(--text-xs);
  font-variant-numeric: tabular-nums;
  text-align: right;
}

/*
 * The rows are the catalogue's own index rows, so the hover sweep — the
 * highlight tail and the tick from sound.js — is the same interaction here.
 * Only the density changes: this list is a picker inside a column, not the
 * page's main content.
 */
.workbench-rows {
  max-height: min(58vh, 40rem);
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  scrollbar-width: thin;
  scrollbar-color: color-mix(in srgb, var(--color-text-faint) 62%, transparent) transparent;
  border-top: 1px solid var(--color-line);
}

.workbench-rows::-webkit-scrollbar,
.workbench-output::-webkit-scrollbar {
  width: 0.7rem;
  height: 0.7rem;
}

.workbench-rows::-webkit-scrollbar-track,
.workbench-output::-webkit-scrollbar-track {
  background: transparent;
}

.workbench-rows::-webkit-scrollbar-thumb,
.workbench-output::-webkit-scrollbar-thumb {
  border: 0.2rem solid transparent;
  border-radius: 999px;
  background: color-mix(in srgb, var(--color-text-faint) 62%, transparent);
  background-clip: padding-box;
}

.workbench-rows::-webkit-scrollbar-thumb:hover,
.workbench-output::-webkit-scrollbar-thumb:hover {
  background: color-mix(in srgb, var(--color-accent) 70%, var(--color-text-faint));
  background-clip: padding-box;
}

.workbench-row {
  padding-block: 0.6rem;
}

.workbench-row .index-row__name {
  font-size: var(--text-md);
}

/* The second line is a worked example (input → output), in quiet type. */
.workbench-row .index-row__desc {
  overflow: hidden;
  color: var(--color-text-faint);
  font-size: var(--text-xs);
  text-overflow: ellipsis;
  white-space: nowrap;
}

/*
 * Group headings in the unfiltered list — 常用, 文本, 数据… They stay pinned
 * to the top of the scrolling list while their group is in view, so the
 * reader always knows which part of 1174 they are in.
 */
.workbench-group {
  position: sticky;
  z-index: 1;
  top: 0;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 0.85rem var(--space-3) 0.45rem;
  border-bottom: 1px solid var(--color-line);
  background: var(--color-bg);
}

.workbench-group__label {
  color: var(--color-text);
  font-size: var(--text-sm);
  font-weight: 700;
}

.workbench-group__count {
  color: var(--color-text-faint);
  font-size: var(--text-xs);
  font-variant-numeric: tabular-nums;
}

.workbench-row[aria-selected="true"]::before,
.workbench-row.is-active::before {
  opacity: 1;
}

.workbench-row[aria-selected="true"]::after {
  transform: scaleY(1);
  opacity: 1;
}

html.motion-standard .workbench-row:hover,
html.motion-full .workbench-row:hover,
html.motion-standard .workbench-row:focus-visible,
html.motion-full .workbench-row:focus-visible,
html.motion-standard .workbench-row[aria-selected="true"],
html.motion-full .workbench-row[aria-selected="true"] {
  transform: none;
}

html.motion-standard .workbench-row:active,
html.motion-full .workbench-row:active {
  transform: scale(0.994);
}

.workbench-more {
  display: flex;
  justify-content: center;
  padding-top: var(--space-4);
}

/* ----------------------------------------------------------------- panel */

/*
 * The panel is laid out like an editor: a title line with its few actions,
 * the parameters in one row, and two panes — input and result — each a
 * framed box with its own tool bar on top and its counts at the foot. The
 * pipeline follows as a flow drawn down the left edge.
 */
.workbench-panel {
  display: grid;
  gap: var(--space-6);
  align-content: start;
  min-width: 0;
  container-type: inline-size;
}

.workbench-placeholder {
  padding: var(--space-6);
  border: 1px dashed var(--color-line);
  border-radius: var(--radius-lg);
  color: var(--color-text-muted);
  font-size: var(--text-sm);
}

.workbench-placeholder > p:first-of-type + p {
  max-width: 38rem;
}

.workbench-placeholder__title {
  margin-top: 0;
  color: var(--color-text);
  font-size: var(--text-lg);
  font-weight: 600;
}

.workbench-placeholder code {
  font-family: var(--font-mono);
  font-size: 0.9em;
}

.workbench-placeholder__label {
  margin: var(--space-5) 0 var(--space-2);
  color: var(--color-text-faint);
  font-size: var(--text-xs);
  font-weight: 600;
}

.workbench-quick {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.workbench-quick__item {
  min-height: 2.1rem;
  padding-inline: 0.85rem;
  border: 1px solid var(--color-line);
  border-radius: 999px;
  background: var(--color-surface);
  color: var(--color-text);
  font-size: var(--text-sm);
  cursor: pointer;
  transition: border-color 600ms var(--ease-out-quint), color 600ms var(--ease-out-quint);
}

.workbench-quick__item:hover {
  border-color: var(--color-accent);
  color: var(--color-accent);
  transition-duration: 100ms;
}

.workbench-quick__item--preset::before {
  content: "⇢ ";
  color: var(--color-accent);
}

/* A saved pipeline: the chip, and a small × that deletes it. */
.wb-chip {
  display: inline-flex;
  align-items: center;
}

.wb-chip .workbench-quick__item {
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
}

.wb-chip__remove {
  min-height: 2.1rem;
  padding-inline: 0.6rem;
  border: 1px solid var(--color-line);
  border-left: 0;
  border-radius: 0 999px 999px 0;
  background: var(--color-surface);
  color: var(--color-text-faint);
  cursor: pointer;
  transition: color 600ms var(--ease-out-quint);
}

.wb-chip__remove:hover {
  color: var(--color-error);
  transition-duration: 100ms;
}

.workbench-keys {
  margin: var(--space-5) 0 0;
  color: var(--color-text-faint);
  font-size: var(--text-xs);
  line-height: 2;
}

.workbench kbd {
  display: inline-block;
  min-width: 1.5em;
  padding: 0.05em 0.4em;
  border: 1px solid var(--color-line);
  border-bottom-width: 2px;
  border-radius: 0.35rem;
  background: var(--color-surface);
  color: var(--color-text-soft);
  font-family: inherit;
  font-size: 0.85em;
  text-align: center;
}

/* Only the phone layout needs a way back to the list. */
.workbench-back {
  display: none;
  margin-bottom: var(--space-3);
}

/* ------------------------------------------------------------ tool page */

.workbench-toolpage h2 {
  margin: 0 0 var(--space-2);
  font-size: var(--text-2xl);
}

.workbench-toolpage__desc {
  margin: 0 0 var(--space-4);
  color: var(--color-text-muted);
}

.workbench-related {
  border-top: 1px solid var(--color-line);
}

.workbench-related__none {
  margin: var(--space-3) 0 0;
  color: var(--color-text-muted);
  font-size: var(--text-sm);
}

/* ----------------------------------------------------------------- head */

.wb-head {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3) var(--space-5);
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: var(--space-5);
}

.wb-head__titles {
  flex: 1 1 14rem;
  min-width: 0;
}

.wb-head__crumb {
  margin: 0 0 0.2rem;
  color: var(--color-text-faint);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
}

.wb-head h2 {
  margin: 0;
  font-size: var(--text-2xl);
  letter-spacing: -0.015em;
}

.wb-head__actions {
  display: flex;
  gap: var(--space-2);
  align-items: center;
}

.wb-head__pipe {
  gap: 0.35rem;
  min-height: 2.25rem;
  padding-inline: 0.9rem 1rem;
  font-size: var(--text-sm);
}

.wb-head__pipe .wb-btn__icon {
  width: 1rem;
  height: 1rem;
}

.wb-editing {
  margin: 0 0 var(--space-4);
  padding: var(--space-3) var(--space-4);
  border-left: 3px solid var(--color-accent);
  background: var(--color-accent-wash);
  color: var(--color-text-soft);
  font-size: var(--text-sm);
}

/* ------------------------------------------------------------- buttons */

/*
 * Small quiet buttons for the tool bars: an icon and a word, no frame until
 * the pointer is on them. Colour arrives in 100ms and leaves over 600ms.
 */
.wb-btn {
  display: inline-flex;
  gap: 0.3rem;
  align-items: center;
  justify-content: center;
  min-height: 1.9rem;
  padding: 0 0.55rem;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--color-text-muted);
  font-size: var(--text-xs);
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 600ms var(--ease-out-quint), color 600ms var(--ease-out-quint);
}

.wb-btn:hover:not(:disabled) {
  background: color-mix(in srgb, var(--color-text) 7%, transparent);
  color: var(--color-text);
  transition-duration: 100ms;
}

.wb-btn:disabled {
  cursor: default;
  opacity: 0.35;
}

.wb-btn[hidden] {
  display: none;
}

.wb-btn__icon {
  flex: none;
  width: 0.95rem;
  height: 0.95rem;
}

.wb-btn--icon {
  width: 2.25rem;
  min-height: 2.25rem;
  padding: 0;
  border: 1px solid var(--color-line);
  border-radius: 999px;
  background: var(--color-surface);
}

.wb-btn--icon .wb-btn__icon {
  width: 1.1rem;
  height: 1.1rem;
}

.wb-btn--icon[aria-pressed="true"] {
  border-color: color-mix(in srgb, var(--color-accent) 45%, var(--color-line));
  color: var(--color-accent);
}

.wb-btn--icon[aria-pressed="true"] .wb-btn__icon {
  fill: currentColor;
}

.wb-btn--sm {
  width: 1.75rem;
  min-height: 1.75rem;
  border: 0;
  background: transparent;
}

.wb-btn--sm .wb-btn__icon {
  width: 0.95rem;
  height: 0.95rem;
}

.wb-run {
  min-height: 2rem;
  padding-inline: 1.1rem;
  font-size: var(--text-sm);
}

/* ------------------------------------------------------------ parameters */

.wb-args {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3) var(--space-4);
  margin-bottom: var(--space-4);
}

.wb-args[hidden] {
  display: none;
}

.wb-arg {
  display: grid;
  gap: 0.25rem;
  min-width: 8rem;
  color: var(--color-text-muted);
  font-size: var(--text-xs);
  font-weight: 600;
}

.wb-arg input {
  min-height: 2.25rem;
  padding: 0 0.7rem;
  border: 1px solid var(--color-line);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  color: var(--color-text);
  font-size: var(--text-sm);
  font-weight: 400;
}

/* ----------------------------------------------------------------- panes */

.wb-panes {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: var(--space-4);
  align-items: stretch;
}

@container (max-width: 40rem) {
  .wb-panes {
    grid-template-columns: minmax(0, 1fr);
  }
}

.wb-pane {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  min-width: 0;
  min-height: 16rem;
  overflow: hidden;
  border: 1px solid var(--color-line);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  transition: border-color 300ms var(--ease-out-quint), box-shadow 300ms var(--ease-out-quint);
}

.wb-pane:focus-within {
  border-color: color-mix(in srgb, var(--color-accent) 55%, var(--color-line));
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-accent) 14%, transparent);
}

.wb-pane.is-dropping {
  border-color: var(--color-accent);
  border-style: dashed;
}

.wb-pane__bar,
.wb-pane__foot {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  align-items: center;
  justify-content: space-between;
  min-height: 2.6rem;
  padding: 0.3rem 0.4rem 0.3rem 0.85rem;
  background: var(--color-surface-sunken);
}

.wb-pane__bar {
  border-bottom: 1px solid var(--color-line);
}

.wb-pane__foot {
  border-top: 1px solid var(--color-line);
}

.wb-pane__title {
  color: var(--color-text);
  font-size: var(--text-sm);
  font-weight: 600;
}

.wb-pane__tools,
.wb-pane__options {
  display: flex;
  flex-wrap: wrap;
  gap: 0.15rem;
  align-items: center;
}

.wb-pane__tools[hidden] {
  display: none;
}

.wb-pane__options {
  gap: var(--space-3);
}

.wb-pane__stats {
  color: var(--color-text-faint);
  font-size: var(--text-xs);
  font-variant-numeric: tabular-nums;
}

.wb-pane__body {
  display: grid;
  min-height: 0;
}

/* The text areas sit flush in the pane: the pane is the field. */
.wb-input {
  width: 100%;
  min-height: 10rem;
  padding: 0.85rem;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--color-text);
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  line-height: 1.6;
  resize: vertical;
}

.wb-input:focus {
  outline: none;
  box-shadow: none;
}

.wb-output {
  max-height: 28rem;
  margin: 0;
  padding: 0.85rem;
  overflow: auto;
  border: 0;
  background: transparent;
  color: var(--color-text);
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  line-height: 1.6;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  scrollbar-width: thin;
}

.wb-output.is-idle {
  color: var(--color-text-faint);
}

.wb-output.is-error {
  color: var(--color-error);
}

.wb-pane__empty {
  margin: 0;
  padding: 0.85rem;
  color: var(--color-text-faint);
  font-size: var(--text-sm);
}

.wb-check {
  display: inline-flex;
  gap: 0.3rem;
  align-items: center;
  color: var(--color-text-muted);
  font-size: var(--text-xs);
  cursor: pointer;
}

.wb-check[hidden] {
  display: none;
}

/* A file: a drop target filling the pane, with the picker inside it. */
.wb-file {
  display: grid;
  place-content: center;
  gap: 0.35rem;
  margin: 0.85rem;
  padding: var(--space-5);
  border: 1px dashed var(--color-rule);
  border-radius: var(--radius-sm);
  color: var(--color-text-muted);
  font-size: var(--text-sm);
  text-align: center;
}

.wb-file__title {
  color: var(--color-text);
  font-weight: 600;
}

.wb-file__note {
  color: var(--color-text-faint);
  font-size: var(--text-xs);
}

.wb-file input {
  justify-self: center;
  margin-top: var(--space-2);
  font-size: var(--text-sm);
}

.workbench-preview {
  padding: 0.85rem 0.85rem 0;
}

.workbench-preview__image {
  max-width: 100%;
  max-height: 18rem;
  border: 1px solid var(--color-line);
  border-radius: var(--radius-sm);
  /* A checkerboard, so a transparent result is visibly transparent rather
     than looking like it came out white. */
  background-image:
    linear-gradient(45deg, var(--color-surface-sunken) 25%, transparent 25%),
    linear-gradient(-45deg, var(--color-surface-sunken) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, var(--color-surface-sunken) 75%),
    linear-gradient(-45deg, transparent 75%, var(--color-surface-sunken) 75%);
  background-position: 0 0, 0 6px, 6px -6px, -6px 0;
  background-size: 12px 12px;
}

.workbench-swatches {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  overflow: hidden;
  border: 1px solid var(--color-line);
  border-radius: var(--radius-sm);
}

.workbench-swatch {
  flex: 1 1 3rem;
  min-width: 2.5rem;
  height: 3.5rem;
}

/* -------------------------------------------------------------- pipeline */

.wb-pipe {
  display: grid;
  gap: var(--space-4);
  padding-top: var(--space-6);
  border-top: 1px solid var(--color-line);
}

.wb-pipe[hidden] {
  display: none;
}

.wb-pipe__head {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3) var(--space-5);
  align-items: flex-end;
  justify-content: space-between;
}

.wb-pipe__head h3 {
  margin: 0;
  font-size: var(--text-xl);
}

.wb-pipe__meta {
  margin: 0.15rem 0 0;
  color: var(--color-text-faint);
  font-size: var(--text-xs);
}

.wb-pipe__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.15rem;
  align-items: center;
}

.wb-pipe__actions .wb-run {
  margin-left: var(--space-2);
}

/*
 * The flow: a line down the left through one dot per node — the input, each
 * step (numbered), the result. What happens to the text reads top to bottom.
 */
.wb-flow {
  --dot: 1.75rem;
  position: relative;
  display: grid;
}

.wb-flow::before {
  content: "";
  position: absolute;
  top: calc(var(--dot) / 2);
  bottom: 0;
  left: calc(var(--dot) / 2 - 1px);
  width: 2px;
  background: var(--color-line);
}

.wb-flow__steps {
  display: grid;
  margin: 0;
  padding: 0;
  list-style: none;
}

.wb-flow__node {
  position: relative;
  display: grid;
  grid-template-columns: var(--dot) minmax(0, 1fr);
  gap: var(--space-3);
  align-items: start;
  padding-bottom: var(--space-4);
}

.wb-flow__dot {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  width: var(--dot);
  height: var(--dot);
  border: 2px solid var(--color-line);
  border-radius: 999px;
  background: var(--color-bg);
  color: var(--color-text-soft);
  font-size: var(--text-xs);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.wb-flow__node--io .wb-flow__dot {
  border-color: var(--color-text-faint);
}

.wb-flow__dot--end {
  border-color: var(--color-accent) !important;
  background: var(--color-accent);
}

.wb-flow__content {
  min-width: 0;
}

/* The line ends at the result's dot, not at the foot of its pane. */
.wb-flow__node--end::before {
  content: "";
  position: absolute;
  top: var(--dot);
  bottom: 0;
  left: 0;
  width: var(--dot);
  background: var(--color-bg);
}

.wb-flow__label {
  display: block;
  margin: 0.25rem 0 0.4rem;
  color: var(--color-text);
  font-size: var(--text-sm);
  font-weight: 600;
}

.wb-flow__input {
  width: 100%;
  padding: 0.7rem 0.85rem;
  border: 1px solid var(--color-line);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  color: var(--color-text);
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  line-height: 1.6;
  resize: vertical;
}

.wb-flow .wb-pane {
  min-height: 0;
}

/* A step: one line of what it is, one muted line of what it made. */
.wb-step__content {
  display: grid;
  gap: 0.2rem;
  padding-top: 0.2rem;
}

.wb-step__line {
  display: flex;
  flex-wrap: wrap;
  gap: 0.2rem var(--space-3);
  align-items: center;
  min-height: 1.5rem;
}

.wb-step__name {
  padding: 0;
  border: 0;
  background: none;
  color: var(--color-text);
  font-size: var(--text-base);
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  transition: color 600ms var(--ease-out-quint);
}

.wb-step__name:hover {
  color: var(--color-accent);
  transition-duration: 100ms;
}

.wb-step__tag {
  padding: 0.05rem 0.45rem;
  border-radius: 999px;
  background: var(--color-accent-wash);
  color: var(--color-accent);
  font-size: var(--text-xs);
  font-weight: 600;
}

.wb-step__args {
  color: var(--color-text-muted);
  font-size: var(--text-xs);
}

/* Reordering and removal wait until the step is pointed at or focused. */
.wb-step__tools {
  display: inline-flex;
  margin-left: auto;
  opacity: 0;
  transition: opacity 300ms var(--ease-out-quint);
}

.wb-step:hover .wb-step__tools,
.wb-step:focus-within .wb-step__tools {
  opacity: 1;
  transition-duration: 100ms;
}

@media (hover: none) {
  .wb-step__tools {
    opacity: 1;
  }
}

.wb-step__peek {
  display: flex;
  gap: var(--space-2);
  min-width: 0;
  margin: 0;
  color: var(--color-text-muted);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
}

.wb-step__peek-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.wb-step__peek-text::before {
  content: "→ ";
  color: var(--color-text-faint);
}

.wb-step__peek-more {
  flex: none;
  color: var(--color-text-faint);
}

.wb-step.is-editing .wb-flow__dot {
  border-color: var(--color-accent);
  background: var(--color-accent);
  color: var(--color-on-accent);
}

.wb-step.is-error .wb-flow__dot {
  border-color: var(--color-error);
  color: var(--color-error);
}

.wb-step.is-error .wb-step__peek {
  color: var(--color-error);
}

/* A new step slides in from the left, on the tab timing. */
@keyframes step-in {
  from { opacity: 0; transform: translateX(-10px); }
  to { opacity: 1; transform: none; }
}

.wb-step.is-new {
  animation: step-in 500ms var(--ease-out-quint) both;
}

/* Saved pipelines under an open operation, while none is being built. */
.wb-saved {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2) var(--space-3);
  align-items: center;
  padding-top: var(--space-5);
  border-top: 1px solid var(--color-line);
}

.wb-saved[hidden] {
  display: none;
}

.wb-saved__label {
  color: var(--color-text-faint);
  font-size: var(--text-xs);
  font-weight: 600;
}

.workbench-noscript {
  padding: var(--space-5);
  border: 1px solid var(--color-line);
  border-radius: var(--radius-md);
  color: var(--color-text-muted);
}

html.motion-none .wb-step.is-new {
  animation: none;
}

/* ------------------------------------------------------------ responsive */

@media (max-width: 74rem) {
  .workbench {
    grid-template-columns: 11rem minmax(0, 1fr);
  }

  /* The panel runs the full width below; a sticky rail would ride over it. */
  .workbench-rail {
    position: static;
  }

  .workbench-panel {
    grid-column: 1 / -1;
  }

  .workbench-rows {
    max-height: 26rem;
  }
}

/*
 * Below this the three panes become two stages. Showing a rail, a list and a
 * panel stacked would mean scrolling past two of them to reach the one being
 * used, so `data-stage` hides whichever is not current and the back button
 * appears.
 */
@media (max-width: 48rem) {
  .workbench {
    grid-template-columns: minmax(0, 1fr);
    gap: var(--space-4);
  }

  /* The rail becomes a scrolling chip row, kept above the list in both
     stages so the category is always changeable in one tap. */
  .workbench-rail {
    flex-direction: row;
    gap: var(--space-2);
    margin-inline: calc(var(--gutter) * -1);
    padding-inline: var(--gutter);
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scrollbar-width: none;
    scroll-snap-type: x proximity;
  }

  .workbench-rail::-webkit-scrollbar {
    display: none;
  }

  .workbench-rail__item {
    flex: 0 0 auto;
    border: 1px solid var(--color-line);
    border-radius: 999px;
    scroll-snap-align: start;
  }

  .workbench-rail__item[aria-pressed="true"] {
    border-color: transparent;
  }

  .workbench-rail__divider {
    flex: none;
    width: 1px;
    height: auto;
    margin: 0.35rem 0.15rem;
  }

  .workbench-rows {
    max-height: none;
    overflow: visible;
  }

  .workbench-back {
    display: inline-flex;
  }

  .workbench[data-stage="panel"] .workbench-list,
  .workbench[data-stage="list"] .workbench-panel {
    display: none;
  }

  /* Touch targets: a 44px row is the floor, and the input must not zoom the
     page on focus, which iOS does below 16px. */
  .workbench-row {
    padding-block: 0.75rem;
  }

  .workbench-search input,
  .wb-input,
  .wb-flow__input,
  .wb-arg input {
    font-size: 1rem;
  }

  .wb-output {
    max-height: 20rem;
  }

  .wb-input {
    max-height: 40vh;
  }

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

  .workbench-shell {
    padding-block: var(--space-4) var(--space-6);
  }
}
