.workflow-builder-page {
  background: #f7f8fc;
}

.workflow-builder-page .site-header {
  background: rgba(255, 248, 237, 0.96);
}

.workflow-builder-page .nav-menu a[aria-current="page"] {
  color: var(--primary-hover);
  background: rgba(46, 70, 157, 0.1);
}

.builder-main {
  overflow-x: clip;
}

.builder-intro {
  padding: 70px 0 62px;
  color: #ffffff;
  background:
    linear-gradient(115deg, rgba(46, 70, 157, 1) 0%, rgba(37, 58, 132, 1) 72%, rgba(31, 53, 125, 1) 100%);
}

.builder-intro-inner {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 52px;
}

.builder-intro-copy {
  max-width: 790px;
}

.builder-intro .eyebrow {
  margin-bottom: 14px;
  color: var(--accent-color);
  opacity: 1;
}

.builder-intro h1 {
  max-width: 760px;
  color: #ffffff;
  font-size: clamp(38px, 5vw, 58px);
  line-height: 1.08;
}

.builder-intro-copy > p:last-child {
  max-width: 700px;
  margin-top: 20px;
  color: rgba(255, 255, 255, 0.78);
  font-size: 17px;
}

.builder-overview {
  min-width: 220px;
  display: grid;
  gap: 18px;
  padding-left: 28px;
  border-left: 1px solid rgba(255, 255, 255, 0.24);
}

.builder-overview div {
  display: grid;
}

.builder-overview strong {
  color: var(--accent-color);
  font-size: 42px;
  line-height: 1;
}

.builder-overview span {
  color: rgba(255, 255, 255, 0.7);
  font-size: 13px;
}

.builder-overview a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: #ffffff;
  font-size: 14px;
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 4px;
}

.builder-workspace-section {
  padding: 46px 0 90px;
}

.builder-layout {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  align-items: start;
  gap: 30px;
}

.workflow-library {
  position: sticky;
  top: 108px;
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--border-color);
  border-radius: 14px;
  background: #ffffff;
}

.library-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 22px 20px 18px;
  border-bottom: 1px solid var(--border-color);
}

.library-kicker,
.editor-kicker,
.dialog-kicker {
  margin-bottom: 5px;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 700;
  line-height: 1.3;
  text-transform: uppercase;
}

.library-heading h2,
.editor-heading h2 {
  margin: 0;
  color: var(--text-dark);
  font-size: 21px;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.workflow-list {
  display: grid;
  max-height: calc(100vh - 250px);
  overflow-y: auto;
}

.workflow-list-empty {
  padding: 32px 22px 36px;
  text-align: left;
}

.workflow-list-empty strong {
  display: block;
  margin-bottom: 8px;
  color: var(--text-dark);
  font-size: 16px;
}

.workflow-list-empty p {
  color: var(--text-body);
  font-size: 13px;
  line-height: 1.6;
}

.workflow-list-item {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  border-bottom: 1px solid var(--border-color);
  background: #ffffff;
}

.workflow-list-item:last-child {
  border-bottom: 0;
}

.workflow-list-item.is-active {
  box-shadow: inset 4px 0 0 var(--primary-color);
  background: var(--accent-soft);
}

.workflow-edit-button {
  min-width: 0;
  display: grid;
  gap: 9px;
  padding: 18px 8px 18px 20px;
  border: 0;
  color: inherit;
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.workflow-edit-button:hover,
.workflow-edit-button:focus-visible {
  background: rgba(209, 249, 244, 0.28);
  outline: none;
}

.workflow-name {
  min-width: 0;
  overflow: hidden;
  color: var(--text-dark);
  font-size: 14px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.workflow-features {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.workflow-features span {
  padding: 3px 7px;
  border-radius: 5px;
  color: var(--primary-color);
  background: rgba(46, 70, 157, 0.08);
  font-size: 10px;
  font-weight: 650;
}

.workflow-modified {
  color: var(--text-muted);
  font-size: 11px;
}

.workflow-delete-button {
  align-self: stretch;
  padding: 0 13px;
  border: 0;
  color: #9b3535;
  background: transparent;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.workflow-delete-button:hover,
.workflow-delete-button:focus-visible {
  background: #fff0f0;
  outline: none;
}

.workflow-editor {
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--border-color);
  border-radius: 14px;
  background: #ffffff;
  box-shadow: 0 20px 55px rgba(20, 32, 68, 0.07);
}

#workflowForm {
  padding: 30px;
}

.editor-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--border-color);
}

.editor-version {
  flex: 0 0 auto;
  padding: 5px 9px;
  border: 1px solid var(--border-color);
  border-radius: 999px;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 650;
}

.builder-message {
  margin-top: 20px;
  padding: 12px 14px;
  border: 1px solid rgba(46, 70, 157, 0.15);
  border-radius: 8px;
  color: var(--primary-color);
  background: var(--accent-soft);
  font-size: 13px;
  line-height: 1.55;
}

.builder-message[data-type="success"] {
  border-color: rgba(28, 112, 68, 0.18);
  color: #185c37;
  background: #eaf7ef;
}

.builder-message[data-type="error"] {
  border-color: rgba(155, 53, 53, 0.2);
  color: #8b2929;
  background: #fff1f1;
}

.workflow-name-field {
  margin-top: 24px;
}

.builder-field {
  min-width: 0;
  display: grid;
  align-content: start;
  gap: 7px;
  color: var(--text-dark);
  font-size: 13px;
  font-weight: 600;
}

.builder-field > span:first-child,
.radio-fieldset legend {
  line-height: 1.35;
}

.builder-field input,
.builder-field select,
.compound-field,
.range-line {
  min-width: 0;
}

.builder-field input:not([type="range"]):not([type="checkbox"]):not([type="color"]),
.builder-field select,
.compound-field {
  width: 100%;
  min-height: 42px;
  border: 1px solid #cfd7e6;
  border-radius: 7px;
  color: var(--text-dark);
  background: #ffffff;
  font-size: 14px;
  font-weight: 450;
}

.builder-field input:not([type="range"]):not([type="checkbox"]):not([type="color"]),
.builder-field select {
  padding: 9px 11px;
}

.builder-field input:focus,
.builder-field select:focus,
.compound-field:focus-within {
  border-color: var(--primary-color);
  outline: 3px solid rgba(46, 70, 157, 0.12);
}

.builder-field small,
.builder-check small,
.module-title small,
.radio-card small {
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 450;
  line-height: 1.5;
}

.feature-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-top: 32px;
  padding-top: 26px;
  border-top: 1px solid var(--border-color);
}

