.marketplace-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 0 0 30px;
}

.marketplace-legend span {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 7px 13px;
  border: 1px solid #4b315d;
  border-radius: 999px;
  background: linear-gradient(180deg, #1b1024, #130b1a);
  color: #d8cbe1;
  font-size: 12px;
  line-height: 1.35;
}

.marketplace-controls {
  display: grid;
  grid-template-columns: minmax(210px, 1fr) minmax(230px, 1.25fr) auto;
  grid-template-areas:
    "search-label category-label action"
    "search category action";
  gap: 8px 14px;
  align-items: end;
  margin: 0 0 26px;
  padding: 20px;
  border: 1px solid #352141;
  border-radius: 14px;
  background: linear-gradient(135deg, #100a16, #0c0810);
}

.marketplace-controls label {
  color: #b8a9c4;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .04em;
}

.marketplace-controls label[for="marketplace-search"] {
  grid-area: search-label;
}

.marketplace-controls label[for="marketplace-category"] {
  grid-area: category-label;
}

#marketplace-search {
  grid-area: search;
}

#marketplace-category {
  grid-area: category;
}

#marketplace-refresh {
  grid-area: action;
}

.marketplace-controls input,
.marketplace-controls select {
  width: 100%;
  min-height: 46px;
  box-sizing: border-box;
  border: 1px solid #49305a;
  border-radius: 10px;
  padding: 11px 13px;
  background: #09060c;
  color: #f8f3ff;
  font: inherit;
  transition:
    border-color .16s ease,
    box-shadow .16s ease,
    background .16s ease;
}

.marketplace-controls input::placeholder {
  color: #776984;
}

.marketplace-controls input:hover,
.marketplace-controls select:hover {
  border-color: #6a477e;
  background: #0d0811;
}

.marketplace-controls input:focus,
.marketplace-controls select:focus {
  outline: none;
  border-color: #a56cff;
  box-shadow: 0 0 0 3px rgba(143, 92, 255, .18);
}

#marketplace-refresh.button.secondary {
  min-height: 46px;
  padding: 0 20px;
  border: 1px solid #6b4380;
  border-radius: 10px;
  background: linear-gradient(180deg, #251330, #1a0e22);
  color: #f8f3ff;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  box-shadow: inset 0 1px rgba(255,255,255,.04);
  transition:
    transform .15s ease,
    border-color .15s ease,
    background .15s ease,
    box-shadow .15s ease;
}

#marketplace-refresh.button.secondary:hover {
  border-color: #b15cff;
  background: linear-gradient(180deg, #32173f, #21102b);
  box-shadow: 0 8px 24px rgba(0,0,0,.22);
}

#marketplace-refresh.button.secondary:active {
  transform: translateY(1px);
}

#marketplace-refresh.button.secondary:focus-visible {
  outline: 2px solid #d8b6ff;
  outline-offset: 3px;
}

#marketplace-status {
  min-height: 22px;
  margin: 0 0 18px;
  color: #a99ab5;
  font-size: 13px;
}

.marketplace-section {
  margin: 0 0 34px;
}

.marketplace-section h2 {
  margin: 0 0 14px;
  font-size: 24px;
  letter-spacing: -.025em;
}

