:root {
  --ink: #102033;
  --muted: #647187;
  --line: #dce4ef;
  --wash: #f5f8fc;
  --soft: #edf7ef;
  --green: #17a34a;
  --green-dark: #087334;
  --blue: #0b4778;
  --red: #b42318;
  --warning: #b7791f;
  --shadow: 0 14px 40px rgba(15, 35, 65, 0.1);
  --radius: 12px;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  width: 100%;
  margin: 0;
  color: var(--ink);
  background: #ffffff;
  font-family: Inter, Arial, Helvetica, sans-serif;
  overflow-x: hidden;
}

button,
input,
select,
textarea {
  font: inherit;
}

.shell {
  width: 100%;
  max-width: 1660px;
  margin: 0 auto;
  padding: clamp(16px, 2.4vw, 26px);
  overflow-x: hidden;
}

.heading {
  display: block;
  margin-bottom: 14px;
}

.heading > * {
  min-width: 0;
}

.kicker {
  margin: 0 0 5px;
  color: var(--blue);
  font-size: 0.78rem;
  font-weight: 850;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  max-width: none;
  margin-bottom: 7px;
  font-size: clamp(1.9rem, 3vw, 2.6rem);
  line-height: 1.04;
  white-space: normal;
}

h2 {
  margin-bottom: 6px;
  font-size: 1rem;
}

.lead,
.panel-head p,
.preview-head p {
  color: var(--muted);
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.lead {
  max-width: 820px;
  margin-bottom: 0;
  font-size: 0.98rem;
}

.state-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #ffffff;
  box-shadow: var(--shadow);
}

.state-card {
  padding: 12px 14px;
}

