body {
  display: flex;
}

form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

label>span {
  display: block;
  background: #000;
  color: #fff;
  padding: 10px;
}

:checked+span {
  background: #777;
}

input {
  display: none;
}

ul {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
}

li {
  list-style: none;
  width: 40px;
  height: 40px;
  display: flex;
  justify-content: center;
  align-items: center;
  color: #fff;
}

.red {
  background-color: red;
}

.green {
  background-color: green;
}

.blue {
  background-color: blue;
}

aside:has([value=""]:not(:checked)):has([value="red"]:not(:checked))+main .red,
aside:has([value=""]:not(:checked)):has([value="green"]:not(:checked))+main .green,
aside:has([value=""]:not(:checked)):has([value="blue"]:not(:checked))+main .blue {
  display: none;
}
