:root {
  --ink: #171313;
  --Tekst-Gwny: #100707;
  --muted: #aaa6a6;
  --line: #e1dfdf;
  --accent: #ff7a00;
  --swatch: #333;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  margin: 0;
}

body {
  overflow: hidden;
  background: #f6f6f5;
  color: var(--ink);
  font-family: Poppins, Arial, Helvetica, sans-serif;
}

button {
  color: inherit;
  font: inherit;
}

.configurator {
  display: grid;
  grid-template-columns: minmax(380px, 35.3vw) 1fr;
  gap: 12px;
  width: 100%;
  height: 100dvh;
  min-height: 650px;
  padding: 8px 10px 8px 16px;
}

.panel,
.viewer {
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

.category-list {
  display: grid;
  grid-auto-rows: minmax(88px, auto);
  gap: 10px;
  height: 100%;
  overflow-y: auto;
  padding-right: 3px;
  scrollbar-color: #cac6c6 transparent;
  scrollbar-width: thin;
}

.category-card {
  display: grid;
  grid-template-columns: 50px minmax(0, 1fr) auto;
  align-items: center;
  gap: 18px;
  width: 100%;
  min-height: 0;
  padding: 12px 28px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: #fff;
  text-align: left;
  cursor: pointer;
  transition:
    border-color 160ms ease,
    box-shadow 160ms ease,
    transform 160ms ease;
}

.category-card:hover,
.category-card:focus-visible {
  border-color: #c9c5c5;
  box-shadow: 0 8px 22px rgb(32 25 23 / 7%);
  outline: 0;
  transform: translateY(-1px);
}

.swatch,
.option-color {
  display: block;
  border: 1px solid rgb(0 0 0 / 4%);
  border-radius: 50%;
  background-color: var(--swatch);
}

.swatch {
  width: 46px;
  height: 46px;
}

.card-copy {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.card-copy strong {
  overflow: hidden;
  color: var(--Tekst-Gwny, #100707);
  font-family: Poppins, Arial, Helvetica, sans-serif;
  font-size: 19px;
  font-style: normal;
  font-weight: 700;
  letter-spacing: 1.9px;
  line-height: 115%;
  text-align: left;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}

.card-copy span {
  overflow: hidden;
  color: #474242;
  font-size: 16px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

em {
  color: var(--accent);
  font-style: normal;
}

.choose {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 16px;
  white-space: nowrap;
}

.choose b {
  font-size: 25px;
  font-weight: 400;
  line-height: 0;
}

.option-panel {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: none;
  grid-template-rows: 64px 1fr;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: #fff;
}

.option-panel.open {
  display: grid;
  animation: enter 220ms ease both;
}

@keyframes enter {
  from {
    opacity: 0;
    transform: translateX(-12px);
  }
}

.option-header {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 0 16px;
  border-bottom: 1px solid #f0eeee;
}

.option-header h1 {
  margin: 0;
  font-size: 23px;
  font-weight: 800;
  letter-spacing: 0.055em;
  text-transform: uppercase;
}

.back {
  justify-self: start;
  padding: 10px 8px 10px 0;
  border: 0;
  background: transparent;
  color: #575151;
  cursor: pointer;
  font-size: 18px;
}

.option-scroll {
  overflow-y: auto;
  padding: 22px 36px 40px;
  scrollbar-color: #cac6c6 transparent;
  scrollbar-width: thin;
}

.group-title {
  margin: 0 0 20px;
  color: #514c4b;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.38em;
  text-align: center;
}

.option-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 30px 18px;
}

.option-subgroup {
  grid-column: 1 / -1;
  margin: 12px 0 -7px;
  color: #777170;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.option-subgroup:first-child {
  margin-top: 0;
}

.option {
  position: relative;
  display: grid;
  width: 54px;
  height: 54px;
  place-items: center;
  justify-self: center;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
}

.option:disabled {
  cursor: not-allowed;
  opacity: 0.38;
}

.option:disabled:hover .option-color {
  transform: none;
}

.option-color {
  width: 40px;
  height: 40px;
  transition:
    box-shadow 150ms ease,
    transform 150ms ease;
}

.option:hover .option-color,
.option:focus-visible .option-color {
  outline: 0;
  transform: scale(1.07);
}

.option:focus-visible {
  outline: 0;
}

.option.selected .option-color {
  box-shadow:
    0 0 0 5px #fff,
    0 0 0 10px var(--accent);
}

.tooltip {
  position: absolute;
  top: calc(100% + 9px);
  left: 50%;
  z-index: 8;
  width: max-content;
  max-width: 155px;
  padding: 9px 12px;
  border: 1px solid #e1dddd;
  border-radius: 13px;
  background: #fff;
  box-shadow: 0 8px 20px rgb(23 17 17 / 12%);
  color: #888283;
  font-size: 13px;
  line-height: 1.15;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -4px);
  transition: 130ms ease;
}

.option:hover .tooltip,
.option:focus-visible .tooltip {
  opacity: 1;
  transform: translate(-50%, 0);
}

.selected-info {
  display: flex;
  align-items: center;
  gap: 13px;
  margin-top: 38px;
  padding: 17px 19px;
  border-radius: 15px;
  background: #f7f6f4;
  color: #898383;
  font-size: 13px;
}

.selected-info .swatch {
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
}

.selected-info div {
  display: grid;
  gap: 3px;
}

.selected-info strong {
  color: #312c2b;
  font-size: 16px;
}

.texture-leather {
  background:
    radial-gradient(circle at 25% 30%, rgb(255 255 255 / 13%) 0 1px, transparent 1.5px) 0 0 / 4px 4px,
    var(--swatch);
}

.texture-wood {
  background:
    repeating-linear-gradient(72deg,
      transparent 0 2px,
      rgb(255 255 255 / 9%) 3px,
      rgb(0 0 0 / 7%) 4px),
    var(--swatch);
}

.texture-grid {
  background:
    linear-gradient(45deg, transparent 43%, rgb(0 0 0 / 45%) 44% 52%, transparent 53%),
    linear-gradient(-45deg, transparent 43%, rgb(0 0 0 / 35%) 44% 52%, transparent 53%),
    var(--swatch);
  background-size: 20px 20px;
}

.texture-lines {
  background: repeating-linear-gradient(135deg,
      var(--swatch) 0 7px,
      rgb(0 0 0 / 22%) 8px 10px);
}

.texture-dots {
  background:
    radial-gradient(circle, rgb(0 0 0 / 38%) 0 2px, transparent 2.5px) 0 0 / 9px 9px,
    var(--swatch);
}

.swatch.has-image,
.option-color.has-image {
  background-color: var(--swatch);
  background-image: var(--swatch-image);
  background-position: center;
  background-size: cover;
}

.viewer {
  border: 1px solid var(--line);
  border-radius: 20px;
  background: #fff;
}

model-viewer {
  width: 100%;
  height: 100%;
  background: transparent;
  --poster-color: transparent;
}

model-viewer.model-switching {
  opacity: 0;
}

.model-transition-preview {
  position: absolute;
  inset: 0;
  z-index: 2;
  width: 100%;
  height: 100%;
  object-fit: fill;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition:
    opacity 180ms ease,
    visibility 0s linear 180ms;
}

.model-transition-preview.show {
  opacity: 1;
  visibility: visible;
  transition-delay: 0s;
}

.pick-hint {
  position: absolute;
  top: 24px;
  left: 24px;
  z-index: 4;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 10px 14px;
  border: 1px solid #ebe8e8;
  border-radius: 99px;
  background: rgb(255 255 255 / 90%);
  box-shadow: 0 5px 18px rgb(0 0 0 / 6%);
  color: #6f6969;
  font-size: 12px;
  pointer-events: none;
  transition:
    opacity 180ms ease,
    transform 180ms ease;
}

.pick-hint span {
  width: 8px;
  height: 8px;
  border: 2px solid var(--accent);
  border-radius: 50%;
  box-shadow: 0 0 0 4px rgb(255 122 0 / 12%);
}

.pick-hint.hide {
  opacity: 0;
  transform: translateY(-5px);
}

.fullscreen {
  position: absolute;
  top: 34px;
  right: 36px;
  z-index: 4;
  display: grid;
  width: 46px;
  height: 46px;
  place-items: center;
  border: 0;
  background: transparent;
  cursor: pointer;
}

.fullscreen img {
  display: block;
  width: 31px;
  height: 26px;
  object-fit: contain;
}

.progress-box {
  position: absolute;
  bottom: 30px;
  left: 50%;
  z-index: 7;
  display: grid;
  gap: 8px;
  width: min(260px, 60%);
  padding: 12px 17px;
  border: 1px solid #ebe8e8;
  border-radius: 14px;
  background: rgb(255 255 255 / 92%);
  box-shadow: 0 8px 24px rgb(0 0 0 / 7%);
  color: #6f6969;
  font-size: 12px;
  text-align: center;
  transform: translateX(-50%);
  transition: opacity 200ms ease;
}

.progress-box.hide {
  visibility: hidden;
  opacity: 0;
}

.progress-track {
  overflow: hidden;
  height: 3px;
  border-radius: 99px;
  background: #eceaea;
}

.update-bar {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transition: width 100ms linear;
}

#ar-button {
  position: absolute;
  right: 25px;
  bottom: 25px;
  display: grid;
  width: 52px;
  height: 52px;
  place-items: center;
  padding: 0;
  border: 1px solid #ddd9d9;
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 6px 18px rgb(0 0 0 / 8%);
  cursor: pointer;
}

#ar-button img {
  display: block;
  width: 38px;
  height: 38px;
  object-fit: contain;
}

