.icon-carpet-page {
  min-height: 100vh;
  background: #fff;
  color: var(--foreground);
}

.icon-carpet-main {
  display: flex;
  flex-direction: column;
  padding: 0;
}

.icon-carpet-stage-wrap {
  position: relative;
  width: 100%;
  min-height: calc(100vh - var(--header-height, 4.5rem));
  min-height: calc(100dvh - var(--header-height, 4.5rem));
  background: #fff;
  overflow: hidden;
}

.icon-carpet-stage {
  position: absolute;
  inset: 0;
}

.icon-carpet-stage::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  background: linear-gradient(
    to top,
    rgba(255, 255, 255, 0) 22%,
    rgba(255, 255, 255, 0.55) 58%,
    #ffffff 86%
  );
}

.icon-carpet-canvas {
  display: block;
  width: 100%;
  height: 100%;
  /* Scroll-driven only — keep page scroll + pinch-zoom over the canvas. */
  touch-action: pan-y pinch-zoom;
}

.icon-carpet-controls {
  position: absolute;
  left: 50%;
  bottom: max(1.5rem, env(safe-area-inset-bottom));
  z-index: 4;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  transform: translateX(-50%);
  padding: 0.55rem 0.7rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.82);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.9) inset,
    0 10px 28px rgba(0, 0, 0, 0.12);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.icon-carpet-swatch {
  box-sizing: border-box;
  appearance: none;
  border: 0;
  margin: 0;
  padding: 0;
  width: 2.35rem;
  height: 2.35rem;
  border-radius: 999px;
  background: var(--swatch, #e8e8e8);
  box-shadow:
    0 0 0 2px rgba(255, 255, 255, 0.95),
    0 0 0 3px rgba(0, 0, 0, 0.08);
  cursor: pointer;
  transition:
    transform 160ms ease,
    box-shadow 160ms ease;
}

.icon-carpet-swatch:hover {
  transform: scale(1.08);
}

.icon-carpet-swatch:focus-visible {
  outline: 2px solid #288cef;
  outline-offset: 3px;
}

.icon-carpet-swatch.is-active {
  box-shadow:
    0 0 0 2px rgba(255, 255, 255, 0.95),
    0 0 0 4px rgba(0, 0, 0, 0.55);
  transform: scale(1.1);
}

.icon-carpet-swatch[data-color-key=""] {
  width: auto;
  min-width: 2.35rem;
  padding: 0 0.85rem;
  font: 600 0.8rem/1 var(--font-sans, system-ui, sans-serif);
  letter-spacing: 0.02em;
  color: #222;
  background: #f2f2f2;
}

.icon-carpet-hint {
  position: absolute;
  left: 50%;
  bottom: calc(max(1.5rem, env(safe-area-inset-bottom)) + 3.6rem);
  z-index: 4;
  margin: 0;
  transform: translateX(-50%);
  max-width: min(22rem, calc(100% - 2rem));
  text-align: center;
  font-size: 0.85rem;
  line-height: 1.35;
  color: rgba(0, 0, 0, 0.45);
  pointer-events: none;
}

@media (max-width: 640px) {
  .icon-carpet-controls {
    gap: 0.4rem;
    padding: 0.45rem 0.55rem;
  }

  .icon-carpet-swatch {
    width: 2.1rem;
    height: 2.1rem;
  }

  .icon-carpet-hint {
    bottom: calc(max(1.25rem, env(safe-area-inset-bottom)) + 3.2rem);
    font-size: 0.78rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .icon-carpet-swatch {
    transition: none;
  }
}
