:root {
  --dm-control-height: 40px;
}

.dm-shop {
  background: #fff;
  color: #000;
}

.dm-shop-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 40px 24px 72px;
}

.dm-shop-note {
  font-weight: 300;
  margin: 0;
}

/* Toolbar layout (filter + sort) */
.dm-shop-toolbar {
  margin: 0 0 22px;
  background: transparent;
  padding-top: 20px;
}

.dm-shop-toolbar-row {
  display: grid;
  gap: 14px;
}

@media (min-width: 900px) {
  .dm-shop-toolbar-row {
    grid-template-columns: 1fr 260px;
    align-items: start;
  }
}

/* Product grid */
.dm-shop-grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 18px;
}

.dm-product-card {
  grid-column: span 12;
  border: 1px solid #000;
  background: #fff;
}

@media (min-width: 720px) {
  .dm-product-card {
    grid-column: span 6;
  }
}

@media (min-width: 1024px) {
  .dm-product-card {
    grid-column: span 4;
  }
}

/* Card carousel */
.dm-product-media {
  position: relative;
  aspect-ratio: 4 / 5;
  overflow: hidden;
  background: #fff;
  border-bottom: 1px solid #000;
}

.dm-product-track {
  position: relative;
  width: 100%;
  height: 100%;
}

.dm-product-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 160ms linear;
}

.dm-product-img.is-active {
  opacity: 1;
}

.dm-product-img--empty {
  background: #fff;
}

.dm-carousel-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  border: 1px solid #000;
  background: #fff;
  color: #000;
  width: 34px;
  height: 34px;
  padding: 0;
  display: grid;
  place-items: center;
  cursor: pointer;
  opacity: 0;
  transition: opacity 160ms linear;
}

.dm-carousel-btn[disabled] {
  opacity: 0 !important;
  pointer-events: none;
}

.dm-carousel-btn--prev {
  left: 10px;
}

.dm-carousel-btn--next {
  right: 10px;
}

.dm-product-card:hover .dm-carousel-btn {
  opacity: 1;
}

.dm-carousel-btn:focus-visible {
  outline: 2px solid #000;
  outline-offset: 2px;
}

.dm-carousel-btn:hover {
  background: #fff;
  color: #000;
}

.dm-carousel-dots {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 10px;
  display: flex;
  justify-content: center;
  gap: 6px;
  pointer-events: none;
}

.dm-dot {
  width: 6px;
  height: 6px;
  border: 1px solid #000;
  background: #fff;
  opacity: 0.8;
}

.dm-dot.is-active {
  background: #000;
  opacity: 1;
}

/* Card content */
.dm-product-body {
  padding: 14px 14px 16px;
}

.dm-product-top {
  display: grid;
  gap: 10px;
}

/* Title/price left, swatches right */
.dm-product-top--split {
  grid-template-columns: 1fr auto;
  align-items: start;
  gap: 14px;
}

.dm-product-top-left {
  display: grid;
  gap: 10px;
}

.dm-product-top-right {
  display: grid;
  align-content: start;
  justify-items: end;
}

.dm-swatch-row {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.dm-product-title {
  margin: 0;
  font-size: 16px;
  font-weight: 400;
  letter-spacing: 0.01em;
}

.dm-product-price {
  font-weight: 300;
  font-size: 14px;
}

/* Variant controls (fallback select) */
.dm-variant-row {
  display: grid;
  gap: 8px;
  margin-top: 2px;
}

.dm-variant-label {
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.dm-variant-select {
  border: 1px solid #000;
  background: #fff;
  color: #000;
  padding: 10px 12px;
  font-weight: 300;
}

.dm-variant-select:focus-visible {
  outline: 2px solid #000;
  outline-offset: 2px;
}

/* Card actions */
.dm-product-actions {
  margin-top: 14px;
}

.dm-details-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 8px 14px;
  border: 1px solid #000;
  background: #fff;
  color: #000;
  text-decoration: none;
  font-weight: 300;
  letter-spacing: 0.02em;
  cursor: pointer;
}

.dm-details-btn:hover {
  background: #000;
  color: #fff;
}

.dm-details-btn:focus-visible {
  outline: 2px solid #000;
  outline-offset: 2px;
}

/* Modal shell */
.dm-modal[hidden] {
  display: none;
}

.dm-modal {
  position: fixed;
  inset: 0;
  z-index: 99999;
}

.dm-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
}

.dm-modal-panel {
  position: relative;
  margin: 4vh auto;
  width: min(1180px, calc(100vw - 32px));
  max-height: 92vh;
  background: #fff;
  overflow: hidden;
  border: 1px solid #000;
}

