/* ─────────────────────────────────────────────
   editor.css
   Editor responsive:
   - Desktop
   - Laptop
   - Tablet horizontal / vertical
   - Mobile
─────────────────────────────────────────────── */


/* ═════════════════════════════════════════════
   BASE
═════════════════════════════════════════════ */

*,
*::before,
*::after {
  box-sizing: border-box;
}

#view-editor {
  width: 100%;
  height: 100vh;
  height: 100dvh;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}


/* ═════════════════════════════════════════════
   TOPBAR
═════════════════════════════════════════════ */

.editor-topbar {
  min-height: var(--topbar-h);
  height: var(--topbar-h);
  flex-shrink: 0;

  display: flex;
  align-items: center;
  gap: 10px;

  padding: 0 16px;

  background: var(--ink-950);
  color: var(--paper);

  border-bottom: 1px solid var(--ink-800);

  overflow: hidden;
}

.editor-back {
  background: transparent;
  border: none;
  color: var(--paper);

  width: 34px;
  height: 34px;
  min-width: 34px;

  border-radius: var(--r-pill);

  display: flex;
  align-items: center;
  justify-content: center;

  cursor: pointer;
  font-size: 18px;

  flex-shrink: 0;
}

.editor-back:hover {
  background: rgba(255,255,255,.08);
}

.editor-title-wrap {
  display: flex;
  flex-direction: column;

  min-width: 0;
  margin-right: 8px;
}

.editor-title-wrap .folio {
  color: rgba(255,255,255,.5);

  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.editor-title-wrap .editor-title {
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 600;

  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}


.editor-topbar-group {
  display: flex;
  align-items: center;
  gap: 6px;

  padding: 0 10px;

  border-left: 1px solid rgba(255,255,255,.12);

  height: 34px;

  flex-shrink: 0;
}

.editor-topbar select {
  max-width: 170px;
  background: rgba(255,255,255,.07);
  border: 1px solid rgba(255,255,255,.14);
  color: var(--paper);
  border-radius: var(--r-sm);
  padding: 6px 9px;
  font-size: 12.5px;
  font-family: var(--font-body);
  outline: none;
  cursor: pointer;
}

.editor-topbar select option { 
  background: #ffffff;
  color: #151515; 
  font-family: var(--font-body);
}

.editor-topbar .btn-icon {
  border-color: rgba(255,255,255,.16);
  color: var(--paper);
}

.editor-topbar .btn-icon:hover:not(:disabled) {
  background: rgba(255,255,255,.08);
}

.editor-topbar .btn-icon.active {
  background: var(--accent);
  border-color: var(--accent);
}

.zoom-pct {
  font-family: var(--font-mono);
  font-size: 12px;

  width: 40px;

  text-align: center;

  color: rgba(255,255,255,.55);
}

.editor-topbar-spacer {
  flex: 1 1 auto;
  min-width: 0;
}


/* ═════════════════════════════════════════════
   BODY
═════════════════════════════════════════════ */

.editor-body {
  flex: 1 1 auto;

  display: flex;

  min-width: 0;
  min-height: 0;

  position: relative;

  overflow: hidden;
}


/* ═════════════════════════════════════════════
   PANELS
═════════════════════════════════════════════ */

.editor-panel {
  width: 300px;
  min-width: 300px;

  flex: 0 0 300px;

  background: var(--surface);

  border-right: 1px solid var(--line);

  display: flex;
  flex-direction: column;

  min-height: 0;

  overflow: hidden;

  z-index: 20;
}

.editor-panel.right {
  border-right: none;
  border-left: 1px solid var(--line);
}

.editor-panel-scroll {
  flex: 1;

  min-height: 0;

  overflow-y: auto;
  overflow-x: hidden;

  padding: 16px;

  display: flex;
  flex-direction: column;
  gap: 18px;

  overscroll-behavior: contain;

  scrollbar-width: thin;
}

.panel-tabs-wrap {
  padding: 12px 16px 0;
}


/* ═════════════════════════════════════════════
   FIELDS
═════════════════════════════════════════════ */

.field-group-title {
  font-family: var(--font-mono);
  font-size: 10.5px;

  text-transform: uppercase;
  letter-spacing: .06em;

  color: var(--ink-400);

  padding-bottom: 6px;

  border-bottom: 1px solid var(--line);

  margin-bottom: 2px;
}

.field-list {
  display: flex;
  flex-direction: column;
  gap: 12px;

  min-width: 0;
}


/* ═════════════════════════════════════════════
   ADD ELEMENT
═════════════════════════════════════════════ */

.add-el-grid {
  display: grid;

  grid-template-columns: repeat(2, minmax(0, 1fr));

  gap: 8px;

  margin-bottom: 4px;
}

.add-el-btn {
  min-width: 0;

  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;

  padding: 12px 6px;

  border: 1px dashed var(--line-strong);
  border-radius: var(--r-md);

  background: var(--paper);

  cursor: pointer;

  font-size: 11px;
  color: var(--ink-700);
  font-family: var(--font-body);

  touch-action: manipulation;
}

.add-el-btn:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-hover);
}

