.kpd-product-designer,
.kpd-modal {
  --kpd-bg: #eef1f3;
  --kpd-surface: #ffffff;
  --kpd-soft: #f6f8f9;
  --kpd-ink: #17201f;
  --kpd-muted: #62706c;
  --kpd-line: #d7dedb;
  --kpd-accent: #16705f;
  --kpd-accent-strong: #0e5346;
  --kpd-accent-soft: #e1f1ec;
  --kpd-danger: #aa3c2f;
  --kpd-warning: #a05a13;
  color: var(--kpd-ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.kpd-product-designer {
  margin: 18px 0;
}

.kpd-product-designer *,
.kpd-product-designer *::before,
.kpd-product-designer *::after,
.kpd-modal,
.kpd-modal *,
.kpd-modal *::before,
.kpd-modal *::after {
  box-sizing: border-box;
}

.kpd-product-designer [hidden],
.kpd-modal[hidden] {
  display: none !important;
}

.kpd-launch {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  padding: 14px;
  border: 1px solid var(--kpd-line);
  border-radius: 8px;
  background: var(--kpd-soft);
}

.kpd-open,
.kpd-save-design {
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  padding: 0 16px;
  background: var(--kpd-accent);
  color: #fff;
  cursor: pointer;
  font-weight: 800;
}

.kpd-launch-status,
.kpd-fee-note {
  color: var(--kpd-muted);
  font-size: 0.9rem;
  font-weight: 650;
}

.kpd-fee-note {
  color: var(--kpd-accent-strong);
}

.kpd-modal {
  position: fixed;
  inset: 0;
  z-index: 2147483647;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(17, 24, 23, 0.56);
}

.kpd-dialog {
  position: relative;
  z-index: 1;
  isolation: isolate;
  width: min(1440px, 96vw);
  height: min(900px, 94vh);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
  border-radius: 10px;
  background: var(--kpd-surface);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.24);
}

.kpd-topbar {
  min-height: 70px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--kpd-line);
}

.kpd-topbar strong {
  display: block;
  color: var(--kpd-ink);
  font-size: 1.05rem;
  line-height: 1.2;
}

.kpd-save-state {
  display: block;
  margin-top: 3px;
  color: var(--kpd-muted);
  font-size: 0.84rem;
}

.kpd-top-actions,
.kpd-zoom-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.kpd-top-actions {
  justify-content: flex-end;
  flex-wrap: wrap;
}

.kpd-icon-button,
.kpd-close,
.kpd-language-button,
.kpd-view,
.kpd-tool-grid button,
.kpd-layer-button,
.kpd-delete-layer,
.kpd-garment-color {
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  font: inherit;
}

.kpd-language-switch {
  display: flex;
  align-items: center;
  overflow: hidden;
  border: 1px solid var(--kpd-line);
  border-radius: 8px;
  background: var(--kpd-soft);
}

.kpd-language-button {
  min-height: 38px;
  padding: 0 10px;
  background: transparent;
  color: var(--kpd-muted);
  font-size: 0.78rem;
  font-weight: 850;
  white-space: nowrap;
}

.kpd-language-button.is-active {
  background: var(--kpd-accent);
  color: #fff;
}

.kpd-icon-button,
.kpd-close {
  width: 38px;
  height: 38px;
  display: inline-grid;
  place-items: center;
  padding: 0;
  border: 1px solid var(--kpd-line);
  background: var(--kpd-soft);
  color: var(--kpd-ink);
}

.kpd-icon-button.small {
  width: 31px;
  height: 31px;
}

.kpd-icon-button svg,
.kpd-close svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.kpd-workspace {
  min-height: 0;
  display: grid;
  grid-template-columns: 286px minmax(420px, 1fr) 320px;
  gap: 1px;
  background: var(--kpd-line);
}

.kpd-mobile-drawer {
  display: none;
}

.kpd-panel,
.kpd-canvas-stage {
  min-height: 0;
  background: var(--kpd-surface);
}

.kpd-panel {
  overflow: auto;
  padding: 18px;
}

.kpd-section {
  padding-bottom: 18px;
  margin-bottom: 18px;
  border-bottom: 1px solid var(--kpd-line);
}

.kpd-section:last-child {
  padding-bottom: 0;
  margin-bottom: 0;
  border-bottom: 0;
}

.kpd-section h3,
.kpd-section p {
  margin: 0;
}

.kpd-section h3 {
  color: var(--kpd-ink);
  font-size: 0.86rem;
  font-weight: 850;
}

.kpd-section p,
.kpd-selected-summary,
.kpd-canvas-toolbar span,
.kpd-size-readout,
.kpd-rotate-readout,
.kpd-zoom-label {
  color: var(--kpd-muted);
}

.kpd-section-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  margin-bottom: 12px;
}

.kpd-total-price {
  color: var(--kpd-accent-strong);
  font-weight: 850;
}

