* {
  box-sizing: border-box;
  outline-offset: 4px;
}

html,
body {
  width: 100%;
  height: 100%;
}

body {
  --color-background: hsl(225 8% 90% / 1);
  --color-code-background: hsl(225 8% 90% / 80%);
  --color-code-selector: hsl(119 34% 47% / 1);
  --color-code-properties: hsl(5 74% 59% / 1);
  --color-code-value: hsl(220 7% 17% / 1);
  --color-code: hsl(228 8% 24% / 1);
  --color-select-code: hsl(225 8% 10% / 1);

  margin: 0;
  padding: 0;
  background: var(--color-background);
  font-family: "Roboto Mono", monospace;
  font-style: normal;
  font-weight: normal;
  font-size: 18px;
  line-height: 1.3;
  color: var(--color-code);
}

body._dark {
  --color-background: hsl(225 8% 10% / 1);
  --color-code-background: hsl(225 8% 10% / 90%);
  --color-code-selector: hsl(95 38% 62% / 1);
  --color-code-properties: hsl(355 65% 65% / 1);
  --color-code-value: hsl(0 0% 100% / 1);
  --color-code: hsl(219 14% 71%);
  --color-select-code: hsl(225 8% 10% / 1);
}

.main-wrap {
  display: grid;
  grid-template-columns: 1fr;
  grid-auto-flow: row;
  grid-row-gap: 24px;
  margin: auto;
  width: 100%;
  max-width: 1000px;
  min-width: 660px;
  padding: 50px;
}

.code {
  position: relative;
  display: block;
  tab-size: 4;
  font-family: "Roboto Mono", monospace;
  font-style: normal;
  font-weight: normal;
  font-size: 20px;
  line-height: 1.4;
  color: var(--color-code);
  background-color: var(--color-code-background);
  z-index: 2;
}

.code * {
  font: inherit;
}

.code pre {
  display: block;
  margin: 0;
  padding: 0;
}

.code__selector {
  color: var(--color-code-selector);
}

.code__properties {
  color: var(--color-code-properties);
}

.code__value {
  color: var(--color-code-value);
}

.code__select {
  appearance: none;
  display: block;
  tab-size: 4;
  font-family: "Roboto Mono", monospace;
  font-style: normal;
  font-weight: normal;
  font-size: 20px;
  line-height: 1.3;
  color: var(--color-select-code);
  margin: 0 0 0 -4px;
  padding: 0 0 0 4px;
  border-radius: 6px;
  display: inline;
  border: none;
  cursor: pointer;

  background-color: var(--color-code-properties);
  background-image: url("data:image/svg+xml,%3Csvg width='14' height='14' viewBox='0 0 14 14' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 4L7 10L13 4' stroke-width='1.8' stroke='%23282a2e'/%3E%3C/svg%3E%0A");
  background-size: 16px;
  background-repeat: no-repeat;
  background-position: calc(100% - 4px) center;
}

._active .code__select:hover,
.code__select:hover {
  background-color: hsl(0 0% 50% / 20%);
  color: var(--color-code-value);
}

._active .code__select:active,
.code__select:active {
  background-color: hsl(0 0% 50% / 40%);
}

._dark .code__select:hover {
  background-image: url("data:image/svg+xml,%3Csvg width='14' height='14' viewBox='0 0 14 14' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 4L7 10L13 4' stroke-width='2' stroke='%23ffffff'/%3E%3C/svg%3E%0A");
}

.code__select option {
  color: var(--color-code-value);
  background: var(--color-background);
}

._active .code__properties {
  color: hsl(209deg 100% 59%);
}

._active .code__select {
  background-color: hsl(209deg 100% 59%);
}

.demo {
  position: relative;
  width: 100%;
  height: 360px;
  display: flex;
  background: hsl(0 0% 50% / 10%);
  border: 4px solid hsl(0 0% 50% / 40%);
  z-index: 1;
}

.item {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 100px;
  height: auto;
  padding: 12px 16px;
  font-size: 18px;
  text-align: center;
  color: hsl(0 0% 0%);
  background: hsl(209 100% 59%);
  border: 1px solid var(--color-background);
}

.demo._baseline .item._size:nth-child(5n + 1) {
  padding-top: 2px;
  padding-bottom: 34px;
}

.demo._baseline .item._size:nth-child(5n + 2) {
  padding-top: 34px;
  padding-bottom: 2px;
}

.demo._baseline .item._size:nth-child(5n + 3) {
  padding-top: 20px;
  padding-bottom: 4px;
}

.demo._baseline .item._size:nth-child(5n + 4) {
  padding-top: 8px;
  padding-bottom: 30px;
}

.demo._baseline .item._size:nth-child(5n) {
  padding-top: 32px;
}

.item.item_2,
.item.item_7,
.item.item_12,
.item.item_17 {
  background: hsl(276 100% 72%);
}

.item.item_3,
.item.item_8,
.item.item_13,
.item.item_18 {
  background: hsl(346 81% 78%);
}

.item.item_4,
.item.item_9,
.item.item_14,
.item.item_19 {
  background: hsl(162 90% 51%);
}

.item.item_5,
.item.item_10,
.item.item_15,
.item.item_20 {
  background: hsl(49 100% 58%);
}

.item_start {
  min-width: auto;
  background: hsl(25 100% 59%);
}

.item_end {
  min-width: auto;
  background: hsl(122 78% 58%);
}

.item__name {
  position: relative;
  font-family: "Roboto", sans-serif;
}

.item__order {
  position: relative;
  font-size: 14px;
  margin-top: 8px;
}

.demo._baseline .item__name::before {
  content: "";
  display: block;
  height: 1px;
  width: calc(100% + 300px);
  position: absolute;
  top: 1em;
  left: 50%;
  transform: translateX(-50%);
  background: hsl(0 100% 50%);
  pointer-events: none;
  z-index: 1;
}

.demo._baseline .item:first-child .item__name::before {
  width: calc(100% + 100px);
}

.demo._baseline .item:last-child .item__name::before {
  width: calc(100% + 100px);
}

.item__controls {
  visibility: hidden;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 100%;
  max-width: 180px;
  min-height: 100%;
  padding: 6px 0;
  background: inherit;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  align-content: center;
  justify-items: center;
  align-items: center;
}

.item:hover .item__controls {
  visibility: visible;
  z-index: 1;
}

.item__btn {
  width: 30px;
  height: 30px;
  padding: 0;
  margin: 0;
  background-color: hsl(0 0% 100% / 40%);
  border: none;
  border-radius: 30px;
  cursor: pointer;
  background-position: center;
  background-size: 20px;
  background-repeat: no-repeat;
}

.item__btn:hover {
  background-color: hsl(0 0% 100% / 80%);
}

.item__btn_add {
  background-image: url(./img/icon_plus.svg);
}

.item__btn_remove {
  background-image: url(./img/icon_minus.svg);
}

.item__btn_size {
  background-image: url(./img/icon_irow-more.svg);
}

.item._size .item__btn_size {
  background-image: url(./img/icon_irow-less.svg);
}

.item__controls-order {
  grid-column: 1 / -1;
  font-size: 14px;
  margin-top: 8px;
}
