.three-d-preview-section {
  color: rgb(var(--color-text));
  background-color: rgb(var(--color-background));
}

theme-3d-preview {
  --three-d-scene-floor: #fdf2d6;
  --three-d-scene-wall: #faf8f2;
  display: block;
  box-sizing: border-box;
  width: 100%;
  margin: 0;
  color: rgb(var(--color-text));
  background-color: rgb(var(--color-background));
  font: inherit;
}

theme-3d-preview *,
theme-3d-preview *::before,
theme-3d-preview *::after {
  box-sizing: border-box;
}

theme-3d-preview .hidden {
  display: none !important;
}

.three-d-preview__header {
  width: 100%;
  margin: 0;
  text-align: center;
}

.three-d-preview__header h1,
.three-d-preview__header h2 {
  margin: 0;
  color: rgb(var(--color-text));
}

.three-d-preview__header p {
  max-width: 900px;
  margin: 22px auto 0;
  color: rgb(var(--color-text));
}

.three-d-preview__workspace {
  display: grid;
  grid-template-columns: clamp(250px, 26%, 295px) minmax(0, 1fr);
  align-items: stretch;
  width: 100%;
  margin-top: 40px;
  overflow: hidden;
  border-radius: var(--card-border-radius);
}

.three-d-preview__catalog {
  position: relative;
  min-width: 0;
  min-height: 0;
  padding: 10px;
  overflow: hidden;
  background: rgb(var(--color-button-background));
  contain: size layout;
}

.three-d-preview__catalog-inner {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  min-height: 0;
  overflow: hidden;
  border-radius: var(--card-border-radius);
  background: rgb(var(--color-background));
}

.three-d-preview__tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  flex: 0 0 auto;
  margin: 10px 10px 0;
}

.three-d-preview__tab {
  appearance: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 0;
  min-height: 58px;
  padding: 6px 12px 7px;
  border: 0;
  border-bottom: 3px solid transparent;
  background: rgb(var(--color-media-background));
  color: rgb(var(--color-text));
  cursor: pointer;
  font: inherit;
  transition: background-color 0.2s ease, color 0.2s ease;
}

.three-d-preview__tab:first-child {
  border-radius: 10px 0 0 10px;
}

.three-d-preview__tab:last-child {
  border-radius: 0 10px 10px 0;
}

.three-d-preview__tab:hover {
  background: rgba(var(--color-button-background), 0.12);
}

.three-d-preview__tab.is-active {
  background: rgb(var(--color-button-background));
  color: rgb(var(--color-button-text));
}

.three-d-preview__tab span {
  display: block;
  margin-top: 2px;
  font-size: 15px;
  font-weight: 500;
  line-height: 1;
}

.three-d-preview__tab-icon {
  display: block;
  width: 24px;
  height: 24px;
  object-fit: contain;
}

.three-d-preview__tab-icon--active,
.three-d-preview__tab.is-active .three-d-preview__tab-icon--inactive {
  display: none;
}

.three-d-preview__tab.is-active .three-d-preview__tab-icon--active {
  display: block;
}

.three-d-preview__tools {
  position: relative;
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 5px 10px 3px;
}