.state-card span,
.summary span {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.state-card strong {
  display: block;
  font-size: 1.1rem;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(420px, 470px) minmax(0, 1fr);
  gap: 0;
  align-items: stretch;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #ffffff;
  box-shadow: var(--shadow);
}

.view-switcher {
  display: none;
}

.workspace > *,
.preview-panel,
.preview-frame,
.preview {
  min-width: 0;
}

.panel {
  display: flex;
  flex-direction: column;
  align-self: stretch;
  justify-content: flex-start;
  gap: 0;
  height: 100%;
  padding: 24px;
  border-right: 1px solid var(--line);
  background: #ffffff;
}

.panel-head,
.preview-head {
  position: relative;
}

.panel-head {
  padding-left: 0;
  padding-bottom: 8px;
}

.panel-head h2 {
  margin-bottom: 0;
}

.panel-head::before,
.preview-head::before {
  display: none;
  content: none;
}

label {
  display: grid;
  gap: 6px;
  color: var(--ink);
  font-size: 0.9rem;
  font-weight: 800;
}

.panel > label {
  padding: 15px 0;
  border-top: 1px solid var(--line);
}

.panel > .panel-head + label {
  border-top: 0;
}

/* Las plantillas públicas de WordPress agrupan cada control en `.field`.
   Conservamos esa estructura como parte del engine común para que sus iconos
   y números de paso no hereden el tamaño libre del SVG. */
.field {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  min-width: 0;
}

.field + .field {
  margin-top: 0;
  padding-top: 17px;
  padding-bottom: 17px;
  border-top: 1px solid var(--line);
}

.panel-head + .field {
  padding-top: 16px;
  padding-bottom: 17px;
}

.field .step-no {
  display: none;
  grid-row: 1 / span 3;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 999px;
  color: #ffffff;
  background: var(--blue);
  font-size: 0.7rem;
  font-weight: 900;
  line-height: 1;
}

.field label {
  display: flex;
  grid-column: 1;
  gap: 7px;
  align-items: center;
  min-width: 0;
}

.help-trigger {
  display: inline-grid;
  place-items: center;
  flex: 0 0 19px;
  width: 19px;
  min-height: 19px;
  height: 19px;
  margin-left: auto;
  border: 1px solid #8eb4d5;
  border-radius: 999px;
  padding: 0;
  color: var(--blue);
  background: #f4f9ff;
  font-size: 0.7rem;
  font-weight: 900;
  line-height: 1;
  cursor: help;
}

.help-tooltip {
  display: none;
  z-index: 3;
  margin: 0;
  padding: 9px 10px;
  border: 1px solid #b9cee1;
  border-radius: 8px;
  color: #223c56;
  background: #f4f9ff;
  box-shadow: 0 8px 24px rgba(15, 35, 65, 0.12);
  font-size: 0.78rem;
  font-weight: 650;
  line-height: 1.35;
}

.help-tooltip.is-open {
  display: block;
}

.size-choice > .help-tooltip {
  grid-column: 1;
}

.field label svg {
  display: none;
}

.field .control,
.field .hint {
  grid-column: 1;
  min-width: 0;
}

.field .hint {
  margin: 0;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid #9fb4ca;
  border-radius: 9px;
  min-height: 46px;
  padding: 11px 13px;
  color: var(--ink);
  background: #f3f6f9;
  box-shadow: inset 0 1px 2px rgba(16, 32, 51, 0.04);
}

input:hover,
select:hover,
textarea:hover {
  border-color: #668fb4;
  background: #ffffff;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--blue);
  background: #ffffff;
  box-shadow: 0 0 0 3px rgba(11, 71, 120, 0.1);
}

.hint {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 650;
  line-height: 1.3;
}

/* Compatibilidad de bootstraps internos antiguos sin wrapper `.field`: la
   explicación extensa no compite con el control principal. */
.ux-enhanced .panel > label > .hint {
  display: none;
}

.size-choice {
  gap: 10px;
  padding: 18px 0 0;
  border: 0;
  border-top: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
}

.size-choice__title::after {
  content: " · Tú decides";
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 700;
}

.size-choice.is-override {
  border-top-color: #c98920;
}

.size-choice select {
  min-height: 40px;
  color: var(--muted);
  font-weight: 650;
}

.price-summary {
  display: grid;
  gap: 7px;
  margin-top: 14px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: #f8fafc;
}

.price-summary[hidden] {
  display: none;
}

.price-summary__label {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 800;
  text-transform: uppercase;
}

.price-summary__value {
  color: var(--ink);
  font-size: 1.65rem;
  line-height: 1.15;
}

.price-summary__details,
.price-summary__notice {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 650;
  line-height: 1.35;
}

.price-summary__notice {
  margin-top: 2px;
  color: #526579;
}

.price-summary[data-sale-status="production_review_required"],
.price-summary[data-sale-status="logistics_review_required"] {
  border-color: #c7d5e2;
  background: #f6f9fc;
}

.primary-monetary-field {
  margin: 0;
  padding: 17px 0;
  border: 0;
  border-top: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
}

.primary-monetary-field input {
  border-color: #76a7d1;
  font-size: 1.04rem;
  font-weight: 800;
}

.kind-guidance {
  display: grid;
  gap: 7px;
  margin: 4px 0 2px;
  padding: 13px 14px;
  border: 1px solid #bfd3e5;
  border-left: 4px solid var(--blue);
  border-radius: 10px;
  color: #263b52;
  background: #f4f8fc;
  font-size: 0.8rem;
  line-height: 1.38;
}

.kind-guidance__title {
  color: var(--ink);
  font-size: 0.88rem;
}

.kind-guidance p,
.kind-guidance ul {
  margin: 0;
}

.kind-guidance details {
  padding-top: 2px;
}

.kind-guidance summary {
  color: var(--blue);
  cursor: pointer;
  font-weight: 800;
}

.kind-guidance details[open] summary {
  margin-bottom: 7px;
}

.kind-guidance ul {
  display: grid;
  gap: 4px;
  padding-left: 18px;
}

.kind-guidance__note {
  margin-top: 8px !important;
  color: var(--muted);
}

.kind-guidance a {
  display: inline-block;
  margin-top: 8px;
  color: var(--blue);
  font-weight: 800;
}

.kind-guidance + .field {
  margin-top: 0;
  padding-top: 17px;
  padding-bottom: 17px;
  border-top: 1px solid var(--line);
}

.shipping-choice {
  display: grid;
  gap: 9px;
  min-width: 0;
  margin: 14px 0 0;
  padding: 0;
  border: 0;
}

.shipping-choice[hidden] {
  display: none;
}

.shipping-choice legend {
  margin-bottom: 9px;
  padding: 0;
  color: var(--ink);
  font-size: 0.9rem;
  font-weight: 850;
}

.shipping-option {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr) auto;
  gap: 11px;
  align-items: center;
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--ink);
  background: #f8fafc;
  cursor: pointer;
  transition: border-color 150ms ease, background 150ms ease, box-shadow 150ms ease;
}

.shipping-option:hover {
  border-color: #9fb4ca;
}

