.clp-editor {
  --clp-ink: #0d3034;
  --clp-mint: #6ce0d5;
  --clp-lilac: #cbb5df;
  margin: 28px 0;
  padding: 20px;
  border: 1px solid #dce7e7;
  border-radius: 20px;
  background: #f7fafa;
  color: var(--clp-ink);
}

.clp-editor-heading h3 { margin: 5px 0; font-size: clamp(22px, 2.5vw, 30px); }
.clp-editor-heading p { margin: 0 0 16px; }
.clp-step { font-size: 12px; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; }
.clp-inline-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.clp-upload-button {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  min-height: 50px;
  padding: 0 24px;
  border: 0;
  border-radius: 999px;
  background: var(--clp-ink);
  color: #fff !important;
  font-weight: 800;
  cursor: pointer;
}

.clp-file-name { margin: 10px 0 0; overflow-wrap: anywhere; font-size: 13px; }
.clp-status { margin-top: 14px; font-size: 14px; font-weight: 700; }
.clp-unavailable .clp-inline-actions { opacity: .45; pointer-events: none; }
.clp-cart-thumb { width: 80px !important; height: 100px !important; object-fit: contain; }
.clp-stage-wrap {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 500px;
  padding: 18px;
  border-radius: 16px;
  background: linear-gradient(145deg, #dff7f4, #eadff2);
  overflow: hidden;
}

.clp-canvas {
  display: block;
  max-width: 100%;
  height: auto;
  max-height: 560px;
  filter: drop-shadow(0 16px 22px rgba(13, 48, 52, .18));
  touch-action: none;
  cursor: grab;
}

.clp-canvas:active { cursor: grabbing; }
.clp-empty-state {
  position: absolute;
  max-width: 220px;
  padding: 12px 16px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .9);
  text-align: center;
  font-weight: 700;
}

.clp-edit-hint {
  display: none;
  position: absolute;
  left: 50%;
  bottom: 14px;
  transform: translateX(-50%);
  z-index: 3;
  padding: 9px 18px !important;
  border: 0 !important;
  border-radius: 999px !important;
  background: rgba(13, 48, 52, .88) !important;
  color: #fff !important;
  box-shadow: 0 6px 18px rgba(13, 48, 52, .22) !important;
  font-size: 13px;
  font-weight: 800;
  line-height: 1;
  cursor: pointer;
}