#ar-prompt {
  position: absolute;
  bottom: 86px;
  left: 50%;
  transform: translateX(-50%);
}

#ar-prompt img {
  display: block;
  width: 54px;
  height: auto;
  filter: drop-shadow(0 5px 8px rgb(0 0 0 / 18%));
  animation: ar-hand-prompt 1.8s ease-in-out infinite;
}

@keyframes ar-hand-prompt {

  0%,
  100% {
    transform: translateX(-14px) rotate(-4deg);
  }

  50% {
    transform: translateX(14px) rotate(4deg);
  }
}

.model-error {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: none;
  place-content: center;
  padding: 30px;
  background: #fff;
  color: #8f8988;
  text-align: center;
}

.model-error.show {
  display: grid;
}

.model-error strong {
  margin-bottom: 6px;
  color: #302b2a;
  font-size: 18px;
}

@media (max-width: 1050px) {
  .configurator {
    grid-template-columns: minmax(340px, 39vw) 1fr;
  }

  .category-card {
    grid-template-columns: 44px minmax(0, 1fr) auto;
    gap: 13px;
    padding: 10px 18px;
  }

  .swatch {
    width: 42px;
    height: 42px;
  }

  .option-grid {
    grid-template-columns: repeat(5, 1fr);
  }
}

@media (max-width: 760px) {
  body {
    overflow: auto;
  }

  .configurator {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(300px, 53dvh) 1fr;
    gap: 8px;
    min-height: 640px;
    padding: 8px;
    overflow: auto;
  }

  .viewer {
    grid-row: 1;
    border-radius: 17px;
  }

  .panel {
    grid-row: 2;
    min-height: 440px;
    overflow: visible;
  }

  .category-list {
    grid-auto-rows: 86px;
    height: auto;
  }

  .option-panel {
    position: fixed;
    inset: auto 8px 8px;
    z-index: 20;
    height: min(74dvh, 650px);
    border-radius: 20px;
    box-shadow: 0 -12px 40px rgb(27 21 21 / 16%);
  }

  .option-panel::before {
    position: fixed;
    inset: 0;
    z-index: -1;
    background: rgb(30 26 25 / 20%);
    content: "";
  }

  .option-scroll {
    padding: 20px 25px 30px;
  }

  .option-header h1 {
    font-size: 18px;
  }

  .option-grid {
    grid-template-columns: repeat(5, 1fr);
    gap: 27px 12px;
  }

  .fullscreen {
    top: 15px;
    right: 15px;
  }

  .pick-hint {
    top: 16px;
    left: 16px;
    max-width: calc(100% - 86px);
    border-radius: 13px;
    line-height: 1.25;
  }
}

@media (max-width: 430px) {
  .category-card {
    padding: 10px 14px;
  }

  .card-copy span,
  .choose {
    font-size: 13px;
  }

  .option-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

@media (prefers-reduced-motion: reduce) {

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