.dm-modal-close {
  position: absolute;
  top: 18px;
  right: 18px;
  z-index: 50;
  border: 0;
  background: transparent;
  padding: 0;
  width: auto;
  height: auto;
  cursor: pointer;
  font-size: 34px;
  line-height: 1;
  font-weight: 300;
  color: #000;
}

.dm-modal-close:hover {
  background: transparent;
  color: #000;
  opacity: 1;
}

.dm-modal-close:focus-visible {
  outline: 2px solid #000;
  outline-offset: 4px;
}

/* Modal layout */
.dm-modal-grid {
  display: grid;
  grid-template-columns: 1fr;
  max-height: 92vh;
}

@media (min-width: 900px) {
  .dm-modal-grid {
    grid-template-columns: 1.05fr 0.95fr;
  }
}

/* Modal media column */
.dm-modal-media {
  padding: 28px 26px 22px;
  background: #fff;
  display: grid;
  gap: 14px;
  align-content: start;
}

.dm-modal-media-frame {
  position: relative;
  width: 100%;
  height: clamp(360px, 62vh, 640px);
  background: #f6f6f6;
  overflow: hidden;
}

.dm-modal-track {
  position: relative;
  width: 100%;
  height: 100%;
}

.dm-modal-media .dm-product-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  opacity: 0;
  transition: opacity 160ms linear;
  background: transparent;
}

.dm-modal-media .dm-product-img.is-active {
  opacity: 1;
}

.dm-modal-dots {
  position: absolute;
  left: 14px;
  right: 14px;
  bottom: 14px;
  display: flex;
  justify-content: center;
  gap: 6px;
  pointer-events: none;
}

.dm-modal .dm-carousel-btn {
  opacity: 1;
  pointer-events: auto;
  z-index: 5;
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid #000;
  color: #000;
}

/* Modal swatches live under the image */
.dm-modal-swatches--under {
  padding: 0;
}

.dm-modal-swatches--under:not(:has(.dm-swatch))::before {
  content: none;
}

.dm-modal-swatches--under:has(.dm-swatch)::before {
  content: "Color";
  display: block;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 10px;
  opacity: 0.55;
}

.dm-modal-swatches--under {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  justify-content: flex-start;
  align-items: center;
}

.dm-modal-swatches--under .dm-swatch {
  width: 26px;
  height: 26px;
  border: 1px solid #000;
}

/* Modal content column */
.dm-modal-content {
  padding: 34px 38px 26px;
  display: flex;
  flex-direction: column;
  max-height: 92vh;
}

.dm-modal-header {
  padding-right: 42px;
  display: grid;
  gap: 10px;
}

.dm-modal-title {
  margin: 0;
  font-size: 24px;
  font-weight: 500;
  line-height: 1.15;
}

.dm-modal-price {
  font-weight: 300;
  font-size: 15px;
  opacity: 0.75;
}

.dm-modal-body {
  margin-top: 22px;
  line-height: 1.6;
}

.dm-modal-body p {
  margin: 0 0 14px;
}

.dm-modal-actions {
  margin-top: auto;
  padding-top: 22px;
  display: flex;
  justify-content: flex-end;
  border-top: 1px solid rgba(0, 0, 0, 0.12);
}

.dm-modal-contact {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 10px 16px;
  border: 1px solid #000;
  background: #fff;
  color: #000;
  text-decoration: none;
  font-weight: 300;
  letter-spacing: 0.02em;
  cursor: pointer;
}

.dm-modal-contact:hover {
  background: #000;
  color: #fff;
}

.dm-modal-contact:focus-visible {
  outline: 2px solid #000;
  outline-offset: 2px;
}

