.workflow-history-result {
  grid-template-rows: minmax(320px, 1fr) auto;
}

.workflow-generation-support {
  display: grid;
  gap: 10px;
  margin-top: 12px;
  padding: 12px;
  border: 1px solid var(--line, rgba(123, 146, 174, .24));
  border-radius: 12px;
  background: var(--surface-2, var(--color-surface-raised, #f4f6f9));
}

.workflow-generation-support[hidden] {
  display: none;
}

.workflow-generation-notice {
  padding: 9px 11px;
  border: 1px solid color-mix(in srgb, var(--accent, #13866f) 34%, transparent);
  border-radius: 8px;
  color: var(--text, var(--color-text-primary, #172133));
  background: color-mix(in srgb, var(--accent, #13866f) 7%, transparent);
  font-size: 10px;
  font-weight: 700;
}

.workflow-generation-notice.is-error {
  border-color: color-mix(in srgb, var(--color-error, #c62828) 52%, transparent);
  color: var(--color-error, #c62828);
  background: color-mix(in srgb, var(--color-error, #c62828) 8%, transparent);
}

.workflow-generation-notice[hidden] {
  display: none;
}

.d6-result-box.is-failed .d6-result-empty-state,
.d6-result-box.is-failed .d6-result-empty-state :is(strong, span) {
  color: var(--color-error, #c62828);
}

.d6-result-actions button,
.d6-result-actions a,
.workflow-generation-gallery__footer a {
  min-height: 32px;
  padding: 7px 12px;
  border: 1px solid color-mix(in srgb, var(--accent, #13866f) 36%, transparent);
  border-radius: 8px;
  color: var(--accent, #13866f);
  background: color-mix(in srgb, var(--accent, #13866f) 7%, transparent);
  font: inherit;
  font-size: 10px;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
}

.d6-result-actions button:hover,
.d6-result-actions a:hover,
.workflow-generation-gallery__footer a:hover {
  background: color-mix(in srgb, var(--accent, #13866f) 14%, transparent);
  border-color: color-mix(in srgb, var(--accent, #13866f) 62%, transparent);
}

.workflow-generation-history {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.workflow-generation-history__heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--text, var(--color-text-primary, #172133));
  font-size: 10px;
}

.workflow-generation-history__heading span {
  min-width: 22px;
  padding: 2px 7px;
  border: 1px solid var(--line, rgba(123, 146, 174, .24));
  border-radius: 999px;
  text-align: center;
}

.workflow-generation-history__row {
  display: flex;
  gap: 8px;
  min-width: 0;
  padding: 2px;
  overflow-x: auto;
  scrollbar-width: thin;
}

.workflow-generation-history__item {
  position: relative;
  flex: 0 0 76px;
  height: 58px;
  padding: 3px;
  overflow: hidden;
  border: 1px solid var(--line, rgba(123, 146, 174, .32));
  border-radius: 8px;
  background: var(--color-surface-raised, #f4f6f9);
  cursor: pointer;
}

.workflow-generation-history__item:hover {
  border-color: color-mix(in srgb, var(--accent, #13866f) 56%, transparent);
  background: color-mix(in srgb, var(--accent, #13866f) 7%, var(--color-surface-raised, #f4f6f9));
}

.workflow-generation-history__item.is-selected {
  border-color: var(--accent, #13866f);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent, #13866f) 20%, transparent);
}

.workflow-generation-history__item img {
  width: 100%;
  height: 100%;
  border-radius: 5px;
  object-fit: cover;
}

.workflow-generation-history__item span {
  position: absolute;
  right: 5px;
  bottom: 5px;
  display: grid;
  width: 18px;
  height: 18px;
  place-items: center;
  border-radius: 999px;
  color: #fff;
  background: rgba(8, 17, 27, .78);
  font-size: 10px;
  font-weight: 800;
}

.workflow-generation-gallery {
  width: min(1040px, calc(100vw - 32px));
  max-width: none;
  max-height: calc(100vh - 32px);
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--line-strong, rgba(123, 146, 174, .44));
  border-radius: 18px;
  color: var(--text, var(--color-text-primary, #172133));
  background: var(--surface, var(--color-surface, #fff));
  box-shadow: 0 24px 72px rgba(7, 15, 26, .34);
}

.workflow-generation-gallery::backdrop {
  background: rgba(7, 12, 20, .72);
  backdrop-filter: blur(4px);
}

.workflow-generation-gallery__shell {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  max-height: calc(100vh - 32px);
}

.workflow-generation-gallery__header,
.workflow-generation-gallery__footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line, rgba(123, 146, 174, .24));
}

html[data-theme="dark"] .workflow-generation-gallery {
  color: #f5f7fc;
  background: #111722;
  border-color: #344055;
}

html[data-theme="dark"] .workflow-generation-gallery__header,
html[data-theme="dark"] .workflow-generation-gallery__footer {
  background: #111722;
  border-color: #2a3548;
}

html[data-theme="dark"] .workflow-generation-gallery__header small,
html[data-theme="dark"] .workflow-generation-gallery__stage figcaption {
  color: #9aa8bc;
}

html[data-theme="dark"] .workflow-generation-gallery__stage {
  background: #0b1018;
}

html[data-theme="dark"] .workflow-generation-gallery__close,
html[data-theme="dark"] .workflow-generation-gallery__arrow {
  color: #f5f7fc;
  background: #18202d;
  border-color: #46536a;
}

html[data-theme="dark"] .workflow-generation-gallery__close:hover,
html[data-theme="dark"] .workflow-generation-gallery__arrow:hover:not(:disabled) {
  background: #222c3b;
}

html[data-theme="dark"] .workflow-generation-gallery__footer a {
  color: #74e6c2;
  background: rgba(19, 134, 111, .16);
  border-color: rgba(91, 214, 176, .42);
}

.workflow-generation-gallery__header small {
  display: block;
  margin-bottom: 3px;
  color: var(--muted, var(--color-text-muted, #617086));
  font-size: 10px;
  font-weight: 700;
}

.workflow-generation-gallery__header h2 {
  margin: 0;
  font-size: 18px;
}

.workflow-generation-gallery__close,
.workflow-generation-gallery__arrow {
  display: grid;
  width: 40px;
  height: 40px;
  padding: 0;
  place-items: center;
  border: 1px solid var(--line-strong, rgba(123, 146, 174, .44));
  border-radius: 10px;
  color: var(--text, var(--color-text-primary, #172133));
  background: var(--color-surface-raised, #f4f6f9);
  font-size: 20px;
  cursor: pointer;
}

.workflow-generation-gallery__close:hover,
.workflow-generation-gallery__arrow:hover:not(:disabled) {
  border-color: var(--accent, #13866f);
  background: color-mix(in srgb, var(--accent, #13866f) 9%, var(--color-surface-raised, #f4f6f9));
}

.workflow-generation-gallery__arrow:disabled {
  opacity: .35;
  cursor: default;
}

.workflow-generation-gallery__stage {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  min-height: 320px;
  padding: 16px;
  overflow: hidden;
  background: var(--color-canvas-subtle, #eef2f6);
}

.workflow-generation-gallery__stage figure {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  gap: 8px;
  min-width: 0;
  min-height: 0;
  height: 100%;
  margin: 0;
}

.workflow-generation-gallery__stage img {
  width: 100%;
  height: 100%;
  min-height: 0;
  max-height: calc(100vh - 190px);
  object-fit: contain;
}

.workflow-generation-gallery__stage figcaption {
  color: var(--muted, var(--color-text-muted, #617086));
  font-size: 10px;
  text-align: center;
}

.workflow-generation-gallery__footer {
  justify-content: flex-end;
  border-top: 1px solid var(--line, rgba(123, 146, 174, .24));
  border-bottom: 0;
}

@media (max-width: 560px) {
  .workflow-history-result {
    grid-template-rows: minmax(240px, 1fr) auto;
  }

  .workflow-generation-gallery__stage {
    grid-template-columns: 36px minmax(0, 1fr) 36px;
    gap: 6px;
    padding: 10px;
  }

  .workflow-generation-gallery__arrow {
    width: 36px;
    height: 36px;
  }

  .workflow-generation-history__item {
    flex-basis: 68px;
    height: 52px;
  }
}
