.cve-personaliser {
  --cve-paper: #fbf7f1;
  --cve-line: #d8cfbf;
  --cve-ink: #241c14;
  --cve-accent: #2b241d;
  border: 1px solid var(--cve-line);
  border-radius: 18px;
  padding: 20px;
  margin: 20px 0;
  background: linear-gradient(180deg, #fffefb 0%, var(--cve-paper) 100%);
  color: var(--cve-ink);
}

.cve-personaliser.cve-display-popup {
  border: 0;
  padding: 0;
  margin: 0;
  background: transparent;
}

.cve-fields-panel {
  min-width: 0;
}

.cve-fields-panel > :last-child {
  margin-bottom: 0 !important;
}

.cve-await-variation {
  padding: 16px 18px;
  border: 1px dashed #cfc4b6;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.76);
  color: #6d614f;
}

.cve-fields-panel h3 {
  margin: 0 0 12px;
  font-size: 22px;
}

.cve-font-choice-group {
  margin-bottom: 14px;
}

.cve-font-choice-group > label {
  display: block;
  margin-bottom: 8px;
}

.cve-inline-font-picker {
  margin-bottom: 14px;
}

.cve-font-picker-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  padding: 14px 16px;
  border: 1px solid #cfc4b6;
  border-radius: 12px;
  background: #fffefb;
  color: #111111;
  text-align: left;
  cursor: pointer;
  font-family: inherit !important;
  text-transform: none !important;
  letter-spacing: 0 !important;
  font-variant: normal !important;
}

.cve-font-picker-text {
  flex: 1 1 auto;
  min-width: 0;
  font-weight: 500;
  font-family: inherit !important;
  text-align: left;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-transform: none !important;
  letter-spacing: 0 !important;
  font-variant: normal !important;
}

.cve-font-picker-arrow {
  flex: 0 0 auto;
  font-size: 22px;
  line-height: 1;
  font-family: inherit !important;
}

.cve-inline-font-picker.is-open .cve-font-picker-arrow {
  transform: rotate(45deg);
}

.cve-font-picker-panel {
  margin-top: 12px;
}

.cve-font-choice-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
}

.cve-font-choice {
  position: relative;
  display: flex;
  align-items: stretch;
  width: 100%;
}

.cve-font-choice input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.cve-font-choice span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  width: 100%;
  min-width: 0;
  min-height: 54px;
  padding: 10px 14px;
  border: 1px solid #cfc4b6;
  border-radius: 12px;
  background: #fff;
  color: #111111;
  text-align: center;
  line-height: 1.2;
  white-space: normal;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease, color 0.2s ease;
}

.cve-font-choice input:checked + span {
  border-color: #7a1f3d;
  box-shadow: 0 0 0 2px rgba(122, 31, 61, 0.14);
  background: #7a1f3d;
  color: #ffffff;
}

.cve-font-choice-list-radio {
  grid-template-columns: 1fr;
}

.cve-font-choice-list-radio .cve-font-choice span {
  justify-content: center;
  min-width: 0;
}

.cve-zone-field,
.cve-personaliser .form-row {
  margin-bottom: 14px;
}

.cve-text-fields {
  display: grid;
  gap: 14px 16px;
  margin: 0;
}

.cve-text-fields .cve-zone-field {
  margin-bottom: 0;
}

.cve-symbol-row {
  margin-bottom: 14px;
}

.cve-personaliser .cve-symbol-row,
.cve-modal .cve-symbol-row,
.cve-personaliser #cve_symbol,
.cve-modal #cve_symbol {
  display: none !important;
}

.cve-personaliser.cve-display-inline .cve-text-fields {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: start;
}

.cve-personaliser textarea,
.cve-personaliser select,
.cve-modal textarea,
.cve-modal select {
  width: 100%;
  border-radius: 12px;
  border: 1px solid #cfc4b6;
  background: #fffefb;
  color: #111111;
  padding: 14px 12px 16px;
}

.cve-personaliser textarea,
.cve-modal textarea {
  height: auto !important;
  min-height: 0 !important;
  max-height: none;
  resize: vertical;
  line-height: 1.28;
}

.cve-counter {
  color: #706354;
  font-size: 12px;
}

.cve-preview-wrap {
  margin-top: 16px;
}

.cve-preview-base {
  position: relative;
  width: 100%;
  max-width: 680px;
  overflow: hidden;
  border-radius: 16px;
  background: #f4eee3;
  box-shadow: 0 20px 50px rgba(21, 16, 11, 0.12);
}

.cve-preview-base img {
  width: 100%;
  height: auto;
  display: block;
}

.cve-preview-text {
  position: absolute;
  transform: translate(-50%, -50%);
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  line-height: 1.22;
  white-space: pre-line;
  word-break: normal;
  overflow-wrap: normal;
  hyphens: none;
  font-weight: 600;
  color: #111111;
  text-shadow:
    -0.5px -0.5px 0 rgba(255, 255, 255, 0.34),
    0.5px 0.5px 0 rgba(0, 0, 0, 0.24),
    0 0 0.8px rgba(0, 0, 0, 0.2);
  pointer-events: none;
  overflow: hidden;
  padding: 6px 8px 10px;
  box-sizing: border-box;
  -webkit-font-smoothing: antialiased;
  text-rendering: geometricPrecision;
}

.cve-gallery-preview-host {
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  margin: 0;
}