.shipping-option.is-selected {
  border-color: var(--green);
  background: #f2faf4;
  box-shadow: 0 0 0 2px rgba(23, 163, 74, 0.08);
}

.shipping-option input {
  width: 18px;
  min-height: 18px;
  height: 18px;
  margin: 0;
  padding: 0;
  border: 0;
  accent-color: var(--green);
  box-shadow: none;
}

.shipping-option__copy {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.shipping-option__copy strong {
  font-size: 0.87rem;
}

.shipping-option__copy small {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 650;
  line-height: 1.3;
}

.shipping-option__price {
  color: var(--green-dark);
  font-size: 0.86rem;
  white-space: nowrap;
}

textarea {
  min-height: 72px;
  resize: vertical;
}

.summary {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--wash);
}

.preview-guidance {
  display: grid;
  gap: 12px;
  padding: 16px 18px 18px;
  border-top: 1px solid var(--line);
  background: #ffffff;
}

.preview-guidance h2,
.preview-guidance h3 {
  margin: 0;
  font-size: 0.92rem;
}

.preview-guidance .summary {
  padding: 10px 12px;
  box-shadow: none;
}

.preview-guidance__status {
  margin: 0;
  padding: 10px 12px;
  border-left: 3px solid #8aa2b8;
  border-radius: 7px;
  color: #43566c;
  background: #f6f9fc;
  font-size: 0.82rem;
  font-weight: 700;
  line-height: 1.35;
}

.preview-guidance__status.is-ready {
  border-left-color: var(--green);
  color: #245532;
  background: #f3faf5;
}

.review-details {
  border-top: 1px solid var(--line);
  padding-top: 10px;
}

.review-details > summary {
  color: #43566c;
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 800;
}

.review-details[open] > summary {
  margin-bottom: 9px;
}

.preview-guidance #messages,
.preview-guidance .messages {
  display: grid;
  gap: 7px;
  padding: 0;
  margin: 0;
  list-style: none;
}

.preview-guidance #messages li,
.preview-guidance .messages li {
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--green);
  border-radius: 6px;
  color: var(--muted);
  background: #ffffff;
  font-size: 0.8rem;
  line-height: 1.35;
}

.preview-guidance #messages li.error,
.preview-guidance .messages li.error {
  border-left-color: var(--red);
  color: var(--ink);
  background: #fff8f7;
}

.preview-guidance #messages li.warning,
.preview-guidance .messages li.warning {
  border-left-color: #8aa2b8;
  background: #f6f9fc;
}

.actions {
  display: grid;
  gap: 10px;
}

.sample-tools {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 0.82fr);
  gap: 8px;
}

.sample-tools button {
  width: 100%;
  min-width: 0;
  line-height: 1.25;
}

.sample-download {
  border-color: #b8c9dc;
  color: #17324d;
  background: #eef4fa;
}

.sample-reset {
  color: #536579;
  background: #ffffff;
}

.sample-tools__status {
  display: block;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 650;
  line-height: 1.35;
}

#export-status {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 650;
  line-height: 1.35;
}

button {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 14px;
  color: var(--muted);
  background: #f9fbfe;
  font-weight: 850;
}

button.primary {
  border-color: #b9d9bf;
  color: #376141;
  background: var(--soft);
}

button.primary.cart,
#add-to-cart {
  min-height: 50px;
  border-color: var(--green-dark);
  color: #ffffff;
  background: var(--green);
  box-shadow: 0 10px 22px rgba(23, 163, 74, 0.24);
  border-radius: 10px;
  font-size: 1rem;
  transition: background 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

button.primary.cart:not(:disabled):hover,
#add-to-cart:not(:disabled):hover {
  background: var(--green-dark);
  box-shadow: 0 12px 26px rgba(8, 115, 52, 0.3);
  transform: translateY(-1px);
}

button.primary.cart:disabled,
#add-to-cart:disabled {
  border-color: #b8c6d3;
  color: #66768a;
  background: #eaf0f5;
  box-shadow: none;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.78;
}

button.cart svg {
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
}

.preview-panel {
  overflow: hidden;
  min-height: 100%;
  background: #ffffff;
}

@media (min-width: 761px) {
  .preview-panel {
    position: sticky;
    top: 12px;
  }
}

.preview-head {
  display: none;
  gap: 14px;
  justify-content: space-between;
  align-items: flex-start;
  padding: 14px 18px;
}

