/* ============================================================
   MOBILE (≤768px) — capa 100% aislada del escritorio.
   Todo vive dentro del media query; en desktop este archivo
   no aplica ni una sola regla.
   ============================================================ */
@media (max-width: 768px) {

  /* ── Base: app-like, sin scroll de página ── */
  html, body {
    height: 100dvh !important;
    overflow: hidden !important;
    overscroll-behavior: none;
    -webkit-tap-highlight-color: transparent;
  }
  body { touch-action: manipulation; }

  .main-container {
    display: block !important;
    height: 100dvh !important;
    padding: 0 !important;
    gap: 0 !important;
  }

  /* ── Ocultar piezas de escritorio ── */
  .sidebar,
  .ruler-h, .ruler-v, .ruler-corner,
  .zoom-floating,
  .precio-burbuja,
  #tab-bar-vacio { display: none !important; }

  /* ── Editor: ocupa toda la pantalla, sin card flotante ── */
  .editor {
    border-radius: 0 !important;
    margin: 0 !important;
    height: 100dvh !important;
    max-height: 100dvh !important;
    width: 100vw !important;
    box-shadow: none !important;
    display: flex !important;
    flex-direction: column !important;
  }

  /* ── Topbar compacto ── */
  .topbar {
    height: 48px !important;
    min-height: 48px !important;
    padding: 0 10px 0 14px !important;
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
    border-bottom: 1px solid rgba(0,0,0,0.06);
    position: relative !important;
    z-index: 300 !important;
    background: #fff;
  }
  .topbar #tab-list {
    position: static !important;
    top: auto !important;
    left: auto !important;
    flex: 1 !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    white-space: nowrap;
  }
  .topbar #tab-list::-webkit-scrollbar { display: none; }
  .topbar .editor-tab { flex-shrink: 0 !important; }
  .topbar-isla { flex-shrink: 0 !important; }

  /* ── Workspace: lienzo protagonista ── */
  .workspace {
    flex: 1 !important;
    min-height: 0 !important;
    position: relative !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 46px 0 118px !important; /* espacio toolbar arriba + barras abajo */
    box-sizing: border-box !important;
    overflow: hidden !important;
  }

  /* ── Herramientas: tira horizontal deslizable arriba del lienzo ── */
  .herramientas-verticales {
    position: absolute !important;
    top: 6px !important;
    left: 8px !important;
    right: 8px !important;
    bottom: auto !important;
    transform: none !important;
    flex-direction: row !important;
    width: auto !important;
    max-width: none !important;
    height: 40px !important;
    padding: 0 8px !important;
    gap: 2px !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    align-items: center !important;
    justify-content: flex-start !important;
    border-radius: 12px !important;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    z-index: 250 !important;
  }
  .herramientas-verticales::-webkit-scrollbar { display: none; }
  .herramienta-btn {
    flex-shrink: 0 !important;
    width: 34px !important;
    height: 34px !important;
  }
  .herramienta-sep {
    width: 1px !important;
    height: 18px !important;
    margin: 0 4px !important;
    flex-shrink: 0 !important;
  }

  /* ── Producto: encaja en el alto disponible ── */
  .stamp-area-wrap {
    width: min(100vw - 16px, calc((100dvh - 220px) * 0.75)) !important;
    max-width: none !important;
    margin: 0 auto !important;
  }

  /* Botón girar: siempre alcanzable */
  .btn-girar-camiseta {
    top: auto !important;
    bottom: 6px !important;
    right: 6px !important;
    width: 42px !important;
    height: 42px !important;
  }

  /* ── Isla favorito/compartir/descargar: columna al borde derecho ── */
  .bottom-controls {
    position: absolute !important;
    right: 8px !important;
    top: 56px !important;
    bottom: auto !important;
    left: auto !important;
    width: auto !important;
    z-index: 240 !important;
  }
  .acciones-flotantes {
    flex-direction: column !important;
    padding: 6px 4px !important;
    gap: 2px !important;
  }
  .accion-sep { width: 18px !important; height: 1px !important; margin: 2px auto !important; }
  .accion-btn { width: 36px !important; height: 36px !important; }

  /* ── Redes flotantes: sobre la barra de acción ── */
  .floating-buttons {
    bottom: 132px !important;
    right: 10px !important;
    gap: 8px !important;
    z-index: 240 !important;
  }
  .floating-buttons .btn-circle { width: 42px !important; height: 42px !important; }

  /* ============================================================
     BOTTOM SHEET — el .submenu se convierte en hoja deslizante
     ============================================================ */
  .submenu {
    position: fixed !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    top: auto !important;
    width: 100% !important;
    min-width: 0 !important;
    height: auto !important;
    max-height: calc(72dvh) !important;
    margin: 0 !important;
    border-radius: 20px 20px 0 0 !important;
    padding: 10px 16px calc(76px + env(safe-area-inset-bottom)) !important;
    box-shadow: 0 -8px 32px rgba(0,0,0,0.18) !important;
    z-index: 4600 !important;
    transform: translateY(105%);
    transition: transform 0.32s cubic-bezier(0.32, 0.72, 0.24, 1);
    display: flex !important;
    flex-direction: column !important;
  }
  html.m-sheet-open .submenu { transform: translateY(0); }

  /* Asa de arrastre */
  .submenu::before {
    content: '';
    display: block;
    width: 40px;
    height: 4px;
    border-radius: 4px;
    background: rgba(0,0,0,0.16);
    margin: 2px auto 8px;
    flex-shrink: 0;
  }

  /* Título del panel visible en la hoja */
  .submenu-header { display: block !important; margin-bottom: 6px !important; }
  .submenu-header h2 { font-size: 12px !important; }

  .submenu-content { display: none !important; }
  .submenu-content.active {
    display: block !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch;
    min-height: 120px;
    max-height: calc(72dvh - 150px);
  }

  /* Continuar dentro de la hoja: fijo al fondo de la hoja */
  .btn-continuar-global {
    position: absolute !important;
    left: 16px !important;
    right: 16px !important;
    bottom: calc(78px + env(safe-area-inset-bottom)) !important;
    width: auto !important;
    padding: 13px !important;
    font-size: 14px !important;
    z-index: 2;
  }
  /* En móvil el Continuar flotante de la action bar es el principal;
     el de la hoja se oculta para no duplicar. */
  html.is-mobile .btn-continuar-global { display: none !important; }

  /* Grids dentro de la hoja: más columnas, táctiles */
  .formas-container, .disenos-grid {
    display: grid !important;
    grid-template-columns: repeat(4, 1fr) !important;
    gap: 10px !important;
  }
  .galeria-miniaturas {
    display: grid !important;
    grid-template-columns: repeat(4, 1fr) !important;
    gap: 8px !important;
  }
  .galeria-prod { grid-template-columns: repeat(5, 1fr) !important; }

  /* ============================================================
     SCRIM — fondo oscurecido detrás de la hoja
     ============================================================ */
  #m-scrim {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.42);
    z-index: 4500;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
  }
  html.m-sheet-open #m-scrim { opacity: 1; pointer-events: auto; }

  /* ============================================================
     ACTION BAR — total + continuar, flotante sobre la nav
     ============================================================ */
  #m-actionbar {
    position: fixed;
    left: 10px;
    right: 10px;
    bottom: calc(64px + env(safe-area-inset-bottom) + 8px);
    height: 52px;
    background: rgba(20,20,20,0.92);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-radius: 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 8px 0 16px;
    box-shadow: 0 6px 24px rgba(0,0,0,0.25);
    z-index: 4400;
  }
  #m-actionbar .m-total-wrap {
    display: flex;
    flex-direction: column;
    line-height: 1.15;
    flex: 1;
    min-width: 0;
  }
  #m-actionbar .m-total-label {
    font-size: 9.5px;
    font-weight: 600;
    letter-spacing: 0.8px;
    text-transform: uppercase;
    color: rgba(255,255,255,0.45);
    font-family: 'Poppins', sans-serif;
  }
  #m-actionbar .m-total-num {
    font-size: 17px;
    font-weight: 700;
    color: #fff;
    font-family: 'Poppins', sans-serif;
    white-space: nowrap;
  }
  #m-actionbar .m-continuar {
    background: #17c385;
    color: #fff;
    border: none;
    border-radius: 12px;
    height: 38px;
    padding: 0 22px;
    font-size: 13.5px;
    font-weight: 600;
    font-family: 'Poppins', sans-serif;
    cursor: pointer;
    flex-shrink: 0;
  }
  #m-actionbar .m-continuar:active { background: #13aa72; }

  /* ============================================================
     BOTTOM NAVIGATION — estilo app nativa
     ============================================================ */
  #m-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    height: calc(64px + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom);
    background: #ffffff;
    border-top: 1px solid rgba(0,0,0,0.07);
    display: flex;
    align-items: stretch;
    z-index: 4700;
    box-shadow: 0 -2px 16px rgba(0,0,0,0.06);
  }
  .m-nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    background: none;
    border: none;
    cursor: pointer;
    font-family: 'Poppins', sans-serif;
    font-size: 9.5px;
    font-weight: 500;
    color: #9aa0ab;
    padding: 0;
    position: relative;
    transition: color 0.15s;
  }
  .m-nav-item img {
    width: 21px;
    height: 21px;
    object-fit: contain;
    opacity: 0.55;
    transition: opacity 0.15s, transform 0.15s;
  }
  .m-nav-item.activo { color: #17c385; }
  .m-nav-item.activo img { opacity: 1; transform: translateY(-1px); }
  .m-nav-item.activo::before {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 28px;
    height: 3px;
    border-radius: 0 0 4px 4px;
    background: #17c385;
  }

  /* ============================================================
     MODAL PRODUCTO — hoja a pantalla casi completa
     ============================================================ */
  #modalProducto .modal-contenido {
    width: 94vw !important;
    max-width: none !important;
    max-height: 80dvh !important;
    overflow-y: auto !important;
    padding: 44px 14px 20px !important;
    box-sizing: border-box !important;
  }
  .fila-productos {
    display: grid !important;
    grid-template-columns: repeat(3, 1fr) !important;
    gap: 10px !important;
  }

  /* ── Modal compartir ── */
  #modal-compartir .modal-compartir-contenido {
    width: 92vw !important;
    max-width: none !important;
    box-sizing: border-box !important;
  }

  /* ============================================================
     CHECKOUT — flujo en columna tipo app
     ============================================================ */
  .co-topbar { padding: 12px 16px !important; }
  .co-brand { font-size: 15px !important; }

  .co-body {
    flex-direction: column !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch;
  }
  .co-izq {
    flex: 0 0 auto !important;
    width: 100% !important;
    padding: 0 16px 8px !important;
    box-sizing: border-box !important;
  }
  #co-single-preview { padding: 0 !important; }
  .co-img-wrap {
    flex: 0 0 auto !important;
    height: 34dvh !important;
    max-height: 34dvh !important;
  }
  .co-preview-img { max-height: 100% !important; }

  .co-der {
    flex: 1 1 auto !important;
    width: 100% !important;
    box-sizing: border-box !important;
    padding: 4px 20px calc(28px + env(safe-area-inset-bottom)) !important;
    justify-content: flex-start !important;
    gap: 14px !important;
    overflow: visible !important;
  }
  .co-titulo { font-size: 21px !important; }
  .co-subtitulo { font-size: 12.5px !important; }

  /* 16px evita el auto-zoom de iOS al enfocar inputs */
  .co-input { font-size: 16px !important; }

  .co-multi-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    max-height: 34dvh !important;
    overflow-y: auto !important;
  }

  /* Confirmación (paso 4) */
  .co-confirm-screen { overflow-y: auto !important; }
  .co-confirm-card {
    width: 92vw !important;
    max-width: none !important;
    max-height: calc(100dvh - 32px) !important;
    overflow-y: auto !important;
    box-sizing: border-box !important;
    padding: 24px 20px !important;
  }
  .co-cf-header { flex-direction: column !important; gap: 12px !important; }

  /* ── Toast arriba para no chocar con las barras ── */
  #toast-descarga {
    bottom: auto !important;
    top: 58px !important;
  }

} /* /@media */
