@property --f-bri {
  syntax: "<integer>";
  inherits: true;
  initial-value: 100;
}
@property --f-con {
  syntax: "<integer>";
  inherits: true;
  initial-value: 110;
}
@property --f-sat {
  syntax: "<integer>";
  inherits: true;
  initial-value: 130;
}
@property --f-blur {
  syntax: "<integer>";
  inherits: true;
  initial-value: 0;
}
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;
  --f-bri: 100;
  --f-con: 110;
  --f-sat: 130;
  --f-blur: 0;
  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 {
  position: relative;
  flex: 0 0 auto;
  overflow: hidden;
  box-sizing: border-box;
  width: 116px;
  height: 80px;
  border-radius: 8px;
  background: #ffd23f;
  filter: brightness(calc(var(--f-bri) * 1%)) contrast(calc(var(--f-con) * 1%)) saturate(calc(var(--f-sat) * 1%)) blur(calc(var(--f-blur) * 1px));
}

.gen__sun {
  position: absolute;
  left: 22px;
  top: 14px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #ff4d1f;
}

.gen__hill {
  position: absolute;
  bottom: 0;
  width: 90px;
  height: 44px;
  border-radius: 999px 999px 0 0;
}

.gen__hill--a {
  left: -20px;
  background: #2f6df6;
}

.gen__hill--b {
  right: -24px;
  background: #0a4fe8;
}

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

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

.gen__lab {
  flex: 0 0 auto;
  width: 26px;
  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(--f-bri) - 50) / 100 * 100);
}

.gen__row:nth-child(2) .gen__thumb {
  --pct: calc((var(--f-con) - 50) / 100 * 100);
}

.gen__row:nth-child(3) .gen__thumb {
  --pct: calc(var(--f-sat) / 200 * 100);
}

.gen__row:nth-child(4) .gen__thumb {
  --pct: calc(var(--f-blur) / 8 * 100);
}

.gen__presets {
  display: flex;
  gap: 8px;
}

.gen__preset {
  flex: 1 1 0;
  padding: 4px 8px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  color: #fff7e6;
  font-family: inherit;
  font-weight: 700;
  font-size: 10px;
  line-height: 1.4;
  cursor: pointer;
}

.gen__preset:hover {
  background: rgba(255, 255, 255, 0.12);
}

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

.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--bri::after {
  counter-reset: v var(--f-bri);
  content: counter(v);
}

.gen__v--con::after {
  counter-reset: v var(--f-con);
  content: counter(v);
}

.gen__v--sat::after {
  counter-reset: v var(--f-sat);
  content: counter(v);
}

.gen__v--blur::after {
  counter-reset: v var(--f-blur);
  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 fBri {
  0%, 100% {
    --f-bri: 100;
  }
  50% {
    --f-bri: 85;
  }
}
@keyframes fCon {
  0%, 100% {
    --f-con: 110;
  }
  50% {
    --f-con: 140;
  }
}
@keyframes fSat {
  0%, 100% {
    --f-sat: 130;
  }
  30% {
    --f-sat: 0;
  }
  70% {
    --f-sat: 180;
  }
}
@keyframes fBlur {
  0%, 100% {
    --f-blur: 0;
  }
  45% {
    --f-blur: 2;
  }
  85% {
    --f-blur: 0;
  }
}
.gen.is-demo {
  animation-name: fBri, fCon, fSat, fBlur;
  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: 96px;
    height: 68px;
  }
  .gen__preset {
    font-size: 9px;
  }
  .gen__code {
    font-size: 9px;
  }
}