.clp-edit-hint:hover,
.clp-edit-hint:focus-visible { background: #1c4a4f !important; color: #fff !important; }
.clp-stage-wrap.clp-editable .clp-edit-hint { display: inline-block; }
.clp-stage-wrap.clp-editable { cursor: pointer; }
.clp-stage-wrap.clp-editable .clp-canvas { cursor: pointer; }
.clp-modal .clp-edit-hint { display: none !important; }
.clp-editor > .clp-stage-wrap { display: none; }
.clp-editor.clp-stage-inline > .clp-stage-wrap { display: grid; margin-top: 14px; }
.woocommerce-product-gallery.clp-gallery-host { display: flex; flex-direction: column; gap: 12px; opacity: 1 !important; }
.clp-gallery-host .woocommerce-product-gallery__wrapper,
.clp-gallery-host .woocommerce-product-gallery__trigger,
.clp-gallery-host .flex-viewport,
.clp-gallery-host .flex-control-nav { display: none !important; }
.clp-gallery-label { color: var(--clp-ink, #0d3034); font-size: 12px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.clp-gallery-host > .clp-stage-wrap { display: grid; width: 100%; min-height: 640px; box-sizing: border-box; border-radius: 0; }
.clp-gallery-host .clp-canvas { max-height: 650px; }

/* ============ Modal 0.7: previsualización + área de impresión ============ */
.clp-modal[hidden] { display: none !important; }
.clp-modal {
  position: fixed;
  inset: 0;
  z-index: 100000;
  display: grid;
  place-items: center;
  padding: 12px;
}

.clp-modal-backdrop { position: absolute; inset: 0; background: rgba(4, 22, 25, .8); backdrop-filter: blur(5px); }
.clp-modal-dialog {
  position: relative;
  width: min(1020px, calc(100vw - 24px));
  height: min(860px, calc(100dvh - 24px));
  max-height: calc(100dvh - 24px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid #dce7e7;
  border-radius: 22px;
  background: #fff;
  box-shadow: 0 28px 80px rgba(0, 0, 0, .35);
}

.clp-modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 4;
  width: 42px;
  height: 42px;
  padding: 0;
  border: 0 !important;
  border-radius: 50%;
  background: #eef3f3 !important;
  color: var(--clp-ink, #0d3034) !important;
  box-shadow: none !important;
  font-size: 29px;
  line-height: 1;
  cursor: pointer;
}

.clp-modal-close:hover,
.clp-modal-close:focus-visible {
  border-color: transparent !important;
  background: #dfe9e8 !important;
  color: var(--clp-ink, #0d3034) !important;
  outline: 2px solid #b49bd0;
  outline-offset: 2px;
}

.clp-modal-body {
  min-height: 0;
  flex: 1 1 auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr);
  gap: 16px;
  padding: 16px;
  overflow: hidden;
}

.clp-modal-pane {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
  min-height: 0;
}

.clp-pane-label {
  flex: 0 0 auto;
  color: #56696a;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .1em;
  line-height: 1.3;
  text-transform: uppercase;
}

.clp-modal-editor > .clp-pane-label { padding-right: 52px; }
.clp-modal-stage-slot {
  display: block;
  position: relative;
  width: 100%;
  min-width: 0;
  min-height: 0;
  flex: 1 1 auto;
  overflow: hidden;
}

/* Panel izquierdo: vista previa del estuche terminado */
.clp-modal .clp-stage-wrap {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  min-height: 0;
  padding: 0;
  box-sizing: border-box;
  border: 1px solid #e3ecec;
  border-radius: 14px;
  background: linear-gradient(160deg, #f3fbfa, #f8f5fc);
  overflow: hidden;
}

.clp-modal .clp-canvas {
  position: absolute;
  inset: 0;
  margin: auto;
  width: auto !important;
  height: auto !important;
  max-width: calc(100% - 28px) !important;
  max-height: calc(100% - 28px) !important;
  filter: drop-shadow(0 12px 24px rgba(13, 48, 52, .22));
  cursor: grab;
}

/* Panel derecho: área imprimible sobre fondo transparente */
.clp-edit-viewport {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  min-width: 0;
  border: 1px solid #d7dddd;
  border-radius: 14px;
  background-color: #f8f8f8;
  background-image:
    linear-gradient(45deg, #e1e1e1 25%, transparent 25%),
    linear-gradient(-45deg, #e1e1e1 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #e1e1e1 75%),
    linear-gradient(-45deg, transparent 75%, #e1e1e1 75%);
  background-position: 0 0, 0 10px, 10px -10px, -10px 0;
  background-size: 20px 20px;
  overflow: hidden;
}

.clp-edit-canvas {
  position: absolute;
  inset: 0;
  margin: auto;
  display: block;
  width: auto;
  height: auto;
  max-width: calc(100% - 16px);
  max-height: calc(100% - 16px);
  touch-action: none;
  cursor: grab;
}

.clp-edit-canvas:active,
.clp-modal .clp-canvas:active { cursor: grabbing; }
.clp-modal .clp-empty-state { left: 50%; top: 50%; transform: translate(-50%, -50%); }

.clp-modal-tools {
  flex: 0 0 auto;
  align-self: center;
  display: inline-flex;
  max-width: 100%;
  overflow: hidden;
  border: 1px solid var(--clp-ink, #0d3034);
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 5px 16px rgba(13, 48, 52, .1);
}

.clp-tool {
  appearance: none;
  width: 54px;
  height: 50px;
  display: grid;
  place-items: center;
  margin: 0;
  padding: 0;
  border: 0 !important;
  border-left: 1px solid var(--clp-ink, #0d3034) !important;
  border-radius: 0 !important;
  background: #fff !important;
  color: var(--clp-ink, #0d3034) !important;
  box-shadow: none !important;
  line-height: 1;
  cursor: pointer;
  transition: background-color .18s ease, color .18s ease;
}

.clp-tool:first-child { border-left: 0 !important; }
.clp-tool svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 2.25; stroke-linecap: round; stroke-linejoin: round; }
.clp-tool:hover,
.clp-tool:focus-visible { border-color: var(--clp-ink, #0d3034) !important; background: #eef3f3 !important; color: var(--clp-ink, #0d3034) !important; outline: none; }
.clp-delete:hover,
.clp-delete:focus-visible { background: #fff0f0 !important; color: #a51f2b !important; }
.clp-modal-confirm { background: var(--clp-ink, #0d3034) !important; color: #fff !important; }
.clp-modal-confirm:hover,
.clp-modal-confirm:focus-visible { background: #344c4e !important; color: #fff !important; }
.clp-tool-status { flex: 0 0 auto; display: flex; justify-content: center; gap: 18px; color: #506263; font-size: 12px; font-weight: 700; }
.clp-tool-status output { color: var(--clp-ink, #0d3034); }
.clp-modal-help { flex: 0 0 auto; margin: 0; color: #5b6d6e; font-size: 12px; line-height: 1.35; text-align: center; }
.clp-quality { flex: 0 0 auto; max-height: 40px; padding: 6px 9px; overflow: auto; border-radius: 9px; background: #e2f6eb; color: #175f3b; font-size: 11px; line-height: 1.3; }
.clp-quality:empty { display: none; }
.clp-quality.is-warning { background: #fff2cc; color: #765600; }
.clp-modal-open { overflow: hidden !important; }

@media (max-width: 700px) {
  .clp-editor { padding: 16px; }
  .clp-gallery-host > .clp-stage-wrap { min-height: 440px; }
  .clp-gallery-host .clp-canvas { max-height: 500px; }
}

/* Una sola columna: vista previa arriba, área de impresión abajo */
@media (max-width: 900px) {
  .clp-modal { padding: 5px; }
  .clp-modal-dialog { width: calc(100vw - 10px); height: calc(100dvh - 10px); max-height: calc(100dvh - 10px); border-radius: 16px; }
  .clp-modal-close { top: 8px; right: 8px; }
  .clp-modal-body {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(0, 0.85fr) minmax(0, 1.3fr);
    gap: 10px;
    padding: 10px;
  }
  .clp-modal-preview > .clp-pane-label { padding-right: 52px; }
  .clp-modal-editor > .clp-pane-label { padding-right: 0; }
  .clp-modal-pane { gap: 6px; }
  .clp-modal .clp-canvas { max-width: calc(100% - 16px) !important; max-height: calc(100% - 16px) !important; }
  .clp-tool { width: 52px; height: 48px; }
  .clp-tool svg { width: 25px; height: 25px; }
  .clp-modal-help { font-size: 11px; }
  .clp-quality { max-height: 34px; padding: 5px 7px; font-size: 10px; }
}

@media (max-width: 380px) {
  .clp-tool { width: 47px; }
  .clp-tool-status { gap: 12px; }
}

@media (max-height: 700px) {
  .clp-modal-help { display: none; }
}

@media (max-height: 620px) {
  .clp-quality { display: none; }
  .clp-pane-label { display: none; }
}
