/* Hallmark · genre: modern-minimal · macrostructure: Workbench
 * design-system: design.md · designed-as-app
 */

.tool-runner {
  position: relative;
}

.tool-runner.is-busy .tool-dropzone {
  pointer-events: none;
  opacity: 0.55;
}

/* Dropzone — the workbench frame */

.tool-dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-xs);
  min-height: 16rem;
  padding: var(--space-xl) var(--space-md);
  border: 1.5px dashed var(--color-rule-2);
  border-radius: var(--radius-md);
  background: var(--color-paper-2);
  text-align: center;
  cursor: pointer;
  transition: border-color var(--dur-short) var(--ease-out), background-color var(--dur-short) var(--ease-out);
}

.tool-dropzone:hover,
.tool-dropzone:focus-visible {
  border-color: var(--color-accent);
}

.tool-dropzone.is-dragging {
  border-color: var(--color-accent);
  border-style: solid;
  background: color-mix(in oklch, var(--color-accent) 6%, var(--color-paper-2));
}

.tool-dropzone__icon {
  display: inline-grid;
  place-items: center;
  width: 2.5rem;
  height: 2.5rem;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.5rem;
  line-height: 1;
  color: var(--color-accent);
  border: 1px solid var(--color-rule-2);
  border-radius: var(--radius-sm);
  margin-bottom: var(--space-xs);
}

.tool-dropzone__prompt {
  font-weight: 500;
  color: var(--color-ink);
}

.tool-dropzone__hint {
  font-size: var(--text-sm);
  color: var(--color-muted);
}

.tool-disclaimer__tick {
  color: var(--color-accent);
  flex-shrink: 0;
}

.tool-error {
  margin-top: var(--space-md);
  padding: var(--space-sm) var(--space-md);
  border: 1px solid var(--color-error);
  border-radius: var(--radius-sm);
  background: color-mix(in oklch, var(--color-error) 8%, var(--color-paper));
  color: var(--color-error);
  font-size: var(--text-sm);
}

.tool-output {
  margin-top: var(--space-lg);
}

.tool-output__media img {
  display: block;
  max-width: 100%;
  height: auto;
  border: 1px solid var(--color-rule);
  border-radius: var(--radius-md);
}

.tool-output__report {
  margin: var(--space-sm) 0 0;
  padding: var(--space-md);
  background: var(--color-graphite);
  color: var(--color-on-graphite-2);
  border-radius: var(--radius-md);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

.tool-output__name {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--color-muted);
  margin: var(--space-sm) 0;
}

.tool-output__actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-xs);
}

/* Controls — bordered instrument sliders */

.tool-controls {
  margin-top: var(--space-lg);
  padding: var(--space-lg);
  border: 1px solid var(--color-rule);
  border-radius: var(--radius-md);
  background: var(--color-paper-2);
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 15rem), 1fr));
  gap: var(--space-md);
}

.control {
  display: flex;
  flex-direction: column;
  gap: var(--space-2xs);
  min-width: 0;
}

.control-group {
  display: contents;
}

.control__label {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--color-muted);
}

.control input[type="range"] {
  width: 100%;
  accent-color: var(--color-accent);
}

.control input[type="text"],
.control select,
.control input[type="color"] {
  width: 100%;
  padding: 0.45rem 0.6rem;
  font-family: var(--font-body);
  font-size: var(--text-sm);
  color: var(--color-ink);
  background: var(--color-paper);
  border: 1px solid var(--color-rule-2);
  border-radius: var(--radius-sm);
}

.control input[type="text"]:focus-visible,
.control select:focus-visible {
  outline: 2px solid var(--color-focus);
  outline-offset: 2px;
}

.control input[type="color"] {
  padding: 0.2rem;
  height: 2.2rem;
}

/* Busy states */

.editor-workspace.is-busy .editor-canvas-wrap,
.tool-runner.is-busy .tool-dropzone {
  opacity: 0.7;
}

/* Error boundary toast — stacked, fixed, silent */

.error-boundary {
  position: fixed;
  bottom: var(--space-md);
  right: var(--space-md);
  z-index: var(--z-toast);
  max-width: min(22rem, calc(100vw - 2rem));
  padding: var(--space-sm) var(--space-md);
  background: var(--color-error);
  color: var(--color-on-error);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
  font-size: var(--text-sm);
  line-height: 1.5;
}

/* Mask surface (object removal) */

.mask-surface {
  position: relative;
  margin-top: var(--space-md);
}

.mask-surface__frame {
  position: relative;
  display: inline-block;
  max-width: 100%;
}

.mask-surface__image {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-rule);
  display: block;
}

.mask-surface__overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border-radius: var(--radius-md);
  cursor: crosshair;
  touch-action: none;
}

.mask-surface__hint {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--color-muted);
  margin: var(--space-xs) 0 var(--space-2xs);
}

.mask-surface__actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-xs);
  margin-top: var(--space-xs);
}

/* JS-generated buttons (mask-painter controller) — mapped to the .btn language */
.mask-surface__actions .button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2xs);
  padding: 0.55rem 1.1rem;
  font-family: var(--font-body);
  font-weight: 500;
  font-size: var(--text-sm);
  line-height: 1.3;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--color-ink);
  border: 1px solid var(--color-rule-2);
  cursor: pointer;
  white-space: nowrap;
  transition: transform 100ms var(--ease-out), background-color var(--dur-short) var(--ease-out),
              border-color var(--dur-short) var(--ease-out), color var(--dur-short) var(--ease-out);
}

.mask-surface__actions .button:hover {
  border-color: var(--color-accent);
}

.mask-surface__actions .button:active {
  transform: translateY(1px);
}

.mask-surface__actions .button--primary {
  background: var(--color-accent);
  color: var(--color-accent-ink);
  border: 1px solid var(--color-accent);
}

.mask-surface__actions .button--primary:hover {
  filter: brightness(1.06);
  border-color: var(--color-accent);
}