/* Category tag on cards */
.dm-cat-tag {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 2;
  border: 1px solid #000;
  background: #fff;
  color: #000;
  padding: 6px 8px;
  font-size: 12px;
  font-weight: 400;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* Swatches */
.dm-swatch-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.dm-swatch {
  width: 22px;
  height: 22px;
  border: 1px solid #000;
  background: var(--dm-swatch-color, #fff);
  padding: 0;
  cursor: pointer;
  display: inline-block;
}

.dm-swatch.is-active {
  outline: 2px solid #000;
  outline-offset: 2px;
}

/* Screen-reader select used as the "source of truth" */
.dm-variant-select--sr {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

/* Carousel controls always visible on touch */
@media (hover: none),
(pointer: coarse) {
  .dm-carousel-btn {
    opacity: 1;
  }
}

/* Modal sizing tweaks */
.dm-modal-panel {
  width: min(1400px, calc(100vw - 64px));
  max-height: calc(100vh - 64px);
  margin: 32px auto;
}

@media (min-width: 900px) {
  .dm-modal-grid {
    grid-template-columns: 1.25fr 0.75fr;
  }
}

.dm-modal-media-frame {
  height: clamp(520px, 74vh, 820px);
}

.dm-modal-media {
  padding: 22px 22px 18px;
}

.dm-modal-content {
  padding: 28px 32px 24px;
}

.dm-modal .dm-carousel-btn {
  opacity: 0;
  transition: opacity 160ms linear;
}

@media (hover: hover) and (pointer: fine) {
  .dm-modal-media-frame:hover .dm-carousel-btn {
    opacity: 1;
  }
}

@media (hover: none),
(pointer: coarse) {
  .dm-modal .dm-carousel-btn {
    opacity: 1;
  }
}

/* Modal mobile layout */
@media (max-width: 899px) {
  .dm-modal-panel {
    width: calc(100vw - 24px);
    height: calc(100dvh - 24px);
    margin: 12px auto;
    display: flex;
    flex-direction: column;
  }

  .dm-modal-grid {
    grid-template-columns: 1fr;
    flex: 1;
    min-height: 0;
  }

  .dm-modal-media {
    padding: 14px 14px 10px;
    gap: 10px;
  }

  .dm-modal-media-frame {
    height: clamp(420px, 58vh, 620px);
  }

  .dm-modal-content {
    padding: 0;
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    position: relative;
  }

  .dm-modal-scroll {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 12px 16px 90px;
    /* space for button */
    min-height: 0;
  }

  .dm-modal-header {
    padding-right: 44px;
    gap: 6px;
    margin: 0 0 14px;
  }

  .dm-modal-title {
    font-size: 18px;
    line-height: 1.2;
  }

  .dm-modal-price {
    font-size: 14px;
    opacity: 0.75;
  }

  .dm-modal-body {
    margin: 0;
    line-height: 1.6;
  }

  .dm-modal-actions {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;

    padding: 12px 16px;
    background: #fff;
    border-top: 1px solid rgba(0, 0, 0, 0.12);

    z-index: 5;
  }

  .dm-modal-contact {
    width: 100%;
    min-height: 44px;
  }

  .dm-modal-swatches--under {
    gap: 12px;
  }
}

/* Categories filter */
.dm-filter {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.dm-filter-label {
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
}

.dm-filter-title {
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin: 0;
  line-height: 1;
}

.dm-filter-count {
  font-size: 12px;
  font-weight: 300;
  opacity: 0.75;
  line-height: 1;
}

.dm-filter-list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 14px;
}

.dm-filter-item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid #000;
  background: #fff;
  height: var(--dm-control-height);
  padding: 0 12px;
  cursor: pointer;
  user-select: none;
  font-weight: 300;
  font-size: 14px;
  line-height: 1;
}

.dm-filter-item input {
  accent-color: #000;
  margin: 0;
}

.dm-filter-item:focus-within {
  outline: 2px solid #000;
  outline-offset: 2px;
}

@media (hover: hover) and (pointer: fine) {
  .dm-filter-item:hover {
    background: #000;
    color: #fff;
  }

  .dm-filter-item:hover input {
    accent-color: #fff;
  }
}

@media (max-width: 540px) {
  .dm-filter-list {
    gap: 10px 10px;
  }

  .dm-filter-item {
    padding: 10px 10px;
  }
}

/* Sort control */
.dm-sort {
  display: grid;
  gap: 8px;
  justify-items: end;
  min-width: 0;
}

.dm-sort-label {
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin: 0;
  line-height: 1;
}

.dm-sort-select {
  width: 240px;
  height: var(--dm-control-height);
  max-width: 100%;
  border: 1px solid #000;
  background: #fff;
  color: #000;
  display: inline-flex;
  align-items: center;
  padding: 0 40px 0 12px;
  font-weight: 300;
  font-size: 14px;
  line-height: 1;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, #000 50%),
    linear-gradient(135deg, #000 50%, transparent 50%);
  background-position:
    calc(100% - 18px) 50%,
    calc(100% - 12px) 50%;
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
}

@media (max-width: 899px) {
  .dm-sort {
    justify-items: start;
  }

  .dm-sort-select {
    width: 100%;
  }
}

/* Swatches: keep color stable (protect against theme button:hover rules) */
.dm-shop .dm-swatch,
.dm-modal .dm-swatch {
  background-color: var(--dm-swatch-color, #fff) !important;
  background: var(--dm-swatch-color, #fff) !important;
  opacity: 1;
  filter: none;
}

.dm-modal-contact {
  display: inline-block;
  margin-top: 20px;
  padding: 12px 22px;
  border: 1px solid #000;
  background: #fff;
  color: #000;
  text-decoration: none;
  font-size: 12px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  transition: opacity 160ms ease, transform 160ms ease;
}

.dm-modal-contact:hover {
  opacity: 0.9;
  transform: translateY(-1px);
  background: #000;
  color: #fff;
}