.add-el-btn i {
  font-size: 19px;
}


/* ═════════════════════════════════════════════
   LAYERS
═════════════════════════════════════════════ */

.layer-list {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.layer-row {
  display: flex;
  align-items: center;
  gap: 9px;

  min-width: 0;

  padding: 8px 9px;

  border-radius: var(--r-xs);

  font-size: 12.5px;
  color: var(--ink-700);

  cursor: pointer;

  touch-action: manipulation;
}

.layer-row:hover {
  background: var(--paper);
}

.layer-row.active {
  background: var(--accent-soft);
  color: var(--accent-hover);
}

.layer-row i {
  font-size: 15px;

  flex-shrink: 0;

  color: var(--ink-400);
}

.layer-row.active i {
  color: var(--accent);
}

.layer-row span {
  flex: 1;

  min-width: 0;

  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.layer-del {
  background: none;
  border: none;

  color: var(--ink-400);

  cursor: pointer;

  padding: 3px;

  border-radius: 5px;

  opacity: 0;

  transition: opacity .1s;
}

.layer-row:hover .layer-del {
  opacity: 1;
}

.layer-del:hover {
  color: var(--seal);
  background: var(--seal-soft);
}

.layer-row-sub {
  padding-left: 26px;

  font-size: 11.5px;
  color: var(--ink-600);
}

.layer-row-sub i {
  font-size: 13px;
}


/* ═════════════════════════════════════════════
   FONT SELECT
═════════════════════════════════════════════ */

.font-select-list {
  display: flex;
  flex-direction: column;
  gap: 4px;

  max-height: 168px;

  overflow-y: auto;

  border: 1px solid var(--line);
  border-radius: var(--r-xs);

  padding: 4px;

  scrollbar-width: thin;
}

.font-select-list button {
  text-align: left;

  padding: 7px 9px;

  border-radius: 6px;
  border: none;

  background: transparent;

  cursor: pointer;

  font-size: 13.5px;
  color: var(--ink-800);
}

.font-select-list button:hover {
  background: var(--paper);
}

.font-select-list button.active {
  background: var(--accent-soft);
  color: var(--accent-hover);

  font-weight: 600;
}


/* ═════════════════════════════════════════════
   LISTS
═════════════════════════════════════════════ */

.list-field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.list-item-row {
  display: flex;
  align-items: center;
  gap: 8px;

  min-width: 0;
}

.list-item-row input {
  flex: 1;
  min-width: 0;
}

.list-item-num {
  width: 22px;
  height: 22px;
  min-width: 22px;

  border-radius: 50%;

  background: var(--paper);
  color: var(--ink-700);

  font-size: 11px;
  font-weight: 600;

  display: flex;
  align-items: center;
  justify-content: center;

  font-family: var(--font-mono);
}

.list-item-del {
  background: none;
  border: none;

  color: var(--ink-400);

  cursor: pointer;

  font-size: 17px;
  padding: 4px;

  border-radius: 5px;

  flex-shrink: 0;
}

.list-item-del:hover {
  color: var(--seal);
  background: var(--seal-soft);
}

.btn-add-item {
  border: 1px dashed var(--line-strong);

  background: transparent;

  border-radius: var(--r-xs);

  padding: 8px;

  font-size: 12px;
  color: var(--ink-600);

  cursor: pointer;

  font-family: var(--font-body);
}

.btn-add-item:hover {
  border-color: var(--ink-400);
  background: var(--paper);
}


/* ═════════════════════════════════════════════
   IMAGE FIELD
═════════════════════════════════════════════ */

.image-field-box {
  position: relative;

  width: 100%;

  border: 1.5px dashed var(--line-strong);
  border-radius: var(--r-md);

  overflow: hidden;

  background: var(--paper);

  aspect-ratio: 4 / 3;

  display: flex;
  align-items: center;
  justify-content: center;

  cursor: pointer;

  transition: border-color .12s;
}

.image-field-box:hover {
  border-color: var(--accent);
}

.image-field-box.has-image {
  border-style: solid;
  border-color: var(--line);
}

.image-field-box img {
  width: 100%;
  height: 100%;

  object-fit: contain;

  background: #fff;
}

.image-field-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;

  color: var(--ink-400);

  font-size: 11.5px;
  text-align: center;

  padding: 10px;
}

.image-field-empty i {
  font-size: 22px;
}

.image-field-actions {
  position: absolute;

  top: 6px;
  right: 6px;

  display: flex;
  gap: 5px;
}

.image-field-actions button {
  width: 26px;
  height: 26px;

  border-radius: 50%;
  border: none;

  background: rgba(23,23,23,.75);
  color: #fff;

  font-size: 13px;

  cursor: pointer;

  display: flex;
  align-items: center;
  justify-content: center;
}

.image-field-actions button:hover {
  background: var(--ink-950);
}


/* ═════════════════════════════════════════════
   BATCH
═════════════════════════════════════════════ */

.batch-field-check {
  display: flex;
  align-items: center;
  gap: 9px;

  padding: 8px 10px;

  border: 1px solid var(--line);
  border-radius: var(--r-xs);

  font-size: 13px;

  cursor: pointer;
}

.batch-field-check input {
  accent-color: var(--accent);

  width: 15px;
  height: 15px;

  flex-shrink: 0;
}

.batch-order {
  font-family: var(--font-mono);
  font-size: 11px;

  color: var(--accent);

  margin-left: auto;
}

.batch-format-hint {
  font-family: var(--font-mono);
  font-size: 11px;

  color: var(--ink-600);

  background: var(--paper);

  border-radius: var(--r-xs);

  padding: 8px 10px;

  line-height: 1.6;

  overflow-wrap: anywhere;
}

.batch-progress {
  font-size: 12px;
  color: var(--ink-600);

  text-align: center;
}


/* ═════════════════════════════════════════════
   CANVAS
═════════════════════════════════════════════ */

.editor-canvas-col {
  flex: 1 1 auto;

  min-width: 0;
  min-height: 0;

  display: flex;
  flex-direction: column;

  background: #E2EAEC;

  position: relative;
}

.editor-canvas-scroll {
  flex: 1 1 auto;

  min-width: 0;
  min-height: 0;

  overflow: auto;

  display: flex;
  align-items: flex-start;
  justify-content: center;

  padding: clamp(24px, 4vw, 44px)
           clamp(14px, 3vw, 30px);

  overscroll-behavior: contain;

  scrollbar-width: thin;
}


/* ═════════════════════════════════════════════
   PAGE NAV
═════════════════════════════════════════════ */

.page-nav {
  min-height: 52px;

  display: flex;
  align-items: center;
  justify-content: center;

  gap: 12px;

  padding: 8px 10px;

  flex-shrink: 0;

  background: #E2EAEC;

  border-top: 1px solid var(--line);

  z-index: 5;
}

.page-nav .btn-icon {
  background: var(--surface);
}

.page-nav-label {
  font-family: var(--font-mono);
  font-size: 12px;

  color: var(--ink-700);

  white-space: nowrap;
}


/* ═════════════════════════════════════════════
   DOCUMENT FRAME
═════════════════════════════════════════════ */

.doc-page-frame {
  position: relative;

  flex-shrink: 0;

  /* evita que el documento toque los bordes */
  margin: 8px;
}

.crop-mark {
  position: absolute;

  width: 9px;
  height: 9px;

  border-color: var(--ink-600);

  pointer-events: none;
}

.crop-tl {
  top: -14px;
  left: -14px;

  border-top: 1.2px solid;
  border-left: 1.2px solid;
}

.crop-tr {
  top: -14px;
  right: -14px;

  border-top: 1.2px solid;
  border-right: 1.2px solid;
}

.crop-bl {
  bottom: -14px;
  left: -14px;

  border-bottom: 1.2px solid;
  border-left: 1.2px solid;
}

.crop-br {
  bottom: -14px;
  right: -14px;

  border-bottom: 1.2px solid;
  border-right: 1.2px solid;
}


.doc-page {
  position: relative;

  background: #fff;

  box-shadow:
    0 1px 3px rgba(23,23,23,.15),
    0 18px 44px rgba(23,23,23,.16);

  overflow: hidden;

  user-select: none;

  flex-shrink: 0;
}

.doc-page.design-unlocked {
  cursor: default;
}

.doc-margin-guide {
  position: absolute;

  border: 1px dashed rgba(255,81,0,.18);

  pointer-events: none;
}


/* ═════════════════════════════════════════════
   DOCUMENT ELEMENTS
═════════════════════════════════════════════ */

.doc-el {
  position: absolute;

  overflow: visible;

  max-width: none;
}

.doc-el-content {
  width: 100%;
  height: 100%;

  white-space: pre-wrap;
  word-break: break-word;
}

.doc-el-content.img-fit-contain img,
.doc-el-content img {
  width: 100%;
  height: 100%;

  object-fit: contain;

  display: block;
}

.design-unlocked .doc-el {
  cursor: grab;

  touch-action: none;
}

.design-unlocked .doc-el:hover {
  outline: 1px solid rgba(255,81,0,.35);
  outline-offset: 1px;
}

.doc-el.selected {
  outline: 1.5px solid var(--accent) !important;
  outline-offset: 1px;

  z-index: 50;
}

.doc-el.overflow {
  outline: 1.5px dashed var(--seal) !important;
}

.doc-el.dragging {
  cursor: grabbing;

  opacity: .92;

  z-index: 60;
}

.doc-el.image-empty .doc-el-content {
  border: 1.5px dashed var(--line-strong);

  background: rgba(148,152,160,.08);

  display: flex;
  align-items: center;
  justify-content: center;
}


/* ═════════════════════════════════════════════
   RESIZE HANDLES
═════════════════════════════════════════════ */

.resize-handle {
  position: absolute;

  width: 10px;
  height: 10px;

  background: var(--accent);

  border: 1.5px solid #fff;

  border-radius: 2px;

  z-index: 55;

  touch-action: none;
}

.resize-handle.e {
  right: -5px;
  top: 50%;

  transform: translateY(-50%);

  cursor: ew-resize;
}

.resize-handle.se {
  right: -5px;
  bottom: -5px;

  cursor: nwse-resize;
}

.resize-handle.s {
  bottom: -5px;
  left: 50%;

  transform: translateX(-50%);

  cursor: ns-resize;
}


/* ═════════════════════════════════════════════
   SNAP GUIDES
═════════════════════════════════════════════ */

.snap-guide {
  position: absolute;

  background: var(--seal);

  pointer-events: none;

  z-index: 70;
}

.snap-guide.v {
  width: 1px;

  top: 0;
  bottom: 0;
}

.snap-guide.h {
  height: 1px;

  left: 0;
  right: 0;
}


/* ═════════════════════════════════════════════
   RASTRO DE ARRASTRE
═════════════════════════════════════════════ */

.drag-trail-layer {
  position: absolute;
  inset: 0;

  pointer-events: none;

  z-index: 58;
}

.drag-trail-dot {
  position: absolute;

  width: 8px;
  height: 8px;
  margin: -4px 0 0 -4px;

  border-radius: 50%;
  background: var(--accent);

  opacity: .5;
  transform: scale(1);

  transition: opacity .48s ease-out, transform .48s ease-out;
}

.drag-trail-dot.fade {
  opacity: 0;
  transform: scale(.3);
}


/* ═════════════════════════════════════════════
   PROPERTIES
═════════════════════════════════════════════ */

.prop-empty {
  padding: 30px 18px;

  text-align: center;

  color: var(--ink-400);

  font-size: 12.5px;
}

.prop-empty i {
  font-size: 26px;

  display: block;

  margin-bottom: 8px;
}

.prop-section {
  display: flex;
  flex-direction: column;
  gap: 8px;

  min-width: 0;
}

.prop-label {
  font-size: 11px;
  font-weight: 500;

  color: var(--ink-600);

  text-transform: uppercase;
  letter-spacing: .03em;
}

.btn-group {
  display: flex;

  border: 1px solid var(--line);

  border-radius: var(--r-pill);

  overflow: hidden;
}

.btn-group button {
  flex: 1;

  min-width: 0;

  background: var(--surface);

  border: none;
  border-right: 1px solid var(--line);

  padding: 8px 0;

  cursor: pointer;

  color: var(--ink-600);

  font-size: 14px;

  display: flex;
  align-items: center;
  justify-content: center;

  touch-action: manipulation;
}

.btn-group button:last-child {
  border-right: none;
}

.btn-group button:hover {
  background: var(--paper);
}

.btn-group button.active {
  background: var(--ink-950);
  color: #fff;
}


.prop-row {
  display: flex;
  align-items: center;
  gap: 8px;

  min-width: 0;
}

.prop-row .field {
  flex: 1;
  min-width: 0;
}

.swatch-row {
  display: flex;
  gap: 6px;
  align-items: center;

  flex-wrap: wrap;
}

.swatch {
  width: 22px;
  height: 22px;

  border-radius: 50%;

  border: 1.5px solid var(--line);

  cursor: pointer;

  padding: 0;

  flex-shrink: 0;
}

.swatch.active {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.color-input {
  width: 30px;
  height: 30px;

  border: 1px solid var(--line);
  border-radius: var(--r-xs);

  padding: 2px;

  background: var(--surface);

  cursor: pointer;

  flex-shrink: 0;
}


.range-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.range-row input[type=range] {
  flex: 1;
  min-width: 0;

  accent-color: var(--accent);
}

.range-val {
  font-family: var(--font-mono);
  font-size: 11.5px;

  color: var(--ink-600);

  width: 34px;

  text-align: right;

  flex-shrink: 0;
}


.xywh-grid {
  display: grid;

  grid-template-columns: repeat(2, minmax(0, 1fr));

  gap: 8px;
}

.xywh-grid .field label {
  display: flex;
  justify-content: space-between;
}


/* ═════════════════════════════════════════════
   MOBILE PANEL TOGGLE
═════════════════════════════════════════════ */

.panel-toggle-mobile {
  display: none;
}


/* ═════════════════════════════════════════════
   TOUCH
═════════════════════════════════════════════ */

@media (pointer: coarse) {

  .resize-handle::after {
    content: '';

    position: absolute;

    inset: -9px;

    /* aumenta área táctil sin cambiar tamaño visual */
  }

  .design-unlocked .doc-el {
    touch-action: none;
  }

  button,
  select,
  input {
    touch-action: manipulation;
  }
}


/* ═════════════════════════════════════════════
   LARGE DESKTOP
   1440px+
═════════════════════════════════════════════ */

@media (min-width: 1440px) {

  .editor-panel {
    width: 320px;
    min-width: 320px;
    flex-basis: 320px;
  }

  .editor-panel-scroll {
    padding: 18px;
  }

  .editor-canvas-scroll {
    padding: 48px 40px;
  }
}


/* ═════════════════════════════════════════════
   DESKTOP / LAPTOP
   1181px - 1439px
═════════════════════════════════════════════ */

@media (max-width: 1439px) and (min-width: 1181px) {

  .editor-panel {
    width: 280px;
    min-width: 280px;
    flex-basis: 280px;
  }

  .editor-panel-scroll {
    padding: 15px;
  }

  .editor-canvas-scroll {
    padding: 36px 24px;
  }
}


/* ═════════════════════════════════════════════
   LAPTOP PEQUEÑA
   1025px - 1180px
═════════════════════════════════════════════ */

@media (max-width: 1180px) and (min-width: 1025px) {

  .editor-panel {
    width: 250px;
    min-width: 250px;
    flex-basis: 250px;
  }

  .editor-panel-scroll {
    padding: 13px;
    gap: 15px;
  }

  .editor-topbar {
    padding-left: 10px;
    padding-right: 10px;

    gap: 7px;
  }

  .editor-topbar-group {
    padding: 0 7px;
  }

  .editor-topbar select {
    max-width: 130px;
  }

  .editor-canvas-scroll {
    padding: 30px 18px;
  }
}


/* ═════════════════════════════════════════════
   TABLET
   861px - 1024px

   Los paneles pasan a drawers.
═════════════════════════════════════════════ */

@media (max-width: 1024px) {

  .editor-topbar {
    height: auto;
    min-height: var(--topbar-h);

    padding: 7px 10px;

    flex-wrap: wrap;

    row-gap: 7px;

    overflow: visible;
  }

  .editor-title-wrap {
    flex: 0 1 auto;

    max-width: 30vw;

    margin-right: 2px;
  }

  .editor-topbar-spacer {
    flex: 1 1 20px;
  }

  .editor-topbar-group {
    height: 32px;
    padding: 0 6px;
  }

  .editor-panel {
    position: absolute;

    top: 0;
    bottom: 0;

    width: min(320px, 82vw);
    min-width: min(320px, 82vw);

    flex-basis: auto;

    z-index: 80;

    box-shadow: var(--shadow-lg);

    transition: transform .22s ease-out;

    will-change: transform;
  }

  .editor-panel:not(.right) {
    left: 0;

    transform: translateX(-105%);
  }

  .editor-panel.right {
    right: 0;
    left: auto;

    transform: translateX(105%);
  }

  .editor-panel.open {
    transform: translateX(0);
  }

  .editor-canvas-col {
    width: 100%;
    min-width: 100%;
  }

  .panel-toggle-mobile {
    display: inline-flex !important;
  }

  .editor-canvas-scroll {
    padding: 28px 18px;
  }
}


/* ═════════════════════════════════════════════
   TABLET VERTICAL
   601px - 860px
═════════════════════════════════════════════ */

@media (max-width: 860px) and (min-width: 601px) {

  .editor-topbar {
    padding: 7px 9px;

    gap: 6px;
  }

  .editor-title-wrap {
    max-width: 28vw;
  }

  .editor-title-wrap .editor-title {
    font-size: 13px;
  }

  .editor-topbar-group {
    padding: 0 5px;
  }

  .editor-topbar select {
    max-width: 125px;

    padding-left: 7px;
    padding-right: 7px;
  }

  .editor-canvas-scroll {
    padding: 24px 14px;
  }

  .page-nav {
    min-height: 50px;
  }

  .editor-panel-scroll {
    padding: 15px;
  }
}


/* ═════════════════════════════════════════════
   MOBILE
   <= 600px
═════════════════════════════════════════════ */

@media (max-width: 600px) {

  #view-editor {
    min-height: 100dvh;
  }


  /* ───── topbar ───── */

  .editor-topbar {
    min-height: 52px;

    padding: 6px 8px;

    gap: 5px;

    flex-wrap: nowrap;

    overflow-x: auto;
    overflow-y: hidden;

    scrollbar-width: none;

    -webkit-overflow-scrolling: touch;
  }

  .editor-topbar::-webkit-scrollbar {
    display: none;
  }

  .editor-back {
    width: 32px;
    height: 32px;
    min-width: 32px;

    font-size: 17px;
  }

  .editor-title-wrap {
    width: auto;
    max-width: 42vw;

    min-width: 0;

    margin-right: 2px;
  }

  .editor-title-wrap .folio {
    font-size: 9px;
  }

  .editor-title-wrap .editor-title {
    max-width: 42vw;

    font-size: 12.5px;

    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .editor-topbar-group {
    height: 32px;

    padding: 0 4px;

    gap: 4px;
  }

  .editor-topbar select {
    max-width: 105px;

    padding: 5px 7px;

    font-size: 11px;
  }

  .editor-topbar .btn-icon {
    width: 30px;
    height: 30px;

    min-width: 30px;
  }

  .zoom-pct {
    width: 34px;

    font-size: 10.5px;
  }

  .editor-topbar-spacer {
    display: none;
  }


  /* ───── body ───── */

  .editor-body {
    overflow: hidden;
  }


  /* ───── drawers ───── */

  .editor-panel {
    width: min(88vw, 330px);
    min-width: min(88vw, 330px);

    max-width: 330px;

    box-shadow:
      0 10px 35px rgba(0,0,0,.22);

    z-index: 100;
  }

  .editor-panel-scroll {
    padding: 14px;

    gap: 16px;
  }

  .panel-tabs-wrap {
    padding: 10px 14px 0;
  }


  /* ───── canvas ───── */

  .editor-canvas-col {
    min-width: 0;
    width: 100%;
  }

  .editor-canvas-scroll {
    padding: 18px 10px 24px;

    justify-content: flex-start;

    /* permite desplazar horizontalmente documentos grandes */
    overflow: auto;

    -webkit-overflow-scrolling: touch;
  }

  .doc-page-frame {
    margin: 8px 14px;
  }


  /* ───── page navigation ───── */

  .page-nav {
    min-height: 48px;

    padding: 7px 8px;

    gap: 8px;

    padding-bottom: max(7px, env(safe-area-inset-bottom));
  }

  .page-nav-label {
    font-size: 11px;
  }

  .page-nav .btn-icon {
    width: 32px;
    height: 32px;
  }


  /* ───── touch handles ───── */

  .resize-handle {
    width: 11px;
    height: 11px;
  }

  .resize-handle::after {
    inset: -10px;
  }


  /* ───── fields ───── */

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

  .add-el-grid {
    gap: 7px;
  }

  .add-el-btn {
    min-height: 70px;
    padding: 10px 5px;
  }
}


/* ═════════════════════════════════════════════
   PHONE PEQUEÑO
   <= 400px
═════════════════════════════════════════════ */

@media (max-width: 400px) {

  .editor-topbar {
    padding-left: 6px;
    padding-right: 6px;
  }

  .editor-title-wrap {
    max-width: 35vw;
  }

  .editor-title-wrap .editor-title {
    max-width: 35vw;

    font-size: 12px;
  }

  .editor-topbar-group {
    padding: 0 3px;
  }

  .editor-topbar select {
    max-width: 90px;
  }

  .editor-panel {
    width: 92vw;
    min-width: 92vw;
  }

  .editor-panel-scroll {
    padding: 12px;
  }

  .editor-canvas-scroll {
    padding-left: 6px;
    padding-right: 6px;
  }

  .doc-page-frame {
    margin-left: 10px;
    margin-right: 10px;
  }

  .page-nav {
    gap: 5px;
  }

  .page-nav-label {
    font-size: 10px;
  }
}


/* ═════════════════════════════════════════════
   VERY SHORT SCREENS
   Ej: teléfonos horizontales
═════════════════════════════════════════════ */

@media (max-height: 500px) and (orientation: landscape) {

  .editor-topbar {
    min-height: 44px;
    padding-top: 4px;
    padding-bottom: 4px;
  }

  .editor-topbar .btn-icon {
    width: 28px;
    height: 28px;
  }

  .editor-back {
    width: 28px;
    height: 28px;
    min-width: 28px;
  }

  .editor-canvas-scroll {
    padding-top: 14px;
    padding-bottom: 14px;
  }

  .page-nav {
    min-height: 42px;
    padding: 4px 8px;
  }

  .editor-panel-scroll {
    padding-top: 10px;
    padding-bottom: 10px;

    gap: 12px;
  }
}


/* ═════════════════════════════════════════════
   REDUCED MOTION
═════════════════════════════════════════════ */

@media (prefers-reduced-motion: reduce) {

  .editor-panel {
    transition: none;
  }

  .image-field-box {
    transition: none;
  }

  .drag-trail-dot {
    display: none;
  }
}


/* ═════════════════════════════════════════════
   SAFE AREA — IPHONE / NOTCH
═════════════════════════════════════════════ */

@supports (padding: env(safe-area-inset-left)) {

  .editor-topbar {
    padding-left: max(8px, env(safe-area-inset-left));
    padding-right: max(8px, env(safe-area-inset-right));
  }

  .page-nav {
    padding-left: max(8px, env(safe-area-inset-left));
    padding-right: max(8px, env(safe-area-inset-right));

    padding-bottom: max(
      7px,
      env(safe-area-inset-bottom)
    );
  }
}