.marketplace-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.marketplace-card {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 190px;
  padding: 22px;
  overflow: hidden;
  border: 1px solid #3d2850;
  border-radius: 16px;
  background:
    radial-gradient(circle at 100% 0%, rgba(139, 68, 183, .10), transparent 38%),
    linear-gradient(145deg, #130b1a, #0d0812);
  box-shadow: inset 0 1px rgba(255,255,255,.025);
  transition:
    transform .16s ease,
    border-color .16s ease,
    box-shadow .16s ease;
}

.marketplace-card:hover {
  transform: translateY(-2px);
  border-color: #69427e;
  box-shadow: 0 12px 30px rgba(0,0,0,.20);
}

.marketplace-card h3 {
  margin: 15px 0 8px;
  color: #fff;
  font-size: 18px;
  line-height: 1.3;
}

.marketplace-card p {
  margin: 0 0 18px;
  color: #b8a9c4;
  font-size: 14px;
  line-height: 1.55;
}

.marketplace-badge {
  align-self: flex-start;
  max-width: 100%;
  padding: 6px 10px;
  border: 1px solid #5a3a70;
  border-radius: 999px;
  background: #1c1026;
  color: #d8b6ff;
  font-size: 11px;
  font-weight: 700;
  line-height: 1.25;
}

.marketplace-card .button.secondary {
  align-self: flex-start;
  margin-top: auto;
  padding: 9px 12px;
  border: 1px solid #503362;
  border-radius: 9px;
  background: #160d1d;
  color: #f4eaff;
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
  transition:
    border-color .15s ease,
    background .15s ease,
    transform .15s ease;
}

.marketplace-card .button.secondary:hover {
  border-color: #b15cff;
  background: #21102b;
}

.marketplace-card .button.secondary:active {
  transform: translateY(1px);
}

.marketplace-card .button.secondary:focus-visible {
  outline: 2px solid #d8b6ff;
  outline-offset: 3px;
}

.marketplace-empty {
  grid-column: 1 / -1;
  padding: 24px;
  border: 1px dashed #49305a;
  border-radius: 12px;
  background: #0c0810;
  color: #9586a1;
  text-align: center;
}

@media (max-width: 980px) {
  .marketplace-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .marketplace-controls {
    grid-template-columns: 1fr;
    grid-template-areas:
      "search-label"
      "search"
      "category-label"
      "category"
      "action";
  }

  #marketplace-refresh.button.secondary {
    width: 100%;
  }

  .marketplace-grid {
    grid-template-columns: 1fr;
  }
}

/* Marketplace form-control theme */
.workspace-body input[type="checkbox"],
.workspace-body input[type="radio"] {
  appearance: none;
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  margin: 0;
  flex: 0 0 18px;
  border: 1px solid #5b3a6e;
  background: #09060c;
  display: inline-grid;
  place-content: center;
  vertical-align: middle;
  cursor: pointer;
  transition:
    border-color .15s ease,
    background .15s ease,
    box-shadow .15s ease;
}

.workspace-body input[type="checkbox"] {
  border-radius: 5px;
}

.workspace-body input[type="radio"] {
  border-radius: 999px;
}

.workspace-body input[type="checkbox"]:hover,
.workspace-body input[type="radio"]:hover {
  border-color: #a260c0;
  background: #100a16;
}

.workspace-body input[type="checkbox"]:focus-visible,
.workspace-body input[type="radio"]:focus-visible {
  outline: 2px solid #d8b6ff;
  outline-offset: 3px;
}

.workspace-body input[type="checkbox"]:checked {
  border-color: #b35cff;
  background:
    linear-gradient(135deg, #a74dff, #ee4dff);
}

.workspace-body input[type="checkbox"]:checked::after {
  content: "";
  width: 8px;
  height: 4px;
  border-left: 2px solid #fff;
  border-bottom: 2px solid #fff;
  transform: rotate(-45deg) translateY(-1px);
}

.workspace-body input[type="radio"]:checked {
  border-color: #b35cff;
  background: #100a16;
}

.workspace-body input[type="radio"]:checked::after {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: linear-gradient(135deg, #a74dff, #ee4dff);
}

.workspace-body input[type="checkbox"]:disabled,
.workspace-body input[type="radio"]:disabled,
.marketplace-controls input:disabled,
.marketplace-controls select:disabled {
  opacity: .5;
  cursor: not-allowed;
}

.marketplace-controls select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 42px;
  background-image:
    linear-gradient(45deg, transparent 50%, #b8a9c4 50%),
    linear-gradient(135deg, #b8a9c4 50%, transparent 50%);
  background-position:
    calc(100% - 18px) 19px,
    calc(100% - 13px) 19px;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}

.marketplace-controls select:focus {
  background-image:
    linear-gradient(45deg, transparent 50%, #d8b6ff 50%),
    linear-gradient(135deg, #d8b6ff 50%, transparent 50%);
}

.marketplace-controls input[type="search"]::-webkit-search-cancel-button {
  filter: invert(1);
  opacity: .65;
}