.three-d-preview__search-shell {
  display: flex;
  align-items: center;
  gap: 5px;
  width: 100%;
  max-width: 300px;
  height: 30px;
  padding: 0 9px;
  border: var(--input-border-thickness) solid
    rgba(var(--color-text), var(--input-border-opacity));
  border-radius: var(--input-border-radius);
  background: rgb(var(--color-background));
  box-shadow: var(--input-shadow-offset-x) var(--input-shadow-offset-y)
    var(--input-shadow-blur)
    rgba(var(--color-shadow), var(--input-shadow-opacity));
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.three-d-preview__search-shell:focus-within {
  border-color: rgb(var(--color-button-background));
  outline: 2px solid rgba(var(--color-button-background), 0.25);
  outline-offset: 1px;
}

.three-d-preview__search-icon {
  display: block;
  flex: 0 0 20px;
  width: 20px;
  height: 20px;
}

.three-d-preview__search {
  flex: 1 1 auto;
  width: 0;
  height: 100%;
  margin: 0;
  padding: 0 4px 2px 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: rgb(var(--color-text));
  font: inherit;
  font-size: 13px;
  line-height: 1;
}

.three-d-preview__search::placeholder {
  color: rgb(var(--color-light-text));
  opacity: 1;
}

.three-d-preview__icon-button {
  appearance: none;
  position: absolute;
  z-index: 2;
  top: -61px;
  right: 1px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 35px;
  height: 35px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgb(var(--color-media-background));
  cursor: pointer;
  transition: background-color 0.2s ease, transform 0.2s ease;
}

.three-d-preview__icon-button:hover {
  background: rgba(var(--color-button-background), 0.12);
  transform: scale(1.08);
}

.three-d-preview__icon-button.is-active {
  background: rgb(var(--color-button-background));
  color: rgb(var(--color-button-text));
}

.three-d-preview__icon-button img {
  display: block;
  width: 20px;
  height: 20px;
}

.three-d-preview__clear-history {
  appearance: none;
  position: absolute;
  z-index: 2;
  right: 8px;
  bottom: -24px;
  padding: 3px 7px;
  border: 0;
  border-radius: 10px;
  background: rgba(var(--color-background), 0.94);
  color: rgb(var(--color-light-text));
  cursor: pointer;
  font: inherit;
  font-size: 10px;
}

.three-d-preview__catalog-content {
  position: relative;
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  min-height: 0;
  padding: 10px;
  overflow: hidden;
  background: rgb(var(--color-background));
}

.three-d-preview__products {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 15px;
  flex: 1 1 auto;
  min-height: 0;
  padding: 10px;
  overflow-x: hidden;
  overflow-y: auto;
}

.three-d-preview__product {
  appearance: none;
  position: relative;
  display: block;
  width: 100%;
  min-width: 0;
  height: 84px;
  padding: 0;
  overflow: hidden;
  border: 2px solid transparent;
  border-radius: var(--product-card-border-radius);
  background: transparent;
  color: inherit;
  cursor: pointer;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}

.three-d-preview__product:hover {
  border-color: rgba(var(--color-button-background), 0.55);
  transform: scale(1.04);
}

.three-d-preview__product.is-selected {
  border-color: rgb(var(--color-button-background));
  box-shadow: 0 0 10px rgba(var(--color-button-background), 0.25);
}

.three-d-preview__product img {
  display: block;
  width: 100%;
  height: 80px;
  border-radius: max(calc(var(--product-card-border-radius) - 2px), 0px);
  object-fit: cover;
}

.three-d-preview__product > span {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

.three-d-preview__product small {
  position: absolute;
  right: 3px;
  bottom: 3px;
  padding: 2px 5px;
  border-radius: 8px;
  background: rgba(var(--color-background), 0.92);
  color: rgb(var(--color-error-message));
  font-size: 9px;
}

.three-d-preview__products::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

.three-d-preview__products::-webkit-scrollbar-track {
  border-radius: 3px;
  background: rgb(var(--color-media-background));
}

.three-d-preview__products::-webkit-scrollbar-thumb {
  border-radius: 3px;
  background: rgb(var(--color-entry-line));
}

.three-d-preview__pagination {
  display: grid;
  grid-template-columns: 36px 1fr 36px;
  align-items: center;
  flex: 0 0 auto;
  min-height: 46px;
  margin: auto -10px -10px;
  padding: 5px 10px;
  border-top: 1px solid rgb(var(--color-entry-line));
  background: rgb(var(--color-background));
}

.three-d-preview__pagination button {
  appearance: none;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 9px;
  border: 1px solid rgba(var(--color-entry-line), 0.6);
  border-radius: 6px;
  background: rgba(var(--color-background), 0.85);
  color: rgb(var(--color-text));
  cursor: pointer;
}

.three-d-preview__pagination button:first-child svg {
  transform: rotate(180deg);
}

.three-d-preview__pagination button:disabled {
  cursor: not-allowed;
  opacity: 0.35;
}

.three-d-preview__pagination > span {
  color: rgb(var(--color-button-background));
  font-size: 14px;
  font-weight: 600;
  text-align: center;
}

.three-d-preview__empty {
  margin: auto;
  padding: 30px 12px;
  color: rgb(var(--color-light-text));
  font-size: 13px;
  text-align: center;
}

.three-d-preview__loading {
  position: absolute;
  z-index: 10;
  inset: 0;
  display: none;
  place-items: center;
  border-radius: 8px;
  background: rgba(var(--color-background), 0.82);
}

.three-d-preview__loading.is-active {
  display: grid;
}

.three-d-preview__spinner {
  width: 34px;
  height: 34px;
  color: rgb(var(--color-button-background));
  animation: three-d-preview-spin 0.8s linear infinite;
}

.three-d-preview__scene {
  position: relative;
  isolation: isolate;
  z-index: 0;
  min-width: 0;
  width: 100%;
  overflow: hidden;
  aspect-ratio: 11 / 9;
  background: var(--three-d-scene-floor);
}

.three-d-preview__scene-background,
.three-d-preview__dom-layer,
.three-d-preview__canvas-layer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.three-d-preview__scene-background {
  z-index: 1;
}

.three-d-preview__scene-background-wall {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 54%;
  background-color: var(--three-d-scene-wall);
  background-image: var(--three-d-preview-wall-pattern, none);
  background-repeat: repeat;
  background-size: 240px;
}

.three-d-preview__scene-background-floor {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  height: 46%;
  background: var(--three-d-scene-floor);
}

.three-d-preview__dom-layer {
  z-index: 2;
  pointer-events: none;
  perspective: 1000px;
}

.three-d-preview__canvas-layer {
  z-index: 2;
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.three-d-preview__canvas-layer canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.three-d-preview__scene.is-renderer-ready .three-d-preview__canvas-layer {
  visibility: visible;
  opacity: 1;
}

.three-d-preview__dom-zone {
  position: absolute;
  left: 0;
  display: flex;
  flex-direction: column-reverse;
  width: 100%;
  transform-style: preserve-3d;
}

.three-d-preview__dom-zone--wall {
  top: 0;
  height: 62%;
}

.three-d-preview__dom-zone--floor {
  bottom: 0;
  height: 38%;
}

.three-d-preview__quick-buy {
  appearance: none;
  position: relative;
  display: flex;
  flex: 0 0 auto;
  width: 49%;
  height: 100%;
  margin: 0 auto;
  padding: 0;
  overflow: hidden;
  border: 0;
  border-radius: 0;
  background: transparent;
  cursor: var(--three-d-preview-cart-cursor, pointer);
  pointer-events: auto;
}

.three-d-preview__quick-buy[data-role="wall"] {
  align-items: flex-end;
}

.three-d-preview__quick-buy[data-role="floor"] {
  align-items: flex-start;
  transform: rotateX(65deg);
  transform-origin: top;
}

.three-d-preview__quick-buy:disabled {
  cursor: default;
}

.three-d-preview__quick-buy.is-loading {
  cursor: wait;
}

.three-d-preview__quick-buy-loader {
  position: absolute;
  z-index: 6;
  left: var(--three-d-preview-quick-buy-loader-x, 50%);
  top: var(--three-d-preview-quick-buy-loader-y, 50%);
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 1px solid rgba(var(--color-entry-line), 0.7);
  border-radius: 50%;
  background: rgba(var(--color-background), 0.94);
  box-shadow: 0 3px 12px rgba(var(--color-shadow), 0.2);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -50%) scale(0.82);
  transition: opacity 0.16s ease, transform 0.16s ease;
}

.three-d-preview__quick-buy-loader.is-active {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

.three-d-preview__quick-buy-loader .loading--rotator {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
}

.three-d-preview__quick-buy-loader .loading--rotator svg {
  display: block;
  width: 100%;
  height: 100%;
}

.three-d-preview__quick-buy-spinner {
  width: 22px;
  height: 22px;
  color: rgb(var(--color-button-background));
  animation: three-d-preview-spin 0.8s linear infinite;
}

.three-d-preview__dom-wall,
.three-d-preview__dom-floor {
  display: block;
  width: 100%;
  height: 100%;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.three-d-preview__dom-wall {
  object-fit: scale-down;
}

.three-d-preview__dom-floor {
  object-fit: cover;
}

.three-d-preview__scene.is-renderer-ready .three-d-preview__dom-wall,
.three-d-preview__scene.is-renderer-ready .three-d-preview__dom-floor {
  opacity: 0;
}

.three-d-preview__gallery {
  --three-d-preview-gallery-height: 54px;
  position: absolute;
  z-index: 4;
  right: 12px;
  left: 12px;
  display: flex;
  align-items: stretch;
  justify-content: flex-start;
  pointer-events: none;
}

.three-d-preview__gallery--wall {
  top: 10px;
}

.three-d-preview__gallery--floor {
  bottom: 10px;
}

.three-d-preview__gallery-toggle {
  appearance: none;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 24px;
  width: 24px;
  min-width: 24px;
  height: var(--three-d-preview-gallery-height);
  padding: 4px;
  border: 1px solid rgba(var(--color-entry-line), 0.75);
  border-right: 0;
  border-radius: 9px 0 0 9px;
  background: rgba(var(--color-background), 0.9);
  color: rgb(var(--color-light-text));
  cursor: pointer;
  pointer-events: auto;
}

.three-d-preview__gallery-toggle svg {
  width: 16px;
  height: 16px;
  transform: rotate(180deg);
  transition: transform 0.25s ease;
}

.three-d-preview__gallery-scroll {
  width: max-content;
  height: var(--three-d-preview-gallery-height);
  max-width: calc(100% - 24px);
  overflow-x: auto;
  overflow-y: hidden;
  padding: 5px;
  border: 1px solid rgba(var(--color-entry-line), 0.75);
  border-left: 0;
  border-radius: 0 9px 9px 0;
  background: rgba(var(--color-background), 0.9);
  box-shadow: none;
  backdrop-filter: blur(6px);
  pointer-events: auto;
  opacity: 1;
  transform: translateX(0);
  transform-origin: left center;
  transition: max-width 0.28s ease, padding 0.28s ease, opacity 0.18s ease, transform 0.28s ease;
  scrollbar-width: none;
}

.three-d-preview__gallery-scroll::-webkit-scrollbar {
  display: none;
}

.three-d-preview__gallery.is-collapsed .three-d-preview__gallery-scroll {
  max-width: 0;
  padding-right: 0;
  padding-left: 0;
  border-width: 0;
  opacity: 0;
  transform: translateX(-8px);
  pointer-events: none;
}

.three-d-preview__gallery.is-collapsed .three-d-preview__gallery-toggle {
  border-right: 1px solid rgba(var(--color-entry-line), 0.75);
  border-radius: 9px;
}

.three-d-preview__gallery.is-collapsed .three-d-preview__gallery-toggle svg {
  transform: rotate(0deg);
}

.three-d-preview__gallery-track {
  display: flex;
  gap: 5px;
  width: max-content;
}

.three-d-preview__gallery-item {
  appearance: none;
  flex: 0 0 56px;
  width: 56px;
  height: 42px;
  padding: 0;
  overflow: hidden;
  border: 2px solid transparent;
  border-radius: 6px;
  background: transparent;
  cursor: pointer;
}

.three-d-preview__gallery-item.is-selected {
  border-color: rgb(var(--color-button-background));
}

.three-d-preview__gallery-item img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.three-d-preview__status {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.three-d-preview__actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  width: 100%;
  margin-top: 20px;
}

.three-d-preview__action {
  gap: 12px;
  min-width: 0;
  min-height: 36px;
  overflow: hidden;
}

.three-d-preview__action--primary {
  --three-d-preview-action-icon: url("./action-cart.png");
}

.three-d-preview__action--reset {
  --three-d-preview-action-icon: url("./reset.svg");
}

.three-d-preview__action--continue {
  --three-d-preview-action-icon: url("./action-continue.png");
}

.three-d-preview__action-icon {
  flex: 0 0 20px;
  width: 20px;
  height: 20px;
  display: block;
  background-color: currentColor;
  -webkit-mask: var(--three-d-preview-action-icon) center / contain no-repeat;
  mask: var(--three-d-preview-action-icon) center / contain no-repeat;
}

.three-d-preview--simple .three-d-preview__header p {
  max-width: 760px;
}

.three-d-preview--simple .three-d-preview__catalog-content {
  padding-top: 8px;
}

.three-d-preview--simple .three-d-preview__actions {
  justify-content: space-between;
}

.three-d-preview__tab:focus-visible,
.three-d-preview__icon-button:focus-visible,
.three-d-preview__clear-history:focus-visible,
.three-d-preview__product:focus-visible,
.three-d-preview__pagination button:focus-visible,
.three-d-preview__quick-buy:focus-visible,
.three-d-preview__gallery-toggle:focus-visible,
.three-d-preview__gallery-item:focus-visible,
.three-d-preview__action:focus-visible {
  outline: 3px solid rgb(var(--color-button-background));
  outline-offset: 2px;
}

@keyframes three-d-preview-spin {
  to { transform: rotate(360deg); }
}

@media (max-width: 1000px) {
  .three-d-preview__header p {
    margin-top: 14px;
  }

  .three-d-preview__workspace {
    display: flex;
    flex-direction: column;
    margin-top: 26px;
  }

  .three-d-preview__catalog {
    order: 1;
    width: 100%;
    height: 250px;
    contain: layout;
  }

  .three-d-preview__scene {
    order: 2;
    flex: 0 0 auto;
    width: 100%;
    aspect-ratio: 11 / 9;
  }

  .three-d-preview__products {
    display: flex;
    flex-direction: row;
    gap: 5px;
    padding: 0;
    overflow-x: auto;
    overflow-y: hidden;
  }

  .three-d-preview__product {
    flex: 0 0 90px;
    width: 90px;
    height: 64px;
  }

  .three-d-preview__product img {
    height: 60px;
  }

  .three-d-preview__pagination {
    min-height: 36px;
    margin: 4px -10px -10px;
    padding: 0 10px;
    border-top: 0;
  }

  .three-d-preview__pagination button {
    width: 32px;
    height: 32px;
    border-radius: 50%;
  }

  .three-d-preview__dom-layer {
    perspective: 600px;
  }

  .three-d-preview__dom-zone--wall {
    height: 60%;
  }

  .three-d-preview__dom-zone--floor {
    height: 40%;
  }

  .three-d-preview__quick-buy[data-role="floor"] {
    transform: rotateX(55deg);
  }

  .three-d-preview__gallery {
    --three-d-preview-gallery-height: 44px;
    right: 6px;
    left: 6px;
  }

  .three-d-preview__gallery--wall {
    top: 6px;
  }

  .three-d-preview__gallery--floor {
    bottom: 6px;
  }

  .three-d-preview__gallery-toggle {
    flex-basis: 20px;
    width: 20px;
    min-width: 20px;
    border-radius: 7px 0 0 7px;
  }

  .three-d-preview__gallery.is-collapsed .three-d-preview__gallery-toggle {
    border-radius: 7px;
  }

  .three-d-preview__gallery-scroll {
    max-width: calc(100% - 20px);
    padding: 4px;
    border-radius: 0 7px 7px 0;
  }

  .three-d-preview__gallery-item {
    flex-basis: 44px;
    width: 44px;
    height: 34px;
    border-radius: 5px;
  }

  .three-d-preview--simple .three-d-preview__catalog {
    height: 205px;
  }
}

@media (max-width: 768px) {
  .three-d-preview__actions {
    flex-direction: column;
    align-items: stretch;
    gap: 15px;
    margin-top: 15px;
  }

  .three-d-preview__action {
    position: relative;
    width: 100%;
    min-height: 38px;
  }

  .three-d-preview__action > span:first-child {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    white-space: nowrap;
  }

  .three-d-preview__action-icon {
    margin-left: auto;
  }
}

@media (prefers-reduced-motion: reduce) {
  .three-d-preview__product,
  .three-d-preview__canvas-layer,
  .three-d-preview__dom-wall,
  .three-d-preview__dom-floor,
  .three-d-preview__gallery-scroll,
  .three-d-preview__gallery-toggle svg,
  .three-d-preview__action,
  .three-d-preview__quick-buy-loader {
    transition: none;
  }

  .three-d-preview__spinner,
  .three-d-preview__quick-buy-spinner {
    animation: none;
  }
}