.feature-heading h3 {
  color: var(--text-dark);
  font-size: 18px;
}

.feature-heading p {
  max-width: 580px;
  margin-top: 5px;
  color: var(--text-body);
  font-size: 13px;
  line-height: 1.55;
}

.feature-count {
  flex: 0 0 auto;
  padding: 5px 9px;
  border-radius: 999px;
  color: var(--primary-color);
  background: var(--accent-soft);
  font-size: 11px;
  font-weight: 700;
}

.feature-empty-hint {
  margin-top: 14px;
  color: #8b2929;
  font-size: 12px;
  font-weight: 600;
}

.builder-module {
  margin-top: 16px;
  overflow: hidden;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  background: #ffffff;
}

.builder-module.is-enabled {
  border-color: rgba(46, 70, 157, 0.25);
}

.module-heading {
  min-height: 74px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 16px 18px;
  background: #fafbfd;
}

.builder-module.is-enabled .module-heading {
  background: var(--accent-soft);
}

.module-toggle {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 13px;
  cursor: pointer;
}

.module-toggle > input {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  clip-path: inset(50%);
}

.toggle-track {
  position: relative;
  width: 42px;
  height: 24px;
  flex: 0 0 auto;
  border: 1px solid #b8c1d3;
  border-radius: 999px;
  background: #dfe4ee;
  transition: background 160ms ease, border-color 160ms ease;
}

.toggle-track span {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 1px 3px rgba(20, 32, 68, 0.24);
  transition: transform 160ms ease;
}

.module-toggle input:checked + .toggle-track {
  border-color: var(--primary-color);
  background: var(--primary-color);
}

.module-toggle input:checked + .toggle-track span {
  transform: translateX(18px);
}

.module-toggle input:focus-visible + .toggle-track {
  outline: 3px solid rgba(46, 70, 157, 0.18);
  outline-offset: 2px;
}

