/* Compatibilidade estrutural do chaveiro sobre o mesmo tema visual do Clicker. */
.pep3d-app[data-pep3d-app] {
  display: flex;
  width: 100%;
  max-width: 100%;
  height: clamp(620px, calc(100dvh - 24px), 920px);
  min-height: 0;
  flex-direction: column;
}

.pep3d-toolbar {
  min-height: 68px;
  height: auto;
}

.pep3d-actions {
  flex-wrap: wrap;
}

.pep3d-workspace {
  min-width: 0;
  min-height: 0;
  flex: 1 1 auto;
  grid-template-columns: 300px minmax(380px, 1fr) 300px;
  grid-template-rows: minmax(0, 1fr);
}

.pep3d-panel {
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  scrollbar-width: thin;
  scrollbar-color: rgba(252, 148, 84, .75) transparent;
}

.pep3d-panel .pep3d-section-first,
.pep3d-panel .pep3d-section-first h3 {
  margin-top: 0;
}

.pep3d-panel section.pep3d-section-first {
  border-top: 0;
}

.pep3d-panel label output {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.pep3d-panel label input[type="text"] {
  grid-column: 1 / -1;
  width: 100%;
}

.pep3d-panel input[type="text"],
.pep3d-panel select {
  min-width: 0;
  min-height: 40px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
}

.pep3d-panel input[type="text"]:focus-visible,
.pep3d-panel select:focus-visible {
  outline: 2px solid var(--p);
  outline-offset: 2px;
}

.pep3d-field-wide small {
  grid-column: 1 / -1;
  line-height: 1.35;
}


/* Ajustes visuais do bloco de texto para coincidir com o layout de referência. */
.pep3d-text-controls > .pep3d-field-wide {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
  width: 100%;
}

.pep3d-text-controls > .pep3d-field-wide > :is(span, small, textarea),
.pep3d-text-controls > .pep3d-field-wide > input,
.pep3d-text-controls > .pep3d-field-wide > select {
  grid-column: auto;
}

.pep3d-panel textarea[data-pep3d-input="names"] {
  display: block;
  box-sizing: border-box;
  width: 100%;
  min-height: 96px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  resize: vertical;
  line-height: 1.3;
}

.pep3d-panel textarea[data-pep3d-input="names"]:focus-visible {
  outline: 2px solid var(--p);
  outline-offset: 2px;
}

.pep3d-text-controls > .pep3d-field-wide > small {
  margin: 0;
}

.pep3d-viewer {
  width: 100%;
  height: 100%;
  min-height: 0;
  overflow: hidden;
}

.pep3d-viewer canvas {
  min-width: 0;
  min-height: 0;
  cursor: grab;
}

.pep3d-viewer canvas.is-dragging {
  cursor: grabbing;
}

.pep3d-viewer canvas.is-object-hover {
  cursor: move;
}

.pep3d-viewer canvas.is-object-dragging {
  cursor: grabbing !important;
}

.pep3d-view-hint,
.pep3d-status {
  pointer-events: none;
}

.pep3d-upload {
  padding: 18px;
}

.pep3d-upload.is-dragging {
  border-color: #FC9454;
  background: #fff4ed;
}

.pep3d-webgl-error {
  position: absolute;
  inset: 50% auto auto 50%;
  max-width: 360px;
  padding: 18px;
  transform: translate(-50%, -50%);
  border-radius: 10px;
  background: #fff;
  color: #9b1c1c;
  text-align: center;
}

/* Mantém o comportamento responsivo solicitado para o chaveiro. */
@media (max-width: 1120px) {
  .pep3d-app[data-pep3d-app] {
    height: auto;
    min-height: 0;
  }

  .pep3d-workspace {
    grid-template-columns: 240px minmax(0, 1fr);
    grid-template-rows: clamp(500px, 70dvh, 760px) auto;
  }

  .pep3d-panel-left,
  .pep3d-viewer {
    height: 100%;
  }

  .pep3d-panel-right {
    grid-column: 1 / -1;
    display: grid;
    height: auto;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
    max-height: none;
    border-top: 1px solid var(--line);
    border-left: 0;
  }

  .pep3d-panel-right > section {
    margin-top: 0;
    border-top: 0;
  }

  .pep3d-toolbar {
    grid-template-columns: minmax(240px, 1fr) auto;
    gap: 10px 16px;
  }

  .pep3d-actions {
    grid-column: 1 / -1;
    display: flex;
    justify-content: flex-end;
  }
}

@media (max-width: 760px) {
  .pep3d-toolbar {
    grid-template-columns: 1fr;
    padding: 12px;
  }

  .pep3d-segmented {
    width: 100%;
    justify-self: stretch;
  }

  .pep3d-segmented button {
    flex: 1;
  }

  .pep3d-actions {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    justify-content: stretch;
  }

  .pep3d-actions button {
    min-width: 0;
    padding-inline: 6px;
  }

  .pep3d-workspace {
    display: flex;
    flex-direction: column;
  }

  .pep3d-panel {
    height: auto;
    max-height: none;
    border: 0;
  }

  .pep3d-panel-left {
    order: 2;
  }

  .pep3d-viewer {
    order: 1;
    height: clamp(400px, 62dvh, 620px);
    min-height: 400px;
  }

  .pep3d-viewer canvas {
    height: 100%;
    min-height: 0;
  }

  .pep3d-panel-right {
    order: 3;
    display: block;
  }

  .pep3d-panel-right > section + section {
    margin-top: 16px;
    border-top: 1px solid var(--line);
  }
}

@media (max-width: 480px) {
  .pep3d-toolbar strong {
    font-size: 16px;
  }

  .pep3d-actions {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .pep3d-viewer {
    height: clamp(360px, 58dvh, 500px);
    min-height: 360px;
  }

  .pep3d-panel {
    padding: 14px;
  }
}

/* Mantém o modelo visível durante a edição exclusivamente em celulares. */
@media (max-width: 760px) {
  .pep3d-app[data-pep3d-app] {
    overflow: visible;
  }

  .pep3d-workspace {
    overflow: visible;
  }

  .pep3d-viewer {
    position: sticky;
    z-index: 60;
    top: 0;
    height: clamp(280px, 42svh, 390px);
    min-height: 280px;
    flex: none;
    overflow: hidden;
    border-bottom: 1px solid var(--line);
    box-shadow: 0 10px 24px rgba(7, 31, 35, .2);
  }

  .pep3d-viewer canvas {
    height: 100%;
    min-height: 0;
  }

  .pep3d-status {
    max-width: calc(100% - 20px);
    overflow: hidden;
    text-overflow: ellipsis;
  }
}

@media (max-width: 480px) {
  .pep3d-viewer {
    height: clamp(240px, 38svh, 320px);
    min-height: 240px;
  }
}


/* Campo numérico manual sincronizado com cada controle deslizante.
 * O input ocupa o lugar do valor textual e a unidade fica dentro da área do campo. */
.pep3d-manual-range-label {
  width: 100%;
  min-width: 0;
  max-width: none;
  grid-template-columns: minmax(0, 1fr) 111px !important;
  column-gap: 6px;
}

/* Mantém os parâmetros da barra direita com a mesma ocupação da barra esquerda.
 * A seção e cada label precisam se esticar; caso contrário, o grid pode adotar a
 * largura do conteúdo e deixar slider e campo numérico recuados à direita. */
.pep3d-panel-right > section,
.pep3d-panel-right .pep3d-image-parameters,
.pep3d-panel-right .pep3d-manual-range-label {
  width: 100%;
  min-width: 0;
  max-width: none;
}

.pep3d-panel-right .pep3d-manual-range-label {
  justify-self: stretch;
  grid-template-rows: 30px 16px;
  row-gap: 6px;
  margin: 6px 0 !important;
}

.pep3d-panel-right .pep3d-manual-range-label > .pep3d-range-number-control,
.pep3d-panel-right .pep3d-manual-range-label > .pep3d-range-number-control input[type="range"] {
  height: 16px;
}

.pep3d-manual-range-label > output {
  display: none !important;
}

.pep3d-range-number-control {
  display: block;
  width: 100%;
  min-width: 0;
}

.pep3d-panel .pep3d-manual-range-label > .pep3d-range-number-control {
  grid-column: 1 / -1;
  grid-row: 2;
  justify-self: stretch;
}

.pep3d-range-number-control input[type="range"] {
  min-width: 0;
  width: 100%;
  margin: 0;
}

.pep3d-app .pep3d-panel label.pep3d-manual-range-label > .pep3d-number-field {
  position: relative !important;
  display: flex !important;
  align-items: stretch !important;
  grid-column: 2;
  grid-row: 1;
  justify-self: end;
  width: 111px !important;
  min-width: 111px !important;
  max-width: 111px !important;
  height: 30px !important;
  box-sizing: border-box !important;
  overflow: hidden !important;
  border: 1px solid rgba(23, 60, 66, 0.24) !important;
  border-radius: 9px !important;
  background: #ffffff !important;
  box-shadow: 0 1px 1px rgba(0, 0, 0, 0.06) !important;
}

.pep3d-app .pep3d-panel label.pep3d-manual-range-label > .pep3d-number-field.has-active-reset {
  width: 111px !important;
  min-width: 111px !important;
  max-width: 111px !important;
}

.pep3d-manual-reset {
  position: relative;
  z-index: 2;
  flex: 0 0 27px;
  width: 27px;
  min-width: 27px !important;
  height: 100%;
  min-height: 0 !important;
  padding: 0 !important;
  border: 0 !important;
  border-right: 1px solid rgba(23, 60, 66, 0.12) !important;
  border-radius: 0 !important;
  background: #fff !important;
  color: var(--p, #FC9454) !important;
  font-size: 18px !important;
  font-weight: 700 !important;
  line-height: 1 !important;
  cursor: pointer;
}

.pep3d-manual-reset:hover,
.pep3d-manual-reset:focus-visible {
  background: #fff7f2 !important;
  color: #e66d24 !important;
}

.pep3d-manual-reset[hidden] {
  display: none !important;
}

.pep3d-app .pep3d-panel .pep3d-number-field:focus-within {
  border-color: var(--p, #FC9454) !important;
  box-shadow: 0 0 0 2px rgba(252, 148, 84, 0.38) !important;
}

.pep3d-app .pep3d-panel input.pep3d-number-input[type="number"] {
  display: block !important;
  width: 100% !important;
  min-width: 0 !important;
  max-width: none !important;
  height: 100% !important;
  box-sizing: border-box !important;
  margin: 0 !important;
  padding: 4px 28px 4px 8px !important;
  border: 0 !important;
  border-radius: 8px !important;
  outline: 0 !important;
  background: #ffffff !important;
  color: var(--ink, #173C42) !important;
  font: inherit !important;
  font-weight: 700 !important;
  font-size: 14px !important;
  line-height: 1.2 !important;
  letter-spacing: 0 !important;
  font-variant-numeric: tabular-nums !important;
  text-align: center !important;
  appearance: auto !important;
  -webkit-appearance: auto !important;
  -moz-appearance: auto !important;
}

.pep3d-app .pep3d-panel .pep3d-number-field.has-active-reset input.pep3d-number-input[type="number"] {
  flex: 1 1 0 !important;
  width: 0 !important;
}

.pep3d-app .pep3d-panel input.pep3d-number-input[type="number"]:hover,
.pep3d-app .pep3d-panel input.pep3d-number-input[type="number"]:focus,
.pep3d-app .pep3d-panel input.pep3d-number-input[type="number"]:focus-visible {
  border: 0 !important;
  border-radius: 8px !important;
  outline: 0 !important;
  background: #ffffff !important;
}

.pep3d-app .pep3d-panel .pep3d-number-unit {
  position: absolute !important;
  top: 50%;
  right: 8px;
  transform: translateY(-50%);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  pointer-events: none;
  color: rgba(23, 60, 66, 0.68) !important;
  font-size: 12px !important;
  font-weight: 700 !important;
  line-height: 1 !important;
  white-space: nowrap;
}

.pep3d-app .pep3d-panel .pep3d-number-unit.is-empty {
  display: none !important;
}

.pep3d-app .pep3d-panel .pep3d-number-field.has-no-unit input.pep3d-number-input[type="number"] {
  padding-right: 8px !important;
}

.pep3d-app .pep3d-panel input.pep3d-number-input[type="number"]::-webkit-inner-spin-button,
.pep3d-app .pep3d-panel input.pep3d-number-input[type="number"]::-webkit-outer-spin-button {
  opacity: 1 !important;
  -webkit-appearance: auto !important;
}

/* No editor de imagem, o input substitui o output mantendo a unidade dentro do campo. */
.pep3d-adjustments label.pep3d-manual-range-label {
  grid-template-columns: 120px minmax(0, 1fr) 84px !important;
}

.pep3d-adjustments label.pep3d-manual-range-label:has(.pep3d-number-field.has-active-reset) {
  grid-template-columns: 120px minmax(0, 1fr) 111px !important;
}

.pep3d-adjustments label.pep3d-manual-range-label > .pep3d-number-field.has-active-reset {
  width: 111px !important;
  min-width: 111px !important;
}

.pep3d-adjustments label.pep3d-manual-range-label > .pep3d-range-number-control {
  grid-column: 2;
  grid-row: 1;
}

.pep3d-adjustments label.pep3d-manual-range-label > .pep3d-number-field {
  grid-column: 3;
  grid-row: 1;
}

@media (max-width: 480px) {
  .pep3d-manual-range-label {
    grid-template-columns: minmax(0, 1fr) 105px !important;
  }

  .pep3d-app .pep3d-panel label.pep3d-manual-range-label > .pep3d-number-field {
    width: 105px !important;
    min-width: 105px !important;
    max-width: 105px !important;
  }

  .pep3d-manual-range-label:has(.pep3d-number-field.has-active-reset) {
    grid-template-columns: minmax(0, 1fr) 105px !important;
  }

  .pep3d-app .pep3d-panel label.pep3d-manual-range-label > .pep3d-number-field.has-active-reset {
    width: 105px !important;
    min-width: 105px !important;
    max-width: 105px !important;
  }

  .pep3d-app .pep3d-panel input.pep3d-number-input[type="number"] {
    padding-left: 6px !important;
    padding-right: 25px !important;
  }

  .pep3d-adjustments label.pep3d-manual-range-label {
    grid-template-columns: 96px minmax(0, 1fr) 78px !important;
  }
}

/* Checkboxes alinhados à esquerda, com o texto imediatamente à direita. */
.pep3d-panel .pep3d-checkbox-field {
  display: flex !important;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  width: 100%;
  margin: 8px 0 12px;
  text-align: left;
}

.pep3d-panel .pep3d-checkbox-field input[type="checkbox"] {
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  margin: 0;
}

.pep3d-panel .pep3d-checkbox-field span {
  flex: 0 1 auto;
  margin: 0;
}

.pep3d-section-header,
.pep3d-plate-section-header,
.pep3d-text-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.pep3d-section-header h3,
.pep3d-plate-section-header h3,
.pep3d-text-section-header h3 {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin: 0;
}

.pep3d-panel .pep3d-section-collapse {
  display: inline-flex !important;
  align-items: center;
  gap: 7px;
  min-height: 0 !important;
  padding: 0 !important;
  border: 0 !important;
  border-radius: 0 !important;
  background: transparent !important;
  color: #fc9454 !important;
  font: inherit;
  letter-spacing: inherit;
  text-transform: inherit;
}

.pep3d-panel .pep3d-section-collapse:hover,
.pep3d-panel .pep3d-section-collapse:focus-visible {
  color: #ffffff !important;
}

.pep3d-section-collapse span {
  width: 10px;
  font-size: 10px;
  line-height: 1;
}

[data-pep3d-section-body][hidden] { display: none !important; }

.pep3d-text-section.is-disabled > [data-pep3d-section-body] {
  opacity: 0.55;
}

.pep3d-plate-section.is-disabled > [data-pep3d-section-body] {
  opacity: 0.55;
}

.pep3d-text-section.is-disabled > [data-pep3d-section-body] :is(input, select, textarea, button) {
  cursor: not-allowed !important;
}

.pep3d-plate-section.is-disabled > [data-pep3d-section-body] :is(input, select, textarea, button) {
  cursor: not-allowed !important;
}

/* Mesmo ritmo vertical e separador inferior das seções do personalizador-letreiro. */
.pep3d-panel > section,
.pep3d-panel > section.pep3d-section-first {
  margin: 0 0 20px;
  padding: 0 0 20px;
  border-top: 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}

.pep3d-panel > section:last-child {
  margin-bottom: 0;
}

.pep3d-panel .pep3d-text-enabled-field,
.pep3d-panel .pep3d-section-enabled-field {
  width: auto;
  margin: 0;
  gap: 5px;
  font-size: 12px;
  white-space: nowrap;
}

.pep3d-panel .pep3d-text-enabled-field input[type="checkbox"],
.pep3d-panel .pep3d-section-enabled-field input[type="checkbox"] {
  width: 13px;
  height: 13px;
}

.pep3d-text-controls {
  display: contents;
}

.pep3d-text-styles {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 8px 0 12px;
}

.pep3d-app .pep3d-text-styles button {
  display: grid;
  width: 30px;
  min-height: 30px;
  padding: 3px;
  place-items: center;
  border: 1px solid #b9c9cc;
  border-radius: 6px;
  background: #fff;
  color: #173c42;
}

.pep3d-app .pep3d-text-styles button:hover,
.pep3d-app .pep3d-text-styles button.is-active {
  border-color: #fc9454;
  background: #fc9454;
  color: #173c42;
}

.pep3d-style-italic { font-style: italic; }
.pep3d-style-underline { text-decoration: underline; }
.pep3d-style-strike { text-decoration: line-through; }


.pep3d-text-align-button[data-pep3d-text-align-button="left"] { text-align: left; justify-items: start; padding-left: 8px; }
.pep3d-text-align-button[data-pep3d-text-align-button="center"] { text-align: center; justify-items: center; }
.pep3d-text-align-button[data-pep3d-text-align-button="right"] { text-align: right; justify-items: end; padding-right: 8px; }

/* Seletor visual de fontes, equivalente ao usado no personalizador de letreiro. */
.pep3d-font-field {
  margin: 12px 0;
}

.pep3d-font-field > span {
  display: block;
  margin-bottom: 6px;
}

.pep3d-font-picker {
  position: relative;
}

.pep3d-native-font {
  display: none !important;
}

.pep3d-app .pep3d-font-trigger {
  display: flex;
  width: 100%;
  min-height: 40px;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 7px 9px;
  text-align: left;
}

.pep3d-font-trigger .pep3d-font-preview {
  margin-left: auto;
  color: #64748b;
}

.pep3d-font-menu {
  position: absolute;
  z-index: 80;
  top: calc(100% + 5px);
  right: 0;
  left: 0;
  max-height: 310px;
  padding: 6px;
  overflow-y: auto;
  border: 1px solid #43545a;
  border-radius: 8px;
  background: #202127;
  box-shadow: 0 12px 28px rgba(0, 0, 0, .4);
}

.pep3d-font-menu[hidden] {
  display: none !important;
}

.pep3d-app .pep3d-font-menu button {
  display: flex;
  width: 100%;
  min-height: 36px;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 7px 9px;
  border: 0;
  background: transparent;
  color: #fff;
  text-align: left;
}

.pep3d-app .pep3d-font-menu button:hover,
.pep3d-app .pep3d-font-menu button:focus,
.pep3d-app .pep3d-font-menu button[aria-selected="true"] {
  background: #34353e;
  color: #fff;
}

.pep3d-font-menu .pep3d-font-preview {
  margin-left: auto;
  color: #b8bac1;
  font-size: 15px;
}

.pep3d-panel .pep3d-font-search[type="search"] {
  position: sticky;
  z-index: 3;
  top: -6px;
  width: 100%;
  margin: 0 0 6px;
  padding: 8px 10px;
  border: 1px solid #526168;
  border-radius: 7px;
  background: #fff;
  color: #173c42;
}

.pep3d-font-categories {
  position: sticky;
  z-index: 2;
  top: 35px;
  display: flex;
  gap: 6px;
  margin: 0 -6px 6px;
  padding: 7px 6px;
  overflow-x: auto;
  background: #202127;
  scrollbar-width: thin;
  scroll-snap-type: x proximity;
}

.pep3d-app .pep3d-font-categories button {
  flex: 0 0 auto !important;
  width: auto !important;
  min-height: 30px !important;
  padding: 5px 10px !important;
  border: 1px solid #526168 !important;
  border-radius: 999px !important;
  background: #2b2d33 !important;
  font-size: 11px;
  white-space: nowrap;
  scroll-snap-align: start;
}

.pep3d-app .pep3d-font-categories button:hover,
.pep3d-app .pep3d-font-categories button.is-active {
  border-color: #fc9454 !important;
  background: #fc9454 !important;
  color: #173c42 !important;
}

.pep3d-font-options { min-height: 36px; }
.pep3d-font-sentinel { height: 1px; }


.pep3d-app {
  position: relative;
}

.pep3d-generation-lock {
  position: absolute;
  z-index: 2147483000;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 10px;
  padding: 24px;
  background: rgba(7, 24, 28, .78);
  color: #fff;
  text-align: center;
  cursor: wait;
  pointer-events: auto;
}

.pep3d-generation-lock[hidden] {
  display: none !important;
}

.pep3d-generation-lock strong {
  font-size: 20px;
}

.pep3d-generation-lock small {
  opacity: .85;
}

.pep3d-cancel-export {
  margin-top: 8px;
  padding: 10px 18px;
  border: 1px solid rgba(255, 255, 255, .75);
  border-radius: 8px;
  background: rgba(255, 255, 255, .12);
  color: #fff;
  font-weight: 700;
  cursor: pointer;
}

.pep3d-cancel-export:hover,
.pep3d-cancel-export:focus-visible {
  background: rgba(255, 255, 255, .22);
}

.pep3d-cancel-export[hidden] {
  display: none !important;
}

.pep3d-generation-spinner {
  width: 44px;
  height: 44px;
  border: 4px solid rgba(255, 255, 255, .3);
  border-top-color: #fc9454;
  border-radius: 50%;
  animation: pep3d-generation-spin .8s linear infinite;
}

@keyframes pep3d-generation-spin {
  to { transform: rotate(360deg); }
}