.kpd-product-tile {
  height: 150px;
  display: grid;
  place-items: center;
  margin-bottom: 12px;
  border: 1px solid var(--kpd-line);
  border-radius: 8px;
  background:
    linear-gradient(45deg, #edf1f0 25%, transparent 25%),
    linear-gradient(-45deg, #edf1f0 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #edf1f0 75%),
    linear-gradient(-45deg, transparent 75%, #edf1f0 75%);
  background-color: #f8faf9;
  background-position: 0 0, 0 8px, 8px -8px, -8px 0;
  background-size: 16px 16px;
}

.kpd-product-tile svg {
  width: 118px;
  height: 118px;
  stroke-width: 1.8;
}

.kpd-product-tile img {
  max-width: 138px;
  max-height: 138px;
  object-fit: contain;
}

.kpd-product-tile rect {
  fill: rgba(22, 112, 95, 0.08);
  stroke: var(--kpd-accent);
  stroke-dasharray: 5 4;
}

.kpd-choice-field {
  display: grid;
  gap: 7px;
  margin: 0 0 12px;
  color: var(--kpd-ink);
  font-size: 0.8rem;
  font-weight: 850;
}

.kpd-choice-field > span {
  display: block;
}

.kpd-garment-colors {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.kpd-garment-color {
  min-width: 0;
  min-height: 38px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 9px;
  border: 1px solid var(--kpd-line);
  background: var(--kpd-soft);
  color: var(--kpd-ink);
  text-align: left;
}

.kpd-garment-color span {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  border: 1px solid rgba(23, 32, 31, 0.24);
  border-radius: 999px;
  background: var(--kpd-swatch);
}

.kpd-garment-color strong {
  min-width: 0;
  overflow: hidden;
  font-size: 0.78rem;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.kpd-garment-color.is-active {
  border-color: var(--kpd-accent);
  background: var(--kpd-accent-soft);
  color: var(--kpd-accent-strong);
}

.kpd-segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  padding: 3px;
  border: 1px solid var(--kpd-line);
  border-radius: 8px;
  background: var(--kpd-soft);
}

.kpd-view {
  min-height: 34px;
  background: transparent;
  color: var(--kpd-ink);
  font-weight: 800;
}

.kpd-view.is-active {
  background: var(--kpd-surface);
  color: var(--kpd-accent-strong);
  box-shadow: 0 1px 3px rgba(20, 30, 28, 0.08);
}

.kpd-tool-grid {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.kpd-tool-grid button {
  min-height: 46px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 12px;
  border: 1px solid var(--kpd-line);
  background: var(--kpd-soft);
  color: var(--kpd-ink);
  font-weight: 800;
  text-align: left;
}

.kpd-tool-grid button > span:first-child {
  width: 24px;
  height: 24px;
  flex: 0 0 24px;
  display: inline-grid;
  place-items: center;
  color: var(--kpd-accent);
  font-weight: 900;
}

.kpd-tool-grid button > span:last-child {
  min-width: 0;
  flex: 1 1 auto;
  overflow: hidden;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
  word-break: keep-all;
  overflow-wrap: normal;
  writing-mode: horizontal-tb;
}

.kpd-delete-layer {
  padding: 6px 8px;
  background: transparent;
  color: var(--kpd-danger);
  font-weight: 850;
}

.kpd-layer-list {
  display: grid;
  gap: 7px;
}

.kpd-layer-button {
  width: 100%;
  min-height: 42px;
  display: grid;
  grid-template-columns: 26px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  padding: 8px;
  border: 1px solid var(--kpd-line);
  background: var(--kpd-soft);
  color: var(--kpd-ink);
  text-align: left;
}

.kpd-layer-button.is-active {
  border-color: var(--kpd-accent);
  background: var(--kpd-accent-soft);
}

.kpd-layer-type {
  width: 26px;
  height: 26px;
  display: inline-grid;
  place-items: center;
  border-radius: 6px;
  background: #fff;
  color: var(--kpd-accent);
  font-size: 0.75rem;
  font-weight: 900;
}

.kpd-layer-name {
  overflow: hidden;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.kpd-layer-meta {
  color: var(--kpd-muted);
  font-size: 0.76rem;
}

.kpd-canvas-stage {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  min-width: 0;
}

.kpd-canvas-toolbar {
  min-height: 58px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 0 18px;
  border-bottom: 1px solid var(--kpd-line);
}

.kpd-canvas-toolbar strong,
.kpd-canvas-toolbar span {
  display: block;
}

.kpd-canvas-toolbar span {
  margin-top: 3px;
  font-size: 0.82rem;
}

.kpd-zoom-label {
  min-width: 44px;
  text-align: center;
  font-size: 0.82rem;
  font-weight: 850;
}

.kpd-canvas-wrap {
  min-height: 0;
  display: grid;
  place-items: center;
  overflow: auto;
  padding: 18px;
  background:
    linear-gradient(45deg, rgba(23, 32, 31, 0.045) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(23, 32, 31, 0.045) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, rgba(23, 32, 31, 0.045) 75%),
    linear-gradient(-45deg, transparent 75%, rgba(23, 32, 31, 0.045) 75%);
  background-color: #f4f6f7;
  background-position: 0 0, 0 12px, 12px -12px, -12px 0;
  background-size: 24px 24px;
}

.kpd-canvas {
  width: min(700px, 100%);
  max-height: min(700px, calc(94vh - 190px));
  aspect-ratio: 1;
  display: block;
  touch-action: none;
  user-select: none;
  border: 1px solid var(--kpd-line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 18px 38px rgba(25, 34, 32, 0.08);
}

.kpd-warning-bar {
  min-height: 48px;
  display: flex;
  align-items: center;
  padding: 0 18px;
  border-top: 1px solid var(--kpd-line);
  color: var(--kpd-muted);
  font-size: 0.86rem;
}

.kpd-warning-bar.has-warning {
  background: #fff4dd;
  color: var(--kpd-warning);
}

.kpd-section label {
  display: grid;
  gap: 7px;
  margin: 0 0 12px;
  color: var(--kpd-ink);
  font-size: 0.8rem;
  font-weight: 850;
}

.kpd-section input,
.kpd-section textarea,
.kpd-section select {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--kpd-line);
  border-radius: 8px;
  background: var(--kpd-soft);
  color: var(--kpd-ink);
  padding: 8px 10px;
  outline: 0;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 650;
}

.kpd-section input:focus,
.kpd-section textarea:focus,
.kpd-section select:focus {
  border-color: var(--kpd-accent);
  box-shadow: 0 0 0 3px rgba(22, 112, 95, 0.12);
}

.kpd-rhinestone-text-entry {
  display: grid;
  gap: 9px;
  margin-bottom: 14px;
}

.kpd-rhinestone-text-entry > label {
  margin: 0;
}

.kpd-text-guidance-copy {
  display: grid;
  gap: 4px;
  padding: 9px 10px;
  border-left: 3px solid var(--kpd-accent);
  background: var(--kpd-accent-soft);
}

.kpd-text-requirements,
.kpd-text-layer-guidance {
  margin: 0;
  color: var(--kpd-ink);
  font-size: 0.8rem;
  line-height: 1.4;
}

.kpd-text-requirements {
  font-weight: 800;
}

.kpd-text-layer-guidance {
  color: var(--kpd-muted);
  font-weight: 650;
}

.kpd-add-another-rhinestone-text {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--kpd-accent);
  border-radius: 8px;
  background: #fff;
  color: var(--kpd-accent-strong);
  padding: 8px 12px;
  cursor: pointer;
  font: inherit;
  font-size: 0.82rem;
  font-weight: 850;
  line-height: 1.25;
}

.kpd-add-another-rhinestone-text:hover,
.kpd-add-another-rhinestone-text:focus-visible {
  background: var(--kpd-accent-soft);
  outline: 0;
  box-shadow: 0 0 0 3px rgba(22, 112, 95, 0.12);
}

.kpd-section input[type="color"] {
  height: 42px;
  padding: 5px;
}

.kpd-section input[type="range"] {
  min-height: 24px;
  padding: 0;
  accent-color: var(--kpd-accent);
  background: transparent;
}

.kpd-field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.kpd-rhinestone-controls {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--kpd-line);
  border-radius: 8px;
  background: var(--kpd-soft);
}

.kpd-rhinestone-controls label {
  margin-bottom: 0;
}

.kpd-stone-summary {
  color: var(--kpd-accent-strong);
  font-size: 0.8rem;
  font-weight: 850;
  line-height: 1.35;
}

.kpd-section input:disabled {
  opacity: 0.62;
  cursor: not-allowed;
}

.kpd-price-impact {
  margin-top: 10px;
  padding: 14px;
  border-radius: 8px;
  background: var(--kpd-accent-soft);
  color: var(--kpd-accent-strong);
  font-size: 1.35rem;
  font-weight: 900;
}

.kpd-price-impact strong,
.kpd-price-impact span {
  display: block;
}

.kpd-price-impact span {
  margin-top: 5px;
  font-size: 0.76rem;
  font-weight: 750;
  line-height: 1.35;
}

body.kpd-modal-open {
  overflow: hidden;
}

@media (max-width: 1100px) {
  .kpd-dialog {
    overflow: auto;
  }

  .kpd-workspace {
    display: block;
  }

  .kpd-panel,
  .kpd-canvas-stage {
    min-height: auto;
  }

  .kpd-canvas-stage {
    border-top: 1px solid var(--kpd-line);
    border-bottom: 1px solid var(--kpd-line);
  }

  .kpd-canvas {
    width: 100% !important;
    max-height: none;
  }
}

@media (max-width: 1100px) {
  .kpd-modal {
    padding: 0;
    background: #fff;
  }

  .kpd-dialog {
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    max-height: 100dvh;
    border-radius: 0;
    overflow: hidden;
  }

  .kpd-topbar {
    min-height: 86px;
    align-items: stretch;
    flex-direction: column;
    gap: 8px;
    padding: calc(8px + env(safe-area-inset-top)) 10px 8px;
  }

  .kpd-topbar strong {
    max-width: 100%;
    overflow: hidden;
    font-size: 0.92rem;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .kpd-save-state {
    display: none;
  }

  .kpd-top-actions {
    width: 100%;
    flex-wrap: nowrap;
    gap: 6px;
  }

  .kpd-language-button {
    min-height: 34px;
    padding: 0 8px;
    font-size: 0.72rem;
  }

  .kpd-icon-button,
  .kpd-close {
    width: 34px;
    height: 34px;
  }

  .kpd-save-design {
    min-height: 34px;
    flex: 1 1 auto;
    padding: 0 10px;
    font-size: 0.82rem;
    white-space: nowrap;
  }

  .kpd-workspace {
    height: 100%;
    display: grid;
    grid-template-columns: 1fr;
    grid-template-rows: minmax(0, 1fr) auto minmax(132px, 20vh);
    overflow: hidden;
  }

  .kpd-canvas-stage {
    order: 1;
    min-height: 0;
  }

  .kpd-left-panel {
    order: 2;
    max-height: 148px;
    display: flex;
    flex-direction: column;
    border-top: 1px solid var(--kpd-line);
  }

  .kpd-inspector-panel {
    order: 3;
    border-top: 1px solid var(--kpd-line);
  }

  .kpd-panel {
    min-height: 0;
    overflow: auto;
    padding: 10px;
    overscroll-behavior: contain;
  }

  .kpd-canvas-toolbar {
    min-height: 44px;
    align-items: center;
    flex-direction: row;
    gap: 8px;
    padding: 7px 10px;
  }

  .kpd-canvas-toolbar strong {
    max-width: 56vw;
    overflow: hidden;
    font-size: 0.86rem;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .kpd-canvas-toolbar span:not(.kpd-zoom-label) {
    display: none;
  }

  .kpd-zoom-controls {
    gap: 5px;
  }

  .kpd-zoom-label {
    min-width: 38px;
    font-size: 0.78rem;
  }

  .kpd-canvas-wrap {
    overflow: hidden;
    padding: 8px;
  }

  .kpd-canvas {
    width: min(100%, calc(100dvh - 448px)) !important;
    min-width: 214px;
    max-width: 100%;
    max-height: 100%;
    border-radius: 6px;
    box-shadow: 0 10px 22px rgba(25, 34, 32, 0.08);
  }

  .kpd-warning-bar {
    min-height: 34px;
    padding: 0 10px;
    font-size: 0.76rem;
  }

  .kpd-section {
    padding-bottom: 10px;
    margin-bottom: 10px;
  }

  .kpd-section-head {
    margin-bottom: 8px;
  }

  .kpd-section h3 {
    font-size: 0.8rem;
  }

  .kpd-left-panel .kpd-product-tile {
    display: none;
  }

  .kpd-left-panel .kpd-section:nth-child(2) {
    order: 1;
  }

  .kpd-left-panel .kpd-section:nth-child(1) {
    order: 2;
  }

  .kpd-left-panel .kpd-section:nth-child(3) {
    order: 3;
  }

  .kpd-choice-field {
    gap: 5px;
    margin-bottom: 8px;
    font-size: 0.74rem;
  }

  .kpd-garment-colors {
    display: flex;
    gap: 7px;
    overflow-x: auto;
    padding-bottom: 3px;
    scrollbar-width: none;
  }

  .kpd-garment-colors::-webkit-scrollbar,
  .kpd-tool-grid::-webkit-scrollbar,
  .kpd-layer-list::-webkit-scrollbar {
    display: none;
  }

  .kpd-garment-color {
    width: 42px;
    min-width: 42px;
    min-height: 38px;
    justify-content: center;
    padding: 0;
  }

  .kpd-garment-color span {
    width: 22px;
    height: 22px;
  }

  .kpd-garment-color strong {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }

  .kpd-segmented {
    grid-template-columns: repeat(2, minmax(82px, 1fr));
  }

  .kpd-view {
    min-height: 32px;
    font-size: 0.78rem;
  }

  .kpd-tool-grid {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 3px;
  }

  .kpd-tool-grid button {
    min-width: 112px;
    min-height: 54px;
    flex-direction: column;
    justify-content: center;
    gap: 4px;
    padding: 6px;
    font-size: 0.72rem;
    text-align: center;
  }

  .kpd-tool-grid button > span:first-child {
    width: auto;
    height: auto;
    flex-basis: auto;
  }

  .kpd-tool-grid button > span:last-child {
    max-width: 100%;
  }

  .kpd-layer-list {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 3px;
  }

  .kpd-layer-button {
    min-width: 164px;
  }

  .kpd-delete-layer {
    padding: 4px 6px;
    font-size: 0.78rem;
  }

  .kpd-inspector-panel .kpd-text-controls,
  .kpd-inspector-panel .kpd-shared-controls {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 9px;
  }

  .kpd-inspector-panel .kpd-text-controls label:first-child,
  .kpd-rhinestone-controls {
    grid-column: 1 / -1;
  }

  .kpd-section label {
    gap: 5px;
    margin-bottom: 0;
    font-size: 0.74rem;
  }

  .kpd-section input,
  .kpd-section textarea,
  .kpd-section select {
    min-height: 34px;
    padding: 6px 8px;
    font-size: 0.84rem;
  }

  .kpd-section textarea {
    min-height: 56px;
  }

  .kpd-rhinestone-controls {
    gap: 8px;
    padding: 9px;
  }

  .kpd-price-impact {
    margin-top: 8px;
    padding: 10px;
    font-size: 1rem;
  }

  body.kpd-modal-open {
    position: fixed;
    inset: 0;
    width: 100%;
    overflow: hidden;
  }
}

@media (max-width: 390px) {
  .kpd-topbar {
    min-height: 82px;
  }

  .kpd-language-button {
    padding: 0 6px;
  }

  .kpd-icon-button,
  .kpd-close {
    width: 32px;
    height: 32px;
  }

  .kpd-save-design {
    min-width: 76px;
    padding: 0 8px;
  }

  .kpd-left-panel {
    max-height: 136px;
  }

  .kpd-canvas {
    width: min(100%, calc(100dvh - 426px)) !important;
    min-width: 196px;
  }
}

@media (max-width: 768px) {
  body.woocommerce-cart .woocommerce-cart-form table.shop_table_responsive tr.kpd-cart-item-has-design,
  body.woocommerce-cart .woocommerce-cart-form table.shop_table tr.kpd-cart-item-has-design {
    display: grid !important;
    grid-template-columns: 84px minmax(0, 1fr);
    grid-template-areas: "thumbnail product";
    gap: 10px;
    width: 100%;
    padding: 16px 0;
    box-sizing: border-box;
  }

  body.woocommerce-cart tr.kpd-cart-item-has-design > td,
  body.woocommerce-cart tr.kpd-cart-item-has-design > th {
    display: block !important;
    width: auto !important;
    min-width: 0 !important;
    padding: 0 !important;
    border: 0 !important;
    box-sizing: border-box;
  }

  body.woocommerce-cart tr.kpd-cart-item-has-design > td::before,
  body.woocommerce-cart tr.kpd-cart-item-has-design > th::before {
    display: none !important;
  }

  body.woocommerce-cart tr.kpd-cart-item-has-design .product-thumbnail {
    grid-area: thumbnail;
    align-self: start;
  }

  body.woocommerce-cart tr.kpd-cart-item-has-design .product-thumbnail a,
  body.woocommerce-cart tr.kpd-cart-item-has-design .product-thumbnail img {
    display: block !important;
    width: 84px !important;
    max-width: 84px !important;
    height: auto !important;
    margin: 0 !important;
  }

  body.woocommerce-cart tr.kpd-cart-item-has-design .product-name {
    grid-area: product;
    overflow-wrap: anywhere;
  }

  body.woocommerce-cart tr.kpd-cart-item-has-design > .product-price,
  body.woocommerce-cart tr.kpd-cart-item-has-design > .product-quantity,
  body.woocommerce-cart tr.kpd-cart-item-has-design > .product-subtotal,
  body.woocommerce-cart tr.kpd-cart-item-has-design > .product-remove {
    display: none !important;
  }

  body.woocommerce-cart tr.kpd-cart-item-has-design .kpd-cart-design-summary {
    width: 100%;
    margin-top: 10px !important;
    padding: 10px !important;
    box-sizing: border-box;
  }

  body.woocommerce-cart tr.kpd-cart-item-has-design .kpd-cart-design-summary > div {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) !important;
    gap: 1px !important;
  }

  body.woocommerce-cart tr.kpd-cart-item-has-design .kpd-cart-design-summary strong {
    min-width: 0 !important;
  }
}

@media (max-height: 700px) and (max-width: 1100px) {
  .kpd-workspace {
    grid-template-rows: minmax(260px, auto) auto minmax(112px, auto);
    overflow-y: auto;
  }

  .kpd-canvas-stage {
    min-height: 260px;
  }

  .kpd-topbar {
    min-height: 76px;
  }

  .kpd-left-panel {
    min-height: 124px;
    max-height: 124px;
  }

  .kpd-inspector-panel {
    padding: 8px;
  }

  .kpd-canvas {
    width: min(100%, calc(100dvh - 400px)) !important;
    min-width: 168px;
  }
}

/* Saved-design preview and purchase workflow. */
.kpd-modal [hidden] {
  display: none !important;
}

.kpd-required-message {
  margin: 8px 0 0;
  color: var(--kpd-danger);
  font-size: 0.84rem;
  font-weight: 750;
}

.kpd-saved-confirmation {
  display: grid;
  grid-template-columns: 84px minmax(0, 1fr);
  gap: 14px;
  align-items: center;
  margin-top: 10px;
  padding: 12px 14px;
  border-left: 4px solid var(--kpd-accent);
  background: var(--kpd-accent-soft);
}

.kpd-saved-confirmation img {
  width: 84px;
  height: 84px;
  object-fit: contain;
  background: #fff;
}

.kpd-saved-confirmation strong,
.kpd-saved-confirmation p {
  display: block;
  margin: 0;
}

.kpd-saved-confirmation p {
  margin-top: 4px;
  color: var(--kpd-muted);
  font-size: 0.84rem;
  line-height: 1.55;
}

.kpd-preview-design,
.kpd-preview-save,
.kpd-designer-add-cart {
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  padding: 0 16px;
  background: var(--kpd-accent);
  color: #fff;
  cursor: pointer;
  font: inherit;
  font-weight: 800;
}

.kpd-modal.is-preview-mode .kpd-undo,
.kpd-modal.is-preview-mode .kpd-redo,
.kpd-modal.is-preview-mode .kpd-preview-design,
.kpd-modal.is-preview-mode .kpd-save-design {
  display: none;
}

.kpd-preview-design,
.kpd-preview-save {
  border: 1px solid var(--kpd-accent);
  background: #fff;
  color: var(--kpd-accent-strong);
}

.kpd-preview-mode {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  overflow: auto;
  background: #f4f6f5;
}

.kpd-preview-mode.has-purchase-sidebar {
  grid-template-columns: minmax(0, 1fr) minmax(360px, 430px);
}

.kpd-preview-product {
  min-width: 0;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  gap: 14px;
  padding: 20px;
}

.kpd-preview-side-switch {
  grid-row: 2;
  width: min(340px, 100%);
  display: grid;
  grid-template-columns: 1fr 1fr;
  justify-self: center;
  padding: 3px;
  border: 1px solid var(--kpd-line);
  border-radius: 8px;
  background: #fff;
}

.kpd-preview-side {
  min-height: 38px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--kpd-ink);
  cursor: pointer;
  font: inherit;
  font-weight: 800;
}

.kpd-preview-side.is-active {
  background: var(--kpd-accent);
  color: #fff;
}

.kpd-preview-image-wrap {
  grid-row: 3;
  min-height: 0;
  display: grid;
  place-items: center;
  overflow: hidden;
}

.kpd-preview-image {
  width: min(680px, 100%);
  max-height: calc(94vh - 220px);
  aspect-ratio: 1;
  object-fit: contain;
  background: #fff;
}

.kpd-preview-actions {
  grid-row: 1;
  width: min(360px, 100%);
  display: flex;
  align-items: stretch;
  justify-content: center;
  justify-self: center;
  gap: 10px;
}

.kpd-preview-actions .kpd-return-editor,
.kpd-preview-actions .kpd-preview-save {
  min-width: 0;
  height: 42px;
  min-height: 42px;
  display: inline-flex;
  flex: 1 1 0;
  align-items: center;
  justify-content: center;
  padding: 0 12px;
  font-size: 0.9rem;
  line-height: 1.2;
  white-space: nowrap;
}

.kpd-preview-actions .kpd-preview-save {
  border-color: var(--kpd-accent);
  background: var(--kpd-accent);
  color: #fff;
}

.kpd-return-editor,
.kpd-add-variation-row,
.kpd-continue-shopping,
.kpd-view-cart {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 15px;
  border: 1px solid var(--kpd-line);
  border-radius: 8px;
  background: #fff;
  color: var(--kpd-ink);
  cursor: pointer;
  font: inherit;
  font-weight: 800;
  text-decoration: none;
}

.kpd-purchase-panel {
  overflow: auto;
  padding: 20px;
  border-left: 1px solid var(--kpd-line);
  background: #fff;
}

.kpd-purchase-panel h3,
.kpd-order-summary h3 {
  margin: 18px 0 10px;
  font-size: 0.92rem;
}

.kpd-save-confirmation {
  padding: 12px 0 14px;
  border-bottom: 1px solid var(--kpd-line);
}

.kpd-save-confirmation strong,
.kpd-save-confirmation p {
  display: block;
  margin: 0;
}

.kpd-save-confirmation strong {
  color: var(--kpd-accent-strong);
}

.kpd-save-confirmation p {
  margin-top: 5px;
  color: var(--kpd-muted);
  font-size: 0.82rem;
  line-height: 1.55;
}

.kpd-variation-rows {
  display: grid;
  gap: 9px;
}

.kpd-variation-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(86px, 0.7fr) 76px 34px;
  gap: 7px;
  align-items: end;
  padding-bottom: 9px;
  border-bottom: 1px solid var(--kpd-line);
}

.kpd-variation-row label {
  min-width: 0;
  display: grid;
  gap: 4px;
  margin: 0;
  color: var(--kpd-muted);
  font-size: 0.72rem;
  font-weight: 750;
}

.kpd-variation-row select,
.kpd-variation-row input {
  width: 100%;
  min-width: 0;
  min-height: 38px;
  padding: 7px 8px;
  border: 1px solid var(--kpd-line);
  border-radius: 7px;
  background: var(--kpd-soft);
  color: var(--kpd-ink);
  font: inherit;
}

.kpd-remove-row {
  width: 34px;
  height: 38px;
  border: 1px solid var(--kpd-line);
  border-radius: 7px;
  background: #fff;
  color: var(--kpd-danger);
  cursor: pointer;
  font-size: 1.3rem;
}

.kpd-add-variation-row {
  width: 100%;
  margin-top: 10px;
  border-style: dashed;
}

.kpd-contrast-warning {
  margin-top: 12px;
  padding: 10px 12px;
  border-left: 3px solid var(--kpd-warning);
  background: #fff4dd;
  color: #7b430d;
  font-size: 0.8rem;
  font-weight: 750;
  line-height: 1.45;
}

.kpd-order-summary {
  margin-top: 16px;
  padding-top: 1px;
  border-top: 1px solid var(--kpd-line);
}

.kpd-order-summary-content {
  font-size: 0.78rem;
}

.kpd-summary-preview {
  width: 100%;
  max-height: 180px;
  object-fit: contain;
  background: var(--kpd-soft);
}

.kpd-order-summary dl,
.kpd-order-summary ul {
  margin: 10px 0 0;
}

.kpd-order-summary dl > div {
  display: grid;
  grid-template-columns: minmax(110px, 0.8fr) minmax(0, 1.2fr);
  gap: 10px;
  padding: 6px 0;
  border-bottom: 1px solid #edf0ef;
}

.kpd-order-summary dt {
  color: var(--kpd-muted);
  font-weight: 700;
}

.kpd-order-summary dd {
  margin: 0;
  text-align: right;
  overflow-wrap: anywhere;
}

.kpd-order-summary .kpd-summary-total {
  color: var(--kpd-accent-strong);
  font-size: 0.92rem;
  font-weight: 900;
}

.kpd-order-summary ul {
  padding-left: 18px;
  color: var(--kpd-muted);
}

.kpd-purchase-status {
  min-height: 22px;
  margin-top: 12px;
  color: var(--kpd-accent-strong);
  font-size: 0.8rem;
  font-weight: 750;
}

.kpd-designer-add-cart {
  width: 100%;
  min-height: 50px;
  margin-top: 7px;
}

.kpd-designer-add-cart:disabled,
.kpd-preview-save:disabled,
.kpd-save-design:disabled {
  opacity: 0.55;
  cursor: wait;
}

.kpd-cart-success {
  align-self: center;
  margin: 30px 20px;
  padding: 22px;
  border-left: 4px solid var(--kpd-accent);
  background: #fff;
}

.kpd-cart-success strong,
.kpd-cart-success p {
  display: block;
  margin: 0;
}

.kpd-cart-success p {
  margin-top: 6px;
  color: var(--kpd-muted);
}

.kpd-cart-success > div {
  display: flex;
  gap: 9px;
  margin-top: 16px;
}

.kpd-view-cart {
  border-color: var(--kpd-accent);
  background: var(--kpd-accent);
  color: #fff;
}

@media (max-width: 1100px) {
  .kpd-preview-mode,
  .kpd-preview-mode.has-purchase-sidebar {
    grid-template-columns: 1fr;
  }

  .kpd-preview-image {
    max-height: 66vh;
  }

  .kpd-purchase-panel {
    overflow: visible;
    border-top: 1px solid var(--kpd-line);
    border-left: 0;
  }
}

@media (max-width: 1100px) {
  .kpd-dialog {
    grid-template-columns: minmax(0, 1fr);
  }

  .kpd-topbar,
  .kpd-top-actions,
  .kpd-workspace,
  .kpd-canvas-stage,
  .kpd-garment-colors {
    min-width: 0;
    max-width: 100%;
  }

  .kpd-garment-colors {
    width: 100%;
  }

  .kpd-save-design {
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .kpd-preview-design {
    min-height: 34px;
    padding: 0 9px;
    font-size: 0.78rem;
  }

  .kpd-preview-mode {
    display: block;
    overflow: auto;
  }

  .kpd-preview-product,
  .kpd-purchase-panel {
    padding: 12px;
  }

  .kpd-preview-image {
    width: 100%;
    max-height: none;
  }

  .kpd-preview-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .kpd-preview-actions .kpd-return-editor,
  .kpd-preview-actions .kpd-preview-save {
    min-width: 0;
  }

  .kpd-variation-row {
    grid-template-columns: minmax(0, 1fr) minmax(78px, 0.72fr) 66px 34px;
    gap: 5px;
  }

  .kpd-variation-row select,
  .kpd-variation-row input {
    padding: 6px;
    font-size: 0.78rem;
  }

  .kpd-cart-success > div {
    display: grid;
  }
}

@media (max-width: 340px) {
  .kpd-preview-actions {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 390px) {
  .kpd-topbar {
    min-height: 118px;
  }

  .kpd-top-actions {
    display: grid;
    grid-template-columns: max-content 32px 32px minmax(0, 1fr) 32px;
    grid-template-rows: 34px 34px;
    gap: 6px;
  }

  .kpd-language-switch {
    grid-column: 1;
    grid-row: 1;
  }

  .kpd-undo {
    grid-column: 2;
    grid-row: 1;
  }

  .kpd-redo {
    grid-column: 3;
    grid-row: 1;
  }

  .kpd-close {
    grid-column: 5;
    grid-row: 1;
  }

  .kpd-preview-design {
    grid-column: 1 / span 2;
    grid-row: 2;
  }

  .kpd-save-design {
    grid-column: 3 / span 3;
    grid-row: 2;
  }

  .kpd-preview-design,
  .kpd-save-design {
    width: 100%;
    min-width: 0;
    min-height: 34px;
    padding: 0 8px;
  }

  .kpd-modal.is-preview-mode .kpd-topbar {
    min-height: 82px;
  }

  .kpd-modal.is-preview-mode .kpd-top-actions {
    display: flex;
    justify-content: space-between;
  }
}

/* Mobile and tablet editor: one canvas with a single horizontal tool drawer. */
@media (max-width: 1100px) {
  .kpd-workspace {
    height: 100%;
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr) auto;
    overflow: hidden;
  }

  .kpd-left-panel,
  .kpd-inspector-panel {
    display: none;
  }

  .kpd-canvas-stage {
    grid-row: 1;
    order: 0;
    min-height: 0;
    border-top: 0;
    border-bottom: 0;
  }

  .kpd-canvas-wrap {
    min-height: 0;
    overflow: hidden;
  }

  .kpd-canvas {
    width: min(100%, max(140px, calc(100dvh - 405px))) !important;
    height: auto;
    min-width: 0;
    max-width: 100%;
    max-height: 100%;
  }

  .kpd-mobile-drawer {
    grid-row: 2;
    min-width: 0;
    display: grid;
    grid-template-rows: 166px minmax(54px, auto);
    overflow: hidden;
    border-top: 1px solid var(--kpd-line);
    background: var(--kpd-surface);
  }

  .kpd-mobile-drawer-content {
    min-width: 0;
    min-height: 0;
    display: flex;
    align-items: stretch;
    gap: 12px;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 10px 12px;
    scroll-behavior: smooth;
    scrollbar-width: none;
    overscroll-behavior-x: contain;
    -webkit-overflow-scrolling: touch;
  }

  .kpd-mobile-drawer-content::-webkit-scrollbar,
  .kpd-mobile-drawer-track::-webkit-scrollbar {
    display: none;
  }

  .kpd-mobile-drawer-content > .kpd-section {
    min-width: 0;
    flex: 0 0 auto;
    padding: 0;
    margin: 0;
    border: 0;
  }

  .kpd-mobile-drawer-content .kpd-section h3 {
    font-size: 0.76rem;
  }

  .kpd-mobile-drawer-content .kpd-section-head {
    margin-bottom: 7px;
  }

  .kpd-mobile-drawer-content .kpd-product-tile,
  .kpd-mobile-drawer-content .kpd-mobile-panel-product > .kpd-section-head {
    display: none;
  }

  .kpd-mobile-drawer-content .kpd-mobile-panel-product {
    width: max(100%, 680px);
    display: grid;
    grid-template-columns: 150px minmax(330px, 1fr) 174px;
    gap: 12px;
    align-items: end;
  }

  .kpd-mobile-drawer-content .kpd-mobile-panel-product .kpd-choice-field {
    min-width: 0;
    margin: 0;
  }

  .kpd-mobile-drawer-content .kpd-garment-colors {
    width: 100%;
    display: flex;
    gap: 7px;
    overflow-x: visible;
    padding: 0;
  }

  .kpd-mobile-drawer-content .kpd-segmented {
    min-width: 174px;
  }

  .kpd-mobile-drawer-content .kpd-mobile-panel-add,
  .kpd-mobile-drawer-content .kpd-mobile-panel-layers {
    width: max(100%, 430px);
  }

  .kpd-mobile-drawer-content .kpd-mobile-panel-add > h3 {
    margin-bottom: 7px;
  }

  .kpd-mobile-drawer-content .kpd-tool-grid,
  .kpd-mobile-drawer-content .kpd-layer-list {
    display: flex;
    gap: 8px;
    overflow: visible;
    padding: 0;
    margin: 0;
  }

  .kpd-mobile-drawer-content .kpd-tool-grid button {
    min-width: 124px;
    min-height: 92px;
  }

  .kpd-mobile-drawer-content .kpd-layer-button {
    min-width: 172px;
    min-height: 84px;
  }

  .kpd-mobile-drawer-content .kpd-mobile-panel-selection {
    width: 112px;
    padding-right: 8px;
    border-right: 1px solid var(--kpd-line);
  }

  .kpd-mobile-drawer-content .kpd-mobile-panel-selection p {
    margin-top: 7px;
    font-size: 0.8rem;
    line-height: 1.35;
  }

  .kpd-mobile-drawer-content .kpd-text-controls,
  .kpd-mobile-drawer-content .kpd-shared-controls {
    width: max-content;
    display: flex;
    align-items: flex-start;
    gap: 10px;
  }

  .kpd-mobile-drawer-content .kpd-text-controls > label,
  .kpd-mobile-drawer-content .kpd-shared-controls > label {
    width: 184px;
    flex: 0 0 184px;
    margin: 0;
  }

  .kpd-mobile-drawer-content .kpd-rhinestone-text-entry {
    width: 500px;
    flex: 0 0 500px;
    display: grid;
    grid-template-columns: 270px 220px;
    grid-template-rows: auto 1fr;
    align-items: start;
    column-gap: 10px;
    row-gap: 6px;
    margin: 0;
  }

  .kpd-mobile-drawer-content .kpd-rhinestone-text-entry > label {
    width: 270px;
    grid-column: 1;
    grid-row: 1;
  }

  .kpd-mobile-drawer-content .kpd-text-guidance-copy {
    grid-column: 1;
    grid-row: 2;
    gap: 2px;
    padding: 6px 8px;
  }

  .kpd-mobile-drawer-content .kpd-text-requirements,
  .kpd-mobile-drawer-content .kpd-text-layer-guidance {
    font-size: 0.68rem;
    line-height: 1.25;
  }

  .kpd-mobile-drawer-content .kpd-add-another-rhinestone-text {
    width: 220px;
    min-height: 72px;
    grid-column: 2;
    grid-row: 1 / span 2;
    align-self: center;
  }

  .kpd-mobile-drawer-content .kpd-rhinestone-controls {
    width: 268px;
    flex: 0 0 268px;
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 6px;
    padding: 8px;
  }

  .kpd-mobile-drawer-content .kpd-stone-summary {
    font-size: 0.72rem;
  }

  .kpd-mobile-drawer-content .kpd-shared-controls > label:nth-child(2),
  .kpd-mobile-drawer-content .kpd-shared-controls > label:nth-child(3) {
    width: 220px;
    flex-basis: 220px;
  }

  .kpd-mobile-drawer-content .kpd-shared-controls > label:first-child {
    width: 92px;
    flex-basis: 92px;
  }

  .kpd-mobile-drawer-content .kpd-field-row {
    width: 176px;
    flex: 0 0 176px;
  }

  .kpd-mobile-drawer-content .kpd-mobile-panel-price {
    width: max(100%, 430px);
    display: grid;
    grid-template-columns: 110px minmax(180px, 240px) minmax(220px, 1fr);
    align-items: center;
    gap: 12px;
  }

  .kpd-mobile-drawer-content .kpd-price-impact {
    margin: 0;
  }

  .kpd-mobile-drawer-content .kpd-mobile-panel-price > p {
    font-size: 0.76rem;
    line-height: 1.4;
  }

  .kpd-mobile-drawer-bar {
    min-width: 0;
    display: grid;
    grid-template-columns: 46px minmax(0, 1fr) 46px;
    align-items: center;
    gap: 4px;
    padding: 4px 6px calc(4px + env(safe-area-inset-bottom));
    border-top: 1px solid var(--kpd-line);
    background: #fff;
  }

  .kpd-mobile-drawer-arrow {
    width: 44px;
    height: 44px;
    display: grid;
    place-items: center;
    padding: 0;
    border: 1px solid var(--kpd-accent);
    border-radius: 6px;
    background: #fff;
    color: var(--kpd-accent-strong);
  }

  .kpd-mobile-drawer-arrow svg {
    width: 24px;
    height: 24px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2.4;
    stroke-linecap: round;
    stroke-linejoin: round;
  }

  .kpd-mobile-drawer-arrow:focus-visible,
  .kpd-mobile-drawer-track button:focus-visible {
    outline: 3px solid rgba(22, 112, 95, 0.24);
    outline-offset: 1px;
  }

  .kpd-mobile-drawer-arrow:disabled {
    opacity: 0.32;
    cursor: default;
  }

  .kpd-mobile-drawer-track {
    min-width: 0;
    display: flex;
    align-items: stretch;
    gap: 4px;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-behavior: smooth;
    scrollbar-width: none;
    scroll-snap-type: x proximity;
    overscroll-behavior-x: contain;
    -webkit-overflow-scrolling: touch;
  }

  .kpd-mobile-drawer-track button {
    min-width: 92px;
    min-height: 44px;
    flex: 0 0 92px;
    padding: 0 10px;
    scroll-snap-align: center;
    border: 0;
    border-bottom: 3px solid transparent;
    border-radius: 4px 4px 0 0;
    background: transparent;
    color: var(--kpd-muted);
    font-size: 0.78rem;
    font-weight: 850;
    white-space: nowrap;
  }

  .kpd-mobile-drawer-track button.is-active {
    border-bottom-color: var(--kpd-accent);
    background: var(--kpd-accent-soft);
    color: var(--kpd-accent-strong);
  }
}

@media (max-height: 700px) and (max-width: 1100px) {
  .kpd-workspace {
    grid-template-rows: minmax(0, 1fr) auto;
    overflow: hidden;
  }

  .kpd-mobile-drawer {
    grid-template-rows: 146px minmax(54px, auto);
  }

  .kpd-mobile-drawer-content {
    padding-top: 8px;
    padding-bottom: 8px;
  }

  .kpd-mobile-drawer-content .kpd-tool-grid button {
    min-height: 78px;
  }
}