.module-title {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.module-title strong {
  color: var(--text-dark);
  font-size: 15px;
}

.module-index {
  color: #a4adc1;
  font-size: 11px;
  font-weight: 700;
}

.module-body {
  display: grid;
  gap: 18px;
  padding: 20px;
  border-top: 1px solid var(--border-color);
}

.builder-grid {
  min-width: 0;
  display: grid;
  gap: 16px;
}

.builder-grid--two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.builder-grid--three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.field-note {
  color: var(--text-muted);
  font-size: 11px;
  line-height: 1.55;
}

.builder-check {
  min-width: 0;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  align-self: end;
  min-height: 42px;
  padding: 9px 10px;
  border: 1px solid var(--border-color);
  border-radius: 7px;
  background: #ffffff;
  cursor: pointer;
}

.builder-check input {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
  margin-top: 2px;
  accent-color: var(--primary-color);
}

.builder-check span {
  display: grid;
  gap: 2px;
}

.builder-check strong {
  color: var(--text-dark);
  font-size: 12px;
}

.color-field {
  min-height: 42px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 5px 10px;
  border: 1px solid #cfd7e6;
  border-radius: 7px;
}

.color-field input {
  width: 28px;
  height: 28px;
  padding: 0;
  overflow: hidden;
  border: 0;
  border-radius: 5px;
  background: transparent;
  cursor: pointer;
}

.color-field output {
  color: var(--text-body);
  font-size: 12px;
  font-weight: 550;
}

.builder-range-field {
  align-content: start;
}

.range-line {
  min-height: 42px;
  display: grid;
  grid-template-columns: minmax(80px, 1fr) 92px;
  align-items: center;
  gap: 12px;
}

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

.range-number {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  border: 1px solid #cfd7e6;
  border-radius: 7px;
  overflow: hidden;
}

.range-number input {
  min-height: 40px;
  padding: 8px 8px 8px 10px;
  border: 0;
  color: var(--text-dark);
  background: #ffffff;
  font-size: 13px;
}

.range-number span {
  padding-right: 9px;
  color: var(--text-muted);
  font-size: 11px;
}

.target-conflict {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 16px;
  padding: 14px;
  border-left: 4px solid #bf7a1d;
  border-radius: 0 7px 7px 0;
  color: #624414;
  background: #fff7e6;
}

.target-conflict strong {
  font-size: 13px;
}

.target-conflict p {
  max-width: 600px;
  margin-top: 3px;
  font-size: 11px;
  line-height: 1.55;
}

.target-conflict-actions {
  flex: 0 0 auto;
  display: flex;
  gap: 7px;
}

.target-conflict-actions button {
  padding: 7px 9px;
  border: 1px solid rgba(98, 68, 20, 0.22);
  border-radius: 5px;
  color: #624414;
  background: #ffffff;
  font-size: 10px;
  font-weight: 700;
  cursor: pointer;
}

.target-conflict-actions button:hover,
.target-conflict-actions button:focus-visible {
  border-color: #bf7a1d;
  outline: none;
}

.compound-field {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 84px;
  overflow: hidden;
}

.compound-field input,
.compound-field select {
  min-width: 0;
  min-height: 40px;
  padding: 8px 10px;
  border: 0;
  color: var(--text-dark);
  background: #ffffff;
  font-size: 13px;
}

.compound-field select {
  border-left: 1px solid var(--border-color);
}

.compound-field--suffix {
  grid-template-columns: minmax(0, 1fr) auto;
}

.compound-field--suffix span {
  align-self: center;
  padding: 0 11px;
  color: var(--text-muted);
  font-size: 11px;
}

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

.radio-fieldset legend {
  grid-column: 1 / -1;
  margin-bottom: 7px;
  color: var(--text-dark);
  font-size: 13px;
  font-weight: 600;
}

.radio-card {
  min-width: 0;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--border-color);
  border-radius: 7px;
  cursor: pointer;
}

.radio-card:has(input:checked) {
  border-color: rgba(46, 70, 157, 0.42);
  background: var(--accent-soft);
}

.radio-card input {
  margin-top: 2px;
  accent-color: var(--primary-color);
}

.radio-card span {
  display: grid;
  gap: 2px;
}

.radio-card strong {
  color: var(--text-dark);
  font-size: 12px;
}

.logo-workbench {
  display: grid;
  grid-template-columns: 180px minmax(0, 1fr);
  gap: 18px;
  align-items: stretch;
}

.logo-drop-zone {
  min-height: 128px;
  display: grid;
  place-items: center;
  overflow: hidden;
  padding: 12px;
  border: 1px dashed rgba(46, 70, 157, 0.35);
  border-radius: 8px;
  background: #fafbfd;
  cursor: pointer;
}

.logo-drop-zone:hover,
.logo-drop-zone:focus-visible,
.logo-drop-zone.is-dragging {
  border-color: var(--primary-color);
  background: var(--accent-soft);
  outline: none;
}

.logo-placeholder {
  display: grid;
  justify-items: center;
  gap: 4px;
  text-align: center;
}

.logo-placeholder strong {
  color: var(--text-dark);
  font-size: 13px;
}

.logo-placeholder span {
  color: var(--text-muted);
  font-size: 10px;
}

.logo-preview {
  width: 100%;
  height: 104px;
  display: grid;
  place-items: center;
  overflow: hidden;
}

