@property --g-min {
  syntax: "<integer>";
  inherits: true;
  initial-value: 120;
}
@property --g-gap {
  syntax: "<integer>";
  inherits: true;
  initial-value: 8;
}
html, body {
  margin: 0;
  overflow: hidden;
}

.stage {
  box-sizing: border-box;
  min-height: 100vh;
  display: grid;
  place-items: center;
  margin: 0;
  background: #17141a;
  font-family: -apple-system, "Segoe UI", "Noto Sans KR", sans-serif;
  padding: clamp(8px, 4vw, 24px);
}

.gen {
  min-width: 0;
  --g-min: 120;
  --g-gap: 8;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-sizing: border-box;
  width: min(100%, 400px);
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.05);
}

.gen__top {
  display: flex;
  align-items: center;
  gap: 12px;
}

.gen__preview {
  flex: 0 0 auto;
  box-sizing: border-box;
  width: 148px;
  height: 92px;
  padding: 4px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.28);
  display: grid;
  align-content: start;
  grid-template-columns: repeat(auto-fit, minmax(calc(var(--g-min) * 0.32px), 1fr));
  gap: 0;
  overflow: hidden;
}

.gen__cell {
  height: 20px;
  border-radius: 4px;
  box-sizing: border-box;
  border: calc(var(--g-gap) * 0.32px / 2) solid transparent;
  background-clip: padding-box;
}

.gen__cell--a {
  background: #2f6df6;
}

.gen__cell--b {
  background: #ff9ebb;
}

.gen__grid {
  flex: 1 1 auto;
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 4px;
}

.gen__row {
  display: flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
}

.gen__lab {
  flex: 0 0 auto;
  width: 42px;
  color: #fff7e6;
  font-weight: 700;
  font-size: 10px;
  line-height: 1.4;
}

.gen__slot {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
  display: grid;
  align-items: center;
  height: 16px;
}

.gen__slot::before {
  content: "";
  grid-area: 1/1;
  height: 4px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.2);
}

.gen__rng {
  grid-area: 1/1;
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  min-width: 0;
  height: 16px;
  margin: 0;
  background: transparent;
  cursor: pointer;
}

.gen__rng::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 12px;
  height: 12px;
  border: 0;
  border-radius: 50%;
  background: transparent;
}

.gen__rng::-moz-range-thumb {
  width: 12px;
  height: 12px;
  border: 0;
  border-radius: 50%;
  background: transparent;
}

.gen__rng:focus-visible {
  outline: 2px solid #5b8cf8;
  outline-offset: 2px;
  border-radius: 999px;
}

.gen__thumb {
  position: absolute;
  top: 50%;
  left: calc(var(--pct) * 1%);
  width: 12px;
  height: 12px;
  margin-top: -6px;
  margin-left: -6px;
  border-radius: 50%;
  background: #5b8cf8;
  pointer-events: none;
}

.gen__row:nth-child(1) .gen__thumb {
  --pct: calc((var(--g-min) - 80) / 180 * 100);
}

.gen__row:nth-child(2) .gen__thumb {
  --pct: calc(var(--g-gap) / 24 * 100);
}

.gen__out {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.gen__code {
  flex: 1 1 auto;
  min-width: 0;
  padding: 8px;
  border-radius: 8px;
  background: #17141a;
  color: #fff7e6;
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Consolas, "Liberation Mono", monospace;
  font-weight: 500;
  font-size: 10px;
  line-height: 1.5;
  white-space: nowrap;
  overflow: hidden;
}

.gen__prop {
  color: #5b8cf8;
}

.gen__v {
  font-weight: 700;
}

.gen__v--min::after {
  counter-reset: v var(--g-min);
  content: counter(v);
}

.gen__v--gap::after {
  counter-reset: v var(--g-gap);
  content: counter(v);
}

.gen__copy {
  flex: 0 0 auto;
  padding: 8px 12px;
  border: 0;
  border-radius: 8px;
  background: #0a4fe8;
  color: #fff7e6;
  font-family: inherit;
  font-weight: 700;
  font-size: 11px;
  line-height: 1.4;
  cursor: pointer;
}

.gen__copy:focus-visible {
  outline: 2px solid #5b8cf8;
  outline-offset: 2px;
}

@keyframes gMin {
  0%, 100% {
    --g-min: 120;
  }
  40% {
    --g-min: 240;
  }
  75% {
    --g-min: 80;
  }
}
@keyframes gGap {
  0%, 100% {
    --g-gap: 8;
  }
  50% {
    --g-gap: 20;
  }
  85% {
    --g-gap: 0;
  }
}
.gen.is-demo {
  animation-name: gMin, gGap;
  animation-duration: 2s;
  animation-timing-function: cubic-bezier(0.2, 0.8, 0.2, 1);
  animation-iteration-count: infinite;
}

@media (prefers-reduced-motion: reduce) {
  .gen.is-demo {
    animation: none !important;
  }
}
@media (max-width: 340px) {
  .gen {
    gap: 8px;
    padding: 8px;
  }
  .gen__top {
    gap: 8px;
  }
  .gen__preview {
    width: 116px;
    height: 84px;
  }
  .gen__code {
    font-size: 9px;
  }
}