.cve-gallery-preview-host .cve-preview-wrap {
  margin: 0;
  height: 100%;
}

.cve-gallery-preview-host .cve-preview-base {
  max-width: none;
  width: 100%;
  height: 100%;
  border-radius: inherit;
  box-shadow: none;
  background: transparent;
}

.cve-gallery-preview-host .cve-preview-base img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.cve-gallery-first-replaced {
  position: relative;
}

.cve-gallery-first-replaced .cve-gallery-source-media {
  opacity: 0 !important;
}

.cve-personaliser.cve-display-inline.cve-mode-live .cve-dynamic-content > .cve-preview-wrap {
  display: none;
}

.cve-personaliser.cve-shortcode-showcase.cve-display-inline.cve-mode-live .cve-dynamic-content > .cve-preview-wrap {
  display: block;
}

.cve-modal[hidden] {
  display: none !important;
}

.cve-modal {
  position: fixed;
  inset: 0;
  z-index: 2147483647;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(20px, 6vh, 48px);
}

.cve-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(24, 18, 10, 0.58);
}

.cve-popup-panel {
  position: relative;
  z-index: 1;
  width: calc(100vw - 24px);
  max-height: calc(100vh - 24px);
  overflow: auto;
  margin: 0;
  padding: 24px 24px 18px;
  border-radius: 22px;
  background: linear-gradient(180deg, #fffefb 0%, #f3ebe0 100%);
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.28);
}

body.cve-modal-open {
  overflow: hidden !important;
}

.cve-open-popup {
  margin: 10px 0;
}

.cve-open-popup[hidden] {
  display: none !important;
}

.cve-shortcode-empty {
  padding: 16px 18px;
  border: 1px dashed #cfc4b6;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.76);
  color: #6d614f;
}

.cve-inline-preview-actions {
  margin-top: 16px;
}

.cve-personaliser.cve-mode-basic .cve-inline-preview-actions {
  display: none !important;
}

.cve-inline-preview-jump {
  width: 100%;
  justify-content: center;
}

.cve-popup-dismiss {
  position: fixed;
  top: 18px;
  right: 18px;
  z-index: 2147483647;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border: 1px solid #cfc4b6;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.96);
  color: #2b241d;
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
}

.cve-popup-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 18px;
  padding-top: 18px;
  background: linear-gradient(180deg, rgba(243, 235, 224, 0) 0%, rgba(243, 235, 224, 0.96) 28%, #f3ebe0 100%);
}

.cve-popup-add-to-cart,
.cve-cancel-engraving {
  width: 100%;
  justify-content: center;
}

.cve-cancel-engraving {
  margin: 0;
}

@media (min-width: 980px) {
  .cve-modal {
    padding: 12px;
  }

  .cve-modal .cve-popup-panel {
    display: grid;
    grid-template-columns: minmax(0, 1.6fr) minmax(480px, 0.95fr);
    grid-template-areas:
      "preview fields"
      "actions actions";
    gap: 24px;
    align-items: start;
  }

  .cve-modal .cve-popup-panel .cve-font-choice-list {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .cve-modal .cve-popup-panel .cve-font-choice span {
    min-height: 68px;
    padding: 12px 10px;
  }

  .cve-modal .cve-popup-panel .cve-preview-wrap {
    grid-area: preview;
    width: 100%;
    margin-top: 0;
    align-self: start;
  }

  .cve-modal .cve-popup-panel .cve-preview-base {
    width: 100%;
    max-width: none;
  }

  .cve-modal .cve-popup-panel .cve-fields-panel {
    grid-area: fields;
    min-width: 0;
    align-self: start;
  }

  .cve-modal .cve-popup-panel .cve-text-fields {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: start;
  }

  .cve-modal .cve-popup-panel .cve-popup-actions {
    grid-area: actions;
    position: sticky;
    bottom: -22px;
    padding-bottom: 22px;
  }
}

@media (max-width: 767px) {
  .cve-personaliser {
    padding: 14px;
  }

  .cve-personaliser.cve-display-inline .cve-text-fields {
    grid-template-columns: 1fr;
  }

  .cve-modal {
    align-items: flex-start;
    padding: calc(8px + env(safe-area-inset-top, 0px)) 8px calc(12px + env(safe-area-inset-bottom, 0px));
  }

  .cve-popup-panel {
    display: flex;
    flex-direction: column;
    width: calc(100vw - 16px);
    max-height: calc(100dvh - 20px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
    padding: calc(56px + env(safe-area-inset-top, 0px)) 14px calc(14px + env(safe-area-inset-bottom, 0px));
  }

  .cve-modal .cve-popup-panel .cve-font-choice-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .cve-modal .cve-popup-panel .cve-text-fields {
    grid-template-columns: 1fr;
  }

  .cve-modal .cve-popup-panel .cve-preview-wrap {
    order: 1;
    margin-top: 0;
    margin-bottom: 14px;
  }

  .cve-modal .cve-popup-panel .cve-fields-panel {
    order: 2;
  }

  .cve-modal .cve-popup-panel .cve-popup-actions {
    order: 3;
    position: sticky;
    bottom: 0;
    width: 100%;
    margin-top: 14px;
    padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
    z-index: 2;
  }

  .cve-popup-dismiss {
    top: calc(10px + env(safe-area-inset-top, 0px));
    right: 10px;
  }
}