.preview-tag {
  flex: 0 0 auto;
  margin-left: auto;
  white-space: nowrap;
}

@media (max-width: 1100px) {
  h1 {
    white-space: normal;
  }
}

.notice {
  padding: 9px 18px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  background: var(--wash);
  font-size: 0.9rem;
  font-weight: 750;
}

.ux-enhanced .notice,
.ux-enhanced .public-warnings {
  display: none;
}

.public-warnings {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  padding: 8px 18px;
  margin: 0;
  border-top: 1px solid var(--line);
  list-style: none;
  background: #ffffff;
}

.public-warnings li {
  min-height: 36px;
  display: grid;
  align-items: center;
  padding: 7px 9px;
  border: 1px solid #d8e5d9;
  border-radius: 6px;
  color: #274d31;
  background: var(--soft);
  font-size: 0.78rem;
  font-weight: 850;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.preview-frame {
  --preview-frame-height: clamp(500px, 65vh, 700px);
  --preview-inner-height: calc(var(--preview-frame-height) - 40px);
  display: grid;
  grid-template-columns: minmax(0, 1fr) 54px;
  grid-template-rows: minmax(0, 1fr) 38px;
  place-items: stretch;
  height: var(--preview-frame-height);
  padding: clamp(12px, 2.2vw, 20px);
  position: relative;
  background: linear-gradient(135deg, #eef3f8 0%, #ffffff 100%);
  overflow: hidden;
}

.preview-frame[data-poster-orientation="landscape"] {
  --preview-frame-height: clamp(360px, 50vh, 540px);
}

.preview {
  display: grid;
  grid-column: 1;
  grid-row: 1;
  place-items: center;
  align-self: center;
  justify-self: center;
  width: min(100%, calc(var(--preview-inner-height) * var(--poster-ratio, 0.7565)));
  aspect-ratio: var(--poster-aspect, 870 / 1150);
  height: auto;
  max-width: 100%;
  max-height: 100%;
  contain: layout paint;
}

.poster-dimension {
  position: absolute;
  z-index: 2;
  color: #536579;
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  line-height: 1;
  pointer-events: none;
  user-select: none;
}

.poster-dimension--width {
  height: 28px;
}

.poster-dimension--height {
  width: 48px;
}

.poster-dimension__line {
  position: absolute;
  display: block;
  background: #7f93a8;
}

.poster-dimension--width .poster-dimension__line {
  right: 0;
  bottom: 4px;
  left: 0;
  height: 1px;
}

.poster-dimension--width .poster-dimension__line::before,
.poster-dimension--width .poster-dimension__line::after,
.poster-dimension--height .poster-dimension__line::before,
.poster-dimension--height .poster-dimension__line::after {
  position: absolute;
  display: block;
  width: 0;
  height: 0;
  content: "";
}

.poster-dimension--width .poster-dimension__line::before {
  top: -4px;
  left: 0;
  border-top: 4px solid transparent;
  border-right: 7px solid #7f93a8;
  border-bottom: 4px solid transparent;
}

.poster-dimension--width .poster-dimension__line::after {
  top: -4px;
  right: 0;
  border-top: 4px solid transparent;
  border-bottom: 4px solid transparent;
  border-left: 7px solid #7f93a8;
}

.poster-dimension--width .poster-dimension__value {
  position: absolute;
  top: 1px;
  left: 50%;
  padding: 0 6px;
  background: #f8fafc;
  transform: translateX(-50%);
  white-space: nowrap;
}

.poster-dimension--height .poster-dimension__line {
  top: 0;
  bottom: 0;
  left: 4px;
  width: 1px;
}

.poster-dimension--height .poster-dimension__line::before {
  top: 0;
  left: -4px;
  border-right: 4px solid transparent;
  border-bottom: 7px solid #7f93a8;
  border-left: 4px solid transparent;
}

.poster-dimension--height .poster-dimension__line::after {
  bottom: 0;
  left: -4px;
  border-top: 7px solid #7f93a8;
  border-right: 4px solid transparent;
  border-left: 4px solid transparent;
}

.poster-dimension--height .poster-dimension__value {
  position: absolute;
  top: 50%;
  left: 15px;
  padding: 6px 0;
  background: #f8fafc;
  transform: translateY(-50%) rotate(180deg);
  writing-mode: vertical-rl;
  white-space: nowrap;
}

.preview svg {
  display: block;
  width: 100%;
  height: auto;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 18px 24px rgba(16, 32, 51, 0.2));
}

.checks {
  padding: 14px 18px 16px;
  border-top: 1px solid var(--line);
}

.checks ul {
  display: grid;
  gap: 8px;
  padding: 0;
  margin: 0;
  list-style: none;
}

.checks li {
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--green);
  border-radius: 6px;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.4;
}