.logo-preview img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.logo-meta {
  min-width: 0;
  display: grid;
  align-content: center;
  gap: 10px;
}

.logo-file-name {
  overflow: hidden;
  color: var(--text-dark);
  font-size: 13px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

.logo-meta small {
  color: var(--text-muted);
  font-size: 11px;
  line-height: 1.5;
}

.builder-button {
  min-height: 38px;
  padding: 8px 13px;
  border: 1px solid transparent;
  border-radius: 7px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.builder-button:focus-visible,
.text-button:focus-visible,
.workflow-edit-button:focus-visible,
.workflow-delete-button:focus-visible {
  outline: 3px solid rgba(46, 70, 157, 0.18);
  outline-offset: 2px;
}

.builder-button--quiet {
  border-color: var(--border-color);
  color: var(--primary-color);
  background: #ffffff;
}

.builder-button--quiet:hover {
  border-color: rgba(46, 70, 157, 0.4);
  background: var(--accent-soft);
}

.builder-button--primary {
  min-height: 44px;
  padding-inline: 20px;
  color: #ffffff;
  background: var(--primary-color);
}

.builder-button--primary:hover {
  background: var(--primary-hover);
}

.builder-button--primary:disabled {
  color: #ffffff;
  background: #98a1b7;
  cursor: not-allowed;
}

.builder-button--danger {
  color: #ffffff;
  background: #9b3535;
}

.builder-button--danger:hover {
  background: #7f2929;
}

.text-button {
  padding: 4px;
  border: 0;
  color: #8b2929;
  background: transparent;
  font-size: 11px;
  font-weight: 650;
  cursor: pointer;
}

.editor-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-top: 26px;
  padding-top: 22px;
  border-top: 1px solid var(--border-color);
}

.editor-actions p {
  color: var(--text-muted);
  font-size: 11px;
  line-height: 1.5;
}

.delete-dialog {
  width: min(440px, calc(100vw - 32px));
  padding: 0;
  border: 1px solid var(--border-color);
  border-radius: 12px;
  color: var(--text-dark);
  background: #ffffff;
  box-shadow: 0 30px 80px rgba(20, 32, 68, 0.28);
}

.delete-dialog::backdrop {
  background: rgba(20, 32, 68, 0.42);
}

.delete-dialog form {
  padding: 26px;
}

.delete-dialog h2 {
  color: var(--text-dark);
  font-size: 24px;
}

.delete-dialog p:not(.dialog-kicker) {
  margin-top: 10px;
  color: var(--text-body);
  font-size: 13px;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 24px;
}

.workflow-builder-page [hidden] {
  display: none;
}

@media (max-width: 980px) {
  .builder-intro-inner {
    grid-template-columns: 1fr;
  }

  .builder-overview {
    min-width: 0;
    grid-template-columns: auto auto;
    align-items: center;
    justify-content: space-between;
    padding: 20px 0 0;
    border-top: 1px solid rgba(255, 255, 255, 0.24);
    border-left: 0;
  }

  .builder-layout {
    grid-template-columns: 1fr;
  }

  .workflow-library {
    position: static;
  }

  .workflow-list {
    max-height: none;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .workflow-list-item {
    border-right: 1px solid var(--border-color);
  }

  .target-conflict {
    flex-direction: column;
  }
}

@media (max-width: 760px) {
  .builder-intro {
    padding: 50px 0 44px;
  }

  .builder-intro h1 {
    font-size: 38px;
  }

  .builder-workspace-section {
    padding: 28px 0 58px;
  }

  #workflowForm {
    padding: 22px;
  }

  .builder-grid--three {
    grid-template-columns: 1fr;
  }

  .workflow-list {
    grid-template-columns: 1fr;
  }

  .workflow-list-item {
    border-right: 0;
  }
}

@media (max-width: 560px) {
  .builder-intro-inner {
    gap: 30px;
  }

  .builder-overview {
    grid-template-columns: 1fr;
  }

  .builder-overview a {
    justify-self: start;
  }

  .builder-layout {
    gap: 20px;
  }

  #workflowForm {
    padding: 18px;
  }

  .editor-heading {
    flex-direction: column;
  }

  .feature-heading {
    flex-direction: column;
  }

  .builder-grid--two,
  .radio-fieldset,
  .logo-workbench {
    grid-template-columns: 1fr;
  }

  .logo-drop-zone {
    min-height: 150px;
  }

  .target-conflict-actions {
    width: 100%;
    flex-direction: column;
  }

  .editor-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .editor-actions .builder-button {
    width: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  .toggle-track,
  .toggle-track span {
    transition: none;
  }
}