.checks li.error {
  border-left-color: var(--red);
  color: var(--ink);
  background: #fff8f7;
}

.checks li.warning {
  border-left-color: #8aa2b8;
  background: #f6f9fc;
}

@media (min-width: 1400px) {
  .preview-frame {
    --preview-frame-height: clamp(620px, 70vh, 760px);
  }
}

@media (max-width: 760px) {
  .shell {
    padding: 12px;
  }

  .heading,
  .workspace {
    display: flex;
    flex-direction: column;
  }

  .heading {
    gap: 10px;
    align-items: stretch;
    margin-bottom: 10px;
  }

  h1 {
    margin-bottom: 6px;
    font-size: clamp(1.7rem, 8.5vw, 2.15rem);
    line-height: 1.02;
    white-space: normal;
  }

  .kicker {
    overflow-wrap: anywhere;
  }

  .lead,
  .panel-head p,
  .preview-head p {
    font-size: 0.9rem;
  }

  .state-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 12px;
  }

  .state-card span {
    margin: 0;
  }

  .state-card strong {
    font-size: 0.96rem;
  }

  .workspace {
    align-items: stretch;
    gap: 0;
  }

  .preview-panel {
    order: 2;
  }

  .panel {
    order: 1;
    display: grid;
    height: auto;
    justify-content: stretch;
    border-top: 1px solid var(--line);
    border-right: 0;
  }

  .view-switcher {
    display: grid;
    order: 0;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    padding: 12px 14px;
    border-bottom: 1px solid var(--line);
    background: #f8fafc;
  }

  .view-switcher button {
    min-height: 40px;
  }

  .panel {
    gap: 0;
    padding: 16px;
  }

  .preview-head {
    display: none;
    align-items: flex-start;
    gap: 8px;
    padding: 14px;
  }

  .preview-head > strong {
    margin-left: auto;
    text-align: right;
  }

  .preview-head p {
    margin-bottom: 0;
  }

  .notice {
    padding: 10px 16px;
  }

  .public-warnings {
    grid-template-columns: repeat(3, minmax(150px, 1fr));
    padding: 8px 14px;
    overflow-x: auto;
    overscroll-behavior-inline: contain;
    scroll-snap-type: inline proximity;
  }

  .public-warnings li {
    scroll-snap-align: start;
  }

  .preview-frame {
    --preview-frame-height: clamp(390px, 58vh, 500px);
    --preview-inner-height: calc(var(--preview-frame-height) - 20px);
    grid-template-columns: minmax(0, 1fr) 38px;
    grid-template-rows: minmax(0, 1fr) 32px;
    height: var(--preview-frame-height);
    padding: 12px;
  }

  .poster-dimension {
    font-size: 0.72rem;
  }

  .preview-frame[data-poster-orientation="landscape"] {
    --preview-frame-height: clamp(270px, 38vh, 340px);
  }

  .preview {
    width: min(100%, calc(var(--preview-inner-height) * var(--poster-ratio, 0.7565)));
    height: auto;
    overflow: hidden;
  }

  .preview svg {
    width: 100%;
    height: auto;
  }

  .checks {
    padding: 14px 16px 16px;
  }

  .preview-guidance {
    padding: 12px 14px 14px;
  }

  .preview-guidance #messages,
  .preview-guidance .messages {
    gap: 6px;
  }

  .panel.cart-ready .actions {
    position: sticky;
    bottom: 0;
    z-index: 5;
    margin: 12px -16px -16px;
    padding: 12px 16px 16px;
    border-top: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.96);
    box-shadow: 0 -10px 26px rgba(15, 35, 65, 0.1);
    backdrop-filter: blur(8px);
  }

  .sample-tools {
    grid-template-columns: 1fr;
  }
}

/* Accesibilidad: foco visible fuerte para navegación por teclado (WCAG 2.4.7).
   :focus-visible no dispara con clic de ratón, solo con teclado. */
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
button:focus-visible {
  outline: 2px solid #159447;
  outline-offset: 2px;
}
